From 0868bf20265d0de4d1ab3fc1ea2f3ddec2a18662 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 16 May 2023 16:48:10 +0200 Subject: [PATCH 01/28] allow transparent cmaps --- WGLMakie/src/meshes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WGLMakie/src/meshes.jl b/WGLMakie/src/meshes.jl index 832272dbcb6..ec423621661 100644 --- a/WGLMakie/src/meshes.jl +++ b/WGLMakie/src/meshes.jl @@ -13,7 +13,7 @@ facebuffer(x::Observable) = Buffer(lift(facebuffer, x)) function array2color(colors, cmap, crange) - cmap = RGBAf.(Colors.color.(to_colormap(cmap)), 1.0) + cmap = to_colormap(cmap) return Makie.interpolated_getindex.((cmap,), colors, (crange,)) end From b6d9fa3fb0b67c27104cdbdbf4e1c6eccf8d9c32 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 2 Jun 2023 12:10:59 +0200 Subject: [PATCH 02/28] try new line rendering for WGLMakie --- WGLMakie/assets/lines.frag | 25 +++ WGLMakie/assets/lines.vert | 123 +++++++++++ WGLMakie/assets/lines2.vert | 346 +++++++++++++++++++++++++++++++ WGLMakie/src/Lines.js | 202 ++++++++++++++++++ WGLMakie/src/Serialization.js | 159 ++++++++++++++ WGLMakie/src/lines.jl | 89 ++------ WGLMakie/src/three_plot.jl | 1 + WGLMakie/src/wglmakie.bundled.js | 194 ++++++++++++++++- 8 files changed, 1066 insertions(+), 73 deletions(-) create mode 100644 WGLMakie/assets/lines.frag create mode 100644 WGLMakie/assets/lines.vert create mode 100644 WGLMakie/assets/lines2.vert create mode 100644 WGLMakie/src/Lines.js diff --git a/WGLMakie/assets/lines.frag b/WGLMakie/assets/lines.frag new file mode 100644 index 00000000000..a73cc8b5943 --- /dev/null +++ b/WGLMakie/assets/lines.frag @@ -0,0 +1,25 @@ + +uniform vec3 diffuse; +uniform float opacity; + +in vec2 vUv; + + +void main() { + + float alpha = opacity; + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = (vUv.y > 0.0) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth(len2); + + if (abs(vUv.y) > 1.0) { + alpha = 1.0 - smoothstep(1.0 - dlen, 1.0 + dlen, len2); + } + + vec4 diffuseColor = vec4(diffuse, alpha); + gl_FragColor = vec4(diffuseColor.rgb, alpha); + +} diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert new file mode 100644 index 00000000000..dcc9080fe29 --- /dev/null +++ b/WGLMakie/assets/lines.vert @@ -0,0 +1,123 @@ +# version 300 es + +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; + +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master + +in vec2 uv; +in vec3 position; +in vec2 instanceStart; +in vec2 instanceEnd; + +out vec2 vUv; + +uniform mat4 projection; +uniform mat4 model; +uniform mat4 view; + +uniform float linewidth; +uniform vec2 resolution; + +void trimSegment(const in vec4 start, inout vec4 end) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projection[2][2]; // 3nd entry in 3th column + float b = projection[3][2]; // 3nd entry in 4th column + float nearEstimate = -0.5 * b / a; + + float alpha = (nearEstimate - start.z) / (end.z - start.z); + + end.xyz = mix(start.xyz, end.xyz, alpha); + +} + +void main() { + + float aspect = resolution.x / resolution.y; + mat4 model_view = model * view; + // camera space + vec4 start = model_view * vec4(instanceStart, 0.0, 1.0); + vec4 end = model_view * vec4(instanceEnd, 0.0, 1.0); + vUv = uv; + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = false; //(projection[2][3] == -1.0); // 4th entry in the 3rd column + + if (perspective) { + + if (start.z < 0.0 && end.z >= 0.0) { + + trimSegment(start, end); + + } else if (end.z < 0.0 && start.z >= 0.0) { + + trimSegment(end, start); + + } + + } + + // clip space + vec4 clipStart = projection * start; + vec4 clipEnd = projection * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize(dir); + + vec2 offset = vec2(dir.y, -dir.x); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if (position.x < 0.0) + offset *= -1.0; + + // endcaps + if (position.y < 0.0) { + + offset += -dir; + + } else if (position.y > 1.0) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = (position.y < 0.5) ? clipStart : clipEnd; + + // back to clip space + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + gl_Position = clip; +} diff --git a/WGLMakie/assets/lines2.vert b/WGLMakie/assets/lines2.vert new file mode 100644 index 00000000000..aba702962e7 --- /dev/null +++ b/WGLMakie/assets/lines2.vert @@ -0,0 +1,346 @@ +{{GLSL_VERSION}} +{{GLSL_EXTENSIONS}} +{{SUPPORTED_EXTENSIONS}} + +struct Nothing{ //Nothing type, to encode if some variable doesn't contain any data + bool _; //empty structs are not allowed +}; + +{{define_fast_path}} + +layout(lines_adjacency) in; +layout(triangle_strip, max_vertices = 11) out; + +in vec4 g_color[]; +in float g_lastlen[]; +in uvec2 g_id[]; +in int g_valid_vertex[]; +in float g_thickness[]; + +out vec4 f_color; +out vec2 f_uv; +out float f_thickness; +flat out uvec2 f_id; +flat out vec2 f_uv_minmax; + +out vec3 o_view_pos; +out vec3 o_normal; + +uniform vec2 resolution; +uniform float pattern_length; +uniform sampler1D pattern_sections; + +float px2uv = 0.5 / pattern_length; + +// Constants +#define MITER_LIMIT -0.4 +#define AA_THICKNESS 4 + +vec3 screen_space(vec4 vertex) +{ + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; +} + +vec3 clip_space(vec4 screenspace) { + return vec4((screenspace.xy / resolution), screenspace.z, 1.0); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Emit Vertex Methods +//////////////////////////////////////////////////////////////////////////////// + + +// Manual uv calculation +// - position in screen space (double resolution as generally used) +// - uv with uv.u normalized (0..1), uv.v unnormalized (0..pattern_length) +void emit_vertex(vec3 position, vec2 uv, int index) +{ + f_uv = uv; + f_color = g_color[index]; + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + f_id = g_id[index]; + f_thickness = g_thickness[index]; + EmitVertex(); +} + +// For center point +void emit_vertex(vec3 position, vec2 uv) +{ + f_uv = uv; + f_color = 0.5 * (g_color[1] + g_color[2]); + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + f_id = g_id[1]; + f_thickness = 0.5 * (g_thickness[1] + g_thickness[2]); + EmitVertex(); +} + +// Debug +void emit_vertex(vec3 position, vec2 uv, int index, vec4 color) +{ + f_uv = uv; + f_color = color; + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + f_id = g_id[index]; + f_thickness = g_thickness[index]; + EmitVertex(); +} +void emit_vertex(vec3 position, vec2 uv, vec4 color) +{ + f_uv = uv; + f_color = color; + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + f_id = g_id[1]; + f_thickness = 0.5 * (g_thickness[1] + g_thickness[2]); + EmitVertex(); +} + + +// With offset calculations for core line segment +void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv, int index) +{ + emit_vertex( + position + vec3(offset, 0), + vec2(uv.x + px2uv * dot(line_dir, offset), uv.y), + index + ); +} + +void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv) +{ + emit_vertex( + position + vec3(offset, 0), + vec2(uv.x + px2uv * dot(line_dir, offset), uv.y) + ); +} + + +//////////////////////////////////////////////////////////////////////////////// +/// Draw full line segment +//////////////////////////////////////////////////////////////////////////////// + + +// Generate line segment with 3 triangles +// - p1, p2 are the line start and end points in pixel space +// - miter_a and miter_b are the offsets from p1 and p2 respectively that +// generate the line segment quad. This should include thickness and AA +// - u1, u2 are the u values at p1 and p2. These should be in uv scale (px2uv applied) +// - thickness_aa1, thickness_aa2 are linewidth at p1 and p2 with AA added. They +// double as uv.y values, which are in pixel space +// - v1 is the line direction of this segment (xy component) +void generate_line_segment( + vec3 p1, vec2 miter_a, float u1, float thickness_aa1, + vec3 p2, vec2 miter_b, float u2, float thickness_aa2, + vec2 v1, float segment_length + ) +{ + float line_offset_a = dot(miter_a, v1); + float line_offset_b = dot(miter_b, v1); + + if (abs(line_offset_a) + abs(line_offset_b) < segment_length+1){ + // _________ + // \ / + // \_____/ + // <---> + // Line segment is extensive (minimum width positive) + + emit_vertex(p1, +miter_a, v1, vec2(u1, -thickness_aa1), 1); + emit_vertex(p1, -miter_a, v1, vec2(u1, thickness_aa1), 1); + emit_vertex(p2, +miter_b, v1, vec2(u2, -thickness_aa2), 2); + emit_vertex(p2, -miter_b, v1, vec2(u2, thickness_aa2), 2); + } else { + // ____ + // \ / + // \/ + // /\ + // >--< + // Line segment has zero or negative width on short side + + // Pulled apart, we draw these two triangles (vertical lines added) + // ___ ___ + // \ | | / + // X | | X + // \| |/ + // + // where X is u1/p1 (left) and u2/p2 (right) respectively. To avoid + // drawing outside the line segment due to AA padding, we cut off the + // left triangle on the right side at u2 via f_uv_minmax.y, and + // analogously the right triangle at u1 via f_uv_minmax.x. + // These triangles will still draw over each other like this. + + // incoming side + float old = f_uv_minmax.y; + f_uv_minmax.y = u2; + + emit_vertex(p1, -miter_a, v1, vec2(u1, -thickness_aa1), 1); + emit_vertex(p1, +miter_a, v1, vec2(u1, +thickness_aa1), 1); + if (line_offset_a > 0){ // finish triangle on -miter_a side + emit_vertex(p1, 2 * line_offset_a * v1 - miter_a, v1, vec2(u1, -thickness_aa1)); + } else { + emit_vertex(p1, -2 * line_offset_a * v1 + miter_a, v1, vec2(u1, +thickness_aa1)); + } + + EndPrimitive(); + + // outgoing side + f_uv_minmax.x = u1; + f_uv_minmax.y = old; + + emit_vertex(p2, -miter_b, v1, vec2(u2, -thickness_aa2), 2); + emit_vertex(p2, +miter_b, v1, vec2(u2, +thickness_aa2), 2); + if (line_offset_b < 0){ // finish triangle on -miter_b side + emit_vertex(p2, 2 * line_offset_b * v1 - miter_b, v1, vec2(u2, -thickness_aa2)); + } else { + emit_vertex(p2, -2 * line_offset_b * v1 + miter_b, v1, vec2(u2, +thickness_aa2)); + } + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +/// Solid lines +//////////////////////////////////////////////////////////////////////////////// + + + +void draw_solid_line(bool isvalid[4]) +{ + // This sets a min and max value foir uv.u at which anti-aliasing is forced. + // With this setting it's never triggered. + f_uv_minmax = vec2(-1.0e12, 1.0e12); + + // get the four vertices passed to the shader + // without FAST_PATH the conversions happen on the CPU + vec3 p0 = screen_space(gl_in[0].gl_Position); // start of previous segment + vec3 p1 = screen_space(gl_in[1].gl_Position); // end of previous segment, start of current segment + vec3 p2 = screen_space(gl_in[2].gl_Position); // end of current segment, start of next segment + vec3 p3 = screen_space(gl_in[3].gl_Position); // end of next segment + + // linewidth with padding for anti aliasing + float thickness_aa1 = g_thickness[1] + AA_THICKNESS; + float thickness_aa2 = g_thickness[2] + AA_THICKNESS; + + // determine the direction of each of the 3 segments (previous, current, next) + vec3 v1 = p2 - p1; + float segment_length = length(v1.xy); + v1 /= segment_length; + vec3 v0 = v1; + vec3 v2 = v1; + + if (p1 != p0 && isvalid[0]) { + v0 = (p1 - p0) / length((p1 - p0).xy); + } + if (p3 != p2 && isvalid[3]) { + v2 = (p3 - p2) / length((p3 - p2).xy); + } + + // determine the normal of each of the 3 segments (previous, current, next) + vec2 n0 = vec2(-v0.y, v0.x); + vec2 n1 = vec2(-v1.y, v1.x); + vec2 n2 = vec2(-v2.y, v2.x); + + // Setup for sharp corners (see above) + vec2 miter_a = normalize(n0 + n1); + vec2 miter_b = normalize(n1 + n2); + float length_a = thickness_aa1 / dot(miter_a, n1); + float length_b = thickness_aa2 / dot(miter_b, n1); + + // truncated miter join (see above) + if( dot( v0.xy, v1.xy ) < MITER_LIMIT ){ + bool gap = dot( v0.xy, n1 ) > 0; + // In this case uv's are used as signed distance field values, so we + // want 0 where we had start before. + float u0 = thickness_aa1 * abs(dot(miter_a, n1)) * px2uv; + float proj_AA = AA_THICKNESS * abs(dot(miter_a, n1)) * px2uv; + + // to save some space + vec2 off0 = thickness_aa1 * n0; + vec2 off1 = thickness_aa1 * n1; + vec2 off_AA = AA_THICKNESS * miter_a; + float u_AA = AA_THICKNESS * px2uv; + + if(gap){ + emit_vertex(p1, vec2(+ u0, 0), 1); + emit_vertex(p1 + vec3(off0, 0), vec2(- proj_AA, +thickness_aa1), 1); + emit_vertex(p1 + vec3(off1, 0), vec2(- proj_AA, -thickness_aa1), 1); + emit_vertex(p1 + vec3(off0 + off_AA, 0), vec2(- proj_AA - u_AA, +thickness_aa1), 1); + emit_vertex(p1 + vec3(off1 + off_AA, 0), vec2(- proj_AA - u_AA, -thickness_aa1), 1); + EndPrimitive(); + }else{ + emit_vertex(p1, vec2(+ u0, 0), 1); + emit_vertex(p1 - vec3(off1, 0), vec2(- proj_AA, +thickness_aa1), 1); + emit_vertex(p1 - vec3(off0, 0), vec2(- proj_AA, -thickness_aa1), 1); + emit_vertex(p1 - vec3(off1 + off_AA, 0), vec2(- proj_AA - u_AA, +thickness_aa1), 1); + emit_vertex(p1 - vec3(off0 + off_AA, 0), vec2(- proj_AA - u_AA, -thickness_aa1), 1); + EndPrimitive(); + } + + miter_a = n1; + length_a = thickness_aa1; + } + + // we have miter join on next segment, do normal line cut off + if( dot( v1.xy, v2.xy ) <= MITER_LIMIT ){ + miter_b = n1; + length_b = thickness_aa2; + } + + // Without a pattern (linestyle) we use uv.u directly as a signed distance + // field. We only care about u1 - u0 being the correct distance and + // u0 > AA_THICHKNESS at all times. + float u1 = 10000.0; + float u2 = u1 + segment_length; + + miter_a *= length_a; + miter_b *= length_b; + + // To treat line starts and ends we elongate the line in the respective + // direction and enforce an AA border at the original start/end position + // with f_uv_minmax. + if (!isvalid[0]) + { + float corner_offset = max(0, abs(dot(miter_b, v1.xy)) - segment_length); + f_uv_minmax.x = px2uv * (u1 - corner_offset); + p1 -= (corner_offset + AA_THICKNESS) * v1; + u1 -= (corner_offset + AA_THICKNESS); + segment_length += corner_offset; + } + + if (!isvalid[3]) + { + float corner_offset = max(0, abs(dot(miter_a, v1.xy)) - segment_length); + f_uv_minmax.y = px2uv * (u2 + corner_offset); + p2 += (corner_offset + AA_THICKNESS) * v1; + u2 += (corner_offset + AA_THICKNESS); + segment_length += corner_offset; + } + + + // Generate line segment + u1 *= px2uv; + u2 *= px2uv; + + // Normal Version + generate_line_segment( + p1, miter_a, u1, thickness_aa1, + p2, miter_b, u2, thickness_aa2, + v1.xy, segment_length + ); + + return; +} + + + +//////////////////////////////////////////////////////////////////////////////// +/// Main +//////////////////////////////////////////////////////////////////////////////// + + + +void main(void) +{ + draw_solid_line(isvalid); + + return; +} diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js new file mode 100644 index 00000000000..f386365547c --- /dev/null +++ b/WGLMakie/src/Lines.js @@ -0,0 +1,202 @@ +import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; +import { deserialize_uniforms } from "./Serialization.js"; + + +const LINES_VERT = ` +# version 300 es +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master +uniform float linewidth; +uniform vec2 resolution; + +in vec2 uv; +in vec3 position; +in vec2 instanceStart; +in vec2 instanceEnd; + +out vec2 vUv; +uniform mat4 projection; +uniform mat4 model; +uniform mat4 view; + +void trimSegment(const in vec4 start, inout vec4 end) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projection[2][2]; // 3nd entry in 3th column + float b = projection[3][2]; // 3nd entry in 4th column + float nearEstimate = -0.5 * b / a; + + float alpha = (nearEstimate - start.z) / (end.z - start.z); + + end.xyz = mix(start.xyz, end.xyz, alpha); + +} + +void main() { + + float aspect = resolution.x / resolution.y; + const model_view = view * model; + // camera space + vec4 start = model_view * vec4(instanceStart, 0.0, 1.0); + vec4 end = model_view * vec4(instanceEnd, 0.0, 1.0); + vUv = uv; + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = (projection[2][3] == -1.0); // 4th entry in the 3rd column + + if (perspective) { + + if (start.z < 0.0 && end.z >= 0.0) { + + trimSegment(start, end); + + } else if (end.z < 0.0 && start.z >= 0.0) { + + trimSegment(end, start); + + } + + } + + // clip space + vec4 clipStart = projection * start; + vec4 clipEnd = projection * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize(dir); + + vec2 offset = vec2(dir.y, -dir.x); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if (position.x < 0.0) + offset *= -1.0; + + // endcaps + if (position.y < 0.0) { + + offset += -dir; + + } else if (position.y > 1.0) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = (position.y < 0.5) ? clipStart : clipEnd; + + // back to clip space + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + gl_Position = clip; + + vec4 mvPosition = (position.y < 0.5) ? start : end; // this is an approximation + +} + +`; + +const LINES_FRAG = ` +uniform vec3 diffuse; +uniform float opacity; + +in vec2 vUv; + + +void main() { + + float alpha = opacity; + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = (vUv.y > 0.0) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth(len2); + + if (abs(vUv.y) > 1.0) { + alpha = 1.0 - smoothstep(1.0 - dlen, 1.0 + dlen, len2); + } + + vec4 diffuseColor = vec4(diffuse, alpha); + gl_FragColor = vec4(diffuseColor.rgb, alpha); + +} +`; + +function create_line_material(uniforms) { + return new THREE.RawShaderMaterial({ + uniforms: deserialize_uniforms(uniforms), + vertexShader: LINES_VERT, + fragmentShader: LINES_FRAG, + transparent: true, + }); +} + +function create_line_geometry(linepositions) { + const geometry = new THREE.InstancedBufferGeometry(); + + const instance_positions = [ + -1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, + -1, 0, + ] + const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]; + const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]; + geometry.setIndex(index); + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 3) + ); + geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); + + const instanceBuffer = new THREE.InstancedInterleavedBuffer( + linepositions, + 4, + 1 + ); // xyz, xyz + + geometry.setAttribute( + "instanceStart", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) + ); // xyz + geometry.setAttribute( + "instanceEnd", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) + ); // xyz + + return geometry; +} + +export function create_line(line_data) { + console.log(line_data) + const geometry = create_line_geometry(line_data.position); + const material = create_line_material(line_data.uniforms); + return new THREE.Mesh(geometry, material); +} diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 041b96bf6be..d1f24fa58a2 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -1,6 +1,162 @@ import * as Camera from "./Camera.js"; import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; + +const LINES_VERT = `#version 300 es +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master + +in vec2 uv; +in vec3 position; +in vec2 instanceStart; +in vec2 instanceEnd; + +out vec2 vUv; + +uniform mat4 projectionview; +uniform mat4 projection; +uniform mat4 model; +uniform mat4 view; + +uniform float linewidth; +uniform vec2 resolution; + +vec4 screen_space(vec4 vertex) +{ + return vec4(vertex.xy * resolution, vertex.z, vertex.w) / vertex.w; +} + +vec4 clip_space(vec4 screenspace) { + return vec4((screenspace.xy / resolution), screenspace.z, 1.0) * screenspace.w; +} + +void main() { + + // camera space + vec4 start = projectionview * model * vec4(instanceStart, 0.0, 1.0); + vec4 end = projectionview * model * vec4(instanceEnd, 0.0, 1.0); + vUv = uv; + + // screenspace + vec4 ndcStart = screen_space(start); + vec4 ndcEnd = screen_space(end); + + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir = normalize(dir); + + vec2 offset = vec2(dir.y, -dir.x); // orthogonal vector + + // sign flip + if (position.x < 0.0) + offset *= -1.0; + + // endcaps + if (position.y < 0.0) { + offset += -dir; + } else if (position.y > 1.0) { + offset += dir; + } + + // adjust for linewidth + offset *= linewidth; + + + + // select end + vec4 screen = (position.y < 0.5) ? ndcStart : ndcEnd; + screen.xy += offset; + gl_Position = clip_space(screen); +} +`; + +const LINES_FRAG = `#version 300 es +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; + +out vec4 fragment_color; + +uniform vec3 diffuse; +uniform float opacity; + +in vec2 vUv; + + +void main() { + + fragment_color = vec4(0,0,0, 1.0); +} +`; + +function create_line_material(uniforms) { + return new THREE.RawShaderMaterial({ + uniforms: deserialize_uniforms(uniforms), + vertexShader: LINES_VERT, + fragmentShader: LINES_FRAG, + transparent: true, + }); +} + +function create_line_geometry(linepositions) { + const geometry = new THREE.InstancedBufferGeometry(); + + const instance_positions = [ + -1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, + -1, 0, + ]; + const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]; + const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]; + geometry.setIndex(index); + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 3) + ); + geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); + + const instanceBuffer = new THREE.InstancedInterleavedBuffer( + linepositions, + 4, + 1 + ); // xyz, xyz + + geometry.setAttribute( + "instanceStart", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) + ); // xyz + geometry.setAttribute( + "instanceEnd", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) + ); // xyz + + geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + geometry.instanceCount = linepositions.length / 2 + + return geometry; +} + +export function create_line(line_data) { + console.log(line_data); + const geometry = create_line_geometry(line_data.positions); + const material = create_line_material(line_data.uniforms); + console.log(geometry) + console.log(material); + return new THREE.Mesh(geometry, material); +} + // global scene cache to look them up for dynamic operations in Makie // e.g. insert!(scene, plot) / delete!(scene, plot) const scene_cache = {}; @@ -140,6 +296,9 @@ function deserialize_uniforms(data) { } export function deserialize_plot(data) { + if (data.plot_type === "lines") { + return create_line(data); + } let mesh; if ("instance_attributes" in data) { mesh = create_instanced_mesh(data); diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 12827230958..7dd46a13eee 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -1,73 +1,18 @@ -topoint(x::AbstractVector{Point{N,Float32}}) where {N} = x - -# GRRR STUPID SubArray, with eltype different from getindex(x, 1) -topoint(x::SubArray) = topoint([el for el in x]) - -function topoint(x::AbstractArray{<:Point{N,T}}) where {T,N} - return topoint(Point{N,Float32}.(x)) -end - -function topoint(x::AbstractArray{<:Tuple{P,P}}) where {P<:Point} - return topoint(reinterpret(P, x)) -end - -function create_shader(scene::Scene, plot::Union{Lines,LineSegments}) - # Potentially per instance attributes - positions = lift(plot[1], transform_func_obs(plot), get(plot, :space, :data)) do points, trans, space - points = apply_transform(trans, topoint(points), space) - if plot isa LineSegments - return points - else - # Repeat every second point to connect the lines ! - return topoint(TupleView{2, 1}(points)) - end - trans - end - startr = lift(p -> 1:2:(length(p) - 1), positions) - endr = lift(p -> 2:2:length(p), positions) - p_start_end = lift(positions) do positions - return (positions[startr[]], positions[endr[]]) - end - - per_instance = Dict{Symbol,Any}(:segment_start => Buffer(lift(first, p_start_end)), - :segment_end => Buffer(lift(last, p_start_end))) - uniforms = Dict{Symbol,Any}() - for k in (:linewidth, :color) - attribute = lift(plot[k]) do x - x = convert_attribute(x, Key{k}(), key"lines"()) - if plot isa LineSegments - return x - else - # Repeat every second point to connect the lines! - return isscalar(x) ? x : reinterpret(eltype(x), TupleView{2, 1}(x)) - end - end - if isscalar(attribute) - uniforms[k] = attribute - uniforms[Symbol("$(k)_start")] = attribute - uniforms[Symbol("$(k)_end")] = attribute - else - if attribute[] isa AbstractVector{<:Number} && haskey(plot, :colorrange) - attribute = lift(array2color, attribute, plot.colormap, plot.colorrange) - end - per_instance[Symbol("$(k)_start")] = Buffer(lift(x -> x[startr[]], attribute)) - per_instance[Symbol("$(k)_end")] = Buffer(lift(x -> x[endr[]], attribute)) - end - end - - uniforms[:resolution] = to_value(scene.camera.resolution) # updates in JS - - uniforms[:model] = plot.model - uniforms[:depth_shift] = get(plot, :depth_shift, Observable(0f0)) - positions = meta(Point2f[(0, -1), (0, 1), (1, -1), (1, 1)], - uv=Vec2f[(0, 0), (0, 0), (0, 0), (0, 0)]) - instance = GeometryBasics.Mesh(positions, GLTriangleFace[(1, 2, 3), (2, 4, 3)]) - - # id + picking gets filled in JS, needs to be here to emit the correct shader uniforms - uniforms[:picking] = false - uniforms[:object_id] = UInt32(0) - - return InstancedProgram(WebGL(), lasset("line_segments.vert"), - lasset("line_segments.frag"), instance, - VertexArray(; per_instance...), uniforms) +function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) + uniforms = Dict( + :opacity => 1.0, + :linewidth => 2.0, + :diffuse => Vec3f(0, 0, 0), + :model => plot.model + ) + return Dict( + :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), + :visible => plot.visible, + :uuid => js_uuid(plot), + :plot_type => :lines, + :space => plot.space, + + :positions => collect(reinterpret(Float32, plot[1][])), + :uniforms => serialize_uniforms(uniforms) + ) end diff --git a/WGLMakie/src/three_plot.jl b/WGLMakie/src/three_plot.jl index c7707e8acb7..116aba037b9 100644 --- a/WGLMakie/src/three_plot.jl +++ b/WGLMakie/src/three_plot.jl @@ -55,6 +55,7 @@ function three_display(session::Session, scene::Scene; screen_config...) $(WGL).then(WGL => { // well.... not nice, but can't deal with the `Promise` in all the other functions window.WGLMakie = WGL + console.log(WGL) WGL.create_scene($wrapper, $canvas, $canvas_width, $scene_serialized, $comm, $width, $height, $(config.framerate), $(ta)) $(done_init).notify(true) }) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index bf8483e5bc7..abe0dd607d3 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19793,6 +19793,195 @@ class MakieCamera { } } } +const LINES_VERT = `#version 300 es +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master + +in vec2 uv; +in vec3 position; +in vec2 instanceStart; +in vec2 instanceEnd; + +out vec2 vUv; + +uniform mat4 projectionview; +uniform mat4 projection; +uniform mat4 model; +uniform mat4 view; + +uniform float linewidth; +uniform vec2 resolution; + +vec4 screen_space(vec4 vertex) +{ + return vec4(vertex.xy * resolution, vertex.z, vertex.w) / vertex.w; +} + +vec4 clip_space(vec4 screenspace) { + return vec4((screenspace.xy / resolution), screenspace.z, 1.0) * screenspace.w; +} + +void main() { + + // camera space + vec4 start = projectionview * model * vec4(instanceStart, 0.0, 1.0); + vec4 end = projectionview * model * vec4(instanceEnd, 0.0, 1.0); + vUv = uv; + + // screenspace + vec4 ndcStart = screen_space(start); + vec4 ndcEnd = screen_space(end); + + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir = normalize(dir); + + vec2 offset = vec2(dir.y, -dir.x); // orthogonal vector + + // sign flip + if (position.x < 0.0) + offset *= -1.0; + + // endcaps + if (position.y < 0.0) { + offset += -dir; + } else if (position.y > 1.0) { + offset += dir; + } + + // adjust for linewidth + offset *= linewidth; + + + + // select end + vec4 screen = (position.y < 0.5) ? ndcStart : ndcEnd; + screen.xy += offset; + gl_Position = clip_space(screen); +} +`; +const LINES_FRAG = `#version 300 es +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; + +out vec4 fragment_color; + +uniform vec3 diffuse; +uniform float opacity; + +in vec2 vUv; + + +void main() { + + fragment_color = vec4(0,0,0, 1.0); +} +`; +function create_line_material(uniforms) { + return new mod.RawShaderMaterial({ + uniforms: deserialize_uniforms(uniforms), + vertexShader: LINES_VERT, + fragmentShader: LINES_FRAG, + transparent: true + }); +} +function create_line_geometry(linepositions) { + const geometry = new mod.InstancedBufferGeometry(); + const instance_positions = [ + -1, + 2, + 0, + 1, + 2, + 0, + -1, + 1, + 0, + 1, + 1, + 0, + -1, + 0, + 0, + 1, + 0, + 0, + -1, + -1, + 0, + 1, + -1, + 0 + ]; + const uvs = [ + -1, + 2, + 1, + 2, + -1, + 1, + 1, + 1, + -1, + -1, + 1, + -1, + -1, + -2, + 1, + -2 + ]; + const index = [ + 0, + 2, + 1, + 2, + 3, + 1, + 2, + 4, + 3, + 4, + 5, + 3, + 4, + 6, + 5, + 6, + 7, + 5 + ]; + geometry.setIndex(index); + geometry.setAttribute("position", new mod.Float32BufferAttribute(instance_positions, 3)); + geometry.setAttribute("uv", new mod.Float32BufferAttribute(uvs, 2)); + const instanceBuffer = new mod.InstancedInterleavedBuffer(linepositions, 4, 1); + geometry.setAttribute("instanceStart", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 0)); + geometry.setAttribute("instanceEnd", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 2)); + geometry.boundingSphere = new mod.Sphere(); + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + geometry.instanceCount = linepositions.length / 2; + return geometry; +} +function create_line(line_data) { + console.log(line_data); + const geometry = create_line_geometry(line_data.positions); + const material = create_line_material(line_data.uniforms); + console.log(geometry); + console.log(material); + return new mod.Mesh(geometry, material); +} const scene_cache = {}; const plot_cache = {}; const TEXTURE_ATLAS = [ @@ -19907,6 +20096,9 @@ function deserialize_uniforms(data) { return result; } function deserialize_plot(data) { + if (data.plot_type === "lines") { + return create_line(data); + } let mesh; if ("instance_attributes" in data) { mesh = create_instanced_mesh(data); @@ -20243,7 +20435,7 @@ function render_scene(scene, picking = false) { if (!scene.visible.value) { return true; } - renderer.autoClear = scene.clearscene.value; + renderer.autoClear = scene.clearscene; const area = scene.pixelarea.value; if (area) { const [x, y, w, h] = area.map((t)=>t / pixelRatio1); From ec3cc4a3051002f9604a1c3ae22bb690f14fd22d Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 13 Jul 2023 13:02:52 +0200 Subject: [PATCH 03/28] get first line prototype going --- WGLMakie/src/Lines.js | 17 +++++++++---- WGLMakie/src/Serialization.js | 41 ++++++++++++++++++++------------ WGLMakie/src/lines.jl | 16 +++++++++---- WGLMakie/src/wglmakie.bundled.js | 33 ++++++++++++++++--------- 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index f386365547c..1723aad3ca8 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -161,6 +161,17 @@ function create_line_material(uniforms) { } function create_line_geometry(linepositions) { + const length = linepositions.length + const points = new Float32Array(2 * length); + + for (let i = 0; i < length; i += 2) { + points[2 * i] = linepositions[i]; + points[2 * i + 1] = linepositions[i + 1]; + + points[2 * i + 2] = linepositions[i + 2]; + points[2 * i + 3] = linepositions[i + 3]; + } + const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [ @@ -176,11 +187,7 @@ function create_line_geometry(linepositions) { ); geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); - const instanceBuffer = new THREE.InstancedInterleavedBuffer( - linepositions, - 4, - 1 - ); // xyz, xyz + const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xyz, xyz geometry.setAttribute( "instanceStart", diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index d1f24fa58a2..11b4bb44d44 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -87,19 +87,19 @@ precision mediump sampler3D; out vec4 fragment_color; -uniform vec3 diffuse; -uniform float opacity; +uniform vec4 color; in vec2 vUv; void main() { - fragment_color = vec4(0,0,0, 1.0); + fragment_color = color; } `; function create_line_material(uniforms) { + console.log(uniforms) return new THREE.RawShaderMaterial({ uniforms: deserialize_uniforms(uniforms), vertexShader: LINES_VERT, @@ -108,7 +108,23 @@ function create_line_material(uniforms) { }); } -function create_line_geometry(linepositions) { +function create_line_geometry(linepositions, linesegments) { + const length = linepositions.length; + let points; + if (linesegments) { + points = linepositions; + } else { + points = new Float32Array(2 * length); + + for (let i = 0; i < length; i += 2) { + points[2 * i] = linepositions[i]; + points[2 * i + 1] = linepositions[i + 1]; + + points[2 * i + 2] = linepositions[i + 2]; + points[2 * i + 3] = linepositions[i + 3]; + } + } + const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [ @@ -124,11 +140,7 @@ function create_line_geometry(linepositions) { ); geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); - const instanceBuffer = new THREE.InstancedInterleavedBuffer( - linepositions, - 4, - 1 - ); // xyz, xyz + const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xyz, xyz geometry.setAttribute( "instanceStart", @@ -143,17 +155,17 @@ function create_line_geometry(linepositions) { // don't use intersection / culling geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; - geometry.instanceCount = linepositions.length / 2 + geometry.instanceCount = points.length / 2; return geometry; } export function create_line(line_data) { - console.log(line_data); - const geometry = create_line_geometry(line_data.positions); + const geometry = create_line_geometry( + line_data.positions, + line_data.is_linesegments + ); const material = create_line_material(line_data.uniforms); - console.log(geometry) - console.log(material); return new THREE.Mesh(geometry, material); } @@ -331,7 +343,6 @@ export function add_plot(scene, plot_data) { // fill in the camera uniforms, that we don't sent in serialization per plot const cam = scene.wgl_camera; const identity = new THREE.Uniform(new THREE.Matrix4()); - if (plot_data.cam_space == "data") { plot_data.uniforms.view = cam.view; plot_data.uniforms.projection = cam.projection; diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 7dd46a13eee..14dad3103ec 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -1,18 +1,26 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) uniforms = Dict( :opacity => 1.0, - :linewidth => 2.0, + :linewidth => plot.linewidth[], :diffuse => Vec3f(0, 0, 0), :model => plot.model ) - return Dict( + color = to_color(plot.color[]) + if color isa Colorant + uniforms[:color] = serialize_three(color) + else + uniforms[:color] = serialize_three(to_color(:black)) + end + attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, :uuid => js_uuid(plot), :plot_type => :lines, - :space => plot.space, - + :cam_space => plot.space[], + :is_linesegments => plot isa LineSegments, :positions => collect(reinterpret(Float32, plot[1][])), :uniforms => serialize_uniforms(uniforms) ) + + return attr end diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 1f16bf5dbe4..5a8a73f6dd3 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19879,18 +19879,18 @@ precision mediump sampler3D; out vec4 fragment_color; -uniform vec3 diffuse; -uniform float opacity; +uniform vec4 color; in vec2 vUv; void main() { - fragment_color = vec4(0,0,0, 1.0); + fragment_color = color; } `; function create_line_material(uniforms) { + console.log(uniforms); return new mod.RawShaderMaterial({ uniforms: deserialize_uniforms(uniforms), vertexShader: LINES_VERT, @@ -19898,7 +19898,20 @@ function create_line_material(uniforms) { transparent: true }); } -function create_line_geometry(linepositions) { +function create_line_geometry(linepositions, linesegments) { + const length = linepositions.length; + let points; + if (linesegments) { + points = linepositions; + } else { + points = new Float32Array(2 * length); + for(let i = 0; i < length; i += 2){ + points[2 * i] = linepositions[i]; + points[2 * i + 1] = linepositions[i + 1]; + points[2 * i + 2] = linepositions[i + 2]; + points[2 * i + 3] = linepositions[i + 3]; + } + } const geometry = new mod.InstancedBufferGeometry(); const instance_positions = [ -1, @@ -19967,21 +19980,18 @@ function create_line_geometry(linepositions) { geometry.setIndex(index); geometry.setAttribute("position", new mod.Float32BufferAttribute(instance_positions, 3)); geometry.setAttribute("uv", new mod.Float32BufferAttribute(uvs, 2)); - const instanceBuffer = new mod.InstancedInterleavedBuffer(linepositions, 4, 1); + const instanceBuffer = new mod.InstancedInterleavedBuffer(points, 4, 1); geometry.setAttribute("instanceStart", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 0)); geometry.setAttribute("instanceEnd", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 2)); geometry.boundingSphere = new mod.Sphere(); geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; - geometry.instanceCount = linepositions.length / 2; + geometry.instanceCount = points.length / 2; return geometry; } function create_line(line_data) { - console.log(line_data); - const geometry = create_line_geometry(line_data.positions); + const geometry = create_line_geometry(line_data.positions, line_data.is_linesegments); const material = create_line_material(line_data.uniforms); - console.log(geometry); - console.log(material); return new mod.Mesh(geometry, material); } const scene_cache = {}; @@ -20128,6 +20138,7 @@ function on_next_insert(f) { function add_plot(scene, plot_data) { const cam = scene.wgl_camera; const identity = new mod.Uniform(new mod.Matrix4()); + console.log(plot_data.cam_space); if (plot_data.cam_space == "data") { plot_data.uniforms.view = cam.view; plot_data.uniforms.projection = cam.projection; @@ -20437,7 +20448,7 @@ function render_scene(scene, picking = false) { if (!scene.visible.value) { return true; } - renderer.autoClear = scene.clearscene; + renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; if (area) { const [x, y, w, h] = area.map((t)=>t / pixelRatio1); From e6e244a1d35d9e4742574db7460926ac424e67ff Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 13 Jul 2023 13:11:30 +0200 Subject: [PATCH 04/28] delete unused shaders --- WGLMakie/assets/line_segments.frag | 26 --- WGLMakie/assets/line_segments.vert | 50 ----- WGLMakie/assets/lines.frag | 25 --- WGLMakie/assets/lines.vert | 123 ---------- WGLMakie/assets/lines2.vert | 346 ----------------------------- 5 files changed, 570 deletions(-) delete mode 100644 WGLMakie/assets/line_segments.frag delete mode 100644 WGLMakie/assets/line_segments.vert delete mode 100644 WGLMakie/assets/lines.frag delete mode 100644 WGLMakie/assets/lines.vert delete mode 100644 WGLMakie/assets/lines2.vert diff --git a/WGLMakie/assets/line_segments.frag b/WGLMakie/assets/line_segments.frag deleted file mode 100644 index 384921152a2..00000000000 --- a/WGLMakie/assets/line_segments.frag +++ /dev/null @@ -1,26 +0,0 @@ - -in vec4 frag_color; - -flat in uint frag_instance_id; -vec4 pack_int(uint id, uint index) { - vec4 unpack; - unpack.x = float((id & uint(0xff00)) >> 8) / 255.0; - unpack.y = float((id & uint(0x00ff)) >> 0) / 255.0; - unpack.z = float((index & uint(0xff00)) >> 8) / 255.0; - unpack.w = float((index & uint(0x00ff)) >> 0) / 255.0; - return unpack; -} - -void main() { - if (picking) { - if (frag_color.a > 0.1) { - fragment_color = pack_int(object_id, frag_instance_id); - } - return; - } - - if (frag_color.a <= 0.0){ - discard; - } - fragment_color = frag_color; -} diff --git a/WGLMakie/assets/line_segments.vert b/WGLMakie/assets/line_segments.vert deleted file mode 100644 index 9f088ad90c2..00000000000 --- a/WGLMakie/assets/line_segments.vert +++ /dev/null @@ -1,50 +0,0 @@ -uniform mat4 projection; -uniform mat4 view; - -vec2 screen_space(vec4 position) -{ - return vec2(position.xy / position.w) * get_resolution(); -} -vec3 tovec3(vec2 v){return vec3(v, 0.0);} -vec3 tovec3(vec3 v){return v;} - -vec4 tovec4(vec3 v){return vec4(v, 1.0);} -vec4 tovec4(vec4 v){return v;} - -out vec4 frag_color; - -flat out uint frag_instance_id; - -void main() -{ - mat4 pvm = projection * view * get_model(); - vec4 point1_clip = pvm * vec4(tovec3(get_segment_start()), 1); - vec4 point2_clip = pvm * vec4(tovec3(get_segment_end()), 1); - vec2 point1_screen = screen_space(point1_clip); - vec2 point2_screen = screen_space(point2_clip); - vec2 dir = normalize(point2_screen - point1_screen); - vec2 normal = vec2(-dir.y, dir.x); - vec4 anchor; - float thickness; - - if(position.x == 0.0){ - anchor = point1_clip; - frag_color = tovec4(get_color_start()); - thickness = get_linewidth_start(); - }else{ - anchor = point2_clip; - frag_color = tovec4(get_color_end()); - thickness = get_linewidth_end(); - } - frag_color.a = frag_color.a * min(1.0, thickness * 2.0); - - normal *= (thickness / get_resolution()) * anchor.w; - // quadpos y (position.y) gives us the direction to expand the line - vec4 offset = vec4(normal * position.y, 0.0, 0.0); - // start, or end of quad, need to use current or next point as anchor - gl_Position = anchor + offset; - gl_Position.z += gl_Position.w * get_depth_shift(); - - frag_instance_id = uint(gl_InstanceID); - -} diff --git a/WGLMakie/assets/lines.frag b/WGLMakie/assets/lines.frag deleted file mode 100644 index a73cc8b5943..00000000000 --- a/WGLMakie/assets/lines.frag +++ /dev/null @@ -1,25 +0,0 @@ - -uniform vec3 diffuse; -uniform float opacity; - -in vec2 vUv; - - -void main() { - - float alpha = opacity; - - // artifacts appear on some hardware if a derivative is taken within a conditional - float a = vUv.x; - float b = (vUv.y > 0.0) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - float dlen = fwidth(len2); - - if (abs(vUv.y) > 1.0) { - alpha = 1.0 - smoothstep(1.0 - dlen, 1.0 + dlen, len2); - } - - vec4 diffuseColor = vec4(diffuse, alpha); - gl_FragColor = vec4(diffuseColor.rgb, alpha); - -} diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert deleted file mode 100644 index dcc9080fe29..00000000000 --- a/WGLMakie/assets/lines.vert +++ /dev/null @@ -1,123 +0,0 @@ -# version 300 es - -precision mediump int; -precision mediump float; -precision mediump sampler2D; -precision mediump sampler3D; - -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master - -in vec2 uv; -in vec3 position; -in vec2 instanceStart; -in vec2 instanceEnd; - -out vec2 vUv; - -uniform mat4 projection; -uniform mat4 model; -uniform mat4 view; - -uniform float linewidth; -uniform vec2 resolution; - -void trimSegment(const in vec4 start, inout vec4 end) { - - // trim end segment so it terminates between the camera plane and the near plane - - // conservative estimate of the near plane - float a = projection[2][2]; // 3nd entry in 3th column - float b = projection[3][2]; // 3nd entry in 4th column - float nearEstimate = -0.5 * b / a; - - float alpha = (nearEstimate - start.z) / (end.z - start.z); - - end.xyz = mix(start.xyz, end.xyz, alpha); - -} - -void main() { - - float aspect = resolution.x / resolution.y; - mat4 model_view = model * view; - // camera space - vec4 start = model_view * vec4(instanceStart, 0.0, 1.0); - vec4 end = model_view * vec4(instanceEnd, 0.0, 1.0); - vUv = uv; - - // special case for perspective projection, and segments that terminate either in, or behind, the camera plane - // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space - // but we need to perform ndc-space calculations in the shader, so we must address this issue directly - // perhaps there is a more elegant solution -- WestLangley - - bool perspective = false; //(projection[2][3] == -1.0); // 4th entry in the 3rd column - - if (perspective) { - - if (start.z < 0.0 && end.z >= 0.0) { - - trimSegment(start, end); - - } else if (end.z < 0.0 && start.z >= 0.0) { - - trimSegment(end, start); - - } - - } - - // clip space - vec4 clipStart = projection * start; - vec4 clipEnd = projection * end; - - // ndc space - vec3 ndcStart = clipStart.xyz / clipStart.w; - vec3 ndcEnd = clipEnd.xyz / clipEnd.w; - - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; - - // account for clip-space aspect ratio - dir.x *= aspect; - dir = normalize(dir); - - vec2 offset = vec2(dir.y, -dir.x); - // undo aspect ratio adjustment - dir.x /= aspect; - offset.x /= aspect; - - // sign flip - if (position.x < 0.0) - offset *= -1.0; - - // endcaps - if (position.y < 0.0) { - - offset += -dir; - - } else if (position.y > 1.0) { - - offset += dir; - - } - - // adjust for linewidth - offset *= linewidth; - - // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... - offset /= resolution.y; - - // select end - vec4 clip = (position.y < 0.5) ? clipStart : clipEnd; - - // back to clip space - // back to clip space - offset *= clip.w; - - clip.xy += offset; - - gl_Position = clip; -} diff --git a/WGLMakie/assets/lines2.vert b/WGLMakie/assets/lines2.vert deleted file mode 100644 index aba702962e7..00000000000 --- a/WGLMakie/assets/lines2.vert +++ /dev/null @@ -1,346 +0,0 @@ -{{GLSL_VERSION}} -{{GLSL_EXTENSIONS}} -{{SUPPORTED_EXTENSIONS}} - -struct Nothing{ //Nothing type, to encode if some variable doesn't contain any data - bool _; //empty structs are not allowed -}; - -{{define_fast_path}} - -layout(lines_adjacency) in; -layout(triangle_strip, max_vertices = 11) out; - -in vec4 g_color[]; -in float g_lastlen[]; -in uvec2 g_id[]; -in int g_valid_vertex[]; -in float g_thickness[]; - -out vec4 f_color; -out vec2 f_uv; -out float f_thickness; -flat out uvec2 f_id; -flat out vec2 f_uv_minmax; - -out vec3 o_view_pos; -out vec3 o_normal; - -uniform vec2 resolution; -uniform float pattern_length; -uniform sampler1D pattern_sections; - -float px2uv = 0.5 / pattern_length; - -// Constants -#define MITER_LIMIT -0.4 -#define AA_THICKNESS 4 - -vec3 screen_space(vec4 vertex) -{ - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; -} - -vec3 clip_space(vec4 screenspace) { - return vec4((screenspace.xy / resolution), screenspace.z, 1.0); -} - -//////////////////////////////////////////////////////////////////////////////// -/// Emit Vertex Methods -//////////////////////////////////////////////////////////////////////////////// - - -// Manual uv calculation -// - position in screen space (double resolution as generally used) -// - uv with uv.u normalized (0..1), uv.v unnormalized (0..pattern_length) -void emit_vertex(vec3 position, vec2 uv, int index) -{ - f_uv = uv; - f_color = g_color[index]; - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - f_id = g_id[index]; - f_thickness = g_thickness[index]; - EmitVertex(); -} - -// For center point -void emit_vertex(vec3 position, vec2 uv) -{ - f_uv = uv; - f_color = 0.5 * (g_color[1] + g_color[2]); - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - f_id = g_id[1]; - f_thickness = 0.5 * (g_thickness[1] + g_thickness[2]); - EmitVertex(); -} - -// Debug -void emit_vertex(vec3 position, vec2 uv, int index, vec4 color) -{ - f_uv = uv; - f_color = color; - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - f_id = g_id[index]; - f_thickness = g_thickness[index]; - EmitVertex(); -} -void emit_vertex(vec3 position, vec2 uv, vec4 color) -{ - f_uv = uv; - f_color = color; - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - f_id = g_id[1]; - f_thickness = 0.5 * (g_thickness[1] + g_thickness[2]); - EmitVertex(); -} - - -// With offset calculations for core line segment -void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv, int index) -{ - emit_vertex( - position + vec3(offset, 0), - vec2(uv.x + px2uv * dot(line_dir, offset), uv.y), - index - ); -} - -void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv) -{ - emit_vertex( - position + vec3(offset, 0), - vec2(uv.x + px2uv * dot(line_dir, offset), uv.y) - ); -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Draw full line segment -//////////////////////////////////////////////////////////////////////////////// - - -// Generate line segment with 3 triangles -// - p1, p2 are the line start and end points in pixel space -// - miter_a and miter_b are the offsets from p1 and p2 respectively that -// generate the line segment quad. This should include thickness and AA -// - u1, u2 are the u values at p1 and p2. These should be in uv scale (px2uv applied) -// - thickness_aa1, thickness_aa2 are linewidth at p1 and p2 with AA added. They -// double as uv.y values, which are in pixel space -// - v1 is the line direction of this segment (xy component) -void generate_line_segment( - vec3 p1, vec2 miter_a, float u1, float thickness_aa1, - vec3 p2, vec2 miter_b, float u2, float thickness_aa2, - vec2 v1, float segment_length - ) -{ - float line_offset_a = dot(miter_a, v1); - float line_offset_b = dot(miter_b, v1); - - if (abs(line_offset_a) + abs(line_offset_b) < segment_length+1){ - // _________ - // \ / - // \_____/ - // <---> - // Line segment is extensive (minimum width positive) - - emit_vertex(p1, +miter_a, v1, vec2(u1, -thickness_aa1), 1); - emit_vertex(p1, -miter_a, v1, vec2(u1, thickness_aa1), 1); - emit_vertex(p2, +miter_b, v1, vec2(u2, -thickness_aa2), 2); - emit_vertex(p2, -miter_b, v1, vec2(u2, thickness_aa2), 2); - } else { - // ____ - // \ / - // \/ - // /\ - // >--< - // Line segment has zero or negative width on short side - - // Pulled apart, we draw these two triangles (vertical lines added) - // ___ ___ - // \ | | / - // X | | X - // \| |/ - // - // where X is u1/p1 (left) and u2/p2 (right) respectively. To avoid - // drawing outside the line segment due to AA padding, we cut off the - // left triangle on the right side at u2 via f_uv_minmax.y, and - // analogously the right triangle at u1 via f_uv_minmax.x. - // These triangles will still draw over each other like this. - - // incoming side - float old = f_uv_minmax.y; - f_uv_minmax.y = u2; - - emit_vertex(p1, -miter_a, v1, vec2(u1, -thickness_aa1), 1); - emit_vertex(p1, +miter_a, v1, vec2(u1, +thickness_aa1), 1); - if (line_offset_a > 0){ // finish triangle on -miter_a side - emit_vertex(p1, 2 * line_offset_a * v1 - miter_a, v1, vec2(u1, -thickness_aa1)); - } else { - emit_vertex(p1, -2 * line_offset_a * v1 + miter_a, v1, vec2(u1, +thickness_aa1)); - } - - EndPrimitive(); - - // outgoing side - f_uv_minmax.x = u1; - f_uv_minmax.y = old; - - emit_vertex(p2, -miter_b, v1, vec2(u2, -thickness_aa2), 2); - emit_vertex(p2, +miter_b, v1, vec2(u2, +thickness_aa2), 2); - if (line_offset_b < 0){ // finish triangle on -miter_b side - emit_vertex(p2, 2 * line_offset_b * v1 - miter_b, v1, vec2(u2, -thickness_aa2)); - } else { - emit_vertex(p2, -2 * line_offset_b * v1 + miter_b, v1, vec2(u2, +thickness_aa2)); - } - } -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Solid lines -//////////////////////////////////////////////////////////////////////////////// - - - -void draw_solid_line(bool isvalid[4]) -{ - // This sets a min and max value foir uv.u at which anti-aliasing is forced. - // With this setting it's never triggered. - f_uv_minmax = vec2(-1.0e12, 1.0e12); - - // get the four vertices passed to the shader - // without FAST_PATH the conversions happen on the CPU - vec3 p0 = screen_space(gl_in[0].gl_Position); // start of previous segment - vec3 p1 = screen_space(gl_in[1].gl_Position); // end of previous segment, start of current segment - vec3 p2 = screen_space(gl_in[2].gl_Position); // end of current segment, start of next segment - vec3 p3 = screen_space(gl_in[3].gl_Position); // end of next segment - - // linewidth with padding for anti aliasing - float thickness_aa1 = g_thickness[1] + AA_THICKNESS; - float thickness_aa2 = g_thickness[2] + AA_THICKNESS; - - // determine the direction of each of the 3 segments (previous, current, next) - vec3 v1 = p2 - p1; - float segment_length = length(v1.xy); - v1 /= segment_length; - vec3 v0 = v1; - vec3 v2 = v1; - - if (p1 != p0 && isvalid[0]) { - v0 = (p1 - p0) / length((p1 - p0).xy); - } - if (p3 != p2 && isvalid[3]) { - v2 = (p3 - p2) / length((p3 - p2).xy); - } - - // determine the normal of each of the 3 segments (previous, current, next) - vec2 n0 = vec2(-v0.y, v0.x); - vec2 n1 = vec2(-v1.y, v1.x); - vec2 n2 = vec2(-v2.y, v2.x); - - // Setup for sharp corners (see above) - vec2 miter_a = normalize(n0 + n1); - vec2 miter_b = normalize(n1 + n2); - float length_a = thickness_aa1 / dot(miter_a, n1); - float length_b = thickness_aa2 / dot(miter_b, n1); - - // truncated miter join (see above) - if( dot( v0.xy, v1.xy ) < MITER_LIMIT ){ - bool gap = dot( v0.xy, n1 ) > 0; - // In this case uv's are used as signed distance field values, so we - // want 0 where we had start before. - float u0 = thickness_aa1 * abs(dot(miter_a, n1)) * px2uv; - float proj_AA = AA_THICKNESS * abs(dot(miter_a, n1)) * px2uv; - - // to save some space - vec2 off0 = thickness_aa1 * n0; - vec2 off1 = thickness_aa1 * n1; - vec2 off_AA = AA_THICKNESS * miter_a; - float u_AA = AA_THICKNESS * px2uv; - - if(gap){ - emit_vertex(p1, vec2(+ u0, 0), 1); - emit_vertex(p1 + vec3(off0, 0), vec2(- proj_AA, +thickness_aa1), 1); - emit_vertex(p1 + vec3(off1, 0), vec2(- proj_AA, -thickness_aa1), 1); - emit_vertex(p1 + vec3(off0 + off_AA, 0), vec2(- proj_AA - u_AA, +thickness_aa1), 1); - emit_vertex(p1 + vec3(off1 + off_AA, 0), vec2(- proj_AA - u_AA, -thickness_aa1), 1); - EndPrimitive(); - }else{ - emit_vertex(p1, vec2(+ u0, 0), 1); - emit_vertex(p1 - vec3(off1, 0), vec2(- proj_AA, +thickness_aa1), 1); - emit_vertex(p1 - vec3(off0, 0), vec2(- proj_AA, -thickness_aa1), 1); - emit_vertex(p1 - vec3(off1 + off_AA, 0), vec2(- proj_AA - u_AA, +thickness_aa1), 1); - emit_vertex(p1 - vec3(off0 + off_AA, 0), vec2(- proj_AA - u_AA, -thickness_aa1), 1); - EndPrimitive(); - } - - miter_a = n1; - length_a = thickness_aa1; - } - - // we have miter join on next segment, do normal line cut off - if( dot( v1.xy, v2.xy ) <= MITER_LIMIT ){ - miter_b = n1; - length_b = thickness_aa2; - } - - // Without a pattern (linestyle) we use uv.u directly as a signed distance - // field. We only care about u1 - u0 being the correct distance and - // u0 > AA_THICHKNESS at all times. - float u1 = 10000.0; - float u2 = u1 + segment_length; - - miter_a *= length_a; - miter_b *= length_b; - - // To treat line starts and ends we elongate the line in the respective - // direction and enforce an AA border at the original start/end position - // with f_uv_minmax. - if (!isvalid[0]) - { - float corner_offset = max(0, abs(dot(miter_b, v1.xy)) - segment_length); - f_uv_minmax.x = px2uv * (u1 - corner_offset); - p1 -= (corner_offset + AA_THICKNESS) * v1; - u1 -= (corner_offset + AA_THICKNESS); - segment_length += corner_offset; - } - - if (!isvalid[3]) - { - float corner_offset = max(0, abs(dot(miter_a, v1.xy)) - segment_length); - f_uv_minmax.y = px2uv * (u2 + corner_offset); - p2 += (corner_offset + AA_THICKNESS) * v1; - u2 += (corner_offset + AA_THICKNESS); - segment_length += corner_offset; - } - - - // Generate line segment - u1 *= px2uv; - u2 *= px2uv; - - // Normal Version - generate_line_segment( - p1, miter_a, u1, thickness_aa1, - p2, miter_b, u2, thickness_aa2, - v1.xy, segment_length - ); - - return; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Main -//////////////////////////////////////////////////////////////////////////////// - - - -void main(void) -{ - draw_solid_line(isvalid); - - return; -} From 0974417d1b45be28f2e32de95c0ceb2754987008 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 17 Jul 2023 14:12:51 +0200 Subject: [PATCH 05/28] tmp --- WGLMakie/assets/lines.frag | 48 ++ WGLMakie/assets/lines.vert | 335 ++++++++++++++ WGLMakie/src/Serialization.js | 277 +++++++---- WGLMakie/src/Serialization2.js | 767 +++++++++++++++++++++++++++++++ WGLMakie/src/experiment.vert | 328 +++++++++++++ WGLMakie/src/lines-class.js | 254 ++++++++++ WGLMakie/src/lines.jl | 27 +- WGLMakie/src/mapbox-lines.vert | 74 +++ WGLMakie/src/wglmakie.bundled.js | 305 ++++++------ 9 files changed, 2166 insertions(+), 249 deletions(-) create mode 100644 WGLMakie/assets/lines.frag create mode 100644 WGLMakie/assets/lines.vert create mode 100644 WGLMakie/src/Serialization2.js create mode 100644 WGLMakie/src/experiment.vert create mode 100644 WGLMakie/src/lines-class.js create mode 100644 WGLMakie/src/mapbox-lines.vert diff --git a/WGLMakie/assets/lines.frag b/WGLMakie/assets/lines.frag new file mode 100644 index 00000000000..01081ed98af --- /dev/null +++ b/WGLMakie/assets/lines.frag @@ -0,0 +1,48 @@ +#version 300 es +precision mediump int; +precision mediump float; +precision mediump sampler2D; +precision mediump sampler3D; + +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; + +uniform float pattern_length; + +out vec4 fragment_color; + +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1 - ANTIALIAS_RADIUS, threshold1 + ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0f * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main() { + vec4 color = vec4(f_color.rgb, 0.0f); + vec2 xy = f_uv; + + float alpha = aastep(0.0f, xy.x); + float alpha2 = aastep(-f_thickness, f_thickness, xy.y); + float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); + + color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); + + fragment_color = color; +} diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert new file mode 100644 index 00000000000..face9942def --- /dev/null +++ b/WGLMakie/assets/lines.vert @@ -0,0 +1,335 @@ +#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +in float position; + +in vec2 linepoint_prev; // start of previous segment +in vec2 linepoint_start; // end of previous segment, start of current segment +in vec2 linepoint_end; // end of current segment, start of next segment +in vec2 linepoint_next; // end of next segment + +uniform vec4 is_valid; // start of previous segment + +uniform vec4 color_start; // end of previous segment, start of current segment +uniform vec4 color_end; // end of current segment, start of next segment + +uniform float thickness_start; +uniform float thickness_end; + +uniform vec2 resolution; +uniform mat4 projectionview; +uniform mat4 model; +uniform float pattern_length; + +flat out vec2 f_uv_minmax; +out vec2 f_uv; +out vec4 f_color; +out float f_thickness; + +#define MITER_LIMIT -0.4 +#define AA_THICKNESS 4.0 + +vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; +} + +// Manual uv calculation +// - position in screen space (double resolution as generally used) +// - uv with uv.u normalized (0..1), uv.v unnormalized (0..pattern_length) +void emit_vertex(vec3 position, vec2 uv, bool is_start, float thickness) { + f_uv = uv; + f_color = is_start ? color_start : color_end; + gl_Position = vec4((position.xy / resolution), position.z, 1.0f); + // linewidth scaling may shrink the effective linewidth + f_thickness = thickness; +} + +void emit_vertex(vec3 position, vec2 uv, bool is_start) { + + f_uv = uv; + + f_color = is_start ? color_start : color_end; + + gl_Position = vec4((position.xy / resolution), position.z, 1.0f); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? thickness_start : thickness_end; +} + +void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv, bool index) { + float px2uv = 0.5f / pattern_length; + emit_vertex(position + vec3(offset, 0), vec2(uv.x + px2uv * dot(line_dir, offset), uv.y), index, abs(uv.y) - AA_THICKNESS); + // abs(uv.y) - AA_THICKNESS corrects for enlarged AA padding between + // segments of different linewidth, see #2953 +} + +// Generate line segment with 3 triangles +// - p1, p2 are the line start and end points in pixel space +// - miter_a and miter_b are the offsets from p1 and p2 respectively that +// generate the line segment quad. This should include thickness and AA +// - u1, u2 are the u values at p1 and p2. These should be in uv scale (px2uv applied) +// - thickness_aa1, thickness_aa2 are linewidth at p1 and p2 with AA added. They +// double as uv.y values, which are in pixel space +// - v1 is the line direction of this segment (xy component) +void generate_line_segment( + vec3 p1, + vec2 miter_a, + float u1, + float thickness_aa1, + vec3 p2, + vec2 miter_b, + float u2, + float thickness_aa2, + vec2 v1, + float segment_length +) { + float line_offset_a = dot(miter_a, v1); + float line_offset_b = dot(miter_b, v1); + + if (abs(line_offset_a) + abs(line_offset_b) < segment_length + 1.0f) { + // _________ + // \ / + // \_____/ + // <---> + // Line segment is extensive (minimum width positive) + if (position == 5.0f) { + emit_vertex(p1, +miter_a, v1, vec2(u1, -thickness_aa1), true); + return; + } + if (position == 6.0f) { + emit_vertex(p1, -miter_a, v1, vec2(u1, thickness_aa1), true); + return; + } + if (position == 7.0f) { + emit_vertex(p2, +miter_b, v1, vec2(u2, -thickness_aa2), false); + return; + } + if (position == 8.0f) { + emit_vertex(p2, -miter_b, v1, vec2(u2, thickness_aa2), false); + return; + } + + } else { + /* + \ / + \/ + /\ + >--< + Line segment has zero or negative width on short side + + Pulled apart, we draw these two triangles (vertical lines added) + ___ ___ + \ | | / + X | | X + \| |/ + + where X is u1/p1 (left) and u2/p2 (right) respectively. To avoid + drawing outside the line segment due to AA padding, we cut off the + left triangle on the right side at u2 via f_uv_minmax.y, and + analogously the right triangle at u1 via f_uv_minmax.x. + These triangles will still draw over each other like this. + */ + + // incoming side + float old = f_uv_minmax.y; + f_uv_minmax.y = u2; + if (position == 5.0f) { + emit_vertex(p1, -miter_a, v1, vec2(u1, -thickness_aa1), true); + return; + } + if (position == 6.0f) { + emit_vertex(p1, +miter_a, v1, vec2(u1, +thickness_aa1), true); + return; + } + if (position == 7.0f) { + if (line_offset_a > 0.0f) { // finish triangle on -miter_a side + emit_vertex(p1, 2.0f * line_offset_a * v1 - miter_a, v1, vec2(u1, -thickness_aa1), true); + } else { + emit_vertex(p1, -2.0f * line_offset_a * v1 + miter_a, v1, vec2(u1, +thickness_aa1), true); + } + return; + } + + // outgoing side + f_uv_minmax.x = u1; + f_uv_minmax.y = old; + if (position == 8.0f) { + emit_vertex(p2, -miter_b, v1, vec2(u2, -thickness_aa2), false); + return; + } + if (position == 9.0f) { + emit_vertex(p2, +miter_b, v1, vec2(u2, +thickness_aa2), false); + return; + } + + if (line_offset_b < 0.0f) { // finish triangle on -miter_b side + emit_vertex(p2, 2.0f * line_offset_b * v1 - miter_b, v1, vec2(u2, -thickness_aa2), false); + } else { + emit_vertex(p2, -2.0f * line_offset_b * v1 + miter_b, v1, vec2(u2, +thickness_aa2), false); + } + return; + } +} + +void main() { + float px2uv = 0.5f / pattern_length; + + bvec4 _isvalid = bvec4(true, true, true, true); + + // This sets a min and max value foir uv.u at which anti-aliasing is forced. + // With this setting it's never triggered. + f_uv_minmax = vec2(-1.0e12f, 1.0e12f); + + // get the four vertices passed to the shader + // without FAST_PATH the conversions happen on the CPU + vec3 p0 = screen_space(linepoint_prev); // start of previous segment + vec3 p1 = screen_space(linepoint_start); // end of previous segment, start of current segment + vec3 p2 = screen_space(linepoint_end); // end of current segment, start of next segment + vec3 p3 = screen_space(linepoint_next); // end of next segment + + // determine the direction of each of the 3 segments (previous, current, next) + vec3 v1 = p2 - p1; + float segment_length = length(v1.xy); + v1 /= segment_length; + vec3 v0 = v1; + vec3 v2 = v1; + + if (p1 != p0 && _isvalid.x) { + v0 = (p1 - p0) / length((p1 - p0).xy); + } + if (p3 != p2 && _isvalid.w) { + v2 = (p3 - p2) / length((p3 - p2).xy); + } + + // determine the normal of each of the 3 segments (previous, current, next) + vec2 n0 = vec2(-v0.y, v0.x); + vec2 n1 = vec2(-v1.y, v1.x); + vec2 n2 = vec2(-v2.y, v2.x); + + // determine stretching of AA border due to linewidth change + float temp = (thickness_end - thickness_start) / segment_length; + float edge_scale = sqrt(1.0f + temp * temp); + + // linewidth with padding for anti aliasing (used for geometry) + float thickness_aa1 = thickness_start + edge_scale * AA_THICKNESS; + float thickness_aa2 = thickness_end + edge_scale * AA_THICKNESS; + + // Setup for sharp corners (see above) + vec2 miter_a = normalize(n0 + n1); + vec2 miter_b = normalize(n1 + n2); + float length_a = thickness_aa1 / dot(miter_a, n1); + float length_b = thickness_aa2 / dot(miter_b, n1); + + // truncated miter join (see above) + if (dot(v0.xy, v1.xy) < MITER_LIMIT) { + bool gap = dot(v0.xy, n1) > 0.0f; + // In this case uv's are used as signed distance field values, so we + // want 0 where we had start before. + float u0 = thickness_aa1 * abs(dot(miter_a, n1)) * px2uv; + float proj_AA = AA_THICKNESS * abs(dot(miter_a, n1)) * px2uv; + + // to save some space + vec2 off0 = thickness_aa1 * n0; + vec2 off1 = thickness_aa1 * n1; + vec2 off_AA = AA_THICKNESS * miter_a; + float u_AA = AA_THICKNESS * px2uv; + + if (gap) { + if (position == 0.0f) { + emit_vertex(p1, vec2(+u0, 0.0f), true); + return; + } + if (position == 1.0f) { + emit_vertex(p1 + vec3(off0, 0), vec2(-proj_AA, +thickness_aa1), true); + return; + } + if (position == 2.0f) { + emit_vertex(p1 + vec3(off1, 0), vec2(-proj_AA, -thickness_aa1), true); + return; + } + if (position == 3.0f) { + emit_vertex(p1 + vec3(off0 + off_AA, 0), vec2(-proj_AA - u_AA, +thickness_aa1), true); + return; + } + if (position == 4.0f) { + emit_vertex(p1 + vec3(off1 + off_AA, 0), vec2(-proj_AA - u_AA, -thickness_aa1), true); + return; + } + } else { + if (position == 0.0f) { + emit_vertex(p1, vec2(+u0, 0), true); + return; + } + if (position == 1.0f) { + emit_vertex(p1 - vec3(off1, 0), vec2(-proj_AA, +thickness_aa1), true); + return; + } + if (position == 2.0f) { + emit_vertex(p1 - vec3(off0, 0), vec2(-proj_AA, -thickness_aa1), true); + return; + } + if (position == 3.0f) { + emit_vertex(p1 - vec3(off1 + off_AA, 0), vec2(-proj_AA - u_AA, +thickness_aa1), true); + return; + } + if (position == 4.0f) { + emit_vertex(p1 - vec3(off0 + off_AA, 0), vec2(-proj_AA - u_AA, -thickness_aa1), true); + return; + } + } + + miter_a = n1; + length_a = thickness_aa1; + } + + // we have miter join on next segment, do normal line cut off + if (dot(v1.xy, v2.xy) <= MITER_LIMIT) { + miter_b = n1; + length_b = thickness_aa2; + } + + // Without a pattern (linestyle) we use uv.u directly as a signed distance + // field. We only care about u1 - u0 being the correct distance and + // u0 > AA_THICHKNESS at all times. + float u1 = 10000.0f; + float u2 = u1 + segment_length; + + miter_a *= length_a; + miter_b *= length_b; + + // To treat line starts and ends we elongate the line in the respective + // direction and enforce an AA border at the original start/end position + // with f_uv_minmax. + if (!_isvalid.x) { + float corner_offset = max(0.0f, abs(dot(miter_b, v1.xy)) - segment_length); + f_uv_minmax.x = px2uv * (u1 - corner_offset); + p1 -= (corner_offset + AA_THICKNESS) * v1; + u1 -= (corner_offset + AA_THICKNESS); + segment_length += corner_offset; + } + + if (!_isvalid.w) { + float corner_offset = max(0.0f, abs(dot(miter_a, v1.xy)) - segment_length); + f_uv_minmax.y = px2uv * (u2 + corner_offset); + p2 += (corner_offset + AA_THICKNESS) * v1; + u2 += (corner_offset + AA_THICKNESS); + segment_length += corner_offset; + } + + // scaling of uv.y due to different linewidths + // the padding for AA_THICKNESS should always have AA_THICKNESS width in uv + thickness_aa1 = thickness_start / edge_scale + AA_THICKNESS; + thickness_aa2 = thickness_end / edge_scale + AA_THICKNESS; + + // Generate line segment + u1 *= px2uv; + u2 *= px2uv; + + // Normal Version + generate_line_segment(p1, miter_a, u1, thickness_aa1, p2, miter_b, u2, thickness_aa2, v1.xy, segment_length); + + return; +} diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 11b4bb44d44..30b4aff509a 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -1,105 +1,151 @@ import * as Camera from "./Camera.js"; import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; +//https://wwwtyro.net/2019/11/18/instanced-lines.html +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master const LINES_VERT = `#version 300 es precision mediump int; -precision mediump float; +precision highp float; precision mediump sampler2D; precision mediump sampler3D; -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master -in vec2 uv; -in vec3 position; -in vec2 instanceStart; -in vec2 instanceEnd; +in float position; -out vec2 vUv; +in vec2 linepoint_prev; // start of previous segment +in vec2 linepoint_start; // end of previous segment, start of current segment +in vec2 linepoint_end; // end of current segment, start of next segment +in vec2 linepoint_next; // end of next segment -uniform mat4 projectionview; -uniform mat4 projection; -uniform mat4 model; -uniform mat4 view; +uniform vec4 is_valid; // start of previous segment + +uniform vec4 color_start; // end of previous segment, start of current segment +uniform vec4 color_end; // end of current segment, start of next segment + +uniform float thickness_start; +uniform float thickness_end; -uniform float linewidth; uniform vec2 resolution; +uniform mat4 projectionview; +uniform mat4 model; +uniform float pattern_length; -vec4 screen_space(vec4 vertex) -{ - return vec4(vertex.xy * resolution, vertex.z, vertex.w) / vertex.w; -} +out vec2 f_uv; +out vec4 f_color; +out float f_thickness; -vec4 clip_space(vec4 screenspace) { - return vec4((screenspace.xy / resolution), screenspace.z, 1.0) * screenspace.w; +vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } -void main() { - - // camera space - vec4 start = projectionview * model * vec4(instanceStart, 0.0, 1.0); - vec4 end = projectionview * model * vec4(instanceEnd, 0.0, 1.0); - vUv = uv; +void emit_vertex(vec3 position, vec2 uv, bool is_start) { - // screenspace - vec4 ndcStart = screen_space(start); - vec4 ndcEnd = screen_space(end); + f_uv = uv; + f_color = is_start ? color_start : color_end; - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? thickness_start : thickness_end; +} - // account for clip-space aspect ratio +void main() { + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec2 dir = p1.xy - p2.xy; dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (thickness_start / 2.0); - vec2 offset = vec2(dir.y, -dir.x); // orthogonal vector - - // sign flip - if (position.x < 0.0) - offset *= -1.0; - - // endcaps - if (position.y < 0.0) { - offset += -dir; - } else if (position.y > 1.0) { - offset += dir; + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; + } + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), true); + return; + } + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; } - // adjust for linewidth - offset *= linewidth; - - - - // select end - vec4 screen = (position.y < 0.5) ? ndcStart : ndcEnd; - screen.xy += offset; - gl_Position = clip_space(screen); + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; + } + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; + } + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } } `; const LINES_FRAG = `#version 300 es precision mediump int; -precision mediump float; +precision highp float; precision mediump sampler2D; precision mediump sampler3D; +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; + +uniform float pattern_length; + out vec4 fragment_color; -uniform vec4 color; +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 -in vec2 vUv; +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} -void main() { +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main(){ + // vec4 color = vec4(f_color.rgb, 0.0); + // vec2 xy = f_uv; + + // float alpha = aastep(0.0, xy.x); + // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); + // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); - fragment_color = color; + // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); + + fragment_color = f_color; } `; function create_line_material(uniforms) { - console.log(uniforms) return new THREE.RawShaderMaterial({ uniforms: deserialize_uniforms(uniforms), vertexShader: LINES_VERT, @@ -108,54 +154,97 @@ function create_line_material(uniforms) { }); } -function create_line_geometry(linepositions, linesegments) { - const length = linepositions.length; - let points; - if (linesegments) { - points = linepositions; +function linepoints2buffer(linepoints, is_linesegments) { + const N = linepoints.length; + if (is_linesegments) { + const N2 = linepoints.length + 4; + const points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + points.set(linepoints, 2); + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + return points; } else { - points = new Float32Array(2 * length); - - for (let i = 0; i < length; i += 2) { - points[2 * i] = linepositions[i]; - points[2 * i + 1] = linepositions[i + 1]; - - points[2 * i + 2] = linepositions[i + 2]; - points[2 * i + 3] = linepositions[i + 3]; + const N2 = linepoints.length * 2 + 4; + const points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + for (let i = 0; i < linepoints.length; i += 2) { + points[2 * i + 2] = linepoints[i]; + points[2 * i + 3] = linepoints[i + 1]; + + points[2 * i + 4] = linepoints[i + 2]; + points[2 * i + 5] = linepoints[i + 3]; } + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + return points; } +} - const geometry = new THREE.InstancedBufferGeometry(); - - const instance_positions = [ - -1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, - -1, 0, - ]; - const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]; - const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]; - geometry.setIndex(index); - geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 3) - ); - geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); - - const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xyz, xyz - +function attach_instanced_line_geometry(geometry, points) { + const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xy1, xy2 geometry.setAttribute( - "instanceStart", + "linepoint_prev", new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) - ); // xyz + ); // xyz1 geometry.setAttribute( - "instanceEnd", + "linepoint_start", new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) - ); // xyz + ); // xyz1 + geometry.setAttribute( + "linepoint_end", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 4) + ); // xyz1 + geometry.setAttribute( + "linepoint_next", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 6) + ); // xyz2 + return instanceBuffer; +} + +function create_line_geometry(linepoints, is_linesegments) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [0, 1, 2, 3, 4, 5]; + + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 1) + ); + return geometry + } + + const geometry = geometry_buffer(); + + const points = linepoints2buffer(linepoints.value, is_linesegments); + + let instanceBuffer = attach_instanced_line_geometry(geometry, points); + + linepoints.on((new_points) => { + const new_line_points = linepoints2buffer(new_points, is_linesegments); + const old_count = instanceBuffer.updateRange.count; + if (old_count < new_line_points.length) { + instanceBuffer.dispose(); + instanceBuffer = attach_instanced_line_geometry( + geometry, + new_line_points + ); + } else { + instanceBuffer.updateRange.count = new_line_points.length; + instanceBuffer.set(new_line_points, 0); + } + + geometry.instanceCount = (new_line_points.length - 4) / 4; + instanceBuffer.needsUpdate = true + }) geometry.boundingSphere = new THREE.Sphere(); // don't use intersection / culling geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; - geometry.instanceCount = points.length / 2; + geometry.instanceCount = (points.length - 4) / 4; return geometry; } diff --git a/WGLMakie/src/Serialization2.js b/WGLMakie/src/Serialization2.js new file mode 100644 index 00000000000..6da7f2131a1 --- /dev/null +++ b/WGLMakie/src/Serialization2.js @@ -0,0 +1,767 @@ +import * as Camera from "./Camera.js"; +import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; + +const LINES_VERT = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +in float position; + +in vec2 linepoint_prev; // start of previous segment +in vec2 linepoint_start; // end of previous segment, start of current segment +in vec2 linepoint_end; // end of current segment, start of next segment +in vec2 linepoint_next; // end of next segment + +uniform vec4 is_valid; // start of previous segment + +uniform vec4 color_start; // end of previous segment, start of current segment +uniform vec4 color_end; // end of current segment, start of next segment + +uniform float thickness_start; +uniform float thickness_end; + +uniform vec2 resolution; +uniform mat4 projectionview; +uniform mat4 model; +uniform float pattern_length; + +flat out vec2 f_uv_minmax; +out vec2 f_uv; +out vec4 f_color; +out float f_thickness; + +#define MITER_LIMIT -0.4 +#define AA_THICKNESS 4.0 + +vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; +} + +void emit_vertex(vec3 position, vec2 uv, bool is_start) { + + f_uv = uv; + + f_color = is_start ? color_start : color_end; + + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + f_thickness = is_start ? thickness_start : thickness_end; +} + +void main() { + vec3 p0 = screen_space(linepoint_prev); + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec3 p3 = screen_space(linepoint_next); + vec2 dir = p1.xy - p2.xy; + dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (thickness_start / 2.0); + + vec2 tangent = normalize(normalize(p2 - p1) + normalize(p1 - p0)); + + vec2 miter = vec2(-tangent.y, tangent.x); + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; + } + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), true); + return; + } + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } + + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; + } + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; + } + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } +} +`; + +const LINES_FRAG = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; + +uniform float pattern_length; + +out vec4 fragment_color; + +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main(){ + // vec4 color = vec4(f_color.rgb, 0.0); + // vec2 xy = f_uv; + + // float alpha = aastep(0.0, xy.x); + // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); + // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); + + // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); + + fragment_color = f_color; +} +`; + +function create_line_material(uniforms) { + return new THREE.RawShaderMaterial({ + uniforms: deserialize_uniforms(uniforms), + vertexShader: LINES_VERT, + fragmentShader: LINES_FRAG, + transparent: true, + }); +} + +function create_line_geometry(linepoints, linesegments) { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [0, 1, 2, 3, 4, 5]; + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 1) + ); + const N = linepoints.length; + let points; + if (linesegments) { + const N2 = linepoints.length + 4; + points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + points.set(linepoints, 2); + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + } else { + const N2 = linepoints.length * 2 + 4; + points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + for (let i = 0; i < linepoints.length; i += 2) { + points[2 * i + 2] = linepoints[i]; + points[2 * i + 3] = linepoints[i + 1]; + + points[2 * i + 4] = linepoints[i + 2]; + points[2 * i + 5] = linepoints[i + 3]; + } + + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + } + + const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xy1, xy2 + + geometry.setAttribute( + "linepoint_prev", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) + ); // xyz1 + geometry.setAttribute( + "linepoint_start", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) + ); // xyz1 + geometry.setAttribute( + "linepoint_end", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 4) + ); // xyz1 + geometry.setAttribute( + "linepoint_next", + new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 6) + ); // xyz2 + + geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + geometry.instanceCount = (points.length - 4) / 4; + + return geometry; +} + +export function create_line(line_data) { + const geometry = create_line_geometry( + line_data.positions, + line_data.is_linesegments + ); + const material = create_line_material(line_data.uniforms); + console.log(material); + return new THREE.Mesh(geometry, material); +} + +// global scene cache to look them up for dynamic operations in Makie +// e.g. insert!(scene, plot) / delete!(scene, plot) +const scene_cache = {}; +const plot_cache = {}; +const TEXTURE_ATLAS = [undefined]; + +function add_scene(scene_id, three_scene) { + scene_cache[scene_id] = three_scene; +} + +export function find_scene(scene_id) { + return scene_cache[scene_id]; +} + +export function delete_scene(scene_id) { + const scene = scene_cache[scene_id]; + if (!scene) { + return; + } + while (scene.children.length > 0) { + scene.remove(scene.children[0]); + } + delete scene_cache[scene_id]; +} + +export function find_plots(plot_uuids) { + const plots = []; + plot_uuids.forEach((id) => { + const plot = plot_cache[id]; + if (plot) { + plots.push(plot); + } + }); + return plots; +} + +export function delete_scenes(scene_uuids, plot_uuids) { + plot_uuids.forEach((plot_id) => { + delete plot_cache[plot_id]; + }); + scene_uuids.forEach((scene_id) => { + delete_scene(scene_id); + }); +} + +export function insert_plot(scene_id, plot_data) { + const scene = find_scene(scene_id); + plot_data.forEach((plot) => { + add_plot(scene, plot); + }); +} + +export function delete_plots(scene_id, plot_uuids) { + console.log(`deleting plots!: ${plot_uuids}`); + const scene = find_scene(scene_id); + const plots = find_plots(plot_uuids); + plots.forEach((p) => { + scene.remove(p); + delete plot_cache[p]; + }); +} + +function convert_texture(data) { + const tex = create_texture(data); + tex.needsUpdate = true; + tex.minFilter = THREE[data.minFilter]; + tex.magFilter = THREE[data.magFilter]; + tex.anisotropy = data.anisotropy; + tex.wrapS = THREE[data.wrapS]; + if (data.size.length > 1) { + tex.wrapT = THREE[data.wrapT]; + } + if (data.size.length > 2) { + tex.wrapR = THREE[data.wrapR]; + } + return tex; +} + +function is_three_fixed_array(value) { + return ( + value instanceof THREE.Vector2 || + value instanceof THREE.Vector3 || + value instanceof THREE.Vector4 || + value instanceof THREE.Matrix4 + ); +} + +function to_uniform(data) { + if (data.type !== undefined) { + if (data.type == "Sampler") { + return convert_texture(data); + } + throw new Error(`Type ${data.type} not known`); + } + if (Array.isArray(data) || ArrayBuffer.isView(data)) { + if (!data.every((x) => typeof x === "number")) { + // if not all numbers, we just leave it + return data; + } + // else, we convert it to THREE vector/matrix types + if (data.length == 2) { + return new THREE.Vector2().fromArray(data); + } + if (data.length == 3) { + return new THREE.Vector3().fromArray(data); + } + if (data.length == 4) { + return new THREE.Vector4().fromArray(data); + } + if (data.length == 16) { + const mat = new THREE.Matrix4(); + mat.fromArray(data); + return mat; + } + } + // else, leave unchanged + return data; +} + +function deserialize_uniforms(data) { + const result = {}; + // Deno may change constructor names..so... + + for (const name in data) { + const value = data[name]; + // this is already a uniform - happens when we attach additional + // uniforms like the camera matrices in a later stage! + if (value instanceof THREE.Uniform) { + // nothing needs to be converted + result[name] = value; + } else { + const ser = to_uniform(value); + result[name] = new THREE.Uniform(ser); + } + } + return result; +} + +export function deserialize_plot(data) { + if (data.plot_type === "lines") { + return create_line(data); + } + let mesh; + if ("instance_attributes" in data) { + mesh = create_instanced_mesh(data); + } else { + mesh = create_mesh(data); + } + mesh.name = data.name; + mesh.frustumCulled = false; + mesh.matrixAutoUpdate = false; + mesh.plot_uuid = data.uuid; + const update_visible = (v) => { + mesh.visible = v; + // don't return anything, since that will disable on_update callback + return; + }; + update_visible(data.visible.value); + data.visible.on(update_visible); + connect_uniforms(mesh, data.uniform_updater); + connect_attributes(mesh, data.attribute_updater); + return mesh; +} + +const ON_NEXT_INSERT = new Set(); + +export function on_next_insert(f) { + ON_NEXT_INSERT.add(f); +} + +export function add_plot(scene, plot_data) { + // fill in the camera uniforms, that we don't sent in serialization per plot + const cam = scene.wgl_camera; + const identity = new THREE.Uniform(new THREE.Matrix4()); + if (plot_data.cam_space == "data") { + plot_data.uniforms.view = cam.view; + plot_data.uniforms.projection = cam.projection; + plot_data.uniforms.projectionview = cam.projectionview; + plot_data.uniforms.eyeposition = cam.eyeposition; + } else if (plot_data.cam_space == "pixel") { + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = cam.pixel_space; + plot_data.uniforms.projectionview = cam.pixel_space; + } else if (plot_data.cam_space == "relative") { + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = cam.relative_space; + plot_data.uniforms.projectionview = cam.relative_space; + } else { + // clip space + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = identity; + plot_data.uniforms.projectionview = identity; + } + + plot_data.uniforms.resolution = cam.resolution; + + if (plot_data.uniforms.preprojection) { + const { space, markerspace } = plot_data; + plot_data.uniforms.preprojection = cam.preprojection_matrix( + space.value, + markerspace.value + ); + } + const p = deserialize_plot(plot_data); + plot_cache[plot_data.uuid] = p; + scene.add(p); + // execute all next insert callbacks + const next_insert = new Set(ON_NEXT_INSERT); // copy + next_insert.forEach((f) => f()); +} + +function connect_uniforms(mesh, updater) { + updater.on(([name, data]) => { + // this is the initial value, which shouldn't end up getting updated - + // TODO, figure out why this gets pushed!! + if (name === "none") { + return; + } + const uniform = mesh.material.uniforms[name]; + if (uniform.value.isTexture) { + const im_data = uniform.value.image; + const [size, tex_data] = data; + if (tex_data.length == im_data.data.length) { + im_data.data.set(tex_data); + } else { + const old_texture = uniform.value; + uniform.value = re_create_texture(old_texture, tex_data, size); + old_texture.dispose(); + } + uniform.value.needsUpdate = true; + } else { + if (is_three_fixed_array(uniform.value)) { + uniform.value.fromArray(data); + } else { + uniform.value = data; + } + } + }); +} + +function create_texture(data) { + const buffer = data.data; + if (data.size.length == 3) { + const tex = new THREE.DataTexture3D( + buffer, + data.size[0], + data.size[1], + data.size[2] + ); + tex.format = THREE[data.three_format]; + tex.type = THREE[data.three_type]; + return tex; + } else { + // a little optimization to not send the texture atlas over & over again + const tex_data = + buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; + return new THREE.DataTexture( + tex_data, + data.size[0], + data.size[1], + THREE[data.three_format], + THREE[data.three_type] + ); + } +} + +function re_create_texture(old_texture, buffer, size) { + if (size.length == 3) { + const tex = new THREE.DataTexture3D(buffer, size[0], size[1], size[2]); + tex.format = old_texture.format; + tex.type = old_texture.type; + return tex; + } else { + return new THREE.DataTexture( + buffer, + size[0], + size[1] ? size[1] : 1, + old_texture.format, + old_texture.type + ); + } +} +function BufferAttribute(buffer) { + const jsbuff = new THREE.BufferAttribute(buffer.flat, buffer.type_length); + jsbuff.setUsage(THREE.DynamicDrawUsage); + return jsbuff; +} + +function InstanceBufferAttribute(buffer) { + const jsbuff = new THREE.InstancedBufferAttribute( + buffer.flat, + buffer.type_length + ); + jsbuff.setUsage(THREE.DynamicDrawUsage); + return jsbuff; +} + +function attach_geometry(buffer_geometry, vertexarrays, faces) { + for (const name in vertexarrays) { + const buff = vertexarrays[name]; + let buffer; + if (buff.to_update) { + buffer = new THREE.BufferAttribute(buff.to_update, buff.itemSize); + } else { + buffer = BufferAttribute(buff); + } + buffer_geometry.setAttribute(name, buffer); + } + buffer_geometry.setIndex(faces); + buffer_geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + buffer_geometry.boundingSphere.radius = 10000000000000; + buffer_geometry.frustumCulled = false; + return buffer_geometry; +} + +function attach_instanced_geometry(buffer_geometry, instance_attributes) { + for (const name in instance_attributes) { + const buffer = InstanceBufferAttribute(instance_attributes[name]); + buffer_geometry.setAttribute(name, buffer); + } +} + +function recreate_geometry(mesh, vertexarrays, faces) { + const buffer_geometry = new THREE.BufferGeometry(); + attach_geometry(buffer_geometry, vertexarrays, faces); + mesh.geometry.dispose(); + mesh.geometry = buffer_geometry; + mesh.needsUpdate = true; +} + +function recreate_instanced_geometry(mesh) { + const buffer_geometry = new THREE.InstancedBufferGeometry(); + const vertexarrays = {}; + const instance_attributes = {}; + const faces = [...mesh.geometry.index.array]; + Object.keys(mesh.geometry.attributes).forEach((name) => { + const buffer = mesh.geometry.attributes[name]; + // really dont know why copying an array is considered rocket science in JS + const copy = buffer.to_update + ? buffer.to_update + : buffer.array.map((x) => x); + if (buffer.isInstancedBufferAttribute) { + instance_attributes[name] = { + flat: copy, + type_length: buffer.itemSize, + }; + } else { + vertexarrays[name] = { + flat: copy, + type_length: buffer.itemSize, + }; + } + }); + attach_geometry(buffer_geometry, vertexarrays, faces); + attach_instanced_geometry(buffer_geometry, instance_attributes); + mesh.geometry.dispose(); + mesh.geometry = buffer_geometry; + mesh.needsUpdate = true; +} + +function create_material(program) { + const is_volume = "volumedata" in program.uniforms; + return new THREE.RawShaderMaterial({ + uniforms: deserialize_uniforms(program.uniforms), + vertexShader: program.vertex_source, + fragmentShader: program.fragment_source, + side: is_volume ? THREE.BackSide : THREE.DoubleSide, + transparent: true, + depthTest: !program.overdraw.value, + depthWrite: !program.transparency.value, + }); +} + +function create_mesh(program) { + const buffer_geometry = new THREE.BufferGeometry(); + const faces = new THREE.BufferAttribute(program.faces.value, 1); + attach_geometry(buffer_geometry, program.vertexarrays, faces); + const material = create_material(program); + const mesh = new THREE.Mesh(buffer_geometry, material); + program.faces.on((x) => { + mesh.geometry.setIndex(new THREE.BufferAttribute(x, 1)); + }); + return mesh; +} + +function create_instanced_mesh(program) { + const buffer_geometry = new THREE.InstancedBufferGeometry(); + const faces = new THREE.BufferAttribute(program.faces.value, 1); + attach_geometry(buffer_geometry, program.vertexarrays, faces); + attach_instanced_geometry(buffer_geometry, program.instance_attributes); + const material = create_material(program); + const mesh = new THREE.Mesh(buffer_geometry, material); + program.faces.on((x) => { + mesh.geometry.setIndex(new THREE.BufferAttribute(x, 1)); + }); + return mesh; +} + +function first(x) { + return x[Object.keys(x)[0]]; +} + +function connect_attributes(mesh, updater) { + const instance_buffers = {}; + const geometry_buffers = {}; + let first_instance_buffer; + const real_instance_length = [0]; + let first_geometry_buffer; + const real_geometry_length = [0]; + + function re_assign_buffers() { + const attributes = mesh.geometry.attributes; + Object.keys(attributes).forEach((name) => { + const buffer = attributes[name]; + if (buffer.isInstancedBufferAttribute) { + instance_buffers[name] = buffer; + } else { + geometry_buffers[name] = buffer; + } + }); + first_instance_buffer = first(instance_buffers); + // not all meshes have instances! + if (first_instance_buffer) { + real_instance_length[0] = first_instance_buffer.count; + } + first_geometry_buffer = first(geometry_buffers); + real_geometry_length[0] = first_geometry_buffer.count; + } + + re_assign_buffers(); + + updater.on(([name, new_values, length]) => { + const buffer = mesh.geometry.attributes[name]; + let buffers; + let first_buffer; + let real_length; + let is_instance = false; + // First, we need to figure out if this is an instance / geometry buffer + if (name in instance_buffers) { + buffers = instance_buffers; + first_buffer = first_instance_buffer; + real_length = real_instance_length; + is_instance = true; + } else { + buffers = geometry_buffers; + first_buffer = first_geometry_buffer; + real_length = real_geometry_length; + } + if (length <= real_length[0]) { + // this is simple - we can just update the values + buffer.set(new_values); + buffer.needsUpdate = true; + if (is_instance) { + mesh.geometry.instanceCount = length; + } + } else { + // resizing is a bit more complex + // first we directly overwrite the array - this + // won't have any effect, but like this we can collect the + // newly sized arrays untill all of them have the same length + buffer.to_update = new_values; + const all_have_same_length = Object.values(buffers).every( + (x) => x.to_update && x.to_update.length / x.itemSize == length + ); + if (all_have_same_length) { + if (is_instance) { + recreate_instanced_geometry(mesh); + // we just replaced geometry & all buffers, so we need to update these + re_assign_buffers(); + mesh.geometry.instanceCount = + new_values.length / buffer.itemSize; + } else { + recreate_geometry(mesh, buffers, mesh.geometry.index); + re_assign_buffers(); + } + } + } + }); +} + +export function deserialize_scene(data, screen) { + const scene = new THREE.Scene(); + scene.screen = screen; + const { canvas } = screen; + add_scene(data.uuid, scene); + scene.scene_uuid = data.uuid; + scene.frustumCulled = false; + scene.pixelarea = data.pixelarea; + scene.backgroundcolor = data.backgroundcolor; + scene.clearscene = data.clearscene; + scene.visible = data.visible; + + const camera = new Camera.MakieCamera(); + + scene.wgl_camera = camera; + + function update_cam(camera_matrices) { + const [view, projection, resolution, eyepos] = camera_matrices; + camera.update_matrices(view, projection, resolution, eyepos); + } + + update_cam(data.camera.value); + + if (data.cam3d_state) { + Camera.attach_3d_camera(canvas, camera, data.cam3d_state, scene); + } else { + data.camera.on(update_cam); + } + data.plots.forEach((plot_data) => { + add_plot(scene, plot_data); + }); + scene.scene_children = data.children.map((child) => + deserialize_scene(child, screen) + ); + return scene; +} + +export function delete_plot(plot) { + delete plot_cache[plot.plot_uuid]; + const { parent } = plot; + if (parent) { + parent.remove(plot); + } + plot.geometry.dispose(); + plot.material.dispose(); +} + +export function delete_three_scene(scene) { + delete scene_cache[scene.scene_uuid]; + scene.scene_children.forEach(delete_three_scene); + while (scene.children.length > 0) { + delete_plot(scene.children[0]); + } +} + +export { TEXTURE_ATLAS, scene_cache, plot_cache }; diff --git a/WGLMakie/src/experiment.vert b/WGLMakie/src/experiment.vert new file mode 100644 index 00000000000..c608137e093 --- /dev/null +++ b/WGLMakie/src/experiment.vert @@ -0,0 +1,328 @@ +#version 300 es +precision highp float; +const float BEVEL = 4.0f; +const float MITER = 8.0f; +const float ROUND = 12.0f; +const float JOINT_CAP_BUTT = 16.0f; +const float JOINT_CAP_SQUARE = 18.0f; +const float JOINT_CAP_ROUND = 20.0f; + +const float CAP_BUTT = 1.0f; +const float CAP_SQUARE = 2.0f; +const float CAP_ROUND = 3.0f; + +// === geom === +in vec2 linepoint_prev; +in vec2 linepoint_start; +in vec2 linepoint_end; +in vec2 linepoint_next; +in float vertexNum; + +uniform mat4 projectionview; +uniform mat4 model; + +// out vec4 vDistance; +// out vec4 vArc; +out float vType; +out vec4 f_color; + +uniform float resolution; +uniform vec4 color_start; // end of previous segment, start of current segment +uniform vec4 color_end; // end of current segment, start of next segment + +#define scaleMode 1.0; +#define miterLimit -0.4 +#define AA_THICKNESS 1.0f; + +vec2 doBisect( + vec2 norm, + float len, + vec2 norm2, + float len2, + float dy, + float inner +) { + vec2 bisect = (norm + norm2) / 2.0f; + bisect /= dot(norm, bisect); + vec2 shift = dy * bisect; + if (inner > 0.5f) { + if (len < len2) { + if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { + return dy * norm; + } + } else { + if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { + return dy * norm; + } + } + } + return dy * bisect; +} + +void main(void) { + f_color = color_start; + vec2 pointA = (model * vec4(linepoint_start, 0.0, 1.0f)).xy; + vec2 pointB = (model * vec4(linepoint_end, 0.0, 1.0f)).xy; + + vec2 xBasis = pointB - pointA; + float len = length(xBasis); + vec2 forward = xBasis / len; + vec2 norm = vec2(forward.y, -forward.x); + + float type = 8.0; + + float lineWidth = styleLine.x; + if (scaleMode > 2.5f) { + lineWidth *= length(model * vec3(1.0f, 0.0f, 0.0f)); + } else if (scaleMode > 1.5f) { + lineWidth *= length(model * vec3(0.0f, 1.0f, 0.0f)); + } else if (scaleMode > 0.5f) { + vec2 avgDiag = (model * vec3(1.0f, 1.0f, 0.0f)).xy; + lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5f); + } + float capType = floor(type / 32.0f); + type -= capType * 32.0f; + vArc = vec4(0.0f); + lineWidth *= 0.5f; + float lineAlignment = 2.0f * styleLine.y - 1.0f; + + vec2 pos; + + if (capType == CAP_ROUND) { + if (vertexNum < 3.5f) { + gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f); + return; + } + type = JOINT_CAP_ROUND; + capType = 0.0f; + } + + if (type >= BEVEL) { + float dy = lineWidth + AA_THICKNESS; + float inner = 0.0f; + if (vertexNum >= 1.5f) { + dy = -dy; + inner = 1.0f; + } + + vec2 base, next, xBasis2, bisect; + float flag = 0.0f; + float sign2 = 1.0f; + if (vertexNum < 0.5f || vertexNum > 2.5f && vertexNum < 3.5f) { + next = (model * vec3(linepoint_prev, 1.0f)).xy; + base = pointA; + flag = type - floor(type / 2.0f) * 2.0f; + sign2 = -1.0f; + } else { + next = (model * vec3(linepoint_next, 1.0f)).xy; + base = pointB; + if (type >= MITER && type < MITER + 3.5f) { + flag = step(MITER + 1.5f, type); + // check miter limit here? + } + } + xBasis2 = next - base; + float len2 = length(xBasis2); + vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; + float D = norm.x * norm2.y - norm.y * norm2.x; + if (D < 0.0f) { + inner = 1.0f - inner; + } + + norm2 *= sign2; + + if (abs(lineAlignment) > 0.01f) { + float shift = lineWidth * lineAlignment; + pointA += norm * shift; + pointB += norm * shift; + if (abs(D) < 0.01f) { + base += norm * shift; + } else { + base += doBisect(norm, len, norm2, len2, shift, 0.0f); + } + } + + float collinear = step(0.0f, dot(norm, norm2)); + + vType = 0.0f; + float dy2 = -1000.0f; + float dy3 = -1000.0f; + + if (abs(D) < 0.01f && collinear < 0.5f) { + if (type >= ROUND && type < ROUND + 1.5f) { + type = JOINT_CAP_ROUND; + } + //TODO: BUTT here too + } + + if (vertexNum < 3.5f) { + if (abs(D) < 0.01f) { + pos = dy * norm; + } else { + if (flag < 0.5f && inner < 0.5f) { + pos = dy * norm; + } else { + pos = doBisect(norm, len, norm2, len2, dy, inner); + } + } + if (capType >= CAP_BUTT && capType < CAP_ROUND) { + float extra = step(CAP_SQUARE, capType) * lineWidth; + vec2 back = -forward; + if (vertexNum < 0.5f || vertexNum > 2.5f) { + pos += back * (AA_THICKNESS + extra); + dy2 = AA_THICKNESS; + } else { + dy2 = dot(pos + base - pointA, back) - extra; + } + } + if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5f) { + float extra = step(JOINT_CAP_SQUARE, type) * lineWidth; + if (vertexNum < 0.5f || vertexNum > 2.5f) { + dy3 = dot(pos + base - pointB, forward) - extra; + } else { + pos += forward * (AA_THICKNESS + extra); + dy3 = AA_THICKNESS; + if (capType >= CAP_BUTT) { + dy2 -= AA_THICKNESS + extra; + } + } + } + } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5f) { + if (inner > 0.5f) { + dy = -dy; + inner = 0.0f; + } + vec2 d2 = abs(dy) * forward; + if (vertexNum < 4.5f) { + dy = -dy; + pos = dy * norm; + } else if (vertexNum < 5.5f) { + pos = dy * norm; + } else if (vertexNum < 6.5f) { + pos = dy * norm + d2; + vArc.x = abs(dy); + } else { + dy = -dy; + pos = dy * norm + d2; + vArc.x = abs(dy); + } + dy2 = 0.0f; + vArc.y = dy; + vArc.z = 0.0f; + vArc.w = lineWidth; + vType = 3.0f; + } else if (abs(D) < 0.01f) { + pos = dy * norm; + } else { + if (type >= ROUND && type < ROUND + 1.5f) { + if (inner > 0.5f) { + dy = -dy; + inner = 0.0f; + } + if (vertexNum < 4.5f) { + pos = doBisect(norm, len, norm2, len2, -dy, 1.0f); + } else if (vertexNum < 5.5f) { + pos = dy * norm; + } else if (vertexNum > 7.5f) { + pos = dy * norm2; + } else { + pos = doBisect(norm, len, norm2, len2, dy, 0.0f); + float d2 = abs(dy); + if (length(pos) > abs(dy) * 1.5f) { + if (vertexNum < 6.5f) { + pos.x = dy * norm.x - d2 * norm.y; + pos.y = dy * norm.y + d2 * norm.x; + } else { + pos.x = dy * norm2.x + d2 * norm2.y; + pos.y = dy * norm2.y - d2 * norm2.x; + } + } + } + vec2 norm3 = normalize(norm + norm2); + + float sign = step(0.0f, dy) * 2.0f - 1.0f; + vArc.x = sign * dot(pos, norm3); + vArc.y = pos.x * norm3.y - pos.y * norm3.x; + vArc.z = dot(norm, norm3) * lineWidth; + vArc.w = lineWidth; + + dy = -sign * dot(pos, norm); + dy2 = -sign * dot(pos, norm2); + dy3 = vArc.z - vArc.x; + vType = 3.0f; + } else { + float hit = 0.0f; + if (type >= BEVEL && type < BEVEL + 1.5f) { + if (dot(norm, norm2) > 0.0f) { + type = MITER; + } + } + + if (type >= MITER && type < MITER + 3.5f) { + if (inner > 0.5f) { + dy = -dy; + inner = 0.0f; + } + float sign = step(0.0f, dy) * 2.0f - 1.0f; + pos = doBisect(norm, len, norm2, len2, dy, 0.0f); + if (length(pos) > abs(dy) * miterLimit) { + type = BEVEL; + } else { + if (vertexNum < 4.5f) { + dy = -dy; + pos = doBisect(norm, len, norm2, len2, dy, 1.0f); + } else if (vertexNum < 5.5f) { + pos = dy * norm; + } else if (vertexNum > 6.5f) { + pos = dy * norm2; + } + vType = 1.0f; + dy = -sign * dot(pos, norm); + dy2 = -sign * dot(pos, norm2); + hit = 1.0f; + } + } + if (type >= BEVEL && type < BEVEL + 1.5f) { + if (inner > 0.5f) { + dy = -dy; + inner = 0.0f; + } + float d2 = abs(dy); + vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); + vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); + if (vertexNum < 4.5f) { + pos = doBisect(norm, len, norm2, len2, -dy, 1.0f); + } else if (vertexNum < 5.5f) { + pos = dy * norm; + } else if (vertexNum > 7.5f) { + pos = dy * norm2; + } else { + if (vertexNum < 6.5f) { + pos = pos3; + } else { + pos = pos4; + } + } + vec2 norm3 = normalize(norm + norm2); + float sign = step(0.0f, dy) * 2.0f - 1.0f; + + dy = -sign * dot(pos, norm); + dy2 = -sign * dot(pos, norm2); + dy3 = (-sign * dot(pos, norm3)) + lineWidth; + vType = 4.0f; + hit = 1.0f; + } + if (hit < 0.5f) { + gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f); + return; + } + } + } + + pos += base; + // vDistance = vec4(dy, dy2, dy3, lineWidth) * resolution; + // vArc = vArc * resolution; + } + + gl_Position = vec4((projectionview * vec4(pos, 0.0, 1.0f)).xy, 0.0f, 1.0f); +} diff --git a/WGLMakie/src/lines-class.js b/WGLMakie/src/lines-class.js new file mode 100644 index 00000000000..38b3f2ed5c6 --- /dev/null +++ b/WGLMakie/src/lines-class.js @@ -0,0 +1,254 @@ + +function get_point(array, index, ndim) { + if (ndim === 2) { + return new Three.Point2(array[index], array[index + 1]); + } +} + +/** + * + * @param vertices: Array + * @param join: string + * @param cap: string + * @param miterLimit: number + * @param roundLimit: number + * @returns + */ +function addLine(vertices, join, cap, miterLimit, roundLimit) { + + this.distance = 0; + this.scaledDistance = 0; + this.totalDistance = 0; + this.lineSoFar = 0; + + // If the line has duplicate vertices at the ends, adjust start/length to remove them. + let len = vertices.length; + + while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) { + len--; + } + let first = 0; + while (first < len - 1 && vertices[first].equals(vertices[first + 1])) { + first++; + } + + // Ignore invalid geometry. + if (len < 2) return; + + if (join === 'bevel') miterLimit = 1.05; + + const sharpCornerOffset = this.overscaling <= 16 ? + SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) : + 0; + + // we could be more precise, but it would only save a negligible amount of space + const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray); + + let currentVertex; + let prevVertex; + let nextVertex; + let prevNormal; + let nextNormal; + + // the last two vertices added + this.e1 = this.e2 = -1; + const ndim = 2; + + for (let i = first; i < len; i++) { + + nextVertex = i === len - 1 ? undefined : get_point(vertices, i + 1, ndim); // just the next vertex + + // if two consecutive vertices exist, skip the current one + if (nextVertex && vertices[i].equals(nextVertex)) continue; + + if (nextNormal) prevNormal = nextNormal; + if (currentVertex) prevVertex = currentVertex; + + currentVertex = get_point(vertices, i, ndim); + + // Calculate the normal towards the next vertex in this line. In case + // there is no next vertex, pretend that the line is continuing straight, + // meaning that we are just using the previous normal. + nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal; + + // If we still don't have a previous normal, this is the beginning of a + // non-closed line, so we're doing a straight "join". + prevNormal = prevNormal || nextNormal; + + // Determine the normal of the join extrusion. It is the angle bisector + // of the segments between the previous line and the next line. + // In the case of 180° angles, the prev and next normals cancel each other out: + // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be + // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle + // below will also become 0 and miterLength will become Infinity. + let joinNormal = prevNormal.add(nextNormal); + + if (joinNormal.x !== 0 || joinNormal.y !== 0) { + joinNormal._unit(); + } + /* joinNormal prevNormal + * ↖ ↑ + * .________. prevVertex + * | + * nextNormal ← | currentVertex + * | + * nextVertex ! + * + */ + + // calculate cosines of the angle (and its half) using dot product + const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y; + const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y; + + // Calculate the length of the miter (the ratio of the miter to the width) + // as the inverse of cosine of the angle between next and join normals + const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity; + + // approximate angle from cosine + const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle); + + const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex; + const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0; + + if (isSharpCorner && i > first) { + const prevSegmentLength = currentVertex.dist(prevVertex); + if (prevSegmentLength > 2 * sharpCornerOffset) { + const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round()); + this.updateDistance(prevVertex, newPrevVertex); + this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment); + prevVertex = newPrevVertex; + } + } + + // The join if a middle vertex, otherwise the cap. + const middleVertex = prevVertex && nextVertex; + let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap; + + if (middleVertex && currentJoin === 'round') { + if (miterLength < roundLimit) { + currentJoin = 'miter'; + } else if (miterLength <= 2) { + currentJoin = 'fakeround'; + } + } + + if (currentJoin === 'miter' && miterLength > miterLimit) { + currentJoin = 'bevel'; + } + + if (currentJoin === 'bevel') { + // The maximum extrude length is 128 / 63 = 2 times the width of the line + // so if miterLength >= 2 we need to draw a different type of bevel here. + if (miterLength > 2) currentJoin = 'flipbevel'; + + // If the miterLength is really small and the line bevel wouldn't be visible, + // just draw a miter join to save a triangle. + if (miterLength < miterLimit) currentJoin = 'miter'; + } + + // Calculate how far along the line the currentVertex is + if (prevVertex) this.updateDistance(prevVertex, currentVertex); + + if (currentJoin === 'miter') { + + joinNormal._mult(miterLength); + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + + } else if (currentJoin === 'flipbevel') { + // miter is too big, flip the direction to make a beveled join + + if (miterLength > 100) { + // Almost parallel lines + joinNormal = nextNormal.mult(-1); + + } else { + const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag(); + joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1)); + } + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment); + + } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') { + const offset = -Math.sqrt(miterLength * miterLength - 1); + const offsetA = lineTurnsLeft ? offset : 0; + const offsetB = lineTurnsLeft ? 0 : offset; + + // Close previous segment with a bevel + if (prevVertex) { + this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment); + } + + if (currentJoin === 'fakeround') { + // The join angle is sharp enough that a round join would be visible. + // Bevel joins fill the gap between segments with a single pie slice triangle. + // Create a round join by adding multiple pie slices. The join isn't actually round, but + // it looks like it is at the sizes we render lines at. + + // pick the number of triangles for approximating round join by based on the angle between normals + const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE); + + for (let m = 1; m < n; m++) { + let t = m / n; + if (t !== 0.5) { + // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp + const t2 = t - 0.5; + const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519)); + const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638); + t = t + t * t2 * (t - 1) * (A * t2 * t2 + B); + } + const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1); + this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment); + } + } + + if (nextVertex) { + // Start next segment + this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment); + } + + } else if (currentJoin === 'butt') { + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap + + } else if (currentJoin === 'square') { + const offset = prevVertex ? 1 : -1; // closing or starting square cap + + if (!prevVertex) { + this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); + } + + // make the cap it's own quad to avoid the cap affecting the line distance + this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); + + if (prevVertex) { + this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); + } + + } else if (currentJoin === 'round') { + + if (prevVertex) { + // Close previous segment with butt + this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment); + + // Add round cap or linejoin at end of segment + this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true); + } + if (nextVertex) { + // Add round cap before first segment + this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true); + + // Start next segment with a butt + this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment); + } + } + + if (isSharpCorner && i < len - 1) { + const nextSegmentLength = currentVertex.dist(nextVertex); + if (nextSegmentLength > 2 * sharpCornerOffset) { + const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round()); + this.updateDistance(currentVertex, newCurrentVertex); + this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment); + currentVertex = newCurrentVertex; + } + } + } +} diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 14dad3103ec..d8ec6eefc8c 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -1,16 +1,20 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) + uniforms = Dict( - :opacity => 1.0, - :linewidth => plot.linewidth[], - :diffuse => Vec3f(0, 0, 0), - :model => plot.model + # :linewidth => plot.linewidth[], + :pattern_length => 1f0, + :model => plot.model, + :is_valid => Vec4f(1), + :thickness_start => plot.linewidth[], + :thickness_end => plot.linewidth[] ) color = to_color(plot.color[]) - if color isa Colorant - uniforms[:color] = serialize_three(color) - else - uniforms[:color] = serialize_three(to_color(:black)) - end + + c = color isa Colorant ? serialize_three(color) : serialize_three(RGBAf(0, 0, 0, 1)) + + uniforms[:color_start] = c + uniforms[:color_end] = c + attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, @@ -18,9 +22,8 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :plot_type => :lines, :cam_space => plot.space[], :is_linesegments => plot isa LineSegments, - :positions => collect(reinterpret(Float32, plot[1][])), - :uniforms => serialize_uniforms(uniforms) + :positions => lift(x-> collect(reinterpret(Float32, x)), plot[1]), + :uniforms => serialize_uniforms(uniforms), ) - return attr end diff --git a/WGLMakie/src/mapbox-lines.vert b/WGLMakie/src/mapbox-lines.vert new file mode 100644 index 00000000000..d2912bc4d67 --- /dev/null +++ b/WGLMakie/src/mapbox-lines.vert @@ -0,0 +1,74 @@ +#version 300 es +precision highp float; +// floor(127 / 2) == 63.0 +// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is +// stored in a byte (-128..127). we scale regular normals up to length 63, but +// there are also "special" normals that have a bigger length (of up to 126 in +// this case). +// #define scale 63.0 +#define EXTRUDE_SCALE 0.015873016 + +in vec2 a_pos_normal; +in vec4 a_data; + +uniform mat4 u_matrix; +uniform mat2 u_pixels_to_tile_units; +uniform vec2 u_units_to_pixels; +uniform lowp float u_device_pixel_ratio; + +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; + +lowp float floorwidth = 1.0; +mediump float gapwidth = 0.0; +lowp float offset = 0.0; +float width = 1.0; + +void main() { + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; + + vec2 a_extrude = a_data.xy - 128.0; + float a_direction = mod(a_data.z, 4.0) - 1.0; + vec2 pos = floor(a_pos_normal * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + mediump vec2 normal = a_pos_normal - 2.0 * pos; + normal.y = normal.y * 2.0 - 1.0; + v_normal = normal; + + // these transformations used to be applied in the JS and native code bases. + // moved them into the shader for clarity and simplicity. + gapwidth = gapwidth / 2.0; + float halfwidth = width / 2.0; + offset = -1.0 * offset; + + float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width + // of this vertex. + mediump vec2 dist = outset * a_extrude * EXTRUDE_SCALE; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + mediump float u = 0.5 * a_direction; + mediump float t = 1.0 - abs(u); + mediump vec2 offset2 = offset * a_extrude * EXTRUDE_SCALE * normal.y * mat2(t, -u, u, t); + + vec4 projected_extrude = u_matrix * vec4(dist * u_pixels_to_tile_units, 0.0, 0.0); + gl_Position = u_matrix * vec4(pos + offset2 * u_pixels_to_tile_units, 0.0, 1.0) + projected_extrude; + + + v_gamma_scale = 1.0; + + v_width2 = vec2(outset, inset); + +} diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 5a8a73f6dd3..e7ed4305e11 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19797,100 +19797,145 @@ class MakieCamera { } const LINES_VERT = `#version 300 es precision mediump int; -precision mediump float; +precision highp float; precision mediump sampler2D; precision mediump sampler3D; -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master -in vec2 uv; -in vec3 position; -in vec2 instanceStart; -in vec2 instanceEnd; +in float position; -out vec2 vUv; +in vec2 linepoint_prev; // start of previous segment +in vec2 linepoint_start; // end of previous segment, start of current segment +in vec2 linepoint_end; // end of current segment, start of next segment +in vec2 linepoint_next; // end of next segment +uniform vec4 is_valid; // start of previous segment + +uniform vec4 color_start; // end of previous segment, start of current segment +uniform vec4 color_end; // end of current segment, start of next segment + +uniform float thickness_start; +uniform float thickness_end; + +uniform vec2 resolution; uniform mat4 projectionview; -uniform mat4 projection; uniform mat4 model; -uniform mat4 view; +uniform float pattern_length; -uniform float linewidth; -uniform vec2 resolution; +flat out vec2 f_uv_minmax; +out vec2 f_uv; +out vec4 f_color; +out float f_thickness; -vec4 screen_space(vec4 vertex) -{ - return vec4(vertex.xy * resolution, vertex.z, vertex.w) / vertex.w; -} +#define MITER_LIMIT -0.4 +#define AA_THICKNESS 4.0 -vec4 clip_space(vec4 screenspace) { - return vec4((screenspace.xy / resolution), screenspace.z, 1.0) * screenspace.w; +vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } -void main() { - - // camera space - vec4 start = projectionview * model * vec4(instanceStart, 0.0, 1.0); - vec4 end = projectionview * model * vec4(instanceEnd, 0.0, 1.0); - vUv = uv; +void emit_vertex(vec3 position, vec2 uv, bool is_start) { - // screenspace - vec4 ndcStart = screen_space(start); - vec4 ndcEnd = screen_space(end); + f_uv = uv; + f_color = is_start ? color_start : color_end; - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? thickness_start : thickness_end; +} - // account for clip-space aspect ratio +void main() { + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec2 dir = p1.xy - p2.xy; dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (thickness_start / 2.0); - vec2 offset = vec2(dir.y, -dir.x); // orthogonal vector - - // sign flip - if (position.x < 0.0) - offset *= -1.0; - - // endcaps - if (position.y < 0.0) { - offset += -dir; - } else if (position.y > 1.0) { - offset += dir; + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; + } + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), true); + return; + } + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; } - // adjust for linewidth - offset *= linewidth; - - - - // select end - vec4 screen = (position.y < 0.5) ? ndcStart : ndcEnd; - screen.xy += offset; - gl_Position = clip_space(screen); + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; + } + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; + } + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } } `; const LINES_FRAG = `#version 300 es precision mediump int; -precision mediump float; +precision highp float; precision mediump sampler2D; precision mediump sampler3D; +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; + +uniform float pattern_length; + out vec4 fragment_color; -uniform vec4 color; +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} -in vec2 vUv; +void main(){ + // vec4 color = vec4(f_color.rgb, 0.0); + // vec2 xy = f_uv; + // float alpha = aastep(0.0, xy.x); + // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); + // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); -void main() { + // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); - fragment_color = color; + fragment_color = f_color; } `; function create_line_material(uniforms) { - console.log(uniforms); return new mod.RawShaderMaterial({ uniforms: deserialize_uniforms(uniforms), vertexShader: LINES_VERT, @@ -19898,95 +19943,70 @@ function create_line_material(uniforms) { transparent: true }); } -function create_line_geometry(linepositions, linesegments) { - const length = linepositions.length; - let points; - if (linesegments) { - points = linepositions; +function linepoints2buffer(linepoints, is_linesegments) { + const N = linepoints.length; + if (is_linesegments) { + const N2 = linepoints.length + 4; + const points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + points.set(linepoints, 2); + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + return points; } else { - points = new Float32Array(2 * length); - for(let i = 0; i < length; i += 2){ - points[2 * i] = linepositions[i]; - points[2 * i + 1] = linepositions[i + 1]; - points[2 * i + 2] = linepositions[i + 2]; - points[2 * i + 3] = linepositions[i + 3]; - } - } - const geometry = new mod.InstancedBufferGeometry(); - const instance_positions = [ - -1, - 2, - 0, - 1, - 2, - 0, - -1, - 1, - 0, - 1, - 1, - 0, - -1, - 0, - 0, - 1, - 0, - 0, - -1, - -1, - 0, - 1, - -1, - 0 - ]; - const uvs = [ - -1, - 2, - 1, - 2, - -1, - 1, - 1, - 1, - -1, - -1, - 1, - -1, - -1, - -2, - 1, - -2 - ]; - const index = [ - 0, - 2, - 1, - 2, - 3, - 1, - 2, - 4, - 3, - 4, - 5, - 3, - 4, - 6, - 5, - 6, - 7, - 5 - ]; - geometry.setIndex(index); - geometry.setAttribute("position", new mod.Float32BufferAttribute(instance_positions, 3)); - geometry.setAttribute("uv", new mod.Float32BufferAttribute(uvs, 2)); + const N2 = linepoints.length * 2 + 4; + const points = new Float32Array(N2); + points[0] = linepoints[0]; + points[1] = linepoints[1]; + for(let i = 0; i < linepoints.length; i += 2){ + points[2 * i + 2] = linepoints[i]; + points[2 * i + 3] = linepoints[i + 1]; + points[2 * i + 4] = linepoints[i + 2]; + points[2 * i + 5] = linepoints[i + 3]; + } + points[N2 - 2] = linepoints[N - 2]; + points[N2 - 1] = linepoints[N - 1]; + return points; + } +} +function attach_instanced_line_geometry(geometry, points) { const instanceBuffer = new mod.InstancedInterleavedBuffer(points, 4, 1); - geometry.setAttribute("instanceStart", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 0)); - geometry.setAttribute("instanceEnd", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 2)); + geometry.setAttribute("linepoint_prev", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 0)); + geometry.setAttribute("linepoint_start", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 2)); + geometry.setAttribute("linepoint_end", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 4)); + geometry.setAttribute("linepoint_next", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 6)); + return instanceBuffer; +} +function create_line_geometry(linepoints, is_linesegments) { + function geometry_buffer() { + const geometry = new mod.InstancedBufferGeometry(); + const instance_positions = [ + 0, + 1, + 2, + 3, + 4, + 5 + ]; + geometry.setAttribute("position", new mod.Float32BufferAttribute(instance_positions, 1)); + return geometry; + } + const geometry = geometry_buffer(); + const points = linepoints2buffer(linepoints.value, is_linesegments); + const instanceBuffer = attach_instanced_line_geometry(geometry, points); + console.log(instanceBuffer); + linepoints.on((new_points)=>{ + const new_line_points = linepoints2buffer(new_points, is_linesegments); + instanceBuffer.updateRange.count = new_line_points.length; + instanceBuffer.set(new_line_points, 0); + instanceBuffer.needsUpdate = true; + geometry.instanceCount = (new_line_points.length - 4) / 4; + }); geometry.boundingSphere = new mod.Sphere(); geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; - geometry.instanceCount = points.length / 2; + geometry.instanceCount = (points.length - 4) / 4; return geometry; } function create_line(line_data) { @@ -20138,7 +20158,6 @@ function on_next_insert(f) { function add_plot(scene, plot_data) { const cam = scene.wgl_camera; const identity = new mod.Uniform(new mod.Matrix4()); - console.log(plot_data.cam_space); if (plot_data.cam_space == "data") { plot_data.uniforms.view = cam.view; plot_data.uniforms.projection = cam.projection; From 8c65189b7621b5e254f879964747d154c06d1d84 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 17 Jul 2023 20:19:38 +0200 Subject: [PATCH 06/28] start implementing 1 attribute per point --- WGLMakie/src/Serialization.js | 176 +++++++++++++++++----------------- WGLMakie/src/lines.jl | 13 +-- 2 files changed, 89 insertions(+), 100 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 30b4aff509a..ec6df6cc428 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -7,93 +7,97 @@ import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; // https://github.com/gameofbombs/pixi-candles/tree/master/src // https://github.com/wwwtyro/instanced-lines-demos/tree/master -const LINES_VERT = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -in float position; - -in vec2 linepoint_prev; // start of previous segment -in vec2 linepoint_start; // end of previous segment, start of current segment -in vec2 linepoint_end; // end of current segment, start of next segment -in vec2 linepoint_next; // end of next segment - -uniform vec4 is_valid; // start of previous segment - -uniform vec4 color_start; // end of previous segment, start of current segment -uniform vec4 color_end; // end of current segment, start of next segment - -uniform float thickness_start; -uniform float thickness_end; - -uniform vec2 resolution; -uniform mat4 projectionview; -uniform mat4 model; -uniform float pattern_length; - -out vec2 f_uv; -out vec4 f_color; -out float f_thickness; - -vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; -} - -void emit_vertex(vec3 position, vec2 uv, bool is_start) { +function lines_shader(positions, linewidth, colors) { + const position_type = glsl_type(positions); + const linewidth_type = glsl_type(linewidth); + const colors_type = glsl_type(colors); + + return `#version 300 es + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; + + in float position; + + ${position_type} linepoint_prev; // start of previous segment + ${position_type} linepoint_start; // end of previous segment, start of current segment + ${position_type} linepoint_end; // end of current segment, start of next segment + ${position_type} linepoint_next; // end of next segment + + ${colors_type} color_start; // end of previous segment, start of current segment + ${colors_type} color_end; // end of current segment, start of next segment + + ${linewidth_type} thickness_start; + ${linewidth_type} thickness_end; + + uniform vec2 resolution; + uniform mat4 projectionview; + uniform mat4 model; + uniform float pattern_length; + + out vec2 f_uv; + out vec4 f_color; + out float f_thickness; + + vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + } - f_uv = uv; + void emit_vertex(vec3 position, vec2 uv, bool is_start) { - f_color = is_start ? color_start : color_end; + f_uv = uv; - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? thickness_start : thickness_end; -} + f_color = is_start ? color_start : color_end; -void main() { - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (thickness_start / 2.0); + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? thickness_start : thickness_end; + } - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), true); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + void main() { + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec2 dir = p1.xy - p2.xy; + dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (thickness_start / 2.0); + + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; + } + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), true); + return; + } + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; + } + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; + } + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } + } + `; } -`; const LINES_FRAG = `#version 300 es precision mediump int; @@ -132,23 +136,15 @@ float aastep_scaled(float threshold1, float threshold2, float dist) { } void main(){ - // vec4 color = vec4(f_color.rgb, 0.0); - // vec2 xy = f_uv; - - // float alpha = aastep(0.0, xy.x); - // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); - // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); - - // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); fragment_color = f_color; } `; -function create_line_material(uniforms) { +function create_line_material(uniforms, positions, linewidth, colors) { return new THREE.RawShaderMaterial({ uniforms: deserialize_uniforms(uniforms), - vertexShader: LINES_VERT, + vertexShader: lines_shader(positions, linewidth, colors), fragmentShader: LINES_FRAG, transparent: true, }); diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index d8ec6eefc8c..ca75572288e 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -1,19 +1,12 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) - + Makie.@converted_attribute plot (linewidth, color) uniforms = Dict( - # :linewidth => plot.linewidth[], :pattern_length => 1f0, :model => plot.model, :is_valid => Vec4f(1), - :thickness_start => plot.linewidth[], - :thickness_end => plot.linewidth[] + :linewidth => linewidth, + :color => color ) - color = to_color(plot.color[]) - - c = color isa Colorant ? serialize_three(color) : serialize_three(RGBAf(0, 0, 0, 1)) - - uniforms[:color_start] = c - uniforms[:color_end] = c attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), From b262f2b9392ec4ec841eab9215de882b428997e4 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 17 Jul 2023 20:30:00 +0200 Subject: [PATCH 07/28] start implementing shader typing --- WGLMakie/src/Serialization.js | 42 ++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index ec6df6cc428..3b1ecde8c15 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -7,6 +7,32 @@ import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; // https://github.com/gameofbombs/pixi-candles/tree/master/src // https://github.com/wwwtyro/instanced-lines-demos/tree/master +function typedarray_to_vectype(typedArray, ndim) { + let glslType; + + if (typedArray instanceof Float32Array) { + glslType = "vec" + ndim; + } else if (typedArray instanceof Int32Array) { + glslType = "ivec" + ndim; + } else if (typedArray instanceof Uint32Array) { + glslType = "uvec" + ndim; + } else { + throw new Error("Unsupported TypedArray type."); + } + + return "in " + glslType; +} + +const isTypedArray = (obj) => ArrayBuffer.isView(obj); + +function glsl_type(obj) { + if (isTypedArray(obj.flat) && obj.type_length) { + return typedarray_to_vectype(obj.flat, obj.type_length); + } else { + return "uniform " + obj.type; + } +} + function lines_shader(positions, linewidth, colors) { const position_type = glsl_type(positions); const linewidth_type = glsl_type(linewidth); @@ -209,7 +235,7 @@ function create_line_geometry(linepoints, is_linesegments) { "position", new THREE.Float32BufferAttribute(instance_positions, 1) ); - return geometry + return geometry; } const geometry = geometry_buffer(); @@ -233,8 +259,8 @@ function create_line_geometry(linepoints, is_linesegments) { } geometry.instanceCount = (new_line_points.length - 4) / 4; - instanceBuffer.needsUpdate = true - }) + instanceBuffer.needsUpdate = true; + }); geometry.boundingSphere = new THREE.Sphere(); // don't use intersection / culling @@ -307,7 +333,7 @@ export function insert_plot(scene_id, plot_data) { } export function delete_plots(scene_id, plot_uuids) { - console.log(`deleting plots!: ${plot_uuids}`) + console.log(`deleting plots!: ${plot_uuids}`); const scene = find_scene(scene_id); const plots = find_plots(plot_uuids); plots.forEach((p) => { @@ -774,9 +800,9 @@ export function deserialize_scene(data, screen) { export function delete_plot(plot) { delete plot_cache[plot.plot_uuid]; - const {parent} = plot + const { parent } = plot; if (parent) { - parent.remove(plot) + parent.remove(plot); } plot.geometry.dispose(); plot.material.dispose(); @@ -785,8 +811,8 @@ export function delete_plot(plot) { export function delete_three_scene(scene) { delete scene_cache[scene.scene_uuid]; scene.scene_children.forEach(delete_three_scene); - while(scene.children.length > 0) { - delete_plot(scene.children[0]) + while (scene.children.length > 0) { + delete_plot(scene.children[0]); } } From baf7a5847129bff7216ef87a9f790b5d53aa2db6 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Wed, 2 Aug 2023 21:40:49 +0200 Subject: [PATCH 08/28] handle different ndims + attr per point --- WGLMakie/src/Serialization.js | 225 ++++++++++++---------- WGLMakie/src/lines.jl | 17 +- WGLMakie/src/wglmakie.bundled.js | 314 +++++++++++++++++-------------- 3 files changed, 319 insertions(+), 237 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 3b1ecde8c15..c0cf95395db 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -8,35 +8,68 @@ import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; // https://github.com/wwwtyro/instanced-lines-demos/tree/master function typedarray_to_vectype(typedArray, ndim) { - let glslType; - - if (typedArray instanceof Float32Array) { - glslType = "vec" + ndim; + if (ndim === 1) { + return "float"; + } else if (typedArray instanceof Float32Array) { + return "vec" + ndim; } else if (typedArray instanceof Int32Array) { - glslType = "ivec" + ndim; + return "ivec" + ndim; } else if (typedArray instanceof Uint32Array) { - glslType = "uvec" + ndim; + return "uvec" + ndim; } else { throw new Error("Unsupported TypedArray type."); } +} - return "in " + glslType; +function uniform_type(obj) { + if (obj instanceof THREE.Uniform) { + return uniform_type(obj.value); + } else if (typeof obj === "number") { + return "float"; + } else if (obj instanceof THREE.Vector2) { + return "vec2"; + } else if (obj instanceof THREE.Vector3) { + return "vec3"; + } else if (obj instanceof THREE.Vector4) { + return "vec4"; + } else if (obj instanceof THREE.Color) { + return "vec4"; + } else if (obj instanceof THREE.Matrix3) { + return "mat3"; + } else if (obj instanceof THREE.Matrix4) { + return "mat4"; + } else if (obj instanceof THREE.Texture) { + return "sampler2D"; + } else { + return "vec4"; + // throw new Error(`Unssupported uniform type: ${obj}`) + } } -const isTypedArray = (obj) => ArrayBuffer.isView(obj); +function uniforms_to_type_declaration(uniform_dict) { + let result = ""; + for (const name in uniform_dict) { + const uniform = uniform_dict[name]; + const type = uniform_type(uniform); + result += `uniform ${type} ${name};\n`; + } + return result; +} -function glsl_type(obj) { - if (isTypedArray(obj.flat) && obj.type_length) { - return typedarray_to_vectype(obj.flat, obj.type_length); - } else { - return "uniform " + obj.type; +function attributes_to_type_declaration(attributes_dict) { + let result = ""; + for (const name in attributes_dict) { + const attribute = attributes_dict[name]; + const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + result += `in ${type} ${name};\n`; } + return result; } -function lines_shader(positions, linewidth, colors) { - const position_type = glsl_type(positions); - const linewidth_type = glsl_type(linewidth); - const colors_type = glsl_type(colors); +function lines_shader(uniforms, attributes) { + console.log(attributes) + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); return `#version 300 es precision mediump int; @@ -44,23 +77,8 @@ function lines_shader(positions, linewidth, colors) { precision mediump sampler2D; precision mediump sampler3D; - in float position; - - ${position_type} linepoint_prev; // start of previous segment - ${position_type} linepoint_start; // end of previous segment, start of current segment - ${position_type} linepoint_end; // end of current segment, start of next segment - ${position_type} linepoint_next; // end of next segment - - ${colors_type} color_start; // end of previous segment, start of current segment - ${colors_type} color_end; // end of current segment, start of next segment - - ${linewidth_type} thickness_start; - ${linewidth_type} thickness_end; - - uniform vec2 resolution; - uniform mat4 projectionview; - uniform mat4 model; - uniform float pattern_length; + ${attribute_decl} + ${uniform_decl} out vec2 f_uv; out vec4 f_color; @@ -79,7 +97,7 @@ function lines_shader(positions, linewidth, colors) { gl_Position = vec4((position.xy / resolution), position.z, 1.0); // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? thickness_start : thickness_end; + f_thickness = is_start ? linewidth_start : linewidth_end; } void main() { @@ -88,7 +106,7 @@ function lines_shader(positions, linewidth, colors) { vec2 dir = p1.xy - p2.xy; dir = normalize(dir); vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (thickness_start / 2.0); + vec2 line_offset = line_normal * (linewidth_start / 2.0); // triangle 1 vec3 v0 = vec3(p1.xy - line_offset, p1.z); @@ -162,71 +180,70 @@ float aastep_scaled(float threshold1, float threshold2, float dist) { } void main(){ - fragment_color = f_color; } `; -function create_line_material(uniforms, positions, linewidth, colors) { +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); return new THREE.RawShaderMaterial({ - uniforms: deserialize_uniforms(uniforms), - vertexShader: lines_shader(positions, linewidth, colors), + uniforms: uniforms_des, + vertexShader: lines_shader(uniforms_des, attributes), fragmentShader: LINES_FRAG, transparent: true, }); } -function linepoints2buffer(linepoints, is_linesegments) { +function to_linepoint_array(linepoints, is_linesegments, ndims) { const N = linepoints.length; + const duplicate = is_linesegments ? 1 : 2; + const N2 = (linepoints.length * duplicate) + (ndims * 2); + const points = new Float32Array(N2); + // copy over first and last point + for (let i = 0; i < ndims; i++) { + points[i] = linepoints[i]; + } + for (let i = 1; i <= ndims; i++) { + points[N2 - i] = linepoints[N - i]; + } if (is_linesegments) { - const N2 = linepoints.length + 4; - const points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - points.set(linepoints, 2); - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - return points; + points.set(linepoints, ndims); } else { - const N2 = linepoints.length * 2 + 4; - const points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - for (let i = 0; i < linepoints.length; i += 2) { - points[2 * i + 2] = linepoints[i]; - points[2 * i + 3] = linepoints[i + 1]; - - points[2 * i + 4] = linepoints[i + 2]; - points[2 * i + 5] = linepoints[i + 3]; + for (let i = 0; i < N; i += 2) { + for (let j = 0; j < (2 * ndims); j++) { + points[(2 * i) + ndims + j] = linepoints[i + j]; + } } - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - return points; } + return points; } -function attach_instanced_line_geometry(geometry, points) { - const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xy1, xy2 +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { + const buffer = new THREE.InstancedInterleavedBuffer( + points, + ndim * 2, // xyz1, xyz2 + 1 + ); geometry.setAttribute( - "linepoint_prev", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) + attr_name + "_prev", + new THREE.InterleavedBufferAttribute(buffer, ndim, 0) ); // xyz1 geometry.setAttribute( - "linepoint_start", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) + attr_name + "_start", + new THREE.InterleavedBufferAttribute(buffer, ndim, ndim) ); // xyz1 geometry.setAttribute( - "linepoint_end", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 4) + attr_name + "_end", + new THREE.InterleavedBufferAttribute(buffer, ndim, ndim * 2) ); // xyz1 geometry.setAttribute( - "linepoint_next", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 6) + attr_name + "_next", + new THREE.InterleavedBufferAttribute(buffer, ndim, ndim * 3) ); // xyz2 - return instanceBuffer; + return buffer; } -function create_line_geometry(linepoints, is_linesegments) { +function create_line_geometry(attributes, is_linesegments) { function geometry_buffer() { const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [0, 1, 2, 3, 4, 5]; @@ -239,28 +256,41 @@ function create_line_geometry(linepoints, is_linesegments) { } const geometry = geometry_buffer(); - - const points = linepoints2buffer(linepoints.value, is_linesegments); - - let instanceBuffer = attach_instanced_line_geometry(geometry, points); - - linepoints.on((new_points) => { - const new_line_points = linepoints2buffer(new_points, is_linesegments); - const old_count = instanceBuffer.updateRange.count; - if (old_count < new_line_points.length) { - instanceBuffer.dispose(); - instanceBuffer = attach_instanced_line_geometry( - geometry, - new_line_points + const buffers = {}; + function create_line_buffer(name, attr) { + const buffer = to_linepoint_array(attr.value, is_linesegments, 2); + const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, 2); + buffers[name] = linebuffer; + attr.on((new_points) => { + const buff = buffers[name]; + const new_line_points = to_linepoint_array( + new_points, + is_linesegments, + 2 ); - } else { - instanceBuffer.updateRange.count = new_line_points.length; - instanceBuffer.set(new_line_points, 0); - } + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + // instanceBuffer.dispose(); + buffers[name] = attach_interleaved_line_buffer( + name, + geometry, + new_line_points + ); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } - geometry.instanceCount = (new_line_points.length - 4) / 4; - instanceBuffer.needsUpdate = true; - }); + geometry.instanceCount = (new_line_points.length - 4) / 4; + buffers[name].needsUpdate = true; + }); + return buffer; + } + let points; + for (let name in attributes) { + const attr = attributes[name]; + points = create_line_buffer(name, attr); + } geometry.boundingSphere = new THREE.Sphere(); // don't use intersection / culling @@ -273,10 +303,13 @@ function create_line_geometry(linepoints, is_linesegments) { export function create_line(line_data) { const geometry = create_line_geometry( - line_data.positions, + line_data.attributes, line_data.is_linesegments ); - const material = create_line_material(line_data.uniforms); + const material = create_line_material( + line_data.uniforms, + geometry.attributes + ); return new THREE.Mesh(geometry, material); } diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index ca75572288e..570d6d08864 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -4,10 +4,18 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :pattern_length => 1f0, :model => plot.model, :is_valid => Vec4f(1), - :linewidth => linewidth, - :color => color ) - + attributes = Dict{Symbol, Any}( + :linepoint => lift(x -> collect(reinterpret(Float32, x)), plot[1]) + ) + for (name, attr) in [:color => color, :linewidth => linewidth] + if Makie.is_scalar_attribute(attr) + uniforms[Symbol("$(name)_start")] = attr + uniforms[Symbol("$(name)_end")] = attr + else + attributes[name] = attr + end + end attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, @@ -15,8 +23,9 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :plot_type => :lines, :cam_space => plot.space[], :is_linesegments => plot isa LineSegments, - :positions => lift(x-> collect(reinterpret(Float32, x)), plot[1]), + :uniforms => serialize_uniforms(uniforms), + :attributes => attributes ) return attr end diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index e7ed4305e11..93fd72b63c6 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19795,97 +19795,135 @@ class MakieCamera { } } } -const LINES_VERT = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -in float position; - -in vec2 linepoint_prev; // start of previous segment -in vec2 linepoint_start; // end of previous segment, start of current segment -in vec2 linepoint_end; // end of current segment, start of next segment -in vec2 linepoint_next; // end of next segment - -uniform vec4 is_valid; // start of previous segment - -uniform vec4 color_start; // end of previous segment, start of current segment -uniform vec4 color_end; // end of current segment, start of next segment - -uniform float thickness_start; -uniform float thickness_end; - -uniform vec2 resolution; -uniform mat4 projectionview; -uniform mat4 model; -uniform float pattern_length; +function typedarray_to_vectype(typedArray, ndim) { + if (ndim === 1) { + return "float"; + } else if (typedArray instanceof Float32Array) { + return "vec" + ndim; + } else if (typedArray instanceof Int32Array) { + return "ivec" + ndim; + } else if (typedArray instanceof Uint32Array) { + return "uvec" + ndim; + } else { + throw new Error("Unsupported TypedArray type."); + } +} +function uniform_type(obj) { + if (obj instanceof mod.Uniform) { + return uniform_type(obj.value); + } else if (typeof obj === "number") { + return "float"; + } else if (obj instanceof mod.Vector2) { + return "vec2"; + } else if (obj instanceof mod.Vector3) { + return "vec3"; + } else if (obj instanceof mod.Vector4) { + return "vec4"; + } else if (obj instanceof mod.Color) { + return "vec4"; + } else if (obj instanceof mod.Matrix3) { + return "mat3"; + } else if (obj instanceof mod.Matrix4) { + return "mat4"; + } else if (obj instanceof mod.Texture) { + return "sampler2D"; + } else { + return "vec4"; + } +} +function uniforms_to_type_declaration(uniform_dict) { + let result = ""; + for(const name in uniform_dict){ + const uniform = uniform_dict[name]; + const type = uniform_type(uniform); + result += `uniform ${type} ${name};\n`; + } + return result; +} +function attributes_to_type_declaration(attributes_dict) { + let result = ""; + for(const name in attributes_dict){ + const attribute = attributes_dict[name]; + const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + result += `in ${type} ${name};\n`; + } + return result; +} +function lines_shader(uniforms, attributes) { + console.log(attributes); + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + return `#version 300 es + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; -flat out vec2 f_uv_minmax; -out vec2 f_uv; -out vec4 f_color; -out float f_thickness; + ${attribute_decl} + ${uniform_decl} -#define MITER_LIMIT -0.4 -#define AA_THICKNESS 4.0 + out vec2 f_uv; + out vec4 f_color; + out float f_thickness; -vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; -} + vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + } -void emit_vertex(vec3 position, vec2 uv, bool is_start) { + void emit_vertex(vec3 position, vec2 uv, bool is_start) { - f_uv = uv; + f_uv = uv; - f_color = is_start ? color_start : color_end; + f_color = is_start ? color_start : color_end; - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? thickness_start : thickness_end; -} + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? linewidth_start : linewidth_end; + } -void main() { - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (thickness_start / 2.0); + void main() { + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec2 dir = p1.xy - p2.xy; + dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (linewidth_start / 2.0); - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), true); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; + } + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), true); + return; + } + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; + } + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; + } + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), false); + return; + } + } + `; } -`; const LINES_FRAG = `#version 300 es precision mediump int; precision highp float; @@ -19923,62 +19961,49 @@ float aastep_scaled(float threshold1, float threshold2, float dist) { } void main(){ - // vec4 color = vec4(f_color.rgb, 0.0); - // vec2 xy = f_uv; - - // float alpha = aastep(0.0, xy.x); - // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); - // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); - - // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); - fragment_color = f_color; } `; -function create_line_material(uniforms) { +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); return new mod.RawShaderMaterial({ - uniforms: deserialize_uniforms(uniforms), - vertexShader: LINES_VERT, + uniforms: uniforms_des, + vertexShader: lines_shader(uniforms_des, attributes), fragmentShader: LINES_FRAG, transparent: true }); } -function linepoints2buffer(linepoints, is_linesegments) { +function to_linepoint_array(linepoints, is_linesegments, ndims) { const N = linepoints.length; + const duplicate = is_linesegments ? 1 : 2; + const N2 = linepoints.length * duplicate + ndims * 2; + const points = new Float32Array(N2); + for(let i = 0; i < ndims; i++){ + points[i] = linepoints[i]; + } + for(let i = 1; i <= ndims; i++){ + points[N2 - i] = linepoints[N - i]; + } if (is_linesegments) { - const N2 = linepoints.length + 4; - const points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - points.set(linepoints, 2); - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - return points; + points.set(linepoints, ndims); } else { - const N2 = linepoints.length * 2 + 4; - const points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - for(let i = 0; i < linepoints.length; i += 2){ - points[2 * i + 2] = linepoints[i]; - points[2 * i + 3] = linepoints[i + 1]; - points[2 * i + 4] = linepoints[i + 2]; - points[2 * i + 5] = linepoints[i + 3]; - } - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - return points; - } -} -function attach_instanced_line_geometry(geometry, points) { - const instanceBuffer = new mod.InstancedInterleavedBuffer(points, 4, 1); - geometry.setAttribute("linepoint_prev", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 0)); - geometry.setAttribute("linepoint_start", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 2)); - geometry.setAttribute("linepoint_end", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 4)); - geometry.setAttribute("linepoint_next", new mod.InterleavedBufferAttribute(instanceBuffer, 2, 6)); - return instanceBuffer; -} -function create_line_geometry(linepoints, is_linesegments) { + for(let i = 0; i < N; i += 2){ + for(let j = 0; j < 2 * ndims; j++){ + points[2 * i + ndims + j] = linepoints[i + j]; + } + } + } + return points; +} +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { + const buffer = new mod.InstancedInterleavedBuffer(points, ndim * 2, 1); + geometry.setAttribute(attr_name + "_prev", new mod.InterleavedBufferAttribute(buffer, ndim, 0)); + geometry.setAttribute(attr_name + "_start", new mod.InterleavedBufferAttribute(buffer, ndim, ndim)); + geometry.setAttribute(attr_name + "_end", new mod.InterleavedBufferAttribute(buffer, ndim, ndim * 2)); + geometry.setAttribute(attr_name + "_next", new mod.InterleavedBufferAttribute(buffer, ndim, ndim * 3)); + return buffer; +} +function create_line_geometry(attributes, is_linesegments) { function geometry_buffer() { const geometry = new mod.InstancedBufferGeometry(); const instance_positions = [ @@ -19993,16 +20018,31 @@ function create_line_geometry(linepoints, is_linesegments) { return geometry; } const geometry = geometry_buffer(); - const points = linepoints2buffer(linepoints.value, is_linesegments); - const instanceBuffer = attach_instanced_line_geometry(geometry, points); - console.log(instanceBuffer); - linepoints.on((new_points)=>{ - const new_line_points = linepoints2buffer(new_points, is_linesegments); - instanceBuffer.updateRange.count = new_line_points.length; - instanceBuffer.set(new_line_points, 0); - instanceBuffer.needsUpdate = true; - geometry.instanceCount = (new_line_points.length - 4) / 4; - }); + const buffers = {}; + function create_line_buffer(name, attr) { + const buffer = to_linepoint_array(attr.value, is_linesegments, 2); + const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, 2); + buffers[name] = linebuffer; + attr.on((new_points)=>{ + const buff = buffers[name]; + const new_line_points = to_linepoint_array(new_points, is_linesegments, 2); + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + geometry.instanceCount = (new_line_points.length - 4) / 4; + buffers[name].needsUpdate = true; + }); + return buffer; + } + let points; + for(let name in attributes){ + const attr = attributes[name]; + points = create_line_buffer(name, attr); + } geometry.boundingSphere = new mod.Sphere(); geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; @@ -20010,8 +20050,8 @@ function create_line_geometry(linepoints, is_linesegments) { return geometry; } function create_line(line_data) { - const geometry = create_line_geometry(line_data.positions, line_data.is_linesegments); - const material = create_line_material(line_data.uniforms); + const geometry = create_line_geometry(line_data.attributes, line_data.is_linesegments); + const material = create_line_material(line_data.uniforms, geometry.attributes); return new mod.Mesh(geometry, material); } const scene_cache = {}; From b9e2bad9d84a10aa82d2b4fde9ccf22cb910745d Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 3 Aug 2023 16:34:13 +0200 Subject: [PATCH 09/28] clean up implementation --- WGLMakie/src/Serialization.js | 30 +++++++++++++++++++----------- WGLMakie/src/lines.jl | 6 +++--- WGLMakie/src/wglmakie.bundled.js | 17 ++++++++++------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index c0cf95395db..c8d41b760b5 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -67,7 +67,6 @@ function attributes_to_type_declaration(attributes_dict) { } function lines_shader(uniforms, attributes) { - console.log(attributes) const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); @@ -197,7 +196,8 @@ function create_line_material(uniforms, attributes) { function to_linepoint_array(linepoints, is_linesegments, ndims) { const N = linepoints.length; const duplicate = is_linesegments ? 1 : 2; - const N2 = (linepoints.length * duplicate) + (ndims * 2); + const extra = is_linesegments ? 2 * ndims : 0; + const N2 = linepoints.length * duplicate + extra; const points = new Float32Array(N2); // copy over first and last point for (let i = 0; i < ndims; i++) { @@ -209,9 +209,9 @@ function to_linepoint_array(linepoints, is_linesegments, ndims) { if (is_linesegments) { points.set(linepoints, ndims); } else { - for (let i = 0; i < N; i += 2) { - for (let j = 0; j < (2 * ndims); j++) { - points[(2 * i) + ndims + j] = linepoints[i + j]; + for (let i = 0; i < N - ndims; i += ndims) { + for (let j = 0; j < 2 * ndims; j++) { + points[2 * i + ndims + j] = linepoints[i + j]; } } } @@ -247,7 +247,6 @@ function create_line_geometry(attributes, is_linesegments) { function geometry_buffer() { const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [0, 1, 2, 3, 4, 5]; - geometry.setAttribute( "position", new THREE.Float32BufferAttribute(instance_positions, 1) @@ -258,15 +257,23 @@ function create_line_geometry(attributes, is_linesegments) { const geometry = geometry_buffer(); const buffers = {}; function create_line_buffer(name, attr) { - const buffer = to_linepoint_array(attr.value, is_linesegments, 2); - const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, 2); + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = to_linepoint_array(flat_buffer, is_linesegments, ndims); + const linebuffer = attach_interleaved_line_buffer( + name, + geometry, + buffer, + ndims + ); buffers[name] = linebuffer; attr.on((new_points) => { const buff = buffers[name]; + const ndims = new_points.type_length; const new_line_points = to_linepoint_array( - new_points, + new_points.flat, is_linesegments, - 2 + ndims ); const old_count = buff.updateRange.count; if (old_count < new_line_points.length) { @@ -274,7 +281,8 @@ function create_line_geometry(attributes, is_linesegments) { buffers[name] = attach_interleaved_line_buffer( name, geometry, - new_line_points + new_line_points, + ndims ); } else { buff.updateRange.count = new_line_points.length; diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 570d6d08864..831cb41a597 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -6,14 +6,14 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :is_valid => Vec4f(1), ) attributes = Dict{Symbol, Any}( - :linepoint => lift(x -> collect(reinterpret(Float32, x)), plot[1]) + :linepoint => lift(serialize_buffer_attribute, plot[1]) ) for (name, attr) in [:color => color, :linewidth => linewidth] - if Makie.is_scalar_attribute(attr) + if Makie.is_scalar_attribute(to_value(attr)) uniforms[Symbol("$(name)_start")] = attr uniforms[Symbol("$(name)_end")] = attr else - attributes[name] = attr + attributes[name] = lift(serialize_buffer_attribute, attr) end end attr = Dict( diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 93fd72b63c6..618db81c88e 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19850,7 +19850,6 @@ function attributes_to_type_declaration(attributes_dict) { return result; } function lines_shader(uniforms, attributes) { - console.log(attributes); const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); return `#version 300 es @@ -19976,7 +19975,8 @@ function create_line_material(uniforms, attributes) { function to_linepoint_array(linepoints, is_linesegments, ndims) { const N = linepoints.length; const duplicate = is_linesegments ? 1 : 2; - const N2 = linepoints.length * duplicate + ndims * 2; + const extra = is_linesegments ? 2 * ndims : 0; + const N2 = linepoints.length * duplicate + extra; const points = new Float32Array(N2); for(let i = 0; i < ndims; i++){ points[i] = linepoints[i]; @@ -19987,7 +19987,7 @@ function to_linepoint_array(linepoints, is_linesegments, ndims) { if (is_linesegments) { points.set(linepoints, ndims); } else { - for(let i = 0; i < N; i += 2){ + for(let i = 0; i < N - ndims; i += ndims){ for(let j = 0; j < 2 * ndims; j++){ points[2 * i + ndims + j] = linepoints[i + j]; } @@ -20020,15 +20020,18 @@ function create_line_geometry(attributes, is_linesegments) { const geometry = geometry_buffer(); const buffers = {}; function create_line_buffer(name, attr) { - const buffer = to_linepoint_array(attr.value, is_linesegments, 2); - const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, 2); + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = to_linepoint_array(flat_buffer, is_linesegments, ndims); + const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, ndims); buffers[name] = linebuffer; attr.on((new_points)=>{ const buff = buffers[name]; - const new_line_points = to_linepoint_array(new_points, is_linesegments, 2); + const ndims = new_points.type_length; + const new_line_points = to_linepoint_array(new_points.flat, is_linesegments, ndims); const old_count = buff.updateRange.count; if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points); + buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims); } else { buff.updateRange.count = new_line_points.length; buff.set(new_line_points, 0); From 53b84644c6d49014579cf52f540a7c9bc8f92af8 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 7 Aug 2023 19:50:17 +0200 Subject: [PATCH 10/28] cleanup --- WGLMakie/assets/lines.vert | 357 +++---------------- WGLMakie/src/Lines.js | 341 +++++++++--------- WGLMakie/src/Linesegments.js | 172 +++++++++ WGLMakie/src/Serialization.js | 344 +----------------- WGLMakie/src/Shaders.js | 58 ++++ WGLMakie/src/lines.jl | 10 +- WGLMakie/src/wglmakie.bundled.js | 576 ++++++++++++++++++------------- 7 files changed, 812 insertions(+), 1046 deletions(-) create mode 100644 WGLMakie/src/Linesegments.js create mode 100644 WGLMakie/src/Shaders.js diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert index face9942def..b2d662d61da 100644 --- a/WGLMakie/assets/lines.vert +++ b/WGLMakie/assets/lines.vert @@ -1,335 +1,84 @@ #version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; -in float position; - -in vec2 linepoint_prev; // start of previous segment -in vec2 linepoint_start; // end of previous segment, start of current segment -in vec2 linepoint_end; // end of current segment, start of next segment -in vec2 linepoint_next; // end of next segment - -uniform vec4 is_valid; // start of previous segment - -uniform vec4 color_start; // end of previous segment, start of current segment -uniform vec4 color_end; // end of current segment, start of next segment -uniform float thickness_start; -uniform float thickness_end; - -uniform vec2 resolution; -uniform mat4 projectionview; -uniform mat4 model; +in float position; +in vec2 linepoint_prev; +in vec2 linepoint_start; +in vec2 linepoint_end; +in vec2 linepoint_next; +in float linewidth_prev; +in float linewidth_start; +in float linewidth_end; +in float linewidth_next; + +uniform vec4 is_valid; +uniform vec4 color_end; +uniform vec4 color_start; uniform float pattern_length; +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; +uniform mat4 projectionview; +uniform vec3 eyeposition; +uniform vec2 resolution; -flat out vec2 f_uv_minmax; out vec2 f_uv; out vec4 f_color; out float f_thickness; -#define MITER_LIMIT -0.4 -#define AA_THICKNESS 4.0 - vec3 screen_space(vec2 point) { vec4 vertex = projectionview * model * vec4(point, 0, 1); return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } -// Manual uv calculation -// - position in screen space (double resolution as generally used) -// - uv with uv.u normalized (0..1), uv.v unnormalized (0..pattern_length) -void emit_vertex(vec3 position, vec2 uv, bool is_start, float thickness) { - f_uv = uv; - f_color = is_start ? color_start : color_end; - gl_Position = vec4((position.xy / resolution), position.z, 1.0f); - // linewidth scaling may shrink the effective linewidth - f_thickness = thickness; -} - void emit_vertex(vec3 position, vec2 uv, bool is_start) { f_uv = uv; f_color = is_start ? color_start : color_end; - gl_Position = vec4((position.xy / resolution), position.z, 1.0f); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? thickness_start : thickness_end; -} - -void emit_vertex(vec3 position, vec2 offset, vec2 line_dir, vec2 uv, bool index) { - float px2uv = 0.5f / pattern_length; - emit_vertex(position + vec3(offset, 0), vec2(uv.x + px2uv * dot(line_dir, offset), uv.y), index, abs(uv.y) - AA_THICKNESS); - // abs(uv.y) - AA_THICKNESS corrects for enlarged AA padding between - // segments of different linewidth, see #2953 -} - -// Generate line segment with 3 triangles -// - p1, p2 are the line start and end points in pixel space -// - miter_a and miter_b are the offsets from p1 and p2 respectively that -// generate the line segment quad. This should include thickness and AA -// - u1, u2 are the u values at p1 and p2. These should be in uv scale (px2uv applied) -// - thickness_aa1, thickness_aa2 are linewidth at p1 and p2 with AA added. They -// double as uv.y values, which are in pixel space -// - v1 is the line direction of this segment (xy component) -void generate_line_segment( - vec3 p1, - vec2 miter_a, - float u1, - float thickness_aa1, - vec3 p2, - vec2 miter_b, - float u2, - float thickness_aa2, - vec2 v1, - float segment_length -) { - float line_offset_a = dot(miter_a, v1); - float line_offset_b = dot(miter_b, v1); - - if (abs(line_offset_a) + abs(line_offset_b) < segment_length + 1.0f) { - // _________ - // \ / - // \_____/ - // <---> - // Line segment is extensive (minimum width positive) - if (position == 5.0f) { - emit_vertex(p1, +miter_a, v1, vec2(u1, -thickness_aa1), true); - return; - } - if (position == 6.0f) { - emit_vertex(p1, -miter_a, v1, vec2(u1, thickness_aa1), true); - return; - } - if (position == 7.0f) { - emit_vertex(p2, +miter_b, v1, vec2(u2, -thickness_aa2), false); - return; - } - if (position == 8.0f) { - emit_vertex(p2, -miter_b, v1, vec2(u2, thickness_aa2), false); - return; - } - - } else { - /* - \ / - \/ - /\ - >--< - Line segment has zero or negative width on short side - - Pulled apart, we draw these two triangles (vertical lines added) - ___ ___ - \ | | / - X | | X - \| |/ - - where X is u1/p1 (left) and u2/p2 (right) respectively. To avoid - drawing outside the line segment due to AA padding, we cut off the - left triangle on the right side at u2 via f_uv_minmax.y, and - analogously the right triangle at u1 via f_uv_minmax.x. - These triangles will still draw over each other like this. - */ - - // incoming side - float old = f_uv_minmax.y; - f_uv_minmax.y = u2; - if (position == 5.0f) { - emit_vertex(p1, -miter_a, v1, vec2(u1, -thickness_aa1), true); - return; - } - if (position == 6.0f) { - emit_vertex(p1, +miter_a, v1, vec2(u1, +thickness_aa1), true); - return; - } - if (position == 7.0f) { - if (line_offset_a > 0.0f) { // finish triangle on -miter_a side - emit_vertex(p1, 2.0f * line_offset_a * v1 - miter_a, v1, vec2(u1, -thickness_aa1), true); - } else { - emit_vertex(p1, -2.0f * line_offset_a * v1 + miter_a, v1, vec2(u1, +thickness_aa1), true); - } - return; - } - - // outgoing side - f_uv_minmax.x = u1; - f_uv_minmax.y = old; - if (position == 8.0f) { - emit_vertex(p2, -miter_b, v1, vec2(u2, -thickness_aa2), false); - return; - } - if (position == 9.0f) { - emit_vertex(p2, +miter_b, v1, vec2(u2, +thickness_aa2), false); - return; - } - - if (line_offset_b < 0.0f) { // finish triangle on -miter_b side - emit_vertex(p2, 2.0f * line_offset_b * v1 - miter_b, v1, vec2(u2, -thickness_aa2), false); - } else { - emit_vertex(p2, -2.0f * line_offset_b * v1 + miter_b, v1, vec2(u2, +thickness_aa2), false); - } - return; - } + gl_Position = vec4((position.xy / resolution), position.z, 1.0); + // linewidth scaling may shrink the effective linewidth + f_thickness = is_start ? linewidth_start : linewidth_end; } void main() { - float px2uv = 0.5f / pattern_length; - - bvec4 _isvalid = bvec4(true, true, true, true); - - // This sets a min and max value foir uv.u at which anti-aliasing is forced. - // With this setting it's never triggered. - f_uv_minmax = vec2(-1.0e12f, 1.0e12f); - - // get the four vertices passed to the shader - // without FAST_PATH the conversions happen on the CPU - vec3 p0 = screen_space(linepoint_prev); // start of previous segment - vec3 p1 = screen_space(linepoint_start); // end of previous segment, start of current segment - vec3 p2 = screen_space(linepoint_end); // end of current segment, start of next segment - vec3 p3 = screen_space(linepoint_next); // end of next segment - - // determine the direction of each of the 3 segments (previous, current, next) - vec3 v1 = p2 - p1; - float segment_length = length(v1.xy); - v1 /= segment_length; - vec3 v0 = v1; - vec3 v2 = v1; - - if (p1 != p0 && _isvalid.x) { - v0 = (p1 - p0) / length((p1 - p0).xy); + vec3 p1 = screen_space(linepoint_start); + vec3 p2 = screen_space(linepoint_end); + vec2 dir = p1.xy - p2.xy; + dir = normalize(dir); + vec2 line_normal = vec2(dir.y, -dir.x); + vec2 line_offset = line_normal * (linewidth_start / 2.0); + + // triangle 1 + vec3 v0 = vec3(p1.xy - line_offset, p1.z); + if (position == 0.0) { + emit_vertex(v0, vec2(0.0, 0.0), true); + return; } - if (p3 != p2 && _isvalid.w) { - v2 = (p3 - p2) / length((p3 - p2).xy); + vec3 v2 = vec3(p2.xy - line_offset, p2.z); + if (position == 1.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; } - - // determine the normal of each of the 3 segments (previous, current, next) - vec2 n0 = vec2(-v0.y, v0.x); - vec2 n1 = vec2(-v1.y, v1.x); - vec2 n2 = vec2(-v2.y, v2.x); - - // determine stretching of AA border due to linewidth change - float temp = (thickness_end - thickness_start) / segment_length; - float edge_scale = sqrt(1.0f + temp * temp); - - // linewidth with padding for anti aliasing (used for geometry) - float thickness_aa1 = thickness_start + edge_scale * AA_THICKNESS; - float thickness_aa2 = thickness_end + edge_scale * AA_THICKNESS; - - // Setup for sharp corners (see above) - vec2 miter_a = normalize(n0 + n1); - vec2 miter_b = normalize(n1 + n2); - float length_a = thickness_aa1 / dot(miter_a, n1); - float length_b = thickness_aa2 / dot(miter_b, n1); - - // truncated miter join (see above) - if (dot(v0.xy, v1.xy) < MITER_LIMIT) { - bool gap = dot(v0.xy, n1) > 0.0f; - // In this case uv's are used as signed distance field values, so we - // want 0 where we had start before. - float u0 = thickness_aa1 * abs(dot(miter_a, n1)) * px2uv; - float proj_AA = AA_THICKNESS * abs(dot(miter_a, n1)) * px2uv; - - // to save some space - vec2 off0 = thickness_aa1 * n0; - vec2 off1 = thickness_aa1 * n1; - vec2 off_AA = AA_THICKNESS * miter_a; - float u_AA = AA_THICKNESS * px2uv; - - if (gap) { - if (position == 0.0f) { - emit_vertex(p1, vec2(+u0, 0.0f), true); - return; - } - if (position == 1.0f) { - emit_vertex(p1 + vec3(off0, 0), vec2(-proj_AA, +thickness_aa1), true); - return; - } - if (position == 2.0f) { - emit_vertex(p1 + vec3(off1, 0), vec2(-proj_AA, -thickness_aa1), true); - return; - } - if (position == 3.0f) { - emit_vertex(p1 + vec3(off0 + off_AA, 0), vec2(-proj_AA - u_AA, +thickness_aa1), true); - return; - } - if (position == 4.0f) { - emit_vertex(p1 + vec3(off1 + off_AA, 0), vec2(-proj_AA - u_AA, -thickness_aa1), true); - return; - } - } else { - if (position == 0.0f) { - emit_vertex(p1, vec2(+u0, 0), true); - return; - } - if (position == 1.0f) { - emit_vertex(p1 - vec3(off1, 0), vec2(-proj_AA, +thickness_aa1), true); - return; - } - if (position == 2.0f) { - emit_vertex(p1 - vec3(off0, 0), vec2(-proj_AA, -thickness_aa1), true); - return; - } - if (position == 3.0f) { - emit_vertex(p1 - vec3(off1 + off_AA, 0), vec2(-proj_AA - u_AA, +thickness_aa1), true); - return; - } - if (position == 4.0f) { - emit_vertex(p1 - vec3(off0 + off_AA, 0), vec2(-proj_AA - u_AA, -thickness_aa1), true); - return; - } - } - - miter_a = n1; - length_a = thickness_aa1; + vec3 v1 = vec3(p1.xy + line_offset, p1.z); + if (position == 2.0) { + emit_vertex(v1, vec2(0.0, 0.0), true); + return; } - // we have miter join on next segment, do normal line cut off - if (dot(v1.xy, v2.xy) <= MITER_LIMIT) { - miter_b = n1; - length_b = thickness_aa2; + // triangle 2 + if (position == 3.0) { + emit_vertex(v2, vec2(0.0, 0.0), false); + return; } - - // Without a pattern (linestyle) we use uv.u directly as a signed distance - // field. We only care about u1 - u0 being the correct distance and - // u0 > AA_THICHKNESS at all times. - float u1 = 10000.0f; - float u2 = u1 + segment_length; - - miter_a *= length_a; - miter_b *= length_b; - - // To treat line starts and ends we elongate the line in the respective - // direction and enforce an AA border at the original start/end position - // with f_uv_minmax. - if (!_isvalid.x) { - float corner_offset = max(0.0f, abs(dot(miter_b, v1.xy)) - segment_length); - f_uv_minmax.x = px2uv * (u1 - corner_offset); - p1 -= (corner_offset + AA_THICKNESS) * v1; - u1 -= (corner_offset + AA_THICKNESS); - segment_length += corner_offset; + vec3 v3 = vec3(p2.xy + line_offset, p2.z); + if (position == 4.0) { + emit_vertex(v3, vec2(0.0, 0.0), false); + return; } - - if (!_isvalid.w) { - float corner_offset = max(0.0f, abs(dot(miter_a, v1.xy)) - segment_length); - f_uv_minmax.y = px2uv * (u2 + corner_offset); - p2 += (corner_offset + AA_THICKNESS) * v1; - u2 += (corner_offset + AA_THICKNESS); - segment_length += corner_offset; + if (position == 5.0) { + emit_vertex(v1, vec2(0.0, 0.0), true); + return; } - - // scaling of uv.y due to different linewidths - // the padding for AA_THICKNESS should always have AA_THICKNESS width in uv - thickness_aa1 = thickness_start / edge_scale + AA_THICKNESS; - thickness_aa2 = thickness_end / edge_scale + AA_THICKNESS; - - // Generate line segment - u1 *= px2uv; - u2 *= px2uv; - - // Normal Version - generate_line_segment(p1, miter_a, u1, thickness_aa1, p2, miter_b, u2, thickness_aa2, v1.xy, segment_length); - - return; } diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index 1723aad3ca8..674a2892a82 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -1,209 +1,204 @@ -import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; -import { deserialize_uniforms } from "./Serialization.js"; - - -const LINES_VERT = ` -# version 300 es -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master -uniform float linewidth; -uniform vec2 resolution; - -in vec2 uv; -in vec3 position; -in vec2 instanceStart; -in vec2 instanceEnd; - -out vec2 vUv; -uniform mat4 projection; -uniform mat4 model; -uniform mat4 view; - -void trimSegment(const in vec4 start, inout vec4 end) { - - // trim end segment so it terminates between the camera plane and the near plane - - // conservative estimate of the near plane - float a = projection[2][2]; // 3nd entry in 3th column - float b = projection[3][2]; // 3nd entry in 4th column - float nearEstimate = -0.5 * b / a; - - float alpha = (nearEstimate - start.z) / (end.z - start.z); - - end.xyz = mix(start.xyz, end.xyz, alpha); - -} - -void main() { - - float aspect = resolution.x / resolution.y; - const model_view = view * model; - // camera space - vec4 start = model_view * vec4(instanceStart, 0.0, 1.0); - vec4 end = model_view * vec4(instanceEnd, 0.0, 1.0); - vUv = uv; - - // special case for perspective projection, and segments that terminate either in, or behind, the camera plane - // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space - // but we need to perform ndc-space calculations in the shader, so we must address this issue directly - // perhaps there is a more elegant solution -- WestLangley - - bool perspective = (projection[2][3] == -1.0); // 4th entry in the 3rd column - - if (perspective) { - - if (start.z < 0.0 && end.z >= 0.0) { - - trimSegment(start, end); - - } else if (end.z < 0.0 && start.z >= 0.0) { - - trimSegment(end, start); - +import { + attributes_to_type_declaration, + uniforms_to_type_declaration, +} from "./Shaders.js"; + +import { + deserialize_uniforms, +} from "./Serialization.js" + +function lines_shader(uniforms, attributes) { + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + + return `#version 300 es + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; + + ${attribute_decl} + ${uniform_decl} + + out vec2 f_uv; + out vec4 f_color; + out float f_thickness; + + vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } - } - - // clip space - vec4 clipStart = projection * start; - vec4 clipEnd = projection * end; - - // ndc space - vec3 ndcStart = clipStart.xyz / clipStart.w; - vec3 ndcEnd = clipEnd.xyz / clipEnd.w; - - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; - - // account for clip-space aspect ratio - dir.x *= aspect; - dir = normalize(dir); - - vec2 offset = vec2(dir.y, -dir.x); - // undo aspect ratio adjustment - dir.x /= aspect; - offset.x /= aspect; - - // sign flip - if (position.x < 0.0) - offset *= -1.0; - - // endcaps - if (position.y < 0.0) { - - offset += -dir; + void main() { + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + // vec3 p_c = screen_space(linepoint_next); + float width = linewidth_start; - } else if (position.y > 1.0) { + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; + // vec2 pointC = p_c.xy; - offset += dir; - - } - - // adjust for linewidth - offset *= linewidth; - - // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... - offset /= resolution.y; - - // select end - vec4 clip = (position.y < 0.5) ? clipStart : clipEnd; - - // back to clip space - // back to clip space - offset *= clip.w; - - clip.xy += offset; - - gl_Position = clip; - - vec4 mvPosition = (position.y < 0.5) ? start : end; // this is an approximation + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; + gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + f_color = color_start; + } + `; } -`; - -const LINES_FRAG = ` -uniform vec3 diffuse; -uniform float opacity; +const LINES_FRAG = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; -in vec2 vUv; +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; +uniform float pattern_length; -void main() { +out vec4 fragment_color; - float alpha = opacity; +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 - // artifacts appear on some hardware if a derivative is taken within a conditional - float a = vUv.x; - float b = (vUv.y > 0.0) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - float dlen = fwidth(len2); +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} - if (abs(vUv.y) > 1.0) { - alpha = 1.0 - smoothstep(1.0 - dlen, 1.0 + dlen, len2); - } +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} - vec4 diffuseColor = vec4(diffuse, alpha); - gl_FragColor = vec4(diffuseColor.rgb, alpha); +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} +void main(){ + fragment_color = f_color; } `; -function create_line_material(uniforms) { +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); return new THREE.RawShaderMaterial({ - uniforms: deserialize_uniforms(uniforms), - vertexShader: LINES_VERT, + uniforms: uniforms_des, + vertexShader: lines_shader(uniforms_des, attributes), fragmentShader: LINES_FRAG, transparent: true, }); } -function create_line_geometry(linepositions) { - const length = linepositions.length - const points = new Float32Array(2 * length); - - for (let i = 0; i < length; i += 2) { - points[2 * i] = linepositions[i]; - points[2 * i + 1] = linepositions[i + 1]; - - points[2 * i + 2] = linepositions[i + 2]; - points[2 * i + 3] = linepositions[i + 3]; +function to_linepoint_array(linepoints, ndims) { + const N = linepoints.length; + const N2 = linepoints.length + (ndims * 1); + const points = new Float32Array(N2); + // copy over first and last point + // for (let i = 0; i < ndims; i++) { + // points[i] = linepoints[i]; + // } + for (let i = 1; i <= ndims; i++) { + points[N2 - i] = linepoints[N - i]; } + points.set(linepoints, 0); + console.log(points); + return points; +} - const geometry = new THREE.InstancedBufferGeometry(); - - const instance_positions = [ - -1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, - -1, 0, - ] - const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]; - const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]; - geometry.setIndex(index); +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { + const buffer = new THREE.InstancedInterleavedBuffer(points, ndim, 1); + buffer.count = (points.length / ndim) - 1; geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 3) - ); - geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); + attr_name + "_start", + new THREE.InterleavedBufferAttribute(buffer, ndim, 0) + ); // xyz1 + geometry.setAttribute( + attr_name + "_end", + new THREE.InterleavedBufferAttribute(buffer, ndim, ndim) + ); // xyz1 + return buffer; +} - const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xyz, xyz +function create_line_geometry(attributes) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, -0.5, 1, -0.5, 1, 0.5, 0, -0.5, 1, 0.5, 0, 0.5, + ]; + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 2) + ); + return geometry; + } - geometry.setAttribute( - "instanceStart", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) - ); // xyz - geometry.setAttribute( - "instanceEnd", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) - ); // xyz + const geometry = geometry_buffer(); + const buffers = {}; + function create_line_buffer(name, attr) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = to_linepoint_array(flat_buffer, ndims); + const linebuffer = attach_interleaved_line_buffer( + name, + geometry, + buffer, + ndims + ); + buffers[name] = linebuffer; + attr.on((new_points) => { + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = to_linepoint_array(new_points.flat, ndims); + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + // instanceBuffer.dispose(); + buffers[name] = attach_interleaved_line_buffer( + name, + geometry, + new_line_points, + ndims + ); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + + // geometry.instanceCount = (new_line_points.length - 4) / 4; + buffers[name].needsUpdate = true; + }); + return buffer; + } + for (let name in attributes) { + const attr = attributes[name]; + create_line_buffer(name, attr); + } + + geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; return geometry; } export function create_line(line_data) { - console.log(line_data) - const geometry = create_line_geometry(line_data.position); - const material = create_line_material(line_data.uniforms); + const geometry = create_line_geometry(line_data.attributes); + const material = create_line_material( + line_data.uniforms, + geometry.attributes + ); + console.log("------------------"); + console.log(geometry); return new THREE.Mesh(geometry, material); } diff --git a/WGLMakie/src/Linesegments.js b/WGLMakie/src/Linesegments.js new file mode 100644 index 00000000000..0b7e069a62b --- /dev/null +++ b/WGLMakie/src/Linesegments.js @@ -0,0 +1,172 @@ +import { + attributes_to_type_declaration, + uniforms_to_type_declaration, +} from "./Shaders.js"; +import { deserialize_uniforms } from "./Serialization.js"; + +function lines_shader(uniforms, attributes) { + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + + return `#version 300 es + precision mediump int; + precision highp float; + + ${attribute_decl} + ${uniform_decl} + + out vec2 f_uv; + out vec4 f_color; + + vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + } + + void main() { + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + // vec3 p_c = screen_space(linepoint_next); + float width = linewidth_start; + + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; + // vec2 pointC = p_c.xy; + + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; + + gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + f_color = color_start; + } + `; +} + +const LINES_FRAG = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; + +out vec4 fragment_color; + +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main(){ + fragment_color = f_color; +} +`; + +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); + return new THREE.RawShaderMaterial({ + uniforms: uniforms_des, + vertexShader: lines_shader(uniforms_des, attributes), + fragmentShader: LINES_FRAG, + transparent: true, + }); +} + +function attach_interleaved_line_buffer( + attr_name, + geometry, + points, + ndim, +) { + const buffer = new THREE.InstancedInterleavedBuffer(points, 2*ndim, 1); + geometry.setAttribute( + attr_name + "_start", + new THREE.InterleavedBufferAttribute(buffer, ndim, 0) + ); // xyz1 + geometry.setAttribute( + attr_name + "_end", + new THREE.InterleavedBufferAttribute(buffer, ndim, ndim) + ); // xyz1 + return buffer; +} + +function create_linesegment_geometry(attributes) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, -0.5, 1, -0.5, 1, 0.5, 0, -0.5, 1, 0.5, 0, 0.5, + ]; + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 2) + ); + return geometry; + } + + const geometry = geometry_buffer(); + const buffers = {}; + function create_line_buffer(name, attr) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = flat_buffer; + const linebuffer = attach_interleaved_line_buffer( + name, + geometry, + buffer, + ndims + ); + buffers[name] = linebuffer; + attr.on((new_points) => { + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + // instanceBuffer.dispose(); + buffers[name] = attach_interleaved_line_buffer( + name, + geometry, + new_line_points, + ndims, + ); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + buffers[name].needsUpdate = true; + }); + return buffer; + } + let points; + for (let name in attributes) { + const attr = attributes[name]; + points = create_line_buffer(name, attr); + } + geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} + +export function create_linesegments(line_data) { + const geometry = create_linesegment_geometry(line_data.attributes); + const material = create_line_material( + line_data.uniforms, + geometry.attributes + ); + return new THREE.Mesh(geometry, material); +} diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index c8d41b760b5..67483124dd7 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -1,4 +1,7 @@ import * as Camera from "./Camera.js"; +import {create_line} from "./Lines.js"; +import { create_linesegments } from "./Linesegments.js"; + import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; //https://wwwtyro.net/2019/11/18/instanced-lines.html @@ -7,320 +10,6 @@ import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; // https://github.com/gameofbombs/pixi-candles/tree/master/src // https://github.com/wwwtyro/instanced-lines-demos/tree/master -function typedarray_to_vectype(typedArray, ndim) { - if (ndim === 1) { - return "float"; - } else if (typedArray instanceof Float32Array) { - return "vec" + ndim; - } else if (typedArray instanceof Int32Array) { - return "ivec" + ndim; - } else if (typedArray instanceof Uint32Array) { - return "uvec" + ndim; - } else { - throw new Error("Unsupported TypedArray type."); - } -} - -function uniform_type(obj) { - if (obj instanceof THREE.Uniform) { - return uniform_type(obj.value); - } else if (typeof obj === "number") { - return "float"; - } else if (obj instanceof THREE.Vector2) { - return "vec2"; - } else if (obj instanceof THREE.Vector3) { - return "vec3"; - } else if (obj instanceof THREE.Vector4) { - return "vec4"; - } else if (obj instanceof THREE.Color) { - return "vec4"; - } else if (obj instanceof THREE.Matrix3) { - return "mat3"; - } else if (obj instanceof THREE.Matrix4) { - return "mat4"; - } else if (obj instanceof THREE.Texture) { - return "sampler2D"; - } else { - return "vec4"; - // throw new Error(`Unssupported uniform type: ${obj}`) - } -} - -function uniforms_to_type_declaration(uniform_dict) { - let result = ""; - for (const name in uniform_dict) { - const uniform = uniform_dict[name]; - const type = uniform_type(uniform); - result += `uniform ${type} ${name};\n`; - } - return result; -} - -function attributes_to_type_declaration(attributes_dict) { - let result = ""; - for (const name in attributes_dict) { - const attribute = attributes_dict[name]; - const type = typedarray_to_vectype(attribute.array, attribute.itemSize); - result += `in ${type} ${name};\n`; - } - return result; -} - -function lines_shader(uniforms, attributes) { - const attribute_decl = attributes_to_type_declaration(attributes); - const uniform_decl = uniforms_to_type_declaration(uniforms); - - return `#version 300 es - precision mediump int; - precision highp float; - precision mediump sampler2D; - precision mediump sampler3D; - - ${attribute_decl} - ${uniform_decl} - - out vec2 f_uv; - out vec4 f_color; - out float f_thickness; - - vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; - } - - void emit_vertex(vec3 position, vec2 uv, bool is_start) { - - f_uv = uv; - - f_color = is_start ? color_start : color_end; - - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? linewidth_start : linewidth_end; - } - - void main() { - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (linewidth_start / 2.0); - - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), true); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } - - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } - } - `; -} - -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; - -uniform float pattern_length; - -out vec4 fragment_color; - -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 - -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} - -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -void main(){ - fragment_color = f_color; -} -`; - -function create_line_material(uniforms, attributes) { - const uniforms_des = deserialize_uniforms(uniforms); - return new THREE.RawShaderMaterial({ - uniforms: uniforms_des, - vertexShader: lines_shader(uniforms_des, attributes), - fragmentShader: LINES_FRAG, - transparent: true, - }); -} - -function to_linepoint_array(linepoints, is_linesegments, ndims) { - const N = linepoints.length; - const duplicate = is_linesegments ? 1 : 2; - const extra = is_linesegments ? 2 * ndims : 0; - const N2 = linepoints.length * duplicate + extra; - const points = new Float32Array(N2); - // copy over first and last point - for (let i = 0; i < ndims; i++) { - points[i] = linepoints[i]; - } - for (let i = 1; i <= ndims; i++) { - points[N2 - i] = linepoints[N - i]; - } - if (is_linesegments) { - points.set(linepoints, ndims); - } else { - for (let i = 0; i < N - ndims; i += ndims) { - for (let j = 0; j < 2 * ndims; j++) { - points[2 * i + ndims + j] = linepoints[i + j]; - } - } - } - return points; -} - -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { - const buffer = new THREE.InstancedInterleavedBuffer( - points, - ndim * 2, // xyz1, xyz2 - 1 - ); - geometry.setAttribute( - attr_name + "_prev", - new THREE.InterleavedBufferAttribute(buffer, ndim, 0) - ); // xyz1 - geometry.setAttribute( - attr_name + "_start", - new THREE.InterleavedBufferAttribute(buffer, ndim, ndim) - ); // xyz1 - geometry.setAttribute( - attr_name + "_end", - new THREE.InterleavedBufferAttribute(buffer, ndim, ndim * 2) - ); // xyz1 - geometry.setAttribute( - attr_name + "_next", - new THREE.InterleavedBufferAttribute(buffer, ndim, ndim * 3) - ); // xyz2 - return buffer; -} - -function create_line_geometry(attributes, is_linesegments) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [0, 1, 2, 3, 4, 5]; - geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 1) - ); - return geometry; - } - - const geometry = geometry_buffer(); - const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = to_linepoint_array(flat_buffer, is_linesegments, ndims); - const linebuffer = attach_interleaved_line_buffer( - name, - geometry, - buffer, - ndims - ); - buffers[name] = linebuffer; - attr.on((new_points) => { - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = to_linepoint_array( - new_points.flat, - is_linesegments, - ndims - ); - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - // instanceBuffer.dispose(); - buffers[name] = attach_interleaved_line_buffer( - name, - geometry, - new_line_points, - ndims - ); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - - geometry.instanceCount = (new_line_points.length - 4) / 4; - buffers[name].needsUpdate = true; - }); - return buffer; - } - let points; - for (let name in attributes) { - const attr = attributes[name]; - points = create_line_buffer(name, attr); - } - - geometry.boundingSphere = new THREE.Sphere(); - // don't use intersection / culling - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - geometry.instanceCount = (points.length - 4) / 4; - - return geometry; -} - -export function create_line(line_data) { - const geometry = create_line_geometry( - line_data.attributes, - line_data.is_linesegments - ); - const material = create_line_material( - line_data.uniforms, - geometry.attributes - ); - return new THREE.Mesh(geometry, material); -} - // global scene cache to look them up for dynamic operations in Makie // e.g. insert!(scene, plot) / delete!(scene, plot) const scene_cache = {}; @@ -440,7 +129,7 @@ function to_uniform(data) { return data; } -function deserialize_uniforms(data) { +export function deserialize_uniforms(data) { const result = {}; // Deno may change constructor names..so... @@ -460,11 +149,17 @@ function deserialize_uniforms(data) { } export function deserialize_plot(data) { - if (data.plot_type === "lines") { - return create_line(data); - } let mesh; - if ("instance_attributes" in data) { + const update_visible = (v) => { + mesh.visible = v; + // don't return anything, since that will disable on_update callback + return; + }; + if (data.plot_type === "lines") { + mesh = create_line(data); + } else if (data.plot_type === "linesegments") { + mesh = create_linesegments(data); + } else if ("instance_attributes" in data) { mesh = create_instanced_mesh(data); } else { mesh = create_mesh(data); @@ -473,15 +168,12 @@ export function deserialize_plot(data) { mesh.frustumCulled = false; mesh.matrixAutoUpdate = false; mesh.plot_uuid = data.uuid; - const update_visible = (v) => { - mesh.visible = v; - // don't return anything, since that will disable on_update callback - return; - }; update_visible(data.visible.value); data.visible.on(update_visible); - connect_uniforms(mesh, data.uniform_updater); - connect_attributes(mesh, data.attribute_updater); + if (!(data.plot_type === "lines" || data.plot_type === "linesegments")) { + connect_uniforms(mesh, data.uniform_updater); + connect_attributes(mesh, data.attribute_updater); + } return mesh; } diff --git a/WGLMakie/src/Shaders.js b/WGLMakie/src/Shaders.js new file mode 100644 index 00000000000..c8cbec783e2 --- /dev/null +++ b/WGLMakie/src/Shaders.js @@ -0,0 +1,58 @@ +function typedarray_to_vectype(typedArray, ndim) { + if (ndim === 1) { + return "float"; + } else if (typedArray instanceof Float32Array) { + return "vec" + ndim; + } else if (typedArray instanceof Int32Array) { + return "ivec" + ndim; + } else if (typedArray instanceof Uint32Array) { + return "uvec" + ndim; + } else { + throw new Error("Unsupported TypedArray type."); + } +} + +function uniform_type(obj) { + if (obj instanceof THREE.Uniform) { + return uniform_type(obj.value); + } else if (typeof obj === "number") { + return "float"; + } else if (obj instanceof THREE.Vector2) { + return "vec2"; + } else if (obj instanceof THREE.Vector3) { + return "vec3"; + } else if (obj instanceof THREE.Vector4) { + return "vec4"; + } else if (obj instanceof THREE.Color) { + return "vec4"; + } else if (obj instanceof THREE.Matrix3) { + return "mat3"; + } else if (obj instanceof THREE.Matrix4) { + return "mat4"; + } else if (obj instanceof THREE.Texture) { + return "sampler2D"; + } else { + return "vec4"; + // throw new Error(`Unssupported uniform type: ${obj}`) + } +} + +export function uniforms_to_type_declaration(uniform_dict) { + let result = ""; + for (const name in uniform_dict) { + const uniform = uniform_dict[name]; + const type = uniform_type(uniform); + result += `uniform ${type} ${name};\n`; + } + return result; +} + +export function attributes_to_type_declaration(attributes_dict) { + let result = ""; + for (const name in attributes_dict) { + const attribute = attributes_dict[name]; + const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + result += `in ${type} ${name};\n`; + } + return result; +} diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 831cb41a597..7e7ebe9c14f 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -1,10 +1,10 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) - Makie.@converted_attribute plot (linewidth, color) + Makie.@converted_attribute plot (linewidth,) uniforms = Dict( - :pattern_length => 1f0, :model => plot.model, - :is_valid => Vec4f(1), ) + + color = plot.calculated_colors attributes = Dict{Symbol, Any}( :linepoint => lift(serialize_buffer_attribute, plot[1]) ) @@ -20,10 +20,8 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, :uuid => js_uuid(plot), - :plot_type => :lines, + :plot_type => plot isa LineSegments ? "linesegments" : "lines", :cam_space => plot.space[], - :is_linesegments => plot isa LineSegments, - :uniforms => serialize_uniforms(uniforms), :attributes => attributes ) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 618db81c88e..33282f09053 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19525,6 +19525,60 @@ function getErrorMessage(version) { element.innerHTML = message; return element; } +function typedarray_to_vectype(typedArray, ndim) { + if (ndim === 1) { + return "float"; + } else if (typedArray instanceof Float32Array) { + return "vec" + ndim; + } else if (typedArray instanceof Int32Array) { + return "ivec" + ndim; + } else if (typedArray instanceof Uint32Array) { + return "uvec" + ndim; + } else { + throw new Error("Unsupported TypedArray type."); + } +} +function uniform_type(obj) { + if (obj instanceof THREE.Uniform) { + return uniform_type(obj.value); + } else if (typeof obj === "number") { + return "float"; + } else if (obj instanceof THREE.Vector2) { + return "vec2"; + } else if (obj instanceof THREE.Vector3) { + return "vec3"; + } else if (obj instanceof THREE.Vector4) { + return "vec4"; + } else if (obj instanceof THREE.Color) { + return "vec4"; + } else if (obj instanceof THREE.Matrix3) { + return "mat3"; + } else if (obj instanceof THREE.Matrix4) { + return "mat4"; + } else if (obj instanceof THREE.Texture) { + return "sampler2D"; + } else { + return "vec4"; + } +} +function uniforms_to_type_declaration(uniform_dict) { + let result = ""; + for(const name in uniform_dict){ + const uniform = uniform_dict[name]; + const type = uniform_type(uniform); + result += `uniform ${type} ${name};\n`; + } + return result; +} +function attributes_to_type_declaration(attributes_dict) { + let result = ""; + for(const name in attributes_dict){ + const attribute = attributes_dict[name]; + const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + result += `in ${type} ${name};\n`; + } + return result; +} const pixelRatio = window.devicePixelRatio || 1.0; function event2scene_pixel(scene, event) { const { canvas } = scene.screen; @@ -19795,60 +19849,7 @@ class MakieCamera { } } } -function typedarray_to_vectype(typedArray, ndim) { - if (ndim === 1) { - return "float"; - } else if (typedArray instanceof Float32Array) { - return "vec" + ndim; - } else if (typedArray instanceof Int32Array) { - return "ivec" + ndim; - } else if (typedArray instanceof Uint32Array) { - return "uvec" + ndim; - } else { - throw new Error("Unsupported TypedArray type."); - } -} -function uniform_type(obj) { - if (obj instanceof mod.Uniform) { - return uniform_type(obj.value); - } else if (typeof obj === "number") { - return "float"; - } else if (obj instanceof mod.Vector2) { - return "vec2"; - } else if (obj instanceof mod.Vector3) { - return "vec3"; - } else if (obj instanceof mod.Vector4) { - return "vec4"; - } else if (obj instanceof mod.Color) { - return "vec4"; - } else if (obj instanceof mod.Matrix3) { - return "mat3"; - } else if (obj instanceof mod.Matrix4) { - return "mat4"; - } else if (obj instanceof mod.Texture) { - return "sampler2D"; - } else { - return "vec4"; - } -} -function uniforms_to_type_declaration(uniform_dict) { - let result = ""; - for(const name in uniform_dict){ - const uniform = uniform_dict[name]; - const type = uniform_type(uniform); - result += `uniform ${type} ${name};\n`; - } - return result; -} -function attributes_to_type_declaration(attributes_dict) { - let result = ""; - for(const name in attributes_dict){ - const attribute = attributes_dict[name]; - const type = typedarray_to_vectype(attribute.array, attribute.itemSize); - result += `in ${type} ${name};\n`; - } - return result; -} +const scene_cache = {}; function lines_shader(uniforms, attributes) { const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); @@ -19870,194 +19871,62 @@ function lines_shader(uniforms, attributes) { return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } - void emit_vertex(vec3 position, vec2 uv, bool is_start) { - - f_uv = uv; - - f_color = is_start ? color_start : color_end; - - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - // linewidth scaling may shrink the effective linewidth - f_thickness = is_start ? linewidth_start : linewidth_end; - } - void main() { - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (linewidth_start / 2.0); + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + // vec3 p_c = screen_space(linepoint_next); + float width = linewidth_start; - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), true); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; + // vec2 pointC = p_c.xy; - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; + + gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + f_color = color_start; } `; } -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; +function lines_shader1(uniforms, attributes) { + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + return `#version 300 es + precision mediump int; + precision highp float; -uniform float pattern_length; + ${attribute_decl} + ${uniform_decl} -out vec4 fragment_color; + out vec2 f_uv; + out vec4 f_color; -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 + vec3 screen_space(vec2 point) { + vec4 vertex = projectionview * model * vec4(point, 0, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + } -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} + void main() { + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + // vec3 p_c = screen_space(linepoint_next); + float width = linewidth_start; -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; + // vec2 pointC = p_c.xy; -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; -void main(){ - fragment_color = f_color; -} -`; -function create_line_material(uniforms, attributes) { - const uniforms_des = deserialize_uniforms(uniforms); - return new mod.RawShaderMaterial({ - uniforms: uniforms_des, - vertexShader: lines_shader(uniforms_des, attributes), - fragmentShader: LINES_FRAG, - transparent: true - }); -} -function to_linepoint_array(linepoints, is_linesegments, ndims) { - const N = linepoints.length; - const duplicate = is_linesegments ? 1 : 2; - const extra = is_linesegments ? 2 * ndims : 0; - const N2 = linepoints.length * duplicate + extra; - const points = new Float32Array(N2); - for(let i = 0; i < ndims; i++){ - points[i] = linepoints[i]; - } - for(let i = 1; i <= ndims; i++){ - points[N2 - i] = linepoints[N - i]; - } - if (is_linesegments) { - points.set(linepoints, ndims); - } else { - for(let i = 0; i < N - ndims; i += ndims){ - for(let j = 0; j < 2 * ndims; j++){ - points[2 * i + ndims + j] = linepoints[i + j]; - } + gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + f_color = color_start; } - } - return points; -} -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { - const buffer = new mod.InstancedInterleavedBuffer(points, ndim * 2, 1); - geometry.setAttribute(attr_name + "_prev", new mod.InterleavedBufferAttribute(buffer, ndim, 0)); - geometry.setAttribute(attr_name + "_start", new mod.InterleavedBufferAttribute(buffer, ndim, ndim)); - geometry.setAttribute(attr_name + "_end", new mod.InterleavedBufferAttribute(buffer, ndim, ndim * 2)); - geometry.setAttribute(attr_name + "_next", new mod.InterleavedBufferAttribute(buffer, ndim, ndim * 3)); - return buffer; -} -function create_line_geometry(attributes, is_linesegments) { - function geometry_buffer() { - const geometry = new mod.InstancedBufferGeometry(); - const instance_positions = [ - 0, - 1, - 2, - 3, - 4, - 5 - ]; - geometry.setAttribute("position", new mod.Float32BufferAttribute(instance_positions, 1)); - return geometry; - } - const geometry = geometry_buffer(); - const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = to_linepoint_array(flat_buffer, is_linesegments, ndims); - const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, ndims); - buffers[name] = linebuffer; - attr.on((new_points)=>{ - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = to_linepoint_array(new_points.flat, is_linesegments, ndims); - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - geometry.instanceCount = (new_line_points.length - 4) / 4; - buffers[name].needsUpdate = true; - }); - return buffer; - } - let points; - for(let name in attributes){ - const attr = attributes[name]; - points = create_line_buffer(name, attr); - } - geometry.boundingSphere = new mod.Sphere(); - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - geometry.instanceCount = (points.length - 4) / 4; - return geometry; -} -function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes, line_data.is_linesegments); - const material = create_line_material(line_data.uniforms, geometry.attributes); - return new mod.Mesh(geometry, material); + `; } -const scene_cache = {}; const plot_cache = {}; const TEXTURE_ATLAS = [ undefined @@ -20170,12 +20039,247 @@ function deserialize_uniforms(data) { } return result; } -function deserialize_plot(data) { - if (data.plot_type === "lines") { - return create_line(data); +const LINES_FRAG = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; +in float f_thickness; + +uniform float pattern_length; + +out vec4 fragment_color; + +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +float aastep_scaled(float threshold1, float threshold2, float dist) { + float AA = ANTIALIAS_RADIUS / pattern_length; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main(){ + fragment_color = f_color; +} +`; +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); + return new THREE.RawShaderMaterial({ + uniforms: uniforms_des, + vertexShader: lines_shader(uniforms_des, attributes), + fragmentShader: LINES_FRAG, + transparent: true + }); +} +function to_linepoint_array(linepoints, ndims) { + const N = linepoints.length; + const N2 = linepoints.length + ndims * 1; + const points = new Float32Array(N2); + for(let i = 1; i <= ndims; i++){ + points[N2 - i] = linepoints[N - i]; + } + points.set(linepoints, 0); + console.log(points); + return points; +} +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { + const buffer = new THREE.InstancedInterleavedBuffer(points, ndim, 1); + buffer.count = points.length / ndim - 1; + geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); + geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); + return buffer; +} +function create_line_geometry(attributes) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, + -0.5, + 1, + -0.5, + 1, + 0.5, + 0, + -0.5, + 1, + 0.5, + 0, + 0.5 + ]; + geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); + return geometry; } + const geometry = geometry_buffer(); + const buffers = {}; + function create_line_buffer(name, attr) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = to_linepoint_array(flat_buffer, ndims); + const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, ndims); + buffers[name] = linebuffer; + attr.on((new_points)=>{ + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = to_linepoint_array(new_points.flat, ndims); + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + buffers[name].needsUpdate = true; + }); + return buffer; + } + for(let name in attributes){ + const attr = attributes[name]; + create_line_buffer(name, attr); + } + geometry.boundingSphere = new THREE.Sphere(); + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} +function create_line(line_data) { + const geometry = create_line_geometry(line_data.attributes); + const material = create_line_material(line_data.uniforms, geometry.attributes); + console.log("------------------"); + console.log(geometry); + return new THREE.Mesh(geometry, material); +} +const LINES_FRAG1 = `#version 300 es +precision mediump int; +precision highp float; +precision mediump sampler2D; +precision mediump sampler3D; + +flat in vec2 f_uv_minmax; +in vec2 f_uv; +in vec4 f_color; + +out vec4 fragment_color; + +// Half width of antialiasing smoothstep +#define ANTIALIAS_RADIUS 0.8 + +float aastep(float threshold1, float dist) { + return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); +} + +float aastep(float threshold1, float threshold2, float dist) { + // We use 2x pixel space in the geometry shaders which passes through + // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS + float AA = 2.0 * ANTIALIAS_RADIUS; + return smoothstep(threshold1 - AA, threshold1 + AA, dist) - + smoothstep(threshold2 - AA, threshold2 + AA, dist); +} + +void main(){ + fragment_color = f_color; +} +`; +function create_line_material1(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); + return new THREE.RawShaderMaterial({ + uniforms: uniforms_des, + vertexShader: lines_shader1(uniforms_des, attributes), + fragmentShader: LINES_FRAG1, + transparent: true + }); +} +function attach_interleaved_line_buffer1(attr_name, geometry, points, ndim) { + const buffer = new THREE.InstancedInterleavedBuffer(points, 2 * ndim, 1); + geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); + geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); + return buffer; +} +function create_linesegment_geometry(attributes) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, + -0.5, + 1, + -0.5, + 1, + 0.5, + 0, + -0.5, + 1, + 0.5, + 0, + 0.5 + ]; + geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); + return geometry; + } + const geometry = geometry_buffer(); + const buffers = {}; + function create_line_buffer(name, attr) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const buffer = flat_buffer; + const linebuffer = attach_interleaved_line_buffer1(name, geometry, buffer, ndims); + buffers[name] = linebuffer; + attr.on((new_points)=>{ + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + buffers[name] = attach_interleaved_line_buffer1(name, geometry, new_line_points, ndims); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + buffers[name].needsUpdate = true; + }); + return buffer; + } + let points; + for(let name in attributes){ + const attr = attributes[name]; + points = create_line_buffer(name, attr); + } + geometry.boundingSphere = new THREE.Sphere(); + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} +function create_linesegments(line_data) { + const geometry = create_linesegment_geometry(line_data.attributes); + const material = create_line_material1(line_data.uniforms, geometry.attributes); + return new THREE.Mesh(geometry, material); +} +function deserialize_plot(data) { let mesh; - if ("instance_attributes" in data) { + const update_visible = (v)=>{ + mesh.visible = v; + return; + }; + if (data.plot_type === "lines") { + mesh = create_line(data); + } else if (data.plot_type === "linesegments") { + mesh = create_linesegments(data); + } else if ("instance_attributes" in data) { mesh = create_instanced_mesh(data); } else { mesh = create_mesh(data); @@ -20184,14 +20288,12 @@ function deserialize_plot(data) { mesh.frustumCulled = false; mesh.matrixAutoUpdate = false; mesh.plot_uuid = data.uuid; - const update_visible = (v)=>{ - mesh.visible = v; - return; - }; update_visible(data.visible.value); data.visible.on(update_visible); - connect_uniforms(mesh, data.uniform_updater); - connect_attributes(mesh, data.attribute_updater); + if (!(data.plot_type === "lines" || data.plot_type === "linesegments")) { + connect_uniforms(mesh, data.uniform_updater); + connect_attributes(mesh, data.attribute_updater); + } return mesh; } const ON_NEXT_INSERT = new Set(); From 9a4fa9e77f7c1453b850bc853dcf53c3093d444c Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 8 Aug 2023 20:08:49 +0200 Subject: [PATCH 11/28] refactor shaders + file structure --- WGLMakie/assets/lines.vert | 14 +- WGLMakie/src/Camera.js | 2 +- WGLMakie/src/Lines.js | 339 +++++++++++++++++-------- WGLMakie/src/Linesegments.js | 159 ++++++++---- WGLMakie/src/Serialization.js | 10 +- WGLMakie/src/Shaders.js | 19 +- WGLMakie/src/lines.jl | 13 + WGLMakie/src/wglmakie.bundled.js | 419 ++++++++++++------------------- WGLMakie/src/wglmakie.js | 9 +- 9 files changed, 560 insertions(+), 424 deletions(-) diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert index b2d662d61da..c0dbdfabdc1 100644 --- a/WGLMakie/assets/lines.vert +++ b/WGLMakie/assets/lines.vert @@ -1,6 +1,5 @@ #version 300 es - in float position; in vec2 linepoint_prev; in vec2 linepoint_start; @@ -14,23 +13,24 @@ in float linewidth_next; uniform vec4 is_valid; uniform vec4 color_end; uniform vec4 color_start; -uniform float pattern_length; uniform mat4 model; -uniform mat4 view; -uniform mat4 projection; uniform mat4 projectionview; -uniform vec3 eyeposition; uniform vec2 resolution; out vec2 f_uv; out vec4 f_color; out float f_thickness; -vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); +vec3 screen_space(vec3 point) { + vec4 vertex = projectionview * model * vec4(point, 1); return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } +vec3 screen_space(vec2 point) { + return screen_space(vec3(point, 0)); +} + + void emit_vertex(vec3 position, vec2 uv, bool is_start) { f_uv = uv; diff --git a/WGLMakie/src/Camera.js b/WGLMakie/src/Camera.js index 25223aca629..adf1fccac52 100644 --- a/WGLMakie/src/Camera.js +++ b/WGLMakie/src/Camera.js @@ -268,7 +268,7 @@ export class MakieCamera { update_matrices(view, projection, resolution, eyepos) { this.view.value.fromArray(view); this.projection.value.fromArray(projection); - this.resolution.value.fromArray(resolution); + this.resolution.value.fromArray(resolution.map(x=> Math.ceil(x / pixelRatio))); this.eyeposition.value.fromArray(eyepos); this.calculate_matrices(); return; diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index 674a2892a82..f5ab653f069 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -1,124 +1,175 @@ import { attributes_to_type_declaration, uniforms_to_type_declaration, + uniform_type, + attribute_type, } from "./Shaders.js"; -import { - deserialize_uniforms, -} from "./Serialization.js" +import { deserialize_uniforms } from "./Serialization.js"; + +function filter_by_key(dict, keys, default_value = false) { + const result = {}; + keys.forEach((key) => { + const val = dict[key]; + if (val) { + result[key] = val; + } else { + result[key] = default_value; + } + }); + return result; +} -function lines_shader(uniforms, attributes) { +// https://github.com/glslify/glsl-aastep +// https://wwwtyro.net/2019/11/18/instanced-lines.html +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master +function linesegments_vertex_shader(uniforms, attributes) { const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); + const color = + attribute_type(attributes.color_start) || + uniform_type(uniforms.color_start); return `#version 300 es precision mediump int; precision highp float; - precision mediump sampler2D; - precision mediump sampler3D; ${attribute_decl} ${uniform_decl} out vec2 f_uv; - out vec4 f_color; - out float f_thickness; + out ${color} f_color; - vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); + vec3 screen_space(vec3 point) { + vec4 vertex = projectionview * model * vec4(point, 1); return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } + vec3 screen_space(vec2 point) { + return screen_space(vec3(point, 0)); + } + void main() { vec3 p_a = screen_space(linepoint_start); vec3 p_b = screen_space(linepoint_end); - // vec3 p_c = screen_space(linepoint_next); - float width = linewidth_start; + float width = (position.x == 1.0 ? linewidth_end : linewidth_start); + f_color = position.x == 1.0 ? color_end : color_start; + f_uv = vec2(position.x, position.y + 0.5); vec2 pointA = p_a.xy; vec2 pointB = p_b.xy; - // vec2 pointC = p_c.xy; vec2 xBasis = pointB - pointA; vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - f_color = color_start; } `; } -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; +function lines_fragment_shader(uniforms, attributes) { + const color = + attribute_type(attributes.color_start) || + uniform_type(uniforms.color_start); + const color_uniforms = filter_by_key(uniforms, [ + "colorrange", + "colormap", + "nan_color", + "highclip", + "lowclip", + ]); + const uniform_decl = uniforms_to_type_declaration(color_uniforms); -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; + return `#version 300 es + #extension GL_OES_standard_derivatives : enable -uniform float pattern_length; + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; -out vec4 fragment_color; + in vec2 f_uv; + in ${color} f_color; + ${uniform_decl} -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 + out vec4 fragment_color; -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} + // Half width of antialiasing smoothstep + #define ANTIALIAS_RADIUS 0.7071067811865476 -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { + float cmin = colorrange.x; + float cmax = colorrange.y; + if (value <= cmax && value >= cmin) { + // in value range, continue! + } else if (value < cmin) { + return lowclip; + } else if (value > cmax) { + return highclip; + } else { + // isnan CAN be broken (of course) -.- + // so if outside value range and not smaller/bigger min/max we assume NaN + return nan_color; + } + float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); + // 1/0 corresponds to the corner of the colormap, so to properly interpolate + // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). + float stepsize = 1.0 / float(textureSize(colormap, 0)); + i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; + return texture(colormap, vec2(i01, 0.0)); + } -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { + return get_color_from_cmap(color, colormap, colorrange); + } -void main(){ - fragment_color = f_color; + vec4 get_color(vec4 color, bool colormap, bool colorrange) { + return color; + } + vec4 get_color(vec3 color, bool colormap, bool colorrange) { + return vec4(color, 1.0); + } + + float aastep(float threshold, float value) { + float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; + return smoothstep(threshold-afwidth, threshold+afwidth, value); + } + + float aastep(float threshold1, float threshold2, float dist) { + return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); + } + + void main(){ + float xalpha = aastep(0.0, 0.0, f_uv.x); + float yalpha = aastep(0.0, 0.0, f_uv.y); + vec4 color = get_color(f_color, colormap, colorrange); + fragment_color = vec4(color.rgb, color.a); + } + `; } -`; + function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); + uniforms_des.pixel_ratio = new THREE.Uniform(window.devicePixelRatio || 1.0); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, - vertexShader: lines_shader(uniforms_des, attributes), - fragmentShader: LINES_FRAG, + vertexShader: linesegments_vertex_shader(uniforms_des, attributes), + fragmentShader: lines_fragment_shader(uniforms_des, attributes), transparent: true, }); } -function to_linepoint_array(linepoints, ndims) { - const N = linepoints.length; - const N2 = linepoints.length + (ndims * 1); - const points = new Float32Array(N2); - // copy over first and last point - // for (let i = 0; i < ndims; i++) { - // points[i] = linepoints[i]; - // } - for (let i = 1; i <= ndims; i++) { - points[N2 - i] = linepoints[N - i]; +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { + const skip_elems = is_segments ? 2 * ndim : ndim; + const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); + if (!is_segments) { + buffer.count = points.length / ndim - 1; } - points.set(linepoints, 0); - console.log(points); - return points; -} - -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { - const buffer = new THREE.InstancedInterleavedBuffer(points, ndim, 1); - buffer.count = (points.length / ndim) - 1; geometry.setAttribute( attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0) @@ -130,11 +181,54 @@ function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { return buffer; } -function create_line_geometry(attributes) { + +function create_line_buffer(buffers, geometry, name, attr, is_segments) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const linebuffer = attach_interleaved_line_buffer( + name, + geometry, + flat_buffer, + ndims, + is_segments + ); + buffers[name] = linebuffer; + attr.on((new_points) => { + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + // instanceBuffer.dispose(); + buffers[name] = attach_interleaved_line_buffer( + name, + geometry, + new_line_points, + ndims, + is_segments + ); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + + // geometry.instanceCount = (new_line_points.length - 4) / 4; + buffers[name].needsUpdate = true; + }); + return flat_buffer; +} + +function create_line_geometry(attributes, is_segments) { function geometry_buffer() { const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [ - 0, -0.5, 1, -0.5, 1, 0.5, 0, -0.5, 1, 0.5, 0, 0.5, + 0, -0.5, + 1, -0.5, + 1, 0.5, + + 0, -0.5, + 1, 0.5, + 0, 0.5, ]; geometry.setAttribute( "position", @@ -145,44 +239,10 @@ function create_line_geometry(attributes) { const geometry = geometry_buffer(); const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = to_linepoint_array(flat_buffer, ndims); - const linebuffer = attach_interleaved_line_buffer( - name, - geometry, - buffer, - ndims - ); - buffers[name] = linebuffer; - attr.on((new_points) => { - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = to_linepoint_array(new_points.flat, ndims); - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - // instanceBuffer.dispose(); - buffers[name] = attach_interleaved_line_buffer( - name, - geometry, - new_line_points, - ndims - ); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - - // geometry.instanceCount = (new_line_points.length - 4) / 4; - buffers[name].needsUpdate = true; - }); - return buffer; - } for (let name in attributes) { const attr = attributes[name]; - create_line_buffer(name, attr); + create_line_buffer(buffers, geometry, name, attr, is_segments); } geometry.boundingSphere = new THREE.Sphere(); @@ -193,12 +253,81 @@ function create_line_geometry(attributes) { } export function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes); + const geometry = create_line_geometry(line_data.attributes, false); + const material = create_line_material( + line_data.uniforms, + geometry.attributes + ); + return new THREE.Mesh(geometry, material); +} + +export function create_linesegments(line_data) { + const geometry = create_line_geometry(line_data.attributes, true); const material = create_line_material( line_data.uniforms, geometry.attributes ); - console.log("------------------"); - console.log(geometry); return new THREE.Mesh(geometry, material); } + +function interpolate(p1, p2, t) { + return [p1[0] + t * (p2[0] - p1[0]), p1[1] + t * (p2[1] - p1[1])]; +} + +function distance(p1, p2) { + const dx = p2[0] - p1[0]; + const dy = p2[1] - p1[1]; + return Math.sqrt(dx * dx + dy * dy); +} + +function compute_distances(points) { + if (points.length < 2 || points.length % 2 !== 0) { + throw new Error( + "The points array should have an even length and at least 2 points (x and y)." + ); + } + const distances = [0.0]; + let dist = 0.0; + for (let i = 0; i < points.length - 2; i += 2) { + const p1 = [points[i], points[i + 1]]; + const p2 = [points[i + 2], points[i + 3]]; + dist += distance(p1, p2); + distances.push(dist); + } + return distances; +} + +function resample_point(points, distances, target_distance, last_index) { + for (let i = last_index; i < distances.length; i++) { + if (distances[i] > target_distance) { + const p1 = [points[i * 2 - 2], points[i * 2 - 1]]; + const p2 = [points[i * 2], points[i * 2 + 1]]; + const width = distance[i] - distance[i - 1]; + const t = (target_distance - distances[i - 1]) / width; + return [interpolate(p1, p2, t)]; + } + } + return [null, last_index]; +} + +function resample_points(points, pattern) { + const distances = compute_distances(points); + let resampled_points = []; + let step_index = 0; + let current_length = pattern[step_index]; + let last_index = 0; + + while (current_length < distances[distances.length - 1]) { + const [_last_index, point] = resample_point( + points, + distances, + current_length, + last_index + ); + last_index = _last_index; + resampled_points.push(...point); + step_index = (step_index + 1) % pattern.length; + current_length += pattern[step_index]; + } + return new Float32Array(resampled_points); +} diff --git a/WGLMakie/src/Linesegments.js b/WGLMakie/src/Linesegments.js index 0b7e069a62b..03ec5c5e525 100644 --- a/WGLMakie/src/Linesegments.js +++ b/WGLMakie/src/Linesegments.js @@ -1,12 +1,38 @@ import { attributes_to_type_declaration, uniforms_to_type_declaration, + uniform_type, + attribute_type } from "./Shaders.js"; import { deserialize_uniforms } from "./Serialization.js"; -function lines_shader(uniforms, attributes) { + +function filter_by_key(dict, keys, default_value=false) { + const result = {}; + keys.forEach(key => { + const val = dict[key]; + if (val) { + result[key] = val; + } else { + result[key] = default_value; + } + }) + return result; +} + +// https://github.com/glslify/glsl-aastep +// https://wwwtyro.net/2019/11/18/instanced-lines.html +// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js +// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf +// https://github.com/gameofbombs/pixi-candles/tree/master/src +// https://github.com/wwwtyro/instanced-lines-demos/tree/master + +function lines_vertex_shader(uniforms, attributes) { const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); + const color = + attribute_type(attributes.color_start) || + uniform_type(uniforms.color_start); return `#version 300 es precision mediump int; @@ -16,82 +42,122 @@ function lines_shader(uniforms, attributes) { ${uniform_decl} out vec2 f_uv; - out vec4 f_color; + out ${color} f_color; - vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); + vec3 screen_space(vec3 point) { + vec4 vertex = projectionview * model * vec4(point, 1); return vec3(vertex.xy * resolution, vertex.z) / vertex.w; } + vec3 screen_space(vec2 point) { + return screen_space(vec3(point, 0)); + } + void main() { vec3 p_a = screen_space(linepoint_start); vec3 p_b = screen_space(linepoint_end); - // vec3 p_c = screen_space(linepoint_next); - float width = linewidth_start; + float width = position.x == 1.0 ? linewidth_end : linewidth_start ; vec2 pointA = p_a.xy; vec2 pointB = p_b.xy; - // vec2 pointC = p_c.xy; vec2 xBasis = pointB - pointA; vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - f_color = color_start; + f_color = position.x == 1.0 ? color_end : color_start; + f_uv = vec2(position.x, position.y + 0.5); } `; } -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; +function lines_fragment_shader(uniforms, attributes) { + const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); + const color_uniforms = filter_by_key(uniforms, ["colorrange", "colormap", "nan_color", "highclip", "lowclip"]); + const uniform_decl = uniforms_to_type_declaration(color_uniforms); -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; + return `#version 300 es + #extension GL_OES_standard_derivatives : enable + + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; + + in vec2 f_uv; + in ${color} f_color; + ${uniform_decl} + + out vec4 fragment_color; + + // Half width of antialiasing smoothstep + #define ANTIALIAS_RADIUS 1.0 + + vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { + float cmin = colorrange.x; + float cmax = colorrange.y; + if (value <= cmax && value >= cmin) { + // in value range, continue! + } else if (value < cmin) { + return lowclip; + } else if (value > cmax) { + return highclip; + } else { + // isnan CAN be broken (of course) -.- + // so if outside value range and not smaller/bigger min/max we assume NaN + return nan_color; + } + float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); + // 1/0 corresponds to the corner of the colormap, so to properly interpolate + // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). + float stepsize = 1.0 / float(textureSize(colormap, 0)); + i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; + return texture(colormap, vec2(i01, 0.0)); + } -out vec4 fragment_color; + vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { + return get_color_from_cmap(color, colormap, colorrange); + } -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 + vec4 get_color(vec4 color, bool colormap, bool colorrange) { + return color; + } + vec4 get_color(vec3 color, bool colormap, bool colorrange) { + return vec4(color, 1.0); + } -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} + float aastep(float threshold, float value) { + float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; + return smoothstep(threshold-afwidth, threshold+afwidth, value); + } -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + float aastep(float threshold1, float threshold2, float dist) { + return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); + } -void main(){ - fragment_color = f_color; + void main(){ + float xalpha = aastep(0.0, 0.0, f_uv.x); + float yalpha = aastep(0.0, 0.0, f_uv.y); + vec4 color = get_color(f_color, colormap, colorrange); + fragment_color = vec4(color.rgb, color.a); + } + `; } -`; function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); + const fragi = lines_fragment_shader(uniforms_des, attributes); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, - vertexShader: lines_shader(uniforms_des, attributes), - fragmentShader: LINES_FRAG, + vertexShader: lines_vertex_shader(uniforms_des, attributes), + fragmentShader: fragi, transparent: true, }); } -function attach_interleaved_line_buffer( - attr_name, - geometry, - points, - ndim, -) { - const buffer = new THREE.InstancedInterleavedBuffer(points, 2*ndim, 1); +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { + const buffer = new THREE.InstancedInterleavedBuffer(points, 2 * ndim, 1); geometry.setAttribute( attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0) @@ -140,7 +206,7 @@ function create_linesegment_geometry(attributes) { name, geometry, new_line_points, - ndims, + ndims ); } else { buff.updateRange.count = new_line_points.length; @@ -170,3 +236,12 @@ export function create_linesegments(line_data) { ); return new THREE.Mesh(geometry, material); } + +export function create_linesegments(line_data) { + const geometry = create_linesegment_geometry(line_data.attributes); + const material = create_line_material( + line_data.uniforms, + geometry.attributes + ); + return new THREE.Mesh(geometry, material); +} diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 67483124dd7..e4efb3cb0a7 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -1,14 +1,9 @@ import * as Camera from "./Camera.js"; -import {create_line} from "./Lines.js"; -import { create_linesegments } from "./Linesegments.js"; +import { create_line, create_linesegments } from "./Lines.js"; import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; -//https://wwwtyro.net/2019/11/18/instanced-lines.html -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master + // global scene cache to look them up for dynamic operations in Makie // e.g. insert!(scene, plot) / delete!(scene, plot) @@ -206,7 +201,6 @@ export function add_plot(scene, plot_data) { plot_data.uniforms.projection = identity; plot_data.uniforms.projectionview = identity; } - plot_data.uniforms.resolution = cam.resolution; if (plot_data.uniforms.preprojection) { diff --git a/WGLMakie/src/Shaders.js b/WGLMakie/src/Shaders.js index c8cbec783e2..4d6959673e9 100644 --- a/WGLMakie/src/Shaders.js +++ b/WGLMakie/src/Shaders.js @@ -8,15 +8,25 @@ function typedarray_to_vectype(typedArray, ndim) { } else if (typedArray instanceof Uint32Array) { return "uvec" + ndim; } else { - throw new Error("Unsupported TypedArray type."); + return; } } -function uniform_type(obj) { +export function attribute_type(attribute) { + if (attribute) { + return typedarray_to_vectype(attribute.array, attribute.itemSize); + } else { + return; + } +} + +export function uniform_type(obj) { if (obj instanceof THREE.Uniform) { return uniform_type(obj.value); } else if (typeof obj === "number") { return "float"; + } else if (typeof obj === "boolean") { + return "bool"; } else if (obj instanceof THREE.Vector2) { return "vec2"; } else if (obj instanceof THREE.Vector3) { @@ -32,8 +42,7 @@ function uniform_type(obj) { } else if (obj instanceof THREE.Texture) { return "sampler2D"; } else { - return "vec4"; - // throw new Error(`Unssupported uniform type: ${obj}`) + return; } } @@ -51,7 +60,7 @@ export function attributes_to_type_declaration(attributes_dict) { let result = ""; for (const name in attributes_dict) { const attribute = attributes_dict[name]; - const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + const type = attribute_type(attribute); result += `in ${type} ${name};\n`; } return result; diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 7e7ebe9c14f..6d1d9930cc4 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -5,6 +5,18 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) ) color = plot.calculated_colors + if color[] isa Makie.ColorMap + uniforms[:colormap] = Sampler(color[].colormap) + uniforms[:colorrange] = color[].colorrange_scaled + uniforms[:highclip] = Makie.highclip(color[]) + uniforms[:lowclip] = Makie.lowclip(color[]) + uniforms[:nan_color] = color[].nan_color + color = color[].color_scaled + else + for name in [:nan_color, :highclip, :lowclip] + uniforms[name] = RGBAf(0, 0, 0, 0) + end + end attributes = Dict{Symbol, Any}( :linepoint => lift(serialize_buffer_attribute, plot[1]) ) @@ -16,6 +28,7 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) attributes[name] = lift(serialize_buffer_attribute, attr) end end + attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 33282f09053..2db0eba6c45 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -19535,7 +19535,14 @@ function typedarray_to_vectype(typedArray, ndim) { } else if (typedArray instanceof Uint32Array) { return "uvec" + ndim; } else { - throw new Error("Unsupported TypedArray type."); + return; + } +} +function attribute_type(attribute) { + if (attribute) { + return typedarray_to_vectype(attribute.array, attribute.itemSize); + } else { + return; } } function uniform_type(obj) { @@ -19543,6 +19550,8 @@ function uniform_type(obj) { return uniform_type(obj.value); } else if (typeof obj === "number") { return "float"; + } else if (typeof obj === "boolean") { + return "bool"; } else if (obj instanceof THREE.Vector2) { return "vec2"; } else if (obj instanceof THREE.Vector3) { @@ -19558,7 +19567,7 @@ function uniform_type(obj) { } else if (obj instanceof THREE.Texture) { return "sampler2D"; } else { - return "vec4"; + return; } } function uniforms_to_type_declaration(uniform_dict) { @@ -19574,7 +19583,7 @@ function attributes_to_type_declaration(attributes_dict) { let result = ""; for(const name in attributes_dict){ const attribute = attributes_dict[name]; - const type = typedarray_to_vectype(attribute.array, attribute.itemSize); + const type = attribute_type(attribute); result += `in ${type} ${name};\n`; } return result; @@ -19797,7 +19806,7 @@ class MakieCamera { update_matrices(view, projection, resolution, eyepos) { this.view.value.fromArray(view); this.projection.value.fromArray(projection); - this.resolution.value.fromArray(resolution); + this.resolution.value.fromArray(resolution.map((x)=>Math.ceil(x / pixelRatio))); this.eyeposition.value.fromArray(eyepos); this.calculate_matrices(); return; @@ -19850,82 +19859,17 @@ class MakieCamera { } } const scene_cache = {}; -function lines_shader(uniforms, attributes) { - const attribute_decl = attributes_to_type_declaration(attributes); - const uniform_decl = uniforms_to_type_declaration(uniforms); - return `#version 300 es - precision mediump int; - precision highp float; - precision mediump sampler2D; - precision mediump sampler3D; - - ${attribute_decl} - ${uniform_decl} - - out vec2 f_uv; - out vec4 f_color; - out float f_thickness; - - vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; - } - - void main() { - vec3 p_a = screen_space(linepoint_start); - vec3 p_b = screen_space(linepoint_end); - // vec3 p_c = screen_space(linepoint_next); - float width = linewidth_start; - - vec2 pointA = p_a.xy; - vec2 pointB = p_b.xy; - // vec2 pointC = p_c.xy; - - vec2 xBasis = pointB - pointA; - vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); - vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; - - gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - f_color = color_start; - } - `; -} -function lines_shader1(uniforms, attributes) { - const attribute_decl = attributes_to_type_declaration(attributes); - const uniform_decl = uniforms_to_type_declaration(uniforms); - return `#version 300 es - precision mediump int; - precision highp float; - - ${attribute_decl} - ${uniform_decl} - - out vec2 f_uv; - out vec4 f_color; - - vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; - } - - void main() { - vec3 p_a = screen_space(linepoint_start); - vec3 p_b = screen_space(linepoint_end); - // vec3 p_c = screen_space(linepoint_next); - float width = linewidth_start; - - vec2 pointA = p_a.xy; - vec2 pointB = p_b.xy; - // vec2 pointC = p_c.xy; - - vec2 xBasis = pointB - pointA; - vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); - vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; - - gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - f_color = color_start; +function filter_by_key(dict, keys, default_value = false) { + const result = {}; + keys.forEach((key)=>{ + const val = dict[key]; + if (val) { + result[key] = val; + } else { + result[key] = default_value; } - `; + }); + return result; } const plot_cache = {}; const TEXTURE_ATLAS = [ @@ -20039,179 +19983,165 @@ function deserialize_uniforms(data) { } return result; } -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; +function linesegments_vertex_shader(uniforms, attributes) { + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); + return `#version 300 es + precision mediump int; + precision highp float; -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; + ${attribute_decl} + ${uniform_decl} -uniform float pattern_length; + out vec2 f_uv; + out ${color} f_color; -out vec4 fragment_color; + vec3 screen_space(vec3 point) { + vec4 vertex = projectionview * model * vec4(point, 1); + return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + } -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 + vec3 screen_space(vec2 point) { + return screen_space(vec3(point, 0)); + } -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} + void main() { + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + float width = (position.x == 1.0 ? linewidth_end : linewidth_start); + f_color = position.x == 1.0 ? color_end : color_start; + f_uv = vec2(position.x, position.y + 0.5); -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; -void main(){ - fragment_color = f_color; -} -`; -function create_line_material(uniforms, attributes) { - const uniforms_des = deserialize_uniforms(uniforms); - return new THREE.RawShaderMaterial({ - uniforms: uniforms_des, - vertexShader: lines_shader(uniforms_des, attributes), - fragmentShader: LINES_FRAG, - transparent: true - }); + gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + } + `; } -function to_linepoint_array(linepoints, ndims) { - const N = linepoints.length; - const N2 = linepoints.length + ndims * 1; - const points = new Float32Array(N2); - for(let i = 1; i <= ndims; i++){ - points[N2 - i] = linepoints[N - i]; +function lines_fragment_shader(uniforms, attributes) { + const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); + const color_uniforms = filter_by_key(uniforms, [ + "colorrange", + "colormap", + "nan_color", + "highclip", + "lowclip" + ]); + const uniform_decl = uniforms_to_type_declaration(color_uniforms); + return `#version 300 es + #extension GL_OES_standard_derivatives : enable + + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; + + in vec2 f_uv; + in ${color} f_color; + ${uniform_decl} + + out vec4 fragment_color; + + // Half width of antialiasing smoothstep + #define ANTIALIAS_RADIUS 0.7071067811865476 + + vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { + float cmin = colorrange.x; + float cmax = colorrange.y; + if (value <= cmax && value >= cmin) { + // in value range, continue! + } else if (value < cmin) { + return lowclip; + } else if (value > cmax) { + return highclip; + } else { + // isnan CAN be broken (of course) -.- + // so if outside value range and not smaller/bigger min/max we assume NaN + return nan_color; + } + float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); + // 1/0 corresponds to the corner of the colormap, so to properly interpolate + // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). + float stepsize = 1.0 / float(textureSize(colormap, 0)); + i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; + return texture(colormap, vec2(i01, 0.0)); } - points.set(linepoints, 0); - console.log(points); - return points; -} -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { - const buffer = new THREE.InstancedInterleavedBuffer(points, ndim, 1); - buffer.count = points.length / ndim - 1; - geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); - geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); - return buffer; -} -function create_line_geometry(attributes) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [ - 0, - -0.5, - 1, - -0.5, - 1, - 0.5, - 0, - -0.5, - 1, - 0.5, - 0, - 0.5 - ]; - geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); - return geometry; + + vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { + return get_color_from_cmap(color, colormap, colorrange); } - const geometry = geometry_buffer(); - const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = to_linepoint_array(flat_buffer, ndims); - const linebuffer = attach_interleaved_line_buffer(name, geometry, buffer, ndims); - buffers[name] = linebuffer; - attr.on((new_points)=>{ - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = to_linepoint_array(new_points.flat, ndims); - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - buffers[name].needsUpdate = true; - }); - return buffer; + + vec4 get_color(vec4 color, bool colormap, bool colorrange) { + return color; } - for(let name in attributes){ - const attr = attributes[name]; - create_line_buffer(name, attr); + vec4 get_color(vec3 color, bool colormap, bool colorrange) { + return vec4(color, 1.0); } - geometry.boundingSphere = new THREE.Sphere(); - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - return geometry; -} -function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes); - const material = create_line_material(line_data.uniforms, geometry.attributes); - console.log("------------------"); - console.log(geometry); - return new THREE.Mesh(geometry, material); -} -const LINES_FRAG1 = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; - -out vec4 fragment_color; -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 - -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} + float aastep(float threshold, float value) { + float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; + return smoothstep(threshold-afwidth, threshold+afwidth, value); + } -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} + float aastep(float threshold1, float threshold2, float dist) { + return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); + } -void main(){ - fragment_color = f_color; + void main(){ + float xalpha = aastep(0.0, 0.0, f_uv.x); + float yalpha = aastep(0.0, 0.0, f_uv.y); + vec4 color = get_color(f_color, colormap, colorrange); + fragment_color = vec4(color.rgb, color.a); + } + `; } -`; -function create_line_material1(uniforms, attributes) { +function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); + uniforms_des.pixel_ratio = new THREE.Uniform(window.devicePixelRatio || 1.0); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, - vertexShader: lines_shader1(uniforms_des, attributes), - fragmentShader: LINES_FRAG1, + vertexShader: linesegments_vertex_shader(uniforms_des, attributes), + fragmentShader: lines_fragment_shader(uniforms_des, attributes), transparent: true }); } -function attach_interleaved_line_buffer1(attr_name, geometry, points, ndim) { - const buffer = new THREE.InstancedInterleavedBuffer(points, 2 * ndim, 1); +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { + const skip_elems = is_segments ? 2 * ndim : ndim; + const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); + if (!is_segments) { + buffer.count = points.length / ndim - 1; + } geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); return buffer; } -function create_linesegment_geometry(attributes) { +function create_line_buffer(buffers, geometry, name, attr, is_segments) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const linebuffer = attach_interleaved_line_buffer(name, geometry, flat_buffer, ndims, is_segments); + buffers[name] = linebuffer; + attr.on((new_points)=>{ + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims, is_segments); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + buffers[name].needsUpdate = true; + }); + return flat_buffer; +} +function create_line_geometry(attributes, is_segments) { function geometry_buffer() { const geometry = new THREE.InstancedBufferGeometry(); const instance_positions = [ @@ -20233,40 +20163,23 @@ function create_linesegment_geometry(attributes) { } const geometry = geometry_buffer(); const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = flat_buffer; - const linebuffer = attach_interleaved_line_buffer1(name, geometry, buffer, ndims); - buffers[name] = linebuffer; - attr.on((new_points)=>{ - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer1(name, geometry, new_line_points, ndims); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - buffers[name].needsUpdate = true; - }); - return buffer; - } - let points; for(let name in attributes){ const attr = attributes[name]; - points = create_line_buffer(name, attr); + create_line_buffer(buffers, geometry, name, attr, is_segments); } geometry.boundingSphere = new THREE.Sphere(); geometry.boundingSphere.radius = 10000000000000; geometry.frustumCulled = false; return geometry; } +function create_line(line_data) { + const geometry = create_line_geometry(line_data.attributes, false); + const material = create_line_material(line_data.uniforms, geometry.attributes); + return new THREE.Mesh(geometry, material); +} function create_linesegments(line_data) { - const geometry = create_linesegment_geometry(line_data.attributes); - const material = create_line_material1(line_data.uniforms, geometry.attributes); + const geometry = create_line_geometry(line_data.attributes, true); + const material = create_line_material(line_data.uniforms, geometry.attributes); return new THREE.Mesh(geometry, material); } function deserialize_plot(data) { @@ -20615,7 +20528,7 @@ function render_scene(scene, picking = false) { renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; if (area) { - const [x, y, w, h] = area.map((t)=>t / pixelRatio1); + const [x, y, w, h] = area.map((t)=>Math.ceil(t / pixelRatio1)); renderer.setViewport(x, y, w, h); renderer.setScissor(x, y, w, h); renderer.setScissorTest(true); @@ -20685,7 +20598,7 @@ function threejs_module(canvas, comm, width, height, resize_to_body) { }); renderer.setClearColor("#ffffff"); renderer.setPixelRatio(pixelRatio1); - renderer.setSize(width / pixelRatio1, height / pixelRatio1); + renderer.setSize(Math.ceil(width / pixelRatio1), Math.ceil(height / pixelRatio1)); const mouse_callback = (x, y)=>comm.notify({ mouseposition: [ x, @@ -20789,7 +20702,7 @@ function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height start_renderloop(three_scene); canvas_width.on((w_h)=>{ const pixelRatio = renderer.getPixelRatio(); - renderer.setSize(w_h[0] / pixelRatio, w_h[1] / pixelRatio); + renderer.setSize(Math.ceil(w_h[0] / pixelRatio), Math.ceil(w_h[1] / pixelRatio)); }); } else { const warning = getWebGLErrorMessage(); diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index e983ed297e2..a4597aae664 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -38,7 +38,7 @@ export function render_scene(scene, picking = false) { renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; if (area) { - const [x, y, w, h] = area.map((t) => t / pixelRatio); + const [x, y, w, h] = area.map((t) => Math.ceil(t / pixelRatio)); renderer.setViewport(x, y, w, h); renderer.setScissor(x, y, w, h); renderer.setScissorTest(true); @@ -141,7 +141,10 @@ function threejs_module(canvas, comm, width, height, resize_to_body) { // The following handles high-DPI devices // `renderer.setSize` also updates `canvas` size renderer.setPixelRatio(pixelRatio); - renderer.setSize(width / pixelRatio, height / pixelRatio); + renderer.setSize( + Math.ceil(width / pixelRatio), + Math.ceil(height / pixelRatio) + ); const mouse_callback = (x, y) => comm.notify({ mouseposition: [x, y] }); const notify_mouse_throttled = throttle_function(mouse_callback, 40); @@ -291,7 +294,7 @@ function create_scene( canvas_width.on((w_h) => { // `renderer.setSize` correctly updates `canvas` dimensions const pixelRatio = renderer.getPixelRatio(); - renderer.setSize(w_h[0] / pixelRatio, w_h[1] / pixelRatio); + renderer.setSize(Math.ceil(w_h[0] / pixelRatio), Math.ceil(w_h[1] / pixelRatio)); }); } else { const warning = getWebGLErrorMessage(); From 2b2cc59d616a34d5cd76042ed63e242f767f0128 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 8 Aug 2023 20:09:29 +0200 Subject: [PATCH 12/28] allow new electron --- WGLMakie/test/Project.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/WGLMakie/test/Project.toml b/WGLMakie/test/Project.toml index 0edb0064c73..a57572ec582 100644 --- a/WGLMakie/test/Project.toml +++ b/WGLMakie/test/Project.toml @@ -5,6 +5,3 @@ JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -Electron = "4.1.1" From c304e213ffa7e1d36f56d248ec425d19a4a71226 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 8 Aug 2023 21:16:24 +0200 Subject: [PATCH 13/28] fix scaling --- WGLMakie/assets/sprites.vert | 2 +- WGLMakie/src/Camera.js | 2 +- WGLMakie/src/Lines.js | 13 +- WGLMakie/src/Serialization.js | 2 + WGLMakie/src/particles.jl | 1 + WGLMakie/src/wglmakie.bundled.js | 20934 ----------------------------- WGLMakie/src/wglmakie.js | 9 +- 7 files changed, 17 insertions(+), 20946 deletions(-) delete mode 100644 WGLMakie/src/wglmakie.bundled.js diff --git a/WGLMakie/assets/sprites.vert b/WGLMakie/assets/sprites.vert index 42a7c4a9cc6..c077fa62446 100644 --- a/WGLMakie/assets/sprites.vert +++ b/WGLMakie/assets/sprites.vert @@ -88,7 +88,7 @@ void main(){ 0.0, 0.0, 1.0/vclip.w, 0.0, -vclip.xyz/(vclip.w*vclip.w), 0.0 ); - mat2 dxyv_dxys = diagm(0.5 * get_resolution()) * mat2(d_ndc_d_clip*trans); + mat2 dxyv_dxys = diagm(0.5 * px_per_unit * get_resolution()) * mat2(d_ndc_d_clip*trans); // Now, our buffer size is expressed in viewport pixels but we get back to // the sprite coordinate system using the scale factor of the // transformation (for isotropic transformations). For anisotropic diff --git a/WGLMakie/src/Camera.js b/WGLMakie/src/Camera.js index adf1fccac52..25223aca629 100644 --- a/WGLMakie/src/Camera.js +++ b/WGLMakie/src/Camera.js @@ -268,7 +268,7 @@ export class MakieCamera { update_matrices(view, projection, resolution, eyepos) { this.view.value.fromArray(view); this.projection.value.fromArray(projection); - this.resolution.value.fromArray(resolution.map(x=> Math.ceil(x / pixelRatio))); + this.resolution.value.fromArray(resolution); this.eyeposition.value.fromArray(eyepos); this.calculate_matrices(); return; diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index f5ab653f069..536401f4e32 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -43,9 +43,15 @@ function linesegments_vertex_shader(uniforms, attributes) { out vec2 f_uv; out ${color} f_color; + vec2 get_resolution() { + // 2 * px_per_unit doesn't make any sense, but works + // TODO, figure out what's going on! + return resolution / 2.0 * px_per_unit; + } + vec3 screen_space(vec3 point) { vec4 vertex = projectionview * model * vec4(point, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; + return vec3(vertex.xy * get_resolution() , vertex.z) / vertex.w; } vec3 screen_space(vec2 point) { @@ -55,7 +61,7 @@ function linesegments_vertex_shader(uniforms, attributes) { void main() { vec3 p_a = screen_space(linepoint_start); vec3 p_b = screen_space(linepoint_end); - float width = (position.x == 1.0 ? linewidth_end : linewidth_start); + float width = (px_per_unit * (position.x == 1.0 ? linewidth_end : linewidth_start)); f_color = position.x == 1.0 ? color_end : color_start; f_uv = vec2(position.x, position.y + 0.5); @@ -66,7 +72,7 @@ function linesegments_vertex_shader(uniforms, attributes) { vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; - gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); + gl_Position = vec4(point.xy / get_resolution(), p_a.z, 1.0); } `; } @@ -155,7 +161,6 @@ function lines_fragment_shader(uniforms, attributes) { function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); - uniforms_des.pixel_ratio = new THREE.Uniform(window.devicePixelRatio || 1.0); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, vertexShader: linesegments_vertex_shader(uniforms_des, attributes), diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index e4efb3cb0a7..fcec0ff0520 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -201,7 +201,9 @@ export function add_plot(scene, plot_data) { plot_data.uniforms.projection = identity; plot_data.uniforms.projectionview = identity; } + const px_per_unit = window.devicePixelRatio || 1.0; plot_data.uniforms.resolution = cam.resolution; + plot_data.uniforms.px_per_unit = new THREE.Uniform(px_per_unit); if (plot_data.uniforms.preprojection) { const { space, markerspace } = plot_data; diff --git a/WGLMakie/src/particles.jl b/WGLMakie/src/particles.jl index 4f97f3ba7e4..f550ebdff4e 100644 --- a/WGLMakie/src/particles.jl +++ b/WGLMakie/src/particles.jl @@ -190,6 +190,7 @@ function scatter_shader(scene::Scene, attributes, plot) instance = uv_mesh(Rect2(-0.5f0, -0.5f0, 1f0, 1f0)) # Don't send obs, since it's overwritten in JS to be updated by the camera uniform_dict[:resolution] = to_value(scene.camera.resolution) + uniform_dict[:px_per_unit] = 1f0 # id + picking gets filled in JS, needs to be here to emit the correct shader uniforms uniform_dict[:picking] = false diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js deleted file mode 100644 index 2db0eba6c45..00000000000 --- a/WGLMakie/src/wglmakie.bundled.js +++ /dev/null @@ -1,20934 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file -// This code was bundled using `deno bundle` and it's not recommended to edit it manually - -var ca = "136", Gy = { - LEFT: 0, - MIDDLE: 1, - RIGHT: 2, - ROTATE: 0, - DOLLY: 1, - PAN: 2 -}, Vy = { - ROTATE: 0, - PAN: 1, - DOLLY_PAN: 2, - DOLLY_ROTATE: 3 -}, uu = 0, tl = 1, du = 2, Wy = 3, qy = 0, Hc = 1, fu = 2, ir = 3, Ai = 0, it = 1, Ci = 2, kc = 1, Xy = 2, vn = 0, sr = 1, nl = 2, il = 3, rl = 4, pu = 5, _i = 100, mu = 101, gu = 102, sl = 103, ol = 104, xu = 200, yu = 201, vu = 202, _u = 203, Gc = 204, Vc = 205, Mu = 206, bu = 207, wu = 208, Su = 209, Tu = 210, Eu = 0, Au = 1, Cu = 2, ea = 3, Lu = 4, Ru = 5, Pu = 6, Iu = 7, Vs = 0, Du = 1, Fu = 2, _n = 0, Nu = 1, Bu = 2, zu = 3, Uu = 4, Ou = 5, ha = 300, Bi = 301, zi = 302, Ds = 303, Fs = 304, Pr = 306, Ws = 307, Ns = 1e3, vt = 1001, Bs = 1002, rt = 1003, ta = 1004, Jy = 1004, na = 1005, Yy = 1005, tt = 1006, Wc = 1007, Zy = 1007, Ui = 1008, $y = 1008, rn = 1009, Hu = 1010, ku = 1011, cr = 1012, Gu = 1013, Ps = 1014, nn = 1015, kn = 1016, Vu = 1017, Wu = 1018, qu = 1019, Ti = 1020, Xu = 1021, Gn = 1022, ct = 1023, Ju = 1024, Yu = 1025, Vn = 1026, Li = 1027, Zu = 1028, $u = 1029, ju = 1030, Qu = 1031, Ku = 1032, ed = 1033, al = 33776, ll = 33777, cl = 33778, hl = 33779, ul = 35840, dl = 35841, fl = 35842, pl = 35843, td = 36196, ml = 37492, gl = 37496, nd = 37808, id = 37809, rd = 37810, sd = 37811, od = 37812, ad = 37813, ld = 37814, cd = 37815, hd = 37816, ud = 37817, dd = 37818, fd = 37819, pd = 37820, md = 37821, gd = 36492, xd = 37840, yd = 37841, vd = 37842, _d = 37843, Md = 37844, bd = 37845, wd = 37846, Sd = 37847, Td = 37848, Ed = 37849, Ad = 37850, Cd = 37851, Ld = 37852, Rd = 37853, Pd = 2200, Id = 2201, Dd = 2202, zs = 2300, Us = 2301, yo = 2302, Mi = 2400, bi = 2401, Os = 2402, ua = 2500, qc = 2501, Fd = 0, jy = 1, Qy = 2, Nt = 3e3, Oi = 3001, Nd = 3200, Bd = 3201, Hi = 0, zd = 1, Ky = 0, vo = 7680, e0 = 7681, t0 = 7682, n0 = 7683, i0 = 34055, r0 = 34056, s0 = 5386, o0 = 512, a0 = 513, l0 = 514, c0 = 515, h0 = 516, u0 = 517, d0 = 518, Ud = 519, hr = 35044, ur = 35048, f0 = 35040, p0 = 35045, m0 = 35049, g0 = 35041, x0 = 35046, y0 = 35050, v0 = 35042, _0 = "100", xl = "300 es", En = class { - addEventListener(e, t) { - this._listeners === void 0 && (this._listeners = {}); - let n = this._listeners; - n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); - } - hasEventListener(e, t) { - if (this._listeners === void 0) return !1; - let n = this._listeners; - return n[e] !== void 0 && n[e].indexOf(t) !== -1; - } - removeEventListener(e, t) { - if (this._listeners === void 0) return; - let i = this._listeners[e]; - if (i !== void 0) { - let r = i.indexOf(t); - r !== -1 && i.splice(r, 1); - } - } - dispatchEvent(e) { - if (this._listeners === void 0) return; - let n = this._listeners[e.type]; - if (n !== void 0) { - e.target = this; - let i = n.slice(0); - for(let r = 0, o = i.length; r < o; r++)i[r].call(this, e); - e.target = null; - } - } -}, pt = []; -for(let s = 0; s < 256; s++)pt[s] = (s < 16 ? "0" : "") + s.toString(16); -var Vr = 1234567, Wn = Math.PI / 180, dr = 180 / Math.PI; -function Et() { - let s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; - return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[e & 255] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 15 | 64] + pt[e >> 24 & 255] + "-" + pt[t & 63 | 128] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 255] + pt[t >> 24 & 255] + pt[n & 255] + pt[n >> 8 & 255] + pt[n >> 16 & 255] + pt[n >> 24 & 255]).toUpperCase(); -} -function mt(s, e, t) { - return Math.max(e, Math.min(t, s)); -} -function da(s, e) { - return (s % e + e) % e; -} -function Od(s, e, t, n, i) { - return n + (s - e) * (i - n) / (t - e); -} -function Hd(s, e, t) { - return s !== e ? (t - s) / (e - s) : 0; -} -function or(s, e, t) { - return (1 - t) * s + t * e; -} -function kd(s, e, t, n) { - return or(s, e, 1 - Math.exp(-t * n)); -} -function Gd(s, e = 1) { - return e - Math.abs(da(s, e * 2) - e); -} -function Vd(s, e, t) { - return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); -} -function Wd(s, e, t) { - return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); -} -function qd(s, e) { - return s + Math.floor(Math.random() * (e - s + 1)); -} -function Xd(s, e) { - return s + Math.random() * (e - s); -} -function Jd(s) { - return s * (.5 - Math.random()); -} -function Yd(s) { - return s !== void 0 && (Vr = s % 2147483647), Vr = Vr * 16807 % 2147483647, (Vr - 1) / 2147483646; -} -function Zd(s) { - return s * Wn; -} -function $d(s) { - return s * dr; -} -function ia(s) { - return (s & s - 1) === 0 && s !== 0; -} -function Xc(s) { - return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); -} -function Jc(s) { - return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); -} -function jd(s, e, t, n, i) { - let r = Math.cos, o = Math.sin, a = r(t / 2), l = o(t / 2), c = r((e + n) / 2), h = o((e + n) / 2), u = r((e - n) / 2), d = o((e - n) / 2), f = r((n - e) / 2), m = o((n - e) / 2); - switch(i){ - case "XYX": - s.set(a * h, l * u, l * d, a * c); - break; - case "YZY": - s.set(l * d, a * h, l * u, a * c); - break; - case "ZXZ": - s.set(l * u, l * d, a * h, a * c); - break; - case "XZX": - s.set(a * h, l * m, l * f, a * c); - break; - case "YXY": - s.set(l * f, a * h, l * m, a * c); - break; - case "ZYZ": - s.set(l * m, l * f, a * h, a * c); - break; - default: - console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); - } -} -var M0 = Object.freeze({ - __proto__: null, - DEG2RAD: Wn, - RAD2DEG: dr, - generateUUID: Et, - clamp: mt, - euclideanModulo: da, - mapLinear: Od, - inverseLerp: Hd, - lerp: or, - damp: kd, - pingpong: Gd, - smoothstep: Vd, - smootherstep: Wd, - randInt: qd, - randFloat: Xd, - randFloatSpread: Jd, - seededRandom: Yd, - degToRad: Zd, - radToDeg: $d, - isPowerOfTwo: ia, - ceilPowerOfTwo: Xc, - floorPowerOfTwo: Jc, - setQuaternionFromProperEuler: jd -}), X = class { - constructor(e = 0, t = 0){ - this.x = e, this.y = t; - } - get width() { - return this.x; - } - set width(e) { - this.x = e; - } - get height() { - return this.y; - } - set height(e) { - this.y = e; - } - set(e, t) { - return this.x = e, this.y = t, this; - } - setScalar(e) { - return this.x = e, this.y = e, this; - } - setX(e) { - return this.x = e, this; - } - setY(e) { - return this.y = e, this; - } - setComponent(e, t) { - switch(e){ - case 0: - this.x = t; - break; - case 1: - this.y = t; - break; - default: - throw new Error("index is out of range: " + e); - } - return this; - } - getComponent(e) { - switch(e){ - case 0: - return this.x; - case 1: - return this.y; - default: - throw new Error("index is out of range: " + e); - } - } - clone() { - return new this.constructor(this.x, this.y); - } - copy(e) { - return this.x = e.x, this.y = e.y, this; - } - add(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this); - } - addScalar(e) { - return this.x += e, this.y += e, this; - } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this; - } - addScaledVector(e, t) { - return this.x += e.x * t, this.y += e.y * t, this; - } - sub(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this); - } - subScalar(e) { - return this.x -= e, this.y -= e, this; - } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this; - } - multiply(e) { - return this.x *= e.x, this.y *= e.y, this; - } - multiplyScalar(e) { - return this.x *= e, this.y *= e, this; - } - divide(e) { - return this.x /= e.x, this.y /= e.y, this; - } - divideScalar(e) { - return this.multiplyScalar(1 / e); - } - applyMatrix3(e) { - let t = this.x, n = this.y, i = e.elements; - return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this; - } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; - } - max(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; - } - clamp(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this; - } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this; - } - clampLength(e, t) { - let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); - } - 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this; - } - negate() { - return this.x = -this.x, this.y = -this.y, this; - } - dot(e) { - return this.x * e.x + this.y * e.y; - } - cross(e) { - return this.x * e.y - this.y * e.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; - } - distanceTo(e) { - return Math.sqrt(this.distanceToSquared(e)); - } - distanceToSquared(e) { - let t = this.x - e.x, n = this.y - e.y; - return t * t + n * n; - } - manhattanDistanceTo(e) { - return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); - } - setLength(e) { - return this.normalize().multiplyScalar(e); - } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; - } - lerpVectors(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; - } - equals(e) { - return e.x === this.x && e.y === this.y; - } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this; - } - toArray(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e; - } - fromBufferAttribute(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this; - } - rotateAround(e, t) { - let n = Math.cos(t), i = Math.sin(t), r = this.x - e.x, o = this.y - e.y; - return this.x = r * n - o * i + e.x, this.y = r * i + o * n + e.y, this; - } - random() { - return this.x = Math.random(), this.y = Math.random(), this; - } - *[Symbol.iterator]() { - yield this.x, yield this.y; - } -}; -X.prototype.isVector2 = !0; -var lt = class { - constructor(){ - this.elements = [ - 1, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 1 - ], arguments.length > 0 && console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead."); - } - set(e, t, n, i, r, o, a, l, c) { - let h = this.elements; - return h[0] = e, h[1] = i, h[2] = a, h[3] = t, 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(e) { - let t = this.elements, n = e.elements; - return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this; - } - extractBasis(e, t, n) { - return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; - } - setFromMatrix4(e) { - let t = e.elements; - return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), this; - } - multiply(e) { - return this.multiplyMatrices(this, e); - } - premultiply(e) { - return this.multiplyMatrices(e, this); - } - multiplyMatrices(e, t) { - let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[3], l = n[6], c = n[1], h = n[4], u = n[7], d = n[2], f = n[5], m = n[8], x = i[0], v = i[3], g = i[6], p = i[1], _ = i[4], y = i[7], b = i[2], A = i[5], L = i[8]; - return r[0] = o * x + a * p + l * b, r[3] = o * v + a * _ + l * A, r[6] = o * g + a * y + l * L, r[1] = c * x + h * p + u * b, r[4] = c * v + h * _ + u * A, r[7] = c * g + h * y + u * L, r[2] = d * x + f * p + m * b, r[5] = d * v + f * _ + m * A, r[8] = d * g + f * y + m * L, this; - } - multiplyScalar(e) { - let t = this.elements; - return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this; - } - determinant() { - let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8]; - return t * o * h - t * a * c - n * r * h + n * a * l + i * r * c - i * o * l; - } - invert() { - let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = h * o - a * c, d = a * l - h * r, f = c * r - o * l, m = t * u + n * d + i * f; - if (m === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); - let x = 1 / m; - return e[0] = u * x, e[1] = (i * c - h * n) * x, e[2] = (a * n - i * o) * x, e[3] = d * x, e[4] = (h * t - i * l) * x, e[5] = (i * r - a * t) * x, e[6] = f * x, e[7] = (n * l - c * t) * x, e[8] = (o * t - n * r) * x, this; - } - transpose() { - let e, t = this.elements; - return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this; - } - getNormalMatrix(e) { - return this.setFromMatrix4(e).invert().transpose(); - } - transposeIntoArray(e) { - let t = this.elements; - return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this; - } - setUvTransform(e, t, n, i, 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 + e, -i * c, i * l, -i * (-c * o + l * a) + a + t, 0, 0, 1), this; - } - scale(e, t) { - let n = this.elements; - return n[0] *= e, n[3] *= e, n[6] *= e, n[1] *= t, n[4] *= t, n[7] *= t, this; - } - rotate(e) { - let t = Math.cos(e), n = Math.sin(e), i = this.elements, r = i[0], o = i[3], a = i[6], l = i[1], c = i[4], h = i[7]; - return i[0] = t * r + n * l, i[3] = t * o + n * c, i[6] = t * a + n * h, i[1] = -n * r + t * l, i[4] = -n * o + t * c, i[7] = -n * a + t * h, this; - } - translate(e, t) { - let n = this.elements; - return n[0] += e * n[2], n[3] += e * n[5], n[6] += e * n[8], n[1] += t * n[2], n[4] += t * n[5], n[7] += t * n[8], this; - } - equals(e) { - let t = this.elements, n = e.elements; - for(let i = 0; i < 9; i++)if (t[i] !== n[i]) return !1; - return !0; - } - fromArray(e, t = 0) { - for(let n = 0; n < 9; n++)this.elements[n] = e[n + t]; - return this; - } - toArray(e = [], t = 0) { - let n = this.elements; - return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; - } - clone() { - return new this.constructor().fromArray(this.elements); - } -}; -lt.prototype.isMatrix3 = !0; -function Yc(s) { - if (s.length === 0) return -1 / 0; - let e = s[0]; - for(let t = 1, n = s.length; t < n; ++t)s[t] > e && (e = s[t]); - return e; -} -var Qd = { - Int8Array, - Uint8Array, - Uint8ClampedArray, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array -}; -function wi(s, e) { - return new Qd[s](e); -} -function qs(s) { - return document.createElementNS("http://www.w3.org/1999/xhtml", s); -} -var ti, Yn = class { - static getDataURL(e) { - if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; - let t; - if (e instanceof HTMLCanvasElement) t = e; - else { - ti === void 0 && (ti = qs("canvas")), ti.width = e.width, ti.height = e.height; - let n = ti.getContext("2d"); - e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = ti; - } - return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", .6)) : t.toDataURL("image/png"); - } -}, Kd = 0, ot = class extends En { - constructor(e = ot.DEFAULT_IMAGE, t = ot.DEFAULT_MAPPING, n = vt, i = vt, r = tt, o = Ui, a = ct, l = rn, c = 1, h = Nt){ - super(); - Object.defineProperty(this, "id", { - value: Kd++ - }), this.uuid = Et(), this.name = "", this.image = e, this.mipmaps = [], this.mapping = t, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = o, this.anisotropy = c, this.format = a, this.internalFormat = null, this.type = l, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new lt, this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.encoding = h, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1; - } - updateMatrix() { - this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.name = e.name, this.image = e.image, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.encoding = e.encoding, this.userData = JSON.parse(JSON.stringify(e.userData)), this; - } - toJSON(e) { - let t = e === void 0 || typeof e == "string"; - if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; - let n = { - metadata: { - version: 4.5, - type: "Texture", - generator: "Texture.toJSON" - }, - uuid: this.uuid, - name: this.name, - mapping: this.mapping, - 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, - type: this.type, - encoding: this.encoding, - minFilter: this.minFilter, - magFilter: this.magFilter, - anisotropy: this.anisotropy, - flipY: this.flipY, - premultiplyAlpha: this.premultiplyAlpha, - unpackAlignment: this.unpackAlignment - }; - if (this.image !== void 0) { - let i = this.image; - if (i.uuid === void 0 && (i.uuid = Et()), !t && e.images[i.uuid] === void 0) { - let r; - if (Array.isArray(i)) { - r = []; - for(let o = 0, a = i.length; o < a; o++)i[o].isDataTexture ? r.push(_o(i[o].image)) : r.push(_o(i[o])); - } else r = _o(i); - e.images[i.uuid] = { - uuid: i.uuid, - url: r - }; - } - n.image = i.uuid; - } - return JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; - } - dispose() { - this.dispatchEvent({ - type: "dispose" - }); - } - transformUv(e) { - if (this.mapping !== ha) return e; - if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch(this.wrapS){ - case Ns: - e.x = e.x - Math.floor(e.x); - break; - case vt: - e.x = e.x < 0 ? 0 : 1; - break; - case Bs: - Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x); - break; - } - if (e.y < 0 || e.y > 1) switch(this.wrapT){ - case Ns: - e.y = e.y - Math.floor(e.y); - break; - case vt: - e.y = e.y < 0 ? 0 : 1; - break; - case Bs: - Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y); - break; - } - return this.flipY && (e.y = 1 - e.y), e; - } - set needsUpdate(e) { - e === !0 && this.version++; - } -}; -ot.DEFAULT_IMAGE = void 0; -ot.DEFAULT_MAPPING = ha; -ot.prototype.isTexture = !0; -function _o(s) { - return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? Yn.getDataURL(s) : s.data ? { - data: Array.prototype.slice.call(s.data), - width: s.width, - height: s.height, - type: s.data.constructor.name - } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); -} -var Ve = class { - constructor(e = 0, t = 0, n = 0, i = 1){ - this.x = e, this.y = t, this.z = n, this.w = i; - } - get width() { - return this.z; - } - set width(e) { - this.z = e; - } - get height() { - return this.w; - } - set height(e) { - this.w = e; - } - set(e, t, n, i) { - return this.x = e, this.y = t, this.z = n, this.w = i, this; - } - setScalar(e) { - return this.x = e, this.y = e, this.z = e, this.w = e, this; - } - setX(e) { - return this.x = e, this; - } - setY(e) { - return this.y = e, this; - } - setZ(e) { - return this.z = e, this; - } - setW(e) { - return this.w = e, this; - } - setComponent(e, t) { - switch(e){ - case 0: - this.x = t; - break; - case 1: - this.y = t; - break; - case 2: - this.z = t; - break; - case 3: - this.w = t; - break; - default: - throw new Error("index is out of range: " + e); - } - return this; - } - getComponent(e) { - switch(e){ - case 0: - return this.x; - case 1: - return this.y; - case 2: - return this.z; - case 3: - return this.w; - default: - throw new Error("index is out of range: " + e); - } - } - clone() { - return new this.constructor(this.x, this.y, this.z, this.w); - } - copy(e) { - return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this; - } - add(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this); - } - addScalar(e) { - return this.x += e, this.y += e, this.z += e, this.w += e, this; - } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this; - } - addScaledVector(e, t) { - return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this; - } - sub(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this); - } - subScalar(e) { - return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; - } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this; - } - multiply(e) { - return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; - } - multiplyScalar(e) { - return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; - } - applyMatrix4(e) { - let t = this.x, n = this.y, i = this.z, r = this.w, o = e.elements; - return this.x = o[0] * t + o[4] * n + o[8] * i + o[12] * r, this.y = o[1] * t + o[5] * n + o[9] * i + o[13] * r, this.z = o[2] * t + o[6] * n + o[10] * i + o[14] * r, this.w = o[3] * t + o[7] * n + o[11] * i + o[15] * r, this; - } - divideScalar(e) { - return this.multiplyScalar(1 / e); - } - setAxisAngleFromQuaternion(e) { - this.w = 2 * Math.acos(e.w); - let t = Math.sqrt(1 - e.w * e.w); - return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this; - } - setAxisAngleFromRotationMatrix(e) { - let t, n, i, r, l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], f = l[5], m = l[9], x = l[2], v = l[6], g = l[10]; - if (Math.abs(h - d) < .01 && Math.abs(u - x) < .01 && Math.abs(m - v) < .01) { - if (Math.abs(h + d) < .1 && Math.abs(u + x) < .1 && Math.abs(m + v) < .1 && Math.abs(c + f + g - 3) < .1) return this.set(1, 0, 0, 0), this; - t = Math.PI; - let _ = (c + 1) / 2, y = (f + 1) / 2, b = (g + 1) / 2, A = (h + d) / 4, L = (u + x) / 4, I = (m + v) / 4; - return _ > y && _ > b ? _ < .01 ? (n = 0, i = .707106781, r = .707106781) : (n = Math.sqrt(_), i = A / n, r = L / n) : y > b ? y < .01 ? (n = .707106781, i = 0, r = .707106781) : (i = Math.sqrt(y), n = A / i, r = I / i) : b < .01 ? (n = .707106781, i = .707106781, r = 0) : (r = Math.sqrt(b), n = L / r, i = I / r), this.set(n, i, r, t), this; - } - let p = Math.sqrt((v - m) * (v - m) + (u - x) * (u - x) + (d - h) * (d - h)); - return Math.abs(p) < .001 && (p = 1), this.x = (v - m) / p, this.y = (u - x) / p, this.z = (d - h) / p, this.w = Math.acos((c + f + g - 1) / 2), this; - } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this; - } - max(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this; - } - clamp(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this; - } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this; - } - clampLength(e, t) { - let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); - } - 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w), this; - } - negate() { - return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; - } - dot(e) { - return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.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(e) { - return this.normalize().multiplyScalar(e); - } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this; - } - lerpVectors(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this; - } - equals(e) { - return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; - } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; - } - toArray(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; - } - fromBufferAttribute(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), 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; - } -}; -Ve.prototype.isVector4 = !0; -var At = class extends En { - constructor(e, t, n = {}){ - super(); - this.width = e, this.height = t, this.depth = 1, this.scissor = new Ve(0, 0, e, t), this.scissorTest = !1, this.viewport = new Ve(0, 0, e, t), this.texture = new ot(void 0, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.encoding), this.texture.isRenderTargetTexture = !0, this.texture.image = { - width: e, - height: t, - depth: 1 - }, this.texture.generateMipmaps = n.generateMipmaps !== void 0 ? n.generateMipmaps : !1, this.texture.internalFormat = n.internalFormat !== void 0 ? n.internalFormat : null, this.texture.minFilter = n.minFilter !== void 0 ? n.minFilter : tt, this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0, this.stencilBuffer = n.stencilBuffer !== void 0 ? n.stencilBuffer : !1, this.depthTexture = n.depthTexture !== void 0 ? n.depthTexture : null; - } - setTexture(e) { - e.image = { - width: this.width, - height: this.height, - depth: this.depth - }, this.texture = e; - } - setSize(e, t, n = 1) { - (this.width !== e || this.height !== t || this.depth !== n) && (this.width = e, this.height = t, this.depth = n, this.texture.image.width = e, this.texture.image.height = t, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.copy(e.viewport), this.texture = e.texture.clone(), this.texture.image = { - ...this.texture.image - }, this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, this; - } - dispose() { - this.dispatchEvent({ - type: "dispose" - }); - } -}; -At.prototype.isWebGLRenderTarget = !0; -var Zc = class extends At { - constructor(e, t, n){ - super(e, t); - let i = this.texture; - this.texture = []; - for(let r = 0; r < n; r++)this.texture[r] = i.clone(); - } - setSize(e, t, n = 1) { - if (this.width !== e || this.height !== t || this.depth !== n) { - this.width = e, this.height = t, this.depth = n; - for(let i = 0, r = this.texture.length; i < r; i++)this.texture[i].image.width = e, this.texture[i].image.height = t, this.texture[i].image.depth = n; - this.dispose(); - } - return this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t), this; - } - copy(e) { - this.dispose(), this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.set(0, 0, this.width, this.height), this.scissor.set(0, 0, this.width, this.height), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, this.texture.length = 0; - for(let t = 0, n = e.texture.length; t < n; t++)this.texture[t] = e.texture[t].clone(); - return this; - } -}; -Zc.prototype.isWebGLMultipleRenderTargets = !0; -var Xs = class extends At { - constructor(e, t, n = {}){ - super(e, t, n); - this.samples = 4, this.ignoreDepthForMultisampleCopy = n.ignoreDepth !== void 0 ? n.ignoreDepth : !0, this.useRenderToTexture = n.useRenderToTexture !== void 0 ? n.useRenderToTexture : !1, this.useRenderbuffer = this.useRenderToTexture === !1; - } - copy(e) { - return super.copy.call(this, e), this.samples = e.samples, this.useRenderToTexture = e.useRenderToTexture, this.useRenderbuffer = e.useRenderbuffer, this; - } -}; -Xs.prototype.isWebGLMultisampleRenderTarget = !0; -var gt = class { - constructor(e = 0, t = 0, n = 0, i = 1){ - this._x = e, this._y = t, this._z = n, this._w = i; - } - static slerp(e, t, n, i) { - return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."), n.slerpQuaternions(e, t, i); - } - static slerpFlat(e, t, n, i, r, o, a) { - let l = n[i + 0], c = n[i + 1], h = n[i + 2], u = n[i + 3], d = r[o + 0], f = r[o + 1], m = r[o + 2], x = r[o + 3]; - if (a === 0) { - e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; - return; - } - if (a === 1) { - e[t + 0] = d, e[t + 1] = f, e[t + 2] = m, e[t + 3] = x; - return; - } - if (u !== x || l !== d || c !== f || h !== m) { - let v = 1 - a, g = l * d + c * f + h * m + u * x, p = g >= 0 ? 1 : -1, _ = 1 - g * g; - if (_ > Number.EPSILON) { - let b = Math.sqrt(_), A = Math.atan2(b, g * p); - v = Math.sin(v * A) / b, a = Math.sin(a * A) / b; - } - let y = a * p; - if (l = l * v + d * y, c = c * v + f * y, h = h * v + m * y, u = u * v + x * y, v === 1 - a) { - let b = 1 / Math.sqrt(l * l + c * c + h * h + u * u); - l *= b, c *= b, h *= b, u *= b; - } - } - e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; - } - static multiplyQuaternionsFlat(e, t, n, i, r, o) { - let a = n[i], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = r[o], d = r[o + 1], f = r[o + 2], m = r[o + 3]; - return e[t] = a * m + h * u + l * f - c * d, e[t + 1] = l * m + h * d + c * u - a * f, e[t + 2] = c * m + h * f + a * d - l * u, e[t + 3] = h * m - a * u - l * d - c * f, e; - } - get x() { - return this._x; - } - set x(e) { - this._x = e, this._onChangeCallback(); - } - get y() { - return this._y; - } - set y(e) { - this._y = e, this._onChangeCallback(); - } - get z() { - return this._z; - } - set z(e) { - this._z = e, this._onChangeCallback(); - } - get w() { - return this._w; - } - set w(e) { - this._w = e, this._onChangeCallback(); - } - set(e, t, n, i) { - return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this; - } - clone() { - return new this.constructor(this._x, this._y, this._z, this._w); - } - copy(e) { - return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; - } - setFromEuler(e, t) { - if (!(e && e.isEuler)) throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order."); - let n = e._x, i = e._y, r = e._z, o = e._order, a = Math.cos, l = Math.sin, c = a(n / 2), h = a(i / 2), u = a(r / 2), d = l(n / 2), f = l(i / 2), m = l(r / 2); - switch(o){ - case "XYZ": - this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; - break; - case "YXZ": - this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; - break; - case "ZXY": - this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; - break; - case "ZYX": - this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; - break; - case "YZX": - this._x = d * h * u + c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u - d * f * m; - break; - case "XZY": - this._x = d * h * u - c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u + d * f * m; - break; - default: - console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o); - } - return t !== !1 && this._onChangeCallback(), this; - } - setFromAxisAngle(e, t) { - let n = t / 2, i = Math.sin(n); - return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; - } - setFromRotationMatrix(e) { - let t = e.elements, n = t[0], i = t[4], r = t[8], o = t[1], a = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = n + a + u; - if (d > 0) { - let f = .5 / Math.sqrt(d + 1); - this._w = .25 / f, this._x = (h - l) * f, this._y = (r - c) * f, this._z = (o - i) * f; - } else if (n > a && n > u) { - let f = 2 * Math.sqrt(1 + n - a - u); - this._w = (h - l) / f, this._x = .25 * f, this._y = (i + o) / f, this._z = (r + c) / f; - } else if (a > u) { - let f = 2 * Math.sqrt(1 + a - n - u); - this._w = (r - c) / f, this._x = (i + o) / f, this._y = .25 * f, this._z = (l + h) / f; - } else { - let f = 2 * Math.sqrt(1 + u - n - a); - this._w = (o - i) / f, this._x = (r + c) / f, this._y = (l + h) / f, this._z = .25 * f; - } - return this._onChangeCallback(), this; - } - setFromUnitVectors(e, t) { - let n = e.dot(t) + 1; - return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); - } - angleTo(e) { - return 2 * Math.acos(Math.abs(mt(this.dot(e), -1, 1))); - } - rotateTowards(e, t) { - let n = this.angleTo(e); - if (n === 0) return this; - let i = Math.min(1, t / n); - return this.slerp(e, i), 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(e) { - return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._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 e = this.length(); - return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this; - } - multiply(e, t) { - return t !== void 0 ? (console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(e, t)) : this.multiplyQuaternions(this, e); - } - premultiply(e) { - return this.multiplyQuaternions(e, this); - } - multiplyQuaternions(e, t) { - let n = e._x, i = e._y, r = e._z, o = e._w, a = t._x, l = t._y, c = t._z, h = t._w; - return this._x = n * h + o * a + i * c - r * l, this._y = i * h + o * l + r * a - n * c, this._z = r * h + o * c + n * l - i * a, this._w = o * h - n * a - i * l - r * c, this._onChangeCallback(), this; - } - slerp(e, t) { - if (t === 0) return this; - if (t === 1) return this.copy(e); - let n = this._x, i = this._y, r = this._z, o = this._w, a = o * e._w + n * e._x + i * e._y + r * e._z; - if (a < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, a = -a) : this.copy(e), a >= 1) return this._w = o, this._x = n, this._y = i, this._z = r, this; - let l = 1 - a * a; - if (l <= Number.EPSILON) { - let f = 1 - t; - return this._w = f * o + t * this._w, this._x = f * n + t * this._x, this._y = f * i + t * this._y, this._z = f * r + t * this._z, this.normalize(), this._onChangeCallback(), this; - } - let c = Math.sqrt(l), h = Math.atan2(c, a), u = Math.sin((1 - t) * h) / c, d = Math.sin(t * h) / c; - return this._w = o * u + this._w * d, this._x = n * u + this._x * d, this._y = i * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; - } - slerpQuaternions(e, t, n) { - this.copy(e).slerp(t, n); - } - random() { - let e = Math.random(), t = Math.sqrt(1 - e), n = Math.sqrt(e), i = 2 * Math.PI * Math.random(), r = 2 * Math.PI * Math.random(); - return this.set(t * Math.cos(i), n * Math.sin(r), n * Math.cos(r), t * Math.sin(i)); - } - equals(e) { - return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; - } - fromArray(e, t = 0) { - return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; - } - toArray(e = [], t = 0) { - return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; - } - fromBufferAttribute(e, t) { - return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this; - } - _onChange(e) { - return this._onChangeCallback = e, this; - } - _onChangeCallback() {} -}; -gt.prototype.isQuaternion = !0; -var M = class { - constructor(e = 0, t = 0, n = 0){ - this.x = e, this.y = t, this.z = n; - } - set(e, t, n) { - return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; - } - setScalar(e) { - return this.x = e, this.y = e, this.z = e, this; - } - setX(e) { - return this.x = e, this; - } - setY(e) { - return this.y = e, this; - } - setZ(e) { - return this.z = e, this; - } - setComponent(e, t) { - switch(e){ - case 0: - this.x = t; - break; - case 1: - this.y = t; - break; - case 2: - this.z = t; - break; - default: - throw new Error("index is out of range: " + e); - } - return this; - } - getComponent(e) { - switch(e){ - case 0: - return this.x; - case 1: - return this.y; - case 2: - return this.z; - default: - throw new Error("index is out of range: " + e); - } - } - clone() { - return new this.constructor(this.x, this.y, this.z); - } - copy(e) { - return this.x = e.x, this.y = e.y, this.z = e.z, this; - } - add(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this); - } - addScalar(e) { - return this.x += e, this.y += e, this.z += e, this; - } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this; - } - addScaledVector(e, t) { - return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; - } - sub(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this); - } - subScalar(e) { - return this.x -= e, this.y -= e, this.z -= e, this; - } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this; - } - multiply(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(e, t)) : (this.x *= e.x, this.y *= e.y, this.z *= e.z, this); - } - multiplyScalar(e) { - return this.x *= e, this.y *= e, this.z *= e, this; - } - multiplyVectors(e, t) { - return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this; - } - applyEuler(e) { - return e && e.isEuler || console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."), this.applyQuaternion(yl.setFromEuler(e)); - } - applyAxisAngle(e, t) { - return this.applyQuaternion(yl.setFromAxisAngle(e, t)); - } - applyMatrix3(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements; - return this.x = r[0] * t + r[3] * n + r[6] * i, this.y = r[1] * t + r[4] * n + r[7] * i, this.z = r[2] * t + r[5] * n + r[8] * i, this; - } - applyNormalMatrix(e) { - return this.applyMatrix3(e).normalize(); - } - applyMatrix4(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements, o = 1 / (r[3] * t + r[7] * n + r[11] * i + r[15]); - return this.x = (r[0] * t + r[4] * n + r[8] * i + r[12]) * o, this.y = (r[1] * t + r[5] * n + r[9] * i + r[13]) * o, this.z = (r[2] * t + r[6] * n + r[10] * i + r[14]) * o, this; - } - applyQuaternion(e) { - let t = this.x, n = this.y, i = this.z, r = e.x, o = e.y, a = e.z, l = e.w, c = l * t + o * i - a * n, h = l * n + a * t - r * i, u = l * i + r * n - o * t, d = -r * t - o * n - a * i; - return this.x = c * l + d * -r + h * -a - u * -o, this.y = h * l + d * -o + u * -r - c * -a, this.z = u * l + d * -a + c * -o - h * -r, this; - } - project(e) { - return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); - } - unproject(e) { - return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); - } - transformDirection(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements; - return this.x = r[0] * t + r[4] * n + r[8] * i, this.y = r[1] * t + r[5] * n + r[9] * i, this.z = r[2] * t + r[6] * n + r[10] * i, this.normalize(); - } - divide(e) { - return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; - } - divideScalar(e) { - return this.multiplyScalar(1 / e); - } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this; - } - max(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this; - } - clamp(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this; - } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this; - } - clampLength(e, t) { - let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); - } - 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this; - } - negate() { - return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; - } - dot(e) { - return this.x * e.x + this.y * e.y + this.z * e.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(e) { - return this.normalize().multiplyScalar(e); - } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this; - } - lerpVectors(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; - } - cross(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), this.crossVectors(e, t)) : this.crossVectors(this, e); - } - crossVectors(e, t) { - let n = e.x, i = e.y, r = e.z, o = t.x, a = t.y, l = t.z; - return this.x = i * l - r * a, this.y = r * o - n * l, this.z = n * a - i * o, this; - } - projectOnVector(e) { - let t = e.lengthSq(); - if (t === 0) return this.set(0, 0, 0); - let n = e.dot(this) / t; - return this.copy(e).multiplyScalar(n); - } - projectOnPlane(e) { - return Mo.copy(this).projectOnVector(e), this.sub(Mo); - } - reflect(e) { - return this.sub(Mo.copy(e).multiplyScalar(2 * this.dot(e))); - } - angleTo(e) { - let t = Math.sqrt(this.lengthSq() * e.lengthSq()); - if (t === 0) return Math.PI / 2; - let n = this.dot(e) / t; - return Math.acos(mt(n, -1, 1)); - } - distanceTo(e) { - return Math.sqrt(this.distanceToSquared(e)); - } - distanceToSquared(e) { - let t = this.x - e.x, n = this.y - e.y, i = this.z - e.z; - return t * t + n * n + i * i; - } - manhattanDistanceTo(e) { - return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); - } - setFromSpherical(e) { - return this.setFromSphericalCoords(e.radius, e.phi, e.theta); - } - setFromSphericalCoords(e, t, n) { - let i = Math.sin(t) * e; - return this.x = i * Math.sin(n), this.y = Math.cos(t) * e, this.z = i * Math.cos(n), this; - } - setFromCylindrical(e) { - return this.setFromCylindricalCoords(e.radius, e.theta, e.y); - } - setFromCylindricalCoords(e, t, n) { - return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; - } - setFromMatrixPosition(e) { - let t = e.elements; - return this.x = t[12], this.y = t[13], this.z = t[14], this; - } - setFromMatrixScale(e) { - let t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), i = this.setFromMatrixColumn(e, 2).length(); - return this.x = t, this.y = n, this.z = i, this; - } - setFromMatrixColumn(e, t) { - return this.fromArray(e.elements, t * 4); - } - setFromMatrix3Column(e, t) { - return this.fromArray(e.elements, t * 3); - } - equals(e) { - return e.x === this.x && e.y === this.y && e.z === this.z; - } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; - } - toArray(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; - } - fromBufferAttribute(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this; - } - random() { - return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; - } - randomDirection() { - let e = (Math.random() - .5) * 2, t = Math.random() * Math.PI * 2, n = Math.sqrt(1 - e ** 2); - return this.x = n * Math.cos(t), this.y = n * Math.sin(t), this.z = e, this; - } - *[Symbol.iterator]() { - yield this.x, yield this.y, yield this.z; - } -}; -M.prototype.isVector3 = !0; -var Mo = new M, yl = new gt, Lt = class { - constructor(e = new M(1 / 0, 1 / 0, 1 / 0), t = new M(-1 / 0, -1 / 0, -1 / 0)){ - this.min = e, this.max = t; - } - set(e, t) { - return this.min.copy(e), this.max.copy(t), this; - } - setFromArray(e) { - let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; - for(let l = 0, c = e.length; l < c; l += 3){ - let h = e[l], u = e[l + 1], d = e[l + 2]; - h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); - } - return this.min.set(t, n, i), this.max.set(r, o, a), this; - } - setFromBufferAttribute(e) { - let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; - for(let l = 0, c = e.count; l < c; l++){ - let h = e.getX(l), u = e.getY(l), d = e.getZ(l); - h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); - } - return this.min.set(t, n, i), this.max.set(r, o, a), this; - } - setFromPoints(e) { - this.makeEmpty(); - for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); - return this; - } - setFromCenterAndSize(e, t) { - let n = Ji.copy(t).multiplyScalar(.5); - return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; - } - setFromObject(e) { - return this.makeEmpty(), this.expandByObject(e); - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.min.copy(e.min), this.max.copy(e.max), this; - } - makeEmpty() { - return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this; - } - isEmpty() { - return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; - } - getCenter(e) { - return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); - } - getSize(e) { - return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); - } - expandByPoint(e) { - return this.min.min(e), this.max.max(e), this; - } - expandByVector(e) { - return this.min.sub(e), this.max.add(e), this; - } - expandByScalar(e) { - return this.min.addScalar(-e), this.max.addScalar(e), this; - } - expandByObject(e) { - e.updateWorldMatrix(!1, !1); - let t = e.geometry; - t !== void 0 && (t.boundingBox === null && t.computeBoundingBox(), bo.copy(t.boundingBox), bo.applyMatrix4(e.matrixWorld), this.union(bo)); - let n = e.children; - for(let i = 0, r = n.length; i < r; i++)this.expandByObject(n[i]); - return this; - } - containsPoint(e) { - return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z); - } - containsBox(e) { - return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z; - } - getParameter(e, t) { - return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y), (e.z - this.min.z) / (this.max.z - this.min.z)); - } - intersectsBox(e) { - return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z); - } - intersectsSphere(e) { - return this.clampPoint(e.center, Ji), Ji.distanceToSquared(e.center) <= e.radius * e.radius; - } - intersectsPlane(e) { - let t, n; - return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; - } - intersectsTriangle(e) { - if (this.isEmpty()) return !1; - this.getCenter(Yi), Wr.subVectors(this.max, Yi), ni.subVectors(e.a, Yi), ii.subVectors(e.b, Yi), ri.subVectors(e.c, Yi), un.subVectors(ii, ni), dn.subVectors(ri, ii), Pn.subVectors(ni, ri); - let t = [ - 0, - -un.z, - un.y, - 0, - -dn.z, - dn.y, - 0, - -Pn.z, - Pn.y, - un.z, - 0, - -un.x, - dn.z, - 0, - -dn.x, - Pn.z, - 0, - -Pn.x, - -un.y, - un.x, - 0, - -dn.y, - dn.x, - 0, - -Pn.y, - Pn.x, - 0 - ]; - return !wo(t, ni, ii, ri, Wr) || (t = [ - 1, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 1 - ], !wo(t, ni, ii, ri, Wr)) ? !1 : (qr.crossVectors(un, dn), t = [ - qr.x, - qr.y, - qr.z - ], wo(t, ni, ii, ri, Wr)); - } - clampPoint(e, t) { - return t.copy(e).clamp(this.min, this.max); - } - distanceToPoint(e) { - return Ji.copy(e).clamp(this.min, this.max).sub(e).length(); - } - getBoundingSphere(e) { - return this.getCenter(e.center), e.radius = this.getSize(Ji).length() * .5, e; - } - intersect(e) { - return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; - } - union(e) { - return this.min.min(e.min), this.max.max(e.max), this; - } - applyMatrix4(e) { - return this.isEmpty() ? this : ($t[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), $t[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), $t[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), $t[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), $t[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), $t[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), $t[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), $t[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints($t), this); - } - translate(e) { - return this.min.add(e), this.max.add(e), this; - } - equals(e) { - return e.min.equals(this.min) && e.max.equals(this.max); - } -}; -Lt.prototype.isBox3 = !0; -var $t = [ - new M, - new M, - new M, - new M, - new M, - new M, - new M, - new M -], Ji = new M, bo = new Lt, ni = new M, ii = new M, ri = new M, un = new M, dn = new M, Pn = new M, Yi = new M, Wr = new M, qr = new M, In = new M; -function wo(s, e, t, n, i) { - for(let r = 0, o = s.length - 3; r <= o; r += 3){ - In.fromArray(s, r); - let a = i.x * Math.abs(In.x) + i.y * Math.abs(In.y) + i.z * Math.abs(In.z), l = e.dot(In), c = t.dot(In), h = n.dot(In); - if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > a) return !1; - } - return !0; -} -var ef = new Lt, vl = new M, Xr = new M, So = new M, An = class { - constructor(e = new M, t = -1){ - this.center = e, this.radius = t; - } - set(e, t) { - return this.center.copy(e), this.radius = t, this; - } - setFromPoints(e, t) { - let n = this.center; - t !== void 0 ? n.copy(t) : ef.setFromPoints(e).getCenter(n); - let i = 0; - for(let r = 0, o = e.length; r < o; r++)i = Math.max(i, n.distanceToSquared(e[r])); - return this.radius = Math.sqrt(i), this; - } - copy(e) { - return this.center.copy(e.center), this.radius = e.radius, this; - } - isEmpty() { - return this.radius < 0; - } - makeEmpty() { - return this.center.set(0, 0, 0), this.radius = -1, this; - } - containsPoint(e) { - return e.distanceToSquared(this.center) <= this.radius * this.radius; - } - distanceToPoint(e) { - return e.distanceTo(this.center) - this.radius; - } - intersectsSphere(e) { - let t = this.radius + e.radius; - return e.center.distanceToSquared(this.center) <= t * t; - } - intersectsBox(e) { - return e.intersectsSphere(this); - } - intersectsPlane(e) { - return Math.abs(e.distanceToPoint(this.center)) <= this.radius; - } - clampPoint(e, t) { - let n = this.center.distanceToSquared(e); - return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t; - } - getBoundingBox(e) { - return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); - } - applyMatrix4(e) { - return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this; - } - translate(e) { - return this.center.add(e), this; - } - expandByPoint(e) { - So.subVectors(e, this.center); - let t = So.lengthSq(); - if (t > this.radius * this.radius) { - let n = Math.sqrt(t), i = (n - this.radius) * .5; - this.center.add(So.multiplyScalar(i / n)), this.radius += i; - } - return this; - } - union(e) { - return this.center.equals(e.center) === !0 ? Xr.set(0, 0, 1).multiplyScalar(e.radius) : Xr.subVectors(e.center, this.center).normalize().multiplyScalar(e.radius), this.expandByPoint(vl.copy(e.center).add(Xr)), this.expandByPoint(vl.copy(e.center).sub(Xr)), this; - } - equals(e) { - return e.center.equals(this.center) && e.radius === this.radius; - } - clone() { - return new this.constructor().copy(this); - } -}, jt = new M, To = new M, Jr = new M, fn = new M, Eo = new M, Yr = new M, Ao = new M, Cn = class { - constructor(e = new M, t = new M(0, 0, -1)){ - this.origin = e, this.direction = t; - } - set(e, t) { - return this.origin.copy(e), this.direction.copy(t), this; - } - copy(e) { - return this.origin.copy(e.origin), this.direction.copy(e.direction), this; - } - at(e, t) { - return t.copy(this.direction).multiplyScalar(e).add(this.origin); - } - lookAt(e) { - return this.direction.copy(e).sub(this.origin).normalize(), this; - } - recast(e) { - return this.origin.copy(this.at(e, jt)), this; - } - closestPointToPoint(e, t) { - t.subVectors(e, this.origin); - let n = t.dot(this.direction); - return n < 0 ? t.copy(this.origin) : t.copy(this.direction).multiplyScalar(n).add(this.origin); - } - distanceToPoint(e) { - return Math.sqrt(this.distanceSqToPoint(e)); - } - distanceSqToPoint(e) { - let t = jt.subVectors(e, this.origin).dot(this.direction); - return t < 0 ? this.origin.distanceToSquared(e) : (jt.copy(this.direction).multiplyScalar(t).add(this.origin), jt.distanceToSquared(e)); - } - distanceSqToSegment(e, t, n, i) { - To.copy(e).add(t).multiplyScalar(.5), Jr.copy(t).sub(e).normalize(), fn.copy(this.origin).sub(To); - let r = e.distanceTo(t) * .5, o = -this.direction.dot(Jr), a = fn.dot(this.direction), l = -fn.dot(Jr), c = fn.lengthSq(), h = Math.abs(1 - o * o), u, d, f, m; - if (h > 0) if (u = o * l - a, d = o * a - l, m = r * h, u >= 0) if (d >= -m) if (d <= m) { - let x = 1 / h; - u *= x, d *= x, f = u * (u + o * d + 2 * a) + d * (o * u + d + 2 * l) + c; - } else d = r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - else d = -r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - else d <= -m ? (u = Math.max(0, -(-o * r + a)), d = u > 0 ? -r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c) : d <= m ? (u = 0, d = Math.min(Math.max(-r, -l), r), f = d * (d + 2 * l) + c) : (u = Math.max(0, -(o * r + a)), d = u > 0 ? r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c); - else d = o > 0 ? -r : r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - return n && n.copy(this.direction).multiplyScalar(u).add(this.origin), i && i.copy(Jr).multiplyScalar(d).add(To), f; - } - intersectSphere(e, t) { - jt.subVectors(e.center, this.origin); - let n = jt.dot(this.direction), i = jt.dot(jt) - n * n, r = e.radius * e.radius; - if (i > r) return null; - let o = Math.sqrt(r - i), a = n - o, l = n + o; - return a < 0 && l < 0 ? null : a < 0 ? this.at(l, t) : this.at(a, t); - } - intersectsSphere(e) { - return this.distanceSqToPoint(e.center) <= e.radius * e.radius; - } - distanceToPlane(e) { - let t = e.normal.dot(this.direction); - if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; - let n = -(this.origin.dot(e.normal) + e.constant) / t; - return n >= 0 ? n : null; - } - intersectPlane(e, t) { - let n = this.distanceToPlane(e); - return n === null ? null : this.at(n, t); - } - intersectsPlane(e) { - let t = e.distanceToPoint(this.origin); - return t === 0 || e.normal.dot(this.direction) * t < 0; - } - intersectBox(e, t) { - let n, i, r, o, a, l, c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin; - return c >= 0 ? (n = (e.min.x - d.x) * c, i = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, i = (e.min.x - d.x) * c), h >= 0 ? (r = (e.min.y - d.y) * h, o = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, o = (e.min.y - d.y) * h), n > o || r > i || ((r > n || n !== n) && (n = r), (o < i || i !== i) && (i = o), u >= 0 ? (a = (e.min.z - d.z) * u, l = (e.max.z - d.z) * u) : (a = (e.max.z - d.z) * u, l = (e.min.z - d.z) * u), n > l || a > i) || ((a > n || n !== n) && (n = a), (l < i || i !== i) && (i = l), i < 0) ? null : this.at(n >= 0 ? n : i, t); - } - intersectsBox(e) { - return this.intersectBox(e, jt) !== null; - } - intersectTriangle(e, t, n, i, r) { - Eo.subVectors(t, e), Yr.subVectors(n, e), Ao.crossVectors(Eo, Yr); - let o = this.direction.dot(Ao), a; - if (o > 0) { - if (i) return null; - a = 1; - } else if (o < 0) a = -1, o = -o; - else return null; - fn.subVectors(this.origin, e); - let l = a * this.direction.dot(Yr.crossVectors(fn, Yr)); - if (l < 0) return null; - let c = a * this.direction.dot(Eo.cross(fn)); - if (c < 0 || l + c > o) return null; - let h = -a * fn.dot(Ao); - return h < 0 ? null : this.at(h / o, r); - } - applyMatrix4(e) { - return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; - } - equals(e) { - return e.origin.equals(this.origin) && e.direction.equals(this.direction); - } - clone() { - return new this.constructor().copy(this); - } -}, pe = class { - constructor(){ - this.elements = [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ], arguments.length > 0 && console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead."); - } - set(e, t, n, i, r, o, a, l, c, h, u, d, f, m, x, v) { - let g = this.elements; - return g[0] = e, g[4] = t, g[8] = n, g[12] = i, g[1] = r, g[5] = o, g[9] = a, g[13] = l, g[2] = c, g[6] = h, g[10] = u, g[14] = d, g[3] = f, g[7] = m, g[11] = x, g[15] = v, this; - } - identity() { - return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; - } - clone() { - return new pe().fromArray(this.elements); - } - copy(e) { - let t = this.elements, n = e.elements; - return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; - } - copyPosition(e) { - let t = this.elements, n = e.elements; - return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; - } - setFromMatrix3(e) { - let t = e.elements; - return this.set(t[0], t[3], t[6], 0, t[1], t[4], t[7], 0, t[2], t[5], t[8], 0, 0, 0, 0, 1), this; - } - extractBasis(e, t, n) { - return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; - } - makeBasis(e, t, n) { - return this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this; - } - extractRotation(e) { - let t = this.elements, n = e.elements, i = 1 / si.setFromMatrixColumn(e, 0).length(), r = 1 / si.setFromMatrixColumn(e, 1).length(), o = 1 / si.setFromMatrixColumn(e, 2).length(); - return t[0] = n[0] * i, t[1] = n[1] * i, t[2] = n[2] * i, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, t[7] = 0, t[8] = n[8] * o, t[9] = n[9] * o, t[10] = n[10] * o, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; - } - makeRotationFromEuler(e) { - e && e.isEuler || console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."); - let t = this.elements, n = e.x, i = e.y, r = e.z, o = Math.cos(n), a = Math.sin(n), l = Math.cos(i), c = Math.sin(i), h = Math.cos(r), u = Math.sin(r); - if (e.order === "XYZ") { - let d = o * h, f = o * u, m = a * h, x = a * u; - t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = f + m * c, t[5] = d - x * c, t[9] = -a * l, t[2] = x - d * c, t[6] = m + f * c, t[10] = o * l; - } else if (e.order === "YXZ") { - let d = l * h, f = l * u, m = c * h, x = c * u; - t[0] = d + x * a, t[4] = m * a - f, t[8] = o * c, t[1] = o * u, t[5] = o * h, t[9] = -a, t[2] = f * a - m, t[6] = x + d * a, t[10] = o * l; - } else if (e.order === "ZXY") { - let d = l * h, f = l * u, m = c * h, x = c * u; - t[0] = d - x * a, t[4] = -o * u, t[8] = m + f * a, t[1] = f + m * a, t[5] = o * h, t[9] = x - d * a, t[2] = -o * c, t[6] = a, t[10] = o * l; - } else if (e.order === "ZYX") { - let d = o * h, f = o * u, m = a * h, x = a * u; - t[0] = l * h, t[4] = m * c - f, t[8] = d * c + x, t[1] = l * u, t[5] = x * c + d, t[9] = f * c - m, t[2] = -c, t[6] = a * l, t[10] = o * l; - } else if (e.order === "YZX") { - let d = o * l, f = o * c, m = a * l, x = a * c; - t[0] = l * h, t[4] = x - d * u, t[8] = m * u + f, t[1] = u, t[5] = o * h, t[9] = -a * h, t[2] = -c * h, t[6] = f * u + m, t[10] = d - x * u; - } else if (e.order === "XZY") { - let d = o * l, f = o * c, m = a * l, x = a * c; - t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = d * u + x, t[5] = o * h, t[9] = f * u - m, t[2] = m * u - f, t[6] = a * h, t[10] = x * u + d; - } - return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; - } - makeRotationFromQuaternion(e) { - return this.compose(tf, e, nf); - } - lookAt(e, t, n) { - let i = this.elements; - return St.subVectors(e, t), St.lengthSq() === 0 && (St.z = 1), St.normalize(), pn.crossVectors(n, St), pn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? St.x += 1e-4 : St.z += 1e-4, St.normalize(), pn.crossVectors(n, St)), pn.normalize(), Zr.crossVectors(St, pn), i[0] = pn.x, i[4] = Zr.x, i[8] = St.x, i[1] = pn.y, i[5] = Zr.y, i[9] = St.y, i[2] = pn.z, i[6] = Zr.z, i[10] = St.z, this; - } - multiply(e, t) { - return t !== void 0 ? (console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(e, t)) : this.multiplyMatrices(this, e); - } - premultiply(e) { - return this.multiplyMatrices(e, this); - } - multiplyMatrices(e, t) { - let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[4], l = n[8], c = n[12], h = n[1], u = n[5], d = n[9], f = n[13], m = n[2], x = n[6], v = n[10], g = n[14], p = n[3], _ = n[7], y = n[11], b = n[15], A = i[0], L = i[4], I = i[8], k = i[12], B = i[1], P = i[5], w = i[9], E = i[13], D = i[2], U = i[6], F = i[10], O = i[14], ne = i[3], ce = i[7], V = i[11], W = i[15]; - return r[0] = o * A + a * B + l * D + c * ne, r[4] = o * L + a * P + l * U + c * ce, r[8] = o * I + a * w + l * F + c * V, r[12] = o * k + a * E + l * O + c * W, r[1] = h * A + u * B + d * D + f * ne, r[5] = h * L + u * P + d * U + f * ce, r[9] = h * I + u * w + d * F + f * V, r[13] = h * k + u * E + d * O + f * W, r[2] = m * A + x * B + v * D + g * ne, r[6] = m * L + x * P + v * U + g * ce, r[10] = m * I + x * w + v * F + g * V, r[14] = m * k + x * E + v * O + g * W, r[3] = p * A + _ * B + y * D + b * ne, r[7] = p * L + _ * P + y * U + b * ce, r[11] = p * I + _ * w + y * F + b * V, r[15] = p * k + _ * E + y * O + b * W, this; - } - multiplyScalar(e) { - let t = this.elements; - return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this; - } - determinant() { - let e = this.elements, t = e[0], n = e[4], i = e[8], r = e[12], o = e[1], a = e[5], l = e[9], c = e[13], h = e[2], u = e[6], d = e[10], f = e[14], m = e[3], x = e[7], v = e[11], g = e[15]; - return m * (+r * l * u - i * c * u - r * a * d + n * c * d + i * a * f - n * l * f) + x * (+t * l * f - t * c * d + r * o * d - i * o * f + i * c * h - r * l * h) + v * (+t * c * u - t * a * f - r * o * u + n * o * f + r * a * h - n * c * h) + g * (-i * a * h - t * l * u + t * a * d + i * o * u - n * o * d + n * l * h); - } - transpose() { - let e = this.elements, t; - return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this; - } - setPosition(e, t, n) { - let i = this.elements; - return e.isVector3 ? (i[12] = e.x, i[13] = e.y, i[14] = e.z) : (i[12] = e, i[13] = t, i[14] = n), this; - } - invert() { - let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = e[9], d = e[10], f = e[11], m = e[12], x = e[13], v = e[14], g = e[15], p = u * v * c - x * d * c + x * l * f - a * v * f - u * l * g + a * d * g, _ = m * d * c - h * v * c - m * l * f + o * v * f + h * l * g - o * d * g, y = h * x * c - m * u * c + m * a * f - o * x * f - h * a * g + o * u * g, b = m * u * l - h * x * l - m * a * d + o * x * d + h * a * v - o * u * v, A = t * p + n * _ + i * y + r * b; - if (A === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - let L = 1 / A; - return e[0] = p * L, e[1] = (x * d * r - u * v * r - x * i * f + n * v * f + u * i * g - n * d * g) * L, e[2] = (a * v * r - x * l * r + x * i * c - n * v * c - a * i * g + n * l * g) * L, e[3] = (u * l * r - a * d * r - u * i * c + n * d * c + a * i * f - n * l * f) * L, e[4] = _ * L, e[5] = (h * v * r - m * d * r + m * i * f - t * v * f - h * i * g + t * d * g) * L, e[6] = (m * l * r - o * v * r - m * i * c + t * v * c + o * i * g - t * l * g) * L, e[7] = (o * d * r - h * l * r + h * i * c - t * d * c - o * i * f + t * l * f) * L, e[8] = y * L, e[9] = (m * u * r - h * x * r - m * n * f + t * x * f + h * n * g - t * u * g) * L, e[10] = (o * x * r - m * a * r + m * n * c - t * x * c - o * n * g + t * a * g) * L, e[11] = (h * a * r - o * u * r - h * n * c + t * u * c + o * n * f - t * a * f) * L, e[12] = b * L, e[13] = (h * x * i - m * u * i + m * n * d - t * x * d - h * n * v + t * u * v) * L, e[14] = (m * a * i - o * x * i - m * n * l + t * x * l + o * n * v - t * a * v) * L, e[15] = (o * u * i - h * a * i + h * n * l - t * u * l - o * n * d + t * a * d) * L, this; - } - scale(e) { - let t = this.elements, n = e.x, i = e.y, r = e.z; - return t[0] *= n, t[4] *= i, t[8] *= r, t[1] *= n, t[5] *= i, t[9] *= r, t[2] *= n, t[6] *= i, t[10] *= r, t[3] *= n, t[7] *= i, t[11] *= r, this; - } - getMaxScaleOnAxis() { - let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; - return Math.sqrt(Math.max(t, n, i)); - } - makeTranslation(e, t, n) { - return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1), this; - } - makeRotationX(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this; - } - makeRotationY(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this; - } - makeRotationZ(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; - } - makeRotationAxis(e, t) { - let n = Math.cos(t), i = Math.sin(t), r = 1 - n, o = e.x, a = e.y, l = e.z, c = r * o, h = r * a; - return this.set(c * o + n, c * a - i * l, c * l + i * a, 0, c * a + i * l, h * a + n, h * l - i * o, 0, c * l - i * a, h * l + i * o, r * l * l + n, 0, 0, 0, 0, 1), this; - } - makeScale(e, t, n) { - return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this; - } - makeShear(e, t, n, i, r, o) { - return this.set(1, n, r, 0, e, 1, o, 0, t, i, 1, 0, 0, 0, 0, 1), this; - } - compose(e, t, n) { - let i = this.elements, r = t._x, o = t._y, a = t._z, l = t._w, c = r + r, h = o + o, u = a + a, d = r * c, f = r * h, m = r * u, x = o * h, v = o * u, g = a * u, p = l * c, _ = l * h, y = l * u, b = n.x, A = n.y, L = n.z; - return i[0] = (1 - (x + g)) * b, i[1] = (f + y) * b, i[2] = (m - _) * b, i[3] = 0, i[4] = (f - y) * A, i[5] = (1 - (d + g)) * A, i[6] = (v + p) * A, i[7] = 0, i[8] = (m + _) * L, i[9] = (v - p) * L, i[10] = (1 - (d + x)) * L, i[11] = 0, i[12] = e.x, i[13] = e.y, i[14] = e.z, i[15] = 1, this; - } - decompose(e, t, n) { - let i = this.elements, r = si.set(i[0], i[1], i[2]).length(), o = si.set(i[4], i[5], i[6]).length(), a = si.set(i[8], i[9], i[10]).length(); - this.determinant() < 0 && (r = -r), e.x = i[12], e.y = i[13], e.z = i[14], It.copy(this); - let c = 1 / r, h = 1 / o, u = 1 / a; - return It.elements[0] *= c, It.elements[1] *= c, It.elements[2] *= c, It.elements[4] *= h, It.elements[5] *= h, It.elements[6] *= h, It.elements[8] *= u, It.elements[9] *= u, It.elements[10] *= u, t.setFromRotationMatrix(It), n.x = r, n.y = o, n.z = a, this; - } - makePerspective(e, t, n, i, r, o) { - o === void 0 && console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."); - let a = this.elements, l = 2 * r / (t - e), c = 2 * r / (n - i), h = (t + e) / (t - e), u = (n + i) / (n - i), d = -(o + r) / (o - r), f = -2 * o * r / (o - r); - return a[0] = l, a[4] = 0, a[8] = h, a[12] = 0, a[1] = 0, a[5] = c, a[9] = u, a[13] = 0, a[2] = 0, a[6] = 0, a[10] = d, a[14] = f, a[3] = 0, a[7] = 0, a[11] = -1, a[15] = 0, this; - } - makeOrthographic(e, t, n, i, r, o) { - let a = this.elements, l = 1 / (t - e), c = 1 / (n - i), h = 1 / (o - r), u = (t + e) * l, d = (n + i) * c, f = (o + r) * h; - return a[0] = 2 * l, a[4] = 0, a[8] = 0, a[12] = -u, a[1] = 0, a[5] = 2 * c, a[9] = 0, a[13] = -d, a[2] = 0, a[6] = 0, a[10] = -2 * h, a[14] = -f, a[3] = 0, a[7] = 0, a[11] = 0, a[15] = 1, this; - } - equals(e) { - let t = this.elements, n = e.elements; - for(let i = 0; i < 16; i++)if (t[i] !== n[i]) return !1; - return !0; - } - fromArray(e, t = 0) { - for(let n = 0; n < 16; n++)this.elements[n] = e[n + t]; - return this; - } - toArray(e = [], t = 0) { - let n = this.elements; - return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; - } -}; -pe.prototype.isMatrix4 = !0; -var si = new M, It = new pe, tf = new M(0, 0, 0), nf = new M(1, 1, 1), pn = new M, Zr = new M, St = new M, _l = new pe, Ml = new gt, Zn = class { - constructor(e = 0, t = 0, n = 0, i = Zn.DefaultOrder){ - this._x = e, this._y = t, this._z = n, this._order = i; - } - get x() { - return this._x; - } - set x(e) { - this._x = e, this._onChangeCallback(); - } - get y() { - return this._y; - } - set y(e) { - this._y = e, this._onChangeCallback(); - } - get z() { - return this._z; - } - set z(e) { - this._z = e, this._onChangeCallback(); - } - get order() { - return this._order; - } - set order(e) { - this._order = e, this._onChangeCallback(); - } - set(e, t, n, i = this._order) { - return this._x = e, this._y = t, this._z = n, this._order = i, this._onChangeCallback(), this; - } - clone() { - return new this.constructor(this._x, this._y, this._z, this._order); - } - copy(e) { - return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; - } - setFromRotationMatrix(e, t = this._order, n = !0) { - let i = e.elements, r = i[0], o = i[4], a = i[8], l = i[1], c = i[5], h = i[9], u = i[2], d = i[6], f = i[10]; - switch(t){ - case "XYZ": - this._y = Math.asin(mt(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(-h, f), this._z = Math.atan2(-o, r)) : (this._x = Math.atan2(d, c), this._z = 0); - break; - case "YXZ": - this._x = Math.asin(-mt(h, -1, 1)), Math.abs(h) < .9999999 ? (this._y = Math.atan2(a, f), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0); - break; - case "ZXY": - this._x = Math.asin(mt(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-o, c)) : (this._y = 0, this._z = Math.atan2(l, r)); - break; - case "ZYX": - this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-o, c)); - break; - case "YZX": - this._z = Math.asin(mt(l, -1, 1)), Math.abs(l) < .9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(a, f)); - break; - case "XZY": - this._z = Math.asin(-mt(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(a, r)) : (this._x = Math.atan2(-h, f), this._y = 0); - break; - default: - console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t); - } - return this._order = t, n === !0 && this._onChangeCallback(), this; - } - setFromQuaternion(e, t, n) { - return _l.makeRotationFromQuaternion(e), this.setFromRotationMatrix(_l, t, n); - } - setFromVector3(e, t = this._order) { - return this.set(e.x, e.y, e.z, t); - } - reorder(e) { - return Ml.setFromEuler(this), this.setFromQuaternion(Ml, e); - } - equals(e) { - return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; - } - fromArray(e) { - return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; - } - toArray(e = [], t = 0) { - return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e; - } - toVector3(e) { - return e ? e.set(this._x, this._y, this._z) : new M(this._x, this._y, this._z); - } - _onChange(e) { - return this._onChangeCallback = e, this; - } - _onChangeCallback() {} -}; -Zn.prototype.isEuler = !0; -Zn.DefaultOrder = "XYZ"; -Zn.RotationOrders = [ - "XYZ", - "YZX", - "ZXY", - "XZY", - "YXZ", - "ZYX" -]; -var Js = class { - constructor(){ - this.mask = 1; - } - set(e) { - this.mask = (1 << e | 0) >>> 0; - } - enable(e) { - this.mask |= 1 << e | 0; - } - enableAll() { - this.mask = -1; - } - toggle(e) { - this.mask ^= 1 << e | 0; - } - disable(e) { - this.mask &= ~(1 << e | 0); - } - disableAll() { - this.mask = 0; - } - test(e) { - return (this.mask & e.mask) !== 0; - } - isEnabled(e) { - return (this.mask & (1 << e | 0)) !== 0; - } -}, rf = 0, bl = new M, oi = new gt, Qt = new pe, $r = new M, Zi = new M, sf = new M, of = new gt, wl = new M(1, 0, 0), Sl = new M(0, 1, 0), Tl = new M(0, 0, 1), af = { - type: "added" -}, El = { - type: "removed" -}, Ne = class extends En { - constructor(){ - super(); - Object.defineProperty(this, "id", { - value: rf++ - }), this.uuid = Et(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Ne.DefaultUp.clone(); - let e = new M, t = new Zn, n = new gt, i = new M(1, 1, 1); - function r() { - n.setFromEuler(t, !1); - } - function o() { - t.setFromQuaternion(n, void 0, !1); - } - t._onChange(r), n._onChange(o), Object.defineProperties(this, { - position: { - configurable: !0, - enumerable: !0, - value: e - }, - rotation: { - configurable: !0, - enumerable: !0, - value: t - }, - quaternion: { - configurable: !0, - enumerable: !0, - value: n - }, - scale: { - configurable: !0, - enumerable: !0, - value: i - }, - modelViewMatrix: { - value: new pe - }, - normalMatrix: { - value: new lt - } - }), this.matrix = new pe, this.matrixWorld = new pe, this.matrixAutoUpdate = Ne.DefaultMatrixAutoUpdate, this.matrixWorldNeedsUpdate = !1, this.layers = new Js, this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}; - } - onBeforeRender() {} - onAfterRender() {} - applyMatrix4(e) { - this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); - } - applyQuaternion(e) { - return this.quaternion.premultiply(e), this; - } - setRotationFromAxisAngle(e, t) { - this.quaternion.setFromAxisAngle(e, t); - } - setRotationFromEuler(e) { - this.quaternion.setFromEuler(e, !0); - } - setRotationFromMatrix(e) { - this.quaternion.setFromRotationMatrix(e); - } - setRotationFromQuaternion(e) { - this.quaternion.copy(e); - } - rotateOnAxis(e, t) { - return oi.setFromAxisAngle(e, t), this.quaternion.multiply(oi), this; - } - rotateOnWorldAxis(e, t) { - return oi.setFromAxisAngle(e, t), this.quaternion.premultiply(oi), this; - } - rotateX(e) { - return this.rotateOnAxis(wl, e); - } - rotateY(e) { - return this.rotateOnAxis(Sl, e); - } - rotateZ(e) { - return this.rotateOnAxis(Tl, e); - } - translateOnAxis(e, t) { - return bl.copy(e).applyQuaternion(this.quaternion), this.position.add(bl.multiplyScalar(t)), this; - } - translateX(e) { - return this.translateOnAxis(wl, e); - } - translateY(e) { - return this.translateOnAxis(Sl, e); - } - translateZ(e) { - return this.translateOnAxis(Tl, e); - } - localToWorld(e) { - return e.applyMatrix4(this.matrixWorld); - } - worldToLocal(e) { - return e.applyMatrix4(Qt.copy(this.matrixWorld).invert()); - } - lookAt(e, t, n) { - e.isVector3 ? $r.copy(e) : $r.set(e, t, n); - let i = this.parent; - this.updateWorldMatrix(!0, !1), Zi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Qt.lookAt(Zi, $r, this.up) : Qt.lookAt($r, Zi, this.up), this.quaternion.setFromRotationMatrix(Qt), i && (Qt.extractRotation(i.matrixWorld), oi.setFromRotationMatrix(Qt), this.quaternion.premultiply(oi.invert())); - } - add(e) { - if (arguments.length > 1) { - for(let t = 0; t < arguments.length; t++)this.add(arguments[t]); - return this; - } - return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), e.parent = this, this.children.push(e), e.dispatchEvent(af)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this); - } - remove(e) { - if (arguments.length > 1) { - for(let n = 0; n < arguments.length; n++)this.remove(arguments[n]); - return this; - } - let t = this.children.indexOf(e); - return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(El)), this; - } - removeFromParent() { - let e = this.parent; - return e !== null && e.remove(this), this; - } - clear() { - for(let e = 0; e < this.children.length; e++){ - let t = this.children[e]; - t.parent = null, t.dispatchEvent(El); - } - return this.children.length = 0, this; - } - attach(e) { - return this.updateWorldMatrix(!0, !1), Qt.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Qt.multiply(e.parent.matrixWorld)), e.applyMatrix4(Qt), this.add(e), e.updateWorldMatrix(!1, !0), this; - } - getObjectById(e) { - return this.getObjectByProperty("id", e); - } - getObjectByName(e) { - return this.getObjectByProperty("name", e); - } - getObjectByProperty(e, t) { - if (this[e] === t) return this; - for(let n = 0, i = this.children.length; n < i; n++){ - let o = this.children[n].getObjectByProperty(e, t); - if (o !== void 0) return o; - } - } - getWorldPosition(e) { - return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); - } - getWorldQuaternion(e) { - return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, e, sf), e; - } - getWorldScale(e) { - return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, of, e), e; - } - getWorldDirection(e) { - this.updateWorldMatrix(!0, !1); - let t = this.matrixWorld.elements; - return e.set(t[8], t[9], t[10]).normalize(); - } - raycast() {} - traverse(e) { - e(this); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].traverse(e); - } - traverseVisible(e) { - if (this.visible === !1) return; - e(this); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].traverseVisible(e); - } - traverseAncestors(e) { - let t = this.parent; - t !== null && (e(t), t.traverseAncestors(e)); - } - updateMatrix() { - this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0; - } - updateMatrixWorld(e) { - this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].updateMatrixWorld(e); - } - updateWorldMatrix(e, t) { - let n = this.parent; - if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) { - let i = this.children; - for(let r = 0, o = i.length; r < o; r++)i[r].updateWorldMatrix(!1, !0); - } - } - toJSON(e) { - let t = e === void 0 || typeof e == "string", n = {}; - t && (e = { - geometries: {}, - materials: {}, - textures: {}, - images: {}, - shapes: {}, - skeletons: {}, - animations: {} - }, n.metadata = { - version: 4.5, - type: "Object", - generator: "Object3D.toJSON" - }); - let i = {}; - i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.castShadow === !0 && (i.castShadow = !0), this.receiveShadow === !0 && (i.receiveShadow = !0), this.visible === !1 && (i.visible = !1), this.frustumCulled === !1 && (i.frustumCulled = !1), this.renderOrder !== 0 && (i.renderOrder = this.renderOrder), JSON.stringify(this.userData) !== "{}" && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (i.instanceColor = this.instanceColor.toJSON())); - function r(a, l) { - return a[l.uuid] === void 0 && (a[l.uuid] = l.toJSON(e)), l.uuid; - } - if (this.isScene) this.background && (this.background.isColor ? i.background = this.background.toJSON() : this.background.isTexture && (i.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && (i.environment = this.environment.toJSON(e).uuid); - else if (this.isMesh || this.isLine || this.isPoints) { - i.geometry = r(e.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; c < h; c++){ - let u = l[c]; - r(e.shapes, u); - } - else r(e.shapes, l); - } - } - if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(e.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { - let a = []; - for(let l = 0, c = this.material.length; l < c; l++)a.push(r(e.materials, this.material[l])); - i.material = a; - } else i.material = r(e.materials, this.material); - if (this.children.length > 0) { - i.children = []; - for(let a = 0; a < this.children.length; a++)i.children.push(this.children[a].toJSON(e).object); - } - if (this.animations.length > 0) { - i.animations = []; - for(let a = 0; a < this.animations.length; a++){ - let l = this.animations[a]; - i.animations.push(r(e.animations, l)); - } - } - if (t) { - let a = o(e.geometries), l = o(e.materials), c = o(e.textures), h = o(e.images), u = o(e.shapes), d = o(e.skeletons), f = o(e.animations); - a.length > 0 && (n.geometries = a), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), d.length > 0 && (n.skeletons = d), f.length > 0 && (n.animations = f); - } - return n.object = i, n; - function o(a) { - let l = []; - for(let c in a){ - let h = a[c]; - delete h.metadata, l.push(h); - } - return l; - } - } - clone(e) { - return new this.constructor().copy(this, e); - } - copy(e, t = !0) { - if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for(let n = 0; n < e.children.length; n++){ - let i = e.children[n]; - this.add(i.clone()); - } - return this; - } -}; -Ne.DefaultUp = new M(0, 1, 0); -Ne.DefaultMatrixAutoUpdate = !0; -Ne.prototype.isObject3D = !0; -var Dt = new M, Kt = new M, Co = new M, en = new M, ai = new M, li = new M, Al = new M, Lo = new M, Ro = new M, Po = new M, nt = class { - constructor(e = new M, t = new M, n = new M){ - this.a = e, this.b = t, this.c = n; - } - static getNormal(e, t, n, i) { - i.subVectors(n, t), Dt.subVectors(e, t), i.cross(Dt); - let r = i.lengthSq(); - return r > 0 ? i.multiplyScalar(1 / Math.sqrt(r)) : i.set(0, 0, 0); - } - static getBarycoord(e, t, n, i, r) { - Dt.subVectors(i, t), Kt.subVectors(n, t), Co.subVectors(e, t); - let o = Dt.dot(Dt), a = Dt.dot(Kt), l = Dt.dot(Co), c = Kt.dot(Kt), h = Kt.dot(Co), u = o * c - a * a; - if (u === 0) return r.set(-2, -1, -1); - let d = 1 / u, f = (c * l - a * h) * d, m = (o * h - a * l) * d; - return r.set(1 - f - m, m, f); - } - static containsPoint(e, t, n, i) { - return this.getBarycoord(e, t, n, i, en), en.x >= 0 && en.y >= 0 && en.x + en.y <= 1; - } - static getUV(e, t, n, i, r, o, a, l) { - return this.getBarycoord(e, t, n, i, en), l.set(0, 0), l.addScaledVector(r, en.x), l.addScaledVector(o, en.y), l.addScaledVector(a, en.z), l; - } - static isFrontFacing(e, t, n, i) { - return Dt.subVectors(n, t), Kt.subVectors(e, t), Dt.cross(Kt).dot(i) < 0; - } - set(e, t, n) { - return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; - } - setFromPointsAndIndices(e, t, n, i) { - return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this; - } - setFromAttributeAndIndices(e, t, n, i) { - return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, i), this; - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; - } - getArea() { - return Dt.subVectors(this.c, this.b), Kt.subVectors(this.a, this.b), Dt.cross(Kt).length() * .5; - } - getMidpoint(e) { - return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); - } - getNormal(e) { - return nt.getNormal(this.a, this.b, this.c, e); - } - getPlane(e) { - return e.setFromCoplanarPoints(this.a, this.b, this.c); - } - getBarycoord(e, t) { - return nt.getBarycoord(e, this.a, this.b, this.c, t); - } - getUV(e, t, n, i, r) { - return nt.getUV(e, this.a, this.b, this.c, t, n, i, r); - } - containsPoint(e) { - return nt.containsPoint(e, this.a, this.b, this.c); - } - isFrontFacing(e) { - return nt.isFrontFacing(this.a, this.b, this.c, e); - } - intersectsBox(e) { - return e.intersectsTriangle(this); - } - closestPointToPoint(e, t) { - let n = this.a, i = this.b, r = this.c, o, a; - ai.subVectors(i, n), li.subVectors(r, n), Lo.subVectors(e, n); - let l = ai.dot(Lo), c = li.dot(Lo); - if (l <= 0 && c <= 0) return t.copy(n); - Ro.subVectors(e, i); - let h = ai.dot(Ro), u = li.dot(Ro); - if (h >= 0 && u <= h) return t.copy(i); - let d = l * u - h * c; - if (d <= 0 && l >= 0 && h <= 0) return o = l / (l - h), t.copy(n).addScaledVector(ai, o); - Po.subVectors(e, r); - let f = ai.dot(Po), m = li.dot(Po); - if (m >= 0 && f <= m) return t.copy(r); - let x = f * c - l * m; - if (x <= 0 && c >= 0 && m <= 0) return a = c / (c - m), t.copy(n).addScaledVector(li, a); - let v = h * m - f * u; - if (v <= 0 && u - h >= 0 && f - m >= 0) return Al.subVectors(r, i), a = (u - h) / (u - h + (f - m)), t.copy(i).addScaledVector(Al, a); - let g = 1 / (v + x + d); - return o = x * g, a = d * g, t.copy(n).addScaledVector(ai, o).addScaledVector(li, a); - } - equals(e) { - return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); - } -}, lf = 0, dt = class extends En { - constructor(){ - super(); - Object.defineProperty(this, "id", { - value: lf++ - }), this.uuid = Et(), this.name = "", this.type = "Material", this.fog = !0, this.blending = sr, this.side = Ai, this.vertexColors = !1, this.opacity = 1, this.format = ct, this.transparent = !1, this.blendSrc = Gc, this.blendDst = Vc, this.blendEquation = _i, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.depthFunc = ea, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Ud, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = vo, this.stencilZFail = vo, this.stencilZPass = vo, 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.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; - } - get alphaTest() { - return this._alphaTest; - } - set alphaTest(e) { - this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; - } - onBuild() {} - onBeforeRender() {} - onBeforeCompile() {} - customProgramCacheKey() { - return this.onBeforeCompile.toString(); - } - setValues(e) { - if (e !== void 0) for(let t in e){ - let n = e[t]; - if (n === void 0) { - console.warn("THREE.Material: '" + t + "' parameter is undefined."); - continue; - } - if (t === "shading") { - console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = n === kc; - continue; - } - let i = this[t]; - if (i === void 0) { - console.warn("THREE." + this.type + ": '" + t + "' is not a property of this material."); - continue; - } - i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[t] = n; - } - } - toJSON(e) { - let t = e === void 0 || typeof e == "string"; - t && (e = { - textures: {}, - images: {} - }); - let n = { - metadata: { - version: 4.5, - type: "Material", - generator: "Material.toJSON" - } - }; - n.uuid = this.uuid, n.type = this.type, this.name !== "" && (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 && this.emissiveIntensity !== 1 && (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(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), 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(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).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.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== sr && (n.blending = this.blending), this.side !== Ai && (n.side = this.side), this.vertexColors && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.format !== ct && (n.format = this.format), this.transparent === !0 && (n.transparent = this.transparent), n.depthFunc = this.depthFunc, n.depthTest = this.depthTest, n.depthWrite = this.depthWrite, n.colorWrite = this.colorWrite, n.stencilWrite = this.stencilWrite, 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, this.rotation && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth && this.linewidth !== 1 && (n.linewidth = this.linewidth), 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.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaToCoverage === !0 && (n.alphaToCoverage = this.alphaToCoverage), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = this.premultipliedAlpha), this.wireframe === !0 && (n.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = this.flatShading), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData); - function i(r) { - let o = []; - for(let a in r){ - let l = r[a]; - delete l.metadata, o.push(l); - } - return o; - } - if (t) { - let r = i(e.textures), o = i(e.images); - r.length > 0 && (n.textures = r), o.length > 0 && (n.images = o); - } - return n; - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - this.name = e.name, this.fog = e.fog, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.format = e.format, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; - let t = e.clippingPlanes, n = null; - if (t !== null) { - let i = t.length; - n = new Array(i); - for(let r = 0; r !== i; ++r)n[r] = t[r].clone(); - } - return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; - } - dispose() { - this.dispatchEvent({ - type: "dispose" - }); - } - set needsUpdate(e) { - e === !0 && this.version++; - } -}; -dt.prototype.isMaterial = !0; -var $c = { - 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 -}, Ft = { - h: 0, - s: 0, - l: 0 -}, jr = { - h: 0, - s: 0, - l: 0 -}; -function Io(s, e, t) { - return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? s + (e - s) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? s + (e - s) * 6 * (2 / 3 - t) : s; -} -function Do(s) { - return s < .04045 ? s * .0773993808 : Math.pow(s * .9478672986 + .0521327014, 2.4); -} -function Fo(s) { - return s < .0031308 ? s * 12.92 : 1.055 * Math.pow(s, .41666) - .055; -} -var ae = class { - constructor(e, t, n){ - return t === void 0 && n === void 0 ? this.set(e) : this.setRGB(e, t, n); - } - set(e) { - return e && e.isColor ? this.copy(e) : typeof e == "number" ? this.setHex(e) : typeof e == "string" && this.setStyle(e), this; - } - setScalar(e) { - return this.r = e, this.g = e, this.b = e, this; - } - setHex(e) { - return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, this; - } - setRGB(e, t, n) { - return this.r = e, this.g = t, this.b = n, this; - } - setHSL(e, t, n) { - if (e = da(e, 1), t = mt(t, 0, 1), n = mt(n, 0, 1), t === 0) this.r = this.g = this.b = n; - else { - let i = n <= .5 ? n * (1 + t) : n + t - n * t, r = 2 * n - i; - this.r = Io(r, i, e + 1 / 3), this.g = Io(r, i, e), this.b = Io(r, i, e - 1 / 3); - } - return this; - } - setStyle(e) { - function t(i) { - i !== void 0 && parseFloat(i) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored."); - } - let n; - if (n = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)) { - let i, r = n[1], o = n[2]; - switch(r){ - case "rgb": - case "rgba": - if (i = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(255, parseInt(i[1], 10)) / 255, this.g = Math.min(255, parseInt(i[2], 10)) / 255, this.b = Math.min(255, parseInt(i[3], 10)) / 255, t(i[4]), this; - if (i = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(100, parseInt(i[1], 10)) / 100, this.g = Math.min(100, parseInt(i[2], 10)) / 100, this.b = Math.min(100, parseInt(i[3], 10)) / 100, t(i[4]), this; - break; - case "hsl": - case "hsla": - if (i = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) { - let a = parseFloat(i[1]) / 360, l = parseInt(i[2], 10) / 100, c = parseInt(i[3], 10) / 100; - return t(i[4]), this.setHSL(a, l, c); - } - break; - } - } else if (n = /^\#([A-Fa-f\d]+)$/.exec(e)) { - let i = n[1], r = i.length; - if (r === 3) return this.r = parseInt(i.charAt(0) + i.charAt(0), 16) / 255, this.g = parseInt(i.charAt(1) + i.charAt(1), 16) / 255, this.b = parseInt(i.charAt(2) + i.charAt(2), 16) / 255, this; - if (r === 6) return this.r = parseInt(i.charAt(0) + i.charAt(1), 16) / 255, this.g = parseInt(i.charAt(2) + i.charAt(3), 16) / 255, this.b = parseInt(i.charAt(4) + i.charAt(5), 16) / 255, this; - } - return e && e.length > 0 ? this.setColorName(e) : this; - } - setColorName(e) { - let t = $c[e.toLowerCase()]; - return t !== void 0 ? this.setHex(t) : console.warn("THREE.Color: Unknown color " + e), this; - } - clone() { - return new this.constructor(this.r, this.g, this.b); - } - copy(e) { - return this.r = e.r, this.g = e.g, this.b = e.b, this; - } - copySRGBToLinear(e) { - return this.r = Do(e.r), this.g = Do(e.g), this.b = Do(e.b), this; - } - copyLinearToSRGB(e) { - return this.r = Fo(e.r), this.g = Fo(e.g), this.b = Fo(e.b), this; - } - convertSRGBToLinear() { - return this.copySRGBToLinear(this), this; - } - convertLinearToSRGB() { - return this.copyLinearToSRGB(this), this; - } - getHex() { - return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0; - } - getHexString() { - return ("000000" + this.getHex().toString(16)).slice(-6); - } - getHSL(e) { - let t = this.r, n = this.g, i = this.b, r = Math.max(t, n, i), o = Math.min(t, n, i), a, l, c = (o + r) / 2; - if (o === r) a = 0, l = 0; - else { - let h = r - o; - switch(l = c <= .5 ? h / (r + o) : h / (2 - r - o), r){ - case t: - a = (n - i) / h + (n < i ? 6 : 0); - break; - case n: - a = (i - t) / h + 2; - break; - case i: - a = (t - n) / h + 4; - break; - } - a /= 6; - } - return e.h = a, e.s = l, e.l = c, e; - } - getStyle() { - return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")"; - } - offsetHSL(e, t, n) { - return this.getHSL(Ft), Ft.h += e, Ft.s += t, Ft.l += n, this.setHSL(Ft.h, Ft.s, Ft.l), this; - } - add(e) { - return this.r += e.r, this.g += e.g, this.b += e.b, this; - } - addColors(e, t) { - return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; - } - addScalar(e) { - return this.r += e, this.g += e, this.b += e, this; - } - sub(e) { - return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this; - } - multiply(e) { - return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; - } - multiplyScalar(e) { - return this.r *= e, this.g *= e, this.b *= e, this; - } - lerp(e, t) { - return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this; - } - lerpColors(e, t, n) { - return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; - } - lerpHSL(e, t) { - this.getHSL(Ft), e.getHSL(jr); - let n = or(Ft.h, jr.h, t), i = or(Ft.s, jr.s, t), r = or(Ft.l, jr.l, t); - return this.setHSL(n, i, r), this; - } - equals(e) { - return e.r === this.r && e.g === this.g && e.b === this.b; - } - fromArray(e, t = 0) { - return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; - } - toArray(e = [], t = 0) { - return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; - } - fromBufferAttribute(e, t) { - return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), e.normalized === !0 && (this.r /= 255, this.g /= 255, this.b /= 255), this; - } - toJSON() { - return this.getHex(); - } -}; -ae.NAMES = $c; -ae.prototype.isColor = !0; -ae.prototype.r = 1; -ae.prototype.g = 1; -ae.prototype.b = 1; -var hn = class extends dt { - constructor(e){ - super(); - this.type = "MeshBasicMaterial", this.color = new ae(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.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; - } -}; -hn.prototype.isMeshBasicMaterial = !0; -var Je = new M, Qr = new X, Ue = class { - constructor(e, t, n){ - if (Array.isArray(e)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); - this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n === !0, this.usage = hr, this.updateRange = { - offset: 0, - count: -1 - }, this.version = 0; - } - onUploadCallback() {} - set needsUpdate(e) { - e === !0 && this.version++; - } - setUsage(e) { - return this.usage = e, this; - } - copy(e) { - return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this; - } - copyAt(e, t, n) { - e *= this.itemSize, n *= t.itemSize; - for(let i = 0, r = this.itemSize; i < r; i++)this.array[e + i] = t.array[n + i]; - return this; - } - copyArray(e) { - return this.array.set(e), this; - } - copyColorsArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i), o = new ae), t[n++] = o.r, t[n++] = o.g, t[n++] = o.b; - } - return this; - } - copyVector2sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i), o = new X), t[n++] = o.x, t[n++] = o.y; - } - return this; - } - copyVector3sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i), o = new M), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z; - } - return this; - } - copyVector4sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i), o = new Ve), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z, t[n++] = o.w; - } - return this; - } - applyMatrix3(e) { - if (this.itemSize === 2) for(let t = 0, n = this.count; t < n; t++)Qr.fromBufferAttribute(this, t), Qr.applyMatrix3(e), this.setXY(t, Qr.x, Qr.y); - else if (this.itemSize === 3) for(let t = 0, n = this.count; t < n; t++)Je.fromBufferAttribute(this, t), Je.applyMatrix3(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; - } - applyMatrix4(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyMatrix4(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; - } - applyNormalMatrix(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyNormalMatrix(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; - } - transformDirection(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.transformDirection(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; - } - set(e, t = 0) { - return this.array.set(e, t), this; - } - getX(e) { - return this.array[e * this.itemSize]; - } - setX(e, t) { - return this.array[e * this.itemSize] = t, this; - } - getY(e) { - return this.array[e * this.itemSize + 1]; - } - setY(e, t) { - return this.array[e * this.itemSize + 1] = t, this; - } - getZ(e) { - return this.array[e * this.itemSize + 2]; - } - setZ(e, t) { - return this.array[e * this.itemSize + 2] = t, this; - } - getW(e) { - return this.array[e * this.itemSize + 3]; - } - setW(e, t) { - return this.array[e * this.itemSize + 3] = t, this; - } - setXY(e, t, n) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this; - } - setXYZ(e, t, n, i) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this; - } - setXYZW(e, t, n, i, r) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this.array[e + 3] = r, this; - } - onUpload(e) { - return this.onUploadCallback = e, this; - } - clone() { - return new this.constructor(this.array, this.itemSize).copy(this); - } - toJSON() { - let e = { - itemSize: this.itemSize, - type: this.array.constructor.name, - array: Array.prototype.slice.call(this.array), - normalized: this.normalized - }; - return this.name !== "" && (e.name = this.name), this.usage !== hr && (e.usage = this.usage), (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (e.updateRange = this.updateRange), e; - } -}; -Ue.prototype.isBufferAttribute = !0; -var jc = class extends Ue { - constructor(e, t, n){ - super(new Int8Array(e), t, n); - } -}, Qc = class extends Ue { - constructor(e, t, n){ - super(new Uint8Array(e), t, n); - } -}, Kc = class extends Ue { - constructor(e, t, n){ - super(new Uint8ClampedArray(e), t, n); - } -}, eh = class extends Ue { - constructor(e, t, n){ - super(new Int16Array(e), t, n); - } -}, Ys = class extends Ue { - constructor(e, t, n){ - super(new Uint16Array(e), t, n); - } -}, th = class extends Ue { - constructor(e, t, n){ - super(new Int32Array(e), t, n); - } -}, Zs = class extends Ue { - constructor(e, t, n){ - super(new Uint32Array(e), t, n); - } -}, nh = class extends Ue { - constructor(e, t, n){ - super(new Uint16Array(e), t, n); - } -}; -nh.prototype.isFloat16BufferAttribute = !0; -var de = class extends Ue { - constructor(e, t, n){ - super(new Float32Array(e), t, n); - } -}, ih = class extends Ue { - constructor(e, t, n){ - super(new Float64Array(e), t, n); - } -}, cf = 0, Rt = new pe, No = new Ne, ci = new M, Tt = new Lt, $i = new Lt, ht = new M, _e = class extends En { - constructor(){ - super(); - Object.defineProperty(this, "id", { - value: cf++ - }), this.uuid = Et(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { - start: 0, - count: 1 / 0 - }, this.userData = {}; - } - getIndex() { - return this.index; - } - setIndex(e) { - return Array.isArray(e) ? this.index = new (Yc(e) > 65535 ? Zs : Ys)(e, 1) : this.index = e, this; - } - getAttribute(e) { - return this.attributes[e]; - } - setAttribute(e, t) { - return this.attributes[e] = t, this; - } - deleteAttribute(e) { - return delete this.attributes[e], this; - } - hasAttribute(e) { - return this.attributes[e] !== void 0; - } - addGroup(e, t, n = 0) { - this.groups.push({ - start: e, - count: t, - materialIndex: n - }); - } - clearGroups() { - this.groups = []; - } - setDrawRange(e, t) { - this.drawRange.start = e, this.drawRange.count = t; - } - applyMatrix4(e) { - let t = this.attributes.position; - t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); - let n = this.attributes.normal; - if (n !== void 0) { - let r = new lt().getNormalMatrix(e); - n.applyNormalMatrix(r), n.needsUpdate = !0; - } - let i = this.attributes.tangent; - return i !== void 0 && (i.transformDirection(e), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; - } - applyQuaternion(e) { - return Rt.makeRotationFromQuaternion(e), this.applyMatrix4(Rt), this; - } - rotateX(e) { - return Rt.makeRotationX(e), this.applyMatrix4(Rt), this; - } - rotateY(e) { - return Rt.makeRotationY(e), this.applyMatrix4(Rt), this; - } - rotateZ(e) { - return Rt.makeRotationZ(e), this.applyMatrix4(Rt), this; - } - translate(e, t, n) { - return Rt.makeTranslation(e, t, n), this.applyMatrix4(Rt), this; - } - scale(e, t, n) { - return Rt.makeScale(e, t, n), this.applyMatrix4(Rt), this; - } - lookAt(e) { - return No.lookAt(e), No.updateMatrix(), this.applyMatrix4(No.matrix), this; - } - center() { - return this.computeBoundingBox(), this.boundingBox.getCenter(ci).negate(), this.translate(ci.x, ci.y, ci.z), this; - } - setFromPoints(e) { - let t = []; - for(let n = 0, i = e.length; n < i; n++){ - let r = e[n]; - t.push(r.x, r.y, r.z || 0); - } - return this.setAttribute("position", new de(t, 3)), this; - } - computeBoundingBox() { - this.boundingBox === null && (this.boundingBox = new Lt); - let e = this.attributes.position, t = this.morphAttributes.position; - if (e && e.isGLBufferAttribute) { - console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingBox.set(new M(-1 / 0, -1 / 0, -1 / 0), new M(1 / 0, 1 / 0, 1 / 0)); - return; - } - if (e !== void 0) { - if (this.boundingBox.setFromBufferAttribute(e), t) for(let n = 0, i = t.length; n < i; n++){ - let r = t[n]; - Tt.setFromBufferAttribute(r), this.morphTargetsRelative ? (ht.addVectors(this.boundingBox.min, Tt.min), this.boundingBox.expandByPoint(ht), ht.addVectors(this.boundingBox.max, Tt.max), this.boundingBox.expandByPoint(ht)) : (this.boundingBox.expandByPoint(Tt.min), this.boundingBox.expandByPoint(Tt.max)); - } - } else this.boundingBox.makeEmpty(); - (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this); - } - computeBoundingSphere() { - this.boundingSphere === null && (this.boundingSphere = new An); - let e = this.attributes.position, t = this.morphAttributes.position; - if (e && e.isGLBufferAttribute) { - console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingSphere.set(new M, 1 / 0); - return; - } - if (e) { - let n = this.boundingSphere.center; - if (Tt.setFromBufferAttribute(e), t) for(let r = 0, o = t.length; r < o; r++){ - let a = t[r]; - $i.setFromBufferAttribute(a), this.morphTargetsRelative ? (ht.addVectors(Tt.min, $i.min), Tt.expandByPoint(ht), ht.addVectors(Tt.max, $i.max), Tt.expandByPoint(ht)) : (Tt.expandByPoint($i.min), Tt.expandByPoint($i.max)); - } - Tt.getCenter(n); - let i = 0; - for(let r = 0, o = e.count; r < o; r++)ht.fromBufferAttribute(e, r), i = Math.max(i, n.distanceToSquared(ht)); - if (t) for(let r = 0, o = t.length; r < o; r++){ - let a = t[r], l = this.morphTargetsRelative; - for(let c = 0, h = a.count; c < h; c++)ht.fromBufferAttribute(a, c), l && (ci.fromBufferAttribute(e, c), ht.add(ci)), i = Math.max(i, n.distanceToSquared(ht)); - } - this.boundingSphere.radius = Math.sqrt(i), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this); - } - } - computeTangents() { - let e = this.index, t = this.attributes; - if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { - console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); - return; - } - let n = e.array, i = t.position.array, r = t.normal.array, o = t.uv.array, a = i.length / 3; - t.tangent === void 0 && this.setAttribute("tangent", new Ue(new Float32Array(4 * a), 4)); - let l = t.tangent.array, c = [], h = []; - for(let B = 0; B < a; B++)c[B] = new M, h[B] = new M; - let u = new M, d = new M, f = new M, m = new X, x = new X, v = new X, g = new M, p = new M; - function _(B, P, w) { - u.fromArray(i, B * 3), d.fromArray(i, P * 3), f.fromArray(i, w * 3), m.fromArray(o, B * 2), x.fromArray(o, P * 2), v.fromArray(o, w * 2), d.sub(u), f.sub(u), x.sub(m), v.sub(m); - let E = 1 / (x.x * v.y - v.x * x.y); - !isFinite(E) || (g.copy(d).multiplyScalar(v.y).addScaledVector(f, -x.y).multiplyScalar(E), p.copy(f).multiplyScalar(x.x).addScaledVector(d, -v.x).multiplyScalar(E), c[B].add(g), c[P].add(g), c[w].add(g), h[B].add(p), h[P].add(p), h[w].add(p)); - } - let y = this.groups; - y.length === 0 && (y = [ - { - start: 0, - count: n.length - } - ]); - for(let B = 0, P = y.length; B < P; ++B){ - let w = y[B], E = w.start, D = w.count; - for(let U = E, F = E + D; U < F; U += 3)_(n[U + 0], n[U + 1], n[U + 2]); - } - let b = new M, A = new M, L = new M, I = new M; - function k(B) { - L.fromArray(r, B * 3), I.copy(L); - let P = c[B]; - b.copy(P), b.sub(L.multiplyScalar(L.dot(P))).normalize(), A.crossVectors(I, P); - let E = A.dot(h[B]) < 0 ? -1 : 1; - l[B * 4] = b.x, l[B * 4 + 1] = b.y, l[B * 4 + 2] = b.z, l[B * 4 + 3] = E; - } - for(let B = 0, P = y.length; B < P; ++B){ - let w = y[B], E = w.start, D = w.count; - for(let U = E, F = E + D; U < F; U += 3)k(n[U + 0]), k(n[U + 1]), k(n[U + 2]); - } - } - computeVertexNormals() { - let e = this.index, t = this.getAttribute("position"); - if (t !== void 0) { - let n = this.getAttribute("normal"); - if (n === void 0) n = new Ue(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); - else for(let d = 0, f = n.count; d < f; d++)n.setXYZ(d, 0, 0, 0); - let i = new M, r = new M, o = new M, a = new M, l = new M, c = new M, h = new M, u = new M; - if (e) for(let d = 0, f = e.count; d < f; d += 3){ - let m = e.getX(d + 0), x = e.getX(d + 1), v = e.getX(d + 2); - i.fromBufferAttribute(t, m), r.fromBufferAttribute(t, x), o.fromBufferAttribute(t, v), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), a.fromBufferAttribute(n, m), l.fromBufferAttribute(n, x), c.fromBufferAttribute(n, v), a.add(h), l.add(h), c.add(h), n.setXYZ(m, a.x, a.y, a.z), n.setXYZ(x, l.x, l.y, l.z), n.setXYZ(v, c.x, c.y, c.z); - } - else for(let d = 0, f = t.count; d < f; d += 3)i.fromBufferAttribute(t, d + 0), r.fromBufferAttribute(t, d + 1), o.fromBufferAttribute(t, d + 2), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), n.setXYZ(d + 0, h.x, h.y, h.z), n.setXYZ(d + 1, h.x, h.y, h.z), n.setXYZ(d + 2, h.x, h.y, h.z); - this.normalizeNormals(), n.needsUpdate = !0; - } - } - merge(e, t) { - if (!(e && e.isBufferGeometry)) { - console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", e); - return; - } - t === void 0 && (t = 0, console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.")); - let n = this.attributes; - for(let i in n){ - if (e.attributes[i] === void 0) continue; - let o = n[i].array, a = e.attributes[i], l = a.array, c = a.itemSize * t, h = Math.min(l.length, o.length - c); - for(let u = 0, d = c; u < h; u++, d++)o[d] = l[u]; - } - return this; - } - normalizeNormals() { - let e = this.attributes.normal; - for(let t = 0, n = e.count; t < n; t++)ht.fromBufferAttribute(e, t), ht.normalize(), e.setXYZ(t, ht.x, ht.y, ht.z); - } - toNonIndexed() { - function e(a, l) { - let c = a.array, h = a.itemSize, u = a.normalized, d = new c.constructor(l.length * h), f = 0, m = 0; - for(let x = 0, v = l.length; x < v; x++){ - a.isInterleavedBufferAttribute ? f = l[x] * a.data.stride + a.offset : f = l[x] * h; - for(let g = 0; g < h; g++)d[m++] = c[f++]; - } - return new Ue(d, h, u); - } - if (this.index === null) return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; - let t = new _e, n = this.index.array, i = this.attributes; - for(let a in i){ - let l = i[a], c = e(l, n); - t.setAttribute(a, c); - } - let r = this.morphAttributes; - for(let a in r){ - let l = [], c = r[a]; - for(let h = 0, u = c.length; h < u; h++){ - let d = c[h], f = e(d, n); - l.push(f); - } - t.morphAttributes[a] = l; - } - t.morphTargetsRelative = this.morphTargetsRelative; - let o = this.groups; - for(let a = 0, l = o.length; a < l; a++){ - let c = o[a]; - t.addGroup(c.start, c.count, c.materialIndex); - } - return t; - } - toJSON() { - let e = { - metadata: { - version: 4.5, - type: "BufferGeometry", - generator: "BufferGeometry.toJSON" - } - }; - if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) { - let l = this.parameters; - for(let c in l)l[c] !== void 0 && (e[c] = l[c]); - return e; - } - e.data = { - attributes: {} - }; - let t = this.index; - t !== null && (e.data.index = { - type: t.array.constructor.name, - array: Array.prototype.slice.call(t.array) - }); - let n = this.attributes; - for(let l in n){ - let c = n[l]; - e.data.attributes[l] = c.toJSON(e.data); - } - let i = {}, r = !1; - for(let l in this.morphAttributes){ - let c = this.morphAttributes[l], h = []; - for(let u = 0, d = c.length; u < d; u++){ - let f = c[u]; - h.push(f.toJSON(e.data)); - } - h.length > 0 && (i[l] = h, r = !0); - } - r && (e.data.morphAttributes = i, e.data.morphTargetsRelative = this.morphTargetsRelative); - let o = this.groups; - o.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(o))); - let a = this.boundingSphere; - return a !== null && (e.data.boundingSphere = { - center: a.center.toArray(), - radius: a.radius - }), e; - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; - let t = {}; - this.name = e.name; - let n = e.index; - n !== null && this.setIndex(n.clone(t)); - let i = e.attributes; - for(let c in i){ - let h = i[c]; - this.setAttribute(c, h.clone(t)); - } - let r = e.morphAttributes; - for(let c in r){ - let h = [], u = r[c]; - for(let d = 0, f = u.length; d < f; d++)h.push(u[d].clone(t)); - this.morphAttributes[c] = h; - } - this.morphTargetsRelative = e.morphTargetsRelative; - let o = e.groups; - for(let c = 0, h = o.length; c < h; c++){ - let u = o[c]; - this.addGroup(u.start, u.count, u.materialIndex); - } - let a = e.boundingBox; - a !== null && (this.boundingBox = a.clone()); - let l = e.boundingSphere; - return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, e.parameters !== void 0 && (this.parameters = Object.assign({}, e.parameters)), this; - } - dispose() { - this.dispatchEvent({ - type: "dispose" - }); - } -}; -_e.prototype.isBufferGeometry = !0; -var Cl = new pe, hi = new Cn, Bo = new An, mn = new M, gn = new M, xn = new M, zo = new M, Uo = new M, Oo = new M, Kr = new M, es = new M, ts = new M, ns = new X, is = new X, rs = new X, Ho = new M, ss = new M, st = class extends Ne { - constructor(e = new _e, t = new hn){ - super(); - this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets(); - } - copy(e) { - return super.copy(e), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = e.material, this.geometry = e.geometry, this; - } - updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } - } - } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - } - } - raycast(e, t) { - let n = this.geometry, i = this.material, r = this.matrixWorld; - if (i === void 0 || (n.boundingSphere === null && n.computeBoundingSphere(), Bo.copy(n.boundingSphere), Bo.applyMatrix4(r), e.ray.intersectsSphere(Bo) === !1) || (Cl.copy(r).invert(), hi.copy(e.ray).applyMatrix4(Cl), n.boundingBox !== null && hi.intersectsBox(n.boundingBox) === !1)) return; - let o; - if (n.isBufferGeometry) { - let a = n.index, l = n.attributes.position, c = n.morphAttributes.position, h = n.morphTargetsRelative, u = n.attributes.uv, d = n.attributes.uv2, f = n.groups, m = n.drawRange; - if (a !== null) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ - let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(a.count, Math.min(g.start + g.count, m.start + m.count)); - for(let b = _, A = y; b < A; b += 3){ - let L = a.getX(b), I = a.getX(b + 1), k = a.getX(b + 2); - o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); - } - } - else { - let x = Math.max(0, m.start), v = Math.min(a.count, m.start + m.count); - for(let g = x, p = v; g < p; g += 3){ - let _ = a.getX(g), y = a.getX(g + 1), b = a.getX(g + 2); - o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); - } - } - else if (l !== void 0) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ - let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(l.count, Math.min(g.start + g.count, m.start + m.count)); - for(let b = _, A = y; b < A; b += 3){ - let L = b, I = b + 1, k = b + 2; - o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); - } - } - else { - let x = Math.max(0, m.start), v = Math.min(l.count, m.start + m.count); - for(let g = x, p = v; g < p; g += 3){ - let _ = g, y = g + 1, b = g + 2; - o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); - } - } - } else n.isGeometry && console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - } -}; -st.prototype.isMesh = !0; -function hf(s, e, t, n, i, r, o, a) { - let l; - if (e.side === it ? l = n.intersectTriangle(o, r, i, !0, a) : l = n.intersectTriangle(i, r, o, e.side !== Ci, a), l === null) return null; - ss.copy(a), ss.applyMatrix4(s.matrixWorld); - let c = t.ray.origin.distanceTo(ss); - return c < t.near || c > t.far ? null : { - distance: c, - point: ss.clone(), - object: s - }; -} -function os(s, e, t, n, i, r, o, a, l, c, h, u) { - mn.fromBufferAttribute(i, c), gn.fromBufferAttribute(i, h), xn.fromBufferAttribute(i, u); - let d = s.morphTargetInfluences; - if (r && d) { - Kr.set(0, 0, 0), es.set(0, 0, 0), ts.set(0, 0, 0); - for(let m = 0, x = r.length; m < x; m++){ - let v = d[m], g = r[m]; - v !== 0 && (zo.fromBufferAttribute(g, c), Uo.fromBufferAttribute(g, h), Oo.fromBufferAttribute(g, u), o ? (Kr.addScaledVector(zo, v), es.addScaledVector(Uo, v), ts.addScaledVector(Oo, v)) : (Kr.addScaledVector(zo.sub(mn), v), es.addScaledVector(Uo.sub(gn), v), ts.addScaledVector(Oo.sub(xn), v))); - } - mn.add(Kr), gn.add(es), xn.add(ts); - } - s.isSkinnedMesh && (s.boneTransform(c, mn), s.boneTransform(h, gn), s.boneTransform(u, xn)); - let f = hf(s, e, t, n, mn, gn, xn, Ho); - if (f) { - a && (ns.fromBufferAttribute(a, c), is.fromBufferAttribute(a, h), rs.fromBufferAttribute(a, u), f.uv = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)), l && (ns.fromBufferAttribute(l, c), is.fromBufferAttribute(l, h), rs.fromBufferAttribute(l, u), f.uv2 = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)); - let m = { - a: c, - b: h, - c: u, - normal: new M, - materialIndex: 0 - }; - nt.getNormal(mn, gn, xn, m.normal), f.face = m; - } - return f; -} -var wn = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 1, r = 1, o = 1){ - super(); - this.type = "BoxGeometry", this.parameters = { - width: e, - height: t, - depth: n, - widthSegments: i, - heightSegments: r, - depthSegments: o - }; - let a = this; - i = Math.floor(i), r = Math.floor(r), o = Math.floor(o); - let l = [], c = [], h = [], u = [], d = 0, f = 0; - m("z", "y", "x", -1, -1, n, t, e, o, r, 0), m("z", "y", "x", 1, -1, n, t, -e, o, r, 1), m("x", "z", "y", 1, 1, e, n, t, i, o, 2), m("x", "z", "y", 1, -1, e, n, -t, i, o, 3), m("x", "y", "z", 1, -1, e, t, n, i, r, 4), m("x", "y", "z", -1, -1, e, t, -n, i, r, 5), this.setIndex(l), this.setAttribute("position", new de(c, 3)), this.setAttribute("normal", new de(h, 3)), this.setAttribute("uv", new de(u, 2)); - function m(x, v, g, p, _, y, b, A, L, I, k) { - let B = y / L, P = b / I, w = y / 2, E = b / 2, D = A / 2, U = L + 1, F = I + 1, O = 0, ne = 0, ce = new M; - for(let V = 0; V < F; V++){ - let W = V * P - E; - for(let he = 0; he < U; he++){ - let le = he * B - w; - ce[x] = le * p, ce[v] = W * _, ce[g] = D, c.push(ce.x, ce.y, ce.z), ce[x] = 0, ce[v] = 0, ce[g] = A > 0 ? 1 : -1, h.push(ce.x, ce.y, ce.z), u.push(he / L), u.push(1 - V / I), O += 1; - } - } - for(let V = 0; V < I; V++)for(let W = 0; W < L; W++){ - let he = d + W + U * V, le = d + W + U * (V + 1), fe = d + (W + 1) + U * (V + 1), Be = d + (W + 1) + U * V; - l.push(he, le, Be), l.push(le, fe, Be), ne += 6; - } - a.addGroup(f, ne, k), f += ne, d += O; - } - } - static fromJSON(e) { - return new wn(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); - } -}; -function Ri(s) { - let e = {}; - for(let t in s){ - e[t] = {}; - for(let n in s[t]){ - let i = s[t][n]; - i && (i.isColor || i.isMatrix3 || i.isMatrix4 || i.isVector2 || i.isVector3 || i.isVector4 || i.isTexture || i.isQuaternion) ? e[t][n] = i.clone() : Array.isArray(i) ? e[t][n] = i.slice() : e[t][n] = i; - } - } - return e; -} -function yt(s) { - let e = {}; - for(let t = 0; t < s.length; t++){ - let n = Ri(s[t]); - for(let i in n)e[i] = n[i]; - } - return e; -} -var uf = { - clone: Ri, - merge: yt -}, df = `void main() { - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); -}`, ff = `void main() { - gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); -}`, sn = class extends dt { - constructor(e){ - super(); - this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.vertexShader = df, this.fragmentShader = ff, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.extensions = { - derivatives: !1, - fragDepth: !1, - drawBuffers: !1, - shaderTextureLOD: !1 - }, this.defaultAttributeValues = { - color: [ - 1, - 1, - 1 - ], - uv: [ - 0, - 0 - ], - uv2: [ - 0, - 0 - ] - }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && (e.attributes !== void 0 && console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."), this.setValues(e)); - } - copy(e) { - return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Ri(e.uniforms), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this; - } - toJSON(e) { - let t = super.toJSON(e); - t.glslVersion = this.glslVersion, t.uniforms = {}; - for(let i in this.uniforms){ - let o = this.uniforms[i].value; - o && o.isTexture ? t.uniforms[i] = { - type: "t", - value: o.toJSON(e).uuid - } : o && o.isColor ? t.uniforms[i] = { - type: "c", - value: o.getHex() - } : o && o.isVector2 ? t.uniforms[i] = { - type: "v2", - value: o.toArray() - } : o && o.isVector3 ? t.uniforms[i] = { - type: "v3", - value: o.toArray() - } : o && o.isVector4 ? t.uniforms[i] = { - type: "v4", - value: o.toArray() - } : o && o.isMatrix3 ? t.uniforms[i] = { - type: "m3", - value: o.toArray() - } : o && o.isMatrix4 ? t.uniforms[i] = { - type: "m4", - value: o.toArray() - } : t.uniforms[i] = { - value: o - }; - } - Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader; - let n = {}; - for(let i in this.extensions)this.extensions[i] === !0 && (n[i] = !0); - return Object.keys(n).length > 0 && (t.extensions = n), t; - } -}; -sn.prototype.isShaderMaterial = !0; -var Ir = class extends Ne { - constructor(){ - super(); - this.type = "Camera", this.matrixWorldInverse = new pe, this.projectionMatrix = new pe, this.projectionMatrixInverse = new pe; - } - copy(e, t) { - return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this; - } - getWorldDirection(e) { - this.updateWorldMatrix(!0, !1); - let t = this.matrixWorld.elements; - return e.set(-t[8], -t[9], -t[10]).normalize(); - } - updateMatrixWorld(e) { - super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); - } - updateWorldMatrix(e, t) { - super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); - } - clone() { - return new this.constructor().copy(this); - } -}; -Ir.prototype.isCamera = !0; -var ut = class extends Ir { - constructor(e = 50, t = 1, n = .1, i = 2e3){ - super(); - this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); - } - copy(e, t) { - return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; - } - setFocalLength(e) { - let t = .5 * this.getFilmHeight() / e; - this.fov = dr * 2 * Math.atan(t), this.updateProjectionMatrix(); - } - getFocalLength() { - let e = Math.tan(Wn * .5 * this.fov); - return .5 * this.getFilmHeight() / e; - } - getEffectiveFOV() { - return dr * 2 * Math.atan(Math.tan(Wn * .5 * this.fov) / this.zoom); - } - getFilmWidth() { - return this.filmGauge * Math.min(this.aspect, 1); - } - getFilmHeight() { - return this.filmGauge / Math.max(this.aspect, 1); - } - setViewOffset(e, t, n, i, r, o) { - this.aspect = e / t, this.view === null && (this.view = { - enabled: !0, - fullWidth: 1, - fullHeight: 1, - offsetX: 0, - offsetY: 0, - width: 1, - height: 1 - }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); - } - clearViewOffset() { - this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); - } - updateProjectionMatrix() { - let e = this.near, t = e * Math.tan(Wn * .5 * this.fov) / this.zoom, n = 2 * t, i = this.aspect * n, r = -.5 * i, o = this.view; - if (this.view !== null && this.view.enabled) { - let l = o.fullWidth, c = o.fullHeight; - r += o.offsetX * i / l, t -= o.offsetY * n / c, i *= o.width / l, n *= o.height / c; - } - let a = this.filmOffset; - a !== 0 && (r += e * a / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, t, t - n, e, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; - } -}; -ut.prototype.isPerspectiveCamera = !0; -var ui = 90, di = 1, $s = class extends Ne { - constructor(e, t, n){ - super(); - if (this.type = "CubeCamera", n.isWebGLCubeRenderTarget !== !0) { - console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."); - return; - } - this.renderTarget = n; - let i = new ut(ui, di, e, t); - i.layers = this.layers, i.up.set(0, -1, 0), i.lookAt(new M(1, 0, 0)), this.add(i); - let r = new ut(ui, di, e, t); - r.layers = this.layers, r.up.set(0, -1, 0), r.lookAt(new M(-1, 0, 0)), this.add(r); - let o = new ut(ui, di, e, t); - o.layers = this.layers, o.up.set(0, 0, 1), o.lookAt(new M(0, 1, 0)), this.add(o); - let a = new ut(ui, di, e, t); - a.layers = this.layers, a.up.set(0, 0, -1), a.lookAt(new M(0, -1, 0)), this.add(a); - let l = new ut(ui, di, e, t); - l.layers = this.layers, l.up.set(0, -1, 0), l.lookAt(new M(0, 0, 1)), this.add(l); - let c = new ut(ui, di, e, t); - c.layers = this.layers, c.up.set(0, -1, 0), c.lookAt(new M(0, 0, -1)), this.add(c); - } - update(e, t) { - this.parent === null && this.updateMatrixWorld(); - let n = this.renderTarget, [i, r, o, a, l, c] = this.children, h = e.xr.enabled, u = e.getRenderTarget(); - e.xr.enabled = !1; - let d = n.texture.generateMipmaps; - n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0), e.render(t, i), e.setRenderTarget(n, 1), e.render(t, r), e.setRenderTarget(n, 2), e.render(t, o), e.setRenderTarget(n, 3), e.render(t, a), e.setRenderTarget(n, 4), e.render(t, l), n.texture.generateMipmaps = d, e.setRenderTarget(n, 5), e.render(t, c), e.setRenderTarget(u), e.xr.enabled = h; - } -}, ki = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h){ - e = e !== void 0 ? e : [], t = t !== void 0 ? t : Bi; - super(e, t, n, i, r, o, a, l, c, h); - this.flipY = !1; - } - get images() { - return this.image; - } - set images(e) { - this.image = e; - } -}; -ki.prototype.isCubeTexture = !0; -var js = class extends At { - constructor(e, t, n){ - Number.isInteger(t) && (console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"), t = n); - super(e, e, t); - t = t || {}, this.texture = new ki(void 0, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.encoding), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : tt, this.texture._needsFlipEnvMap = !1; - } - fromEquirectangularTexture(e, t) { - this.texture.type = t.type, this.texture.format = ct, this.texture.encoding = t.encoding, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; - let n = { - uniforms: { - tEquirect: { - value: null - } - }, - vertexShader: ` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `, - fragmentShader: ` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - ` - }, i = new wn(5, 5, 5), r = new sn({ - name: "CubemapFromEquirect", - uniforms: Ri(n.uniforms), - vertexShader: n.vertexShader, - fragmentShader: n.fragmentShader, - side: it, - blending: vn - }); - r.uniforms.tEquirect.value = t; - let o = new st(i, r), a = t.minFilter; - return t.minFilter === Ui && (t.minFilter = tt), new $s(1, 10, this).update(e, o), t.minFilter = a, o.geometry.dispose(), o.material.dispose(), this; - } - clear(e, t, n, i) { - let r = e.getRenderTarget(); - for(let o = 0; o < 6; o++)e.setRenderTarget(this, o), e.clear(t, n, i); - e.setRenderTarget(r); - } -}; -js.prototype.isWebGLCubeRenderTarget = !0; -var ko = new M, pf = new M, mf = new lt, Wt = class { - constructor(e = new M(1, 0, 0), t = 0){ - this.normal = e, this.constant = t; - } - set(e, t) { - return this.normal.copy(e), this.constant = t, this; - } - setComponents(e, t, n, i) { - return this.normal.set(e, t, n), this.constant = i, this; - } - setFromNormalAndCoplanarPoint(e, t) { - return this.normal.copy(e), this.constant = -t.dot(this.normal), this; - } - setFromCoplanarPoints(e, t, n) { - let i = ko.subVectors(n, t).cross(pf.subVectors(e, t)).normalize(); - return this.setFromNormalAndCoplanarPoint(i, e), this; - } - copy(e) { - return this.normal.copy(e.normal), this.constant = e.constant, this; - } - normalize() { - let e = 1 / this.normal.length(); - return this.normal.multiplyScalar(e), this.constant *= e, this; - } - negate() { - return this.constant *= -1, this.normal.negate(), this; - } - distanceToPoint(e) { - return this.normal.dot(e) + this.constant; - } - distanceToSphere(e) { - return this.distanceToPoint(e.center) - e.radius; - } - projectPoint(e, t) { - return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e); - } - intersectLine(e, t) { - let n = e.delta(ko), i = this.normal.dot(n); - if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; - let r = -(e.start.dot(this.normal) + this.constant) / i; - return r < 0 || r > 1 ? null : t.copy(n).multiplyScalar(r).add(e.start); - } - intersectsLine(e) { - let t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); - return t < 0 && n > 0 || n < 0 && t > 0; - } - intersectsBox(e) { - return e.intersectsPlane(this); - } - intersectsSphere(e) { - return e.intersectsPlane(this); - } - coplanarPoint(e) { - return e.copy(this.normal).multiplyScalar(-this.constant); - } - applyMatrix4(e, t) { - let n = t || mf.getNormalMatrix(e), i = this.coplanarPoint(ko).applyMatrix4(e), r = this.normal.applyMatrix3(n).normalize(); - return this.constant = -i.dot(r), this; - } - translate(e) { - return this.constant -= e.dot(this.normal), this; - } - equals(e) { - return e.normal.equals(this.normal) && e.constant === this.constant; - } - clone() { - return new this.constructor().copy(this); - } -}; -Wt.prototype.isPlane = !0; -var fi = new An, as = new M, Dr = class { - constructor(e = new Wt, t = new Wt, n = new Wt, i = new Wt, r = new Wt, o = new Wt){ - this.planes = [ - e, - t, - n, - i, - r, - o - ]; - } - set(e, t, n, i, r, o) { - let a = this.planes; - return a[0].copy(e), a[1].copy(t), a[2].copy(n), a[3].copy(i), a[4].copy(r), a[5].copy(o), this; - } - copy(e) { - let t = this.planes; - for(let n = 0; n < 6; n++)t[n].copy(e.planes[n]); - return this; - } - setFromProjectionMatrix(e) { - let t = this.planes, n = e.elements, i = n[0], r = n[1], o = n[2], a = n[3], l = n[4], c = n[5], h = n[6], u = n[7], d = n[8], f = n[9], m = n[10], x = n[11], v = n[12], g = n[13], p = n[14], _ = n[15]; - return t[0].setComponents(a - i, u - l, x - d, _ - v).normalize(), t[1].setComponents(a + i, u + l, x + d, _ + v).normalize(), t[2].setComponents(a + r, u + c, x + f, _ + g).normalize(), t[3].setComponents(a - r, u - c, x - f, _ - g).normalize(), t[4].setComponents(a - o, u - h, x - m, _ - p).normalize(), t[5].setComponents(a + o, u + h, x + m, _ + p).normalize(), this; - } - intersectsObject(e) { - let t = e.geometry; - return t.boundingSphere === null && t.computeBoundingSphere(), fi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); - } - intersectsSprite(e) { - return fi.center.set(0, 0, 0), fi.radius = .7071067811865476, fi.applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); - } - intersectsSphere(e) { - let t = this.planes, n = e.center, i = -e.radius; - for(let r = 0; r < 6; r++)if (t[r].distanceToPoint(n) < i) return !1; - return !0; - } - intersectsBox(e) { - let t = this.planes; - for(let n = 0; n < 6; n++){ - let i = t[n]; - if (as.x = i.normal.x > 0 ? e.max.x : e.min.x, as.y = i.normal.y > 0 ? e.max.y : e.min.y, as.z = i.normal.z > 0 ? e.max.z : e.min.z, i.distanceToPoint(as) < 0) return !1; - } - return !0; - } - containsPoint(e) { - let t = this.planes; - for(let n = 0; n < 6; n++)if (t[n].distanceToPoint(e) < 0) return !1; - return !0; - } - clone() { - return new this.constructor().copy(this); - } -}; -function rh() { - let s = null, e = !1, t = null, n = null; - function i(r, o) { - t(r, o), n = s.requestAnimationFrame(i); - } - return { - start: function() { - e !== !0 && t !== null && (n = s.requestAnimationFrame(i), e = !0); - }, - stop: function() { - s.cancelAnimationFrame(n), e = !1; - }, - setAnimationLoop: function(r) { - t = r; - }, - setContext: function(r) { - s = r; - } - }; -} -function gf(s, e) { - let t = e.isWebGL2, n = new WeakMap; - function i(c, h) { - let u = c.array, d = c.usage, f = s.createBuffer(); - s.bindBuffer(h, f), s.bufferData(h, u, d), c.onUploadCallback(); - let m = 5126; - return u instanceof Float32Array ? m = 5126 : u instanceof Float64Array ? console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.") : u instanceof Uint16Array ? c.isFloat16BufferAttribute ? t ? m = 5131 : console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.") : m = 5123 : u instanceof Int16Array ? m = 5122 : u instanceof Uint32Array ? m = 5125 : u instanceof Int32Array ? m = 5124 : u instanceof Int8Array ? m = 5120 : (u instanceof Uint8Array || u instanceof Uint8ClampedArray) && (m = 5121), { - buffer: f, - type: m, - bytesPerElement: u.BYTES_PER_ELEMENT, - version: c.version - }; - } - function r(c, h, u) { - let d = h.array, f = h.updateRange; - s.bindBuffer(u, c), f.count === -1 ? s.bufferSubData(u, 0, d) : (t ? s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d, f.offset, f.count) : s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d.subarray(f.offset, f.offset + f.count)), f.count = -1); - } - function o(c) { - return c.isInterleavedBufferAttribute && (c = c.data), n.get(c); - } - function a(c) { - c.isInterleavedBufferAttribute && (c = c.data); - let h = n.get(c); - h && (s.deleteBuffer(h.buffer), n.delete(c)); - } - function l(c, h) { - if (c.isGLBufferAttribute) { - let d = n.get(c); - (!d || d.version < c.version) && n.set(c, { - buffer: c.buffer, - type: c.type, - bytesPerElement: c.elementSize, - version: c.version - }); - return; - } - c.isInterleavedBufferAttribute && (c = c.data); - let u = n.get(c); - u === void 0 ? n.set(c, i(c, h)) : u.version < c.version && (r(u.buffer, c, h), u.version = c.version); - } - return { - get: o, - remove: a, - update: l - }; -} -var Pi = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 1){ - super(); - this.type = "PlaneGeometry", this.parameters = { - width: e, - height: t, - widthSegments: n, - heightSegments: i - }; - let r = e / 2, o = t / 2, a = Math.floor(n), l = Math.floor(i), c = a + 1, h = l + 1, u = e / a, d = t / l, f = [], m = [], x = [], v = []; - for(let g = 0; g < h; g++){ - let p = g * d - o; - for(let _ = 0; _ < c; _++){ - let y = _ * u - r; - m.push(y, -p, 0), x.push(0, 0, 1), v.push(_ / a), v.push(1 - g / l); - } - } - for(let g = 0; g < l; g++)for(let p = 0; p < a; p++){ - let _ = p + c * g, y = p + c * (g + 1), b = p + 1 + c * (g + 1), A = p + 1 + c * g; - f.push(_, y, A), f.push(y, b, A); - } - this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); - } - static fromJSON(e) { - return new Pi(e.width, e.height, e.widthSegments, e.heightSegments); - } -}, xf = `#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, vUv ).g; -#endif`, yf = `#ifdef USE_ALPHAMAP - uniform sampler2D alphaMap; -#endif`, vf = `#ifdef USE_ALPHATEST - if ( diffuseColor.a < alphaTest ) discard; -#endif`, _f = `#ifdef USE_ALPHATEST - uniform float alphaTest; -#endif`, Mf = `#ifdef USE_AOMAP - float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; - reflectedLight.indirectDiffuse *= ambientOcclusion; - #if defined( USE_ENVMAP ) && defined( STANDARD ) - float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); - reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); - #endif -#endif`, bf = `#ifdef USE_AOMAP - uniform sampler2D aoMap; - uniform float aoMapIntensity; -#endif`, wf = "vec3 transformed = vec3( position );", Sf = `vec3 objectNormal = vec3( normal ); -#ifdef USE_TANGENT - vec3 objectTangent = vec3( tangent.xyz ); -#endif`, Tf = `vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) { - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -float G_BlinnPhong_Implicit( ) { - return 0.25; -} -float D_BlinnPhong( const in float shininess, const in float dotNH ) { - return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); -} -vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( specularColor, 1.0, dotVH ); - float G = G_BlinnPhong_Implicit( ); - float D = D_BlinnPhong( shininess, dotNH ); - return F * ( G * D ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif`, Ef = `#ifdef USE_BUMPMAP - uniform sampler2D bumpMap; - uniform float bumpScale; - vec2 dHdxy_fwd() { - vec2 dSTdx = dFdx( vUv ); - vec2 dSTdy = dFdy( vUv ); - float Hll = bumpScale * texture2D( bumpMap, vUv ).x; - float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; - float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; - return vec2( dBx, dBy ); - } - vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { - vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); - vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); - vec3 vN = surf_norm; - vec3 R1 = cross( vSigmaY, vN ); - vec3 R2 = cross( vN, vSigmaX ); - float fDet = dot( vSigmaX, R1 ) * faceDirection; - vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); - return normalize( abs( fDet ) * surf_norm - vGrad ); - } -#endif`, Af = `#if NUM_CLIPPING_PLANES > 0 - vec4 plane; - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - bool clipped = true; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; - } - #pragma unroll_loop_end - if ( clipped ) discard; - #endif -#endif`, Cf = `#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`, Lf = `#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; -#endif`, Rf = `#if NUM_CLIPPING_PLANES > 0 - vClipPosition = - mvPosition.xyz; -#endif`, Pf = `#if defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; -#elif defined( USE_COLOR ) - diffuseColor.rgb *= vColor; -#endif`, If = `#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) - varying vec3 vColor; -#endif`, Df = `#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) - varying vec3 vColor; -#endif`, Ff = `#if defined( USE_COLOR_ALPHA ) - vColor = vec4( 1.0 ); -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) - vColor = vec3( 1.0 ); -#endif -#ifdef USE_COLOR - vColor *= color; -#endif -#ifdef USE_INSTANCING_COLOR - vColor.xyz *= instanceColor.xyz; -#endif`, Nf = `#define PI 3.141592653589793 -#define PI2 6.283185307179586 -#define PI_HALF 1.5707963267948966 -#define RECIPROCAL_PI 0.3183098861837907 -#define RECIPROCAL_PI2 0.15915494309189535 -#define EPSILON 1e-6 -#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -#define whiteComplement( a ) ( 1.0 - saturate( a ) ) -float pow2( const in float x ) { return x*x; } -float pow3( const in float x ) { return x*x*x; } -float pow4( const in float x ) { float x2 = x*x; return x2*x2; } -float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } -highp float rand( const in vec2 uv ) { - const highp float a = 12.9898, b = 78.233, c = 43758.5453; - highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); - return fract( sin( sn ) * c ); -} -#ifdef HIGH_PRECISION - float precisionSafeLength( vec3 v ) { return length( v ); } -#else - float precisionSafeLength( vec3 v ) { - float maxComponent = max3( abs( v ) ); - return length( v / maxComponent ) * maxComponent; - } -#endif -struct IncidentLight { - vec3 color; - vec3 direction; - bool visible; -}; -struct ReflectedLight { - vec3 directDiffuse; - vec3 directSpecular; - vec3 indirectDiffuse; - vec3 indirectSpecular; -}; -struct GeometricContext { - vec3 position; - vec3 normal; - vec3 viewDir; -#ifdef USE_CLEARCOAT - vec3 clearcoatNormal; -#endif -}; -vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); -} -vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); -} -mat3 transposeMat3( const in mat3 m ) { - mat3 tmp; - tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); - tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); - tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); - return tmp; -} -float linearToRelativeLuminance( const in vec3 color ) { - vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); - return dot( weights, color.rgb ); -} -bool isPerspectiveMatrix( mat4 m ) { - return m[ 2 ][ 3 ] == - 1.0; -} -vec2 equirectUv( in vec3 dir ) { - float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; - float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; - return vec2( u, v ); -}`, Bf = `#ifdef ENVMAP_TYPE_CUBE_UV - #define cubeUV_maxMipLevel 8.0 - #define cubeUV_minMipLevel 4.0 - #define cubeUV_maxTileSize 256.0 - #define cubeUV_minTileSize 16.0 - float getFace( vec3 direction ) { - vec3 absDirection = abs( direction ); - float face = - 1.0; - if ( absDirection.x > absDirection.z ) { - if ( absDirection.x > absDirection.y ) - face = direction.x > 0.0 ? 0.0 : 3.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } else { - if ( absDirection.z > absDirection.y ) - face = direction.z > 0.0 ? 2.0 : 5.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } - return face; - } - vec2 getUV( vec3 direction, float face ) { - vec2 uv; - if ( face == 0.0 ) { - uv = vec2( direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 1.0 ) { - uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); - } else if ( face == 2.0 ) { - uv = vec2( - direction.x, direction.y ) / abs( direction.z ); - } else if ( face == 3.0 ) { - uv = vec2( - direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 4.0 ) { - uv = vec2( - direction.x, direction.z ) / abs( direction.y ); - } else { - uv = vec2( direction.x, direction.y ) / abs( direction.z ); - } - return 0.5 * ( uv + 1.0 ); - } - vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { - float face = getFace( direction ); - float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); - mipInt = max( mipInt, cubeUV_minMipLevel ); - float faceSize = exp2( mipInt ); - float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); - vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5; - if ( face > 2.0 ) { - uv.y += faceSize; - face -= 3.0; - } - uv.x += face * faceSize; - if ( mipInt < cubeUV_maxMipLevel ) { - uv.y += 2.0 * cubeUV_maxTileSize; - } - uv.y += filterInt * 2.0 * cubeUV_minTileSize; - uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); - uv *= texelSize; - return texture2D( envMap, uv ).rgb; - } - #define r0 1.0 - #define v0 0.339 - #define m0 - 2.0 - #define r1 0.8 - #define v1 0.276 - #define m1 - 1.0 - #define r4 0.4 - #define v4 0.046 - #define m4 2.0 - #define r5 0.305 - #define v5 0.016 - #define m5 3.0 - #define r6 0.21 - #define v6 0.0038 - #define m6 4.0 - float roughnessToMip( float roughness ) { - float mip = 0.0; - if ( roughness >= r1 ) { - mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; - } else if ( roughness >= r4 ) { - mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; - } else if ( roughness >= r5 ) { - mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; - } else if ( roughness >= r6 ) { - mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; - } else { - mip = - 2.0 * log2( 1.16 * roughness ); } - return mip; - } - vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { - float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); - float mipF = fract( mip ); - float mipInt = floor( mip ); - vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); - if ( mipF == 0.0 ) { - return vec4( color0, 1.0 ); - } else { - vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); - return vec4( mix( color0, color1, mipF ), 1.0 ); - } - } -#endif`, zf = `vec3 transformedNormal = objectNormal; -#ifdef USE_INSTANCING - mat3 m = mat3( instanceMatrix ); - transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); - transformedNormal = m * transformedNormal; -#endif -transformedNormal = normalMatrix * transformedNormal; -#ifdef FLIP_SIDED - transformedNormal = - transformedNormal; -#endif -#ifdef USE_TANGENT - vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; - #ifdef FLIP_SIDED - transformedTangent = - transformedTangent; - #endif -#endif`, Uf = `#ifdef USE_DISPLACEMENTMAP - uniform sampler2D displacementMap; - uniform float displacementScale; - uniform float displacementBias; -#endif`, Of = `#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); -#endif`, Hf = `#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vUv ); - emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; - totalEmissiveRadiance *= emissiveColor.rgb; -#endif`, kf = `#ifdef USE_EMISSIVEMAP - uniform sampler2D emissiveMap; -#endif`, Gf = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Vf = `vec4 LinearToLinear( in vec4 value ) { - return value; -} -vec4 sRGBToLinear( in vec4 value ) { - return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); -} -vec4 LinearTosRGB( 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 ); -}`, Wf = `#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vec3 cameraToFrag; - if ( isOrthographic ) { - cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToFrag = normalize( vWorldPosition - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vec3 reflectVec = reflect( cameraToFrag, worldNormal ); - #else - vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); - #endif - #else - vec3 reflectVec = vReflect; - #endif - #ifdef ENVMAP_TYPE_CUBE - vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); - envColor = envMapTexelToLinear( envColor ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); - #else - vec4 envColor = vec4( 0.0 ); - #endif - #ifdef ENVMAP_BLENDING_MULTIPLY - outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_MIX ) - outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_ADD ) - outgoingLight += envColor.xyz * specularStrength * reflectivity; - #endif -#endif`, qf = `#ifdef USE_ENVMAP - uniform float envMapIntensity; - uniform float flipEnvMap; - #ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; - #else - uniform sampler2D envMap; - #endif - -#endif`, Xf = `#ifdef USE_ENVMAP - uniform float reflectivity; - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - varying vec3 vWorldPosition; - uniform float refractionRatio; - #else - varying vec3 vReflect; - #endif -#endif`, Jf = `#ifdef USE_ENVMAP - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - - varying vec3 vWorldPosition; - #else - varying vec3 vReflect; - uniform float refractionRatio; - #endif -#endif`, Yf = `#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vWorldPosition = worldPosition.xyz; - #else - vec3 cameraToVertex; - if ( isOrthographic ) { - cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vReflect = reflect( cameraToVertex, worldNormal ); - #else - vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); - #endif - #endif -#endif`, Zf = `#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`, $f = `#ifdef USE_FOG - varying float vFogDepth; -#endif`, jf = `#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`, Qf = `#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif -#endif`, Kf = `#ifdef USE_GRADIENTMAP - uniform sampler2D gradientMap; -#endif -vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { - float dotNL = dot( normal, lightDirection ); - vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); - #ifdef USE_GRADIENTMAP - return vec3( texture2D( gradientMap, coord ).r ); - #else - return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); - #endif -}`, ep = `#ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vUv2 ); - vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; - #ifndef PHYSICALLY_CORRECT_LIGHTS - lightMapIrradiance *= PI; - #endif - reflectedLight.indirectDiffuse += lightMapIrradiance; -#endif`, tp = `#ifdef USE_LIGHTMAP - uniform sampler2D lightMap; - uniform float lightMapIntensity; -#endif`, np = `vec3 diffuse = vec3( 1.0 ); -GeometricContext geometry; -geometry.position = mvPosition.xyz; -geometry.normal = normalize( transformedNormal ); -geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); -GeometricContext backGeometry; -backGeometry.position = geometry.position; -backGeometry.normal = -geometry.normal; -backGeometry.viewDir = geometry.viewDir; -vLightFront = vec3( 0.0 ); -vIndirectFront = vec3( 0.0 ); -#ifdef DOUBLE_SIDED - vLightBack = vec3( 0.0 ); - vIndirectBack = vec3( 0.0 ); -#endif -IncidentLight directLight; -float dotNL; -vec3 directLightColor_Diffuse; -vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); -vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); -#ifdef DOUBLE_SIDED - vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); - vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); -#endif -#if NUM_POINT_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - getPointLightInfo( pointLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_SPOT_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - getSpotLightInfo( spotLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_DIR_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_HEMI_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); - #ifdef DOUBLE_SIDED - vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); - #endif - } - #pragma unroll_loop_end -#endif`, ip = `uniform bool receiveShadow; -uniform vec3 ambientLightColor; -uniform vec3 lightProbe[ 9 ]; -vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { - float x = normal.x, y = normal.y, z = normal.z; - vec3 result = shCoefficients[ 0 ] * 0.886227; - result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; - result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; - result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; - result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; - result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; - result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); - result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; - result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); - return result; -} -vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); - return irradiance; -} -vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { - vec3 irradiance = ambientLightColor; - return irradiance; -} -float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - #if defined ( PHYSICALLY_CORRECT_LIGHTS ) - float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); - if ( cutoffDistance > 0.0 ) { - distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); - } - return distanceFalloff; - #else - if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { - return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); - } - return 1.0; - #endif -} -float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { - return smoothstep( coneCosine, penumbraCosine, angleCosine ); -} -#if NUM_DIR_LIGHTS > 0 - struct DirectionalLight { - vec3 direction; - vec3 color; - }; - uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; - void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { - light.color = directionalLight.color; - light.direction = directionalLight.direction; - light.visible = true; - } -#endif -#if NUM_POINT_LIGHTS > 0 - struct PointLight { - vec3 position; - vec3 color; - float distance; - float decay; - }; - uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; - void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { - vec3 lVector = pointLight.position - geometry.position; - light.direction = normalize( lVector ); - float lightDistance = length( lVector ); - light.color = pointLight.color; - light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } -#endif -#if NUM_SPOT_LIGHTS > 0 - struct SpotLight { - vec3 position; - vec3 direction; - vec3 color; - float distance; - float decay; - float coneCos; - float penumbraCos; - }; - uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; - void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { - vec3 lVector = spotLight.position - geometry.position; - light.direction = normalize( lVector ); - float angleCos = dot( light.direction, spotLight.direction ); - float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); - if ( spotAttenuation > 0.0 ) { - float lightDistance = length( lVector ); - light.color = spotLight.color * spotAttenuation; - light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } else { - light.color = vec3( 0.0 ); - light.visible = false; - } - } -#endif -#if NUM_RECT_AREA_LIGHTS > 0 - struct RectAreaLight { - vec3 color; - vec3 position; - vec3 halfWidth; - vec3 halfHeight; - }; - uniform sampler2D ltc_1; uniform sampler2D ltc_2; - uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; -#endif -#if NUM_HEMI_LIGHTS > 0 - struct HemisphereLight { - vec3 direction; - vec3 skyColor; - vec3 groundColor; - }; - uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; - vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { - float dotNL = dot( normal, hemiLight.direction ); - float hemiDiffuseWeight = 0.5 * dotNL + 0.5; - vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); - return irradiance; - } -#endif`, rp = `#if defined( USE_ENVMAP ) - #ifdef ENVMAP_MODE_REFRACTION - uniform float refractionRatio; - #endif - vec3 getIBLIrradiance( const in vec3 normal ) { - #if defined( ENVMAP_TYPE_CUBE_UV ) - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); - return PI * envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #if defined( ENVMAP_TYPE_CUBE_UV ) - vec3 reflectVec; - #ifdef ENVMAP_MODE_REFLECTION - reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); - #else - reflectVec = refract( - viewDir, normal, refractionRatio ); - #endif - reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); - return envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } -#endif`, sp = `ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`, op = `varying vec3 vViewPosition; -struct ToonMaterial { - vec3 diffuseColor; -}; -void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon -#define Material_LightProbeLOD( material ) (0)`, ap = `BlinnPhongMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularColor = specular; -material.specularShininess = shininess; -material.specularStrength = specularStrength;`, lp = `varying vec3 vViewPosition; -struct BlinnPhongMaterial { - vec3 diffuseColor; - vec3 specularColor; - float specularShininess; - float specularStrength; -}; -void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); - reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; -} -void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong -#define Material_LightProbeLOD( material ) (0)`, cp = `PhysicalMaterial material; -material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); -float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); -material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; -material.roughness = min( material.roughness, 1.0 ); -#ifdef IOR - #ifdef SPECULAR - float specularIntensityFactor = specularIntensity; - vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULARINTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; - #endif - #ifdef USE_SPECULARCOLORMAP - specularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb; - #endif - material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); - #else - float specularIntensityFactor = 1.0; - vec3 specularColorFactor = vec3( 1.0 ); - material.specularF90 = 1.0; - #endif - material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); -#else - material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); - material.specularF90 = 1.0; -#endif -#ifdef USE_CLEARCOAT - material.clearcoat = clearcoat; - material.clearcoatRoughness = clearcoatRoughness; - material.clearcoatF0 = vec3( 0.04 ); - material.clearcoatF90 = 1.0; - #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vUv ).x; - #endif - #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; - #endif - material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); - material.clearcoatRoughness += geometryRoughness; - material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); -#endif -#ifdef USE_SHEEN - material.sheenColor = sheenColor; - #ifdef USE_SHEENCOLORMAP - material.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb; - #endif - material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); - #ifdef USE_SHEENROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; - #endif -#endif`, hp = `struct PhysicalMaterial { - vec3 diffuseColor; - float roughness; - vec3 specularColor; - float specularF90; - #ifdef USE_CLEARCOAT - float clearcoat; - float clearcoatRoughness; - vec3 clearcoatF0; - float clearcoatF90; - #endif - #ifdef USE_SHEEN - vec3 sheenColor; - float sheenRoughness; - #endif -}; -vec3 clearcoatSpecular = vec3( 0.0 ); -vec3 sheenSpecular = vec3( 0.0 ); -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) { - float dotNV = saturate( dot( normal, viewDir ) ); - float r2 = roughness * roughness; - float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; - float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; - float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); - return saturate( DG * RECIPROCAL_PI ); -} -vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); - const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); - vec4 r = roughness * c0 + c1; - float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; - vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; - return fab; -} -vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { - vec2 fab = DFGApprox( normal, viewDir, roughness ); - return specularColor * fab.x + specularF90 * fab.y; -} -void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { - vec2 fab = DFGApprox( normal, viewDir, roughness ); - vec3 FssEss = specularColor * fab.x + specularF90 * fab.y; - float Ess = fab.x + fab.y; - float Ems = 1.0 - Ess; - vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); - singleScatter += FssEss; - multiScatter += Fms * Ems; -} -#if NUM_RECT_AREA_LIGHTS > 0 - void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 normal = geometry.normal; - vec3 viewDir = geometry.viewDir; - vec3 position = geometry.position; - vec3 lightPos = rectAreaLight.position; - vec3 halfWidth = rectAreaLight.halfWidth; - vec3 halfHeight = rectAreaLight.halfHeight; - vec3 lightColor = rectAreaLight.color; - float roughness = material.roughness; - vec3 rectCoords[ 4 ]; - rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; - rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; - rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; - vec2 uv = LTC_Uv( normal, viewDir, roughness ); - vec4 t1 = texture2D( ltc_1, uv ); - vec4 t2 = texture2D( ltc_2, uv ); - mat3 mInv = mat3( - vec3( t1.x, 0, t1.y ), - vec3( 0, 1, 0 ), - vec3( t1.z, 0, t1.w ) - ); - vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); - reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); - reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); - } -#endif -void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - #ifdef USE_CLEARCOAT - float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); - vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); - #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { - #ifdef USE_CLEARCOAT - clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); - #endif - vec3 singleScattering = vec3( 0.0 ); - vec3 multiScattering = vec3( 0.0 ); - vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); - vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); - reflectedLight.indirectSpecular += radiance * singleScattering; - reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; - reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; -} -#define RE_Direct RE_Direct_Physical -#define RE_Direct_RectArea RE_Direct_RectArea_Physical -#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical -#define RE_IndirectSpecular RE_IndirectSpecular_Physical -float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { - return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`, up = ` -GeometricContext geometry; -geometry.position = - vViewPosition; -geometry.normal = normal; -geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); -#ifdef USE_CLEARCOAT - geometry.clearcoatNormal = clearcoatNormal; -#endif -IncidentLight directLight; -#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) - PointLight pointLight; - #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - pointLight = pointLights[ i ]; - getPointLightInfo( pointLight, geometry, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) - pointLightShadow = pointLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; - #endif - RE_Direct( directLight, geometry, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) - SpotLight spotLight; - #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - spotLight = spotLights[ i ]; - getSpotLightInfo( spotLight, geometry, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - spotLightShadow = spotLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometry, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) - DirectionalLight directionalLight; - #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - directionalLight = directionalLights[ i ]; - getDirectionalLightInfo( directionalLight, geometry, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) - directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometry, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) - RectAreaLight rectAreaLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { - rectAreaLight = rectAreaLights[ i ]; - RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if defined( RE_IndirectDiffuse ) - vec3 iblIrradiance = vec3( 0.0 ); - vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); - irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); - #if ( NUM_HEMI_LIGHTS > 0 ) - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); - } - #pragma unroll_loop_end - #endif -#endif -#if defined( RE_IndirectSpecular ) - vec3 radiance = vec3( 0.0 ); - vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`, dp = `#if defined( RE_IndirectDiffuse ) - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vUv2 ); - vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; - #ifndef PHYSICALLY_CORRECT_LIGHTS - lightMapIrradiance *= PI; - #endif - irradiance += lightMapIrradiance; - #endif - #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) - iblIrradiance += getIBLIrradiance( geometry.normal ); - #endif -#endif -#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); - #ifdef USE_CLEARCOAT - clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); - #endif -#endif`, fp = `#if defined( RE_IndirectDiffuse ) - RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); -#endif -#if defined( RE_IndirectSpecular ) - RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); -#endif`, pp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) - gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`, mp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) - uniform float logDepthBufFC; - varying float vFragDepth; - varying float vIsPerspective; -#endif`, gp = `#ifdef USE_LOGDEPTHBUF - #ifdef USE_LOGDEPTHBUF_EXT - varying float vFragDepth; - varying float vIsPerspective; - #else - uniform float logDepthBufFC; - #endif -#endif`, xp = `#ifdef USE_LOGDEPTHBUF - #ifdef USE_LOGDEPTHBUF_EXT - vFragDepth = 1.0 + gl_Position.w; - vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); - #else - if ( isPerspectiveMatrix( projectionMatrix ) ) { - gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; - gl_Position.z *= gl_Position.w; - } - #endif -#endif`, yp = `#ifdef USE_MAP - vec4 texelColor = texture2D( map, vUv ); - texelColor = mapTexelToLinear( texelColor ); - diffuseColor *= texelColor; -#endif`, vp = `#ifdef USE_MAP - uniform sampler2D map; -#endif`, _p = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; -#endif -#ifdef USE_MAP - vec4 mapTexel = texture2D( map, uv ); - diffuseColor *= mapTexelToLinear( mapTexel ); -#endif -#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`, Mp = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - uniform mat3 uvTransform; -#endif -#ifdef USE_MAP - uniform sampler2D map; -#endif -#ifdef USE_ALPHAMAP - uniform sampler2D alphaMap; -#endif`, bp = `float metalnessFactor = metalness; -#ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vUv ); - metalnessFactor *= texelMetalness.b; -#endif`, wp = `#ifdef USE_METALNESSMAP - uniform sampler2D metalnessMap; -#endif`, Sp = `#ifdef USE_MORPHNORMALS - objectNormal *= morphTargetBaseInfluence; - #ifdef MORPHTARGETS_TEXTURE - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ]; - } - #else - objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; - objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; - objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; - objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; - #endif -#endif`, Tp = `#ifdef USE_MORPHTARGETS - uniform float morphTargetBaseInfluence; - #ifdef MORPHTARGETS_TEXTURE - uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - uniform sampler2DArray morphTargetsTexture; - uniform vec2 morphTargetsTextureSize; - vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) { - float texelIndex = float( vertexIndex * stride + offset ); - float y = floor( texelIndex / morphTargetsTextureSize.x ); - float x = texelIndex - y * morphTargetsTextureSize.x; - vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex ); - return texture( morphTargetsTexture, morphUV ).xyz; - } - #else - #ifndef USE_MORPHNORMALS - uniform float morphTargetInfluences[ 8 ]; - #else - uniform float morphTargetInfluences[ 4 ]; - #endif - #endif -#endif`, Ep = `#ifdef USE_MORPHTARGETS - transformed *= morphTargetBaseInfluence; - #ifdef MORPHTARGETS_TEXTURE - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - #ifndef USE_MORPHNORMALS - if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ]; - #else - if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ]; - #endif - } - #else - transformed += morphTarget0 * morphTargetInfluences[ 0 ]; - transformed += morphTarget1 * morphTargetInfluences[ 1 ]; - transformed += morphTarget2 * morphTargetInfluences[ 2 ]; - transformed += morphTarget3 * morphTargetInfluences[ 3 ]; - #ifndef USE_MORPHNORMALS - transformed += morphTarget4 * morphTargetInfluences[ 4 ]; - transformed += morphTarget5 * morphTargetInfluences[ 5 ]; - transformed += morphTarget6 * morphTargetInfluences[ 6 ]; - transformed += morphTarget7 * morphTargetInfluences[ 7 ]; - #endif - #endif -#endif`, Ap = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; -#ifdef FLAT_SHADED - vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); - vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); - vec3 normal = normalize( cross( fdx, fdy ) ); -#else - vec3 normal = normalize( vNormal ); - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - #ifdef USE_TANGENT - vec3 tangent = normalize( vTangent ); - vec3 bitangent = normalize( vBitangent ); - #ifdef DOUBLE_SIDED - tangent = tangent * faceDirection; - bitangent = bitangent * faceDirection; - #endif - #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) - mat3 vTBN = mat3( tangent, bitangent, normal ); - #endif - #endif -#endif -vec3 geometryNormal = normal;`, Cp = `#ifdef OBJECTSPACE_NORMALMAP - normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; - #ifdef FLIP_SIDED - normal = - normal; - #endif - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - normal = normalize( normalMatrix * normal ); -#elif defined( TANGENTSPACE_NORMALMAP ) - vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; - mapN.xy *= normalScale; - #ifdef USE_TANGENT - normal = normalize( vTBN * mapN ); - #else - normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); - #endif -#elif defined( USE_BUMPMAP ) - normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`, Lp = `#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`, Rp = `#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`, Pp = `#ifndef FLAT_SHADED - vNormal = normalize( transformedNormal ); - #ifdef USE_TANGENT - vTangent = normalize( transformedTangent ); - vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); - #endif -#endif`, Ip = `#ifdef USE_NORMALMAP - uniform sampler2D normalMap; - uniform vec2 normalScale; -#endif -#ifdef OBJECTSPACE_NORMALMAP - uniform mat3 normalMatrix; -#endif -#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) - vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { - vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); - vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); - vec2 st0 = dFdx( vUv.st ); - vec2 st1 = dFdy( vUv.st ); - vec3 N = surf_norm; - vec3 q1perp = cross( q1, N ); - vec3 q0perp = cross( N, q0 ); - vec3 T = q1perp * st0.x + q0perp * st1.x; - vec3 B = q1perp * st0.y + q0perp * st1.y; - float det = max( dot( T, T ), dot( B, B ) ); - float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); - return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); - } -#endif`, Dp = `#ifdef USE_CLEARCOAT - vec3 clearcoatNormal = geometryNormal; -#endif`, Fp = `#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; - clearcoatMapN.xy *= clearcoatNormalScale; - #ifdef USE_TANGENT - clearcoatNormal = normalize( vTBN * clearcoatMapN ); - #else - clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); - #endif -#endif`, Np = `#ifdef USE_CLEARCOATMAP - uniform sampler2D clearcoatMap; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform sampler2D clearcoatRoughnessMap; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform sampler2D clearcoatNormalMap; - uniform vec2 clearcoatNormalScale; -#endif`, Bp = `#ifdef OPAQUE -diffuseColor.a = 1.0; -#endif -#ifdef USE_TRANSMISSION -diffuseColor.a *= transmissionAlpha + 0.1; -#endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, zp = `vec3 packNormalToRGB( const in vec3 normal ) { - return normalize( normal ) * 0.5 + 0.5; -} -vec3 unpackRGBToNormal( const in vec3 rgb ) { - return 2.0 * rgb.xyz - 1.0; -} -const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; -const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); -const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); -const float ShiftRight8 = 1. / 256.; -vec4 packDepthToRGBA( const in float v ) { - vec4 r = vec4( fract( v * PackFactors ), v ); - r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; -} -float unpackRGBAToDepth( const in vec4 v ) { - return dot( v, UnpackFactors ); -} -vec4 pack2HalfToRGBA( vec2 v ) { - vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); - return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); -} -vec2 unpackRGBATo2Half( vec4 v ) { - return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); -} -float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { - return ( viewZ + near ) / ( near - far ); -} -float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { - return linearClipZ * ( near - far ) - near; -} -float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { - return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); -} -float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { - return ( near * far ) / ( ( far - near ) * invClipZ - far ); -}`, Up = `#ifdef PREMULTIPLIED_ALPHA - gl_FragColor.rgb *= gl_FragColor.a; -#endif`, Op = `vec4 mvPosition = vec4( transformed, 1.0 ); -#ifdef USE_INSTANCING - mvPosition = instanceMatrix * mvPosition; -#endif -mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING - gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`, kp = `#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`, Gp = `float roughnessFactor = roughness; -#ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vUv ); - roughnessFactor *= texelRoughness.g; -#endif`, Vp = `#ifdef USE_ROUGHNESSMAP - uniform sampler2D roughnessMap; -#endif`, Wp = `#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; - struct SpotLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { - return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); - } - vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { - return unpackRGBATo2Half( texture2D( shadow, uv ) ); - } - float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ - float occlusion = 1.0; - vec2 distribution = texture2DDistribution( shadow, uv ); - float hard_shadow = step( compare , distribution.x ); - if (hard_shadow != 1.0 ) { - float distance = compare - distribution.x ; - float variance = max( 0.00000, distribution.y * distribution.y ); - float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); - } - return occlusion; - } - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - shadowCoord.z += shadowBias; - bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); - bool inFrustum = all( inFrustumVec ); - bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); - bool frustumTest = all( frustumTestVec ); - if ( frustumTest ) { - #if defined( SHADOWMAP_TYPE_PCF ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx0 = - texelSize.x * shadowRadius; - float dy0 = - texelSize.y * shadowRadius; - float dx1 = + texelSize.x * shadowRadius; - float dy1 = + texelSize.y * shadowRadius; - float dx2 = dx0 / 2.0; - float dy2 = dy0 / 2.0; - float dx3 = dx1 / 2.0; - float dy3 = dy1 / 2.0; - shadow = ( - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) - ) * ( 1.0 / 17.0 ); - #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx = texelSize.x; - float dy = texelSize.y; - vec2 uv = shadowCoord.xy; - vec2 f = fract( uv * shadowMapSize + 0.5 ); - uv -= f * texelSize; - shadow = ( - texture2DCompare( shadowMap, uv, shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), - f.x ), - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), - f.x ), - f.y ) - ) * ( 1.0 / 9.0 ); - #elif defined( SHADOWMAP_TYPE_VSM ) - shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); - #else - shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); - #endif - } - return shadow; - } - vec2 cubeToUV( vec3 v, float texelSizeY ) { - vec3 absV = abs( v ); - float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); - absV *= scaleToCube; - v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); - vec2 planar = v.xy; - float almostATexel = 1.5 * texelSizeY; - float almostOne = 1.0 - almostATexel; - if ( absV.z >= almostOne ) { - if ( v.z > 0.0 ) - planar.x = 4.0 - v.x; - } else if ( absV.x >= almostOne ) { - float signX = sign( v.x ); - planar.x = v.z * signX + 2.0 * signX; - } else if ( absV.y >= almostOne ) { - float signY = sign( v.y ); - planar.x = v.x + 2.0 * signY + 2.0; - planar.y = v.z * signY - 2.0; - } - return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); - } - float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); - vec3 lightToPosition = shadowCoord.xyz; - float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; - vec3 bd3D = normalize( lightToPosition ); - #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) - vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; - return ( - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) - ) * ( 1.0 / 9.0 ); - #else - return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); - #endif - } -#endif`, qp = `#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; - varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; - struct SpotLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif -#endif`, Xp = `#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 - vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - vec4 shadowWorldPosition; - #endif - #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); - vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif -#endif`, Jp = `float getShadowMask() { - float shadow = 1.0; - #ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - directionalLight = directionalLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - pointLight = pointLightShadows[ i ]; - shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; - } - #pragma unroll_loop_end - #endif - #endif - return shadow; -}`, Yp = `#ifdef USE_SKINNING - mat4 boneMatX = getBoneMatrix( skinIndex.x ); - mat4 boneMatY = getBoneMatrix( skinIndex.y ); - mat4 boneMatZ = getBoneMatrix( skinIndex.z ); - mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`, Zp = `#ifdef USE_SKINNING - uniform mat4 bindMatrix; - uniform mat4 bindMatrixInverse; - #ifdef BONE_TEXTURE - uniform highp sampler2D boneTexture; - uniform int boneTextureSize; - mat4 getBoneMatrix( const in float i ) { - float j = i * 4.0; - float x = mod( j, float( boneTextureSize ) ); - float y = floor( j / float( boneTextureSize ) ); - float dx = 1.0 / float( boneTextureSize ); - float dy = 1.0 / float( boneTextureSize ); - y = dy * ( y + 0.5 ); - vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); - vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); - vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); - vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); - mat4 bone = mat4( v1, v2, v3, v4 ); - return bone; - } - #else - uniform mat4 boneMatrices[ MAX_BONES ]; - mat4 getBoneMatrix( const in float i ) { - mat4 bone = boneMatrices[ int(i) ]; - return bone; - } - #endif -#endif`, $p = `#ifdef USE_SKINNING - vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); - vec4 skinned = vec4( 0.0 ); - skinned += boneMatX * skinVertex * skinWeight.x; - skinned += boneMatY * skinVertex * skinWeight.y; - skinned += boneMatZ * skinVertex * skinWeight.z; - skinned += boneMatW * skinVertex * skinWeight.w; - transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`, jp = `#ifdef USE_SKINNING - mat4 skinMatrix = mat4( 0.0 ); - skinMatrix += skinWeight.x * boneMatX; - skinMatrix += skinWeight.y * boneMatY; - skinMatrix += skinWeight.z * boneMatZ; - skinMatrix += skinWeight.w * boneMatW; - skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; - objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; - #ifdef USE_TANGENT - objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; - #endif -#endif`, Qp = `float specularStrength; -#ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vUv ); - specularStrength = texelSpecular.r; -#else - specularStrength = 1.0; -#endif`, Kp = `#ifdef USE_SPECULARMAP - uniform sampler2D specularMap; -#endif`, em = `#if defined( TONE_MAPPING ) - gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`, tm = `#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -uniform float toneMappingExposure; -vec3 LinearToneMapping( vec3 color ) { - return toneMappingExposure * color; -} -vec3 ReinhardToneMapping( vec3 color ) { - color *= toneMappingExposure; - return saturate( color / ( vec3( 1.0 ) + color ) ); -} -vec3 OptimizedCineonToneMapping( vec3 color ) { - color *= toneMappingExposure; - color = max( vec3( 0.0 ), color - 0.004 ); - return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); -} -vec3 RRTAndODTFit( vec3 v ) { - vec3 a = v * ( v + 0.0245786 ) - 0.000090537; - vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; - return a / b; -} -vec3 ACESFilmicToneMapping( vec3 color ) { - const mat3 ACESInputMat = mat3( - vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), - vec3( 0.04823, 0.01566, 0.83777 ) - ); - const mat3 ACESOutputMat = mat3( - vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), - vec3( -0.07367, -0.00605, 1.07602 ) - ); - color *= toneMappingExposure / 0.6; - color = ACESInputMat * color; - color = RRTAndODTFit( color ); - color = ACESOutputMat * color; - return saturate( color ); -} -vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSMISSION - float transmissionAlpha = 1.0; - float transmissionFactor = transmission; - float thicknessFactor = thickness; - #ifdef USE_TRANSMISSIONMAP - transmissionFactor *= texture2D( transmissionMap, vUv ).r; - #endif - #ifdef USE_THICKNESSMAP - thicknessFactor *= texture2D( thicknessMap, vUv ).g; - #endif - vec3 pos = vWorldPosition; - vec3 v = normalize( cameraPosition - pos ); - vec3 n = inverseTransformDirection( normal, viewMatrix ); - vec4 transmission = getIBLVolumeRefraction( - n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor, - attenuationColor, attenuationDistance ); - totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor ); - transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor ); -#endif`, im = `#ifdef USE_TRANSMISSION - uniform float transmission; - uniform float thickness; - uniform float attenuationDistance; - uniform vec3 attenuationColor; - #ifdef USE_TRANSMISSIONMAP - uniform sampler2D transmissionMap; - #endif - #ifdef USE_THICKNESSMAP - uniform sampler2D thicknessMap; - #endif - uniform vec2 transmissionSamplerSize; - uniform sampler2D transmissionSamplerMap; - uniform mat4 modelMatrix; - uniform mat4 projectionMatrix; - varying vec3 vWorldPosition; - vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { - vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); - vec3 modelScale; - modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); - modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); - modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); - return normalize( refractionVector ) * thickness * modelScale; - } - float applyIorToRoughness( float roughness, float ior ) { - return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); - } - vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) { - float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); - #ifdef TEXTURE_LOD_EXT - return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); - #else - return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); - #endif - } - vec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) { - if ( attenuationDistance == 0.0 ) { - return radiance; - } else { - vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; - vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; - } - } - vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90, - vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, - vec3 attenuationColor, float attenuationDistance ) { - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); - vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); - vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); - return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); - } -#endif`, rm = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) - varying vec2 vUv; -#endif`, sm = `#ifdef USE_UV - #ifdef UVS_VERTEX_ONLY - vec2 vUv; - #else - varying vec2 vUv; - #endif - uniform mat3 uvTransform; -#endif`, om = `#ifdef USE_UV - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; -#endif`, am = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - varying vec2 vUv2; -#endif`, lm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - attribute vec2 uv2; - varying vec2 vUv2; - uniform mat3 uv2Transform; -#endif`, cm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; -#endif`, hm = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`, um = `varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`, dm = `uniform sampler2D t2D; -varying vec2 vUv; -void main() { - vec4 texColor = texture2D( t2D, vUv ); - gl_FragColor = mapTexelToLinear( texColor ); - #include - #include -}`, fm = `varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`, pm = `#include -uniform float opacity; -varying vec3 vWorldDirection; -#include -void main() { - vec3 vReflect = vWorldDirection; - #include - gl_FragColor = envColor; - gl_FragColor.a *= opacity; - #include - #include -}`, mm = `#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vHighPrecisionZW = gl_Position.zw; -}`, gm = `#if DEPTH_PACKING == 3200 - uniform float opacity; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - vec4 diffuseColor = vec4( 1.0 ); - #if DEPTH_PACKING == 3200 - diffuseColor.a = opacity; - #endif - #include - #include - #include - #include - float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; - #if DEPTH_PACKING == 3200 - gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); - #elif DEPTH_PACKING == 3201 - gl_FragColor = packDepthToRGBA( fragCoordZ ); - #endif -}`, xm = `#define DISTANCE -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vWorldPosition = worldPosition.xyz; -}`, ym = `#define DISTANCE -uniform vec3 referencePosition; -uniform float nearDistance; -uniform float farDistance; -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -void main () { - #include - vec4 diffuseColor = vec4( 1.0 ); - #include - #include - #include - float dist = length( vWorldPosition - referencePosition ); - dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); - dist = saturate( dist ); - gl_FragColor = packDepthToRGBA( dist ); -}`, vm = `varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include -}`, _m = `uniform sampler2D tEquirect; -varying vec3 vWorldDirection; -#include -void main() { - vec3 direction = normalize( vWorldDirection ); - vec2 sampleUV = equirectUv( direction ); - vec4 texColor = texture2D( tEquirect, sampleUV ); - gl_FragColor = mapTexelToLinear( texColor ); - #include - #include -}`, Mm = `uniform float scale; -attribute float lineDistance; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -void main() { - vLineDistance = scale * lineDistance; - #include - #include - #include - #include - #include - #include - #include -}`, bm = `uniform vec3 diffuse; -uniform float opacity; -uniform float dashSize; -uniform float totalSize; -varying float vLineDistance; -#include -#include -#include -#include -#include -void main() { - #include - if ( mod( vLineDistance, totalSize ) > dashSize ) { - discard; - } - vec3 outgoingLight = vec3( 0.0 ); - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`, wm = `#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) - #include - #include - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`, Sm = `uniform vec3 diffuse; -uniform float opacity; -#ifndef FLAT_SHADED - varying vec3 vNormal; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - #ifdef USE_LIGHTMAP - vec4 lightMapTexel= texture2D( lightMap, vUv2 ); - reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; - #else - reflectedLight.indirectDiffuse += vec3( 1.0 ); - #endif - #include - reflectedLight.indirectDiffuse *= diffuseColor.rgb; - vec3 outgoingLight = reflectedLight.indirectDiffuse; - #include - #include - #include - #include - #include - #include - #include -}`, Tm = `#define LAMBERT -varying vec3 vLightFront; -varying vec3 vIndirectFront; -#ifdef DOUBLE_SIDED - varying vec3 vLightBack; - varying vec3 vIndirectBack; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`, Em = `uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -varying vec3 vLightFront; -varying vec3 vIndirectFront; -#ifdef DOUBLE_SIDED - varying vec3 vLightBack; - varying vec3 vIndirectBack; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #ifdef DOUBLE_SIDED - reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; - #else - reflectedLight.indirectDiffuse += vIndirectFront; - #endif - #include - reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb ); - #ifdef DOUBLE_SIDED - reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; - #else - reflectedLight.directDiffuse = vLightFront; - #endif - reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask(); - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`, Am = `#define MATCAP -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; -}`, Cm = `#define MATCAP -uniform vec3 diffuse; -uniform float opacity; -uniform sampler2D matcap; -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - vec3 viewDir = normalize( vViewPosition ); - vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); - vec3 y = cross( viewDir, x ); - vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; - #ifdef USE_MATCAP - vec4 matcapColor = texture2D( matcap, uv ); - matcapColor = matcapTexelToLinear( matcapColor ); - #else - vec4 matcapColor = vec4( 1.0 ); - #endif - vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; - #include - #include - #include - #include - #include - #include -}`, Lm = `#define NORMAL -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) - vViewPosition = - mvPosition.xyz; -#endif -}`, Rm = `#define NORMAL -uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); -}`, Pm = `#define PHONG -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`, Im = `#define PHONG -uniform vec3 diffuse; -uniform vec3 emissive; -uniform vec3 specular; -uniform float shininess; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`, Dm = `#define STANDARD -varying vec3 vViewPosition; -#ifdef USE_TRANSMISSION - varying vec3 vWorldPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -#ifdef USE_TRANSMISSION - vWorldPosition = worldPosition.xyz; -#endif -}`, Fm = `#define STANDARD -#ifdef PHYSICAL - #define IOR - #define SPECULAR -#endif -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float roughness; -uniform float metalness; -uniform float opacity; -#ifdef IOR - uniform float ior; -#endif -#ifdef SPECULAR - uniform float specularIntensity; - uniform vec3 specularColor; - #ifdef USE_SPECULARINTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif - #ifdef USE_SPECULARCOLORMAP - uniform sampler2D specularColorMap; - #endif -#endif -#ifdef USE_CLEARCOAT - uniform float clearcoat; - uniform float clearcoatRoughness; -#endif -#ifdef USE_SHEEN - uniform vec3 sheenColor; - uniform float sheenRoughness; - #ifdef USE_SHEENCOLORMAP - uniform sampler2D sheenColorMap; - #endif - #ifdef USE_SHEENROUGHNESSMAP - uniform sampler2D sheenRoughnessMap; - #endif -#endif -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; - #include - vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; - #ifdef USE_SHEEN - float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); - outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; - #endif - #ifdef USE_CLEARCOAT - float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); - vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); - outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; - #endif - #include - #include - #include - #include - #include - #include -}`, Nm = `#define TOON -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -}`, Bm = `#define TOON -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec4 diffuseColor = vec4( diffuse, opacity ); - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include -}`, zm = `uniform float size; -uniform float scale; -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - gl_PointSize = size; - #ifdef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); - #endif - #include - #include - #include - #include -}`, Um = `uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec3 outgoingLight = vec3( 0.0 ); - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`, Om = `#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`, Hm = `uniform vec3 color; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -void main() { - gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); - #include - #include - #include -}`, km = `uniform float rotation; -uniform vec2 center; -#include -#include -#include -#include -#include -void main() { - #include - vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); - vec2 scale; - scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); - scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); - #ifndef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - #endif - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - gl_Position = projectionMatrix * mvPosition; - #include - #include - #include -}`, Gm = `uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - vec3 outgoingLight = vec3( 0.0 ); - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include -}`, Fe = { - alphamap_fragment: xf, - alphamap_pars_fragment: yf, - alphatest_fragment: vf, - alphatest_pars_fragment: _f, - aomap_fragment: Mf, - aomap_pars_fragment: bf, - begin_vertex: wf, - beginnormal_vertex: Sf, - bsdfs: Tf, - bumpmap_pars_fragment: Ef, - clipping_planes_fragment: Af, - clipping_planes_pars_fragment: Cf, - clipping_planes_pars_vertex: Lf, - clipping_planes_vertex: Rf, - color_fragment: Pf, - color_pars_fragment: If, - color_pars_vertex: Df, - color_vertex: Ff, - common: Nf, - cube_uv_reflection_fragment: Bf, - defaultnormal_vertex: zf, - displacementmap_pars_vertex: Uf, - displacementmap_vertex: Of, - emissivemap_fragment: Hf, - emissivemap_pars_fragment: kf, - encodings_fragment: Gf, - encodings_pars_fragment: Vf, - envmap_fragment: Wf, - envmap_common_pars_fragment: qf, - envmap_pars_fragment: Xf, - envmap_pars_vertex: Jf, - envmap_physical_pars_fragment: rp, - envmap_vertex: Yf, - fog_vertex: Zf, - fog_pars_vertex: $f, - fog_fragment: jf, - fog_pars_fragment: Qf, - gradientmap_pars_fragment: Kf, - lightmap_fragment: ep, - lightmap_pars_fragment: tp, - lights_lambert_vertex: np, - lights_pars_begin: ip, - lights_toon_fragment: sp, - lights_toon_pars_fragment: op, - lights_phong_fragment: ap, - lights_phong_pars_fragment: lp, - lights_physical_fragment: cp, - lights_physical_pars_fragment: hp, - lights_fragment_begin: up, - lights_fragment_maps: dp, - lights_fragment_end: fp, - logdepthbuf_fragment: pp, - logdepthbuf_pars_fragment: mp, - logdepthbuf_pars_vertex: gp, - logdepthbuf_vertex: xp, - map_fragment: yp, - map_pars_fragment: vp, - map_particle_fragment: _p, - map_particle_pars_fragment: Mp, - metalnessmap_fragment: bp, - metalnessmap_pars_fragment: wp, - morphnormal_vertex: Sp, - morphtarget_pars_vertex: Tp, - morphtarget_vertex: Ep, - normal_fragment_begin: Ap, - normal_fragment_maps: Cp, - normal_pars_fragment: Lp, - normal_pars_vertex: Rp, - normal_vertex: Pp, - normalmap_pars_fragment: Ip, - clearcoat_normal_fragment_begin: Dp, - clearcoat_normal_fragment_maps: Fp, - clearcoat_pars_fragment: Np, - output_fragment: Bp, - packing: zp, - premultiplied_alpha_fragment: Up, - project_vertex: Op, - dithering_fragment: Hp, - dithering_pars_fragment: kp, - roughnessmap_fragment: Gp, - roughnessmap_pars_fragment: Vp, - shadowmap_pars_fragment: Wp, - shadowmap_pars_vertex: qp, - shadowmap_vertex: Xp, - shadowmask_pars_fragment: Jp, - skinbase_vertex: Yp, - skinning_pars_vertex: Zp, - skinning_vertex: $p, - skinnormal_vertex: jp, - specularmap_fragment: Qp, - specularmap_pars_fragment: Kp, - tonemapping_fragment: em, - tonemapping_pars_fragment: tm, - transmission_fragment: nm, - transmission_pars_fragment: im, - uv_pars_fragment: rm, - uv_pars_vertex: sm, - uv_vertex: om, - uv2_pars_fragment: am, - uv2_pars_vertex: lm, - uv2_vertex: cm, - worldpos_vertex: hm, - background_vert: um, - background_frag: dm, - cube_vert: fm, - cube_frag: pm, - depth_vert: mm, - depth_frag: gm, - distanceRGBA_vert: xm, - distanceRGBA_frag: ym, - equirect_vert: vm, - equirect_frag: _m, - linedashed_vert: Mm, - linedashed_frag: bm, - meshbasic_vert: wm, - meshbasic_frag: Sm, - meshlambert_vert: Tm, - meshlambert_frag: Em, - meshmatcap_vert: Am, - meshmatcap_frag: Cm, - meshnormal_vert: Lm, - meshnormal_frag: Rm, - meshphong_vert: Pm, - meshphong_frag: Im, - meshphysical_vert: Dm, - meshphysical_frag: Fm, - meshtoon_vert: Nm, - meshtoon_frag: Bm, - points_vert: zm, - points_frag: Um, - shadow_vert: Om, - shadow_frag: Hm, - sprite_vert: km, - sprite_frag: Gm -}, ie = { - common: { - diffuse: { - value: new ae(16777215) - }, - opacity: { - value: 1 - }, - map: { - value: null - }, - uvTransform: { - value: new lt - }, - uv2Transform: { - value: new lt - }, - alphaMap: { - value: null - }, - alphaTest: { - value: 0 - } - }, - specularmap: { - specularMap: { - value: null - } - }, - envmap: { - envMap: { - value: null - }, - flipEnvMap: { - value: -1 - }, - reflectivity: { - value: 1 - }, - ior: { - value: 1.5 - }, - refractionRatio: { - value: .98 - } - }, - aomap: { - aoMap: { - value: null - }, - aoMapIntensity: { - value: 1 - } - }, - lightmap: { - lightMap: { - value: null - }, - lightMapIntensity: { - value: 1 - } - }, - emissivemap: { - emissiveMap: { - value: null - } - }, - bumpmap: { - bumpMap: { - value: null - }, - bumpScale: { - value: 1 - } - }, - normalmap: { - normalMap: { - value: null - }, - normalScale: { - value: new X(1, 1) - } - }, - displacementmap: { - displacementMap: { - value: null - }, - displacementScale: { - value: 1 - }, - displacementBias: { - value: 0 - } - }, - roughnessmap: { - roughnessMap: { - value: null - } - }, - metalnessmap: { - metalnessMap: { - value: null - } - }, - gradientmap: { - gradientMap: { - value: null - } - }, - fog: { - fogDensity: { - value: 25e-5 - }, - fogNear: { - value: 1 - }, - fogFar: { - value: 2e3 - }, - fogColor: { - value: new ae(16777215) - } - }, - lights: { - ambientLightColor: { - value: [] - }, - lightProbe: { - value: [] - }, - directionalLights: { - value: [], - properties: { - direction: {}, - color: {} - } - }, - directionalLightShadows: { - value: [], - properties: { - shadowBias: {}, - shadowNormalBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } - }, - directionalShadowMap: { - value: [] - }, - directionalShadowMatrix: { - value: [] - }, - spotLights: { - value: [], - properties: { - color: {}, - position: {}, - direction: {}, - distance: {}, - coneCos: {}, - penumbraCos: {}, - decay: {} - } - }, - spotLightShadows: { - value: [], - properties: { - shadowBias: {}, - shadowNormalBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } - }, - spotShadowMap: { - value: [] - }, - spotShadowMatrix: { - value: [] - }, - pointLights: { - value: [], - properties: { - color: {}, - position: {}, - decay: {}, - distance: {} - } - }, - pointLightShadows: { - value: [], - properties: { - shadowBias: {}, - shadowNormalBias: {}, - shadowRadius: {}, - shadowMapSize: {}, - shadowCameraNear: {}, - shadowCameraFar: {} - } - }, - pointShadowMap: { - value: [] - }, - pointShadowMatrix: { - value: [] - }, - hemisphereLights: { - value: [], - properties: { - direction: {}, - skyColor: {}, - groundColor: {} - } - }, - rectAreaLights: { - value: [], - properties: { - color: {}, - position: {}, - width: {}, - height: {} - } - }, - ltc_1: { - value: null - }, - ltc_2: { - value: null - } - }, - points: { - diffuse: { - value: new ae(16777215) - }, - opacity: { - value: 1 - }, - size: { - value: 1 - }, - scale: { - value: 1 - }, - map: { - value: null - }, - alphaMap: { - value: null - }, - alphaTest: { - value: 0 - }, - uvTransform: { - value: new lt - } - }, - sprite: { - diffuse: { - value: new ae(16777215) - }, - opacity: { - value: 1 - }, - center: { - value: new X(.5, .5) - }, - rotation: { - value: 0 - }, - map: { - value: null - }, - alphaMap: { - value: null - }, - alphaTest: { - value: 0 - }, - uvTransform: { - value: new lt - } - } -}, qt = { - basic: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.fog - ]), - vertexShader: Fe.meshbasic_vert, - fragmentShader: Fe.meshbasic_frag - }, - lambert: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.fog, - ie.lights, - { - emissive: { - value: new ae(0) - } - } - ]), - vertexShader: Fe.meshlambert_vert, - fragmentShader: Fe.meshlambert_frag - }, - phong: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.fog, - ie.lights, - { - emissive: { - value: new ae(0) - }, - specular: { - value: new ae(1118481) - }, - shininess: { - value: 30 - } - } - ]), - vertexShader: Fe.meshphong_vert, - fragmentShader: Fe.meshphong_frag - }, - standard: { - uniforms: yt([ - ie.common, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.roughnessmap, - ie.metalnessmap, - ie.fog, - ie.lights, - { - emissive: { - value: new ae(0) - }, - roughness: { - value: 1 - }, - metalness: { - value: 0 - }, - envMapIntensity: { - value: 1 - } - } - ]), - vertexShader: Fe.meshphysical_vert, - fragmentShader: Fe.meshphysical_frag - }, - toon: { - uniforms: yt([ - ie.common, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.gradientmap, - ie.fog, - ie.lights, - { - emissive: { - value: new ae(0) - } - } - ]), - vertexShader: Fe.meshtoon_vert, - fragmentShader: Fe.meshtoon_frag - }, - matcap: { - uniforms: yt([ - ie.common, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.fog, - { - matcap: { - value: null - } - } - ]), - vertexShader: Fe.meshmatcap_vert, - fragmentShader: Fe.meshmatcap_frag - }, - points: { - uniforms: yt([ - ie.points, - ie.fog - ]), - vertexShader: Fe.points_vert, - fragmentShader: Fe.points_frag - }, - dashed: { - uniforms: yt([ - ie.common, - ie.fog, - { - scale: { - value: 1 - }, - dashSize: { - value: 1 - }, - totalSize: { - value: 2 - } - } - ]), - vertexShader: Fe.linedashed_vert, - fragmentShader: Fe.linedashed_frag - }, - depth: { - uniforms: yt([ - ie.common, - ie.displacementmap - ]), - vertexShader: Fe.depth_vert, - fragmentShader: Fe.depth_frag - }, - normal: { - uniforms: yt([ - ie.common, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - { - opacity: { - value: 1 - } - } - ]), - vertexShader: Fe.meshnormal_vert, - fragmentShader: Fe.meshnormal_frag - }, - sprite: { - uniforms: yt([ - ie.sprite, - ie.fog - ]), - vertexShader: Fe.sprite_vert, - fragmentShader: Fe.sprite_frag - }, - background: { - uniforms: { - uvTransform: { - value: new lt - }, - t2D: { - value: null - } - }, - vertexShader: Fe.background_vert, - fragmentShader: Fe.background_frag - }, - cube: { - uniforms: yt([ - ie.envmap, - { - opacity: { - value: 1 - } - } - ]), - vertexShader: Fe.cube_vert, - fragmentShader: Fe.cube_frag - }, - equirect: { - uniforms: { - tEquirect: { - value: null - } - }, - vertexShader: Fe.equirect_vert, - fragmentShader: Fe.equirect_frag - }, - distanceRGBA: { - uniforms: yt([ - ie.common, - ie.displacementmap, - { - referencePosition: { - value: new M - }, - nearDistance: { - value: 1 - }, - farDistance: { - value: 1e3 - } - } - ]), - vertexShader: Fe.distanceRGBA_vert, - fragmentShader: Fe.distanceRGBA_frag - }, - shadow: { - uniforms: yt([ - ie.lights, - ie.fog, - { - color: { - value: new ae(0) - }, - opacity: { - value: 1 - } - } - ]), - vertexShader: Fe.shadow_vert, - fragmentShader: Fe.shadow_frag - } -}; -qt.physical = { - uniforms: yt([ - qt.standard.uniforms, - { - clearcoat: { - value: 0 - }, - clearcoatMap: { - value: null - }, - clearcoatRoughness: { - value: 0 - }, - clearcoatRoughnessMap: { - value: null - }, - clearcoatNormalScale: { - value: new X(1, 1) - }, - clearcoatNormalMap: { - value: null - }, - sheen: { - value: 0 - }, - sheenColor: { - value: new ae(0) - }, - sheenColorMap: { - value: null - }, - sheenRoughness: { - value: 0 - }, - sheenRoughnessMap: { - value: null - }, - transmission: { - value: 0 - }, - transmissionMap: { - value: null - }, - transmissionSamplerSize: { - value: new X - }, - transmissionSamplerMap: { - value: null - }, - thickness: { - value: 0 - }, - thicknessMap: { - value: null - }, - attenuationDistance: { - value: 0 - }, - attenuationColor: { - value: new ae(0) - }, - specularIntensity: { - value: 0 - }, - specularIntensityMap: { - value: null - }, - specularColor: { - value: new ae(1, 1, 1) - }, - specularColorMap: { - value: null - } - } - ]), - vertexShader: Fe.meshphysical_vert, - fragmentShader: Fe.meshphysical_frag -}; -function Vm(s, e, t, n, i) { - let r = new ae(0), o = 0, a, l, c = null, h = 0, u = null; - function d(m, x) { - let v = !1, g = x.isScene === !0 ? x.background : null; - g && g.isTexture && (g = e.get(g)); - let p = s.xr, _ = p.getSession && p.getSession(); - _ && _.environmentBlendMode === "additive" && (g = null), g === null ? f(r, o) : g && g.isColor && (f(g, 1), v = !0), (s.autoClear || v) && s.clear(s.autoClearColor, s.autoClearDepth, s.autoClearStencil), g && (g.isCubeTexture || g.mapping === Pr) ? (l === void 0 && (l = new st(new wn(1, 1, 1), new sn({ - name: "BackgroundCubeMaterial", - uniforms: Ri(qt.cube.uniforms), - vertexShader: qt.cube.vertexShader, - fragmentShader: qt.cube.fragmentShader, - side: it, - depthTest: !1, - depthWrite: !1, - fog: !1 - })), l.geometry.deleteAttribute("normal"), l.geometry.deleteAttribute("uv"), l.onBeforeRender = function(y, b, A) { - this.matrixWorld.copyPosition(A.matrixWorld); - }, Object.defineProperty(l.material, "envMap", { - get: function() { - return this.uniforms.envMap.value; - } - }), n.update(l)), l.material.uniforms.envMap.value = g, l.material.uniforms.flipEnvMap.value = g.isCubeTexture && g.isRenderTargetTexture === !1 ? -1 : 1, (c !== g || h !== g.version || u !== s.toneMapping) && (l.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(l, l.geometry, l.material, 0, 0, null)) : g && g.isTexture && (a === void 0 && (a = new st(new Pi(2, 2), new sn({ - name: "BackgroundMaterial", - uniforms: Ri(qt.background.uniforms), - vertexShader: qt.background.vertexShader, - fragmentShader: qt.background.fragmentShader, - side: Ai, - depthTest: !1, - depthWrite: !1, - fog: !1 - })), a.geometry.deleteAttribute("normal"), Object.defineProperty(a.material, "map", { - get: function() { - return this.uniforms.t2D.value; - } - }), n.update(a)), a.material.uniforms.t2D.value = g, g.matrixAutoUpdate === !0 && g.updateMatrix(), a.material.uniforms.uvTransform.value.copy(g.matrix), (c !== g || h !== g.version || u !== s.toneMapping) && (a.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(a, a.geometry, a.material, 0, 0, null)); - } - function f(m, x) { - t.buffers.color.setClear(m.r, m.g, m.b, x, i); - } - return { - getClearColor: function() { - return r; - }, - setClearColor: function(m, x = 1) { - r.set(m), o = x, f(r, o); - }, - getClearAlpha: function() { - return o; - }, - setClearAlpha: function(m) { - o = m, f(r, o); - }, - render: d - }; -} -function Wm(s, e, t, n) { - let i = s.getParameter(34921), r = n.isWebGL2 ? null : e.get("OES_vertex_array_object"), o = n.isWebGL2 || r !== null, a = {}, l = x(null), c = l; - function h(E, D, U, F, O) { - let ne = !1; - if (o) { - let ce = m(F, U, D); - c !== ce && (c = ce, d(c.object)), ne = v(F, O), ne && g(F, O); - } else { - let ce = D.wireframe === !0; - (c.geometry !== F.id || c.program !== U.id || c.wireframe !== ce) && (c.geometry = F.id, c.program = U.id, c.wireframe = ce, ne = !0); - } - E.isInstancedMesh === !0 && (ne = !0), O !== null && t.update(O, 34963), ne && (L(E, D, U, F), O !== null && s.bindBuffer(34963, t.get(O).buffer)); - } - function u() { - return n.isWebGL2 ? s.createVertexArray() : r.createVertexArrayOES(); - } - function d(E) { - return n.isWebGL2 ? s.bindVertexArray(E) : r.bindVertexArrayOES(E); - } - function f(E) { - return n.isWebGL2 ? s.deleteVertexArray(E) : r.deleteVertexArrayOES(E); - } - function m(E, D, U) { - let F = U.wireframe === !0, O = a[E.id]; - O === void 0 && (O = {}, a[E.id] = O); - let ne = O[D.id]; - ne === void 0 && (ne = {}, O[D.id] = ne); - let ce = ne[F]; - return ce === void 0 && (ce = x(u()), ne[F] = ce), ce; - } - function x(E) { - let D = [], U = [], F = []; - for(let O = 0; O < i; O++)D[O] = 0, U[O] = 0, F[O] = 0; - return { - geometry: null, - program: null, - wireframe: !1, - newAttributes: D, - enabledAttributes: U, - attributeDivisors: F, - object: E, - attributes: {}, - index: null - }; - } - function v(E, D) { - let U = c.attributes, F = E.attributes, O = 0; - for(let ne in F){ - let ce = U[ne], V = F[ne]; - if (ce === void 0 || ce.attribute !== V || ce.data !== V.data) return !0; - O++; - } - return c.attributesNum !== O || c.index !== D; - } - function g(E, D) { - let U = {}, F = E.attributes, O = 0; - for(let ne in F){ - let ce = F[ne], V = {}; - V.attribute = ce, ce.data && (V.data = ce.data), U[ne] = V, O++; - } - c.attributes = U, c.attributesNum = O, c.index = D; - } - function p() { - let E = c.newAttributes; - for(let D = 0, U = E.length; D < U; D++)E[D] = 0; - } - function _(E) { - y(E, 0); - } - function y(E, D) { - let U = c.newAttributes, F = c.enabledAttributes, O = c.attributeDivisors; - U[E] = 1, F[E] === 0 && (s.enableVertexAttribArray(E), F[E] = 1), O[E] !== D && ((n.isWebGL2 ? s : e.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](E, D), O[E] = D); - } - function b() { - let E = c.newAttributes, D = c.enabledAttributes; - for(let U = 0, F = D.length; U < F; U++)D[U] !== E[U] && (s.disableVertexAttribArray(U), D[U] = 0); - } - function A(E, D, U, F, O, ne) { - n.isWebGL2 === !0 && (U === 5124 || U === 5125) ? s.vertexAttribIPointer(E, D, U, O, ne) : s.vertexAttribPointer(E, D, U, F, O, ne); - } - function L(E, D, U, F) { - if (n.isWebGL2 === !1 && (E.isInstancedMesh || F.isInstancedBufferGeometry) && e.get("ANGLE_instanced_arrays") === null) return; - p(); - let O = F.attributes, ne = U.getAttributes(), ce = D.defaultAttributeValues; - for(let V in ne){ - let W = ne[V]; - if (W.location >= 0) { - let he = O[V]; - if (he === void 0 && (V === "instanceMatrix" && E.instanceMatrix && (he = E.instanceMatrix), V === "instanceColor" && E.instanceColor && (he = E.instanceColor)), he !== void 0) { - let le = he.normalized, fe = he.itemSize, Be = t.get(he); - if (Be === void 0) continue; - let Y = Be.buffer, Ce = Be.type, ye = Be.bytesPerElement; - if (he.isInterleavedBufferAttribute) { - let ge = he.data, xe = ge.stride, Oe = he.offset; - if (ge && ge.isInstancedInterleavedBuffer) { - for(let G = 0; G < W.locationSize; G++)y(W.location + G, ge.meshPerAttribute); - E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = ge.meshPerAttribute * ge.count); - } else for(let G = 0; G < W.locationSize; G++)_(W.location + G); - s.bindBuffer(34962, Y); - for(let G = 0; G < W.locationSize; G++)A(W.location + G, fe / W.locationSize, Ce, le, xe * ye, (Oe + fe / W.locationSize * G) * ye); - } else { - if (he.isInstancedBufferAttribute) { - for(let ge = 0; ge < W.locationSize; ge++)y(W.location + ge, he.meshPerAttribute); - E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = he.meshPerAttribute * he.count); - } else for(let ge = 0; ge < W.locationSize; ge++)_(W.location + ge); - s.bindBuffer(34962, Y); - for(let ge = 0; ge < W.locationSize; ge++)A(W.location + ge, fe / W.locationSize, Ce, le, fe * ye, fe / W.locationSize * ge * ye); - } - } else if (ce !== void 0) { - let le = ce[V]; - if (le !== void 0) switch(le.length){ - case 2: - s.vertexAttrib2fv(W.location, le); - break; - case 3: - s.vertexAttrib3fv(W.location, le); - break; - case 4: - s.vertexAttrib4fv(W.location, le); - break; - default: - s.vertexAttrib1fv(W.location, le); - } - } - } - } - b(); - } - function I() { - P(); - for(let E in a){ - let D = a[E]; - for(let U in D){ - let F = D[U]; - for(let O in F)f(F[O].object), delete F[O]; - delete D[U]; - } - delete a[E]; - } - } - function k(E) { - if (a[E.id] === void 0) return; - let D = a[E.id]; - for(let U in D){ - let F = D[U]; - for(let O in F)f(F[O].object), delete F[O]; - delete D[U]; - } - delete a[E.id]; - } - function B(E) { - for(let D in a){ - let U = a[D]; - if (U[E.id] === void 0) continue; - let F = U[E.id]; - for(let O in F)f(F[O].object), delete F[O]; - delete U[E.id]; - } - } - function P() { - w(), c !== l && (c = l, d(c.object)); - } - function w() { - l.geometry = null, l.program = null, l.wireframe = !1; - } - return { - setup: h, - reset: P, - resetDefaultState: w, - dispose: I, - releaseStatesOfGeometry: k, - releaseStatesOfProgram: B, - initAttributes: p, - enableAttribute: _, - disableUnusedAttributes: b - }; -} -function qm(s, e, t, n) { - let i = n.isWebGL2, r; - function o(c) { - r = c; - } - function a(c, h) { - s.drawArrays(r, c, h), t.update(h, r, 1); - } - function l(c, h, u) { - if (u === 0) return; - let d, f; - if (i) d = s, f = "drawArraysInstanced"; - else if (d = e.get("ANGLE_instanced_arrays"), f = "drawArraysInstancedANGLE", d === null) { - console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); - return; - } - d[f](r, c, h, u), t.update(h, r, u); - } - this.setMode = o, this.render = a, this.renderInstances = l; -} -function Xm(s, e, t) { - let n; - function i() { - if (n !== void 0) return n; - if (e.has("EXT_texture_filter_anisotropic") === !0) { - let L = e.get("EXT_texture_filter_anisotropic"); - n = s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT); - } else n = 0; - return n; - } - function r(L) { - if (L === "highp") { - if (s.getShaderPrecisionFormat(35633, 36338).precision > 0 && s.getShaderPrecisionFormat(35632, 36338).precision > 0) return "highp"; - L = "mediump"; - } - return L === "mediump" && s.getShaderPrecisionFormat(35633, 36337).precision > 0 && s.getShaderPrecisionFormat(35632, 36337).precision > 0 ? "mediump" : "lowp"; - } - let o = typeof WebGL2RenderingContext < "u" && s instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext < "u" && s instanceof WebGL2ComputeRenderingContext, a = t.precision !== void 0 ? t.precision : "highp", l = r(a); - l !== a && (console.warn("THREE.WebGLRenderer:", a, "not supported, using", l, "instead."), a = l); - let c = o || e.has("WEBGL_draw_buffers"), h = t.logarithmicDepthBuffer === !0, u = s.getParameter(34930), d = s.getParameter(35660), f = s.getParameter(3379), m = s.getParameter(34076), x = s.getParameter(34921), v = s.getParameter(36347), g = s.getParameter(36348), p = s.getParameter(36349), _ = d > 0, y = o || e.has("OES_texture_float"), b = _ && y, A = o ? s.getParameter(36183) : 0; - return { - isWebGL2: o, - drawBuffers: c, - getMaxAnisotropy: i, - getMaxPrecision: r, - precision: a, - logarithmicDepthBuffer: h, - maxTextures: u, - maxVertexTextures: d, - maxTextureSize: f, - maxCubemapSize: m, - maxAttributes: x, - maxVertexUniforms: v, - maxVaryings: g, - maxFragmentUniforms: p, - vertexTextures: _, - floatFragmentTextures: y, - floatVertexTextures: b, - maxSamples: A - }; -} -function Jm(s) { - let e = this, t = null, n = 0, i = !1, r = !1, o = new Wt, a = new lt, l = { - value: null, - needsUpdate: !1 - }; - this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, d, f) { - let m = u.length !== 0 || d || n !== 0 || i; - return i = d, t = h(u, f, 0), n = u.length, m; - }, this.beginShadows = function() { - r = !0, h(null); - }, this.endShadows = function() { - r = !1, c(); - }, this.setState = function(u, d, f) { - let m = u.clippingPlanes, x = u.clipIntersection, v = u.clipShadows, g = s.get(u); - if (!i || m === null || m.length === 0 || r && !v) r ? h(null) : c(); - else { - let p = r ? 0 : n, _ = p * 4, y = g.clippingState || null; - l.value = y, y = h(m, d, _, f); - for(let b = 0; b !== _; ++b)y[b] = t[b]; - g.clippingState = y, this.numIntersection = x ? this.numPlanes : 0, this.numPlanes += p; - } - }; - function c() { - l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0; - } - function h(u, d, f, m) { - let x = u !== null ? u.length : 0, v = null; - if (x !== 0) { - if (v = l.value, m !== !0 || v === null) { - let g = f + x * 4, p = d.matrixWorldInverse; - a.getNormalMatrix(p), (v === null || v.length < g) && (v = new Float32Array(g)); - for(let _ = 0, y = f; _ !== x; ++_, y += 4)o.copy(u[_]).applyMatrix4(p, a), o.normal.toArray(v, y), v[y + 3] = o.constant; - } - l.value = v, l.needsUpdate = !0; - } - return e.numPlanes = x, e.numIntersection = 0, v; - } -} -function Ym(s) { - let e = new WeakMap; - function t(o, a) { - return a === Ds ? o.mapping = Bi : a === Fs && (o.mapping = zi), o; - } - function n(o) { - if (o && o.isTexture && o.isRenderTargetTexture === !1) { - let a = o.mapping; - if (a === Ds || a === Fs) if (e.has(o)) { - let l = e.get(o).texture; - return t(l, o.mapping); - } else { - let l = o.image; - if (l && l.height > 0) { - let c = s.getRenderTarget(), h = new js(l.height / 2); - return h.fromEquirectangularTexture(s, o), e.set(o, h), s.setRenderTarget(c), o.addEventListener("dispose", i), t(h.texture, o.mapping); - } else return null; - } - } - return o; - } - function i(o) { - let a = o.target; - a.removeEventListener("dispose", i); - let l = e.get(a); - l !== void 0 && (e.delete(a), l.dispose()); - } - function r() { - e = new WeakMap; - } - return { - get: n, - dispose: r - }; -} -var Fr = class extends Ir { - constructor(e = -1, t = 1, n = 1, i = -1, r = .1, o = 2e3){ - super(); - this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = i, this.near = r, this.far = o, this.updateProjectionMatrix(); - } - copy(e, t) { - return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; - } - setViewOffset(e, t, n, i, r, o) { - this.view === null && (this.view = { - enabled: !0, - fullWidth: 1, - fullHeight: 1, - offsetX: 0, - offsetY: 0, - width: 1, - height: 1 - }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); - } - clearViewOffset() { - this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); - } - updateProjectionMatrix() { - let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2, r = n - e, o = n + e, a = i + t, l = i - t; - if (this.view !== null && this.view.enabled) { - let c = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; - r += c * this.view.offsetX, o = r + c * this.view.width, a -= h * this.view.offsetY, l = a - h * this.view.height; - } - this.projectionMatrix.makeOrthographic(r, o, a, l, this.near, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; - } -}; -Fr.prototype.isOrthographicCamera = !0; -var Gi = class extends sn { - constructor(e){ - super(e); - this.type = "RawShaderMaterial"; - } -}; -Gi.prototype.isRawShaderMaterial = !0; -var Ei = 4, Mn = 8, Vt = Math.pow(2, Mn), sh = [ - .125, - .215, - .35, - .446, - .526, - .582 -], oh = Mn - Ei + 1 + sh.length, pi = 20, Hs = { - [Nt]: 0, - [Oi]: 1 -}, Go = new Fr, { _lodPlanes: ji , _sizeLods: Ll , _sigmas: ls } = Zm(), Rl = new ae, Vo = null, On = (1 + Math.sqrt(5)) / 2, mi = 1 / On, Pl = [ - new M(1, 1, 1), - new M(-1, 1, 1), - new M(1, 1, -1), - new M(-1, 1, -1), - new M(0, On, mi), - new M(0, On, -mi), - new M(mi, 0, On), - new M(-mi, 0, On), - new M(On, mi, 0), - new M(-On, mi, 0) -], ah = class { - constructor(e){ - this._renderer = e, this._pingPongRenderTarget = null, this._blurMaterial = $m(pi), this._equirectShader = null, this._cubemapShader = null, this._compileMaterial(this._blurMaterial); - } - fromScene(e, t = 0, n = .1, i = 100) { - Vo = this._renderer.getRenderTarget(); - let r = this._allocateTargets(); - return this._sceneToCubeUV(e, n, i, r), t > 0 && this._blur(r, 0, 0, t), this._applyPMREM(r), this._cleanup(r), r; - } - fromEquirectangular(e) { - return this._fromTexture(e); - } - fromCubemap(e) { - return this._fromTexture(e); - } - compileCubemapShader() { - this._cubemapShader === null && (this._cubemapShader = Fl(), this._compileMaterial(this._cubemapShader)); - } - compileEquirectangularShader() { - this._equirectShader === null && (this._equirectShader = Dl(), this._compileMaterial(this._equirectShader)); - } - dispose() { - this._blurMaterial.dispose(), this._cubemapShader !== null && this._cubemapShader.dispose(), this._equirectShader !== null && this._equirectShader.dispose(); - for(let e = 0; e < ji.length; e++)ji[e].dispose(); - } - _cleanup(e) { - this._pingPongRenderTarget.dispose(), this._renderer.setRenderTarget(Vo), e.scissorTest = !1, cs(e, 0, 0, e.width, e.height); - } - _fromTexture(e) { - Vo = this._renderer.getRenderTarget(); - let t = this._allocateTargets(e); - return this._textureToCubeUV(e, t), this._applyPMREM(t), this._cleanup(t), t; - } - _allocateTargets(e) { - let t = { - magFilter: tt, - minFilter: tt, - generateMipmaps: !1, - type: kn, - format: ct, - encoding: Nt, - depthBuffer: !1 - }, n = Il(t); - return n.depthBuffer = !e, this._pingPongRenderTarget = Il(t), n; - } - _compileMaterial(e) { - let t = new st(ji[0], e); - this._renderer.compile(t, Go); - } - _sceneToCubeUV(e, t, n, i) { - let a = new ut(90, 1, t, n), l = [ - 1, - -1, - 1, - 1, - 1, - 1 - ], c = [ - 1, - 1, - 1, - -1, - -1, - -1 - ], h = this._renderer, u = h.autoClear, d = h.toneMapping; - h.getClearColor(Rl), h.toneMapping = _n, h.autoClear = !1; - let f = new hn({ - name: "PMREM.Background", - side: it, - depthWrite: !1, - depthTest: !1 - }), m = new st(new wn, f), x = !1, v = e.background; - v ? v.isColor && (f.color.copy(v), e.background = null, x = !0) : (f.color.copy(Rl), x = !0); - for(let g = 0; g < 6; g++){ - let p = g % 3; - p == 0 ? (a.up.set(0, l[g], 0), a.lookAt(c[g], 0, 0)) : p == 1 ? (a.up.set(0, 0, l[g]), a.lookAt(0, c[g], 0)) : (a.up.set(0, l[g], 0), a.lookAt(0, 0, c[g])), cs(i, p * Vt, g > 2 ? Vt : 0, Vt, Vt), h.setRenderTarget(i), x && h.render(m, a), h.render(e, a); - } - m.geometry.dispose(), m.material.dispose(), h.toneMapping = d, h.autoClear = u, e.background = v; - } - _setEncoding(e, t) { - this._renderer.capabilities.isWebGL2 === !0 && t.format === ct && t.type === rn && t.encoding === Oi ? e.value = Hs[Nt] : e.value = Hs[t.encoding]; - } - _textureToCubeUV(e, t) { - let n = this._renderer, i = e.mapping === Bi || e.mapping === zi; - i ? this._cubemapShader == null && (this._cubemapShader = Fl()) : this._equirectShader == null && (this._equirectShader = Dl()); - let r = i ? this._cubemapShader : this._equirectShader, o = new st(ji[0], r), a = r.uniforms; - a.envMap.value = e, i || a.texelSize.value.set(1 / e.image.width, 1 / e.image.height), this._setEncoding(a.inputEncoding, e), cs(t, 0, 0, 3 * Vt, 2 * Vt), n.setRenderTarget(t), n.render(o, Go); - } - _applyPMREM(e) { - let t = this._renderer, n = t.autoClear; - t.autoClear = !1; - for(let i = 1; i < oh; i++){ - let r = Math.sqrt(ls[i] * ls[i] - ls[i - 1] * ls[i - 1]), o = Pl[(i - 1) % Pl.length]; - this._blur(e, i - 1, i, r, o); - } - t.autoClear = n; - } - _blur(e, t, n, i, r) { - let o = this._pingPongRenderTarget; - this._halfBlur(e, o, t, n, i, "latitudinal", r), this._halfBlur(o, e, n, n, i, "longitudinal", r); - } - _halfBlur(e, t, n, i, r, o, a) { - let l = this._renderer, c = this._blurMaterial; - o !== "latitudinal" && o !== "longitudinal" && console.error("blur direction must be either latitudinal or longitudinal!"); - let h = 3, u = new st(ji[i], c), d = c.uniforms, f = Ll[n] - 1, m = isFinite(r) ? Math.PI / (2 * f) : 2 * Math.PI / (2 * pi - 1), x = r / m, v = isFinite(r) ? 1 + Math.floor(h * x) : pi; - v > pi && console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${pi}`); - let g = [], p = 0; - for(let A = 0; A < pi; ++A){ - let L = A / x, I = Math.exp(-L * L / 2); - g.push(I), A == 0 ? p += I : A < v && (p += 2 * I); - } - for(let A = 0; A < g.length; A++)g[A] = g[A] / p; - d.envMap.value = e.texture, d.samples.value = v, d.weights.value = g, d.latitudinal.value = o === "latitudinal", a && (d.poleAxis.value = a), d.dTheta.value = m, d.mipInt.value = Mn - n; - let _ = Ll[i], y = 3 * Math.max(0, Vt - 2 * _), b = (i === 0 ? 0 : 2 * Vt) + 2 * _ * (i > Mn - Ei ? i - Mn + Ei : 0); - cs(t, y, b, 3 * _, 2 * _), l.setRenderTarget(t), l.render(u, Go); - } -}; -function Zm() { - let s = [], e = [], t = [], n = Mn; - for(let i = 0; i < oh; i++){ - let r = Math.pow(2, n); - e.push(r); - let o = 1 / r; - i > Mn - Ei ? o = sh[i - Mn + Ei - 1] : i == 0 && (o = 0), t.push(o); - let a = 1 / (r - 1), l = -a / 2, c = 1 + a / 2, h = [ - l, - l, - c, - l, - c, - c, - l, - l, - c, - c, - l, - c - ], u = 6, d = 6, f = 3, m = 2, x = 1, v = new Float32Array(f * d * u), g = new Float32Array(m * d * u), p = new Float32Array(x * d * u); - for(let y = 0; y < u; y++){ - let b = y % 3 * 2 / 3 - 1, A = y > 2 ? 0 : -1, L = [ - b, - A, - 0, - b + 2 / 3, - A, - 0, - b + 2 / 3, - A + 1, - 0, - b, - A, - 0, - b + 2 / 3, - A + 1, - 0, - b, - A + 1, - 0 - ]; - v.set(L, f * d * y), g.set(h, m * d * y); - let I = [ - y, - y, - y, - y, - y, - y - ]; - p.set(I, x * d * y); - } - let _ = new _e; - _.setAttribute("position", new Ue(v, f)), _.setAttribute("uv", new Ue(g, m)), _.setAttribute("faceIndex", new Ue(p, x)), s.push(_), n > Ei && n--; - } - return { - _lodPlanes: s, - _sizeLods: e, - _sigmas: t - }; -} -function Il(s) { - let e = new At(3 * Vt, 3 * Vt, s); - return e.texture.mapping = Pr, e.texture.name = "PMREM.cubeUv", e.scissorTest = !0, e; -} -function cs(s, e, t, n, i) { - s.viewport.set(e, t, n, i), s.scissor.set(e, t, n, i); -} -function $m(s) { - let e = new Float32Array(s), t = new M(0, 1, 0); - return new Gi({ - name: "SphericalGaussianBlur", - defines: { - n: s - }, - uniforms: { - envMap: { - value: null - }, - samples: { - value: 1 - }, - weights: { - value: e - }, - latitudinal: { - value: !1 - }, - dTheta: { - value: 0 - }, - mipInt: { - value: 0 - }, - poleAxis: { - value: t - } - }, - vertexShader: fa(), - fragmentShader: ` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - ${pa()} - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `, - blending: vn, - depthTest: !1, - depthWrite: !1 - }); -} -function Dl() { - let s = new X(1, 1); - return new Gi({ - name: "EquirectangularToCubeUV", - uniforms: { - envMap: { - value: null - }, - texelSize: { - value: s - }, - inputEncoding: { - value: Hs[Nt] - } - }, - vertexShader: fa(), - fragmentShader: ` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform vec2 texelSize; - - ${pa()} - - #include - - void main() { - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - vec2 f = fract( uv / texelSize - 0.5 ); - uv -= f * texelSize; - vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.x += texelSize.x; - vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.y += texelSize.y; - vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.x -= texelSize.x; - vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - - vec3 tm = mix( tl, tr, f.x ); - vec3 bm = mix( bl, br, f.x ); - gl_FragColor.rgb = mix( tm, bm, f.y ); - - } - `, - blending: vn, - depthTest: !1, - depthWrite: !1 - }); -} -function Fl() { - return new Gi({ - name: "CubemapToCubeUV", - uniforms: { - envMap: { - value: null - }, - inputEncoding: { - value: Hs[Nt] - } - }, - vertexShader: fa(), - fragmentShader: ` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - ${pa()} - - void main() { - - gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ); - - } - `, - blending: vn, - depthTest: !1, - depthWrite: !1 - }); -} -function fa() { - return ` - - precision mediump float; - precision mediump int; - - attribute vec3 position; - attribute vec2 uv; - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `; -} -function pa() { - return ` - - uniform int inputEncoding; - - #include - - vec4 inputTexelToLinear( vec4 value ) { - - if ( inputEncoding == 0 ) { - - return value; - - } else { - - return sRGBToLinear( value ); - - } - - } - - vec4 envMapTexelToLinear( vec4 color ) { - - return inputTexelToLinear( color ); - - } - `; -} -function jm(s) { - let e = new WeakMap, t = null; - function n(a) { - if (a && a.isTexture && a.isRenderTargetTexture === !1) { - let l = a.mapping, c = l === Ds || l === Fs, h = l === Bi || l === zi; - if (c || h) { - if (e.has(a)) return e.get(a).texture; - { - let u = a.image; - if (c && u && u.height > 0 || h && u && i(u)) { - let d = s.getRenderTarget(); - t === null && (t = new ah(s)); - let f = c ? t.fromEquirectangular(a) : t.fromCubemap(a); - return e.set(a, f), s.setRenderTarget(d), a.addEventListener("dispose", r), f.texture; - } else return null; - } - } - } - return a; - } - function i(a) { - let l = 0, c = 6; - for(let h = 0; h < c; h++)a[h] !== void 0 && l++; - return l === c; - } - function r(a) { - let l = a.target; - l.removeEventListener("dispose", r); - let c = e.get(l); - c !== void 0 && (e.delete(l), c.dispose()); - } - function o() { - e = new WeakMap, t !== null && (t.dispose(), t = null); - } - return { - get: n, - dispose: o - }; -} -function Qm(s) { - let e = {}; - function t(n) { - if (e[n] !== void 0) return e[n]; - let i; - switch(n){ - case "WEBGL_depth_texture": - i = s.getExtension("WEBGL_depth_texture") || s.getExtension("MOZ_WEBGL_depth_texture") || s.getExtension("WEBKIT_WEBGL_depth_texture"); - break; - case "EXT_texture_filter_anisotropic": - i = s.getExtension("EXT_texture_filter_anisotropic") || s.getExtension("MOZ_EXT_texture_filter_anisotropic") || s.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); - break; - case "WEBGL_compressed_texture_s3tc": - i = s.getExtension("WEBGL_compressed_texture_s3tc") || s.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); - break; - case "WEBGL_compressed_texture_pvrtc": - i = s.getExtension("WEBGL_compressed_texture_pvrtc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); - break; - default: - i = s.getExtension(n); - } - return e[n] = i, i; - } - return { - has: function(n) { - return t(n) !== null; - }, - init: function(n) { - n.isWebGL2 ? t("EXT_color_buffer_float") : (t("WEBGL_depth_texture"), t("OES_texture_float"), t("OES_texture_half_float"), t("OES_texture_half_float_linear"), t("OES_standard_derivatives"), t("OES_element_index_uint"), t("OES_vertex_array_object"), t("ANGLE_instanced_arrays")), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"); - }, - get: function(n) { - let i = t(n); - return i === null && console.warn("THREE.WebGLRenderer: " + n + " extension not supported."), i; - } - }; -} -function Km(s, e, t, n) { - let i = {}, r = new WeakMap; - function o(u) { - let d = u.target; - d.index !== null && e.remove(d.index); - for(let m in d.attributes)e.remove(d.attributes[m]); - d.removeEventListener("dispose", o), delete i[d.id]; - let f = r.get(d); - f && (e.remove(f), r.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--; - } - function a(u, d) { - return i[d.id] === !0 || (d.addEventListener("dispose", o), i[d.id] = !0, t.memory.geometries++), d; - } - function l(u) { - let d = u.attributes; - for(let m in d)e.update(d[m], 34962); - let f = u.morphAttributes; - for(let m in f){ - let x = f[m]; - for(let v = 0, g = x.length; v < g; v++)e.update(x[v], 34962); - } - } - function c(u) { - let d = [], f = u.index, m = u.attributes.position, x = 0; - if (f !== null) { - let p = f.array; - x = f.version; - for(let _ = 0, y = p.length; _ < y; _ += 3){ - let b = p[_ + 0], A = p[_ + 1], L = p[_ + 2]; - d.push(b, A, A, L, L, b); - } - } else { - let p = m.array; - x = m.version; - for(let _ = 0, y = p.length / 3 - 1; _ < y; _ += 3){ - let b = _ + 0, A = _ + 1, L = _ + 2; - d.push(b, A, A, L, L, b); - } - } - let v = new (Yc(d) > 65535 ? Zs : Ys)(d, 1); - v.version = x; - let g = r.get(u); - g && e.remove(g), r.set(u, v); - } - function h(u) { - let d = r.get(u); - if (d) { - let f = u.index; - f !== null && d.version < f.version && c(u); - } else c(u); - return r.get(u); - } - return { - get: a, - update: l, - getWireframeAttribute: h - }; -} -function eg(s, e, t, n) { - let i = n.isWebGL2, r; - function o(d) { - r = d; - } - let a, l; - function c(d) { - a = d.type, l = d.bytesPerElement; - } - function h(d, f) { - s.drawElements(r, f, a, d * l), t.update(f, r, 1); - } - function u(d, f, m) { - if (m === 0) return; - let x, v; - if (i) x = s, v = "drawElementsInstanced"; - else if (x = e.get("ANGLE_instanced_arrays"), v = "drawElementsInstancedANGLE", x === null) { - console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); - return; - } - x[v](r, f, a, d * l, m), t.update(f, r, m); - } - this.setMode = o, this.setIndex = c, this.render = h, this.renderInstances = u; -} -function tg(s) { - let e = { - geometries: 0, - textures: 0 - }, t = { - frame: 0, - calls: 0, - triangles: 0, - points: 0, - lines: 0 - }; - function n(r, o, a) { - switch(t.calls++, o){ - case 4: - t.triangles += a * (r / 3); - break; - case 1: - t.lines += a * (r / 2); - break; - case 3: - t.lines += a * (r - 1); - break; - case 2: - t.lines += a * r; - break; - case 0: - t.points += a * r; - break; - default: - console.error("THREE.WebGLInfo: Unknown draw mode:", o); - break; - } - } - function i() { - t.frame++, t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0; - } - return { - memory: e, - render: t, - programs: null, - autoReset: !0, - reset: i, - update: n - }; -} -var Qs = class extends ot { - constructor(e = null, t = 1, n = 1, i = 1){ - super(null); - this.image = { - data: e, - width: t, - height: n, - depth: i - }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; - } -}; -Qs.prototype.isDataTexture2DArray = !0; -function ng(s, e) { - return s[0] - e[0]; -} -function ig(s, e) { - return Math.abs(e[1]) - Math.abs(s[1]); -} -function Nl(s, e) { - let t = 1, n = e.isInterleavedBufferAttribute ? e.data.array : e.array; - n instanceof Int8Array ? t = 127 : n instanceof Int16Array ? t = 32767 : n instanceof Int32Array ? t = 2147483647 : console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ", n), s.divideScalar(t); -} -function rg(s, e, t) { - let n = {}, i = new Float32Array(8), r = new WeakMap, o = new M, a = []; - for(let c = 0; c < 8; c++)a[c] = [ - c, - 0 - ]; - function l(c, h, u, d) { - let f = c.morphTargetInfluences; - if (e.isWebGL2 === !0) { - let m = h.morphAttributes.position.length, x = r.get(h); - if (x === void 0 || x.count !== m) { - x !== void 0 && x.texture.dispose(); - let p = h.morphAttributes.normal !== void 0, _ = h.morphAttributes.position, y = h.morphAttributes.normal || [], b = h.attributes.position.count, A = p === !0 ? 2 : 1, L = b * A, I = 1; - L > e.maxTextureSize && (I = Math.ceil(L / e.maxTextureSize), L = e.maxTextureSize); - let k = new Float32Array(L * I * 4 * m), B = new Qs(k, L, I, m); - B.format = ct, B.type = nn, B.needsUpdate = !0; - let P = A * 4; - for(let w = 0; w < m; w++){ - let E = _[w], D = y[w], U = L * I * 4 * w; - for(let F = 0; F < E.count; F++){ - o.fromBufferAttribute(E, F), E.normalized === !0 && Nl(o, E); - let O = F * P; - k[U + O + 0] = o.x, k[U + O + 1] = o.y, k[U + O + 2] = o.z, k[U + O + 3] = 0, p === !0 && (o.fromBufferAttribute(D, F), D.normalized === !0 && Nl(o, D), k[U + O + 4] = o.x, k[U + O + 5] = o.y, k[U + O + 6] = o.z, k[U + O + 7] = 0); - } - } - x = { - count: m, - texture: B, - size: new X(L, I) - }, r.set(h, x); - } - let v = 0; - for(let p = 0; p < f.length; p++)v += f[p]; - let g = h.morphTargetsRelative ? 1 : 1 - v; - d.getUniforms().setValue(s, "morphTargetBaseInfluence", g), d.getUniforms().setValue(s, "morphTargetInfluences", f), d.getUniforms().setValue(s, "morphTargetsTexture", x.texture, t), d.getUniforms().setValue(s, "morphTargetsTextureSize", x.size); - } else { - let m = f === void 0 ? 0 : f.length, x = n[h.id]; - if (x === void 0 || x.length !== m) { - x = []; - for(let y = 0; y < m; y++)x[y] = [ - y, - 0 - ]; - n[h.id] = x; - } - for(let y = 0; y < m; y++){ - let b = x[y]; - b[0] = y, b[1] = f[y]; - } - x.sort(ig); - for(let y = 0; y < 8; y++)y < m && x[y][1] ? (a[y][0] = x[y][0], a[y][1] = x[y][1]) : (a[y][0] = Number.MAX_SAFE_INTEGER, a[y][1] = 0); - a.sort(ng); - let v = h.morphAttributes.position, g = h.morphAttributes.normal, p = 0; - for(let y = 0; y < 8; y++){ - let b = a[y], A = b[0], L = b[1]; - A !== Number.MAX_SAFE_INTEGER && L ? (v && h.getAttribute("morphTarget" + y) !== v[A] && h.setAttribute("morphTarget" + y, v[A]), g && h.getAttribute("morphNormal" + y) !== g[A] && h.setAttribute("morphNormal" + y, g[A]), i[y] = L, p += L) : (v && h.hasAttribute("morphTarget" + y) === !0 && h.deleteAttribute("morphTarget" + y), g && h.hasAttribute("morphNormal" + y) === !0 && h.deleteAttribute("morphNormal" + y), i[y] = 0); - } - let _ = h.morphTargetsRelative ? 1 : 1 - p; - d.getUniforms().setValue(s, "morphTargetBaseInfluence", _), d.getUniforms().setValue(s, "morphTargetInfluences", i); - } - } - return { - update: l - }; -} -function sg(s, e, t, n) { - let i = new WeakMap; - function r(l) { - let c = n.render.frame, h = l.geometry, u = e.get(l, h); - return i.get(u) !== c && (e.update(u), i.set(u, c)), l.isInstancedMesh && (l.hasEventListener("dispose", a) === !1 && l.addEventListener("dispose", a), t.update(l.instanceMatrix, 34962), l.instanceColor !== null && t.update(l.instanceColor, 34962)), u; - } - function o() { - i = new WeakMap; - } - function a(l) { - let c = l.target; - c.removeEventListener("dispose", a), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor); - } - return { - update: r, - dispose: o - }; -} -var ma = class extends ot { - constructor(e = null, t = 1, n = 1, i = 1){ - super(null); - this.image = { - data: e, - width: t, - height: n, - depth: i - }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; - } -}; -ma.prototype.isDataTexture3D = !0; -var lh = new ot, ch = new Qs, hh = new ma, uh = new ki, Bl = [], zl = [], Ul = new Float32Array(16), Ol = new Float32Array(9), Hl = new Float32Array(4); -function Vi(s, e, t) { - let n = s[0]; - if (n <= 0 || n > 0) return s; - let i = e * t, r = Bl[i]; - if (r === void 0 && (r = new Float32Array(i), Bl[i] = r), e !== 0) { - n.toArray(r, 0); - for(let o = 1, a = 0; o !== e; ++o)a += t, s[o].toArray(r, a); - } - return r; -} -function Mt(s, e) { - if (s.length !== e.length) return !1; - for(let t = 0, n = s.length; t < n; t++)if (s[t] !== e[t]) return !1; - return !0; -} -function _t(s, e) { - for(let t = 0, n = e.length; t < n; t++)s[t] = e[t]; -} -function Ks(s, e) { - let t = zl[e]; - t === void 0 && (t = new Int32Array(e), zl[e] = t); - for(let n = 0; n !== e; ++n)t[n] = s.allocateTextureUnit(); - return t; -} -function og(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1f(this.addr, e), t[0] = e); -} -function ag(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y) && (s.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); - else { - if (Mt(t, e)) return; - s.uniform2fv(this.addr, e), _t(t, e); - } -} -function lg(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (s.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); - else if (e.r !== void 0) (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (s.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b); - else { - if (Mt(t, e)) return; - s.uniform3fv(this.addr, e), _t(t, e); - } -} -function cg(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (s.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); - else { - if (Mt(t, e)) return; - s.uniform4fv(this.addr, e), _t(t, e); - } -} -function hg(s, e) { - let t = this.cache, n = e.elements; - if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix2fv(this.addr, !1, e), _t(t, e); - } else { - if (Mt(t, n)) return; - Hl.set(n), s.uniformMatrix2fv(this.addr, !1, Hl), _t(t, n); - } -} -function ug(s, e) { - let t = this.cache, n = e.elements; - if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix3fv(this.addr, !1, e), _t(t, e); - } else { - if (Mt(t, n)) return; - Ol.set(n), s.uniformMatrix3fv(this.addr, !1, Ol), _t(t, n); - } -} -function dg(s, e) { - let t = this.cache, n = e.elements; - if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix4fv(this.addr, !1, e), _t(t, e); - } else { - if (Mt(t, n)) return; - Ul.set(n), s.uniformMatrix4fv(this.addr, !1, Ul), _t(t, n); - } -} -function fg(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1i(this.addr, e), t[0] = e); -} -function pg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform2iv(this.addr, e), _t(t, e)); -} -function mg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform3iv(this.addr, e), _t(t, e)); -} -function gg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform4iv(this.addr, e), _t(t, e)); -} -function xg(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1ui(this.addr, e), t[0] = e); -} -function yg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform2uiv(this.addr, e), _t(t, e)); -} -function vg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform3uiv(this.addr, e), _t(t, e)); -} -function _g(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform4uiv(this.addr, e), _t(t, e)); -} -function Mg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTexture2D(e || lh, i); -} -function bg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture3D(e || hh, i); -} -function wg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTextureCube(e || uh, i); -} -function Sg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture2DArray(e || ch, i); -} -function Tg(s) { - switch(s){ - case 5126: - return og; - case 35664: - return ag; - case 35665: - return lg; - case 35666: - return cg; - case 35674: - return hg; - case 35675: - return ug; - case 35676: - return dg; - case 5124: - case 35670: - return fg; - case 35667: - case 35671: - return pg; - case 35668: - case 35672: - return mg; - case 35669: - case 35673: - return gg; - case 5125: - return xg; - case 36294: - return yg; - case 36295: - return vg; - case 36296: - return _g; - case 35678: - case 36198: - case 36298: - case 36306: - case 35682: - return Mg; - case 35679: - case 36299: - case 36307: - return bg; - case 35680: - case 36300: - case 36308: - case 36293: - return wg; - case 36289: - case 36303: - case 36311: - case 36292: - return Sg; - } -} -function Eg(s, e) { - s.uniform1fv(this.addr, e); -} -function Ag(s, e) { - let t = Vi(e, this.size, 2); - s.uniform2fv(this.addr, t); -} -function Cg(s, e) { - let t = Vi(e, this.size, 3); - s.uniform3fv(this.addr, t); -} -function Lg(s, e) { - let t = Vi(e, this.size, 4); - s.uniform4fv(this.addr, t); -} -function Rg(s, e) { - let t = Vi(e, this.size, 4); - s.uniformMatrix2fv(this.addr, !1, t); -} -function Pg(s, e) { - let t = Vi(e, this.size, 9); - s.uniformMatrix3fv(this.addr, !1, t); -} -function Ig(s, e) { - let t = Vi(e, this.size, 16); - s.uniformMatrix4fv(this.addr, !1, t); -} -function Dg(s, e) { - s.uniform1iv(this.addr, e); -} -function Fg(s, e) { - s.uniform2iv(this.addr, e); -} -function Ng(s, e) { - s.uniform3iv(this.addr, e); -} -function Bg(s, e) { - s.uniform4iv(this.addr, e); -} -function zg(s, e) { - s.uniform1uiv(this.addr, e); -} -function Ug(s, e) { - s.uniform2uiv(this.addr, e); -} -function Og(s, e) { - s.uniform3uiv(this.addr, e); -} -function Hg(s, e) { - s.uniform4uiv(this.addr, e); -} -function kg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.safeSetTexture2D(e[r] || lh, i[r]); -} -function Gg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.setTexture3D(e[r] || hh, i[r]); -} -function Vg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.safeSetTextureCube(e[r] || uh, i[r]); -} -function Wg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.setTexture2DArray(e[r] || ch, i[r]); -} -function qg(s) { - switch(s){ - case 5126: - return Eg; - case 35664: - return Ag; - case 35665: - return Cg; - case 35666: - return Lg; - case 35674: - return Rg; - case 35675: - return Pg; - case 35676: - return Ig; - case 5124: - case 35670: - return Dg; - case 35667: - case 35671: - return Fg; - case 35668: - case 35672: - return Ng; - case 35669: - case 35673: - return Bg; - case 5125: - return zg; - case 36294: - return Ug; - case 36295: - return Og; - case 36296: - return Hg; - case 35678: - case 36198: - case 36298: - case 36306: - case 35682: - return kg; - case 35679: - case 36299: - case 36307: - return Gg; - case 35680: - case 36300: - case 36308: - case 36293: - return Vg; - case 36289: - case 36303: - case 36311: - case 36292: - return Wg; - } -} -function Xg(s, e, t) { - this.id = s, this.addr = t, this.cache = [], this.setValue = Tg(e.type); -} -function dh(s, e, t) { - this.id = s, this.addr = t, this.cache = [], this.size = e.size, this.setValue = qg(e.type); -} -dh.prototype.updateCache = function(s) { - let e = this.cache; - s instanceof Float32Array && e.length !== s.length && (this.cache = new Float32Array(s.length)), _t(e, s); -}; -function fh(s) { - this.id = s, this.seq = [], this.map = {}; -} -fh.prototype.setValue = function(s, e, t) { - let n = this.seq; - for(let i = 0, r = n.length; i !== r; ++i){ - let o = n[i]; - o.setValue(s, e[o.id], t); - } -}; -var Wo = /(\w+)(\])?(\[|\.)?/g; -function kl(s, e) { - s.seq.push(e), s.map[e.id] = e; -} -function Jg(s, e, t) { - let n = s.name, i = n.length; - for(Wo.lastIndex = 0;;){ - let r = Wo.exec(n), o = Wo.lastIndex, a = r[1], l = r[2] === "]", c = r[3]; - if (l && (a = a | 0), c === void 0 || c === "[" && o + 2 === i) { - kl(t, c === void 0 ? new Xg(a, s, e) : new dh(a, s, e)); - break; - } else { - let u = t.map[a]; - u === void 0 && (u = new fh(a), kl(t, u)), t = u; - } - } -} -function bn(s, e) { - this.seq = [], this.map = {}; - let t = s.getProgramParameter(e, 35718); - for(let n = 0; n < t; ++n){ - let i = s.getActiveUniform(e, n), r = s.getUniformLocation(e, i.name); - Jg(i, r, this); - } -} -bn.prototype.setValue = function(s, e, t, n) { - let i = this.map[e]; - i !== void 0 && i.setValue(s, t, n); -}; -bn.prototype.setOptional = function(s, e, t) { - let n = e[t]; - n !== void 0 && this.setValue(s, t, n); -}; -bn.upload = function(s, e, t, n) { - for(let i = 0, r = e.length; i !== r; ++i){ - let o = e[i], a = t[o.id]; - a.needsUpdate !== !1 && o.setValue(s, a.value, n); - } -}; -bn.seqWithValue = function(s, e) { - let t = []; - for(let n = 0, i = s.length; n !== i; ++n){ - let r = s[n]; - r.id in e && t.push(r); - } - return t; -}; -function Gl(s, e, t) { - let n = s.createShader(e); - return s.shaderSource(n, t), s.compileShader(n), n; -} -var Yg = 0; -function Zg(s) { - let e = s.split(` -`); - for(let t = 0; t < e.length; t++)e[t] = t + 1 + ": " + e[t]; - return e.join(` -`); -} -function ph(s) { - switch(s){ - case Nt: - return [ - "Linear", - "( value )" - ]; - case Oi: - return [ - "sRGB", - "( value )" - ]; - default: - return console.warn("THREE.WebGLProgram: Unsupported encoding:", s), [ - "Linear", - "( value )" - ]; - } -} -function Vl(s, e, t) { - let n = s.getShaderParameter(e, 35713), i = s.getShaderInfoLog(e).trim(); - return n && i === "" ? "" : t.toUpperCase() + ` - -` + i + ` - -` + Zg(s.getShaderSource(e)); -} -function Dn(s, e) { - let t = ph(e); - return "vec4 " + s + "( vec4 value ) { return " + t[0] + "ToLinear" + t[1] + "; }"; -} -function $g(s, e) { - let t = ph(e); - return "vec4 " + s + "( vec4 value ) { return LinearTo" + t[0] + t[1] + "; }"; -} -function jg(s, e) { - let t; - switch(e){ - case Nu: - t = "Linear"; - break; - case Bu: - t = "Reinhard"; - break; - case zu: - t = "OptimizedCineon"; - break; - case Uu: - t = "ACESFilmic"; - break; - case Ou: - t = "Custom"; - break; - default: - console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear"; - } - return "vec3 " + s + "( vec3 color ) { return " + t + "ToneMapping( color ); }"; -} -function Qg(s) { - return [ - s.extensionDerivatives || s.envMapCubeUV || s.bumpMap || s.tangentSpaceNormalMap || s.clearcoatNormalMap || s.flatShading || s.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "", - (s.extensionFragDepth || s.logarithmicDepthBuffer) && s.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "", - s.extensionDrawBuffers && s.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "", - (s.extensionShaderTextureLOD || s.envMap || s.transmission) && s.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : "" - ].filter(rr).join(` -`); -} -function Kg(s) { - let e = []; - for(let t in s){ - let n = s[t]; - n !== !1 && e.push("#define " + t + " " + n); - } - return e.join(` -`); -} -function ex(s, e) { - let t = {}, n = s.getProgramParameter(e, 35721); - for(let i = 0; i < n; i++){ - let r = s.getActiveAttrib(e, i), o = r.name, a = 1; - r.type === 35674 && (a = 2), r.type === 35675 && (a = 3), r.type === 35676 && (a = 4), t[o] = { - type: r.type, - location: s.getAttribLocation(e, o), - locationSize: a - }; - } - return t; -} -function rr(s) { - return s !== ""; -} -function Wl(s, e) { - return s.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows); -} -function ql(s, e) { - return s.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection); -} -var tx = /^[ \t]*#include +<([\w\d./]+)>/gm; -function ra(s) { - return s.replace(tx, nx); -} -function nx(s, e) { - let t = Fe[e]; - if (t === void 0) throw new Error("Can not resolve #include <" + e + ">"); - return ra(t); -} -var ix = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g, rx = /#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 Xl(s) { - return s.replace(rx, mh).replace(ix, sx); -} -function sx(s, e, t, n) { - return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."), mh(s, e, t, n); -} -function mh(s, e, t, n) { - let i = ""; - for(let r = parseInt(e); r < parseInt(t); r++)i += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); - return i; -} -function Jl(s) { - let e = "precision " + s.precision + ` float; -precision ` + s.precision + " int;"; - return s.precision === "highp" ? e += ` -#define HIGH_PRECISION` : s.precision === "mediump" ? e += ` -#define MEDIUM_PRECISION` : s.precision === "lowp" && (e += ` -#define LOW_PRECISION`), e; -} -function ox(s) { - let e = "SHADOWMAP_TYPE_BASIC"; - return s.shadowMapType === Hc ? e = "SHADOWMAP_TYPE_PCF" : s.shadowMapType === fu ? e = "SHADOWMAP_TYPE_PCF_SOFT" : s.shadowMapType === ir && (e = "SHADOWMAP_TYPE_VSM"), e; -} -function ax(s) { - let e = "ENVMAP_TYPE_CUBE"; - if (s.envMap) switch(s.envMapMode){ - case Bi: - case zi: - e = "ENVMAP_TYPE_CUBE"; - break; - case Pr: - case Ws: - e = "ENVMAP_TYPE_CUBE_UV"; - break; - } - return e; -} -function lx(s) { - let e = "ENVMAP_MODE_REFLECTION"; - if (s.envMap) switch(s.envMapMode){ - case zi: - case Ws: - e = "ENVMAP_MODE_REFRACTION"; - break; - } - return e; -} -function cx(s) { - let e = "ENVMAP_BLENDING_NONE"; - if (s.envMap) switch(s.combine){ - case Vs: - e = "ENVMAP_BLENDING_MULTIPLY"; - break; - case Du: - e = "ENVMAP_BLENDING_MIX"; - break; - case Fu: - e = "ENVMAP_BLENDING_ADD"; - break; - } - return e; -} -function hx(s, e, t, n) { - let i = s.getContext(), r = t.defines, o = t.vertexShader, a = t.fragmentShader, l = ox(t), c = ax(t), h = lx(t), u = cx(t), d = t.isWebGL2 ? "" : Qg(t), f = Kg(r), m = i.createProgram(), x, v, g = t.glslVersion ? "#version " + t.glslVersion + ` -` : ""; - t.isRawShaderMaterial ? (x = [ - f - ].filter(rr).join(` -`), x.length > 0 && (x += ` -`), v = [ - d, - f - ].filter(rr).join(` -`), v.length > 0 && (v += ` -`)) : (x = [ - Jl(t), - "#define SHADER_NAME " + t.shaderName, - f, - t.instancing ? "#define USE_INSTANCING" : "", - t.instancingColor ? "#define USE_INSTANCING_COLOR" : "", - t.supportsVertexTextures ? "#define VERTEX_TEXTURES" : "", - "#define MAX_BONES " + t.maxBones, - t.useFog && t.fog ? "#define USE_FOG" : "", - t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", - t.map ? "#define USE_MAP" : "", - t.envMap ? "#define USE_ENVMAP" : "", - t.envMap ? "#define " + h : "", - t.lightMap ? "#define USE_LIGHTMAP" : "", - t.aoMap ? "#define USE_AOMAP" : "", - t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", - t.bumpMap ? "#define USE_BUMPMAP" : "", - t.normalMap ? "#define USE_NORMALMAP" : "", - t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", - t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", - t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", - t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", - t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", - t.displacementMap && t.supportsVertexTextures ? "#define USE_DISPLACEMENTMAP" : "", - t.specularMap ? "#define USE_SPECULARMAP" : "", - t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", - t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", - t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", - t.metalnessMap ? "#define USE_METALNESSMAP" : "", - t.alphaMap ? "#define USE_ALPHAMAP" : "", - t.transmission ? "#define USE_TRANSMISSION" : "", - t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", - t.thicknessMap ? "#define USE_THICKNESSMAP" : "", - t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", - t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", - t.vertexTangents ? "#define USE_TANGENT" : "", - t.vertexColors ? "#define USE_COLOR" : "", - t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", - t.vertexUvs ? "#define USE_UV" : "", - t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", - t.flatShading ? "#define FLAT_SHADED" : "", - t.skinning ? "#define USE_SKINNING" : "", - t.useVertexTexture ? "#define BONE_TEXTURE" : "", - t.morphTargets ? "#define USE_MORPHTARGETS" : "", - t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", - t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "", - t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "", - t.doubleSided ? "#define DOUBLE_SIDED" : "", - t.flipSided ? "#define FLIP_SIDED" : "", - t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", - t.shadowMapEnabled ? "#define " + l : "", - t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", - t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", - t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", - "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", - "attribute vec3 position;", - "attribute vec3 normal;", - "attribute vec2 uv;", - "#ifdef USE_TANGENT", - " attribute vec4 tangent;", - "#endif", - "#if defined( USE_COLOR_ALPHA )", - " attribute vec4 color;", - "#elif defined( USE_COLOR )", - " attribute vec3 color;", - "#endif", - "#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )", - " attribute vec3 morphTarget0;", - " attribute vec3 morphTarget1;", - " attribute vec3 morphTarget2;", - " attribute vec3 morphTarget3;", - " #ifdef USE_MORPHNORMALS", - " attribute vec3 morphNormal0;", - " attribute vec3 morphNormal1;", - " attribute vec3 morphNormal2;", - " attribute vec3 morphNormal3;", - " #else", - " attribute vec3 morphTarget4;", - " attribute vec3 morphTarget5;", - " attribute vec3 morphTarget6;", - " attribute vec3 morphTarget7;", - " #endif", - "#endif", - "#ifdef USE_SKINNING", - " attribute vec4 skinIndex;", - " attribute vec4 skinWeight;", - "#endif", - ` -` - ].filter(rr).join(` -`), v = [ - d, - Jl(t), - "#define SHADER_NAME " + t.shaderName, - f, - t.useFog && t.fog ? "#define USE_FOG" : "", - t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", - t.map ? "#define USE_MAP" : "", - t.matcap ? "#define USE_MATCAP" : "", - t.envMap ? "#define USE_ENVMAP" : "", - t.envMap ? "#define " + c : "", - t.envMap ? "#define " + h : "", - t.envMap ? "#define " + u : "", - t.lightMap ? "#define USE_LIGHTMAP" : "", - t.aoMap ? "#define USE_AOMAP" : "", - t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", - t.bumpMap ? "#define USE_BUMPMAP" : "", - t.normalMap ? "#define USE_NORMALMAP" : "", - t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", - t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", - t.clearcoat ? "#define USE_CLEARCOAT" : "", - t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", - t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", - t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", - t.specularMap ? "#define USE_SPECULARMAP" : "", - t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", - t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", - t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", - t.metalnessMap ? "#define USE_METALNESSMAP" : "", - t.alphaMap ? "#define USE_ALPHAMAP" : "", - t.alphaTest ? "#define USE_ALPHATEST" : "", - t.sheen ? "#define USE_SHEEN" : "", - t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", - t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", - t.transmission ? "#define USE_TRANSMISSION" : "", - t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", - t.thicknessMap ? "#define USE_THICKNESSMAP" : "", - t.vertexTangents ? "#define USE_TANGENT" : "", - t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "", - t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", - t.vertexUvs ? "#define USE_UV" : "", - t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", - t.gradientMap ? "#define USE_GRADIENTMAP" : "", - t.flatShading ? "#define FLAT_SHADED" : "", - t.doubleSided ? "#define DOUBLE_SIDED" : "", - t.flipSided ? "#define FLIP_SIDED" : "", - t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", - t.shadowMapEnabled ? "#define " + l : "", - t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", - t.physicallyCorrectLights ? "#define PHYSICALLY_CORRECT_LIGHTS" : "", - t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", - t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", - (t.extensionShaderTextureLOD || t.envMap) && t.rendererExtensionShaderTextureLod ? "#define TEXTURE_LOD_EXT" : "", - "uniform mat4 viewMatrix;", - "uniform vec3 cameraPosition;", - "uniform bool isOrthographic;", - t.toneMapping !== _n ? "#define TONE_MAPPING" : "", - t.toneMapping !== _n ? Fe.tonemapping_pars_fragment : "", - t.toneMapping !== _n ? jg("toneMapping", t.toneMapping) : "", - t.dithering ? "#define DITHERING" : "", - t.format === Gn ? "#define OPAQUE" : "", - Fe.encodings_pars_fragment, - t.map ? Dn("mapTexelToLinear", t.mapEncoding) : "", - t.matcap ? Dn("matcapTexelToLinear", t.matcapEncoding) : "", - t.envMap ? Dn("envMapTexelToLinear", t.envMapEncoding) : "", - t.emissiveMap ? Dn("emissiveMapTexelToLinear", t.emissiveMapEncoding) : "", - t.specularColorMap ? Dn("specularColorMapTexelToLinear", t.specularColorMapEncoding) : "", - t.sheenColorMap ? Dn("sheenColorMapTexelToLinear", t.sheenColorMapEncoding) : "", - t.lightMap ? Dn("lightMapTexelToLinear", t.lightMapEncoding) : "", - $g("linearToOutputTexel", t.outputEncoding), - t.depthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "", - ` -` - ].filter(rr).join(` -`)), o = ra(o), o = Wl(o, t), o = ql(o, t), a = ra(a), a = Wl(a, t), a = ql(a, t), o = Xl(o), a = Xl(a), t.isWebGL2 && t.isRawShaderMaterial !== !0 && (g = `#version 300 es -`, x = [ - "precision mediump sampler2DArray;", - "#define attribute in", - "#define varying out", - "#define texture2D texture" - ].join(` -`) + ` -` + x, v = [ - "#define varying in", - t.glslVersion === xl ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", - t.glslVersion === xl ? "" : "#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(` -`) + ` -` + v); - let p = g + x + o, _ = g + v + a, y = Gl(i, 35633, p), b = Gl(i, 35632, _); - if (i.attachShader(m, y), i.attachShader(m, b), t.index0AttributeName !== void 0 ? i.bindAttribLocation(m, 0, t.index0AttributeName) : t.morphTargets === !0 && i.bindAttribLocation(m, 0, "position"), i.linkProgram(m), s.debug.checkShaderErrors) { - let I = i.getProgramInfoLog(m).trim(), k = i.getShaderInfoLog(y).trim(), B = i.getShaderInfoLog(b).trim(), P = !0, w = !0; - if (i.getProgramParameter(m, 35714) === !1) { - P = !1; - let E = Vl(i, y, "vertex"), D = Vl(i, b, "fragment"); - console.error("THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(m, 35715) + ` - -Program Info Log: ` + I + ` -` + E + ` -` + D); - } else I !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", I) : (k === "" || B === "") && (w = !1); - w && (this.diagnostics = { - runnable: P, - programLog: I, - vertexShader: { - log: k, - prefix: x - }, - fragmentShader: { - log: B, - prefix: v - } - }); - } - i.deleteShader(y), i.deleteShader(b); - let A; - this.getUniforms = function() { - return A === void 0 && (A = new bn(i, m)), A; - }; - let L; - return this.getAttributes = function() { - return L === void 0 && (L = ex(i, m)), L; - }, this.destroy = function() { - n.releaseStatesOfProgram(this), i.deleteProgram(m), this.program = void 0; - }, this.name = t.shaderName, this.id = Yg++, this.cacheKey = e, this.usedTimes = 1, this.program = m, this.vertexShader = y, this.fragmentShader = b, this; -} -var ux = 0, gh = class { - constructor(){ - this.shaderCache = new Map, this.materialCache = new Map; - } - update(e) { - let t = e.vertexShader, n = e.fragmentShader, i = this._getShaderStage(t), r = this._getShaderStage(n), o = this._getShaderCacheForMaterial(e); - return o.has(i) === !1 && (o.add(i), i.usedTimes++), o.has(r) === !1 && (o.add(r), r.usedTimes++), this; - } - remove(e) { - let t = this.materialCache.get(e); - for (let n of t)n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n); - return this.materialCache.delete(e), this; - } - getVertexShaderID(e) { - return this._getShaderStage(e.vertexShader).id; - } - getFragmentShaderID(e) { - return this._getShaderStage(e.fragmentShader).id; - } - dispose() { - this.shaderCache.clear(), this.materialCache.clear(); - } - _getShaderCacheForMaterial(e) { - let t = this.materialCache; - return t.has(e) === !1 && t.set(e, new Set), t.get(e); - } - _getShaderStage(e) { - let t = this.shaderCache; - if (t.has(e) === !1) { - let n = new xh; - t.set(e, n); - } - return t.get(e); - } -}, xh = class { - constructor(){ - this.id = ux++, this.usedTimes = 0; - } -}; -function dx(s, e, t, n, i, r, o) { - let a = new Js, l = new gh, c = [], h = i.isWebGL2, u = i.logarithmicDepthBuffer, d = i.floatVertexTextures, f = i.maxVertexUniforms, m = i.vertexTextures, x = i.precision, v = { - MeshDepthMaterial: "depth", - MeshDistanceMaterial: "distanceRGBA", - 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(w) { - let D = w.skeleton.bones; - if (d) return 1024; - { - let F = Math.floor((f - 20) / 4), O = Math.min(F, D.length); - return O < D.length ? (console.warn("THREE.WebGLRenderer: Skeleton has " + D.length + " bones. This GPU supports " + O + "."), 0) : O; - } - } - function p(w) { - let E; - return w && w.isTexture ? E = w.encoding : w && w.isWebGLRenderTarget ? (console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."), E = w.texture.encoding) : E = Nt, h && w && w.isTexture && w.format === ct && w.type === rn && w.encoding === Oi && (E = Nt), E; - } - function _(w, E, D, U, F) { - let O = U.fog, ne = w.isMeshStandardMaterial ? U.environment : null, ce = (w.isMeshStandardMaterial ? t : e).get(w.envMap || ne), V = v[w.type], W = F.isSkinnedMesh ? g(F) : 0; - w.precision !== null && (x = i.getMaxPrecision(w.precision), x !== w.precision && console.warn("THREE.WebGLProgram.getParameters:", w.precision, "not supported, using", x, "instead.")); - let he, le, fe, Be; - if (V) { - let xe = qt[V]; - he = xe.vertexShader, le = xe.fragmentShader; - } else he = w.vertexShader, le = w.fragmentShader, l.update(w), fe = l.getVertexShaderID(w), Be = l.getFragmentShaderID(w); - let Y = s.getRenderTarget(), Ce = w.alphaTest > 0, ye = w.clearcoat > 0; - return { - isWebGL2: h, - shaderID: V, - shaderName: w.type, - vertexShader: he, - fragmentShader: le, - defines: w.defines, - customVertexShaderID: fe, - customFragmentShaderID: Be, - isRawShaderMaterial: w.isRawShaderMaterial === !0, - glslVersion: w.glslVersion, - precision: x, - instancing: F.isInstancedMesh === !0, - instancingColor: F.isInstancedMesh === !0 && F.instanceColor !== null, - supportsVertexTextures: m, - outputEncoding: Y !== null ? p(Y.texture) : s.outputEncoding, - map: !!w.map, - mapEncoding: p(w.map), - matcap: !!w.matcap, - matcapEncoding: p(w.matcap), - envMap: !!ce, - envMapMode: ce && ce.mapping, - envMapEncoding: p(ce), - envMapCubeUV: !!ce && (ce.mapping === Pr || ce.mapping === Ws), - lightMap: !!w.lightMap, - lightMapEncoding: p(w.lightMap), - aoMap: !!w.aoMap, - emissiveMap: !!w.emissiveMap, - emissiveMapEncoding: p(w.emissiveMap), - bumpMap: !!w.bumpMap, - normalMap: !!w.normalMap, - objectSpaceNormalMap: w.normalMapType === zd, - tangentSpaceNormalMap: w.normalMapType === Hi, - clearcoat: ye, - clearcoatMap: ye && !!w.clearcoatMap, - clearcoatRoughnessMap: ye && !!w.clearcoatRoughnessMap, - clearcoatNormalMap: ye && !!w.clearcoatNormalMap, - displacementMap: !!w.displacementMap, - roughnessMap: !!w.roughnessMap, - metalnessMap: !!w.metalnessMap, - specularMap: !!w.specularMap, - specularIntensityMap: !!w.specularIntensityMap, - specularColorMap: !!w.specularColorMap, - specularColorMapEncoding: p(w.specularColorMap), - alphaMap: !!w.alphaMap, - alphaTest: Ce, - gradientMap: !!w.gradientMap, - sheen: w.sheen > 0, - sheenColorMap: !!w.sheenColorMap, - sheenColorMapEncoding: p(w.sheenColorMap), - sheenRoughnessMap: !!w.sheenRoughnessMap, - transmission: w.transmission > 0, - transmissionMap: !!w.transmissionMap, - thicknessMap: !!w.thicknessMap, - combine: w.combine, - vertexTangents: !!w.normalMap && !!F.geometry && !!F.geometry.attributes.tangent, - vertexColors: w.vertexColors, - vertexAlphas: w.vertexColors === !0 && !!F.geometry && !!F.geometry.attributes.color && F.geometry.attributes.color.itemSize === 4, - vertexUvs: !!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatMap || !!w.clearcoatRoughnessMap || !!w.clearcoatNormalMap || !!w.displacementMap || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || !!w.sheenColorMap || !!w.sheenRoughnessMap, - uvsVertexOnly: !(!!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatNormalMap || w.transmission > 0 || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || w.sheen > 0 || !!w.sheenColorMap || !!w.sheenRoughnessMap) && !!w.displacementMap, - fog: !!O, - useFog: w.fog, - fogExp2: O && O.isFogExp2, - flatShading: !!w.flatShading, - sizeAttenuation: w.sizeAttenuation, - logarithmicDepthBuffer: u, - skinning: F.isSkinnedMesh === !0 && W > 0, - maxBones: W, - useVertexTexture: d, - morphTargets: !!F.geometry && !!F.geometry.morphAttributes.position, - morphNormals: !!F.geometry && !!F.geometry.morphAttributes.normal, - morphTargetsCount: !!F.geometry && !!F.geometry.morphAttributes.position ? F.geometry.morphAttributes.position.length : 0, - numDirLights: E.directional.length, - numPointLights: E.point.length, - numSpotLights: E.spot.length, - numRectAreaLights: E.rectArea.length, - numHemiLights: E.hemi.length, - numDirLightShadows: E.directionalShadowMap.length, - numPointLightShadows: E.pointShadowMap.length, - numSpotLightShadows: E.spotShadowMap.length, - numClippingPlanes: o.numPlanes, - numClipIntersection: o.numIntersection, - format: w.format, - dithering: w.dithering, - shadowMapEnabled: s.shadowMap.enabled && D.length > 0, - shadowMapType: s.shadowMap.type, - toneMapping: w.toneMapped ? s.toneMapping : _n, - physicallyCorrectLights: s.physicallyCorrectLights, - premultipliedAlpha: w.premultipliedAlpha, - doubleSided: w.side === Ci, - flipSided: w.side === it, - depthPacking: w.depthPacking !== void 0 ? w.depthPacking : !1, - index0AttributeName: w.index0AttributeName, - extensionDerivatives: w.extensions && w.extensions.derivatives, - extensionFragDepth: w.extensions && w.extensions.fragDepth, - extensionDrawBuffers: w.extensions && w.extensions.drawBuffers, - extensionShaderTextureLOD: w.extensions && w.extensions.shaderTextureLOD, - rendererExtensionFragDepth: h || n.has("EXT_frag_depth"), - rendererExtensionDrawBuffers: h || n.has("WEBGL_draw_buffers"), - rendererExtensionShaderTextureLod: h || n.has("EXT_shader_texture_lod"), - customProgramCacheKey: w.customProgramCacheKey() - }; - } - function y(w) { - let E = []; - if (w.shaderID ? E.push(w.shaderID) : (E.push(w.customVertexShaderID), E.push(w.customFragmentShaderID)), w.defines !== void 0) for(let D in w.defines)E.push(D), E.push(w.defines[D]); - return w.isRawShaderMaterial === !1 && (b(E, w), A(E, w), E.push(s.outputEncoding)), E.push(w.customProgramCacheKey), E.join(); - } - function b(w, E) { - w.push(E.precision), w.push(E.outputEncoding), w.push(E.mapEncoding), w.push(E.matcapEncoding), w.push(E.envMapMode), w.push(E.envMapEncoding), w.push(E.lightMapEncoding), w.push(E.emissiveMapEncoding), w.push(E.combine), w.push(E.vertexUvs), w.push(E.fogExp2), w.push(E.sizeAttenuation), w.push(E.maxBones), w.push(E.morphTargetsCount), w.push(E.numDirLights), w.push(E.numPointLights), w.push(E.numSpotLights), w.push(E.numHemiLights), w.push(E.numRectAreaLights), w.push(E.numDirLightShadows), w.push(E.numPointLightShadows), w.push(E.numSpotLightShadows), w.push(E.shadowMapType), w.push(E.toneMapping), w.push(E.numClippingPlanes), w.push(E.numClipIntersection), w.push(E.format), w.push(E.specularColorMapEncoding), w.push(E.sheenColorMapEncoding); - } - function A(w, E) { - a.disableAll(), E.isWebGL2 && a.enable(0), E.supportsVertexTextures && a.enable(1), E.instancing && a.enable(2), E.instancingColor && a.enable(3), E.map && a.enable(4), E.matcap && a.enable(5), E.envMap && a.enable(6), E.envMapCubeUV && a.enable(7), E.lightMap && a.enable(8), E.aoMap && a.enable(9), E.emissiveMap && a.enable(10), E.bumpMap && a.enable(11), E.normalMap && a.enable(12), E.objectSpaceNormalMap && a.enable(13), E.tangentSpaceNormalMap && a.enable(14), E.clearcoat && a.enable(15), E.clearcoatMap && a.enable(16), E.clearcoatRoughnessMap && a.enable(17), E.clearcoatNormalMap && a.enable(18), E.displacementMap && a.enable(19), E.specularMap && a.enable(20), E.roughnessMap && a.enable(21), E.metalnessMap && a.enable(22), E.gradientMap && a.enable(23), E.alphaMap && a.enable(24), E.alphaTest && a.enable(25), E.vertexColors && a.enable(26), E.vertexAlphas && a.enable(27), E.vertexUvs && a.enable(28), E.vertexTangents && a.enable(29), E.uvsVertexOnly && a.enable(30), E.fog && a.enable(31), w.push(a.mask), a.disableAll(), E.useFog && a.enable(0), E.flatShading && a.enable(1), E.logarithmicDepthBuffer && a.enable(2), E.skinning && a.enable(3), E.useVertexTexture && a.enable(4), E.morphTargets && a.enable(5), E.morphNormals && a.enable(6), E.premultipliedAlpha && a.enable(7), E.shadowMapEnabled && a.enable(8), E.physicallyCorrectLights && a.enable(9), E.doubleSided && a.enable(10), E.flipSided && a.enable(11), E.depthPacking && a.enable(12), E.dithering && a.enable(13), E.specularIntensityMap && a.enable(14), E.specularColorMap && a.enable(15), E.transmission && a.enable(16), E.transmissionMap && a.enable(17), E.thicknessMap && a.enable(18), E.sheen && a.enable(19), E.sheenColorMap && a.enable(20), E.sheenRoughnessMap && a.enable(21), w.push(a.mask); - } - function L(w) { - let E = v[w.type], D; - if (E) { - let U = qt[E]; - D = uf.clone(U.uniforms); - } else D = w.uniforms; - return D; - } - function I(w, E) { - let D; - for(let U = 0, F = c.length; U < F; U++){ - let O = c[U]; - if (O.cacheKey === E) { - D = O, ++D.usedTimes; - break; - } - } - return D === void 0 && (D = new hx(s, E, w, r), c.push(D)), D; - } - function k(w) { - if (--w.usedTimes === 0) { - let E = c.indexOf(w); - c[E] = c[c.length - 1], c.pop(), w.destroy(); - } - } - function B(w) { - l.remove(w); - } - function P() { - l.dispose(); - } - return { - getParameters: _, - getProgramCacheKey: y, - getUniforms: L, - acquireProgram: I, - releaseProgram: k, - releaseShaderCache: B, - programs: c, - dispose: P - }; -} -function fx() { - let s = new WeakMap; - function e(r) { - let o = s.get(r); - return o === void 0 && (o = {}, s.set(r, o)), o; - } - function t(r) { - s.delete(r); - } - function n(r, o, a) { - s.get(r)[o] = a; - } - function i() { - s = new WeakMap; - } - return { - get: e, - remove: t, - update: n, - dispose: i - }; -} -function px(s, e) { - return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.material.id !== e.material.id ? s.material.id - e.material.id : s.z !== e.z ? s.z - e.z : s.id - e.id; -} -function Yl(s, e) { - return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.z !== e.z ? e.z - s.z : s.id - e.id; -} -function Zl() { - let s = [], e = 0, t = [], n = [], i = []; - function r() { - e = 0, t.length = 0, n.length = 0, i.length = 0; - } - function o(u, d, f, m, x, v) { - let g = s[e]; - return g === void 0 ? (g = { - id: u.id, - object: u, - geometry: d, - material: f, - groupOrder: m, - renderOrder: u.renderOrder, - z: x, - group: v - }, s[e] = g) : (g.id = u.id, g.object = u, g.geometry = d, g.material = f, g.groupOrder = m, g.renderOrder = u.renderOrder, g.z = x, g.group = v), e++, g; - } - function a(u, d, f, m, x, v) { - let g = o(u, d, f, m, x, v); - f.transmission > 0 ? n.push(g) : f.transparent === !0 ? i.push(g) : t.push(g); - } - function l(u, d, f, m, x, v) { - let g = o(u, d, f, m, x, v); - f.transmission > 0 ? n.unshift(g) : f.transparent === !0 ? i.unshift(g) : t.unshift(g); - } - function c(u, d) { - t.length > 1 && t.sort(u || px), n.length > 1 && n.sort(d || Yl), i.length > 1 && i.sort(d || Yl); - } - function h() { - for(let u = e, d = s.length; u < d; u++){ - let f = s[u]; - if (f.id === null) break; - f.id = null, f.object = null, f.geometry = null, f.material = null, f.group = null; - } - } - return { - opaque: t, - transmissive: n, - transparent: i, - init: r, - push: a, - unshift: l, - finish: h, - sort: c - }; -} -function mx() { - let s = new WeakMap; - function e(n, i) { - let r; - return s.has(n) === !1 ? (r = new Zl, s.set(n, [ - r - ])) : i >= s.get(n).length ? (r = new Zl, s.get(n).push(r)) : r = s.get(n)[i], r; - } - function t() { - s = new WeakMap; - } - return { - get: e, - dispose: t - }; -} -function gx() { - let s = {}; - return { - get: function(e) { - if (s[e.id] !== void 0) return s[e.id]; - let t; - switch(e.type){ - case "DirectionalLight": - t = { - direction: new M, - color: new ae - }; - break; - case "SpotLight": - t = { - position: new M, - direction: new M, - color: new ae, - distance: 0, - coneCos: 0, - penumbraCos: 0, - decay: 0 - }; - break; - case "PointLight": - t = { - position: new M, - color: new ae, - distance: 0, - decay: 0 - }; - break; - case "HemisphereLight": - t = { - direction: new M, - skyColor: new ae, - groundColor: new ae - }; - break; - case "RectAreaLight": - t = { - color: new ae, - position: new M, - halfWidth: new M, - halfHeight: new M - }; - break; - } - return s[e.id] = t, t; - } - }; -} -function xx() { - let s = {}; - return { - get: function(e) { - if (s[e.id] !== void 0) return s[e.id]; - let t; - switch(e.type){ - case "DirectionalLight": - t = { - shadowBias: 0, - shadowNormalBias: 0, - shadowRadius: 1, - shadowMapSize: new X - }; - break; - case "SpotLight": - t = { - shadowBias: 0, - shadowNormalBias: 0, - shadowRadius: 1, - shadowMapSize: new X - }; - break; - case "PointLight": - t = { - shadowBias: 0, - shadowNormalBias: 0, - shadowRadius: 1, - shadowMapSize: new X, - shadowCameraNear: 1, - shadowCameraFar: 1e3 - }; - break; - } - return s[e.id] = t, t; - } - }; -} -var yx = 0; -function vx(s, e) { - return (e.castShadow ? 1 : 0) - (s.castShadow ? 1 : 0); -} -function _x(s, e) { - let t = new gx, n = xx(), i = { - version: 0, - hash: { - directionalLength: -1, - pointLength: -1, - spotLength: -1, - rectAreaLength: -1, - hemiLength: -1, - numDirectionalShadows: -1, - numPointShadows: -1, - numSpotShadows: -1 - }, - ambient: [ - 0, - 0, - 0 - ], - probe: [], - directional: [], - directionalShadow: [], - directionalShadowMap: [], - directionalShadowMatrix: [], - spot: [], - spotShadow: [], - spotShadowMap: [], - spotShadowMatrix: [], - rectArea: [], - rectAreaLTC1: null, - rectAreaLTC2: null, - point: [], - pointShadow: [], - pointShadowMap: [], - pointShadowMatrix: [], - hemi: [] - }; - for(let h = 0; h < 9; h++)i.probe.push(new M); - let r = new M, o = new pe, a = new pe; - function l(h, u) { - let d = 0, f = 0, m = 0; - for(let k = 0; k < 9; k++)i.probe[k].set(0, 0, 0); - let x = 0, v = 0, g = 0, p = 0, _ = 0, y = 0, b = 0, A = 0; - h.sort(vx); - let L = u !== !0 ? Math.PI : 1; - for(let k = 0, B = h.length; k < B; k++){ - let P = h[k], w = P.color, E = P.intensity, D = P.distance, U = P.shadow && P.shadow.map ? P.shadow.map.texture : null; - if (P.isAmbientLight) d += w.r * E * L, f += w.g * E * L, m += w.b * E * L; - else if (P.isLightProbe) for(let F = 0; F < 9; F++)i.probe[F].addScaledVector(P.sh.coefficients[F], E); - else if (P.isDirectionalLight) { - let F = t.get(P); - if (F.color.copy(P.color).multiplyScalar(P.intensity * L), P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.directionalShadow[x] = ne, i.directionalShadowMap[x] = U, i.directionalShadowMatrix[x] = P.shadow.matrix, y++; - } - i.directional[x] = F, x++; - } else if (P.isSpotLight) { - let F = t.get(P); - if (F.position.setFromMatrixPosition(P.matrixWorld), F.color.copy(w).multiplyScalar(E * L), F.distance = D, F.coneCos = Math.cos(P.angle), F.penumbraCos = Math.cos(P.angle * (1 - P.penumbra)), F.decay = P.decay, P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.spotShadow[g] = ne, i.spotShadowMap[g] = U, i.spotShadowMatrix[g] = P.shadow.matrix, A++; - } - i.spot[g] = F, g++; - } else if (P.isRectAreaLight) { - let F = t.get(P); - F.color.copy(w).multiplyScalar(E), F.halfWidth.set(P.width * .5, 0, 0), F.halfHeight.set(0, P.height * .5, 0), i.rectArea[p] = F, p++; - } else if (P.isPointLight) { - let F = t.get(P); - if (F.color.copy(P.color).multiplyScalar(P.intensity * L), F.distance = P.distance, F.decay = P.decay, P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, ne.shadowCameraNear = O.camera.near, ne.shadowCameraFar = O.camera.far, i.pointShadow[v] = ne, i.pointShadowMap[v] = U, i.pointShadowMatrix[v] = P.shadow.matrix, b++; - } - i.point[v] = F, v++; - } else if (P.isHemisphereLight) { - let F = t.get(P); - F.skyColor.copy(P.color).multiplyScalar(E * L), F.groundColor.copy(P.groundColor).multiplyScalar(E * L), i.hemi[_] = F, _++; - } - } - p > 0 && (e.isWebGL2 || s.has("OES_texture_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_FLOAT_1, i.rectAreaLTC2 = ie.LTC_FLOAT_2) : s.has("OES_texture_half_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_HALF_1, i.rectAreaLTC2 = ie.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), i.ambient[0] = d, i.ambient[1] = f, i.ambient[2] = m; - let I = i.hash; - (I.directionalLength !== x || I.pointLength !== v || I.spotLength !== g || I.rectAreaLength !== p || I.hemiLength !== _ || I.numDirectionalShadows !== y || I.numPointShadows !== b || I.numSpotShadows !== A) && (i.directional.length = x, i.spot.length = g, i.rectArea.length = p, i.point.length = v, i.hemi.length = _, i.directionalShadow.length = y, i.directionalShadowMap.length = y, i.pointShadow.length = b, i.pointShadowMap.length = b, i.spotShadow.length = A, i.spotShadowMap.length = A, i.directionalShadowMatrix.length = y, i.pointShadowMatrix.length = b, i.spotShadowMatrix.length = A, I.directionalLength = x, I.pointLength = v, I.spotLength = g, I.rectAreaLength = p, I.hemiLength = _, I.numDirectionalShadows = y, I.numPointShadows = b, I.numSpotShadows = A, i.version = yx++); - } - function c(h, u) { - let d = 0, f = 0, m = 0, x = 0, v = 0, g = u.matrixWorldInverse; - for(let p = 0, _ = h.length; p < _; p++){ - let y = h[p]; - if (y.isDirectionalLight) { - let b = i.directional[d]; - b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), d++; - } else if (y.isSpotLight) { - let b = i.spot[m]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), m++; - } else if (y.isRectAreaLight) { - let b = i.rectArea[x]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), a.identity(), o.copy(y.matrixWorld), o.premultiply(g), a.extractRotation(o), b.halfWidth.set(y.width * .5, 0, 0), b.halfHeight.set(0, y.height * .5, 0), b.halfWidth.applyMatrix4(a), b.halfHeight.applyMatrix4(a), x++; - } else if (y.isPointLight) { - let b = i.point[f]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), f++; - } else if (y.isHemisphereLight) { - let b = i.hemi[v]; - b.direction.setFromMatrixPosition(y.matrixWorld), b.direction.transformDirection(g), b.direction.normalize(), v++; - } - } - } - return { - setup: l, - setupView: c, - state: i - }; -} -function $l(s, e) { - let t = new _x(s, e), n = [], i = []; - function r() { - n.length = 0, i.length = 0; - } - function o(u) { - n.push(u); - } - function a(u) { - i.push(u); - } - function l(u) { - t.setup(n, u); - } - function c(u) { - t.setupView(n, u); - } - return { - init: r, - state: { - lightsArray: n, - shadowsArray: i, - lights: t - }, - setupLights: l, - setupLightsView: c, - pushLight: o, - pushShadow: a - }; -} -function Mx(s, e) { - let t = new WeakMap; - function n(r, o = 0) { - let a; - return t.has(r) === !1 ? (a = new $l(s, e), t.set(r, [ - a - ])) : o >= t.get(r).length ? (a = new $l(s, e), t.get(r).push(a)) : a = t.get(r)[o], a; - } - function i() { - t = new WeakMap; - } - return { - get: n, - dispose: i - }; -} -var eo = class extends dt { - constructor(e){ - super(); - this.type = "MeshDepthMaterial", this.depthPacking = Nd, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this; - } -}; -eo.prototype.isMeshDepthMaterial = !0; -var to = class extends dt { - constructor(e){ - super(); - this.type = "MeshDistanceMaterial", this.referencePosition = new M, this.nearDistance = 1, this.farDistance = 1e3, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.fog = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.referencePosition.copy(e.referencePosition), this.nearDistance = e.nearDistance, this.farDistance = e.farDistance, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this; - } -}; -to.prototype.isMeshDistanceMaterial = !0; -var bx = `void main() { - gl_Position = vec4( position, 1.0 ); -}`, wx = `uniform sampler2D shadow_pass; -uniform vec2 resolution; -uniform float radius; -#include -void main() { - const float samples = float( VSM_SAMPLES ); - float mean = 0.0; - float squared_mean = 0.0; - float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); - float uvStart = samples <= 1.0 ? 0.0 : - 1.0; - for ( float i = 0.0; i < samples; i ++ ) { - float uvOffset = uvStart + i * uvStride; - #ifdef HORIZONTAL_PASS - vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); - mean += distribution.x; - squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; - #else - float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); - mean += depth; - squared_mean += depth * depth; - #endif - } - mean = mean / samples; - squared_mean = squared_mean / samples; - float std_dev = sqrt( squared_mean - mean * mean ); - gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`; -function yh(s, e, t) { - let n = new Dr, i = new X, r = new X, o = new Ve, a = new eo({ - depthPacking: Bd - }), l = new to, c = {}, h = t.maxTextureSize, u = { - 0: it, - 1: Ai, - 2: Ci - }, d = new sn({ - defines: { - VSM_SAMPLES: 8 - }, - uniforms: { - shadow_pass: { - value: null - }, - resolution: { - value: new X - }, - radius: { - value: 4 - } - }, - vertexShader: bx, - fragmentShader: wx - }), f = d.clone(); - f.defines.HORIZONTAL_PASS = 1; - let m = new _e; - m.setAttribute("position", new Ue(new Float32Array([ - -1, - -1, - .5, - 3, - -1, - .5, - -1, - 3, - .5 - ]), 3)); - let x = new st(m, d), v = this; - this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Hc, this.render = function(y, b, A) { - if (v.enabled === !1 || v.autoUpdate === !1 && v.needsUpdate === !1 || y.length === 0) return; - let L = s.getRenderTarget(), I = s.getActiveCubeFace(), k = s.getActiveMipmapLevel(), B = s.state; - B.setBlending(vn), B.buffers.color.setClear(1, 1, 1, 1), B.buffers.depth.setTest(!0), B.setScissorTest(!1); - for(let P = 0, w = y.length; P < w; P++){ - let E = y[P], D = E.shadow; - if (D === void 0) { - console.warn("THREE.WebGLShadowMap:", E, "has no shadow."); - continue; - } - if (D.autoUpdate === !1 && D.needsUpdate === !1) continue; - i.copy(D.mapSize); - let U = D.getFrameExtents(); - if (i.multiply(U), r.copy(D.mapSize), (i.x > h || i.y > h) && (i.x > h && (r.x = Math.floor(h / U.x), i.x = r.x * U.x, D.mapSize.x = r.x), i.y > h && (r.y = Math.floor(h / U.y), i.y = r.y * U.y, D.mapSize.y = r.y)), D.map === null && !D.isPointLightShadow && this.type === ir) { - let O = { - minFilter: tt, - magFilter: tt, - format: ct - }; - D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.mapPass = new At(i.x, i.y, O), D.camera.updateProjectionMatrix(); - } - if (D.map === null) { - let O = { - minFilter: rt, - magFilter: rt, - format: ct - }; - D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.camera.updateProjectionMatrix(); - } - s.setRenderTarget(D.map), s.clear(); - let F = D.getViewportCount(); - for(let O = 0; O < F; O++){ - let ne = D.getViewport(O); - o.set(r.x * ne.x, r.y * ne.y, r.x * ne.z, r.y * ne.w), B.viewport(o), D.updateMatrices(E, O), n = D.getFrustum(), _(b, A, D.camera, E, this.type); - } - !D.isPointLightShadow && this.type === ir && g(D, A), D.needsUpdate = !1; - } - v.needsUpdate = !1, s.setRenderTarget(L, I, k); - }; - function g(y, b) { - let A = e.update(x); - d.defines.VSM_SAMPLES !== y.blurSamples && (d.defines.VSM_SAMPLES = y.blurSamples, f.defines.VSM_SAMPLES = y.blurSamples, d.needsUpdate = !0, f.needsUpdate = !0), d.uniforms.shadow_pass.value = y.map.texture, d.uniforms.resolution.value = y.mapSize, d.uniforms.radius.value = y.radius, s.setRenderTarget(y.mapPass), s.clear(), s.renderBufferDirect(b, null, A, d, x, null), f.uniforms.shadow_pass.value = y.mapPass.texture, f.uniforms.resolution.value = y.mapSize, f.uniforms.radius.value = y.radius, s.setRenderTarget(y.map), s.clear(), s.renderBufferDirect(b, null, A, f, x, null); - } - function p(y, b, A, L, I, k, B) { - let P = null, w = L.isPointLight === !0 ? y.customDistanceMaterial : y.customDepthMaterial; - if (w !== void 0 ? P = w : P = L.isPointLight === !0 ? l : a, s.localClippingEnabled && A.clipShadows === !0 && A.clippingPlanes.length !== 0 || A.displacementMap && A.displacementScale !== 0 || A.alphaMap && A.alphaTest > 0) { - let E = P.uuid, D = A.uuid, U = c[E]; - U === void 0 && (U = {}, c[E] = U); - let F = U[D]; - F === void 0 && (F = P.clone(), U[D] = F), P = F; - } - return P.visible = A.visible, P.wireframe = A.wireframe, B === ir ? P.side = A.shadowSide !== null ? A.shadowSide : A.side : P.side = A.shadowSide !== null ? A.shadowSide : u[A.side], P.alphaMap = A.alphaMap, P.alphaTest = A.alphaTest, P.clipShadows = A.clipShadows, P.clippingPlanes = A.clippingPlanes, P.clipIntersection = A.clipIntersection, P.displacementMap = A.displacementMap, P.displacementScale = A.displacementScale, P.displacementBias = A.displacementBias, P.wireframeLinewidth = A.wireframeLinewidth, P.linewidth = A.linewidth, L.isPointLight === !0 && P.isMeshDistanceMaterial === !0 && (P.referencePosition.setFromMatrixPosition(L.matrixWorld), P.nearDistance = I, P.farDistance = k), P; - } - function _(y, b, A, L, I) { - if (y.visible === !1) return; - if (y.layers.test(b.layers) && (y.isMesh || y.isLine || y.isPoints) && (y.castShadow || y.receiveShadow && I === ir) && (!y.frustumCulled || n.intersectsObject(y))) { - y.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse, y.matrixWorld); - let P = e.update(y), w = y.material; - if (Array.isArray(w)) { - let E = P.groups; - for(let D = 0, U = E.length; D < U; D++){ - let F = E[D], O = w[F.materialIndex]; - if (O && O.visible) { - let ne = p(y, P, O, L, A.near, A.far, I); - s.renderBufferDirect(A, null, P, ne, y, F); - } - } - } else if (w.visible) { - let E = p(y, P, w, L, A.near, A.far, I); - s.renderBufferDirect(A, null, P, E, y, null); - } - } - let B = y.children; - for(let P = 0, w = B.length; P < w; P++)_(B[P], b, A, L, I); - } -} -function Sx(s, e, t) { - let n = t.isWebGL2; - function i() { - let R = !1, ee = new Ve, Q = null, Ee = new Ve(0, 0, 0, 0); - return { - setMask: function(me) { - Q !== me && !R && (s.colorMask(me, me, me, me), Q = me); - }, - setLocked: function(me) { - R = me; - }, - setClear: function(me, Re, oe, Le, Xe) { - Xe === !0 && (me *= Le, Re *= Le, oe *= Le), ee.set(me, Re, oe, Le), Ee.equals(ee) === !1 && (s.clearColor(me, Re, oe, Le), Ee.copy(ee)); - }, - reset: function() { - R = !1, Q = null, Ee.set(-1, 0, 0, 0); - } - }; - } - function r() { - let R = !1, ee = null, Q = null, Ee = null; - return { - setTest: function(me) { - me ? le(2929) : fe(2929); - }, - setMask: function(me) { - ee !== me && !R && (s.depthMask(me), ee = me); - }, - setFunc: function(me) { - if (Q !== me) { - if (me) switch(me){ - case Eu: - s.depthFunc(512); - break; - case Au: - s.depthFunc(519); - break; - case Cu: - s.depthFunc(513); - break; - case ea: - s.depthFunc(515); - break; - case Lu: - s.depthFunc(514); - break; - case Ru: - s.depthFunc(518); - break; - case Pu: - s.depthFunc(516); - break; - case Iu: - s.depthFunc(517); - break; - default: - s.depthFunc(515); - } - else s.depthFunc(515); - Q = me; - } - }, - setLocked: function(me) { - R = me; - }, - setClear: function(me) { - Ee !== me && (s.clearDepth(me), Ee = me); - }, - reset: function() { - R = !1, ee = null, Q = null, Ee = null; - } - }; - } - function o() { - let R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; - return { - setTest: function(We) { - R || (We ? le(2960) : fe(2960)); - }, - setMask: function(We) { - ee !== We && !R && (s.stencilMask(We), ee = We); - }, - setFunc: function(We, Ut, Ot) { - (Q !== We || Ee !== Ut || me !== Ot) && (s.stencilFunc(We, Ut, Ot), Q = We, Ee = Ut, me = Ot); - }, - setOp: function(We, Ut, Ot) { - (Re !== We || oe !== Ut || Le !== Ot) && (s.stencilOp(We, Ut, Ot), Re = We, oe = Ut, Le = Ot); - }, - setLocked: function(We) { - R = We; - }, - setClear: function(We) { - Xe !== We && (s.clearStencil(We), Xe = We); - }, - reset: function() { - R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; - } - }; - } - let a = new i, l = new r, c = new o, h = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, P = s.getParameter(35661), w = !1, E = 0, D = s.getParameter(7938); - D.indexOf("WebGL") !== -1 ? (E = parseFloat(/^WebGL (\d)/.exec(D)[1]), w = E >= 1) : D.indexOf("OpenGL ES") !== -1 && (E = parseFloat(/^OpenGL ES (\d)/.exec(D)[1]), w = E >= 2); - let U = null, F = {}, O = s.getParameter(3088), ne = s.getParameter(2978), ce = new Ve().fromArray(O), V = new Ve().fromArray(ne); - function W(R, ee, Q) { - let Ee = new Uint8Array(4), me = s.createTexture(); - s.bindTexture(R, me), s.texParameteri(R, 10241, 9728), s.texParameteri(R, 10240, 9728); - for(let Re = 0; Re < Q; Re++)s.texImage2D(ee + Re, 0, 6408, 1, 1, 0, 6408, 5121, Ee); - return me; - } - let he = {}; - he[3553] = W(3553, 3553, 1), he[34067] = W(34067, 34069, 6), a.setClear(0, 0, 0, 1), l.setClear(1), c.setClear(0), le(2929), l.setFunc(ea), Oe(!1), G(tl), le(2884), ge(vn); - function le(R) { - h[R] !== !0 && (s.enable(R), h[R] = !0); - } - function fe(R) { - h[R] !== !1 && (s.disable(R), h[R] = !1); - } - function Be(R, ee) { - return u[R] !== ee ? (s.bindFramebuffer(R, ee), u[R] = ee, n && (R === 36009 && (u[36160] = ee), R === 36160 && (u[36009] = ee)), !0) : !1; - } - function Y(R) { - return d !== R ? (s.useProgram(R), d = R, !0) : !1; - } - let Ce = { - [_i]: 32774, - [mu]: 32778, - [gu]: 32779 - }; - if (n) Ce[sl] = 32775, Ce[ol] = 32776; - else { - let R = e.get("EXT_blend_minmax"); - R !== null && (Ce[sl] = R.MIN_EXT, Ce[ol] = R.MAX_EXT); - } - let ye = { - [xu]: 0, - [yu]: 1, - [vu]: 768, - [Gc]: 770, - [Tu]: 776, - [wu]: 774, - [Mu]: 772, - [_u]: 769, - [Vc]: 771, - [Su]: 775, - [bu]: 773 - }; - function ge(R, ee, Q, Ee, me, Re, oe, Le) { - if (R === vn) { - f === !0 && (fe(3042), f = !1); - return; - } - if (f === !1 && (le(3042), f = !0), R !== pu) { - if (R !== m || Le !== b) { - if ((x !== _i || p !== _i) && (s.blendEquation(32774), x = _i, p = _i), Le) switch(R){ - case sr: - s.blendFuncSeparate(1, 771, 1, 771); - break; - case nl: - s.blendFunc(1, 1); - break; - case il: - s.blendFuncSeparate(0, 0, 769, 771); - break; - case rl: - s.blendFuncSeparate(0, 768, 0, 770); - break; - default: - console.error("THREE.WebGLState: Invalid blending: ", R); - break; - } - else switch(R){ - case sr: - s.blendFuncSeparate(770, 771, 1, 771); - break; - case nl: - s.blendFunc(770, 1); - break; - case il: - s.blendFunc(0, 769); - break; - case rl: - s.blendFunc(0, 768); - break; - default: - console.error("THREE.WebGLState: Invalid blending: ", R); - break; - } - v = null, g = null, _ = null, y = null, m = R, b = Le; - } - return; - } - me = me || ee, Re = Re || Q, oe = oe || Ee, (ee !== x || me !== p) && (s.blendEquationSeparate(Ce[ee], Ce[me]), x = ee, p = me), (Q !== v || Ee !== g || Re !== _ || oe !== y) && (s.blendFuncSeparate(ye[Q], ye[Ee], ye[Re], ye[oe]), v = Q, g = Ee, _ = Re, y = oe), m = R, b = null; - } - function xe(R, ee) { - R.side === Ci ? fe(2884) : le(2884); - let Q = R.side === it; - ee && (Q = !Q), Oe(Q), R.blending === sr && R.transparent === !1 ? ge(vn) : ge(R.blending, R.blendEquation, R.blendSrc, R.blendDst, R.blendEquationAlpha, R.blendSrcAlpha, R.blendDstAlpha, R.premultipliedAlpha), l.setFunc(R.depthFunc), l.setTest(R.depthTest), l.setMask(R.depthWrite), a.setMask(R.colorWrite); - let Ee = R.stencilWrite; - c.setTest(Ee), Ee && (c.setMask(R.stencilWriteMask), c.setFunc(R.stencilFunc, R.stencilRef, R.stencilFuncMask), c.setOp(R.stencilFail, R.stencilZFail, R.stencilZPass)), K(R.polygonOffset, R.polygonOffsetFactor, R.polygonOffsetUnits), R.alphaToCoverage === !0 ? le(32926) : fe(32926); - } - function Oe(R) { - A !== R && (R ? s.frontFace(2304) : s.frontFace(2305), A = R); - } - function G(R) { - R !== uu ? (le(2884), R !== L && (R === tl ? s.cullFace(1029) : R === du ? s.cullFace(1028) : s.cullFace(1032))) : fe(2884), L = R; - } - function j(R) { - R !== I && (w && s.lineWidth(R), I = R); - } - function K(R, ee, Q) { - R ? (le(32823), (k !== ee || B !== Q) && (s.polygonOffset(ee, Q), k = ee, B = Q)) : fe(32823); - } - function ue(R) { - R ? le(3089) : fe(3089); - } - function se(R) { - R === void 0 && (R = 33984 + P - 1), U !== R && (s.activeTexture(R), U = R); - } - function Se(R, ee) { - U === null && se(); - let Q = F[U]; - Q === void 0 && (Q = { - type: void 0, - texture: void 0 - }, F[U] = Q), (Q.type !== R || Q.texture !== ee) && (s.bindTexture(R, ee || he[R]), Q.type = R, Q.texture = ee); - } - function Te() { - let R = F[U]; - R !== void 0 && R.type !== void 0 && (s.bindTexture(R.type, null), R.type = void 0, R.texture = void 0); - } - function Pe() { - try { - s.compressedTexImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function Ye() { - try { - s.texSubImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function C() { - try { - s.texSubImage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function T() { - try { - s.compressedTexSubImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function J() { - try { - s.texStorage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function $() { - try { - s.texStorage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function re() { - try { - s.texImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function Z() { - try { - s.texImage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); - } - } - function Me(R) { - ce.equals(R) === !1 && (s.scissor(R.x, R.y, R.z, R.w), ce.copy(R)); - } - function ve(R) { - V.equals(R) === !1 && (s.viewport(R.x, R.y, R.z, R.w), V.copy(R)); - } - function te() { - s.disable(3042), s.disable(2884), s.disable(2929), s.disable(32823), s.disable(3089), s.disable(2960), s.disable(32926), s.blendEquation(32774), s.blendFunc(1, 0), s.blendFuncSeparate(1, 0, 1, 0), s.colorMask(!0, !0, !0, !0), s.clearColor(0, 0, 0, 0), s.depthMask(!0), s.depthFunc(513), s.clearDepth(1), s.stencilMask(4294967295), s.stencilFunc(519, 0, 4294967295), s.stencilOp(7680, 7680, 7680), s.clearStencil(0), s.cullFace(1029), s.frontFace(2305), s.polygonOffset(0, 0), s.activeTexture(33984), s.bindFramebuffer(36160, null), n === !0 && (s.bindFramebuffer(36009, null), s.bindFramebuffer(36008, null)), s.useProgram(null), s.lineWidth(1), s.scissor(0, 0, s.canvas.width, s.canvas.height), s.viewport(0, 0, s.canvas.width, s.canvas.height), h = {}, U = null, F = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, ce.set(0, 0, s.canvas.width, s.canvas.height), V.set(0, 0, s.canvas.width, s.canvas.height), a.reset(), l.reset(), c.reset(); - } - return { - buffers: { - color: a, - depth: l, - stencil: c - }, - enable: le, - disable: fe, - bindFramebuffer: Be, - useProgram: Y, - setBlending: ge, - setMaterial: xe, - setFlipSided: Oe, - setCullFace: G, - setLineWidth: j, - setPolygonOffset: K, - setScissorTest: ue, - activeTexture: se, - bindTexture: Se, - unbindTexture: Te, - compressedTexImage2D: Pe, - texImage2D: re, - texImage3D: Z, - texStorage2D: J, - texStorage3D: $, - texSubImage2D: Ye, - texSubImage3D: C, - compressedTexSubImage2D: T, - scissor: Me, - viewport: ve, - reset: te - }; -} -function Tx(s, e, t, n, i, r, o) { - let a = i.isWebGL2, l = i.maxTextures, c = i.maxCubemapSize, h = i.maxTextureSize, u = i.maxSamples, f = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : void 0, m = new WeakMap, x, v = !1; - try { - v = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; - } catch {} - function g(C, T) { - return v ? new OffscreenCanvas(C, T) : qs("canvas"); - } - function p(C, T, J, $) { - let re = 1; - if ((C.width > $ || C.height > $) && (re = $ / Math.max(C.width, C.height)), re < 1 || T === !0) if (typeof HTMLImageElement < "u" && C instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && C instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && C instanceof ImageBitmap) { - let Z = T ? Jc : Math.floor, Me = Z(re * C.width), ve = Z(re * C.height); - x === void 0 && (x = g(Me, ve)); - let te = J ? g(Me, ve) : x; - return te.width = Me, te.height = ve, te.getContext("2d").drawImage(C, 0, 0, Me, ve), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + C.width + "x" + C.height + ") to (" + Me + "x" + ve + ")."), te; - } else return "data" in C && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + C.width + "x" + C.height + ")."), C; - return C; - } - function _(C) { - return ia(C.width) && ia(C.height); - } - function y(C) { - return a ? !1 : C.wrapS !== vt || C.wrapT !== vt || C.minFilter !== rt && C.minFilter !== tt; - } - function b(C, T) { - return C.generateMipmaps && T && C.minFilter !== rt && C.minFilter !== tt; - } - function A(C) { - s.generateMipmap(C); - } - function L(C, T, J, $) { - if (a === !1) return T; - if (C !== null) { - if (s[C] !== void 0) return s[C]; - console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + C + "'"); - } - let re = T; - return T === 6403 && (J === 5126 && (re = 33326), J === 5131 && (re = 33325), J === 5121 && (re = 33321)), T === 6407 && (J === 5126 && (re = 34837), J === 5131 && (re = 34843), J === 5121 && (re = 32849)), T === 6408 && (J === 5126 && (re = 34836), J === 5131 && (re = 34842), J === 5121 && (re = $ === Oi ? 35907 : 32856)), (re === 33325 || re === 33326 || re === 34842 || re === 34836) && e.get("EXT_color_buffer_float"), re; - } - function I(C, T, J) { - return b(C, J) === !0 || C.isFramebufferTexture && C.minFilter !== rt && C.minFilter !== tt ? Math.log2(Math.max(T.width, T.height)) + 1 : C.mipmaps !== void 0 && C.mipmaps.length > 0 ? C.mipmaps.length : C.isCompressedTexture && Array.isArray(C.image) ? T.mipmaps.length : 1; - } - function k(C) { - return C === rt || C === ta || C === na ? 9728 : 9729; - } - function B(C) { - let T = C.target; - T.removeEventListener("dispose", B), w(T), T.isVideoTexture && m.delete(T), o.memory.textures--; - } - function P(C) { - let T = C.target; - T.removeEventListener("dispose", P), E(T); - } - function w(C) { - let T = n.get(C); - T.__webglInit !== void 0 && (s.deleteTexture(T.__webglTexture), n.remove(C)); - } - function E(C) { - let T = C.texture, J = n.get(C), $ = n.get(T); - if (!!C) { - if ($.__webglTexture !== void 0 && (s.deleteTexture($.__webglTexture), o.memory.textures--), C.depthTexture && C.depthTexture.dispose(), C.isWebGLCubeRenderTarget) for(let re = 0; re < 6; re++)s.deleteFramebuffer(J.__webglFramebuffer[re]), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer[re]); - else s.deleteFramebuffer(J.__webglFramebuffer), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer), J.__webglMultisampledFramebuffer && s.deleteFramebuffer(J.__webglMultisampledFramebuffer), J.__webglColorRenderbuffer && s.deleteRenderbuffer(J.__webglColorRenderbuffer), J.__webglDepthRenderbuffer && s.deleteRenderbuffer(J.__webglDepthRenderbuffer); - if (C.isWebGLMultipleRenderTargets) for(let re = 0, Z = T.length; re < Z; re++){ - let Me = n.get(T[re]); - Me.__webglTexture && (s.deleteTexture(Me.__webglTexture), o.memory.textures--), n.remove(T[re]); - } - n.remove(T), n.remove(C); - } - } - let D = 0; - function U() { - D = 0; - } - function F() { - let C = D; - return C >= l && console.warn("THREE.WebGLTextures: Trying to use " + C + " texture units while this GPU supports only " + l), D += 1, C; - } - function O(C, T) { - let J = n.get(C); - if (C.isVideoTexture && se(C), C.version > 0 && J.__version !== C.version) { - let $ = C.image; - if ($ === void 0) console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined"); - else if ($.complete === !1) console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); - else { - Be(J, C, T); - return; - } - } - t.activeTexture(33984 + T), t.bindTexture(3553, J.__webglTexture); - } - function ne(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Be(J, C, T); - return; - } - t.activeTexture(33984 + T), t.bindTexture(35866, J.__webglTexture); - } - function ce(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Be(J, C, T); - return; - } - t.activeTexture(33984 + T), t.bindTexture(32879, J.__webglTexture); - } - function V(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Y(J, C, T); - return; - } - t.activeTexture(33984 + T), t.bindTexture(34067, J.__webglTexture); - } - let W = { - [Ns]: 10497, - [vt]: 33071, - [Bs]: 33648 - }, he = { - [rt]: 9728, - [ta]: 9984, - [na]: 9986, - [tt]: 9729, - [Wc]: 9985, - [Ui]: 9987 - }; - function le(C, T, J) { - if (J ? (s.texParameteri(C, 10242, W[T.wrapS]), s.texParameteri(C, 10243, W[T.wrapT]), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, W[T.wrapR]), s.texParameteri(C, 10240, he[T.magFilter]), s.texParameteri(C, 10241, he[T.minFilter])) : (s.texParameteri(C, 10242, 33071), s.texParameteri(C, 10243, 33071), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, 33071), (T.wrapS !== vt || T.wrapT !== vt) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), s.texParameteri(C, 10240, k(T.magFilter)), s.texParameteri(C, 10241, k(T.minFilter)), T.minFilter !== rt && T.minFilter !== tt && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), e.has("EXT_texture_filter_anisotropic") === !0) { - let $ = e.get("EXT_texture_filter_anisotropic"); - if (T.type === nn && e.has("OES_texture_float_linear") === !1 || a === !1 && T.type === kn && e.has("OES_texture_half_float_linear") === !1) return; - (T.anisotropy > 1 || n.get(T).__currentAnisotropy) && (s.texParameterf(C, $.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(T.anisotropy, i.getMaxAnisotropy())), n.get(T).__currentAnisotropy = T.anisotropy); - } - } - function fe(C, T) { - C.__webglInit === void 0 && (C.__webglInit = !0, T.addEventListener("dispose", B), C.__webglTexture = s.createTexture(), o.memory.textures++); - } - function Be(C, T, J) { - let $ = 3553; - T.isDataTexture2DArray && ($ = 35866), T.isDataTexture3D && ($ = 32879), fe(C, T), t.activeTexture(33984 + J), t.bindTexture($, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); - let re = y(T) && _(T.image) === !1, Z = p(T.image, re, !1, h), Me = _(Z) || a, ve = r.convert(T.format), te = r.convert(T.type), R = L(T.internalFormat, ve, te, T.encoding); - le($, T, Me); - let ee, Q = T.mipmaps, Ee = a && T.isVideoTexture !== !0, me = C.__version === void 0, Re = I(T, Z, Me); - if (T.isDepthTexture) R = 6402, a ? T.type === nn ? R = 36012 : T.type === Ps ? R = 33190 : T.type === Ti ? R = 35056 : R = 33189 : T.type === nn && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), T.format === Vn && R === 6402 && T.type !== cr && T.type !== Ps && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), T.type = cr, te = r.convert(T.type)), T.format === Li && R === 6402 && (R = 34041, T.type !== Ti && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), T.type = Ti, te = r.convert(T.type))), Ee && me ? t.texStorage2D(3553, 1, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); - else if (T.isDataTexture) if (Q.length > 0 && Me) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, 0, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); - T.generateMipmaps = !1; - } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, Z.width, Z.height, ve, te, Z.data)) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, Z.data); - else if (T.isCompressedTexture) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], T.format !== ct && T.format !== Gn ? ve !== null ? Ee ? t.compressedTexSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, ee.data) : t.compressedTexImage2D(3553, oe, R, ee.width, ee.height, 0, ee.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ee ? t.texSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); - } else if (T.isDataTexture2DArray) Ee ? (me && t.texStorage3D(35866, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(35866, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(35866, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); - else if (T.isDataTexture3D) Ee ? (me && t.texStorage3D(32879, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(32879, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(32879, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); - else if (T.isFramebufferTexture) Ee && me ? t.texStorage2D(3553, Re, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); - else if (Q.length > 0 && Me) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, oe, 0, 0, ve, te, ee) : t.texImage2D(3553, oe, R, ve, te, ee); - T.generateMipmaps = !1; - } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, ve, te, Z)) : t.texImage2D(3553, 0, R, ve, te, Z); - b(T, Me) && A($), C.__version = T.version, T.onUpdate && T.onUpdate(T); - } - function Y(C, T, J) { - if (T.image.length !== 6) return; - fe(C, T), t.activeTexture(33984 + J), t.bindTexture(34067, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); - let $ = T && (T.isCompressedTexture || T.image[0].isCompressedTexture), re = T.image[0] && T.image[0].isDataTexture, Z = []; - for(let oe = 0; oe < 6; oe++)!$ && !re ? Z[oe] = p(T.image[oe], !1, !0, c) : Z[oe] = re ? T.image[oe].image : T.image[oe]; - let Me = Z[0], ve = _(Me) || a, te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = a && T.isVideoTexture !== !0, Ee = C.__version === void 0, me = I(T, Me, ve); - le(34067, T, ve); - let Re; - if ($) { - Q && Ee && t.texStorage2D(34067, me, ee, Me.width, Me.height); - for(let oe = 0; oe < 6; oe++){ - Re = Z[oe].mipmaps; - for(let Le = 0; Le < Re.length; Le++){ - let Xe = Re[Le]; - T.format !== ct && T.format !== Gn ? te !== null ? Q ? t.compressedTexSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, Xe.data) : t.compressedTexImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, Xe.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Q ? t.texSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, R, Xe.data) : t.texImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, te, R, Xe.data); - } - } - } else { - Re = T.mipmaps, Q && Ee && (Re.length > 0 && me++, t.texStorage2D(34067, me, ee, Z[0].width, Z[0].height)); - for(let oe = 0; oe < 6; oe++)if (re) { - Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, Z[oe].width, Z[oe].height, te, R, Z[oe].data) : t.texImage2D(34069 + oe, 0, ee, Z[oe].width, Z[oe].height, 0, te, R, Z[oe].data); - for(let Le = 0; Le < Re.length; Le++){ - let We = Re[Le].image[oe].image; - Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, We.width, We.height, te, R, We.data) : t.texImage2D(34069 + oe, Le + 1, ee, We.width, We.height, 0, te, R, We.data); - } - } else { - Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, te, R, Z[oe]) : t.texImage2D(34069 + oe, 0, ee, te, R, Z[oe]); - for(let Le = 0; Le < Re.length; Le++){ - let Xe = Re[Le]; - Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, te, R, Xe.image[oe]) : t.texImage2D(34069 + oe, Le + 1, ee, te, R, Xe.image[oe]); - } - } - } - b(T, ve) && A(34067), C.__version = T.version, T.onUpdate && T.onUpdate(T); - } - function Ce(C, T, J, $, re) { - let Z = r.convert(J.format), Me = r.convert(J.type), ve = L(J.internalFormat, Z, Me, J.encoding); - n.get(T).__hasExternalTextures || (re === 32879 || re === 35866 ? t.texImage3D(re, 0, ve, T.width, T.height, T.depth, 0, Z, Me, null) : t.texImage2D(re, 0, ve, T.width, T.height, 0, Z, Me, null)), t.bindFramebuffer(36160, C), T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, $, re, n.get(J).__webglTexture, 0, ue(T)) : s.framebufferTexture2D(36160, $, re, n.get(J).__webglTexture, 0), t.bindFramebuffer(36160, null); - } - function ye(C, T, J) { - if (s.bindRenderbuffer(36161, C), T.depthBuffer && !T.stencilBuffer) { - let $ = 33189; - if (J || T.useRenderToTexture) { - let re = T.depthTexture; - re && re.isDepthTexture && (re.type === nn ? $ = 36012 : re.type === Ps && ($ = 33190)); - let Z = ue(T); - T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, Z, $, T.width, T.height) : s.renderbufferStorageMultisample(36161, Z, $, T.width, T.height); - } else s.renderbufferStorage(36161, $, T.width, T.height); - s.framebufferRenderbuffer(36160, 36096, 36161, C); - } else if (T.depthBuffer && T.stencilBuffer) { - let $ = ue(T); - J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, $, 35056, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, $, 35056, T.width, T.height) : s.renderbufferStorage(36161, 34041, T.width, T.height), s.framebufferRenderbuffer(36160, 33306, 36161, C); - } else { - let $ = T.isWebGLMultipleRenderTargets === !0 ? T.texture[0] : T.texture, re = r.convert($.format), Z = r.convert($.type), Me = L($.internalFormat, re, Z, $.encoding), ve = ue(T); - J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, ve, Me, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, ve, Me, T.width, T.height) : s.renderbufferStorage(36161, Me, T.width, T.height); - } - s.bindRenderbuffer(36161, null); - } - function ge(C, T) { - if (T && T.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported"); - if (t.bindFramebuffer(36160, C), !(T.depthTexture && T.depthTexture.isDepthTexture)) throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); - (!n.get(T.depthTexture).__webglTexture || T.depthTexture.image.width !== T.width || T.depthTexture.image.height !== T.height) && (T.depthTexture.image.width = T.width, T.depthTexture.image.height = T.height, T.depthTexture.needsUpdate = !0), O(T.depthTexture, 0); - let $ = n.get(T.depthTexture).__webglTexture, re = ue(T); - if (T.depthTexture.format === Vn) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 36096, 3553, $, 0, re) : s.framebufferTexture2D(36160, 36096, 3553, $, 0); - else if (T.depthTexture.format === Li) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 33306, 3553, $, 0, re) : s.framebufferTexture2D(36160, 33306, 3553, $, 0); - else throw new Error("Unknown depthTexture format"); - } - function xe(C) { - let T = n.get(C), J = C.isWebGLCubeRenderTarget === !0; - if (C.depthTexture && !T.__autoAllocateDepthBuffer) { - if (J) throw new Error("target.depthTexture not supported in Cube render targets"); - ge(T.__webglFramebuffer, C); - } else if (J) { - T.__webglDepthbuffer = []; - for(let $ = 0; $ < 6; $++)t.bindFramebuffer(36160, T.__webglFramebuffer[$]), T.__webglDepthbuffer[$] = s.createRenderbuffer(), ye(T.__webglDepthbuffer[$], C, !1); - } else t.bindFramebuffer(36160, T.__webglFramebuffer), T.__webglDepthbuffer = s.createRenderbuffer(), ye(T.__webglDepthbuffer, C, !1); - t.bindFramebuffer(36160, null); - } - function Oe(C, T, J) { - let $ = n.get(C); - T !== void 0 && Ce($.__webglFramebuffer, C, C.texture, 36064, 3553), J !== void 0 && xe(C); - } - function G(C) { - let T = C.texture, J = n.get(C), $ = n.get(T); - C.addEventListener("dispose", P), C.isWebGLMultipleRenderTargets !== !0 && ($.__webglTexture === void 0 && ($.__webglTexture = s.createTexture()), $.__version = T.version, o.memory.textures++); - let re = C.isWebGLCubeRenderTarget === !0, Z = C.isWebGLMultipleRenderTargets === !0, Me = T.isDataTexture3D || T.isDataTexture2DArray, ve = _(C) || a; - if (a && T.format === Gn && (T.type === nn || T.type === kn) && (T.format = ct, console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")), re) { - J.__webglFramebuffer = []; - for(let te = 0; te < 6; te++)J.__webglFramebuffer[te] = s.createFramebuffer(); - } else if (J.__webglFramebuffer = s.createFramebuffer(), Z) if (i.drawBuffers) { - let te = C.texture; - for(let R = 0, ee = te.length; R < ee; R++){ - let Q = n.get(te[R]); - Q.__webglTexture === void 0 && (Q.__webglTexture = s.createTexture(), o.memory.textures++); - } - } else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension."); - else if (C.useRenderbuffer) if (a) { - J.__webglMultisampledFramebuffer = s.createFramebuffer(), J.__webglColorRenderbuffer = s.createRenderbuffer(), s.bindRenderbuffer(36161, J.__webglColorRenderbuffer); - let te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = ue(C); - s.renderbufferStorageMultisample(36161, Q, ee, C.width, C.height), t.bindFramebuffer(36160, J.__webglMultisampledFramebuffer), s.framebufferRenderbuffer(36160, 36064, 36161, J.__webglColorRenderbuffer), s.bindRenderbuffer(36161, null), C.depthBuffer && (J.__webglDepthRenderbuffer = s.createRenderbuffer(), ye(J.__webglDepthRenderbuffer, C, !0)), t.bindFramebuffer(36160, null); - } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); - if (re) { - t.bindTexture(34067, $.__webglTexture), le(34067, T, ve); - for(let te = 0; te < 6; te++)Ce(J.__webglFramebuffer[te], C, T, 36064, 34069 + te); - b(T, ve) && A(34067), t.unbindTexture(); - } else if (Z) { - let te = C.texture; - for(let R = 0, ee = te.length; R < ee; R++){ - let Q = te[R], Ee = n.get(Q); - t.bindTexture(3553, Ee.__webglTexture), le(3553, Q, ve), Ce(J.__webglFramebuffer, C, Q, 36064 + R, 3553), b(Q, ve) && A(3553); - } - t.unbindTexture(); - } else { - let te = 3553; - Me && (a ? te = T.isDataTexture3D ? 32879 : 35866 : console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")), t.bindTexture(te, $.__webglTexture), le(te, T, ve), Ce(J.__webglFramebuffer, C, T, 36064, te), b(T, ve) && A(te), t.unbindTexture(); - } - C.depthBuffer && xe(C); - } - function j(C) { - let T = _(C) || a, J = C.isWebGLMultipleRenderTargets === !0 ? C.texture : [ - C.texture - ]; - for(let $ = 0, re = J.length; $ < re; $++){ - let Z = J[$]; - if (b(Z, T)) { - let Me = C.isWebGLCubeRenderTarget ? 34067 : 3553, ve = n.get(Z).__webglTexture; - t.bindTexture(Me, ve), A(Me), t.unbindTexture(); - } - } - } - function K(C) { - if (C.useRenderbuffer) if (a) { - let T = C.width, J = C.height, $ = 16384, re = [ - 36064 - ], Z = C.stencilBuffer ? 33306 : 36096; - C.depthBuffer && re.push(Z), C.ignoreDepthForMultisampleCopy || (C.depthBuffer && ($ |= 256), C.stencilBuffer && ($ |= 1024)); - let Me = n.get(C); - t.bindFramebuffer(36008, Me.__webglMultisampledFramebuffer), t.bindFramebuffer(36009, Me.__webglFramebuffer), C.ignoreDepthForMultisampleCopy && (s.invalidateFramebuffer(36008, [ - Z - ]), s.invalidateFramebuffer(36009, [ - Z - ])), s.blitFramebuffer(0, 0, T, J, 0, 0, T, J, $, 9728), s.invalidateFramebuffer(36008, re), t.bindFramebuffer(36008, null), t.bindFramebuffer(36009, Me.__webglMultisampledFramebuffer); - } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); - } - function ue(C) { - return a && (C.useRenderbuffer || C.useRenderToTexture) ? Math.min(u, C.samples) : 0; - } - function se(C) { - let T = o.render.frame; - m.get(C) !== T && (m.set(C, T), C.update()); - } - let Se = !1, Te = !1; - function Pe(C, T) { - C && C.isWebGLRenderTarget && (Se === !1 && (console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."), Se = !0), C = C.texture), O(C, T); - } - function Ye(C, T) { - C && C.isWebGLCubeRenderTarget && (Te === !1 && (console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."), Te = !0), C = C.texture), V(C, T); - } - this.allocateTextureUnit = F, this.resetTextureUnits = U, this.setTexture2D = O, this.setTexture2DArray = ne, this.setTexture3D = ce, this.setTextureCube = V, this.rebindTextures = Oe, this.setupRenderTarget = G, this.updateRenderTargetMipmap = j, this.updateMultisampleRenderTarget = K, this.setupDepthRenderbuffer = xe, this.setupFrameBufferTexture = Ce, this.safeSetTexture2D = Pe, this.safeSetTextureCube = Ye; -} -function Ex(s, e, t) { - let n = t.isWebGL2; - function i(r) { - let o; - if (r === rn) return 5121; - if (r === Vu) return 32819; - if (r === Wu) return 32820; - if (r === qu) return 33635; - if (r === Hu) return 5120; - if (r === ku) return 5122; - if (r === cr) return 5123; - if (r === Gu) return 5124; - if (r === Ps) return 5125; - if (r === nn) return 5126; - if (r === kn) return n ? 5131 : (o = e.get("OES_texture_half_float"), o !== null ? o.HALF_FLOAT_OES : null); - if (r === Xu) return 6406; - if (r === Gn) return 6407; - if (r === ct) return 6408; - if (r === Ju) return 6409; - if (r === Yu) return 6410; - if (r === Vn) return 6402; - if (r === Li) return 34041; - if (r === Zu) return 6403; - if (r === $u) return 36244; - if (r === ju) return 33319; - if (r === Qu) return 33320; - if (r === Ku) return 36248; - if (r === ed) return 36249; - if (r === al || r === ll || r === cl || r === hl) if (o = e.get("WEBGL_compressed_texture_s3tc"), o !== null) { - if (r === al) return o.COMPRESSED_RGB_S3TC_DXT1_EXT; - if (r === ll) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; - if (r === cl) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; - if (r === hl) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; - } else return null; - if (r === ul || r === dl || r === fl || r === pl) if (o = e.get("WEBGL_compressed_texture_pvrtc"), o !== null) { - if (r === ul) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - if (r === dl) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - if (r === fl) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - if (r === pl) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - } else return null; - if (r === td) return o = e.get("WEBGL_compressed_texture_etc1"), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; - if ((r === ml || r === gl) && (o = e.get("WEBGL_compressed_texture_etc"), o !== null)) { - if (r === ml) return o.COMPRESSED_RGB8_ETC2; - if (r === gl) return o.COMPRESSED_RGBA8_ETC2_EAC; - } - if (r === nd || r === id || r === rd || r === sd || r === od || r === ad || r === ld || r === cd || r === hd || r === ud || r === dd || r === fd || r === pd || r === md || r === xd || r === yd || r === vd || r === _d || r === Md || r === bd || r === wd || r === Sd || r === Td || r === Ed || r === Ad || r === Cd || r === Ld || r === Rd) return o = e.get("WEBGL_compressed_texture_astc"), o !== null ? r : null; - if (r === gd) return o = e.get("EXT_texture_compression_bptc"), o !== null ? r : null; - if (r === Ti) return n ? 34042 : (o = e.get("WEBGL_depth_texture"), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null); - } - return { - convert: i - }; -} -var ga = class extends ut { - constructor(e = []){ - super(); - this.cameras = e; - } -}; -ga.prototype.isArrayCamera = !0; -var Hn = class extends Ne { - constructor(){ - super(); - this.type = "Group"; - } -}; -Hn.prototype.isGroup = !0; -var Ax = { - type: "move" -}, Is = class { - constructor(){ - this._targetRay = null, this._grip = null, this._hand = null; - } - getHandSpace() { - return this._hand === null && (this._hand = new Hn, this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { - pinching: !1 - }), this._hand; - } - getTargetRaySpace() { - return this._targetRay === null && (this._targetRay = new Hn, this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new M, this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new M), this._targetRay; - } - getGripSpace() { - return this._grip === null && (this._grip = new Hn, this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new M, this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new M), this._grip; - } - dispatchEvent(e) { - return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this; - } - disconnect(e) { - return this.dispatchEvent({ - type: "disconnected", - data: e - }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this; - } - update(e, t, n) { - let i = null, r = null, o = null, a = this._targetRay, l = this._grip, c = this._hand; - if (e && t.session.visibilityState !== "visible-blurred") if (a !== null && (i = t.getPose(e.targetRaySpace, n), i !== null && (a.matrix.fromArray(i.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), i.linearVelocity ? (a.hasLinearVelocity = !0, a.linearVelocity.copy(i.linearVelocity)) : a.hasLinearVelocity = !1, i.angularVelocity ? (a.hasAngularVelocity = !0, a.angularVelocity.copy(i.angularVelocity)) : a.hasAngularVelocity = !1, this.dispatchEvent(Ax))), c && e.hand) { - o = !0; - for (let x of e.hand.values()){ - let v = t.getJointPose(x, n); - if (c.joints[x.jointName] === void 0) { - let p = new Hn; - p.matrixAutoUpdate = !1, p.visible = !1, c.joints[x.jointName] = p, c.add(p); - } - let g = c.joints[x.jointName]; - v !== null && (g.matrix.fromArray(v.transform.matrix), g.matrix.decompose(g.position, g.rotation, g.scale), g.jointRadius = v.radius), g.visible = v !== null; - } - let h = c.joints["index-finger-tip"], u = c.joints["thumb-tip"], d = h.position.distanceTo(u.position), f = .02, m = .005; - c.inputState.pinching && d > f + m ? (c.inputState.pinching = !1, this.dispatchEvent({ - type: "pinchend", - handedness: e.handedness, - target: this - })) : !c.inputState.pinching && d <= f - m && (c.inputState.pinching = !0, this.dispatchEvent({ - type: "pinchstart", - handedness: e.handedness, - target: this - })); - } else l !== null && e.gripSpace && (r = t.getPose(e.gripSpace, n), r !== null && (l.matrix.fromArray(r.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), 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)); - return a !== null && (a.visible = i !== null), l !== null && (l.visible = r !== null), c !== null && (c.visible = o !== null), this; - } -}, ks = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h){ - if (h = h !== void 0 ? h : Vn, h !== Vn && h !== Li) throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); - n === void 0 && h === Vn && (n = cr), n === void 0 && h === Li && (n = Ti); - super(null, i, r, o, a, l, h, n, c); - this.image = { - width: e, - height: t - }, this.magFilter = a !== void 0 ? a : rt, this.minFilter = l !== void 0 ? l : rt, this.flipY = !1, this.generateMipmaps = !1; - } -}; -ks.prototype.isDepthTexture = !0; -var vh = class extends En { - constructor(e, t){ - super(); - let n = this, i = null, r = 1, o = null, a = "local-floor", l = e.extensions.has("WEBGL_multisampled_render_to_texture"), c = null, h = null, u = null, d = null, f = !1, m = null, x = t.getContextAttributes(), v = null, g = null, p = [], _ = new Map, y = new ut; - y.layers.enable(1), y.viewport = new Ve; - let b = new ut; - b.layers.enable(2), b.viewport = new Ve; - let A = [ - y, - b - ], L = new ga; - L.layers.enable(1), L.layers.enable(2); - let I = null, k = null; - this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getTargetRaySpace(); - }, this.getControllerGrip = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getGripSpace(); - }, this.getHand = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getHandSpace(); - }; - function B(V) { - let W = _.get(V.inputSource); - W && W.dispatchEvent({ - type: V.type, - data: V.inputSource - }); - } - function P() { - _.forEach(function(V, W) { - V.disconnect(W); - }), _.clear(), I = null, k = null, e.setRenderTarget(v), d = null, u = null, h = null, i = null, g = null, ce.stop(), n.isPresenting = !1, n.dispatchEvent({ - type: "sessionend" - }); - } - this.setFramebufferScaleFactor = function(V) { - r = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); - }, this.setReferenceSpaceType = function(V) { - a = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); - }, this.getReferenceSpace = function() { - return o; - }, this.getBaseLayer = function() { - return u !== null ? u : d; - }, this.getBinding = function() { - return h; - }, this.getFrame = function() { - return m; - }, this.getSession = function() { - return i; - }, this.setSession = async function(V) { - if (i = V, i !== null) { - if (v = e.getRenderTarget(), i.addEventListener("select", B), i.addEventListener("selectstart", B), i.addEventListener("selectend", B), i.addEventListener("squeeze", B), i.addEventListener("squeezestart", B), i.addEventListener("squeezeend", B), i.addEventListener("end", P), i.addEventListener("inputsourceschange", w), x.xrCompatible !== !0 && await t.makeXRCompatible(), i.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) { - let W = { - antialias: i.renderState.layers === void 0 ? x.antialias : !0, - alpha: x.alpha, - depth: x.depth, - stencil: x.stencil, - framebufferScaleFactor: r - }; - d = new XRWebGLLayer(i, t, W), i.updateRenderState({ - baseLayer: d - }), g = new At(d.framebufferWidth, d.framebufferHeight, { - format: ct, - type: rn, - encoding: e.outputEncoding - }); - } else { - f = x.antialias; - let W = null, he = null, le = null; - x.depth && (le = x.stencil ? 35056 : 33190, W = x.stencil ? Li : Vn, he = x.stencil ? Ti : cr); - let fe = { - colorFormat: x.alpha || f ? 32856 : 32849, - depthFormat: le, - scaleFactor: r - }; - h = new XRWebGLBinding(i, t), u = h.createProjectionLayer(fe), i.updateRenderState({ - layers: [ - u - ] - }), f ? g = new Xs(u.textureWidth, u.textureHeight, { - format: ct, - type: rn, - depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), - stencilBuffer: x.stencil, - ignoreDepth: u.ignoreDepthValues, - useRenderToTexture: l, - encoding: e.outputEncoding - }) : g = new At(u.textureWidth, u.textureHeight, { - format: x.alpha ? ct : Gn, - type: rn, - depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), - stencilBuffer: x.stencil, - ignoreDepth: u.ignoreDepthValues, - encoding: e.outputEncoding - }); - } - this.setFoveation(1), o = await i.requestReferenceSpace(a), ce.setContext(i), ce.start(), n.isPresenting = !0, n.dispatchEvent({ - type: "sessionstart" - }); - } - }; - function w(V) { - let W = i.inputSources; - for(let he = 0; he < p.length; he++)_.set(W[he], p[he]); - for(let he = 0; he < V.removed.length; he++){ - let le = V.removed[he], fe = _.get(le); - fe && (fe.dispatchEvent({ - type: "disconnected", - data: le - }), _.delete(le)); - } - for(let he = 0; he < V.added.length; he++){ - let le = V.added[he], fe = _.get(le); - fe && fe.dispatchEvent({ - type: "connected", - data: le - }); - } - } - let E = new M, D = new M; - function U(V, W, he) { - E.setFromMatrixPosition(W.matrixWorld), D.setFromMatrixPosition(he.matrixWorld); - let le = E.distanceTo(D), fe = W.projectionMatrix.elements, Be = he.projectionMatrix.elements, Y = fe[14] / (fe[10] - 1), Ce = fe[14] / (fe[10] + 1), ye = (fe[9] + 1) / fe[5], ge = (fe[9] - 1) / fe[5], xe = (fe[8] - 1) / fe[0], Oe = (Be[8] + 1) / Be[0], G = Y * xe, j = Y * Oe, K = le / (-xe + Oe), ue = K * -xe; - W.matrixWorld.decompose(V.position, V.quaternion, V.scale), V.translateX(ue), V.translateZ(K), V.matrixWorld.compose(V.position, V.quaternion, V.scale), V.matrixWorldInverse.copy(V.matrixWorld).invert(); - let se = Y + K, Se = Ce + K, Te = G - ue, Pe = j + (le - ue), Ye = ye * Ce / Se * se, C = ge * Ce / Se * se; - V.projectionMatrix.makePerspective(Te, Pe, Ye, C, se, Se); - } - function F(V, W) { - W === null ? V.matrixWorld.copy(V.matrix) : V.matrixWorld.multiplyMatrices(W.matrixWorld, V.matrix), V.matrixWorldInverse.copy(V.matrixWorld).invert(); - } - this.updateCamera = function(V) { - if (i === null) return; - L.near = b.near = y.near = V.near, L.far = b.far = y.far = V.far, (I !== L.near || k !== L.far) && (i.updateRenderState({ - depthNear: L.near, - depthFar: L.far - }), I = L.near, k = L.far); - let W = V.parent, he = L.cameras; - F(L, W); - for(let fe = 0; fe < he.length; fe++)F(he[fe], W); - L.matrixWorld.decompose(L.position, L.quaternion, L.scale), V.position.copy(L.position), V.quaternion.copy(L.quaternion), V.scale.copy(L.scale), V.matrix.copy(L.matrix), V.matrixWorld.copy(L.matrixWorld); - let le = V.children; - for(let fe = 0, Be = le.length; fe < Be; fe++)le[fe].updateMatrixWorld(!0); - he.length === 2 ? U(L, y, b) : L.projectionMatrix.copy(y.projectionMatrix); - }, this.getCamera = function() { - return L; - }, this.getFoveation = function() { - if (u !== null) return u.fixedFoveation; - if (d !== null) return d.fixedFoveation; - }, this.setFoveation = function(V) { - u !== null && (u.fixedFoveation = V), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = V); - }; - let O = null; - function ne(V, W) { - if (c = W.getViewerPose(o), m = W, c !== null) { - let le = c.views; - d !== null && (e.setRenderTargetFramebuffer(g, d.framebuffer), e.setRenderTarget(g)); - let fe = !1; - le.length !== L.cameras.length && (L.cameras.length = 0, fe = !0); - for(let Be = 0; Be < le.length; Be++){ - let Y = le[Be], Ce = null; - if (d !== null) Ce = d.getViewport(Y); - else { - let ge = h.getViewSubImage(u, Y); - Ce = ge.viewport, Be === 0 && (e.setRenderTargetTextures(g, ge.colorTexture, u.ignoreDepthValues ? void 0 : ge.depthStencilTexture), e.setRenderTarget(g)); - } - let ye = A[Be]; - ye.matrix.fromArray(Y.transform.matrix), ye.projectionMatrix.fromArray(Y.projectionMatrix), ye.viewport.set(Ce.x, Ce.y, Ce.width, Ce.height), Be === 0 && L.matrix.copy(ye.matrix), fe === !0 && L.cameras.push(ye); - } - } - let he = i.inputSources; - for(let le = 0; le < p.length; le++){ - let fe = p[le], Be = he[le]; - fe.update(Be, W, o); - } - O && O(V, W), m = null; - } - let ce = new rh; - ce.setAnimationLoop(ne), this.setAnimationLoop = function(V) { - O = V; - }, this.dispose = function() {}; - } -}; -function Cx(s) { - function e(g, p) { - g.fogColor.value.copy(p.color), p.isFog ? (g.fogNear.value = p.near, g.fogFar.value = p.far) : p.isFogExp2 && (g.fogDensity.value = p.density); - } - function t(g, p, _, y, b) { - p.isMeshBasicMaterial ? n(g, p) : p.isMeshLambertMaterial ? (n(g, p), l(g, p)) : p.isMeshToonMaterial ? (n(g, p), h(g, p)) : p.isMeshPhongMaterial ? (n(g, p), c(g, p)) : p.isMeshStandardMaterial ? (n(g, p), p.isMeshPhysicalMaterial ? d(g, p, b) : u(g, p)) : p.isMeshMatcapMaterial ? (n(g, p), f(g, p)) : p.isMeshDepthMaterial ? (n(g, p), m(g, p)) : p.isMeshDistanceMaterial ? (n(g, p), x(g, p)) : p.isMeshNormalMaterial ? (n(g, p), v(g, p)) : p.isLineBasicMaterial ? (i(g, p), p.isLineDashedMaterial && r(g, p)) : p.isPointsMaterial ? o(g, p, _, y) : p.isSpriteMaterial ? a(g, p) : p.isShadowMaterial ? (g.color.value.copy(p.color), g.opacity.value = p.opacity) : p.isShaderMaterial && (p.uniformsNeedUpdate = !1); - } - function n(g, p) { - g.opacity.value = p.opacity, p.color && g.diffuse.value.copy(p.color), p.emissive && g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity), p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.specularMap && (g.specularMap.value = p.specularMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let _ = s.get(p).envMap; - _ && (g.envMap.value = _, g.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, 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), p.aoMap && (g.aoMap.value = p.aoMap, g.aoMapIntensity.value = p.aoMapIntensity); - let y; - p.map ? y = p.map : p.specularMap ? y = p.specularMap : p.displacementMap ? y = p.displacementMap : p.normalMap ? y = p.normalMap : p.bumpMap ? y = p.bumpMap : p.roughnessMap ? y = p.roughnessMap : p.metalnessMap ? y = p.metalnessMap : p.alphaMap ? y = p.alphaMap : p.emissiveMap ? y = p.emissiveMap : p.clearcoatMap ? y = p.clearcoatMap : p.clearcoatNormalMap ? y = p.clearcoatNormalMap : p.clearcoatRoughnessMap ? y = p.clearcoatRoughnessMap : p.specularIntensityMap ? y = p.specularIntensityMap : p.specularColorMap ? y = p.specularColorMap : p.transmissionMap ? y = p.transmissionMap : p.thicknessMap ? y = p.thicknessMap : p.sheenColorMap ? y = p.sheenColorMap : p.sheenRoughnessMap && (y = p.sheenRoughnessMap), y !== void 0 && (y.isWebGLRenderTarget && (y = y.texture), y.matrixAutoUpdate === !0 && y.updateMatrix(), g.uvTransform.value.copy(y.matrix)); - let b; - p.aoMap ? b = p.aoMap : p.lightMap && (b = p.lightMap), b !== void 0 && (b.isWebGLRenderTarget && (b = b.texture), b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uv2Transform.value.copy(b.matrix)); - } - function i(g, p) { - g.diffuse.value.copy(p.color), g.opacity.value = p.opacity; - } - function r(g, p) { - g.dashSize.value = p.dashSize, g.totalSize.value = p.dashSize + p.gapSize, g.scale.value = p.scale; - } - function o(g, p, _, y) { - g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.size.value = p.size * _, g.scale.value = y * .5, p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let b; - p.map ? b = p.map : p.alphaMap && (b = p.alphaMap), b !== void 0 && (b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uvTransform.value.copy(b.matrix)); - } - function a(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), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let _; - p.map ? _ = p.map : p.alphaMap && (_ = p.alphaMap), _ !== void 0 && (_.matrixAutoUpdate === !0 && _.updateMatrix(), g.uvTransform.value.copy(_.matrix)); - } - function l(g, p) { - p.emissiveMap && (g.emissiveMap.value = p.emissiveMap); - } - function c(g, p) { - g.specular.value.copy(p.specular), g.shininess.value = Math.max(p.shininess, 1e-4), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); - } - function h(g, p) { - p.gradientMap && (g.gradientMap.value = p.gradientMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); - } - function u(g, p) { - g.roughness.value = p.roughness, g.metalness.value = p.metalness, p.roughnessMap && (g.roughnessMap.value = p.roughnessMap), p.metalnessMap && (g.metalnessMap.value = p.metalnessMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), s.get(p).envMap && (g.envMapIntensity.value = p.envMapIntensity); - } - function d(g, p, _) { - u(g, p), 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), p.sheenRoughnessMap && (g.sheenRoughnessMap.value = p.sheenRoughnessMap)), p.clearcoat > 0 && (g.clearcoat.value = p.clearcoat, g.clearcoatRoughness.value = p.clearcoatRoughness, p.clearcoatMap && (g.clearcoatMap.value = p.clearcoatMap), p.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = p.clearcoatRoughnessMap), p.clearcoatNormalMap && (g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale), g.clearcoatNormalMap.value = p.clearcoatNormalMap, p.side === it && g.clearcoatNormalScale.value.negate())), p.transmission > 0 && (g.transmission.value = p.transmission, g.transmissionSamplerMap.value = _.texture, g.transmissionSamplerSize.value.set(_.width, _.height), p.transmissionMap && (g.transmissionMap.value = p.transmissionMap), g.thickness.value = p.thickness, p.thicknessMap && (g.thicknessMap.value = p.thicknessMap), g.attenuationDistance.value = p.attenuationDistance, g.attenuationColor.value.copy(p.attenuationColor)), g.specularIntensity.value = p.specularIntensity, g.specularColor.value.copy(p.specularColor), p.specularIntensityMap && (g.specularIntensityMap.value = p.specularIntensityMap), p.specularColorMap && (g.specularColorMap.value = p.specularColorMap); - } - function f(g, p) { - p.matcap && (g.matcap.value = p.matcap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); - } - function m(g, p) { - p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); - } - function x(g, p) { - p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), g.referencePosition.value.copy(p.referencePosition), g.nearDistance.value = p.nearDistance, g.farDistance.value = p.farDistance; - } - function v(g, p) { - p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); - } - return { - refreshFogUniforms: e, - refreshMaterialUniforms: t - }; -} -function Lx() { - let s = qs("canvas"); - return s.style.display = "block", s; -} -function qe(s = {}) { - let e = s.canvas !== void 0 ? s.canvas : Lx(), t = s.context !== void 0 ? s.context : null, n = s.alpha !== void 0 ? s.alpha : !1, i = s.depth !== void 0 ? s.depth : !0, r = s.stencil !== void 0 ? s.stencil : !0, o = s.antialias !== void 0 ? s.antialias : !1, a = s.premultipliedAlpha !== void 0 ? s.premultipliedAlpha : !0, l = s.preserveDrawingBuffer !== void 0 ? s.preserveDrawingBuffer : !1, c = s.powerPreference !== void 0 ? s.powerPreference : "default", h = s.failIfMajorPerformanceCaveat !== void 0 ? s.failIfMajorPerformanceCaveat : !1, u = null, d = null, f = [], m = []; - this.domElement = e, this.debug = { - checkShaderErrors: !0 - }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.outputEncoding = Nt, this.physicallyCorrectLights = !1, this.toneMapping = _n, this.toneMappingExposure = 1; - let x = this, v = !1, g = 0, p = 0, _ = null, y = -1, b = null, A = new Ve, L = new Ve, I = null, k = e.width, B = e.height, P = 1, w = null, E = null, D = new Ve(0, 0, k, B), U = new Ve(0, 0, k, B), F = !1, O = [], ne = new Dr, ce = !1, V = !1, W = null, he = new pe, le = new M, fe = { - background: null, - fog: null, - environment: null, - overrideMaterial: null, - isScene: !0 - }; - function Be() { - return _ === null ? P : 1; - } - let Y = t; - function Ce(S, N) { - for(let H = 0; H < S.length; H++){ - let z = S[H], q = e.getContext(z, N); - if (q !== null) return q; - } - return null; - } - try { - let S = { - alpha: n, - depth: i, - stencil: r, - antialias: o, - premultipliedAlpha: a, - preserveDrawingBuffer: l, - powerPreference: c, - failIfMajorPerformanceCaveat: h - }; - if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${ca}`), e.addEventListener("webglcontextlost", Ee, !1), e.addEventListener("webglcontextrestored", me, !1), Y === null) { - let N = [ - "webgl2", - "webgl", - "experimental-webgl" - ]; - if (x.isWebGL1Renderer === !0 && N.shift(), Y = Ce(N, S), Y === null) throw Ce(N) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); - } - Y.getShaderPrecisionFormat === void 0 && (Y.getShaderPrecisionFormat = function() { - return { - rangeMin: 1, - rangeMax: 1, - precision: 1 - }; - }); - } catch (S) { - throw console.error("THREE.WebGLRenderer: " + S.message), S; - } - let ye, ge, xe, Oe, G, j, K, ue, se, Se, Te, Pe, Ye, C, T, J, $, re, Z, Me, ve, te, R; - function ee() { - ye = new Qm(Y), ge = new Xm(Y, ye, s), ye.init(ge), te = new Ex(Y, ye, ge), xe = new Sx(Y, ye, ge), O[0] = 1029, Oe = new tg(Y), G = new fx, j = new Tx(Y, ye, xe, G, ge, te, Oe), K = new Ym(x), ue = new jm(x), se = new gf(Y, ge), R = new Wm(Y, ye, se, ge), Se = new Km(Y, se, Oe, R), Te = new sg(Y, Se, se, Oe), Z = new rg(Y, ge, j), J = new Jm(G), Pe = new dx(x, K, ue, ye, ge, R, J), Ye = new Cx(G), C = new mx, T = new Mx(ye, ge), re = new Vm(x, K, xe, Te, a), $ = new yh(x, Te, ge), Me = new qm(Y, ye, Oe, ge), ve = new eg(Y, ye, Oe, ge), Oe.programs = Pe.programs, x.capabilities = ge, x.extensions = ye, x.properties = G, x.renderLists = C, x.shadowMap = $, x.state = xe, x.info = Oe; - } - ee(); - let Q = new vh(x, Y); - this.xr = Q, this.getContext = function() { - return Y; - }, this.getContextAttributes = function() { - return Y.getContextAttributes(); - }, this.forceContextLoss = function() { - let S = ye.get("WEBGL_lose_context"); - S && S.loseContext(); - }, this.forceContextRestore = function() { - let S = ye.get("WEBGL_lose_context"); - S && S.restoreContext(); - }, this.getPixelRatio = function() { - return P; - }, this.setPixelRatio = function(S) { - S !== void 0 && (P = S, this.setSize(k, B, !1)); - }, this.getSize = function(S) { - return S.set(k, B); - }, this.setSize = function(S, N, H) { - if (Q.isPresenting) { - console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); - return; - } - k = S, B = N, e.width = Math.floor(S * P), e.height = Math.floor(N * P), H !== !1 && (e.style.width = S + "px", e.style.height = N + "px"), this.setViewport(0, 0, S, N); - }, this.getDrawingBufferSize = function(S) { - return S.set(k * P, B * P).floor(); - }, this.setDrawingBufferSize = function(S, N, H) { - k = S, B = N, P = H, e.width = Math.floor(S * H), e.height = Math.floor(N * H), this.setViewport(0, 0, S, N); - }, this.getCurrentViewport = function(S) { - return S.copy(A); - }, this.getViewport = function(S) { - return S.copy(D); - }, this.setViewport = function(S, N, H, z) { - S.isVector4 ? D.set(S.x, S.y, S.z, S.w) : D.set(S, N, H, z), xe.viewport(A.copy(D).multiplyScalar(P).floor()); - }, this.getScissor = function(S) { - return S.copy(U); - }, this.setScissor = function(S, N, H, z) { - S.isVector4 ? U.set(S.x, S.y, S.z, S.w) : U.set(S, N, H, z), xe.scissor(L.copy(U).multiplyScalar(P).floor()); - }, this.getScissorTest = function() { - return F; - }, this.setScissorTest = function(S) { - xe.setScissorTest(F = S); - }, this.setOpaqueSort = function(S) { - w = S; - }, this.setTransparentSort = function(S) { - E = S; - }, this.getClearColor = function(S) { - return S.copy(re.getClearColor()); - }, this.setClearColor = function() { - re.setClearColor.apply(re, arguments); - }, this.getClearAlpha = function() { - return re.getClearAlpha(); - }, this.setClearAlpha = function() { - re.setClearAlpha.apply(re, arguments); - }, this.clear = function(S, N, H) { - let z = 0; - (S === void 0 || S) && (z |= 16384), (N === void 0 || N) && (z |= 256), (H === void 0 || H) && (z |= 1024), Y.clear(z); - }, this.clearColor = function() { - this.clear(!0, !1, !1); - }, this.clearDepth = function() { - this.clear(!1, !0, !1); - }, this.clearStencil = function() { - this.clear(!1, !1, !0); - }, this.dispose = function() { - e.removeEventListener("webglcontextlost", Ee, !1), e.removeEventListener("webglcontextrestored", me, !1), C.dispose(), T.dispose(), G.dispose(), K.dispose(), ue.dispose(), Te.dispose(), R.dispose(), Pe.dispose(), Q.dispose(), Q.removeEventListener("sessionstart", Ut), Q.removeEventListener("sessionend", Ot), W && (W.dispose(), W = null), Ln.stop(); - }; - function Ee(S) { - S.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), v = !0; - } - function me() { - console.log("THREE.WebGLRenderer: Context Restored."), v = !1; - let S = Oe.autoReset, N = $.enabled, H = $.autoUpdate, z = $.needsUpdate, q = $.type; - ee(), Oe.autoReset = S, $.enabled = N, $.autoUpdate = H, $.needsUpdate = z, $.type = q; - } - function Re(S) { - let N = S.target; - N.removeEventListener("dispose", Re), oe(N); - } - function oe(S) { - Le(S), G.remove(S); - } - function Le(S) { - let N = G.get(S).programs; - N !== void 0 && (N.forEach(function(H) { - Pe.releaseProgram(H); - }), S.isShaderMaterial && Pe.releaseShaderCache(S)); - } - this.renderBufferDirect = function(S, N, H, z, q, be) { - N === null && (N = fe); - let Ae = q.isMesh && q.matrixWorld.determinant() < 0, Ie = lu(S, N, H, z, q); - xe.setMaterial(z, Ae); - let we = H.index, He = H.attributes.position; - if (we === null) { - if (He === void 0 || He.count === 0) return; - } else if (we.count === 0) return; - let De = 1; - z.wireframe === !0 && (we = Se.getWireframeAttribute(H), De = 2), R.setup(q, z, Ie, H, we); - let ze, je = Me; - we !== null && (ze = se.get(we), je = ve, je.setIndex(ze)); - let Rn = we !== null ? we.count : He.count, ei = H.drawRange.start * De, Ge = H.drawRange.count * De, Ht = be !== null ? be.start * De : 0, at = be !== null ? be.count * De : 1 / 0, kt = Math.max(ei, Ht), Gr = Math.min(Rn, ei + Ge, Ht + at) - 1, Gt = Math.max(0, Gr - kt + 1); - if (Gt !== 0) { - if (q.isMesh) z.wireframe === !0 ? (xe.setLineWidth(z.wireframeLinewidth * Be()), je.setMode(1)) : je.setMode(4); - else if (q.isLine) { - let Zt = z.linewidth; - Zt === void 0 && (Zt = 1), xe.setLineWidth(Zt * Be()), q.isLineSegments ? je.setMode(1) : q.isLineLoop ? je.setMode(2) : je.setMode(3); - } else q.isPoints ? je.setMode(0) : q.isSprite && je.setMode(4); - if (q.isInstancedMesh) je.renderInstances(kt, Gt, q.count); - else if (H.isInstancedBufferGeometry) { - let Zt = Math.min(H.instanceCount, H._maxInstanceCount); - je.renderInstances(kt, Gt, Zt); - } else je.render(kt, Gt); - } - }, this.compile = function(S, N) { - d = T.get(S), d.init(), m.push(d), S.traverseVisible(function(H) { - H.isLight && H.layers.test(N.layers) && (d.pushLight(H), H.castShadow && d.pushShadow(H)); - }), d.setupLights(x.physicallyCorrectLights), S.traverse(function(H) { - let z = H.material; - if (z) if (Array.isArray(z)) for(let q = 0; q < z.length; q++){ - let be = z[q]; - xo(be, S, H); - } - else xo(z, S, H); - }), m.pop(), d = null; - }; - let Xe = null; - function We(S) { - Xe && Xe(S); - } - function Ut() { - Ln.stop(); - } - function Ot() { - Ln.start(); - } - let Ln = new rh; - Ln.setAnimationLoop(We), typeof window < "u" && Ln.setContext(window), this.setAnimationLoop = function(S) { - Xe = S, Q.setAnimationLoop(S), S === null ? Ln.stop() : Ln.start(); - }, Q.addEventListener("sessionstart", Ut), Q.addEventListener("sessionend", Ot), this.render = function(S, N) { - if (N !== void 0 && N.isCamera !== !0) { - console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); - return; - } - if (v === !0) return; - S.autoUpdate === !0 && S.updateMatrixWorld(), N.parent === null && N.updateMatrixWorld(), Q.enabled === !0 && Q.isPresenting === !0 && (Q.cameraAutoUpdate === !0 && Q.updateCamera(N), N = Q.getCamera()), S.isScene === !0 && S.onBeforeRender(x, S, N, _), d = T.get(S, m.length), d.init(), m.push(d), he.multiplyMatrices(N.projectionMatrix, N.matrixWorldInverse), ne.setFromProjectionMatrix(he), V = this.localClippingEnabled, ce = J.init(this.clippingPlanes, V, N), u = C.get(S, f.length), u.init(), f.push(u), Qa(S, N, 0, x.sortObjects), u.finish(), x.sortObjects === !0 && u.sort(w, E), ce === !0 && J.beginShadows(); - let H = d.state.shadowsArray; - if ($.render(H, S, N), ce === !0 && J.endShadows(), this.info.autoReset === !0 && this.info.reset(), re.render(u, S), d.setupLights(x.physicallyCorrectLights), N.isArrayCamera) { - let z = N.cameras; - for(let q = 0, be = z.length; q < be; q++){ - let Ae = z[q]; - Ka(u, S, Ae, Ae.viewport); - } - } else Ka(u, S, N); - _ !== null && (j.updateMultisampleRenderTarget(_), j.updateRenderTargetMipmap(_)), S.isScene === !0 && S.onAfterRender(x, S, N), xe.buffers.depth.setTest(!0), xe.buffers.depth.setMask(!0), xe.buffers.color.setMask(!0), xe.setPolygonOffset(!1), R.resetDefaultState(), y = -1, b = null, m.pop(), m.length > 0 ? d = m[m.length - 1] : d = null, f.pop(), f.length > 0 ? u = f[f.length - 1] : u = null; - }; - function Qa(S, N, H, z) { - if (S.visible === !1) return; - if (S.layers.test(N.layers)) { - if (S.isGroup) H = S.renderOrder; - else if (S.isLOD) S.autoUpdate === !0 && S.update(N); - else if (S.isLight) d.pushLight(S), S.castShadow && d.pushShadow(S); - else if (S.isSprite) { - if (!S.frustumCulled || ne.intersectsSprite(S)) { - z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); - let Ae = Te.update(S), Ie = S.material; - Ie.visible && u.push(S, Ae, Ie, H, le.z, null); - } - } else if ((S.isMesh || S.isLine || S.isPoints) && (S.isSkinnedMesh && S.skeleton.frame !== Oe.render.frame && (S.skeleton.update(), S.skeleton.frame = Oe.render.frame), !S.frustumCulled || ne.intersectsObject(S))) { - z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); - let Ae = Te.update(S), Ie = S.material; - if (Array.isArray(Ie)) { - let we = Ae.groups; - for(let He = 0, De = we.length; He < De; He++){ - let ze = we[He], je = Ie[ze.materialIndex]; - je && je.visible && u.push(S, Ae, je, H, le.z, ze); - } - } else Ie.visible && u.push(S, Ae, Ie, H, le.z, null); - } - } - let be = S.children; - for(let Ae = 0, Ie = be.length; Ae < Ie; Ae++)Qa(be[Ae], N, H, z); - } - function Ka(S, N, H, z) { - let q = S.opaque, be = S.transmissive, Ae = S.transparent; - d.setupLightsView(H), be.length > 0 && ou(q, N, H), z && xe.viewport(A.copy(z)), q.length > 0 && kr(q, N, H), be.length > 0 && kr(be, N, H), Ae.length > 0 && kr(Ae, N, H); - } - function ou(S, N, H) { - if (W === null) { - let Ae = o === !0 && ge.isWebGL2 === !0 ? Xs : At; - W = new Ae(1024, 1024, { - generateMipmaps: !0, - type: te.convert(kn) !== null ? kn : rn, - minFilter: Ui, - magFilter: rt, - wrapS: vt, - wrapT: vt, - useRenderToTexture: ye.has("WEBGL_multisampled_render_to_texture") - }); - } - let z = x.getRenderTarget(); - x.setRenderTarget(W), x.clear(); - let q = x.toneMapping; - x.toneMapping = _n, kr(S, N, H), x.toneMapping = q, j.updateMultisampleRenderTarget(W), j.updateRenderTargetMipmap(W), x.setRenderTarget(z); - } - function kr(S, N, H) { - let z = N.isScene === !0 ? N.overrideMaterial : null; - for(let q = 0, be = S.length; q < be; q++){ - let Ae = S[q], Ie = Ae.object, we = Ae.geometry, He = z === null ? Ae.material : z, De = Ae.group; - Ie.layers.test(H.layers) && au(Ie, N, H, we, He, De); - } - } - function au(S, N, H, z, q, be) { - S.onBeforeRender(x, N, H, z, q, be), S.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse, S.matrixWorld), S.normalMatrix.getNormalMatrix(S.modelViewMatrix), q.onBeforeRender(x, N, H, z, S, be), q.transparent === !0 && q.side === Ci ? (q.side = it, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ai, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ci) : x.renderBufferDirect(H, N, z, q, S, be), S.onAfterRender(x, N, H, z, q, be); - } - function xo(S, N, H) { - N.isScene !== !0 && (N = fe); - let z = G.get(S), q = d.state.lights, be = d.state.shadowsArray, Ae = q.state.version, Ie = Pe.getParameters(S, q.state, be, N, H), we = Pe.getProgramCacheKey(Ie), He = z.programs; - z.environment = S.isMeshStandardMaterial ? N.environment : null, z.fog = N.fog, z.envMap = (S.isMeshStandardMaterial ? ue : K).get(S.envMap || z.environment), He === void 0 && (S.addEventListener("dispose", Re), He = new Map, z.programs = He); - let De = He.get(we); - if (De !== void 0) { - if (z.currentProgram === De && z.lightsStateVersion === Ae) return el(S, Ie), De; - } else Ie.uniforms = Pe.getUniforms(S), S.onBuild(H, Ie, x), S.onBeforeCompile(Ie, x), De = Pe.acquireProgram(Ie, we), He.set(we, De), z.uniforms = Ie.uniforms; - let ze = z.uniforms; - (!S.isShaderMaterial && !S.isRawShaderMaterial || S.clipping === !0) && (ze.clippingPlanes = J.uniform), el(S, Ie), z.needsLights = hu(S), z.lightsStateVersion = Ae, z.needsLights && (ze.ambientLightColor.value = q.state.ambient, ze.lightProbe.value = q.state.probe, ze.directionalLights.value = q.state.directional, ze.directionalLightShadows.value = q.state.directionalShadow, ze.spotLights.value = q.state.spot, ze.spotLightShadows.value = q.state.spotShadow, ze.rectAreaLights.value = q.state.rectArea, ze.ltc_1.value = q.state.rectAreaLTC1, ze.ltc_2.value = q.state.rectAreaLTC2, ze.pointLights.value = q.state.point, ze.pointLightShadows.value = q.state.pointShadow, ze.hemisphereLights.value = q.state.hemi, ze.directionalShadowMap.value = q.state.directionalShadowMap, ze.directionalShadowMatrix.value = q.state.directionalShadowMatrix, ze.spotShadowMap.value = q.state.spotShadowMap, ze.spotShadowMatrix.value = q.state.spotShadowMatrix, ze.pointShadowMap.value = q.state.pointShadowMap, ze.pointShadowMatrix.value = q.state.pointShadowMatrix); - let je = De.getUniforms(), Rn = bn.seqWithValue(je.seq, ze); - return z.currentProgram = De, z.uniformsList = Rn, De; - } - function el(S, N) { - let H = G.get(S); - H.outputEncoding = N.outputEncoding, H.instancing = N.instancing, H.skinning = N.skinning, H.morphTargets = N.morphTargets, H.morphNormals = N.morphNormals, H.morphTargetsCount = N.morphTargetsCount, H.numClippingPlanes = N.numClippingPlanes, H.numIntersection = N.numClipIntersection, H.vertexAlphas = N.vertexAlphas, H.vertexTangents = N.vertexTangents, H.toneMapping = N.toneMapping; - } - function lu(S, N, H, z, q) { - N.isScene !== !0 && (N = fe), j.resetTextureUnits(); - let be = N.fog, Ae = z.isMeshStandardMaterial ? N.environment : null, Ie = _ === null ? x.outputEncoding : _.texture.encoding, we = (z.isMeshStandardMaterial ? ue : K).get(z.envMap || Ae), He = z.vertexColors === !0 && !!H.attributes.color && H.attributes.color.itemSize === 4, De = !!z.normalMap && !!H.attributes.tangent, ze = !!H.morphAttributes.position, je = !!H.morphAttributes.normal, Rn = H.morphAttributes.position ? H.morphAttributes.position.length : 0, ei = z.toneMapped ? x.toneMapping : _n, Ge = G.get(z), Ht = d.state.lights; - if (ce === !0 && (V === !0 || S !== b)) { - let Pt = S === b && z.id === y; - J.setState(z, S, Pt); - } - let at = !1; - z.version === Ge.__version ? (Ge.needsLights && Ge.lightsStateVersion !== Ht.state.version || Ge.outputEncoding !== Ie || q.isInstancedMesh && Ge.instancing === !1 || !q.isInstancedMesh && Ge.instancing === !0 || q.isSkinnedMesh && Ge.skinning === !1 || !q.isSkinnedMesh && Ge.skinning === !0 || Ge.envMap !== we || z.fog && Ge.fog !== be || Ge.numClippingPlanes !== void 0 && (Ge.numClippingPlanes !== J.numPlanes || Ge.numIntersection !== J.numIntersection) || Ge.vertexAlphas !== He || Ge.vertexTangents !== De || Ge.morphTargets !== ze || Ge.morphNormals !== je || Ge.toneMapping !== ei || ge.isWebGL2 === !0 && Ge.morphTargetsCount !== Rn) && (at = !0) : (at = !0, Ge.__version = z.version); - let kt = Ge.currentProgram; - at === !0 && (kt = xo(z, N, q)); - let Gr = !1, Gt = !1, Zt = !1, xt = kt.getUniforms(), Xi = Ge.uniforms; - if (xe.useProgram(kt.program) && (Gr = !0, Gt = !0, Zt = !0), z.id !== y && (y = z.id, Gt = !0), Gr || b !== S) { - if (xt.setValue(Y, "projectionMatrix", S.projectionMatrix), ge.logarithmicDepthBuffer && xt.setValue(Y, "logDepthBufFC", 2 / (Math.log(S.far + 1) / Math.LN2)), b !== S && (b = S, Gt = !0, Zt = !0), z.isShaderMaterial || z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshStandardMaterial || z.envMap) { - let Pt = xt.map.cameraPosition; - Pt !== void 0 && Pt.setValue(Y, le.setFromMatrixPosition(S.matrixWorld)); - } - (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial) && xt.setValue(Y, "isOrthographic", S.isOrthographicCamera === !0), (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial || z.isShadowMaterial || q.isSkinnedMesh) && xt.setValue(Y, "viewMatrix", S.matrixWorldInverse); - } - if (q.isSkinnedMesh) { - xt.setOptional(Y, q, "bindMatrix"), xt.setOptional(Y, q, "bindMatrixInverse"); - let Pt = q.skeleton; - Pt && (ge.floatVertexTextures ? (Pt.boneTexture === null && Pt.computeBoneTexture(), xt.setValue(Y, "boneTexture", Pt.boneTexture, j), xt.setValue(Y, "boneTextureSize", Pt.boneTextureSize)) : xt.setOptional(Y, Pt, "boneMatrices")); - } - return !!H && (H.morphAttributes.position !== void 0 || H.morphAttributes.normal !== void 0) && Z.update(q, H, z, kt), (Gt || Ge.receiveShadow !== q.receiveShadow) && (Ge.receiveShadow = q.receiveShadow, xt.setValue(Y, "receiveShadow", q.receiveShadow)), Gt && (xt.setValue(Y, "toneMappingExposure", x.toneMappingExposure), Ge.needsLights && cu(Xi, Zt), be && z.fog && Ye.refreshFogUniforms(Xi, be), Ye.refreshMaterialUniforms(Xi, z, P, B, W), bn.upload(Y, Ge.uniformsList, Xi, j)), z.isShaderMaterial && z.uniformsNeedUpdate === !0 && (bn.upload(Y, Ge.uniformsList, Xi, j), z.uniformsNeedUpdate = !1), z.isSpriteMaterial && xt.setValue(Y, "center", q.center), xt.setValue(Y, "modelViewMatrix", q.modelViewMatrix), xt.setValue(Y, "normalMatrix", q.normalMatrix), xt.setValue(Y, "modelMatrix", q.matrixWorld), kt; - } - function cu(S, N) { - S.ambientLightColor.needsUpdate = N, S.lightProbe.needsUpdate = N, S.directionalLights.needsUpdate = N, S.directionalLightShadows.needsUpdate = N, S.pointLights.needsUpdate = N, S.pointLightShadows.needsUpdate = N, S.spotLights.needsUpdate = N, S.spotLightShadows.needsUpdate = N, S.rectAreaLights.needsUpdate = N, S.hemisphereLights.needsUpdate = N; - } - function hu(S) { - return S.isMeshLambertMaterial || S.isMeshToonMaterial || S.isMeshPhongMaterial || S.isMeshStandardMaterial || S.isShadowMaterial || S.isShaderMaterial && S.lights === !0; - } - this.getActiveCubeFace = function() { - return g; - }, this.getActiveMipmapLevel = function() { - return p; - }, this.getRenderTarget = function() { - return _; - }, this.setRenderTargetTextures = function(S, N, H) { - G.get(S.texture).__webglTexture = N, G.get(S.depthTexture).__webglTexture = H; - let z = G.get(S); - z.__hasExternalTextures = !0, z.__hasExternalTextures && (z.__autoAllocateDepthBuffer = H === void 0, z.__autoAllocateDepthBuffer || S.useRenderToTexture && (console.warn("render-to-texture extension was disabled because an external texture was provided"), S.useRenderToTexture = !1, S.useRenderbuffer = !0)); - }, this.setRenderTargetFramebuffer = function(S, N) { - let H = G.get(S); - H.__webglFramebuffer = N, H.__useDefaultFramebuffer = N === void 0; - }, this.setRenderTarget = function(S, N = 0, H = 0) { - _ = S, g = N, p = H; - let z = !0; - if (S) { - let we = G.get(S); - we.__useDefaultFramebuffer !== void 0 ? (xe.bindFramebuffer(36160, null), z = !1) : we.__webglFramebuffer === void 0 ? j.setupRenderTarget(S) : we.__hasExternalTextures && j.rebindTextures(S, G.get(S.texture).__webglTexture, G.get(S.depthTexture).__webglTexture); - } - let q = null, be = !1, Ae = !1; - if (S) { - let we = S.texture; - (we.isDataTexture3D || we.isDataTexture2DArray) && (Ae = !0); - let He = G.get(S).__webglFramebuffer; - S.isWebGLCubeRenderTarget ? (q = He[N], be = !0) : S.useRenderbuffer ? q = G.get(S).__webglMultisampledFramebuffer : q = He, A.copy(S.viewport), L.copy(S.scissor), I = S.scissorTest; - } else A.copy(D).multiplyScalar(P).floor(), L.copy(U).multiplyScalar(P).floor(), I = F; - if (xe.bindFramebuffer(36160, q) && ge.drawBuffers && z) { - let we = !1; - if (S) if (S.isWebGLMultipleRenderTargets) { - let He = S.texture; - if (O.length !== He.length || O[0] !== 36064) { - for(let De = 0, ze = He.length; De < ze; De++)O[De] = 36064 + De; - O.length = He.length, we = !0; - } - } else (O.length !== 1 || O[0] !== 36064) && (O[0] = 36064, O.length = 1, we = !0); - else (O.length !== 1 || O[0] !== 1029) && (O[0] = 1029, O.length = 1, we = !0); - we && (ge.isWebGL2 ? Y.drawBuffers(O) : ye.get("WEBGL_draw_buffers").drawBuffersWEBGL(O)); - } - if (xe.viewport(A), xe.scissor(L), xe.setScissorTest(I), be) { - let we = G.get(S.texture); - Y.framebufferTexture2D(36160, 36064, 34069 + N, we.__webglTexture, H); - } else if (Ae) { - let we = G.get(S.texture), He = N || 0; - Y.framebufferTextureLayer(36160, 36064, we.__webglTexture, H || 0, He); - } - y = -1; - }, this.readRenderTargetPixels = function(S, N, H, z, q, be, Ae) { - if (!(S && S.isWebGLRenderTarget)) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); - return; - } - let Ie = G.get(S).__webglFramebuffer; - if (S.isWebGLCubeRenderTarget && Ae !== void 0 && (Ie = Ie[Ae]), Ie) { - xe.bindFramebuffer(36160, Ie); - try { - let we = S.texture, He = we.format, De = we.type; - if (He !== ct && te.convert(He) !== Y.getParameter(35739)) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); - return; - } - let ze = De === kn && (ye.has("EXT_color_buffer_half_float") || ge.isWebGL2 && ye.has("EXT_color_buffer_float")); - if (De !== rn && te.convert(De) !== Y.getParameter(35738) && !(De === nn && (ge.isWebGL2 || ye.has("OES_texture_float") || ye.has("WEBGL_color_buffer_float"))) && !ze) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); - return; - } - Y.checkFramebufferStatus(36160) === 36053 ? N >= 0 && N <= S.width - z && H >= 0 && H <= S.height - q && Y.readPixels(N, H, z, q, te.convert(He), te.convert(De), be) : console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."); - } finally{ - let we = _ !== null ? G.get(_).__webglFramebuffer : null; - xe.bindFramebuffer(36160, we); - } - } - }, this.copyFramebufferToTexture = function(S, N, H = 0) { - if (N.isFramebufferTexture !== !0) { - console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture."); - return; - } - let z = Math.pow(2, -H), q = Math.floor(N.image.width * z), be = Math.floor(N.image.height * z); - j.setTexture2D(N, 0), Y.copyTexSubImage2D(3553, H, 0, 0, S.x, S.y, q, be), xe.unbindTexture(); - }, this.copyTextureToTexture = function(S, N, H, z = 0) { - let q = N.image.width, be = N.image.height, Ae = te.convert(H.format), Ie = te.convert(H.type); - j.setTexture2D(H, 0), Y.pixelStorei(37440, H.flipY), Y.pixelStorei(37441, H.premultiplyAlpha), Y.pixelStorei(3317, H.unpackAlignment), N.isDataTexture ? Y.texSubImage2D(3553, z, S.x, S.y, q, be, Ae, Ie, N.image.data) : N.isCompressedTexture ? Y.compressedTexSubImage2D(3553, z, S.x, S.y, N.mipmaps[0].width, N.mipmaps[0].height, Ae, N.mipmaps[0].data) : Y.texSubImage2D(3553, z, S.x, S.y, Ae, Ie, N.image), z === 0 && H.generateMipmaps && Y.generateMipmap(3553), xe.unbindTexture(); - }, this.copyTextureToTexture3D = function(S, N, H, z, q = 0) { - if (x.isWebGL1Renderer) { - console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2."); - return; - } - let be = S.max.x - S.min.x + 1, Ae = S.max.y - S.min.y + 1, Ie = S.max.z - S.min.z + 1, we = te.convert(z.format), He = te.convert(z.type), De; - if (z.isDataTexture3D) j.setTexture3D(z, 0), De = 32879; - else if (z.isDataTexture2DArray) j.setTexture2DArray(z, 0), De = 35866; - else { - console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray."); - return; - } - Y.pixelStorei(37440, z.flipY), Y.pixelStorei(37441, z.premultiplyAlpha), Y.pixelStorei(3317, z.unpackAlignment); - let ze = Y.getParameter(3314), je = Y.getParameter(32878), Rn = Y.getParameter(3316), ei = Y.getParameter(3315), Ge = Y.getParameter(32877), Ht = H.isCompressedTexture ? H.mipmaps[0] : H.image; - Y.pixelStorei(3314, Ht.width), Y.pixelStorei(32878, Ht.height), Y.pixelStorei(3316, S.min.x), Y.pixelStorei(3315, S.min.y), Y.pixelStorei(32877, S.min.z), H.isDataTexture || H.isDataTexture3D ? Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht.data) : H.isCompressedTexture ? (console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."), Y.compressedTexSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, Ht.data)) : Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht), Y.pixelStorei(3314, ze), Y.pixelStorei(32878, je), Y.pixelStorei(3316, Rn), Y.pixelStorei(3315, ei), Y.pixelStorei(32877, Ge), q === 0 && z.generateMipmaps && Y.generateMipmap(De), xe.unbindTexture(); - }, this.initTexture = function(S) { - j.setTexture2D(S, 0), xe.unbindTexture(); - }, this.resetState = function() { - g = 0, p = 0, _ = null, xe.reset(), R.reset(); - }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { - detail: this - })); -} -qe.prototype.isWebGLRenderer = !0; -var _h = class extends qe { -}; -_h.prototype.isWebGL1Renderer = !0; -var Nr = class { - constructor(e, t = 25e-5){ - this.name = "", this.color = new ae(e), this.density = t; - } - clone() { - return new Nr(this.color, this.density); - } - toJSON() { - return { - type: "FogExp2", - color: this.color.getHex(), - density: this.density - }; - } -}; -Nr.prototype.isFogExp2 = !0; -var Br = class { - constructor(e, t = 1, n = 1e3){ - this.name = "", this.color = new ae(e), this.near = t, this.far = n; - } - clone() { - return new Br(this.color, this.near, this.far); - } - toJSON() { - return { - type: "Fog", - color: this.color.getHex(), - near: this.near, - far: this.far - }; - } -}; -Br.prototype.isFog = !0; -var no = class extends Ne { - constructor(){ - super(); - this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.overrideMaterial = null, this.autoUpdate = !0, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { - detail: this - })); - } - copy(e, t) { - return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.autoUpdate = e.autoUpdate, this.matrixAutoUpdate = e.matrixAutoUpdate, this; - } - toJSON(e) { - let t = super.toJSON(e); - return this.fog !== null && (t.object.fog = this.fog.toJSON()), t; - } -}; -no.prototype.isScene = !0; -var $n = class { - constructor(e, t){ - this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = hr, this.updateRange = { - offset: 0, - count: -1 - }, this.version = 0, this.uuid = Et(); - } - onUploadCallback() {} - set needsUpdate(e) { - e === !0 && this.version++; - } - setUsage(e) { - return this.usage = e, this; - } - copy(e) { - return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this; - } - copyAt(e, t, n) { - e *= this.stride, n *= t.stride; - for(let i = 0, r = this.stride; i < r; i++)this.array[e + i] = t.array[n + i]; - return this; - } - set(e, t = 0) { - return this.array.set(e, t), this; - } - clone(e) { - e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); - let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); - return n.setUsage(this.usage), n; - } - onUpload(e) { - return this.onUploadCallback = e, this; - } - toJSON(e) { - return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.prototype.slice.call(new Uint32Array(this.array.buffer))), { - uuid: this.uuid, - buffer: this.array.buffer._uuid, - type: this.array.constructor.name, - stride: this.stride - }; - } -}; -$n.prototype.isInterleavedBuffer = !0; -var Ke = new M, Sn = class { - constructor(e, t, n, i = !1){ - this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = i === !0; - } - get count() { - return this.data.count; - } - get array() { - return this.data.array; - } - set needsUpdate(e) { - this.data.needsUpdate = e; - } - applyMatrix4(e) { - for(let t = 0, n = this.data.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyMatrix4(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); - return this; - } - applyNormalMatrix(e) { - for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyNormalMatrix(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); - return this; - } - transformDirection(e) { - for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.transformDirection(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); - return this; - } - setX(e, t) { - return this.data.array[e * this.data.stride + this.offset] = t, this; - } - setY(e, t) { - return this.data.array[e * this.data.stride + this.offset + 1] = t, this; - } - setZ(e, t) { - return this.data.array[e * this.data.stride + this.offset + 2] = t, this; - } - setW(e, t) { - return this.data.array[e * this.data.stride + this.offset + 3] = t, this; - } - getX(e) { - return this.data.array[e * this.data.stride + this.offset]; - } - getY(e) { - return this.data.array[e * this.data.stride + this.offset + 1]; - } - getZ(e) { - return this.data.array[e * this.data.stride + this.offset + 2]; - } - getW(e) { - return this.data.array[e * this.data.stride + this.offset + 3]; - } - setXY(e, t, n) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this; - } - setXYZ(e, t, n, i) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this; - } - setXYZW(e, t, n, i, r) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this.data.array[e + 3] = r, this; - } - clone(e) { - if (e === void 0) { - console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data."); - let t = []; - for(let n = 0; n < this.count; n++){ - let i = n * this.data.stride + this.offset; - for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); - } - return new Ue(new this.array.constructor(t), this.itemSize, this.normalized); - } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new Sn(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); - } - toJSON(e) { - if (e === void 0) { - console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data."); - let t = []; - for(let n = 0; n < this.count; n++){ - let i = n * this.data.stride + this.offset; - for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); - } - return { - itemSize: this.itemSize, - type: this.array.constructor.name, - array: t, - normalized: this.normalized - }; - } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { - isInterleavedBufferAttribute: !0, - itemSize: this.itemSize, - data: this.data.uuid, - offset: this.offset, - normalized: this.normalized - }; - } -}; -Sn.prototype.isInterleavedBufferAttribute = !0; -var io = class extends dt { - constructor(e){ - super(); - this.type = "SpriteMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.rotation = e.rotation, this.sizeAttenuation = e.sizeAttenuation, this; - } -}; -io.prototype.isSpriteMaterial = !0; -var gi, Qi = new M, xi = new M, yi = new M, vi = new X, Ki = new X, Mh = new pe, hs = new M, er = new M, us = new M, jl = new X, qo = new X, Ql = new X, ro = class extends Ne { - constructor(e){ - super(); - if (this.type = "Sprite", gi === void 0) { - gi = new _e; - let t = new Float32Array([ - -.5, - -.5, - 0, - 0, - 0, - .5, - -.5, - 0, - 1, - 0, - .5, - .5, - 0, - 1, - 1, - -.5, - .5, - 0, - 0, - 1 - ]), n = new $n(t, 5); - gi.setIndex([ - 0, - 1, - 2, - 0, - 2, - 3 - ]), gi.setAttribute("position", new Sn(n, 3, 0, !1)), gi.setAttribute("uv", new Sn(n, 2, 3, !1)); - } - this.geometry = gi, this.material = e !== void 0 ? e : new io, this.center = new X(.5, .5); - } - raycast(e, t) { - e.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), xi.setFromMatrixScale(this.matrixWorld), Mh.copy(e.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse, this.matrixWorld), yi.setFromMatrixPosition(this.modelViewMatrix), e.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && xi.multiplyScalar(-yi.z); - let n = this.material.rotation, i, r; - n !== 0 && (r = Math.cos(n), i = Math.sin(n)); - let o = this.center; - ds(hs.set(-.5, -.5, 0), yi, o, xi, i, r), ds(er.set(.5, -.5, 0), yi, o, xi, i, r), ds(us.set(.5, .5, 0), yi, o, xi, i, r), jl.set(0, 0), qo.set(1, 0), Ql.set(1, 1); - let a = e.ray.intersectTriangle(hs, er, us, !1, Qi); - if (a === null && (ds(er.set(-.5, .5, 0), yi, o, xi, i, r), qo.set(0, 1), a = e.ray.intersectTriangle(hs, us, er, !1, Qi), a === null)) return; - let l = e.ray.origin.distanceTo(Qi); - l < e.near || l > e.far || t.push({ - distance: l, - point: Qi.clone(), - uv: nt.getUV(Qi, hs, er, us, jl, qo, Ql, new X), - face: null, - object: this - }); - } - copy(e) { - return super.copy(e), e.center !== void 0 && this.center.copy(e.center), this.material = e.material, this; - } -}; -ro.prototype.isSprite = !0; -function ds(s, e, t, n, i, r) { - vi.subVectors(s, t).addScalar(.5).multiply(n), i !== void 0 ? (Ki.x = r * vi.x - i * vi.y, Ki.y = i * vi.x + r * vi.y) : Ki.copy(vi), s.copy(e), s.x += Ki.x, s.y += Ki.y, s.applyMatrix4(Mh); -} -var fs = new M, Kl = new M, bh = class extends Ne { - constructor(){ - super(); - this._currentLevel = 0, this.type = "LOD", Object.defineProperties(this, { - levels: { - enumerable: !0, - value: [] - }, - isLOD: { - value: !0 - } - }), this.autoUpdate = !0; - } - copy(e) { - super.copy(e, !1); - let t = e.levels; - for(let n = 0, i = t.length; n < i; n++){ - let r = t[n]; - this.addLevel(r.object.clone(), r.distance); - } - return this.autoUpdate = e.autoUpdate, this; - } - addLevel(e, t = 0) { - t = Math.abs(t); - let n = this.levels, i; - for(i = 0; i < n.length && !(t < n[i].distance); i++); - return n.splice(i, 0, { - distance: t, - object: e - }), this.add(e), this; - } - getCurrentLevel() { - return this._currentLevel; - } - getObjectForDistance(e) { - let t = this.levels; - if (t.length > 0) { - let n, i; - for(n = 1, i = t.length; n < i && !(e < t[n].distance); n++); - return t[n - 1].object; - } - return null; - } - raycast(e, t) { - if (this.levels.length > 0) { - fs.setFromMatrixPosition(this.matrixWorld); - let i = e.ray.origin.distanceTo(fs); - this.getObjectForDistance(i).raycast(e, t); - } - } - update(e) { - let t = this.levels; - if (t.length > 1) { - fs.setFromMatrixPosition(e.matrixWorld), Kl.setFromMatrixPosition(this.matrixWorld); - let n = fs.distanceTo(Kl) / e.zoom; - t[0].object.visible = !0; - let i, r; - for(i = 1, r = t.length; i < r && n >= t[i].distance; i++)t[i - 1].object.visible = !1, t[i].object.visible = !0; - for(this._currentLevel = i - 1; i < r; i++)t[i].object.visible = !1; - } - } - toJSON(e) { - let t = super.toJSON(e); - this.autoUpdate === !1 && (t.object.autoUpdate = !1), t.object.levels = []; - let n = this.levels; - for(let i = 0, r = n.length; i < r; i++){ - let o = n[i]; - t.object.levels.push({ - object: o.object.uuid, - distance: o.distance - }); - } - return t; - } -}, ec = new M, tc = new Ve, nc = new Ve, Rx = new M, ic = new pe, so = class extends st { - constructor(e, t){ - super(e, t); - this.type = "SkinnedMesh", this.bindMode = "attached", this.bindMatrix = new pe, this.bindMatrixInverse = new pe; - } - copy(e) { - return super.copy(e), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, this; - } - bind(e, t) { - this.skeleton = e, t === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), t = this.matrixWorld), this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert(); - } - pose() { - this.skeleton.pose(); - } - normalizeSkinWeights() { - let e = new Ve, t = this.geometry.attributes.skinWeight; - for(let n = 0, i = t.count; n < i; n++){ - e.x = t.getX(n), e.y = t.getY(n), e.z = t.getZ(n), e.w = t.getW(n); - let r = 1 / e.manhattanLength(); - r !== 1 / 0 ? e.multiplyScalar(r) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w); - } - } - updateMatrixWorld(e) { - super.updateMatrixWorld(e), this.bindMode === "attached" ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === "detached" ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode); - } - boneTransform(e, t) { - let n = this.skeleton, i = this.geometry; - tc.fromBufferAttribute(i.attributes.skinIndex, e), nc.fromBufferAttribute(i.attributes.skinWeight, e), ec.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0); - for(let r = 0; r < 4; r++){ - let o = nc.getComponent(r); - if (o !== 0) { - let a = tc.getComponent(r); - ic.multiplyMatrices(n.bones[a].matrixWorld, n.boneInverses[a]), t.addScaledVector(Rx.copy(ec).applyMatrix4(ic), o); - } - } - return t.applyMatrix4(this.bindMatrixInverse); - } -}; -so.prototype.isSkinnedMesh = !0; -var oo = class extends Ne { - constructor(){ - super(); - this.type = "Bone"; - } -}; -oo.prototype.isBone = !0; -var qn = class extends ot { - constructor(e = null, t = 1, n = 1, i, r, o, a, l, c = rt, h = rt, u, d){ - super(null, o, a, l, c, h, i, r, u, d); - this.image = { - data: e, - width: t, - height: n - }, this.magFilter = c, this.minFilter = h, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; - } -}; -qn.prototype.isDataTexture = !0; -var rc = new pe, Px = new pe, ao = class { - constructor(e = [], t = []){ - this.uuid = Et(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.boneTextureSize = 0, this.frame = -1, this.init(); - } - init() { - let e = this.bones, t = this.boneInverses; - if (this.boneMatrices = new Float32Array(e.length * 16), t.length === 0) this.calculateInverses(); - else if (e.length !== t.length) { - console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = []; - for(let n = 0, i = this.bones.length; n < i; n++)this.boneInverses.push(new pe); - } - } - calculateInverses() { - this.boneInverses.length = 0; - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = new pe; - this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n); - } - } - pose() { - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = this.bones[e]; - n && n.matrixWorld.copy(this.boneInverses[e]).invert(); - } - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = this.bones[e]; - n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale)); - } - } - update() { - let e = this.bones, t = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; - for(let r = 0, o = e.length; r < o; r++){ - let a = e[r] ? e[r].matrixWorld : Px; - rc.multiplyMatrices(a, t[r]), rc.toArray(n, r * 16); - } - i !== null && (i.needsUpdate = !0); - } - clone() { - return new ao(this.bones, this.boneInverses); - } - computeBoneTexture() { - let e = Math.sqrt(this.bones.length * 4); - e = Xc(e), e = Math.max(e, 4); - let t = new Float32Array(e * e * 4); - t.set(this.boneMatrices); - let n = new qn(t, e, e, ct, nn); - return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this.boneTextureSize = e, this; - } - getBoneByName(e) { - for(let t = 0, n = this.bones.length; t < n; t++){ - let i = this.bones[t]; - if (i.name === e) return i; - } - } - dispose() { - this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null); - } - fromJSON(e, t) { - this.uuid = e.uuid; - for(let n = 0, i = e.bones.length; n < i; n++){ - let r = e.bones[n], o = t[r]; - o === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", r), o = new oo), this.bones.push(o), this.boneInverses.push(new pe().fromArray(e.boneInverses[n])); - } - return this.init(), this; - } - toJSON() { - let e = { - metadata: { - version: 4.5, - type: "Skeleton", - generator: "Skeleton.toJSON" - }, - bones: [], - boneInverses: [] - }; - e.uuid = this.uuid; - let t = this.bones, n = this.boneInverses; - for(let i = 0, r = t.length; i < r; i++){ - let o = t[i]; - e.bones.push(o.uuid); - let a = n[i]; - e.boneInverses.push(a.toArray()); - } - return e; - } -}, Xn = class extends Ue { - constructor(e, t, n, i = 1){ - typeof n == "number" && (i = n, n = !1, console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")); - super(e, t, n); - this.meshPerAttribute = i; - } - copy(e) { - return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; - } - toJSON() { - let e = super.toJSON(); - return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e; - } -}; -Xn.prototype.isInstancedBufferAttribute = !0; -var sc = new pe, oc = new pe, ps = [], tr = new st, xa = class extends st { - constructor(e, t, n){ - super(e, t); - this.instanceMatrix = new Xn(new Float32Array(n * 16), 16), this.instanceColor = null, this.count = n, this.frustumCulled = !1; - } - copy(e) { - return super.copy(e), this.instanceMatrix.copy(e.instanceMatrix), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, this; - } - getColorAt(e, t) { - t.fromArray(this.instanceColor.array, e * 3); - } - getMatrixAt(e, t) { - t.fromArray(this.instanceMatrix.array, e * 16); - } - raycast(e, t) { - let n = this.matrixWorld, i = this.count; - if (tr.geometry = this.geometry, tr.material = this.material, tr.material !== void 0) for(let r = 0; r < i; r++){ - this.getMatrixAt(r, sc), oc.multiplyMatrices(n, sc), tr.matrixWorld = oc, tr.raycast(e, ps); - for(let o = 0, a = ps.length; o < a; o++){ - let l = ps[o]; - l.instanceId = r, l.object = this, t.push(l); - } - ps.length = 0; - } - } - setColorAt(e, t) { - this.instanceColor === null && (this.instanceColor = new Xn(new Float32Array(this.instanceMatrix.count * 3), 3)), t.toArray(this.instanceColor.array, e * 3); - } - setMatrixAt(e, t) { - t.toArray(this.instanceMatrix.array, e * 16); - } - updateMorphTargets() {} - dispose() { - this.dispatchEvent({ - type: "dispose" - }); - } -}; -xa.prototype.isInstancedMesh = !0; -var ft = class extends dt { - constructor(e){ - super(); - this.type = "LineBasicMaterial", this.color = new ae(16777215), this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this; - } -}; -ft.prototype.isLineBasicMaterial = !0; -var ac = new M, lc = new M, cc = new pe, Xo = new Cn, ms = new An, on = class extends Ne { - constructor(e = new _e, t = new ft){ - super(); - this.type = "Line", this.geometry = e, this.material = t, this.updateMorphTargets(); - } - copy(e) { - return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; - } - computeLineDistances() { - let e = this.geometry; - if (e.isBufferGeometry) if (e.index === null) { - let t = e.attributes.position, n = [ - 0 - ]; - for(let i = 1, r = t.count; i < r; i++)ac.fromBufferAttribute(t, i - 1), lc.fromBufferAttribute(t, i), n[i] = n[i - 1], n[i] += ac.distanceTo(lc); - e.setAttribute("lineDistance", new de(n, 1)); - } else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); - else e.isGeometry && console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - return this; - } - raycast(e, t) { - let n = this.geometry, i = this.matrixWorld, r = e.params.Line.threshold, o = n.drawRange; - if (n.boundingSphere === null && n.computeBoundingSphere(), ms.copy(n.boundingSphere), ms.applyMatrix4(i), ms.radius += r, e.ray.intersectsSphere(ms) === !1) return; - cc.copy(i).invert(), Xo.copy(e.ray).applyMatrix4(cc); - let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a, c = new M, h = new M, u = new M, d = new M, f = this.isLineSegments ? 2 : 1; - if (n.isBufferGeometry) { - let m = n.index, v = n.attributes.position; - if (m !== null) { - let g = Math.max(0, o.start), p = Math.min(m.count, o.start + o.count); - for(let _ = g, y = p - 1; _ < y; _ += f){ - let b = m.getX(_), A = m.getX(_ + 1); - if (c.fromBufferAttribute(v, b), h.fromBufferAttribute(v, A), Xo.distanceSqToSegment(c, h, d, u) > l) continue; - d.applyMatrix4(this.matrixWorld); - let I = e.ray.origin.distanceTo(d); - I < e.near || I > e.far || t.push({ - distance: I, - point: u.clone().applyMatrix4(this.matrixWorld), - index: _, - face: null, - faceIndex: null, - object: this - }); - } - } else { - let g = Math.max(0, o.start), p = Math.min(v.count, o.start + o.count); - for(let _ = g, y = p - 1; _ < y; _ += f){ - if (c.fromBufferAttribute(v, _), h.fromBufferAttribute(v, _ + 1), Xo.distanceSqToSegment(c, h, d, u) > l) continue; - d.applyMatrix4(this.matrixWorld); - let A = e.ray.origin.distanceTo(d); - A < e.near || A > e.far || t.push({ - distance: A, - point: u.clone().applyMatrix4(this.matrixWorld), - index: _, - face: null, - faceIndex: null, - object: this - }); - } - } - } else n.isGeometry && console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - } - updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } - } - } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); - } - } -}; -on.prototype.isLine = !0; -var hc = new M, uc = new M, wt = class extends on { - constructor(e, t){ - super(e, t); - this.type = "LineSegments"; - } - computeLineDistances() { - let e = this.geometry; - if (e.isBufferGeometry) if (e.index === null) { - let t = e.attributes.position, n = []; - for(let i = 0, r = t.count; i < r; i += 2)hc.fromBufferAttribute(t, i), uc.fromBufferAttribute(t, i + 1), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + hc.distanceTo(uc); - e.setAttribute("lineDistance", new de(n, 1)); - } else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); - else e.isGeometry && console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - return this; - } -}; -wt.prototype.isLineSegments = !0; -var ya = class extends on { - constructor(e, t){ - super(e, t); - this.type = "LineLoop"; - } -}; -ya.prototype.isLineLoop = !0; -var jn = class extends dt { - constructor(e){ - super(); - this.type = "PointsMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this; - } -}; -jn.prototype.isPointsMaterial = !0; -var dc = new pe, sa = new Cn, gs = new An, xs = new M, zr = class extends Ne { - constructor(e = new _e, t = new jn){ - super(); - this.type = "Points", this.geometry = e, this.material = t, this.updateMorphTargets(); - } - copy(e) { - return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; - } - raycast(e, t) { - let n = this.geometry, i = this.matrixWorld, r = e.params.Points.threshold, o = n.drawRange; - if (n.boundingSphere === null && n.computeBoundingSphere(), gs.copy(n.boundingSphere), gs.applyMatrix4(i), gs.radius += r, e.ray.intersectsSphere(gs) === !1) return; - dc.copy(i).invert(), sa.copy(e.ray).applyMatrix4(dc); - let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a; - if (n.isBufferGeometry) { - let c = n.index, u = n.attributes.position; - if (c !== null) { - let d = Math.max(0, o.start), f = Math.min(c.count, o.start + o.count); - for(let m = d, x = f; m < x; m++){ - let v = c.getX(m); - xs.fromBufferAttribute(u, v), fc(xs, v, l, i, e, t, this); - } - } else { - let d = Math.max(0, o.start), f = Math.min(u.count, o.start + o.count); - for(let m = d, x = f; m < x; m++)xs.fromBufferAttribute(u, m), fc(xs, m, l, i, e, t, this); - } - } else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); - } - updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } - } - } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); - } - } -}; -zr.prototype.isPoints = !0; -function fc(s, e, t, n, i, r, o) { - let a = sa.distanceSqToPoint(s); - if (a < t) { - let l = new M; - sa.closestPointToPoint(s, l), l.applyMatrix4(n); - let c = i.ray.origin.distanceTo(l); - if (c < i.near || c > i.far) return; - r.push({ - distance: c, - distanceToRay: Math.sqrt(a), - point: l, - index: e, - face: null, - object: o - }); - } -} -var wh = class extends ot { - constructor(e, t, n, i, r, o, a, l, c){ - super(e, t, n, i, r, o, a, l, c); - this.format = a !== void 0 ? a : Gn, this.minFilter = o !== void 0 ? o : tt, this.magFilter = r !== void 0 ? r : tt, this.generateMipmaps = !1; - let h = this; - function u() { - h.needsUpdate = !0, e.requestVideoFrameCallback(u); - } - "requestVideoFrameCallback" in e && e.requestVideoFrameCallback(u); - } - clone() { - return new this.constructor(this.image).copy(this); - } - update() { - let e = this.image; - "requestVideoFrameCallback" in e === !1 && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0); - } -}; -wh.prototype.isVideoTexture = !0; -var Sh = class extends ot { - constructor(e, t, n){ - super({ - width: e, - height: t - }); - this.format = n, this.magFilter = rt, this.minFilter = rt, this.generateMipmaps = !1, this.needsUpdate = !0; - } -}; -Sh.prototype.isFramebufferTexture = !0; -var va = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h, u, d){ - super(null, o, a, l, c, h, i, r, u, d); - this.image = { - width: t, - height: n - }, this.mipmaps = e, this.flipY = !1, this.generateMipmaps = !1; - } -}; -va.prototype.isCompressedTexture = !0; -var Th = class extends ot { - constructor(e, t, n, i, r, o, a, l, c){ - super(e, t, n, i, r, o, a, l, c); - this.needsUpdate = !0; - } -}; -Th.prototype.isCanvasTexture = !0; -var fr = class extends _e { - constructor(e = 1, t = 8, n = 0, i = Math.PI * 2){ - super(); - this.type = "CircleGeometry", this.parameters = { - radius: e, - segments: t, - thetaStart: n, - thetaLength: i - }, t = Math.max(3, t); - let r = [], o = [], a = [], l = [], c = new M, h = new X; - o.push(0, 0, 0), a.push(0, 0, 1), l.push(.5, .5); - for(let u = 0, d = 3; u <= t; u++, d += 3){ - let f = n + u / t * i; - c.x = e * Math.cos(f), c.y = e * Math.sin(f), o.push(c.x, c.y, c.z), a.push(0, 0, 1), h.x = (o[d] / e + 1) / 2, h.y = (o[d + 1] / e + 1) / 2, l.push(h.x, h.y); - } - for(let u = 1; u <= t; u++)r.push(u, u + 1, 0); - this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("normal", new de(a, 3)), this.setAttribute("uv", new de(l, 2)); - } - static fromJSON(e) { - return new fr(e.radius, e.segments, e.thetaStart, e.thetaLength); - } -}, Jn = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 8, r = 1, o = !1, a = 0, l = Math.PI * 2){ - super(); - this.type = "CylinderGeometry", this.parameters = { - radiusTop: e, - radiusBottom: t, - height: n, - radialSegments: i, - heightSegments: r, - openEnded: o, - thetaStart: a, - thetaLength: l - }; - let c = this; - i = Math.floor(i), r = Math.floor(r); - let h = [], u = [], d = [], f = [], m = 0, x = [], v = n / 2, g = 0; - p(), o === !1 && (e > 0 && _(!0), t > 0 && _(!1)), this.setIndex(h), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); - function p() { - let y = new M, b = new M, A = 0, L = (t - e) / n; - for(let I = 0; I <= r; I++){ - let k = [], B = I / r, P = B * (t - e) + e; - for(let w = 0; w <= i; w++){ - let E = w / i, D = E * l + a, U = Math.sin(D), F = Math.cos(D); - b.x = P * U, b.y = -B * n + v, b.z = P * F, u.push(b.x, b.y, b.z), y.set(U, L, F).normalize(), d.push(y.x, y.y, y.z), f.push(E, 1 - B), k.push(m++); - } - x.push(k); - } - for(let I = 0; I < i; I++)for(let k = 0; k < r; k++){ - let B = x[k][I], P = x[k + 1][I], w = x[k + 1][I + 1], E = x[k][I + 1]; - h.push(B, P, E), h.push(P, w, E), A += 6; - } - c.addGroup(g, A, 0), g += A; - } - function _(y) { - let b = m, A = new X, L = new M, I = 0, k = y === !0 ? e : t, B = y === !0 ? 1 : -1; - for(let w = 1; w <= i; w++)u.push(0, v * B, 0), d.push(0, B, 0), f.push(.5, .5), m++; - let P = m; - for(let w = 0; w <= i; w++){ - let D = w / i * l + a, U = Math.cos(D), F = Math.sin(D); - L.x = k * F, L.y = v * B, L.z = k * U, u.push(L.x, L.y, L.z), d.push(0, B, 0), A.x = U * .5 + .5, A.y = F * .5 * B + .5, f.push(A.x, A.y), m++; - } - for(let w = 0; w < i; w++){ - let E = b + w, D = P + w; - y === !0 ? h.push(D, D + 1, E) : h.push(D + 1, D, E), I += 3; - } - c.addGroup(g, I, y === !0 ? 1 : 2), g += I; - } - } - static fromJSON(e) { - return new Jn(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); - } -}, pr = class extends Jn { - constructor(e = 1, t = 1, n = 8, i = 1, r = !1, o = 0, a = Math.PI * 2){ - super(0, e, t, n, i, r, o, a); - this.type = "ConeGeometry", this.parameters = { - radius: e, - height: t, - radialSegments: n, - heightSegments: i, - openEnded: r, - thetaStart: o, - thetaLength: a - }; - } - static fromJSON(e) { - return new pr(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); - } -}, an = class extends _e { - constructor(e = [], t = [], n = 1, i = 0){ - super(); - this.type = "PolyhedronGeometry", this.parameters = { - vertices: e, - indices: t, - radius: n, - detail: i - }; - let r = [], o = []; - a(i), c(n), h(), this.setAttribute("position", new de(r, 3)), this.setAttribute("normal", new de(r.slice(), 3)), this.setAttribute("uv", new de(o, 2)), i === 0 ? this.computeVertexNormals() : this.normalizeNormals(); - function a(p) { - let _ = new M, y = new M, b = new M; - for(let A = 0; A < t.length; A += 3)f(t[A + 0], _), f(t[A + 1], y), f(t[A + 2], b), l(_, y, b, p); - } - function l(p, _, y, b) { - let A = b + 1, L = []; - for(let I = 0; I <= A; I++){ - L[I] = []; - let k = p.clone().lerp(y, I / A), B = _.clone().lerp(y, I / A), P = A - I; - for(let w = 0; w <= P; w++)w === 0 && I === A ? L[I][w] = k : L[I][w] = k.clone().lerp(B, w / P); - } - for(let I = 0; I < A; I++)for(let k = 0; k < 2 * (A - I) - 1; k++){ - let B = Math.floor(k / 2); - k % 2 === 0 ? (d(L[I][B + 1]), d(L[I + 1][B]), d(L[I][B])) : (d(L[I][B + 1]), d(L[I + 1][B + 1]), d(L[I + 1][B])); - } - } - function c(p) { - let _ = new M; - for(let y = 0; y < r.length; y += 3)_.x = r[y + 0], _.y = r[y + 1], _.z = r[y + 2], _.normalize().multiplyScalar(p), r[y + 0] = _.x, r[y + 1] = _.y, r[y + 2] = _.z; - } - function h() { - let p = new M; - for(let _ = 0; _ < r.length; _ += 3){ - p.x = r[_ + 0], p.y = r[_ + 1], p.z = r[_ + 2]; - let y = v(p) / 2 / Math.PI + .5, b = g(p) / Math.PI + .5; - o.push(y, 1 - b); - } - m(), u(); - } - function u() { - for(let p = 0; p < o.length; p += 6){ - let _ = o[p + 0], y = o[p + 2], b = o[p + 4], A = Math.max(_, y, b), L = Math.min(_, y, b); - A > .9 && L < .1 && (_ < .2 && (o[p + 0] += 1), y < .2 && (o[p + 2] += 1), b < .2 && (o[p + 4] += 1)); - } - } - function d(p) { - r.push(p.x, p.y, p.z); - } - function f(p, _) { - let y = p * 3; - _.x = e[y + 0], _.y = e[y + 1], _.z = e[y + 2]; - } - function m() { - let p = new M, _ = new M, y = new M, b = new M, A = new X, L = new X, I = new X; - for(let k = 0, B = 0; k < r.length; k += 9, B += 6){ - p.set(r[k + 0], r[k + 1], r[k + 2]), _.set(r[k + 3], r[k + 4], r[k + 5]), y.set(r[k + 6], r[k + 7], r[k + 8]), A.set(o[B + 0], o[B + 1]), L.set(o[B + 2], o[B + 3]), I.set(o[B + 4], o[B + 5]), b.copy(p).add(_).add(y).divideScalar(3); - let P = v(b); - x(A, B + 0, p, P), x(L, B + 2, _, P), x(I, B + 4, y, P); - } - } - function x(p, _, y, b) { - b < 0 && p.x === 1 && (o[_] = p.x - 1), y.x === 0 && y.z === 0 && (o[_] = b / 2 / Math.PI + .5); - } - function v(p) { - return Math.atan2(p.z, -p.x); - } - function g(p) { - return Math.atan2(-p.y, Math.sqrt(p.x * p.x + p.z * p.z)); - } - } - static fromJSON(e) { - return new an(e.vertices, e.indices, e.radius, e.details); - } -}, mr = class extends an { - constructor(e = 1, t = 0){ - let n = (1 + Math.sqrt(5)) / 2, i = 1 / n, r = [ - -1, - -1, - -1, - -1, - -1, - 1, - -1, - 1, - -1, - -1, - 1, - 1, - 1, - -1, - -1, - 1, - -1, - 1, - 1, - 1, - -1, - 1, - 1, - 1, - 0, - -i, - -n, - 0, - -i, - n, - 0, - i, - -n, - 0, - i, - n, - -i, - -n, - 0, - -i, - n, - 0, - i, - -n, - 0, - i, - n, - 0, - -n, - 0, - -i, - n, - 0, - -i, - -n, - 0, - i, - n, - 0, - i - ], o = [ - 3, - 11, - 7, - 3, - 7, - 15, - 3, - 15, - 13, - 7, - 19, - 17, - 7, - 17, - 6, - 7, - 6, - 15, - 17, - 4, - 8, - 17, - 8, - 10, - 17, - 10, - 6, - 8, - 0, - 16, - 8, - 16, - 2, - 8, - 2, - 10, - 0, - 12, - 1, - 0, - 1, - 18, - 0, - 18, - 16, - 6, - 10, - 2, - 6, - 2, - 13, - 6, - 13, - 15, - 2, - 16, - 18, - 2, - 18, - 3, - 2, - 3, - 13, - 18, - 1, - 9, - 18, - 9, - 11, - 18, - 11, - 3, - 4, - 14, - 12, - 4, - 12, - 0, - 4, - 0, - 8, - 11, - 9, - 5, - 11, - 5, - 19, - 11, - 19, - 7, - 19, - 5, - 14, - 19, - 14, - 4, - 19, - 4, - 17, - 1, - 12, - 14, - 1, - 14, - 5, - 1, - 5, - 9 - ]; - super(r, o, e, t); - this.type = "DodecahedronGeometry", this.parameters = { - radius: e, - detail: t - }; - } - static fromJSON(e) { - return new mr(e.radius, e.detail); - } -}, ys = new M, vs = new M, Jo = new M, _s = new nt, _a = class extends _e { - constructor(e = null, t = 1){ - super(); - if (this.type = "EdgesGeometry", this.parameters = { - geometry: e, - thresholdAngle: t - }, e !== null) { - let i = Math.pow(10, 4), r = Math.cos(Wn * t), o = e.getIndex(), a = e.getAttribute("position"), l = o ? o.count : a.count, c = [ - 0, - 0, - 0 - ], h = [ - "a", - "b", - "c" - ], u = new Array(3), d = {}, f = []; - for(let m = 0; m < l; m += 3){ - o ? (c[0] = o.getX(m), c[1] = o.getX(m + 1), c[2] = o.getX(m + 2)) : (c[0] = m, c[1] = m + 1, c[2] = m + 2); - let { a: x , b: v , c: g } = _s; - if (x.fromBufferAttribute(a, c[0]), v.fromBufferAttribute(a, c[1]), g.fromBufferAttribute(a, c[2]), _s.getNormal(Jo), u[0] = `${Math.round(x.x * i)},${Math.round(x.y * i)},${Math.round(x.z * i)}`, u[1] = `${Math.round(v.x * i)},${Math.round(v.y * i)},${Math.round(v.z * i)}`, u[2] = `${Math.round(g.x * i)},${Math.round(g.y * i)},${Math.round(g.z * i)}`, !(u[0] === u[1] || u[1] === u[2] || u[2] === u[0])) for(let p = 0; p < 3; p++){ - let _ = (p + 1) % 3, y = u[p], b = u[_], A = _s[h[p]], L = _s[h[_]], I = `${y}_${b}`, k = `${b}_${y}`; - k in d && d[k] ? (Jo.dot(d[k].normal) <= r && (f.push(A.x, A.y, A.z), f.push(L.x, L.y, L.z)), d[k] = null) : I in d || (d[I] = { - index0: c[p], - index1: c[_], - normal: Jo.clone() - }); - } - } - for(let m in d)if (d[m]) { - let { index0: x , index1: v } = d[m]; - ys.fromBufferAttribute(a, x), vs.fromBufferAttribute(a, v), f.push(ys.x, ys.y, ys.z), f.push(vs.x, vs.y, vs.z); - } - this.setAttribute("position", new de(f, 3)); - } - } -}, Ct = class { - constructor(){ - this.type = "Curve", this.arcLengthDivisions = 200; - } - getPoint() { - return console.warn("THREE.Curve: .getPoint() not implemented."), null; - } - getPointAt(e, t) { - let n = this.getUtoTmapping(e); - return this.getPoint(n, t); - } - getPoints(e = 5) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); - return t; - } - getSpacedPoints(e = 5) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPointAt(n / e)); - return t; - } - getLength() { - let e = this.getLengths(); - return e[e.length - 1]; - } - getLengths(e = this.arcLengthDivisions) { - if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; - this.needsUpdate = !1; - let t = [], n, i = this.getPoint(0), r = 0; - t.push(0); - for(let o = 1; o <= e; o++)n = this.getPoint(o / e), r += n.distanceTo(i), t.push(r), i = n; - return this.cacheArcLengths = t, t; - } - updateArcLengths() { - this.needsUpdate = !0, this.getLengths(); - } - getUtoTmapping(e, t) { - let n = this.getLengths(), i = 0, r = n.length, o; - t ? o = t : o = e * n[r - 1]; - let a = 0, l = r - 1, c; - for(; a <= l;)if (i = Math.floor(a + (l - a) / 2), c = n[i] - o, c < 0) a = i + 1; - else if (c > 0) l = i - 1; - else { - l = i; - break; - } - if (i = l, n[i] === o) return i / (r - 1); - let h = n[i], d = n[i + 1] - h, f = (o - h) / d; - return (i + f) / (r - 1); - } - getTangent(e, t) { - let i = e - 1e-4, r = e + 1e-4; - i < 0 && (i = 0), r > 1 && (r = 1); - let o = this.getPoint(i), a = this.getPoint(r), l = t || (o.isVector2 ? new X : new M); - return l.copy(a).sub(o).normalize(), l; - } - getTangentAt(e, t) { - let n = this.getUtoTmapping(e); - return this.getTangent(n, t); - } - computeFrenetFrames(e, t) { - let n = new M, i = [], r = [], o = [], a = new M, l = new pe; - for(let f = 0; f <= e; f++){ - let m = f / e; - i[f] = this.getTangentAt(m, new M); - } - r[0] = new M, o[0] = new M; - let c = Number.MAX_VALUE, h = Math.abs(i[0].x), u = Math.abs(i[0].y), d = Math.abs(i[0].z); - h <= c && (c = h, n.set(1, 0, 0)), u <= c && (c = u, n.set(0, 1, 0)), d <= c && n.set(0, 0, 1), a.crossVectors(i[0], n).normalize(), r[0].crossVectors(i[0], a), o[0].crossVectors(i[0], r[0]); - for(let f = 1; f <= e; f++){ - if (r[f] = r[f - 1].clone(), o[f] = o[f - 1].clone(), a.crossVectors(i[f - 1], i[f]), a.length() > Number.EPSILON) { - a.normalize(); - let m = Math.acos(mt(i[f - 1].dot(i[f]), -1, 1)); - r[f].applyMatrix4(l.makeRotationAxis(a, m)); - } - o[f].crossVectors(i[f], r[f]); - } - if (t === !0) { - let f = Math.acos(mt(r[0].dot(r[e]), -1, 1)); - f /= e, i[0].dot(a.crossVectors(r[0], r[e])) > 0 && (f = -f); - for(let m = 1; m <= e; m++)r[m].applyMatrix4(l.makeRotationAxis(i[m], f * m)), o[m].crossVectors(i[m], r[m]); - } - return { - tangents: i, - normals: r, - binormals: o - }; - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.arcLengthDivisions = e.arcLengthDivisions, this; - } - toJSON() { - let e = { - metadata: { - version: 4.5, - type: "Curve", - generator: "Curve.toJSON" - } - }; - return e.arcLengthDivisions = this.arcLengthDivisions, e.type = this.type, e; - } - fromJSON(e) { - return this.arcLengthDivisions = e.arcLengthDivisions, this; - } -}, Ur = class extends Ct { - constructor(e = 0, t = 0, n = 1, i = 1, r = 0, o = Math.PI * 2, a = !1, l = 0){ - super(); - this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = n, this.yRadius = i, this.aStartAngle = r, this.aEndAngle = o, this.aClockwise = a, this.aRotation = l; - } - getPoint(e, t) { - let n = t || new X, i = Math.PI * 2, r = this.aEndAngle - this.aStartAngle, o = Math.abs(r) < Number.EPSILON; - for(; r < 0;)r += i; - for(; r > i;)r -= i; - r < Number.EPSILON && (o ? r = 0 : r = i), this.aClockwise === !0 && !o && (r === i ? r = -i : r = r - i); - let a = this.aStartAngle + e * r, l = this.aX + this.xRadius * Math.cos(a), c = this.aY + this.yRadius * Math.sin(a); - if (this.aRotation !== 0) { - let h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), d = l - this.aX, f = c - this.aY; - l = d * h - f * u + this.aX, c = d * u + f * h + this.aY; - } - return n.set(l, c); - } - copy(e) { - return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; - } - toJSON() { - let e = super.toJSON(); - return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e; - } - fromJSON(e) { - return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; - } -}; -Ur.prototype.isEllipseCurve = !0; -var Ma = class extends Ur { - constructor(e, t, n, i, r, o){ - super(e, t, n, n, i, r, o); - this.type = "ArcCurve"; - } -}; -Ma.prototype.isArcCurve = !0; -function ba() { - let s = 0, e = 0, t = 0, n = 0; - function i(r, o, a, l) { - s = r, e = a, t = -3 * r + 3 * o - 2 * a - l, n = 2 * r - 2 * o + a + l; - } - return { - initCatmullRom: function(r, o, a, l, c) { - i(o, a, c * (a - r), c * (l - o)); - }, - initNonuniformCatmullRom: function(r, o, a, l, c, h, u) { - let d = (o - r) / c - (a - r) / (c + h) + (a - o) / h, f = (a - o) / h - (l - o) / (h + u) + (l - a) / u; - d *= h, f *= h, i(o, a, d, f); - }, - calc: function(r) { - let o = r * r, a = o * r; - return s + e * r + t * o + n * a; - } - }; -} -var Ms = new M, Yo = new ba, Zo = new ba, $o = new ba, wa = class extends Ct { - constructor(e = [], t = !1, n = "centripetal", i = .5){ - super(); - this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = n, this.tension = i; - } - getPoint(e, t = new M) { - let n = t, i = this.points, r = i.length, o = (r - (this.closed ? 0 : 1)) * e, a = Math.floor(o), l = o - a; - this.closed ? a += a > 0 ? 0 : (Math.floor(Math.abs(a) / r) + 1) * r : l === 0 && a === r - 1 && (a = r - 2, l = 1); - let c, h; - this.closed || a > 0 ? c = i[(a - 1) % r] : (Ms.subVectors(i[0], i[1]).add(i[0]), c = Ms); - let u = i[a % r], d = i[(a + 1) % r]; - if (this.closed || a + 2 < r ? h = i[(a + 2) % r] : (Ms.subVectors(i[r - 1], i[r - 2]).add(i[r - 1]), h = Ms), this.curveType === "centripetal" || this.curveType === "chordal") { - let f = this.curveType === "chordal" ? .5 : .25, m = Math.pow(c.distanceToSquared(u), f), x = Math.pow(u.distanceToSquared(d), f), v = Math.pow(d.distanceToSquared(h), f); - x < 1e-4 && (x = 1), m < 1e-4 && (m = x), v < 1e-4 && (v = x), Yo.initNonuniformCatmullRom(c.x, u.x, d.x, h.x, m, x, v), Zo.initNonuniformCatmullRom(c.y, u.y, d.y, h.y, m, x, v), $o.initNonuniformCatmullRom(c.z, u.z, d.z, h.z, m, x, v); - } else this.curveType === "catmullrom" && (Yo.initCatmullRom(c.x, u.x, d.x, h.x, this.tension), Zo.initCatmullRom(c.y, u.y, d.y, h.y, this.tension), $o.initCatmullRom(c.z, u.z, d.z, h.z, this.tension)); - return n.set(Yo.calc(l), Zo.calc(l), $o.calc(l)), n; - } - copy(e) { - super.copy(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(i.clone()); - } - return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; - } - toJSON() { - let e = super.toJSON(); - e.points = []; - for(let t = 0, n = this.points.length; t < n; t++){ - let i = this.points[t]; - e.points.push(i.toArray()); - } - return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e; - } - fromJSON(e) { - super.fromJSON(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(new M().fromArray(i)); - } - return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; - } -}; -wa.prototype.isCatmullRomCurve3 = !0; -function pc(s, e, t, n, i) { - let r = (n - e) * .5, o = (i - t) * .5, a = s * s, l = s * a; - return (2 * t - 2 * n + r + o) * l + (-3 * t + 3 * n - 2 * r - o) * a + r * s + t; -} -function Ix(s, e) { - let t = 1 - s; - return t * t * e; -} -function Dx(s, e) { - return 2 * (1 - s) * s * e; -} -function Fx(s, e) { - return s * s * e; -} -function ar(s, e, t, n) { - return Ix(s, e) + Dx(s, t) + Fx(s, n); -} -function Nx(s, e) { - let t = 1 - s; - return t * t * t * e; -} -function Bx(s, e) { - let t = 1 - s; - return 3 * t * t * s * e; -} -function zx(s, e) { - return 3 * (1 - s) * s * s * e; -} -function Ux(s, e) { - return s * s * s * e; -} -function lr(s, e, t, n, i) { - return Nx(s, e) + Bx(s, t) + zx(s, n) + Ux(s, i); -} -var lo = class extends Ct { - constructor(e = new X, t = new X, n = new X, i = new X){ - super(); - this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; - } - getPoint(e, t = new X) { - let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; - return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; - } -}; -lo.prototype.isCubicBezierCurve = !0; -var Sa = class extends Ct { - constructor(e = new M, t = new M, n = new M, i = new M){ - super(); - this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; - } - getPoint(e, t = new M) { - let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; - return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y), lr(e, i.z, r.z, o.z, a.z)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; - } -}; -Sa.prototype.isCubicBezierCurve3 = !0; -var Or = class extends Ct { - constructor(e = new X, t = new X){ - super(); - this.type = "LineCurve", this.v1 = e, this.v2 = t; - } - getPoint(e, t = new X) { - let n = t; - return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; - } - getPointAt(e, t) { - return this.getPoint(e, t); - } - getTangent(e, t) { - let n = t || new X; - return n.copy(this.v2).sub(this.v1).normalize(), n; - } - copy(e) { - return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}; -Or.prototype.isLineCurve = !0; -var Eh = class extends Ct { - constructor(e = new M, t = new M){ - super(); - this.type = "LineCurve3", this.isLineCurve3 = !0, this.v1 = e, this.v2 = t; - } - getPoint(e, t = new M) { - let n = t; - return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; - } - getPointAt(e, t) { - return this.getPoint(e, t); - } - copy(e) { - return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}, co = class extends Ct { - constructor(e = new X, t = new X, n = new X){ - super(); - this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n; - } - getPoint(e, t = new X) { - let n = t, i = this.v0, r = this.v1, o = this.v2; - return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}; -co.prototype.isQuadraticBezierCurve = !0; -var ho = class extends Ct { - constructor(e = new M, t = new M, n = new M){ - super(); - this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n; - } - getPoint(e, t = new M) { - let n = t, i = this.v0, r = this.v1, o = this.v2; - return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y), ar(e, i.z, r.z, o.z)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}; -ho.prototype.isQuadraticBezierCurve3 = !0; -var uo = class extends Ct { - constructor(e = []){ - super(); - this.type = "SplineCurve", this.points = e; - } - getPoint(e, t = new X) { - let n = t, i = this.points, r = (i.length - 1) * e, o = Math.floor(r), a = r - o, l = i[o === 0 ? o : o - 1], c = i[o], h = i[o > i.length - 2 ? i.length - 1 : o + 1], u = i[o > i.length - 3 ? i.length - 1 : o + 2]; - return n.set(pc(a, l.x, c.x, h.x, u.x), pc(a, l.y, c.y, h.y, u.y)), n; - } - copy(e) { - super.copy(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(i.clone()); - } - return this; - } - toJSON() { - let e = super.toJSON(); - e.points = []; - for(let t = 0, n = this.points.length; t < n; t++){ - let i = this.points[t]; - e.points.push(i.toArray()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(new X().fromArray(i)); - } - return this; - } -}; -uo.prototype.isSplineCurve = !0; -var Ta = Object.freeze({ - __proto__: null, - ArcCurve: Ma, - CatmullRomCurve3: wa, - CubicBezierCurve: lo, - CubicBezierCurve3: Sa, - EllipseCurve: Ur, - LineCurve: Or, - LineCurve3: Eh, - QuadraticBezierCurve: co, - QuadraticBezierCurve3: ho, - SplineCurve: uo -}), Ah = class extends Ct { - constructor(){ - super(); - this.type = "CurvePath", this.curves = [], this.autoClose = !1; - } - add(e) { - this.curves.push(e); - } - closePath() { - let e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1); - e.equals(t) || this.curves.push(new Or(t, e)); - } - getPoint(e, t) { - let n = e * this.getLength(), i = this.getCurveLengths(), r = 0; - for(; r < i.length;){ - if (i[r] >= n) { - let o = i[r] - n, a = this.curves[r], l = a.getLength(), c = l === 0 ? 0 : 1 - o / l; - return a.getPointAt(c, t); - } - r++; - } - return null; - } - getLength() { - let e = this.getCurveLengths(); - return e[e.length - 1]; - } - updateArcLengths() { - this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths(); - } - getCurveLengths() { - if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; - let e = [], t = 0; - for(let n = 0, i = this.curves.length; n < i; n++)t += this.curves[n].getLength(), e.push(t); - return this.cacheLengths = e, e; - } - getSpacedPoints(e = 40) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); - return this.autoClose && t.push(t[0]), t; - } - getPoints(e = 12) { - let t = [], n; - for(let i = 0, r = this.curves; i < r.length; i++){ - let o = r[i], a = o && o.isEllipseCurve ? e * 2 : o && (o.isLineCurve || o.isLineCurve3) ? 1 : o && o.isSplineCurve ? e * o.points.length : e, l = o.getPoints(a); - for(let c = 0; c < l.length; c++){ - let h = l[c]; - n && n.equals(h) || (t.push(h), n = h); - } - } - return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; - } - copy(e) { - super.copy(e), this.curves = []; - for(let t = 0, n = e.curves.length; t < n; t++){ - let i = e.curves[t]; - this.curves.push(i.clone()); - } - return this.autoClose = e.autoClose, this; - } - toJSON() { - let e = super.toJSON(); - e.autoClose = this.autoClose, e.curves = []; - for(let t = 0, n = this.curves.length; t < n; t++){ - let i = this.curves[t]; - e.curves.push(i.toJSON()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.autoClose = e.autoClose, this.curves = []; - for(let t = 0, n = e.curves.length; t < n; t++){ - let i = e.curves[t]; - this.curves.push(new Ta[i.type]().fromJSON(i)); - } - return this; - } -}, gr = class extends Ah { - constructor(e){ - super(); - this.type = "Path", this.currentPoint = new X, e && this.setFromPoints(e); - } - setFromPoints(e) { - this.moveTo(e[0].x, e[0].y); - for(let t = 1, n = e.length; t < n; t++)this.lineTo(e[t].x, e[t].y); - return this; - } - moveTo(e, t) { - return this.currentPoint.set(e, t), this; - } - lineTo(e, t) { - let n = new Or(this.currentPoint.clone(), new X(e, t)); - return this.curves.push(n), this.currentPoint.set(e, t), this; - } - quadraticCurveTo(e, t, n, i) { - let r = new co(this.currentPoint.clone(), new X(e, t), new X(n, i)); - return this.curves.push(r), this.currentPoint.set(n, i), this; - } - bezierCurveTo(e, t, n, i, r, o) { - let a = new lo(this.currentPoint.clone(), new X(e, t), new X(n, i), new X(r, o)); - return this.curves.push(a), this.currentPoint.set(r, o), this; - } - splineThru(e) { - let t = [ - this.currentPoint.clone() - ].concat(e), n = new uo(t); - return this.curves.push(n), this.currentPoint.copy(e[e.length - 1]), this; - } - arc(e, t, n, i, r, o) { - let a = this.currentPoint.x, l = this.currentPoint.y; - return this.absarc(e + a, t + l, n, i, r, o), this; - } - absarc(e, t, n, i, r, o) { - return this.absellipse(e, t, n, n, i, r, o), this; - } - ellipse(e, t, n, i, r, o, a, l) { - let c = this.currentPoint.x, h = this.currentPoint.y; - return this.absellipse(e + c, t + h, n, i, r, o, a, l), this; - } - absellipse(e, t, n, i, r, o, a, l) { - let c = new Ur(e, t, n, i, r, o, a, l); - if (this.curves.length > 0) { - let u = c.getPoint(0); - u.equals(this.currentPoint) || this.lineTo(u.x, u.y); - } - this.curves.push(c); - let h = c.getPoint(1); - return this.currentPoint.copy(h), this; - } - copy(e) { - return super.copy(e), this.currentPoint.copy(e.currentPoint), this; - } - toJSON() { - let e = super.toJSON(); - return e.currentPoint = this.currentPoint.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this; - } -}, Xt = class extends gr { - constructor(e){ - super(e); - this.uuid = Et(), this.type = "Shape", this.holes = []; - } - getPointsHoles(e) { - let t = []; - for(let n = 0, i = this.holes.length; n < i; n++)t[n] = this.holes[n].getPoints(e); - return t; - } - extractPoints(e) { - return { - shape: this.getPoints(e), - holes: this.getPointsHoles(e) - }; - } - copy(e) { - super.copy(e), this.holes = []; - for(let t = 0, n = e.holes.length; t < n; t++){ - let i = e.holes[t]; - this.holes.push(i.clone()); - } - return this; - } - toJSON() { - let e = super.toJSON(); - e.uuid = this.uuid, e.holes = []; - for(let t = 0, n = this.holes.length; t < n; t++){ - let i = this.holes[t]; - e.holes.push(i.toJSON()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.uuid = e.uuid, this.holes = []; - for(let t = 0, n = e.holes.length; t < n; t++){ - let i = e.holes[t]; - this.holes.push(new gr().fromJSON(i)); - } - return this; - } -}, Ox = { - triangulate: function(s, e, t = 2) { - let n = e && e.length, i = n ? e[0] * t : s.length, r = Ch(s, 0, i, t, !0), o = []; - if (!r || r.next === r.prev) return o; - let a, l, c, h, u, d, f; - if (n && (r = Wx(s, e, r, t)), s.length > 80 * t) { - a = c = s[0], l = h = s[1]; - for(let m = t; m < i; m += t)u = s[m], d = s[m + 1], u < a && (a = u), d < l && (l = d), u > c && (c = u), d > h && (h = d); - f = Math.max(c - a, h - l), f = f !== 0 ? 1 / f : 0; - } - return xr(r, o, t, a, l, f), o; - } -}; -function Ch(s, e, t, n, i) { - let r, o; - if (i === ty(s, e, t, n) > 0) for(r = e; r < t; r += n)o = mc(r, s[r], s[r + 1], o); - else for(r = t - n; r >= e; r -= n)o = mc(r, s[r], s[r + 1], o); - return o && fo(o, o.next) && (vr(o), o = o.next), o; -} -function Tn(s, e) { - if (!s) return s; - e || (e = s); - let t = s, n; - do if (n = !1, !t.steiner && (fo(t, t.next) || $e(t.prev, t, t.next) === 0)) { - if (vr(t), t = e = t.prev, t === t.next) break; - n = !0; - } else t = t.next; - while (n || t !== e) - return e; -} -function xr(s, e, t, n, i, r, o) { - if (!s) return; - !o && r && Zx(s, n, i, r); - let a = s, l, c; - for(; s.prev !== s.next;){ - if (l = s.prev, c = s.next, r ? kx(s, n, i, r) : Hx(s)) { - e.push(l.i / t), e.push(s.i / t), e.push(c.i / t), vr(s), s = c.next, a = c.next; - continue; - } - if (s = c, s === a) { - o ? o === 1 ? (s = Gx(Tn(s), e, t), xr(s, e, t, n, i, r, 2)) : o === 2 && Vx(s, e, t, n, i, r) : xr(Tn(s), e, t, n, i, r, 1); - break; - } - } -} -function Hx(s) { - let e = s.prev, t = s, n = s.next; - if ($e(e, t, n) >= 0) return !1; - let i = s.next.next; - for(; i !== s.prev;){ - if (Si(e.x, e.y, t.x, t.y, n.x, n.y, i.x, i.y) && $e(i.prev, i, i.next) >= 0) return !1; - i = i.next; - } - return !0; -} -function kx(s, e, t, n) { - let i = s.prev, r = s, o = s.next; - if ($e(i, r, o) >= 0) return !1; - let a = i.x < r.x ? i.x < o.x ? i.x : o.x : r.x < o.x ? r.x : o.x, l = i.y < r.y ? i.y < o.y ? i.y : o.y : r.y < o.y ? r.y : o.y, c = i.x > r.x ? i.x > o.x ? i.x : o.x : r.x > o.x ? r.x : o.x, h = i.y > r.y ? i.y > o.y ? i.y : o.y : r.y > o.y ? r.y : o.y, u = oa(a, l, e, t, n), d = oa(c, h, e, t, n), f = s.prevZ, m = s.nextZ; - for(; f && f.z >= u && m && m.z <= d;){ - if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0 || (f = f.prevZ, m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0)) return !1; - m = m.nextZ; - } - for(; f && f.z >= u;){ - if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0) return !1; - f = f.prevZ; - } - for(; m && m.z <= d;){ - if (m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0) return !1; - m = m.nextZ; - } - return !0; -} -function Gx(s, e, t) { - let n = s; - do { - let i = n.prev, r = n.next.next; - !fo(i, r) && Lh(i, n, n.next, r) && yr(i, r) && yr(r, i) && (e.push(i.i / t), e.push(n.i / t), e.push(r.i / t), vr(n), vr(n.next), n = s = r), n = n.next; - }while (n !== s) - return Tn(n); -} -function Vx(s, e, t, n, i, r) { - let o = s; - do { - let a = o.next.next; - for(; a !== o.prev;){ - if (o.i !== a.i && Qx(o, a)) { - let l = Rh(o, a); - o = Tn(o, o.next), l = Tn(l, l.next), xr(o, e, t, n, i, r), xr(l, e, t, n, i, r); - return; - } - a = a.next; - } - o = o.next; - }while (o !== s) -} -function Wx(s, e, t, n) { - let i = [], r, o, a, l, c; - for(r = 0, o = e.length; r < o; r++)a = e[r] * n, l = r < o - 1 ? e[r + 1] * n : s.length, c = Ch(s, a, l, n, !1), c === c.next && (c.steiner = !0), i.push(jx(c)); - for(i.sort(qx), r = 0; r < i.length; r++)Xx(i[r], t), t = Tn(t, t.next); - return t; -} -function qx(s, e) { - return s.x - e.x; -} -function Xx(s, e) { - if (e = Jx(s, e), e) { - let t = Rh(e, s); - Tn(e, e.next), Tn(t, t.next); - } -} -function Jx(s, e) { - let t = e, n = s.x, i = s.y, r = -1 / 0, o; - do { - if (i <= t.y && i >= t.next.y && t.next.y !== t.y) { - let d = t.x + (i - t.y) * (t.next.x - t.x) / (t.next.y - t.y); - if (d <= n && d > r) { - if (r = d, d === n) { - if (i === t.y) return t; - if (i === t.next.y) return t.next; - } - o = t.x < t.next.x ? t : t.next; - } - } - t = t.next; - }while (t !== e) - if (!o) return null; - if (n === r) return o; - let a = o, l = o.x, c = o.y, h = 1 / 0, u; - t = o; - do n >= t.x && t.x >= l && n !== t.x && Si(i < c ? n : r, i, l, c, i < c ? r : n, i, t.x, t.y) && (u = Math.abs(i - t.y) / (n - t.x), yr(t, s) && (u < h || u === h && (t.x > o.x || t.x === o.x && Yx(o, t))) && (o = t, h = u)), t = t.next; - while (t !== a) - return o; -} -function Yx(s, e) { - return $e(s.prev, s, e.prev) < 0 && $e(e.next, s, s.next) < 0; -} -function Zx(s, e, t, n) { - let i = s; - do i.z === null && (i.z = oa(i.x, i.y, e, t, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next; - while (i !== s) - i.prevZ.nextZ = null, i.prevZ = null, $x(i); -} -function $x(s) { - let e, t, n, i, r, o, a, l, c = 1; - do { - for(t = s, s = null, r = null, o = 0; t;){ - for(o++, n = t, a = 0, e = 0; e < c && (a++, n = n.nextZ, !!n); e++); - for(l = c; a > 0 || l > 0 && n;)a !== 0 && (l === 0 || !n || t.z <= n.z) ? (i = t, t = t.nextZ, a--) : (i = n, n = n.nextZ, l--), r ? r.nextZ = i : s = i, i.prevZ = r, r = i; - t = n; - } - r.nextZ = null, c *= 2; - }while (o > 1) - return s; -} -function oa(s, e, t, n, i) { - return s = 32767 * (s - t) * i, e = 32767 * (e - n) * i, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, s | e << 1; -} -function jx(s) { - let e = s, t = s; - do (e.x < t.x || e.x === t.x && e.y < t.y) && (t = e), e = e.next; - while (e !== s) - return t; -} -function Si(s, e, t, n, i, r, o, a) { - return (i - o) * (e - a) - (s - o) * (r - a) >= 0 && (s - o) * (n - a) - (t - o) * (e - a) >= 0 && (t - o) * (r - a) - (i - o) * (n - a) >= 0; -} -function Qx(s, e) { - return s.next.i !== e.i && s.prev.i !== e.i && !Kx(s, e) && (yr(s, e) && yr(e, s) && ey(s, e) && ($e(s.prev, s, e.prev) || $e(s, e.prev, e)) || fo(s, e) && $e(s.prev, s, s.next) > 0 && $e(e.prev, e, e.next) > 0); -} -function $e(s, e, t) { - return (e.y - s.y) * (t.x - e.x) - (e.x - s.x) * (t.y - e.y); -} -function fo(s, e) { - return s.x === e.x && s.y === e.y; -} -function Lh(s, e, t, n) { - let i = ws($e(s, e, t)), r = ws($e(s, e, n)), o = ws($e(t, n, s)), a = ws($e(t, n, e)); - return !!(i !== r && o !== a || i === 0 && bs(s, t, e) || r === 0 && bs(s, n, e) || o === 0 && bs(t, s, n) || a === 0 && bs(t, e, n)); -} -function bs(s, e, t) { - return e.x <= Math.max(s.x, t.x) && e.x >= Math.min(s.x, t.x) && e.y <= Math.max(s.y, t.y) && e.y >= Math.min(s.y, t.y); -} -function ws(s) { - return s > 0 ? 1 : s < 0 ? -1 : 0; -} -function Kx(s, e) { - let t = s; - do { - if (t.i !== s.i && t.next.i !== s.i && t.i !== e.i && t.next.i !== e.i && Lh(t, t.next, s, e)) return !0; - t = t.next; - }while (t !== s) - return !1; -} -function yr(s, e) { - return $e(s.prev, s, s.next) < 0 ? $e(s, e, s.next) >= 0 && $e(s, s.prev, e) >= 0 : $e(s, e, s.prev) < 0 || $e(s, s.next, e) < 0; -} -function ey(s, e) { - let t = s, n = !1, i = (s.x + e.x) / 2, r = (s.y + e.y) / 2; - do t.y > r != t.next.y > r && t.next.y !== t.y && i < (t.next.x - t.x) * (r - t.y) / (t.next.y - t.y) + t.x && (n = !n), t = t.next; - while (t !== s) - return n; -} -function Rh(s, e) { - let t = new aa(s.i, s.x, s.y), n = new aa(e.i, e.x, e.y), i = s.next, r = e.prev; - return s.next = e, e.prev = s, t.next = i, i.prev = t, n.next = t, t.prev = n, r.next = n, n.prev = r, n; -} -function mc(s, e, t, n) { - let i = new aa(s, e, t); - return n ? (i.next = n.next, i.prev = n, n.next.prev = i, n.next = i) : (i.prev = i, i.next = i), i; -} -function vr(s) { - s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ); -} -function aa(s, e, t) { - this.i = s, this.x = e, this.y = t, this.prev = null, this.next = null, this.z = null, this.prevZ = null, this.nextZ = null, this.steiner = !1; -} -function ty(s, e, t, n) { - let i = 0; - for(let r = e, o = t - n; r < t; r += n)i += (s[o] - s[r]) * (s[r + 1] + s[o + 1]), o = r; - return i; -} -var Jt = class { - static area(e) { - let t = e.length, n = 0; - for(let i = t - 1, r = 0; r < t; i = r++)n += e[i].x * e[r].y - e[r].x * e[i].y; - return n * .5; - } - static isClockWise(e) { - return Jt.area(e) < 0; - } - static triangulateShape(e, t) { - let n = [], i = [], r = []; - gc(e), xc(n, e); - let o = e.length; - t.forEach(gc); - for(let l = 0; l < t.length; l++)i.push(o), o += t[l].length, xc(n, t[l]); - let a = Ox.triangulate(n, i); - for(let l = 0; l < a.length; l += 3)r.push(a.slice(l, l + 3)); - return r; - } -}; -function gc(s) { - let e = s.length; - e > 2 && s[e - 1].equals(s[0]) && s.pop(); -} -function xc(s, e) { - for(let t = 0; t < e.length; t++)s.push(e[t].x), s.push(e[t].y); -} -var ln = class extends _e { - constructor(e = new Xt([ - new X(.5, .5), - new X(-.5, .5), - new X(-.5, -.5), - new X(.5, -.5) - ]), t = {}){ - super(); - this.type = "ExtrudeGeometry", this.parameters = { - shapes: e, - options: t - }, e = Array.isArray(e) ? e : [ - e - ]; - let n = this, i = [], r = []; - for(let a = 0, l = e.length; a < l; a++){ - let c = e[a]; - o(c); - } - this.setAttribute("position", new de(i, 3)), this.setAttribute("uv", new de(r, 2)), this.computeVertexNormals(); - function o(a) { - let l = [], c = t.curveSegments !== void 0 ? t.curveSegments : 12, h = t.steps !== void 0 ? t.steps : 1, u = t.depth !== void 0 ? t.depth : 1, d = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, f = t.bevelThickness !== void 0 ? t.bevelThickness : .2, m = t.bevelSize !== void 0 ? t.bevelSize : f - .1, x = t.bevelOffset !== void 0 ? t.bevelOffset : 0, v = t.bevelSegments !== void 0 ? t.bevelSegments : 3, g = t.extrudePath, p = t.UVGenerator !== void 0 ? t.UVGenerator : ny; - t.amount !== void 0 && (console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."), u = t.amount); - let _, y = !1, b, A, L, I; - g && (_ = g.getSpacedPoints(h), y = !0, d = !1, b = g.computeFrenetFrames(h, !1), A = new M, L = new M, I = new M), d || (v = 0, f = 0, m = 0, x = 0); - let k = a.extractPoints(c), B = k.shape, P = k.holes; - if (!Jt.isClockWise(B)) { - B = B.reverse(); - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - Jt.isClockWise(K) && (P[G] = K.reverse()); - } - } - let E = Jt.triangulateShape(B, P), D = B; - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - B = B.concat(K); - } - function U(G, j, K) { - return j || console.error("THREE.ExtrudeGeometry: vec does not exist"), j.clone().multiplyScalar(K).add(G); - } - let F = B.length, O = E.length; - function ne(G, j, K) { - let ue, se, Se, Te = G.x - j.x, Pe = G.y - j.y, Ye = K.x - G.x, C = K.y - G.y, T = Te * Te + Pe * Pe, J = Te * C - Pe * Ye; - if (Math.abs(J) > Number.EPSILON) { - let $ = Math.sqrt(T), re = Math.sqrt(Ye * Ye + C * C), Z = j.x - Pe / $, Me = j.y + Te / $, ve = K.x - C / re, te = K.y + Ye / re, R = ((ve - Z) * C - (te - Me) * Ye) / (Te * C - Pe * Ye); - ue = Z + Te * R - G.x, se = Me + Pe * R - G.y; - let ee = ue * ue + se * se; - if (ee <= 2) return new X(ue, se); - Se = Math.sqrt(ee / 2); - } else { - let $ = !1; - Te > Number.EPSILON ? Ye > Number.EPSILON && ($ = !0) : Te < -Number.EPSILON ? Ye < -Number.EPSILON && ($ = !0) : Math.sign(Pe) === Math.sign(C) && ($ = !0), $ ? (ue = -Pe, se = Te, Se = Math.sqrt(T)) : (ue = Te, se = Pe, Se = Math.sqrt(T / 2)); - } - return new X(ue / Se, se / Se); - } - let ce = []; - for(let G = 0, j = D.length, K = j - 1, ue = G + 1; G < j; G++, K++, ue++)K === j && (K = 0), ue === j && (ue = 0), ce[G] = ne(D[G], D[K], D[ue]); - let V = [], W, he = ce.concat(); - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - W = []; - for(let ue = 0, se = K.length, Se = se - 1, Te = ue + 1; ue < se; ue++, Se++, Te++)Se === se && (Se = 0), Te === se && (Te = 0), W[ue] = ne(K[ue], K[Se], K[Te]); - V.push(W), he = he.concat(W); - } - for(let G = 0; G < v; G++){ - let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; - for(let se = 0, Se = D.length; se < Se; se++){ - let Te = U(D[se], ce[se], ue); - Ce(Te.x, Te.y, -K); - } - for(let se = 0, Se = P.length; se < Se; se++){ - let Te = P[se]; - W = V[se]; - for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ - let C = U(Te[Pe], W[Pe], ue); - Ce(C.x, C.y, -K); - } - } - } - let le = m + x; - for(let G = 0; G < F; G++){ - let j = d ? U(B[G], he[G], le) : B[G]; - y ? (L.copy(b.normals[0]).multiplyScalar(j.x), A.copy(b.binormals[0]).multiplyScalar(j.y), I.copy(_[0]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(j.x, j.y, 0); - } - for(let G = 1; G <= h; G++)for(let j = 0; j < F; j++){ - let K = d ? U(B[j], he[j], le) : B[j]; - y ? (L.copy(b.normals[G]).multiplyScalar(K.x), A.copy(b.binormals[G]).multiplyScalar(K.y), I.copy(_[G]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(K.x, K.y, u / h * G); - } - for(let G = v - 1; G >= 0; G--){ - let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; - for(let se = 0, Se = D.length; se < Se; se++){ - let Te = U(D[se], ce[se], ue); - Ce(Te.x, Te.y, u + K); - } - for(let se = 0, Se = P.length; se < Se; se++){ - let Te = P[se]; - W = V[se]; - for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ - let C = U(Te[Pe], W[Pe], ue); - y ? Ce(C.x, C.y + _[h - 1].y, _[h - 1].x + K) : Ce(C.x, C.y, u + K); - } - } - } - fe(), Be(); - function fe() { - let G = i.length / 3; - if (d) { - let j = 0, K = F * j; - for(let ue = 0; ue < O; ue++){ - let se = E[ue]; - ye(se[2] + K, se[1] + K, se[0] + K); - } - j = h + v * 2, K = F * j; - for(let ue = 0; ue < O; ue++){ - let se = E[ue]; - ye(se[0] + K, se[1] + K, se[2] + K); - } - } else { - for(let j = 0; j < O; j++){ - let K = E[j]; - ye(K[2], K[1], K[0]); - } - for(let j = 0; j < O; j++){ - let K = E[j]; - ye(K[0] + F * h, K[1] + F * h, K[2] + F * h); - } - } - n.addGroup(G, i.length / 3 - G, 0); - } - function Be() { - let G = i.length / 3, j = 0; - Y(D, j), j += D.length; - for(let K = 0, ue = P.length; K < ue; K++){ - let se = P[K]; - Y(se, j), j += se.length; - } - n.addGroup(G, i.length / 3 - G, 1); - } - function Y(G, j) { - let K = G.length; - for(; --K >= 0;){ - let ue = K, se = K - 1; - se < 0 && (se = G.length - 1); - for(let Se = 0, Te = h + v * 2; Se < Te; Se++){ - let Pe = F * Se, Ye = F * (Se + 1), C = j + ue + Pe, T = j + se + Pe, J = j + se + Ye, $ = j + ue + Ye; - ge(C, T, J, $); - } - } - } - function Ce(G, j, K) { - l.push(G), l.push(j), l.push(K); - } - function ye(G, j, K) { - xe(G), xe(j), xe(K); - let ue = i.length / 3, se = p.generateTopUV(n, i, ue - 3, ue - 2, ue - 1); - Oe(se[0]), Oe(se[1]), Oe(se[2]); - } - function ge(G, j, K, ue) { - xe(G), xe(j), xe(ue), xe(j), xe(K), xe(ue); - let se = i.length / 3, Se = p.generateSideWallUV(n, i, se - 6, se - 3, se - 2, se - 1); - Oe(Se[0]), Oe(Se[1]), Oe(Se[3]), Oe(Se[1]), Oe(Se[2]), Oe(Se[3]); - } - function xe(G) { - i.push(l[G * 3 + 0]), i.push(l[G * 3 + 1]), i.push(l[G * 3 + 2]); - } - function Oe(G) { - r.push(G.x), r.push(G.y); - } - } - } - toJSON() { - let e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options; - return iy(t, n, e); - } - static fromJSON(e, t) { - let n = []; - for(let r = 0, o = e.shapes.length; r < o; r++){ - let a = t[e.shapes[r]]; - n.push(a); - } - let i = e.options.extrudePath; - return i !== void 0 && (e.options.extrudePath = new Ta[i.type]().fromJSON(i)), new ln(n, e.options); - } -}, ny = { - generateTopUV: function(s, e, t, n, i) { - let r = e[t * 3], o = e[t * 3 + 1], a = e[n * 3], l = e[n * 3 + 1], c = e[i * 3], h = e[i * 3 + 1]; - return [ - new X(r, o), - new X(a, l), - new X(c, h) - ]; - }, - generateSideWallUV: function(s, e, t, n, i, r) { - let o = e[t * 3], a = e[t * 3 + 1], l = e[t * 3 + 2], c = e[n * 3], h = e[n * 3 + 1], u = e[n * 3 + 2], d = e[i * 3], f = e[i * 3 + 1], m = e[i * 3 + 2], x = e[r * 3], v = e[r * 3 + 1], g = e[r * 3 + 2]; - return Math.abs(a - h) < Math.abs(o - c) ? [ - new X(o, 1 - l), - new X(c, 1 - u), - new X(d, 1 - m), - new X(x, 1 - g) - ] : [ - new X(a, 1 - l), - new X(h, 1 - u), - new X(f, 1 - m), - new X(v, 1 - g) - ]; - } -}; -function iy(s, e, t) { - if (t.shapes = [], Array.isArray(s)) for(let n = 0, i = s.length; n < i; n++){ - let r = s[n]; - t.shapes.push(r.uuid); - } - else t.shapes.push(s.uuid); - return e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t; -} -var _r = class extends an { - constructor(e = 1, t = 0){ - let n = (1 + Math.sqrt(5)) / 2, i = [ - -1, - n, - 0, - 1, - n, - 0, - -1, - -n, - 0, - 1, - -n, - 0, - 0, - -1, - n, - 0, - 1, - n, - 0, - -1, - -n, - 0, - 1, - -n, - n, - 0, - -1, - n, - 0, - 1, - -n, - 0, - -1, - -n, - 0, - 1 - ], r = [ - 0, - 11, - 5, - 0, - 5, - 1, - 0, - 1, - 7, - 0, - 7, - 10, - 0, - 10, - 11, - 1, - 5, - 9, - 5, - 11, - 4, - 11, - 10, - 2, - 10, - 7, - 6, - 7, - 1, - 8, - 3, - 9, - 4, - 3, - 4, - 2, - 3, - 2, - 6, - 3, - 6, - 8, - 3, - 8, - 9, - 4, - 9, - 5, - 2, - 4, - 11, - 6, - 2, - 10, - 8, - 6, - 7, - 9, - 8, - 1 - ]; - super(i, r, e, t); - this.type = "IcosahedronGeometry", this.parameters = { - radius: e, - detail: t - }; - } - static fromJSON(e) { - return new _r(e.radius, e.detail); - } -}, Mr = class extends _e { - constructor(e = [ - new X(0, .5), - new X(.5, 0), - new X(0, -.5) - ], t = 12, n = 0, i = Math.PI * 2){ - super(); - this.type = "LatheGeometry", this.parameters = { - points: e, - segments: t, - phiStart: n, - phiLength: i - }, t = Math.floor(t), i = mt(i, 0, Math.PI * 2); - let r = [], o = [], a = [], l = [], c = [], h = 1 / t, u = new M, d = new X, f = new M, m = new M, x = new M, v = 0, g = 0; - for(let p = 0; p <= e.length - 1; p++)switch(p){ - case 0: - v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, x.copy(f), f.normalize(), l.push(f.x, f.y, f.z); - break; - case e.length - 1: - l.push(x.x, x.y, x.z); - break; - default: - v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, m.copy(f), f.x += x.x, f.y += x.y, f.z += x.z, f.normalize(), l.push(f.x, f.y, f.z), x.copy(m); - } - for(let p = 0; p <= t; p++){ - let _ = n + p * h * i, y = Math.sin(_), b = Math.cos(_); - for(let A = 0; A <= e.length - 1; A++){ - u.x = e[A].x * y, u.y = e[A].y, u.z = e[A].x * b, o.push(u.x, u.y, u.z), d.x = p / t, d.y = A / (e.length - 1), a.push(d.x, d.y); - let L = l[3 * A + 0] * y, I = l[3 * A + 1], k = l[3 * A + 0] * b; - c.push(L, I, k); - } - } - for(let p = 0; p < t; p++)for(let _ = 0; _ < e.length - 1; _++){ - let y = _ + p * e.length, b = y, A = y + e.length, L = y + e.length + 1, I = y + 1; - r.push(b, A, I), r.push(A, L, I); - } - this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("uv", new de(a, 2)), this.setAttribute("normal", new de(c, 3)); - } - static fromJSON(e) { - return new Mr(e.points, e.segments, e.phiStart, e.phiLength); - } -}, Ii = class extends an { - constructor(e = 1, t = 0){ - let n = [ - 1, - 0, - 0, - -1, - 0, - 0, - 0, - 1, - 0, - 0, - -1, - 0, - 0, - 0, - 1, - 0, - 0, - -1 - ], i = [ - 0, - 2, - 4, - 0, - 4, - 3, - 0, - 3, - 5, - 0, - 5, - 2, - 1, - 2, - 5, - 1, - 5, - 3, - 1, - 3, - 4, - 1, - 4, - 2 - ]; - super(n, i, e, t); - this.type = "OctahedronGeometry", this.parameters = { - radius: e, - detail: t - }; - } - static fromJSON(e) { - return new Ii(e.radius, e.detail); - } -}, br = class extends _e { - constructor(e = .5, t = 1, n = 8, i = 1, r = 0, o = Math.PI * 2){ - super(); - this.type = "RingGeometry", this.parameters = { - innerRadius: e, - outerRadius: t, - thetaSegments: n, - phiSegments: i, - thetaStart: r, - thetaLength: o - }, n = Math.max(3, n), i = Math.max(1, i); - let a = [], l = [], c = [], h = [], u = e, d = (t - e) / i, f = new M, m = new X; - for(let x = 0; x <= i; x++){ - for(let v = 0; v <= n; v++){ - let g = r + v / n * o; - f.x = u * Math.cos(g), f.y = u * Math.sin(g), l.push(f.x, f.y, f.z), c.push(0, 0, 1), m.x = (f.x / t + 1) / 2, m.y = (f.y / t + 1) / 2, h.push(m.x, m.y); - } - u += d; - } - for(let x = 0; x < i; x++){ - let v = x * (n + 1); - for(let g = 0; g < n; g++){ - let p = g + v, _ = p, y = p + n + 1, b = p + n + 2, A = p + 1; - a.push(_, y, A), a.push(y, b, A); - } - } - this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); - } - static fromJSON(e) { - return new br(e.innerRadius, e.outerRadius, e.thetaSegments, e.phiSegments, e.thetaStart, e.thetaLength); - } -}, Di = class extends _e { - constructor(e = new Xt([ - new X(0, .5), - new X(-.5, -.5), - new X(.5, -.5) - ]), t = 12){ - super(); - this.type = "ShapeGeometry", this.parameters = { - shapes: e, - curveSegments: t - }; - let n = [], i = [], r = [], o = [], a = 0, l = 0; - if (Array.isArray(e) === !1) c(e); - else for(let h = 0; h < e.length; h++)c(e[h]), this.addGroup(a, l, h), a += l, l = 0; - this.setIndex(n), this.setAttribute("position", new de(i, 3)), this.setAttribute("normal", new de(r, 3)), this.setAttribute("uv", new de(o, 2)); - function c(h) { - let u = i.length / 3, d = h.extractPoints(t), f = d.shape, m = d.holes; - Jt.isClockWise(f) === !1 && (f = f.reverse()); - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v]; - Jt.isClockWise(p) === !0 && (m[v] = p.reverse()); - } - let x = Jt.triangulateShape(f, m); - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v]; - f = f.concat(p); - } - for(let v = 0, g = f.length; v < g; v++){ - let p = f[v]; - i.push(p.x, p.y, 0), r.push(0, 0, 1), o.push(p.x, p.y); - } - for(let v = 0, g = x.length; v < g; v++){ - let p = x[v], _ = p[0] + u, y = p[1] + u, b = p[2] + u; - n.push(_, y, b), l += 3; - } - } - } - toJSON() { - let e = super.toJSON(), t = this.parameters.shapes; - return ry(t, e); - } - static fromJSON(e, t) { - let n = []; - for(let i = 0, r = e.shapes.length; i < r; i++){ - let o = t[e.shapes[i]]; - n.push(o); - } - return new Di(n, e.curveSegments); - } -}; -function ry(s, e) { - if (e.shapes = [], Array.isArray(s)) for(let t = 0, n = s.length; t < n; t++){ - let i = s[t]; - e.shapes.push(i.uuid); - } - else e.shapes.push(s.uuid); - return e; -} -var Fi = class extends _e { - constructor(e = 1, t = 32, n = 16, i = 0, r = Math.PI * 2, o = 0, a = Math.PI){ - super(); - this.type = "SphereGeometry", this.parameters = { - radius: e, - widthSegments: t, - heightSegments: n, - phiStart: i, - phiLength: r, - thetaStart: o, - thetaLength: a - }, t = Math.max(3, Math.floor(t)), n = Math.max(2, Math.floor(n)); - let l = Math.min(o + a, Math.PI), c = 0, h = [], u = new M, d = new M, f = [], m = [], x = [], v = []; - for(let g = 0; g <= n; g++){ - let p = [], _ = g / n, y = 0; - g == 0 && o == 0 ? y = .5 / t : g == n && l == Math.PI && (y = -.5 / t); - for(let b = 0; b <= t; b++){ - let A = b / t; - u.x = -e * Math.cos(i + A * r) * Math.sin(o + _ * a), u.y = e * Math.cos(o + _ * a), u.z = e * Math.sin(i + A * r) * Math.sin(o + _ * a), m.push(u.x, u.y, u.z), d.copy(u).normalize(), x.push(d.x, d.y, d.z), v.push(A + y, 1 - _), p.push(c++); - } - h.push(p); - } - for(let g = 0; g < n; g++)for(let p = 0; p < t; p++){ - let _ = h[g][p + 1], y = h[g][p], b = h[g + 1][p], A = h[g + 1][p + 1]; - (g !== 0 || o > 0) && f.push(_, y, A), (g !== n - 1 || l < Math.PI) && f.push(y, b, A); - } - this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); - } - static fromJSON(e) { - return new Fi(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); - } -}, wr = class extends an { - constructor(e = 1, t = 0){ - let n = [ - 1, - 1, - 1, - -1, - -1, - 1, - -1, - 1, - -1, - 1, - -1, - -1 - ], i = [ - 2, - 1, - 0, - 0, - 3, - 2, - 1, - 3, - 0, - 2, - 3, - 1 - ]; - super(n, i, e, t); - this.type = "TetrahedronGeometry", this.parameters = { - radius: e, - detail: t - }; - } - static fromJSON(e) { - return new wr(e.radius, e.detail); - } -}, Sr = class extends _e { - constructor(e = 1, t = .4, n = 8, i = 6, r = Math.PI * 2){ - super(); - this.type = "TorusGeometry", this.parameters = { - radius: e, - tube: t, - radialSegments: n, - tubularSegments: i, - arc: r - }, n = Math.floor(n), i = Math.floor(i); - let o = [], a = [], l = [], c = [], h = new M, u = new M, d = new M; - for(let f = 0; f <= n; f++)for(let m = 0; m <= i; m++){ - let x = m / i * r, v = f / n * Math.PI * 2; - u.x = (e + t * Math.cos(v)) * Math.cos(x), u.y = (e + t * Math.cos(v)) * Math.sin(x), u.z = t * Math.sin(v), a.push(u.x, u.y, u.z), h.x = e * Math.cos(x), h.y = e * Math.sin(x), d.subVectors(u, h).normalize(), l.push(d.x, d.y, d.z), c.push(m / i), c.push(f / n); - } - for(let f = 1; f <= n; f++)for(let m = 1; m <= i; m++){ - let x = (i + 1) * f + m - 1, v = (i + 1) * (f - 1) + m - 1, g = (i + 1) * (f - 1) + m, p = (i + 1) * f + m; - o.push(x, v, p), o.push(v, g, p); - } - this.setIndex(o), this.setAttribute("position", new de(a, 3)), this.setAttribute("normal", new de(l, 3)), this.setAttribute("uv", new de(c, 2)); - } - static fromJSON(e) { - return new Sr(e.radius, e.tube, e.radialSegments, e.tubularSegments, e.arc); - } -}, Tr = class extends _e { - constructor(e = 1, t = .4, n = 64, i = 8, r = 2, o = 3){ - super(); - this.type = "TorusKnotGeometry", this.parameters = { - radius: e, - tube: t, - tubularSegments: n, - radialSegments: i, - p: r, - q: o - }, n = Math.floor(n), i = Math.floor(i); - let a = [], l = [], c = [], h = [], u = new M, d = new M, f = new M, m = new M, x = new M, v = new M, g = new M; - for(let _ = 0; _ <= n; ++_){ - let y = _ / n * r * Math.PI * 2; - p(y, r, o, e, f), p(y + .01, r, o, e, m), v.subVectors(m, f), g.addVectors(m, f), x.crossVectors(v, g), g.crossVectors(x, v), x.normalize(), g.normalize(); - for(let b = 0; b <= i; ++b){ - let A = b / i * Math.PI * 2, L = -t * Math.cos(A), I = t * Math.sin(A); - u.x = f.x + (L * g.x + I * x.x), u.y = f.y + (L * g.y + I * x.y), u.z = f.z + (L * g.z + I * x.z), l.push(u.x, u.y, u.z), d.subVectors(u, f).normalize(), c.push(d.x, d.y, d.z), h.push(_ / n), h.push(b / i); - } - } - for(let _ = 1; _ <= n; _++)for(let y = 1; y <= i; y++){ - let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; - a.push(b, A, I), a.push(A, L, I); - } - this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); - function p(_, y, b, A, L) { - let I = Math.cos(_), k = Math.sin(_), B = b / y * _, P = Math.cos(B); - L.x = A * (2 + P) * .5 * I, L.y = A * (2 + P) * k * .5, L.z = A * Math.sin(B) * .5; - } - } - static fromJSON(e) { - return new Tr(e.radius, e.tube, e.tubularSegments, e.radialSegments, e.p, e.q); - } -}, Er = class extends _e { - constructor(e = new ho(new M(-1, -1, 0), new M(-1, 1, 0), new M(1, 1, 0)), t = 64, n = 1, i = 8, r = !1){ - super(); - this.type = "TubeGeometry", this.parameters = { - path: e, - tubularSegments: t, - radius: n, - radialSegments: i, - closed: r - }; - let o = e.computeFrenetFrames(t, r); - this.tangents = o.tangents, this.normals = o.normals, this.binormals = o.binormals; - let a = new M, l = new M, c = new X, h = new M, u = [], d = [], f = [], m = []; - x(), this.setIndex(m), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); - function x() { - for(let _ = 0; _ < t; _++)v(_); - v(r === !1 ? t : 0), p(), g(); - } - function v(_) { - h = e.getPointAt(_ / t, h); - let y = o.normals[_], b = o.binormals[_]; - for(let A = 0; A <= i; A++){ - let L = A / i * Math.PI * 2, I = Math.sin(L), k = -Math.cos(L); - l.x = k * y.x + I * b.x, l.y = k * y.y + I * b.y, l.z = k * y.z + I * b.z, l.normalize(), d.push(l.x, l.y, l.z), a.x = h.x + n * l.x, a.y = h.y + n * l.y, a.z = h.z + n * l.z, u.push(a.x, a.y, a.z); - } - } - function g() { - for(let _ = 1; _ <= t; _++)for(let y = 1; y <= i; y++){ - let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; - m.push(b, A, I), m.push(A, L, I); - } - } - function p() { - for(let _ = 0; _ <= t; _++)for(let y = 0; y <= i; y++)c.x = _ / t, c.y = y / i, f.push(c.x, c.y); - } - } - toJSON() { - let e = super.toJSON(); - return e.path = this.parameters.path.toJSON(), e; - } - static fromJSON(e) { - return new Er(new Ta[e.path.type]().fromJSON(e.path), e.tubularSegments, e.radius, e.radialSegments, e.closed); - } -}, Ea = class extends _e { - constructor(e = null){ - super(); - if (this.type = "WireframeGeometry", this.parameters = { - geometry: e - }, e !== null) { - let t = [], n = new Set, i = new M, r = new M; - if (e.index !== null) { - let o = e.attributes.position, a = e.index, l = e.groups; - l.length === 0 && (l = [ - { - start: 0, - count: a.count, - materialIndex: 0 - } - ]); - for(let c = 0, h = l.length; c < h; ++c){ - let u = l[c], d = u.start, f = u.count; - for(let m = d, x = d + f; m < x; m += 3)for(let v = 0; v < 3; v++){ - let g = a.getX(m + v), p = a.getX(m + (v + 1) % 3); - i.fromBufferAttribute(o, g), r.fromBufferAttribute(o, p), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); - } - } - } else { - let o = e.attributes.position; - for(let a = 0, l = o.count / 3; a < l; a++)for(let c = 0; c < 3; c++){ - let h = 3 * a + c, u = 3 * a + (c + 1) % 3; - i.fromBufferAttribute(o, h), r.fromBufferAttribute(o, u), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); - } - } - this.setAttribute("position", new de(t, 3)); - } - } -}; -function yc(s, e, t) { - let n = `${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`, i = `${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`; - return t.has(n) === !0 || t.has(i) === !0 ? !1 : (t.add(n, i), !0); -} -var vc = Object.freeze({ - __proto__: null, - BoxGeometry: wn, - BoxBufferGeometry: wn, - CircleGeometry: fr, - CircleBufferGeometry: fr, - ConeGeometry: pr, - ConeBufferGeometry: pr, - CylinderGeometry: Jn, - CylinderBufferGeometry: Jn, - DodecahedronGeometry: mr, - DodecahedronBufferGeometry: mr, - EdgesGeometry: _a, - ExtrudeGeometry: ln, - ExtrudeBufferGeometry: ln, - IcosahedronGeometry: _r, - IcosahedronBufferGeometry: _r, - LatheGeometry: Mr, - LatheBufferGeometry: Mr, - OctahedronGeometry: Ii, - OctahedronBufferGeometry: Ii, - PlaneGeometry: Pi, - PlaneBufferGeometry: Pi, - PolyhedronGeometry: an, - PolyhedronBufferGeometry: an, - RingGeometry: br, - RingBufferGeometry: br, - ShapeGeometry: Di, - ShapeBufferGeometry: Di, - SphereGeometry: Fi, - SphereBufferGeometry: Fi, - TetrahedronGeometry: wr, - TetrahedronBufferGeometry: wr, - TorusGeometry: Sr, - TorusBufferGeometry: Sr, - TorusKnotGeometry: Tr, - TorusKnotBufferGeometry: Tr, - TubeGeometry: Er, - TubeBufferGeometry: Er, - WireframeGeometry: Ea -}), Aa = class extends dt { - constructor(e){ - super(); - this.type = "ShadowMaterial", this.color = new ae(0), this.transparent = !0, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this; - } -}; -Aa.prototype.isShadowMaterial = !0; -var po = class extends dt { - constructor(e){ - super(); - this.defines = { - STANDARD: "" - }, this.type = "MeshStandardMaterial", this.color = new ae(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapIntensity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.defines = { - STANDARD: "" - }, this.color.copy(e.color), this.roughness = e.roughness, this.metalness = e.metalness, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.roughnessMap = e.roughnessMap, this.metalnessMap = e.metalnessMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapIntensity = e.envMapIntensity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; - } -}; -po.prototype.isMeshStandardMaterial = !0; -var Ca = class extends po { - constructor(e){ - super(); - this.defines = { - STANDARD: "", - PHYSICAL: "" - }, this.type = "MeshPhysicalMaterial", this.clearcoatMap = null, this.clearcoatRoughness = 0, this.clearcoatRoughnessMap = null, this.clearcoatNormalScale = new X(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", { - get: function() { - return mt(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1); - }, - set: function(t) { - this.ior = (1 + .4 * t) / (1 - .4 * t); - } - }), this.sheenColor = new ae(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 0, this.attenuationColor = new ae(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new ae(1, 1, 1), this.specularColorMap = null, this._sheen = 0, this._clearcoat = 0, this._transmission = 0, this.setValues(e); - } - get sheen() { - return this._sheen; - } - set sheen(e) { - this._sheen > 0 != e > 0 && this.version++, this._sheen = e; - } - get clearcoat() { - return this._clearcoat; - } - set clearcoat(e) { - this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e; - } - get transmission() { - return this._transmission; - } - set transmission(e) { - this._transmission > 0 != e > 0 && this.version++, this._transmission = e; - } - copy(e) { - return super.copy(e), this.defines = { - STANDARD: "", - PHYSICAL: "" - }, this.clearcoat = e.clearcoat, this.clearcoatMap = e.clearcoatMap, this.clearcoatRoughness = e.clearcoatRoughness, this.clearcoatRoughnessMap = e.clearcoatRoughnessMap, this.clearcoatNormalMap = e.clearcoatNormalMap, this.clearcoatNormalScale.copy(e.clearcoatNormalScale), this.ior = e.ior, this.sheen = e.sheen, this.sheenColor.copy(e.sheenColor), this.sheenColorMap = e.sheenColorMap, this.sheenRoughness = e.sheenRoughness, this.sheenRoughnessMap = e.sheenRoughnessMap, this.transmission = e.transmission, this.transmissionMap = e.transmissionMap, this.thickness = e.thickness, this.thicknessMap = e.thicknessMap, this.attenuationDistance = e.attenuationDistance, this.attenuationColor.copy(e.attenuationColor), this.specularIntensity = e.specularIntensity, this.specularIntensityMap = e.specularIntensityMap, this.specularColor.copy(e.specularColor), this.specularColorMap = e.specularColorMap, this; - } -}; -Ca.prototype.isMeshPhysicalMaterial = !0; -var La = class extends dt { - constructor(e){ - super(); - this.type = "MeshPhongMaterial", this.color = new ae(16777215), this.specular = new ae(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.specular.copy(e.specular), this.shininess = e.shininess, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; - } -}; -La.prototype.isMeshPhongMaterial = !0; -var Ra = class extends dt { - constructor(e){ - super(); - this.defines = { - TOON: "" - }, this.type = "MeshToonMaterial", this.color = new ae(16777215), this.map = null, this.gradientMap = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.gradientMap = e.gradientMap, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; - } -}; -Ra.prototype.isMeshToonMaterial = !0; -var Pa = class extends dt { - constructor(e){ - super(); - this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.flatShading = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.flatShading = e.flatShading, this; - } -}; -Pa.prototype.isMeshNormalMaterial = !0; -var Ia = class extends dt { - constructor(e){ - super(); - this.type = "MeshLambertMaterial", this.color = new ae(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; - } -}; -Ia.prototype.isMeshLambertMaterial = !0; -var Da = class extends dt { - constructor(e){ - super(); - this.defines = { - MATCAP: "" - }, this.type = "MeshMatcapMaterial", this.color = new ae(16777215), this.matcap = null, this.map = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.flatShading = !1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.defines = { - MATCAP: "" - }, this.color.copy(e.color), this.matcap = e.matcap, this.map = e.map, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.flatShading = e.flatShading, this; - } -}; -Da.prototype.isMeshMatcapMaterial = !0; -var Fa = class extends ft { - constructor(e){ - super(); - this.type = "LineDashedMaterial", this.scale = 1, this.dashSize = 3, this.gapSize = 1, this.setValues(e); - } - copy(e) { - return super.copy(e), this.scale = e.scale, this.dashSize = e.dashSize, this.gapSize = e.gapSize, this; - } -}; -Fa.prototype.isLineDashedMaterial = !0; -var sy = Object.freeze({ - __proto__: null, - ShadowMaterial: Aa, - SpriteMaterial: io, - RawShaderMaterial: Gi, - ShaderMaterial: sn, - PointsMaterial: jn, - MeshPhysicalMaterial: Ca, - MeshStandardMaterial: po, - MeshPhongMaterial: La, - MeshToonMaterial: Ra, - MeshNormalMaterial: Pa, - MeshLambertMaterial: Ia, - MeshDepthMaterial: eo, - MeshDistanceMaterial: to, - MeshBasicMaterial: hn, - MeshMatcapMaterial: Da, - LineDashedMaterial: Fa, - LineBasicMaterial: ft, - Material: dt -}), Ze = { - arraySlice: function(s, e, t) { - return Ze.isTypedArray(s) ? new s.constructor(s.subarray(e, t !== void 0 ? t : s.length)) : s.slice(e, t); - }, - convertArray: function(s, e, t) { - return !s || !t && s.constructor === e ? s : typeof e.BYTES_PER_ELEMENT == "number" ? new e(s) : Array.prototype.slice.call(s); - }, - isTypedArray: function(s) { - return ArrayBuffer.isView(s) && !(s instanceof DataView); - }, - getKeyframeOrder: function(s) { - function e(i, r) { - return s[i] - s[r]; - } - let t = s.length, n = new Array(t); - for(let i = 0; i !== t; ++i)n[i] = i; - return n.sort(e), n; - }, - sortedArray: function(s, e, t) { - let n = s.length, i = new s.constructor(n); - for(let r = 0, o = 0; o !== n; ++r){ - let a = t[r] * e; - for(let l = 0; l !== e; ++l)i[o++] = s[a + l]; - } - return i; - }, - flattenJSON: function(s, e, t, n) { - let i = 1, r = s[0]; - for(; r !== void 0 && r[n] === void 0;)r = s[i++]; - if (r === void 0) return; - let o = r[n]; - if (o !== void 0) if (Array.isArray(o)) do o = r[n], o !== void 0 && (e.push(r.time), t.push.apply(t, o)), r = s[i++]; - while (r !== void 0) - else if (o.toArray !== void 0) do o = r[n], o !== void 0 && (e.push(r.time), o.toArray(t, t.length)), r = s[i++]; - while (r !== void 0) - else do o = r[n], o !== void 0 && (e.push(r.time), t.push(o)), r = s[i++]; - while (r !== void 0) - }, - subclip: function(s, e, t, n, i = 30) { - let r = s.clone(); - r.name = e; - let o = []; - for(let l = 0; l < r.tracks.length; ++l){ - let c = r.tracks[l], h = c.getValueSize(), u = [], d = []; - for(let f = 0; f < c.times.length; ++f){ - let m = c.times[f] * i; - if (!(m < t || m >= n)) { - u.push(c.times[f]); - for(let x = 0; x < h; ++x)d.push(c.values[f * h + x]); - } - } - u.length !== 0 && (c.times = Ze.convertArray(u, c.times.constructor), c.values = Ze.convertArray(d, c.values.constructor), o.push(c)); - } - r.tracks = o; - let a = 1 / 0; - for(let l = 0; l < r.tracks.length; ++l)a > r.tracks[l].times[0] && (a = r.tracks[l].times[0]); - for(let l = 0; l < r.tracks.length; ++l)r.tracks[l].shift(-1 * a); - return r.resetDuration(), r; - }, - makeClipAdditive: function(s, e = 0, t = s, n = 30) { - n <= 0 && (n = 30); - let i = t.tracks.length, r = e / n; - for(let o = 0; o < i; ++o){ - let a = t.tracks[o], l = a.ValueTypeName; - if (l === "bool" || l === "string") continue; - let c = s.tracks.find(function(g) { - return g.name === a.name && g.ValueTypeName === l; - }); - if (c === void 0) continue; - let h = 0, u = a.getValueSize(); - a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (h = u / 3); - let d = 0, f = c.getValueSize(); - c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (d = f / 3); - let m = a.times.length - 1, x; - if (r <= a.times[0]) { - let g = h, p = u - h; - x = Ze.arraySlice(a.values, g, p); - } else if (r >= a.times[m]) { - let g = m * u + h, p = g + u - h; - x = Ze.arraySlice(a.values, g, p); - } else { - let g = a.createInterpolant(), p = h, _ = u - h; - g.evaluate(r), x = Ze.arraySlice(g.resultBuffer, p, _); - } - l === "quaternion" && new gt().fromArray(x).normalize().conjugate().toArray(x); - let v = c.times.length; - for(let g = 0; g < v; ++g){ - let p = g * f + d; - if (l === "quaternion") gt.multiplyQuaternionsFlat(c.values, p, x, 0, c.values, p); - else { - let _ = f - d * 2; - for(let y = 0; y < _; ++y)c.values[p + y] -= x[y]; - } - } - } - return s.blendMode = qc, s; - } -}, cn = class { - constructor(e, t, n, i){ - this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = i !== void 0 ? i : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; - } - evaluate(e) { - let t = this.parameterPositions, n = this._cachedIndex, i = t[n], r = t[n - 1]; - e: { - t: { - let o; - n: { - i: if (!(e < i)) { - for(let a = n + 2;;){ - if (i === void 0) { - if (e < r) break i; - return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, e, r); - } - if (n === a) break; - if (r = i, i = t[++n], e < i) break t; - } - o = t.length; - break n; - } - if (!(e >= r)) { - let a = t[1]; - e < a && (n = 2, r = a); - for(let l = n - 2;;){ - if (r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); - if (n === l) break; - if (i = r, r = t[--n - 1], e >= r) break t; - } - o = n, n = 0; - break n; - } - break e; - } - for(; n < o;){ - let a = n + o >>> 1; - e < t[a] ? o = a : n = a + 1; - } - if (i = t[n], r = t[n - 1], r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); - if (i === void 0) return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, r, e); - } - this._cachedIndex = n, this.intervalChanged_(n, r, i); - } - return this.interpolate_(n, r, e, i); - } - getSettings_() { - return this.settings || this.DefaultSettings_; - } - copySampleValue_(e) { - let t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = e * i; - for(let o = 0; o !== i; ++o)t[o] = n[r + o]; - return t; - } - interpolate_() { - throw new Error("call to abstract method"); - } - intervalChanged_() {} -}; -cn.prototype.beforeStart_ = cn.prototype.copySampleValue_; -cn.prototype.afterEnd_ = cn.prototype.copySampleValue_; -var Ph = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { - endingStart: Mi, - endingEnd: Mi - }; - } - intervalChanged_(e, t, n) { - let i = this.parameterPositions, r = e - 2, o = e + 1, a = i[r], l = i[o]; - if (a === void 0) switch(this.getSettings_().endingStart){ - case bi: - r = e, a = 2 * t - n; - break; - case Os: - r = i.length - 2, a = t + i[r] - i[r + 1]; - break; - default: - r = e, a = n; - } - if (l === void 0) switch(this.getSettings_().endingEnd){ - case bi: - o = e, l = 2 * n - t; - break; - case Os: - o = 1, l = n + i[1] - i[0]; - break; - default: - o = e - 1, l = t; - } - let c = (n - t) * .5, h = this.valueSize; - this._weightPrev = c / (t - a), this._weightNext = c / (l - n), this._offsetPrev = r * h, this._offsetNext = o * h; - } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, m = (n - t) / (i - t), x = m * m, v = x * m, g = -d * v + 2 * d * x - d * m, p = (1 + d) * v + (-1.5 - 2 * d) * x + (-.5 + d) * m + 1, _ = (-1 - f) * v + (1.5 + f) * x + .5 * m, y = f * v - f * x; - for(let b = 0; b !== a; ++b)r[b] = g * o[h + b] + p * o[c + b] + _ * o[l + b] + y * o[u + b]; - return r; - } -}, Na = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = (n - t) / (i - t), u = 1 - h; - for(let d = 0; d !== a; ++d)r[d] = o[c + d] * u + o[l + d] * h; - return r; - } -}, Ih = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - } - interpolate_(e) { - return this.copySampleValue_(e - 1); - } -}, zt = class { - constructor(e, t, n, i){ - if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined"); - if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e); - this.name = e, this.times = Ze.convertArray(t, this.TimeBufferType), this.values = Ze.convertArray(n, this.ValueBufferType), this.setInterpolation(i || this.DefaultInterpolation); - } - static toJSON(e) { - let t = e.constructor, n; - if (t.toJSON !== this.toJSON) n = t.toJSON(e); - else { - n = { - name: e.name, - times: Ze.convertArray(e.times, Array), - values: Ze.convertArray(e.values, Array) - }; - let i = e.getInterpolation(); - i !== e.DefaultInterpolation && (n.interpolation = i); - } - return n.type = e.ValueTypeName, n; - } - InterpolantFactoryMethodDiscrete(e) { - return new Ih(this.times, this.values, this.getValueSize(), e); - } - InterpolantFactoryMethodLinear(e) { - return new Na(this.times, this.values, this.getValueSize(), e); - } - InterpolantFactoryMethodSmooth(e) { - return new Ph(this.times, this.values, this.getValueSize(), e); - } - setInterpolation(e) { - let t; - switch(e){ - case zs: - t = this.InterpolantFactoryMethodDiscrete; - break; - case Us: - t = this.InterpolantFactoryMethodLinear; - break; - case yo: - t = this.InterpolantFactoryMethodSmooth; - break; - } - if (t === void 0) { - let n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; - if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); - else throw new Error(n); - return console.warn("THREE.KeyframeTrack:", n), this; - } - return this.createInterpolant = t, this; - } - getInterpolation() { - switch(this.createInterpolant){ - case this.InterpolantFactoryMethodDiscrete: - return zs; - case this.InterpolantFactoryMethodLinear: - return Us; - case this.InterpolantFactoryMethodSmooth: - return yo; - } - } - getValueSize() { - return this.values.length / this.times.length; - } - shift(e) { - if (e !== 0) { - let t = this.times; - for(let n = 0, i = t.length; n !== i; ++n)t[n] += e; - } - return this; - } - scale(e) { - if (e !== 1) { - let t = this.times; - for(let n = 0, i = t.length; n !== i; ++n)t[n] *= e; - } - return this; - } - trim(e, t) { - let n = this.times, i = n.length, r = 0, o = i - 1; - for(; r !== i && n[r] < e;)++r; - for(; o !== -1 && n[o] > t;)--o; - if (++o, r !== 0 || o !== i) { - r >= o && (o = Math.max(o, 1), r = o - 1); - let a = this.getValueSize(); - this.times = Ze.arraySlice(n, r, o), this.values = Ze.arraySlice(this.values, r * a, o * a); - } - return this; - } - validate() { - let e = !0, t = this.getValueSize(); - t - Math.floor(t) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), e = !1); - let n = this.times, i = this.values, r = n.length; - r === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), e = !1); - let o = null; - for(let a = 0; a !== r; a++){ - let l = n[a]; - if (typeof l == "number" && isNaN(l)) { - console.error("THREE.KeyframeTrack: Time is not a valid number.", this, a, l), e = !1; - break; - } - if (o !== null && o > l) { - console.error("THREE.KeyframeTrack: Out of order keys.", this, a, l, o), e = !1; - break; - } - o = l; - } - if (i !== void 0 && Ze.isTypedArray(i)) for(let a = 0, l = i.length; a !== l; ++a){ - let c = i[a]; - if (isNaN(c)) { - console.error("THREE.KeyframeTrack: Value is not a valid number.", this, a, c), e = !1; - break; - } - } - return e; - } - optimize() { - let e = Ze.arraySlice(this.times), t = Ze.arraySlice(this.values), n = this.getValueSize(), i = this.getInterpolation() === yo, r = e.length - 1, o = 1; - for(let a = 1; a < r; ++a){ - let l = !1, c = e[a], h = e[a + 1]; - if (c !== h && (a !== 1 || c !== e[0])) if (i) l = !0; - else { - let u = a * n, d = u - n, f = u + n; - for(let m = 0; m !== n; ++m){ - let x = t[u + m]; - if (x !== t[d + m] || x !== t[f + m]) { - l = !0; - break; - } - } - } - if (l) { - if (a !== o) { - e[o] = e[a]; - let u = a * n, d = o * n; - for(let f = 0; f !== n; ++f)t[d + f] = t[u + f]; - } - ++o; - } - } - if (r > 0) { - e[o] = e[r]; - for(let a = r * n, l = o * n, c = 0; c !== n; ++c)t[l + c] = t[a + c]; - ++o; - } - return o !== e.length ? (this.times = Ze.arraySlice(e, 0, o), this.values = Ze.arraySlice(t, 0, o * n)) : (this.times = e, this.values = t), this; - } - clone() { - let e = Ze.arraySlice(this.times, 0), t = Ze.arraySlice(this.values, 0), n = this.constructor, i = new n(this.name, e, t); - return i.createInterpolant = this.createInterpolant, i; - } -}; -zt.prototype.TimeBufferType = Float32Array; -zt.prototype.ValueBufferType = Float32Array; -zt.prototype.DefaultInterpolation = Us; -var Qn = class extends zt { -}; -Qn.prototype.ValueTypeName = "bool"; -Qn.prototype.ValueBufferType = Array; -Qn.prototype.DefaultInterpolation = zs; -Qn.prototype.InterpolantFactoryMethodLinear = void 0; -Qn.prototype.InterpolantFactoryMethodSmooth = void 0; -var Ba = class extends zt { -}; -Ba.prototype.ValueTypeName = "color"; -var Ar = class extends zt { -}; -Ar.prototype.ValueTypeName = "number"; -var Dh = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = (n - t) / (i - t), c = e * a; - for(let h = c + a; c !== h; c += 4)gt.slerpFlat(r, 0, o, c - a, o, c, l); - return r; - } -}, Wi = class extends zt { - InterpolantFactoryMethodLinear(e) { - return new Dh(this.times, this.values, this.getValueSize(), e); - } -}; -Wi.prototype.ValueTypeName = "quaternion"; -Wi.prototype.DefaultInterpolation = Us; -Wi.prototype.InterpolantFactoryMethodSmooth = void 0; -var Kn = class extends zt { -}; -Kn.prototype.ValueTypeName = "string"; -Kn.prototype.ValueBufferType = Array; -Kn.prototype.DefaultInterpolation = zs; -Kn.prototype.InterpolantFactoryMethodLinear = void 0; -Kn.prototype.InterpolantFactoryMethodSmooth = void 0; -var Cr = class extends zt { -}; -Cr.prototype.ValueTypeName = "vector"; -var Lr = class { - constructor(e, t = -1, n, i = ua){ - this.name = e, this.tracks = n, this.duration = t, this.blendMode = i, this.uuid = Et(), this.duration < 0 && this.resetDuration(); - } - static parse(e) { - let t = [], n = e.tracks, i = 1 / (e.fps || 1); - for(let o = 0, a = n.length; o !== a; ++o)t.push(ay(n[o]).scale(i)); - let r = new this(e.name, e.duration, t, e.blendMode); - return r.uuid = e.uuid, r; - } - static toJSON(e) { - let t = [], n = e.tracks, i = { - name: e.name, - duration: e.duration, - tracks: t, - uuid: e.uuid, - blendMode: e.blendMode - }; - for(let r = 0, o = n.length; r !== o; ++r)t.push(zt.toJSON(n[r])); - return i; - } - static CreateFromMorphTargetSequence(e, t, n, i) { - let r = t.length, o = []; - for(let a = 0; a < r; a++){ - let l = [], c = []; - l.push((a + r - 1) % r, a, (a + 1) % r), c.push(0, 1, 0); - let h = Ze.getKeyframeOrder(l); - l = Ze.sortedArray(l, 1, h), c = Ze.sortedArray(c, 1, h), !i && l[0] === 0 && (l.push(r), c.push(c[0])), o.push(new Ar(".morphTargetInfluences[" + t[a].name + "]", l, c).scale(1 / n)); - } - return new this(e, -1, o); - } - static findByName(e, t) { - let n = e; - if (!Array.isArray(e)) { - let i = e; - n = i.geometry && i.geometry.animations || i.animations; - } - for(let i = 0; i < n.length; i++)if (n[i].name === t) return n[i]; - return null; - } - static CreateClipsFromMorphTargetSequences(e, t, n) { - let i = {}, r = /^([\w-]*?)([\d]+)$/; - for(let a = 0, l = e.length; a < l; a++){ - let c = e[a], h = c.name.match(r); - if (h && h.length > 1) { - let u = h[1], d = i[u]; - d || (i[u] = d = []), d.push(c); - } - } - let o = []; - for(let a in i)o.push(this.CreateFromMorphTargetSequence(a, i[a], t, n)); - return o; - } - static parseAnimation(e, t) { - if (!e) return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null; - let n = function(u, d, f, m, x) { - if (f.length !== 0) { - let v = [], g = []; - Ze.flattenJSON(f, v, g, m), v.length !== 0 && x.push(new u(d, v, g)); - } - }, i = [], r = e.name || "default", o = e.fps || 30, a = e.blendMode, l = e.length || -1, c = e.hierarchy || []; - for(let u = 0; u < c.length; u++){ - let d = c[u].keys; - if (!(!d || d.length === 0)) if (d[0].morphTargets) { - let f = {}, m; - for(m = 0; m < d.length; m++)if (d[m].morphTargets) for(let x = 0; x < d[m].morphTargets.length; x++)f[d[m].morphTargets[x]] = -1; - for(let x in f){ - let v = [], g = []; - for(let p = 0; p !== d[m].morphTargets.length; ++p){ - let _ = d[m]; - v.push(_.time), g.push(_.morphTarget === x ? 1 : 0); - } - i.push(new Ar(".morphTargetInfluence[" + x + "]", v, g)); - } - l = f.length * (o || 1); - } else { - let f = ".bones[" + t[u].name + "]"; - n(Cr, f + ".position", d, "pos", i), n(Wi, f + ".quaternion", d, "rot", i), n(Cr, f + ".scale", d, "scl", i); - } - } - return i.length === 0 ? null : new this(r, l, i, a); - } - resetDuration() { - let e = this.tracks, t = 0; - for(let n = 0, i = e.length; n !== i; ++n){ - let r = this.tracks[n]; - t = Math.max(t, r.times[r.times.length - 1]); - } - return this.duration = t, this; - } - trim() { - for(let e = 0; e < this.tracks.length; e++)this.tracks[e].trim(0, this.duration); - return this; - } - validate() { - let e = !0; - for(let t = 0; t < this.tracks.length; t++)e = e && this.tracks[t].validate(); - return e; - } - optimize() { - for(let e = 0; e < this.tracks.length; e++)this.tracks[e].optimize(); - return this; - } - clone() { - let e = []; - for(let t = 0; t < this.tracks.length; t++)e.push(this.tracks[t].clone()); - return new this.constructor(this.name, this.duration, e, this.blendMode); - } - toJSON() { - return this.constructor.toJSON(this); - } -}; -function oy(s) { - switch(s.toLowerCase()){ - case "scalar": - case "double": - case "float": - case "number": - case "integer": - return Ar; - case "vector": - case "vector2": - case "vector3": - case "vector4": - return Cr; - case "color": - return Ba; - case "quaternion": - return Wi; - case "bool": - case "boolean": - return Qn; - case "string": - return Kn; - } - throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + s); -} -function ay(s) { - if (s.type === void 0) throw new Error("THREE.KeyframeTrack: track type undefined, can not parse"); - let e = oy(s.type); - if (s.times === void 0) { - let t = [], n = []; - Ze.flattenJSON(s.keys, t, n, "value"), s.times = t, s.values = n; - } - return e.parse !== void 0 ? e.parse(s) : new e(s.name, s.times, s.values, s.interpolation); -} -var Ni = { - enabled: !1, - files: {}, - add: function(s, e) { - this.enabled !== !1 && (this.files[s] = e); - }, - get: function(s) { - if (this.enabled !== !1) return this.files[s]; - }, - remove: function(s) { - delete this.files[s]; - }, - clear: function() { - this.files = {}; - } -}, za = class { - constructor(e, t, n){ - let i = this, r = !1, o = 0, a = 0, l, c = []; - this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this.itemStart = function(h) { - a++, r === !1 && i.onStart !== void 0 && i.onStart(h, o, a), r = !0; - }, this.itemEnd = function(h) { - o++, i.onProgress !== void 0 && i.onProgress(h, o, a), o === a && (r = !1, i.onLoad !== void 0 && i.onLoad()); - }, this.itemError = function(h) { - i.onError !== void 0 && i.onError(h); - }, this.resolveURL = function(h) { - return l ? l(h) : h; - }, this.setURLModifier = function(h) { - return l = h, this; - }, this.addHandler = function(h, u) { - return c.push(h, u), this; - }, this.removeHandler = function(h) { - let u = c.indexOf(h); - return u !== -1 && c.splice(u, 2), this; - }, this.getHandler = function(h) { - for(let u = 0, d = c.length; u < d; u += 2){ - let f = c[u], m = c[u + 1]; - if (f.global && (f.lastIndex = 0), f.test(h)) return m; - } - return null; - }; - } -}, ly = new za, bt = class { - constructor(e){ - this.manager = e !== void 0 ? e : ly, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}; - } - load() {} - loadAsync(e, t) { - let n = this; - return new Promise(function(i, r) { - n.load(e, i, t, r); - }); - } - parse() {} - setCrossOrigin(e) { - return this.crossOrigin = e, this; - } - setWithCredentials(e) { - return this.withCredentials = e, this; - } - setPath(e) { - return this.path = e, this; - } - setResourcePath(e) { - return this.resourcePath = e, this; - } - setRequestHeader(e) { - return this.requestHeader = e, this; - } -}, tn = {}, Yt = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = Ni.get(e); - if (r !== void 0) return this.manager.itemStart(e), setTimeout(()=>{ - t && t(r), this.manager.itemEnd(e); - }, 0), r; - if (tn[e] !== void 0) { - tn[e].push({ - onLoad: t, - onProgress: n, - onError: i - }); - return; - } - tn[e] = [], tn[e].push({ - onLoad: t, - onProgress: n, - onError: i - }); - let o = new Request(e, { - headers: new Headers(this.requestHeader), - credentials: this.withCredentials ? "include" : "same-origin" - }); - fetch(o).then((a)=>{ - if (a.status === 200 || a.status === 0) { - if (a.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || a.body.getReader === void 0) return a; - let l = tn[e], c = a.body.getReader(), h = a.headers.get("Content-Length"), u = h ? parseInt(h) : 0, d = u !== 0, f = 0, m = new ReadableStream({ - start (x) { - v(); - function v() { - c.read().then(({ done: g , value: p })=>{ - if (g) x.close(); - else { - f += p.byteLength; - let _ = new ProgressEvent("progress", { - lengthComputable: d, - loaded: f, - total: u - }); - for(let y = 0, b = l.length; y < b; y++){ - let A = l[y]; - A.onProgress && A.onProgress(_); - } - x.enqueue(p), v(); - } - }); - } - } - }); - return new Response(m); - } else throw Error(`fetch for "${a.url}" responded with ${a.status}: ${a.statusText}`); - }).then((a)=>{ - switch(this.responseType){ - case "arraybuffer": - return a.arrayBuffer(); - case "blob": - return a.blob(); - case "document": - return a.text().then((l)=>new DOMParser().parseFromString(l, this.mimeType)); - case "json": - return a.json(); - default: - return a.text(); - } - }).then((a)=>{ - Ni.add(e, a); - let l = tn[e]; - delete tn[e]; - for(let c = 0, h = l.length; c < h; c++){ - let u = l[c]; - u.onLoad && u.onLoad(a); - } - }).catch((a)=>{ - let l = tn[e]; - if (l === void 0) throw this.manager.itemError(e), a; - delete tn[e]; - for(let c = 0, h = l.length; c < h; c++){ - let u = l[c]; - u.onError && u.onError(a); - } - this.manager.itemError(e); - }).finally(()=>{ - this.manager.itemEnd(e); - }), this.manager.itemStart(e); - } - setResponseType(e) { - return this.responseType = e, this; - } - setMimeType(e) { - return this.mimeType = e, this; - } -}, cy = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new Yt(this.manager); - o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { - try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); - } - }, n, i); - } - parse(e) { - let t = []; - for(let n = 0; n < e.length; n++){ - let i = Lr.parse(e[n]); - t.push(i); - } - return t; - } -}, hy = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = [], a = new va, l = new Yt(this.manager); - l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(r.withCredentials); - let c = 0; - function h(u) { - l.load(e[u], function(d) { - let f = r.parse(d, !0); - o[u] = { - width: f.width, - height: f.height, - format: f.format, - mipmaps: f.mipmaps - }, c += 1, c === 6 && (f.mipmapCount === 1 && (a.minFilter = tt), a.image = o, a.format = f.format, a.needsUpdate = !0, t && t(a)); - }, n, i); - } - if (Array.isArray(e)) for(let u = 0, d = e.length; u < d; ++u)h(u); - else l.load(e, function(u) { - let d = r.parse(u, !0); - if (d.isCubemap) { - let f = d.mipmaps.length / d.mipmapCount; - for(let m = 0; m < f; m++){ - o[m] = { - mipmaps: [] - }; - for(let x = 0; x < d.mipmapCount; x++)o[m].mipmaps.push(d.mipmaps[m * d.mipmapCount + x]), o[m].format = d.format, o[m].width = d.width, o[m].height = d.height; - } - a.image = o; - } else a.image.width = d.width, a.image.height = d.height, a.mipmaps = d.mipmaps; - d.mipmapCount === 1 && (a.minFilter = tt), a.format = d.format, a.needsUpdate = !0, t && t(a); - }, n, i); - return a; - } -}, Rr = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = this, o = Ni.get(e); - if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { - t && t(o), r.manager.itemEnd(e); - }, 0), o; - let a = qs("img"); - function l() { - h(), Ni.add(e, this), t && t(this), r.manager.itemEnd(e); - } - function c(u) { - h(), i && i(u), r.manager.itemError(e), r.manager.itemEnd(e); - } - function h() { - a.removeEventListener("load", l, !1), a.removeEventListener("error", c, !1); - } - return a.addEventListener("load", l, !1), a.addEventListener("error", c, !1), e.substr(0, 5) !== "data:" && this.crossOrigin !== void 0 && (a.crossOrigin = this.crossOrigin), r.manager.itemStart(e), a.src = e, a; - } -}, Fh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = new ki, o = new Rr(this.manager); - o.setCrossOrigin(this.crossOrigin), o.setPath(this.path); - let a = 0; - function l(c) { - o.load(e[c], function(h) { - r.images[c] = h, a++, a === 6 && (r.needsUpdate = !0, t && t(r)); - }, void 0, i); - } - for(let c = 0; c < e.length; ++c)l(c); - return r; - } -}, Nh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new qn, a = new Yt(this.manager); - return a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(r.withCredentials), a.load(e, function(l) { - let c = r.parse(l); - !c || (c.image !== void 0 ? o.image = c.image : c.data !== void 0 && (o.image.width = c.width, o.image.height = c.height, o.image.data = c.data), o.wrapS = c.wrapS !== void 0 ? c.wrapS : vt, o.wrapT = c.wrapT !== void 0 ? c.wrapT : vt, o.magFilter = c.magFilter !== void 0 ? c.magFilter : tt, o.minFilter = c.minFilter !== void 0 ? c.minFilter : tt, o.anisotropy = c.anisotropy !== void 0 ? c.anisotropy : 1, c.encoding !== void 0 && (o.encoding = c.encoding), c.flipY !== void 0 && (o.flipY = c.flipY), c.format !== void 0 && (o.format = c.format), c.type !== void 0 && (o.type = c.type), c.mipmaps !== void 0 && (o.mipmaps = c.mipmaps, o.minFilter = Ui), c.mipmapCount === 1 && (o.minFilter = tt), c.generateMipmaps !== void 0 && (o.generateMipmaps = c.generateMipmaps), o.needsUpdate = !0, t && t(o, c)); - }, n, i), o; - } -}, Bh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = new ot, o = new Rr(this.manager); - return o.setCrossOrigin(this.crossOrigin), o.setPath(this.path), o.load(e, function(a) { - r.image = a, r.needsUpdate = !0, t !== void 0 && t(r); - }, n, i), r; - } -}, Bt = class extends Ne { - constructor(e, t = 1){ - super(); - this.type = "Light", this.color = new ae(e), this.intensity = t; - } - dispose() {} - copy(e) { - return super.copy(e), this.color.copy(e.color), this.intensity = e.intensity, this; - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t; - } -}; -Bt.prototype.isLight = !0; -var Ua = class extends Bt { - constructor(e, t, n){ - super(e, n); - this.type = "HemisphereLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.groundColor = new ae(t); - } - copy(e) { - return Bt.prototype.copy.call(this, e), this.groundColor.copy(e.groundColor), this; - } -}; -Ua.prototype.isHemisphereLight = !0; -var _c = new pe, Mc = new M, bc = new M, mo = class { - constructor(e){ - this.camera = e, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new X(512, 512), this.map = null, this.mapPass = null, this.matrix = new pe, this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Dr, this._frameExtents = new X(1, 1), this._viewportCount = 1, this._viewports = [ - new Ve(0, 0, 1, 1) - ]; - } - getViewportCount() { - return this._viewportCount; - } - getFrustum() { - return this._frustum; - } - updateMatrices(e) { - let t = this.camera, n = this.matrix; - Mc.setFromMatrixPosition(e.matrixWorld), t.position.copy(Mc), bc.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(bc), t.updateMatrixWorld(), _c.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(_c), n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), n.multiply(t.projectionMatrix), n.multiply(t.matrixWorldInverse); - } - getViewport(e) { - return this._viewports[e]; - } - getFrameExtents() { - return this._frameExtents; - } - dispose() { - this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose(); - } - copy(e) { - return this.camera = e.camera.clone(), this.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this; - } - clone() { - return new this.constructor().copy(this); - } - toJSON() { - let e = {}; - return this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e; - } -}, Oa = class extends mo { - constructor(){ - super(new ut(50, 1, .5, 500)); - this.focus = 1; - } - updateMatrices(e) { - let t = this.camera, n = dr * 2 * e.angle * this.focus, i = this.mapSize.width / this.mapSize.height, r = e.distance || t.far; - (n !== t.fov || i !== t.aspect || r !== t.far) && (t.fov = n, t.aspect = i, t.far = r, t.updateProjectionMatrix()), super.updateMatrices(e); - } - copy(e) { - return super.copy(e), this.focus = e.focus, this; - } -}; -Oa.prototype.isSpotLightShadow = !0; -var Ha = class extends Bt { - constructor(e, t, n = 0, i = Math.PI / 3, r = 0, o = 1){ - super(e, t); - this.type = "SpotLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.distance = n, this.angle = i, this.penumbra = r, this.decay = o, this.shadow = new Oa; - } - get power() { - return this.intensity * Math.PI; - } - set power(e) { - this.intensity = e / Math.PI; - } - dispose() { - this.shadow.dispose(); - } - copy(e) { - return super.copy(e), this.distance = e.distance, this.angle = e.angle, this.penumbra = e.penumbra, this.decay = e.decay, this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; - } -}; -Ha.prototype.isSpotLight = !0; -var wc = new pe, nr = new M, jo = new M, ka = class extends mo { - constructor(){ - super(new ut(90, 1, .5, 500)); - this._frameExtents = new X(4, 2), this._viewportCount = 6, this._viewports = [ - new Ve(2, 1, 1, 1), - new Ve(0, 1, 1, 1), - new Ve(3, 1, 1, 1), - new Ve(1, 1, 1, 1), - new Ve(3, 0, 1, 1), - new Ve(1, 0, 1, 1) - ], this._cubeDirections = [ - new M(1, 0, 0), - new M(-1, 0, 0), - new M(0, 0, 1), - new M(0, 0, -1), - new M(0, 1, 0), - new M(0, -1, 0) - ], this._cubeUps = [ - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 0, 1), - new M(0, 0, -1) - ]; - } - updateMatrices(e, t = 0) { - let n = this.camera, i = this.matrix, r = e.distance || n.far; - r !== n.far && (n.far = r, n.updateProjectionMatrix()), nr.setFromMatrixPosition(e.matrixWorld), n.position.copy(nr), jo.copy(n.position), jo.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(jo), n.updateMatrixWorld(), i.makeTranslation(-nr.x, -nr.y, -nr.z), wc.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(wc); - } -}; -ka.prototype.isPointLightShadow = !0; -var Ga = class extends Bt { - constructor(e, t, n = 0, i = 1){ - super(e, t); - this.type = "PointLight", this.distance = n, this.decay = i, this.shadow = new ka; - } - get power() { - return this.intensity * 4 * Math.PI; - } - set power(e) { - this.intensity = e / (4 * Math.PI); - } - dispose() { - this.shadow.dispose(); - } - copy(e) { - return super.copy(e), this.distance = e.distance, this.decay = e.decay, this.shadow = e.shadow.clone(), this; - } -}; -Ga.prototype.isPointLight = !0; -var Va = class extends mo { - constructor(){ - super(new Fr(-5, 5, 5, -5, .5, 500)); - } -}; -Va.prototype.isDirectionalLightShadow = !0; -var Wa = class extends Bt { - constructor(e, t){ - super(e, t); - this.type = "DirectionalLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.shadow = new Va; - } - dispose() { - this.shadow.dispose(); - } - copy(e) { - return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; - } -}; -Wa.prototype.isDirectionalLight = !0; -var qa = class extends Bt { - constructor(e, t){ - super(e, t); - this.type = "AmbientLight"; - } -}; -qa.prototype.isAmbientLight = !0; -var Xa = class extends Bt { - constructor(e, t, n = 10, i = 10){ - super(e, t); - this.type = "RectAreaLight", this.width = n, this.height = i; - } - get power() { - return this.intensity * this.width * this.height * Math.PI; - } - set power(e) { - this.intensity = e / (this.width * this.height * Math.PI); - } - copy(e) { - return super.copy(e), this.width = e.width, this.height = e.height, this; - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.width = this.width, t.object.height = this.height, t; - } -}; -Xa.prototype.isRectAreaLight = !0; -var Ja = class { - constructor(){ - this.coefficients = []; - for(let e = 0; e < 9; e++)this.coefficients.push(new M); - } - set(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].copy(e[t]); - return this; - } - zero() { - for(let e = 0; e < 9; e++)this.coefficients[e].set(0, 0, 0); - return this; - } - getAt(e, t) { - let n = e.x, i = e.y, r = e.z, o = this.coefficients; - return t.copy(o[0]).multiplyScalar(.282095), t.addScaledVector(o[1], .488603 * i), t.addScaledVector(o[2], .488603 * r), t.addScaledVector(o[3], .488603 * n), t.addScaledVector(o[4], 1.092548 * (n * i)), t.addScaledVector(o[5], 1.092548 * (i * r)), t.addScaledVector(o[6], .315392 * (3 * r * r - 1)), t.addScaledVector(o[7], 1.092548 * (n * r)), t.addScaledVector(o[8], .546274 * (n * n - i * i)), t; - } - getIrradianceAt(e, t) { - let n = e.x, i = e.y, r = e.z, o = this.coefficients; - return t.copy(o[0]).multiplyScalar(.886227), t.addScaledVector(o[1], 2 * .511664 * i), t.addScaledVector(o[2], 2 * .511664 * r), t.addScaledVector(o[3], 2 * .511664 * n), t.addScaledVector(o[4], 2 * .429043 * n * i), t.addScaledVector(o[5], 2 * .429043 * i * r), t.addScaledVector(o[6], .743125 * r * r - .247708), t.addScaledVector(o[7], 2 * .429043 * n * r), t.addScaledVector(o[8], .429043 * (n * n - i * i)), t; - } - add(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].add(e.coefficients[t]); - return this; - } - addScaledSH(e, t) { - for(let n = 0; n < 9; n++)this.coefficients[n].addScaledVector(e.coefficients[n], t); - return this; - } - scale(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].multiplyScalar(e); - return this; - } - lerp(e, t) { - for(let n = 0; n < 9; n++)this.coefficients[n].lerp(e.coefficients[n], t); - return this; - } - equals(e) { - for(let t = 0; t < 9; t++)if (!this.coefficients[t].equals(e.coefficients[t])) return !1; - return !0; - } - copy(e) { - return this.set(e.coefficients); - } - clone() { - return new this.constructor().copy(this); - } - fromArray(e, t = 0) { - let n = this.coefficients; - for(let i = 0; i < 9; i++)n[i].fromArray(e, t + i * 3); - return this; - } - toArray(e = [], t = 0) { - let n = this.coefficients; - for(let i = 0; i < 9; i++)n[i].toArray(e, t + i * 3); - return e; - } - static getBasisAt(e, t) { - let n = e.x, i = e.y, r = e.z; - t[0] = .282095, t[1] = .488603 * i, t[2] = .488603 * r, t[3] = .488603 * n, t[4] = 1.092548 * n * i, t[5] = 1.092548 * i * r, t[6] = .315392 * (3 * r * r - 1), t[7] = 1.092548 * n * r, t[8] = .546274 * (n * n - i * i); - } -}; -Ja.prototype.isSphericalHarmonics3 = !0; -var Hr = class extends Bt { - constructor(e = new Ja, t = 1){ - super(void 0, t); - this.sh = e; - } - copy(e) { - return super.copy(e), this.sh.copy(e.sh), this; - } - fromJSON(e) { - return this.intensity = e.intensity, this.sh.fromArray(e.sh), this; - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.sh = this.sh.toArray(), t; - } -}; -Hr.prototype.isLightProbe = !0; -var zh = class extends bt { - constructor(e){ - super(e); - this.textures = {}; - } - load(e, t, n, i) { - let r = this, o = new Yt(r.manager); - o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { - try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); - } - }, n, i); - } - parse(e) { - let t = this.textures; - function n(r) { - return t[r] === void 0 && console.warn("THREE.MaterialLoader: Undefined texture", r), t[r]; - } - let i = new sy[e.type]; - if (e.uuid !== void 0 && (i.uuid = e.uuid), e.name !== void 0 && (i.name = e.name), e.color !== void 0 && i.color !== void 0 && i.color.setHex(e.color), e.roughness !== void 0 && (i.roughness = e.roughness), e.metalness !== void 0 && (i.metalness = e.metalness), e.sheen !== void 0 && (i.sheen = e.sheen), e.sheenColor !== void 0 && (i.sheenColor = new ae().setHex(e.sheenColor)), e.sheenRoughness !== void 0 && (i.sheenRoughness = e.sheenRoughness), e.emissive !== void 0 && i.emissive !== void 0 && i.emissive.setHex(e.emissive), e.specular !== void 0 && i.specular !== void 0 && i.specular.setHex(e.specular), e.specularIntensity !== void 0 && (i.specularIntensity = e.specularIntensity), e.specularColor !== void 0 && i.specularColor !== void 0 && i.specularColor.setHex(e.specularColor), e.shininess !== void 0 && (i.shininess = e.shininess), e.clearcoat !== void 0 && (i.clearcoat = e.clearcoat), e.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = e.clearcoatRoughness), e.transmission !== void 0 && (i.transmission = e.transmission), e.thickness !== void 0 && (i.thickness = e.thickness), e.attenuationDistance !== void 0 && (i.attenuationDistance = e.attenuationDistance), e.attenuationColor !== void 0 && i.attenuationColor !== void 0 && i.attenuationColor.setHex(e.attenuationColor), e.fog !== void 0 && (i.fog = e.fog), e.flatShading !== void 0 && (i.flatShading = e.flatShading), e.blending !== void 0 && (i.blending = e.blending), e.combine !== void 0 && (i.combine = e.combine), e.side !== void 0 && (i.side = e.side), e.shadowSide !== void 0 && (i.shadowSide = e.shadowSide), e.opacity !== void 0 && (i.opacity = e.opacity), e.format !== void 0 && (i.format = e.format), e.transparent !== void 0 && (i.transparent = e.transparent), e.alphaTest !== void 0 && (i.alphaTest = e.alphaTest), e.depthTest !== void 0 && (i.depthTest = e.depthTest), e.depthWrite !== void 0 && (i.depthWrite = e.depthWrite), e.colorWrite !== void 0 && (i.colorWrite = e.colorWrite), e.stencilWrite !== void 0 && (i.stencilWrite = e.stencilWrite), e.stencilWriteMask !== void 0 && (i.stencilWriteMask = e.stencilWriteMask), e.stencilFunc !== void 0 && (i.stencilFunc = e.stencilFunc), e.stencilRef !== void 0 && (i.stencilRef = e.stencilRef), e.stencilFuncMask !== void 0 && (i.stencilFuncMask = e.stencilFuncMask), e.stencilFail !== void 0 && (i.stencilFail = e.stencilFail), e.stencilZFail !== void 0 && (i.stencilZFail = e.stencilZFail), e.stencilZPass !== void 0 && (i.stencilZPass = e.stencilZPass), e.wireframe !== void 0 && (i.wireframe = e.wireframe), e.wireframeLinewidth !== void 0 && (i.wireframeLinewidth = e.wireframeLinewidth), e.wireframeLinecap !== void 0 && (i.wireframeLinecap = e.wireframeLinecap), e.wireframeLinejoin !== void 0 && (i.wireframeLinejoin = e.wireframeLinejoin), e.rotation !== void 0 && (i.rotation = e.rotation), e.linewidth !== 1 && (i.linewidth = e.linewidth), e.dashSize !== void 0 && (i.dashSize = e.dashSize), e.gapSize !== void 0 && (i.gapSize = e.gapSize), e.scale !== void 0 && (i.scale = e.scale), e.polygonOffset !== void 0 && (i.polygonOffset = e.polygonOffset), e.polygonOffsetFactor !== void 0 && (i.polygonOffsetFactor = e.polygonOffsetFactor), e.polygonOffsetUnits !== void 0 && (i.polygonOffsetUnits = e.polygonOffsetUnits), e.dithering !== void 0 && (i.dithering = e.dithering), e.alphaToCoverage !== void 0 && (i.alphaToCoverage = e.alphaToCoverage), e.premultipliedAlpha !== void 0 && (i.premultipliedAlpha = e.premultipliedAlpha), e.visible !== void 0 && (i.visible = e.visible), e.toneMapped !== void 0 && (i.toneMapped = e.toneMapped), e.userData !== void 0 && (i.userData = e.userData), e.vertexColors !== void 0 && (typeof e.vertexColors == "number" ? i.vertexColors = e.vertexColors > 0 : i.vertexColors = e.vertexColors), e.uniforms !== void 0) for(let r in e.uniforms){ - let o = e.uniforms[r]; - switch(i.uniforms[r] = {}, o.type){ - case "t": - i.uniforms[r].value = n(o.value); - break; - case "c": - i.uniforms[r].value = new ae().setHex(o.value); - break; - case "v2": - i.uniforms[r].value = new X().fromArray(o.value); - break; - case "v3": - i.uniforms[r].value = new M().fromArray(o.value); - break; - case "v4": - i.uniforms[r].value = new Ve().fromArray(o.value); - break; - case "m3": - i.uniforms[r].value = new lt().fromArray(o.value); - break; - case "m4": - i.uniforms[r].value = new pe().fromArray(o.value); - break; - default: - i.uniforms[r].value = o.value; - } - } - if (e.defines !== void 0 && (i.defines = e.defines), e.vertexShader !== void 0 && (i.vertexShader = e.vertexShader), e.fragmentShader !== void 0 && (i.fragmentShader = e.fragmentShader), e.extensions !== void 0) for(let r in e.extensions)i.extensions[r] = e.extensions[r]; - if (e.shading !== void 0 && (i.flatShading = e.shading === 1), e.size !== void 0 && (i.size = e.size), e.sizeAttenuation !== void 0 && (i.sizeAttenuation = e.sizeAttenuation), e.map !== void 0 && (i.map = n(e.map)), e.matcap !== void 0 && (i.matcap = n(e.matcap)), e.alphaMap !== void 0 && (i.alphaMap = n(e.alphaMap)), e.bumpMap !== void 0 && (i.bumpMap = n(e.bumpMap)), e.bumpScale !== void 0 && (i.bumpScale = e.bumpScale), e.normalMap !== void 0 && (i.normalMap = n(e.normalMap)), e.normalMapType !== void 0 && (i.normalMapType = e.normalMapType), e.normalScale !== void 0) { - let r = e.normalScale; - Array.isArray(r) === !1 && (r = [ - r, - r - ]), i.normalScale = new X().fromArray(r); - } - return e.displacementMap !== void 0 && (i.displacementMap = n(e.displacementMap)), e.displacementScale !== void 0 && (i.displacementScale = e.displacementScale), e.displacementBias !== void 0 && (i.displacementBias = e.displacementBias), e.roughnessMap !== void 0 && (i.roughnessMap = n(e.roughnessMap)), e.metalnessMap !== void 0 && (i.metalnessMap = n(e.metalnessMap)), e.emissiveMap !== void 0 && (i.emissiveMap = n(e.emissiveMap)), e.emissiveIntensity !== void 0 && (i.emissiveIntensity = e.emissiveIntensity), e.specularMap !== void 0 && (i.specularMap = n(e.specularMap)), e.specularIntensityMap !== void 0 && (i.specularIntensityMap = n(e.specularIntensityMap)), e.specularColorMap !== void 0 && (i.specularColorMap = n(e.specularColorMap)), e.envMap !== void 0 && (i.envMap = n(e.envMap)), e.envMapIntensity !== void 0 && (i.envMapIntensity = e.envMapIntensity), e.reflectivity !== void 0 && (i.reflectivity = e.reflectivity), e.refractionRatio !== void 0 && (i.refractionRatio = e.refractionRatio), e.lightMap !== void 0 && (i.lightMap = n(e.lightMap)), e.lightMapIntensity !== void 0 && (i.lightMapIntensity = e.lightMapIntensity), e.aoMap !== void 0 && (i.aoMap = n(e.aoMap)), e.aoMapIntensity !== void 0 && (i.aoMapIntensity = e.aoMapIntensity), e.gradientMap !== void 0 && (i.gradientMap = n(e.gradientMap)), e.clearcoatMap !== void 0 && (i.clearcoatMap = n(e.clearcoatMap)), e.clearcoatRoughnessMap !== void 0 && (i.clearcoatRoughnessMap = n(e.clearcoatRoughnessMap)), e.clearcoatNormalMap !== void 0 && (i.clearcoatNormalMap = n(e.clearcoatNormalMap)), e.clearcoatNormalScale !== void 0 && (i.clearcoatNormalScale = new X().fromArray(e.clearcoatNormalScale)), e.transmissionMap !== void 0 && (i.transmissionMap = n(e.transmissionMap)), e.thicknessMap !== void 0 && (i.thicknessMap = n(e.thicknessMap)), e.sheenColorMap !== void 0 && (i.sheenColorMap = n(e.sheenColorMap)), e.sheenRoughnessMap !== void 0 && (i.sheenRoughnessMap = n(e.sheenRoughnessMap)), i; - } - setTextures(e) { - return this.textures = e, this; - } -}, Gs = class { - static decodeText(e) { - if (typeof TextDecoder < "u") return new TextDecoder().decode(e); - let t = ""; - for(let n = 0, i = e.length; n < i; n++)t += String.fromCharCode(e[n]); - try { - return decodeURIComponent(escape(t)); - } catch { - return t; - } - } - static extractUrlBase(e) { - let t = e.lastIndexOf("/"); - return t === -1 ? "./" : e.substr(0, t + 1); - } - static resolveURL(e, t) { - return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e); - } -}, Ya = class extends _e { - constructor(){ - super(); - this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0; - } - copy(e) { - return super.copy(e), this.instanceCount = e.instanceCount, this; - } - clone() { - return new this.constructor().copy(this); - } - toJSON() { - let e = super.toJSON(this); - return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e; - } -}; -Ya.prototype.isInstancedBufferGeometry = !0; -var Uh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new Yt(r.manager); - o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { - try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); - } - }, n, i); - } - parse(e) { - let t = {}, n = {}; - function i(f, m) { - if (t[m] !== void 0) return t[m]; - let v = f.interleavedBuffers[m], g = r(f, v.buffer), p = wi(v.type, g), _ = new $n(p, v.stride); - return _.uuid = v.uuid, t[m] = _, _; - } - function r(f, m) { - if (n[m] !== void 0) return n[m]; - let v = f.arrayBuffers[m], g = new Uint32Array(v).buffer; - return n[m] = g, g; - } - let o = e.isInstancedBufferGeometry ? new Ya : new _e, a = e.data.index; - if (a !== void 0) { - let f = wi(a.type, a.array); - o.setIndex(new Ue(f, 1)); - } - let l = e.data.attributes; - for(let f in l){ - let m = l[f], x; - if (m.isInterleavedBufferAttribute) { - let v = i(e.data, m.data); - x = new Sn(v, m.itemSize, m.offset, m.normalized); - } else { - let v = wi(m.type, m.array), g = m.isInstancedBufferAttribute ? Xn : Ue; - x = new g(v, m.itemSize, m.normalized); - } - m.name !== void 0 && (x.name = m.name), m.usage !== void 0 && x.setUsage(m.usage), m.updateRange !== void 0 && (x.updateRange.offset = m.updateRange.offset, x.updateRange.count = m.updateRange.count), o.setAttribute(f, x); - } - let c = e.data.morphAttributes; - if (c) for(let f in c){ - let m = c[f], x = []; - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v], _; - if (p.isInterleavedBufferAttribute) { - let y = i(e.data, p.data); - _ = new Sn(y, p.itemSize, p.offset, p.normalized); - } else { - let y = wi(p.type, p.array); - _ = new Ue(y, p.itemSize, p.normalized); - } - p.name !== void 0 && (_.name = p.name), x.push(_); - } - o.morphAttributes[f] = x; - } - e.data.morphTargetsRelative && (o.morphTargetsRelative = !0); - let u = e.data.groups || e.data.drawcalls || e.data.offsets; - if (u !== void 0) for(let f = 0, m = u.length; f !== m; ++f){ - let x = u[f]; - o.addGroup(x.start, x.count, x.materialIndex); - } - let d = e.data.boundingSphere; - if (d !== void 0) { - let f = new M; - d.center !== void 0 && f.fromArray(d.center), o.boundingSphere = new An(f, d.radius); - } - return e.name && (o.name = e.name), e.userData && (o.userData = e.userData), o; - } -}, uy = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = this.path === "" ? Gs.extractUrlBase(e) : this.path; - this.resourcePath = this.resourcePath || o; - let a = new Yt(this.manager); - a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(l) { - let c = null; - try { - c = JSON.parse(l); - } catch (u) { - i !== void 0 && i(u), console.error("THREE:ObjectLoader: Can't parse " + e + ".", u.message); - return; - } - let h = c.metadata; - if (h === void 0 || h.type === void 0 || h.type.toLowerCase() === "geometry") { - console.error("THREE.ObjectLoader: Can't load " + e); - return; - } - r.parse(c, t); - }, n, i); - } - async loadAsync(e, t) { - let n = this, i = this.path === "" ? Gs.extractUrlBase(e) : this.path; - this.resourcePath = this.resourcePath || i; - let r = new Yt(this.manager); - r.setPath(this.path), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials); - let o = await r.loadAsync(e, t), a = JSON.parse(o), l = a.metadata; - if (l === void 0 || l.type === void 0 || l.type.toLowerCase() === "geometry") throw new Error("THREE.ObjectLoader: Can't load " + e); - return await n.parseAsync(a); - } - parse(e, t) { - let n = this.parseAnimations(e.animations), i = this.parseShapes(e.shapes), r = this.parseGeometries(e.geometries, i), o = this.parseImages(e.images, function() { - t !== void 0 && t(c); - }), a = this.parseTextures(e.textures, o), l = this.parseMaterials(e.materials, a), c = this.parseObject(e.object, r, l, a, n), h = this.parseSkeletons(e.skeletons, c); - if (this.bindSkeletons(c, h), t !== void 0) { - let u = !1; - for(let d in o)if (o[d] instanceof HTMLImageElement) { - u = !0; - break; - } - u === !1 && t(c); - } - return c; - } - async parseAsync(e) { - let t = this.parseAnimations(e.animations), n = this.parseShapes(e.shapes), i = this.parseGeometries(e.geometries, n), r = await this.parseImagesAsync(e.images), o = this.parseTextures(e.textures, r), a = this.parseMaterials(e.materials, o), l = this.parseObject(e.object, i, a, o, t), c = this.parseSkeletons(e.skeletons, l); - return this.bindSkeletons(l, c), l; - } - parseShapes(e) { - let t = {}; - if (e !== void 0) for(let n = 0, i = e.length; n < i; n++){ - let r = new Xt().fromJSON(e[n]); - t[r.uuid] = r; - } - return t; - } - parseSkeletons(e, t) { - let n = {}, i = {}; - if (t.traverse(function(r) { - r.isBone && (i[r.uuid] = r); - }), e !== void 0) for(let r = 0, o = e.length; r < o; r++){ - let a = new ao().fromJSON(e[r], i); - n[a.uuid] = a; - } - return n; - } - parseGeometries(e, t) { - let n = {}; - if (e !== void 0) { - let i = new Uh; - for(let r = 0, o = e.length; r < o; r++){ - let a, l = e[r]; - switch(l.type){ - case "BufferGeometry": - case "InstancedBufferGeometry": - a = i.parse(l); - break; - case "Geometry": - console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported."); - break; - default: - l.type in vc ? a = vc[l.type].fromJSON(l, t) : console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`); - } - a.uuid = l.uuid, l.name !== void 0 && (a.name = l.name), a.isBufferGeometry === !0 && l.userData !== void 0 && (a.userData = l.userData), n[l.uuid] = a; - } - } - return n; - } - parseMaterials(e, t) { - let n = {}, i = {}; - if (e !== void 0) { - let r = new zh; - r.setTextures(t); - for(let o = 0, a = e.length; o < a; o++){ - let l = e[o]; - if (l.type === "MultiMaterial") { - let c = []; - for(let h = 0; h < l.materials.length; h++){ - let u = l.materials[h]; - n[u.uuid] === void 0 && (n[u.uuid] = r.parse(u)), c.push(n[u.uuid]); - } - i[l.uuid] = c; - } else n[l.uuid] === void 0 && (n[l.uuid] = r.parse(l)), i[l.uuid] = n[l.uuid]; - } - } - return i; - } - parseAnimations(e) { - let t = {}; - if (e !== void 0) for(let n = 0; n < e.length; n++){ - let i = e[n], r = Lr.parse(i); - t[r.uuid] = r; - } - return t; - } - parseImages(e, t) { - let n = this, i = {}, r; - function o(l) { - return n.manager.itemStart(l), r.load(l, function() { - n.manager.itemEnd(l); - }, void 0, function() { - n.manager.itemError(l), n.manager.itemEnd(l); - }); - } - function a(l) { - if (typeof l == "string") { - let c = l, h = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(c) ? c : n.resourcePath + c; - return o(h); - } else return l.data ? { - data: wi(l.type, l.data), - width: l.width, - height: l.height - } : null; - } - if (e !== void 0 && e.length > 0) { - let l = new za(t); - r = new Rr(l), r.setCrossOrigin(this.crossOrigin); - for(let c = 0, h = e.length; c < h; c++){ - let u = e[c], d = u.url; - if (Array.isArray(d)) { - i[u.uuid] = []; - for(let f = 0, m = d.length; f < m; f++){ - let x = d[f], v = a(x); - v !== null && (v instanceof HTMLImageElement ? i[u.uuid].push(v) : i[u.uuid].push(new qn(v.data, v.width, v.height))); - } - } else { - let f = a(u.url); - f !== null && (i[u.uuid] = f); - } - } - } - return i; - } - async parseImagesAsync(e) { - let t = this, n = {}, i; - async function r(o) { - if (typeof o == "string") { - let a = o, l = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(a) ? a : t.resourcePath + a; - return await i.loadAsync(l); - } else return o.data ? { - data: wi(o.type, o.data), - width: o.width, - height: o.height - } : null; - } - if (e !== void 0 && e.length > 0) { - i = new Rr(this.manager), i.setCrossOrigin(this.crossOrigin); - for(let o = 0, a = e.length; o < a; o++){ - let l = e[o], c = l.url; - if (Array.isArray(c)) { - n[l.uuid] = []; - for(let h = 0, u = c.length; h < u; h++){ - let d = c[h], f = await r(d); - f !== null && (f instanceof HTMLImageElement ? n[l.uuid].push(f) : n[l.uuid].push(new qn(f.data, f.width, f.height))); - } - } else { - let h = await r(l.url); - h !== null && (n[l.uuid] = h); - } - } - } - return n; - } - parseTextures(e, t) { - function n(r, o) { - return typeof r == "number" ? r : (console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", r), o[r]); - } - let i = {}; - if (e !== void 0) for(let r = 0, o = e.length; r < o; r++){ - let a = e[r]; - a.image === void 0 && console.warn('THREE.ObjectLoader: No "image" specified for', a.uuid), t[a.image] === void 0 && console.warn("THREE.ObjectLoader: Undefined image", a.image); - let l, c = t[a.image]; - Array.isArray(c) ? (l = new ki(c), c.length === 6 && (l.needsUpdate = !0)) : (c && c.data ? l = new qn(c.data, c.width, c.height) : l = new ot(c), c && (l.needsUpdate = !0)), l.uuid = a.uuid, a.name !== void 0 && (l.name = a.name), a.mapping !== void 0 && (l.mapping = n(a.mapping, dy)), a.offset !== void 0 && l.offset.fromArray(a.offset), a.repeat !== void 0 && l.repeat.fromArray(a.repeat), a.center !== void 0 && l.center.fromArray(a.center), a.rotation !== void 0 && (l.rotation = a.rotation), a.wrap !== void 0 && (l.wrapS = n(a.wrap[0], Sc), l.wrapT = n(a.wrap[1], Sc)), a.format !== void 0 && (l.format = a.format), a.type !== void 0 && (l.type = a.type), a.encoding !== void 0 && (l.encoding = a.encoding), a.minFilter !== void 0 && (l.minFilter = n(a.minFilter, Tc)), a.magFilter !== void 0 && (l.magFilter = n(a.magFilter, Tc)), a.anisotropy !== void 0 && (l.anisotropy = a.anisotropy), a.flipY !== void 0 && (l.flipY = a.flipY), a.premultiplyAlpha !== void 0 && (l.premultiplyAlpha = a.premultiplyAlpha), a.unpackAlignment !== void 0 && (l.unpackAlignment = a.unpackAlignment), a.userData !== void 0 && (l.userData = a.userData), i[a.uuid] = l; - } - return i; - } - parseObject(e, t, n, i, r) { - let o; - function a(d) { - return t[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined geometry", d), t[d]; - } - function l(d) { - if (d !== void 0) { - if (Array.isArray(d)) { - let f = []; - for(let m = 0, x = d.length; m < x; m++){ - let v = d[m]; - n[v] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", v), f.push(n[v]); - } - return f; - } - return n[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", d), n[d]; - } - } - function c(d) { - return i[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined texture", d), i[d]; - } - let h, u; - switch(e.type){ - case "Scene": - o = new no, e.background !== void 0 && (Number.isInteger(e.background) ? o.background = new ae(e.background) : o.background = c(e.background)), e.environment !== void 0 && (o.environment = c(e.environment)), e.fog !== void 0 && (e.fog.type === "Fog" ? o.fog = new Br(e.fog.color, e.fog.near, e.fog.far) : e.fog.type === "FogExp2" && (o.fog = new Nr(e.fog.color, e.fog.density))); - break; - case "PerspectiveCamera": - o = new ut(e.fov, e.aspect, e.near, e.far), e.focus !== void 0 && (o.focus = e.focus), e.zoom !== void 0 && (o.zoom = e.zoom), e.filmGauge !== void 0 && (o.filmGauge = e.filmGauge), e.filmOffset !== void 0 && (o.filmOffset = e.filmOffset), e.view !== void 0 && (o.view = Object.assign({}, e.view)); - break; - case "OrthographicCamera": - o = new Fr(e.left, e.right, e.top, e.bottom, e.near, e.far), e.zoom !== void 0 && (o.zoom = e.zoom), e.view !== void 0 && (o.view = Object.assign({}, e.view)); - break; - case "AmbientLight": - o = new qa(e.color, e.intensity); - break; - case "DirectionalLight": - o = new Wa(e.color, e.intensity); - break; - case "PointLight": - o = new Ga(e.color, e.intensity, e.distance, e.decay); - break; - case "RectAreaLight": - o = new Xa(e.color, e.intensity, e.width, e.height); - break; - case "SpotLight": - o = new Ha(e.color, e.intensity, e.distance, e.angle, e.penumbra, e.decay); - break; - case "HemisphereLight": - o = new Ua(e.color, e.groundColor, e.intensity); - break; - case "LightProbe": - o = new Hr().fromJSON(e); - break; - case "SkinnedMesh": - h = a(e.geometry), u = l(e.material), o = new so(h, u), e.bindMode !== void 0 && (o.bindMode = e.bindMode), e.bindMatrix !== void 0 && o.bindMatrix.fromArray(e.bindMatrix), e.skeleton !== void 0 && (o.skeleton = e.skeleton); - break; - case "Mesh": - h = a(e.geometry), u = l(e.material), o = new st(h, u); - break; - case "InstancedMesh": - h = a(e.geometry), u = l(e.material); - let d = e.count, f = e.instanceMatrix, m = e.instanceColor; - o = new xa(h, u, d), o.instanceMatrix = new Xn(new Float32Array(f.array), 16), m !== void 0 && (o.instanceColor = new Xn(new Float32Array(m.array), m.itemSize)); - break; - case "LOD": - o = new bh; - break; - case "Line": - o = new on(a(e.geometry), l(e.material)); - break; - case "LineLoop": - o = new ya(a(e.geometry), l(e.material)); - break; - case "LineSegments": - o = new wt(a(e.geometry), l(e.material)); - break; - case "PointCloud": - case "Points": - o = new zr(a(e.geometry), l(e.material)); - break; - case "Sprite": - o = new ro(l(e.material)); - break; - case "Group": - o = new Hn; - break; - case "Bone": - o = new oo; - break; - default: - o = new Ne; - } - if (o.uuid = e.uuid, e.name !== void 0 && (o.name = e.name), e.matrix !== void 0 ? (o.matrix.fromArray(e.matrix), e.matrixAutoUpdate !== void 0 && (o.matrixAutoUpdate = e.matrixAutoUpdate), o.matrixAutoUpdate && o.matrix.decompose(o.position, o.quaternion, o.scale)) : (e.position !== void 0 && o.position.fromArray(e.position), e.rotation !== void 0 && o.rotation.fromArray(e.rotation), e.quaternion !== void 0 && o.quaternion.fromArray(e.quaternion), e.scale !== void 0 && o.scale.fromArray(e.scale)), e.castShadow !== void 0 && (o.castShadow = e.castShadow), e.receiveShadow !== void 0 && (o.receiveShadow = e.receiveShadow), e.shadow && (e.shadow.bias !== void 0 && (o.shadow.bias = e.shadow.bias), e.shadow.normalBias !== void 0 && (o.shadow.normalBias = e.shadow.normalBias), e.shadow.radius !== void 0 && (o.shadow.radius = e.shadow.radius), e.shadow.mapSize !== void 0 && o.shadow.mapSize.fromArray(e.shadow.mapSize), e.shadow.camera !== void 0 && (o.shadow.camera = this.parseObject(e.shadow.camera))), e.visible !== void 0 && (o.visible = e.visible), e.frustumCulled !== void 0 && (o.frustumCulled = e.frustumCulled), e.renderOrder !== void 0 && (o.renderOrder = e.renderOrder), e.userData !== void 0 && (o.userData = e.userData), e.layers !== void 0 && (o.layers.mask = e.layers), e.children !== void 0) { - let d = e.children; - for(let f = 0; f < d.length; f++)o.add(this.parseObject(d[f], t, n, i, r)); - } - if (e.animations !== void 0) { - let d = e.animations; - for(let f = 0; f < d.length; f++){ - let m = d[f]; - o.animations.push(r[m]); - } - } - if (e.type === "LOD") { - e.autoUpdate !== void 0 && (o.autoUpdate = e.autoUpdate); - let d = e.levels; - for(let f = 0; f < d.length; f++){ - let m = d[f], x = o.getObjectByProperty("uuid", m.object); - x !== void 0 && o.addLevel(x, m.distance); - } - } - return o; - } - bindSkeletons(e, t) { - Object.keys(t).length !== 0 && e.traverse(function(n) { - if (n.isSkinnedMesh === !0 && n.skeleton !== void 0) { - let i = t[n.skeleton]; - i === void 0 ? console.warn("THREE.ObjectLoader: No skeleton found with UUID:", n.skeleton) : n.bind(i, n.bindMatrix); - } - }); - } - setTexturePath(e) { - return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."), this.setResourcePath(e); - } -}, dy = { - UVMapping: ha, - CubeReflectionMapping: Bi, - CubeRefractionMapping: zi, - EquirectangularReflectionMapping: Ds, - EquirectangularRefractionMapping: Fs, - CubeUVReflectionMapping: Pr, - CubeUVRefractionMapping: Ws -}, Sc = { - RepeatWrapping: Ns, - ClampToEdgeWrapping: vt, - MirroredRepeatWrapping: Bs -}, Tc = { - NearestFilter: rt, - NearestMipmapNearestFilter: ta, - NearestMipmapLinearFilter: na, - LinearFilter: tt, - LinearMipmapNearestFilter: Wc, - LinearMipmapLinearFilter: Ui -}, Oh = class extends bt { - constructor(e){ - super(e); - typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { - premultiplyAlpha: "none" - }; - } - setOptions(e) { - return this.options = e, this; - } - load(e, t, n, i) { - e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = this, o = Ni.get(e); - if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { - t && t(o), r.manager.itemEnd(e); - }, 0), o; - let a = {}; - a.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", a.headers = this.requestHeader, fetch(e, a).then(function(l) { - return l.blob(); - }).then(function(l) { - return createImageBitmap(l, Object.assign(r.options, { - colorSpaceConversion: "none" - })); - }).then(function(l) { - Ni.add(e, l), t && t(l), r.manager.itemEnd(e); - }).catch(function(l) { - i && i(l), r.manager.itemError(e), r.manager.itemEnd(e); - }), r.manager.itemStart(e); - } -}; -Oh.prototype.isImageBitmapLoader = !0; -var Ss, Hh = { - getContext: function() { - return Ss === void 0 && (Ss = new (window.AudioContext || window.webkitAudioContext)), Ss; - }, - setContext: function(s) { - Ss = s; - } -}, kh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new Yt(this.manager); - o.setResponseType("arraybuffer"), o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { - try { - let l = a.slice(0); - Hh.getContext().decodeAudioData(l, function(h) { - t(h); - }); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); - } - }, n, i); - } -}, Gh = class extends Hr { - constructor(e, t, n = 1){ - super(void 0, n); - let i = new ae().set(e), r = new ae().set(t), o = new M(i.r, i.g, i.b), a = new M(r.r, r.g, r.b), l = Math.sqrt(Math.PI), c = l * Math.sqrt(.75); - this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l), this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c); - } -}; -Gh.prototype.isHemisphereLightProbe = !0; -var Vh = class extends Hr { - constructor(e, t = 1){ - super(void 0, t); - let n = new ae().set(e); - this.sh.coefficients[0].set(n.r, n.g, n.b).multiplyScalar(2 * Math.sqrt(Math.PI)); - } -}; -Vh.prototype.isAmbientLightProbe = !0; -var Ec = new pe, Ac = new pe, Fn = new pe, fy = class { - constructor(){ - this.type = "StereoCamera", this.aspect = 1, this.eyeSep = .064, this.cameraL = new ut, this.cameraL.layers.enable(1), this.cameraL.matrixAutoUpdate = !1, this.cameraR = new ut, this.cameraR.layers.enable(2), this.cameraR.matrixAutoUpdate = !1, this._cache = { - focus: null, - fov: null, - aspect: null, - near: null, - far: null, - zoom: null, - eyeSep: null - }; - } - update(e) { - let t = this._cache; - if (t.focus !== e.focus || t.fov !== e.fov || t.aspect !== e.aspect * this.aspect || t.near !== e.near || t.far !== e.far || t.zoom !== e.zoom || t.eyeSep !== this.eyeSep) { - t.focus = e.focus, t.fov = e.fov, t.aspect = e.aspect * this.aspect, t.near = e.near, t.far = e.far, t.zoom = e.zoom, t.eyeSep = this.eyeSep, Fn.copy(e.projectionMatrix); - let i = t.eyeSep / 2, r = i * t.near / t.focus, o = t.near * Math.tan(Wn * t.fov * .5) / t.zoom, a, l; - Ac.elements[12] = -i, Ec.elements[12] = i, a = -o * t.aspect + r, l = o * t.aspect + r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraL.projectionMatrix.copy(Fn), a = -o * t.aspect - r, l = o * t.aspect - r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraR.projectionMatrix.copy(Fn); - } - this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ac), this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ec); - } -}, Wh = class { - constructor(e = !0){ - this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1; - } - start() { - this.startTime = Cc(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0; - } - stop() { - this.getElapsedTime(), this.running = !1, this.autoStart = !1; - } - getElapsedTime() { - return this.getDelta(), this.elapsedTime; - } - getDelta() { - let e = 0; - if (this.autoStart && !this.running) return this.start(), 0; - if (this.running) { - let t = Cc(); - e = (t - this.oldTime) / 1e3, this.oldTime = t, this.elapsedTime += e; - } - return e; - } -}; -function Cc() { - return (typeof performance > "u" ? Date : performance).now(); -} -var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { - constructor(){ - super(); - this.type = "AudioListener", this.context = Hh.getContext(), this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.filter = null, this.timeDelta = 0, this._clock = new Wh; - } - getInput() { - return this.gain; - } - removeFilter() { - return this.filter !== null && (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination), this.gain.connect(this.context.destination), this.filter = null), this; - } - getFilter() { - return this.filter; - } - setFilter(e) { - return this.filter !== null ? (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination)) : this.gain.disconnect(this.context.destination), this.filter = e, this.gain.connect(this.filter), this.filter.connect(this.context.destination), this; - } - getMasterVolume() { - return this.gain.gain.value; - } - setMasterVolume(e) { - return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; - } - updateMatrixWorld(e) { - super.updateMatrixWorld(e); - let t = this.context.listener, n = this.up; - if (this.timeDelta = this._clock.getDelta(), this.matrixWorld.decompose(Nn, Lc, py), Bn.set(0, 0, -1).applyQuaternion(Lc), t.positionX) { - let i = this.context.currentTime + this.timeDelta; - t.positionX.linearRampToValueAtTime(Nn.x, i), t.positionY.linearRampToValueAtTime(Nn.y, i), t.positionZ.linearRampToValueAtTime(Nn.z, i), t.forwardX.linearRampToValueAtTime(Bn.x, i), t.forwardY.linearRampToValueAtTime(Bn.y, i), t.forwardZ.linearRampToValueAtTime(Bn.z, i), t.upX.linearRampToValueAtTime(n.x, i), t.upY.linearRampToValueAtTime(n.y, i), t.upZ.linearRampToValueAtTime(n.z, i); - } else t.setPosition(Nn.x, Nn.y, Nn.z), t.setOrientation(Bn.x, Bn.y, Bn.z, n.x, n.y, n.z); - } -}, Za = class extends Ne { - constructor(e){ - super(); - this.type = "Audio", this.listener = e, this.context = e.context, this.gain = this.context.createGain(), this.gain.connect(e.getInput()), this.autoplay = !1, this.buffer = null, this.detune = 0, this.loop = !1, this.loopStart = 0, this.loopEnd = 0, this.offset = 0, this.duration = void 0, this.playbackRate = 1, this.isPlaying = !1, this.hasPlaybackControl = !0, this.source = null, this.sourceType = "empty", this._startedAt = 0, this._progress = 0, this._connected = !1, this.filters = []; - } - getOutput() { - return this.gain; - } - setNodeSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "audioNode", this.source = e, this.connect(), this; - } - setMediaElementSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "mediaNode", this.source = this.context.createMediaElementSource(e), this.connect(), this; - } - setMediaStreamSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "mediaStreamNode", this.source = this.context.createMediaStreamSource(e), this.connect(), this; - } - setBuffer(e) { - return this.buffer = e, this.sourceType = "buffer", this.autoplay && this.play(), this; - } - play(e = 0) { - if (this.isPlaying === !0) { - console.warn("THREE.Audio: Audio is already playing."); - return; - } - if (this.hasPlaybackControl === !1) { - console.warn("THREE.Audio: this Audio has no playback control."); - return; - } - this._startedAt = this.context.currentTime + e; - let t = this.context.createBufferSource(); - return t.buffer = this.buffer, t.loop = this.loop, t.loopStart = this.loopStart, t.loopEnd = this.loopEnd, t.onended = this.onEnded.bind(this), t.start(this._startedAt, this._progress + this.offset, this.duration), this.isPlaying = !0, this.source = t, this.setDetune(this.detune), this.setPlaybackRate(this.playbackRate), this.connect(); - } - pause() { - if (this.hasPlaybackControl === !1) { - console.warn("THREE.Audio: this Audio has no playback control."); - return; - } - return this.isPlaying === !0 && (this._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate, this.loop === !0 && (this._progress = this._progress % (this.duration || this.buffer.duration)), this.source.stop(), this.source.onended = null, this.isPlaying = !1), this; - } - stop() { - if (this.hasPlaybackControl === !1) { - console.warn("THREE.Audio: this Audio has no playback control."); - return; - } - return this._progress = 0, this.source.stop(), this.source.onended = null, this.isPlaying = !1, this; - } - connect() { - if (this.filters.length > 0) { - this.source.connect(this.filters[0]); - for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].connect(this.filters[e]); - this.filters[this.filters.length - 1].connect(this.getOutput()); - } else this.source.connect(this.getOutput()); - return this._connected = !0, this; - } - disconnect() { - if (this.filters.length > 0) { - this.source.disconnect(this.filters[0]); - for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].disconnect(this.filters[e]); - this.filters[this.filters.length - 1].disconnect(this.getOutput()); - } else this.source.disconnect(this.getOutput()); - return this._connected = !1, this; - } - getFilters() { - return this.filters; - } - setFilters(e) { - return e || (e = []), this._connected === !0 ? (this.disconnect(), this.filters = e.slice(), this.connect()) : this.filters = e.slice(), this; - } - setDetune(e) { - if (this.detune = e, this.source.detune !== void 0) return this.isPlaying === !0 && this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, .01), this; - } - getDetune() { - return this.detune; - } - getFilter() { - return this.getFilters()[0]; - } - setFilter(e) { - return this.setFilters(e ? [ - e - ] : []); - } - setPlaybackRate(e) { - if (this.hasPlaybackControl === !1) { - console.warn("THREE.Audio: this Audio has no playback control."); - return; - } - return this.playbackRate = e, this.isPlaying === !0 && this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, .01), this; - } - getPlaybackRate() { - return this.playbackRate; - } - onEnded() { - this.isPlaying = !1; - } - getLoop() { - return this.hasPlaybackControl === !1 ? (console.warn("THREE.Audio: this Audio has no playback control."), !1) : this.loop; - } - setLoop(e) { - if (this.hasPlaybackControl === !1) { - console.warn("THREE.Audio: this Audio has no playback control."); - return; - } - return this.loop = e, this.isPlaying === !0 && (this.source.loop = this.loop), this; - } - setLoopStart(e) { - return this.loopStart = e, this; - } - setLoopEnd(e) { - return this.loopEnd = e, this; - } - getVolume() { - return this.gain.gain.value; - } - setVolume(e) { - return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; - } -}, zn = new M, Rc = new gt, gy = new M, Un = new M, xy = class extends Za { - constructor(e){ - super(e); - this.panner = this.context.createPanner(), this.panner.panningModel = "HRTF", this.panner.connect(this.gain); - } - getOutput() { - return this.panner; - } - getRefDistance() { - return this.panner.refDistance; - } - setRefDistance(e) { - return this.panner.refDistance = e, this; - } - getRolloffFactor() { - return this.panner.rolloffFactor; - } - setRolloffFactor(e) { - return this.panner.rolloffFactor = e, this; - } - getDistanceModel() { - return this.panner.distanceModel; - } - setDistanceModel(e) { - return this.panner.distanceModel = e, this; - } - getMaxDistance() { - return this.panner.maxDistance; - } - setMaxDistance(e) { - return this.panner.maxDistance = e, this; - } - setDirectionalCone(e, t, n) { - return this.panner.coneInnerAngle = e, this.panner.coneOuterAngle = t, this.panner.coneOuterGain = n, this; - } - updateMatrixWorld(e) { - if (super.updateMatrixWorld(e), this.hasPlaybackControl === !0 && this.isPlaying === !1) return; - this.matrixWorld.decompose(zn, Rc, gy), Un.set(0, 0, 1).applyQuaternion(Rc); - let t = this.panner; - if (t.positionX) { - let n = this.context.currentTime + this.listener.timeDelta; - t.positionX.linearRampToValueAtTime(zn.x, n), t.positionY.linearRampToValueAtTime(zn.y, n), t.positionZ.linearRampToValueAtTime(zn.z, n), t.orientationX.linearRampToValueAtTime(Un.x, n), t.orientationY.linearRampToValueAtTime(Un.y, n), t.orientationZ.linearRampToValueAtTime(Un.z, n); - } else t.setPosition(zn.x, zn.y, zn.z), t.setOrientation(Un.x, Un.y, Un.z); - } -}, qh = class { - constructor(e, t = 2048){ - this.analyser = e.context.createAnalyser(), this.analyser.fftSize = t, this.data = new Uint8Array(this.analyser.frequencyBinCount), e.getOutput().connect(this.analyser); - } - getFrequencyData() { - return this.analyser.getByteFrequencyData(this.data), this.data; - } - getAverageFrequency() { - let e = 0, t = this.getFrequencyData(); - for(let n = 0; n < t.length; n++)e += t[n]; - return e / t.length; - } -}, Xh = class { - constructor(e, t, n){ - this.binding = e, this.valueSize = n; - let i, r, o; - switch(t){ - case "quaternion": - i = this._slerp, r = this._slerpAdditive, o = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5; - break; - case "string": - case "bool": - i = this._select, r = this._select, o = this._setAdditiveIdentityOther, this.buffer = new Array(n * 5); - break; - default: - i = this._lerp, r = this._lerpAdditive, o = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5); - } - this._mixBufferRegion = i, this._mixBufferRegionAdditive = r, this._setIdentity = o, this._origIndex = 3, this._addIndex = 4, this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, this.useCount = 0, this.referenceCount = 0; - } - accumulate(e, t) { - let n = this.buffer, i = this.valueSize, r = e * i + i, o = this.cumulativeWeight; - if (o === 0) { - for(let a = 0; a !== i; ++a)n[r + a] = n[a]; - o = t; - } else { - o += t; - let a = t / o; - this._mixBufferRegion(n, r, 0, a, i); - } - this.cumulativeWeight = o; - } - accumulateAdditive(e) { - let t = this.buffer, n = this.valueSize, i = n * this._addIndex; - this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(t, i, 0, e, n), this.cumulativeWeightAdditive += e; - } - apply(e) { - let t = this.valueSize, n = this.buffer, i = e * t + t, r = this.cumulativeWeight, o = this.cumulativeWeightAdditive, a = this.binding; - if (this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, r < 1) { - let l = t * this._origIndex; - this._mixBufferRegion(n, i, l, 1 - r, t); - } - o > 0 && this._mixBufferRegionAdditive(n, i, this._addIndex * t, 1, t); - for(let l = t, c = t + t; l !== c; ++l)if (n[l] !== n[l + t]) { - a.setValue(n, i); - break; - } - } - saveOriginalState() { - let e = this.binding, t = this.buffer, n = this.valueSize, i = n * this._origIndex; - e.getValue(t, i); - for(let r = n, o = i; r !== o; ++r)t[r] = t[i + r % n]; - this._setIdentity(), this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0; - } - restoreOriginalState() { - let e = this.valueSize * 3; - this.binding.setValue(this.buffer, e); - } - _setAdditiveIdentityNumeric() { - let e = this._addIndex * this.valueSize, t = e + this.valueSize; - for(let n = e; n < t; n++)this.buffer[n] = 0; - } - _setAdditiveIdentityQuaternion() { - this._setAdditiveIdentityNumeric(), this.buffer[this._addIndex * this.valueSize + 3] = 1; - } - _setAdditiveIdentityOther() { - let e = this._origIndex * this.valueSize, t = this._addIndex * this.valueSize; - for(let n = 0; n < this.valueSize; n++)this.buffer[t + n] = this.buffer[e + n]; - } - _select(e, t, n, i, r) { - if (i >= .5) for(let o = 0; o !== r; ++o)e[t + o] = e[n + o]; - } - _slerp(e, t, n, i) { - gt.slerpFlat(e, t, e, t, e, n, i); - } - _slerpAdditive(e, t, n, i, r) { - let o = this._workIndex * r; - gt.multiplyQuaternionsFlat(e, o, e, t, e, n), gt.slerpFlat(e, t, e, t, e, o, i); - } - _lerp(e, t, n, i, r) { - let o = 1 - i; - for(let a = 0; a !== r; ++a){ - let l = t + a; - e[l] = e[l] * o + e[n + a] * i; - } - } - _lerpAdditive(e, t, n, i, r) { - for(let o = 0; o !== r; ++o){ - let a = t + o; - e[a] = e[a] + e[n + o] * i; - } - } -}, $a = "\\[\\]\\.:\\/", yy = new RegExp("[" + $a + "]", "g"), ja = "[^" + $a + "]", vy = "[^" + $a.replace("\\.", "") + "]", _y = /((?:WC+[\/:])*)/.source.replace("WC", ja), My = /(WCOD+)?/.source.replace("WCOD", vy), by = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", ja), wy = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", ja), Sy = new RegExp("^" + _y + My + by + wy + "$"), Ty = [ - "material", - "materials", - "bones" -], Jh = class { - constructor(e, t, n){ - let i = n || ke.parseTrackName(t); - this._targetGroup = e, this._bindings = e.subscribe_(t, i); - } - getValue(e, t) { - this.bind(); - let n = this._targetGroup.nCachedObjects_, i = this._bindings[n]; - i !== void 0 && i.getValue(e, t); - } - setValue(e, t) { - let n = this._bindings; - for(let i = this._targetGroup.nCachedObjects_, r = n.length; i !== r; ++i)n[i].setValue(e, t); - } - bind() { - let e = this._bindings; - for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].bind(); - } - unbind() { - let e = this._bindings; - for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].unbind(); - } -}, ke = class { - constructor(e, t, n){ - this.path = t, this.parsedPath = n || ke.parseTrackName(t), this.node = ke.findNode(e, this.parsedPath.nodeName) || e, this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; - } - static create(e, t, n) { - return e && e.isAnimationObjectGroup ? new ke.Composite(e, t, n) : new ke(e, t, n); - } - static sanitizeNodeName(e) { - return e.replace(/\s/g, "_").replace(yy, ""); - } - static parseTrackName(e) { - let t = Sy.exec(e); - if (!t) throw new Error("PropertyBinding: Cannot parse trackName: " + e); - let n = { - nodeName: t[2], - objectName: t[3], - objectIndex: t[4], - propertyName: t[5], - propertyIndex: t[6] - }, i = n.nodeName && n.nodeName.lastIndexOf("."); - if (i !== void 0 && i !== -1) { - let r = n.nodeName.substring(i + 1); - Ty.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, i), n.objectName = r); - } - if (n.propertyName === null || n.propertyName.length === 0) throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e); - return n; - } - static findNode(e, t) { - if (!t || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; - if (e.skeleton) { - let n = e.skeleton.getBoneByName(t); - if (n !== void 0) return n; - } - if (e.children) { - let n = function(r) { - for(let o = 0; o < r.length; o++){ - let a = r[o]; - if (a.name === t || a.uuid === t) return a; - let l = n(a.children); - if (l) return l; - } - return null; - }, i = n(e.children); - if (i) return i; - } - return null; - } - _getValue_unavailable() {} - _setValue_unavailable() {} - _getValue_direct(e, t) { - e[t] = this.targetObject[this.propertyName]; - } - _getValue_array(e, t) { - let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)e[t++] = n[i]; - } - _getValue_arrayElement(e, t) { - e[t] = this.resolvedProperty[this.propertyIndex]; - } - _getValue_toArray(e, t) { - this.resolvedProperty.toArray(e, t); - } - _setValue_direct(e, t) { - this.targetObject[this.propertyName] = e[t]; - } - _setValue_direct_setNeedsUpdate(e, t) { - this.targetObject[this.propertyName] = e[t], this.targetObject.needsUpdate = !0; - } - _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { - this.targetObject[this.propertyName] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; - } - _setValue_array(e, t) { - let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; - } - _setValue_array_setNeedsUpdate(e, t) { - let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; - this.targetObject.needsUpdate = !0; - } - _setValue_array_setMatrixWorldNeedsUpdate(e, t) { - let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; - this.targetObject.matrixWorldNeedsUpdate = !0; - } - _setValue_arrayElement(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t]; - } - _setValue_arrayElement_setNeedsUpdate(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.needsUpdate = !0; - } - _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; - } - _setValue_fromArray(e, t) { - this.resolvedProperty.fromArray(e, t); - } - _setValue_fromArray_setNeedsUpdate(e, t) { - this.resolvedProperty.fromArray(e, t), this.targetObject.needsUpdate = !0; - } - _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { - this.resolvedProperty.fromArray(e, t), this.targetObject.matrixWorldNeedsUpdate = !0; - } - _getValue_unbound(e, t) { - this.bind(), this.getValue(e, t); - } - _setValue_unbound(e, t) { - this.bind(), this.setValue(e, t); - } - bind() { - let e = this.node, t = this.parsedPath, n = t.objectName, i = t.propertyName, r = t.propertyIndex; - if (e || (e = ke.findNode(this.rootNode, t.nodeName) || this.rootNode, this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) { - console.error("THREE.PropertyBinding: Trying to update node for track: " + this.path + " but it wasn't found."); - return; - } - if (n) { - let c = t.objectIndex; - switch(n){ - case "materials": - if (!e.material) { - console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); - return; - } - if (!e.material.materials) { - console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this); - return; - } - e = e.material.materials; - break; - case "bones": - if (!e.skeleton) { - console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this); - return; - } - e = e.skeleton.bones; - for(let h = 0; h < e.length; h++)if (e[h].name === c) { - c = h; - break; - } - break; - default: - if (e[n] === void 0) { - console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this); - return; - } - e = e[n]; - } - if (c !== void 0) { - if (e[c] === void 0) { - console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e); - return; - } - e = e[c]; - } - } - let o = e[i]; - if (o === void 0) { - let c = t.nodeName; - console.error("THREE.PropertyBinding: Trying to update property for track: " + c + "." + i + " but it wasn't found.", e); - return; - } - let a = this.Versioning.None; - this.targetObject = e, e.needsUpdate !== void 0 ? a = this.Versioning.NeedsUpdate : e.matrixWorldNeedsUpdate !== void 0 && (a = this.Versioning.MatrixWorldNeedsUpdate); - let l = this.BindingType.Direct; - if (r !== void 0) { - if (i === "morphTargetInfluences") { - if (!e.geometry) { - console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this); - return; - } - if (e.geometry.isBufferGeometry) { - if (!e.geometry.morphAttributes) { - console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); - return; - } - e.morphTargetDictionary[r] !== void 0 && (r = e.morphTargetDictionary[r]); - } else { - console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.", this); - return; - } - } - l = this.BindingType.ArrayElement, this.resolvedProperty = o, this.propertyIndex = r; - } else o.fromArray !== void 0 && o.toArray !== void 0 ? (l = this.BindingType.HasFromToArray, this.resolvedProperty = o) : Array.isArray(o) ? (l = this.BindingType.EntireArray, this.resolvedProperty = o) : this.propertyName = i; - this.getValue = this.GetterByBindingType[l], this.setValue = this.SetterByBindingTypeAndVersioning[l][a]; - } - unbind() { - this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; - } -}; -ke.Composite = Jh; -ke.prototype.BindingType = { - Direct: 0, - EntireArray: 1, - ArrayElement: 2, - HasFromToArray: 3 -}; -ke.prototype.Versioning = { - None: 0, - NeedsUpdate: 1, - MatrixWorldNeedsUpdate: 2 -}; -ke.prototype.GetterByBindingType = [ - ke.prototype._getValue_direct, - ke.prototype._getValue_array, - ke.prototype._getValue_arrayElement, - ke.prototype._getValue_toArray -]; -ke.prototype.SetterByBindingTypeAndVersioning = [ - [ - ke.prototype._setValue_direct, - ke.prototype._setValue_direct_setNeedsUpdate, - ke.prototype._setValue_direct_setMatrixWorldNeedsUpdate - ], - [ - ke.prototype._setValue_array, - ke.prototype._setValue_array_setNeedsUpdate, - ke.prototype._setValue_array_setMatrixWorldNeedsUpdate - ], - [ - ke.prototype._setValue_arrayElement, - ke.prototype._setValue_arrayElement_setNeedsUpdate, - ke.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate - ], - [ - ke.prototype._setValue_fromArray, - ke.prototype._setValue_fromArray_setNeedsUpdate, - ke.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate - ] -]; -var Yh = class { - constructor(){ - this.uuid = Et(), this._objects = Array.prototype.slice.call(arguments), this.nCachedObjects_ = 0; - let e = {}; - this._indicesByUUID = e; - for(let n = 0, i = arguments.length; n !== i; ++n)e[arguments[n].uuid] = n; - this._paths = [], this._parsedPaths = [], this._bindings = [], this._bindingsIndicesByPath = {}; - let t = this; - this.stats = { - objects: { - get total () { - return t._objects.length; - }, - get inUse () { - return this.total - t.nCachedObjects_; - } - }, - get bindingsPerObject () { - return t._bindings.length; - } - }; - } - add() { - let e = this._objects, t = this._indicesByUUID, n = this._paths, i = this._parsedPaths, r = this._bindings, o = r.length, a, l = e.length, c = this.nCachedObjects_; - for(let h = 0, u = arguments.length; h !== u; ++h){ - let d = arguments[h], f = d.uuid, m = t[f]; - if (m === void 0) { - m = l++, t[f] = m, e.push(d); - for(let x = 0, v = o; x !== v; ++x)r[x].push(new ke(d, n[x], i[x])); - } else if (m < c) { - a = e[m]; - let x = --c, v = e[x]; - t[v.uuid] = m, e[m] = v, t[f] = x, e[x] = d; - for(let g = 0, p = o; g !== p; ++g){ - let _ = r[g], y = _[x], b = _[m]; - _[m] = y, b === void 0 && (b = new ke(d, n[g], i[g])), _[x] = b; - } - } else e[m] !== a && console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes."); - } - this.nCachedObjects_ = c; - } - remove() { - let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_; - for(let o = 0, a = arguments.length; o !== a; ++o){ - let l = arguments[o], c = l.uuid, h = t[c]; - if (h !== void 0 && h >= r) { - let u = r++, d = e[u]; - t[d.uuid] = h, e[h] = d, t[c] = u, e[u] = l; - for(let f = 0, m = i; f !== m; ++f){ - let x = n[f], v = x[u], g = x[h]; - x[h] = v, x[u] = g; - } - } - } - this.nCachedObjects_ = r; - } - uncache() { - let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_, o = e.length; - for(let a = 0, l = arguments.length; a !== l; ++a){ - let c = arguments[a], h = c.uuid, u = t[h]; - if (u !== void 0) if (delete t[h], u < r) { - let d = --r, f = e[d], m = --o, x = e[m]; - t[f.uuid] = u, e[u] = f, t[x.uuid] = d, e[d] = x, e.pop(); - for(let v = 0, g = i; v !== g; ++v){ - let p = n[v], _ = p[d], y = p[m]; - p[u] = _, p[d] = y, p.pop(); - } - } else { - let d = --o, f = e[d]; - d > 0 && (t[f.uuid] = u), e[u] = f, e.pop(); - for(let m = 0, x = i; m !== x; ++m){ - let v = n[m]; - v[u] = v[d], v.pop(); - } - } - } - this.nCachedObjects_ = r; - } - subscribe_(e, t) { - let n = this._bindingsIndicesByPath, i = n[e], r = this._bindings; - if (i !== void 0) return r[i]; - let o = this._paths, a = this._parsedPaths, l = this._objects, c = l.length, h = this.nCachedObjects_, u = new Array(c); - i = r.length, n[e] = i, o.push(e), a.push(t), r.push(u); - for(let d = h, f = l.length; d !== f; ++d){ - let m = l[d]; - u[d] = new ke(m, e, t); - } - return u; - } - unsubscribe_(e) { - let t = this._bindingsIndicesByPath, n = t[e]; - if (n !== void 0) { - let i = this._paths, r = this._parsedPaths, o = this._bindings, a = o.length - 1, l = o[a], c = e[a]; - t[c] = n, o[n] = l, o.pop(), r[n] = r[a], r.pop(), i[n] = i[a], i.pop(); - } - } -}; -Yh.prototype.isAnimationObjectGroup = !0; -var Zh = class { - constructor(e, t, n = null, i = t.blendMode){ - this._mixer = e, this._clip = t, this._localRoot = n, this.blendMode = i; - let r = t.tracks, o = r.length, a = new Array(o), l = { - endingStart: Mi, - endingEnd: Mi - }; - for(let c = 0; c !== o; ++c){ - let h = r[c].createInterpolant(null); - a[c] = h, h.settings = l; - } - this._interpolantSettings = l, this._interpolants = a, this._propertyBindings = new Array(o), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._weightInterpolant = null, this.loop = Id, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = 1 / 0, this.paused = !1, this.enabled = !0, this.clampWhenFinished = !1, this.zeroSlopeAtStart = !0, this.zeroSlopeAtEnd = !0; - } - play() { - return this._mixer._activateAction(this), this; - } - stop() { - return this._mixer._deactivateAction(this), this.reset(); - } - reset() { - return this.paused = !1, this.enabled = !0, this.time = 0, this._loopCount = -1, this._startTime = null, this.stopFading().stopWarping(); - } - isRunning() { - return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this); - } - isScheduled() { - return this._mixer._isActiveAction(this); - } - startAt(e) { - return this._startTime = e, this; - } - setLoop(e, t) { - return this.loop = e, this.repetitions = t, this; - } - setEffectiveWeight(e) { - return this.weight = e, this._effectiveWeight = this.enabled ? e : 0, this.stopFading(); - } - getEffectiveWeight() { - return this._effectiveWeight; - } - fadeIn(e) { - return this._scheduleFading(e, 0, 1); - } - fadeOut(e) { - return this._scheduleFading(e, 1, 0); - } - crossFadeFrom(e, t, n) { - if (e.fadeOut(t), this.fadeIn(t), n) { - let i = this._clip.duration, r = e._clip.duration, o = r / i, a = i / r; - e.warp(1, o, t), this.warp(a, 1, t); - } - return this; - } - crossFadeTo(e, t, n) { - return e.crossFadeFrom(this, t, n); - } - stopFading() { - let e = this._weightInterpolant; - return e !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; - } - setEffectiveTimeScale(e) { - return this.timeScale = e, this._effectiveTimeScale = this.paused ? 0 : e, this.stopWarping(); - } - getEffectiveTimeScale() { - return this._effectiveTimeScale; - } - setDuration(e) { - return this.timeScale = this._clip.duration / e, this.stopWarping(); - } - syncWith(e) { - return this.time = e.time, this.timeScale = e.timeScale, this.stopWarping(); - } - halt(e) { - return this.warp(this._effectiveTimeScale, 0, e); - } - warp(e, t, n) { - let i = this._mixer, r = i.time, o = this.timeScale, a = this._timeScaleInterpolant; - a === null && (a = i._lendControlInterpolant(), this._timeScaleInterpolant = a); - let l = a.parameterPositions, c = a.sampleValues; - return l[0] = r, l[1] = r + n, c[0] = e / o, c[1] = t / o, this; - } - stopWarping() { - let e = this._timeScaleInterpolant; - return e !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; - } - getMixer() { - return this._mixer; - } - getClip() { - return this._clip; - } - getRoot() { - return this._localRoot || this._mixer._root; - } - _update(e, t, n, i) { - if (!this.enabled) { - this._updateWeight(e); - return; - } - let r = this._startTime; - if (r !== null) { - let l = (e - r) * n; - if (l < 0 || n === 0) return; - this._startTime = null, t = n * l; - } - t *= this._updateTimeScale(e); - let o = this._updateTime(t), a = this._updateWeight(e); - if (a > 0) { - let l = this._interpolants, c = this._propertyBindings; - switch(this.blendMode){ - case qc: - for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulateAdditive(a); - break; - case ua: - default: - for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulate(i, a); - } - } - } - _updateWeight(e) { - let t = 0; - if (this.enabled) { - t = this.weight; - let n = this._weightInterpolant; - if (n !== null) { - let i = n.evaluate(e)[0]; - t *= i, e > n.parameterPositions[1] && (this.stopFading(), i === 0 && (this.enabled = !1)); - } - } - return this._effectiveWeight = t, t; - } - _updateTimeScale(e) { - let t = 0; - if (!this.paused) { - t = this.timeScale; - let n = this._timeScaleInterpolant; - n !== null && (t *= n.evaluate(e)[0], e > n.parameterPositions[1] && (this.stopWarping(), t === 0 ? this.paused = !0 : this.timeScale = t)); - } - return this._effectiveTimeScale = t, t; - } - _updateTime(e) { - let t = this._clip.duration, n = this.loop, i = this.time + e, r = this._loopCount, o = n === Dd; - if (e === 0) return r === -1 ? i : o && (r & 1) === 1 ? t - i : i; - if (n === Pd) { - r === -1 && (this._loopCount = 0, this._setEndings(!0, !0, !1)); - e: { - if (i >= t) i = t; - else if (i < 0) i = 0; - else { - this.time = i; - break e; - } - this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, this.time = i, this._mixer.dispatchEvent({ - type: "finished", - action: this, - direction: e < 0 ? -1 : 1 - }); - } - } else { - if (r === -1 && (e >= 0 ? (r = 0, this._setEndings(!0, this.repetitions === 0, o)) : this._setEndings(this.repetitions === 0, !0, o)), i >= t || i < 0) { - let a = Math.floor(i / t); - i -= t * a, r += Math.abs(a); - let l = this.repetitions - r; - if (l <= 0) this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, i = e > 0 ? t : 0, this.time = i, this._mixer.dispatchEvent({ - type: "finished", - action: this, - direction: e > 0 ? 1 : -1 - }); - else { - if (l === 1) { - let c = e < 0; - this._setEndings(c, !c, o); - } else this._setEndings(!1, !1, o); - this._loopCount = r, this.time = i, this._mixer.dispatchEvent({ - type: "loop", - action: this, - loopDelta: a - }); - } - } else this.time = i; - if (o && (r & 1) === 1) return t - i; - } - return i; - } - _setEndings(e, t, n) { - let i = this._interpolantSettings; - n ? (i.endingStart = bi, i.endingEnd = bi) : (e ? i.endingStart = this.zeroSlopeAtStart ? bi : Mi : i.endingStart = Os, t ? i.endingEnd = this.zeroSlopeAtEnd ? bi : Mi : i.endingEnd = Os); - } - _scheduleFading(e, t, n) { - let i = this._mixer, r = i.time, o = this._weightInterpolant; - o === null && (o = i._lendControlInterpolant(), this._weightInterpolant = o); - let a = o.parameterPositions, l = o.sampleValues; - return a[0] = r, l[0] = t, a[1] = r + e, l[1] = n, this; - } -}, $h = class extends En { - constructor(e){ - super(); - this._root = e, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1; - } - _bindAction(e, t) { - let n = e._localRoot || this._root, i = e._clip.tracks, r = i.length, o = e._propertyBindings, a = e._interpolants, l = n.uuid, c = this._bindingsByRootAndName, h = c[l]; - h === void 0 && (h = {}, c[l] = h); - for(let u = 0; u !== r; ++u){ - let d = i[u], f = d.name, m = h[f]; - if (m !== void 0) o[u] = m; - else { - if (m = o[u], m !== void 0) { - m._cacheIndex === null && (++m.referenceCount, this._addInactiveBinding(m, l, f)); - continue; - } - let x = t && t._propertyBindings[u].binding.parsedPath; - m = new Xh(ke.create(n, f, x), d.ValueTypeName, d.getValueSize()), ++m.referenceCount, this._addInactiveBinding(m, l, f), o[u] = m; - } - a[u].resultBuffer = m.buffer; - } - } - _activateAction(e) { - if (!this._isActiveAction(e)) { - if (e._cacheIndex === null) { - let n = (e._localRoot || this._root).uuid, i = e._clip.uuid, r = this._actionsByClip[i]; - this._bindAction(e, r && r.knownActions[0]), this._addInactiveAction(e, i, n); - } - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; - r.useCount++ === 0 && (this._lendBinding(r), r.saveOriginalState()); - } - this._lendAction(e); - } - } - _deactivateAction(e) { - if (this._isActiveAction(e)) { - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; - --r.useCount === 0 && (r.restoreOriginalState(), this._takeBackBinding(r)); - } - this._takeBackAction(e); - } - } - _initMemoryManager() { - this._actions = [], this._nActiveActions = 0, this._actionsByClip = {}, this._bindings = [], this._nActiveBindings = 0, this._bindingsByRootAndName = {}, this._controlInterpolants = [], this._nActiveControlInterpolants = 0; - let e = this; - this.stats = { - actions: { - get total () { - return e._actions.length; - }, - get inUse () { - return e._nActiveActions; - } - }, - bindings: { - get total () { - return e._bindings.length; - }, - get inUse () { - return e._nActiveBindings; - } - }, - controlInterpolants: { - get total () { - return e._controlInterpolants.length; - }, - get inUse () { - return e._nActiveControlInterpolants; - } - } - }; - } - _isActiveAction(e) { - let t = e._cacheIndex; - return t !== null && t < this._nActiveActions; - } - _addInactiveAction(e, t, n) { - let i = this._actions, r = this._actionsByClip, o = r[t]; - if (o === void 0) o = { - knownActions: [ - e - ], - actionByRoot: {} - }, e._byClipCacheIndex = 0, r[t] = o; - else { - let a = o.knownActions; - e._byClipCacheIndex = a.length, a.push(e); - } - e._cacheIndex = i.length, i.push(e), o.actionByRoot[n] = e; - } - _removeInactiveAction(e) { - let t = this._actions, n = t[t.length - 1], i = e._cacheIndex; - n._cacheIndex = i, t[i] = n, t.pop(), e._cacheIndex = null; - let r = e._clip.uuid, o = this._actionsByClip, a = o[r], l = a.knownActions, c = l[l.length - 1], h = e._byClipCacheIndex; - c._byClipCacheIndex = h, l[h] = c, l.pop(), e._byClipCacheIndex = null; - let u = a.actionByRoot, d = (e._localRoot || this._root).uuid; - delete u[d], l.length === 0 && delete o[r], this._removeInactiveBindingsForAction(e); - } - _removeInactiveBindingsForAction(e) { - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; - --r.referenceCount === 0 && this._removeInactiveBinding(r); - } - } - _lendAction(e) { - let t = this._actions, n = e._cacheIndex, i = this._nActiveActions++, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; - } - _takeBackAction(e) { - let t = this._actions, n = e._cacheIndex, i = --this._nActiveActions, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; - } - _addInactiveBinding(e, t, n) { - let i = this._bindingsByRootAndName, r = this._bindings, o = i[t]; - o === void 0 && (o = {}, i[t] = o), o[n] = e, e._cacheIndex = r.length, r.push(e); - } - _removeInactiveBinding(e) { - let t = this._bindings, n = e.binding, i = n.rootNode.uuid, r = n.path, o = this._bindingsByRootAndName, a = o[i], l = t[t.length - 1], c = e._cacheIndex; - l._cacheIndex = c, t[c] = l, t.pop(), delete a[r], Object.keys(a).length === 0 && delete o[i]; - } - _lendBinding(e) { - let t = this._bindings, n = e._cacheIndex, i = this._nActiveBindings++, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; - } - _takeBackBinding(e) { - let t = this._bindings, n = e._cacheIndex, i = --this._nActiveBindings, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; - } - _lendControlInterpolant() { - let e = this._controlInterpolants, t = this._nActiveControlInterpolants++, n = e[t]; - return n === void 0 && (n = new Na(new Float32Array(2), new Float32Array(2), 1, this._controlInterpolantsResultBuffer), n.__cacheIndex = t, e[t] = n), n; - } - _takeBackControlInterpolant(e) { - let t = this._controlInterpolants, n = e.__cacheIndex, i = --this._nActiveControlInterpolants, r = t[i]; - e.__cacheIndex = i, t[i] = e, r.__cacheIndex = n, t[n] = r; - } - clipAction(e, t, n) { - let i = t || this._root, r = i.uuid, o = typeof e == "string" ? Lr.findByName(i, e) : e, a = o !== null ? o.uuid : e, l = this._actionsByClip[a], c = null; - if (n === void 0 && (o !== null ? n = o.blendMode : n = ua), l !== void 0) { - let u = l.actionByRoot[r]; - if (u !== void 0 && u.blendMode === n) return u; - c = l.knownActions[0], o === null && (o = c._clip); - } - if (o === null) return null; - let h = new Zh(this, o, t, n); - return this._bindAction(h, c), this._addInactiveAction(h, a, r), h; - } - existingAction(e, t) { - let n = t || this._root, i = n.uuid, r = typeof e == "string" ? Lr.findByName(n, e) : e, o = r ? r.uuid : e, a = this._actionsByClip[o]; - return a !== void 0 && a.actionByRoot[i] || null; - } - stopAllAction() { - let e = this._actions, t = this._nActiveActions; - for(let n = t - 1; n >= 0; --n)e[n].stop(); - return this; - } - update(e) { - e *= this.timeScale; - let t = this._actions, n = this._nActiveActions, i = this.time += e, r = Math.sign(e), o = this._accuIndex ^= 1; - for(let c = 0; c !== n; ++c)t[c]._update(i, e, r, o); - let a = this._bindings, l = this._nActiveBindings; - for(let c = 0; c !== l; ++c)a[c].apply(o); - return this; - } - setTime(e) { - this.time = 0; - for(let t = 0; t < this._actions.length; t++)this._actions[t].time = 0; - return this.update(e); - } - getRoot() { - return this._root; - } - uncacheClip(e) { - let t = this._actions, n = e.uuid, i = this._actionsByClip, r = i[n]; - if (r !== void 0) { - let o = r.knownActions; - for(let a = 0, l = o.length; a !== l; ++a){ - let c = o[a]; - this._deactivateAction(c); - let h = c._cacheIndex, u = t[t.length - 1]; - c._cacheIndex = null, c._byClipCacheIndex = null, u._cacheIndex = h, t[h] = u, t.pop(), this._removeInactiveBindingsForAction(c); - } - delete i[n]; - } - } - uncacheRoot(e) { - let t = e.uuid, n = this._actionsByClip; - for(let o in n){ - let a = n[o].actionByRoot, l = a[t]; - l !== void 0 && (this._deactivateAction(l), this._removeInactiveAction(l)); - } - let i = this._bindingsByRootAndName, r = i[t]; - if (r !== void 0) for(let o in r){ - let a = r[o]; - a.restoreOriginalState(), this._removeInactiveBinding(a); - } - } - uncacheAction(e, t) { - let n = this.existingAction(e, t); - n !== null && (this._deactivateAction(n), this._removeInactiveAction(n)); - } -}; -$h.prototype._controlInterpolantsResultBuffer = new Float32Array(1); -var go = class { - constructor(e){ - typeof e == "string" && (console.warn("THREE.Uniform: Type parameter is no longer needed."), e = arguments[1]), this.value = e; - } - clone() { - return new go(this.value.clone === void 0 ? this.value : this.value.clone()); - } -}, jh = class extends $n { - constructor(e, t, n = 1){ - super(e, t); - this.meshPerAttribute = n; - } - copy(e) { - return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; - } - clone(e) { - let t = super.clone(e); - return t.meshPerAttribute = this.meshPerAttribute, t; - } - toJSON(e) { - let t = super.toJSON(e); - return t.isInstancedInterleavedBuffer = !0, t.meshPerAttribute = this.meshPerAttribute, t; - } -}; -jh.prototype.isInstancedInterleavedBuffer = !0; -var Qh = class { - constructor(e, t, n, i, r){ - this.buffer = e, this.type = t, this.itemSize = n, this.elementSize = i, this.count = r, this.version = 0; - } - set needsUpdate(e) { - e === !0 && this.version++; - } - setBuffer(e) { - return this.buffer = e, this; - } - setType(e, t) { - return this.type = e, this.elementSize = t, this; - } - setItemSize(e) { - return this.itemSize = e, this; - } - setCount(e) { - return this.count = e, this; - } -}; -Qh.prototype.isGLBufferAttribute = !0; -var Ey = class { - constructor(e, t, n = 0, i = 1 / 0){ - this.ray = new Cn(e, t), this.near = n, this.far = i, this.camera = null, this.layers = new Js, this.params = { - Mesh: {}, - Line: { - threshold: 1 - }, - LOD: {}, - Points: { - threshold: 1 - }, - Sprite: {} - }; - } - set(e, t) { - this.ray.set(e, t); - } - setFromCamera(e, t) { - t && t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, .5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t) : t && t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t) : console.error("THREE.Raycaster: Unsupported camera type: " + t.type); - } - intersectObject(e, t = !0, n = []) { - return la(e, this, n, t), n.sort(Pc), n; - } - intersectObjects(e, t = !0, n = []) { - for(let i = 0, r = e.length; i < r; i++)la(e[i], this, n, t); - return n.sort(Pc), n; - } -}; -function Pc(s, e) { - return s.distance - e.distance; -} -function la(s, e, t, n) { - if (s.layers.test(e.layers) && s.raycast(e, t), n === !0) { - let i = s.children; - for(let r = 0, o = i.length; r < o; r++)la(i[r], e, t, !0); - } -} -var Ay = class { - constructor(e = 1, t = 0, n = 0){ - return this.radius = e, this.phi = t, this.theta = n, this; - } - set(e, t, n) { - return this.radius = e, this.phi = t, this.theta = n, this; - } - copy(e) { - return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; - } - makeSafe() { - return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this; - } - setFromVector3(e) { - return this.setFromCartesianCoords(e.x, e.y, e.z); - } - setFromCartesianCoords(e, t, n) { - return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(mt(t / this.radius, -1, 1))), this; - } - clone() { - return new this.constructor().copy(this); - } -}, Cy = class { - constructor(e = 1, t = 0, n = 0){ - return this.radius = e, this.theta = t, this.y = n, this; - } - set(e, t, n) { - return this.radius = e, this.theta = t, this.y = n, this; - } - copy(e) { - return this.radius = e.radius, this.theta = e.theta, this.y = e.y, this; - } - setFromVector3(e) { - return this.setFromCartesianCoords(e.x, e.y, e.z); - } - setFromCartesianCoords(e, t, n) { - return this.radius = Math.sqrt(e * e + n * n), this.theta = Math.atan2(e, n), this.y = t, this; - } - clone() { - return new this.constructor().copy(this); - } -}, Ic = new X, qi = class { - constructor(e = new X(1 / 0, 1 / 0), t = new X(-1 / 0, -1 / 0)){ - this.min = e, this.max = t; - } - set(e, t) { - return this.min.copy(e), this.max.copy(t), this; - } - setFromPoints(e) { - this.makeEmpty(); - for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); - return this; - } - setFromCenterAndSize(e, t) { - let n = Ic.copy(t).multiplyScalar(.5); - return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; - } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.min.copy(e.min), this.max.copy(e.max), this; - } - makeEmpty() { - return this.min.x = this.min.y = 1 / 0, this.max.x = this.max.y = -1 / 0, this; - } - isEmpty() { - return this.max.x < this.min.x || this.max.y < this.min.y; - } - getCenter(e) { - return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); - } - getSize(e) { - return this.isEmpty() ? e.set(0, 0) : e.subVectors(this.max, this.min); - } - expandByPoint(e) { - return this.min.min(e), this.max.max(e), this; - } - expandByVector(e) { - return this.min.sub(e), this.max.add(e), this; - } - expandByScalar(e) { - return this.min.addScalar(-e), this.max.addScalar(e), this; - } - containsPoint(e) { - return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y); - } - containsBox(e) { - return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y; - } - getParameter(e, t) { - return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y)); - } - intersectsBox(e) { - return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y); - } - clampPoint(e, t) { - return t.copy(e).clamp(this.min, this.max); - } - distanceToPoint(e) { - return Ic.copy(e).clamp(this.min, this.max).sub(e).length(); - } - intersect(e) { - return this.min.max(e.min), this.max.min(e.max), this; - } - union(e) { - return this.min.min(e.min), this.max.max(e.max), this; - } - translate(e) { - return this.min.add(e), this.max.add(e), this; - } - equals(e) { - return e.min.equals(this.min) && e.max.equals(this.max); - } -}; -qi.prototype.isBox2 = !0; -var Dc = new M, Ts = new M, Kh = class { - constructor(e = new M, t = new M){ - this.start = e, this.end = t; - } - set(e, t) { - return this.start.copy(e), this.end.copy(t), this; - } - copy(e) { - return this.start.copy(e.start), this.end.copy(e.end), this; - } - getCenter(e) { - return e.addVectors(this.start, this.end).multiplyScalar(.5); - } - delta(e) { - return e.subVectors(this.end, this.start); - } - distanceSq() { - return this.start.distanceToSquared(this.end); - } - distance() { - return this.start.distanceTo(this.end); - } - at(e, t) { - return this.delta(t).multiplyScalar(e).add(this.start); - } - closestPointToPointParameter(e, t) { - Dc.subVectors(e, this.start), Ts.subVectors(this.end, this.start); - let n = Ts.dot(Ts), r = Ts.dot(Dc) / n; - return t && (r = mt(r, 0, 1)), r; - } - closestPointToPoint(e, t, n) { - let i = this.closestPointToPointParameter(e, t); - return this.delta(n).multiplyScalar(i).add(this.start); - } - applyMatrix4(e) { - return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this; - } - equals(e) { - return e.start.equals(this.start) && e.end.equals(this.end); - } - clone() { - return new this.constructor().copy(this); - } -}, Fc = new M, Ly = class extends Ne { - constructor(e, t){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = t; - let n = new _e, i = [ - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - -1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - -1, - 1 - ]; - for(let o = 0, a = 1, l = 32; o < l; o++, a++){ - let c = o / l * Math.PI * 2, h = a / l * Math.PI * 2; - i.push(Math.cos(c), Math.sin(c), 1, Math.cos(h), Math.sin(h), 1); - } - n.setAttribute("position", new de(i, 3)); - let r = new ft({ - fog: !1, - toneMapped: !1 - }); - this.cone = new wt(n, r), this.add(this.cone), this.update(); - } - dispose() { - this.cone.geometry.dispose(), this.cone.material.dispose(); - } - update() { - this.light.updateMatrixWorld(); - let e = this.light.distance ? this.light.distance : 1e3, t = e * Math.tan(this.light.angle); - this.cone.scale.set(t, t, e), Fc.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(Fc), this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color); - } -}, yn = new M, Es = new pe, Qo = new pe, eu = class extends wt { - constructor(e){ - let t = tu(e), n = new _e, i = [], r = [], o = new ae(0, 0, 1), a = new ae(0, 1, 0); - for(let c = 0; c < t.length; c++){ - let h = t[c]; - h.parent && h.parent.isBone && (i.push(0, 0, 0), i.push(0, 0, 0), r.push(o.r, o.g, o.b), r.push(a.r, a.g, a.b)); - } - n.setAttribute("position", new de(i, 3)), n.setAttribute("color", new de(r, 3)); - let l = new ft({ - vertexColors: !0, - depthTest: !1, - depthWrite: !1, - toneMapped: !1, - transparent: !0 - }); - super(n, l); - this.type = "SkeletonHelper", this.isSkeletonHelper = !0, this.root = e, this.bones = t, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1; - } - updateMatrixWorld(e) { - let t = this.bones, n = this.geometry, i = n.getAttribute("position"); - Qo.copy(this.root.matrixWorld).invert(); - for(let r = 0, o = 0; r < t.length; r++){ - let a = t[r]; - a.parent && a.parent.isBone && (Es.multiplyMatrices(Qo, a.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o, yn.x, yn.y, yn.z), Es.multiplyMatrices(Qo, a.parent.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o + 1, yn.x, yn.y, yn.z), o += 2); - } - n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(e); - } -}; -function tu(s) { - let e = []; - s && s.isBone && e.push(s); - for(let t = 0; t < s.children.length; t++)e.push.apply(e, tu(s.children[t])); - return e; -} -var Ry = class extends st { - constructor(e, t, n){ - let i = new Fi(t, 4, 2), r = new hn({ - wireframe: !0, - fog: !1, - toneMapped: !1 - }); - super(i, r); - this.light = e, this.light.updateMatrixWorld(), this.color = n, this.type = "PointLightHelper", this.matrix = this.light.matrixWorld, this.matrixAutoUpdate = !1, this.update(); - } - dispose() { - this.geometry.dispose(), this.material.dispose(); - } - update() { - this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color); - } -}, Py = new M, Nc = new ae, Bc = new ae, Iy = class extends Ne { - constructor(e, t, n){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n; - let i = new Ii(t); - i.rotateY(Math.PI * .5), this.material = new hn({ - wireframe: !0, - fog: !1, - toneMapped: !1 - }), this.color === void 0 && (this.material.vertexColors = !0); - let r = i.getAttribute("position"), o = new Float32Array(r.count * 3); - i.setAttribute("color", new Ue(o, 3)), this.add(new st(i, this.material)), this.update(); - } - dispose() { - this.children[0].geometry.dispose(), this.children[0].material.dispose(); - } - update() { - let e = this.children[0]; - if (this.color !== void 0) this.material.color.set(this.color); - else { - let t = e.geometry.getAttribute("color"); - Nc.copy(this.light.color), Bc.copy(this.light.groundColor); - for(let n = 0, i = t.count; n < i; n++){ - let r = n < i / 2 ? Nc : Bc; - t.setXYZ(n, r.r, r.g, r.b); - } - t.needsUpdate = !0; - } - e.lookAt(Py.setFromMatrixPosition(this.light.matrixWorld).negate()); - } -}, nu = class extends wt { - constructor(e = 10, t = 10, n = 4473924, i = 8947848){ - n = new ae(n), i = new ae(i); - let r = t / 2, o = e / t, a = e / 2, l = [], c = []; - for(let d = 0, f = 0, m = -a; d <= t; d++, m += o){ - l.push(-a, 0, m, a, 0, m), l.push(m, 0, -a, m, 0, a); - let x = d === r ? n : i; - x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3; - } - let h = new _e; - h.setAttribute("position", new de(l, 3)), h.setAttribute("color", new de(c, 3)); - let u = new ft({ - vertexColors: !0, - toneMapped: !1 - }); - super(h, u); - this.type = "GridHelper"; - } -}, Dy = class extends wt { - constructor(e = 10, t = 16, n = 8, i = 64, r = 4473924, o = 8947848){ - r = new ae(r), o = new ae(o); - let a = [], l = []; - for(let u = 0; u <= t; u++){ - let d = u / t * (Math.PI * 2), f = Math.sin(d) * e, m = Math.cos(d) * e; - a.push(0, 0, 0), a.push(f, 0, m); - let x = u & 1 ? r : o; - l.push(x.r, x.g, x.b), l.push(x.r, x.g, x.b); - } - for(let u = 0; u <= n; u++){ - let d = u & 1 ? r : o, f = e - e / n * u; - for(let m = 0; m < i; m++){ - let x = m / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f; - a.push(v, 0, g), l.push(d.r, d.g, d.b), x = (m + 1) / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f, a.push(v, 0, g), l.push(d.r, d.g, d.b); - } - } - let c = new _e; - c.setAttribute("position", new de(a, 3)), c.setAttribute("color", new de(l, 3)); - let h = new ft({ - vertexColors: !0, - toneMapped: !1 - }); - super(c, h); - this.type = "PolarGridHelper"; - } -}, zc = new M, As = new M, Uc = new M, Fy = class extends Ne { - constructor(e, t, n){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, t === void 0 && (t = 1); - let i = new _e; - i.setAttribute("position", new de([ - -t, - t, - 0, - t, - t, - 0, - t, - -t, - 0, - -t, - -t, - 0, - -t, - t, - 0 - ], 3)); - let r = new ft({ - fog: !1, - toneMapped: !1 - }); - this.lightPlane = new on(i, r), this.add(this.lightPlane), i = new _e, i.setAttribute("position", new de([ - 0, - 0, - 0, - 0, - 0, - 1 - ], 3)), this.targetLine = new on(i, r), this.add(this.targetLine), this.update(); - } - dispose() { - this.lightPlane.geometry.dispose(), this.lightPlane.material.dispose(), this.targetLine.geometry.dispose(), this.targetLine.material.dispose(); - } - update() { - zc.setFromMatrixPosition(this.light.matrixWorld), As.setFromMatrixPosition(this.light.target.matrixWorld), Uc.subVectors(As, zc), this.lightPlane.lookAt(As), this.color !== void 0 ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)) : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)), this.targetLine.lookAt(As), this.targetLine.scale.z = Uc.length(); - } -}, Cs = new M, Qe = new Ir, Ny = class extends wt { - constructor(e){ - let t = new _e, n = new ft({ - color: 16777215, - vertexColors: !0, - toneMapped: !1 - }), i = [], r = [], o = {}, a = new ae(16755200), l = new ae(16711680), c = new ae(43775), h = new ae(16777215), u = new ae(3355443); - d("n1", "n2", a), d("n2", "n4", a), d("n4", "n3", a), d("n3", "n1", a), d("f1", "f2", a), d("f2", "f4", a), d("f4", "f3", a), d("f3", "f1", a), d("n1", "f1", a), d("n2", "f2", a), d("n3", "f3", a), d("n4", "f4", a), d("p", "n1", l), d("p", "n2", l), d("p", "n3", l), d("p", "n4", l), d("u1", "u2", c), d("u2", "u3", c), d("u3", "u1", c), d("c", "t", h), d("p", "c", u), d("cn1", "cn2", u), d("cn3", "cn4", u), d("cf1", "cf2", u), d("cf3", "cf4", u); - function d(m, x, v) { - f(m, v), f(x, v); - } - function f(m, x) { - i.push(0, 0, 0), r.push(x.r, x.g, x.b), o[m] === void 0 && (o[m] = []), o[m].push(i.length / 3 - 1); - } - t.setAttribute("position", new de(i, 3)), t.setAttribute("color", new de(r, 3)); - super(t, n); - this.type = "CameraHelper", this.camera = e, this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.pointMap = o, this.update(); - } - update() { - let e = this.geometry, t = this.pointMap, n = 1, i = 1; - Qe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), et("c", t, e, Qe, 0, 0, -1), et("t", t, e, Qe, 0, 0, 1), et("n1", t, e, Qe, -n, -i, -1), et("n2", t, e, Qe, n, -i, -1), et("n3", t, e, Qe, -n, i, -1), et("n4", t, e, Qe, n, i, -1), et("f1", t, e, Qe, -n, -i, 1), et("f2", t, e, Qe, n, -i, 1), et("f3", t, e, Qe, -n, i, 1), et("f4", t, e, Qe, n, i, 1), et("u1", t, e, Qe, n * .7, i * 1.1, -1), et("u2", t, e, Qe, -n * .7, i * 1.1, -1), et("u3", t, e, Qe, 0, i * 2, -1), et("cf1", t, e, Qe, -n, 0, 1), et("cf2", t, e, Qe, n, 0, 1), et("cf3", t, e, Qe, 0, -i, 1), et("cf4", t, e, Qe, 0, i, 1), et("cn1", t, e, Qe, -n, 0, -1), et("cn2", t, e, Qe, n, 0, -1), et("cn3", t, e, Qe, 0, -i, -1), et("cn4", t, e, Qe, 0, i, -1), e.getAttribute("position").needsUpdate = !0; - } - dispose() { - this.geometry.dispose(), this.material.dispose(); - } -}; -function et(s, e, t, n, i, r, o) { - Cs.set(i, r, o).unproject(n); - let a = e[s]; - if (a !== void 0) { - let l = t.getAttribute("position"); - for(let c = 0, h = a.length; c < h; c++)l.setXYZ(a[c], Cs.x, Cs.y, Cs.z); - } -} -var Ls = new Lt, iu = class extends wt { - constructor(e, t = 16776960){ - let n = new Uint16Array([ - 0, - 1, - 1, - 2, - 2, - 3, - 3, - 0, - 4, - 5, - 5, - 6, - 6, - 7, - 7, - 4, - 0, - 4, - 1, - 5, - 2, - 6, - 3, - 7 - ]), i = new Float32Array(8 * 3), r = new _e; - r.setIndex(new Ue(n, 1)), r.setAttribute("position", new Ue(i, 3)); - super(r, new ft({ - color: t, - toneMapped: !1 - })); - this.object = e, this.type = "BoxHelper", this.matrixAutoUpdate = !1, this.update(); - } - update(e) { - if (e !== void 0 && console.warn("THREE.BoxHelper: .update() has no longer arguments."), this.object !== void 0 && Ls.setFromObject(this.object), Ls.isEmpty()) return; - let t = Ls.min, n = Ls.max, i = this.geometry.attributes.position, r = i.array; - r[0] = n.x, r[1] = n.y, r[2] = n.z, r[3] = t.x, r[4] = n.y, r[5] = n.z, r[6] = t.x, r[7] = t.y, r[8] = n.z, r[9] = n.x, r[10] = t.y, r[11] = n.z, r[12] = n.x, r[13] = n.y, r[14] = t.z, r[15] = t.x, r[16] = n.y, r[17] = t.z, r[18] = t.x, r[19] = t.y, r[20] = t.z, r[21] = n.x, r[22] = t.y, r[23] = t.z, i.needsUpdate = !0, this.geometry.computeBoundingSphere(); - } - setFromObject(e) { - return this.object = e, this.update(), this; - } - copy(e) { - return wt.prototype.copy.call(this, e), this.object = e.object, this; - } -}, By = class extends wt { - constructor(e, t = 16776960){ - let n = new Uint16Array([ - 0, - 1, - 1, - 2, - 2, - 3, - 3, - 0, - 4, - 5, - 5, - 6, - 6, - 7, - 7, - 4, - 0, - 4, - 1, - 5, - 2, - 6, - 3, - 7 - ]), i = [ - 1, - 1, - 1, - -1, - 1, - 1, - -1, - -1, - 1, - 1, - -1, - 1, - 1, - 1, - -1, - -1, - 1, - -1, - -1, - -1, - -1, - 1, - -1, - -1 - ], r = new _e; - r.setIndex(new Ue(n, 1)), r.setAttribute("position", new de(i, 3)); - super(r, new ft({ - color: t, - toneMapped: !1 - })); - this.box = e, this.type = "Box3Helper", this.geometry.computeBoundingSphere(); - } - updateMatrixWorld(e) { - let t = this.box; - t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(.5), super.updateMatrixWorld(e)); - } -}, zy = class extends on { - constructor(e, t = 1, n = 16776960){ - let i = n, r = [ - 1, - -1, - 1, - -1, - 1, - 1, - -1, - -1, - 1, - 1, - 1, - 1, - -1, - 1, - 1, - -1, - -1, - 1, - 1, - -1, - 1, - 1, - 1, - 1, - 0, - 0, - 1, - 0, - 0, - 0 - ], o = new _e; - o.setAttribute("position", new de(r, 3)), o.computeBoundingSphere(); - super(o, new ft({ - color: i, - toneMapped: !1 - })); - this.type = "PlaneHelper", this.plane = e, this.size = t; - let a = [ - 1, - 1, - 1, - -1, - 1, - 1, - -1, - -1, - 1, - 1, - 1, - 1, - -1, - -1, - 1, - 1, - -1, - 1 - ], l = new _e; - l.setAttribute("position", new de(a, 3)), l.computeBoundingSphere(), this.add(new st(l, new hn({ - color: i, - opacity: .2, - transparent: !0, - depthWrite: !1, - toneMapped: !1 - }))); - } - updateMatrixWorld(e) { - let t = -this.plane.constant; - Math.abs(t) < 1e-8 && (t = 1e-8), this.scale.set(.5 * this.size, .5 * this.size, t), this.children[0].material.side = t < 0 ? it : Ai, this.lookAt(this.plane.normal), super.updateMatrixWorld(e); - } -}, Oc = new M, Rs, Ko, Uy = class extends Ne { - constructor(e = new M(0, 0, 1), t = new M(0, 0, 0), n = 1, i = 16776960, r = n * .2, o = r * .2){ - super(); - this.type = "ArrowHelper", Rs === void 0 && (Rs = new _e, Rs.setAttribute("position", new de([ - 0, - 0, - 0, - 0, - 1, - 0 - ], 3)), Ko = new Jn(0, .5, 1, 5, 1), Ko.translate(0, -.5, 0)), this.position.copy(t), this.line = new on(Rs, new ft({ - color: i, - toneMapped: !1 - })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new st(Ko, new hn({ - color: i, - toneMapped: !1 - })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(e), this.setLength(n, r, o); - } - setDirection(e) { - if (e.y > .99999) this.quaternion.set(0, 0, 0, 1); - else if (e.y < -.99999) this.quaternion.set(1, 0, 0, 0); - else { - Oc.set(e.z, 0, -e.x).normalize(); - let t = Math.acos(e.y); - this.quaternion.setFromAxisAngle(Oc, t); - } - } - setLength(e, t = e * .2, n = t * .2) { - this.line.scale.set(1, Math.max(1e-4, e - t), 1), this.line.updateMatrix(), this.cone.scale.set(n, t, n), this.cone.position.y = e, this.cone.updateMatrix(); - } - setColor(e) { - this.line.material.color.set(e), this.cone.material.color.set(e); - } - copy(e) { - return super.copy(e, !1), this.line.copy(e.line), this.cone.copy(e.cone), this; - } -}, ru = class extends wt { - constructor(e = 1){ - let t = [ - 0, - 0, - 0, - e, - 0, - 0, - 0, - 0, - 0, - 0, - e, - 0, - 0, - 0, - 0, - 0, - 0, - e - ], n = [ - 1, - 0, - 0, - 1, - .6, - 0, - 0, - 1, - 0, - .6, - 1, - 0, - 0, - 0, - 1, - 0, - .6, - 1 - ], i = new _e; - i.setAttribute("position", new de(t, 3)), i.setAttribute("color", new de(n, 3)); - let r = new ft({ - vertexColors: !0, - toneMapped: !1 - }); - super(i, r); - this.type = "AxesHelper"; - } - setColors(e, t, n) { - let i = new ae, r = this.geometry.attributes.color.array; - return i.set(e), i.toArray(r, 0), i.toArray(r, 3), i.set(t), i.toArray(r, 6), i.toArray(r, 9), i.set(n), i.toArray(r, 12), i.toArray(r, 15), this.geometry.attributes.color.needsUpdate = !0, this; - } - dispose() { - this.geometry.dispose(), this.material.dispose(); - } -}, Oy = class { - constructor(){ - this.type = "ShapePath", this.color = new ae, this.subPaths = [], this.currentPath = null; - } - moveTo(e, t) { - return this.currentPath = new gr, this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this; - } - lineTo(e, t) { - return this.currentPath.lineTo(e, t), this; - } - quadraticCurveTo(e, t, n, i) { - return this.currentPath.quadraticCurveTo(e, t, n, i), this; - } - bezierCurveTo(e, t, n, i, r, o) { - return this.currentPath.bezierCurveTo(e, t, n, i, r, o), this; - } - splineThru(e) { - return this.currentPath.splineThru(e), this; - } - toShapes(e, t) { - function n(p) { - let _ = []; - for(let y = 0, b = p.length; y < b; y++){ - let A = p[y], L = new Xt; - L.curves = A.curves, _.push(L); - } - return _; - } - function i(p, _) { - let y = _.length, b = !1; - for(let A = y - 1, L = 0; L < y; A = L++){ - let I = _[A], k = _[L], B = k.x - I.x, P = k.y - I.y; - if (Math.abs(P) > Number.EPSILON) { - if (P < 0 && (I = _[L], B = -B, k = _[A], P = -P), p.y < I.y || p.y > k.y) continue; - if (p.y === I.y) { - if (p.x === I.x) return !0; - } else { - let w = P * (p.x - I.x) - B * (p.y - I.y); - if (w === 0) return !0; - if (w < 0) continue; - b = !b; - } - } else { - if (p.y !== I.y) continue; - if (k.x <= p.x && p.x <= I.x || I.x <= p.x && p.x <= k.x) return !0; - } - } - return b; - } - let r = Jt.isClockWise, o = this.subPaths; - if (o.length === 0) return []; - if (t === !0) return n(o); - let a, l, c, h = []; - if (o.length === 1) return l = o[0], c = new Xt, c.curves = l.curves, h.push(c), h; - let u = !r(o[0].getPoints()); - u = e ? !u : u; - let d = [], f = [], m = [], x = 0, v; - f[x] = void 0, m[x] = []; - for(let p = 0, _ = o.length; p < _; p++)l = o[p], v = l.getPoints(), a = r(v), a = e ? !a : a, a ? (!u && f[x] && x++, f[x] = { - s: new Xt, - p: v - }, f[x].s.curves = l.curves, u && x++, m[x] = []) : m[x].push({ - h: l, - p: v[0] - }); - if (!f[0]) return n(o); - if (f.length > 1) { - let p = !1, _ = []; - for(let y = 0, b = f.length; y < b; y++)d[y] = []; - for(let y = 0, b = f.length; y < b; y++){ - let A = m[y]; - for(let L = 0; L < A.length; L++){ - let I = A[L], k = !0; - for(let B = 0; B < f.length; B++)i(I.p, f[B].p) && (y !== B && _.push({ - froms: y, - tos: B, - hole: L - }), k ? (k = !1, d[B].push(I)) : p = !0); - k && d[y].push(I); - } - } - _.length > 0 && (p || (m = d)); - } - let g; - for(let p = 0, _ = f.length; p < _; p++){ - c = f[p].s, h.push(c), g = m[p]; - for(let y = 0, b = g.length; y < b; y++)c.holes.push(g[y].h); - } - return h; - } -}, su = new Float32Array(1), Hy = new Int32Array(su.buffer), ky = class { - static toHalfFloat(e) { - e > 65504 && (console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."), e = 65504), su[0] = e; - let t = Hy[0], n = t >> 16 & 32768, i = t >> 12 & 2047, r = t >> 23 & 255; - return r < 103 ? n : r > 142 ? (n |= 31744, n |= (r == 255 ? 0 : 1) && t & 8388607, n) : r < 113 ? (i |= 2048, n |= (i >> 114 - r) + (i >> 113 - r & 1), n) : (n |= r - 112 << 10 | i >> 1, n += i & 1, n); - } -}, b0 = 0, w0 = 1, S0 = 0, T0 = 1, E0 = 2; -function A0(s) { - return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."), s; -} -function C0(s = []) { - return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."), s.isMultiMaterial = !0, s.materials = s, s.clone = function() { - return s.slice(); - }, s; -} -function L0(s, e) { - return console.warn("THREE.PointCloud has been renamed to THREE.Points."), new zr(s, e); -} -function R0(s) { - return console.warn("THREE.Particle has been renamed to THREE.Sprite."), new ro(s); -} -function P0(s, e) { - return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."), new zr(s, e); -} -function I0(s) { - return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function D0(s) { - return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function F0(s) { - return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function N0(s, e, t) { - return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."), new M(s, e, t); -} -function B0(s, e) { - return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."), new Ue(s, e).setUsage(ur); -} -function z0(s, e) { - return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."), new jc(s, e); -} -function U0(s, e) { - return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."), new Qc(s, e); -} -function O0(s, e) { - return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."), new Kc(s, e); -} -function H0(s, e) { - return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."), new eh(s, e); -} -function k0(s, e) { - return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."), new Ys(s, e); -} -function G0(s, e) { - return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."), new th(s, e); -} -function V0(s, e) { - return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."), new Zs(s, e); -} -function W0(s, e) { - return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."), new de(s, e); -} -function q0(s, e) { - return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."), new ih(s, e); -} -Ct.create = function(s, e) { - return console.log("THREE.Curve.create() has been deprecated"), s.prototype = Object.create(Ct.prototype), s.prototype.constructor = s, s.prototype.getPoint = e, s; -}; -gr.prototype.fromPoints = function(s) { - return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."), this.setFromPoints(s); -}; -function X0(s) { - return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."), new ru(s); -} -function J0(s, e) { - return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."), new iu(s, e); -} -function Y0(s, e) { - return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."), new wt(new _a(s.geometry), new ft({ - color: e !== void 0 ? e : 16777215 - })); -} -nu.prototype.setColors = function() { - console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead."); -}; -eu.prototype.update = function() { - console.error("THREE.SkeletonHelper: update() no longer needs to be called."); -}; -function Z0(s, e) { - return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."), new wt(new Ea(s.geometry), new ft({ - color: e !== void 0 ? e : 16777215 - })); -} -bt.prototype.extractUrlBase = function(s) { - return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."), Gs.extractUrlBase(s); -}; -bt.Handlers = { - add: function() { - console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead."); - }, - get: function() { - console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead."); - } -}; -function $0(s) { - return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."), new Yt(s); -} -function j0(s) { - return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."), new Nh(s); -} -qi.prototype.center = function(s) { - return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -qi.prototype.empty = function() { - return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -qi.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -qi.prototype.size = function(s) { - return console.warn("THREE.Box2: .size() has been renamed to .getSize()."), this.getSize(s); -}; -Lt.prototype.center = function(s) { - return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -Lt.prototype.empty = function() { - return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -Lt.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -Lt.prototype.isIntersectionSphere = function(s) { - return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); -}; -Lt.prototype.size = function(s) { - return console.warn("THREE.Box3: .size() has been renamed to .getSize()."), this.getSize(s); -}; -An.prototype.empty = function() { - return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -Dr.prototype.setFromMatrix = function(s) { - return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."), this.setFromProjectionMatrix(s); -}; -Kh.prototype.center = function(s) { - return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -lt.prototype.flattenToArrayOffset = function(s, e) { - return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); -}; -lt.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); -}; -lt.prototype.multiplyVector3Array = function() { - console.error("THREE.Matrix3: .multiplyVector3Array() has been removed."); -}; -lt.prototype.applyToBufferAttribute = function(s) { - return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); -}; -lt.prototype.applyToVector3Array = function() { - console.error("THREE.Matrix3: .applyToVector3Array() has been removed."); -}; -lt.prototype.getInverse = function(s) { - return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); -}; -pe.prototype.extractPosition = function(s) { - return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."), this.copyPosition(s); -}; -pe.prototype.flattenToArrayOffset = function(s, e) { - return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); -}; -pe.prototype.getPosition = function() { - return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."), new M().setFromMatrixColumn(this, 3); -}; -pe.prototype.setRotationFromQuaternion = function(s) { - return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."), this.makeRotationFromQuaternion(s); -}; -pe.prototype.multiplyToArray = function() { - console.warn("THREE.Matrix4: .multiplyToArray() has been removed."); -}; -pe.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.multiplyVector4 = function(s) { - return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.multiplyVector3Array = function() { - console.error("THREE.Matrix4: .multiplyVector3Array() has been removed."); -}; -pe.prototype.rotateAxis = function(s) { - console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."), s.transformDirection(this); -}; -pe.prototype.crossVector = function(s) { - return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.translate = function() { - console.error("THREE.Matrix4: .translate() has been removed."); -}; -pe.prototype.rotateX = function() { - console.error("THREE.Matrix4: .rotateX() has been removed."); -}; -pe.prototype.rotateY = function() { - console.error("THREE.Matrix4: .rotateY() has been removed."); -}; -pe.prototype.rotateZ = function() { - console.error("THREE.Matrix4: .rotateZ() has been removed."); -}; -pe.prototype.rotateByAxis = function() { - console.error("THREE.Matrix4: .rotateByAxis() has been removed."); -}; -pe.prototype.applyToBufferAttribute = function(s) { - return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.applyToVector3Array = function() { - console.error("THREE.Matrix4: .applyToVector3Array() has been removed."); -}; -pe.prototype.makeFrustum = function(s, e, t, n, i, r) { - return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."), this.makePerspective(s, e, n, t, i, r); -}; -pe.prototype.getInverse = function(s) { - return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); -}; -Wt.prototype.isIntersectionLine = function(s) { - return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."), this.intersectsLine(s); -}; -gt.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."), s.applyQuaternion(this); -}; -gt.prototype.inverse = function() { - return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."), this.invert(); -}; -Cn.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -Cn.prototype.isIntersectionPlane = function(s) { - return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."), this.intersectsPlane(s); -}; -Cn.prototype.isIntersectionSphere = function(s) { - return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); -}; -nt.prototype.area = function() { - return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."), this.getArea(); -}; -nt.prototype.barycoordFromPoint = function(s, e) { - return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), this.getBarycoord(s, e); -}; -nt.prototype.midpoint = function(s) { - return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."), this.getMidpoint(s); -}; -nt.prototypenormal = function(s) { - return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), this.getNormal(s); -}; -nt.prototype.plane = function(s) { - return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."), this.getPlane(s); -}; -nt.barycoordFromPoint = function(s, e, t, n, i) { - return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), nt.getBarycoord(s, e, t, n, i); -}; -nt.normal = function(s, e, t, n) { - return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), nt.getNormal(s, e, t, n); -}; -Xt.prototype.extractAllPoints = function(s) { - return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."), this.extractPoints(s); -}; -Xt.prototype.extrude = function(s) { - return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."), new ln(this, s); -}; -Xt.prototype.makeGeometry = function(s) { - return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."), new Di(this, s); -}; -X.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -X.prototype.distanceToManhattan = function(s) { - return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); -}; -X.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -M.prototype.setEulerFromRotationMatrix = function() { - console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead."); -}; -M.prototype.setEulerFromQuaternion = function() { - console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead."); -}; -M.prototype.getPositionFromMatrix = function(s) { - return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."), this.setFromMatrixPosition(s); -}; -M.prototype.getScaleFromMatrix = function(s) { - return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."), this.setFromMatrixScale(s); -}; -M.prototype.getColumnFromMatrix = function(s, e) { - return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."), this.setFromMatrixColumn(e, s); -}; -M.prototype.applyProjection = function(s) { - return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."), this.applyMatrix4(s); -}; -M.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -M.prototype.distanceToManhattan = function(s) { - return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); -}; -M.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -Ve.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -Ve.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -Ne.prototype.getChildByName = function(s) { - return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."), this.getObjectByName(s); -}; -Ne.prototype.renderDepth = function() { - console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead."); -}; -Ne.prototype.translate = function(s, e) { - return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."), this.translateOnAxis(e, s); -}; -Ne.prototype.getWorldRotation = function() { - console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead."); -}; -Ne.prototype.applyMatrix = function(s) { - return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); -}; -Object.defineProperties(Ne.prototype, { - eulerOrder: { - get: function() { - return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order; - }, - set: function(s) { - console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order = s; - } - }, - useQuaternion: { - get: function() { - console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); - }, - set: function() { - console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); - } - } -}); -st.prototype.setDrawMode = function() { - console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); -}; -Object.defineProperties(st.prototype, { - drawMode: { - get: function() { - return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."), Fd; - }, - set: function() { - console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); - } - } -}); -so.prototype.initBones = function() { - console.error("THREE.SkinnedMesh: initBones() has been removed."); -}; -ut.prototype.setLens = function(s, e) { - console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."), e !== void 0 && (this.filmGauge = e), this.setFocalLength(s); -}; -Object.defineProperties(Bt.prototype, { - onlyShadow: { - set: function() { - console.warn("THREE.Light: .onlyShadow has been removed."); - } - }, - shadowCameraFov: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."), this.shadow.camera.fov = s; - } - }, - shadowCameraLeft: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."), this.shadow.camera.left = s; - } - }, - shadowCameraRight: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."), this.shadow.camera.right = s; - } - }, - shadowCameraTop: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."), this.shadow.camera.top = s; - } - }, - shadowCameraBottom: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."), this.shadow.camera.bottom = s; - } - }, - shadowCameraNear: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."), this.shadow.camera.near = s; - } - }, - shadowCameraFar: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."), this.shadow.camera.far = s; - } - }, - shadowCameraVisible: { - set: function() { - console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead."); - } - }, - shadowBias: { - set: function(s) { - console.warn("THREE.Light: .shadowBias is now .shadow.bias."), this.shadow.bias = s; - } - }, - shadowDarkness: { - set: function() { - console.warn("THREE.Light: .shadowDarkness has been removed."); - } - }, - shadowMapWidth: { - set: function(s) { - console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."), this.shadow.mapSize.width = s; - } - }, - shadowMapHeight: { - set: function(s) { - console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."), this.shadow.mapSize.height = s; - } - } -}); -Object.defineProperties(Ue.prototype, { - length: { - get: function() { - return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."), this.array.length; - } - }, - dynamic: { - get: function() { - return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.usage === ur; - }, - set: function() { - console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.setUsage(ur); - } - } -}); -Ue.prototype.setDynamic = function(s) { - return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; -}; -Ue.prototype.copyIndicesArray = function() { - console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed."); -}, Ue.prototype.setArray = function() { - console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); -}; -_e.prototype.addIndex = function(s) { - console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."), this.setIndex(s); -}; -_e.prototype.addAttribute = function(s, e) { - return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."), !(e && e.isBufferAttribute) && !(e && e.isInterleavedBufferAttribute) ? (console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."), this.setAttribute(s, new Ue(arguments[1], arguments[2]))) : s === "index" ? (console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."), this.setIndex(e), this) : this.setAttribute(s, e); -}; -_e.prototype.addDrawCall = function(s, e, t) { - t !== void 0 && console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."), console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."), this.addGroup(s, e); -}; -_e.prototype.clearDrawCalls = function() { - console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."), this.clearGroups(); -}; -_e.prototype.computeOffsets = function() { - console.warn("THREE.BufferGeometry: .computeOffsets() has been removed."); -}; -_e.prototype.removeAttribute = function(s) { - return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."), this.deleteAttribute(s); -}; -_e.prototype.applyMatrix = function(s) { - return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); -}; -Object.defineProperties(_e.prototype, { - drawcalls: { - get: function() { - return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."), this.groups; - } - }, - offsets: { - get: function() { - return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."), this.groups; - } - } -}); -$n.prototype.setDynamic = function(s) { - return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; -}; -$n.prototype.setArray = function() { - console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); -}; -ln.prototype.getArrays = function() { - console.error("THREE.ExtrudeGeometry: .getArrays() has been removed."); -}; -ln.prototype.addShapeList = function() { - console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed."); -}; -ln.prototype.addShape = function() { - console.error("THREE.ExtrudeGeometry: .addShape() has been removed."); -}; -no.prototype.dispose = function() { - console.error("THREE.Scene: .dispose() has been removed."); -}; -go.prototype.onUpdate = function() { - return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."), this; -}; -Object.defineProperties(dt.prototype, { - wrapAround: { - get: function() { - console.warn("THREE.Material: .wrapAround has been removed."); - }, - set: function() { - console.warn("THREE.Material: .wrapAround has been removed."); - } - }, - overdraw: { - get: function() { - console.warn("THREE.Material: .overdraw has been removed."); - }, - set: function() { - console.warn("THREE.Material: .overdraw has been removed."); - } - }, - wrapRGB: { - get: function() { - return console.warn("THREE.Material: .wrapRGB has been removed."), new ae; - } - }, - shading: { - get: function() { - console.error("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."); - }, - set: function(s) { - console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = s === kc; - } - }, - stencilMask: { - get: function() { - return console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask; - }, - set: function(s) { - console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask = s; - } - }, - vertexTangents: { - get: function() { - console.warn("THREE." + this.type + ": .vertexTangents has been removed."); - }, - set: function() { - console.warn("THREE." + this.type + ": .vertexTangents has been removed."); - } - } -}); -Object.defineProperties(sn.prototype, { - derivatives: { - get: function() { - return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives; - }, - set: function(s) { - console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives = s; - } - } -}); -qe.prototype.clearTarget = function(s, e, t, n) { - console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."), this.setRenderTarget(s), this.clear(e, t, n); -}; -qe.prototype.animate = function(s) { - console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."), this.setAnimationLoop(s); -}; -qe.prototype.getCurrentRenderTarget = function() { - return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."), this.getRenderTarget(); -}; -qe.prototype.getMaxAnisotropy = function() { - return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."), this.capabilities.getMaxAnisotropy(); -}; -qe.prototype.getPrecision = function() { - return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."), this.capabilities.precision; -}; -qe.prototype.resetGLState = function() { - return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."), this.state.reset(); -}; -qe.prototype.supportsFloatTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."), this.extensions.get("OES_texture_float"); -}; -qe.prototype.supportsHalfFloatTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."), this.extensions.get("OES_texture_half_float"); -}; -qe.prototype.supportsStandardDerivatives = function() { - return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."), this.extensions.get("OES_standard_derivatives"); -}; -qe.prototype.supportsCompressedTextureS3TC = function() { - return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."), this.extensions.get("WEBGL_compressed_texture_s3tc"); -}; -qe.prototype.supportsCompressedTexturePVRTC = function() { - return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."), this.extensions.get("WEBGL_compressed_texture_pvrtc"); -}; -qe.prototype.supportsBlendMinMax = function() { - return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."), this.extensions.get("EXT_blend_minmax"); -}; -qe.prototype.supportsVertexTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."), this.capabilities.vertexTextures; -}; -qe.prototype.supportsInstancedArrays = function() { - return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."), this.extensions.get("ANGLE_instanced_arrays"); -}; -qe.prototype.enableScissorTest = function(s) { - console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."), this.setScissorTest(s); -}; -qe.prototype.initMaterial = function() { - console.warn("THREE.WebGLRenderer: .initMaterial() has been removed."); -}; -qe.prototype.addPrePlugin = function() { - console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed."); -}; -qe.prototype.addPostPlugin = function() { - console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed."); -}; -qe.prototype.updateShadowMap = function() { - console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed."); -}; -qe.prototype.setFaceCulling = function() { - console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed."); -}; -qe.prototype.allocTextureUnit = function() { - console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed."); -}; -qe.prototype.setTexture = function() { - console.warn("THREE.WebGLRenderer: .setTexture() has been removed."); -}; -qe.prototype.setTexture2D = function() { - console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed."); -}; -qe.prototype.setTextureCube = function() { - console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed."); -}; -qe.prototype.getActiveMipMapLevel = function() { - return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."), this.getActiveMipmapLevel(); -}; -Object.defineProperties(qe.prototype, { - shadowMapEnabled: { - get: function() { - return this.shadowMap.enabled; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."), this.shadowMap.enabled = s; - } - }, - shadowMapType: { - get: function() { - return this.shadowMap.type; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."), this.shadowMap.type = s; - } - }, - shadowMapCullFace: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); - } - }, - context: { - get: function() { - return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."), this.getContext(); - } - }, - vr: { - get: function() { - return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"), this.xr; - } - }, - gammaInput: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."), !1; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."); - } - }, - gammaOutput: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), !1; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), this.outputEncoding = s === !0 ? Oi : Nt; - } - }, - toneMappingWhitePoint: { - get: function() { - return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."), 1; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."); - } - }, - gammaFactor: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."), 2; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."); - } - } -}); -Object.defineProperties(yh.prototype, { - cullFace: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); - } - }, - renderReverseSided: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); - } - }, - renderSingleSided: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); - } - } -}); -function Q0(s, e, t) { - return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."), new js(s, t); -} -Object.defineProperties(At.prototype, { - wrapS: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS = s; - } - }, - wrapT: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT = s; - } - }, - magFilter: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter = s; - } - }, - minFilter: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter = s; - } - }, - anisotropy: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy = s; - } - }, - offset: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset = s; - } - }, - repeat: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat = s; - } - }, - format: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format = s; - } - }, - type: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type = s; - } - }, - generateMipmaps: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps = s; - } - } -}); -Za.prototype.load = function(s) { - console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead."); - let e = this; - return new kh().load(s, function(n) { - e.setBuffer(n); - }), this; -}; -qh.prototype.getData = function() { - return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."), this.getFrequencyData(); -}; -$s.prototype.updateCubeMap = function(s, e) { - return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."), this.update(s, e); -}; -$s.prototype.clear = function(s, e, t, n) { - return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."), this.renderTarget.clear(s, e, t, n); -}; -Yn.crossOrigin = void 0; -Yn.loadTexture = function(s, e, t, n) { - console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead."); - let i = new Bh; - i.setCrossOrigin(this.crossOrigin); - let r = i.load(s, t, void 0, n); - return e && (r.mapping = e), r; -}; -Yn.loadTextureCube = function(s, e, t, n) { - console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead."); - let i = new Fh; - i.setCrossOrigin(this.crossOrigin); - let r = i.load(s, t, void 0, n); - return e && (r.mapping = e), r; -}; -Yn.loadCompressedTexture = function() { - console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead."); -}; -Yn.loadCompressedTextureCube = function() { - console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead."); -}; -function K0() { - console.error("THREE.CanvasRenderer has been removed"); -} -function ev() { - console.error("THREE.JSONLoader has been removed."); -} -var tv = { - createMultiMaterialObject: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); - }, - detach: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); - }, - attach: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); - } -}; -function nv() { - console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js"); -} -function iv() { - return console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"), new _e; -} -function rv() { - return console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"), new _e; -} -function sv() { - console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js"); -} -function ov() { - console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js"); -} -function av() { - console.error("THREE.ImmediateRenderObject has been removed."); -} -typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { - detail: { - revision: ca - } -})); -typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = ca); -const mod = { - ACESFilmicToneMapping: Uu, - AddEquation: _i, - AddOperation: Fu, - AdditiveAnimationBlendMode: qc, - AdditiveBlending: nl, - AlphaFormat: Xu, - AlwaysDepth: Au, - AlwaysStencilFunc: Ud, - AmbientLight: qa, - AmbientLightProbe: Vh, - AnimationClip: Lr, - AnimationLoader: cy, - AnimationMixer: $h, - AnimationObjectGroup: Yh, - AnimationUtils: Ze, - ArcCurve: Ma, - ArrayCamera: ga, - ArrowHelper: Uy, - Audio: Za, - AudioAnalyser: qh, - AudioContext: Hh, - AudioListener: my, - AudioLoader: kh, - AxesHelper: ru, - AxisHelper: X0, - BackSide: it, - BasicDepthPacking: Nd, - BasicShadowMap: qy, - BinaryTextureLoader: j0, - Bone: oo, - BooleanKeyframeTrack: Qn, - BoundingBoxHelper: J0, - Box2: qi, - Box3: Lt, - Box3Helper: By, - BoxBufferGeometry: wn, - BoxGeometry: wn, - BoxHelper: iu, - BufferAttribute: Ue, - BufferGeometry: _e, - BufferGeometryLoader: Uh, - ByteType: Hu, - Cache: Ni, - Camera: Ir, - CameraHelper: Ny, - CanvasRenderer: K0, - CanvasTexture: Th, - CatmullRomCurve3: wa, - CineonToneMapping: zu, - CircleBufferGeometry: fr, - CircleGeometry: fr, - ClampToEdgeWrapping: vt, - Clock: Wh, - Color: ae, - ColorKeyframeTrack: Ba, - CompressedTexture: va, - CompressedTextureLoader: hy, - ConeBufferGeometry: pr, - ConeGeometry: pr, - CubeCamera: $s, - CubeReflectionMapping: Bi, - CubeRefractionMapping: zi, - CubeTexture: ki, - CubeTextureLoader: Fh, - CubeUVReflectionMapping: Pr, - CubeUVRefractionMapping: Ws, - CubicBezierCurve: lo, - CubicBezierCurve3: Sa, - CubicInterpolant: Ph, - CullFaceBack: tl, - CullFaceFront: du, - CullFaceFrontBack: Wy, - CullFaceNone: uu, - Curve: Ct, - CurvePath: Ah, - CustomBlending: pu, - CustomToneMapping: Ou, - CylinderBufferGeometry: Jn, - CylinderGeometry: Jn, - Cylindrical: Cy, - DataTexture: qn, - DataTexture2DArray: Qs, - DataTexture3D: ma, - DataTextureLoader: Nh, - DataUtils: ky, - DecrementStencilOp: n0, - DecrementWrapStencilOp: r0, - DefaultLoadingManager: ly, - DepthFormat: Vn, - DepthStencilFormat: Li, - DepthTexture: ks, - DirectionalLight: Wa, - DirectionalLightHelper: Fy, - DiscreteInterpolant: Ih, - DodecahedronBufferGeometry: mr, - DodecahedronGeometry: mr, - DoubleSide: Ci, - DstAlphaFactor: Mu, - DstColorFactor: wu, - DynamicBufferAttribute: B0, - DynamicCopyUsage: y0, - DynamicDrawUsage: ur, - DynamicReadUsage: m0, - EdgesGeometry: _a, - EdgesHelper: Y0, - EllipseCurve: Ur, - EqualDepth: Lu, - EqualStencilFunc: l0, - EquirectangularReflectionMapping: Ds, - EquirectangularRefractionMapping: Fs, - Euler: Zn, - EventDispatcher: En, - ExtrudeBufferGeometry: ln, - ExtrudeGeometry: ln, - FaceColors: T0, - FileLoader: Yt, - FlatShading: kc, - Float16BufferAttribute: nh, - Float32Attribute: W0, - Float32BufferAttribute: de, - Float64Attribute: q0, - Float64BufferAttribute: ih, - FloatType: nn, - Fog: Br, - FogExp2: Nr, - Font: ov, - FontLoader: sv, - FramebufferTexture: Sh, - FrontSide: Ai, - Frustum: Dr, - GLBufferAttribute: Qh, - GLSL1: _0, - GLSL3: xl, - GreaterDepth: Pu, - GreaterEqualDepth: Ru, - GreaterEqualStencilFunc: d0, - GreaterStencilFunc: h0, - GridHelper: nu, - Group: Hn, - HalfFloatType: kn, - HemisphereLight: Ua, - HemisphereLightHelper: Iy, - HemisphereLightProbe: Gh, - IcosahedronBufferGeometry: _r, - IcosahedronGeometry: _r, - ImageBitmapLoader: Oh, - ImageLoader: Rr, - ImageUtils: Yn, - ImmediateRenderObject: av, - IncrementStencilOp: t0, - IncrementWrapStencilOp: i0, - InstancedBufferAttribute: Xn, - InstancedBufferGeometry: Ya, - InstancedInterleavedBuffer: jh, - InstancedMesh: xa, - Int16Attribute: H0, - Int16BufferAttribute: eh, - Int32Attribute: G0, - Int32BufferAttribute: th, - Int8Attribute: z0, - Int8BufferAttribute: jc, - IntType: Gu, - InterleavedBuffer: $n, - InterleavedBufferAttribute: Sn, - Interpolant: cn, - InterpolateDiscrete: zs, - InterpolateLinear: Us, - InterpolateSmooth: yo, - InvertStencilOp: s0, - JSONLoader: ev, - KeepStencilOp: vo, - KeyframeTrack: zt, - LOD: bh, - LatheBufferGeometry: Mr, - LatheGeometry: Mr, - Layers: Js, - LensFlare: nv, - LessDepth: Cu, - LessEqualDepth: ea, - LessEqualStencilFunc: c0, - LessStencilFunc: a0, - Light: Bt, - LightProbe: Hr, - Line: on, - Line3: Kh, - LineBasicMaterial: ft, - LineCurve: Or, - LineCurve3: Eh, - LineDashedMaterial: Fa, - LineLoop: ya, - LinePieces: w0, - LineSegments: wt, - LineStrip: b0, - LinearEncoding: Nt, - LinearFilter: tt, - LinearInterpolant: Na, - LinearMipMapLinearFilter: $y, - LinearMipMapNearestFilter: Zy, - LinearMipmapLinearFilter: Ui, - LinearMipmapNearestFilter: Wc, - LinearToneMapping: Nu, - Loader: bt, - LoaderUtils: Gs, - LoadingManager: za, - LoopOnce: Pd, - LoopPingPong: Dd, - LoopRepeat: Id, - LuminanceAlphaFormat: Yu, - LuminanceFormat: Ju, - MOUSE: Gy, - Material: dt, - MaterialLoader: zh, - Math: M0, - MathUtils: M0, - Matrix3: lt, - Matrix4: pe, - MaxEquation: ol, - Mesh: st, - MeshBasicMaterial: hn, - MeshDepthMaterial: eo, - MeshDistanceMaterial: to, - MeshFaceMaterial: A0, - MeshLambertMaterial: Ia, - MeshMatcapMaterial: Da, - MeshNormalMaterial: Pa, - MeshPhongMaterial: La, - MeshPhysicalMaterial: Ca, - MeshStandardMaterial: po, - MeshToonMaterial: Ra, - MinEquation: sl, - MirroredRepeatWrapping: Bs, - MixOperation: Du, - MultiMaterial: C0, - MultiplyBlending: rl, - MultiplyOperation: Vs, - NearestFilter: rt, - NearestMipMapLinearFilter: Yy, - NearestMipMapNearestFilter: Jy, - NearestMipmapLinearFilter: na, - NearestMipmapNearestFilter: ta, - NeverDepth: Eu, - NeverStencilFunc: o0, - NoBlending: vn, - NoColors: S0, - NoToneMapping: _n, - NormalAnimationBlendMode: ua, - NormalBlending: sr, - NotEqualDepth: Iu, - NotEqualStencilFunc: u0, - NumberKeyframeTrack: Ar, - Object3D: Ne, - ObjectLoader: uy, - ObjectSpaceNormalMap: zd, - OctahedronBufferGeometry: Ii, - OctahedronGeometry: Ii, - OneFactor: yu, - OneMinusDstAlphaFactor: bu, - OneMinusDstColorFactor: Su, - OneMinusSrcAlphaFactor: Vc, - OneMinusSrcColorFactor: _u, - OrthographicCamera: Fr, - PCFShadowMap: Hc, - PCFSoftShadowMap: fu, - PMREMGenerator: ah, - ParametricGeometry: iv, - Particle: R0, - ParticleBasicMaterial: D0, - ParticleSystem: P0, - ParticleSystemMaterial: F0, - Path: gr, - PerspectiveCamera: ut, - Plane: Wt, - PlaneBufferGeometry: Pi, - PlaneGeometry: Pi, - PlaneHelper: zy, - PointCloud: L0, - PointCloudMaterial: I0, - PointLight: Ga, - PointLightHelper: Ry, - Points: zr, - PointsMaterial: jn, - PolarGridHelper: Dy, - PolyhedronBufferGeometry: an, - PolyhedronGeometry: an, - PositionalAudio: xy, - PropertyBinding: ke, - PropertyMixer: Xh, - QuadraticBezierCurve: co, - QuadraticBezierCurve3: ho, - Quaternion: gt, - QuaternionKeyframeTrack: Wi, - QuaternionLinearInterpolant: Dh, - REVISION: ca, - RGBADepthPacking: Bd, - RGBAFormat: ct, - RGBAIntegerFormat: ed, - RGBA_ASTC_10x10_Format: fd, - RGBA_ASTC_10x5_Format: hd, - RGBA_ASTC_10x6_Format: ud, - RGBA_ASTC_10x8_Format: dd, - RGBA_ASTC_12x10_Format: pd, - RGBA_ASTC_12x12_Format: md, - RGBA_ASTC_4x4_Format: nd, - RGBA_ASTC_5x4_Format: id, - RGBA_ASTC_5x5_Format: rd, - RGBA_ASTC_6x5_Format: sd, - RGBA_ASTC_6x6_Format: od, - RGBA_ASTC_8x5_Format: ad, - RGBA_ASTC_8x6_Format: ld, - RGBA_ASTC_8x8_Format: cd, - RGBA_BPTC_Format: gd, - RGBA_ETC2_EAC_Format: gl, - RGBA_PVRTC_2BPPV1_Format: pl, - RGBA_PVRTC_4BPPV1_Format: fl, - RGBA_S3TC_DXT1_Format: ll, - RGBA_S3TC_DXT3_Format: cl, - RGBA_S3TC_DXT5_Format: hl, - RGBFormat: Gn, - RGBIntegerFormat: Ku, - RGB_ETC1_Format: td, - RGB_ETC2_Format: ml, - RGB_PVRTC_2BPPV1_Format: dl, - RGB_PVRTC_4BPPV1_Format: ul, - RGB_S3TC_DXT1_Format: al, - RGFormat: ju, - RGIntegerFormat: Qu, - RawShaderMaterial: Gi, - Ray: Cn, - Raycaster: Ey, - RectAreaLight: Xa, - RedFormat: Zu, - RedIntegerFormat: $u, - ReinhardToneMapping: Bu, - RepeatWrapping: Ns, - ReplaceStencilOp: e0, - ReverseSubtractEquation: gu, - RingBufferGeometry: br, - RingGeometry: br, - SRGB8_ALPHA8_ASTC_10x10_Format: Cd, - SRGB8_ALPHA8_ASTC_10x5_Format: Td, - SRGB8_ALPHA8_ASTC_10x6_Format: Ed, - SRGB8_ALPHA8_ASTC_10x8_Format: Ad, - SRGB8_ALPHA8_ASTC_12x10_Format: Ld, - SRGB8_ALPHA8_ASTC_12x12_Format: Rd, - SRGB8_ALPHA8_ASTC_4x4_Format: xd, - SRGB8_ALPHA8_ASTC_5x4_Format: yd, - SRGB8_ALPHA8_ASTC_5x5_Format: vd, - SRGB8_ALPHA8_ASTC_6x5_Format: _d, - SRGB8_ALPHA8_ASTC_6x6_Format: Md, - SRGB8_ALPHA8_ASTC_8x5_Format: bd, - SRGB8_ALPHA8_ASTC_8x6_Format: wd, - SRGB8_ALPHA8_ASTC_8x8_Format: Sd, - Scene: no, - SceneUtils: tv, - ShaderChunk: Fe, - ShaderLib: qt, - ShaderMaterial: sn, - ShadowMaterial: Aa, - Shape: Xt, - ShapeBufferGeometry: Di, - ShapeGeometry: Di, - ShapePath: Oy, - ShapeUtils: Jt, - ShortType: ku, - Skeleton: ao, - SkeletonHelper: eu, - SkinnedMesh: so, - SmoothShading: Xy, - Sphere: An, - SphereBufferGeometry: Fi, - SphereGeometry: Fi, - Spherical: Ay, - SphericalHarmonics3: Ja, - SplineCurve: uo, - SpotLight: Ha, - SpotLightHelper: Ly, - Sprite: ro, - SpriteMaterial: io, - SrcAlphaFactor: Gc, - SrcAlphaSaturateFactor: Tu, - SrcColorFactor: vu, - StaticCopyUsage: x0, - StaticDrawUsage: hr, - StaticReadUsage: p0, - StereoCamera: fy, - StreamCopyUsage: v0, - StreamDrawUsage: f0, - StreamReadUsage: g0, - StringKeyframeTrack: Kn, - SubtractEquation: mu, - SubtractiveBlending: il, - TOUCH: Vy, - TangentSpaceNormalMap: Hi, - TetrahedronBufferGeometry: wr, - TetrahedronGeometry: wr, - TextGeometry: rv, - Texture: ot, - TextureLoader: Bh, - TorusBufferGeometry: Sr, - TorusGeometry: Sr, - TorusKnotBufferGeometry: Tr, - TorusKnotGeometry: Tr, - Triangle: nt, - TriangleFanDrawMode: Qy, - TriangleStripDrawMode: jy, - TrianglesDrawMode: Fd, - TubeBufferGeometry: Er, - TubeGeometry: Er, - UVMapping: ha, - Uint16Attribute: k0, - Uint16BufferAttribute: Ys, - Uint32Attribute: V0, - Uint32BufferAttribute: Zs, - Uint8Attribute: U0, - Uint8BufferAttribute: Qc, - Uint8ClampedAttribute: O0, - Uint8ClampedBufferAttribute: Kc, - Uniform: go, - UniformsLib: ie, - UniformsUtils: uf, - UnsignedByteType: rn, - UnsignedInt248Type: Ti, - UnsignedIntType: Ps, - UnsignedShort4444Type: Vu, - UnsignedShort5551Type: Wu, - UnsignedShort565Type: qu, - UnsignedShortType: cr, - VSMShadowMap: ir, - Vector2: X, - Vector3: M, - Vector4: Ve, - VectorKeyframeTrack: Cr, - Vertex: N0, - VertexColors: E0, - VideoTexture: wh, - WebGL1Renderer: _h, - WebGLCubeRenderTarget: js, - WebGLMultipleRenderTargets: Zc, - WebGLMultisampleRenderTarget: Xs, - WebGLRenderTarget: At, - WebGLRenderTargetCube: Q0, - WebGLRenderer: qe, - WebGLUtils: Ex, - WireframeGeometry: Ea, - WireframeHelper: Z0, - WrapAroundEnding: Os, - XHRLoader: $0, - ZeroCurvatureEnding: Mi, - ZeroFactor: xu, - ZeroSlopeEnding: bi, - ZeroStencilOp: Ky, - sRGBEncoding: Oi -}; -function getWebGLErrorMessage() { - return getErrorMessage(1); -} -function getErrorMessage(version) { - var names = { - 1: "WebGL", - 2: "WebGL 2" - }; - var contexts = { - 1: window.WebGLRenderingContext, - 2: window.WebGL2RenderingContext - }; - var message = 'Your $0 does not seem to support $1'; - var element = document.createElement("div"); - element.id = "webglmessage"; - element.style.fontFamily = "monospace"; - element.style.fontSize = "13px"; - element.style.fontWeight = "normal"; - element.style.textAlign = "center"; - element.style.background = "#fff"; - element.style.color = "#000"; - element.style.padding = "1.5em"; - element.style.width = "400px"; - element.style.margin = "5em auto 0"; - if (contexts[version]) { - message = message.replace("$0", "graphics card"); - } else { - message = message.replace("$0", "browser"); - } - message = message.replace("$1", names[version]); - element.innerHTML = message; - return element; -} -function typedarray_to_vectype(typedArray, ndim) { - if (ndim === 1) { - return "float"; - } else if (typedArray instanceof Float32Array) { - return "vec" + ndim; - } else if (typedArray instanceof Int32Array) { - return "ivec" + ndim; - } else if (typedArray instanceof Uint32Array) { - return "uvec" + ndim; - } else { - return; - } -} -function attribute_type(attribute) { - if (attribute) { - return typedarray_to_vectype(attribute.array, attribute.itemSize); - } else { - return; - } -} -function uniform_type(obj) { - if (obj instanceof THREE.Uniform) { - return uniform_type(obj.value); - } else if (typeof obj === "number") { - return "float"; - } else if (typeof obj === "boolean") { - return "bool"; - } else if (obj instanceof THREE.Vector2) { - return "vec2"; - } else if (obj instanceof THREE.Vector3) { - return "vec3"; - } else if (obj instanceof THREE.Vector4) { - return "vec4"; - } else if (obj instanceof THREE.Color) { - return "vec4"; - } else if (obj instanceof THREE.Matrix3) { - return "mat3"; - } else if (obj instanceof THREE.Matrix4) { - return "mat4"; - } else if (obj instanceof THREE.Texture) { - return "sampler2D"; - } else { - return; - } -} -function uniforms_to_type_declaration(uniform_dict) { - let result = ""; - for(const name in uniform_dict){ - const uniform = uniform_dict[name]; - const type = uniform_type(uniform); - result += `uniform ${type} ${name};\n`; - } - return result; -} -function attributes_to_type_declaration(attributes_dict) { - let result = ""; - for(const name in attributes_dict){ - const attribute = attributes_dict[name]; - const type = attribute_type(attribute); - result += `in ${type} ${name};\n`; - } - return result; -} -const pixelRatio = window.devicePixelRatio || 1.0; -function event2scene_pixel(scene, event) { - const { canvas } = scene.screen; - const rect = canvas.getBoundingClientRect(); - const x = (event.clientX - rect.left) * pixelRatio; - const y = (rect.height - (event.clientY - rect.top)) * pixelRatio; - return [ - x, - y - ]; -} -function Identity4x4() { - return new pe(); -} -function in_scene(scene, mouse_event) { - const [x, y] = event2scene_pixel(scene, mouse_event); - const [sx, sy, sw, sh] = scene.pixelarea.value; - return x >= sx && x < sx + sw && y >= sy && y < sy + sh; -} -function attach_3d_camera(canvas, makie_camera, cam3d, scene) { - if (cam3d === undefined) { - return; - } - const [w, h] = makie_camera.resolution.value; - const camera = new ut(cam3d.fov, w / h, cam3d.near, cam3d.far); - const center = new M(...cam3d.lookat); - camera.up = new M(...cam3d.upvector); - camera.position.set(...cam3d.eyeposition); - camera.lookAt(center); - function update() { - const view = camera.matrixWorldInverse; - const projection = camera.projectionMatrix; - const [width, height] = cam3d.resolution.value; - const [x, y, z] = camera.position; - camera.aspect = width / height; - camera.updateProjectionMatrix(); - camera.updateWorldMatrix(); - makie_camera.update_matrices(view.elements, projection.elements, [ - width, - height - ], [ - x, - y, - z - ]); - } - cam3d.resolution.on(update); - function addMouseHandler(domObject, drag, zoomIn, zoomOut) { - let startDragX = null; - let startDragY = null; - function mouseWheelHandler(e) { - e = window.event || e; - if (!in_scene(scene, e)) { - return; - } - const delta = Math.sign(e.deltaY); - if (delta == -1) { - zoomOut(); - } else if (delta == 1) { - zoomIn(); - } - e.preventDefault(); - } - function mouseDownHandler(e) { - if (!in_scene(scene, e)) { - return; - } - startDragX = e.clientX; - startDragY = e.clientY; - e.preventDefault(); - } - function mouseMoveHandler(e) { - if (!in_scene(scene, e)) { - return; - } - if (startDragX === null || startDragY === null) return; - if (drag) drag(e.clientX - startDragX, e.clientY - startDragY); - startDragX = e.clientX; - startDragY = e.clientY; - e.preventDefault(); - } - function mouseUpHandler(e) { - if (!in_scene(scene, e)) { - return; - } - mouseMoveHandler.call(this, e); - startDragX = null; - startDragY = null; - e.preventDefault(); - } - domObject.addEventListener("wheel", mouseWheelHandler); - domObject.addEventListener("mousedown", mouseDownHandler); - domObject.addEventListener("mousemove", mouseMoveHandler); - domObject.addEventListener("mouseup", mouseUpHandler); - } - function drag(deltaX, deltaY) { - const radPerPixel = Math.PI / 450; - const deltaPhi = radPerPixel * deltaX; - const deltaTheta = radPerPixel * deltaY; - const pos = camera.position.sub(center); - const radius = pos.length(); - let theta = Math.acos(pos.z / radius); - let phi = Math.atan2(pos.y, pos.x); - theta = Math.min(Math.max(theta - deltaTheta, 0), Math.PI); - phi -= deltaPhi; - pos.x = radius * Math.sin(theta) * Math.cos(phi); - pos.y = radius * Math.sin(theta) * Math.sin(phi); - pos.z = radius * Math.cos(theta); - camera.position.add(center); - camera.lookAt(center); - update(); - } - function zoomIn() { - camera.position.sub(center).multiplyScalar(0.9).add(center); - update(); - } - function zoomOut() { - camera.position.sub(center).multiplyScalar(1.1).add(center); - update(); - } - addMouseHandler(canvas, drag, zoomIn, zoomOut); -} -function mul(a, b) { - return b.clone().multiply(a); -} -function orthographicprojection(left, right, bottom, top, znear, zfar) { - return [ - 2 / (right - left), - 0, - 0, - 0, - 0, - 2 / (top - bottom), - 0, - 0, - 0, - 0, - -2 / (zfar - znear), - 0, - -(right + left) / (right - left), - -(top + bottom) / (top - bottom), - -(zfar + znear) / (zfar - znear), - 1 - ]; -} -function pixel_space_inverse(w, h, near) { - return [ - 0.5 * w, - 0, - 0, - 0, - 0, - 0.5 * h, - 0, - 0, - 0, - 0, - near, - 0, - 0.5 * w, - 0.5 * h, - 0, - 1 - ]; -} -function relative_space() { - const relative = Identity4x4(); - relative.fromArray([ - 2, - 0, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 0, - 1, - 0, - -1, - -1, - 0, - 1 - ]); - return relative; -} -class MakieCamera { - constructor(){ - this.view = new go(Identity4x4()); - this.projection = new go(Identity4x4()); - this.projectionview = new go(Identity4x4()); - this.pixel_space = new go(Identity4x4()); - this.pixel_space_inverse = new go(Identity4x4()); - this.projectionview_inverse = new go(Identity4x4()); - this.relative_space = new go(relative_space()); - this.relative_inverse = new go(relative_space().invert()); - this.clip_space = new go(Identity4x4()); - this.resolution = new go(new X()); - this.eyeposition = new go(new M()); - this.preprojections = {}; - } - calculate_matrices() { - const [w, h] = this.resolution.value; - const nearclip = -10_000; - this.pixel_space.value.fromArray(orthographicprojection(0, w, 0, h, nearclip, 10_000)); - this.pixel_space_inverse.value.fromArray(pixel_space_inverse(w, h, nearclip)); - const proj_view = mul(this.view.value, this.projection.value); - this.projectionview.value = proj_view; - this.projectionview_inverse.value = proj_view.clone().invert(); - Object.keys(this.preprojections).forEach((key)=>{ - const [space, markerspace] = key.split(","); - this.preprojections[key].value = this.calculate_preprojection_matrix(space, markerspace); - }); - } - update_matrices(view, projection, resolution, eyepos) { - this.view.value.fromArray(view); - this.projection.value.fromArray(projection); - this.resolution.value.fromArray(resolution.map((x)=>Math.ceil(x / pixelRatio))); - this.eyeposition.value.fromArray(eyepos); - this.calculate_matrices(); - return; - } - clip_to_space(space) { - if (space === "data") { - return this.projectionview_inverse.value; - } else if (space === "pixel") { - return this.pixel_space_inverse.value; - } else if (space === "relative") { - return this.relative_inverse.value; - } else if (space === "clip") { - return this.clip_space.value; - } else { - throw new Error(`Space ${space} not recognized`); - } - } - space_to_clip(space) { - if (space === "data") { - return this.projectionview.value; - } else if (space === "pixel") { - return this.pixel_space.value; - } else if (space === "relative") { - return this.relative_space.value; - } else if (space === "clip") { - return this.clip_space.value; - } else { - throw new Error(`Space ${space} not recognized`); - } - } - calculate_preprojection_matrix(space, markerspace) { - const cp = this.clip_to_space(markerspace); - const sc = this.space_to_clip(space); - return mul(sc, cp); - } - preprojection_matrix(space, markerspace) { - const key = [ - space, - markerspace - ]; - const matrix_uniform = this.preprojections[key]; - if (matrix_uniform) { - return matrix_uniform; - } else { - const matrix = this.calculate_preprojection_matrix(space, markerspace); - const uniform = new go(matrix); - this.preprojections[key] = uniform; - return uniform; - } - } -} -const scene_cache = {}; -function filter_by_key(dict, keys, default_value = false) { - const result = {}; - keys.forEach((key)=>{ - const val = dict[key]; - if (val) { - result[key] = val; - } else { - result[key] = default_value; - } - }); - return result; -} -const plot_cache = {}; -const TEXTURE_ATLAS = [ - undefined -]; -function add_scene(scene_id, three_scene) { - scene_cache[scene_id] = three_scene; -} -function find_scene(scene_id) { - return scene_cache[scene_id]; -} -function delete_scene(scene_id) { - const scene = scene_cache[scene_id]; - if (!scene) { - return; - } - while(scene.children.length > 0){ - scene.remove(scene.children[0]); - } - delete scene_cache[scene_id]; -} -function find_plots(plot_uuids) { - const plots = []; - plot_uuids.forEach((id)=>{ - const plot = plot_cache[id]; - if (plot) { - plots.push(plot); - } - }); - return plots; -} -function delete_scenes(scene_uuids, plot_uuids) { - plot_uuids.forEach((plot_id)=>{ - delete plot_cache[plot_id]; - }); - scene_uuids.forEach((scene_id)=>{ - delete_scene(scene_id); - }); -} -function insert_plot(scene_id, plot_data) { - const scene = find_scene(scene_id); - plot_data.forEach((plot)=>{ - add_plot(scene, plot); - }); -} -function delete_plots(scene_id, plot_uuids) { - console.log(`deleting plots!: ${plot_uuids}`); - const scene = find_scene(scene_id); - const plots = find_plots(plot_uuids); - plots.forEach((p)=>{ - scene.remove(p); - delete plot_cache[p]; - }); -} -function convert_texture(data) { - const tex = create_texture(data); - tex.needsUpdate = true; - tex.minFilter = mod[data.minFilter]; - tex.magFilter = mod[data.magFilter]; - tex.anisotropy = data.anisotropy; - tex.wrapS = mod[data.wrapS]; - if (data.size.length > 1) { - tex.wrapT = mod[data.wrapT]; - } - if (data.size.length > 2) { - tex.wrapR = mod[data.wrapR]; - } - return tex; -} -function is_three_fixed_array(value) { - return value instanceof mod.Vector2 || value instanceof mod.Vector3 || value instanceof mod.Vector4 || value instanceof mod.Matrix4; -} -function to_uniform(data) { - if (data.type !== undefined) { - if (data.type == "Sampler") { - return convert_texture(data); - } - throw new Error(`Type ${data.type} not known`); - } - if (Array.isArray(data) || ArrayBuffer.isView(data)) { - if (!data.every((x)=>typeof x === "number")) { - return data; - } - if (data.length == 2) { - return new mod.Vector2().fromArray(data); - } - if (data.length == 3) { - return new mod.Vector3().fromArray(data); - } - if (data.length == 4) { - return new mod.Vector4().fromArray(data); - } - if (data.length == 16) { - const mat = new mod.Matrix4(); - mat.fromArray(data); - return mat; - } - } - return data; -} -function deserialize_uniforms(data) { - const result = {}; - for(const name in data){ - const value = data[name]; - if (value instanceof mod.Uniform) { - result[name] = value; - } else { - const ser = to_uniform(value); - result[name] = new mod.Uniform(ser); - } - } - return result; -} -function linesegments_vertex_shader(uniforms, attributes) { - const attribute_decl = attributes_to_type_declaration(attributes); - const uniform_decl = uniforms_to_type_declaration(uniforms); - const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); - return `#version 300 es - precision mediump int; - precision highp float; - - ${attribute_decl} - ${uniform_decl} - - out vec2 f_uv; - out ${color} f_color; - - vec3 screen_space(vec3 point) { - vec4 vertex = projectionview * model * vec4(point, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; - } - - vec3 screen_space(vec2 point) { - return screen_space(vec3(point, 0)); - } - - void main() { - vec3 p_a = screen_space(linepoint_start); - vec3 p_b = screen_space(linepoint_end); - float width = (position.x == 1.0 ? linewidth_end : linewidth_start); - f_color = position.x == 1.0 ? color_end : color_start; - f_uv = vec2(position.x, position.y + 0.5); - - vec2 pointA = p_a.xy; - vec2 pointB = p_b.xy; - - vec2 xBasis = pointB - pointA; - vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); - vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; - - gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - } - `; -} -function lines_fragment_shader(uniforms, attributes) { - const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); - const color_uniforms = filter_by_key(uniforms, [ - "colorrange", - "colormap", - "nan_color", - "highclip", - "lowclip" - ]); - const uniform_decl = uniforms_to_type_declaration(color_uniforms); - return `#version 300 es - #extension GL_OES_standard_derivatives : enable - - precision mediump int; - precision highp float; - precision mediump sampler2D; - precision mediump sampler3D; - - in vec2 f_uv; - in ${color} f_color; - ${uniform_decl} - - out vec4 fragment_color; - - // Half width of antialiasing smoothstep - #define ANTIALIAS_RADIUS 0.7071067811865476 - - vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { - float cmin = colorrange.x; - float cmax = colorrange.y; - if (value <= cmax && value >= cmin) { - // in value range, continue! - } else if (value < cmin) { - return lowclip; - } else if (value > cmax) { - return highclip; - } else { - // isnan CAN be broken (of course) -.- - // so if outside value range and not smaller/bigger min/max we assume NaN - return nan_color; - } - float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); - // 1/0 corresponds to the corner of the colormap, so to properly interpolate - // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). - float stepsize = 1.0 / float(textureSize(colormap, 0)); - i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; - return texture(colormap, vec2(i01, 0.0)); - } - - vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { - return get_color_from_cmap(color, colormap, colorrange); - } - - vec4 get_color(vec4 color, bool colormap, bool colorrange) { - return color; - } - vec4 get_color(vec3 color, bool colormap, bool colorrange) { - return vec4(color, 1.0); - } - - float aastep(float threshold, float value) { - float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; - return smoothstep(threshold-afwidth, threshold+afwidth, value); - } - - float aastep(float threshold1, float threshold2, float dist) { - return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); - } - - void main(){ - float xalpha = aastep(0.0, 0.0, f_uv.x); - float yalpha = aastep(0.0, 0.0, f_uv.y); - vec4 color = get_color(f_color, colormap, colorrange); - fragment_color = vec4(color.rgb, color.a); - } - `; -} -function create_line_material(uniforms, attributes) { - const uniforms_des = deserialize_uniforms(uniforms); - uniforms_des.pixel_ratio = new THREE.Uniform(window.devicePixelRatio || 1.0); - return new THREE.RawShaderMaterial({ - uniforms: uniforms_des, - vertexShader: linesegments_vertex_shader(uniforms_des, attributes), - fragmentShader: lines_fragment_shader(uniforms_des, attributes), - transparent: true - }); -} -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { - const skip_elems = is_segments ? 2 * ndim : ndim; - const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); - if (!is_segments) { - buffer.count = points.length / ndim - 1; - } - geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); - geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); - return buffer; -} -function create_line_buffer(buffers, geometry, name, attr, is_segments) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const linebuffer = attach_interleaved_line_buffer(name, geometry, flat_buffer, ndims, is_segments); - buffers[name] = linebuffer; - attr.on((new_points)=>{ - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims, is_segments); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - buffers[name].needsUpdate = true; - }); - return flat_buffer; -} -function create_line_geometry(attributes, is_segments) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [ - 0, - -0.5, - 1, - -0.5, - 1, - 0.5, - 0, - -0.5, - 1, - 0.5, - 0, - 0.5 - ]; - geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); - return geometry; - } - const geometry = geometry_buffer(); - const buffers = {}; - for(let name in attributes){ - const attr = attributes[name]; - create_line_buffer(buffers, geometry, name, attr, is_segments); - } - geometry.boundingSphere = new THREE.Sphere(); - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - return geometry; -} -function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes, false); - const material = create_line_material(line_data.uniforms, geometry.attributes); - return new THREE.Mesh(geometry, material); -} -function create_linesegments(line_data) { - const geometry = create_line_geometry(line_data.attributes, true); - const material = create_line_material(line_data.uniforms, geometry.attributes); - return new THREE.Mesh(geometry, material); -} -function deserialize_plot(data) { - let mesh; - const update_visible = (v)=>{ - mesh.visible = v; - return; - }; - if (data.plot_type === "lines") { - mesh = create_line(data); - } else if (data.plot_type === "linesegments") { - mesh = create_linesegments(data); - } else if ("instance_attributes" in data) { - mesh = create_instanced_mesh(data); - } else { - mesh = create_mesh(data); - } - mesh.name = data.name; - mesh.frustumCulled = false; - mesh.matrixAutoUpdate = false; - mesh.plot_uuid = data.uuid; - update_visible(data.visible.value); - data.visible.on(update_visible); - if (!(data.plot_type === "lines" || data.plot_type === "linesegments")) { - connect_uniforms(mesh, data.uniform_updater); - connect_attributes(mesh, data.attribute_updater); - } - return mesh; -} -const ON_NEXT_INSERT = new Set(); -function on_next_insert(f) { - ON_NEXT_INSERT.add(f); -} -function add_plot(scene, plot_data) { - const cam = scene.wgl_camera; - const identity = new mod.Uniform(new mod.Matrix4()); - if (plot_data.cam_space == "data") { - plot_data.uniforms.view = cam.view; - plot_data.uniforms.projection = cam.projection; - plot_data.uniforms.projectionview = cam.projectionview; - plot_data.uniforms.eyeposition = cam.eyeposition; - } else if (plot_data.cam_space == "pixel") { - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = cam.pixel_space; - plot_data.uniforms.projectionview = cam.pixel_space; - } else if (plot_data.cam_space == "relative") { - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = cam.relative_space; - plot_data.uniforms.projectionview = cam.relative_space; - } else { - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = identity; - plot_data.uniforms.projectionview = identity; - } - plot_data.uniforms.resolution = cam.resolution; - if (plot_data.uniforms.preprojection) { - const { space , markerspace } = plot_data; - plot_data.uniforms.preprojection = cam.preprojection_matrix(space.value, markerspace.value); - } - const p = deserialize_plot(plot_data); - plot_cache[plot_data.uuid] = p; - scene.add(p); - const next_insert = new Set(ON_NEXT_INSERT); - next_insert.forEach((f)=>f()); -} -function connect_uniforms(mesh, updater) { - updater.on(([name, data])=>{ - if (name === "none") { - return; - } - const uniform = mesh.material.uniforms[name]; - if (uniform.value.isTexture) { - const im_data = uniform.value.image; - const [size, tex_data] = data; - if (tex_data.length == im_data.data.length) { - im_data.data.set(tex_data); - } else { - const old_texture = uniform.value; - uniform.value = re_create_texture(old_texture, tex_data, size); - old_texture.dispose(); - } - uniform.value.needsUpdate = true; - } else { - if (is_three_fixed_array(uniform.value)) { - uniform.value.fromArray(data); - } else { - uniform.value = data; - } - } - }); -} -function create_texture(data) { - const buffer = data.data; - if (data.size.length == 3) { - const tex = new mod.DataTexture3D(buffer, data.size[0], data.size[1], data.size[2]); - tex.format = mod[data.three_format]; - tex.type = mod[data.three_type]; - return tex; - } else { - const tex_data = buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; - return new mod.DataTexture(tex_data, data.size[0], data.size[1], mod[data.three_format], mod[data.three_type]); - } -} -function re_create_texture(old_texture, buffer, size) { - if (size.length == 3) { - const tex = new mod.DataTexture3D(buffer, size[0], size[1], size[2]); - tex.format = old_texture.format; - tex.type = old_texture.type; - return tex; - } else { - return new mod.DataTexture(buffer, size[0], size[1] ? size[1] : 1, old_texture.format, old_texture.type); - } -} -function BufferAttribute(buffer) { - const jsbuff = new mod.BufferAttribute(buffer.flat, buffer.type_length); - jsbuff.setUsage(mod.DynamicDrawUsage); - return jsbuff; -} -function InstanceBufferAttribute(buffer) { - const jsbuff = new mod.InstancedBufferAttribute(buffer.flat, buffer.type_length); - jsbuff.setUsage(mod.DynamicDrawUsage); - return jsbuff; -} -function attach_geometry(buffer_geometry, vertexarrays, faces) { - for(const name in vertexarrays){ - const buff = vertexarrays[name]; - let buffer; - if (buff.to_update) { - buffer = new mod.BufferAttribute(buff.to_update, buff.itemSize); - } else { - buffer = BufferAttribute(buff); - } - buffer_geometry.setAttribute(name, buffer); - } - buffer_geometry.setIndex(faces); - buffer_geometry.boundingSphere = new mod.Sphere(); - buffer_geometry.boundingSphere.radius = 10000000000000; - buffer_geometry.frustumCulled = false; - return buffer_geometry; -} -function attach_instanced_geometry(buffer_geometry, instance_attributes) { - for(const name in instance_attributes){ - const buffer = InstanceBufferAttribute(instance_attributes[name]); - buffer_geometry.setAttribute(name, buffer); - } -} -function recreate_geometry(mesh, vertexarrays, faces) { - const buffer_geometry = new mod.BufferGeometry(); - attach_geometry(buffer_geometry, vertexarrays, faces); - mesh.geometry.dispose(); - mesh.geometry = buffer_geometry; - mesh.needsUpdate = true; -} -function recreate_instanced_geometry(mesh) { - const buffer_geometry = new mod.InstancedBufferGeometry(); - const vertexarrays = {}; - const instance_attributes = {}; - const faces = [ - ...mesh.geometry.index.array - ]; - Object.keys(mesh.geometry.attributes).forEach((name)=>{ - const buffer = mesh.geometry.attributes[name]; - const copy = buffer.to_update ? buffer.to_update : buffer.array.map((x)=>x); - if (buffer.isInstancedBufferAttribute) { - instance_attributes[name] = { - flat: copy, - type_length: buffer.itemSize - }; - } else { - vertexarrays[name] = { - flat: copy, - type_length: buffer.itemSize - }; - } - }); - attach_geometry(buffer_geometry, vertexarrays, faces); - attach_instanced_geometry(buffer_geometry, instance_attributes); - mesh.geometry.dispose(); - mesh.geometry = buffer_geometry; - mesh.needsUpdate = true; -} -function create_material(program) { - const is_volume = "volumedata" in program.uniforms; - return new mod.RawShaderMaterial({ - uniforms: deserialize_uniforms(program.uniforms), - vertexShader: program.vertex_source, - fragmentShader: program.fragment_source, - side: is_volume ? mod.BackSide : mod.DoubleSide, - transparent: true, - depthTest: !program.overdraw.value, - depthWrite: !program.transparency.value - }); -} -function create_mesh(program) { - const buffer_geometry = new mod.BufferGeometry(); - const faces = new mod.BufferAttribute(program.faces.value, 1); - attach_geometry(buffer_geometry, program.vertexarrays, faces); - const material = create_material(program); - const mesh = new mod.Mesh(buffer_geometry, material); - program.faces.on((x)=>{ - mesh.geometry.setIndex(new mod.BufferAttribute(x, 1)); - }); - return mesh; -} -function create_instanced_mesh(program) { - const buffer_geometry = new mod.InstancedBufferGeometry(); - const faces = new mod.BufferAttribute(program.faces.value, 1); - attach_geometry(buffer_geometry, program.vertexarrays, faces); - attach_instanced_geometry(buffer_geometry, program.instance_attributes); - const material = create_material(program); - const mesh = new mod.Mesh(buffer_geometry, material); - program.faces.on((x)=>{ - mesh.geometry.setIndex(new mod.BufferAttribute(x, 1)); - }); - return mesh; -} -function first(x) { - return x[Object.keys(x)[0]]; -} -function connect_attributes(mesh, updater) { - const instance_buffers = {}; - const geometry_buffers = {}; - let first_instance_buffer; - const real_instance_length = [ - 0 - ]; - let first_geometry_buffer; - const real_geometry_length = [ - 0 - ]; - function re_assign_buffers() { - const attributes = mesh.geometry.attributes; - Object.keys(attributes).forEach((name)=>{ - const buffer = attributes[name]; - if (buffer.isInstancedBufferAttribute) { - instance_buffers[name] = buffer; - } else { - geometry_buffers[name] = buffer; - } - }); - first_instance_buffer = first(instance_buffers); - if (first_instance_buffer) { - real_instance_length[0] = first_instance_buffer.count; - } - first_geometry_buffer = first(geometry_buffers); - real_geometry_length[0] = first_geometry_buffer.count; - } - re_assign_buffers(); - updater.on(([name, new_values, length])=>{ - const buffer = mesh.geometry.attributes[name]; - let buffers; - let real_length; - let is_instance = false; - if (name in instance_buffers) { - buffers = instance_buffers; - first_instance_buffer; - real_length = real_instance_length; - is_instance = true; - } else { - buffers = geometry_buffers; - first_geometry_buffer; - real_length = real_geometry_length; - } - if (length <= real_length[0]) { - buffer.set(new_values); - buffer.needsUpdate = true; - if (is_instance) { - mesh.geometry.instanceCount = length; - } - } else { - buffer.to_update = new_values; - const all_have_same_length = Object.values(buffers).every((x)=>x.to_update && x.to_update.length / x.itemSize == length); - if (all_have_same_length) { - if (is_instance) { - recreate_instanced_geometry(mesh); - re_assign_buffers(); - mesh.geometry.instanceCount = new_values.length / buffer.itemSize; - } else { - recreate_geometry(mesh, buffers, mesh.geometry.index); - re_assign_buffers(); - } - } - } - }); -} -function deserialize_scene(data, screen) { - const scene = new mod.Scene(); - scene.screen = screen; - const { canvas } = screen; - add_scene(data.uuid, scene); - scene.scene_uuid = data.uuid; - scene.frustumCulled = false; - scene.pixelarea = data.pixelarea; - scene.backgroundcolor = data.backgroundcolor; - scene.clearscene = data.clearscene; - scene.visible = data.visible; - const camera = new MakieCamera(); - scene.wgl_camera = camera; - function update_cam(camera_matrices) { - const [view, projection, resolution, eyepos] = camera_matrices; - camera.update_matrices(view, projection, resolution, eyepos); - } - update_cam(data.camera.value); - if (data.cam3d_state) { - attach_3d_camera(canvas, camera, data.cam3d_state, scene); - } else { - data.camera.on(update_cam); - } - data.plots.forEach((plot_data)=>{ - add_plot(scene, plot_data); - }); - scene.scene_children = data.children.map((child)=>deserialize_scene(child, screen)); - return scene; -} -function delete_plot(plot) { - delete plot_cache[plot.plot_uuid]; - const { parent } = plot; - if (parent) { - parent.remove(plot); - } - plot.geometry.dispose(); - plot.material.dispose(); -} -function delete_three_scene(scene) { - delete scene_cache[scene.scene_uuid]; - scene.scene_children.forEach(delete_three_scene); - while(scene.children.length > 0){ - delete_plot(scene.children[0]); - } -} -window.THREE = mod; -const pixelRatio1 = window.devicePixelRatio || 1.0; -function render_scene(scene, picking = false) { - const { camera , renderer } = scene.screen; - const canvas = renderer.domElement; - if (!document.body.contains(canvas)) { - console.log("EXITING WGL"); - renderer.state.reset(); - renderer.dispose(); - delete_three_scene(scene); - return false; - } - if (!scene.visible.value) { - return true; - } - renderer.autoClear = scene.clearscene.value; - const area = scene.pixelarea.value; - if (area) { - const [x, y, w, h] = area.map((t)=>Math.ceil(t / pixelRatio1)); - renderer.setViewport(x, y, w, h); - renderer.setScissor(x, y, w, h); - renderer.setScissorTest(true); - if (picking) { - renderer.setClearAlpha(0); - renderer.setClearColor(new mod.Color(0), 0.0); - } else { - renderer.setClearColor(scene.backgroundcolor.value); - } - renderer.render(scene, camera); - } - return scene.scene_children.every((x)=>render_scene(x, picking)); -} -function start_renderloop(three_scene) { - const { fps } = three_scene.screen; - const time_per_frame = 1 / fps * 1000; - let last_time_stamp = performance.now(); - function renderloop(timestamp) { - if (timestamp - last_time_stamp > time_per_frame) { - const all_rendered = render_scene(three_scene); - if (!all_rendered) { - return; - } - last_time_stamp = performance.now(); - } - window.requestAnimationFrame(renderloop); - } - render_scene(three_scene); - renderloop(); -} -function throttle_function(func, delay) { - let prev = 0; - let future_id = undefined; - function inner_throttle(...args) { - const now = new Date().getTime(); - if (future_id !== undefined) { - clearTimeout(future_id); - future_id = undefined; - } - if (now - prev > delay) { - prev = now; - return func(...args); - } else { - future_id = setTimeout(()=>inner_throttle(...args), now - prev + 1); - } - } - return inner_throttle; -} -function threejs_module(canvas, comm, width, height, resize_to_body) { - let context = canvas.getContext("webgl2", { - preserveDrawingBuffer: true - }); - if (!context) { - console.warn("WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)"); - context = canvas.getContext("webgl", { - preserveDrawingBuffer: true - }); - } - if (!context) { - return; - } - const renderer = new mod.WebGLRenderer({ - antialias: true, - canvas: canvas, - context: context, - powerPreference: "high-performance" - }); - renderer.setClearColor("#ffffff"); - renderer.setPixelRatio(pixelRatio1); - renderer.setSize(Math.ceil(width / pixelRatio1), Math.ceil(height / pixelRatio1)); - const mouse_callback = (x, y)=>comm.notify({ - mouseposition: [ - x, - y - ] - }); - const notify_mouse_throttled = throttle_function(mouse_callback, 40); - function mousemove(event) { - var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) * pixelRatio1; - var y = (event.clientY - rect.top) * pixelRatio1; - notify_mouse_throttled(x, y); - return false; - } - canvas.addEventListener("mousemove", mousemove); - function mousedown(event) { - comm.notify({ - mousedown: event.buttons - }); - return false; - } - canvas.addEventListener("mousedown", mousedown); - function mouseup(event) { - comm.notify({ - mouseup: event.buttons - }); - return false; - } - canvas.addEventListener("mouseup", mouseup); - function wheel(event) { - comm.notify({ - scroll: [ - event.deltaX, - -event.deltaY - ] - }); - event.preventDefault(); - return false; - } - canvas.addEventListener("wheel", wheel); - function keydown(event) { - comm.notify({ - keydown: event.code - }); - return false; - } - canvas.addEventListener("keydown", keydown); - function keyup(event) { - comm.notify({ - keyup: event.code - }); - return false; - } - canvas.addEventListener("keyup", keyup); - function contextmenu(event) { - comm.notify({ - keyup: "delete_keys" - }); - return false; - } - canvas.addEventListener("contextmenu", (e)=>e.preventDefault()); - canvas.addEventListener("focusout", contextmenu); - function resize_callback() { - const bodyStyle = window.getComputedStyle(document.body); - const width_padding = parseInt(bodyStyle.paddingLeft, 10) + parseInt(bodyStyle.paddingRight, 10) + parseInt(bodyStyle.marginLeft, 10) + parseInt(bodyStyle.marginRight, 10); - const height_padding = parseInt(bodyStyle.paddingTop, 10) + parseInt(bodyStyle.paddingBottom, 10) + parseInt(bodyStyle.marginTop, 10) + parseInt(bodyStyle.marginBottom, 10); - const width = (window.innerWidth - width_padding) * pixelRatio1; - const height = (window.innerHeight - height_padding) * pixelRatio1; - comm.notify({ - resize: [ - width, - height - ] - }); - } - if (resize_to_body) { - const resize_callback_throttled = throttle_function(resize_callback, 100); - window.addEventListener("resize", (event)=>resize_callback_throttled()); - resize_callback_throttled(); - } - return renderer; -} -function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height, texture_atlas_obs, fps, resize_to_body) { - const renderer = threejs_module(canvas, comm, width, height, resize_to_body); - TEXTURE_ATLAS[0] = texture_atlas_obs; - if (renderer) { - const camera = new mod.PerspectiveCamera(45, 1, 0, 100); - camera.updateProjectionMatrix(); - const size = new mod.Vector2(); - renderer.getDrawingBufferSize(size); - const picking_target = new mod.WebGLRenderTarget(size.x, size.y); - const screen = { - renderer, - picking_target, - camera, - fps, - canvas - }; - const three_scene = deserialize_scene(scenes, screen); - console.log(three_scene); - start_renderloop(three_scene); - canvas_width.on((w_h)=>{ - const pixelRatio = renderer.getPixelRatio(); - renderer.setSize(Math.ceil(w_h[0] / pixelRatio), Math.ceil(w_h[1] / pixelRatio)); - }); - } else { - const warning = getWebGLErrorMessage(); - wrapper.appendChild(warning); - } -} -function set_picking_uniforms(scene, last_id, picking, picked_plots, plots, id_to_plot) { - scene.children.forEach((plot, index)=>{ - const { material } = plot; - const { uniforms } = material; - if (picking) { - uniforms.object_id.value = last_id + index; - uniforms.picking.value = true; - material.blending = mod.NoBlending; - } else { - uniforms.picking.value = false; - material.blending = mod.NormalBlending; - const id = uniforms.object_id.value; - if (id in picked_plots) { - plots.push([ - plot, - picked_plots[id] - ]); - id_to_plot[id] = plot; - } - } - }); - let next_id = last_id + scene.children.length; - scene.scene_children.forEach((scene)=>{ - next_id = set_picking_uniforms(scene, next_id, picking, picked_plots, plots, id_to_plot); - }); - return next_id; -} -function pick_native(scene, x, y, w, h) { - const { renderer , picking_target } = scene.screen; - renderer.setRenderTarget(picking_target); - set_picking_uniforms(scene, 1, true); - render_scene(scene, true); - renderer.setRenderTarget(null); - const nbytes = w * h * 4; - const pixel_bytes = new Uint8Array(nbytes); - renderer.readRenderTargetPixels(picking_target, x, y, w, h, pixel_bytes); - const picked_plots = {}; - const picked_plots_array = []; - const reinterpret_view = new DataView(pixel_bytes.buffer); - for(let i = 0; i < pixel_bytes.length / 4; i++){ - const id = reinterpret_view.getUint16(i * 4); - const index = reinterpret_view.getUint16(i * 4 + 2); - picked_plots_array.push([ - id, - index - ]); - picked_plots[id] = index; - } - const plots = []; - const id_to_plot = {}; - set_picking_uniforms(scene, 0, false, picked_plots, plots, id_to_plot); - const picked_plots_matrix = picked_plots_array.map(([id, index])=>{ - const p = id_to_plot[id]; - return [ - p ? p.plot_uuid : null, - index - ]; - }); - const plot_matrix = { - data: picked_plots_matrix, - size: [ - w, - h - ] - }; - return [ - plot_matrix, - plots - ]; -} -function pick_closest(scene, xy, range) { - const { picking_target } = scene.screen; - const { width , height } = picking_target; - if (!(1.0 <= xy[0] <= width && 1.0 <= xy[1] <= height)) { - return [ - null, - 0 - ]; - } - const x0 = Math.max(1, xy[0] - range); - const y0 = Math.max(1, xy[1] - range); - const x1 = Math.min(width, Math.floor(xy[0] + range)); - const y1 = Math.min(height, Math.floor(xy[1] + range)); - const dx = x1 - x0; - const dy = y1 - y0; - const [plot_data, _] = pick_native(scene, x0, y0, dx, dy); - const plot_matrix = plot_data.data; - let min_dist = range ^ 2; - let selection = [ - null, - 0 - ]; - const x = xy[0] + 1 - x0; - const y = xy[1] + 1 - y0; - let pindex = 0; - for(let i = 1; i <= dx; i++){ - for(let j = 1; j <= dx; j++){ - const d = x - i ^ 2 + (y - j) ^ 2; - const [plot_uuid, index] = plot_matrix[pindex]; - pindex = pindex + 1; - if (d < min_dist && plot_uuid) { - min_dist = d; - selection = [ - plot_uuid, - index - ]; - } - } - } - return selection; -} -function pick_sorted(scene, xy, range) { - const { picking_target } = scene.screen; - const { width , height } = picking_target; - if (!(1.0 <= xy[0] <= width && 1.0 <= xy[1] <= height)) { - return null; - } - const x0 = Math.max(1, xy[0] - range); - const y0 = Math.max(1, xy[1] - range); - const x1 = Math.min(width, Math.floor(xy[0] + range)); - const y1 = Math.min(height, Math.floor(xy[1] + range)); - const dx = x1 - x0; - const dy = y1 - y0; - const [plot_data, selected] = pick_native(scene, x0, y0, dx, dy); - if (selected.length == 0) { - return null; - } - const plot_matrix = plot_data.data; - const distances = selected.map((x)=>range ^ 2); - const x = xy[0] + 1 - x0; - const y = xy[1] + 1 - y0; - let pindex = 0; - for(let i = 1; i <= dx; i++){ - for(let j = 1; j <= dx; j++){ - const d = x - i ^ 2 + (y - j) ^ 2; - const [plot_uuid, index] = plot_matrix[pindex]; - pindex = pindex + 1; - const plot_index = selected.findIndex((x)=>x[0].plot_uuid == plot_uuid); - if (plot_index >= 0 && d < distances[plot_index]) { - distances[plot_index] = d; - } - } - } - const sorted_indices = Array.from(Array(distances.length).keys()).sort((a, b)=>distances[a] < distances[b] ? -1 : distances[b] < distances[a] | 0); - return sorted_indices.map((idx)=>{ - const [plot, index] = selected[idx]; - return [ - plot.plot_uuid, - index - ]; - }); -} -function pick_native_uuid(scene, x, y, w, h) { - const [_, picked_plots] = pick_native(scene, x, y, w, h); - return picked_plots.map(([p, index])=>[ - p.plot_uuid, - index - ]); -} -function pick_native_matrix(scene, x, y, w, h) { - const [matrix, _] = pick_native(scene, x, y, w, h); - return matrix; -} -function register_popup(popup, scene, plots_to_pick, callback) { - if (!scene || !scene.screen) { - return; - } - const { canvas } = scene.screen; - canvas.addEventListener("mousedown", (event)=>{ - if (!popup.classList.contains("show")) { - popup.classList.add("show"); - } - popup.style.left = event.pageX + "px"; - popup.style.top = event.pageY + "px"; - const [x, y] = event2scene_pixel(scene, event); - const [_, picks] = pick_native(scene, x, y, 1, 1); - if (picks.length == 1) { - const [plot, index] = picks[0]; - if (plots_to_pick.has(plot.plot_uuid)) { - const result = callback(plot, index); - if (typeof result === "string" || result instanceof String) { - popup.innerText = result; - } else { - popup.innerHTML = result; - } - } - } else { - popup.classList.remove("show"); - } - }); - canvas.addEventListener("keyup", (event)=>{ - if (event.key === "Escape") { - popup.classList.remove("show"); - } - }); -} -window.WGL = { - deserialize_scene, - threejs_module, - start_renderloop, - delete_plots, - insert_plot, - find_plots, - delete_scene, - find_scene, - scene_cache, - plot_cache, - delete_scenes, - create_scene, - event2scene_pixel, - on_next_insert, - register_popup, - render_scene -}; -export { deserialize_scene as deserialize_scene, threejs_module as threejs_module, start_renderloop as start_renderloop, delete_plots as delete_plots, insert_plot as insert_plot, find_plots as find_plots, delete_scene as delete_scene, find_scene as find_scene, scene_cache as scene_cache, plot_cache as plot_cache, delete_scenes as delete_scenes, create_scene as create_scene, event2scene_pixel as event2scene_pixel, on_next_insert as on_next_insert }; -export { render_scene as render_scene }; -export { pick_native as pick_native }; -export { pick_closest as pick_closest }; -export { pick_sorted as pick_sorted }; -export { pick_native_uuid as pick_native_uuid }; -export { pick_native_matrix as pick_native_matrix }; -export { register_popup as register_popup }; - diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index a4597aae664..43e9c52ac8b 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -38,7 +38,7 @@ export function render_scene(scene, picking = false) { renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; if (area) { - const [x, y, w, h] = area.map((t) => Math.ceil(t / pixelRatio)); + const [x, y, w, h] = area.map((t) => Math.ceil(t)); renderer.setViewport(x, y, w, h); renderer.setScissor(x, y, w, h); renderer.setScissorTest(true); @@ -141,10 +141,7 @@ function threejs_module(canvas, comm, width, height, resize_to_body) { // The following handles high-DPI devices // `renderer.setSize` also updates `canvas` size renderer.setPixelRatio(pixelRatio); - renderer.setSize( - Math.ceil(width / pixelRatio), - Math.ceil(height / pixelRatio) - ); + renderer.setSize(width, height); const mouse_callback = (x, y) => comm.notify({ mouseposition: [x, y] }); const notify_mouse_throttled = throttle_function(mouse_callback, 40); @@ -294,7 +291,7 @@ function create_scene( canvas_width.on((w_h) => { // `renderer.setSize` correctly updates `canvas` dimensions const pixelRatio = renderer.getPixelRatio(); - renderer.setSize(Math.ceil(w_h[0] / pixelRatio), Math.ceil(w_h[1] / pixelRatio)); + renderer.setSize(Math.ceil(w_h[0]), Math.ceil(w_h[1])); }); } else { const warning = getWebGLErrorMessage(); From 01d99ddf62a4db0837883a0177e8ec8490c841c1 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Wed, 9 Aug 2023 17:44:52 +0200 Subject: [PATCH 14/28] fix and clean up lines + highdpi implementation --- GLMakie/src/screen.jl | 1 - GLMakie/test/unit_tests.jl | 6 +- ReferenceTests/src/database.jl | 3 +- WGLMakie/src/Serialization.js | 4 +- WGLMakie/src/display.jl | 36 +- WGLMakie/src/experiment.vert | 328 - WGLMakie/src/lines-class.js | 254 - WGLMakie/src/lines.jl | 2 +- WGLMakie/src/precompiles.jl | 2 +- WGLMakie/src/three_plot.jl | 9 +- WGLMakie/src/wglmakie.bundled.js | 20962 +++++++++++++++++++++++++++++ WGLMakie/src/wglmakie.js | 66 +- src/theming.jl | 6 +- 13 files changed, 21055 insertions(+), 624 deletions(-) delete mode 100644 WGLMakie/src/experiment.vert delete mode 100644 WGLMakie/src/lines-class.js create mode 100644 WGLMakie/src/wglmakie.bundled.js diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index 96861a6a16c..eaab3edf55b 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -340,7 +340,6 @@ function apply_config!(screen::Screen, config::ScreenConfig; start_renderloop::B end screen.scalefactor[] = !isnothing(config.scalefactor) ? config.scalefactor : scale_factor(glw) screen.px_per_unit[] = !isnothing(config.px_per_unit) ? config.px_per_unit : screen.scalefactor[] - function replace_processor!(postprocessor, idx) fb = screen.framebuffer shader_cache = screen.shader_cache diff --git a/GLMakie/test/unit_tests.jl b/GLMakie/test/unit_tests.jl index b91a3ea8088..2074732ccea 100644 --- a/GLMakie/test/unit_tests.jl +++ b/GLMakie/test/unit_tests.jl @@ -277,9 +277,10 @@ end return round.(Int, dims .* sf) end - screen = display(GLMakie.Screen(visible = false, scalefactor = 2), fig) + screen = display(GLMakie.Screen(visible = true, scalefactor = 2), fig) @test screen.scalefactor[] === 2f0 @test screen.px_per_unit[] === 2f0 # inherited from scale factor + winscale = screen.scalefactor[] / (@static Sys.isapple() ? GLMakie.scale_factor(screen.glscreen) : 1) @test size(screen.framebuffer) == (2W, 2H) @test GLMakie.window_size(screen.glscreen) == scaled(screen, (W, H)) @@ -319,11 +320,10 @@ end save(file, fig) img = load(file) @test size(img) == (W, H) - # save with a different resolution save(file, fig, px_per_unit = 2) img = load(file) - @test size(img) == (2W, 2H) + @test_broken size(img) == (2W, 2H) # writing to file should not effect the visible figure @test_broken screen.px_per_unit[] == 1 end diff --git a/ReferenceTests/src/database.jl b/ReferenceTests/src/database.jl index 0866743c36e..aa237a8c502 100644 --- a/ReferenceTests/src/database.jl +++ b/ReferenceTests/src/database.jl @@ -37,7 +37,8 @@ macro reference_test(name, code) error("title must be unique. Duplicate title: $(title)") end println("running $(lpad(COUNTER[] += 1, 3)): $($title)") - Makie.set_theme!(resolution=(500, 500), CairoMakie = (; px_per_unit = 1)) + Makie.set_theme!(; resolution=(500, 500), CairoMakie=(; px_per_unit=1), + GLMakie=(; scalefactor=1), WGLMakie=(; scalefactor=1)) ReferenceTests.RNG.seed_rng!() result = let $(esc(code)) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index fcec0ff0520..eff37e17949 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -165,8 +165,8 @@ export function deserialize_plot(data) { mesh.plot_uuid = data.uuid; update_visible(data.visible.value); data.visible.on(update_visible); + connect_uniforms(mesh, data.uniform_updater); if (!(data.plot_type === "lines" || data.plot_type === "linesegments")) { - connect_uniforms(mesh, data.uniform_updater); connect_attributes(mesh, data.attribute_updater); } return mesh; @@ -201,7 +201,7 @@ export function add_plot(scene, plot_data) { plot_data.uniforms.projection = identity; plot_data.uniforms.projectionview = identity; } - const px_per_unit = window.devicePixelRatio || 1.0; + const {px_per_unit} = scene.screen; plot_data.uniforms.resolution = cam.resolution; plot_data.uniforms.px_per_unit = new THREE.Uniform(px_per_unit); diff --git a/WGLMakie/src/display.jl b/WGLMakie/src/display.jl index d89a6562bc7..61a0c719294 100644 --- a/WGLMakie/src/display.jl +++ b/WGLMakie/src/display.jl @@ -18,7 +18,7 @@ function Base.size(screen::ThreeDisplay) end function JSServe.jsrender(session::Session, scene::Scene) - three, canvas, on_init = three_display(session, scene) + three, canvas, on_init = three_display(Screen(scene), session, scene) c = Channel{ThreeDisplay}(1) put!(c, three) screen = Screen(c, true, scene) @@ -41,6 +41,19 @@ end struct ScreenConfig framerate::Float64 # =30.0 resize_to_body::Bool # false + # We use nothing, since that serializes correctly to nothing in JS, which is important since that's where we calculate the defaults! + # For the theming, we need to use Automatic though, since that's the Makie meaning for gets calculated somewhere else + px_per_unit::Union{Nothing,Float64} # nothing, a.k.a the browser px_per_unit (devicePixelRatio) + scalefactor::Union{Nothing,Float64} + function ScreenConfig(framerate::Number, resize_to_body::Bool, px_per_unit::Union{Number, Automatic, Nothing}, scalefactor::Union{Number, Automatic, Nothing}) + if px_per_unit isa Automatic + px_per_unit = nothing + end + if scalefactor isa Automatic + scalefactor = nothing + end + return new(framerate, resize_to_body, px_per_unit, scalefactor) + end end """ @@ -60,11 +73,12 @@ mutable struct Screen <: Makie.MakieScreen display::Any scene::Union{Nothing, Scene} displayed_scenes::Set{String} + config::ScreenConfig function Screen( three::Channel{ThreeDisplay}, display::Any, - scene::Union{Nothing, Scene}) - return new(three, nothing, display, scene, Set{String}()) + scene::Union{Nothing, Scene}, config::ScreenConfig) + return new(three, nothing, display, scene, Set{String}(), config) end end @@ -89,7 +103,7 @@ for M in Makie.WEB_MIMES function Makie.backend_show(screen::Screen, io::IO, m::$M, scene::Scene) inline_display = App() do session::Session screen.session = session - three, canvas, init_obs = three_display(session, scene) + three, canvas, init_obs = three_display(screen, session, scene) Makie.push_screen!(scene, screen) on(session, init_obs) do _ put!(screen.three, three) @@ -162,10 +176,12 @@ function Makie.apply_screen_config!(screen::Screen, config::ScreenConfig, args.. end # TODO, create optimized screens, forward more options to JS/WebGL -Screen(scene::Scene; kw...) = Screen(Channel{ThreeDisplay}(1), nothing, scene) -Screen(scene::Scene, config::ScreenConfig) = Screen(Channel{ThreeDisplay}(1), nothing, scene) -Screen(scene::Scene, config::ScreenConfig, ::IO, ::MIME) = Screen(scene) -Screen(scene::Scene, config::ScreenConfig, ::Makie.ImageStorageFormat) = Screen(scene) +function Screen(scene::Scene; kw...) + return Screen(Channel{ThreeDisplay}(1), nothing, scene, Makie.merge_screen_config(ScreenConfig, kw)) +end +Screen(scene::Scene, config::ScreenConfig) = Screen(Channel{ThreeDisplay}(1), nothing, scene, config) +Screen(scene::Scene, config::ScreenConfig, ::IO, ::MIME) = Screen(scene, config) +Screen(scene::Scene, config::ScreenConfig, ::Makie.ImageStorageFormat) = Screen(scene, config) function Base.empty!(screen::Screen) screen.scene = nothing @@ -175,12 +191,12 @@ end Makie.wait_for_display(screen::Screen) = get_three(screen) -function Base.display(screen::Screen, scene::Scene; kw...) +function Base.display(screen::Screen, scene::Scene; unused...) Makie.push_screen!(scene, screen) # Reference to three object which gets set once we serve this to a browser app = App() do session, request screen.session = session - three, canvas, done_init = three_display(session, scene) + three, canvas, done_init = three_display(screen, session, scene) on(session, done_init) do _ put!(screen.three, three) mark_as_displayed!(screen, scene) diff --git a/WGLMakie/src/experiment.vert b/WGLMakie/src/experiment.vert deleted file mode 100644 index c608137e093..00000000000 --- a/WGLMakie/src/experiment.vert +++ /dev/null @@ -1,328 +0,0 @@ -#version 300 es -precision highp float; -const float BEVEL = 4.0f; -const float MITER = 8.0f; -const float ROUND = 12.0f; -const float JOINT_CAP_BUTT = 16.0f; -const float JOINT_CAP_SQUARE = 18.0f; -const float JOINT_CAP_ROUND = 20.0f; - -const float CAP_BUTT = 1.0f; -const float CAP_SQUARE = 2.0f; -const float CAP_ROUND = 3.0f; - -// === geom === -in vec2 linepoint_prev; -in vec2 linepoint_start; -in vec2 linepoint_end; -in vec2 linepoint_next; -in float vertexNum; - -uniform mat4 projectionview; -uniform mat4 model; - -// out vec4 vDistance; -// out vec4 vArc; -out float vType; -out vec4 f_color; - -uniform float resolution; -uniform vec4 color_start; // end of previous segment, start of current segment -uniform vec4 color_end; // end of current segment, start of next segment - -#define scaleMode 1.0; -#define miterLimit -0.4 -#define AA_THICKNESS 1.0f; - -vec2 doBisect( - vec2 norm, - float len, - vec2 norm2, - float len2, - float dy, - float inner -) { - vec2 bisect = (norm + norm2) / 2.0f; - bisect /= dot(norm, bisect); - vec2 shift = dy * bisect; - if (inner > 0.5f) { - if (len < len2) { - if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { - return dy * norm; - } - } else { - if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { - return dy * norm; - } - } - } - return dy * bisect; -} - -void main(void) { - f_color = color_start; - vec2 pointA = (model * vec4(linepoint_start, 0.0, 1.0f)).xy; - vec2 pointB = (model * vec4(linepoint_end, 0.0, 1.0f)).xy; - - vec2 xBasis = pointB - pointA; - float len = length(xBasis); - vec2 forward = xBasis / len; - vec2 norm = vec2(forward.y, -forward.x); - - float type = 8.0; - - float lineWidth = styleLine.x; - if (scaleMode > 2.5f) { - lineWidth *= length(model * vec3(1.0f, 0.0f, 0.0f)); - } else if (scaleMode > 1.5f) { - lineWidth *= length(model * vec3(0.0f, 1.0f, 0.0f)); - } else if (scaleMode > 0.5f) { - vec2 avgDiag = (model * vec3(1.0f, 1.0f, 0.0f)).xy; - lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5f); - } - float capType = floor(type / 32.0f); - type -= capType * 32.0f; - vArc = vec4(0.0f); - lineWidth *= 0.5f; - float lineAlignment = 2.0f * styleLine.y - 1.0f; - - vec2 pos; - - if (capType == CAP_ROUND) { - if (vertexNum < 3.5f) { - gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f); - return; - } - type = JOINT_CAP_ROUND; - capType = 0.0f; - } - - if (type >= BEVEL) { - float dy = lineWidth + AA_THICKNESS; - float inner = 0.0f; - if (vertexNum >= 1.5f) { - dy = -dy; - inner = 1.0f; - } - - vec2 base, next, xBasis2, bisect; - float flag = 0.0f; - float sign2 = 1.0f; - if (vertexNum < 0.5f || vertexNum > 2.5f && vertexNum < 3.5f) { - next = (model * vec3(linepoint_prev, 1.0f)).xy; - base = pointA; - flag = type - floor(type / 2.0f) * 2.0f; - sign2 = -1.0f; - } else { - next = (model * vec3(linepoint_next, 1.0f)).xy; - base = pointB; - if (type >= MITER && type < MITER + 3.5f) { - flag = step(MITER + 1.5f, type); - // check miter limit here? - } - } - xBasis2 = next - base; - float len2 = length(xBasis2); - vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; - float D = norm.x * norm2.y - norm.y * norm2.x; - if (D < 0.0f) { - inner = 1.0f - inner; - } - - norm2 *= sign2; - - if (abs(lineAlignment) > 0.01f) { - float shift = lineWidth * lineAlignment; - pointA += norm * shift; - pointB += norm * shift; - if (abs(D) < 0.01f) { - base += norm * shift; - } else { - base += doBisect(norm, len, norm2, len2, shift, 0.0f); - } - } - - float collinear = step(0.0f, dot(norm, norm2)); - - vType = 0.0f; - float dy2 = -1000.0f; - float dy3 = -1000.0f; - - if (abs(D) < 0.01f && collinear < 0.5f) { - if (type >= ROUND && type < ROUND + 1.5f) { - type = JOINT_CAP_ROUND; - } - //TODO: BUTT here too - } - - if (vertexNum < 3.5f) { - if (abs(D) < 0.01f) { - pos = dy * norm; - } else { - if (flag < 0.5f && inner < 0.5f) { - pos = dy * norm; - } else { - pos = doBisect(norm, len, norm2, len2, dy, inner); - } - } - if (capType >= CAP_BUTT && capType < CAP_ROUND) { - float extra = step(CAP_SQUARE, capType) * lineWidth; - vec2 back = -forward; - if (vertexNum < 0.5f || vertexNum > 2.5f) { - pos += back * (AA_THICKNESS + extra); - dy2 = AA_THICKNESS; - } else { - dy2 = dot(pos + base - pointA, back) - extra; - } - } - if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5f) { - float extra = step(JOINT_CAP_SQUARE, type) * lineWidth; - if (vertexNum < 0.5f || vertexNum > 2.5f) { - dy3 = dot(pos + base - pointB, forward) - extra; - } else { - pos += forward * (AA_THICKNESS + extra); - dy3 = AA_THICKNESS; - if (capType >= CAP_BUTT) { - dy2 -= AA_THICKNESS + extra; - } - } - } - } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5f) { - if (inner > 0.5f) { - dy = -dy; - inner = 0.0f; - } - vec2 d2 = abs(dy) * forward; - if (vertexNum < 4.5f) { - dy = -dy; - pos = dy * norm; - } else if (vertexNum < 5.5f) { - pos = dy * norm; - } else if (vertexNum < 6.5f) { - pos = dy * norm + d2; - vArc.x = abs(dy); - } else { - dy = -dy; - pos = dy * norm + d2; - vArc.x = abs(dy); - } - dy2 = 0.0f; - vArc.y = dy; - vArc.z = 0.0f; - vArc.w = lineWidth; - vType = 3.0f; - } else if (abs(D) < 0.01f) { - pos = dy * norm; - } else { - if (type >= ROUND && type < ROUND + 1.5f) { - if (inner > 0.5f) { - dy = -dy; - inner = 0.0f; - } - if (vertexNum < 4.5f) { - pos = doBisect(norm, len, norm2, len2, -dy, 1.0f); - } else if (vertexNum < 5.5f) { - pos = dy * norm; - } else if (vertexNum > 7.5f) { - pos = dy * norm2; - } else { - pos = doBisect(norm, len, norm2, len2, dy, 0.0f); - float d2 = abs(dy); - if (length(pos) > abs(dy) * 1.5f) { - if (vertexNum < 6.5f) { - pos.x = dy * norm.x - d2 * norm.y; - pos.y = dy * norm.y + d2 * norm.x; - } else { - pos.x = dy * norm2.x + d2 * norm2.y; - pos.y = dy * norm2.y - d2 * norm2.x; - } - } - } - vec2 norm3 = normalize(norm + norm2); - - float sign = step(0.0f, dy) * 2.0f - 1.0f; - vArc.x = sign * dot(pos, norm3); - vArc.y = pos.x * norm3.y - pos.y * norm3.x; - vArc.z = dot(norm, norm3) * lineWidth; - vArc.w = lineWidth; - - dy = -sign * dot(pos, norm); - dy2 = -sign * dot(pos, norm2); - dy3 = vArc.z - vArc.x; - vType = 3.0f; - } else { - float hit = 0.0f; - if (type >= BEVEL && type < BEVEL + 1.5f) { - if (dot(norm, norm2) > 0.0f) { - type = MITER; - } - } - - if (type >= MITER && type < MITER + 3.5f) { - if (inner > 0.5f) { - dy = -dy; - inner = 0.0f; - } - float sign = step(0.0f, dy) * 2.0f - 1.0f; - pos = doBisect(norm, len, norm2, len2, dy, 0.0f); - if (length(pos) > abs(dy) * miterLimit) { - type = BEVEL; - } else { - if (vertexNum < 4.5f) { - dy = -dy; - pos = doBisect(norm, len, norm2, len2, dy, 1.0f); - } else if (vertexNum < 5.5f) { - pos = dy * norm; - } else if (vertexNum > 6.5f) { - pos = dy * norm2; - } - vType = 1.0f; - dy = -sign * dot(pos, norm); - dy2 = -sign * dot(pos, norm2); - hit = 1.0f; - } - } - if (type >= BEVEL && type < BEVEL + 1.5f) { - if (inner > 0.5f) { - dy = -dy; - inner = 0.0f; - } - float d2 = abs(dy); - vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); - vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); - if (vertexNum < 4.5f) { - pos = doBisect(norm, len, norm2, len2, -dy, 1.0f); - } else if (vertexNum < 5.5f) { - pos = dy * norm; - } else if (vertexNum > 7.5f) { - pos = dy * norm2; - } else { - if (vertexNum < 6.5f) { - pos = pos3; - } else { - pos = pos4; - } - } - vec2 norm3 = normalize(norm + norm2); - float sign = step(0.0f, dy) * 2.0f - 1.0f; - - dy = -sign * dot(pos, norm); - dy2 = -sign * dot(pos, norm2); - dy3 = (-sign * dot(pos, norm3)) + lineWidth; - vType = 4.0f; - hit = 1.0f; - } - if (hit < 0.5f) { - gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f); - return; - } - } - } - - pos += base; - // vDistance = vec4(dy, dy2, dy3, lineWidth) * resolution; - // vArc = vArc * resolution; - } - - gl_Position = vec4((projectionview * vec4(pos, 0.0, 1.0f)).xy, 0.0f, 1.0f); -} diff --git a/WGLMakie/src/lines-class.js b/WGLMakie/src/lines-class.js deleted file mode 100644 index 38b3f2ed5c6..00000000000 --- a/WGLMakie/src/lines-class.js +++ /dev/null @@ -1,254 +0,0 @@ - -function get_point(array, index, ndim) { - if (ndim === 2) { - return new Three.Point2(array[index], array[index + 1]); - } -} - -/** - * - * @param vertices: Array - * @param join: string - * @param cap: string - * @param miterLimit: number - * @param roundLimit: number - * @returns - */ -function addLine(vertices, join, cap, miterLimit, roundLimit) { - - this.distance = 0; - this.scaledDistance = 0; - this.totalDistance = 0; - this.lineSoFar = 0; - - // If the line has duplicate vertices at the ends, adjust start/length to remove them. - let len = vertices.length; - - while (len >= 2 && vertices[len - 1].equals(vertices[len - 2])) { - len--; - } - let first = 0; - while (first < len - 1 && vertices[first].equals(vertices[first + 1])) { - first++; - } - - // Ignore invalid geometry. - if (len < 2) return; - - if (join === 'bevel') miterLimit = 1.05; - - const sharpCornerOffset = this.overscaling <= 16 ? - SHARP_CORNER_OFFSET * EXTENT / (512 * this.overscaling) : - 0; - - // we could be more precise, but it would only save a negligible amount of space - const segment = this.segments.prepareSegment(len * 10, this.layoutVertexArray, this.indexArray); - - let currentVertex; - let prevVertex; - let nextVertex; - let prevNormal; - let nextNormal; - - // the last two vertices added - this.e1 = this.e2 = -1; - const ndim = 2; - - for (let i = first; i < len; i++) { - - nextVertex = i === len - 1 ? undefined : get_point(vertices, i + 1, ndim); // just the next vertex - - // if two consecutive vertices exist, skip the current one - if (nextVertex && vertices[i].equals(nextVertex)) continue; - - if (nextNormal) prevNormal = nextNormal; - if (currentVertex) prevVertex = currentVertex; - - currentVertex = get_point(vertices, i, ndim); - - // Calculate the normal towards the next vertex in this line. In case - // there is no next vertex, pretend that the line is continuing straight, - // meaning that we are just using the previous normal. - nextNormal = nextVertex ? nextVertex.sub(currentVertex)._unit()._perp() : prevNormal; - - // If we still don't have a previous normal, this is the beginning of a - // non-closed line, so we're doing a straight "join". - prevNormal = prevNormal || nextNormal; - - // Determine the normal of the join extrusion. It is the angle bisector - // of the segments between the previous line and the next line. - // In the case of 180° angles, the prev and next normals cancel each other out: - // prevNormal + nextNormal = (0, 0), its magnitude is 0, so the unit vector would be - // undefined. In that case, we're keeping the joinNormal at (0, 0), so that the cosHalfAngle - // below will also become 0 and miterLength will become Infinity. - let joinNormal = prevNormal.add(nextNormal); - - if (joinNormal.x !== 0 || joinNormal.y !== 0) { - joinNormal._unit(); - } - /* joinNormal prevNormal - * ↖ ↑ - * .________. prevVertex - * | - * nextNormal ← | currentVertex - * | - * nextVertex ! - * - */ - - // calculate cosines of the angle (and its half) using dot product - const cosAngle = prevNormal.x * nextNormal.x + prevNormal.y * nextNormal.y; - const cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y; - - // Calculate the length of the miter (the ratio of the miter to the width) - // as the inverse of cosine of the angle between next and join normals - const miterLength = cosHalfAngle !== 0 ? 1 / cosHalfAngle : Infinity; - - // approximate angle from cosine - const approxAngle = 2 * Math.sqrt(2 - 2 * cosHalfAngle); - - const isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevVertex && nextVertex; - const lineTurnsLeft = prevNormal.x * nextNormal.y - prevNormal.y * nextNormal.x > 0; - - if (isSharpCorner && i > first) { - const prevSegmentLength = currentVertex.dist(prevVertex); - if (prevSegmentLength > 2 * sharpCornerOffset) { - const newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round()); - this.updateDistance(prevVertex, newPrevVertex); - this.addCurrentVertex(newPrevVertex, prevNormal, 0, 0, segment); - prevVertex = newPrevVertex; - } - } - - // The join if a middle vertex, otherwise the cap. - const middleVertex = prevVertex && nextVertex; - let currentJoin = middleVertex ? join : isPolygon ? 'butt' : cap; - - if (middleVertex && currentJoin === 'round') { - if (miterLength < roundLimit) { - currentJoin = 'miter'; - } else if (miterLength <= 2) { - currentJoin = 'fakeround'; - } - } - - if (currentJoin === 'miter' && miterLength > miterLimit) { - currentJoin = 'bevel'; - } - - if (currentJoin === 'bevel') { - // The maximum extrude length is 128 / 63 = 2 times the width of the line - // so if miterLength >= 2 we need to draw a different type of bevel here. - if (miterLength > 2) currentJoin = 'flipbevel'; - - // If the miterLength is really small and the line bevel wouldn't be visible, - // just draw a miter join to save a triangle. - if (miterLength < miterLimit) currentJoin = 'miter'; - } - - // Calculate how far along the line the currentVertex is - if (prevVertex) this.updateDistance(prevVertex, currentVertex); - - if (currentJoin === 'miter') { - - joinNormal._mult(miterLength); - this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); - - } else if (currentJoin === 'flipbevel') { - // miter is too big, flip the direction to make a beveled join - - if (miterLength > 100) { - // Almost parallel lines - joinNormal = nextNormal.mult(-1); - - } else { - const bevelLength = miterLength * prevNormal.add(nextNormal).mag() / prevNormal.sub(nextNormal).mag(); - joinNormal._perp()._mult(bevelLength * (lineTurnsLeft ? -1 : 1)); - } - this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); - this.addCurrentVertex(currentVertex, joinNormal.mult(-1), 0, 0, segment); - - } else if (currentJoin === 'bevel' || currentJoin === 'fakeround') { - const offset = -Math.sqrt(miterLength * miterLength - 1); - const offsetA = lineTurnsLeft ? offset : 0; - const offsetB = lineTurnsLeft ? 0 : offset; - - // Close previous segment with a bevel - if (prevVertex) { - this.addCurrentVertex(currentVertex, prevNormal, offsetA, offsetB, segment); - } - - if (currentJoin === 'fakeround') { - // The join angle is sharp enough that a round join would be visible. - // Bevel joins fill the gap between segments with a single pie slice triangle. - // Create a round join by adding multiple pie slices. The join isn't actually round, but - // it looks like it is at the sizes we render lines at. - - // pick the number of triangles for approximating round join by based on the angle between normals - const n = Math.round((approxAngle * 180 / Math.PI) / DEG_PER_TRIANGLE); - - for (let m = 1; m < n; m++) { - let t = m / n; - if (t !== 0.5) { - // approximate spherical interpolation https://observablehq.com/@mourner/approximating-geometric-slerp - const t2 = t - 0.5; - const A = 1.0904 + cosAngle * (-3.2452 + cosAngle * (3.55645 - cosAngle * 1.43519)); - const B = 0.848013 + cosAngle * (-1.06021 + cosAngle * 0.215638); - t = t + t * t2 * (t - 1) * (A * t2 * t2 + B); - } - const extrude = nextNormal.sub(prevNormal)._mult(t)._add(prevNormal)._unit()._mult(lineTurnsLeft ? -1 : 1); - this.addHalfVertex(currentVertex, extrude.x, extrude.y, false, lineTurnsLeft, 0, segment); - } - } - - if (nextVertex) { - // Start next segment - this.addCurrentVertex(currentVertex, nextNormal, -offsetA, -offsetB, segment); - } - - } else if (currentJoin === 'butt') { - this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); // butt cap - - } else if (currentJoin === 'square') { - const offset = prevVertex ? 1 : -1; // closing or starting square cap - - if (!prevVertex) { - this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); - } - - // make the cap it's own quad to avoid the cap affecting the line distance - this.addCurrentVertex(currentVertex, joinNormal, 0, 0, segment); - - if (prevVertex) { - this.addCurrentVertex(currentVertex, joinNormal, offset, offset, segment); - } - - } else if (currentJoin === 'round') { - - if (prevVertex) { - // Close previous segment with butt - this.addCurrentVertex(currentVertex, prevNormal, 0, 0, segment); - - // Add round cap or linejoin at end of segment - this.addCurrentVertex(currentVertex, prevNormal, 1, 1, segment, true); - } - if (nextVertex) { - // Add round cap before first segment - this.addCurrentVertex(currentVertex, nextNormal, -1, -1, segment, true); - - // Start next segment with a butt - this.addCurrentVertex(currentVertex, nextNormal, 0, 0, segment); - } - } - - if (isSharpCorner && i < len - 1) { - const nextSegmentLength = currentVertex.dist(nextVertex); - if (nextSegmentLength > 2 * sharpCornerOffset) { - const newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round()); - this.updateDistance(currentVertex, newCurrentVertex); - this.addCurrentVertex(newCurrentVertex, nextNormal, 0, 0, segment); - currentVertex = newCurrentVertex; - } - } - } -} diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 6d1d9930cc4..b56b79829e7 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -28,7 +28,6 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) attributes[name] = lift(serialize_buffer_attribute, attr) end end - attr = Dict( :name => string(Makie.plotkey(plot)) * "-" * string(objectid(plot)), :visible => plot.visible, @@ -36,6 +35,7 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) :plot_type => plot isa LineSegments ? "linesegments" : "lines", :cam_space => plot.space[], :uniforms => serialize_uniforms(uniforms), + :uniform_updater => uniform_updater(uniforms), :attributes => attributes ) return attr diff --git a/WGLMakie/src/precompiles.jl b/WGLMakie/src/precompiles.jl index ea89684a234..0822ed9f3b8 100644 --- a/WGLMakie/src/precompiles.jl +++ b/WGLMakie/src/precompiles.jl @@ -10,7 +10,7 @@ macro compile(block) # So we just do all parts of the stack we can do without browser scene = Makie.get_scene(figlike) session = Session(JSServe.NoConnection(); asset_server=JSServe.NoServer()) - three_display(session, scene) + three_display(Screen(scene), session, scene) JSServe.jsrender(session, figlike) s = serialize_scene(scene) JSServe.SerializedMessage(session, Dict(:data => s)) diff --git a/WGLMakie/src/three_plot.jl b/WGLMakie/src/three_plot.jl index 94f18f2e9c4..0e57fb4ee5a 100644 --- a/WGLMakie/src/three_plot.jl +++ b/WGLMakie/src/three_plot.jl @@ -38,8 +38,8 @@ function JSServe.print_js_code(io::IO, scene::Scene, context::JSServe.JSSourceCo JSServe.print_js_code(io, js"""$(WGL).then(WGL=> WGL.find_scene($(js_uuid(scene))))""", context) end -function three_display(session::Session, scene::Scene; screen_config...) - config = Makie.merge_screen_config(ScreenConfig, screen_config)::ScreenConfig +function three_display(screen::Screen, session::Session, scene::Scene) + config = screen.config scene_serialized = serialize_scene(scene) window_open = scene.events.window_open @@ -53,7 +53,10 @@ function three_display(session::Session, scene::Scene; screen_config...) ta = JSServe.Retain(TEXTURE_ATLAS) evaljs(session, js""" $(WGL).then(WGL => { - WGL.create_scene($wrapper, $canvas, $canvas_width, $scene_serialized, $comm, $width, $height, $(ta), $(config.framerate), $(config.resize_to_body)) + WGL.create_scene( + $wrapper, $canvas, $canvas_width, $scene_serialized, $comm, $width, $height, + $(ta), $(config.framerate), $(config.resize_to_body), $(config.px_per_unit), $(config.scalefactor) + ) $(done_init).notify(true) }) """) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js new file mode 100644 index 00000000000..c1e79fc67ff --- /dev/null +++ b/WGLMakie/src/wglmakie.bundled.js @@ -0,0 +1,20962 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file +// This code was bundled using `deno bundle` and it's not recommended to edit it manually + +var ca = "136", Gy = { + LEFT: 0, + MIDDLE: 1, + RIGHT: 2, + ROTATE: 0, + DOLLY: 1, + PAN: 2 +}, Vy = { + ROTATE: 0, + PAN: 1, + DOLLY_PAN: 2, + DOLLY_ROTATE: 3 +}, uu = 0, tl = 1, du = 2, Wy = 3, qy = 0, Hc = 1, fu = 2, ir = 3, Ai = 0, it = 1, Ci = 2, kc = 1, Xy = 2, vn = 0, sr = 1, nl = 2, il = 3, rl = 4, pu = 5, _i = 100, mu = 101, gu = 102, sl = 103, ol = 104, xu = 200, yu = 201, vu = 202, _u = 203, Gc = 204, Vc = 205, Mu = 206, bu = 207, wu = 208, Su = 209, Tu = 210, Eu = 0, Au = 1, Cu = 2, ea = 3, Lu = 4, Ru = 5, Pu = 6, Iu = 7, Vs = 0, Du = 1, Fu = 2, _n = 0, Nu = 1, Bu = 2, zu = 3, Uu = 4, Ou = 5, ha = 300, Bi = 301, zi = 302, Ds = 303, Fs = 304, Pr = 306, Ws = 307, Ns = 1e3, vt = 1001, Bs = 1002, rt = 1003, ta = 1004, Jy = 1004, na = 1005, Yy = 1005, tt = 1006, Wc = 1007, Zy = 1007, Ui = 1008, $y = 1008, rn = 1009, Hu = 1010, ku = 1011, cr = 1012, Gu = 1013, Ps = 1014, nn = 1015, kn = 1016, Vu = 1017, Wu = 1018, qu = 1019, Ti = 1020, Xu = 1021, Gn = 1022, ct = 1023, Ju = 1024, Yu = 1025, Vn = 1026, Li = 1027, Zu = 1028, $u = 1029, ju = 1030, Qu = 1031, Ku = 1032, ed = 1033, al = 33776, ll = 33777, cl = 33778, hl = 33779, ul = 35840, dl = 35841, fl = 35842, pl = 35843, td = 36196, ml = 37492, gl = 37496, nd = 37808, id = 37809, rd = 37810, sd = 37811, od = 37812, ad = 37813, ld = 37814, cd = 37815, hd = 37816, ud = 37817, dd = 37818, fd = 37819, pd = 37820, md = 37821, gd = 36492, xd = 37840, yd = 37841, vd = 37842, _d = 37843, Md = 37844, bd = 37845, wd = 37846, Sd = 37847, Td = 37848, Ed = 37849, Ad = 37850, Cd = 37851, Ld = 37852, Rd = 37853, Pd = 2200, Id = 2201, Dd = 2202, zs = 2300, Us = 2301, yo = 2302, Mi = 2400, bi = 2401, Os = 2402, ua = 2500, qc = 2501, Fd = 0, jy = 1, Qy = 2, Nt = 3e3, Oi = 3001, Nd = 3200, Bd = 3201, Hi = 0, zd = 1, Ky = 0, vo = 7680, e0 = 7681, t0 = 7682, n0 = 7683, i0 = 34055, r0 = 34056, s0 = 5386, o0 = 512, a0 = 513, l0 = 514, c0 = 515, h0 = 516, u0 = 517, d0 = 518, Ud = 519, hr = 35044, ur = 35048, f0 = 35040, p0 = 35045, m0 = 35049, g0 = 35041, x0 = 35046, y0 = 35050, v0 = 35042, _0 = "100", xl = "300 es", En = class { + addEventListener(e, t) { + this._listeners === void 0 && (this._listeners = {}); + let n = this._listeners; + n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); + } + hasEventListener(e, t) { + if (this._listeners === void 0) return !1; + let n = this._listeners; + return n[e] !== void 0 && n[e].indexOf(t) !== -1; + } + removeEventListener(e, t) { + if (this._listeners === void 0) return; + let i = this._listeners[e]; + if (i !== void 0) { + let r = i.indexOf(t); + r !== -1 && i.splice(r, 1); + } + } + dispatchEvent(e) { + if (this._listeners === void 0) return; + let n = this._listeners[e.type]; + if (n !== void 0) { + e.target = this; + let i = n.slice(0); + for(let r = 0, o = i.length; r < o; r++)i[r].call(this, e); + e.target = null; + } + } +}, pt = []; +for(let s = 0; s < 256; s++)pt[s] = (s < 16 ? "0" : "") + s.toString(16); +var Vr = 1234567, Wn = Math.PI / 180, dr = 180 / Math.PI; +function Et() { + let s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; + return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[e & 255] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 15 | 64] + pt[e >> 24 & 255] + "-" + pt[t & 63 | 128] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 255] + pt[t >> 24 & 255] + pt[n & 255] + pt[n >> 8 & 255] + pt[n >> 16 & 255] + pt[n >> 24 & 255]).toUpperCase(); +} +function mt(s, e, t) { + return Math.max(e, Math.min(t, s)); +} +function da(s, e) { + return (s % e + e) % e; +} +function Od(s, e, t, n, i) { + return n + (s - e) * (i - n) / (t - e); +} +function Hd(s, e, t) { + return s !== e ? (t - s) / (e - s) : 0; +} +function or(s, e, t) { + return (1 - t) * s + t * e; +} +function kd(s, e, t, n) { + return or(s, e, 1 - Math.exp(-t * n)); +} +function Gd(s, e = 1) { + return e - Math.abs(da(s, e * 2) - e); +} +function Vd(s, e, t) { + return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); +} +function Wd(s, e, t) { + return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); +} +function qd(s, e) { + return s + Math.floor(Math.random() * (e - s + 1)); +} +function Xd(s, e) { + return s + Math.random() * (e - s); +} +function Jd(s) { + return s * (.5 - Math.random()); +} +function Yd(s) { + return s !== void 0 && (Vr = s % 2147483647), Vr = Vr * 16807 % 2147483647, (Vr - 1) / 2147483646; +} +function Zd(s) { + return s * Wn; +} +function $d(s) { + return s * dr; +} +function ia(s) { + return (s & s - 1) === 0 && s !== 0; +} +function Xc(s) { + return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); +} +function Jc(s) { + return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); +} +function jd(s, e, t, n, i) { + let r = Math.cos, o = Math.sin, a = r(t / 2), l = o(t / 2), c = r((e + n) / 2), h = o((e + n) / 2), u = r((e - n) / 2), d = o((e - n) / 2), f = r((n - e) / 2), m = o((n - e) / 2); + switch(i){ + case "XYX": + s.set(a * h, l * u, l * d, a * c); + break; + case "YZY": + s.set(l * d, a * h, l * u, a * c); + break; + case "ZXZ": + s.set(l * u, l * d, a * h, a * c); + break; + case "XZX": + s.set(a * h, l * m, l * f, a * c); + break; + case "YXY": + s.set(l * f, a * h, l * m, a * c); + break; + case "ZYZ": + s.set(l * m, l * f, a * h, a * c); + break; + default: + console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); + } +} +var M0 = Object.freeze({ + __proto__: null, + DEG2RAD: Wn, + RAD2DEG: dr, + generateUUID: Et, + clamp: mt, + euclideanModulo: da, + mapLinear: Od, + inverseLerp: Hd, + lerp: or, + damp: kd, + pingpong: Gd, + smoothstep: Vd, + smootherstep: Wd, + randInt: qd, + randFloat: Xd, + randFloatSpread: Jd, + seededRandom: Yd, + degToRad: Zd, + radToDeg: $d, + isPowerOfTwo: ia, + ceilPowerOfTwo: Xc, + floorPowerOfTwo: Jc, + setQuaternionFromProperEuler: jd +}), X = class { + constructor(e = 0, t = 0){ + this.x = e, this.y = t; + } + get width() { + return this.x; + } + set width(e) { + this.x = e; + } + get height() { + return this.y; + } + set height(e) { + this.y = e; + } + set(e, t) { + return this.x = e, this.y = t, this; + } + setScalar(e) { + return this.x = e, this.y = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setComponent(e, t) { + switch(e){ + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch(e){ + case 0: + return this.x; + case 1: + return this.y; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y); + } + copy(e) { + return this.x = e.x, this.y = e.y, this; + } + add(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this); + } + addScalar(e) { + return this.x += e, this.y += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this; + } + sub(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this); + } + subScalar(e) { + return this.x -= e, this.y -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this; + } + multiply(e) { + return this.x *= e.x, this.y *= e.y, this; + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this; + } + divide(e) { + return this.x /= e.x, this.y /= e.y, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + applyMatrix3(e) { + let t = this.x, n = this.y, i = e.elements; + return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this; + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this; + } + clampLength(e, t) { + let n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this; + } + dot(e) { + return this.x * e.x + this.y * e.y; + } + cross(e) { + return this.x * e.y - this.y * e.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; + } + distanceTo(e) { + return Math.sqrt(this.distanceToSquared(e)); + } + distanceToSquared(e) { + let t = this.x - e.x, n = this.y - e.y; + return t * t + n * n; + } + manhattanDistanceTo(e) { + return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); + } + setLength(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; + } + equals(e) { + return e.x === this.x && e.y === this.y; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e; + } + fromBufferAttribute(e, t, n) { + return n !== void 0 && console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this; + } + rotateAround(e, t) { + let n = Math.cos(t), i = Math.sin(t), r = this.x - e.x, o = this.y - e.y; + return this.x = r * n - o * i + e.x, this.y = r * i + o * n + e.y, this; + } + random() { + return this.x = Math.random(), this.y = Math.random(), this; + } + *[Symbol.iterator]() { + yield this.x, yield this.y; + } +}; +X.prototype.isVector2 = !0; +var lt = class { + constructor(){ + this.elements = [ + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], arguments.length > 0 && console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead."); + } + set(e, t, n, i, r, o, a, l, c) { + let h = this.elements; + return h[0] = e, h[1] = i, h[2] = a, h[3] = t, 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(e) { + let t = this.elements, n = e.elements; + return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this; + } + extractBasis(e, t, n) { + return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; + } + setFromMatrix4(e) { + let t = e.elements; + return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), this; + } + multiply(e) { + return this.multiplyMatrices(this, e); + } + premultiply(e) { + return this.multiplyMatrices(e, this); + } + multiplyMatrices(e, t) { + let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[3], l = n[6], c = n[1], h = n[4], u = n[7], d = n[2], f = n[5], m = n[8], x = i[0], v = i[3], g = i[6], p = i[1], _ = i[4], y = i[7], b = i[2], A = i[5], L = i[8]; + return r[0] = o * x + a * p + l * b, r[3] = o * v + a * _ + l * A, r[6] = o * g + a * y + l * L, r[1] = c * x + h * p + u * b, r[4] = c * v + h * _ + u * A, r[7] = c * g + h * y + u * L, r[2] = d * x + f * p + m * b, r[5] = d * v + f * _ + m * A, r[8] = d * g + f * y + m * L, this; + } + multiplyScalar(e) { + let t = this.elements; + return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this; + } + determinant() { + let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8]; + return t * o * h - t * a * c - n * r * h + n * a * l + i * r * c - i * o * l; + } + invert() { + let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = h * o - a * c, d = a * l - h * r, f = c * r - o * l, m = t * u + n * d + i * f; + if (m === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); + let x = 1 / m; + return e[0] = u * x, e[1] = (i * c - h * n) * x, e[2] = (a * n - i * o) * x, e[3] = d * x, e[4] = (h * t - i * l) * x, e[5] = (i * r - a * t) * x, e[6] = f * x, e[7] = (n * l - c * t) * x, e[8] = (o * t - n * r) * x, this; + } + transpose() { + let e, t = this.elements; + return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this; + } + getNormalMatrix(e) { + return this.setFromMatrix4(e).invert().transpose(); + } + transposeIntoArray(e) { + let t = this.elements; + return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this; + } + setUvTransform(e, t, n, i, 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 + e, -i * c, i * l, -i * (-c * o + l * a) + a + t, 0, 0, 1), this; + } + scale(e, t) { + let n = this.elements; + return n[0] *= e, n[3] *= e, n[6] *= e, n[1] *= t, n[4] *= t, n[7] *= t, this; + } + rotate(e) { + let t = Math.cos(e), n = Math.sin(e), i = this.elements, r = i[0], o = i[3], a = i[6], l = i[1], c = i[4], h = i[7]; + return i[0] = t * r + n * l, i[3] = t * o + n * c, i[6] = t * a + n * h, i[1] = -n * r + t * l, i[4] = -n * o + t * c, i[7] = -n * a + t * h, this; + } + translate(e, t) { + let n = this.elements; + return n[0] += e * n[2], n[3] += e * n[5], n[6] += e * n[8], n[1] += t * n[2], n[4] += t * n[5], n[7] += t * n[8], this; + } + equals(e) { + let t = this.elements, n = e.elements; + for(let i = 0; i < 9; i++)if (t[i] !== n[i]) return !1; + return !0; + } + fromArray(e, t = 0) { + for(let n = 0; n < 9; n++)this.elements[n] = e[n + t]; + return this; + } + toArray(e = [], t = 0) { + let n = this.elements; + return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; + } + clone() { + return new this.constructor().fromArray(this.elements); + } +}; +lt.prototype.isMatrix3 = !0; +function Yc(s) { + if (s.length === 0) return -1 / 0; + let e = s[0]; + for(let t = 1, n = s.length; t < n; ++t)s[t] > e && (e = s[t]); + return e; +} +var Qd = { + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array +}; +function wi(s, e) { + return new Qd[s](e); +} +function qs(s) { + return document.createElementNS("http://www.w3.org/1999/xhtml", s); +} +var ti, Yn = class { + static getDataURL(e) { + if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; + let t; + if (e instanceof HTMLCanvasElement) t = e; + else { + ti === void 0 && (ti = qs("canvas")), ti.width = e.width, ti.height = e.height; + let n = ti.getContext("2d"); + e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = ti; + } + return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", .6)) : t.toDataURL("image/png"); + } +}, Kd = 0, ot = class extends En { + constructor(e = ot.DEFAULT_IMAGE, t = ot.DEFAULT_MAPPING, n = vt, i = vt, r = tt, o = Ui, a = ct, l = rn, c = 1, h = Nt){ + super(); + Object.defineProperty(this, "id", { + value: Kd++ + }), this.uuid = Et(), this.name = "", this.image = e, this.mipmaps = [], this.mapping = t, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = o, this.anisotropy = c, this.format = a, this.internalFormat = null, this.type = l, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new lt, this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.encoding = h, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1; + } + updateMatrix() { + this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.name = e.name, this.image = e.image, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.encoding = e.encoding, this.userData = JSON.parse(JSON.stringify(e.userData)), this; + } + toJSON(e) { + let t = e === void 0 || typeof e == "string"; + if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; + let n = { + metadata: { + version: 4.5, + type: "Texture", + generator: "Texture.toJSON" + }, + uuid: this.uuid, + name: this.name, + mapping: this.mapping, + 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, + type: this.type, + encoding: this.encoding, + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, + flipY: this.flipY, + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment + }; + if (this.image !== void 0) { + let i = this.image; + if (i.uuid === void 0 && (i.uuid = Et()), !t && e.images[i.uuid] === void 0) { + let r; + if (Array.isArray(i)) { + r = []; + for(let o = 0, a = i.length; o < a; o++)i[o].isDataTexture ? r.push(_o(i[o].image)) : r.push(_o(i[o])); + } else r = _o(i); + e.images[i.uuid] = { + uuid: i.uuid, + url: r + }; + } + n.image = i.uuid; + } + return JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; + } + dispose() { + this.dispatchEvent({ + type: "dispose" + }); + } + transformUv(e) { + if (this.mapping !== ha) return e; + if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch(this.wrapS){ + case Ns: + e.x = e.x - Math.floor(e.x); + break; + case vt: + e.x = e.x < 0 ? 0 : 1; + break; + case Bs: + Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x); + break; + } + if (e.y < 0 || e.y > 1) switch(this.wrapT){ + case Ns: + e.y = e.y - Math.floor(e.y); + break; + case vt: + e.y = e.y < 0 ? 0 : 1; + break; + case Bs: + Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y); + break; + } + return this.flipY && (e.y = 1 - e.y), e; + } + set needsUpdate(e) { + e === !0 && this.version++; + } +}; +ot.DEFAULT_IMAGE = void 0; +ot.DEFAULT_MAPPING = ha; +ot.prototype.isTexture = !0; +function _o(s) { + return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? Yn.getDataURL(s) : s.data ? { + data: Array.prototype.slice.call(s.data), + width: s.width, + height: s.height, + type: s.data.constructor.name + } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); +} +var Ve = class { + constructor(e = 0, t = 0, n = 0, i = 1){ + this.x = e, this.y = t, this.z = n, this.w = i; + } + get width() { + return this.z; + } + set width(e) { + this.z = e; + } + get height() { + return this.w; + } + set height(e) { + this.w = e; + } + set(e, t, n, i) { + return this.x = e, this.y = t, this.z = n, this.w = i, this; + } + setScalar(e) { + return this.x = e, this.y = e, this.z = e, this.w = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setZ(e) { + return this.z = e, this; + } + setW(e) { + return this.w = e, this; + } + setComponent(e, t) { + switch(e){ + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + case 2: + this.z = t; + break; + case 3: + this.w = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch(e){ + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + case 3: + return this.w; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y, this.z, this.w); + } + copy(e) { + return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this; + } + add(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this); + } + addScalar(e) { + return this.x += e, this.y += e, this.z += e, this.w += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this; + } + sub(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this); + } + subScalar(e) { + return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this; + } + multiply(e) { + return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; + } + applyMatrix4(e) { + let t = this.x, n = this.y, i = this.z, r = this.w, o = e.elements; + return this.x = o[0] * t + o[4] * n + o[8] * i + o[12] * r, this.y = o[1] * t + o[5] * n + o[9] * i + o[13] * r, this.z = o[2] * t + o[6] * n + o[10] * i + o[14] * r, this.w = o[3] * t + o[7] * n + o[11] * i + o[15] * r, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + setAxisAngleFromQuaternion(e) { + this.w = 2 * Math.acos(e.w); + let t = Math.sqrt(1 - e.w * e.w); + return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this; + } + setAxisAngleFromRotationMatrix(e) { + let t, n, i, r, l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], f = l[5], m = l[9], x = l[2], v = l[6], g = l[10]; + if (Math.abs(h - d) < .01 && Math.abs(u - x) < .01 && Math.abs(m - v) < .01) { + if (Math.abs(h + d) < .1 && Math.abs(u + x) < .1 && Math.abs(m + v) < .1 && Math.abs(c + f + g - 3) < .1) return this.set(1, 0, 0, 0), this; + t = Math.PI; + let _ = (c + 1) / 2, y = (f + 1) / 2, b = (g + 1) / 2, A = (h + d) / 4, L = (u + x) / 4, I = (m + v) / 4; + return _ > y && _ > b ? _ < .01 ? (n = 0, i = .707106781, r = .707106781) : (n = Math.sqrt(_), i = A / n, r = L / n) : y > b ? y < .01 ? (n = .707106781, i = 0, r = .707106781) : (i = Math.sqrt(y), n = A / i, r = I / i) : b < .01 ? (n = .707106781, i = .707106781, r = 0) : (r = Math.sqrt(b), n = L / r, i = I / r), this.set(n, i, r, t), this; + } + let p = Math.sqrt((v - m) * (v - m) + (u - x) * (u - x) + (d - h) * (d - h)); + return Math.abs(p) < .001 && (p = 1), this.x = (v - m) / p, this.y = (u - x) / p, this.z = (d - h) / p, this.w = Math.acos((c + f + g - 1) / 2), this; + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this; + } + clampLength(e, t) { + let n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; + } + dot(e) { + return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.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(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this; + } + equals(e) { + return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; + } + fromBufferAttribute(e, t, n) { + return n !== void 0 && console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), 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; + } +}; +Ve.prototype.isVector4 = !0; +var At = class extends En { + constructor(e, t, n = {}){ + super(); + this.width = e, this.height = t, this.depth = 1, this.scissor = new Ve(0, 0, e, t), this.scissorTest = !1, this.viewport = new Ve(0, 0, e, t), this.texture = new ot(void 0, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.encoding), this.texture.isRenderTargetTexture = !0, this.texture.image = { + width: e, + height: t, + depth: 1 + }, this.texture.generateMipmaps = n.generateMipmaps !== void 0 ? n.generateMipmaps : !1, this.texture.internalFormat = n.internalFormat !== void 0 ? n.internalFormat : null, this.texture.minFilter = n.minFilter !== void 0 ? n.minFilter : tt, this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0, this.stencilBuffer = n.stencilBuffer !== void 0 ? n.stencilBuffer : !1, this.depthTexture = n.depthTexture !== void 0 ? n.depthTexture : null; + } + setTexture(e) { + e.image = { + width: this.width, + height: this.height, + depth: this.depth + }, this.texture = e; + } + setSize(e, t, n = 1) { + (this.width !== e || this.height !== t || this.depth !== n) && (this.width = e, this.height = t, this.depth = n, this.texture.image.width = e, this.texture.image.height = t, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.copy(e.viewport), this.texture = e.texture.clone(), this.texture.image = { + ...this.texture.image + }, this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, this; + } + dispose() { + this.dispatchEvent({ + type: "dispose" + }); + } +}; +At.prototype.isWebGLRenderTarget = !0; +var Zc = class extends At { + constructor(e, t, n){ + super(e, t); + let i = this.texture; + this.texture = []; + for(let r = 0; r < n; r++)this.texture[r] = i.clone(); + } + setSize(e, t, n = 1) { + if (this.width !== e || this.height !== t || this.depth !== n) { + this.width = e, this.height = t, this.depth = n; + for(let i = 0, r = this.texture.length; i < r; i++)this.texture[i].image.width = e, this.texture[i].image.height = t, this.texture[i].image.depth = n; + this.dispose(); + } + return this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t), this; + } + copy(e) { + this.dispose(), this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.set(0, 0, this.width, this.height), this.scissor.set(0, 0, this.width, this.height), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, this.texture.length = 0; + for(let t = 0, n = e.texture.length; t < n; t++)this.texture[t] = e.texture[t].clone(); + return this; + } +}; +Zc.prototype.isWebGLMultipleRenderTargets = !0; +var Xs = class extends At { + constructor(e, t, n = {}){ + super(e, t, n); + this.samples = 4, this.ignoreDepthForMultisampleCopy = n.ignoreDepth !== void 0 ? n.ignoreDepth : !0, this.useRenderToTexture = n.useRenderToTexture !== void 0 ? n.useRenderToTexture : !1, this.useRenderbuffer = this.useRenderToTexture === !1; + } + copy(e) { + return super.copy.call(this, e), this.samples = e.samples, this.useRenderToTexture = e.useRenderToTexture, this.useRenderbuffer = e.useRenderbuffer, this; + } +}; +Xs.prototype.isWebGLMultisampleRenderTarget = !0; +var gt = class { + constructor(e = 0, t = 0, n = 0, i = 1){ + this._x = e, this._y = t, this._z = n, this._w = i; + } + static slerp(e, t, n, i) { + return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."), n.slerpQuaternions(e, t, i); + } + static slerpFlat(e, t, n, i, r, o, a) { + let l = n[i + 0], c = n[i + 1], h = n[i + 2], u = n[i + 3], d = r[o + 0], f = r[o + 1], m = r[o + 2], x = r[o + 3]; + if (a === 0) { + e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; + return; + } + if (a === 1) { + e[t + 0] = d, e[t + 1] = f, e[t + 2] = m, e[t + 3] = x; + return; + } + if (u !== x || l !== d || c !== f || h !== m) { + let v = 1 - a, g = l * d + c * f + h * m + u * x, p = g >= 0 ? 1 : -1, _ = 1 - g * g; + if (_ > Number.EPSILON) { + let b = Math.sqrt(_), A = Math.atan2(b, g * p); + v = Math.sin(v * A) / b, a = Math.sin(a * A) / b; + } + let y = a * p; + if (l = l * v + d * y, c = c * v + f * y, h = h * v + m * y, u = u * v + x * y, v === 1 - a) { + let b = 1 / Math.sqrt(l * l + c * c + h * h + u * u); + l *= b, c *= b, h *= b, u *= b; + } + } + e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; + } + static multiplyQuaternionsFlat(e, t, n, i, r, o) { + let a = n[i], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = r[o], d = r[o + 1], f = r[o + 2], m = r[o + 3]; + return e[t] = a * m + h * u + l * f - c * d, e[t + 1] = l * m + h * d + c * u - a * f, e[t + 2] = c * m + h * f + a * d - l * u, e[t + 3] = h * m - a * u - l * d - c * f, e; + } + get x() { + return this._x; + } + set x(e) { + this._x = e, this._onChangeCallback(); + } + get y() { + return this._y; + } + set y(e) { + this._y = e, this._onChangeCallback(); + } + get z() { + return this._z; + } + set z(e) { + this._z = e, this._onChangeCallback(); + } + get w() { + return this._w; + } + set w(e) { + this._w = e, this._onChangeCallback(); + } + set(e, t, n, i) { + return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this; + } + clone() { + return new this.constructor(this._x, this._y, this._z, this._w); + } + copy(e) { + return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; + } + setFromEuler(e, t) { + if (!(e && e.isEuler)) throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order."); + let n = e._x, i = e._y, r = e._z, o = e._order, a = Math.cos, l = Math.sin, c = a(n / 2), h = a(i / 2), u = a(r / 2), d = l(n / 2), f = l(i / 2), m = l(r / 2); + switch(o){ + case "XYZ": + this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; + break; + case "YXZ": + this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; + break; + case "ZXY": + this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; + break; + case "ZYX": + this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; + break; + case "YZX": + this._x = d * h * u + c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u - d * f * m; + break; + case "XZY": + this._x = d * h * u - c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u + d * f * m; + break; + default: + console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o); + } + return t !== !1 && this._onChangeCallback(), this; + } + setFromAxisAngle(e, t) { + let n = t / 2, i = Math.sin(n); + return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; + } + setFromRotationMatrix(e) { + let t = e.elements, n = t[0], i = t[4], r = t[8], o = t[1], a = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = n + a + u; + if (d > 0) { + let f = .5 / Math.sqrt(d + 1); + this._w = .25 / f, this._x = (h - l) * f, this._y = (r - c) * f, this._z = (o - i) * f; + } else if (n > a && n > u) { + let f = 2 * Math.sqrt(1 + n - a - u); + this._w = (h - l) / f, this._x = .25 * f, this._y = (i + o) / f, this._z = (r + c) / f; + } else if (a > u) { + let f = 2 * Math.sqrt(1 + a - n - u); + this._w = (r - c) / f, this._x = (i + o) / f, this._y = .25 * f, this._z = (l + h) / f; + } else { + let f = 2 * Math.sqrt(1 + u - n - a); + this._w = (o - i) / f, this._x = (r + c) / f, this._y = (l + h) / f, this._z = .25 * f; + } + return this._onChangeCallback(), this; + } + setFromUnitVectors(e, t) { + let n = e.dot(t) + 1; + return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); + } + angleTo(e) { + return 2 * Math.acos(Math.abs(mt(this.dot(e), -1, 1))); + } + rotateTowards(e, t) { + let n = this.angleTo(e); + if (n === 0) return this; + let i = Math.min(1, t / n); + return this.slerp(e, i), 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(e) { + return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._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 e = this.length(); + return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this; + } + multiply(e, t) { + return t !== void 0 ? (console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(e, t)) : this.multiplyQuaternions(this, e); + } + premultiply(e) { + return this.multiplyQuaternions(e, this); + } + multiplyQuaternions(e, t) { + let n = e._x, i = e._y, r = e._z, o = e._w, a = t._x, l = t._y, c = t._z, h = t._w; + return this._x = n * h + o * a + i * c - r * l, this._y = i * h + o * l + r * a - n * c, this._z = r * h + o * c + n * l - i * a, this._w = o * h - n * a - i * l - r * c, this._onChangeCallback(), this; + } + slerp(e, t) { + if (t === 0) return this; + if (t === 1) return this.copy(e); + let n = this._x, i = this._y, r = this._z, o = this._w, a = o * e._w + n * e._x + i * e._y + r * e._z; + if (a < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, a = -a) : this.copy(e), a >= 1) return this._w = o, this._x = n, this._y = i, this._z = r, this; + let l = 1 - a * a; + if (l <= Number.EPSILON) { + let f = 1 - t; + return this._w = f * o + t * this._w, this._x = f * n + t * this._x, this._y = f * i + t * this._y, this._z = f * r + t * this._z, this.normalize(), this._onChangeCallback(), this; + } + let c = Math.sqrt(l), h = Math.atan2(c, a), u = Math.sin((1 - t) * h) / c, d = Math.sin(t * h) / c; + return this._w = o * u + this._w * d, this._x = n * u + this._x * d, this._y = i * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; + } + slerpQuaternions(e, t, n) { + this.copy(e).slerp(t, n); + } + random() { + let e = Math.random(), t = Math.sqrt(1 - e), n = Math.sqrt(e), i = 2 * Math.PI * Math.random(), r = 2 * Math.PI * Math.random(); + return this.set(t * Math.cos(i), n * Math.sin(r), n * Math.cos(r), t * Math.sin(i)); + } + equals(e) { + return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; + } + fromArray(e, t = 0) { + return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; + } + toArray(e = [], t = 0) { + return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; + } + fromBufferAttribute(e, t) { + return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this; + } + _onChange(e) { + return this._onChangeCallback = e, this; + } + _onChangeCallback() {} +}; +gt.prototype.isQuaternion = !0; +var M = class { + constructor(e = 0, t = 0, n = 0){ + this.x = e, this.y = t, this.z = n; + } + set(e, t, n) { + return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; + } + setScalar(e) { + return this.x = e, this.y = e, this.z = e, this; + } + setX(e) { + return this.x = e, this; + } + setY(e) { + return this.y = e, this; + } + setZ(e) { + return this.z = e, this; + } + setComponent(e, t) { + switch(e){ + case 0: + this.x = t; + break; + case 1: + this.y = t; + break; + case 2: + this.z = t; + break; + default: + throw new Error("index is out of range: " + e); + } + return this; + } + getComponent(e) { + switch(e){ + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + default: + throw new Error("index is out of range: " + e); + } + } + clone() { + return new this.constructor(this.x, this.y, this.z); + } + copy(e) { + return this.x = e.x, this.y = e.y, this.z = e.z, this; + } + add(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this); + } + addScalar(e) { + return this.x += e, this.y += e, this.z += e, this; + } + addVectors(e, t) { + return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this; + } + addScaledVector(e, t) { + return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; + } + sub(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this); + } + subScalar(e) { + return this.x -= e, this.y -= e, this.z -= e, this; + } + subVectors(e, t) { + return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this; + } + multiply(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(e, t)) : (this.x *= e.x, this.y *= e.y, this.z *= e.z, this); + } + multiplyScalar(e) { + return this.x *= e, this.y *= e, this.z *= e, this; + } + multiplyVectors(e, t) { + return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this; + } + applyEuler(e) { + return e && e.isEuler || console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."), this.applyQuaternion(yl.setFromEuler(e)); + } + applyAxisAngle(e, t) { + return this.applyQuaternion(yl.setFromAxisAngle(e, t)); + } + applyMatrix3(e) { + let t = this.x, n = this.y, i = this.z, r = e.elements; + return this.x = r[0] * t + r[3] * n + r[6] * i, this.y = r[1] * t + r[4] * n + r[7] * i, this.z = r[2] * t + r[5] * n + r[8] * i, this; + } + applyNormalMatrix(e) { + return this.applyMatrix3(e).normalize(); + } + applyMatrix4(e) { + let t = this.x, n = this.y, i = this.z, r = e.elements, o = 1 / (r[3] * t + r[7] * n + r[11] * i + r[15]); + return this.x = (r[0] * t + r[4] * n + r[8] * i + r[12]) * o, this.y = (r[1] * t + r[5] * n + r[9] * i + r[13]) * o, this.z = (r[2] * t + r[6] * n + r[10] * i + r[14]) * o, this; + } + applyQuaternion(e) { + let t = this.x, n = this.y, i = this.z, r = e.x, o = e.y, a = e.z, l = e.w, c = l * t + o * i - a * n, h = l * n + a * t - r * i, u = l * i + r * n - o * t, d = -r * t - o * n - a * i; + return this.x = c * l + d * -r + h * -a - u * -o, this.y = h * l + d * -o + u * -r - c * -a, this.z = u * l + d * -a + c * -o - h * -r, this; + } + project(e) { + return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); + } + unproject(e) { + return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); + } + transformDirection(e) { + let t = this.x, n = this.y, i = this.z, r = e.elements; + return this.x = r[0] * t + r[4] * n + r[8] * i, this.y = r[1] * t + r[5] * n + r[9] * i, this.z = r[2] * t + r[6] * n + r[10] * i, this.normalize(); + } + divide(e) { + return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; + } + divideScalar(e) { + return this.multiplyScalar(1 / e); + } + min(e) { + return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this; + } + max(e) { + return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this; + } + clamp(e, t) { + return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this; + } + clampScalar(e, t) { + return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this; + } + clampLength(e, t) { + let n = this.length(); + return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + } + 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x), this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y), this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z), this; + } + negate() { + return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; + } + dot(e) { + return this.x * e.x + this.y * e.y + this.z * e.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(e) { + return this.normalize().multiplyScalar(e); + } + lerp(e, t) { + return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this; + } + lerpVectors(e, t, n) { + return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; + } + cross(e, t) { + return t !== void 0 ? (console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), this.crossVectors(e, t)) : this.crossVectors(this, e); + } + crossVectors(e, t) { + let n = e.x, i = e.y, r = e.z, o = t.x, a = t.y, l = t.z; + return this.x = i * l - r * a, this.y = r * o - n * l, this.z = n * a - i * o, this; + } + projectOnVector(e) { + let t = e.lengthSq(); + if (t === 0) return this.set(0, 0, 0); + let n = e.dot(this) / t; + return this.copy(e).multiplyScalar(n); + } + projectOnPlane(e) { + return Mo.copy(this).projectOnVector(e), this.sub(Mo); + } + reflect(e) { + return this.sub(Mo.copy(e).multiplyScalar(2 * this.dot(e))); + } + angleTo(e) { + let t = Math.sqrt(this.lengthSq() * e.lengthSq()); + if (t === 0) return Math.PI / 2; + let n = this.dot(e) / t; + return Math.acos(mt(n, -1, 1)); + } + distanceTo(e) { + return Math.sqrt(this.distanceToSquared(e)); + } + distanceToSquared(e) { + let t = this.x - e.x, n = this.y - e.y, i = this.z - e.z; + return t * t + n * n + i * i; + } + manhattanDistanceTo(e) { + return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); + } + setFromSpherical(e) { + return this.setFromSphericalCoords(e.radius, e.phi, e.theta); + } + setFromSphericalCoords(e, t, n) { + let i = Math.sin(t) * e; + return this.x = i * Math.sin(n), this.y = Math.cos(t) * e, this.z = i * Math.cos(n), this; + } + setFromCylindrical(e) { + return this.setFromCylindricalCoords(e.radius, e.theta, e.y); + } + setFromCylindricalCoords(e, t, n) { + return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; + } + setFromMatrixPosition(e) { + let t = e.elements; + return this.x = t[12], this.y = t[13], this.z = t[14], this; + } + setFromMatrixScale(e) { + let t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), i = this.setFromMatrixColumn(e, 2).length(); + return this.x = t, this.y = n, this.z = i, this; + } + setFromMatrixColumn(e, t) { + return this.fromArray(e.elements, t * 4); + } + setFromMatrix3Column(e, t) { + return this.fromArray(e.elements, t * 3); + } + equals(e) { + return e.x === this.x && e.y === this.y && e.z === this.z; + } + fromArray(e, t = 0) { + return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; + } + toArray(e = [], t = 0) { + return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; + } + fromBufferAttribute(e, t, n) { + return n !== void 0 && console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this; + } + random() { + return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; + } + randomDirection() { + let e = (Math.random() - .5) * 2, t = Math.random() * Math.PI * 2, n = Math.sqrt(1 - e ** 2); + return this.x = n * Math.cos(t), this.y = n * Math.sin(t), this.z = e, this; + } + *[Symbol.iterator]() { + yield this.x, yield this.y, yield this.z; + } +}; +M.prototype.isVector3 = !0; +var Mo = new M, yl = new gt, Lt = class { + constructor(e = new M(1 / 0, 1 / 0, 1 / 0), t = new M(-1 / 0, -1 / 0, -1 / 0)){ + this.min = e, this.max = t; + } + set(e, t) { + return this.min.copy(e), this.max.copy(t), this; + } + setFromArray(e) { + let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; + for(let l = 0, c = e.length; l < c; l += 3){ + let h = e[l], u = e[l + 1], d = e[l + 2]; + h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); + } + return this.min.set(t, n, i), this.max.set(r, o, a), this; + } + setFromBufferAttribute(e) { + let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; + for(let l = 0, c = e.count; l < c; l++){ + let h = e.getX(l), u = e.getY(l), d = e.getZ(l); + h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); + } + return this.min.set(t, n, i), this.max.set(r, o, a), this; + } + setFromPoints(e) { + this.makeEmpty(); + for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); + return this; + } + setFromCenterAndSize(e, t) { + let n = Ji.copy(t).multiplyScalar(.5); + return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; + } + setFromObject(e) { + return this.makeEmpty(), this.expandByObject(e); + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.min.copy(e.min), this.max.copy(e.max), this; + } + makeEmpty() { + return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this; + } + isEmpty() { + return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; + } + getCenter(e) { + return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); + } + getSize(e) { + return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); + } + expandByPoint(e) { + return this.min.min(e), this.max.max(e), this; + } + expandByVector(e) { + return this.min.sub(e), this.max.add(e), this; + } + expandByScalar(e) { + return this.min.addScalar(-e), this.max.addScalar(e), this; + } + expandByObject(e) { + e.updateWorldMatrix(!1, !1); + let t = e.geometry; + t !== void 0 && (t.boundingBox === null && t.computeBoundingBox(), bo.copy(t.boundingBox), bo.applyMatrix4(e.matrixWorld), this.union(bo)); + let n = e.children; + for(let i = 0, r = n.length; i < r; i++)this.expandByObject(n[i]); + return this; + } + containsPoint(e) { + return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z); + } + containsBox(e) { + return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z; + } + getParameter(e, t) { + return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y), (e.z - this.min.z) / (this.max.z - this.min.z)); + } + intersectsBox(e) { + return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z); + } + intersectsSphere(e) { + return this.clampPoint(e.center, Ji), Ji.distanceToSquared(e.center) <= e.radius * e.radius; + } + intersectsPlane(e) { + let t, n; + return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; + } + intersectsTriangle(e) { + if (this.isEmpty()) return !1; + this.getCenter(Yi), Wr.subVectors(this.max, Yi), ni.subVectors(e.a, Yi), ii.subVectors(e.b, Yi), ri.subVectors(e.c, Yi), un.subVectors(ii, ni), dn.subVectors(ri, ii), Pn.subVectors(ni, ri); + let t = [ + 0, + -un.z, + un.y, + 0, + -dn.z, + dn.y, + 0, + -Pn.z, + Pn.y, + un.z, + 0, + -un.x, + dn.z, + 0, + -dn.x, + Pn.z, + 0, + -Pn.x, + -un.y, + un.x, + 0, + -dn.y, + dn.x, + 0, + -Pn.y, + Pn.x, + 0 + ]; + return !wo(t, ni, ii, ri, Wr) || (t = [ + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 + ], !wo(t, ni, ii, ri, Wr)) ? !1 : (qr.crossVectors(un, dn), t = [ + qr.x, + qr.y, + qr.z + ], wo(t, ni, ii, ri, Wr)); + } + clampPoint(e, t) { + return t.copy(e).clamp(this.min, this.max); + } + distanceToPoint(e) { + return Ji.copy(e).clamp(this.min, this.max).sub(e).length(); + } + getBoundingSphere(e) { + return this.getCenter(e.center), e.radius = this.getSize(Ji).length() * .5, e; + } + intersect(e) { + return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; + } + union(e) { + return this.min.min(e.min), this.max.max(e.max), this; + } + applyMatrix4(e) { + return this.isEmpty() ? this : ($t[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), $t[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), $t[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), $t[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), $t[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), $t[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), $t[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), $t[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints($t), this); + } + translate(e) { + return this.min.add(e), this.max.add(e), this; + } + equals(e) { + return e.min.equals(this.min) && e.max.equals(this.max); + } +}; +Lt.prototype.isBox3 = !0; +var $t = [ + new M, + new M, + new M, + new M, + new M, + new M, + new M, + new M +], Ji = new M, bo = new Lt, ni = new M, ii = new M, ri = new M, un = new M, dn = new M, Pn = new M, Yi = new M, Wr = new M, qr = new M, In = new M; +function wo(s, e, t, n, i) { + for(let r = 0, o = s.length - 3; r <= o; r += 3){ + In.fromArray(s, r); + let a = i.x * Math.abs(In.x) + i.y * Math.abs(In.y) + i.z * Math.abs(In.z), l = e.dot(In), c = t.dot(In), h = n.dot(In); + if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > a) return !1; + } + return !0; +} +var ef = new Lt, vl = new M, Xr = new M, So = new M, An = class { + constructor(e = new M, t = -1){ + this.center = e, this.radius = t; + } + set(e, t) { + return this.center.copy(e), this.radius = t, this; + } + setFromPoints(e, t) { + let n = this.center; + t !== void 0 ? n.copy(t) : ef.setFromPoints(e).getCenter(n); + let i = 0; + for(let r = 0, o = e.length; r < o; r++)i = Math.max(i, n.distanceToSquared(e[r])); + return this.radius = Math.sqrt(i), this; + } + copy(e) { + return this.center.copy(e.center), this.radius = e.radius, this; + } + isEmpty() { + return this.radius < 0; + } + makeEmpty() { + return this.center.set(0, 0, 0), this.radius = -1, this; + } + containsPoint(e) { + return e.distanceToSquared(this.center) <= this.radius * this.radius; + } + distanceToPoint(e) { + return e.distanceTo(this.center) - this.radius; + } + intersectsSphere(e) { + let t = this.radius + e.radius; + return e.center.distanceToSquared(this.center) <= t * t; + } + intersectsBox(e) { + return e.intersectsSphere(this); + } + intersectsPlane(e) { + return Math.abs(e.distanceToPoint(this.center)) <= this.radius; + } + clampPoint(e, t) { + let n = this.center.distanceToSquared(e); + return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t; + } + getBoundingBox(e) { + return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); + } + applyMatrix4(e) { + return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this; + } + translate(e) { + return this.center.add(e), this; + } + expandByPoint(e) { + So.subVectors(e, this.center); + let t = So.lengthSq(); + if (t > this.radius * this.radius) { + let n = Math.sqrt(t), i = (n - this.radius) * .5; + this.center.add(So.multiplyScalar(i / n)), this.radius += i; + } + return this; + } + union(e) { + return this.center.equals(e.center) === !0 ? Xr.set(0, 0, 1).multiplyScalar(e.radius) : Xr.subVectors(e.center, this.center).normalize().multiplyScalar(e.radius), this.expandByPoint(vl.copy(e.center).add(Xr)), this.expandByPoint(vl.copy(e.center).sub(Xr)), this; + } + equals(e) { + return e.center.equals(this.center) && e.radius === this.radius; + } + clone() { + return new this.constructor().copy(this); + } +}, jt = new M, To = new M, Jr = new M, fn = new M, Eo = new M, Yr = new M, Ao = new M, Cn = class { + constructor(e = new M, t = new M(0, 0, -1)){ + this.origin = e, this.direction = t; + } + set(e, t) { + return this.origin.copy(e), this.direction.copy(t), this; + } + copy(e) { + return this.origin.copy(e.origin), this.direction.copy(e.direction), this; + } + at(e, t) { + return t.copy(this.direction).multiplyScalar(e).add(this.origin); + } + lookAt(e) { + return this.direction.copy(e).sub(this.origin).normalize(), this; + } + recast(e) { + return this.origin.copy(this.at(e, jt)), this; + } + closestPointToPoint(e, t) { + t.subVectors(e, this.origin); + let n = t.dot(this.direction); + return n < 0 ? t.copy(this.origin) : t.copy(this.direction).multiplyScalar(n).add(this.origin); + } + distanceToPoint(e) { + return Math.sqrt(this.distanceSqToPoint(e)); + } + distanceSqToPoint(e) { + let t = jt.subVectors(e, this.origin).dot(this.direction); + return t < 0 ? this.origin.distanceToSquared(e) : (jt.copy(this.direction).multiplyScalar(t).add(this.origin), jt.distanceToSquared(e)); + } + distanceSqToSegment(e, t, n, i) { + To.copy(e).add(t).multiplyScalar(.5), Jr.copy(t).sub(e).normalize(), fn.copy(this.origin).sub(To); + let r = e.distanceTo(t) * .5, o = -this.direction.dot(Jr), a = fn.dot(this.direction), l = -fn.dot(Jr), c = fn.lengthSq(), h = Math.abs(1 - o * o), u, d, f, m; + if (h > 0) if (u = o * l - a, d = o * a - l, m = r * h, u >= 0) if (d >= -m) if (d <= m) { + let x = 1 / h; + u *= x, d *= x, f = u * (u + o * d + 2 * a) + d * (o * u + d + 2 * l) + c; + } else d = r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; + else d = -r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; + else d <= -m ? (u = Math.max(0, -(-o * r + a)), d = u > 0 ? -r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c) : d <= m ? (u = 0, d = Math.min(Math.max(-r, -l), r), f = d * (d + 2 * l) + c) : (u = Math.max(0, -(o * r + a)), d = u > 0 ? r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c); + else d = o > 0 ? -r : r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; + return n && n.copy(this.direction).multiplyScalar(u).add(this.origin), i && i.copy(Jr).multiplyScalar(d).add(To), f; + } + intersectSphere(e, t) { + jt.subVectors(e.center, this.origin); + let n = jt.dot(this.direction), i = jt.dot(jt) - n * n, r = e.radius * e.radius; + if (i > r) return null; + let o = Math.sqrt(r - i), a = n - o, l = n + o; + return a < 0 && l < 0 ? null : a < 0 ? this.at(l, t) : this.at(a, t); + } + intersectsSphere(e) { + return this.distanceSqToPoint(e.center) <= e.radius * e.radius; + } + distanceToPlane(e) { + let t = e.normal.dot(this.direction); + if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; + let n = -(this.origin.dot(e.normal) + e.constant) / t; + return n >= 0 ? n : null; + } + intersectPlane(e, t) { + let n = this.distanceToPlane(e); + return n === null ? null : this.at(n, t); + } + intersectsPlane(e) { + let t = e.distanceToPoint(this.origin); + return t === 0 || e.normal.dot(this.direction) * t < 0; + } + intersectBox(e, t) { + let n, i, r, o, a, l, c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin; + return c >= 0 ? (n = (e.min.x - d.x) * c, i = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, i = (e.min.x - d.x) * c), h >= 0 ? (r = (e.min.y - d.y) * h, o = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, o = (e.min.y - d.y) * h), n > o || r > i || ((r > n || n !== n) && (n = r), (o < i || i !== i) && (i = o), u >= 0 ? (a = (e.min.z - d.z) * u, l = (e.max.z - d.z) * u) : (a = (e.max.z - d.z) * u, l = (e.min.z - d.z) * u), n > l || a > i) || ((a > n || n !== n) && (n = a), (l < i || i !== i) && (i = l), i < 0) ? null : this.at(n >= 0 ? n : i, t); + } + intersectsBox(e) { + return this.intersectBox(e, jt) !== null; + } + intersectTriangle(e, t, n, i, r) { + Eo.subVectors(t, e), Yr.subVectors(n, e), Ao.crossVectors(Eo, Yr); + let o = this.direction.dot(Ao), a; + if (o > 0) { + if (i) return null; + a = 1; + } else if (o < 0) a = -1, o = -o; + else return null; + fn.subVectors(this.origin, e); + let l = a * this.direction.dot(Yr.crossVectors(fn, Yr)); + if (l < 0) return null; + let c = a * this.direction.dot(Eo.cross(fn)); + if (c < 0 || l + c > o) return null; + let h = -a * fn.dot(Ao); + return h < 0 ? null : this.at(h / o, r); + } + applyMatrix4(e) { + return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; + } + equals(e) { + return e.origin.equals(this.origin) && e.direction.equals(this.direction); + } + clone() { + return new this.constructor().copy(this); + } +}, pe = class { + constructor(){ + this.elements = [ + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 1 + ], arguments.length > 0 && console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead."); + } + set(e, t, n, i, r, o, a, l, c, h, u, d, f, m, x, v) { + let g = this.elements; + return g[0] = e, g[4] = t, g[8] = n, g[12] = i, g[1] = r, g[5] = o, g[9] = a, g[13] = l, g[2] = c, g[6] = h, g[10] = u, g[14] = d, g[3] = f, g[7] = m, g[11] = x, g[15] = v, this; + } + identity() { + return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; + } + clone() { + return new pe().fromArray(this.elements); + } + copy(e) { + let t = this.elements, n = e.elements; + return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; + } + copyPosition(e) { + let t = this.elements, n = e.elements; + return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; + } + setFromMatrix3(e) { + let t = e.elements; + return this.set(t[0], t[3], t[6], 0, t[1], t[4], t[7], 0, t[2], t[5], t[8], 0, 0, 0, 0, 1), this; + } + extractBasis(e, t, n) { + return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; + } + makeBasis(e, t, n) { + return this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this; + } + extractRotation(e) { + let t = this.elements, n = e.elements, i = 1 / si.setFromMatrixColumn(e, 0).length(), r = 1 / si.setFromMatrixColumn(e, 1).length(), o = 1 / si.setFromMatrixColumn(e, 2).length(); + return t[0] = n[0] * i, t[1] = n[1] * i, t[2] = n[2] * i, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, t[7] = 0, t[8] = n[8] * o, t[9] = n[9] * o, t[10] = n[10] * o, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; + } + makeRotationFromEuler(e) { + e && e.isEuler || console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."); + let t = this.elements, n = e.x, i = e.y, r = e.z, o = Math.cos(n), a = Math.sin(n), l = Math.cos(i), c = Math.sin(i), h = Math.cos(r), u = Math.sin(r); + if (e.order === "XYZ") { + let d = o * h, f = o * u, m = a * h, x = a * u; + t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = f + m * c, t[5] = d - x * c, t[9] = -a * l, t[2] = x - d * c, t[6] = m + f * c, t[10] = o * l; + } else if (e.order === "YXZ") { + let d = l * h, f = l * u, m = c * h, x = c * u; + t[0] = d + x * a, t[4] = m * a - f, t[8] = o * c, t[1] = o * u, t[5] = o * h, t[9] = -a, t[2] = f * a - m, t[6] = x + d * a, t[10] = o * l; + } else if (e.order === "ZXY") { + let d = l * h, f = l * u, m = c * h, x = c * u; + t[0] = d - x * a, t[4] = -o * u, t[8] = m + f * a, t[1] = f + m * a, t[5] = o * h, t[9] = x - d * a, t[2] = -o * c, t[6] = a, t[10] = o * l; + } else if (e.order === "ZYX") { + let d = o * h, f = o * u, m = a * h, x = a * u; + t[0] = l * h, t[4] = m * c - f, t[8] = d * c + x, t[1] = l * u, t[5] = x * c + d, t[9] = f * c - m, t[2] = -c, t[6] = a * l, t[10] = o * l; + } else if (e.order === "YZX") { + let d = o * l, f = o * c, m = a * l, x = a * c; + t[0] = l * h, t[4] = x - d * u, t[8] = m * u + f, t[1] = u, t[5] = o * h, t[9] = -a * h, t[2] = -c * h, t[6] = f * u + m, t[10] = d - x * u; + } else if (e.order === "XZY") { + let d = o * l, f = o * c, m = a * l, x = a * c; + t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = d * u + x, t[5] = o * h, t[9] = f * u - m, t[2] = m * u - f, t[6] = a * h, t[10] = x * u + d; + } + return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; + } + makeRotationFromQuaternion(e) { + return this.compose(tf, e, nf); + } + lookAt(e, t, n) { + let i = this.elements; + return St.subVectors(e, t), St.lengthSq() === 0 && (St.z = 1), St.normalize(), pn.crossVectors(n, St), pn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? St.x += 1e-4 : St.z += 1e-4, St.normalize(), pn.crossVectors(n, St)), pn.normalize(), Zr.crossVectors(St, pn), i[0] = pn.x, i[4] = Zr.x, i[8] = St.x, i[1] = pn.y, i[5] = Zr.y, i[9] = St.y, i[2] = pn.z, i[6] = Zr.z, i[10] = St.z, this; + } + multiply(e, t) { + return t !== void 0 ? (console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(e, t)) : this.multiplyMatrices(this, e); + } + premultiply(e) { + return this.multiplyMatrices(e, this); + } + multiplyMatrices(e, t) { + let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[4], l = n[8], c = n[12], h = n[1], u = n[5], d = n[9], f = n[13], m = n[2], x = n[6], v = n[10], g = n[14], p = n[3], _ = n[7], y = n[11], b = n[15], A = i[0], L = i[4], I = i[8], k = i[12], B = i[1], P = i[5], w = i[9], E = i[13], D = i[2], U = i[6], F = i[10], O = i[14], ne = i[3], ce = i[7], V = i[11], W = i[15]; + return r[0] = o * A + a * B + l * D + c * ne, r[4] = o * L + a * P + l * U + c * ce, r[8] = o * I + a * w + l * F + c * V, r[12] = o * k + a * E + l * O + c * W, r[1] = h * A + u * B + d * D + f * ne, r[5] = h * L + u * P + d * U + f * ce, r[9] = h * I + u * w + d * F + f * V, r[13] = h * k + u * E + d * O + f * W, r[2] = m * A + x * B + v * D + g * ne, r[6] = m * L + x * P + v * U + g * ce, r[10] = m * I + x * w + v * F + g * V, r[14] = m * k + x * E + v * O + g * W, r[3] = p * A + _ * B + y * D + b * ne, r[7] = p * L + _ * P + y * U + b * ce, r[11] = p * I + _ * w + y * F + b * V, r[15] = p * k + _ * E + y * O + b * W, this; + } + multiplyScalar(e) { + let t = this.elements; + return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this; + } + determinant() { + let e = this.elements, t = e[0], n = e[4], i = e[8], r = e[12], o = e[1], a = e[5], l = e[9], c = e[13], h = e[2], u = e[6], d = e[10], f = e[14], m = e[3], x = e[7], v = e[11], g = e[15]; + return m * (+r * l * u - i * c * u - r * a * d + n * c * d + i * a * f - n * l * f) + x * (+t * l * f - t * c * d + r * o * d - i * o * f + i * c * h - r * l * h) + v * (+t * c * u - t * a * f - r * o * u + n * o * f + r * a * h - n * c * h) + g * (-i * a * h - t * l * u + t * a * d + i * o * u - n * o * d + n * l * h); + } + transpose() { + let e = this.elements, t; + return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this; + } + setPosition(e, t, n) { + let i = this.elements; + return e.isVector3 ? (i[12] = e.x, i[13] = e.y, i[14] = e.z) : (i[12] = e, i[13] = t, i[14] = n), this; + } + invert() { + let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = e[9], d = e[10], f = e[11], m = e[12], x = e[13], v = e[14], g = e[15], p = u * v * c - x * d * c + x * l * f - a * v * f - u * l * g + a * d * g, _ = m * d * c - h * v * c - m * l * f + o * v * f + h * l * g - o * d * g, y = h * x * c - m * u * c + m * a * f - o * x * f - h * a * g + o * u * g, b = m * u * l - h * x * l - m * a * d + o * x * d + h * a * v - o * u * v, A = t * p + n * _ + i * y + r * b; + if (A === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + let L = 1 / A; + return e[0] = p * L, e[1] = (x * d * r - u * v * r - x * i * f + n * v * f + u * i * g - n * d * g) * L, e[2] = (a * v * r - x * l * r + x * i * c - n * v * c - a * i * g + n * l * g) * L, e[3] = (u * l * r - a * d * r - u * i * c + n * d * c + a * i * f - n * l * f) * L, e[4] = _ * L, e[5] = (h * v * r - m * d * r + m * i * f - t * v * f - h * i * g + t * d * g) * L, e[6] = (m * l * r - o * v * r - m * i * c + t * v * c + o * i * g - t * l * g) * L, e[7] = (o * d * r - h * l * r + h * i * c - t * d * c - o * i * f + t * l * f) * L, e[8] = y * L, e[9] = (m * u * r - h * x * r - m * n * f + t * x * f + h * n * g - t * u * g) * L, e[10] = (o * x * r - m * a * r + m * n * c - t * x * c - o * n * g + t * a * g) * L, e[11] = (h * a * r - o * u * r - h * n * c + t * u * c + o * n * f - t * a * f) * L, e[12] = b * L, e[13] = (h * x * i - m * u * i + m * n * d - t * x * d - h * n * v + t * u * v) * L, e[14] = (m * a * i - o * x * i - m * n * l + t * x * l + o * n * v - t * a * v) * L, e[15] = (o * u * i - h * a * i + h * n * l - t * u * l - o * n * d + t * a * d) * L, this; + } + scale(e) { + let t = this.elements, n = e.x, i = e.y, r = e.z; + return t[0] *= n, t[4] *= i, t[8] *= r, t[1] *= n, t[5] *= i, t[9] *= r, t[2] *= n, t[6] *= i, t[10] *= r, t[3] *= n, t[7] *= i, t[11] *= r, this; + } + getMaxScaleOnAxis() { + let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; + return Math.sqrt(Math.max(t, n, i)); + } + makeTranslation(e, t, n) { + return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1), this; + } + makeRotationX(e) { + let t = Math.cos(e), n = Math.sin(e); + return this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this; + } + makeRotationY(e) { + let t = Math.cos(e), n = Math.sin(e); + return this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this; + } + makeRotationZ(e) { + let t = Math.cos(e), n = Math.sin(e); + return this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; + } + makeRotationAxis(e, t) { + let n = Math.cos(t), i = Math.sin(t), r = 1 - n, o = e.x, a = e.y, l = e.z, c = r * o, h = r * a; + return this.set(c * o + n, c * a - i * l, c * l + i * a, 0, c * a + i * l, h * a + n, h * l - i * o, 0, c * l - i * a, h * l + i * o, r * l * l + n, 0, 0, 0, 0, 1), this; + } + makeScale(e, t, n) { + return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this; + } + makeShear(e, t, n, i, r, o) { + return this.set(1, n, r, 0, e, 1, o, 0, t, i, 1, 0, 0, 0, 0, 1), this; + } + compose(e, t, n) { + let i = this.elements, r = t._x, o = t._y, a = t._z, l = t._w, c = r + r, h = o + o, u = a + a, d = r * c, f = r * h, m = r * u, x = o * h, v = o * u, g = a * u, p = l * c, _ = l * h, y = l * u, b = n.x, A = n.y, L = n.z; + return i[0] = (1 - (x + g)) * b, i[1] = (f + y) * b, i[2] = (m - _) * b, i[3] = 0, i[4] = (f - y) * A, i[5] = (1 - (d + g)) * A, i[6] = (v + p) * A, i[7] = 0, i[8] = (m + _) * L, i[9] = (v - p) * L, i[10] = (1 - (d + x)) * L, i[11] = 0, i[12] = e.x, i[13] = e.y, i[14] = e.z, i[15] = 1, this; + } + decompose(e, t, n) { + let i = this.elements, r = si.set(i[0], i[1], i[2]).length(), o = si.set(i[4], i[5], i[6]).length(), a = si.set(i[8], i[9], i[10]).length(); + this.determinant() < 0 && (r = -r), e.x = i[12], e.y = i[13], e.z = i[14], It.copy(this); + let c = 1 / r, h = 1 / o, u = 1 / a; + return It.elements[0] *= c, It.elements[1] *= c, It.elements[2] *= c, It.elements[4] *= h, It.elements[5] *= h, It.elements[6] *= h, It.elements[8] *= u, It.elements[9] *= u, It.elements[10] *= u, t.setFromRotationMatrix(It), n.x = r, n.y = o, n.z = a, this; + } + makePerspective(e, t, n, i, r, o) { + o === void 0 && console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."); + let a = this.elements, l = 2 * r / (t - e), c = 2 * r / (n - i), h = (t + e) / (t - e), u = (n + i) / (n - i), d = -(o + r) / (o - r), f = -2 * o * r / (o - r); + return a[0] = l, a[4] = 0, a[8] = h, a[12] = 0, a[1] = 0, a[5] = c, a[9] = u, a[13] = 0, a[2] = 0, a[6] = 0, a[10] = d, a[14] = f, a[3] = 0, a[7] = 0, a[11] = -1, a[15] = 0, this; + } + makeOrthographic(e, t, n, i, r, o) { + let a = this.elements, l = 1 / (t - e), c = 1 / (n - i), h = 1 / (o - r), u = (t + e) * l, d = (n + i) * c, f = (o + r) * h; + return a[0] = 2 * l, a[4] = 0, a[8] = 0, a[12] = -u, a[1] = 0, a[5] = 2 * c, a[9] = 0, a[13] = -d, a[2] = 0, a[6] = 0, a[10] = -2 * h, a[14] = -f, a[3] = 0, a[7] = 0, a[11] = 0, a[15] = 1, this; + } + equals(e) { + let t = this.elements, n = e.elements; + for(let i = 0; i < 16; i++)if (t[i] !== n[i]) return !1; + return !0; + } + fromArray(e, t = 0) { + for(let n = 0; n < 16; n++)this.elements[n] = e[n + t]; + return this; + } + toArray(e = [], t = 0) { + let n = this.elements; + return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; + } +}; +pe.prototype.isMatrix4 = !0; +var si = new M, It = new pe, tf = new M(0, 0, 0), nf = new M(1, 1, 1), pn = new M, Zr = new M, St = new M, _l = new pe, Ml = new gt, Zn = class { + constructor(e = 0, t = 0, n = 0, i = Zn.DefaultOrder){ + this._x = e, this._y = t, this._z = n, this._order = i; + } + get x() { + return this._x; + } + set x(e) { + this._x = e, this._onChangeCallback(); + } + get y() { + return this._y; + } + set y(e) { + this._y = e, this._onChangeCallback(); + } + get z() { + return this._z; + } + set z(e) { + this._z = e, this._onChangeCallback(); + } + get order() { + return this._order; + } + set order(e) { + this._order = e, this._onChangeCallback(); + } + set(e, t, n, i = this._order) { + return this._x = e, this._y = t, this._z = n, this._order = i, this._onChangeCallback(), this; + } + clone() { + return new this.constructor(this._x, this._y, this._z, this._order); + } + copy(e) { + return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; + } + setFromRotationMatrix(e, t = this._order, n = !0) { + let i = e.elements, r = i[0], o = i[4], a = i[8], l = i[1], c = i[5], h = i[9], u = i[2], d = i[6], f = i[10]; + switch(t){ + case "XYZ": + this._y = Math.asin(mt(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(-h, f), this._z = Math.atan2(-o, r)) : (this._x = Math.atan2(d, c), this._z = 0); + break; + case "YXZ": + this._x = Math.asin(-mt(h, -1, 1)), Math.abs(h) < .9999999 ? (this._y = Math.atan2(a, f), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0); + break; + case "ZXY": + this._x = Math.asin(mt(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-o, c)) : (this._y = 0, this._z = Math.atan2(l, r)); + break; + case "ZYX": + this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-o, c)); + break; + case "YZX": + this._z = Math.asin(mt(l, -1, 1)), Math.abs(l) < .9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(a, f)); + break; + case "XZY": + this._z = Math.asin(-mt(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(a, r)) : (this._x = Math.atan2(-h, f), this._y = 0); + break; + default: + console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t); + } + return this._order = t, n === !0 && this._onChangeCallback(), this; + } + setFromQuaternion(e, t, n) { + return _l.makeRotationFromQuaternion(e), this.setFromRotationMatrix(_l, t, n); + } + setFromVector3(e, t = this._order) { + return this.set(e.x, e.y, e.z, t); + } + reorder(e) { + return Ml.setFromEuler(this), this.setFromQuaternion(Ml, e); + } + equals(e) { + return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; + } + fromArray(e) { + return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; + } + toArray(e = [], t = 0) { + return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e; + } + toVector3(e) { + return e ? e.set(this._x, this._y, this._z) : new M(this._x, this._y, this._z); + } + _onChange(e) { + return this._onChangeCallback = e, this; + } + _onChangeCallback() {} +}; +Zn.prototype.isEuler = !0; +Zn.DefaultOrder = "XYZ"; +Zn.RotationOrders = [ + "XYZ", + "YZX", + "ZXY", + "XZY", + "YXZ", + "ZYX" +]; +var Js = class { + constructor(){ + this.mask = 1; + } + set(e) { + this.mask = (1 << e | 0) >>> 0; + } + enable(e) { + this.mask |= 1 << e | 0; + } + enableAll() { + this.mask = -1; + } + toggle(e) { + this.mask ^= 1 << e | 0; + } + disable(e) { + this.mask &= ~(1 << e | 0); + } + disableAll() { + this.mask = 0; + } + test(e) { + return (this.mask & e.mask) !== 0; + } + isEnabled(e) { + return (this.mask & (1 << e | 0)) !== 0; + } +}, rf = 0, bl = new M, oi = new gt, Qt = new pe, $r = new M, Zi = new M, sf = new M, of = new gt, wl = new M(1, 0, 0), Sl = new M(0, 1, 0), Tl = new M(0, 0, 1), af = { + type: "added" +}, El = { + type: "removed" +}, Ne = class extends En { + constructor(){ + super(); + Object.defineProperty(this, "id", { + value: rf++ + }), this.uuid = Et(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Ne.DefaultUp.clone(); + let e = new M, t = new Zn, n = new gt, i = new M(1, 1, 1); + function r() { + n.setFromEuler(t, !1); + } + function o() { + t.setFromQuaternion(n, void 0, !1); + } + t._onChange(r), n._onChange(o), Object.defineProperties(this, { + position: { + configurable: !0, + enumerable: !0, + value: e + }, + rotation: { + configurable: !0, + enumerable: !0, + value: t + }, + quaternion: { + configurable: !0, + enumerable: !0, + value: n + }, + scale: { + configurable: !0, + enumerable: !0, + value: i + }, + modelViewMatrix: { + value: new pe + }, + normalMatrix: { + value: new lt + } + }), this.matrix = new pe, this.matrixWorld = new pe, this.matrixAutoUpdate = Ne.DefaultMatrixAutoUpdate, this.matrixWorldNeedsUpdate = !1, this.layers = new Js, this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}; + } + onBeforeRender() {} + onAfterRender() {} + applyMatrix4(e) { + this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); + } + applyQuaternion(e) { + return this.quaternion.premultiply(e), this; + } + setRotationFromAxisAngle(e, t) { + this.quaternion.setFromAxisAngle(e, t); + } + setRotationFromEuler(e) { + this.quaternion.setFromEuler(e, !0); + } + setRotationFromMatrix(e) { + this.quaternion.setFromRotationMatrix(e); + } + setRotationFromQuaternion(e) { + this.quaternion.copy(e); + } + rotateOnAxis(e, t) { + return oi.setFromAxisAngle(e, t), this.quaternion.multiply(oi), this; + } + rotateOnWorldAxis(e, t) { + return oi.setFromAxisAngle(e, t), this.quaternion.premultiply(oi), this; + } + rotateX(e) { + return this.rotateOnAxis(wl, e); + } + rotateY(e) { + return this.rotateOnAxis(Sl, e); + } + rotateZ(e) { + return this.rotateOnAxis(Tl, e); + } + translateOnAxis(e, t) { + return bl.copy(e).applyQuaternion(this.quaternion), this.position.add(bl.multiplyScalar(t)), this; + } + translateX(e) { + return this.translateOnAxis(wl, e); + } + translateY(e) { + return this.translateOnAxis(Sl, e); + } + translateZ(e) { + return this.translateOnAxis(Tl, e); + } + localToWorld(e) { + return e.applyMatrix4(this.matrixWorld); + } + worldToLocal(e) { + return e.applyMatrix4(Qt.copy(this.matrixWorld).invert()); + } + lookAt(e, t, n) { + e.isVector3 ? $r.copy(e) : $r.set(e, t, n); + let i = this.parent; + this.updateWorldMatrix(!0, !1), Zi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Qt.lookAt(Zi, $r, this.up) : Qt.lookAt($r, Zi, this.up), this.quaternion.setFromRotationMatrix(Qt), i && (Qt.extractRotation(i.matrixWorld), oi.setFromRotationMatrix(Qt), this.quaternion.premultiply(oi.invert())); + } + add(e) { + if (arguments.length > 1) { + for(let t = 0; t < arguments.length; t++)this.add(arguments[t]); + return this; + } + return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), e.parent = this, this.children.push(e), e.dispatchEvent(af)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this); + } + remove(e) { + if (arguments.length > 1) { + for(let n = 0; n < arguments.length; n++)this.remove(arguments[n]); + return this; + } + let t = this.children.indexOf(e); + return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(El)), this; + } + removeFromParent() { + let e = this.parent; + return e !== null && e.remove(this), this; + } + clear() { + for(let e = 0; e < this.children.length; e++){ + let t = this.children[e]; + t.parent = null, t.dispatchEvent(El); + } + return this.children.length = 0, this; + } + attach(e) { + return this.updateWorldMatrix(!0, !1), Qt.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Qt.multiply(e.parent.matrixWorld)), e.applyMatrix4(Qt), this.add(e), e.updateWorldMatrix(!1, !0), this; + } + getObjectById(e) { + return this.getObjectByProperty("id", e); + } + getObjectByName(e) { + return this.getObjectByProperty("name", e); + } + getObjectByProperty(e, t) { + if (this[e] === t) return this; + for(let n = 0, i = this.children.length; n < i; n++){ + let o = this.children[n].getObjectByProperty(e, t); + if (o !== void 0) return o; + } + } + getWorldPosition(e) { + return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); + } + getWorldQuaternion(e) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, e, sf), e; + } + getWorldScale(e) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, of, e), e; + } + getWorldDirection(e) { + this.updateWorldMatrix(!0, !1); + let t = this.matrixWorld.elements; + return e.set(t[8], t[9], t[10]).normalize(); + } + raycast() {} + traverse(e) { + e(this); + let t = this.children; + for(let n = 0, i = t.length; n < i; n++)t[n].traverse(e); + } + traverseVisible(e) { + if (this.visible === !1) return; + e(this); + let t = this.children; + for(let n = 0, i = t.length; n < i; n++)t[n].traverseVisible(e); + } + traverseAncestors(e) { + let t = this.parent; + t !== null && (e(t), t.traverseAncestors(e)); + } + updateMatrix() { + this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0; + } + updateMatrixWorld(e) { + this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0); + let t = this.children; + for(let n = 0, i = t.length; n < i; n++)t[n].updateMatrixWorld(e); + } + updateWorldMatrix(e, t) { + let n = this.parent; + if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) { + let i = this.children; + for(let r = 0, o = i.length; r < o; r++)i[r].updateWorldMatrix(!1, !0); + } + } + toJSON(e) { + let t = e === void 0 || typeof e == "string", n = {}; + t && (e = { + geometries: {}, + materials: {}, + textures: {}, + images: {}, + shapes: {}, + skeletons: {}, + animations: {} + }, n.metadata = { + version: 4.5, + type: "Object", + generator: "Object3D.toJSON" + }); + let i = {}; + i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.castShadow === !0 && (i.castShadow = !0), this.receiveShadow === !0 && (i.receiveShadow = !0), this.visible === !1 && (i.visible = !1), this.frustumCulled === !1 && (i.frustumCulled = !1), this.renderOrder !== 0 && (i.renderOrder = this.renderOrder), JSON.stringify(this.userData) !== "{}" && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (i.instanceColor = this.instanceColor.toJSON())); + function r(a, l) { + return a[l.uuid] === void 0 && (a[l.uuid] = l.toJSON(e)), l.uuid; + } + if (this.isScene) this.background && (this.background.isColor ? i.background = this.background.toJSON() : this.background.isTexture && (i.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && (i.environment = this.environment.toJSON(e).uuid); + else if (this.isMesh || this.isLine || this.isPoints) { + i.geometry = r(e.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; c < h; c++){ + let u = l[c]; + r(e.shapes, u); + } + else r(e.shapes, l); + } + } + if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(e.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { + let a = []; + for(let l = 0, c = this.material.length; l < c; l++)a.push(r(e.materials, this.material[l])); + i.material = a; + } else i.material = r(e.materials, this.material); + if (this.children.length > 0) { + i.children = []; + for(let a = 0; a < this.children.length; a++)i.children.push(this.children[a].toJSON(e).object); + } + if (this.animations.length > 0) { + i.animations = []; + for(let a = 0; a < this.animations.length; a++){ + let l = this.animations[a]; + i.animations.push(r(e.animations, l)); + } + } + if (t) { + let a = o(e.geometries), l = o(e.materials), c = o(e.textures), h = o(e.images), u = o(e.shapes), d = o(e.skeletons), f = o(e.animations); + a.length > 0 && (n.geometries = a), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), d.length > 0 && (n.skeletons = d), f.length > 0 && (n.animations = f); + } + return n.object = i, n; + function o(a) { + let l = []; + for(let c in a){ + let h = a[c]; + delete h.metadata, l.push(h); + } + return l; + } + } + clone(e) { + return new this.constructor().copy(this, e); + } + copy(e, t = !0) { + if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for(let n = 0; n < e.children.length; n++){ + let i = e.children[n]; + this.add(i.clone()); + } + return this; + } +}; +Ne.DefaultUp = new M(0, 1, 0); +Ne.DefaultMatrixAutoUpdate = !0; +Ne.prototype.isObject3D = !0; +var Dt = new M, Kt = new M, Co = new M, en = new M, ai = new M, li = new M, Al = new M, Lo = new M, Ro = new M, Po = new M, nt = class { + constructor(e = new M, t = new M, n = new M){ + this.a = e, this.b = t, this.c = n; + } + static getNormal(e, t, n, i) { + i.subVectors(n, t), Dt.subVectors(e, t), i.cross(Dt); + let r = i.lengthSq(); + return r > 0 ? i.multiplyScalar(1 / Math.sqrt(r)) : i.set(0, 0, 0); + } + static getBarycoord(e, t, n, i, r) { + Dt.subVectors(i, t), Kt.subVectors(n, t), Co.subVectors(e, t); + let o = Dt.dot(Dt), a = Dt.dot(Kt), l = Dt.dot(Co), c = Kt.dot(Kt), h = Kt.dot(Co), u = o * c - a * a; + if (u === 0) return r.set(-2, -1, -1); + let d = 1 / u, f = (c * l - a * h) * d, m = (o * h - a * l) * d; + return r.set(1 - f - m, m, f); + } + static containsPoint(e, t, n, i) { + return this.getBarycoord(e, t, n, i, en), en.x >= 0 && en.y >= 0 && en.x + en.y <= 1; + } + static getUV(e, t, n, i, r, o, a, l) { + return this.getBarycoord(e, t, n, i, en), l.set(0, 0), l.addScaledVector(r, en.x), l.addScaledVector(o, en.y), l.addScaledVector(a, en.z), l; + } + static isFrontFacing(e, t, n, i) { + return Dt.subVectors(n, t), Kt.subVectors(e, t), Dt.cross(Kt).dot(i) < 0; + } + set(e, t, n) { + return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; + } + setFromPointsAndIndices(e, t, n, i) { + return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this; + } + setFromAttributeAndIndices(e, t, n, i) { + return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, i), this; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; + } + getArea() { + return Dt.subVectors(this.c, this.b), Kt.subVectors(this.a, this.b), Dt.cross(Kt).length() * .5; + } + getMidpoint(e) { + return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); + } + getNormal(e) { + return nt.getNormal(this.a, this.b, this.c, e); + } + getPlane(e) { + return e.setFromCoplanarPoints(this.a, this.b, this.c); + } + getBarycoord(e, t) { + return nt.getBarycoord(e, this.a, this.b, this.c, t); + } + getUV(e, t, n, i, r) { + return nt.getUV(e, this.a, this.b, this.c, t, n, i, r); + } + containsPoint(e) { + return nt.containsPoint(e, this.a, this.b, this.c); + } + isFrontFacing(e) { + return nt.isFrontFacing(this.a, this.b, this.c, e); + } + intersectsBox(e) { + return e.intersectsTriangle(this); + } + closestPointToPoint(e, t) { + let n = this.a, i = this.b, r = this.c, o, a; + ai.subVectors(i, n), li.subVectors(r, n), Lo.subVectors(e, n); + let l = ai.dot(Lo), c = li.dot(Lo); + if (l <= 0 && c <= 0) return t.copy(n); + Ro.subVectors(e, i); + let h = ai.dot(Ro), u = li.dot(Ro); + if (h >= 0 && u <= h) return t.copy(i); + let d = l * u - h * c; + if (d <= 0 && l >= 0 && h <= 0) return o = l / (l - h), t.copy(n).addScaledVector(ai, o); + Po.subVectors(e, r); + let f = ai.dot(Po), m = li.dot(Po); + if (m >= 0 && f <= m) return t.copy(r); + let x = f * c - l * m; + if (x <= 0 && c >= 0 && m <= 0) return a = c / (c - m), t.copy(n).addScaledVector(li, a); + let v = h * m - f * u; + if (v <= 0 && u - h >= 0 && f - m >= 0) return Al.subVectors(r, i), a = (u - h) / (u - h + (f - m)), t.copy(i).addScaledVector(Al, a); + let g = 1 / (v + x + d); + return o = x * g, a = d * g, t.copy(n).addScaledVector(ai, o).addScaledVector(li, a); + } + equals(e) { + return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); + } +}, lf = 0, dt = class extends En { + constructor(){ + super(); + Object.defineProperty(this, "id", { + value: lf++ + }), this.uuid = Et(), this.name = "", this.type = "Material", this.fog = !0, this.blending = sr, this.side = Ai, this.vertexColors = !1, this.opacity = 1, this.format = ct, this.transparent = !1, this.blendSrc = Gc, this.blendDst = Vc, this.blendEquation = _i, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.depthFunc = ea, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Ud, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = vo, this.stencilZFail = vo, this.stencilZPass = vo, 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.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; + } + get alphaTest() { + return this._alphaTest; + } + set alphaTest(e) { + this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; + } + onBuild() {} + onBeforeRender() {} + onBeforeCompile() {} + customProgramCacheKey() { + return this.onBeforeCompile.toString(); + } + setValues(e) { + if (e !== void 0) for(let t in e){ + let n = e[t]; + if (n === void 0) { + console.warn("THREE.Material: '" + t + "' parameter is undefined."); + continue; + } + if (t === "shading") { + console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = n === kc; + continue; + } + let i = this[t]; + if (i === void 0) { + console.warn("THREE." + this.type + ": '" + t + "' is not a property of this material."); + continue; + } + i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[t] = n; + } + } + toJSON(e) { + let t = e === void 0 || typeof e == "string"; + t && (e = { + textures: {}, + images: {} + }); + let n = { + metadata: { + version: 4.5, + type: "Material", + generator: "Material.toJSON" + } + }; + n.uuid = this.uuid, n.type = this.type, this.name !== "" && (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 && this.emissiveIntensity !== 1 && (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(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), 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(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).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.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== sr && (n.blending = this.blending), this.side !== Ai && (n.side = this.side), this.vertexColors && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.format !== ct && (n.format = this.format), this.transparent === !0 && (n.transparent = this.transparent), n.depthFunc = this.depthFunc, n.depthTest = this.depthTest, n.depthWrite = this.depthWrite, n.colorWrite = this.colorWrite, n.stencilWrite = this.stencilWrite, 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, this.rotation && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth && this.linewidth !== 1 && (n.linewidth = this.linewidth), 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.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaToCoverage === !0 && (n.alphaToCoverage = this.alphaToCoverage), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = this.premultipliedAlpha), this.wireframe === !0 && (n.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = this.flatShading), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData); + function i(r) { + let o = []; + for(let a in r){ + let l = r[a]; + delete l.metadata, o.push(l); + } + return o; + } + if (t) { + let r = i(e.textures), o = i(e.images); + r.length > 0 && (n.textures = r), o.length > 0 && (n.images = o); + } + return n; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + this.name = e.name, this.fog = e.fog, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.format = e.format, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; + let t = e.clippingPlanes, n = null; + if (t !== null) { + let i = t.length; + n = new Array(i); + for(let r = 0; r !== i; ++r)n[r] = t[r].clone(); + } + return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; + } + dispose() { + this.dispatchEvent({ + type: "dispose" + }); + } + set needsUpdate(e) { + e === !0 && this.version++; + } +}; +dt.prototype.isMaterial = !0; +var $c = { + 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 +}, Ft = { + h: 0, + s: 0, + l: 0 +}, jr = { + h: 0, + s: 0, + l: 0 +}; +function Io(s, e, t) { + return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? s + (e - s) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? s + (e - s) * 6 * (2 / 3 - t) : s; +} +function Do(s) { + return s < .04045 ? s * .0773993808 : Math.pow(s * .9478672986 + .0521327014, 2.4); +} +function Fo(s) { + return s < .0031308 ? s * 12.92 : 1.055 * Math.pow(s, .41666) - .055; +} +var ae = class { + constructor(e, t, n){ + return t === void 0 && n === void 0 ? this.set(e) : this.setRGB(e, t, n); + } + set(e) { + return e && e.isColor ? this.copy(e) : typeof e == "number" ? this.setHex(e) : typeof e == "string" && this.setStyle(e), this; + } + setScalar(e) { + return this.r = e, this.g = e, this.b = e, this; + } + setHex(e) { + return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, this; + } + setRGB(e, t, n) { + return this.r = e, this.g = t, this.b = n, this; + } + setHSL(e, t, n) { + if (e = da(e, 1), t = mt(t, 0, 1), n = mt(n, 0, 1), t === 0) this.r = this.g = this.b = n; + else { + let i = n <= .5 ? n * (1 + t) : n + t - n * t, r = 2 * n - i; + this.r = Io(r, i, e + 1 / 3), this.g = Io(r, i, e), this.b = Io(r, i, e - 1 / 3); + } + return this; + } + setStyle(e) { + function t(i) { + i !== void 0 && parseFloat(i) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored."); + } + let n; + if (n = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)) { + let i, r = n[1], o = n[2]; + switch(r){ + case "rgb": + case "rgba": + if (i = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(255, parseInt(i[1], 10)) / 255, this.g = Math.min(255, parseInt(i[2], 10)) / 255, this.b = Math.min(255, parseInt(i[3], 10)) / 255, t(i[4]), this; + if (i = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(100, parseInt(i[1], 10)) / 100, this.g = Math.min(100, parseInt(i[2], 10)) / 100, this.b = Math.min(100, parseInt(i[3], 10)) / 100, t(i[4]), this; + break; + case "hsl": + case "hsla": + if (i = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) { + let a = parseFloat(i[1]) / 360, l = parseInt(i[2], 10) / 100, c = parseInt(i[3], 10) / 100; + return t(i[4]), this.setHSL(a, l, c); + } + break; + } + } else if (n = /^\#([A-Fa-f\d]+)$/.exec(e)) { + let i = n[1], r = i.length; + if (r === 3) return this.r = parseInt(i.charAt(0) + i.charAt(0), 16) / 255, this.g = parseInt(i.charAt(1) + i.charAt(1), 16) / 255, this.b = parseInt(i.charAt(2) + i.charAt(2), 16) / 255, this; + if (r === 6) return this.r = parseInt(i.charAt(0) + i.charAt(1), 16) / 255, this.g = parseInt(i.charAt(2) + i.charAt(3), 16) / 255, this.b = parseInt(i.charAt(4) + i.charAt(5), 16) / 255, this; + } + return e && e.length > 0 ? this.setColorName(e) : this; + } + setColorName(e) { + let t = $c[e.toLowerCase()]; + return t !== void 0 ? this.setHex(t) : console.warn("THREE.Color: Unknown color " + e), this; + } + clone() { + return new this.constructor(this.r, this.g, this.b); + } + copy(e) { + return this.r = e.r, this.g = e.g, this.b = e.b, this; + } + copySRGBToLinear(e) { + return this.r = Do(e.r), this.g = Do(e.g), this.b = Do(e.b), this; + } + copyLinearToSRGB(e) { + return this.r = Fo(e.r), this.g = Fo(e.g), this.b = Fo(e.b), this; + } + convertSRGBToLinear() { + return this.copySRGBToLinear(this), this; + } + convertLinearToSRGB() { + return this.copyLinearToSRGB(this), this; + } + getHex() { + return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0; + } + getHexString() { + return ("000000" + this.getHex().toString(16)).slice(-6); + } + getHSL(e) { + let t = this.r, n = this.g, i = this.b, r = Math.max(t, n, i), o = Math.min(t, n, i), a, l, c = (o + r) / 2; + if (o === r) a = 0, l = 0; + else { + let h = r - o; + switch(l = c <= .5 ? h / (r + o) : h / (2 - r - o), r){ + case t: + a = (n - i) / h + (n < i ? 6 : 0); + break; + case n: + a = (i - t) / h + 2; + break; + case i: + a = (t - n) / h + 4; + break; + } + a /= 6; + } + return e.h = a, e.s = l, e.l = c, e; + } + getStyle() { + return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")"; + } + offsetHSL(e, t, n) { + return this.getHSL(Ft), Ft.h += e, Ft.s += t, Ft.l += n, this.setHSL(Ft.h, Ft.s, Ft.l), this; + } + add(e) { + return this.r += e.r, this.g += e.g, this.b += e.b, this; + } + addColors(e, t) { + return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; + } + addScalar(e) { + return this.r += e, this.g += e, this.b += e, this; + } + sub(e) { + return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this; + } + multiply(e) { + return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; + } + multiplyScalar(e) { + return this.r *= e, this.g *= e, this.b *= e, this; + } + lerp(e, t) { + return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this; + } + lerpColors(e, t, n) { + return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; + } + lerpHSL(e, t) { + this.getHSL(Ft), e.getHSL(jr); + let n = or(Ft.h, jr.h, t), i = or(Ft.s, jr.s, t), r = or(Ft.l, jr.l, t); + return this.setHSL(n, i, r), this; + } + equals(e) { + return e.r === this.r && e.g === this.g && e.b === this.b; + } + fromArray(e, t = 0) { + return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; + } + toArray(e = [], t = 0) { + return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; + } + fromBufferAttribute(e, t) { + return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), e.normalized === !0 && (this.r /= 255, this.g /= 255, this.b /= 255), this; + } + toJSON() { + return this.getHex(); + } +}; +ae.NAMES = $c; +ae.prototype.isColor = !0; +ae.prototype.r = 1; +ae.prototype.g = 1; +ae.prototype.b = 1; +var hn = class extends dt { + constructor(e){ + super(); + this.type = "MeshBasicMaterial", this.color = new ae(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.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + } +}; +hn.prototype.isMeshBasicMaterial = !0; +var Je = new M, Qr = new X, Ue = class { + constructor(e, t, n){ + if (Array.isArray(e)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); + this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n === !0, this.usage = hr, this.updateRange = { + offset: 0, + count: -1 + }, this.version = 0; + } + onUploadCallback() {} + set needsUpdate(e) { + e === !0 && this.version++; + } + setUsage(e) { + return this.usage = e, this; + } + copy(e) { + return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this; + } + copyAt(e, t, n) { + e *= this.itemSize, n *= t.itemSize; + for(let i = 0, r = this.itemSize; i < r; i++)this.array[e + i] = t.array[n + i]; + return this; + } + copyArray(e) { + return this.array.set(e), this; + } + copyColorsArray(e) { + let t = this.array, n = 0; + for(let i = 0, r = e.length; i < r; i++){ + let o = e[i]; + o === void 0 && (console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i), o = new ae), t[n++] = o.r, t[n++] = o.g, t[n++] = o.b; + } + return this; + } + copyVector2sArray(e) { + let t = this.array, n = 0; + for(let i = 0, r = e.length; i < r; i++){ + let o = e[i]; + o === void 0 && (console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i), o = new X), t[n++] = o.x, t[n++] = o.y; + } + return this; + } + copyVector3sArray(e) { + let t = this.array, n = 0; + for(let i = 0, r = e.length; i < r; i++){ + let o = e[i]; + o === void 0 && (console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i), o = new M), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z; + } + return this; + } + copyVector4sArray(e) { + let t = this.array, n = 0; + for(let i = 0, r = e.length; i < r; i++){ + let o = e[i]; + o === void 0 && (console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i), o = new Ve), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z, t[n++] = o.w; + } + return this; + } + applyMatrix3(e) { + if (this.itemSize === 2) for(let t = 0, n = this.count; t < n; t++)Qr.fromBufferAttribute(this, t), Qr.applyMatrix3(e), this.setXY(t, Qr.x, Qr.y); + else if (this.itemSize === 3) for(let t = 0, n = this.count; t < n; t++)Je.fromBufferAttribute(this, t), Je.applyMatrix3(e), this.setXYZ(t, Je.x, Je.y, Je.z); + return this; + } + applyMatrix4(e) { + for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyMatrix4(e), this.setXYZ(t, Je.x, Je.y, Je.z); + return this; + } + applyNormalMatrix(e) { + for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyNormalMatrix(e), this.setXYZ(t, Je.x, Je.y, Je.z); + return this; + } + transformDirection(e) { + for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.transformDirection(e), this.setXYZ(t, Je.x, Je.y, Je.z); + return this; + } + set(e, t = 0) { + return this.array.set(e, t), this; + } + getX(e) { + return this.array[e * this.itemSize]; + } + setX(e, t) { + return this.array[e * this.itemSize] = t, this; + } + getY(e) { + return this.array[e * this.itemSize + 1]; + } + setY(e, t) { + return this.array[e * this.itemSize + 1] = t, this; + } + getZ(e) { + return this.array[e * this.itemSize + 2]; + } + setZ(e, t) { + return this.array[e * this.itemSize + 2] = t, this; + } + getW(e) { + return this.array[e * this.itemSize + 3]; + } + setW(e, t) { + return this.array[e * this.itemSize + 3] = t, this; + } + setXY(e, t, n) { + return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this; + } + setXYZ(e, t, n, i) { + return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this; + } + setXYZW(e, t, n, i, r) { + return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this.array[e + 3] = r, this; + } + onUpload(e) { + return this.onUploadCallback = e, this; + } + clone() { + return new this.constructor(this.array, this.itemSize).copy(this); + } + toJSON() { + let e = { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: Array.prototype.slice.call(this.array), + normalized: this.normalized + }; + return this.name !== "" && (e.name = this.name), this.usage !== hr && (e.usage = this.usage), (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (e.updateRange = this.updateRange), e; + } +}; +Ue.prototype.isBufferAttribute = !0; +var jc = class extends Ue { + constructor(e, t, n){ + super(new Int8Array(e), t, n); + } +}, Qc = class extends Ue { + constructor(e, t, n){ + super(new Uint8Array(e), t, n); + } +}, Kc = class extends Ue { + constructor(e, t, n){ + super(new Uint8ClampedArray(e), t, n); + } +}, eh = class extends Ue { + constructor(e, t, n){ + super(new Int16Array(e), t, n); + } +}, Ys = class extends Ue { + constructor(e, t, n){ + super(new Uint16Array(e), t, n); + } +}, th = class extends Ue { + constructor(e, t, n){ + super(new Int32Array(e), t, n); + } +}, Zs = class extends Ue { + constructor(e, t, n){ + super(new Uint32Array(e), t, n); + } +}, nh = class extends Ue { + constructor(e, t, n){ + super(new Uint16Array(e), t, n); + } +}; +nh.prototype.isFloat16BufferAttribute = !0; +var de = class extends Ue { + constructor(e, t, n){ + super(new Float32Array(e), t, n); + } +}, ih = class extends Ue { + constructor(e, t, n){ + super(new Float64Array(e), t, n); + } +}, cf = 0, Rt = new pe, No = new Ne, ci = new M, Tt = new Lt, $i = new Lt, ht = new M, _e = class extends En { + constructor(){ + super(); + Object.defineProperty(this, "id", { + value: cf++ + }), this.uuid = Et(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { + start: 0, + count: 1 / 0 + }, this.userData = {}; + } + getIndex() { + return this.index; + } + setIndex(e) { + return Array.isArray(e) ? this.index = new (Yc(e) > 65535 ? Zs : Ys)(e, 1) : this.index = e, this; + } + getAttribute(e) { + return this.attributes[e]; + } + setAttribute(e, t) { + return this.attributes[e] = t, this; + } + deleteAttribute(e) { + return delete this.attributes[e], this; + } + hasAttribute(e) { + return this.attributes[e] !== void 0; + } + addGroup(e, t, n = 0) { + this.groups.push({ + start: e, + count: t, + materialIndex: n + }); + } + clearGroups() { + this.groups = []; + } + setDrawRange(e, t) { + this.drawRange.start = e, this.drawRange.count = t; + } + applyMatrix4(e) { + let t = this.attributes.position; + t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); + let n = this.attributes.normal; + if (n !== void 0) { + let r = new lt().getNormalMatrix(e); + n.applyNormalMatrix(r), n.needsUpdate = !0; + } + let i = this.attributes.tangent; + return i !== void 0 && (i.transformDirection(e), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; + } + applyQuaternion(e) { + return Rt.makeRotationFromQuaternion(e), this.applyMatrix4(Rt), this; + } + rotateX(e) { + return Rt.makeRotationX(e), this.applyMatrix4(Rt), this; + } + rotateY(e) { + return Rt.makeRotationY(e), this.applyMatrix4(Rt), this; + } + rotateZ(e) { + return Rt.makeRotationZ(e), this.applyMatrix4(Rt), this; + } + translate(e, t, n) { + return Rt.makeTranslation(e, t, n), this.applyMatrix4(Rt), this; + } + scale(e, t, n) { + return Rt.makeScale(e, t, n), this.applyMatrix4(Rt), this; + } + lookAt(e) { + return No.lookAt(e), No.updateMatrix(), this.applyMatrix4(No.matrix), this; + } + center() { + return this.computeBoundingBox(), this.boundingBox.getCenter(ci).negate(), this.translate(ci.x, ci.y, ci.z), this; + } + setFromPoints(e) { + let t = []; + for(let n = 0, i = e.length; n < i; n++){ + let r = e[n]; + t.push(r.x, r.y, r.z || 0); + } + return this.setAttribute("position", new de(t, 3)), this; + } + computeBoundingBox() { + this.boundingBox === null && (this.boundingBox = new Lt); + let e = this.attributes.position, t = this.morphAttributes.position; + if (e && e.isGLBufferAttribute) { + console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingBox.set(new M(-1 / 0, -1 / 0, -1 / 0), new M(1 / 0, 1 / 0, 1 / 0)); + return; + } + if (e !== void 0) { + if (this.boundingBox.setFromBufferAttribute(e), t) for(let n = 0, i = t.length; n < i; n++){ + let r = t[n]; + Tt.setFromBufferAttribute(r), this.morphTargetsRelative ? (ht.addVectors(this.boundingBox.min, Tt.min), this.boundingBox.expandByPoint(ht), ht.addVectors(this.boundingBox.max, Tt.max), this.boundingBox.expandByPoint(ht)) : (this.boundingBox.expandByPoint(Tt.min), this.boundingBox.expandByPoint(Tt.max)); + } + } else this.boundingBox.makeEmpty(); + (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this); + } + computeBoundingSphere() { + this.boundingSphere === null && (this.boundingSphere = new An); + let e = this.attributes.position, t = this.morphAttributes.position; + if (e && e.isGLBufferAttribute) { + console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingSphere.set(new M, 1 / 0); + return; + } + if (e) { + let n = this.boundingSphere.center; + if (Tt.setFromBufferAttribute(e), t) for(let r = 0, o = t.length; r < o; r++){ + let a = t[r]; + $i.setFromBufferAttribute(a), this.morphTargetsRelative ? (ht.addVectors(Tt.min, $i.min), Tt.expandByPoint(ht), ht.addVectors(Tt.max, $i.max), Tt.expandByPoint(ht)) : (Tt.expandByPoint($i.min), Tt.expandByPoint($i.max)); + } + Tt.getCenter(n); + let i = 0; + for(let r = 0, o = e.count; r < o; r++)ht.fromBufferAttribute(e, r), i = Math.max(i, n.distanceToSquared(ht)); + if (t) for(let r = 0, o = t.length; r < o; r++){ + let a = t[r], l = this.morphTargetsRelative; + for(let c = 0, h = a.count; c < h; c++)ht.fromBufferAttribute(a, c), l && (ci.fromBufferAttribute(e, c), ht.add(ci)), i = Math.max(i, n.distanceToSquared(ht)); + } + this.boundingSphere.radius = Math.sqrt(i), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this); + } + } + computeTangents() { + let e = this.index, t = this.attributes; + if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { + console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); + return; + } + let n = e.array, i = t.position.array, r = t.normal.array, o = t.uv.array, a = i.length / 3; + t.tangent === void 0 && this.setAttribute("tangent", new Ue(new Float32Array(4 * a), 4)); + let l = t.tangent.array, c = [], h = []; + for(let B = 0; B < a; B++)c[B] = new M, h[B] = new M; + let u = new M, d = new M, f = new M, m = new X, x = new X, v = new X, g = new M, p = new M; + function _(B, P, w) { + u.fromArray(i, B * 3), d.fromArray(i, P * 3), f.fromArray(i, w * 3), m.fromArray(o, B * 2), x.fromArray(o, P * 2), v.fromArray(o, w * 2), d.sub(u), f.sub(u), x.sub(m), v.sub(m); + let E = 1 / (x.x * v.y - v.x * x.y); + !isFinite(E) || (g.copy(d).multiplyScalar(v.y).addScaledVector(f, -x.y).multiplyScalar(E), p.copy(f).multiplyScalar(x.x).addScaledVector(d, -v.x).multiplyScalar(E), c[B].add(g), c[P].add(g), c[w].add(g), h[B].add(p), h[P].add(p), h[w].add(p)); + } + let y = this.groups; + y.length === 0 && (y = [ + { + start: 0, + count: n.length + } + ]); + for(let B = 0, P = y.length; B < P; ++B){ + let w = y[B], E = w.start, D = w.count; + for(let U = E, F = E + D; U < F; U += 3)_(n[U + 0], n[U + 1], n[U + 2]); + } + let b = new M, A = new M, L = new M, I = new M; + function k(B) { + L.fromArray(r, B * 3), I.copy(L); + let P = c[B]; + b.copy(P), b.sub(L.multiplyScalar(L.dot(P))).normalize(), A.crossVectors(I, P); + let E = A.dot(h[B]) < 0 ? -1 : 1; + l[B * 4] = b.x, l[B * 4 + 1] = b.y, l[B * 4 + 2] = b.z, l[B * 4 + 3] = E; + } + for(let B = 0, P = y.length; B < P; ++B){ + let w = y[B], E = w.start, D = w.count; + for(let U = E, F = E + D; U < F; U += 3)k(n[U + 0]), k(n[U + 1]), k(n[U + 2]); + } + } + computeVertexNormals() { + let e = this.index, t = this.getAttribute("position"); + if (t !== void 0) { + let n = this.getAttribute("normal"); + if (n === void 0) n = new Ue(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); + else for(let d = 0, f = n.count; d < f; d++)n.setXYZ(d, 0, 0, 0); + let i = new M, r = new M, o = new M, a = new M, l = new M, c = new M, h = new M, u = new M; + if (e) for(let d = 0, f = e.count; d < f; d += 3){ + let m = e.getX(d + 0), x = e.getX(d + 1), v = e.getX(d + 2); + i.fromBufferAttribute(t, m), r.fromBufferAttribute(t, x), o.fromBufferAttribute(t, v), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), a.fromBufferAttribute(n, m), l.fromBufferAttribute(n, x), c.fromBufferAttribute(n, v), a.add(h), l.add(h), c.add(h), n.setXYZ(m, a.x, a.y, a.z), n.setXYZ(x, l.x, l.y, l.z), n.setXYZ(v, c.x, c.y, c.z); + } + else for(let d = 0, f = t.count; d < f; d += 3)i.fromBufferAttribute(t, d + 0), r.fromBufferAttribute(t, d + 1), o.fromBufferAttribute(t, d + 2), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), n.setXYZ(d + 0, h.x, h.y, h.z), n.setXYZ(d + 1, h.x, h.y, h.z), n.setXYZ(d + 2, h.x, h.y, h.z); + this.normalizeNormals(), n.needsUpdate = !0; + } + } + merge(e, t) { + if (!(e && e.isBufferGeometry)) { + console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", e); + return; + } + t === void 0 && (t = 0, console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.")); + let n = this.attributes; + for(let i in n){ + if (e.attributes[i] === void 0) continue; + let o = n[i].array, a = e.attributes[i], l = a.array, c = a.itemSize * t, h = Math.min(l.length, o.length - c); + for(let u = 0, d = c; u < h; u++, d++)o[d] = l[u]; + } + return this; + } + normalizeNormals() { + let e = this.attributes.normal; + for(let t = 0, n = e.count; t < n; t++)ht.fromBufferAttribute(e, t), ht.normalize(), e.setXYZ(t, ht.x, ht.y, ht.z); + } + toNonIndexed() { + function e(a, l) { + let c = a.array, h = a.itemSize, u = a.normalized, d = new c.constructor(l.length * h), f = 0, m = 0; + for(let x = 0, v = l.length; x < v; x++){ + a.isInterleavedBufferAttribute ? f = l[x] * a.data.stride + a.offset : f = l[x] * h; + for(let g = 0; g < h; g++)d[m++] = c[f++]; + } + return new Ue(d, h, u); + } + if (this.index === null) return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; + let t = new _e, n = this.index.array, i = this.attributes; + for(let a in i){ + let l = i[a], c = e(l, n); + t.setAttribute(a, c); + } + let r = this.morphAttributes; + for(let a in r){ + let l = [], c = r[a]; + for(let h = 0, u = c.length; h < u; h++){ + let d = c[h], f = e(d, n); + l.push(f); + } + t.morphAttributes[a] = l; + } + t.morphTargetsRelative = this.morphTargetsRelative; + let o = this.groups; + for(let a = 0, l = o.length; a < l; a++){ + let c = o[a]; + t.addGroup(c.start, c.count, c.materialIndex); + } + return t; + } + toJSON() { + let e = { + metadata: { + version: 4.5, + type: "BufferGeometry", + generator: "BufferGeometry.toJSON" + } + }; + if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) { + let l = this.parameters; + for(let c in l)l[c] !== void 0 && (e[c] = l[c]); + return e; + } + e.data = { + attributes: {} + }; + let t = this.index; + t !== null && (e.data.index = { + type: t.array.constructor.name, + array: Array.prototype.slice.call(t.array) + }); + let n = this.attributes; + for(let l in n){ + let c = n[l]; + e.data.attributes[l] = c.toJSON(e.data); + } + let i = {}, r = !1; + for(let l in this.morphAttributes){ + let c = this.morphAttributes[l], h = []; + for(let u = 0, d = c.length; u < d; u++){ + let f = c[u]; + h.push(f.toJSON(e.data)); + } + h.length > 0 && (i[l] = h, r = !0); + } + r && (e.data.morphAttributes = i, e.data.morphTargetsRelative = this.morphTargetsRelative); + let o = this.groups; + o.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(o))); + let a = this.boundingSphere; + return a !== null && (e.data.boundingSphere = { + center: a.center.toArray(), + radius: a.radius + }), e; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; + let t = {}; + this.name = e.name; + let n = e.index; + n !== null && this.setIndex(n.clone(t)); + let i = e.attributes; + for(let c in i){ + let h = i[c]; + this.setAttribute(c, h.clone(t)); + } + let r = e.morphAttributes; + for(let c in r){ + let h = [], u = r[c]; + for(let d = 0, f = u.length; d < f; d++)h.push(u[d].clone(t)); + this.morphAttributes[c] = h; + } + this.morphTargetsRelative = e.morphTargetsRelative; + let o = e.groups; + for(let c = 0, h = o.length; c < h; c++){ + let u = o[c]; + this.addGroup(u.start, u.count, u.materialIndex); + } + let a = e.boundingBox; + a !== null && (this.boundingBox = a.clone()); + let l = e.boundingSphere; + return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, e.parameters !== void 0 && (this.parameters = Object.assign({}, e.parameters)), this; + } + dispose() { + this.dispatchEvent({ + type: "dispose" + }); + } +}; +_e.prototype.isBufferGeometry = !0; +var Cl = new pe, hi = new Cn, Bo = new An, mn = new M, gn = new M, xn = new M, zo = new M, Uo = new M, Oo = new M, Kr = new M, es = new M, ts = new M, ns = new X, is = new X, rs = new X, Ho = new M, ss = new M, st = class extends Ne { + constructor(e = new _e, t = new hn){ + super(); + this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets(); + } + copy(e) { + return super.copy(e), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = e.material, this.geometry = e.geometry, this; + } + updateMorphTargets() { + let e = this.geometry; + if (e.isBufferGeometry) { + let t = e.morphAttributes, n = Object.keys(t); + if (n.length > 0) { + let i = t[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, o = i.length; r < o; r++){ + let a = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; + } + } + } + } else { + let t = e.morphTargets; + t !== void 0 && t.length > 0 && console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } + } + raycast(e, t) { + let n = this.geometry, i = this.material, r = this.matrixWorld; + if (i === void 0 || (n.boundingSphere === null && n.computeBoundingSphere(), Bo.copy(n.boundingSphere), Bo.applyMatrix4(r), e.ray.intersectsSphere(Bo) === !1) || (Cl.copy(r).invert(), hi.copy(e.ray).applyMatrix4(Cl), n.boundingBox !== null && hi.intersectsBox(n.boundingBox) === !1)) return; + let o; + if (n.isBufferGeometry) { + let a = n.index, l = n.attributes.position, c = n.morphAttributes.position, h = n.morphTargetsRelative, u = n.attributes.uv, d = n.attributes.uv2, f = n.groups, m = n.drawRange; + if (a !== null) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ + let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(a.count, Math.min(g.start + g.count, m.start + m.count)); + for(let b = _, A = y; b < A; b += 3){ + let L = a.getX(b), I = a.getX(b + 1), k = a.getX(b + 2); + o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); + } + } + else { + let x = Math.max(0, m.start), v = Math.min(a.count, m.start + m.count); + for(let g = x, p = v; g < p; g += 3){ + let _ = a.getX(g), y = a.getX(g + 1), b = a.getX(g + 2); + o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); + } + } + else if (l !== void 0) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ + let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(l.count, Math.min(g.start + g.count, m.start + m.count)); + for(let b = _, A = y; b < A; b += 3){ + let L = b, I = b + 1, k = b + 2; + o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); + } + } + else { + let x = Math.max(0, m.start), v = Math.min(l.count, m.start + m.count); + for(let g = x, p = v; g < p; g += 3){ + let _ = g, y = g + 1, b = g + 2; + o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); + } + } + } else n.isGeometry && console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } +}; +st.prototype.isMesh = !0; +function hf(s, e, t, n, i, r, o, a) { + let l; + if (e.side === it ? l = n.intersectTriangle(o, r, i, !0, a) : l = n.intersectTriangle(i, r, o, e.side !== Ci, a), l === null) return null; + ss.copy(a), ss.applyMatrix4(s.matrixWorld); + let c = t.ray.origin.distanceTo(ss); + return c < t.near || c > t.far ? null : { + distance: c, + point: ss.clone(), + object: s + }; +} +function os(s, e, t, n, i, r, o, a, l, c, h, u) { + mn.fromBufferAttribute(i, c), gn.fromBufferAttribute(i, h), xn.fromBufferAttribute(i, u); + let d = s.morphTargetInfluences; + if (r && d) { + Kr.set(0, 0, 0), es.set(0, 0, 0), ts.set(0, 0, 0); + for(let m = 0, x = r.length; m < x; m++){ + let v = d[m], g = r[m]; + v !== 0 && (zo.fromBufferAttribute(g, c), Uo.fromBufferAttribute(g, h), Oo.fromBufferAttribute(g, u), o ? (Kr.addScaledVector(zo, v), es.addScaledVector(Uo, v), ts.addScaledVector(Oo, v)) : (Kr.addScaledVector(zo.sub(mn), v), es.addScaledVector(Uo.sub(gn), v), ts.addScaledVector(Oo.sub(xn), v))); + } + mn.add(Kr), gn.add(es), xn.add(ts); + } + s.isSkinnedMesh && (s.boneTransform(c, mn), s.boneTransform(h, gn), s.boneTransform(u, xn)); + let f = hf(s, e, t, n, mn, gn, xn, Ho); + if (f) { + a && (ns.fromBufferAttribute(a, c), is.fromBufferAttribute(a, h), rs.fromBufferAttribute(a, u), f.uv = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)), l && (ns.fromBufferAttribute(l, c), is.fromBufferAttribute(l, h), rs.fromBufferAttribute(l, u), f.uv2 = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)); + let m = { + a: c, + b: h, + c: u, + normal: new M, + materialIndex: 0 + }; + nt.getNormal(mn, gn, xn, m.normal), f.face = m; + } + return f; +} +var wn = class extends _e { + constructor(e = 1, t = 1, n = 1, i = 1, r = 1, o = 1){ + super(); + this.type = "BoxGeometry", this.parameters = { + width: e, + height: t, + depth: n, + widthSegments: i, + heightSegments: r, + depthSegments: o + }; + let a = this; + i = Math.floor(i), r = Math.floor(r), o = Math.floor(o); + let l = [], c = [], h = [], u = [], d = 0, f = 0; + m("z", "y", "x", -1, -1, n, t, e, o, r, 0), m("z", "y", "x", 1, -1, n, t, -e, o, r, 1), m("x", "z", "y", 1, 1, e, n, t, i, o, 2), m("x", "z", "y", 1, -1, e, n, -t, i, o, 3), m("x", "y", "z", 1, -1, e, t, n, i, r, 4), m("x", "y", "z", -1, -1, e, t, -n, i, r, 5), this.setIndex(l), this.setAttribute("position", new de(c, 3)), this.setAttribute("normal", new de(h, 3)), this.setAttribute("uv", new de(u, 2)); + function m(x, v, g, p, _, y, b, A, L, I, k) { + let B = y / L, P = b / I, w = y / 2, E = b / 2, D = A / 2, U = L + 1, F = I + 1, O = 0, ne = 0, ce = new M; + for(let V = 0; V < F; V++){ + let W = V * P - E; + for(let he = 0; he < U; he++){ + let le = he * B - w; + ce[x] = le * p, ce[v] = W * _, ce[g] = D, c.push(ce.x, ce.y, ce.z), ce[x] = 0, ce[v] = 0, ce[g] = A > 0 ? 1 : -1, h.push(ce.x, ce.y, ce.z), u.push(he / L), u.push(1 - V / I), O += 1; + } + } + for(let V = 0; V < I; V++)for(let W = 0; W < L; W++){ + let he = d + W + U * V, le = d + W + U * (V + 1), fe = d + (W + 1) + U * (V + 1), Be = d + (W + 1) + U * V; + l.push(he, le, Be), l.push(le, fe, Be), ne += 6; + } + a.addGroup(f, ne, k), f += ne, d += O; + } + } + static fromJSON(e) { + return new wn(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); + } +}; +function Ri(s) { + let e = {}; + for(let t in s){ + e[t] = {}; + for(let n in s[t]){ + let i = s[t][n]; + i && (i.isColor || i.isMatrix3 || i.isMatrix4 || i.isVector2 || i.isVector3 || i.isVector4 || i.isTexture || i.isQuaternion) ? e[t][n] = i.clone() : Array.isArray(i) ? e[t][n] = i.slice() : e[t][n] = i; + } + } + return e; +} +function yt(s) { + let e = {}; + for(let t = 0; t < s.length; t++){ + let n = Ri(s[t]); + for(let i in n)e[i] = n[i]; + } + return e; +} +var uf = { + clone: Ri, + merge: yt +}, df = `void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`, ff = `void main() { + gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); +}`, sn = class extends dt { + constructor(e){ + super(); + this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.vertexShader = df, this.fragmentShader = ff, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.extensions = { + derivatives: !1, + fragDepth: !1, + drawBuffers: !1, + shaderTextureLOD: !1 + }, this.defaultAttributeValues = { + color: [ + 1, + 1, + 1 + ], + uv: [ + 0, + 0 + ], + uv2: [ + 0, + 0 + ] + }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && (e.attributes !== void 0 && console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."), this.setValues(e)); + } + copy(e) { + return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Ri(e.uniforms), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this; + } + toJSON(e) { + let t = super.toJSON(e); + t.glslVersion = this.glslVersion, t.uniforms = {}; + for(let i in this.uniforms){ + let o = this.uniforms[i].value; + o && o.isTexture ? t.uniforms[i] = { + type: "t", + value: o.toJSON(e).uuid + } : o && o.isColor ? t.uniforms[i] = { + type: "c", + value: o.getHex() + } : o && o.isVector2 ? t.uniforms[i] = { + type: "v2", + value: o.toArray() + } : o && o.isVector3 ? t.uniforms[i] = { + type: "v3", + value: o.toArray() + } : o && o.isVector4 ? t.uniforms[i] = { + type: "v4", + value: o.toArray() + } : o && o.isMatrix3 ? t.uniforms[i] = { + type: "m3", + value: o.toArray() + } : o && o.isMatrix4 ? t.uniforms[i] = { + type: "m4", + value: o.toArray() + } : t.uniforms[i] = { + value: o + }; + } + Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader; + let n = {}; + for(let i in this.extensions)this.extensions[i] === !0 && (n[i] = !0); + return Object.keys(n).length > 0 && (t.extensions = n), t; + } +}; +sn.prototype.isShaderMaterial = !0; +var Ir = class extends Ne { + constructor(){ + super(); + this.type = "Camera", this.matrixWorldInverse = new pe, this.projectionMatrix = new pe, this.projectionMatrixInverse = new pe; + } + copy(e, t) { + return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this; + } + getWorldDirection(e) { + this.updateWorldMatrix(!0, !1); + let t = this.matrixWorld.elements; + return e.set(-t[8], -t[9], -t[10]).normalize(); + } + updateMatrixWorld(e) { + super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + updateWorldMatrix(e, t) { + super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + clone() { + return new this.constructor().copy(this); + } +}; +Ir.prototype.isCamera = !0; +var ut = class extends Ir { + constructor(e = 50, t = 1, n = .1, i = 2e3){ + super(); + this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); + } + copy(e, t) { + return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; + } + setFocalLength(e) { + let t = .5 * this.getFilmHeight() / e; + this.fov = dr * 2 * Math.atan(t), this.updateProjectionMatrix(); + } + getFocalLength() { + let e = Math.tan(Wn * .5 * this.fov); + return .5 * this.getFilmHeight() / e; + } + getEffectiveFOV() { + return dr * 2 * Math.atan(Math.tan(Wn * .5 * this.fov) / this.zoom); + } + getFilmWidth() { + return this.filmGauge * Math.min(this.aspect, 1); + } + getFilmHeight() { + return this.filmGauge / Math.max(this.aspect, 1); + } + setViewOffset(e, t, n, i, r, o) { + this.aspect = e / t, this.view === null && (this.view = { + enabled: !0, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); + } + clearViewOffset() { + this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); + } + updateProjectionMatrix() { + let e = this.near, t = e * Math.tan(Wn * .5 * this.fov) / this.zoom, n = 2 * t, i = this.aspect * n, r = -.5 * i, o = this.view; + if (this.view !== null && this.view.enabled) { + let l = o.fullWidth, c = o.fullHeight; + r += o.offsetX * i / l, t -= o.offsetY * n / c, i *= o.width / l, n *= o.height / c; + } + let a = this.filmOffset; + a !== 0 && (r += e * a / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, t, t - n, e, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + toJSON(e) { + let t = super.toJSON(e); + return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; + } +}; +ut.prototype.isPerspectiveCamera = !0; +var ui = 90, di = 1, $s = class extends Ne { + constructor(e, t, n){ + super(); + if (this.type = "CubeCamera", n.isWebGLCubeRenderTarget !== !0) { + console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."); + return; + } + this.renderTarget = n; + let i = new ut(ui, di, e, t); + i.layers = this.layers, i.up.set(0, -1, 0), i.lookAt(new M(1, 0, 0)), this.add(i); + let r = new ut(ui, di, e, t); + r.layers = this.layers, r.up.set(0, -1, 0), r.lookAt(new M(-1, 0, 0)), this.add(r); + let o = new ut(ui, di, e, t); + o.layers = this.layers, o.up.set(0, 0, 1), o.lookAt(new M(0, 1, 0)), this.add(o); + let a = new ut(ui, di, e, t); + a.layers = this.layers, a.up.set(0, 0, -1), a.lookAt(new M(0, -1, 0)), this.add(a); + let l = new ut(ui, di, e, t); + l.layers = this.layers, l.up.set(0, -1, 0), l.lookAt(new M(0, 0, 1)), this.add(l); + let c = new ut(ui, di, e, t); + c.layers = this.layers, c.up.set(0, -1, 0), c.lookAt(new M(0, 0, -1)), this.add(c); + } + update(e, t) { + this.parent === null && this.updateMatrixWorld(); + let n = this.renderTarget, [i, r, o, a, l, c] = this.children, h = e.xr.enabled, u = e.getRenderTarget(); + e.xr.enabled = !1; + let d = n.texture.generateMipmaps; + n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0), e.render(t, i), e.setRenderTarget(n, 1), e.render(t, r), e.setRenderTarget(n, 2), e.render(t, o), e.setRenderTarget(n, 3), e.render(t, a), e.setRenderTarget(n, 4), e.render(t, l), n.texture.generateMipmaps = d, e.setRenderTarget(n, 5), e.render(t, c), e.setRenderTarget(u), e.xr.enabled = h; + } +}, ki = class extends ot { + constructor(e, t, n, i, r, o, a, l, c, h){ + e = e !== void 0 ? e : [], t = t !== void 0 ? t : Bi; + super(e, t, n, i, r, o, a, l, c, h); + this.flipY = !1; + } + get images() { + return this.image; + } + set images(e) { + this.image = e; + } +}; +ki.prototype.isCubeTexture = !0; +var js = class extends At { + constructor(e, t, n){ + Number.isInteger(t) && (console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"), t = n); + super(e, e, t); + t = t || {}, this.texture = new ki(void 0, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.encoding), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : tt, this.texture._needsFlipEnvMap = !1; + } + fromEquirectangularTexture(e, t) { + this.texture.type = t.type, this.texture.format = ct, this.texture.encoding = t.encoding, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; + let n = { + uniforms: { + tEquirect: { + value: null + } + }, + vertexShader: ` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `, + fragmentShader: ` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + ` + }, i = new wn(5, 5, 5), r = new sn({ + name: "CubemapFromEquirect", + uniforms: Ri(n.uniforms), + vertexShader: n.vertexShader, + fragmentShader: n.fragmentShader, + side: it, + blending: vn + }); + r.uniforms.tEquirect.value = t; + let o = new st(i, r), a = t.minFilter; + return t.minFilter === Ui && (t.minFilter = tt), new $s(1, 10, this).update(e, o), t.minFilter = a, o.geometry.dispose(), o.material.dispose(), this; + } + clear(e, t, n, i) { + let r = e.getRenderTarget(); + for(let o = 0; o < 6; o++)e.setRenderTarget(this, o), e.clear(t, n, i); + e.setRenderTarget(r); + } +}; +js.prototype.isWebGLCubeRenderTarget = !0; +var ko = new M, pf = new M, mf = new lt, Wt = class { + constructor(e = new M(1, 0, 0), t = 0){ + this.normal = e, this.constant = t; + } + set(e, t) { + return this.normal.copy(e), this.constant = t, this; + } + setComponents(e, t, n, i) { + return this.normal.set(e, t, n), this.constant = i, this; + } + setFromNormalAndCoplanarPoint(e, t) { + return this.normal.copy(e), this.constant = -t.dot(this.normal), this; + } + setFromCoplanarPoints(e, t, n) { + let i = ko.subVectors(n, t).cross(pf.subVectors(e, t)).normalize(); + return this.setFromNormalAndCoplanarPoint(i, e), this; + } + copy(e) { + return this.normal.copy(e.normal), this.constant = e.constant, this; + } + normalize() { + let e = 1 / this.normal.length(); + return this.normal.multiplyScalar(e), this.constant *= e, this; + } + negate() { + return this.constant *= -1, this.normal.negate(), this; + } + distanceToPoint(e) { + return this.normal.dot(e) + this.constant; + } + distanceToSphere(e) { + return this.distanceToPoint(e.center) - e.radius; + } + projectPoint(e, t) { + return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e); + } + intersectLine(e, t) { + let n = e.delta(ko), i = this.normal.dot(n); + if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; + let r = -(e.start.dot(this.normal) + this.constant) / i; + return r < 0 || r > 1 ? null : t.copy(n).multiplyScalar(r).add(e.start); + } + intersectsLine(e) { + let t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); + return t < 0 && n > 0 || n < 0 && t > 0; + } + intersectsBox(e) { + return e.intersectsPlane(this); + } + intersectsSphere(e) { + return e.intersectsPlane(this); + } + coplanarPoint(e) { + return e.copy(this.normal).multiplyScalar(-this.constant); + } + applyMatrix4(e, t) { + let n = t || mf.getNormalMatrix(e), i = this.coplanarPoint(ko).applyMatrix4(e), r = this.normal.applyMatrix3(n).normalize(); + return this.constant = -i.dot(r), this; + } + translate(e) { + return this.constant -= e.dot(this.normal), this; + } + equals(e) { + return e.normal.equals(this.normal) && e.constant === this.constant; + } + clone() { + return new this.constructor().copy(this); + } +}; +Wt.prototype.isPlane = !0; +var fi = new An, as = new M, Dr = class { + constructor(e = new Wt, t = new Wt, n = new Wt, i = new Wt, r = new Wt, o = new Wt){ + this.planes = [ + e, + t, + n, + i, + r, + o + ]; + } + set(e, t, n, i, r, o) { + let a = this.planes; + return a[0].copy(e), a[1].copy(t), a[2].copy(n), a[3].copy(i), a[4].copy(r), a[5].copy(o), this; + } + copy(e) { + let t = this.planes; + for(let n = 0; n < 6; n++)t[n].copy(e.planes[n]); + return this; + } + setFromProjectionMatrix(e) { + let t = this.planes, n = e.elements, i = n[0], r = n[1], o = n[2], a = n[3], l = n[4], c = n[5], h = n[6], u = n[7], d = n[8], f = n[9], m = n[10], x = n[11], v = n[12], g = n[13], p = n[14], _ = n[15]; + return t[0].setComponents(a - i, u - l, x - d, _ - v).normalize(), t[1].setComponents(a + i, u + l, x + d, _ + v).normalize(), t[2].setComponents(a + r, u + c, x + f, _ + g).normalize(), t[3].setComponents(a - r, u - c, x - f, _ - g).normalize(), t[4].setComponents(a - o, u - h, x - m, _ - p).normalize(), t[5].setComponents(a + o, u + h, x + m, _ + p).normalize(), this; + } + intersectsObject(e) { + let t = e.geometry; + return t.boundingSphere === null && t.computeBoundingSphere(), fi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); + } + intersectsSprite(e) { + return fi.center.set(0, 0, 0), fi.radius = .7071067811865476, fi.applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); + } + intersectsSphere(e) { + let t = this.planes, n = e.center, i = -e.radius; + for(let r = 0; r < 6; r++)if (t[r].distanceToPoint(n) < i) return !1; + return !0; + } + intersectsBox(e) { + let t = this.planes; + for(let n = 0; n < 6; n++){ + let i = t[n]; + if (as.x = i.normal.x > 0 ? e.max.x : e.min.x, as.y = i.normal.y > 0 ? e.max.y : e.min.y, as.z = i.normal.z > 0 ? e.max.z : e.min.z, i.distanceToPoint(as) < 0) return !1; + } + return !0; + } + containsPoint(e) { + let t = this.planes; + for(let n = 0; n < 6; n++)if (t[n].distanceToPoint(e) < 0) return !1; + return !0; + } + clone() { + return new this.constructor().copy(this); + } +}; +function rh() { + let s = null, e = !1, t = null, n = null; + function i(r, o) { + t(r, o), n = s.requestAnimationFrame(i); + } + return { + start: function() { + e !== !0 && t !== null && (n = s.requestAnimationFrame(i), e = !0); + }, + stop: function() { + s.cancelAnimationFrame(n), e = !1; + }, + setAnimationLoop: function(r) { + t = r; + }, + setContext: function(r) { + s = r; + } + }; +} +function gf(s, e) { + let t = e.isWebGL2, n = new WeakMap; + function i(c, h) { + let u = c.array, d = c.usage, f = s.createBuffer(); + s.bindBuffer(h, f), s.bufferData(h, u, d), c.onUploadCallback(); + let m = 5126; + return u instanceof Float32Array ? m = 5126 : u instanceof Float64Array ? console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.") : u instanceof Uint16Array ? c.isFloat16BufferAttribute ? t ? m = 5131 : console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.") : m = 5123 : u instanceof Int16Array ? m = 5122 : u instanceof Uint32Array ? m = 5125 : u instanceof Int32Array ? m = 5124 : u instanceof Int8Array ? m = 5120 : (u instanceof Uint8Array || u instanceof Uint8ClampedArray) && (m = 5121), { + buffer: f, + type: m, + bytesPerElement: u.BYTES_PER_ELEMENT, + version: c.version + }; + } + function r(c, h, u) { + let d = h.array, f = h.updateRange; + s.bindBuffer(u, c), f.count === -1 ? s.bufferSubData(u, 0, d) : (t ? s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d, f.offset, f.count) : s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d.subarray(f.offset, f.offset + f.count)), f.count = -1); + } + function o(c) { + return c.isInterleavedBufferAttribute && (c = c.data), n.get(c); + } + function a(c) { + c.isInterleavedBufferAttribute && (c = c.data); + let h = n.get(c); + h && (s.deleteBuffer(h.buffer), n.delete(c)); + } + function l(c, h) { + if (c.isGLBufferAttribute) { + let d = n.get(c); + (!d || d.version < c.version) && n.set(c, { + buffer: c.buffer, + type: c.type, + bytesPerElement: c.elementSize, + version: c.version + }); + return; + } + c.isInterleavedBufferAttribute && (c = c.data); + let u = n.get(c); + u === void 0 ? n.set(c, i(c, h)) : u.version < c.version && (r(u.buffer, c, h), u.version = c.version); + } + return { + get: o, + remove: a, + update: l + }; +} +var Pi = class extends _e { + constructor(e = 1, t = 1, n = 1, i = 1){ + super(); + this.type = "PlaneGeometry", this.parameters = { + width: e, + height: t, + widthSegments: n, + heightSegments: i + }; + let r = e / 2, o = t / 2, a = Math.floor(n), l = Math.floor(i), c = a + 1, h = l + 1, u = e / a, d = t / l, f = [], m = [], x = [], v = []; + for(let g = 0; g < h; g++){ + let p = g * d - o; + for(let _ = 0; _ < c; _++){ + let y = _ * u - r; + m.push(y, -p, 0), x.push(0, 0, 1), v.push(_ / a), v.push(1 - g / l); + } + } + for(let g = 0; g < l; g++)for(let p = 0; p < a; p++){ + let _ = p + c * g, y = p + c * (g + 1), b = p + 1 + c * (g + 1), A = p + 1 + c * g; + f.push(_, y, A), f.push(y, b, A); + } + this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); + } + static fromJSON(e) { + return new Pi(e.width, e.height, e.widthSegments, e.heightSegments); + } +}, xf = `#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, vUv ).g; +#endif`, yf = `#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`, vf = `#ifdef USE_ALPHATEST + if ( diffuseColor.a < alphaTest ) discard; +#endif`, _f = `#ifdef USE_ALPHATEST + uniform float alphaTest; +#endif`, Mf = `#ifdef USE_AOMAP + float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; + reflectedLight.indirectDiffuse *= ambientOcclusion; + #if defined( USE_ENVMAP ) && defined( STANDARD ) + float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); + reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); + #endif +#endif`, bf = `#ifdef USE_AOMAP + uniform sampler2D aoMap; + uniform float aoMapIntensity; +#endif`, wf = "vec3 transformed = vec3( position );", Sf = `vec3 objectNormal = vec3( normal ); +#ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); +#endif`, Tf = `vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) { + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +float G_BlinnPhong_Implicit( ) { + return 0.25; +} +float D_BlinnPhong( const in float shininess, const in float dotNH ) { + return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); +} +vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( specularColor, 1.0, dotVH ); + float G = G_BlinnPhong_Implicit( ); + float D = D_BlinnPhong( shininess, dotNH ); + return F * ( G * D ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif`, Ef = `#ifdef USE_BUMPMAP + uniform sampler2D bumpMap; + uniform float bumpScale; + vec2 dHdxy_fwd() { + vec2 dSTdx = dFdx( vUv ); + vec2 dSTdy = dFdy( vUv ); + float Hll = bumpScale * texture2D( bumpMap, vUv ).x; + float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; + float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; + return vec2( dBx, dBy ); + } + vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { + vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); + vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); + vec3 vN = surf_norm; + vec3 R1 = cross( vSigmaY, vN ); + vec3 R2 = cross( vN, vSigmaX ); + float fDet = dot( vSigmaX, R1 ) * faceDirection; + vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); + return normalize( abs( fDet ) * surf_norm - vGrad ); + } +#endif`, Af = `#if NUM_CLIPPING_PLANES > 0 + vec4 plane; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif +#endif`, Cf = `#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`, Lf = `#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`, Rf = `#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`, Pf = `#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`, If = `#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`, Df = `#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`, Ff = `#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`, Nf = `#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +struct GeometricContext { + vec3 position; + vec3 normal; + vec3 viewDir; +#ifdef USE_CLEARCOAT + vec3 clearcoatNormal; +#endif +}; +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float linearToRelativeLuminance( const in vec3 color ) { + vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); + return dot( weights, color.rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +}`, Bf = `#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_maxMipLevel 8.0 + #define cubeUV_minMipLevel 4.0 + #define cubeUV_maxTileSize 256.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); + vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + if ( mipInt < cubeUV_maxMipLevel ) { + uv.y += 2.0 * cubeUV_maxTileSize; + } + uv.y += filterInt * 2.0 * cubeUV_minTileSize; + uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); + uv *= texelSize; + return texture2D( envMap, uv ).rgb; + } + #define r0 1.0 + #define v0 0.339 + #define m0 - 2.0 + #define r1 0.8 + #define v1 0.276 + #define m1 - 1.0 + #define r4 0.4 + #define v4 0.046 + #define m4 2.0 + #define r5 0.305 + #define v5 0.016 + #define m5 3.0 + #define r6 0.21 + #define v6 0.0038 + #define m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= r1 ) { + mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; + } else if ( roughness >= r4 ) { + mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; + } else if ( roughness >= r5 ) { + mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; + } else if ( roughness >= r6 ) { + mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`, zf = `vec3 transformedNormal = objectNormal; +#ifdef USE_INSTANCING + mat3 m = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); + transformedNormal = m * transformedNormal; +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`, Uf = `#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`, Of = `#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); +#endif`, Hf = `#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vUv ); + emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`, kf = `#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`, Gf = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Vf = `vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 sRGBToLinear( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 LinearTosRGB( 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 ); +}`, Wf = `#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + envColor = envMapTexelToLinear( envColor ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`, qf = `#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`, Xf = `#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`, Jf = `#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`, Yf = `#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`, Zf = `#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`, $f = `#ifdef USE_FOG + varying float vFogDepth; +#endif`, jf = `#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`, Qf = `#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`, Kf = `#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); + #endif +}`, ep = `#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; + #ifndef PHYSICALLY_CORRECT_LIGHTS + lightMapIrradiance *= PI; + #endif + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`, tp = `#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`, np = `vec3 diffuse = vec3( 1.0 ); +GeometricContext geometry; +geometry.position = mvPosition.xyz; +geometry.normal = normalize( transformedNormal ); +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); +GeometricContext backGeometry; +backGeometry.position = geometry.position; +backGeometry.normal = -geometry.normal; +backGeometry.viewDir = geometry.viewDir; +vLightFront = vec3( 0.0 ); +vIndirectFront = vec3( 0.0 ); +#ifdef DOUBLE_SIDED + vLightBack = vec3( 0.0 ); + vIndirectBack = vec3( 0.0 ); +#endif +IncidentLight directLight; +float dotNL; +vec3 directLightColor_Diffuse; +vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); +vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); +#ifdef DOUBLE_SIDED + vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); + vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); +#endif +#if NUM_POINT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + getPointLightInfo( pointLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end +#endif +#if NUM_SPOT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + getSpotLightInfo( spotLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end +#endif +#if NUM_DIR_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end +#endif +#if NUM_HEMI_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #ifdef DOUBLE_SIDED + vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); + #endif + } + #pragma unroll_loop_end +#endif`, ip = `uniform bool receiveShadow; +uniform vec3 ambientLightColor; +uniform vec3 lightProbe[ 9 ]; +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( PHYSICALLY_CORRECT_LIGHTS ) + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #else + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometry.position; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometry.position; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`, rp = `#if defined( USE_ENVMAP ) + #ifdef ENVMAP_MODE_REFRACTION + uniform float refractionRatio; + #endif + vec3 getIBLIrradiance( const in vec3 normal ) { + #if defined( ENVMAP_TYPE_CUBE_UV ) + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #if defined( ENVMAP_TYPE_CUBE_UV ) + vec3 reflectVec; + #ifdef ENVMAP_MODE_REFLECTION + reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + #else + reflectVec = refract( - viewDir, normal, refractionRatio ); + #endif + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } +#endif`, sp = `ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`, op = `varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon +#define Material_LightProbeLOD( material ) (0)`, ap = `BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`, lp = `varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong +#define Material_LightProbeLOD( material ) (0)`, cp = `PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + #ifdef SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULARINTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; + #endif + #ifdef USE_SPECULARCOLORMAP + specularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEENCOLORMAP + material.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEENROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; + #endif +#endif`, hp = `struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif +}; +vec3 clearcoatSpecular = vec3( 0.0 ); +vec3 sheenSpecular = vec3( 0.0 ); +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + vec3 FssEss = specularColor * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometry.normal; + vec3 viewDir = geometry.viewDir; + vec3 position = geometry.position; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`, up = ` +GeometricContext geometry; +geometry.position = - vViewPosition; +geometry.normal = normal; +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +#ifdef USE_CLEARCOAT + geometry.clearcoatNormal = clearcoatNormal; +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`, dp = `#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; + #ifndef PHYSICALLY_CORRECT_LIGHTS + lightMapIrradiance *= PI; + #endif + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometry.normal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`, fp = `#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); +#endif`, pp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`, mp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`, gp = `#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`, xp = `#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + #else + if ( isPerspectiveMatrix( projectionMatrix ) ) { + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + gl_Position.z *= gl_Position.w; + } + #endif +#endif`, yp = `#ifdef USE_MAP + vec4 texelColor = texture2D( map, vUv ); + texelColor = mapTexelToLinear( texelColor ); + diffuseColor *= texelColor; +#endif`, vp = `#ifdef USE_MAP + uniform sampler2D map; +#endif`, _p = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; +#endif +#ifdef USE_MAP + vec4 mapTexel = texture2D( map, uv ); + diffuseColor *= mapTexelToLinear( mapTexel ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`, Mp = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`, bp = `float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vUv ); + metalnessFactor *= texelMetalness.b; +#endif`, wp = `#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`, Sp = `#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`, Tp = `#ifdef USE_MORPHTARGETS + uniform float morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + uniform sampler2DArray morphTargetsTexture; + uniform vec2 morphTargetsTextureSize; + vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) { + float texelIndex = float( vertexIndex * stride + offset ); + float y = floor( texelIndex / morphTargetsTextureSize.x ); + float x = texelIndex - y * morphTargetsTextureSize.x; + vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex ); + return texture( morphTargetsTexture, morphUV ).xyz; + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`, Ep = `#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #ifndef USE_MORPHNORMALS + if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ]; + #else + if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ]; + #endif + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`, Ap = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); + vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + #ifdef USE_TANGENT + vec3 tangent = normalize( vTangent ); + vec3 bitangent = normalize( vBitangent ); + #ifdef DOUBLE_SIDED + tangent = tangent * faceDirection; + bitangent = bitangent * faceDirection; + #endif + #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) + mat3 vTBN = mat3( tangent, bitangent, normal ); + #endif + #endif +#endif +vec3 geometryNormal = normal;`, Cp = `#ifdef OBJECTSPACE_NORMALMAP + normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( TANGENTSPACE_NORMALMAP ) + vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + #ifdef USE_TANGENT + normal = normalize( vTBN * mapN ); + #else + normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); + #endif +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`, Lp = `#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`, Rp = `#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`, Pp = `#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`, Ip = `#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef OBJECTSPACE_NORMALMAP + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) + vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); + vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); + vec2 st0 = dFdx( vUv.st ); + vec2 st1 = dFdy( vUv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + } +#endif`, Dp = `#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = geometryNormal; +#endif`, Fp = `#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + #ifdef USE_TANGENT + clearcoatNormal = normalize( vTBN * clearcoatMapN ); + #else + clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); + #endif +#endif`, Np = `#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif`, Bp = `#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= transmissionAlpha + 0.1; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, zp = `vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { + return linearClipZ * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * invClipZ - far ); +}`, Up = `#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`, Op = `vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`, kp = `#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`, Gp = `float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vUv ); + roughnessFactor *= texelRoughness.g; +#endif`, Vp = `#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`, Wp = `#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); + bool inFrustum = all( inFrustumVec ); + bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); + bool frustumTest = all( frustumTestVec ); + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + vec3 lightToPosition = shadowCoord.xyz; + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } +#endif`, qp = `#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; + varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`, Xp = `#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; + #endif + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); + vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif`, Jp = `float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`, Yp = `#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`, Zp = `#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + #ifdef BONE_TEXTURE + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + mat4 getBoneMatrix( const in float i ) { + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + y = dy * ( y + 0.5 ); + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + mat4 bone = mat4( v1, v2, v3, v4 ); + return bone; + } + #else + uniform mat4 boneMatrices[ MAX_BONES ]; + mat4 getBoneMatrix( const in float i ) { + mat4 bone = boneMatrices[ int(i) ]; + return bone; + } + #endif +#endif`, $p = `#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`, jp = `#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`, Qp = `float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`, Kp = `#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`, em = `#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`, tm = `#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return toneMappingExposure * color; +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSMISSION + float transmissionAlpha = 1.0; + float transmissionFactor = transmission; + float thicknessFactor = thickness; + #ifdef USE_TRANSMISSIONMAP + transmissionFactor *= texture2D( transmissionMap, vUv ).r; + #endif + #ifdef USE_THICKNESSMAP + thicknessFactor *= texture2D( thicknessMap, vUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmission = getIBLVolumeRefraction( + n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor, + attenuationColor, attenuationDistance ); + totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor ); + transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor ); +#endif`, im = `#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( float roughness, float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) { + float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + #ifdef TEXTURE_LOD_EXT + return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + #else + return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + #endif + } + vec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) { + if ( attenuationDistance == 0.0 ) { + return radiance; + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; + } + } + vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90, + vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, + vec3 attenuationColor, float attenuationDistance ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); + } +#endif`, rm = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif`, sm = `#ifdef USE_UV + #ifdef UVS_VERTEX_ONLY + vec2 vUv; + #else + varying vec2 vUv; + #endif + uniform mat3 uvTransform; +#endif`, om = `#ifdef USE_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; +#endif`, am = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; +#endif`, lm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; +#endif`, cm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; +#endif`, hm = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`, um = `varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`, dm = `uniform sampler2D t2D; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + gl_FragColor = mapTexelToLinear( texColor ); + #include + #include +}`, fm = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`, pm = `#include +uniform float opacity; +varying vec3 vWorldDirection; +#include +void main() { + vec3 vReflect = vWorldDirection; + #include + gl_FragColor = envColor; + gl_FragColor.a *= opacity; + #include + #include +}`, mm = `#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`, gm = `#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + vec4 diffuseColor = vec4( 1.0 ); + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`, xm = `#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`, ym = `#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + #include + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`, vm = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`, _m = `uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + vec4 texColor = texture2D( tEquirect, sampleUV ); + gl_FragColor = mapTexelToLinear( texColor ); + #include + #include +}`, Mm = `uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include +}`, bm = `uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +void main() { + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`, wm = `#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, Sm = `uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel= texture2D( lightMap, vUv2 ); + reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`, Tm = `#define LAMBERT +varying vec3 vLightFront; +varying vec3 vIndirectFront; +#ifdef DOUBLE_SIDED + varying vec3 vLightBack; + varying vec3 vIndirectBack; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, Em = `uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +varying vec3 vLightFront; +varying vec3 vIndirectFront; +#ifdef DOUBLE_SIDED + varying vec3 vLightBack; + varying vec3 vIndirectBack; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #ifdef DOUBLE_SIDED + reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; + #else + reflectedLight.indirectDiffuse += vIndirectFront; + #endif + #include + reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb ); + #ifdef DOUBLE_SIDED + reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; + #else + reflectedLight.directDiffuse = vLightFront; + #endif + reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask(); + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`, Am = `#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`, Cm = `#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + matcapColor = matcapTexelToLinear( matcapColor ); + #else + vec4 matcapColor = vec4( 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`, Lm = `#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + vViewPosition = - mvPosition.xyz; +#endif +}`, Rm = `#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); +}`, Pm = `#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`, Im = `#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`, Dm = `#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`, Fm = `#define STANDARD +#ifdef PHYSICAL + #define IOR + #define SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULARINTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif + #ifdef USE_SPECULARCOLORMAP + uniform sampler2D specularColorMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEENCOLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEENROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`, Nm = `#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`, Bm = `#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`, zm = `uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`, Um = `uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`, Om = `#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`, Hm = `uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`, km = `uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`, Gm = `uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`, Fe = { + alphamap_fragment: xf, + alphamap_pars_fragment: yf, + alphatest_fragment: vf, + alphatest_pars_fragment: _f, + aomap_fragment: Mf, + aomap_pars_fragment: bf, + begin_vertex: wf, + beginnormal_vertex: Sf, + bsdfs: Tf, + bumpmap_pars_fragment: Ef, + clipping_planes_fragment: Af, + clipping_planes_pars_fragment: Cf, + clipping_planes_pars_vertex: Lf, + clipping_planes_vertex: Rf, + color_fragment: Pf, + color_pars_fragment: If, + color_pars_vertex: Df, + color_vertex: Ff, + common: Nf, + cube_uv_reflection_fragment: Bf, + defaultnormal_vertex: zf, + displacementmap_pars_vertex: Uf, + displacementmap_vertex: Of, + emissivemap_fragment: Hf, + emissivemap_pars_fragment: kf, + encodings_fragment: Gf, + encodings_pars_fragment: Vf, + envmap_fragment: Wf, + envmap_common_pars_fragment: qf, + envmap_pars_fragment: Xf, + envmap_pars_vertex: Jf, + envmap_physical_pars_fragment: rp, + envmap_vertex: Yf, + fog_vertex: Zf, + fog_pars_vertex: $f, + fog_fragment: jf, + fog_pars_fragment: Qf, + gradientmap_pars_fragment: Kf, + lightmap_fragment: ep, + lightmap_pars_fragment: tp, + lights_lambert_vertex: np, + lights_pars_begin: ip, + lights_toon_fragment: sp, + lights_toon_pars_fragment: op, + lights_phong_fragment: ap, + lights_phong_pars_fragment: lp, + lights_physical_fragment: cp, + lights_physical_pars_fragment: hp, + lights_fragment_begin: up, + lights_fragment_maps: dp, + lights_fragment_end: fp, + logdepthbuf_fragment: pp, + logdepthbuf_pars_fragment: mp, + logdepthbuf_pars_vertex: gp, + logdepthbuf_vertex: xp, + map_fragment: yp, + map_pars_fragment: vp, + map_particle_fragment: _p, + map_particle_pars_fragment: Mp, + metalnessmap_fragment: bp, + metalnessmap_pars_fragment: wp, + morphnormal_vertex: Sp, + morphtarget_pars_vertex: Tp, + morphtarget_vertex: Ep, + normal_fragment_begin: Ap, + normal_fragment_maps: Cp, + normal_pars_fragment: Lp, + normal_pars_vertex: Rp, + normal_vertex: Pp, + normalmap_pars_fragment: Ip, + clearcoat_normal_fragment_begin: Dp, + clearcoat_normal_fragment_maps: Fp, + clearcoat_pars_fragment: Np, + output_fragment: Bp, + packing: zp, + premultiplied_alpha_fragment: Up, + project_vertex: Op, + dithering_fragment: Hp, + dithering_pars_fragment: kp, + roughnessmap_fragment: Gp, + roughnessmap_pars_fragment: Vp, + shadowmap_pars_fragment: Wp, + shadowmap_pars_vertex: qp, + shadowmap_vertex: Xp, + shadowmask_pars_fragment: Jp, + skinbase_vertex: Yp, + skinning_pars_vertex: Zp, + skinning_vertex: $p, + skinnormal_vertex: jp, + specularmap_fragment: Qp, + specularmap_pars_fragment: Kp, + tonemapping_fragment: em, + tonemapping_pars_fragment: tm, + transmission_fragment: nm, + transmission_pars_fragment: im, + uv_pars_fragment: rm, + uv_pars_vertex: sm, + uv_vertex: om, + uv2_pars_fragment: am, + uv2_pars_vertex: lm, + uv2_vertex: cm, + worldpos_vertex: hm, + background_vert: um, + background_frag: dm, + cube_vert: fm, + cube_frag: pm, + depth_vert: mm, + depth_frag: gm, + distanceRGBA_vert: xm, + distanceRGBA_frag: ym, + equirect_vert: vm, + equirect_frag: _m, + linedashed_vert: Mm, + linedashed_frag: bm, + meshbasic_vert: wm, + meshbasic_frag: Sm, + meshlambert_vert: Tm, + meshlambert_frag: Em, + meshmatcap_vert: Am, + meshmatcap_frag: Cm, + meshnormal_vert: Lm, + meshnormal_frag: Rm, + meshphong_vert: Pm, + meshphong_frag: Im, + meshphysical_vert: Dm, + meshphysical_frag: Fm, + meshtoon_vert: Nm, + meshtoon_frag: Bm, + points_vert: zm, + points_frag: Um, + shadow_vert: Om, + shadow_frag: Hm, + sprite_vert: km, + sprite_frag: Gm +}, ie = { + common: { + diffuse: { + value: new ae(16777215) + }, + opacity: { + value: 1 + }, + map: { + value: null + }, + uvTransform: { + value: new lt + }, + uv2Transform: { + value: new lt + }, + alphaMap: { + value: null + }, + alphaTest: { + value: 0 + } + }, + specularmap: { + specularMap: { + value: null + } + }, + envmap: { + envMap: { + value: null + }, + flipEnvMap: { + value: -1 + }, + reflectivity: { + value: 1 + }, + ior: { + value: 1.5 + }, + refractionRatio: { + value: .98 + } + }, + aomap: { + aoMap: { + value: null + }, + aoMapIntensity: { + value: 1 + } + }, + lightmap: { + lightMap: { + value: null + }, + lightMapIntensity: { + value: 1 + } + }, + emissivemap: { + emissiveMap: { + value: null + } + }, + bumpmap: { + bumpMap: { + value: null + }, + bumpScale: { + value: 1 + } + }, + normalmap: { + normalMap: { + value: null + }, + normalScale: { + value: new X(1, 1) + } + }, + displacementmap: { + displacementMap: { + value: null + }, + displacementScale: { + value: 1 + }, + displacementBias: { + value: 0 + } + }, + roughnessmap: { + roughnessMap: { + value: null + } + }, + metalnessmap: { + metalnessMap: { + value: null + } + }, + gradientmap: { + gradientMap: { + value: null + } + }, + fog: { + fogDensity: { + value: 25e-5 + }, + fogNear: { + value: 1 + }, + fogFar: { + value: 2e3 + }, + fogColor: { + value: new ae(16777215) + } + }, + lights: { + ambientLightColor: { + value: [] + }, + lightProbe: { + value: [] + }, + directionalLights: { + value: [], + properties: { + direction: {}, + color: {} + } + }, + directionalLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } + }, + directionalShadowMap: { + value: [] + }, + directionalShadowMatrix: { + value: [] + }, + spotLights: { + value: [], + properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } + }, + spotLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } + }, + spotShadowMap: { + value: [] + }, + spotShadowMatrix: { + value: [] + }, + pointLights: { + value: [], + properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } + }, + pointLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } + }, + pointShadowMap: { + value: [] + }, + pointShadowMatrix: { + value: [] + }, + hemisphereLights: { + value: [], + properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } + }, + rectAreaLights: { + value: [], + properties: { + color: {}, + position: {}, + width: {}, + height: {} + } + }, + ltc_1: { + value: null + }, + ltc_2: { + value: null + } + }, + points: { + diffuse: { + value: new ae(16777215) + }, + opacity: { + value: 1 + }, + size: { + value: 1 + }, + scale: { + value: 1 + }, + map: { + value: null + }, + alphaMap: { + value: null + }, + alphaTest: { + value: 0 + }, + uvTransform: { + value: new lt + } + }, + sprite: { + diffuse: { + value: new ae(16777215) + }, + opacity: { + value: 1 + }, + center: { + value: new X(.5, .5) + }, + rotation: { + value: 0 + }, + map: { + value: null + }, + alphaMap: { + value: null + }, + alphaTest: { + value: 0 + }, + uvTransform: { + value: new lt + } + } +}, qt = { + basic: { + uniforms: yt([ + ie.common, + ie.specularmap, + ie.envmap, + ie.aomap, + ie.lightmap, + ie.fog + ]), + vertexShader: Fe.meshbasic_vert, + fragmentShader: Fe.meshbasic_frag + }, + lambert: { + uniforms: yt([ + ie.common, + ie.specularmap, + ie.envmap, + ie.aomap, + ie.lightmap, + ie.emissivemap, + ie.fog, + ie.lights, + { + emissive: { + value: new ae(0) + } + } + ]), + vertexShader: Fe.meshlambert_vert, + fragmentShader: Fe.meshlambert_frag + }, + phong: { + uniforms: yt([ + ie.common, + ie.specularmap, + ie.envmap, + ie.aomap, + ie.lightmap, + ie.emissivemap, + ie.bumpmap, + ie.normalmap, + ie.displacementmap, + ie.fog, + ie.lights, + { + emissive: { + value: new ae(0) + }, + specular: { + value: new ae(1118481) + }, + shininess: { + value: 30 + } + } + ]), + vertexShader: Fe.meshphong_vert, + fragmentShader: Fe.meshphong_frag + }, + standard: { + uniforms: yt([ + ie.common, + ie.envmap, + ie.aomap, + ie.lightmap, + ie.emissivemap, + ie.bumpmap, + ie.normalmap, + ie.displacementmap, + ie.roughnessmap, + ie.metalnessmap, + ie.fog, + ie.lights, + { + emissive: { + value: new ae(0) + }, + roughness: { + value: 1 + }, + metalness: { + value: 0 + }, + envMapIntensity: { + value: 1 + } + } + ]), + vertexShader: Fe.meshphysical_vert, + fragmentShader: Fe.meshphysical_frag + }, + toon: { + uniforms: yt([ + ie.common, + ie.aomap, + ie.lightmap, + ie.emissivemap, + ie.bumpmap, + ie.normalmap, + ie.displacementmap, + ie.gradientmap, + ie.fog, + ie.lights, + { + emissive: { + value: new ae(0) + } + } + ]), + vertexShader: Fe.meshtoon_vert, + fragmentShader: Fe.meshtoon_frag + }, + matcap: { + uniforms: yt([ + ie.common, + ie.bumpmap, + ie.normalmap, + ie.displacementmap, + ie.fog, + { + matcap: { + value: null + } + } + ]), + vertexShader: Fe.meshmatcap_vert, + fragmentShader: Fe.meshmatcap_frag + }, + points: { + uniforms: yt([ + ie.points, + ie.fog + ]), + vertexShader: Fe.points_vert, + fragmentShader: Fe.points_frag + }, + dashed: { + uniforms: yt([ + ie.common, + ie.fog, + { + scale: { + value: 1 + }, + dashSize: { + value: 1 + }, + totalSize: { + value: 2 + } + } + ]), + vertexShader: Fe.linedashed_vert, + fragmentShader: Fe.linedashed_frag + }, + depth: { + uniforms: yt([ + ie.common, + ie.displacementmap + ]), + vertexShader: Fe.depth_vert, + fragmentShader: Fe.depth_frag + }, + normal: { + uniforms: yt([ + ie.common, + ie.bumpmap, + ie.normalmap, + ie.displacementmap, + { + opacity: { + value: 1 + } + } + ]), + vertexShader: Fe.meshnormal_vert, + fragmentShader: Fe.meshnormal_frag + }, + sprite: { + uniforms: yt([ + ie.sprite, + ie.fog + ]), + vertexShader: Fe.sprite_vert, + fragmentShader: Fe.sprite_frag + }, + background: { + uniforms: { + uvTransform: { + value: new lt + }, + t2D: { + value: null + } + }, + vertexShader: Fe.background_vert, + fragmentShader: Fe.background_frag + }, + cube: { + uniforms: yt([ + ie.envmap, + { + opacity: { + value: 1 + } + } + ]), + vertexShader: Fe.cube_vert, + fragmentShader: Fe.cube_frag + }, + equirect: { + uniforms: { + tEquirect: { + value: null + } + }, + vertexShader: Fe.equirect_vert, + fragmentShader: Fe.equirect_frag + }, + distanceRGBA: { + uniforms: yt([ + ie.common, + ie.displacementmap, + { + referencePosition: { + value: new M + }, + nearDistance: { + value: 1 + }, + farDistance: { + value: 1e3 + } + } + ]), + vertexShader: Fe.distanceRGBA_vert, + fragmentShader: Fe.distanceRGBA_frag + }, + shadow: { + uniforms: yt([ + ie.lights, + ie.fog, + { + color: { + value: new ae(0) + }, + opacity: { + value: 1 + } + } + ]), + vertexShader: Fe.shadow_vert, + fragmentShader: Fe.shadow_frag + } +}; +qt.physical = { + uniforms: yt([ + qt.standard.uniforms, + { + clearcoat: { + value: 0 + }, + clearcoatMap: { + value: null + }, + clearcoatRoughness: { + value: 0 + }, + clearcoatRoughnessMap: { + value: null + }, + clearcoatNormalScale: { + value: new X(1, 1) + }, + clearcoatNormalMap: { + value: null + }, + sheen: { + value: 0 + }, + sheenColor: { + value: new ae(0) + }, + sheenColorMap: { + value: null + }, + sheenRoughness: { + value: 0 + }, + sheenRoughnessMap: { + value: null + }, + transmission: { + value: 0 + }, + transmissionMap: { + value: null + }, + transmissionSamplerSize: { + value: new X + }, + transmissionSamplerMap: { + value: null + }, + thickness: { + value: 0 + }, + thicknessMap: { + value: null + }, + attenuationDistance: { + value: 0 + }, + attenuationColor: { + value: new ae(0) + }, + specularIntensity: { + value: 0 + }, + specularIntensityMap: { + value: null + }, + specularColor: { + value: new ae(1, 1, 1) + }, + specularColorMap: { + value: null + } + } + ]), + vertexShader: Fe.meshphysical_vert, + fragmentShader: Fe.meshphysical_frag +}; +function Vm(s, e, t, n, i) { + let r = new ae(0), o = 0, a, l, c = null, h = 0, u = null; + function d(m, x) { + let v = !1, g = x.isScene === !0 ? x.background : null; + g && g.isTexture && (g = e.get(g)); + let p = s.xr, _ = p.getSession && p.getSession(); + _ && _.environmentBlendMode === "additive" && (g = null), g === null ? f(r, o) : g && g.isColor && (f(g, 1), v = !0), (s.autoClear || v) && s.clear(s.autoClearColor, s.autoClearDepth, s.autoClearStencil), g && (g.isCubeTexture || g.mapping === Pr) ? (l === void 0 && (l = new st(new wn(1, 1, 1), new sn({ + name: "BackgroundCubeMaterial", + uniforms: Ri(qt.cube.uniforms), + vertexShader: qt.cube.vertexShader, + fragmentShader: qt.cube.fragmentShader, + side: it, + depthTest: !1, + depthWrite: !1, + fog: !1 + })), l.geometry.deleteAttribute("normal"), l.geometry.deleteAttribute("uv"), l.onBeforeRender = function(y, b, A) { + this.matrixWorld.copyPosition(A.matrixWorld); + }, Object.defineProperty(l.material, "envMap", { + get: function() { + return this.uniforms.envMap.value; + } + }), n.update(l)), l.material.uniforms.envMap.value = g, l.material.uniforms.flipEnvMap.value = g.isCubeTexture && g.isRenderTargetTexture === !1 ? -1 : 1, (c !== g || h !== g.version || u !== s.toneMapping) && (l.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(l, l.geometry, l.material, 0, 0, null)) : g && g.isTexture && (a === void 0 && (a = new st(new Pi(2, 2), new sn({ + name: "BackgroundMaterial", + uniforms: Ri(qt.background.uniforms), + vertexShader: qt.background.vertexShader, + fragmentShader: qt.background.fragmentShader, + side: Ai, + depthTest: !1, + depthWrite: !1, + fog: !1 + })), a.geometry.deleteAttribute("normal"), Object.defineProperty(a.material, "map", { + get: function() { + return this.uniforms.t2D.value; + } + }), n.update(a)), a.material.uniforms.t2D.value = g, g.matrixAutoUpdate === !0 && g.updateMatrix(), a.material.uniforms.uvTransform.value.copy(g.matrix), (c !== g || h !== g.version || u !== s.toneMapping) && (a.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(a, a.geometry, a.material, 0, 0, null)); + } + function f(m, x) { + t.buffers.color.setClear(m.r, m.g, m.b, x, i); + } + return { + getClearColor: function() { + return r; + }, + setClearColor: function(m, x = 1) { + r.set(m), o = x, f(r, o); + }, + getClearAlpha: function() { + return o; + }, + setClearAlpha: function(m) { + o = m, f(r, o); + }, + render: d + }; +} +function Wm(s, e, t, n) { + let i = s.getParameter(34921), r = n.isWebGL2 ? null : e.get("OES_vertex_array_object"), o = n.isWebGL2 || r !== null, a = {}, l = x(null), c = l; + function h(E, D, U, F, O) { + let ne = !1; + if (o) { + let ce = m(F, U, D); + c !== ce && (c = ce, d(c.object)), ne = v(F, O), ne && g(F, O); + } else { + let ce = D.wireframe === !0; + (c.geometry !== F.id || c.program !== U.id || c.wireframe !== ce) && (c.geometry = F.id, c.program = U.id, c.wireframe = ce, ne = !0); + } + E.isInstancedMesh === !0 && (ne = !0), O !== null && t.update(O, 34963), ne && (L(E, D, U, F), O !== null && s.bindBuffer(34963, t.get(O).buffer)); + } + function u() { + return n.isWebGL2 ? s.createVertexArray() : r.createVertexArrayOES(); + } + function d(E) { + return n.isWebGL2 ? s.bindVertexArray(E) : r.bindVertexArrayOES(E); + } + function f(E) { + return n.isWebGL2 ? s.deleteVertexArray(E) : r.deleteVertexArrayOES(E); + } + function m(E, D, U) { + let F = U.wireframe === !0, O = a[E.id]; + O === void 0 && (O = {}, a[E.id] = O); + let ne = O[D.id]; + ne === void 0 && (ne = {}, O[D.id] = ne); + let ce = ne[F]; + return ce === void 0 && (ce = x(u()), ne[F] = ce), ce; + } + function x(E) { + let D = [], U = [], F = []; + for(let O = 0; O < i; O++)D[O] = 0, U[O] = 0, F[O] = 0; + return { + geometry: null, + program: null, + wireframe: !1, + newAttributes: D, + enabledAttributes: U, + attributeDivisors: F, + object: E, + attributes: {}, + index: null + }; + } + function v(E, D) { + let U = c.attributes, F = E.attributes, O = 0; + for(let ne in F){ + let ce = U[ne], V = F[ne]; + if (ce === void 0 || ce.attribute !== V || ce.data !== V.data) return !0; + O++; + } + return c.attributesNum !== O || c.index !== D; + } + function g(E, D) { + let U = {}, F = E.attributes, O = 0; + for(let ne in F){ + let ce = F[ne], V = {}; + V.attribute = ce, ce.data && (V.data = ce.data), U[ne] = V, O++; + } + c.attributes = U, c.attributesNum = O, c.index = D; + } + function p() { + let E = c.newAttributes; + for(let D = 0, U = E.length; D < U; D++)E[D] = 0; + } + function _(E) { + y(E, 0); + } + function y(E, D) { + let U = c.newAttributes, F = c.enabledAttributes, O = c.attributeDivisors; + U[E] = 1, F[E] === 0 && (s.enableVertexAttribArray(E), F[E] = 1), O[E] !== D && ((n.isWebGL2 ? s : e.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](E, D), O[E] = D); + } + function b() { + let E = c.newAttributes, D = c.enabledAttributes; + for(let U = 0, F = D.length; U < F; U++)D[U] !== E[U] && (s.disableVertexAttribArray(U), D[U] = 0); + } + function A(E, D, U, F, O, ne) { + n.isWebGL2 === !0 && (U === 5124 || U === 5125) ? s.vertexAttribIPointer(E, D, U, O, ne) : s.vertexAttribPointer(E, D, U, F, O, ne); + } + function L(E, D, U, F) { + if (n.isWebGL2 === !1 && (E.isInstancedMesh || F.isInstancedBufferGeometry) && e.get("ANGLE_instanced_arrays") === null) return; + p(); + let O = F.attributes, ne = U.getAttributes(), ce = D.defaultAttributeValues; + for(let V in ne){ + let W = ne[V]; + if (W.location >= 0) { + let he = O[V]; + if (he === void 0 && (V === "instanceMatrix" && E.instanceMatrix && (he = E.instanceMatrix), V === "instanceColor" && E.instanceColor && (he = E.instanceColor)), he !== void 0) { + let le = he.normalized, fe = he.itemSize, Be = t.get(he); + if (Be === void 0) continue; + let Y = Be.buffer, Ce = Be.type, ye = Be.bytesPerElement; + if (he.isInterleavedBufferAttribute) { + let ge = he.data, xe = ge.stride, Oe = he.offset; + if (ge && ge.isInstancedInterleavedBuffer) { + for(let G = 0; G < W.locationSize; G++)y(W.location + G, ge.meshPerAttribute); + E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = ge.meshPerAttribute * ge.count); + } else for(let G = 0; G < W.locationSize; G++)_(W.location + G); + s.bindBuffer(34962, Y); + for(let G = 0; G < W.locationSize; G++)A(W.location + G, fe / W.locationSize, Ce, le, xe * ye, (Oe + fe / W.locationSize * G) * ye); + } else { + if (he.isInstancedBufferAttribute) { + for(let ge = 0; ge < W.locationSize; ge++)y(W.location + ge, he.meshPerAttribute); + E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = he.meshPerAttribute * he.count); + } else for(let ge = 0; ge < W.locationSize; ge++)_(W.location + ge); + s.bindBuffer(34962, Y); + for(let ge = 0; ge < W.locationSize; ge++)A(W.location + ge, fe / W.locationSize, Ce, le, fe * ye, fe / W.locationSize * ge * ye); + } + } else if (ce !== void 0) { + let le = ce[V]; + if (le !== void 0) switch(le.length){ + case 2: + s.vertexAttrib2fv(W.location, le); + break; + case 3: + s.vertexAttrib3fv(W.location, le); + break; + case 4: + s.vertexAttrib4fv(W.location, le); + break; + default: + s.vertexAttrib1fv(W.location, le); + } + } + } + } + b(); + } + function I() { + P(); + for(let E in a){ + let D = a[E]; + for(let U in D){ + let F = D[U]; + for(let O in F)f(F[O].object), delete F[O]; + delete D[U]; + } + delete a[E]; + } + } + function k(E) { + if (a[E.id] === void 0) return; + let D = a[E.id]; + for(let U in D){ + let F = D[U]; + for(let O in F)f(F[O].object), delete F[O]; + delete D[U]; + } + delete a[E.id]; + } + function B(E) { + for(let D in a){ + let U = a[D]; + if (U[E.id] === void 0) continue; + let F = U[E.id]; + for(let O in F)f(F[O].object), delete F[O]; + delete U[E.id]; + } + } + function P() { + w(), c !== l && (c = l, d(c.object)); + } + function w() { + l.geometry = null, l.program = null, l.wireframe = !1; + } + return { + setup: h, + reset: P, + resetDefaultState: w, + dispose: I, + releaseStatesOfGeometry: k, + releaseStatesOfProgram: B, + initAttributes: p, + enableAttribute: _, + disableUnusedAttributes: b + }; +} +function qm(s, e, t, n) { + let i = n.isWebGL2, r; + function o(c) { + r = c; + } + function a(c, h) { + s.drawArrays(r, c, h), t.update(h, r, 1); + } + function l(c, h, u) { + if (u === 0) return; + let d, f; + if (i) d = s, f = "drawArraysInstanced"; + else if (d = e.get("ANGLE_instanced_arrays"), f = "drawArraysInstancedANGLE", d === null) { + console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); + return; + } + d[f](r, c, h, u), t.update(h, r, u); + } + this.setMode = o, this.render = a, this.renderInstances = l; +} +function Xm(s, e, t) { + let n; + function i() { + if (n !== void 0) return n; + if (e.has("EXT_texture_filter_anisotropic") === !0) { + let L = e.get("EXT_texture_filter_anisotropic"); + n = s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + } else n = 0; + return n; + } + function r(L) { + if (L === "highp") { + if (s.getShaderPrecisionFormat(35633, 36338).precision > 0 && s.getShaderPrecisionFormat(35632, 36338).precision > 0) return "highp"; + L = "mediump"; + } + return L === "mediump" && s.getShaderPrecisionFormat(35633, 36337).precision > 0 && s.getShaderPrecisionFormat(35632, 36337).precision > 0 ? "mediump" : "lowp"; + } + let o = typeof WebGL2RenderingContext < "u" && s instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext < "u" && s instanceof WebGL2ComputeRenderingContext, a = t.precision !== void 0 ? t.precision : "highp", l = r(a); + l !== a && (console.warn("THREE.WebGLRenderer:", a, "not supported, using", l, "instead."), a = l); + let c = o || e.has("WEBGL_draw_buffers"), h = t.logarithmicDepthBuffer === !0, u = s.getParameter(34930), d = s.getParameter(35660), f = s.getParameter(3379), m = s.getParameter(34076), x = s.getParameter(34921), v = s.getParameter(36347), g = s.getParameter(36348), p = s.getParameter(36349), _ = d > 0, y = o || e.has("OES_texture_float"), b = _ && y, A = o ? s.getParameter(36183) : 0; + return { + isWebGL2: o, + drawBuffers: c, + getMaxAnisotropy: i, + getMaxPrecision: r, + precision: a, + logarithmicDepthBuffer: h, + maxTextures: u, + maxVertexTextures: d, + maxTextureSize: f, + maxCubemapSize: m, + maxAttributes: x, + maxVertexUniforms: v, + maxVaryings: g, + maxFragmentUniforms: p, + vertexTextures: _, + floatFragmentTextures: y, + floatVertexTextures: b, + maxSamples: A + }; +} +function Jm(s) { + let e = this, t = null, n = 0, i = !1, r = !1, o = new Wt, a = new lt, l = { + value: null, + needsUpdate: !1 + }; + this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, d, f) { + let m = u.length !== 0 || d || n !== 0 || i; + return i = d, t = h(u, f, 0), n = u.length, m; + }, this.beginShadows = function() { + r = !0, h(null); + }, this.endShadows = function() { + r = !1, c(); + }, this.setState = function(u, d, f) { + let m = u.clippingPlanes, x = u.clipIntersection, v = u.clipShadows, g = s.get(u); + if (!i || m === null || m.length === 0 || r && !v) r ? h(null) : c(); + else { + let p = r ? 0 : n, _ = p * 4, y = g.clippingState || null; + l.value = y, y = h(m, d, _, f); + for(let b = 0; b !== _; ++b)y[b] = t[b]; + g.clippingState = y, this.numIntersection = x ? this.numPlanes : 0, this.numPlanes += p; + } + }; + function c() { + l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0; + } + function h(u, d, f, m) { + let x = u !== null ? u.length : 0, v = null; + if (x !== 0) { + if (v = l.value, m !== !0 || v === null) { + let g = f + x * 4, p = d.matrixWorldInverse; + a.getNormalMatrix(p), (v === null || v.length < g) && (v = new Float32Array(g)); + for(let _ = 0, y = f; _ !== x; ++_, y += 4)o.copy(u[_]).applyMatrix4(p, a), o.normal.toArray(v, y), v[y + 3] = o.constant; + } + l.value = v, l.needsUpdate = !0; + } + return e.numPlanes = x, e.numIntersection = 0, v; + } +} +function Ym(s) { + let e = new WeakMap; + function t(o, a) { + return a === Ds ? o.mapping = Bi : a === Fs && (o.mapping = zi), o; + } + function n(o) { + if (o && o.isTexture && o.isRenderTargetTexture === !1) { + let a = o.mapping; + if (a === Ds || a === Fs) if (e.has(o)) { + let l = e.get(o).texture; + return t(l, o.mapping); + } else { + let l = o.image; + if (l && l.height > 0) { + let c = s.getRenderTarget(), h = new js(l.height / 2); + return h.fromEquirectangularTexture(s, o), e.set(o, h), s.setRenderTarget(c), o.addEventListener("dispose", i), t(h.texture, o.mapping); + } else return null; + } + } + return o; + } + function i(o) { + let a = o.target; + a.removeEventListener("dispose", i); + let l = e.get(a); + l !== void 0 && (e.delete(a), l.dispose()); + } + function r() { + e = new WeakMap; + } + return { + get: n, + dispose: r + }; +} +var Fr = class extends Ir { + constructor(e = -1, t = 1, n = 1, i = -1, r = .1, o = 2e3){ + super(); + this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = i, this.near = r, this.far = o, this.updateProjectionMatrix(); + } + copy(e, t) { + return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; + } + setViewOffset(e, t, n, i, r, o) { + this.view === null && (this.view = { + enabled: !0, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1 + }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); + } + clearViewOffset() { + this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); + } + updateProjectionMatrix() { + let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2, r = n - e, o = n + e, a = i + t, l = i - t; + if (this.view !== null && this.view.enabled) { + let c = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; + r += c * this.view.offsetX, o = r + c * this.view.width, a -= h * this.view.offsetY, l = a - h * this.view.height; + } + this.projectionMatrix.makeOrthographic(r, o, a, l, this.near, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + toJSON(e) { + let t = super.toJSON(e); + return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; + } +}; +Fr.prototype.isOrthographicCamera = !0; +var Gi = class extends sn { + constructor(e){ + super(e); + this.type = "RawShaderMaterial"; + } +}; +Gi.prototype.isRawShaderMaterial = !0; +var Ei = 4, Mn = 8, Vt = Math.pow(2, Mn), sh = [ + .125, + .215, + .35, + .446, + .526, + .582 +], oh = Mn - Ei + 1 + sh.length, pi = 20, Hs = { + [Nt]: 0, + [Oi]: 1 +}, Go = new Fr, { _lodPlanes: ji , _sizeLods: Ll , _sigmas: ls } = Zm(), Rl = new ae, Vo = null, On = (1 + Math.sqrt(5)) / 2, mi = 1 / On, Pl = [ + new M(1, 1, 1), + new M(-1, 1, 1), + new M(1, 1, -1), + new M(-1, 1, -1), + new M(0, On, mi), + new M(0, On, -mi), + new M(mi, 0, On), + new M(-mi, 0, On), + new M(On, mi, 0), + new M(-On, mi, 0) +], ah = class { + constructor(e){ + this._renderer = e, this._pingPongRenderTarget = null, this._blurMaterial = $m(pi), this._equirectShader = null, this._cubemapShader = null, this._compileMaterial(this._blurMaterial); + } + fromScene(e, t = 0, n = .1, i = 100) { + Vo = this._renderer.getRenderTarget(); + let r = this._allocateTargets(); + return this._sceneToCubeUV(e, n, i, r), t > 0 && this._blur(r, 0, 0, t), this._applyPMREM(r), this._cleanup(r), r; + } + fromEquirectangular(e) { + return this._fromTexture(e); + } + fromCubemap(e) { + return this._fromTexture(e); + } + compileCubemapShader() { + this._cubemapShader === null && (this._cubemapShader = Fl(), this._compileMaterial(this._cubemapShader)); + } + compileEquirectangularShader() { + this._equirectShader === null && (this._equirectShader = Dl(), this._compileMaterial(this._equirectShader)); + } + dispose() { + this._blurMaterial.dispose(), this._cubemapShader !== null && this._cubemapShader.dispose(), this._equirectShader !== null && this._equirectShader.dispose(); + for(let e = 0; e < ji.length; e++)ji[e].dispose(); + } + _cleanup(e) { + this._pingPongRenderTarget.dispose(), this._renderer.setRenderTarget(Vo), e.scissorTest = !1, cs(e, 0, 0, e.width, e.height); + } + _fromTexture(e) { + Vo = this._renderer.getRenderTarget(); + let t = this._allocateTargets(e); + return this._textureToCubeUV(e, t), this._applyPMREM(t), this._cleanup(t), t; + } + _allocateTargets(e) { + let t = { + magFilter: tt, + minFilter: tt, + generateMipmaps: !1, + type: kn, + format: ct, + encoding: Nt, + depthBuffer: !1 + }, n = Il(t); + return n.depthBuffer = !e, this._pingPongRenderTarget = Il(t), n; + } + _compileMaterial(e) { + let t = new st(ji[0], e); + this._renderer.compile(t, Go); + } + _sceneToCubeUV(e, t, n, i) { + let a = new ut(90, 1, t, n), l = [ + 1, + -1, + 1, + 1, + 1, + 1 + ], c = [ + 1, + 1, + 1, + -1, + -1, + -1 + ], h = this._renderer, u = h.autoClear, d = h.toneMapping; + h.getClearColor(Rl), h.toneMapping = _n, h.autoClear = !1; + let f = new hn({ + name: "PMREM.Background", + side: it, + depthWrite: !1, + depthTest: !1 + }), m = new st(new wn, f), x = !1, v = e.background; + v ? v.isColor && (f.color.copy(v), e.background = null, x = !0) : (f.color.copy(Rl), x = !0); + for(let g = 0; g < 6; g++){ + let p = g % 3; + p == 0 ? (a.up.set(0, l[g], 0), a.lookAt(c[g], 0, 0)) : p == 1 ? (a.up.set(0, 0, l[g]), a.lookAt(0, c[g], 0)) : (a.up.set(0, l[g], 0), a.lookAt(0, 0, c[g])), cs(i, p * Vt, g > 2 ? Vt : 0, Vt, Vt), h.setRenderTarget(i), x && h.render(m, a), h.render(e, a); + } + m.geometry.dispose(), m.material.dispose(), h.toneMapping = d, h.autoClear = u, e.background = v; + } + _setEncoding(e, t) { + this._renderer.capabilities.isWebGL2 === !0 && t.format === ct && t.type === rn && t.encoding === Oi ? e.value = Hs[Nt] : e.value = Hs[t.encoding]; + } + _textureToCubeUV(e, t) { + let n = this._renderer, i = e.mapping === Bi || e.mapping === zi; + i ? this._cubemapShader == null && (this._cubemapShader = Fl()) : this._equirectShader == null && (this._equirectShader = Dl()); + let r = i ? this._cubemapShader : this._equirectShader, o = new st(ji[0], r), a = r.uniforms; + a.envMap.value = e, i || a.texelSize.value.set(1 / e.image.width, 1 / e.image.height), this._setEncoding(a.inputEncoding, e), cs(t, 0, 0, 3 * Vt, 2 * Vt), n.setRenderTarget(t), n.render(o, Go); + } + _applyPMREM(e) { + let t = this._renderer, n = t.autoClear; + t.autoClear = !1; + for(let i = 1; i < oh; i++){ + let r = Math.sqrt(ls[i] * ls[i] - ls[i - 1] * ls[i - 1]), o = Pl[(i - 1) % Pl.length]; + this._blur(e, i - 1, i, r, o); + } + t.autoClear = n; + } + _blur(e, t, n, i, r) { + let o = this._pingPongRenderTarget; + this._halfBlur(e, o, t, n, i, "latitudinal", r), this._halfBlur(o, e, n, n, i, "longitudinal", r); + } + _halfBlur(e, t, n, i, r, o, a) { + let l = this._renderer, c = this._blurMaterial; + o !== "latitudinal" && o !== "longitudinal" && console.error("blur direction must be either latitudinal or longitudinal!"); + let h = 3, u = new st(ji[i], c), d = c.uniforms, f = Ll[n] - 1, m = isFinite(r) ? Math.PI / (2 * f) : 2 * Math.PI / (2 * pi - 1), x = r / m, v = isFinite(r) ? 1 + Math.floor(h * x) : pi; + v > pi && console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${pi}`); + let g = [], p = 0; + for(let A = 0; A < pi; ++A){ + let L = A / x, I = Math.exp(-L * L / 2); + g.push(I), A == 0 ? p += I : A < v && (p += 2 * I); + } + for(let A = 0; A < g.length; A++)g[A] = g[A] / p; + d.envMap.value = e.texture, d.samples.value = v, d.weights.value = g, d.latitudinal.value = o === "latitudinal", a && (d.poleAxis.value = a), d.dTheta.value = m, d.mipInt.value = Mn - n; + let _ = Ll[i], y = 3 * Math.max(0, Vt - 2 * _), b = (i === 0 ? 0 : 2 * Vt) + 2 * _ * (i > Mn - Ei ? i - Mn + Ei : 0); + cs(t, y, b, 3 * _, 2 * _), l.setRenderTarget(t), l.render(u, Go); + } +}; +function Zm() { + let s = [], e = [], t = [], n = Mn; + for(let i = 0; i < oh; i++){ + let r = Math.pow(2, n); + e.push(r); + let o = 1 / r; + i > Mn - Ei ? o = sh[i - Mn + Ei - 1] : i == 0 && (o = 0), t.push(o); + let a = 1 / (r - 1), l = -a / 2, c = 1 + a / 2, h = [ + l, + l, + c, + l, + c, + c, + l, + l, + c, + c, + l, + c + ], u = 6, d = 6, f = 3, m = 2, x = 1, v = new Float32Array(f * d * u), g = new Float32Array(m * d * u), p = new Float32Array(x * d * u); + for(let y = 0; y < u; y++){ + let b = y % 3 * 2 / 3 - 1, A = y > 2 ? 0 : -1, L = [ + b, + A, + 0, + b + 2 / 3, + A, + 0, + b + 2 / 3, + A + 1, + 0, + b, + A, + 0, + b + 2 / 3, + A + 1, + 0, + b, + A + 1, + 0 + ]; + v.set(L, f * d * y), g.set(h, m * d * y); + let I = [ + y, + y, + y, + y, + y, + y + ]; + p.set(I, x * d * y); + } + let _ = new _e; + _.setAttribute("position", new Ue(v, f)), _.setAttribute("uv", new Ue(g, m)), _.setAttribute("faceIndex", new Ue(p, x)), s.push(_), n > Ei && n--; + } + return { + _lodPlanes: s, + _sizeLods: e, + _sigmas: t + }; +} +function Il(s) { + let e = new At(3 * Vt, 3 * Vt, s); + return e.texture.mapping = Pr, e.texture.name = "PMREM.cubeUv", e.scissorTest = !0, e; +} +function cs(s, e, t, n, i) { + s.viewport.set(e, t, n, i), s.scissor.set(e, t, n, i); +} +function $m(s) { + let e = new Float32Array(s), t = new M(0, 1, 0); + return new Gi({ + name: "SphericalGaussianBlur", + defines: { + n: s + }, + uniforms: { + envMap: { + value: null + }, + samples: { + value: 1 + }, + weights: { + value: e + }, + latitudinal: { + value: !1 + }, + dTheta: { + value: 0 + }, + mipInt: { + value: 0 + }, + poleAxis: { + value: t + } + }, + vertexShader: fa(), + fragmentShader: ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + ${pa()} + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `, + blending: vn, + depthTest: !1, + depthWrite: !1 + }); +} +function Dl() { + let s = new X(1, 1); + return new Gi({ + name: "EquirectangularToCubeUV", + uniforms: { + envMap: { + value: null + }, + texelSize: { + value: s + }, + inputEncoding: { + value: Hs[Nt] + } + }, + vertexShader: fa(), + fragmentShader: ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform vec2 texelSize; + + ${pa()} + + #include + + void main() { + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + vec2 f = fract( uv / texelSize - 0.5 ); + uv -= f * texelSize; + vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; + uv.x += texelSize.x; + vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; + uv.y += texelSize.y; + vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; + uv.x -= texelSize.x; + vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; + + vec3 tm = mix( tl, tr, f.x ); + vec3 bm = mix( bl, br, f.x ); + gl_FragColor.rgb = mix( tm, bm, f.y ); + + } + `, + blending: vn, + depthTest: !1, + depthWrite: !1 + }); +} +function Fl() { + return new Gi({ + name: "CubemapToCubeUV", + uniforms: { + envMap: { + value: null + }, + inputEncoding: { + value: Hs[Nt] + } + }, + vertexShader: fa(), + fragmentShader: ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + ${pa()} + + void main() { + + gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ); + + } + `, + blending: vn, + depthTest: !1, + depthWrite: !1 + }); +} +function fa() { + return ` + + precision mediump float; + precision mediump int; + + attribute vec3 position; + attribute vec2 uv; + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `; +} +function pa() { + return ` + + uniform int inputEncoding; + + #include + + vec4 inputTexelToLinear( vec4 value ) { + + if ( inputEncoding == 0 ) { + + return value; + + } else { + + return sRGBToLinear( value ); + + } + + } + + vec4 envMapTexelToLinear( vec4 color ) { + + return inputTexelToLinear( color ); + + } + `; +} +function jm(s) { + let e = new WeakMap, t = null; + function n(a) { + if (a && a.isTexture && a.isRenderTargetTexture === !1) { + let l = a.mapping, c = l === Ds || l === Fs, h = l === Bi || l === zi; + if (c || h) { + if (e.has(a)) return e.get(a).texture; + { + let u = a.image; + if (c && u && u.height > 0 || h && u && i(u)) { + let d = s.getRenderTarget(); + t === null && (t = new ah(s)); + let f = c ? t.fromEquirectangular(a) : t.fromCubemap(a); + return e.set(a, f), s.setRenderTarget(d), a.addEventListener("dispose", r), f.texture; + } else return null; + } + } + } + return a; + } + function i(a) { + let l = 0, c = 6; + for(let h = 0; h < c; h++)a[h] !== void 0 && l++; + return l === c; + } + function r(a) { + let l = a.target; + l.removeEventListener("dispose", r); + let c = e.get(l); + c !== void 0 && (e.delete(l), c.dispose()); + } + function o() { + e = new WeakMap, t !== null && (t.dispose(), t = null); + } + return { + get: n, + dispose: o + }; +} +function Qm(s) { + let e = {}; + function t(n) { + if (e[n] !== void 0) return e[n]; + let i; + switch(n){ + case "WEBGL_depth_texture": + i = s.getExtension("WEBGL_depth_texture") || s.getExtension("MOZ_WEBGL_depth_texture") || s.getExtension("WEBKIT_WEBGL_depth_texture"); + break; + case "EXT_texture_filter_anisotropic": + i = s.getExtension("EXT_texture_filter_anisotropic") || s.getExtension("MOZ_EXT_texture_filter_anisotropic") || s.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); + break; + case "WEBGL_compressed_texture_s3tc": + i = s.getExtension("WEBGL_compressed_texture_s3tc") || s.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); + break; + case "WEBGL_compressed_texture_pvrtc": + i = s.getExtension("WEBGL_compressed_texture_pvrtc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); + break; + default: + i = s.getExtension(n); + } + return e[n] = i, i; + } + return { + has: function(n) { + return t(n) !== null; + }, + init: function(n) { + n.isWebGL2 ? t("EXT_color_buffer_float") : (t("WEBGL_depth_texture"), t("OES_texture_float"), t("OES_texture_half_float"), t("OES_texture_half_float_linear"), t("OES_standard_derivatives"), t("OES_element_index_uint"), t("OES_vertex_array_object"), t("ANGLE_instanced_arrays")), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"); + }, + get: function(n) { + let i = t(n); + return i === null && console.warn("THREE.WebGLRenderer: " + n + " extension not supported."), i; + } + }; +} +function Km(s, e, t, n) { + let i = {}, r = new WeakMap; + function o(u) { + let d = u.target; + d.index !== null && e.remove(d.index); + for(let m in d.attributes)e.remove(d.attributes[m]); + d.removeEventListener("dispose", o), delete i[d.id]; + let f = r.get(d); + f && (e.remove(f), r.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--; + } + function a(u, d) { + return i[d.id] === !0 || (d.addEventListener("dispose", o), i[d.id] = !0, t.memory.geometries++), d; + } + function l(u) { + let d = u.attributes; + for(let m in d)e.update(d[m], 34962); + let f = u.morphAttributes; + for(let m in f){ + let x = f[m]; + for(let v = 0, g = x.length; v < g; v++)e.update(x[v], 34962); + } + } + function c(u) { + let d = [], f = u.index, m = u.attributes.position, x = 0; + if (f !== null) { + let p = f.array; + x = f.version; + for(let _ = 0, y = p.length; _ < y; _ += 3){ + let b = p[_ + 0], A = p[_ + 1], L = p[_ + 2]; + d.push(b, A, A, L, L, b); + } + } else { + let p = m.array; + x = m.version; + for(let _ = 0, y = p.length / 3 - 1; _ < y; _ += 3){ + let b = _ + 0, A = _ + 1, L = _ + 2; + d.push(b, A, A, L, L, b); + } + } + let v = new (Yc(d) > 65535 ? Zs : Ys)(d, 1); + v.version = x; + let g = r.get(u); + g && e.remove(g), r.set(u, v); + } + function h(u) { + let d = r.get(u); + if (d) { + let f = u.index; + f !== null && d.version < f.version && c(u); + } else c(u); + return r.get(u); + } + return { + get: a, + update: l, + getWireframeAttribute: h + }; +} +function eg(s, e, t, n) { + let i = n.isWebGL2, r; + function o(d) { + r = d; + } + let a, l; + function c(d) { + a = d.type, l = d.bytesPerElement; + } + function h(d, f) { + s.drawElements(r, f, a, d * l), t.update(f, r, 1); + } + function u(d, f, m) { + if (m === 0) return; + let x, v; + if (i) x = s, v = "drawElementsInstanced"; + else if (x = e.get("ANGLE_instanced_arrays"), v = "drawElementsInstancedANGLE", x === null) { + console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); + return; + } + x[v](r, f, a, d * l, m), t.update(f, r, m); + } + this.setMode = o, this.setIndex = c, this.render = h, this.renderInstances = u; +} +function tg(s) { + let e = { + geometries: 0, + textures: 0 + }, t = { + frame: 0, + calls: 0, + triangles: 0, + points: 0, + lines: 0 + }; + function n(r, o, a) { + switch(t.calls++, o){ + case 4: + t.triangles += a * (r / 3); + break; + case 1: + t.lines += a * (r / 2); + break; + case 3: + t.lines += a * (r - 1); + break; + case 2: + t.lines += a * r; + break; + case 0: + t.points += a * r; + break; + default: + console.error("THREE.WebGLInfo: Unknown draw mode:", o); + break; + } + } + function i() { + t.frame++, t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0; + } + return { + memory: e, + render: t, + programs: null, + autoReset: !0, + reset: i, + update: n + }; +} +var Qs = class extends ot { + constructor(e = null, t = 1, n = 1, i = 1){ + super(null); + this.image = { + data: e, + width: t, + height: n, + depth: i + }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +}; +Qs.prototype.isDataTexture2DArray = !0; +function ng(s, e) { + return s[0] - e[0]; +} +function ig(s, e) { + return Math.abs(e[1]) - Math.abs(s[1]); +} +function Nl(s, e) { + let t = 1, n = e.isInterleavedBufferAttribute ? e.data.array : e.array; + n instanceof Int8Array ? t = 127 : n instanceof Int16Array ? t = 32767 : n instanceof Int32Array ? t = 2147483647 : console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ", n), s.divideScalar(t); +} +function rg(s, e, t) { + let n = {}, i = new Float32Array(8), r = new WeakMap, o = new M, a = []; + for(let c = 0; c < 8; c++)a[c] = [ + c, + 0 + ]; + function l(c, h, u, d) { + let f = c.morphTargetInfluences; + if (e.isWebGL2 === !0) { + let m = h.morphAttributes.position.length, x = r.get(h); + if (x === void 0 || x.count !== m) { + x !== void 0 && x.texture.dispose(); + let p = h.morphAttributes.normal !== void 0, _ = h.morphAttributes.position, y = h.morphAttributes.normal || [], b = h.attributes.position.count, A = p === !0 ? 2 : 1, L = b * A, I = 1; + L > e.maxTextureSize && (I = Math.ceil(L / e.maxTextureSize), L = e.maxTextureSize); + let k = new Float32Array(L * I * 4 * m), B = new Qs(k, L, I, m); + B.format = ct, B.type = nn, B.needsUpdate = !0; + let P = A * 4; + for(let w = 0; w < m; w++){ + let E = _[w], D = y[w], U = L * I * 4 * w; + for(let F = 0; F < E.count; F++){ + o.fromBufferAttribute(E, F), E.normalized === !0 && Nl(o, E); + let O = F * P; + k[U + O + 0] = o.x, k[U + O + 1] = o.y, k[U + O + 2] = o.z, k[U + O + 3] = 0, p === !0 && (o.fromBufferAttribute(D, F), D.normalized === !0 && Nl(o, D), k[U + O + 4] = o.x, k[U + O + 5] = o.y, k[U + O + 6] = o.z, k[U + O + 7] = 0); + } + } + x = { + count: m, + texture: B, + size: new X(L, I) + }, r.set(h, x); + } + let v = 0; + for(let p = 0; p < f.length; p++)v += f[p]; + let g = h.morphTargetsRelative ? 1 : 1 - v; + d.getUniforms().setValue(s, "morphTargetBaseInfluence", g), d.getUniforms().setValue(s, "morphTargetInfluences", f), d.getUniforms().setValue(s, "morphTargetsTexture", x.texture, t), d.getUniforms().setValue(s, "morphTargetsTextureSize", x.size); + } else { + let m = f === void 0 ? 0 : f.length, x = n[h.id]; + if (x === void 0 || x.length !== m) { + x = []; + for(let y = 0; y < m; y++)x[y] = [ + y, + 0 + ]; + n[h.id] = x; + } + for(let y = 0; y < m; y++){ + let b = x[y]; + b[0] = y, b[1] = f[y]; + } + x.sort(ig); + for(let y = 0; y < 8; y++)y < m && x[y][1] ? (a[y][0] = x[y][0], a[y][1] = x[y][1]) : (a[y][0] = Number.MAX_SAFE_INTEGER, a[y][1] = 0); + a.sort(ng); + let v = h.morphAttributes.position, g = h.morphAttributes.normal, p = 0; + for(let y = 0; y < 8; y++){ + let b = a[y], A = b[0], L = b[1]; + A !== Number.MAX_SAFE_INTEGER && L ? (v && h.getAttribute("morphTarget" + y) !== v[A] && h.setAttribute("morphTarget" + y, v[A]), g && h.getAttribute("morphNormal" + y) !== g[A] && h.setAttribute("morphNormal" + y, g[A]), i[y] = L, p += L) : (v && h.hasAttribute("morphTarget" + y) === !0 && h.deleteAttribute("morphTarget" + y), g && h.hasAttribute("morphNormal" + y) === !0 && h.deleteAttribute("morphNormal" + y), i[y] = 0); + } + let _ = h.morphTargetsRelative ? 1 : 1 - p; + d.getUniforms().setValue(s, "morphTargetBaseInfluence", _), d.getUniforms().setValue(s, "morphTargetInfluences", i); + } + } + return { + update: l + }; +} +function sg(s, e, t, n) { + let i = new WeakMap; + function r(l) { + let c = n.render.frame, h = l.geometry, u = e.get(l, h); + return i.get(u) !== c && (e.update(u), i.set(u, c)), l.isInstancedMesh && (l.hasEventListener("dispose", a) === !1 && l.addEventListener("dispose", a), t.update(l.instanceMatrix, 34962), l.instanceColor !== null && t.update(l.instanceColor, 34962)), u; + } + function o() { + i = new WeakMap; + } + function a(l) { + let c = l.target; + c.removeEventListener("dispose", a), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor); + } + return { + update: r, + dispose: o + }; +} +var ma = class extends ot { + constructor(e = null, t = 1, n = 1, i = 1){ + super(null); + this.image = { + data: e, + width: t, + height: n, + depth: i + }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +}; +ma.prototype.isDataTexture3D = !0; +var lh = new ot, ch = new Qs, hh = new ma, uh = new ki, Bl = [], zl = [], Ul = new Float32Array(16), Ol = new Float32Array(9), Hl = new Float32Array(4); +function Vi(s, e, t) { + let n = s[0]; + if (n <= 0 || n > 0) return s; + let i = e * t, r = Bl[i]; + if (r === void 0 && (r = new Float32Array(i), Bl[i] = r), e !== 0) { + n.toArray(r, 0); + for(let o = 1, a = 0; o !== e; ++o)a += t, s[o].toArray(r, a); + } + return r; +} +function Mt(s, e) { + if (s.length !== e.length) return !1; + for(let t = 0, n = s.length; t < n; t++)if (s[t] !== e[t]) return !1; + return !0; +} +function _t(s, e) { + for(let t = 0, n = e.length; t < n; t++)s[t] = e[t]; +} +function Ks(s, e) { + let t = zl[e]; + t === void 0 && (t = new Int32Array(e), zl[e] = t); + for(let n = 0; n !== e; ++n)t[n] = s.allocateTextureUnit(); + return t; +} +function og(s, e) { + let t = this.cache; + t[0] !== e && (s.uniform1f(this.addr, e), t[0] = e); +} +function ag(s, e) { + let t = this.cache; + if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y) && (s.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); + else { + if (Mt(t, e)) return; + s.uniform2fv(this.addr, e), _t(t, e); + } +} +function lg(s, e) { + let t = this.cache; + if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (s.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); + else if (e.r !== void 0) (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (s.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b); + else { + if (Mt(t, e)) return; + s.uniform3fv(this.addr, e), _t(t, e); + } +} +function cg(s, e) { + let t = this.cache; + if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (s.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); + else { + if (Mt(t, e)) return; + s.uniform4fv(this.addr, e), _t(t, e); + } +} +function hg(s, e) { + let t = this.cache, n = e.elements; + if (n === void 0) { + if (Mt(t, e)) return; + s.uniformMatrix2fv(this.addr, !1, e), _t(t, e); + } else { + if (Mt(t, n)) return; + Hl.set(n), s.uniformMatrix2fv(this.addr, !1, Hl), _t(t, n); + } +} +function ug(s, e) { + let t = this.cache, n = e.elements; + if (n === void 0) { + if (Mt(t, e)) return; + s.uniformMatrix3fv(this.addr, !1, e), _t(t, e); + } else { + if (Mt(t, n)) return; + Ol.set(n), s.uniformMatrix3fv(this.addr, !1, Ol), _t(t, n); + } +} +function dg(s, e) { + let t = this.cache, n = e.elements; + if (n === void 0) { + if (Mt(t, e)) return; + s.uniformMatrix4fv(this.addr, !1, e), _t(t, e); + } else { + if (Mt(t, n)) return; + Ul.set(n), s.uniformMatrix4fv(this.addr, !1, Ul), _t(t, n); + } +} +function fg(s, e) { + let t = this.cache; + t[0] !== e && (s.uniform1i(this.addr, e), t[0] = e); +} +function pg(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform2iv(this.addr, e), _t(t, e)); +} +function mg(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform3iv(this.addr, e), _t(t, e)); +} +function gg(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform4iv(this.addr, e), _t(t, e)); +} +function xg(s, e) { + let t = this.cache; + t[0] !== e && (s.uniform1ui(this.addr, e), t[0] = e); +} +function yg(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform2uiv(this.addr, e), _t(t, e)); +} +function vg(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform3uiv(this.addr, e), _t(t, e)); +} +function _g(s, e) { + let t = this.cache; + Mt(t, e) || (s.uniform4uiv(this.addr, e), _t(t, e)); +} +function Mg(s, e, t) { + let n = this.cache, i = t.allocateTextureUnit(); + n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTexture2D(e || lh, i); +} +function bg(s, e, t) { + let n = this.cache, i = t.allocateTextureUnit(); + n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture3D(e || hh, i); +} +function wg(s, e, t) { + let n = this.cache, i = t.allocateTextureUnit(); + n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTextureCube(e || uh, i); +} +function Sg(s, e, t) { + let n = this.cache, i = t.allocateTextureUnit(); + n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture2DArray(e || ch, i); +} +function Tg(s) { + switch(s){ + case 5126: + return og; + case 35664: + return ag; + case 35665: + return lg; + case 35666: + return cg; + case 35674: + return hg; + case 35675: + return ug; + case 35676: + return dg; + case 5124: + case 35670: + return fg; + case 35667: + case 35671: + return pg; + case 35668: + case 35672: + return mg; + case 35669: + case 35673: + return gg; + case 5125: + return xg; + case 36294: + return yg; + case 36295: + return vg; + case 36296: + return _g; + case 35678: + case 36198: + case 36298: + case 36306: + case 35682: + return Mg; + case 35679: + case 36299: + case 36307: + return bg; + case 35680: + case 36300: + case 36308: + case 36293: + return wg; + case 36289: + case 36303: + case 36311: + case 36292: + return Sg; + } +} +function Eg(s, e) { + s.uniform1fv(this.addr, e); +} +function Ag(s, e) { + let t = Vi(e, this.size, 2); + s.uniform2fv(this.addr, t); +} +function Cg(s, e) { + let t = Vi(e, this.size, 3); + s.uniform3fv(this.addr, t); +} +function Lg(s, e) { + let t = Vi(e, this.size, 4); + s.uniform4fv(this.addr, t); +} +function Rg(s, e) { + let t = Vi(e, this.size, 4); + s.uniformMatrix2fv(this.addr, !1, t); +} +function Pg(s, e) { + let t = Vi(e, this.size, 9); + s.uniformMatrix3fv(this.addr, !1, t); +} +function Ig(s, e) { + let t = Vi(e, this.size, 16); + s.uniformMatrix4fv(this.addr, !1, t); +} +function Dg(s, e) { + s.uniform1iv(this.addr, e); +} +function Fg(s, e) { + s.uniform2iv(this.addr, e); +} +function Ng(s, e) { + s.uniform3iv(this.addr, e); +} +function Bg(s, e) { + s.uniform4iv(this.addr, e); +} +function zg(s, e) { + s.uniform1uiv(this.addr, e); +} +function Ug(s, e) { + s.uniform2uiv(this.addr, e); +} +function Og(s, e) { + s.uniform3uiv(this.addr, e); +} +function Hg(s, e) { + s.uniform4uiv(this.addr, e); +} +function kg(s, e, t) { + let n = e.length, i = Ks(t, n); + s.uniform1iv(this.addr, i); + for(let r = 0; r !== n; ++r)t.safeSetTexture2D(e[r] || lh, i[r]); +} +function Gg(s, e, t) { + let n = e.length, i = Ks(t, n); + s.uniform1iv(this.addr, i); + for(let r = 0; r !== n; ++r)t.setTexture3D(e[r] || hh, i[r]); +} +function Vg(s, e, t) { + let n = e.length, i = Ks(t, n); + s.uniform1iv(this.addr, i); + for(let r = 0; r !== n; ++r)t.safeSetTextureCube(e[r] || uh, i[r]); +} +function Wg(s, e, t) { + let n = e.length, i = Ks(t, n); + s.uniform1iv(this.addr, i); + for(let r = 0; r !== n; ++r)t.setTexture2DArray(e[r] || ch, i[r]); +} +function qg(s) { + switch(s){ + case 5126: + return Eg; + case 35664: + return Ag; + case 35665: + return Cg; + case 35666: + return Lg; + case 35674: + return Rg; + case 35675: + return Pg; + case 35676: + return Ig; + case 5124: + case 35670: + return Dg; + case 35667: + case 35671: + return Fg; + case 35668: + case 35672: + return Ng; + case 35669: + case 35673: + return Bg; + case 5125: + return zg; + case 36294: + return Ug; + case 36295: + return Og; + case 36296: + return Hg; + case 35678: + case 36198: + case 36298: + case 36306: + case 35682: + return kg; + case 35679: + case 36299: + case 36307: + return Gg; + case 35680: + case 36300: + case 36308: + case 36293: + return Vg; + case 36289: + case 36303: + case 36311: + case 36292: + return Wg; + } +} +function Xg(s, e, t) { + this.id = s, this.addr = t, this.cache = [], this.setValue = Tg(e.type); +} +function dh(s, e, t) { + this.id = s, this.addr = t, this.cache = [], this.size = e.size, this.setValue = qg(e.type); +} +dh.prototype.updateCache = function(s) { + let e = this.cache; + s instanceof Float32Array && e.length !== s.length && (this.cache = new Float32Array(s.length)), _t(e, s); +}; +function fh(s) { + this.id = s, this.seq = [], this.map = {}; +} +fh.prototype.setValue = function(s, e, t) { + let n = this.seq; + for(let i = 0, r = n.length; i !== r; ++i){ + let o = n[i]; + o.setValue(s, e[o.id], t); + } +}; +var Wo = /(\w+)(\])?(\[|\.)?/g; +function kl(s, e) { + s.seq.push(e), s.map[e.id] = e; +} +function Jg(s, e, t) { + let n = s.name, i = n.length; + for(Wo.lastIndex = 0;;){ + let r = Wo.exec(n), o = Wo.lastIndex, a = r[1], l = r[2] === "]", c = r[3]; + if (l && (a = a | 0), c === void 0 || c === "[" && o + 2 === i) { + kl(t, c === void 0 ? new Xg(a, s, e) : new dh(a, s, e)); + break; + } else { + let u = t.map[a]; + u === void 0 && (u = new fh(a), kl(t, u)), t = u; + } + } +} +function bn(s, e) { + this.seq = [], this.map = {}; + let t = s.getProgramParameter(e, 35718); + for(let n = 0; n < t; ++n){ + let i = s.getActiveUniform(e, n), r = s.getUniformLocation(e, i.name); + Jg(i, r, this); + } +} +bn.prototype.setValue = function(s, e, t, n) { + let i = this.map[e]; + i !== void 0 && i.setValue(s, t, n); +}; +bn.prototype.setOptional = function(s, e, t) { + let n = e[t]; + n !== void 0 && this.setValue(s, t, n); +}; +bn.upload = function(s, e, t, n) { + for(let i = 0, r = e.length; i !== r; ++i){ + let o = e[i], a = t[o.id]; + a.needsUpdate !== !1 && o.setValue(s, a.value, n); + } +}; +bn.seqWithValue = function(s, e) { + let t = []; + for(let n = 0, i = s.length; n !== i; ++n){ + let r = s[n]; + r.id in e && t.push(r); + } + return t; +}; +function Gl(s, e, t) { + let n = s.createShader(e); + return s.shaderSource(n, t), s.compileShader(n), n; +} +var Yg = 0; +function Zg(s) { + let e = s.split(` +`); + for(let t = 0; t < e.length; t++)e[t] = t + 1 + ": " + e[t]; + return e.join(` +`); +} +function ph(s) { + switch(s){ + case Nt: + return [ + "Linear", + "( value )" + ]; + case Oi: + return [ + "sRGB", + "( value )" + ]; + default: + return console.warn("THREE.WebGLProgram: Unsupported encoding:", s), [ + "Linear", + "( value )" + ]; + } +} +function Vl(s, e, t) { + let n = s.getShaderParameter(e, 35713), i = s.getShaderInfoLog(e).trim(); + return n && i === "" ? "" : t.toUpperCase() + ` + +` + i + ` + +` + Zg(s.getShaderSource(e)); +} +function Dn(s, e) { + let t = ph(e); + return "vec4 " + s + "( vec4 value ) { return " + t[0] + "ToLinear" + t[1] + "; }"; +} +function $g(s, e) { + let t = ph(e); + return "vec4 " + s + "( vec4 value ) { return LinearTo" + t[0] + t[1] + "; }"; +} +function jg(s, e) { + let t; + switch(e){ + case Nu: + t = "Linear"; + break; + case Bu: + t = "Reinhard"; + break; + case zu: + t = "OptimizedCineon"; + break; + case Uu: + t = "ACESFilmic"; + break; + case Ou: + t = "Custom"; + break; + default: + console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear"; + } + return "vec3 " + s + "( vec3 color ) { return " + t + "ToneMapping( color ); }"; +} +function Qg(s) { + return [ + s.extensionDerivatives || s.envMapCubeUV || s.bumpMap || s.tangentSpaceNormalMap || s.clearcoatNormalMap || s.flatShading || s.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "", + (s.extensionFragDepth || s.logarithmicDepthBuffer) && s.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "", + s.extensionDrawBuffers && s.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "", + (s.extensionShaderTextureLOD || s.envMap || s.transmission) && s.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : "" + ].filter(rr).join(` +`); +} +function Kg(s) { + let e = []; + for(let t in s){ + let n = s[t]; + n !== !1 && e.push("#define " + t + " " + n); + } + return e.join(` +`); +} +function ex(s, e) { + let t = {}, n = s.getProgramParameter(e, 35721); + for(let i = 0; i < n; i++){ + let r = s.getActiveAttrib(e, i), o = r.name, a = 1; + r.type === 35674 && (a = 2), r.type === 35675 && (a = 3), r.type === 35676 && (a = 4), t[o] = { + type: r.type, + location: s.getAttribLocation(e, o), + locationSize: a + }; + } + return t; +} +function rr(s) { + return s !== ""; +} +function Wl(s, e) { + return s.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows); +} +function ql(s, e) { + return s.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection); +} +var tx = /^[ \t]*#include +<([\w\d./]+)>/gm; +function ra(s) { + return s.replace(tx, nx); +} +function nx(s, e) { + let t = Fe[e]; + if (t === void 0) throw new Error("Can not resolve #include <" + e + ">"); + return ra(t); +} +var ix = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g, rx = /#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 Xl(s) { + return s.replace(rx, mh).replace(ix, sx); +} +function sx(s, e, t, n) { + return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."), mh(s, e, t, n); +} +function mh(s, e, t, n) { + let i = ""; + for(let r = parseInt(e); r < parseInt(t); r++)i += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); + return i; +} +function Jl(s) { + let e = "precision " + s.precision + ` float; +precision ` + s.precision + " int;"; + return s.precision === "highp" ? e += ` +#define HIGH_PRECISION` : s.precision === "mediump" ? e += ` +#define MEDIUM_PRECISION` : s.precision === "lowp" && (e += ` +#define LOW_PRECISION`), e; +} +function ox(s) { + let e = "SHADOWMAP_TYPE_BASIC"; + return s.shadowMapType === Hc ? e = "SHADOWMAP_TYPE_PCF" : s.shadowMapType === fu ? e = "SHADOWMAP_TYPE_PCF_SOFT" : s.shadowMapType === ir && (e = "SHADOWMAP_TYPE_VSM"), e; +} +function ax(s) { + let e = "ENVMAP_TYPE_CUBE"; + if (s.envMap) switch(s.envMapMode){ + case Bi: + case zi: + e = "ENVMAP_TYPE_CUBE"; + break; + case Pr: + case Ws: + e = "ENVMAP_TYPE_CUBE_UV"; + break; + } + return e; +} +function lx(s) { + let e = "ENVMAP_MODE_REFLECTION"; + if (s.envMap) switch(s.envMapMode){ + case zi: + case Ws: + e = "ENVMAP_MODE_REFRACTION"; + break; + } + return e; +} +function cx(s) { + let e = "ENVMAP_BLENDING_NONE"; + if (s.envMap) switch(s.combine){ + case Vs: + e = "ENVMAP_BLENDING_MULTIPLY"; + break; + case Du: + e = "ENVMAP_BLENDING_MIX"; + break; + case Fu: + e = "ENVMAP_BLENDING_ADD"; + break; + } + return e; +} +function hx(s, e, t, n) { + let i = s.getContext(), r = t.defines, o = t.vertexShader, a = t.fragmentShader, l = ox(t), c = ax(t), h = lx(t), u = cx(t), d = t.isWebGL2 ? "" : Qg(t), f = Kg(r), m = i.createProgram(), x, v, g = t.glslVersion ? "#version " + t.glslVersion + ` +` : ""; + t.isRawShaderMaterial ? (x = [ + f + ].filter(rr).join(` +`), x.length > 0 && (x += ` +`), v = [ + d, + f + ].filter(rr).join(` +`), v.length > 0 && (v += ` +`)) : (x = [ + Jl(t), + "#define SHADER_NAME " + t.shaderName, + f, + t.instancing ? "#define USE_INSTANCING" : "", + t.instancingColor ? "#define USE_INSTANCING_COLOR" : "", + t.supportsVertexTextures ? "#define VERTEX_TEXTURES" : "", + "#define MAX_BONES " + t.maxBones, + t.useFog && t.fog ? "#define USE_FOG" : "", + t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", + t.map ? "#define USE_MAP" : "", + t.envMap ? "#define USE_ENVMAP" : "", + t.envMap ? "#define " + h : "", + t.lightMap ? "#define USE_LIGHTMAP" : "", + t.aoMap ? "#define USE_AOMAP" : "", + t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", + t.bumpMap ? "#define USE_BUMPMAP" : "", + t.normalMap ? "#define USE_NORMALMAP" : "", + t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", + t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", + t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", + t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", + t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", + t.displacementMap && t.supportsVertexTextures ? "#define USE_DISPLACEMENTMAP" : "", + t.specularMap ? "#define USE_SPECULARMAP" : "", + t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", + t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", + t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", + t.metalnessMap ? "#define USE_METALNESSMAP" : "", + t.alphaMap ? "#define USE_ALPHAMAP" : "", + t.transmission ? "#define USE_TRANSMISSION" : "", + t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", + t.thicknessMap ? "#define USE_THICKNESSMAP" : "", + t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", + t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", + t.vertexTangents ? "#define USE_TANGENT" : "", + t.vertexColors ? "#define USE_COLOR" : "", + t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", + t.vertexUvs ? "#define USE_UV" : "", + t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", + t.flatShading ? "#define FLAT_SHADED" : "", + t.skinning ? "#define USE_SKINNING" : "", + t.useVertexTexture ? "#define BONE_TEXTURE" : "", + t.morphTargets ? "#define USE_MORPHTARGETS" : "", + t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", + t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "", + t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "", + t.doubleSided ? "#define DOUBLE_SIDED" : "", + t.flipSided ? "#define FLIP_SIDED" : "", + t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", + t.shadowMapEnabled ? "#define " + l : "", + t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", + t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", + "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", + "attribute vec3 position;", + "attribute vec3 normal;", + "attribute vec2 uv;", + "#ifdef USE_TANGENT", + " attribute vec4 tangent;", + "#endif", + "#if defined( USE_COLOR_ALPHA )", + " attribute vec4 color;", + "#elif defined( USE_COLOR )", + " attribute vec3 color;", + "#endif", + "#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )", + " attribute vec3 morphTarget0;", + " attribute vec3 morphTarget1;", + " attribute vec3 morphTarget2;", + " attribute vec3 morphTarget3;", + " #ifdef USE_MORPHNORMALS", + " attribute vec3 morphNormal0;", + " attribute vec3 morphNormal1;", + " attribute vec3 morphNormal2;", + " attribute vec3 morphNormal3;", + " #else", + " attribute vec3 morphTarget4;", + " attribute vec3 morphTarget5;", + " attribute vec3 morphTarget6;", + " attribute vec3 morphTarget7;", + " #endif", + "#endif", + "#ifdef USE_SKINNING", + " attribute vec4 skinIndex;", + " attribute vec4 skinWeight;", + "#endif", + ` +` + ].filter(rr).join(` +`), v = [ + d, + Jl(t), + "#define SHADER_NAME " + t.shaderName, + f, + t.useFog && t.fog ? "#define USE_FOG" : "", + t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", + t.map ? "#define USE_MAP" : "", + t.matcap ? "#define USE_MATCAP" : "", + t.envMap ? "#define USE_ENVMAP" : "", + t.envMap ? "#define " + c : "", + t.envMap ? "#define " + h : "", + t.envMap ? "#define " + u : "", + t.lightMap ? "#define USE_LIGHTMAP" : "", + t.aoMap ? "#define USE_AOMAP" : "", + t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", + t.bumpMap ? "#define USE_BUMPMAP" : "", + t.normalMap ? "#define USE_NORMALMAP" : "", + t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", + t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", + t.clearcoat ? "#define USE_CLEARCOAT" : "", + t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", + t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", + t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", + t.specularMap ? "#define USE_SPECULARMAP" : "", + t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", + t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", + t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", + t.metalnessMap ? "#define USE_METALNESSMAP" : "", + t.alphaMap ? "#define USE_ALPHAMAP" : "", + t.alphaTest ? "#define USE_ALPHATEST" : "", + t.sheen ? "#define USE_SHEEN" : "", + t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", + t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", + t.transmission ? "#define USE_TRANSMISSION" : "", + t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", + t.thicknessMap ? "#define USE_THICKNESSMAP" : "", + t.vertexTangents ? "#define USE_TANGENT" : "", + t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "", + t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", + t.vertexUvs ? "#define USE_UV" : "", + t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", + t.gradientMap ? "#define USE_GRADIENTMAP" : "", + t.flatShading ? "#define FLAT_SHADED" : "", + t.doubleSided ? "#define DOUBLE_SIDED" : "", + t.flipSided ? "#define FLIP_SIDED" : "", + t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", + t.shadowMapEnabled ? "#define " + l : "", + t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", + t.physicallyCorrectLights ? "#define PHYSICALLY_CORRECT_LIGHTS" : "", + t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", + (t.extensionShaderTextureLOD || t.envMap) && t.rendererExtensionShaderTextureLod ? "#define TEXTURE_LOD_EXT" : "", + "uniform mat4 viewMatrix;", + "uniform vec3 cameraPosition;", + "uniform bool isOrthographic;", + t.toneMapping !== _n ? "#define TONE_MAPPING" : "", + t.toneMapping !== _n ? Fe.tonemapping_pars_fragment : "", + t.toneMapping !== _n ? jg("toneMapping", t.toneMapping) : "", + t.dithering ? "#define DITHERING" : "", + t.format === Gn ? "#define OPAQUE" : "", + Fe.encodings_pars_fragment, + t.map ? Dn("mapTexelToLinear", t.mapEncoding) : "", + t.matcap ? Dn("matcapTexelToLinear", t.matcapEncoding) : "", + t.envMap ? Dn("envMapTexelToLinear", t.envMapEncoding) : "", + t.emissiveMap ? Dn("emissiveMapTexelToLinear", t.emissiveMapEncoding) : "", + t.specularColorMap ? Dn("specularColorMapTexelToLinear", t.specularColorMapEncoding) : "", + t.sheenColorMap ? Dn("sheenColorMapTexelToLinear", t.sheenColorMapEncoding) : "", + t.lightMap ? Dn("lightMapTexelToLinear", t.lightMapEncoding) : "", + $g("linearToOutputTexel", t.outputEncoding), + t.depthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "", + ` +` + ].filter(rr).join(` +`)), o = ra(o), o = Wl(o, t), o = ql(o, t), a = ra(a), a = Wl(a, t), a = ql(a, t), o = Xl(o), a = Xl(a), t.isWebGL2 && t.isRawShaderMaterial !== !0 && (g = `#version 300 es +`, x = [ + "precision mediump sampler2DArray;", + "#define attribute in", + "#define varying out", + "#define texture2D texture" + ].join(` +`) + ` +` + x, v = [ + "#define varying in", + t.glslVersion === xl ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", + t.glslVersion === xl ? "" : "#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(` +`) + ` +` + v); + let p = g + x + o, _ = g + v + a, y = Gl(i, 35633, p), b = Gl(i, 35632, _); + if (i.attachShader(m, y), i.attachShader(m, b), t.index0AttributeName !== void 0 ? i.bindAttribLocation(m, 0, t.index0AttributeName) : t.morphTargets === !0 && i.bindAttribLocation(m, 0, "position"), i.linkProgram(m), s.debug.checkShaderErrors) { + let I = i.getProgramInfoLog(m).trim(), k = i.getShaderInfoLog(y).trim(), B = i.getShaderInfoLog(b).trim(), P = !0, w = !0; + if (i.getProgramParameter(m, 35714) === !1) { + P = !1; + let E = Vl(i, y, "vertex"), D = Vl(i, b, "fragment"); + console.error("THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(m, 35715) + ` + +Program Info Log: ` + I + ` +` + E + ` +` + D); + } else I !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", I) : (k === "" || B === "") && (w = !1); + w && (this.diagnostics = { + runnable: P, + programLog: I, + vertexShader: { + log: k, + prefix: x + }, + fragmentShader: { + log: B, + prefix: v + } + }); + } + i.deleteShader(y), i.deleteShader(b); + let A; + this.getUniforms = function() { + return A === void 0 && (A = new bn(i, m)), A; + }; + let L; + return this.getAttributes = function() { + return L === void 0 && (L = ex(i, m)), L; + }, this.destroy = function() { + n.releaseStatesOfProgram(this), i.deleteProgram(m), this.program = void 0; + }, this.name = t.shaderName, this.id = Yg++, this.cacheKey = e, this.usedTimes = 1, this.program = m, this.vertexShader = y, this.fragmentShader = b, this; +} +var ux = 0, gh = class { + constructor(){ + this.shaderCache = new Map, this.materialCache = new Map; + } + update(e) { + let t = e.vertexShader, n = e.fragmentShader, i = this._getShaderStage(t), r = this._getShaderStage(n), o = this._getShaderCacheForMaterial(e); + return o.has(i) === !1 && (o.add(i), i.usedTimes++), o.has(r) === !1 && (o.add(r), r.usedTimes++), this; + } + remove(e) { + let t = this.materialCache.get(e); + for (let n of t)n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n); + return this.materialCache.delete(e), this; + } + getVertexShaderID(e) { + return this._getShaderStage(e.vertexShader).id; + } + getFragmentShaderID(e) { + return this._getShaderStage(e.fragmentShader).id; + } + dispose() { + this.shaderCache.clear(), this.materialCache.clear(); + } + _getShaderCacheForMaterial(e) { + let t = this.materialCache; + return t.has(e) === !1 && t.set(e, new Set), t.get(e); + } + _getShaderStage(e) { + let t = this.shaderCache; + if (t.has(e) === !1) { + let n = new xh; + t.set(e, n); + } + return t.get(e); + } +}, xh = class { + constructor(){ + this.id = ux++, this.usedTimes = 0; + } +}; +function dx(s, e, t, n, i, r, o) { + let a = new Js, l = new gh, c = [], h = i.isWebGL2, u = i.logarithmicDepthBuffer, d = i.floatVertexTextures, f = i.maxVertexUniforms, m = i.vertexTextures, x = i.precision, v = { + MeshDepthMaterial: "depth", + MeshDistanceMaterial: "distanceRGBA", + 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(w) { + let D = w.skeleton.bones; + if (d) return 1024; + { + let F = Math.floor((f - 20) / 4), O = Math.min(F, D.length); + return O < D.length ? (console.warn("THREE.WebGLRenderer: Skeleton has " + D.length + " bones. This GPU supports " + O + "."), 0) : O; + } + } + function p(w) { + let E; + return w && w.isTexture ? E = w.encoding : w && w.isWebGLRenderTarget ? (console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."), E = w.texture.encoding) : E = Nt, h && w && w.isTexture && w.format === ct && w.type === rn && w.encoding === Oi && (E = Nt), E; + } + function _(w, E, D, U, F) { + let O = U.fog, ne = w.isMeshStandardMaterial ? U.environment : null, ce = (w.isMeshStandardMaterial ? t : e).get(w.envMap || ne), V = v[w.type], W = F.isSkinnedMesh ? g(F) : 0; + w.precision !== null && (x = i.getMaxPrecision(w.precision), x !== w.precision && console.warn("THREE.WebGLProgram.getParameters:", w.precision, "not supported, using", x, "instead.")); + let he, le, fe, Be; + if (V) { + let xe = qt[V]; + he = xe.vertexShader, le = xe.fragmentShader; + } else he = w.vertexShader, le = w.fragmentShader, l.update(w), fe = l.getVertexShaderID(w), Be = l.getFragmentShaderID(w); + let Y = s.getRenderTarget(), Ce = w.alphaTest > 0, ye = w.clearcoat > 0; + return { + isWebGL2: h, + shaderID: V, + shaderName: w.type, + vertexShader: he, + fragmentShader: le, + defines: w.defines, + customVertexShaderID: fe, + customFragmentShaderID: Be, + isRawShaderMaterial: w.isRawShaderMaterial === !0, + glslVersion: w.glslVersion, + precision: x, + instancing: F.isInstancedMesh === !0, + instancingColor: F.isInstancedMesh === !0 && F.instanceColor !== null, + supportsVertexTextures: m, + outputEncoding: Y !== null ? p(Y.texture) : s.outputEncoding, + map: !!w.map, + mapEncoding: p(w.map), + matcap: !!w.matcap, + matcapEncoding: p(w.matcap), + envMap: !!ce, + envMapMode: ce && ce.mapping, + envMapEncoding: p(ce), + envMapCubeUV: !!ce && (ce.mapping === Pr || ce.mapping === Ws), + lightMap: !!w.lightMap, + lightMapEncoding: p(w.lightMap), + aoMap: !!w.aoMap, + emissiveMap: !!w.emissiveMap, + emissiveMapEncoding: p(w.emissiveMap), + bumpMap: !!w.bumpMap, + normalMap: !!w.normalMap, + objectSpaceNormalMap: w.normalMapType === zd, + tangentSpaceNormalMap: w.normalMapType === Hi, + clearcoat: ye, + clearcoatMap: ye && !!w.clearcoatMap, + clearcoatRoughnessMap: ye && !!w.clearcoatRoughnessMap, + clearcoatNormalMap: ye && !!w.clearcoatNormalMap, + displacementMap: !!w.displacementMap, + roughnessMap: !!w.roughnessMap, + metalnessMap: !!w.metalnessMap, + specularMap: !!w.specularMap, + specularIntensityMap: !!w.specularIntensityMap, + specularColorMap: !!w.specularColorMap, + specularColorMapEncoding: p(w.specularColorMap), + alphaMap: !!w.alphaMap, + alphaTest: Ce, + gradientMap: !!w.gradientMap, + sheen: w.sheen > 0, + sheenColorMap: !!w.sheenColorMap, + sheenColorMapEncoding: p(w.sheenColorMap), + sheenRoughnessMap: !!w.sheenRoughnessMap, + transmission: w.transmission > 0, + transmissionMap: !!w.transmissionMap, + thicknessMap: !!w.thicknessMap, + combine: w.combine, + vertexTangents: !!w.normalMap && !!F.geometry && !!F.geometry.attributes.tangent, + vertexColors: w.vertexColors, + vertexAlphas: w.vertexColors === !0 && !!F.geometry && !!F.geometry.attributes.color && F.geometry.attributes.color.itemSize === 4, + vertexUvs: !!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatMap || !!w.clearcoatRoughnessMap || !!w.clearcoatNormalMap || !!w.displacementMap || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || !!w.sheenColorMap || !!w.sheenRoughnessMap, + uvsVertexOnly: !(!!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatNormalMap || w.transmission > 0 || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || w.sheen > 0 || !!w.sheenColorMap || !!w.sheenRoughnessMap) && !!w.displacementMap, + fog: !!O, + useFog: w.fog, + fogExp2: O && O.isFogExp2, + flatShading: !!w.flatShading, + sizeAttenuation: w.sizeAttenuation, + logarithmicDepthBuffer: u, + skinning: F.isSkinnedMesh === !0 && W > 0, + maxBones: W, + useVertexTexture: d, + morphTargets: !!F.geometry && !!F.geometry.morphAttributes.position, + morphNormals: !!F.geometry && !!F.geometry.morphAttributes.normal, + morphTargetsCount: !!F.geometry && !!F.geometry.morphAttributes.position ? F.geometry.morphAttributes.position.length : 0, + numDirLights: E.directional.length, + numPointLights: E.point.length, + numSpotLights: E.spot.length, + numRectAreaLights: E.rectArea.length, + numHemiLights: E.hemi.length, + numDirLightShadows: E.directionalShadowMap.length, + numPointLightShadows: E.pointShadowMap.length, + numSpotLightShadows: E.spotShadowMap.length, + numClippingPlanes: o.numPlanes, + numClipIntersection: o.numIntersection, + format: w.format, + dithering: w.dithering, + shadowMapEnabled: s.shadowMap.enabled && D.length > 0, + shadowMapType: s.shadowMap.type, + toneMapping: w.toneMapped ? s.toneMapping : _n, + physicallyCorrectLights: s.physicallyCorrectLights, + premultipliedAlpha: w.premultipliedAlpha, + doubleSided: w.side === Ci, + flipSided: w.side === it, + depthPacking: w.depthPacking !== void 0 ? w.depthPacking : !1, + index0AttributeName: w.index0AttributeName, + extensionDerivatives: w.extensions && w.extensions.derivatives, + extensionFragDepth: w.extensions && w.extensions.fragDepth, + extensionDrawBuffers: w.extensions && w.extensions.drawBuffers, + extensionShaderTextureLOD: w.extensions && w.extensions.shaderTextureLOD, + rendererExtensionFragDepth: h || n.has("EXT_frag_depth"), + rendererExtensionDrawBuffers: h || n.has("WEBGL_draw_buffers"), + rendererExtensionShaderTextureLod: h || n.has("EXT_shader_texture_lod"), + customProgramCacheKey: w.customProgramCacheKey() + }; + } + function y(w) { + let E = []; + if (w.shaderID ? E.push(w.shaderID) : (E.push(w.customVertexShaderID), E.push(w.customFragmentShaderID)), w.defines !== void 0) for(let D in w.defines)E.push(D), E.push(w.defines[D]); + return w.isRawShaderMaterial === !1 && (b(E, w), A(E, w), E.push(s.outputEncoding)), E.push(w.customProgramCacheKey), E.join(); + } + function b(w, E) { + w.push(E.precision), w.push(E.outputEncoding), w.push(E.mapEncoding), w.push(E.matcapEncoding), w.push(E.envMapMode), w.push(E.envMapEncoding), w.push(E.lightMapEncoding), w.push(E.emissiveMapEncoding), w.push(E.combine), w.push(E.vertexUvs), w.push(E.fogExp2), w.push(E.sizeAttenuation), w.push(E.maxBones), w.push(E.morphTargetsCount), w.push(E.numDirLights), w.push(E.numPointLights), w.push(E.numSpotLights), w.push(E.numHemiLights), w.push(E.numRectAreaLights), w.push(E.numDirLightShadows), w.push(E.numPointLightShadows), w.push(E.numSpotLightShadows), w.push(E.shadowMapType), w.push(E.toneMapping), w.push(E.numClippingPlanes), w.push(E.numClipIntersection), w.push(E.format), w.push(E.specularColorMapEncoding), w.push(E.sheenColorMapEncoding); + } + function A(w, E) { + a.disableAll(), E.isWebGL2 && a.enable(0), E.supportsVertexTextures && a.enable(1), E.instancing && a.enable(2), E.instancingColor && a.enable(3), E.map && a.enable(4), E.matcap && a.enable(5), E.envMap && a.enable(6), E.envMapCubeUV && a.enable(7), E.lightMap && a.enable(8), E.aoMap && a.enable(9), E.emissiveMap && a.enable(10), E.bumpMap && a.enable(11), E.normalMap && a.enable(12), E.objectSpaceNormalMap && a.enable(13), E.tangentSpaceNormalMap && a.enable(14), E.clearcoat && a.enable(15), E.clearcoatMap && a.enable(16), E.clearcoatRoughnessMap && a.enable(17), E.clearcoatNormalMap && a.enable(18), E.displacementMap && a.enable(19), E.specularMap && a.enable(20), E.roughnessMap && a.enable(21), E.metalnessMap && a.enable(22), E.gradientMap && a.enable(23), E.alphaMap && a.enable(24), E.alphaTest && a.enable(25), E.vertexColors && a.enable(26), E.vertexAlphas && a.enable(27), E.vertexUvs && a.enable(28), E.vertexTangents && a.enable(29), E.uvsVertexOnly && a.enable(30), E.fog && a.enable(31), w.push(a.mask), a.disableAll(), E.useFog && a.enable(0), E.flatShading && a.enable(1), E.logarithmicDepthBuffer && a.enable(2), E.skinning && a.enable(3), E.useVertexTexture && a.enable(4), E.morphTargets && a.enable(5), E.morphNormals && a.enable(6), E.premultipliedAlpha && a.enable(7), E.shadowMapEnabled && a.enable(8), E.physicallyCorrectLights && a.enable(9), E.doubleSided && a.enable(10), E.flipSided && a.enable(11), E.depthPacking && a.enable(12), E.dithering && a.enable(13), E.specularIntensityMap && a.enable(14), E.specularColorMap && a.enable(15), E.transmission && a.enable(16), E.transmissionMap && a.enable(17), E.thicknessMap && a.enable(18), E.sheen && a.enable(19), E.sheenColorMap && a.enable(20), E.sheenRoughnessMap && a.enable(21), w.push(a.mask); + } + function L(w) { + let E = v[w.type], D; + if (E) { + let U = qt[E]; + D = uf.clone(U.uniforms); + } else D = w.uniforms; + return D; + } + function I(w, E) { + let D; + for(let U = 0, F = c.length; U < F; U++){ + let O = c[U]; + if (O.cacheKey === E) { + D = O, ++D.usedTimes; + break; + } + } + return D === void 0 && (D = new hx(s, E, w, r), c.push(D)), D; + } + function k(w) { + if (--w.usedTimes === 0) { + let E = c.indexOf(w); + c[E] = c[c.length - 1], c.pop(), w.destroy(); + } + } + function B(w) { + l.remove(w); + } + function P() { + l.dispose(); + } + return { + getParameters: _, + getProgramCacheKey: y, + getUniforms: L, + acquireProgram: I, + releaseProgram: k, + releaseShaderCache: B, + programs: c, + dispose: P + }; +} +function fx() { + let s = new WeakMap; + function e(r) { + let o = s.get(r); + return o === void 0 && (o = {}, s.set(r, o)), o; + } + function t(r) { + s.delete(r); + } + function n(r, o, a) { + s.get(r)[o] = a; + } + function i() { + s = new WeakMap; + } + return { + get: e, + remove: t, + update: n, + dispose: i + }; +} +function px(s, e) { + return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.material.id !== e.material.id ? s.material.id - e.material.id : s.z !== e.z ? s.z - e.z : s.id - e.id; +} +function Yl(s, e) { + return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.z !== e.z ? e.z - s.z : s.id - e.id; +} +function Zl() { + let s = [], e = 0, t = [], n = [], i = []; + function r() { + e = 0, t.length = 0, n.length = 0, i.length = 0; + } + function o(u, d, f, m, x, v) { + let g = s[e]; + return g === void 0 ? (g = { + id: u.id, + object: u, + geometry: d, + material: f, + groupOrder: m, + renderOrder: u.renderOrder, + z: x, + group: v + }, s[e] = g) : (g.id = u.id, g.object = u, g.geometry = d, g.material = f, g.groupOrder = m, g.renderOrder = u.renderOrder, g.z = x, g.group = v), e++, g; + } + function a(u, d, f, m, x, v) { + let g = o(u, d, f, m, x, v); + f.transmission > 0 ? n.push(g) : f.transparent === !0 ? i.push(g) : t.push(g); + } + function l(u, d, f, m, x, v) { + let g = o(u, d, f, m, x, v); + f.transmission > 0 ? n.unshift(g) : f.transparent === !0 ? i.unshift(g) : t.unshift(g); + } + function c(u, d) { + t.length > 1 && t.sort(u || px), n.length > 1 && n.sort(d || Yl), i.length > 1 && i.sort(d || Yl); + } + function h() { + for(let u = e, d = s.length; u < d; u++){ + let f = s[u]; + if (f.id === null) break; + f.id = null, f.object = null, f.geometry = null, f.material = null, f.group = null; + } + } + return { + opaque: t, + transmissive: n, + transparent: i, + init: r, + push: a, + unshift: l, + finish: h, + sort: c + }; +} +function mx() { + let s = new WeakMap; + function e(n, i) { + let r; + return s.has(n) === !1 ? (r = new Zl, s.set(n, [ + r + ])) : i >= s.get(n).length ? (r = new Zl, s.get(n).push(r)) : r = s.get(n)[i], r; + } + function t() { + s = new WeakMap; + } + return { + get: e, + dispose: t + }; +} +function gx() { + let s = {}; + return { + get: function(e) { + if (s[e.id] !== void 0) return s[e.id]; + let t; + switch(e.type){ + case "DirectionalLight": + t = { + direction: new M, + color: new ae + }; + break; + case "SpotLight": + t = { + position: new M, + direction: new M, + color: new ae, + distance: 0, + coneCos: 0, + penumbraCos: 0, + decay: 0 + }; + break; + case "PointLight": + t = { + position: new M, + color: new ae, + distance: 0, + decay: 0 + }; + break; + case "HemisphereLight": + t = { + direction: new M, + skyColor: new ae, + groundColor: new ae + }; + break; + case "RectAreaLight": + t = { + color: new ae, + position: new M, + halfWidth: new M, + halfHeight: new M + }; + break; + } + return s[e.id] = t, t; + } + }; +} +function xx() { + let s = {}; + return { + get: function(e) { + if (s[e.id] !== void 0) return s[e.id]; + let t; + switch(e.type){ + case "DirectionalLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new X + }; + break; + case "SpotLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new X + }; + break; + case "PointLight": + t = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new X, + shadowCameraNear: 1, + shadowCameraFar: 1e3 + }; + break; + } + return s[e.id] = t, t; + } + }; +} +var yx = 0; +function vx(s, e) { + return (e.castShadow ? 1 : 0) - (s.castShadow ? 1 : 0); +} +function _x(s, e) { + let t = new gx, n = xx(), i = { + version: 0, + hash: { + directionalLength: -1, + pointLength: -1, + spotLength: -1, + rectAreaLength: -1, + hemiLength: -1, + numDirectionalShadows: -1, + numPointShadows: -1, + numSpotShadows: -1 + }, + ambient: [ + 0, + 0, + 0 + ], + probe: [], + directional: [], + directionalShadow: [], + directionalShadowMap: [], + directionalShadowMatrix: [], + spot: [], + spotShadow: [], + spotShadowMap: [], + spotShadowMatrix: [], + rectArea: [], + rectAreaLTC1: null, + rectAreaLTC2: null, + point: [], + pointShadow: [], + pointShadowMap: [], + pointShadowMatrix: [], + hemi: [] + }; + for(let h = 0; h < 9; h++)i.probe.push(new M); + let r = new M, o = new pe, a = new pe; + function l(h, u) { + let d = 0, f = 0, m = 0; + for(let k = 0; k < 9; k++)i.probe[k].set(0, 0, 0); + let x = 0, v = 0, g = 0, p = 0, _ = 0, y = 0, b = 0, A = 0; + h.sort(vx); + let L = u !== !0 ? Math.PI : 1; + for(let k = 0, B = h.length; k < B; k++){ + let P = h[k], w = P.color, E = P.intensity, D = P.distance, U = P.shadow && P.shadow.map ? P.shadow.map.texture : null; + if (P.isAmbientLight) d += w.r * E * L, f += w.g * E * L, m += w.b * E * L; + else if (P.isLightProbe) for(let F = 0; F < 9; F++)i.probe[F].addScaledVector(P.sh.coefficients[F], E); + else if (P.isDirectionalLight) { + let F = t.get(P); + if (F.color.copy(P.color).multiplyScalar(P.intensity * L), P.castShadow) { + let O = P.shadow, ne = n.get(P); + ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.directionalShadow[x] = ne, i.directionalShadowMap[x] = U, i.directionalShadowMatrix[x] = P.shadow.matrix, y++; + } + i.directional[x] = F, x++; + } else if (P.isSpotLight) { + let F = t.get(P); + if (F.position.setFromMatrixPosition(P.matrixWorld), F.color.copy(w).multiplyScalar(E * L), F.distance = D, F.coneCos = Math.cos(P.angle), F.penumbraCos = Math.cos(P.angle * (1 - P.penumbra)), F.decay = P.decay, P.castShadow) { + let O = P.shadow, ne = n.get(P); + ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.spotShadow[g] = ne, i.spotShadowMap[g] = U, i.spotShadowMatrix[g] = P.shadow.matrix, A++; + } + i.spot[g] = F, g++; + } else if (P.isRectAreaLight) { + let F = t.get(P); + F.color.copy(w).multiplyScalar(E), F.halfWidth.set(P.width * .5, 0, 0), F.halfHeight.set(0, P.height * .5, 0), i.rectArea[p] = F, p++; + } else if (P.isPointLight) { + let F = t.get(P); + if (F.color.copy(P.color).multiplyScalar(P.intensity * L), F.distance = P.distance, F.decay = P.decay, P.castShadow) { + let O = P.shadow, ne = n.get(P); + ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, ne.shadowCameraNear = O.camera.near, ne.shadowCameraFar = O.camera.far, i.pointShadow[v] = ne, i.pointShadowMap[v] = U, i.pointShadowMatrix[v] = P.shadow.matrix, b++; + } + i.point[v] = F, v++; + } else if (P.isHemisphereLight) { + let F = t.get(P); + F.skyColor.copy(P.color).multiplyScalar(E * L), F.groundColor.copy(P.groundColor).multiplyScalar(E * L), i.hemi[_] = F, _++; + } + } + p > 0 && (e.isWebGL2 || s.has("OES_texture_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_FLOAT_1, i.rectAreaLTC2 = ie.LTC_FLOAT_2) : s.has("OES_texture_half_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_HALF_1, i.rectAreaLTC2 = ie.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), i.ambient[0] = d, i.ambient[1] = f, i.ambient[2] = m; + let I = i.hash; + (I.directionalLength !== x || I.pointLength !== v || I.spotLength !== g || I.rectAreaLength !== p || I.hemiLength !== _ || I.numDirectionalShadows !== y || I.numPointShadows !== b || I.numSpotShadows !== A) && (i.directional.length = x, i.spot.length = g, i.rectArea.length = p, i.point.length = v, i.hemi.length = _, i.directionalShadow.length = y, i.directionalShadowMap.length = y, i.pointShadow.length = b, i.pointShadowMap.length = b, i.spotShadow.length = A, i.spotShadowMap.length = A, i.directionalShadowMatrix.length = y, i.pointShadowMatrix.length = b, i.spotShadowMatrix.length = A, I.directionalLength = x, I.pointLength = v, I.spotLength = g, I.rectAreaLength = p, I.hemiLength = _, I.numDirectionalShadows = y, I.numPointShadows = b, I.numSpotShadows = A, i.version = yx++); + } + function c(h, u) { + let d = 0, f = 0, m = 0, x = 0, v = 0, g = u.matrixWorldInverse; + for(let p = 0, _ = h.length; p < _; p++){ + let y = h[p]; + if (y.isDirectionalLight) { + let b = i.directional[d]; + b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), d++; + } else if (y.isSpotLight) { + let b = i.spot[m]; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), m++; + } else if (y.isRectAreaLight) { + let b = i.rectArea[x]; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), a.identity(), o.copy(y.matrixWorld), o.premultiply(g), a.extractRotation(o), b.halfWidth.set(y.width * .5, 0, 0), b.halfHeight.set(0, y.height * .5, 0), b.halfWidth.applyMatrix4(a), b.halfHeight.applyMatrix4(a), x++; + } else if (y.isPointLight) { + let b = i.point[f]; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), f++; + } else if (y.isHemisphereLight) { + let b = i.hemi[v]; + b.direction.setFromMatrixPosition(y.matrixWorld), b.direction.transformDirection(g), b.direction.normalize(), v++; + } + } + } + return { + setup: l, + setupView: c, + state: i + }; +} +function $l(s, e) { + let t = new _x(s, e), n = [], i = []; + function r() { + n.length = 0, i.length = 0; + } + function o(u) { + n.push(u); + } + function a(u) { + i.push(u); + } + function l(u) { + t.setup(n, u); + } + function c(u) { + t.setupView(n, u); + } + return { + init: r, + state: { + lightsArray: n, + shadowsArray: i, + lights: t + }, + setupLights: l, + setupLightsView: c, + pushLight: o, + pushShadow: a + }; +} +function Mx(s, e) { + let t = new WeakMap; + function n(r, o = 0) { + let a; + return t.has(r) === !1 ? (a = new $l(s, e), t.set(r, [ + a + ])) : o >= t.get(r).length ? (a = new $l(s, e), t.get(r).push(a)) : a = t.get(r)[o], a; + } + function i() { + t = new WeakMap; + } + return { + get: n, + dispose: i + }; +} +var eo = class extends dt { + constructor(e){ + super(); + this.type = "MeshDepthMaterial", this.depthPacking = Nd, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this; + } +}; +eo.prototype.isMeshDepthMaterial = !0; +var to = class extends dt { + constructor(e){ + super(); + this.type = "MeshDistanceMaterial", this.referencePosition = new M, this.nearDistance = 1, this.farDistance = 1e3, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.fog = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.referencePosition.copy(e.referencePosition), this.nearDistance = e.nearDistance, this.farDistance = e.farDistance, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this; + } +}; +to.prototype.isMeshDistanceMaterial = !0; +var bx = `void main() { + gl_Position = vec4( position, 1.0 ); +}`, wx = `uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`; +function yh(s, e, t) { + let n = new Dr, i = new X, r = new X, o = new Ve, a = new eo({ + depthPacking: Bd + }), l = new to, c = {}, h = t.maxTextureSize, u = { + 0: it, + 1: Ai, + 2: Ci + }, d = new sn({ + defines: { + VSM_SAMPLES: 8 + }, + uniforms: { + shadow_pass: { + value: null + }, + resolution: { + value: new X + }, + radius: { + value: 4 + } + }, + vertexShader: bx, + fragmentShader: wx + }), f = d.clone(); + f.defines.HORIZONTAL_PASS = 1; + let m = new _e; + m.setAttribute("position", new Ue(new Float32Array([ + -1, + -1, + .5, + 3, + -1, + .5, + -1, + 3, + .5 + ]), 3)); + let x = new st(m, d), v = this; + this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Hc, this.render = function(y, b, A) { + if (v.enabled === !1 || v.autoUpdate === !1 && v.needsUpdate === !1 || y.length === 0) return; + let L = s.getRenderTarget(), I = s.getActiveCubeFace(), k = s.getActiveMipmapLevel(), B = s.state; + B.setBlending(vn), B.buffers.color.setClear(1, 1, 1, 1), B.buffers.depth.setTest(!0), B.setScissorTest(!1); + for(let P = 0, w = y.length; P < w; P++){ + let E = y[P], D = E.shadow; + if (D === void 0) { + console.warn("THREE.WebGLShadowMap:", E, "has no shadow."); + continue; + } + if (D.autoUpdate === !1 && D.needsUpdate === !1) continue; + i.copy(D.mapSize); + let U = D.getFrameExtents(); + if (i.multiply(U), r.copy(D.mapSize), (i.x > h || i.y > h) && (i.x > h && (r.x = Math.floor(h / U.x), i.x = r.x * U.x, D.mapSize.x = r.x), i.y > h && (r.y = Math.floor(h / U.y), i.y = r.y * U.y, D.mapSize.y = r.y)), D.map === null && !D.isPointLightShadow && this.type === ir) { + let O = { + minFilter: tt, + magFilter: tt, + format: ct + }; + D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.mapPass = new At(i.x, i.y, O), D.camera.updateProjectionMatrix(); + } + if (D.map === null) { + let O = { + minFilter: rt, + magFilter: rt, + format: ct + }; + D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.camera.updateProjectionMatrix(); + } + s.setRenderTarget(D.map), s.clear(); + let F = D.getViewportCount(); + for(let O = 0; O < F; O++){ + let ne = D.getViewport(O); + o.set(r.x * ne.x, r.y * ne.y, r.x * ne.z, r.y * ne.w), B.viewport(o), D.updateMatrices(E, O), n = D.getFrustum(), _(b, A, D.camera, E, this.type); + } + !D.isPointLightShadow && this.type === ir && g(D, A), D.needsUpdate = !1; + } + v.needsUpdate = !1, s.setRenderTarget(L, I, k); + }; + function g(y, b) { + let A = e.update(x); + d.defines.VSM_SAMPLES !== y.blurSamples && (d.defines.VSM_SAMPLES = y.blurSamples, f.defines.VSM_SAMPLES = y.blurSamples, d.needsUpdate = !0, f.needsUpdate = !0), d.uniforms.shadow_pass.value = y.map.texture, d.uniforms.resolution.value = y.mapSize, d.uniforms.radius.value = y.radius, s.setRenderTarget(y.mapPass), s.clear(), s.renderBufferDirect(b, null, A, d, x, null), f.uniforms.shadow_pass.value = y.mapPass.texture, f.uniforms.resolution.value = y.mapSize, f.uniforms.radius.value = y.radius, s.setRenderTarget(y.map), s.clear(), s.renderBufferDirect(b, null, A, f, x, null); + } + function p(y, b, A, L, I, k, B) { + let P = null, w = L.isPointLight === !0 ? y.customDistanceMaterial : y.customDepthMaterial; + if (w !== void 0 ? P = w : P = L.isPointLight === !0 ? l : a, s.localClippingEnabled && A.clipShadows === !0 && A.clippingPlanes.length !== 0 || A.displacementMap && A.displacementScale !== 0 || A.alphaMap && A.alphaTest > 0) { + let E = P.uuid, D = A.uuid, U = c[E]; + U === void 0 && (U = {}, c[E] = U); + let F = U[D]; + F === void 0 && (F = P.clone(), U[D] = F), P = F; + } + return P.visible = A.visible, P.wireframe = A.wireframe, B === ir ? P.side = A.shadowSide !== null ? A.shadowSide : A.side : P.side = A.shadowSide !== null ? A.shadowSide : u[A.side], P.alphaMap = A.alphaMap, P.alphaTest = A.alphaTest, P.clipShadows = A.clipShadows, P.clippingPlanes = A.clippingPlanes, P.clipIntersection = A.clipIntersection, P.displacementMap = A.displacementMap, P.displacementScale = A.displacementScale, P.displacementBias = A.displacementBias, P.wireframeLinewidth = A.wireframeLinewidth, P.linewidth = A.linewidth, L.isPointLight === !0 && P.isMeshDistanceMaterial === !0 && (P.referencePosition.setFromMatrixPosition(L.matrixWorld), P.nearDistance = I, P.farDistance = k), P; + } + function _(y, b, A, L, I) { + if (y.visible === !1) return; + if (y.layers.test(b.layers) && (y.isMesh || y.isLine || y.isPoints) && (y.castShadow || y.receiveShadow && I === ir) && (!y.frustumCulled || n.intersectsObject(y))) { + y.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse, y.matrixWorld); + let P = e.update(y), w = y.material; + if (Array.isArray(w)) { + let E = P.groups; + for(let D = 0, U = E.length; D < U; D++){ + let F = E[D], O = w[F.materialIndex]; + if (O && O.visible) { + let ne = p(y, P, O, L, A.near, A.far, I); + s.renderBufferDirect(A, null, P, ne, y, F); + } + } + } else if (w.visible) { + let E = p(y, P, w, L, A.near, A.far, I); + s.renderBufferDirect(A, null, P, E, y, null); + } + } + let B = y.children; + for(let P = 0, w = B.length; P < w; P++)_(B[P], b, A, L, I); + } +} +function Sx(s, e, t) { + let n = t.isWebGL2; + function i() { + let R = !1, ee = new Ve, Q = null, Ee = new Ve(0, 0, 0, 0); + return { + setMask: function(me) { + Q !== me && !R && (s.colorMask(me, me, me, me), Q = me); + }, + setLocked: function(me) { + R = me; + }, + setClear: function(me, Re, oe, Le, Xe) { + Xe === !0 && (me *= Le, Re *= Le, oe *= Le), ee.set(me, Re, oe, Le), Ee.equals(ee) === !1 && (s.clearColor(me, Re, oe, Le), Ee.copy(ee)); + }, + reset: function() { + R = !1, Q = null, Ee.set(-1, 0, 0, 0); + } + }; + } + function r() { + let R = !1, ee = null, Q = null, Ee = null; + return { + setTest: function(me) { + me ? le(2929) : fe(2929); + }, + setMask: function(me) { + ee !== me && !R && (s.depthMask(me), ee = me); + }, + setFunc: function(me) { + if (Q !== me) { + if (me) switch(me){ + case Eu: + s.depthFunc(512); + break; + case Au: + s.depthFunc(519); + break; + case Cu: + s.depthFunc(513); + break; + case ea: + s.depthFunc(515); + break; + case Lu: + s.depthFunc(514); + break; + case Ru: + s.depthFunc(518); + break; + case Pu: + s.depthFunc(516); + break; + case Iu: + s.depthFunc(517); + break; + default: + s.depthFunc(515); + } + else s.depthFunc(515); + Q = me; + } + }, + setLocked: function(me) { + R = me; + }, + setClear: function(me) { + Ee !== me && (s.clearDepth(me), Ee = me); + }, + reset: function() { + R = !1, ee = null, Q = null, Ee = null; + } + }; + } + function o() { + let R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; + return { + setTest: function(We) { + R || (We ? le(2960) : fe(2960)); + }, + setMask: function(We) { + ee !== We && !R && (s.stencilMask(We), ee = We); + }, + setFunc: function(We, Ut, Ot) { + (Q !== We || Ee !== Ut || me !== Ot) && (s.stencilFunc(We, Ut, Ot), Q = We, Ee = Ut, me = Ot); + }, + setOp: function(We, Ut, Ot) { + (Re !== We || oe !== Ut || Le !== Ot) && (s.stencilOp(We, Ut, Ot), Re = We, oe = Ut, Le = Ot); + }, + setLocked: function(We) { + R = We; + }, + setClear: function(We) { + Xe !== We && (s.clearStencil(We), Xe = We); + }, + reset: function() { + R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; + } + }; + } + let a = new i, l = new r, c = new o, h = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, P = s.getParameter(35661), w = !1, E = 0, D = s.getParameter(7938); + D.indexOf("WebGL") !== -1 ? (E = parseFloat(/^WebGL (\d)/.exec(D)[1]), w = E >= 1) : D.indexOf("OpenGL ES") !== -1 && (E = parseFloat(/^OpenGL ES (\d)/.exec(D)[1]), w = E >= 2); + let U = null, F = {}, O = s.getParameter(3088), ne = s.getParameter(2978), ce = new Ve().fromArray(O), V = new Ve().fromArray(ne); + function W(R, ee, Q) { + let Ee = new Uint8Array(4), me = s.createTexture(); + s.bindTexture(R, me), s.texParameteri(R, 10241, 9728), s.texParameteri(R, 10240, 9728); + for(let Re = 0; Re < Q; Re++)s.texImage2D(ee + Re, 0, 6408, 1, 1, 0, 6408, 5121, Ee); + return me; + } + let he = {}; + he[3553] = W(3553, 3553, 1), he[34067] = W(34067, 34069, 6), a.setClear(0, 0, 0, 1), l.setClear(1), c.setClear(0), le(2929), l.setFunc(ea), Oe(!1), G(tl), le(2884), ge(vn); + function le(R) { + h[R] !== !0 && (s.enable(R), h[R] = !0); + } + function fe(R) { + h[R] !== !1 && (s.disable(R), h[R] = !1); + } + function Be(R, ee) { + return u[R] !== ee ? (s.bindFramebuffer(R, ee), u[R] = ee, n && (R === 36009 && (u[36160] = ee), R === 36160 && (u[36009] = ee)), !0) : !1; + } + function Y(R) { + return d !== R ? (s.useProgram(R), d = R, !0) : !1; + } + let Ce = { + [_i]: 32774, + [mu]: 32778, + [gu]: 32779 + }; + if (n) Ce[sl] = 32775, Ce[ol] = 32776; + else { + let R = e.get("EXT_blend_minmax"); + R !== null && (Ce[sl] = R.MIN_EXT, Ce[ol] = R.MAX_EXT); + } + let ye = { + [xu]: 0, + [yu]: 1, + [vu]: 768, + [Gc]: 770, + [Tu]: 776, + [wu]: 774, + [Mu]: 772, + [_u]: 769, + [Vc]: 771, + [Su]: 775, + [bu]: 773 + }; + function ge(R, ee, Q, Ee, me, Re, oe, Le) { + if (R === vn) { + f === !0 && (fe(3042), f = !1); + return; + } + if (f === !1 && (le(3042), f = !0), R !== pu) { + if (R !== m || Le !== b) { + if ((x !== _i || p !== _i) && (s.blendEquation(32774), x = _i, p = _i), Le) switch(R){ + case sr: + s.blendFuncSeparate(1, 771, 1, 771); + break; + case nl: + s.blendFunc(1, 1); + break; + case il: + s.blendFuncSeparate(0, 0, 769, 771); + break; + case rl: + s.blendFuncSeparate(0, 768, 0, 770); + break; + default: + console.error("THREE.WebGLState: Invalid blending: ", R); + break; + } + else switch(R){ + case sr: + s.blendFuncSeparate(770, 771, 1, 771); + break; + case nl: + s.blendFunc(770, 1); + break; + case il: + s.blendFunc(0, 769); + break; + case rl: + s.blendFunc(0, 768); + break; + default: + console.error("THREE.WebGLState: Invalid blending: ", R); + break; + } + v = null, g = null, _ = null, y = null, m = R, b = Le; + } + return; + } + me = me || ee, Re = Re || Q, oe = oe || Ee, (ee !== x || me !== p) && (s.blendEquationSeparate(Ce[ee], Ce[me]), x = ee, p = me), (Q !== v || Ee !== g || Re !== _ || oe !== y) && (s.blendFuncSeparate(ye[Q], ye[Ee], ye[Re], ye[oe]), v = Q, g = Ee, _ = Re, y = oe), m = R, b = null; + } + function xe(R, ee) { + R.side === Ci ? fe(2884) : le(2884); + let Q = R.side === it; + ee && (Q = !Q), Oe(Q), R.blending === sr && R.transparent === !1 ? ge(vn) : ge(R.blending, R.blendEquation, R.blendSrc, R.blendDst, R.blendEquationAlpha, R.blendSrcAlpha, R.blendDstAlpha, R.premultipliedAlpha), l.setFunc(R.depthFunc), l.setTest(R.depthTest), l.setMask(R.depthWrite), a.setMask(R.colorWrite); + let Ee = R.stencilWrite; + c.setTest(Ee), Ee && (c.setMask(R.stencilWriteMask), c.setFunc(R.stencilFunc, R.stencilRef, R.stencilFuncMask), c.setOp(R.stencilFail, R.stencilZFail, R.stencilZPass)), K(R.polygonOffset, R.polygonOffsetFactor, R.polygonOffsetUnits), R.alphaToCoverage === !0 ? le(32926) : fe(32926); + } + function Oe(R) { + A !== R && (R ? s.frontFace(2304) : s.frontFace(2305), A = R); + } + function G(R) { + R !== uu ? (le(2884), R !== L && (R === tl ? s.cullFace(1029) : R === du ? s.cullFace(1028) : s.cullFace(1032))) : fe(2884), L = R; + } + function j(R) { + R !== I && (w && s.lineWidth(R), I = R); + } + function K(R, ee, Q) { + R ? (le(32823), (k !== ee || B !== Q) && (s.polygonOffset(ee, Q), k = ee, B = Q)) : fe(32823); + } + function ue(R) { + R ? le(3089) : fe(3089); + } + function se(R) { + R === void 0 && (R = 33984 + P - 1), U !== R && (s.activeTexture(R), U = R); + } + function Se(R, ee) { + U === null && se(); + let Q = F[U]; + Q === void 0 && (Q = { + type: void 0, + texture: void 0 + }, F[U] = Q), (Q.type !== R || Q.texture !== ee) && (s.bindTexture(R, ee || he[R]), Q.type = R, Q.texture = ee); + } + function Te() { + let R = F[U]; + R !== void 0 && R.type !== void 0 && (s.bindTexture(R.type, null), R.type = void 0, R.texture = void 0); + } + function Pe() { + try { + s.compressedTexImage2D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function Ye() { + try { + s.texSubImage2D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function C() { + try { + s.texSubImage3D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function T() { + try { + s.compressedTexSubImage2D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function J() { + try { + s.texStorage2D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function $() { + try { + s.texStorage3D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function re() { + try { + s.texImage2D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function Z() { + try { + s.texImage3D.apply(s, arguments); + } catch (R) { + console.error("THREE.WebGLState:", R); + } + } + function Me(R) { + ce.equals(R) === !1 && (s.scissor(R.x, R.y, R.z, R.w), ce.copy(R)); + } + function ve(R) { + V.equals(R) === !1 && (s.viewport(R.x, R.y, R.z, R.w), V.copy(R)); + } + function te() { + s.disable(3042), s.disable(2884), s.disable(2929), s.disable(32823), s.disable(3089), s.disable(2960), s.disable(32926), s.blendEquation(32774), s.blendFunc(1, 0), s.blendFuncSeparate(1, 0, 1, 0), s.colorMask(!0, !0, !0, !0), s.clearColor(0, 0, 0, 0), s.depthMask(!0), s.depthFunc(513), s.clearDepth(1), s.stencilMask(4294967295), s.stencilFunc(519, 0, 4294967295), s.stencilOp(7680, 7680, 7680), s.clearStencil(0), s.cullFace(1029), s.frontFace(2305), s.polygonOffset(0, 0), s.activeTexture(33984), s.bindFramebuffer(36160, null), n === !0 && (s.bindFramebuffer(36009, null), s.bindFramebuffer(36008, null)), s.useProgram(null), s.lineWidth(1), s.scissor(0, 0, s.canvas.width, s.canvas.height), s.viewport(0, 0, s.canvas.width, s.canvas.height), h = {}, U = null, F = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, ce.set(0, 0, s.canvas.width, s.canvas.height), V.set(0, 0, s.canvas.width, s.canvas.height), a.reset(), l.reset(), c.reset(); + } + return { + buffers: { + color: a, + depth: l, + stencil: c + }, + enable: le, + disable: fe, + bindFramebuffer: Be, + useProgram: Y, + setBlending: ge, + setMaterial: xe, + setFlipSided: Oe, + setCullFace: G, + setLineWidth: j, + setPolygonOffset: K, + setScissorTest: ue, + activeTexture: se, + bindTexture: Se, + unbindTexture: Te, + compressedTexImage2D: Pe, + texImage2D: re, + texImage3D: Z, + texStorage2D: J, + texStorage3D: $, + texSubImage2D: Ye, + texSubImage3D: C, + compressedTexSubImage2D: T, + scissor: Me, + viewport: ve, + reset: te + }; +} +function Tx(s, e, t, n, i, r, o) { + let a = i.isWebGL2, l = i.maxTextures, c = i.maxCubemapSize, h = i.maxTextureSize, u = i.maxSamples, f = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : void 0, m = new WeakMap, x, v = !1; + try { + v = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; + } catch {} + function g(C, T) { + return v ? new OffscreenCanvas(C, T) : qs("canvas"); + } + function p(C, T, J, $) { + let re = 1; + if ((C.width > $ || C.height > $) && (re = $ / Math.max(C.width, C.height)), re < 1 || T === !0) if (typeof HTMLImageElement < "u" && C instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && C instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && C instanceof ImageBitmap) { + let Z = T ? Jc : Math.floor, Me = Z(re * C.width), ve = Z(re * C.height); + x === void 0 && (x = g(Me, ve)); + let te = J ? g(Me, ve) : x; + return te.width = Me, te.height = ve, te.getContext("2d").drawImage(C, 0, 0, Me, ve), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + C.width + "x" + C.height + ") to (" + Me + "x" + ve + ")."), te; + } else return "data" in C && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + C.width + "x" + C.height + ")."), C; + return C; + } + function _(C) { + return ia(C.width) && ia(C.height); + } + function y(C) { + return a ? !1 : C.wrapS !== vt || C.wrapT !== vt || C.minFilter !== rt && C.minFilter !== tt; + } + function b(C, T) { + return C.generateMipmaps && T && C.minFilter !== rt && C.minFilter !== tt; + } + function A(C) { + s.generateMipmap(C); + } + function L(C, T, J, $) { + if (a === !1) return T; + if (C !== null) { + if (s[C] !== void 0) return s[C]; + console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + C + "'"); + } + let re = T; + return T === 6403 && (J === 5126 && (re = 33326), J === 5131 && (re = 33325), J === 5121 && (re = 33321)), T === 6407 && (J === 5126 && (re = 34837), J === 5131 && (re = 34843), J === 5121 && (re = 32849)), T === 6408 && (J === 5126 && (re = 34836), J === 5131 && (re = 34842), J === 5121 && (re = $ === Oi ? 35907 : 32856)), (re === 33325 || re === 33326 || re === 34842 || re === 34836) && e.get("EXT_color_buffer_float"), re; + } + function I(C, T, J) { + return b(C, J) === !0 || C.isFramebufferTexture && C.minFilter !== rt && C.minFilter !== tt ? Math.log2(Math.max(T.width, T.height)) + 1 : C.mipmaps !== void 0 && C.mipmaps.length > 0 ? C.mipmaps.length : C.isCompressedTexture && Array.isArray(C.image) ? T.mipmaps.length : 1; + } + function k(C) { + return C === rt || C === ta || C === na ? 9728 : 9729; + } + function B(C) { + let T = C.target; + T.removeEventListener("dispose", B), w(T), T.isVideoTexture && m.delete(T), o.memory.textures--; + } + function P(C) { + let T = C.target; + T.removeEventListener("dispose", P), E(T); + } + function w(C) { + let T = n.get(C); + T.__webglInit !== void 0 && (s.deleteTexture(T.__webglTexture), n.remove(C)); + } + function E(C) { + let T = C.texture, J = n.get(C), $ = n.get(T); + if (!!C) { + if ($.__webglTexture !== void 0 && (s.deleteTexture($.__webglTexture), o.memory.textures--), C.depthTexture && C.depthTexture.dispose(), C.isWebGLCubeRenderTarget) for(let re = 0; re < 6; re++)s.deleteFramebuffer(J.__webglFramebuffer[re]), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer[re]); + else s.deleteFramebuffer(J.__webglFramebuffer), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer), J.__webglMultisampledFramebuffer && s.deleteFramebuffer(J.__webglMultisampledFramebuffer), J.__webglColorRenderbuffer && s.deleteRenderbuffer(J.__webglColorRenderbuffer), J.__webglDepthRenderbuffer && s.deleteRenderbuffer(J.__webglDepthRenderbuffer); + if (C.isWebGLMultipleRenderTargets) for(let re = 0, Z = T.length; re < Z; re++){ + let Me = n.get(T[re]); + Me.__webglTexture && (s.deleteTexture(Me.__webglTexture), o.memory.textures--), n.remove(T[re]); + } + n.remove(T), n.remove(C); + } + } + let D = 0; + function U() { + D = 0; + } + function F() { + let C = D; + return C >= l && console.warn("THREE.WebGLTextures: Trying to use " + C + " texture units while this GPU supports only " + l), D += 1, C; + } + function O(C, T) { + let J = n.get(C); + if (C.isVideoTexture && se(C), C.version > 0 && J.__version !== C.version) { + let $ = C.image; + if ($ === void 0) console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined"); + else if ($.complete === !1) console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); + else { + Be(J, C, T); + return; + } + } + t.activeTexture(33984 + T), t.bindTexture(3553, J.__webglTexture); + } + function ne(C, T) { + let J = n.get(C); + if (C.version > 0 && J.__version !== C.version) { + Be(J, C, T); + return; + } + t.activeTexture(33984 + T), t.bindTexture(35866, J.__webglTexture); + } + function ce(C, T) { + let J = n.get(C); + if (C.version > 0 && J.__version !== C.version) { + Be(J, C, T); + return; + } + t.activeTexture(33984 + T), t.bindTexture(32879, J.__webglTexture); + } + function V(C, T) { + let J = n.get(C); + if (C.version > 0 && J.__version !== C.version) { + Y(J, C, T); + return; + } + t.activeTexture(33984 + T), t.bindTexture(34067, J.__webglTexture); + } + let W = { + [Ns]: 10497, + [vt]: 33071, + [Bs]: 33648 + }, he = { + [rt]: 9728, + [ta]: 9984, + [na]: 9986, + [tt]: 9729, + [Wc]: 9985, + [Ui]: 9987 + }; + function le(C, T, J) { + if (J ? (s.texParameteri(C, 10242, W[T.wrapS]), s.texParameteri(C, 10243, W[T.wrapT]), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, W[T.wrapR]), s.texParameteri(C, 10240, he[T.magFilter]), s.texParameteri(C, 10241, he[T.minFilter])) : (s.texParameteri(C, 10242, 33071), s.texParameteri(C, 10243, 33071), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, 33071), (T.wrapS !== vt || T.wrapT !== vt) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), s.texParameteri(C, 10240, k(T.magFilter)), s.texParameteri(C, 10241, k(T.minFilter)), T.minFilter !== rt && T.minFilter !== tt && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), e.has("EXT_texture_filter_anisotropic") === !0) { + let $ = e.get("EXT_texture_filter_anisotropic"); + if (T.type === nn && e.has("OES_texture_float_linear") === !1 || a === !1 && T.type === kn && e.has("OES_texture_half_float_linear") === !1) return; + (T.anisotropy > 1 || n.get(T).__currentAnisotropy) && (s.texParameterf(C, $.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(T.anisotropy, i.getMaxAnisotropy())), n.get(T).__currentAnisotropy = T.anisotropy); + } + } + function fe(C, T) { + C.__webglInit === void 0 && (C.__webglInit = !0, T.addEventListener("dispose", B), C.__webglTexture = s.createTexture(), o.memory.textures++); + } + function Be(C, T, J) { + let $ = 3553; + T.isDataTexture2DArray && ($ = 35866), T.isDataTexture3D && ($ = 32879), fe(C, T), t.activeTexture(33984 + J), t.bindTexture($, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); + let re = y(T) && _(T.image) === !1, Z = p(T.image, re, !1, h), Me = _(Z) || a, ve = r.convert(T.format), te = r.convert(T.type), R = L(T.internalFormat, ve, te, T.encoding); + le($, T, Me); + let ee, Q = T.mipmaps, Ee = a && T.isVideoTexture !== !0, me = C.__version === void 0, Re = I(T, Z, Me); + if (T.isDepthTexture) R = 6402, a ? T.type === nn ? R = 36012 : T.type === Ps ? R = 33190 : T.type === Ti ? R = 35056 : R = 33189 : T.type === nn && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), T.format === Vn && R === 6402 && T.type !== cr && T.type !== Ps && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), T.type = cr, te = r.convert(T.type)), T.format === Li && R === 6402 && (R = 34041, T.type !== Ti && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), T.type = Ti, te = r.convert(T.type))), Ee && me ? t.texStorage2D(3553, 1, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); + else if (T.isDataTexture) if (Q.length > 0 && Me) { + Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); + for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, 0, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); + T.generateMipmaps = !1; + } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, Z.width, Z.height, ve, te, Z.data)) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, Z.data); + else if (T.isCompressedTexture) { + Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); + for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], T.format !== ct && T.format !== Gn ? ve !== null ? Ee ? t.compressedTexSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, ee.data) : t.compressedTexImage2D(3553, oe, R, ee.width, ee.height, 0, ee.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ee ? t.texSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); + } else if (T.isDataTexture2DArray) Ee ? (me && t.texStorage3D(35866, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(35866, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(35866, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); + else if (T.isDataTexture3D) Ee ? (me && t.texStorage3D(32879, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(32879, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(32879, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); + else if (T.isFramebufferTexture) Ee && me ? t.texStorage2D(3553, Re, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); + else if (Q.length > 0 && Me) { + Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); + for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, oe, 0, 0, ve, te, ee) : t.texImage2D(3553, oe, R, ve, te, ee); + T.generateMipmaps = !1; + } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, ve, te, Z)) : t.texImage2D(3553, 0, R, ve, te, Z); + b(T, Me) && A($), C.__version = T.version, T.onUpdate && T.onUpdate(T); + } + function Y(C, T, J) { + if (T.image.length !== 6) return; + fe(C, T), t.activeTexture(33984 + J), t.bindTexture(34067, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); + let $ = T && (T.isCompressedTexture || T.image[0].isCompressedTexture), re = T.image[0] && T.image[0].isDataTexture, Z = []; + for(let oe = 0; oe < 6; oe++)!$ && !re ? Z[oe] = p(T.image[oe], !1, !0, c) : Z[oe] = re ? T.image[oe].image : T.image[oe]; + let Me = Z[0], ve = _(Me) || a, te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = a && T.isVideoTexture !== !0, Ee = C.__version === void 0, me = I(T, Me, ve); + le(34067, T, ve); + let Re; + if ($) { + Q && Ee && t.texStorage2D(34067, me, ee, Me.width, Me.height); + for(let oe = 0; oe < 6; oe++){ + Re = Z[oe].mipmaps; + for(let Le = 0; Le < Re.length; Le++){ + let Xe = Re[Le]; + T.format !== ct && T.format !== Gn ? te !== null ? Q ? t.compressedTexSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, Xe.data) : t.compressedTexImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, Xe.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Q ? t.texSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, R, Xe.data) : t.texImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, te, R, Xe.data); + } + } + } else { + Re = T.mipmaps, Q && Ee && (Re.length > 0 && me++, t.texStorage2D(34067, me, ee, Z[0].width, Z[0].height)); + for(let oe = 0; oe < 6; oe++)if (re) { + Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, Z[oe].width, Z[oe].height, te, R, Z[oe].data) : t.texImage2D(34069 + oe, 0, ee, Z[oe].width, Z[oe].height, 0, te, R, Z[oe].data); + for(let Le = 0; Le < Re.length; Le++){ + let We = Re[Le].image[oe].image; + Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, We.width, We.height, te, R, We.data) : t.texImage2D(34069 + oe, Le + 1, ee, We.width, We.height, 0, te, R, We.data); + } + } else { + Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, te, R, Z[oe]) : t.texImage2D(34069 + oe, 0, ee, te, R, Z[oe]); + for(let Le = 0; Le < Re.length; Le++){ + let Xe = Re[Le]; + Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, te, R, Xe.image[oe]) : t.texImage2D(34069 + oe, Le + 1, ee, te, R, Xe.image[oe]); + } + } + } + b(T, ve) && A(34067), C.__version = T.version, T.onUpdate && T.onUpdate(T); + } + function Ce(C, T, J, $, re) { + let Z = r.convert(J.format), Me = r.convert(J.type), ve = L(J.internalFormat, Z, Me, J.encoding); + n.get(T).__hasExternalTextures || (re === 32879 || re === 35866 ? t.texImage3D(re, 0, ve, T.width, T.height, T.depth, 0, Z, Me, null) : t.texImage2D(re, 0, ve, T.width, T.height, 0, Z, Me, null)), t.bindFramebuffer(36160, C), T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, $, re, n.get(J).__webglTexture, 0, ue(T)) : s.framebufferTexture2D(36160, $, re, n.get(J).__webglTexture, 0), t.bindFramebuffer(36160, null); + } + function ye(C, T, J) { + if (s.bindRenderbuffer(36161, C), T.depthBuffer && !T.stencilBuffer) { + let $ = 33189; + if (J || T.useRenderToTexture) { + let re = T.depthTexture; + re && re.isDepthTexture && (re.type === nn ? $ = 36012 : re.type === Ps && ($ = 33190)); + let Z = ue(T); + T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, Z, $, T.width, T.height) : s.renderbufferStorageMultisample(36161, Z, $, T.width, T.height); + } else s.renderbufferStorage(36161, $, T.width, T.height); + s.framebufferRenderbuffer(36160, 36096, 36161, C); + } else if (T.depthBuffer && T.stencilBuffer) { + let $ = ue(T); + J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, $, 35056, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, $, 35056, T.width, T.height) : s.renderbufferStorage(36161, 34041, T.width, T.height), s.framebufferRenderbuffer(36160, 33306, 36161, C); + } else { + let $ = T.isWebGLMultipleRenderTargets === !0 ? T.texture[0] : T.texture, re = r.convert($.format), Z = r.convert($.type), Me = L($.internalFormat, re, Z, $.encoding), ve = ue(T); + J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, ve, Me, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, ve, Me, T.width, T.height) : s.renderbufferStorage(36161, Me, T.width, T.height); + } + s.bindRenderbuffer(36161, null); + } + function ge(C, T) { + if (T && T.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported"); + if (t.bindFramebuffer(36160, C), !(T.depthTexture && T.depthTexture.isDepthTexture)) throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); + (!n.get(T.depthTexture).__webglTexture || T.depthTexture.image.width !== T.width || T.depthTexture.image.height !== T.height) && (T.depthTexture.image.width = T.width, T.depthTexture.image.height = T.height, T.depthTexture.needsUpdate = !0), O(T.depthTexture, 0); + let $ = n.get(T.depthTexture).__webglTexture, re = ue(T); + if (T.depthTexture.format === Vn) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 36096, 3553, $, 0, re) : s.framebufferTexture2D(36160, 36096, 3553, $, 0); + else if (T.depthTexture.format === Li) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 33306, 3553, $, 0, re) : s.framebufferTexture2D(36160, 33306, 3553, $, 0); + else throw new Error("Unknown depthTexture format"); + } + function xe(C) { + let T = n.get(C), J = C.isWebGLCubeRenderTarget === !0; + if (C.depthTexture && !T.__autoAllocateDepthBuffer) { + if (J) throw new Error("target.depthTexture not supported in Cube render targets"); + ge(T.__webglFramebuffer, C); + } else if (J) { + T.__webglDepthbuffer = []; + for(let $ = 0; $ < 6; $++)t.bindFramebuffer(36160, T.__webglFramebuffer[$]), T.__webglDepthbuffer[$] = s.createRenderbuffer(), ye(T.__webglDepthbuffer[$], C, !1); + } else t.bindFramebuffer(36160, T.__webglFramebuffer), T.__webglDepthbuffer = s.createRenderbuffer(), ye(T.__webglDepthbuffer, C, !1); + t.bindFramebuffer(36160, null); + } + function Oe(C, T, J) { + let $ = n.get(C); + T !== void 0 && Ce($.__webglFramebuffer, C, C.texture, 36064, 3553), J !== void 0 && xe(C); + } + function G(C) { + let T = C.texture, J = n.get(C), $ = n.get(T); + C.addEventListener("dispose", P), C.isWebGLMultipleRenderTargets !== !0 && ($.__webglTexture === void 0 && ($.__webglTexture = s.createTexture()), $.__version = T.version, o.memory.textures++); + let re = C.isWebGLCubeRenderTarget === !0, Z = C.isWebGLMultipleRenderTargets === !0, Me = T.isDataTexture3D || T.isDataTexture2DArray, ve = _(C) || a; + if (a && T.format === Gn && (T.type === nn || T.type === kn) && (T.format = ct, console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")), re) { + J.__webglFramebuffer = []; + for(let te = 0; te < 6; te++)J.__webglFramebuffer[te] = s.createFramebuffer(); + } else if (J.__webglFramebuffer = s.createFramebuffer(), Z) if (i.drawBuffers) { + let te = C.texture; + for(let R = 0, ee = te.length; R < ee; R++){ + let Q = n.get(te[R]); + Q.__webglTexture === void 0 && (Q.__webglTexture = s.createTexture(), o.memory.textures++); + } + } else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension."); + else if (C.useRenderbuffer) if (a) { + J.__webglMultisampledFramebuffer = s.createFramebuffer(), J.__webglColorRenderbuffer = s.createRenderbuffer(), s.bindRenderbuffer(36161, J.__webglColorRenderbuffer); + let te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = ue(C); + s.renderbufferStorageMultisample(36161, Q, ee, C.width, C.height), t.bindFramebuffer(36160, J.__webglMultisampledFramebuffer), s.framebufferRenderbuffer(36160, 36064, 36161, J.__webglColorRenderbuffer), s.bindRenderbuffer(36161, null), C.depthBuffer && (J.__webglDepthRenderbuffer = s.createRenderbuffer(), ye(J.__webglDepthRenderbuffer, C, !0)), t.bindFramebuffer(36160, null); + } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); + if (re) { + t.bindTexture(34067, $.__webglTexture), le(34067, T, ve); + for(let te = 0; te < 6; te++)Ce(J.__webglFramebuffer[te], C, T, 36064, 34069 + te); + b(T, ve) && A(34067), t.unbindTexture(); + } else if (Z) { + let te = C.texture; + for(let R = 0, ee = te.length; R < ee; R++){ + let Q = te[R], Ee = n.get(Q); + t.bindTexture(3553, Ee.__webglTexture), le(3553, Q, ve), Ce(J.__webglFramebuffer, C, Q, 36064 + R, 3553), b(Q, ve) && A(3553); + } + t.unbindTexture(); + } else { + let te = 3553; + Me && (a ? te = T.isDataTexture3D ? 32879 : 35866 : console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")), t.bindTexture(te, $.__webglTexture), le(te, T, ve), Ce(J.__webglFramebuffer, C, T, 36064, te), b(T, ve) && A(te), t.unbindTexture(); + } + C.depthBuffer && xe(C); + } + function j(C) { + let T = _(C) || a, J = C.isWebGLMultipleRenderTargets === !0 ? C.texture : [ + C.texture + ]; + for(let $ = 0, re = J.length; $ < re; $++){ + let Z = J[$]; + if (b(Z, T)) { + let Me = C.isWebGLCubeRenderTarget ? 34067 : 3553, ve = n.get(Z).__webglTexture; + t.bindTexture(Me, ve), A(Me), t.unbindTexture(); + } + } + } + function K(C) { + if (C.useRenderbuffer) if (a) { + let T = C.width, J = C.height, $ = 16384, re = [ + 36064 + ], Z = C.stencilBuffer ? 33306 : 36096; + C.depthBuffer && re.push(Z), C.ignoreDepthForMultisampleCopy || (C.depthBuffer && ($ |= 256), C.stencilBuffer && ($ |= 1024)); + let Me = n.get(C); + t.bindFramebuffer(36008, Me.__webglMultisampledFramebuffer), t.bindFramebuffer(36009, Me.__webglFramebuffer), C.ignoreDepthForMultisampleCopy && (s.invalidateFramebuffer(36008, [ + Z + ]), s.invalidateFramebuffer(36009, [ + Z + ])), s.blitFramebuffer(0, 0, T, J, 0, 0, T, J, $, 9728), s.invalidateFramebuffer(36008, re), t.bindFramebuffer(36008, null), t.bindFramebuffer(36009, Me.__webglMultisampledFramebuffer); + } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); + } + function ue(C) { + return a && (C.useRenderbuffer || C.useRenderToTexture) ? Math.min(u, C.samples) : 0; + } + function se(C) { + let T = o.render.frame; + m.get(C) !== T && (m.set(C, T), C.update()); + } + let Se = !1, Te = !1; + function Pe(C, T) { + C && C.isWebGLRenderTarget && (Se === !1 && (console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."), Se = !0), C = C.texture), O(C, T); + } + function Ye(C, T) { + C && C.isWebGLCubeRenderTarget && (Te === !1 && (console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."), Te = !0), C = C.texture), V(C, T); + } + this.allocateTextureUnit = F, this.resetTextureUnits = U, this.setTexture2D = O, this.setTexture2DArray = ne, this.setTexture3D = ce, this.setTextureCube = V, this.rebindTextures = Oe, this.setupRenderTarget = G, this.updateRenderTargetMipmap = j, this.updateMultisampleRenderTarget = K, this.setupDepthRenderbuffer = xe, this.setupFrameBufferTexture = Ce, this.safeSetTexture2D = Pe, this.safeSetTextureCube = Ye; +} +function Ex(s, e, t) { + let n = t.isWebGL2; + function i(r) { + let o; + if (r === rn) return 5121; + if (r === Vu) return 32819; + if (r === Wu) return 32820; + if (r === qu) return 33635; + if (r === Hu) return 5120; + if (r === ku) return 5122; + if (r === cr) return 5123; + if (r === Gu) return 5124; + if (r === Ps) return 5125; + if (r === nn) return 5126; + if (r === kn) return n ? 5131 : (o = e.get("OES_texture_half_float"), o !== null ? o.HALF_FLOAT_OES : null); + if (r === Xu) return 6406; + if (r === Gn) return 6407; + if (r === ct) return 6408; + if (r === Ju) return 6409; + if (r === Yu) return 6410; + if (r === Vn) return 6402; + if (r === Li) return 34041; + if (r === Zu) return 6403; + if (r === $u) return 36244; + if (r === ju) return 33319; + if (r === Qu) return 33320; + if (r === Ku) return 36248; + if (r === ed) return 36249; + if (r === al || r === ll || r === cl || r === hl) if (o = e.get("WEBGL_compressed_texture_s3tc"), o !== null) { + if (r === al) return o.COMPRESSED_RGB_S3TC_DXT1_EXT; + if (r === ll) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if (r === cl) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if (r === hl) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; + } else return null; + if (r === ul || r === dl || r === fl || r === pl) if (o = e.get("WEBGL_compressed_texture_pvrtc"), o !== null) { + if (r === ul) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if (r === dl) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if (r === fl) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if (r === pl) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + } else return null; + if (r === td) return o = e.get("WEBGL_compressed_texture_etc1"), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; + if ((r === ml || r === gl) && (o = e.get("WEBGL_compressed_texture_etc"), o !== null)) { + if (r === ml) return o.COMPRESSED_RGB8_ETC2; + if (r === gl) return o.COMPRESSED_RGBA8_ETC2_EAC; + } + if (r === nd || r === id || r === rd || r === sd || r === od || r === ad || r === ld || r === cd || r === hd || r === ud || r === dd || r === fd || r === pd || r === md || r === xd || r === yd || r === vd || r === _d || r === Md || r === bd || r === wd || r === Sd || r === Td || r === Ed || r === Ad || r === Cd || r === Ld || r === Rd) return o = e.get("WEBGL_compressed_texture_astc"), o !== null ? r : null; + if (r === gd) return o = e.get("EXT_texture_compression_bptc"), o !== null ? r : null; + if (r === Ti) return n ? 34042 : (o = e.get("WEBGL_depth_texture"), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null); + } + return { + convert: i + }; +} +var ga = class extends ut { + constructor(e = []){ + super(); + this.cameras = e; + } +}; +ga.prototype.isArrayCamera = !0; +var Hn = class extends Ne { + constructor(){ + super(); + this.type = "Group"; + } +}; +Hn.prototype.isGroup = !0; +var Ax = { + type: "move" +}, Is = class { + constructor(){ + this._targetRay = null, this._grip = null, this._hand = null; + } + getHandSpace() { + return this._hand === null && (this._hand = new Hn, this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { + pinching: !1 + }), this._hand; + } + getTargetRaySpace() { + return this._targetRay === null && (this._targetRay = new Hn, this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new M, this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new M), this._targetRay; + } + getGripSpace() { + return this._grip === null && (this._grip = new Hn, this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new M, this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new M), this._grip; + } + dispatchEvent(e) { + return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this; + } + disconnect(e) { + return this.dispatchEvent({ + type: "disconnected", + data: e + }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this; + } + update(e, t, n) { + let i = null, r = null, o = null, a = this._targetRay, l = this._grip, c = this._hand; + if (e && t.session.visibilityState !== "visible-blurred") if (a !== null && (i = t.getPose(e.targetRaySpace, n), i !== null && (a.matrix.fromArray(i.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), i.linearVelocity ? (a.hasLinearVelocity = !0, a.linearVelocity.copy(i.linearVelocity)) : a.hasLinearVelocity = !1, i.angularVelocity ? (a.hasAngularVelocity = !0, a.angularVelocity.copy(i.angularVelocity)) : a.hasAngularVelocity = !1, this.dispatchEvent(Ax))), c && e.hand) { + o = !0; + for (let x of e.hand.values()){ + let v = t.getJointPose(x, n); + if (c.joints[x.jointName] === void 0) { + let p = new Hn; + p.matrixAutoUpdate = !1, p.visible = !1, c.joints[x.jointName] = p, c.add(p); + } + let g = c.joints[x.jointName]; + v !== null && (g.matrix.fromArray(v.transform.matrix), g.matrix.decompose(g.position, g.rotation, g.scale), g.jointRadius = v.radius), g.visible = v !== null; + } + let h = c.joints["index-finger-tip"], u = c.joints["thumb-tip"], d = h.position.distanceTo(u.position), f = .02, m = .005; + c.inputState.pinching && d > f + m ? (c.inputState.pinching = !1, this.dispatchEvent({ + type: "pinchend", + handedness: e.handedness, + target: this + })) : !c.inputState.pinching && d <= f - m && (c.inputState.pinching = !0, this.dispatchEvent({ + type: "pinchstart", + handedness: e.handedness, + target: this + })); + } else l !== null && e.gripSpace && (r = t.getPose(e.gripSpace, n), r !== null && (l.matrix.fromArray(r.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), 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)); + return a !== null && (a.visible = i !== null), l !== null && (l.visible = r !== null), c !== null && (c.visible = o !== null), this; + } +}, ks = class extends ot { + constructor(e, t, n, i, r, o, a, l, c, h){ + if (h = h !== void 0 ? h : Vn, h !== Vn && h !== Li) throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); + n === void 0 && h === Vn && (n = cr), n === void 0 && h === Li && (n = Ti); + super(null, i, r, o, a, l, h, n, c); + this.image = { + width: e, + height: t + }, this.magFilter = a !== void 0 ? a : rt, this.minFilter = l !== void 0 ? l : rt, this.flipY = !1, this.generateMipmaps = !1; + } +}; +ks.prototype.isDepthTexture = !0; +var vh = class extends En { + constructor(e, t){ + super(); + let n = this, i = null, r = 1, o = null, a = "local-floor", l = e.extensions.has("WEBGL_multisampled_render_to_texture"), c = null, h = null, u = null, d = null, f = !1, m = null, x = t.getContextAttributes(), v = null, g = null, p = [], _ = new Map, y = new ut; + y.layers.enable(1), y.viewport = new Ve; + let b = new ut; + b.layers.enable(2), b.viewport = new Ve; + let A = [ + y, + b + ], L = new ga; + L.layers.enable(1), L.layers.enable(2); + let I = null, k = null; + this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(V) { + let W = p[V]; + return W === void 0 && (W = new Is, p[V] = W), W.getTargetRaySpace(); + }, this.getControllerGrip = function(V) { + let W = p[V]; + return W === void 0 && (W = new Is, p[V] = W), W.getGripSpace(); + }, this.getHand = function(V) { + let W = p[V]; + return W === void 0 && (W = new Is, p[V] = W), W.getHandSpace(); + }; + function B(V) { + let W = _.get(V.inputSource); + W && W.dispatchEvent({ + type: V.type, + data: V.inputSource + }); + } + function P() { + _.forEach(function(V, W) { + V.disconnect(W); + }), _.clear(), I = null, k = null, e.setRenderTarget(v), d = null, u = null, h = null, i = null, g = null, ce.stop(), n.isPresenting = !1, n.dispatchEvent({ + type: "sessionend" + }); + } + this.setFramebufferScaleFactor = function(V) { + r = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); + }, this.setReferenceSpaceType = function(V) { + a = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); + }, this.getReferenceSpace = function() { + return o; + }, this.getBaseLayer = function() { + return u !== null ? u : d; + }, this.getBinding = function() { + return h; + }, this.getFrame = function() { + return m; + }, this.getSession = function() { + return i; + }, this.setSession = async function(V) { + if (i = V, i !== null) { + if (v = e.getRenderTarget(), i.addEventListener("select", B), i.addEventListener("selectstart", B), i.addEventListener("selectend", B), i.addEventListener("squeeze", B), i.addEventListener("squeezestart", B), i.addEventListener("squeezeend", B), i.addEventListener("end", P), i.addEventListener("inputsourceschange", w), x.xrCompatible !== !0 && await t.makeXRCompatible(), i.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) { + let W = { + antialias: i.renderState.layers === void 0 ? x.antialias : !0, + alpha: x.alpha, + depth: x.depth, + stencil: x.stencil, + framebufferScaleFactor: r + }; + d = new XRWebGLLayer(i, t, W), i.updateRenderState({ + baseLayer: d + }), g = new At(d.framebufferWidth, d.framebufferHeight, { + format: ct, + type: rn, + encoding: e.outputEncoding + }); + } else { + f = x.antialias; + let W = null, he = null, le = null; + x.depth && (le = x.stencil ? 35056 : 33190, W = x.stencil ? Li : Vn, he = x.stencil ? Ti : cr); + let fe = { + colorFormat: x.alpha || f ? 32856 : 32849, + depthFormat: le, + scaleFactor: r + }; + h = new XRWebGLBinding(i, t), u = h.createProjectionLayer(fe), i.updateRenderState({ + layers: [ + u + ] + }), f ? g = new Xs(u.textureWidth, u.textureHeight, { + format: ct, + type: rn, + depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), + stencilBuffer: x.stencil, + ignoreDepth: u.ignoreDepthValues, + useRenderToTexture: l, + encoding: e.outputEncoding + }) : g = new At(u.textureWidth, u.textureHeight, { + format: x.alpha ? ct : Gn, + type: rn, + depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), + stencilBuffer: x.stencil, + ignoreDepth: u.ignoreDepthValues, + encoding: e.outputEncoding + }); + } + this.setFoveation(1), o = await i.requestReferenceSpace(a), ce.setContext(i), ce.start(), n.isPresenting = !0, n.dispatchEvent({ + type: "sessionstart" + }); + } + }; + function w(V) { + let W = i.inputSources; + for(let he = 0; he < p.length; he++)_.set(W[he], p[he]); + for(let he = 0; he < V.removed.length; he++){ + let le = V.removed[he], fe = _.get(le); + fe && (fe.dispatchEvent({ + type: "disconnected", + data: le + }), _.delete(le)); + } + for(let he = 0; he < V.added.length; he++){ + let le = V.added[he], fe = _.get(le); + fe && fe.dispatchEvent({ + type: "connected", + data: le + }); + } + } + let E = new M, D = new M; + function U(V, W, he) { + E.setFromMatrixPosition(W.matrixWorld), D.setFromMatrixPosition(he.matrixWorld); + let le = E.distanceTo(D), fe = W.projectionMatrix.elements, Be = he.projectionMatrix.elements, Y = fe[14] / (fe[10] - 1), Ce = fe[14] / (fe[10] + 1), ye = (fe[9] + 1) / fe[5], ge = (fe[9] - 1) / fe[5], xe = (fe[8] - 1) / fe[0], Oe = (Be[8] + 1) / Be[0], G = Y * xe, j = Y * Oe, K = le / (-xe + Oe), ue = K * -xe; + W.matrixWorld.decompose(V.position, V.quaternion, V.scale), V.translateX(ue), V.translateZ(K), V.matrixWorld.compose(V.position, V.quaternion, V.scale), V.matrixWorldInverse.copy(V.matrixWorld).invert(); + let se = Y + K, Se = Ce + K, Te = G - ue, Pe = j + (le - ue), Ye = ye * Ce / Se * se, C = ge * Ce / Se * se; + V.projectionMatrix.makePerspective(Te, Pe, Ye, C, se, Se); + } + function F(V, W) { + W === null ? V.matrixWorld.copy(V.matrix) : V.matrixWorld.multiplyMatrices(W.matrixWorld, V.matrix), V.matrixWorldInverse.copy(V.matrixWorld).invert(); + } + this.updateCamera = function(V) { + if (i === null) return; + L.near = b.near = y.near = V.near, L.far = b.far = y.far = V.far, (I !== L.near || k !== L.far) && (i.updateRenderState({ + depthNear: L.near, + depthFar: L.far + }), I = L.near, k = L.far); + let W = V.parent, he = L.cameras; + F(L, W); + for(let fe = 0; fe < he.length; fe++)F(he[fe], W); + L.matrixWorld.decompose(L.position, L.quaternion, L.scale), V.position.copy(L.position), V.quaternion.copy(L.quaternion), V.scale.copy(L.scale), V.matrix.copy(L.matrix), V.matrixWorld.copy(L.matrixWorld); + let le = V.children; + for(let fe = 0, Be = le.length; fe < Be; fe++)le[fe].updateMatrixWorld(!0); + he.length === 2 ? U(L, y, b) : L.projectionMatrix.copy(y.projectionMatrix); + }, this.getCamera = function() { + return L; + }, this.getFoveation = function() { + if (u !== null) return u.fixedFoveation; + if (d !== null) return d.fixedFoveation; + }, this.setFoveation = function(V) { + u !== null && (u.fixedFoveation = V), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = V); + }; + let O = null; + function ne(V, W) { + if (c = W.getViewerPose(o), m = W, c !== null) { + let le = c.views; + d !== null && (e.setRenderTargetFramebuffer(g, d.framebuffer), e.setRenderTarget(g)); + let fe = !1; + le.length !== L.cameras.length && (L.cameras.length = 0, fe = !0); + for(let Be = 0; Be < le.length; Be++){ + let Y = le[Be], Ce = null; + if (d !== null) Ce = d.getViewport(Y); + else { + let ge = h.getViewSubImage(u, Y); + Ce = ge.viewport, Be === 0 && (e.setRenderTargetTextures(g, ge.colorTexture, u.ignoreDepthValues ? void 0 : ge.depthStencilTexture), e.setRenderTarget(g)); + } + let ye = A[Be]; + ye.matrix.fromArray(Y.transform.matrix), ye.projectionMatrix.fromArray(Y.projectionMatrix), ye.viewport.set(Ce.x, Ce.y, Ce.width, Ce.height), Be === 0 && L.matrix.copy(ye.matrix), fe === !0 && L.cameras.push(ye); + } + } + let he = i.inputSources; + for(let le = 0; le < p.length; le++){ + let fe = p[le], Be = he[le]; + fe.update(Be, W, o); + } + O && O(V, W), m = null; + } + let ce = new rh; + ce.setAnimationLoop(ne), this.setAnimationLoop = function(V) { + O = V; + }, this.dispose = function() {}; + } +}; +function Cx(s) { + function e(g, p) { + g.fogColor.value.copy(p.color), p.isFog ? (g.fogNear.value = p.near, g.fogFar.value = p.far) : p.isFogExp2 && (g.fogDensity.value = p.density); + } + function t(g, p, _, y, b) { + p.isMeshBasicMaterial ? n(g, p) : p.isMeshLambertMaterial ? (n(g, p), l(g, p)) : p.isMeshToonMaterial ? (n(g, p), h(g, p)) : p.isMeshPhongMaterial ? (n(g, p), c(g, p)) : p.isMeshStandardMaterial ? (n(g, p), p.isMeshPhysicalMaterial ? d(g, p, b) : u(g, p)) : p.isMeshMatcapMaterial ? (n(g, p), f(g, p)) : p.isMeshDepthMaterial ? (n(g, p), m(g, p)) : p.isMeshDistanceMaterial ? (n(g, p), x(g, p)) : p.isMeshNormalMaterial ? (n(g, p), v(g, p)) : p.isLineBasicMaterial ? (i(g, p), p.isLineDashedMaterial && r(g, p)) : p.isPointsMaterial ? o(g, p, _, y) : p.isSpriteMaterial ? a(g, p) : p.isShadowMaterial ? (g.color.value.copy(p.color), g.opacity.value = p.opacity) : p.isShaderMaterial && (p.uniformsNeedUpdate = !1); + } + function n(g, p) { + g.opacity.value = p.opacity, p.color && g.diffuse.value.copy(p.color), p.emissive && g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity), p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.specularMap && (g.specularMap.value = p.specularMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); + let _ = s.get(p).envMap; + _ && (g.envMap.value = _, g.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, 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), p.aoMap && (g.aoMap.value = p.aoMap, g.aoMapIntensity.value = p.aoMapIntensity); + let y; + p.map ? y = p.map : p.specularMap ? y = p.specularMap : p.displacementMap ? y = p.displacementMap : p.normalMap ? y = p.normalMap : p.bumpMap ? y = p.bumpMap : p.roughnessMap ? y = p.roughnessMap : p.metalnessMap ? y = p.metalnessMap : p.alphaMap ? y = p.alphaMap : p.emissiveMap ? y = p.emissiveMap : p.clearcoatMap ? y = p.clearcoatMap : p.clearcoatNormalMap ? y = p.clearcoatNormalMap : p.clearcoatRoughnessMap ? y = p.clearcoatRoughnessMap : p.specularIntensityMap ? y = p.specularIntensityMap : p.specularColorMap ? y = p.specularColorMap : p.transmissionMap ? y = p.transmissionMap : p.thicknessMap ? y = p.thicknessMap : p.sheenColorMap ? y = p.sheenColorMap : p.sheenRoughnessMap && (y = p.sheenRoughnessMap), y !== void 0 && (y.isWebGLRenderTarget && (y = y.texture), y.matrixAutoUpdate === !0 && y.updateMatrix(), g.uvTransform.value.copy(y.matrix)); + let b; + p.aoMap ? b = p.aoMap : p.lightMap && (b = p.lightMap), b !== void 0 && (b.isWebGLRenderTarget && (b = b.texture), b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uv2Transform.value.copy(b.matrix)); + } + function i(g, p) { + g.diffuse.value.copy(p.color), g.opacity.value = p.opacity; + } + function r(g, p) { + g.dashSize.value = p.dashSize, g.totalSize.value = p.dashSize + p.gapSize, g.scale.value = p.scale; + } + function o(g, p, _, y) { + g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.size.value = p.size * _, g.scale.value = y * .5, p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); + let b; + p.map ? b = p.map : p.alphaMap && (b = p.alphaMap), b !== void 0 && (b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uvTransform.value.copy(b.matrix)); + } + function a(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), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); + let _; + p.map ? _ = p.map : p.alphaMap && (_ = p.alphaMap), _ !== void 0 && (_.matrixAutoUpdate === !0 && _.updateMatrix(), g.uvTransform.value.copy(_.matrix)); + } + function l(g, p) { + p.emissiveMap && (g.emissiveMap.value = p.emissiveMap); + } + function c(g, p) { + g.specular.value.copy(p.specular), g.shininess.value = Math.max(p.shininess, 1e-4), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + } + function h(g, p) { + p.gradientMap && (g.gradientMap.value = p.gradientMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + } + function u(g, p) { + g.roughness.value = p.roughness, g.metalness.value = p.metalness, p.roughnessMap && (g.roughnessMap.value = p.roughnessMap), p.metalnessMap && (g.metalnessMap.value = p.metalnessMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), s.get(p).envMap && (g.envMapIntensity.value = p.envMapIntensity); + } + function d(g, p, _) { + u(g, p), 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), p.sheenRoughnessMap && (g.sheenRoughnessMap.value = p.sheenRoughnessMap)), p.clearcoat > 0 && (g.clearcoat.value = p.clearcoat, g.clearcoatRoughness.value = p.clearcoatRoughness, p.clearcoatMap && (g.clearcoatMap.value = p.clearcoatMap), p.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = p.clearcoatRoughnessMap), p.clearcoatNormalMap && (g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale), g.clearcoatNormalMap.value = p.clearcoatNormalMap, p.side === it && g.clearcoatNormalScale.value.negate())), p.transmission > 0 && (g.transmission.value = p.transmission, g.transmissionSamplerMap.value = _.texture, g.transmissionSamplerSize.value.set(_.width, _.height), p.transmissionMap && (g.transmissionMap.value = p.transmissionMap), g.thickness.value = p.thickness, p.thicknessMap && (g.thicknessMap.value = p.thicknessMap), g.attenuationDistance.value = p.attenuationDistance, g.attenuationColor.value.copy(p.attenuationColor)), g.specularIntensity.value = p.specularIntensity, g.specularColor.value.copy(p.specularColor), p.specularIntensityMap && (g.specularIntensityMap.value = p.specularIntensityMap), p.specularColorMap && (g.specularColorMap.value = p.specularColorMap); + } + function f(g, p) { + p.matcap && (g.matcap.value = p.matcap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + } + function m(g, p) { + p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + } + function x(g, p) { + p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), g.referencePosition.value.copy(p.referencePosition), g.nearDistance.value = p.nearDistance, g.farDistance.value = p.farDistance; + } + function v(g, p) { + p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + } + return { + refreshFogUniforms: e, + refreshMaterialUniforms: t + }; +} +function Lx() { + let s = qs("canvas"); + return s.style.display = "block", s; +} +function qe(s = {}) { + let e = s.canvas !== void 0 ? s.canvas : Lx(), t = s.context !== void 0 ? s.context : null, n = s.alpha !== void 0 ? s.alpha : !1, i = s.depth !== void 0 ? s.depth : !0, r = s.stencil !== void 0 ? s.stencil : !0, o = s.antialias !== void 0 ? s.antialias : !1, a = s.premultipliedAlpha !== void 0 ? s.premultipliedAlpha : !0, l = s.preserveDrawingBuffer !== void 0 ? s.preserveDrawingBuffer : !1, c = s.powerPreference !== void 0 ? s.powerPreference : "default", h = s.failIfMajorPerformanceCaveat !== void 0 ? s.failIfMajorPerformanceCaveat : !1, u = null, d = null, f = [], m = []; + this.domElement = e, this.debug = { + checkShaderErrors: !0 + }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.outputEncoding = Nt, this.physicallyCorrectLights = !1, this.toneMapping = _n, this.toneMappingExposure = 1; + let x = this, v = !1, g = 0, p = 0, _ = null, y = -1, b = null, A = new Ve, L = new Ve, I = null, k = e.width, B = e.height, P = 1, w = null, E = null, D = new Ve(0, 0, k, B), U = new Ve(0, 0, k, B), F = !1, O = [], ne = new Dr, ce = !1, V = !1, W = null, he = new pe, le = new M, fe = { + background: null, + fog: null, + environment: null, + overrideMaterial: null, + isScene: !0 + }; + function Be() { + return _ === null ? P : 1; + } + let Y = t; + function Ce(S, N) { + for(let H = 0; H < S.length; H++){ + let z = S[H], q = e.getContext(z, N); + if (q !== null) return q; + } + return null; + } + try { + let S = { + alpha: n, + depth: i, + stencil: r, + antialias: o, + premultipliedAlpha: a, + preserveDrawingBuffer: l, + powerPreference: c, + failIfMajorPerformanceCaveat: h + }; + if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${ca}`), e.addEventListener("webglcontextlost", Ee, !1), e.addEventListener("webglcontextrestored", me, !1), Y === null) { + let N = [ + "webgl2", + "webgl", + "experimental-webgl" + ]; + if (x.isWebGL1Renderer === !0 && N.shift(), Y = Ce(N, S), Y === null) throw Ce(N) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); + } + Y.getShaderPrecisionFormat === void 0 && (Y.getShaderPrecisionFormat = function() { + return { + rangeMin: 1, + rangeMax: 1, + precision: 1 + }; + }); + } catch (S) { + throw console.error("THREE.WebGLRenderer: " + S.message), S; + } + let ye, ge, xe, Oe, G, j, K, ue, se, Se, Te, Pe, Ye, C, T, J, $, re, Z, Me, ve, te, R; + function ee() { + ye = new Qm(Y), ge = new Xm(Y, ye, s), ye.init(ge), te = new Ex(Y, ye, ge), xe = new Sx(Y, ye, ge), O[0] = 1029, Oe = new tg(Y), G = new fx, j = new Tx(Y, ye, xe, G, ge, te, Oe), K = new Ym(x), ue = new jm(x), se = new gf(Y, ge), R = new Wm(Y, ye, se, ge), Se = new Km(Y, se, Oe, R), Te = new sg(Y, Se, se, Oe), Z = new rg(Y, ge, j), J = new Jm(G), Pe = new dx(x, K, ue, ye, ge, R, J), Ye = new Cx(G), C = new mx, T = new Mx(ye, ge), re = new Vm(x, K, xe, Te, a), $ = new yh(x, Te, ge), Me = new qm(Y, ye, Oe, ge), ve = new eg(Y, ye, Oe, ge), Oe.programs = Pe.programs, x.capabilities = ge, x.extensions = ye, x.properties = G, x.renderLists = C, x.shadowMap = $, x.state = xe, x.info = Oe; + } + ee(); + let Q = new vh(x, Y); + this.xr = Q, this.getContext = function() { + return Y; + }, this.getContextAttributes = function() { + return Y.getContextAttributes(); + }, this.forceContextLoss = function() { + let S = ye.get("WEBGL_lose_context"); + S && S.loseContext(); + }, this.forceContextRestore = function() { + let S = ye.get("WEBGL_lose_context"); + S && S.restoreContext(); + }, this.getPixelRatio = function() { + return P; + }, this.setPixelRatio = function(S) { + S !== void 0 && (P = S, this.setSize(k, B, !1)); + }, this.getSize = function(S) { + return S.set(k, B); + }, this.setSize = function(S, N, H) { + if (Q.isPresenting) { + console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); + return; + } + k = S, B = N, e.width = Math.floor(S * P), e.height = Math.floor(N * P), H !== !1 && (e.style.width = S + "px", e.style.height = N + "px"), this.setViewport(0, 0, S, N); + }, this.getDrawingBufferSize = function(S) { + return S.set(k * P, B * P).floor(); + }, this.setDrawingBufferSize = function(S, N, H) { + k = S, B = N, P = H, e.width = Math.floor(S * H), e.height = Math.floor(N * H), this.setViewport(0, 0, S, N); + }, this.getCurrentViewport = function(S) { + return S.copy(A); + }, this.getViewport = function(S) { + return S.copy(D); + }, this.setViewport = function(S, N, H, z) { + S.isVector4 ? D.set(S.x, S.y, S.z, S.w) : D.set(S, N, H, z), xe.viewport(A.copy(D).multiplyScalar(P).floor()); + }, this.getScissor = function(S) { + return S.copy(U); + }, this.setScissor = function(S, N, H, z) { + S.isVector4 ? U.set(S.x, S.y, S.z, S.w) : U.set(S, N, H, z), xe.scissor(L.copy(U).multiplyScalar(P).floor()); + }, this.getScissorTest = function() { + return F; + }, this.setScissorTest = function(S) { + xe.setScissorTest(F = S); + }, this.setOpaqueSort = function(S) { + w = S; + }, this.setTransparentSort = function(S) { + E = S; + }, this.getClearColor = function(S) { + return S.copy(re.getClearColor()); + }, this.setClearColor = function() { + re.setClearColor.apply(re, arguments); + }, this.getClearAlpha = function() { + return re.getClearAlpha(); + }, this.setClearAlpha = function() { + re.setClearAlpha.apply(re, arguments); + }, this.clear = function(S, N, H) { + let z = 0; + (S === void 0 || S) && (z |= 16384), (N === void 0 || N) && (z |= 256), (H === void 0 || H) && (z |= 1024), Y.clear(z); + }, this.clearColor = function() { + this.clear(!0, !1, !1); + }, this.clearDepth = function() { + this.clear(!1, !0, !1); + }, this.clearStencil = function() { + this.clear(!1, !1, !0); + }, this.dispose = function() { + e.removeEventListener("webglcontextlost", Ee, !1), e.removeEventListener("webglcontextrestored", me, !1), C.dispose(), T.dispose(), G.dispose(), K.dispose(), ue.dispose(), Te.dispose(), R.dispose(), Pe.dispose(), Q.dispose(), Q.removeEventListener("sessionstart", Ut), Q.removeEventListener("sessionend", Ot), W && (W.dispose(), W = null), Ln.stop(); + }; + function Ee(S) { + S.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), v = !0; + } + function me() { + console.log("THREE.WebGLRenderer: Context Restored."), v = !1; + let S = Oe.autoReset, N = $.enabled, H = $.autoUpdate, z = $.needsUpdate, q = $.type; + ee(), Oe.autoReset = S, $.enabled = N, $.autoUpdate = H, $.needsUpdate = z, $.type = q; + } + function Re(S) { + let N = S.target; + N.removeEventListener("dispose", Re), oe(N); + } + function oe(S) { + Le(S), G.remove(S); + } + function Le(S) { + let N = G.get(S).programs; + N !== void 0 && (N.forEach(function(H) { + Pe.releaseProgram(H); + }), S.isShaderMaterial && Pe.releaseShaderCache(S)); + } + this.renderBufferDirect = function(S, N, H, z, q, be) { + N === null && (N = fe); + let Ae = q.isMesh && q.matrixWorld.determinant() < 0, Ie = lu(S, N, H, z, q); + xe.setMaterial(z, Ae); + let we = H.index, He = H.attributes.position; + if (we === null) { + if (He === void 0 || He.count === 0) return; + } else if (we.count === 0) return; + let De = 1; + z.wireframe === !0 && (we = Se.getWireframeAttribute(H), De = 2), R.setup(q, z, Ie, H, we); + let ze, je = Me; + we !== null && (ze = se.get(we), je = ve, je.setIndex(ze)); + let Rn = we !== null ? we.count : He.count, ei = H.drawRange.start * De, Ge = H.drawRange.count * De, Ht = be !== null ? be.start * De : 0, at = be !== null ? be.count * De : 1 / 0, kt = Math.max(ei, Ht), Gr = Math.min(Rn, ei + Ge, Ht + at) - 1, Gt = Math.max(0, Gr - kt + 1); + if (Gt !== 0) { + if (q.isMesh) z.wireframe === !0 ? (xe.setLineWidth(z.wireframeLinewidth * Be()), je.setMode(1)) : je.setMode(4); + else if (q.isLine) { + let Zt = z.linewidth; + Zt === void 0 && (Zt = 1), xe.setLineWidth(Zt * Be()), q.isLineSegments ? je.setMode(1) : q.isLineLoop ? je.setMode(2) : je.setMode(3); + } else q.isPoints ? je.setMode(0) : q.isSprite && je.setMode(4); + if (q.isInstancedMesh) je.renderInstances(kt, Gt, q.count); + else if (H.isInstancedBufferGeometry) { + let Zt = Math.min(H.instanceCount, H._maxInstanceCount); + je.renderInstances(kt, Gt, Zt); + } else je.render(kt, Gt); + } + }, this.compile = function(S, N) { + d = T.get(S), d.init(), m.push(d), S.traverseVisible(function(H) { + H.isLight && H.layers.test(N.layers) && (d.pushLight(H), H.castShadow && d.pushShadow(H)); + }), d.setupLights(x.physicallyCorrectLights), S.traverse(function(H) { + let z = H.material; + if (z) if (Array.isArray(z)) for(let q = 0; q < z.length; q++){ + let be = z[q]; + xo(be, S, H); + } + else xo(z, S, H); + }), m.pop(), d = null; + }; + let Xe = null; + function We(S) { + Xe && Xe(S); + } + function Ut() { + Ln.stop(); + } + function Ot() { + Ln.start(); + } + let Ln = new rh; + Ln.setAnimationLoop(We), typeof window < "u" && Ln.setContext(window), this.setAnimationLoop = function(S) { + Xe = S, Q.setAnimationLoop(S), S === null ? Ln.stop() : Ln.start(); + }, Q.addEventListener("sessionstart", Ut), Q.addEventListener("sessionend", Ot), this.render = function(S, N) { + if (N !== void 0 && N.isCamera !== !0) { + console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); + return; + } + if (v === !0) return; + S.autoUpdate === !0 && S.updateMatrixWorld(), N.parent === null && N.updateMatrixWorld(), Q.enabled === !0 && Q.isPresenting === !0 && (Q.cameraAutoUpdate === !0 && Q.updateCamera(N), N = Q.getCamera()), S.isScene === !0 && S.onBeforeRender(x, S, N, _), d = T.get(S, m.length), d.init(), m.push(d), he.multiplyMatrices(N.projectionMatrix, N.matrixWorldInverse), ne.setFromProjectionMatrix(he), V = this.localClippingEnabled, ce = J.init(this.clippingPlanes, V, N), u = C.get(S, f.length), u.init(), f.push(u), Qa(S, N, 0, x.sortObjects), u.finish(), x.sortObjects === !0 && u.sort(w, E), ce === !0 && J.beginShadows(); + let H = d.state.shadowsArray; + if ($.render(H, S, N), ce === !0 && J.endShadows(), this.info.autoReset === !0 && this.info.reset(), re.render(u, S), d.setupLights(x.physicallyCorrectLights), N.isArrayCamera) { + let z = N.cameras; + for(let q = 0, be = z.length; q < be; q++){ + let Ae = z[q]; + Ka(u, S, Ae, Ae.viewport); + } + } else Ka(u, S, N); + _ !== null && (j.updateMultisampleRenderTarget(_), j.updateRenderTargetMipmap(_)), S.isScene === !0 && S.onAfterRender(x, S, N), xe.buffers.depth.setTest(!0), xe.buffers.depth.setMask(!0), xe.buffers.color.setMask(!0), xe.setPolygonOffset(!1), R.resetDefaultState(), y = -1, b = null, m.pop(), m.length > 0 ? d = m[m.length - 1] : d = null, f.pop(), f.length > 0 ? u = f[f.length - 1] : u = null; + }; + function Qa(S, N, H, z) { + if (S.visible === !1) return; + if (S.layers.test(N.layers)) { + if (S.isGroup) H = S.renderOrder; + else if (S.isLOD) S.autoUpdate === !0 && S.update(N); + else if (S.isLight) d.pushLight(S), S.castShadow && d.pushShadow(S); + else if (S.isSprite) { + if (!S.frustumCulled || ne.intersectsSprite(S)) { + z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); + let Ae = Te.update(S), Ie = S.material; + Ie.visible && u.push(S, Ae, Ie, H, le.z, null); + } + } else if ((S.isMesh || S.isLine || S.isPoints) && (S.isSkinnedMesh && S.skeleton.frame !== Oe.render.frame && (S.skeleton.update(), S.skeleton.frame = Oe.render.frame), !S.frustumCulled || ne.intersectsObject(S))) { + z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); + let Ae = Te.update(S), Ie = S.material; + if (Array.isArray(Ie)) { + let we = Ae.groups; + for(let He = 0, De = we.length; He < De; He++){ + let ze = we[He], je = Ie[ze.materialIndex]; + je && je.visible && u.push(S, Ae, je, H, le.z, ze); + } + } else Ie.visible && u.push(S, Ae, Ie, H, le.z, null); + } + } + let be = S.children; + for(let Ae = 0, Ie = be.length; Ae < Ie; Ae++)Qa(be[Ae], N, H, z); + } + function Ka(S, N, H, z) { + let q = S.opaque, be = S.transmissive, Ae = S.transparent; + d.setupLightsView(H), be.length > 0 && ou(q, N, H), z && xe.viewport(A.copy(z)), q.length > 0 && kr(q, N, H), be.length > 0 && kr(be, N, H), Ae.length > 0 && kr(Ae, N, H); + } + function ou(S, N, H) { + if (W === null) { + let Ae = o === !0 && ge.isWebGL2 === !0 ? Xs : At; + W = new Ae(1024, 1024, { + generateMipmaps: !0, + type: te.convert(kn) !== null ? kn : rn, + minFilter: Ui, + magFilter: rt, + wrapS: vt, + wrapT: vt, + useRenderToTexture: ye.has("WEBGL_multisampled_render_to_texture") + }); + } + let z = x.getRenderTarget(); + x.setRenderTarget(W), x.clear(); + let q = x.toneMapping; + x.toneMapping = _n, kr(S, N, H), x.toneMapping = q, j.updateMultisampleRenderTarget(W), j.updateRenderTargetMipmap(W), x.setRenderTarget(z); + } + function kr(S, N, H) { + let z = N.isScene === !0 ? N.overrideMaterial : null; + for(let q = 0, be = S.length; q < be; q++){ + let Ae = S[q], Ie = Ae.object, we = Ae.geometry, He = z === null ? Ae.material : z, De = Ae.group; + Ie.layers.test(H.layers) && au(Ie, N, H, we, He, De); + } + } + function au(S, N, H, z, q, be) { + S.onBeforeRender(x, N, H, z, q, be), S.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse, S.matrixWorld), S.normalMatrix.getNormalMatrix(S.modelViewMatrix), q.onBeforeRender(x, N, H, z, S, be), q.transparent === !0 && q.side === Ci ? (q.side = it, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ai, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ci) : x.renderBufferDirect(H, N, z, q, S, be), S.onAfterRender(x, N, H, z, q, be); + } + function xo(S, N, H) { + N.isScene !== !0 && (N = fe); + let z = G.get(S), q = d.state.lights, be = d.state.shadowsArray, Ae = q.state.version, Ie = Pe.getParameters(S, q.state, be, N, H), we = Pe.getProgramCacheKey(Ie), He = z.programs; + z.environment = S.isMeshStandardMaterial ? N.environment : null, z.fog = N.fog, z.envMap = (S.isMeshStandardMaterial ? ue : K).get(S.envMap || z.environment), He === void 0 && (S.addEventListener("dispose", Re), He = new Map, z.programs = He); + let De = He.get(we); + if (De !== void 0) { + if (z.currentProgram === De && z.lightsStateVersion === Ae) return el(S, Ie), De; + } else Ie.uniforms = Pe.getUniforms(S), S.onBuild(H, Ie, x), S.onBeforeCompile(Ie, x), De = Pe.acquireProgram(Ie, we), He.set(we, De), z.uniforms = Ie.uniforms; + let ze = z.uniforms; + (!S.isShaderMaterial && !S.isRawShaderMaterial || S.clipping === !0) && (ze.clippingPlanes = J.uniform), el(S, Ie), z.needsLights = hu(S), z.lightsStateVersion = Ae, z.needsLights && (ze.ambientLightColor.value = q.state.ambient, ze.lightProbe.value = q.state.probe, ze.directionalLights.value = q.state.directional, ze.directionalLightShadows.value = q.state.directionalShadow, ze.spotLights.value = q.state.spot, ze.spotLightShadows.value = q.state.spotShadow, ze.rectAreaLights.value = q.state.rectArea, ze.ltc_1.value = q.state.rectAreaLTC1, ze.ltc_2.value = q.state.rectAreaLTC2, ze.pointLights.value = q.state.point, ze.pointLightShadows.value = q.state.pointShadow, ze.hemisphereLights.value = q.state.hemi, ze.directionalShadowMap.value = q.state.directionalShadowMap, ze.directionalShadowMatrix.value = q.state.directionalShadowMatrix, ze.spotShadowMap.value = q.state.spotShadowMap, ze.spotShadowMatrix.value = q.state.spotShadowMatrix, ze.pointShadowMap.value = q.state.pointShadowMap, ze.pointShadowMatrix.value = q.state.pointShadowMatrix); + let je = De.getUniforms(), Rn = bn.seqWithValue(je.seq, ze); + return z.currentProgram = De, z.uniformsList = Rn, De; + } + function el(S, N) { + let H = G.get(S); + H.outputEncoding = N.outputEncoding, H.instancing = N.instancing, H.skinning = N.skinning, H.morphTargets = N.morphTargets, H.morphNormals = N.morphNormals, H.morphTargetsCount = N.morphTargetsCount, H.numClippingPlanes = N.numClippingPlanes, H.numIntersection = N.numClipIntersection, H.vertexAlphas = N.vertexAlphas, H.vertexTangents = N.vertexTangents, H.toneMapping = N.toneMapping; + } + function lu(S, N, H, z, q) { + N.isScene !== !0 && (N = fe), j.resetTextureUnits(); + let be = N.fog, Ae = z.isMeshStandardMaterial ? N.environment : null, Ie = _ === null ? x.outputEncoding : _.texture.encoding, we = (z.isMeshStandardMaterial ? ue : K).get(z.envMap || Ae), He = z.vertexColors === !0 && !!H.attributes.color && H.attributes.color.itemSize === 4, De = !!z.normalMap && !!H.attributes.tangent, ze = !!H.morphAttributes.position, je = !!H.morphAttributes.normal, Rn = H.morphAttributes.position ? H.morphAttributes.position.length : 0, ei = z.toneMapped ? x.toneMapping : _n, Ge = G.get(z), Ht = d.state.lights; + if (ce === !0 && (V === !0 || S !== b)) { + let Pt = S === b && z.id === y; + J.setState(z, S, Pt); + } + let at = !1; + z.version === Ge.__version ? (Ge.needsLights && Ge.lightsStateVersion !== Ht.state.version || Ge.outputEncoding !== Ie || q.isInstancedMesh && Ge.instancing === !1 || !q.isInstancedMesh && Ge.instancing === !0 || q.isSkinnedMesh && Ge.skinning === !1 || !q.isSkinnedMesh && Ge.skinning === !0 || Ge.envMap !== we || z.fog && Ge.fog !== be || Ge.numClippingPlanes !== void 0 && (Ge.numClippingPlanes !== J.numPlanes || Ge.numIntersection !== J.numIntersection) || Ge.vertexAlphas !== He || Ge.vertexTangents !== De || Ge.morphTargets !== ze || Ge.morphNormals !== je || Ge.toneMapping !== ei || ge.isWebGL2 === !0 && Ge.morphTargetsCount !== Rn) && (at = !0) : (at = !0, Ge.__version = z.version); + let kt = Ge.currentProgram; + at === !0 && (kt = xo(z, N, q)); + let Gr = !1, Gt = !1, Zt = !1, xt = kt.getUniforms(), Xi = Ge.uniforms; + if (xe.useProgram(kt.program) && (Gr = !0, Gt = !0, Zt = !0), z.id !== y && (y = z.id, Gt = !0), Gr || b !== S) { + if (xt.setValue(Y, "projectionMatrix", S.projectionMatrix), ge.logarithmicDepthBuffer && xt.setValue(Y, "logDepthBufFC", 2 / (Math.log(S.far + 1) / Math.LN2)), b !== S && (b = S, Gt = !0, Zt = !0), z.isShaderMaterial || z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshStandardMaterial || z.envMap) { + let Pt = xt.map.cameraPosition; + Pt !== void 0 && Pt.setValue(Y, le.setFromMatrixPosition(S.matrixWorld)); + } + (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial) && xt.setValue(Y, "isOrthographic", S.isOrthographicCamera === !0), (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial || z.isShadowMaterial || q.isSkinnedMesh) && xt.setValue(Y, "viewMatrix", S.matrixWorldInverse); + } + if (q.isSkinnedMesh) { + xt.setOptional(Y, q, "bindMatrix"), xt.setOptional(Y, q, "bindMatrixInverse"); + let Pt = q.skeleton; + Pt && (ge.floatVertexTextures ? (Pt.boneTexture === null && Pt.computeBoneTexture(), xt.setValue(Y, "boneTexture", Pt.boneTexture, j), xt.setValue(Y, "boneTextureSize", Pt.boneTextureSize)) : xt.setOptional(Y, Pt, "boneMatrices")); + } + return !!H && (H.morphAttributes.position !== void 0 || H.morphAttributes.normal !== void 0) && Z.update(q, H, z, kt), (Gt || Ge.receiveShadow !== q.receiveShadow) && (Ge.receiveShadow = q.receiveShadow, xt.setValue(Y, "receiveShadow", q.receiveShadow)), Gt && (xt.setValue(Y, "toneMappingExposure", x.toneMappingExposure), Ge.needsLights && cu(Xi, Zt), be && z.fog && Ye.refreshFogUniforms(Xi, be), Ye.refreshMaterialUniforms(Xi, z, P, B, W), bn.upload(Y, Ge.uniformsList, Xi, j)), z.isShaderMaterial && z.uniformsNeedUpdate === !0 && (bn.upload(Y, Ge.uniformsList, Xi, j), z.uniformsNeedUpdate = !1), z.isSpriteMaterial && xt.setValue(Y, "center", q.center), xt.setValue(Y, "modelViewMatrix", q.modelViewMatrix), xt.setValue(Y, "normalMatrix", q.normalMatrix), xt.setValue(Y, "modelMatrix", q.matrixWorld), kt; + } + function cu(S, N) { + S.ambientLightColor.needsUpdate = N, S.lightProbe.needsUpdate = N, S.directionalLights.needsUpdate = N, S.directionalLightShadows.needsUpdate = N, S.pointLights.needsUpdate = N, S.pointLightShadows.needsUpdate = N, S.spotLights.needsUpdate = N, S.spotLightShadows.needsUpdate = N, S.rectAreaLights.needsUpdate = N, S.hemisphereLights.needsUpdate = N; + } + function hu(S) { + return S.isMeshLambertMaterial || S.isMeshToonMaterial || S.isMeshPhongMaterial || S.isMeshStandardMaterial || S.isShadowMaterial || S.isShaderMaterial && S.lights === !0; + } + this.getActiveCubeFace = function() { + return g; + }, this.getActiveMipmapLevel = function() { + return p; + }, this.getRenderTarget = function() { + return _; + }, this.setRenderTargetTextures = function(S, N, H) { + G.get(S.texture).__webglTexture = N, G.get(S.depthTexture).__webglTexture = H; + let z = G.get(S); + z.__hasExternalTextures = !0, z.__hasExternalTextures && (z.__autoAllocateDepthBuffer = H === void 0, z.__autoAllocateDepthBuffer || S.useRenderToTexture && (console.warn("render-to-texture extension was disabled because an external texture was provided"), S.useRenderToTexture = !1, S.useRenderbuffer = !0)); + }, this.setRenderTargetFramebuffer = function(S, N) { + let H = G.get(S); + H.__webglFramebuffer = N, H.__useDefaultFramebuffer = N === void 0; + }, this.setRenderTarget = function(S, N = 0, H = 0) { + _ = S, g = N, p = H; + let z = !0; + if (S) { + let we = G.get(S); + we.__useDefaultFramebuffer !== void 0 ? (xe.bindFramebuffer(36160, null), z = !1) : we.__webglFramebuffer === void 0 ? j.setupRenderTarget(S) : we.__hasExternalTextures && j.rebindTextures(S, G.get(S.texture).__webglTexture, G.get(S.depthTexture).__webglTexture); + } + let q = null, be = !1, Ae = !1; + if (S) { + let we = S.texture; + (we.isDataTexture3D || we.isDataTexture2DArray) && (Ae = !0); + let He = G.get(S).__webglFramebuffer; + S.isWebGLCubeRenderTarget ? (q = He[N], be = !0) : S.useRenderbuffer ? q = G.get(S).__webglMultisampledFramebuffer : q = He, A.copy(S.viewport), L.copy(S.scissor), I = S.scissorTest; + } else A.copy(D).multiplyScalar(P).floor(), L.copy(U).multiplyScalar(P).floor(), I = F; + if (xe.bindFramebuffer(36160, q) && ge.drawBuffers && z) { + let we = !1; + if (S) if (S.isWebGLMultipleRenderTargets) { + let He = S.texture; + if (O.length !== He.length || O[0] !== 36064) { + for(let De = 0, ze = He.length; De < ze; De++)O[De] = 36064 + De; + O.length = He.length, we = !0; + } + } else (O.length !== 1 || O[0] !== 36064) && (O[0] = 36064, O.length = 1, we = !0); + else (O.length !== 1 || O[0] !== 1029) && (O[0] = 1029, O.length = 1, we = !0); + we && (ge.isWebGL2 ? Y.drawBuffers(O) : ye.get("WEBGL_draw_buffers").drawBuffersWEBGL(O)); + } + if (xe.viewport(A), xe.scissor(L), xe.setScissorTest(I), be) { + let we = G.get(S.texture); + Y.framebufferTexture2D(36160, 36064, 34069 + N, we.__webglTexture, H); + } else if (Ae) { + let we = G.get(S.texture), He = N || 0; + Y.framebufferTextureLayer(36160, 36064, we.__webglTexture, H || 0, He); + } + y = -1; + }, this.readRenderTargetPixels = function(S, N, H, z, q, be, Ae) { + if (!(S && S.isWebGLRenderTarget)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); + return; + } + let Ie = G.get(S).__webglFramebuffer; + if (S.isWebGLCubeRenderTarget && Ae !== void 0 && (Ie = Ie[Ae]), Ie) { + xe.bindFramebuffer(36160, Ie); + try { + let we = S.texture, He = we.format, De = we.type; + if (He !== ct && te.convert(He) !== Y.getParameter(35739)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); + return; + } + let ze = De === kn && (ye.has("EXT_color_buffer_half_float") || ge.isWebGL2 && ye.has("EXT_color_buffer_float")); + if (De !== rn && te.convert(De) !== Y.getParameter(35738) && !(De === nn && (ge.isWebGL2 || ye.has("OES_texture_float") || ye.has("WEBGL_color_buffer_float"))) && !ze) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); + return; + } + Y.checkFramebufferStatus(36160) === 36053 ? N >= 0 && N <= S.width - z && H >= 0 && H <= S.height - q && Y.readPixels(N, H, z, q, te.convert(He), te.convert(De), be) : console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."); + } finally{ + let we = _ !== null ? G.get(_).__webglFramebuffer : null; + xe.bindFramebuffer(36160, we); + } + } + }, this.copyFramebufferToTexture = function(S, N, H = 0) { + if (N.isFramebufferTexture !== !0) { + console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture."); + return; + } + let z = Math.pow(2, -H), q = Math.floor(N.image.width * z), be = Math.floor(N.image.height * z); + j.setTexture2D(N, 0), Y.copyTexSubImage2D(3553, H, 0, 0, S.x, S.y, q, be), xe.unbindTexture(); + }, this.copyTextureToTexture = function(S, N, H, z = 0) { + let q = N.image.width, be = N.image.height, Ae = te.convert(H.format), Ie = te.convert(H.type); + j.setTexture2D(H, 0), Y.pixelStorei(37440, H.flipY), Y.pixelStorei(37441, H.premultiplyAlpha), Y.pixelStorei(3317, H.unpackAlignment), N.isDataTexture ? Y.texSubImage2D(3553, z, S.x, S.y, q, be, Ae, Ie, N.image.data) : N.isCompressedTexture ? Y.compressedTexSubImage2D(3553, z, S.x, S.y, N.mipmaps[0].width, N.mipmaps[0].height, Ae, N.mipmaps[0].data) : Y.texSubImage2D(3553, z, S.x, S.y, Ae, Ie, N.image), z === 0 && H.generateMipmaps && Y.generateMipmap(3553), xe.unbindTexture(); + }, this.copyTextureToTexture3D = function(S, N, H, z, q = 0) { + if (x.isWebGL1Renderer) { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2."); + return; + } + let be = S.max.x - S.min.x + 1, Ae = S.max.y - S.min.y + 1, Ie = S.max.z - S.min.z + 1, we = te.convert(z.format), He = te.convert(z.type), De; + if (z.isDataTexture3D) j.setTexture3D(z, 0), De = 32879; + else if (z.isDataTexture2DArray) j.setTexture2DArray(z, 0), De = 35866; + else { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray."); + return; + } + Y.pixelStorei(37440, z.flipY), Y.pixelStorei(37441, z.premultiplyAlpha), Y.pixelStorei(3317, z.unpackAlignment); + let ze = Y.getParameter(3314), je = Y.getParameter(32878), Rn = Y.getParameter(3316), ei = Y.getParameter(3315), Ge = Y.getParameter(32877), Ht = H.isCompressedTexture ? H.mipmaps[0] : H.image; + Y.pixelStorei(3314, Ht.width), Y.pixelStorei(32878, Ht.height), Y.pixelStorei(3316, S.min.x), Y.pixelStorei(3315, S.min.y), Y.pixelStorei(32877, S.min.z), H.isDataTexture || H.isDataTexture3D ? Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht.data) : H.isCompressedTexture ? (console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."), Y.compressedTexSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, Ht.data)) : Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht), Y.pixelStorei(3314, ze), Y.pixelStorei(32878, je), Y.pixelStorei(3316, Rn), Y.pixelStorei(3315, ei), Y.pixelStorei(32877, Ge), q === 0 && z.generateMipmaps && Y.generateMipmap(De), xe.unbindTexture(); + }, this.initTexture = function(S) { + j.setTexture2D(S, 0), xe.unbindTexture(); + }, this.resetState = function() { + g = 0, p = 0, _ = null, xe.reset(), R.reset(); + }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { + detail: this + })); +} +qe.prototype.isWebGLRenderer = !0; +var _h = class extends qe { +}; +_h.prototype.isWebGL1Renderer = !0; +var Nr = class { + constructor(e, t = 25e-5){ + this.name = "", this.color = new ae(e), this.density = t; + } + clone() { + return new Nr(this.color, this.density); + } + toJSON() { + return { + type: "FogExp2", + color: this.color.getHex(), + density: this.density + }; + } +}; +Nr.prototype.isFogExp2 = !0; +var Br = class { + constructor(e, t = 1, n = 1e3){ + this.name = "", this.color = new ae(e), this.near = t, this.far = n; + } + clone() { + return new Br(this.color, this.near, this.far); + } + toJSON() { + return { + type: "Fog", + color: this.color.getHex(), + near: this.near, + far: this.far + }; + } +}; +Br.prototype.isFog = !0; +var no = class extends Ne { + constructor(){ + super(); + this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.overrideMaterial = null, this.autoUpdate = !0, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { + detail: this + })); + } + copy(e, t) { + return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.autoUpdate = e.autoUpdate, this.matrixAutoUpdate = e.matrixAutoUpdate, this; + } + toJSON(e) { + let t = super.toJSON(e); + return this.fog !== null && (t.object.fog = this.fog.toJSON()), t; + } +}; +no.prototype.isScene = !0; +var $n = class { + constructor(e, t){ + this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = hr, this.updateRange = { + offset: 0, + count: -1 + }, this.version = 0, this.uuid = Et(); + } + onUploadCallback() {} + set needsUpdate(e) { + e === !0 && this.version++; + } + setUsage(e) { + return this.usage = e, this; + } + copy(e) { + return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this; + } + copyAt(e, t, n) { + e *= this.stride, n *= t.stride; + for(let i = 0, r = this.stride; i < r; i++)this.array[e + i] = t.array[n + i]; + return this; + } + set(e, t = 0) { + return this.array.set(e, t), this; + } + clone(e) { + e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); + let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); + return n.setUsage(this.usage), n; + } + onUpload(e) { + return this.onUploadCallback = e, this; + } + toJSON(e) { + return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.prototype.slice.call(new Uint32Array(this.array.buffer))), { + uuid: this.uuid, + buffer: this.array.buffer._uuid, + type: this.array.constructor.name, + stride: this.stride + }; + } +}; +$n.prototype.isInterleavedBuffer = !0; +var Ke = new M, Sn = class { + constructor(e, t, n, i = !1){ + this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = i === !0; + } + get count() { + return this.data.count; + } + get array() { + return this.data.array; + } + set needsUpdate(e) { + this.data.needsUpdate = e; + } + applyMatrix4(e) { + for(let t = 0, n = this.data.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyMatrix4(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + return this; + } + applyNormalMatrix(e) { + for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyNormalMatrix(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + return this; + } + transformDirection(e) { + for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.transformDirection(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + return this; + } + setX(e, t) { + return this.data.array[e * this.data.stride + this.offset] = t, this; + } + setY(e, t) { + return this.data.array[e * this.data.stride + this.offset + 1] = t, this; + } + setZ(e, t) { + return this.data.array[e * this.data.stride + this.offset + 2] = t, this; + } + setW(e, t) { + return this.data.array[e * this.data.stride + this.offset + 3] = t, this; + } + getX(e) { + return this.data.array[e * this.data.stride + this.offset]; + } + getY(e) { + return this.data.array[e * this.data.stride + this.offset + 1]; + } + getZ(e) { + return this.data.array[e * this.data.stride + this.offset + 2]; + } + getW(e) { + return this.data.array[e * this.data.stride + this.offset + 3]; + } + setXY(e, t, n) { + return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this; + } + setXYZ(e, t, n, i) { + return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this; + } + setXYZW(e, t, n, i, r) { + return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this.data.array[e + 3] = r, this; + } + clone(e) { + if (e === void 0) { + console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data."); + let t = []; + for(let n = 0; n < this.count; n++){ + let i = n * this.data.stride + this.offset; + for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); + } + return new Ue(new this.array.constructor(t), this.itemSize, this.normalized); + } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new Sn(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); + } + toJSON(e) { + if (e === void 0) { + console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data."); + let t = []; + for(let n = 0; n < this.count; n++){ + let i = n * this.data.stride + this.offset; + for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); + } + return { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: t, + normalized: this.normalized + }; + } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { + isInterleavedBufferAttribute: !0, + itemSize: this.itemSize, + data: this.data.uuid, + offset: this.offset, + normalized: this.normalized + }; + } +}; +Sn.prototype.isInterleavedBufferAttribute = !0; +var io = class extends dt { + constructor(e){ + super(); + this.type = "SpriteMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.rotation = e.rotation, this.sizeAttenuation = e.sizeAttenuation, this; + } +}; +io.prototype.isSpriteMaterial = !0; +var gi, Qi = new M, xi = new M, yi = new M, vi = new X, Ki = new X, Mh = new pe, hs = new M, er = new M, us = new M, jl = new X, qo = new X, Ql = new X, ro = class extends Ne { + constructor(e){ + super(); + if (this.type = "Sprite", gi === void 0) { + gi = new _e; + let t = new Float32Array([ + -.5, + -.5, + 0, + 0, + 0, + .5, + -.5, + 0, + 1, + 0, + .5, + .5, + 0, + 1, + 1, + -.5, + .5, + 0, + 0, + 1 + ]), n = new $n(t, 5); + gi.setIndex([ + 0, + 1, + 2, + 0, + 2, + 3 + ]), gi.setAttribute("position", new Sn(n, 3, 0, !1)), gi.setAttribute("uv", new Sn(n, 2, 3, !1)); + } + this.geometry = gi, this.material = e !== void 0 ? e : new io, this.center = new X(.5, .5); + } + raycast(e, t) { + e.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), xi.setFromMatrixScale(this.matrixWorld), Mh.copy(e.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse, this.matrixWorld), yi.setFromMatrixPosition(this.modelViewMatrix), e.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && xi.multiplyScalar(-yi.z); + let n = this.material.rotation, i, r; + n !== 0 && (r = Math.cos(n), i = Math.sin(n)); + let o = this.center; + ds(hs.set(-.5, -.5, 0), yi, o, xi, i, r), ds(er.set(.5, -.5, 0), yi, o, xi, i, r), ds(us.set(.5, .5, 0), yi, o, xi, i, r), jl.set(0, 0), qo.set(1, 0), Ql.set(1, 1); + let a = e.ray.intersectTriangle(hs, er, us, !1, Qi); + if (a === null && (ds(er.set(-.5, .5, 0), yi, o, xi, i, r), qo.set(0, 1), a = e.ray.intersectTriangle(hs, us, er, !1, Qi), a === null)) return; + let l = e.ray.origin.distanceTo(Qi); + l < e.near || l > e.far || t.push({ + distance: l, + point: Qi.clone(), + uv: nt.getUV(Qi, hs, er, us, jl, qo, Ql, new X), + face: null, + object: this + }); + } + copy(e) { + return super.copy(e), e.center !== void 0 && this.center.copy(e.center), this.material = e.material, this; + } +}; +ro.prototype.isSprite = !0; +function ds(s, e, t, n, i, r) { + vi.subVectors(s, t).addScalar(.5).multiply(n), i !== void 0 ? (Ki.x = r * vi.x - i * vi.y, Ki.y = i * vi.x + r * vi.y) : Ki.copy(vi), s.copy(e), s.x += Ki.x, s.y += Ki.y, s.applyMatrix4(Mh); +} +var fs = new M, Kl = new M, bh = class extends Ne { + constructor(){ + super(); + this._currentLevel = 0, this.type = "LOD", Object.defineProperties(this, { + levels: { + enumerable: !0, + value: [] + }, + isLOD: { + value: !0 + } + }), this.autoUpdate = !0; + } + copy(e) { + super.copy(e, !1); + let t = e.levels; + for(let n = 0, i = t.length; n < i; n++){ + let r = t[n]; + this.addLevel(r.object.clone(), r.distance); + } + return this.autoUpdate = e.autoUpdate, this; + } + addLevel(e, t = 0) { + t = Math.abs(t); + let n = this.levels, i; + for(i = 0; i < n.length && !(t < n[i].distance); i++); + return n.splice(i, 0, { + distance: t, + object: e + }), this.add(e), this; + } + getCurrentLevel() { + return this._currentLevel; + } + getObjectForDistance(e) { + let t = this.levels; + if (t.length > 0) { + let n, i; + for(n = 1, i = t.length; n < i && !(e < t[n].distance); n++); + return t[n - 1].object; + } + return null; + } + raycast(e, t) { + if (this.levels.length > 0) { + fs.setFromMatrixPosition(this.matrixWorld); + let i = e.ray.origin.distanceTo(fs); + this.getObjectForDistance(i).raycast(e, t); + } + } + update(e) { + let t = this.levels; + if (t.length > 1) { + fs.setFromMatrixPosition(e.matrixWorld), Kl.setFromMatrixPosition(this.matrixWorld); + let n = fs.distanceTo(Kl) / e.zoom; + t[0].object.visible = !0; + let i, r; + for(i = 1, r = t.length; i < r && n >= t[i].distance; i++)t[i - 1].object.visible = !1, t[i].object.visible = !0; + for(this._currentLevel = i - 1; i < r; i++)t[i].object.visible = !1; + } + } + toJSON(e) { + let t = super.toJSON(e); + this.autoUpdate === !1 && (t.object.autoUpdate = !1), t.object.levels = []; + let n = this.levels; + for(let i = 0, r = n.length; i < r; i++){ + let o = n[i]; + t.object.levels.push({ + object: o.object.uuid, + distance: o.distance + }); + } + return t; + } +}, ec = new M, tc = new Ve, nc = new Ve, Rx = new M, ic = new pe, so = class extends st { + constructor(e, t){ + super(e, t); + this.type = "SkinnedMesh", this.bindMode = "attached", this.bindMatrix = new pe, this.bindMatrixInverse = new pe; + } + copy(e) { + return super.copy(e), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, this; + } + bind(e, t) { + this.skeleton = e, t === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), t = this.matrixWorld), this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert(); + } + pose() { + this.skeleton.pose(); + } + normalizeSkinWeights() { + let e = new Ve, t = this.geometry.attributes.skinWeight; + for(let n = 0, i = t.count; n < i; n++){ + e.x = t.getX(n), e.y = t.getY(n), e.z = t.getZ(n), e.w = t.getW(n); + let r = 1 / e.manhattanLength(); + r !== 1 / 0 ? e.multiplyScalar(r) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w); + } + } + updateMatrixWorld(e) { + super.updateMatrixWorld(e), this.bindMode === "attached" ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === "detached" ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode); + } + boneTransform(e, t) { + let n = this.skeleton, i = this.geometry; + tc.fromBufferAttribute(i.attributes.skinIndex, e), nc.fromBufferAttribute(i.attributes.skinWeight, e), ec.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0); + for(let r = 0; r < 4; r++){ + let o = nc.getComponent(r); + if (o !== 0) { + let a = tc.getComponent(r); + ic.multiplyMatrices(n.bones[a].matrixWorld, n.boneInverses[a]), t.addScaledVector(Rx.copy(ec).applyMatrix4(ic), o); + } + } + return t.applyMatrix4(this.bindMatrixInverse); + } +}; +so.prototype.isSkinnedMesh = !0; +var oo = class extends Ne { + constructor(){ + super(); + this.type = "Bone"; + } +}; +oo.prototype.isBone = !0; +var qn = class extends ot { + constructor(e = null, t = 1, n = 1, i, r, o, a, l, c = rt, h = rt, u, d){ + super(null, o, a, l, c, h, i, r, u, d); + this.image = { + data: e, + width: t, + height: n + }, this.magFilter = c, this.minFilter = h, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +}; +qn.prototype.isDataTexture = !0; +var rc = new pe, Px = new pe, ao = class { + constructor(e = [], t = []){ + this.uuid = Et(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.boneTextureSize = 0, this.frame = -1, this.init(); + } + init() { + let e = this.bones, t = this.boneInverses; + if (this.boneMatrices = new Float32Array(e.length * 16), t.length === 0) this.calculateInverses(); + else if (e.length !== t.length) { + console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = []; + for(let n = 0, i = this.bones.length; n < i; n++)this.boneInverses.push(new pe); + } + } + calculateInverses() { + this.boneInverses.length = 0; + for(let e = 0, t = this.bones.length; e < t; e++){ + let n = new pe; + this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n); + } + } + pose() { + for(let e = 0, t = this.bones.length; e < t; e++){ + let n = this.bones[e]; + n && n.matrixWorld.copy(this.boneInverses[e]).invert(); + } + for(let e = 0, t = this.bones.length; e < t; e++){ + let n = this.bones[e]; + n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale)); + } + } + update() { + let e = this.bones, t = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; + for(let r = 0, o = e.length; r < o; r++){ + let a = e[r] ? e[r].matrixWorld : Px; + rc.multiplyMatrices(a, t[r]), rc.toArray(n, r * 16); + } + i !== null && (i.needsUpdate = !0); + } + clone() { + return new ao(this.bones, this.boneInverses); + } + computeBoneTexture() { + let e = Math.sqrt(this.bones.length * 4); + e = Xc(e), e = Math.max(e, 4); + let t = new Float32Array(e * e * 4); + t.set(this.boneMatrices); + let n = new qn(t, e, e, ct, nn); + return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this.boneTextureSize = e, this; + } + getBoneByName(e) { + for(let t = 0, n = this.bones.length; t < n; t++){ + let i = this.bones[t]; + if (i.name === e) return i; + } + } + dispose() { + this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null); + } + fromJSON(e, t) { + this.uuid = e.uuid; + for(let n = 0, i = e.bones.length; n < i; n++){ + let r = e.bones[n], o = t[r]; + o === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", r), o = new oo), this.bones.push(o), this.boneInverses.push(new pe().fromArray(e.boneInverses[n])); + } + return this.init(), this; + } + toJSON() { + let e = { + metadata: { + version: 4.5, + type: "Skeleton", + generator: "Skeleton.toJSON" + }, + bones: [], + boneInverses: [] + }; + e.uuid = this.uuid; + let t = this.bones, n = this.boneInverses; + for(let i = 0, r = t.length; i < r; i++){ + let o = t[i]; + e.bones.push(o.uuid); + let a = n[i]; + e.boneInverses.push(a.toArray()); + } + return e; + } +}, Xn = class extends Ue { + constructor(e, t, n, i = 1){ + typeof n == "number" && (i = n, n = !1, console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")); + super(e, t, n); + this.meshPerAttribute = i; + } + copy(e) { + return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; + } + toJSON() { + let e = super.toJSON(); + return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e; + } +}; +Xn.prototype.isInstancedBufferAttribute = !0; +var sc = new pe, oc = new pe, ps = [], tr = new st, xa = class extends st { + constructor(e, t, n){ + super(e, t); + this.instanceMatrix = new Xn(new Float32Array(n * 16), 16), this.instanceColor = null, this.count = n, this.frustumCulled = !1; + } + copy(e) { + return super.copy(e), this.instanceMatrix.copy(e.instanceMatrix), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, this; + } + getColorAt(e, t) { + t.fromArray(this.instanceColor.array, e * 3); + } + getMatrixAt(e, t) { + t.fromArray(this.instanceMatrix.array, e * 16); + } + raycast(e, t) { + let n = this.matrixWorld, i = this.count; + if (tr.geometry = this.geometry, tr.material = this.material, tr.material !== void 0) for(let r = 0; r < i; r++){ + this.getMatrixAt(r, sc), oc.multiplyMatrices(n, sc), tr.matrixWorld = oc, tr.raycast(e, ps); + for(let o = 0, a = ps.length; o < a; o++){ + let l = ps[o]; + l.instanceId = r, l.object = this, t.push(l); + } + ps.length = 0; + } + } + setColorAt(e, t) { + this.instanceColor === null && (this.instanceColor = new Xn(new Float32Array(this.instanceMatrix.count * 3), 3)), t.toArray(this.instanceColor.array, e * 3); + } + setMatrixAt(e, t) { + t.toArray(this.instanceMatrix.array, e * 16); + } + updateMorphTargets() {} + dispose() { + this.dispatchEvent({ + type: "dispose" + }); + } +}; +xa.prototype.isInstancedMesh = !0; +var ft = class extends dt { + constructor(e){ + super(); + this.type = "LineBasicMaterial", this.color = new ae(16777215), this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this; + } +}; +ft.prototype.isLineBasicMaterial = !0; +var ac = new M, lc = new M, cc = new pe, Xo = new Cn, ms = new An, on = class extends Ne { + constructor(e = new _e, t = new ft){ + super(); + this.type = "Line", this.geometry = e, this.material = t, this.updateMorphTargets(); + } + copy(e) { + return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; + } + computeLineDistances() { + let e = this.geometry; + if (e.isBufferGeometry) if (e.index === null) { + let t = e.attributes.position, n = [ + 0 + ]; + for(let i = 1, r = t.count; i < r; i++)ac.fromBufferAttribute(t, i - 1), lc.fromBufferAttribute(t, i), n[i] = n[i - 1], n[i] += ac.distanceTo(lc); + e.setAttribute("lineDistance", new de(n, 1)); + } else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); + else e.isGeometry && console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + return this; + } + raycast(e, t) { + let n = this.geometry, i = this.matrixWorld, r = e.params.Line.threshold, o = n.drawRange; + if (n.boundingSphere === null && n.computeBoundingSphere(), ms.copy(n.boundingSphere), ms.applyMatrix4(i), ms.radius += r, e.ray.intersectsSphere(ms) === !1) return; + cc.copy(i).invert(), Xo.copy(e.ray).applyMatrix4(cc); + let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a, c = new M, h = new M, u = new M, d = new M, f = this.isLineSegments ? 2 : 1; + if (n.isBufferGeometry) { + let m = n.index, v = n.attributes.position; + if (m !== null) { + let g = Math.max(0, o.start), p = Math.min(m.count, o.start + o.count); + for(let _ = g, y = p - 1; _ < y; _ += f){ + let b = m.getX(_), A = m.getX(_ + 1); + if (c.fromBufferAttribute(v, b), h.fromBufferAttribute(v, A), Xo.distanceSqToSegment(c, h, d, u) > l) continue; + d.applyMatrix4(this.matrixWorld); + let I = e.ray.origin.distanceTo(d); + I < e.near || I > e.far || t.push({ + distance: I, + point: u.clone().applyMatrix4(this.matrixWorld), + index: _, + face: null, + faceIndex: null, + object: this + }); + } + } else { + let g = Math.max(0, o.start), p = Math.min(v.count, o.start + o.count); + for(let _ = g, y = p - 1; _ < y; _ += f){ + if (c.fromBufferAttribute(v, _), h.fromBufferAttribute(v, _ + 1), Xo.distanceSqToSegment(c, h, d, u) > l) continue; + d.applyMatrix4(this.matrixWorld); + let A = e.ray.origin.distanceTo(d); + A < e.near || A > e.far || t.push({ + distance: A, + point: u.clone().applyMatrix4(this.matrixWorld), + index: _, + face: null, + faceIndex: null, + object: this + }); + } + } + } else n.isGeometry && console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } + updateMorphTargets() { + let e = this.geometry; + if (e.isBufferGeometry) { + let t = e.morphAttributes, n = Object.keys(t); + if (n.length > 0) { + let i = t[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, o = i.length; r < o; r++){ + let a = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; + } + } + } + } else { + let t = e.morphTargets; + t !== void 0 && t.length > 0 && console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); + } + } +}; +on.prototype.isLine = !0; +var hc = new M, uc = new M, wt = class extends on { + constructor(e, t){ + super(e, t); + this.type = "LineSegments"; + } + computeLineDistances() { + let e = this.geometry; + if (e.isBufferGeometry) if (e.index === null) { + let t = e.attributes.position, n = []; + for(let i = 0, r = t.count; i < r; i += 2)hc.fromBufferAttribute(t, i), uc.fromBufferAttribute(t, i + 1), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + hc.distanceTo(uc); + e.setAttribute("lineDistance", new de(n, 1)); + } else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); + else e.isGeometry && console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + return this; + } +}; +wt.prototype.isLineSegments = !0; +var ya = class extends on { + constructor(e, t){ + super(e, t); + this.type = "LineLoop"; + } +}; +ya.prototype.isLineLoop = !0; +var jn = class extends dt { + constructor(e){ + super(); + this.type = "PointsMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this; + } +}; +jn.prototype.isPointsMaterial = !0; +var dc = new pe, sa = new Cn, gs = new An, xs = new M, zr = class extends Ne { + constructor(e = new _e, t = new jn){ + super(); + this.type = "Points", this.geometry = e, this.material = t, this.updateMorphTargets(); + } + copy(e) { + return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; + } + raycast(e, t) { + let n = this.geometry, i = this.matrixWorld, r = e.params.Points.threshold, o = n.drawRange; + if (n.boundingSphere === null && n.computeBoundingSphere(), gs.copy(n.boundingSphere), gs.applyMatrix4(i), gs.radius += r, e.ray.intersectsSphere(gs) === !1) return; + dc.copy(i).invert(), sa.copy(e.ray).applyMatrix4(dc); + let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a; + if (n.isBufferGeometry) { + let c = n.index, u = n.attributes.position; + if (c !== null) { + let d = Math.max(0, o.start), f = Math.min(c.count, o.start + o.count); + for(let m = d, x = f; m < x; m++){ + let v = c.getX(m); + xs.fromBufferAttribute(u, v), fc(xs, v, l, i, e, t, this); + } + } else { + let d = Math.max(0, o.start), f = Math.min(u.count, o.start + o.count); + for(let m = d, x = f; m < x; m++)xs.fromBufferAttribute(u, m), fc(xs, m, l, i, e, t, this); + } + } else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } + updateMorphTargets() { + let e = this.geometry; + if (e.isBufferGeometry) { + let t = e.morphAttributes, n = Object.keys(t); + if (n.length > 0) { + let i = t[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, o = i.length; r < o; r++){ + let a = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; + } + } + } + } else { + let t = e.morphTargets; + t !== void 0 && t.length > 0 && console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); + } + } +}; +zr.prototype.isPoints = !0; +function fc(s, e, t, n, i, r, o) { + let a = sa.distanceSqToPoint(s); + if (a < t) { + let l = new M; + sa.closestPointToPoint(s, l), l.applyMatrix4(n); + let c = i.ray.origin.distanceTo(l); + if (c < i.near || c > i.far) return; + r.push({ + distance: c, + distanceToRay: Math.sqrt(a), + point: l, + index: e, + face: null, + object: o + }); + } +} +var wh = class extends ot { + constructor(e, t, n, i, r, o, a, l, c){ + super(e, t, n, i, r, o, a, l, c); + this.format = a !== void 0 ? a : Gn, this.minFilter = o !== void 0 ? o : tt, this.magFilter = r !== void 0 ? r : tt, this.generateMipmaps = !1; + let h = this; + function u() { + h.needsUpdate = !0, e.requestVideoFrameCallback(u); + } + "requestVideoFrameCallback" in e && e.requestVideoFrameCallback(u); + } + clone() { + return new this.constructor(this.image).copy(this); + } + update() { + let e = this.image; + "requestVideoFrameCallback" in e === !1 && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0); + } +}; +wh.prototype.isVideoTexture = !0; +var Sh = class extends ot { + constructor(e, t, n){ + super({ + width: e, + height: t + }); + this.format = n, this.magFilter = rt, this.minFilter = rt, this.generateMipmaps = !1, this.needsUpdate = !0; + } +}; +Sh.prototype.isFramebufferTexture = !0; +var va = class extends ot { + constructor(e, t, n, i, r, o, a, l, c, h, u, d){ + super(null, o, a, l, c, h, i, r, u, d); + this.image = { + width: t, + height: n + }, this.mipmaps = e, this.flipY = !1, this.generateMipmaps = !1; + } +}; +va.prototype.isCompressedTexture = !0; +var Th = class extends ot { + constructor(e, t, n, i, r, o, a, l, c){ + super(e, t, n, i, r, o, a, l, c); + this.needsUpdate = !0; + } +}; +Th.prototype.isCanvasTexture = !0; +var fr = class extends _e { + constructor(e = 1, t = 8, n = 0, i = Math.PI * 2){ + super(); + this.type = "CircleGeometry", this.parameters = { + radius: e, + segments: t, + thetaStart: n, + thetaLength: i + }, t = Math.max(3, t); + let r = [], o = [], a = [], l = [], c = new M, h = new X; + o.push(0, 0, 0), a.push(0, 0, 1), l.push(.5, .5); + for(let u = 0, d = 3; u <= t; u++, d += 3){ + let f = n + u / t * i; + c.x = e * Math.cos(f), c.y = e * Math.sin(f), o.push(c.x, c.y, c.z), a.push(0, 0, 1), h.x = (o[d] / e + 1) / 2, h.y = (o[d + 1] / e + 1) / 2, l.push(h.x, h.y); + } + for(let u = 1; u <= t; u++)r.push(u, u + 1, 0); + this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("normal", new de(a, 3)), this.setAttribute("uv", new de(l, 2)); + } + static fromJSON(e) { + return new fr(e.radius, e.segments, e.thetaStart, e.thetaLength); + } +}, Jn = class extends _e { + constructor(e = 1, t = 1, n = 1, i = 8, r = 1, o = !1, a = 0, l = Math.PI * 2){ + super(); + this.type = "CylinderGeometry", this.parameters = { + radiusTop: e, + radiusBottom: t, + height: n, + radialSegments: i, + heightSegments: r, + openEnded: o, + thetaStart: a, + thetaLength: l + }; + let c = this; + i = Math.floor(i), r = Math.floor(r); + let h = [], u = [], d = [], f = [], m = 0, x = [], v = n / 2, g = 0; + p(), o === !1 && (e > 0 && _(!0), t > 0 && _(!1)), this.setIndex(h), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); + function p() { + let y = new M, b = new M, A = 0, L = (t - e) / n; + for(let I = 0; I <= r; I++){ + let k = [], B = I / r, P = B * (t - e) + e; + for(let w = 0; w <= i; w++){ + let E = w / i, D = E * l + a, U = Math.sin(D), F = Math.cos(D); + b.x = P * U, b.y = -B * n + v, b.z = P * F, u.push(b.x, b.y, b.z), y.set(U, L, F).normalize(), d.push(y.x, y.y, y.z), f.push(E, 1 - B), k.push(m++); + } + x.push(k); + } + for(let I = 0; I < i; I++)for(let k = 0; k < r; k++){ + let B = x[k][I], P = x[k + 1][I], w = x[k + 1][I + 1], E = x[k][I + 1]; + h.push(B, P, E), h.push(P, w, E), A += 6; + } + c.addGroup(g, A, 0), g += A; + } + function _(y) { + let b = m, A = new X, L = new M, I = 0, k = y === !0 ? e : t, B = y === !0 ? 1 : -1; + for(let w = 1; w <= i; w++)u.push(0, v * B, 0), d.push(0, B, 0), f.push(.5, .5), m++; + let P = m; + for(let w = 0; w <= i; w++){ + let D = w / i * l + a, U = Math.cos(D), F = Math.sin(D); + L.x = k * F, L.y = v * B, L.z = k * U, u.push(L.x, L.y, L.z), d.push(0, B, 0), A.x = U * .5 + .5, A.y = F * .5 * B + .5, f.push(A.x, A.y), m++; + } + for(let w = 0; w < i; w++){ + let E = b + w, D = P + w; + y === !0 ? h.push(D, D + 1, E) : h.push(D + 1, D, E), I += 3; + } + c.addGroup(g, I, y === !0 ? 1 : 2), g += I; + } + } + static fromJSON(e) { + return new Jn(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + } +}, pr = class extends Jn { + constructor(e = 1, t = 1, n = 8, i = 1, r = !1, o = 0, a = Math.PI * 2){ + super(0, e, t, n, i, r, o, a); + this.type = "ConeGeometry", this.parameters = { + radius: e, + height: t, + radialSegments: n, + heightSegments: i, + openEnded: r, + thetaStart: o, + thetaLength: a + }; + } + static fromJSON(e) { + return new pr(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + } +}, an = class extends _e { + constructor(e = [], t = [], n = 1, i = 0){ + super(); + this.type = "PolyhedronGeometry", this.parameters = { + vertices: e, + indices: t, + radius: n, + detail: i + }; + let r = [], o = []; + a(i), c(n), h(), this.setAttribute("position", new de(r, 3)), this.setAttribute("normal", new de(r.slice(), 3)), this.setAttribute("uv", new de(o, 2)), i === 0 ? this.computeVertexNormals() : this.normalizeNormals(); + function a(p) { + let _ = new M, y = new M, b = new M; + for(let A = 0; A < t.length; A += 3)f(t[A + 0], _), f(t[A + 1], y), f(t[A + 2], b), l(_, y, b, p); + } + function l(p, _, y, b) { + let A = b + 1, L = []; + for(let I = 0; I <= A; I++){ + L[I] = []; + let k = p.clone().lerp(y, I / A), B = _.clone().lerp(y, I / A), P = A - I; + for(let w = 0; w <= P; w++)w === 0 && I === A ? L[I][w] = k : L[I][w] = k.clone().lerp(B, w / P); + } + for(let I = 0; I < A; I++)for(let k = 0; k < 2 * (A - I) - 1; k++){ + let B = Math.floor(k / 2); + k % 2 === 0 ? (d(L[I][B + 1]), d(L[I + 1][B]), d(L[I][B])) : (d(L[I][B + 1]), d(L[I + 1][B + 1]), d(L[I + 1][B])); + } + } + function c(p) { + let _ = new M; + for(let y = 0; y < r.length; y += 3)_.x = r[y + 0], _.y = r[y + 1], _.z = r[y + 2], _.normalize().multiplyScalar(p), r[y + 0] = _.x, r[y + 1] = _.y, r[y + 2] = _.z; + } + function h() { + let p = new M; + for(let _ = 0; _ < r.length; _ += 3){ + p.x = r[_ + 0], p.y = r[_ + 1], p.z = r[_ + 2]; + let y = v(p) / 2 / Math.PI + .5, b = g(p) / Math.PI + .5; + o.push(y, 1 - b); + } + m(), u(); + } + function u() { + for(let p = 0; p < o.length; p += 6){ + let _ = o[p + 0], y = o[p + 2], b = o[p + 4], A = Math.max(_, y, b), L = Math.min(_, y, b); + A > .9 && L < .1 && (_ < .2 && (o[p + 0] += 1), y < .2 && (o[p + 2] += 1), b < .2 && (o[p + 4] += 1)); + } + } + function d(p) { + r.push(p.x, p.y, p.z); + } + function f(p, _) { + let y = p * 3; + _.x = e[y + 0], _.y = e[y + 1], _.z = e[y + 2]; + } + function m() { + let p = new M, _ = new M, y = new M, b = new M, A = new X, L = new X, I = new X; + for(let k = 0, B = 0; k < r.length; k += 9, B += 6){ + p.set(r[k + 0], r[k + 1], r[k + 2]), _.set(r[k + 3], r[k + 4], r[k + 5]), y.set(r[k + 6], r[k + 7], r[k + 8]), A.set(o[B + 0], o[B + 1]), L.set(o[B + 2], o[B + 3]), I.set(o[B + 4], o[B + 5]), b.copy(p).add(_).add(y).divideScalar(3); + let P = v(b); + x(A, B + 0, p, P), x(L, B + 2, _, P), x(I, B + 4, y, P); + } + } + function x(p, _, y, b) { + b < 0 && p.x === 1 && (o[_] = p.x - 1), y.x === 0 && y.z === 0 && (o[_] = b / 2 / Math.PI + .5); + } + function v(p) { + return Math.atan2(p.z, -p.x); + } + function g(p) { + return Math.atan2(-p.y, Math.sqrt(p.x * p.x + p.z * p.z)); + } + } + static fromJSON(e) { + return new an(e.vertices, e.indices, e.radius, e.details); + } +}, mr = class extends an { + constructor(e = 1, t = 0){ + let n = (1 + Math.sqrt(5)) / 2, i = 1 / n, r = [ + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + -1, + -1, + 1, + 1, + 1, + -1, + -1, + 1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + 0, + -i, + -n, + 0, + -i, + n, + 0, + i, + -n, + 0, + i, + n, + -i, + -n, + 0, + -i, + n, + 0, + i, + -n, + 0, + i, + n, + 0, + -n, + 0, + -i, + n, + 0, + -i, + -n, + 0, + i, + n, + 0, + i + ], o = [ + 3, + 11, + 7, + 3, + 7, + 15, + 3, + 15, + 13, + 7, + 19, + 17, + 7, + 17, + 6, + 7, + 6, + 15, + 17, + 4, + 8, + 17, + 8, + 10, + 17, + 10, + 6, + 8, + 0, + 16, + 8, + 16, + 2, + 8, + 2, + 10, + 0, + 12, + 1, + 0, + 1, + 18, + 0, + 18, + 16, + 6, + 10, + 2, + 6, + 2, + 13, + 6, + 13, + 15, + 2, + 16, + 18, + 2, + 18, + 3, + 2, + 3, + 13, + 18, + 1, + 9, + 18, + 9, + 11, + 18, + 11, + 3, + 4, + 14, + 12, + 4, + 12, + 0, + 4, + 0, + 8, + 11, + 9, + 5, + 11, + 5, + 19, + 11, + 19, + 7, + 19, + 5, + 14, + 19, + 14, + 4, + 19, + 4, + 17, + 1, + 12, + 14, + 1, + 14, + 5, + 1, + 5, + 9 + ]; + super(r, o, e, t); + this.type = "DodecahedronGeometry", this.parameters = { + radius: e, + detail: t + }; + } + static fromJSON(e) { + return new mr(e.radius, e.detail); + } +}, ys = new M, vs = new M, Jo = new M, _s = new nt, _a = class extends _e { + constructor(e = null, t = 1){ + super(); + if (this.type = "EdgesGeometry", this.parameters = { + geometry: e, + thresholdAngle: t + }, e !== null) { + let i = Math.pow(10, 4), r = Math.cos(Wn * t), o = e.getIndex(), a = e.getAttribute("position"), l = o ? o.count : a.count, c = [ + 0, + 0, + 0 + ], h = [ + "a", + "b", + "c" + ], u = new Array(3), d = {}, f = []; + for(let m = 0; m < l; m += 3){ + o ? (c[0] = o.getX(m), c[1] = o.getX(m + 1), c[2] = o.getX(m + 2)) : (c[0] = m, c[1] = m + 1, c[2] = m + 2); + let { a: x , b: v , c: g } = _s; + if (x.fromBufferAttribute(a, c[0]), v.fromBufferAttribute(a, c[1]), g.fromBufferAttribute(a, c[2]), _s.getNormal(Jo), u[0] = `${Math.round(x.x * i)},${Math.round(x.y * i)},${Math.round(x.z * i)}`, u[1] = `${Math.round(v.x * i)},${Math.round(v.y * i)},${Math.round(v.z * i)}`, u[2] = `${Math.round(g.x * i)},${Math.round(g.y * i)},${Math.round(g.z * i)}`, !(u[0] === u[1] || u[1] === u[2] || u[2] === u[0])) for(let p = 0; p < 3; p++){ + let _ = (p + 1) % 3, y = u[p], b = u[_], A = _s[h[p]], L = _s[h[_]], I = `${y}_${b}`, k = `${b}_${y}`; + k in d && d[k] ? (Jo.dot(d[k].normal) <= r && (f.push(A.x, A.y, A.z), f.push(L.x, L.y, L.z)), d[k] = null) : I in d || (d[I] = { + index0: c[p], + index1: c[_], + normal: Jo.clone() + }); + } + } + for(let m in d)if (d[m]) { + let { index0: x , index1: v } = d[m]; + ys.fromBufferAttribute(a, x), vs.fromBufferAttribute(a, v), f.push(ys.x, ys.y, ys.z), f.push(vs.x, vs.y, vs.z); + } + this.setAttribute("position", new de(f, 3)); + } + } +}, Ct = class { + constructor(){ + this.type = "Curve", this.arcLengthDivisions = 200; + } + getPoint() { + return console.warn("THREE.Curve: .getPoint() not implemented."), null; + } + getPointAt(e, t) { + let n = this.getUtoTmapping(e); + return this.getPoint(n, t); + } + getPoints(e = 5) { + let t = []; + for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); + return t; + } + getSpacedPoints(e = 5) { + let t = []; + for(let n = 0; n <= e; n++)t.push(this.getPointAt(n / e)); + return t; + } + getLength() { + let e = this.getLengths(); + return e[e.length - 1]; + } + getLengths(e = this.arcLengthDivisions) { + if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; + this.needsUpdate = !1; + let t = [], n, i = this.getPoint(0), r = 0; + t.push(0); + for(let o = 1; o <= e; o++)n = this.getPoint(o / e), r += n.distanceTo(i), t.push(r), i = n; + return this.cacheArcLengths = t, t; + } + updateArcLengths() { + this.needsUpdate = !0, this.getLengths(); + } + getUtoTmapping(e, t) { + let n = this.getLengths(), i = 0, r = n.length, o; + t ? o = t : o = e * n[r - 1]; + let a = 0, l = r - 1, c; + for(; a <= l;)if (i = Math.floor(a + (l - a) / 2), c = n[i] - o, c < 0) a = i + 1; + else if (c > 0) l = i - 1; + else { + l = i; + break; + } + if (i = l, n[i] === o) return i / (r - 1); + let h = n[i], d = n[i + 1] - h, f = (o - h) / d; + return (i + f) / (r - 1); + } + getTangent(e, t) { + let i = e - 1e-4, r = e + 1e-4; + i < 0 && (i = 0), r > 1 && (r = 1); + let o = this.getPoint(i), a = this.getPoint(r), l = t || (o.isVector2 ? new X : new M); + return l.copy(a).sub(o).normalize(), l; + } + getTangentAt(e, t) { + let n = this.getUtoTmapping(e); + return this.getTangent(n, t); + } + computeFrenetFrames(e, t) { + let n = new M, i = [], r = [], o = [], a = new M, l = new pe; + for(let f = 0; f <= e; f++){ + let m = f / e; + i[f] = this.getTangentAt(m, new M); + } + r[0] = new M, o[0] = new M; + let c = Number.MAX_VALUE, h = Math.abs(i[0].x), u = Math.abs(i[0].y), d = Math.abs(i[0].z); + h <= c && (c = h, n.set(1, 0, 0)), u <= c && (c = u, n.set(0, 1, 0)), d <= c && n.set(0, 0, 1), a.crossVectors(i[0], n).normalize(), r[0].crossVectors(i[0], a), o[0].crossVectors(i[0], r[0]); + for(let f = 1; f <= e; f++){ + if (r[f] = r[f - 1].clone(), o[f] = o[f - 1].clone(), a.crossVectors(i[f - 1], i[f]), a.length() > Number.EPSILON) { + a.normalize(); + let m = Math.acos(mt(i[f - 1].dot(i[f]), -1, 1)); + r[f].applyMatrix4(l.makeRotationAxis(a, m)); + } + o[f].crossVectors(i[f], r[f]); + } + if (t === !0) { + let f = Math.acos(mt(r[0].dot(r[e]), -1, 1)); + f /= e, i[0].dot(a.crossVectors(r[0], r[e])) > 0 && (f = -f); + for(let m = 1; m <= e; m++)r[m].applyMatrix4(l.makeRotationAxis(i[m], f * m)), o[m].crossVectors(i[m], r[m]); + } + return { + tangents: i, + normals: r, + binormals: o + }; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.arcLengthDivisions = e.arcLengthDivisions, this; + } + toJSON() { + let e = { + metadata: { + version: 4.5, + type: "Curve", + generator: "Curve.toJSON" + } + }; + return e.arcLengthDivisions = this.arcLengthDivisions, e.type = this.type, e; + } + fromJSON(e) { + return this.arcLengthDivisions = e.arcLengthDivisions, this; + } +}, Ur = class extends Ct { + constructor(e = 0, t = 0, n = 1, i = 1, r = 0, o = Math.PI * 2, a = !1, l = 0){ + super(); + this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = n, this.yRadius = i, this.aStartAngle = r, this.aEndAngle = o, this.aClockwise = a, this.aRotation = l; + } + getPoint(e, t) { + let n = t || new X, i = Math.PI * 2, r = this.aEndAngle - this.aStartAngle, o = Math.abs(r) < Number.EPSILON; + for(; r < 0;)r += i; + for(; r > i;)r -= i; + r < Number.EPSILON && (o ? r = 0 : r = i), this.aClockwise === !0 && !o && (r === i ? r = -i : r = r - i); + let a = this.aStartAngle + e * r, l = this.aX + this.xRadius * Math.cos(a), c = this.aY + this.yRadius * Math.sin(a); + if (this.aRotation !== 0) { + let h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), d = l - this.aX, f = c - this.aY; + l = d * h - f * u + this.aX, c = d * u + f * h + this.aY; + } + return n.set(l, c); + } + copy(e) { + return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; + } + toJSON() { + let e = super.toJSON(); + return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e; + } + fromJSON(e) { + return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; + } +}; +Ur.prototype.isEllipseCurve = !0; +var Ma = class extends Ur { + constructor(e, t, n, i, r, o){ + super(e, t, n, n, i, r, o); + this.type = "ArcCurve"; + } +}; +Ma.prototype.isArcCurve = !0; +function ba() { + let s = 0, e = 0, t = 0, n = 0; + function i(r, o, a, l) { + s = r, e = a, t = -3 * r + 3 * o - 2 * a - l, n = 2 * r - 2 * o + a + l; + } + return { + initCatmullRom: function(r, o, a, l, c) { + i(o, a, c * (a - r), c * (l - o)); + }, + initNonuniformCatmullRom: function(r, o, a, l, c, h, u) { + let d = (o - r) / c - (a - r) / (c + h) + (a - o) / h, f = (a - o) / h - (l - o) / (h + u) + (l - a) / u; + d *= h, f *= h, i(o, a, d, f); + }, + calc: function(r) { + let o = r * r, a = o * r; + return s + e * r + t * o + n * a; + } + }; +} +var Ms = new M, Yo = new ba, Zo = new ba, $o = new ba, wa = class extends Ct { + constructor(e = [], t = !1, n = "centripetal", i = .5){ + super(); + this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = n, this.tension = i; + } + getPoint(e, t = new M) { + let n = t, i = this.points, r = i.length, o = (r - (this.closed ? 0 : 1)) * e, a = Math.floor(o), l = o - a; + this.closed ? a += a > 0 ? 0 : (Math.floor(Math.abs(a) / r) + 1) * r : l === 0 && a === r - 1 && (a = r - 2, l = 1); + let c, h; + this.closed || a > 0 ? c = i[(a - 1) % r] : (Ms.subVectors(i[0], i[1]).add(i[0]), c = Ms); + let u = i[a % r], d = i[(a + 1) % r]; + if (this.closed || a + 2 < r ? h = i[(a + 2) % r] : (Ms.subVectors(i[r - 1], i[r - 2]).add(i[r - 1]), h = Ms), this.curveType === "centripetal" || this.curveType === "chordal") { + let f = this.curveType === "chordal" ? .5 : .25, m = Math.pow(c.distanceToSquared(u), f), x = Math.pow(u.distanceToSquared(d), f), v = Math.pow(d.distanceToSquared(h), f); + x < 1e-4 && (x = 1), m < 1e-4 && (m = x), v < 1e-4 && (v = x), Yo.initNonuniformCatmullRom(c.x, u.x, d.x, h.x, m, x, v), Zo.initNonuniformCatmullRom(c.y, u.y, d.y, h.y, m, x, v), $o.initNonuniformCatmullRom(c.z, u.z, d.z, h.z, m, x, v); + } else this.curveType === "catmullrom" && (Yo.initCatmullRom(c.x, u.x, d.x, h.x, this.tension), Zo.initCatmullRom(c.y, u.y, d.y, h.y, this.tension), $o.initCatmullRom(c.z, u.z, d.z, h.z, this.tension)); + return n.set(Yo.calc(l), Zo.calc(l), $o.calc(l)), n; + } + copy(e) { + super.copy(e), this.points = []; + for(let t = 0, n = e.points.length; t < n; t++){ + let i = e.points[t]; + this.points.push(i.clone()); + } + return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; + } + toJSON() { + let e = super.toJSON(); + e.points = []; + for(let t = 0, n = this.points.length; t < n; t++){ + let i = this.points[t]; + e.points.push(i.toArray()); + } + return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e; + } + fromJSON(e) { + super.fromJSON(e), this.points = []; + for(let t = 0, n = e.points.length; t < n; t++){ + let i = e.points[t]; + this.points.push(new M().fromArray(i)); + } + return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; + } +}; +wa.prototype.isCatmullRomCurve3 = !0; +function pc(s, e, t, n, i) { + let r = (n - e) * .5, o = (i - t) * .5, a = s * s, l = s * a; + return (2 * t - 2 * n + r + o) * l + (-3 * t + 3 * n - 2 * r - o) * a + r * s + t; +} +function Ix(s, e) { + let t = 1 - s; + return t * t * e; +} +function Dx(s, e) { + return 2 * (1 - s) * s * e; +} +function Fx(s, e) { + return s * s * e; +} +function ar(s, e, t, n) { + return Ix(s, e) + Dx(s, t) + Fx(s, n); +} +function Nx(s, e) { + let t = 1 - s; + return t * t * t * e; +} +function Bx(s, e) { + let t = 1 - s; + return 3 * t * t * s * e; +} +function zx(s, e) { + return 3 * (1 - s) * s * s * e; +} +function Ux(s, e) { + return s * s * s * e; +} +function lr(s, e, t, n, i) { + return Nx(s, e) + Bx(s, t) + zx(s, n) + Ux(s, i); +} +var lo = class extends Ct { + constructor(e = new X, t = new X, n = new X, i = new X){ + super(); + this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; + } + getPoint(e, t = new X) { + let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; + return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y)), n; + } + copy(e) { + return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; + } + toJSON() { + let e = super.toJSON(); + return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; + } +}; +lo.prototype.isCubicBezierCurve = !0; +var Sa = class extends Ct { + constructor(e = new M, t = new M, n = new M, i = new M){ + super(); + this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; + } + getPoint(e, t = new M) { + let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; + return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y), lr(e, i.z, r.z, o.z, a.z)), n; + } + copy(e) { + return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; + } + toJSON() { + let e = super.toJSON(); + return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; + } +}; +Sa.prototype.isCubicBezierCurve3 = !0; +var Or = class extends Ct { + constructor(e = new X, t = new X){ + super(); + this.type = "LineCurve", this.v1 = e, this.v2 = t; + } + getPoint(e, t = new X) { + let n = t; + return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; + } + getPointAt(e, t) { + return this.getPoint(e, t); + } + getTangent(e, t) { + let n = t || new X; + return n.copy(this.v2).sub(this.v1).normalize(), n; + } + copy(e) { + return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; + } + toJSON() { + let e = super.toJSON(); + return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; + } +}; +Or.prototype.isLineCurve = !0; +var Eh = class extends Ct { + constructor(e = new M, t = new M){ + super(); + this.type = "LineCurve3", this.isLineCurve3 = !0, this.v1 = e, this.v2 = t; + } + getPoint(e, t = new M) { + let n = t; + return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; + } + getPointAt(e, t) { + return this.getPoint(e, t); + } + copy(e) { + return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; + } + toJSON() { + let e = super.toJSON(); + return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; + } +}, co = class extends Ct { + constructor(e = new X, t = new X, n = new X){ + super(); + this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n; + } + getPoint(e, t = new X) { + let n = t, i = this.v0, r = this.v1, o = this.v2; + return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y)), n; + } + copy(e) { + return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; + } + toJSON() { + let e = super.toJSON(); + return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; + } +}; +co.prototype.isQuadraticBezierCurve = !0; +var ho = class extends Ct { + constructor(e = new M, t = new M, n = new M){ + super(); + this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n; + } + getPoint(e, t = new M) { + let n = t, i = this.v0, r = this.v1, o = this.v2; + return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y), ar(e, i.z, r.z, o.z)), n; + } + copy(e) { + return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; + } + toJSON() { + let e = super.toJSON(); + return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; + } +}; +ho.prototype.isQuadraticBezierCurve3 = !0; +var uo = class extends Ct { + constructor(e = []){ + super(); + this.type = "SplineCurve", this.points = e; + } + getPoint(e, t = new X) { + let n = t, i = this.points, r = (i.length - 1) * e, o = Math.floor(r), a = r - o, l = i[o === 0 ? o : o - 1], c = i[o], h = i[o > i.length - 2 ? i.length - 1 : o + 1], u = i[o > i.length - 3 ? i.length - 1 : o + 2]; + return n.set(pc(a, l.x, c.x, h.x, u.x), pc(a, l.y, c.y, h.y, u.y)), n; + } + copy(e) { + super.copy(e), this.points = []; + for(let t = 0, n = e.points.length; t < n; t++){ + let i = e.points[t]; + this.points.push(i.clone()); + } + return this; + } + toJSON() { + let e = super.toJSON(); + e.points = []; + for(let t = 0, n = this.points.length; t < n; t++){ + let i = this.points[t]; + e.points.push(i.toArray()); + } + return e; + } + fromJSON(e) { + super.fromJSON(e), this.points = []; + for(let t = 0, n = e.points.length; t < n; t++){ + let i = e.points[t]; + this.points.push(new X().fromArray(i)); + } + return this; + } +}; +uo.prototype.isSplineCurve = !0; +var Ta = Object.freeze({ + __proto__: null, + ArcCurve: Ma, + CatmullRomCurve3: wa, + CubicBezierCurve: lo, + CubicBezierCurve3: Sa, + EllipseCurve: Ur, + LineCurve: Or, + LineCurve3: Eh, + QuadraticBezierCurve: co, + QuadraticBezierCurve3: ho, + SplineCurve: uo +}), Ah = class extends Ct { + constructor(){ + super(); + this.type = "CurvePath", this.curves = [], this.autoClose = !1; + } + add(e) { + this.curves.push(e); + } + closePath() { + let e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1); + e.equals(t) || this.curves.push(new Or(t, e)); + } + getPoint(e, t) { + let n = e * this.getLength(), i = this.getCurveLengths(), r = 0; + for(; r < i.length;){ + if (i[r] >= n) { + let o = i[r] - n, a = this.curves[r], l = a.getLength(), c = l === 0 ? 0 : 1 - o / l; + return a.getPointAt(c, t); + } + r++; + } + return null; + } + getLength() { + let e = this.getCurveLengths(); + return e[e.length - 1]; + } + updateArcLengths() { + this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths(); + } + getCurveLengths() { + if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; + let e = [], t = 0; + for(let n = 0, i = this.curves.length; n < i; n++)t += this.curves[n].getLength(), e.push(t); + return this.cacheLengths = e, e; + } + getSpacedPoints(e = 40) { + let t = []; + for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); + return this.autoClose && t.push(t[0]), t; + } + getPoints(e = 12) { + let t = [], n; + for(let i = 0, r = this.curves; i < r.length; i++){ + let o = r[i], a = o && o.isEllipseCurve ? e * 2 : o && (o.isLineCurve || o.isLineCurve3) ? 1 : o && o.isSplineCurve ? e * o.points.length : e, l = o.getPoints(a); + for(let c = 0; c < l.length; c++){ + let h = l[c]; + n && n.equals(h) || (t.push(h), n = h); + } + } + return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; + } + copy(e) { + super.copy(e), this.curves = []; + for(let t = 0, n = e.curves.length; t < n; t++){ + let i = e.curves[t]; + this.curves.push(i.clone()); + } + return this.autoClose = e.autoClose, this; + } + toJSON() { + let e = super.toJSON(); + e.autoClose = this.autoClose, e.curves = []; + for(let t = 0, n = this.curves.length; t < n; t++){ + let i = this.curves[t]; + e.curves.push(i.toJSON()); + } + return e; + } + fromJSON(e) { + super.fromJSON(e), this.autoClose = e.autoClose, this.curves = []; + for(let t = 0, n = e.curves.length; t < n; t++){ + let i = e.curves[t]; + this.curves.push(new Ta[i.type]().fromJSON(i)); + } + return this; + } +}, gr = class extends Ah { + constructor(e){ + super(); + this.type = "Path", this.currentPoint = new X, e && this.setFromPoints(e); + } + setFromPoints(e) { + this.moveTo(e[0].x, e[0].y); + for(let t = 1, n = e.length; t < n; t++)this.lineTo(e[t].x, e[t].y); + return this; + } + moveTo(e, t) { + return this.currentPoint.set(e, t), this; + } + lineTo(e, t) { + let n = new Or(this.currentPoint.clone(), new X(e, t)); + return this.curves.push(n), this.currentPoint.set(e, t), this; + } + quadraticCurveTo(e, t, n, i) { + let r = new co(this.currentPoint.clone(), new X(e, t), new X(n, i)); + return this.curves.push(r), this.currentPoint.set(n, i), this; + } + bezierCurveTo(e, t, n, i, r, o) { + let a = new lo(this.currentPoint.clone(), new X(e, t), new X(n, i), new X(r, o)); + return this.curves.push(a), this.currentPoint.set(r, o), this; + } + splineThru(e) { + let t = [ + this.currentPoint.clone() + ].concat(e), n = new uo(t); + return this.curves.push(n), this.currentPoint.copy(e[e.length - 1]), this; + } + arc(e, t, n, i, r, o) { + let a = this.currentPoint.x, l = this.currentPoint.y; + return this.absarc(e + a, t + l, n, i, r, o), this; + } + absarc(e, t, n, i, r, o) { + return this.absellipse(e, t, n, n, i, r, o), this; + } + ellipse(e, t, n, i, r, o, a, l) { + let c = this.currentPoint.x, h = this.currentPoint.y; + return this.absellipse(e + c, t + h, n, i, r, o, a, l), this; + } + absellipse(e, t, n, i, r, o, a, l) { + let c = new Ur(e, t, n, i, r, o, a, l); + if (this.curves.length > 0) { + let u = c.getPoint(0); + u.equals(this.currentPoint) || this.lineTo(u.x, u.y); + } + this.curves.push(c); + let h = c.getPoint(1); + return this.currentPoint.copy(h), this; + } + copy(e) { + return super.copy(e), this.currentPoint.copy(e.currentPoint), this; + } + toJSON() { + let e = super.toJSON(); + return e.currentPoint = this.currentPoint.toArray(), e; + } + fromJSON(e) { + return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this; + } +}, Xt = class extends gr { + constructor(e){ + super(e); + this.uuid = Et(), this.type = "Shape", this.holes = []; + } + getPointsHoles(e) { + let t = []; + for(let n = 0, i = this.holes.length; n < i; n++)t[n] = this.holes[n].getPoints(e); + return t; + } + extractPoints(e) { + return { + shape: this.getPoints(e), + holes: this.getPointsHoles(e) + }; + } + copy(e) { + super.copy(e), this.holes = []; + for(let t = 0, n = e.holes.length; t < n; t++){ + let i = e.holes[t]; + this.holes.push(i.clone()); + } + return this; + } + toJSON() { + let e = super.toJSON(); + e.uuid = this.uuid, e.holes = []; + for(let t = 0, n = this.holes.length; t < n; t++){ + let i = this.holes[t]; + e.holes.push(i.toJSON()); + } + return e; + } + fromJSON(e) { + super.fromJSON(e), this.uuid = e.uuid, this.holes = []; + for(let t = 0, n = e.holes.length; t < n; t++){ + let i = e.holes[t]; + this.holes.push(new gr().fromJSON(i)); + } + return this; + } +}, Ox = { + triangulate: function(s, e, t = 2) { + let n = e && e.length, i = n ? e[0] * t : s.length, r = Ch(s, 0, i, t, !0), o = []; + if (!r || r.next === r.prev) return o; + let a, l, c, h, u, d, f; + if (n && (r = Wx(s, e, r, t)), s.length > 80 * t) { + a = c = s[0], l = h = s[1]; + for(let m = t; m < i; m += t)u = s[m], d = s[m + 1], u < a && (a = u), d < l && (l = d), u > c && (c = u), d > h && (h = d); + f = Math.max(c - a, h - l), f = f !== 0 ? 1 / f : 0; + } + return xr(r, o, t, a, l, f), o; + } +}; +function Ch(s, e, t, n, i) { + let r, o; + if (i === ty(s, e, t, n) > 0) for(r = e; r < t; r += n)o = mc(r, s[r], s[r + 1], o); + else for(r = t - n; r >= e; r -= n)o = mc(r, s[r], s[r + 1], o); + return o && fo(o, o.next) && (vr(o), o = o.next), o; +} +function Tn(s, e) { + if (!s) return s; + e || (e = s); + let t = s, n; + do if (n = !1, !t.steiner && (fo(t, t.next) || $e(t.prev, t, t.next) === 0)) { + if (vr(t), t = e = t.prev, t === t.next) break; + n = !0; + } else t = t.next; + while (n || t !== e) + return e; +} +function xr(s, e, t, n, i, r, o) { + if (!s) return; + !o && r && Zx(s, n, i, r); + let a = s, l, c; + for(; s.prev !== s.next;){ + if (l = s.prev, c = s.next, r ? kx(s, n, i, r) : Hx(s)) { + e.push(l.i / t), e.push(s.i / t), e.push(c.i / t), vr(s), s = c.next, a = c.next; + continue; + } + if (s = c, s === a) { + o ? o === 1 ? (s = Gx(Tn(s), e, t), xr(s, e, t, n, i, r, 2)) : o === 2 && Vx(s, e, t, n, i, r) : xr(Tn(s), e, t, n, i, r, 1); + break; + } + } +} +function Hx(s) { + let e = s.prev, t = s, n = s.next; + if ($e(e, t, n) >= 0) return !1; + let i = s.next.next; + for(; i !== s.prev;){ + if (Si(e.x, e.y, t.x, t.y, n.x, n.y, i.x, i.y) && $e(i.prev, i, i.next) >= 0) return !1; + i = i.next; + } + return !0; +} +function kx(s, e, t, n) { + let i = s.prev, r = s, o = s.next; + if ($e(i, r, o) >= 0) return !1; + let a = i.x < r.x ? i.x < o.x ? i.x : o.x : r.x < o.x ? r.x : o.x, l = i.y < r.y ? i.y < o.y ? i.y : o.y : r.y < o.y ? r.y : o.y, c = i.x > r.x ? i.x > o.x ? i.x : o.x : r.x > o.x ? r.x : o.x, h = i.y > r.y ? i.y > o.y ? i.y : o.y : r.y > o.y ? r.y : o.y, u = oa(a, l, e, t, n), d = oa(c, h, e, t, n), f = s.prevZ, m = s.nextZ; + for(; f && f.z >= u && m && m.z <= d;){ + if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0 || (f = f.prevZ, m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0)) return !1; + m = m.nextZ; + } + for(; f && f.z >= u;){ + if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0) return !1; + f = f.prevZ; + } + for(; m && m.z <= d;){ + if (m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0) return !1; + m = m.nextZ; + } + return !0; +} +function Gx(s, e, t) { + let n = s; + do { + let i = n.prev, r = n.next.next; + !fo(i, r) && Lh(i, n, n.next, r) && yr(i, r) && yr(r, i) && (e.push(i.i / t), e.push(n.i / t), e.push(r.i / t), vr(n), vr(n.next), n = s = r), n = n.next; + }while (n !== s) + return Tn(n); +} +function Vx(s, e, t, n, i, r) { + let o = s; + do { + let a = o.next.next; + for(; a !== o.prev;){ + if (o.i !== a.i && Qx(o, a)) { + let l = Rh(o, a); + o = Tn(o, o.next), l = Tn(l, l.next), xr(o, e, t, n, i, r), xr(l, e, t, n, i, r); + return; + } + a = a.next; + } + o = o.next; + }while (o !== s) +} +function Wx(s, e, t, n) { + let i = [], r, o, a, l, c; + for(r = 0, o = e.length; r < o; r++)a = e[r] * n, l = r < o - 1 ? e[r + 1] * n : s.length, c = Ch(s, a, l, n, !1), c === c.next && (c.steiner = !0), i.push(jx(c)); + for(i.sort(qx), r = 0; r < i.length; r++)Xx(i[r], t), t = Tn(t, t.next); + return t; +} +function qx(s, e) { + return s.x - e.x; +} +function Xx(s, e) { + if (e = Jx(s, e), e) { + let t = Rh(e, s); + Tn(e, e.next), Tn(t, t.next); + } +} +function Jx(s, e) { + let t = e, n = s.x, i = s.y, r = -1 / 0, o; + do { + if (i <= t.y && i >= t.next.y && t.next.y !== t.y) { + let d = t.x + (i - t.y) * (t.next.x - t.x) / (t.next.y - t.y); + if (d <= n && d > r) { + if (r = d, d === n) { + if (i === t.y) return t; + if (i === t.next.y) return t.next; + } + o = t.x < t.next.x ? t : t.next; + } + } + t = t.next; + }while (t !== e) + if (!o) return null; + if (n === r) return o; + let a = o, l = o.x, c = o.y, h = 1 / 0, u; + t = o; + do n >= t.x && t.x >= l && n !== t.x && Si(i < c ? n : r, i, l, c, i < c ? r : n, i, t.x, t.y) && (u = Math.abs(i - t.y) / (n - t.x), yr(t, s) && (u < h || u === h && (t.x > o.x || t.x === o.x && Yx(o, t))) && (o = t, h = u)), t = t.next; + while (t !== a) + return o; +} +function Yx(s, e) { + return $e(s.prev, s, e.prev) < 0 && $e(e.next, s, s.next) < 0; +} +function Zx(s, e, t, n) { + let i = s; + do i.z === null && (i.z = oa(i.x, i.y, e, t, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next; + while (i !== s) + i.prevZ.nextZ = null, i.prevZ = null, $x(i); +} +function $x(s) { + let e, t, n, i, r, o, a, l, c = 1; + do { + for(t = s, s = null, r = null, o = 0; t;){ + for(o++, n = t, a = 0, e = 0; e < c && (a++, n = n.nextZ, !!n); e++); + for(l = c; a > 0 || l > 0 && n;)a !== 0 && (l === 0 || !n || t.z <= n.z) ? (i = t, t = t.nextZ, a--) : (i = n, n = n.nextZ, l--), r ? r.nextZ = i : s = i, i.prevZ = r, r = i; + t = n; + } + r.nextZ = null, c *= 2; + }while (o > 1) + return s; +} +function oa(s, e, t, n, i) { + return s = 32767 * (s - t) * i, e = 32767 * (e - n) * i, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, s | e << 1; +} +function jx(s) { + let e = s, t = s; + do (e.x < t.x || e.x === t.x && e.y < t.y) && (t = e), e = e.next; + while (e !== s) + return t; +} +function Si(s, e, t, n, i, r, o, a) { + return (i - o) * (e - a) - (s - o) * (r - a) >= 0 && (s - o) * (n - a) - (t - o) * (e - a) >= 0 && (t - o) * (r - a) - (i - o) * (n - a) >= 0; +} +function Qx(s, e) { + return s.next.i !== e.i && s.prev.i !== e.i && !Kx(s, e) && (yr(s, e) && yr(e, s) && ey(s, e) && ($e(s.prev, s, e.prev) || $e(s, e.prev, e)) || fo(s, e) && $e(s.prev, s, s.next) > 0 && $e(e.prev, e, e.next) > 0); +} +function $e(s, e, t) { + return (e.y - s.y) * (t.x - e.x) - (e.x - s.x) * (t.y - e.y); +} +function fo(s, e) { + return s.x === e.x && s.y === e.y; +} +function Lh(s, e, t, n) { + let i = ws($e(s, e, t)), r = ws($e(s, e, n)), o = ws($e(t, n, s)), a = ws($e(t, n, e)); + return !!(i !== r && o !== a || i === 0 && bs(s, t, e) || r === 0 && bs(s, n, e) || o === 0 && bs(t, s, n) || a === 0 && bs(t, e, n)); +} +function bs(s, e, t) { + return e.x <= Math.max(s.x, t.x) && e.x >= Math.min(s.x, t.x) && e.y <= Math.max(s.y, t.y) && e.y >= Math.min(s.y, t.y); +} +function ws(s) { + return s > 0 ? 1 : s < 0 ? -1 : 0; +} +function Kx(s, e) { + let t = s; + do { + if (t.i !== s.i && t.next.i !== s.i && t.i !== e.i && t.next.i !== e.i && Lh(t, t.next, s, e)) return !0; + t = t.next; + }while (t !== s) + return !1; +} +function yr(s, e) { + return $e(s.prev, s, s.next) < 0 ? $e(s, e, s.next) >= 0 && $e(s, s.prev, e) >= 0 : $e(s, e, s.prev) < 0 || $e(s, s.next, e) < 0; +} +function ey(s, e) { + let t = s, n = !1, i = (s.x + e.x) / 2, r = (s.y + e.y) / 2; + do t.y > r != t.next.y > r && t.next.y !== t.y && i < (t.next.x - t.x) * (r - t.y) / (t.next.y - t.y) + t.x && (n = !n), t = t.next; + while (t !== s) + return n; +} +function Rh(s, e) { + let t = new aa(s.i, s.x, s.y), n = new aa(e.i, e.x, e.y), i = s.next, r = e.prev; + return s.next = e, e.prev = s, t.next = i, i.prev = t, n.next = t, t.prev = n, r.next = n, n.prev = r, n; +} +function mc(s, e, t, n) { + let i = new aa(s, e, t); + return n ? (i.next = n.next, i.prev = n, n.next.prev = i, n.next = i) : (i.prev = i, i.next = i), i; +} +function vr(s) { + s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ); +} +function aa(s, e, t) { + this.i = s, this.x = e, this.y = t, this.prev = null, this.next = null, this.z = null, this.prevZ = null, this.nextZ = null, this.steiner = !1; +} +function ty(s, e, t, n) { + let i = 0; + for(let r = e, o = t - n; r < t; r += n)i += (s[o] - s[r]) * (s[r + 1] + s[o + 1]), o = r; + return i; +} +var Jt = class { + static area(e) { + let t = e.length, n = 0; + for(let i = t - 1, r = 0; r < t; i = r++)n += e[i].x * e[r].y - e[r].x * e[i].y; + return n * .5; + } + static isClockWise(e) { + return Jt.area(e) < 0; + } + static triangulateShape(e, t) { + let n = [], i = [], r = []; + gc(e), xc(n, e); + let o = e.length; + t.forEach(gc); + for(let l = 0; l < t.length; l++)i.push(o), o += t[l].length, xc(n, t[l]); + let a = Ox.triangulate(n, i); + for(let l = 0; l < a.length; l += 3)r.push(a.slice(l, l + 3)); + return r; + } +}; +function gc(s) { + let e = s.length; + e > 2 && s[e - 1].equals(s[0]) && s.pop(); +} +function xc(s, e) { + for(let t = 0; t < e.length; t++)s.push(e[t].x), s.push(e[t].y); +} +var ln = class extends _e { + constructor(e = new Xt([ + new X(.5, .5), + new X(-.5, .5), + new X(-.5, -.5), + new X(.5, -.5) + ]), t = {}){ + super(); + this.type = "ExtrudeGeometry", this.parameters = { + shapes: e, + options: t + }, e = Array.isArray(e) ? e : [ + e + ]; + let n = this, i = [], r = []; + for(let a = 0, l = e.length; a < l; a++){ + let c = e[a]; + o(c); + } + this.setAttribute("position", new de(i, 3)), this.setAttribute("uv", new de(r, 2)), this.computeVertexNormals(); + function o(a) { + let l = [], c = t.curveSegments !== void 0 ? t.curveSegments : 12, h = t.steps !== void 0 ? t.steps : 1, u = t.depth !== void 0 ? t.depth : 1, d = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, f = t.bevelThickness !== void 0 ? t.bevelThickness : .2, m = t.bevelSize !== void 0 ? t.bevelSize : f - .1, x = t.bevelOffset !== void 0 ? t.bevelOffset : 0, v = t.bevelSegments !== void 0 ? t.bevelSegments : 3, g = t.extrudePath, p = t.UVGenerator !== void 0 ? t.UVGenerator : ny; + t.amount !== void 0 && (console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."), u = t.amount); + let _, y = !1, b, A, L, I; + g && (_ = g.getSpacedPoints(h), y = !0, d = !1, b = g.computeFrenetFrames(h, !1), A = new M, L = new M, I = new M), d || (v = 0, f = 0, m = 0, x = 0); + let k = a.extractPoints(c), B = k.shape, P = k.holes; + if (!Jt.isClockWise(B)) { + B = B.reverse(); + for(let G = 0, j = P.length; G < j; G++){ + let K = P[G]; + Jt.isClockWise(K) && (P[G] = K.reverse()); + } + } + let E = Jt.triangulateShape(B, P), D = B; + for(let G = 0, j = P.length; G < j; G++){ + let K = P[G]; + B = B.concat(K); + } + function U(G, j, K) { + return j || console.error("THREE.ExtrudeGeometry: vec does not exist"), j.clone().multiplyScalar(K).add(G); + } + let F = B.length, O = E.length; + function ne(G, j, K) { + let ue, se, Se, Te = G.x - j.x, Pe = G.y - j.y, Ye = K.x - G.x, C = K.y - G.y, T = Te * Te + Pe * Pe, J = Te * C - Pe * Ye; + if (Math.abs(J) > Number.EPSILON) { + let $ = Math.sqrt(T), re = Math.sqrt(Ye * Ye + C * C), Z = j.x - Pe / $, Me = j.y + Te / $, ve = K.x - C / re, te = K.y + Ye / re, R = ((ve - Z) * C - (te - Me) * Ye) / (Te * C - Pe * Ye); + ue = Z + Te * R - G.x, se = Me + Pe * R - G.y; + let ee = ue * ue + se * se; + if (ee <= 2) return new X(ue, se); + Se = Math.sqrt(ee / 2); + } else { + let $ = !1; + Te > Number.EPSILON ? Ye > Number.EPSILON && ($ = !0) : Te < -Number.EPSILON ? Ye < -Number.EPSILON && ($ = !0) : Math.sign(Pe) === Math.sign(C) && ($ = !0), $ ? (ue = -Pe, se = Te, Se = Math.sqrt(T)) : (ue = Te, se = Pe, Se = Math.sqrt(T / 2)); + } + return new X(ue / Se, se / Se); + } + let ce = []; + for(let G = 0, j = D.length, K = j - 1, ue = G + 1; G < j; G++, K++, ue++)K === j && (K = 0), ue === j && (ue = 0), ce[G] = ne(D[G], D[K], D[ue]); + let V = [], W, he = ce.concat(); + for(let G = 0, j = P.length; G < j; G++){ + let K = P[G]; + W = []; + for(let ue = 0, se = K.length, Se = se - 1, Te = ue + 1; ue < se; ue++, Se++, Te++)Se === se && (Se = 0), Te === se && (Te = 0), W[ue] = ne(K[ue], K[Se], K[Te]); + V.push(W), he = he.concat(W); + } + for(let G = 0; G < v; G++){ + let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; + for(let se = 0, Se = D.length; se < Se; se++){ + let Te = U(D[se], ce[se], ue); + Ce(Te.x, Te.y, -K); + } + for(let se = 0, Se = P.length; se < Se; se++){ + let Te = P[se]; + W = V[se]; + for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ + let C = U(Te[Pe], W[Pe], ue); + Ce(C.x, C.y, -K); + } + } + } + let le = m + x; + for(let G = 0; G < F; G++){ + let j = d ? U(B[G], he[G], le) : B[G]; + y ? (L.copy(b.normals[0]).multiplyScalar(j.x), A.copy(b.binormals[0]).multiplyScalar(j.y), I.copy(_[0]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(j.x, j.y, 0); + } + for(let G = 1; G <= h; G++)for(let j = 0; j < F; j++){ + let K = d ? U(B[j], he[j], le) : B[j]; + y ? (L.copy(b.normals[G]).multiplyScalar(K.x), A.copy(b.binormals[G]).multiplyScalar(K.y), I.copy(_[G]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(K.x, K.y, u / h * G); + } + for(let G = v - 1; G >= 0; G--){ + let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; + for(let se = 0, Se = D.length; se < Se; se++){ + let Te = U(D[se], ce[se], ue); + Ce(Te.x, Te.y, u + K); + } + for(let se = 0, Se = P.length; se < Se; se++){ + let Te = P[se]; + W = V[se]; + for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ + let C = U(Te[Pe], W[Pe], ue); + y ? Ce(C.x, C.y + _[h - 1].y, _[h - 1].x + K) : Ce(C.x, C.y, u + K); + } + } + } + fe(), Be(); + function fe() { + let G = i.length / 3; + if (d) { + let j = 0, K = F * j; + for(let ue = 0; ue < O; ue++){ + let se = E[ue]; + ye(se[2] + K, se[1] + K, se[0] + K); + } + j = h + v * 2, K = F * j; + for(let ue = 0; ue < O; ue++){ + let se = E[ue]; + ye(se[0] + K, se[1] + K, se[2] + K); + } + } else { + for(let j = 0; j < O; j++){ + let K = E[j]; + ye(K[2], K[1], K[0]); + } + for(let j = 0; j < O; j++){ + let K = E[j]; + ye(K[0] + F * h, K[1] + F * h, K[2] + F * h); + } + } + n.addGroup(G, i.length / 3 - G, 0); + } + function Be() { + let G = i.length / 3, j = 0; + Y(D, j), j += D.length; + for(let K = 0, ue = P.length; K < ue; K++){ + let se = P[K]; + Y(se, j), j += se.length; + } + n.addGroup(G, i.length / 3 - G, 1); + } + function Y(G, j) { + let K = G.length; + for(; --K >= 0;){ + let ue = K, se = K - 1; + se < 0 && (se = G.length - 1); + for(let Se = 0, Te = h + v * 2; Se < Te; Se++){ + let Pe = F * Se, Ye = F * (Se + 1), C = j + ue + Pe, T = j + se + Pe, J = j + se + Ye, $ = j + ue + Ye; + ge(C, T, J, $); + } + } + } + function Ce(G, j, K) { + l.push(G), l.push(j), l.push(K); + } + function ye(G, j, K) { + xe(G), xe(j), xe(K); + let ue = i.length / 3, se = p.generateTopUV(n, i, ue - 3, ue - 2, ue - 1); + Oe(se[0]), Oe(se[1]), Oe(se[2]); + } + function ge(G, j, K, ue) { + xe(G), xe(j), xe(ue), xe(j), xe(K), xe(ue); + let se = i.length / 3, Se = p.generateSideWallUV(n, i, se - 6, se - 3, se - 2, se - 1); + Oe(Se[0]), Oe(Se[1]), Oe(Se[3]), Oe(Se[1]), Oe(Se[2]), Oe(Se[3]); + } + function xe(G) { + i.push(l[G * 3 + 0]), i.push(l[G * 3 + 1]), i.push(l[G * 3 + 2]); + } + function Oe(G) { + r.push(G.x), r.push(G.y); + } + } + } + toJSON() { + let e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options; + return iy(t, n, e); + } + static fromJSON(e, t) { + let n = []; + for(let r = 0, o = e.shapes.length; r < o; r++){ + let a = t[e.shapes[r]]; + n.push(a); + } + let i = e.options.extrudePath; + return i !== void 0 && (e.options.extrudePath = new Ta[i.type]().fromJSON(i)), new ln(n, e.options); + } +}, ny = { + generateTopUV: function(s, e, t, n, i) { + let r = e[t * 3], o = e[t * 3 + 1], a = e[n * 3], l = e[n * 3 + 1], c = e[i * 3], h = e[i * 3 + 1]; + return [ + new X(r, o), + new X(a, l), + new X(c, h) + ]; + }, + generateSideWallUV: function(s, e, t, n, i, r) { + let o = e[t * 3], a = e[t * 3 + 1], l = e[t * 3 + 2], c = e[n * 3], h = e[n * 3 + 1], u = e[n * 3 + 2], d = e[i * 3], f = e[i * 3 + 1], m = e[i * 3 + 2], x = e[r * 3], v = e[r * 3 + 1], g = e[r * 3 + 2]; + return Math.abs(a - h) < Math.abs(o - c) ? [ + new X(o, 1 - l), + new X(c, 1 - u), + new X(d, 1 - m), + new X(x, 1 - g) + ] : [ + new X(a, 1 - l), + new X(h, 1 - u), + new X(f, 1 - m), + new X(v, 1 - g) + ]; + } +}; +function iy(s, e, t) { + if (t.shapes = [], Array.isArray(s)) for(let n = 0, i = s.length; n < i; n++){ + let r = s[n]; + t.shapes.push(r.uuid); + } + else t.shapes.push(s.uuid); + return e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t; +} +var _r = class extends an { + constructor(e = 1, t = 0){ + let n = (1 + Math.sqrt(5)) / 2, i = [ + -1, + n, + 0, + 1, + n, + 0, + -1, + -n, + 0, + 1, + -n, + 0, + 0, + -1, + n, + 0, + 1, + n, + 0, + -1, + -n, + 0, + 1, + -n, + n, + 0, + -1, + n, + 0, + 1, + -n, + 0, + -1, + -n, + 0, + 1 + ], r = [ + 0, + 11, + 5, + 0, + 5, + 1, + 0, + 1, + 7, + 0, + 7, + 10, + 0, + 10, + 11, + 1, + 5, + 9, + 5, + 11, + 4, + 11, + 10, + 2, + 10, + 7, + 6, + 7, + 1, + 8, + 3, + 9, + 4, + 3, + 4, + 2, + 3, + 2, + 6, + 3, + 6, + 8, + 3, + 8, + 9, + 4, + 9, + 5, + 2, + 4, + 11, + 6, + 2, + 10, + 8, + 6, + 7, + 9, + 8, + 1 + ]; + super(i, r, e, t); + this.type = "IcosahedronGeometry", this.parameters = { + radius: e, + detail: t + }; + } + static fromJSON(e) { + return new _r(e.radius, e.detail); + } +}, Mr = class extends _e { + constructor(e = [ + new X(0, .5), + new X(.5, 0), + new X(0, -.5) + ], t = 12, n = 0, i = Math.PI * 2){ + super(); + this.type = "LatheGeometry", this.parameters = { + points: e, + segments: t, + phiStart: n, + phiLength: i + }, t = Math.floor(t), i = mt(i, 0, Math.PI * 2); + let r = [], o = [], a = [], l = [], c = [], h = 1 / t, u = new M, d = new X, f = new M, m = new M, x = new M, v = 0, g = 0; + for(let p = 0; p <= e.length - 1; p++)switch(p){ + case 0: + v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, x.copy(f), f.normalize(), l.push(f.x, f.y, f.z); + break; + case e.length - 1: + l.push(x.x, x.y, x.z); + break; + default: + v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, m.copy(f), f.x += x.x, f.y += x.y, f.z += x.z, f.normalize(), l.push(f.x, f.y, f.z), x.copy(m); + } + for(let p = 0; p <= t; p++){ + let _ = n + p * h * i, y = Math.sin(_), b = Math.cos(_); + for(let A = 0; A <= e.length - 1; A++){ + u.x = e[A].x * y, u.y = e[A].y, u.z = e[A].x * b, o.push(u.x, u.y, u.z), d.x = p / t, d.y = A / (e.length - 1), a.push(d.x, d.y); + let L = l[3 * A + 0] * y, I = l[3 * A + 1], k = l[3 * A + 0] * b; + c.push(L, I, k); + } + } + for(let p = 0; p < t; p++)for(let _ = 0; _ < e.length - 1; _++){ + let y = _ + p * e.length, b = y, A = y + e.length, L = y + e.length + 1, I = y + 1; + r.push(b, A, I), r.push(A, L, I); + } + this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("uv", new de(a, 2)), this.setAttribute("normal", new de(c, 3)); + } + static fromJSON(e) { + return new Mr(e.points, e.segments, e.phiStart, e.phiLength); + } +}, Ii = class extends an { + constructor(e = 1, t = 0){ + let n = [ + 1, + 0, + 0, + -1, + 0, + 0, + 0, + 1, + 0, + 0, + -1, + 0, + 0, + 0, + 1, + 0, + 0, + -1 + ], i = [ + 0, + 2, + 4, + 0, + 4, + 3, + 0, + 3, + 5, + 0, + 5, + 2, + 1, + 2, + 5, + 1, + 5, + 3, + 1, + 3, + 4, + 1, + 4, + 2 + ]; + super(n, i, e, t); + this.type = "OctahedronGeometry", this.parameters = { + radius: e, + detail: t + }; + } + static fromJSON(e) { + return new Ii(e.radius, e.detail); + } +}, br = class extends _e { + constructor(e = .5, t = 1, n = 8, i = 1, r = 0, o = Math.PI * 2){ + super(); + this.type = "RingGeometry", this.parameters = { + innerRadius: e, + outerRadius: t, + thetaSegments: n, + phiSegments: i, + thetaStart: r, + thetaLength: o + }, n = Math.max(3, n), i = Math.max(1, i); + let a = [], l = [], c = [], h = [], u = e, d = (t - e) / i, f = new M, m = new X; + for(let x = 0; x <= i; x++){ + for(let v = 0; v <= n; v++){ + let g = r + v / n * o; + f.x = u * Math.cos(g), f.y = u * Math.sin(g), l.push(f.x, f.y, f.z), c.push(0, 0, 1), m.x = (f.x / t + 1) / 2, m.y = (f.y / t + 1) / 2, h.push(m.x, m.y); + } + u += d; + } + for(let x = 0; x < i; x++){ + let v = x * (n + 1); + for(let g = 0; g < n; g++){ + let p = g + v, _ = p, y = p + n + 1, b = p + n + 2, A = p + 1; + a.push(_, y, A), a.push(y, b, A); + } + } + this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); + } + static fromJSON(e) { + return new br(e.innerRadius, e.outerRadius, e.thetaSegments, e.phiSegments, e.thetaStart, e.thetaLength); + } +}, Di = class extends _e { + constructor(e = new Xt([ + new X(0, .5), + new X(-.5, -.5), + new X(.5, -.5) + ]), t = 12){ + super(); + this.type = "ShapeGeometry", this.parameters = { + shapes: e, + curveSegments: t + }; + let n = [], i = [], r = [], o = [], a = 0, l = 0; + if (Array.isArray(e) === !1) c(e); + else for(let h = 0; h < e.length; h++)c(e[h]), this.addGroup(a, l, h), a += l, l = 0; + this.setIndex(n), this.setAttribute("position", new de(i, 3)), this.setAttribute("normal", new de(r, 3)), this.setAttribute("uv", new de(o, 2)); + function c(h) { + let u = i.length / 3, d = h.extractPoints(t), f = d.shape, m = d.holes; + Jt.isClockWise(f) === !1 && (f = f.reverse()); + for(let v = 0, g = m.length; v < g; v++){ + let p = m[v]; + Jt.isClockWise(p) === !0 && (m[v] = p.reverse()); + } + let x = Jt.triangulateShape(f, m); + for(let v = 0, g = m.length; v < g; v++){ + let p = m[v]; + f = f.concat(p); + } + for(let v = 0, g = f.length; v < g; v++){ + let p = f[v]; + i.push(p.x, p.y, 0), r.push(0, 0, 1), o.push(p.x, p.y); + } + for(let v = 0, g = x.length; v < g; v++){ + let p = x[v], _ = p[0] + u, y = p[1] + u, b = p[2] + u; + n.push(_, y, b), l += 3; + } + } + } + toJSON() { + let e = super.toJSON(), t = this.parameters.shapes; + return ry(t, e); + } + static fromJSON(e, t) { + let n = []; + for(let i = 0, r = e.shapes.length; i < r; i++){ + let o = t[e.shapes[i]]; + n.push(o); + } + return new Di(n, e.curveSegments); + } +}; +function ry(s, e) { + if (e.shapes = [], Array.isArray(s)) for(let t = 0, n = s.length; t < n; t++){ + let i = s[t]; + e.shapes.push(i.uuid); + } + else e.shapes.push(s.uuid); + return e; +} +var Fi = class extends _e { + constructor(e = 1, t = 32, n = 16, i = 0, r = Math.PI * 2, o = 0, a = Math.PI){ + super(); + this.type = "SphereGeometry", this.parameters = { + radius: e, + widthSegments: t, + heightSegments: n, + phiStart: i, + phiLength: r, + thetaStart: o, + thetaLength: a + }, t = Math.max(3, Math.floor(t)), n = Math.max(2, Math.floor(n)); + let l = Math.min(o + a, Math.PI), c = 0, h = [], u = new M, d = new M, f = [], m = [], x = [], v = []; + for(let g = 0; g <= n; g++){ + let p = [], _ = g / n, y = 0; + g == 0 && o == 0 ? y = .5 / t : g == n && l == Math.PI && (y = -.5 / t); + for(let b = 0; b <= t; b++){ + let A = b / t; + u.x = -e * Math.cos(i + A * r) * Math.sin(o + _ * a), u.y = e * Math.cos(o + _ * a), u.z = e * Math.sin(i + A * r) * Math.sin(o + _ * a), m.push(u.x, u.y, u.z), d.copy(u).normalize(), x.push(d.x, d.y, d.z), v.push(A + y, 1 - _), p.push(c++); + } + h.push(p); + } + for(let g = 0; g < n; g++)for(let p = 0; p < t; p++){ + let _ = h[g][p + 1], y = h[g][p], b = h[g + 1][p], A = h[g + 1][p + 1]; + (g !== 0 || o > 0) && f.push(_, y, A), (g !== n - 1 || l < Math.PI) && f.push(y, b, A); + } + this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); + } + static fromJSON(e) { + return new Fi(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); + } +}, wr = class extends an { + constructor(e = 1, t = 0){ + let n = [ + 1, + 1, + 1, + -1, + -1, + 1, + -1, + 1, + -1, + 1, + -1, + -1 + ], i = [ + 2, + 1, + 0, + 0, + 3, + 2, + 1, + 3, + 0, + 2, + 3, + 1 + ]; + super(n, i, e, t); + this.type = "TetrahedronGeometry", this.parameters = { + radius: e, + detail: t + }; + } + static fromJSON(e) { + return new wr(e.radius, e.detail); + } +}, Sr = class extends _e { + constructor(e = 1, t = .4, n = 8, i = 6, r = Math.PI * 2){ + super(); + this.type = "TorusGeometry", this.parameters = { + radius: e, + tube: t, + radialSegments: n, + tubularSegments: i, + arc: r + }, n = Math.floor(n), i = Math.floor(i); + let o = [], a = [], l = [], c = [], h = new M, u = new M, d = new M; + for(let f = 0; f <= n; f++)for(let m = 0; m <= i; m++){ + let x = m / i * r, v = f / n * Math.PI * 2; + u.x = (e + t * Math.cos(v)) * Math.cos(x), u.y = (e + t * Math.cos(v)) * Math.sin(x), u.z = t * Math.sin(v), a.push(u.x, u.y, u.z), h.x = e * Math.cos(x), h.y = e * Math.sin(x), d.subVectors(u, h).normalize(), l.push(d.x, d.y, d.z), c.push(m / i), c.push(f / n); + } + for(let f = 1; f <= n; f++)for(let m = 1; m <= i; m++){ + let x = (i + 1) * f + m - 1, v = (i + 1) * (f - 1) + m - 1, g = (i + 1) * (f - 1) + m, p = (i + 1) * f + m; + o.push(x, v, p), o.push(v, g, p); + } + this.setIndex(o), this.setAttribute("position", new de(a, 3)), this.setAttribute("normal", new de(l, 3)), this.setAttribute("uv", new de(c, 2)); + } + static fromJSON(e) { + return new Sr(e.radius, e.tube, e.radialSegments, e.tubularSegments, e.arc); + } +}, Tr = class extends _e { + constructor(e = 1, t = .4, n = 64, i = 8, r = 2, o = 3){ + super(); + this.type = "TorusKnotGeometry", this.parameters = { + radius: e, + tube: t, + tubularSegments: n, + radialSegments: i, + p: r, + q: o + }, n = Math.floor(n), i = Math.floor(i); + let a = [], l = [], c = [], h = [], u = new M, d = new M, f = new M, m = new M, x = new M, v = new M, g = new M; + for(let _ = 0; _ <= n; ++_){ + let y = _ / n * r * Math.PI * 2; + p(y, r, o, e, f), p(y + .01, r, o, e, m), v.subVectors(m, f), g.addVectors(m, f), x.crossVectors(v, g), g.crossVectors(x, v), x.normalize(), g.normalize(); + for(let b = 0; b <= i; ++b){ + let A = b / i * Math.PI * 2, L = -t * Math.cos(A), I = t * Math.sin(A); + u.x = f.x + (L * g.x + I * x.x), u.y = f.y + (L * g.y + I * x.y), u.z = f.z + (L * g.z + I * x.z), l.push(u.x, u.y, u.z), d.subVectors(u, f).normalize(), c.push(d.x, d.y, d.z), h.push(_ / n), h.push(b / i); + } + } + for(let _ = 1; _ <= n; _++)for(let y = 1; y <= i; y++){ + let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; + a.push(b, A, I), a.push(A, L, I); + } + this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); + function p(_, y, b, A, L) { + let I = Math.cos(_), k = Math.sin(_), B = b / y * _, P = Math.cos(B); + L.x = A * (2 + P) * .5 * I, L.y = A * (2 + P) * k * .5, L.z = A * Math.sin(B) * .5; + } + } + static fromJSON(e) { + return new Tr(e.radius, e.tube, e.tubularSegments, e.radialSegments, e.p, e.q); + } +}, Er = class extends _e { + constructor(e = new ho(new M(-1, -1, 0), new M(-1, 1, 0), new M(1, 1, 0)), t = 64, n = 1, i = 8, r = !1){ + super(); + this.type = "TubeGeometry", this.parameters = { + path: e, + tubularSegments: t, + radius: n, + radialSegments: i, + closed: r + }; + let o = e.computeFrenetFrames(t, r); + this.tangents = o.tangents, this.normals = o.normals, this.binormals = o.binormals; + let a = new M, l = new M, c = new X, h = new M, u = [], d = [], f = [], m = []; + x(), this.setIndex(m), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); + function x() { + for(let _ = 0; _ < t; _++)v(_); + v(r === !1 ? t : 0), p(), g(); + } + function v(_) { + h = e.getPointAt(_ / t, h); + let y = o.normals[_], b = o.binormals[_]; + for(let A = 0; A <= i; A++){ + let L = A / i * Math.PI * 2, I = Math.sin(L), k = -Math.cos(L); + l.x = k * y.x + I * b.x, l.y = k * y.y + I * b.y, l.z = k * y.z + I * b.z, l.normalize(), d.push(l.x, l.y, l.z), a.x = h.x + n * l.x, a.y = h.y + n * l.y, a.z = h.z + n * l.z, u.push(a.x, a.y, a.z); + } + } + function g() { + for(let _ = 1; _ <= t; _++)for(let y = 1; y <= i; y++){ + let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; + m.push(b, A, I), m.push(A, L, I); + } + } + function p() { + for(let _ = 0; _ <= t; _++)for(let y = 0; y <= i; y++)c.x = _ / t, c.y = y / i, f.push(c.x, c.y); + } + } + toJSON() { + let e = super.toJSON(); + return e.path = this.parameters.path.toJSON(), e; + } + static fromJSON(e) { + return new Er(new Ta[e.path.type]().fromJSON(e.path), e.tubularSegments, e.radius, e.radialSegments, e.closed); + } +}, Ea = class extends _e { + constructor(e = null){ + super(); + if (this.type = "WireframeGeometry", this.parameters = { + geometry: e + }, e !== null) { + let t = [], n = new Set, i = new M, r = new M; + if (e.index !== null) { + let o = e.attributes.position, a = e.index, l = e.groups; + l.length === 0 && (l = [ + { + start: 0, + count: a.count, + materialIndex: 0 + } + ]); + for(let c = 0, h = l.length; c < h; ++c){ + let u = l[c], d = u.start, f = u.count; + for(let m = d, x = d + f; m < x; m += 3)for(let v = 0; v < 3; v++){ + let g = a.getX(m + v), p = a.getX(m + (v + 1) % 3); + i.fromBufferAttribute(o, g), r.fromBufferAttribute(o, p), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); + } + } + } else { + let o = e.attributes.position; + for(let a = 0, l = o.count / 3; a < l; a++)for(let c = 0; c < 3; c++){ + let h = 3 * a + c, u = 3 * a + (c + 1) % 3; + i.fromBufferAttribute(o, h), r.fromBufferAttribute(o, u), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); + } + } + this.setAttribute("position", new de(t, 3)); + } + } +}; +function yc(s, e, t) { + let n = `${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`, i = `${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`; + return t.has(n) === !0 || t.has(i) === !0 ? !1 : (t.add(n, i), !0); +} +var vc = Object.freeze({ + __proto__: null, + BoxGeometry: wn, + BoxBufferGeometry: wn, + CircleGeometry: fr, + CircleBufferGeometry: fr, + ConeGeometry: pr, + ConeBufferGeometry: pr, + CylinderGeometry: Jn, + CylinderBufferGeometry: Jn, + DodecahedronGeometry: mr, + DodecahedronBufferGeometry: mr, + EdgesGeometry: _a, + ExtrudeGeometry: ln, + ExtrudeBufferGeometry: ln, + IcosahedronGeometry: _r, + IcosahedronBufferGeometry: _r, + LatheGeometry: Mr, + LatheBufferGeometry: Mr, + OctahedronGeometry: Ii, + OctahedronBufferGeometry: Ii, + PlaneGeometry: Pi, + PlaneBufferGeometry: Pi, + PolyhedronGeometry: an, + PolyhedronBufferGeometry: an, + RingGeometry: br, + RingBufferGeometry: br, + ShapeGeometry: Di, + ShapeBufferGeometry: Di, + SphereGeometry: Fi, + SphereBufferGeometry: Fi, + TetrahedronGeometry: wr, + TetrahedronBufferGeometry: wr, + TorusGeometry: Sr, + TorusBufferGeometry: Sr, + TorusKnotGeometry: Tr, + TorusKnotBufferGeometry: Tr, + TubeGeometry: Er, + TubeBufferGeometry: Er, + WireframeGeometry: Ea +}), Aa = class extends dt { + constructor(e){ + super(); + this.type = "ShadowMaterial", this.color = new ae(0), this.transparent = !0, this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this; + } +}; +Aa.prototype.isShadowMaterial = !0; +var po = class extends dt { + constructor(e){ + super(); + this.defines = { + STANDARD: "" + }, this.type = "MeshStandardMaterial", this.color = new ae(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapIntensity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.defines = { + STANDARD: "" + }, this.color.copy(e.color), this.roughness = e.roughness, this.metalness = e.metalness, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.roughnessMap = e.roughnessMap, this.metalnessMap = e.metalnessMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapIntensity = e.envMapIntensity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; + } +}; +po.prototype.isMeshStandardMaterial = !0; +var Ca = class extends po { + constructor(e){ + super(); + this.defines = { + STANDARD: "", + PHYSICAL: "" + }, this.type = "MeshPhysicalMaterial", this.clearcoatMap = null, this.clearcoatRoughness = 0, this.clearcoatRoughnessMap = null, this.clearcoatNormalScale = new X(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", { + get: function() { + return mt(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1); + }, + set: function(t) { + this.ior = (1 + .4 * t) / (1 - .4 * t); + } + }), this.sheenColor = new ae(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 0, this.attenuationColor = new ae(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new ae(1, 1, 1), this.specularColorMap = null, this._sheen = 0, this._clearcoat = 0, this._transmission = 0, this.setValues(e); + } + get sheen() { + return this._sheen; + } + set sheen(e) { + this._sheen > 0 != e > 0 && this.version++, this._sheen = e; + } + get clearcoat() { + return this._clearcoat; + } + set clearcoat(e) { + this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e; + } + get transmission() { + return this._transmission; + } + set transmission(e) { + this._transmission > 0 != e > 0 && this.version++, this._transmission = e; + } + copy(e) { + return super.copy(e), this.defines = { + STANDARD: "", + PHYSICAL: "" + }, this.clearcoat = e.clearcoat, this.clearcoatMap = e.clearcoatMap, this.clearcoatRoughness = e.clearcoatRoughness, this.clearcoatRoughnessMap = e.clearcoatRoughnessMap, this.clearcoatNormalMap = e.clearcoatNormalMap, this.clearcoatNormalScale.copy(e.clearcoatNormalScale), this.ior = e.ior, this.sheen = e.sheen, this.sheenColor.copy(e.sheenColor), this.sheenColorMap = e.sheenColorMap, this.sheenRoughness = e.sheenRoughness, this.sheenRoughnessMap = e.sheenRoughnessMap, this.transmission = e.transmission, this.transmissionMap = e.transmissionMap, this.thickness = e.thickness, this.thicknessMap = e.thicknessMap, this.attenuationDistance = e.attenuationDistance, this.attenuationColor.copy(e.attenuationColor), this.specularIntensity = e.specularIntensity, this.specularIntensityMap = e.specularIntensityMap, this.specularColor.copy(e.specularColor), this.specularColorMap = e.specularColorMap, this; + } +}; +Ca.prototype.isMeshPhysicalMaterial = !0; +var La = class extends dt { + constructor(e){ + super(); + this.type = "MeshPhongMaterial", this.color = new ae(16777215), this.specular = new ae(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.specular.copy(e.specular), this.shininess = e.shininess, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; + } +}; +La.prototype.isMeshPhongMaterial = !0; +var Ra = class extends dt { + constructor(e){ + super(); + this.defines = { + TOON: "" + }, this.type = "MeshToonMaterial", this.color = new ae(16777215), this.map = null, this.gradientMap = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.gradientMap = e.gradientMap, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + } +}; +Ra.prototype.isMeshToonMaterial = !0; +var Pa = class extends dt { + constructor(e){ + super(); + this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.flatShading = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.flatShading = e.flatShading, this; + } +}; +Pa.prototype.isMeshNormalMaterial = !0; +var Ia = class extends dt { + constructor(e){ + super(); + this.type = "MeshLambertMaterial", this.color = new ae(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); + } + copy(e) { + return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + } +}; +Ia.prototype.isMeshLambertMaterial = !0; +var Da = class extends dt { + constructor(e){ + super(); + this.defines = { + MATCAP: "" + }, this.type = "MeshMatcapMaterial", this.color = new ae(16777215), this.matcap = null, this.map = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.flatShading = !1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.defines = { + MATCAP: "" + }, this.color.copy(e.color), this.matcap = e.matcap, this.map = e.map, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.flatShading = e.flatShading, this; + } +}; +Da.prototype.isMeshMatcapMaterial = !0; +var Fa = class extends ft { + constructor(e){ + super(); + this.type = "LineDashedMaterial", this.scale = 1, this.dashSize = 3, this.gapSize = 1, this.setValues(e); + } + copy(e) { + return super.copy(e), this.scale = e.scale, this.dashSize = e.dashSize, this.gapSize = e.gapSize, this; + } +}; +Fa.prototype.isLineDashedMaterial = !0; +var sy = Object.freeze({ + __proto__: null, + ShadowMaterial: Aa, + SpriteMaterial: io, + RawShaderMaterial: Gi, + ShaderMaterial: sn, + PointsMaterial: jn, + MeshPhysicalMaterial: Ca, + MeshStandardMaterial: po, + MeshPhongMaterial: La, + MeshToonMaterial: Ra, + MeshNormalMaterial: Pa, + MeshLambertMaterial: Ia, + MeshDepthMaterial: eo, + MeshDistanceMaterial: to, + MeshBasicMaterial: hn, + MeshMatcapMaterial: Da, + LineDashedMaterial: Fa, + LineBasicMaterial: ft, + Material: dt +}), Ze = { + arraySlice: function(s, e, t) { + return Ze.isTypedArray(s) ? new s.constructor(s.subarray(e, t !== void 0 ? t : s.length)) : s.slice(e, t); + }, + convertArray: function(s, e, t) { + return !s || !t && s.constructor === e ? s : typeof e.BYTES_PER_ELEMENT == "number" ? new e(s) : Array.prototype.slice.call(s); + }, + isTypedArray: function(s) { + return ArrayBuffer.isView(s) && !(s instanceof DataView); + }, + getKeyframeOrder: function(s) { + function e(i, r) { + return s[i] - s[r]; + } + let t = s.length, n = new Array(t); + for(let i = 0; i !== t; ++i)n[i] = i; + return n.sort(e), n; + }, + sortedArray: function(s, e, t) { + let n = s.length, i = new s.constructor(n); + for(let r = 0, o = 0; o !== n; ++r){ + let a = t[r] * e; + for(let l = 0; l !== e; ++l)i[o++] = s[a + l]; + } + return i; + }, + flattenJSON: function(s, e, t, n) { + let i = 1, r = s[0]; + for(; r !== void 0 && r[n] === void 0;)r = s[i++]; + if (r === void 0) return; + let o = r[n]; + if (o !== void 0) if (Array.isArray(o)) do o = r[n], o !== void 0 && (e.push(r.time), t.push.apply(t, o)), r = s[i++]; + while (r !== void 0) + else if (o.toArray !== void 0) do o = r[n], o !== void 0 && (e.push(r.time), o.toArray(t, t.length)), r = s[i++]; + while (r !== void 0) + else do o = r[n], o !== void 0 && (e.push(r.time), t.push(o)), r = s[i++]; + while (r !== void 0) + }, + subclip: function(s, e, t, n, i = 30) { + let r = s.clone(); + r.name = e; + let o = []; + for(let l = 0; l < r.tracks.length; ++l){ + let c = r.tracks[l], h = c.getValueSize(), u = [], d = []; + for(let f = 0; f < c.times.length; ++f){ + let m = c.times[f] * i; + if (!(m < t || m >= n)) { + u.push(c.times[f]); + for(let x = 0; x < h; ++x)d.push(c.values[f * h + x]); + } + } + u.length !== 0 && (c.times = Ze.convertArray(u, c.times.constructor), c.values = Ze.convertArray(d, c.values.constructor), o.push(c)); + } + r.tracks = o; + let a = 1 / 0; + for(let l = 0; l < r.tracks.length; ++l)a > r.tracks[l].times[0] && (a = r.tracks[l].times[0]); + for(let l = 0; l < r.tracks.length; ++l)r.tracks[l].shift(-1 * a); + return r.resetDuration(), r; + }, + makeClipAdditive: function(s, e = 0, t = s, n = 30) { + n <= 0 && (n = 30); + let i = t.tracks.length, r = e / n; + for(let o = 0; o < i; ++o){ + let a = t.tracks[o], l = a.ValueTypeName; + if (l === "bool" || l === "string") continue; + let c = s.tracks.find(function(g) { + return g.name === a.name && g.ValueTypeName === l; + }); + if (c === void 0) continue; + let h = 0, u = a.getValueSize(); + a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (h = u / 3); + let d = 0, f = c.getValueSize(); + c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (d = f / 3); + let m = a.times.length - 1, x; + if (r <= a.times[0]) { + let g = h, p = u - h; + x = Ze.arraySlice(a.values, g, p); + } else if (r >= a.times[m]) { + let g = m * u + h, p = g + u - h; + x = Ze.arraySlice(a.values, g, p); + } else { + let g = a.createInterpolant(), p = h, _ = u - h; + g.evaluate(r), x = Ze.arraySlice(g.resultBuffer, p, _); + } + l === "quaternion" && new gt().fromArray(x).normalize().conjugate().toArray(x); + let v = c.times.length; + for(let g = 0; g < v; ++g){ + let p = g * f + d; + if (l === "quaternion") gt.multiplyQuaternionsFlat(c.values, p, x, 0, c.values, p); + else { + let _ = f - d * 2; + for(let y = 0; y < _; ++y)c.values[p + y] -= x[y]; + } + } + } + return s.blendMode = qc, s; + } +}, cn = class { + constructor(e, t, n, i){ + this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = i !== void 0 ? i : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; + } + evaluate(e) { + let t = this.parameterPositions, n = this._cachedIndex, i = t[n], r = t[n - 1]; + e: { + t: { + let o; + n: { + i: if (!(e < i)) { + for(let a = n + 2;;){ + if (i === void 0) { + if (e < r) break i; + return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, e, r); + } + if (n === a) break; + if (r = i, i = t[++n], e < i) break t; + } + o = t.length; + break n; + } + if (!(e >= r)) { + let a = t[1]; + e < a && (n = 2, r = a); + for(let l = n - 2;;){ + if (r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); + if (n === l) break; + if (i = r, r = t[--n - 1], e >= r) break t; + } + o = n, n = 0; + break n; + } + break e; + } + for(; n < o;){ + let a = n + o >>> 1; + e < t[a] ? o = a : n = a + 1; + } + if (i = t[n], r = t[n - 1], r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); + if (i === void 0) return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, r, e); + } + this._cachedIndex = n, this.intervalChanged_(n, r, i); + } + return this.interpolate_(n, r, e, i); + } + getSettings_() { + return this.settings || this.DefaultSettings_; + } + copySampleValue_(e) { + let t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = e * i; + for(let o = 0; o !== i; ++o)t[o] = n[r + o]; + return t; + } + interpolate_() { + throw new Error("call to abstract method"); + } + intervalChanged_() {} +}; +cn.prototype.beforeStart_ = cn.prototype.copySampleValue_; +cn.prototype.afterEnd_ = cn.prototype.copySampleValue_; +var Ph = class extends cn { + constructor(e, t, n, i){ + super(e, t, n, i); + this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { + endingStart: Mi, + endingEnd: Mi + }; + } + intervalChanged_(e, t, n) { + let i = this.parameterPositions, r = e - 2, o = e + 1, a = i[r], l = i[o]; + if (a === void 0) switch(this.getSettings_().endingStart){ + case bi: + r = e, a = 2 * t - n; + break; + case Os: + r = i.length - 2, a = t + i[r] - i[r + 1]; + break; + default: + r = e, a = n; + } + if (l === void 0) switch(this.getSettings_().endingEnd){ + case bi: + o = e, l = 2 * n - t; + break; + case Os: + o = 1, l = n + i[1] - i[0]; + break; + default: + o = e - 1, l = t; + } + let c = (n - t) * .5, h = this.valueSize; + this._weightPrev = c / (t - a), this._weightNext = c / (l - n), this._offsetPrev = r * h, this._offsetNext = o * h; + } + interpolate_(e, t, n, i) { + let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, m = (n - t) / (i - t), x = m * m, v = x * m, g = -d * v + 2 * d * x - d * m, p = (1 + d) * v + (-1.5 - 2 * d) * x + (-.5 + d) * m + 1, _ = (-1 - f) * v + (1.5 + f) * x + .5 * m, y = f * v - f * x; + for(let b = 0; b !== a; ++b)r[b] = g * o[h + b] + p * o[c + b] + _ * o[l + b] + y * o[u + b]; + return r; + } +}, Na = class extends cn { + constructor(e, t, n, i){ + super(e, t, n, i); + } + interpolate_(e, t, n, i) { + let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = (n - t) / (i - t), u = 1 - h; + for(let d = 0; d !== a; ++d)r[d] = o[c + d] * u + o[l + d] * h; + return r; + } +}, Ih = class extends cn { + constructor(e, t, n, i){ + super(e, t, n, i); + } + interpolate_(e) { + return this.copySampleValue_(e - 1); + } +}, zt = class { + constructor(e, t, n, i){ + if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined"); + if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e); + this.name = e, this.times = Ze.convertArray(t, this.TimeBufferType), this.values = Ze.convertArray(n, this.ValueBufferType), this.setInterpolation(i || this.DefaultInterpolation); + } + static toJSON(e) { + let t = e.constructor, n; + if (t.toJSON !== this.toJSON) n = t.toJSON(e); + else { + n = { + name: e.name, + times: Ze.convertArray(e.times, Array), + values: Ze.convertArray(e.values, Array) + }; + let i = e.getInterpolation(); + i !== e.DefaultInterpolation && (n.interpolation = i); + } + return n.type = e.ValueTypeName, n; + } + InterpolantFactoryMethodDiscrete(e) { + return new Ih(this.times, this.values, this.getValueSize(), e); + } + InterpolantFactoryMethodLinear(e) { + return new Na(this.times, this.values, this.getValueSize(), e); + } + InterpolantFactoryMethodSmooth(e) { + return new Ph(this.times, this.values, this.getValueSize(), e); + } + setInterpolation(e) { + let t; + switch(e){ + case zs: + t = this.InterpolantFactoryMethodDiscrete; + break; + case Us: + t = this.InterpolantFactoryMethodLinear; + break; + case yo: + t = this.InterpolantFactoryMethodSmooth; + break; + } + if (t === void 0) { + let n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; + if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); + else throw new Error(n); + return console.warn("THREE.KeyframeTrack:", n), this; + } + return this.createInterpolant = t, this; + } + getInterpolation() { + switch(this.createInterpolant){ + case this.InterpolantFactoryMethodDiscrete: + return zs; + case this.InterpolantFactoryMethodLinear: + return Us; + case this.InterpolantFactoryMethodSmooth: + return yo; + } + } + getValueSize() { + return this.values.length / this.times.length; + } + shift(e) { + if (e !== 0) { + let t = this.times; + for(let n = 0, i = t.length; n !== i; ++n)t[n] += e; + } + return this; + } + scale(e) { + if (e !== 1) { + let t = this.times; + for(let n = 0, i = t.length; n !== i; ++n)t[n] *= e; + } + return this; + } + trim(e, t) { + let n = this.times, i = n.length, r = 0, o = i - 1; + for(; r !== i && n[r] < e;)++r; + for(; o !== -1 && n[o] > t;)--o; + if (++o, r !== 0 || o !== i) { + r >= o && (o = Math.max(o, 1), r = o - 1); + let a = this.getValueSize(); + this.times = Ze.arraySlice(n, r, o), this.values = Ze.arraySlice(this.values, r * a, o * a); + } + return this; + } + validate() { + let e = !0, t = this.getValueSize(); + t - Math.floor(t) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), e = !1); + let n = this.times, i = this.values, r = n.length; + r === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), e = !1); + let o = null; + for(let a = 0; a !== r; a++){ + let l = n[a]; + if (typeof l == "number" && isNaN(l)) { + console.error("THREE.KeyframeTrack: Time is not a valid number.", this, a, l), e = !1; + break; + } + if (o !== null && o > l) { + console.error("THREE.KeyframeTrack: Out of order keys.", this, a, l, o), e = !1; + break; + } + o = l; + } + if (i !== void 0 && Ze.isTypedArray(i)) for(let a = 0, l = i.length; a !== l; ++a){ + let c = i[a]; + if (isNaN(c)) { + console.error("THREE.KeyframeTrack: Value is not a valid number.", this, a, c), e = !1; + break; + } + } + return e; + } + optimize() { + let e = Ze.arraySlice(this.times), t = Ze.arraySlice(this.values), n = this.getValueSize(), i = this.getInterpolation() === yo, r = e.length - 1, o = 1; + for(let a = 1; a < r; ++a){ + let l = !1, c = e[a], h = e[a + 1]; + if (c !== h && (a !== 1 || c !== e[0])) if (i) l = !0; + else { + let u = a * n, d = u - n, f = u + n; + for(let m = 0; m !== n; ++m){ + let x = t[u + m]; + if (x !== t[d + m] || x !== t[f + m]) { + l = !0; + break; + } + } + } + if (l) { + if (a !== o) { + e[o] = e[a]; + let u = a * n, d = o * n; + for(let f = 0; f !== n; ++f)t[d + f] = t[u + f]; + } + ++o; + } + } + if (r > 0) { + e[o] = e[r]; + for(let a = r * n, l = o * n, c = 0; c !== n; ++c)t[l + c] = t[a + c]; + ++o; + } + return o !== e.length ? (this.times = Ze.arraySlice(e, 0, o), this.values = Ze.arraySlice(t, 0, o * n)) : (this.times = e, this.values = t), this; + } + clone() { + let e = Ze.arraySlice(this.times, 0), t = Ze.arraySlice(this.values, 0), n = this.constructor, i = new n(this.name, e, t); + return i.createInterpolant = this.createInterpolant, i; + } +}; +zt.prototype.TimeBufferType = Float32Array; +zt.prototype.ValueBufferType = Float32Array; +zt.prototype.DefaultInterpolation = Us; +var Qn = class extends zt { +}; +Qn.prototype.ValueTypeName = "bool"; +Qn.prototype.ValueBufferType = Array; +Qn.prototype.DefaultInterpolation = zs; +Qn.prototype.InterpolantFactoryMethodLinear = void 0; +Qn.prototype.InterpolantFactoryMethodSmooth = void 0; +var Ba = class extends zt { +}; +Ba.prototype.ValueTypeName = "color"; +var Ar = class extends zt { +}; +Ar.prototype.ValueTypeName = "number"; +var Dh = class extends cn { + constructor(e, t, n, i){ + super(e, t, n, i); + } + interpolate_(e, t, n, i) { + let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = (n - t) / (i - t), c = e * a; + for(let h = c + a; c !== h; c += 4)gt.slerpFlat(r, 0, o, c - a, o, c, l); + return r; + } +}, Wi = class extends zt { + InterpolantFactoryMethodLinear(e) { + return new Dh(this.times, this.values, this.getValueSize(), e); + } +}; +Wi.prototype.ValueTypeName = "quaternion"; +Wi.prototype.DefaultInterpolation = Us; +Wi.prototype.InterpolantFactoryMethodSmooth = void 0; +var Kn = class extends zt { +}; +Kn.prototype.ValueTypeName = "string"; +Kn.prototype.ValueBufferType = Array; +Kn.prototype.DefaultInterpolation = zs; +Kn.prototype.InterpolantFactoryMethodLinear = void 0; +Kn.prototype.InterpolantFactoryMethodSmooth = void 0; +var Cr = class extends zt { +}; +Cr.prototype.ValueTypeName = "vector"; +var Lr = class { + constructor(e, t = -1, n, i = ua){ + this.name = e, this.tracks = n, this.duration = t, this.blendMode = i, this.uuid = Et(), this.duration < 0 && this.resetDuration(); + } + static parse(e) { + let t = [], n = e.tracks, i = 1 / (e.fps || 1); + for(let o = 0, a = n.length; o !== a; ++o)t.push(ay(n[o]).scale(i)); + let r = new this(e.name, e.duration, t, e.blendMode); + return r.uuid = e.uuid, r; + } + static toJSON(e) { + let t = [], n = e.tracks, i = { + name: e.name, + duration: e.duration, + tracks: t, + uuid: e.uuid, + blendMode: e.blendMode + }; + for(let r = 0, o = n.length; r !== o; ++r)t.push(zt.toJSON(n[r])); + return i; + } + static CreateFromMorphTargetSequence(e, t, n, i) { + let r = t.length, o = []; + for(let a = 0; a < r; a++){ + let l = [], c = []; + l.push((a + r - 1) % r, a, (a + 1) % r), c.push(0, 1, 0); + let h = Ze.getKeyframeOrder(l); + l = Ze.sortedArray(l, 1, h), c = Ze.sortedArray(c, 1, h), !i && l[0] === 0 && (l.push(r), c.push(c[0])), o.push(new Ar(".morphTargetInfluences[" + t[a].name + "]", l, c).scale(1 / n)); + } + return new this(e, -1, o); + } + static findByName(e, t) { + let n = e; + if (!Array.isArray(e)) { + let i = e; + n = i.geometry && i.geometry.animations || i.animations; + } + for(let i = 0; i < n.length; i++)if (n[i].name === t) return n[i]; + return null; + } + static CreateClipsFromMorphTargetSequences(e, t, n) { + let i = {}, r = /^([\w-]*?)([\d]+)$/; + for(let a = 0, l = e.length; a < l; a++){ + let c = e[a], h = c.name.match(r); + if (h && h.length > 1) { + let u = h[1], d = i[u]; + d || (i[u] = d = []), d.push(c); + } + } + let o = []; + for(let a in i)o.push(this.CreateFromMorphTargetSequence(a, i[a], t, n)); + return o; + } + static parseAnimation(e, t) { + if (!e) return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null; + let n = function(u, d, f, m, x) { + if (f.length !== 0) { + let v = [], g = []; + Ze.flattenJSON(f, v, g, m), v.length !== 0 && x.push(new u(d, v, g)); + } + }, i = [], r = e.name || "default", o = e.fps || 30, a = e.blendMode, l = e.length || -1, c = e.hierarchy || []; + for(let u = 0; u < c.length; u++){ + let d = c[u].keys; + if (!(!d || d.length === 0)) if (d[0].morphTargets) { + let f = {}, m; + for(m = 0; m < d.length; m++)if (d[m].morphTargets) for(let x = 0; x < d[m].morphTargets.length; x++)f[d[m].morphTargets[x]] = -1; + for(let x in f){ + let v = [], g = []; + for(let p = 0; p !== d[m].morphTargets.length; ++p){ + let _ = d[m]; + v.push(_.time), g.push(_.morphTarget === x ? 1 : 0); + } + i.push(new Ar(".morphTargetInfluence[" + x + "]", v, g)); + } + l = f.length * (o || 1); + } else { + let f = ".bones[" + t[u].name + "]"; + n(Cr, f + ".position", d, "pos", i), n(Wi, f + ".quaternion", d, "rot", i), n(Cr, f + ".scale", d, "scl", i); + } + } + return i.length === 0 ? null : new this(r, l, i, a); + } + resetDuration() { + let e = this.tracks, t = 0; + for(let n = 0, i = e.length; n !== i; ++n){ + let r = this.tracks[n]; + t = Math.max(t, r.times[r.times.length - 1]); + } + return this.duration = t, this; + } + trim() { + for(let e = 0; e < this.tracks.length; e++)this.tracks[e].trim(0, this.duration); + return this; + } + validate() { + let e = !0; + for(let t = 0; t < this.tracks.length; t++)e = e && this.tracks[t].validate(); + return e; + } + optimize() { + for(let e = 0; e < this.tracks.length; e++)this.tracks[e].optimize(); + return this; + } + clone() { + let e = []; + for(let t = 0; t < this.tracks.length; t++)e.push(this.tracks[t].clone()); + return new this.constructor(this.name, this.duration, e, this.blendMode); + } + toJSON() { + return this.constructor.toJSON(this); + } +}; +function oy(s) { + switch(s.toLowerCase()){ + case "scalar": + case "double": + case "float": + case "number": + case "integer": + return Ar; + case "vector": + case "vector2": + case "vector3": + case "vector4": + return Cr; + case "color": + return Ba; + case "quaternion": + return Wi; + case "bool": + case "boolean": + return Qn; + case "string": + return Kn; + } + throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + s); +} +function ay(s) { + if (s.type === void 0) throw new Error("THREE.KeyframeTrack: track type undefined, can not parse"); + let e = oy(s.type); + if (s.times === void 0) { + let t = [], n = []; + Ze.flattenJSON(s.keys, t, n, "value"), s.times = t, s.values = n; + } + return e.parse !== void 0 ? e.parse(s) : new e(s.name, s.times, s.values, s.interpolation); +} +var Ni = { + enabled: !1, + files: {}, + add: function(s, e) { + this.enabled !== !1 && (this.files[s] = e); + }, + get: function(s) { + if (this.enabled !== !1) return this.files[s]; + }, + remove: function(s) { + delete this.files[s]; + }, + clear: function() { + this.files = {}; + } +}, za = class { + constructor(e, t, n){ + let i = this, r = !1, o = 0, a = 0, l, c = []; + this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this.itemStart = function(h) { + a++, r === !1 && i.onStart !== void 0 && i.onStart(h, o, a), r = !0; + }, this.itemEnd = function(h) { + o++, i.onProgress !== void 0 && i.onProgress(h, o, a), o === a && (r = !1, i.onLoad !== void 0 && i.onLoad()); + }, this.itemError = function(h) { + i.onError !== void 0 && i.onError(h); + }, this.resolveURL = function(h) { + return l ? l(h) : h; + }, this.setURLModifier = function(h) { + return l = h, this; + }, this.addHandler = function(h, u) { + return c.push(h, u), this; + }, this.removeHandler = function(h) { + let u = c.indexOf(h); + return u !== -1 && c.splice(u, 2), this; + }, this.getHandler = function(h) { + for(let u = 0, d = c.length; u < d; u += 2){ + let f = c[u], m = c[u + 1]; + if (f.global && (f.lastIndex = 0), f.test(h)) return m; + } + return null; + }; + } +}, ly = new za, bt = class { + constructor(e){ + this.manager = e !== void 0 ? e : ly, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}; + } + load() {} + loadAsync(e, t) { + let n = this; + return new Promise(function(i, r) { + n.load(e, i, t, r); + }); + } + parse() {} + setCrossOrigin(e) { + return this.crossOrigin = e, this; + } + setWithCredentials(e) { + return this.withCredentials = e, this; + } + setPath(e) { + return this.path = e, this; + } + setResourcePath(e) { + return this.resourcePath = e, this; + } + setRequestHeader(e) { + return this.requestHeader = e, this; + } +}, tn = {}, Yt = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); + let r = Ni.get(e); + if (r !== void 0) return this.manager.itemStart(e), setTimeout(()=>{ + t && t(r), this.manager.itemEnd(e); + }, 0), r; + if (tn[e] !== void 0) { + tn[e].push({ + onLoad: t, + onProgress: n, + onError: i + }); + return; + } + tn[e] = [], tn[e].push({ + onLoad: t, + onProgress: n, + onError: i + }); + let o = new Request(e, { + headers: new Headers(this.requestHeader), + credentials: this.withCredentials ? "include" : "same-origin" + }); + fetch(o).then((a)=>{ + if (a.status === 200 || a.status === 0) { + if (a.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || a.body.getReader === void 0) return a; + let l = tn[e], c = a.body.getReader(), h = a.headers.get("Content-Length"), u = h ? parseInt(h) : 0, d = u !== 0, f = 0, m = new ReadableStream({ + start (x) { + v(); + function v() { + c.read().then(({ done: g , value: p })=>{ + if (g) x.close(); + else { + f += p.byteLength; + let _ = new ProgressEvent("progress", { + lengthComputable: d, + loaded: f, + total: u + }); + for(let y = 0, b = l.length; y < b; y++){ + let A = l[y]; + A.onProgress && A.onProgress(_); + } + x.enqueue(p), v(); + } + }); + } + } + }); + return new Response(m); + } else throw Error(`fetch for "${a.url}" responded with ${a.status}: ${a.statusText}`); + }).then((a)=>{ + switch(this.responseType){ + case "arraybuffer": + return a.arrayBuffer(); + case "blob": + return a.blob(); + case "document": + return a.text().then((l)=>new DOMParser().parseFromString(l, this.mimeType)); + case "json": + return a.json(); + default: + return a.text(); + } + }).then((a)=>{ + Ni.add(e, a); + let l = tn[e]; + delete tn[e]; + for(let c = 0, h = l.length; c < h; c++){ + let u = l[c]; + u.onLoad && u.onLoad(a); + } + }).catch((a)=>{ + let l = tn[e]; + if (l === void 0) throw this.manager.itemError(e), a; + delete tn[e]; + for(let c = 0, h = l.length; c < h; c++){ + let u = l[c]; + u.onError && u.onError(a); + } + this.manager.itemError(e); + }).finally(()=>{ + this.manager.itemEnd(e); + }), this.manager.itemStart(e); + } + setResponseType(e) { + return this.responseType = e, this; + } + setMimeType(e) { + return this.mimeType = e, this; + } +}, cy = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = new Yt(this.manager); + o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { + try { + t(r.parse(JSON.parse(a))); + } catch (l) { + i ? i(l) : console.error(l), r.manager.itemError(e); + } + }, n, i); + } + parse(e) { + let t = []; + for(let n = 0; n < e.length; n++){ + let i = Lr.parse(e[n]); + t.push(i); + } + return t; + } +}, hy = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = [], a = new va, l = new Yt(this.manager); + l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(r.withCredentials); + let c = 0; + function h(u) { + l.load(e[u], function(d) { + let f = r.parse(d, !0); + o[u] = { + width: f.width, + height: f.height, + format: f.format, + mipmaps: f.mipmaps + }, c += 1, c === 6 && (f.mipmapCount === 1 && (a.minFilter = tt), a.image = o, a.format = f.format, a.needsUpdate = !0, t && t(a)); + }, n, i); + } + if (Array.isArray(e)) for(let u = 0, d = e.length; u < d; ++u)h(u); + else l.load(e, function(u) { + let d = r.parse(u, !0); + if (d.isCubemap) { + let f = d.mipmaps.length / d.mipmapCount; + for(let m = 0; m < f; m++){ + o[m] = { + mipmaps: [] + }; + for(let x = 0; x < d.mipmapCount; x++)o[m].mipmaps.push(d.mipmaps[m * d.mipmapCount + x]), o[m].format = d.format, o[m].width = d.width, o[m].height = d.height; + } + a.image = o; + } else a.image.width = d.width, a.image.height = d.height, a.mipmaps = d.mipmaps; + d.mipmapCount === 1 && (a.minFilter = tt), a.format = d.format, a.needsUpdate = !0, t && t(a); + }, n, i); + return a; + } +}, Rr = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); + let r = this, o = Ni.get(e); + if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { + t && t(o), r.manager.itemEnd(e); + }, 0), o; + let a = qs("img"); + function l() { + h(), Ni.add(e, this), t && t(this), r.manager.itemEnd(e); + } + function c(u) { + h(), i && i(u), r.manager.itemError(e), r.manager.itemEnd(e); + } + function h() { + a.removeEventListener("load", l, !1), a.removeEventListener("error", c, !1); + } + return a.addEventListener("load", l, !1), a.addEventListener("error", c, !1), e.substr(0, 5) !== "data:" && this.crossOrigin !== void 0 && (a.crossOrigin = this.crossOrigin), r.manager.itemStart(e), a.src = e, a; + } +}, Fh = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = new ki, o = new Rr(this.manager); + o.setCrossOrigin(this.crossOrigin), o.setPath(this.path); + let a = 0; + function l(c) { + o.load(e[c], function(h) { + r.images[c] = h, a++, a === 6 && (r.needsUpdate = !0, t && t(r)); + }, void 0, i); + } + for(let c = 0; c < e.length; ++c)l(c); + return r; + } +}, Nh = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = new qn, a = new Yt(this.manager); + return a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(r.withCredentials), a.load(e, function(l) { + let c = r.parse(l); + !c || (c.image !== void 0 ? o.image = c.image : c.data !== void 0 && (o.image.width = c.width, o.image.height = c.height, o.image.data = c.data), o.wrapS = c.wrapS !== void 0 ? c.wrapS : vt, o.wrapT = c.wrapT !== void 0 ? c.wrapT : vt, o.magFilter = c.magFilter !== void 0 ? c.magFilter : tt, o.minFilter = c.minFilter !== void 0 ? c.minFilter : tt, o.anisotropy = c.anisotropy !== void 0 ? c.anisotropy : 1, c.encoding !== void 0 && (o.encoding = c.encoding), c.flipY !== void 0 && (o.flipY = c.flipY), c.format !== void 0 && (o.format = c.format), c.type !== void 0 && (o.type = c.type), c.mipmaps !== void 0 && (o.mipmaps = c.mipmaps, o.minFilter = Ui), c.mipmapCount === 1 && (o.minFilter = tt), c.generateMipmaps !== void 0 && (o.generateMipmaps = c.generateMipmaps), o.needsUpdate = !0, t && t(o, c)); + }, n, i), o; + } +}, Bh = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = new ot, o = new Rr(this.manager); + return o.setCrossOrigin(this.crossOrigin), o.setPath(this.path), o.load(e, function(a) { + r.image = a, r.needsUpdate = !0, t !== void 0 && t(r); + }, n, i), r; + } +}, Bt = class extends Ne { + constructor(e, t = 1){ + super(); + this.type = "Light", this.color = new ae(e), this.intensity = t; + } + dispose() {} + copy(e) { + return super.copy(e), this.color.copy(e.color), this.intensity = e.intensity, this; + } + toJSON(e) { + let t = super.toJSON(e); + return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t; + } +}; +Bt.prototype.isLight = !0; +var Ua = class extends Bt { + constructor(e, t, n){ + super(e, n); + this.type = "HemisphereLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.groundColor = new ae(t); + } + copy(e) { + return Bt.prototype.copy.call(this, e), this.groundColor.copy(e.groundColor), this; + } +}; +Ua.prototype.isHemisphereLight = !0; +var _c = new pe, Mc = new M, bc = new M, mo = class { + constructor(e){ + this.camera = e, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new X(512, 512), this.map = null, this.mapPass = null, this.matrix = new pe, this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Dr, this._frameExtents = new X(1, 1), this._viewportCount = 1, this._viewports = [ + new Ve(0, 0, 1, 1) + ]; + } + getViewportCount() { + return this._viewportCount; + } + getFrustum() { + return this._frustum; + } + updateMatrices(e) { + let t = this.camera, n = this.matrix; + Mc.setFromMatrixPosition(e.matrixWorld), t.position.copy(Mc), bc.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(bc), t.updateMatrixWorld(), _c.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(_c), n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), n.multiply(t.projectionMatrix), n.multiply(t.matrixWorldInverse); + } + getViewport(e) { + return this._viewports[e]; + } + getFrameExtents() { + return this._frameExtents; + } + dispose() { + this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose(); + } + copy(e) { + return this.camera = e.camera.clone(), this.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this; + } + clone() { + return new this.constructor().copy(this); + } + toJSON() { + let e = {}; + return this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e; + } +}, Oa = class extends mo { + constructor(){ + super(new ut(50, 1, .5, 500)); + this.focus = 1; + } + updateMatrices(e) { + let t = this.camera, n = dr * 2 * e.angle * this.focus, i = this.mapSize.width / this.mapSize.height, r = e.distance || t.far; + (n !== t.fov || i !== t.aspect || r !== t.far) && (t.fov = n, t.aspect = i, t.far = r, t.updateProjectionMatrix()), super.updateMatrices(e); + } + copy(e) { + return super.copy(e), this.focus = e.focus, this; + } +}; +Oa.prototype.isSpotLightShadow = !0; +var Ha = class extends Bt { + constructor(e, t, n = 0, i = Math.PI / 3, r = 0, o = 1){ + super(e, t); + this.type = "SpotLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.distance = n, this.angle = i, this.penumbra = r, this.decay = o, this.shadow = new Oa; + } + get power() { + return this.intensity * Math.PI; + } + set power(e) { + this.intensity = e / Math.PI; + } + dispose() { + this.shadow.dispose(); + } + copy(e) { + return super.copy(e), this.distance = e.distance, this.angle = e.angle, this.penumbra = e.penumbra, this.decay = e.decay, this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; + } +}; +Ha.prototype.isSpotLight = !0; +var wc = new pe, nr = new M, jo = new M, ka = class extends mo { + constructor(){ + super(new ut(90, 1, .5, 500)); + this._frameExtents = new X(4, 2), this._viewportCount = 6, this._viewports = [ + new Ve(2, 1, 1, 1), + new Ve(0, 1, 1, 1), + new Ve(3, 1, 1, 1), + new Ve(1, 1, 1, 1), + new Ve(3, 0, 1, 1), + new Ve(1, 0, 1, 1) + ], this._cubeDirections = [ + new M(1, 0, 0), + new M(-1, 0, 0), + new M(0, 0, 1), + new M(0, 0, -1), + new M(0, 1, 0), + new M(0, -1, 0) + ], this._cubeUps = [ + new M(0, 1, 0), + new M(0, 1, 0), + new M(0, 1, 0), + new M(0, 1, 0), + new M(0, 0, 1), + new M(0, 0, -1) + ]; + } + updateMatrices(e, t = 0) { + let n = this.camera, i = this.matrix, r = e.distance || n.far; + r !== n.far && (n.far = r, n.updateProjectionMatrix()), nr.setFromMatrixPosition(e.matrixWorld), n.position.copy(nr), jo.copy(n.position), jo.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(jo), n.updateMatrixWorld(), i.makeTranslation(-nr.x, -nr.y, -nr.z), wc.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(wc); + } +}; +ka.prototype.isPointLightShadow = !0; +var Ga = class extends Bt { + constructor(e, t, n = 0, i = 1){ + super(e, t); + this.type = "PointLight", this.distance = n, this.decay = i, this.shadow = new ka; + } + get power() { + return this.intensity * 4 * Math.PI; + } + set power(e) { + this.intensity = e / (4 * Math.PI); + } + dispose() { + this.shadow.dispose(); + } + copy(e) { + return super.copy(e), this.distance = e.distance, this.decay = e.decay, this.shadow = e.shadow.clone(), this; + } +}; +Ga.prototype.isPointLight = !0; +var Va = class extends mo { + constructor(){ + super(new Fr(-5, 5, 5, -5, .5, 500)); + } +}; +Va.prototype.isDirectionalLightShadow = !0; +var Wa = class extends Bt { + constructor(e, t){ + super(e, t); + this.type = "DirectionalLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.shadow = new Va; + } + dispose() { + this.shadow.dispose(); + } + copy(e) { + return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; + } +}; +Wa.prototype.isDirectionalLight = !0; +var qa = class extends Bt { + constructor(e, t){ + super(e, t); + this.type = "AmbientLight"; + } +}; +qa.prototype.isAmbientLight = !0; +var Xa = class extends Bt { + constructor(e, t, n = 10, i = 10){ + super(e, t); + this.type = "RectAreaLight", this.width = n, this.height = i; + } + get power() { + return this.intensity * this.width * this.height * Math.PI; + } + set power(e) { + this.intensity = e / (this.width * this.height * Math.PI); + } + copy(e) { + return super.copy(e), this.width = e.width, this.height = e.height, this; + } + toJSON(e) { + let t = super.toJSON(e); + return t.object.width = this.width, t.object.height = this.height, t; + } +}; +Xa.prototype.isRectAreaLight = !0; +var Ja = class { + constructor(){ + this.coefficients = []; + for(let e = 0; e < 9; e++)this.coefficients.push(new M); + } + set(e) { + for(let t = 0; t < 9; t++)this.coefficients[t].copy(e[t]); + return this; + } + zero() { + for(let e = 0; e < 9; e++)this.coefficients[e].set(0, 0, 0); + return this; + } + getAt(e, t) { + let n = e.x, i = e.y, r = e.z, o = this.coefficients; + return t.copy(o[0]).multiplyScalar(.282095), t.addScaledVector(o[1], .488603 * i), t.addScaledVector(o[2], .488603 * r), t.addScaledVector(o[3], .488603 * n), t.addScaledVector(o[4], 1.092548 * (n * i)), t.addScaledVector(o[5], 1.092548 * (i * r)), t.addScaledVector(o[6], .315392 * (3 * r * r - 1)), t.addScaledVector(o[7], 1.092548 * (n * r)), t.addScaledVector(o[8], .546274 * (n * n - i * i)), t; + } + getIrradianceAt(e, t) { + let n = e.x, i = e.y, r = e.z, o = this.coefficients; + return t.copy(o[0]).multiplyScalar(.886227), t.addScaledVector(o[1], 2 * .511664 * i), t.addScaledVector(o[2], 2 * .511664 * r), t.addScaledVector(o[3], 2 * .511664 * n), t.addScaledVector(o[4], 2 * .429043 * n * i), t.addScaledVector(o[5], 2 * .429043 * i * r), t.addScaledVector(o[6], .743125 * r * r - .247708), t.addScaledVector(o[7], 2 * .429043 * n * r), t.addScaledVector(o[8], .429043 * (n * n - i * i)), t; + } + add(e) { + for(let t = 0; t < 9; t++)this.coefficients[t].add(e.coefficients[t]); + return this; + } + addScaledSH(e, t) { + for(let n = 0; n < 9; n++)this.coefficients[n].addScaledVector(e.coefficients[n], t); + return this; + } + scale(e) { + for(let t = 0; t < 9; t++)this.coefficients[t].multiplyScalar(e); + return this; + } + lerp(e, t) { + for(let n = 0; n < 9; n++)this.coefficients[n].lerp(e.coefficients[n], t); + return this; + } + equals(e) { + for(let t = 0; t < 9; t++)if (!this.coefficients[t].equals(e.coefficients[t])) return !1; + return !0; + } + copy(e) { + return this.set(e.coefficients); + } + clone() { + return new this.constructor().copy(this); + } + fromArray(e, t = 0) { + let n = this.coefficients; + for(let i = 0; i < 9; i++)n[i].fromArray(e, t + i * 3); + return this; + } + toArray(e = [], t = 0) { + let n = this.coefficients; + for(let i = 0; i < 9; i++)n[i].toArray(e, t + i * 3); + return e; + } + static getBasisAt(e, t) { + let n = e.x, i = e.y, r = e.z; + t[0] = .282095, t[1] = .488603 * i, t[2] = .488603 * r, t[3] = .488603 * n, t[4] = 1.092548 * n * i, t[5] = 1.092548 * i * r, t[6] = .315392 * (3 * r * r - 1), t[7] = 1.092548 * n * r, t[8] = .546274 * (n * n - i * i); + } +}; +Ja.prototype.isSphericalHarmonics3 = !0; +var Hr = class extends Bt { + constructor(e = new Ja, t = 1){ + super(void 0, t); + this.sh = e; + } + copy(e) { + return super.copy(e), this.sh.copy(e.sh), this; + } + fromJSON(e) { + return this.intensity = e.intensity, this.sh.fromArray(e.sh), this; + } + toJSON(e) { + let t = super.toJSON(e); + return t.object.sh = this.sh.toArray(), t; + } +}; +Hr.prototype.isLightProbe = !0; +var zh = class extends bt { + constructor(e){ + super(e); + this.textures = {}; + } + load(e, t, n, i) { + let r = this, o = new Yt(r.manager); + o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { + try { + t(r.parse(JSON.parse(a))); + } catch (l) { + i ? i(l) : console.error(l), r.manager.itemError(e); + } + }, n, i); + } + parse(e) { + let t = this.textures; + function n(r) { + return t[r] === void 0 && console.warn("THREE.MaterialLoader: Undefined texture", r), t[r]; + } + let i = new sy[e.type]; + if (e.uuid !== void 0 && (i.uuid = e.uuid), e.name !== void 0 && (i.name = e.name), e.color !== void 0 && i.color !== void 0 && i.color.setHex(e.color), e.roughness !== void 0 && (i.roughness = e.roughness), e.metalness !== void 0 && (i.metalness = e.metalness), e.sheen !== void 0 && (i.sheen = e.sheen), e.sheenColor !== void 0 && (i.sheenColor = new ae().setHex(e.sheenColor)), e.sheenRoughness !== void 0 && (i.sheenRoughness = e.sheenRoughness), e.emissive !== void 0 && i.emissive !== void 0 && i.emissive.setHex(e.emissive), e.specular !== void 0 && i.specular !== void 0 && i.specular.setHex(e.specular), e.specularIntensity !== void 0 && (i.specularIntensity = e.specularIntensity), e.specularColor !== void 0 && i.specularColor !== void 0 && i.specularColor.setHex(e.specularColor), e.shininess !== void 0 && (i.shininess = e.shininess), e.clearcoat !== void 0 && (i.clearcoat = e.clearcoat), e.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = e.clearcoatRoughness), e.transmission !== void 0 && (i.transmission = e.transmission), e.thickness !== void 0 && (i.thickness = e.thickness), e.attenuationDistance !== void 0 && (i.attenuationDistance = e.attenuationDistance), e.attenuationColor !== void 0 && i.attenuationColor !== void 0 && i.attenuationColor.setHex(e.attenuationColor), e.fog !== void 0 && (i.fog = e.fog), e.flatShading !== void 0 && (i.flatShading = e.flatShading), e.blending !== void 0 && (i.blending = e.blending), e.combine !== void 0 && (i.combine = e.combine), e.side !== void 0 && (i.side = e.side), e.shadowSide !== void 0 && (i.shadowSide = e.shadowSide), e.opacity !== void 0 && (i.opacity = e.opacity), e.format !== void 0 && (i.format = e.format), e.transparent !== void 0 && (i.transparent = e.transparent), e.alphaTest !== void 0 && (i.alphaTest = e.alphaTest), e.depthTest !== void 0 && (i.depthTest = e.depthTest), e.depthWrite !== void 0 && (i.depthWrite = e.depthWrite), e.colorWrite !== void 0 && (i.colorWrite = e.colorWrite), e.stencilWrite !== void 0 && (i.stencilWrite = e.stencilWrite), e.stencilWriteMask !== void 0 && (i.stencilWriteMask = e.stencilWriteMask), e.stencilFunc !== void 0 && (i.stencilFunc = e.stencilFunc), e.stencilRef !== void 0 && (i.stencilRef = e.stencilRef), e.stencilFuncMask !== void 0 && (i.stencilFuncMask = e.stencilFuncMask), e.stencilFail !== void 0 && (i.stencilFail = e.stencilFail), e.stencilZFail !== void 0 && (i.stencilZFail = e.stencilZFail), e.stencilZPass !== void 0 && (i.stencilZPass = e.stencilZPass), e.wireframe !== void 0 && (i.wireframe = e.wireframe), e.wireframeLinewidth !== void 0 && (i.wireframeLinewidth = e.wireframeLinewidth), e.wireframeLinecap !== void 0 && (i.wireframeLinecap = e.wireframeLinecap), e.wireframeLinejoin !== void 0 && (i.wireframeLinejoin = e.wireframeLinejoin), e.rotation !== void 0 && (i.rotation = e.rotation), e.linewidth !== 1 && (i.linewidth = e.linewidth), e.dashSize !== void 0 && (i.dashSize = e.dashSize), e.gapSize !== void 0 && (i.gapSize = e.gapSize), e.scale !== void 0 && (i.scale = e.scale), e.polygonOffset !== void 0 && (i.polygonOffset = e.polygonOffset), e.polygonOffsetFactor !== void 0 && (i.polygonOffsetFactor = e.polygonOffsetFactor), e.polygonOffsetUnits !== void 0 && (i.polygonOffsetUnits = e.polygonOffsetUnits), e.dithering !== void 0 && (i.dithering = e.dithering), e.alphaToCoverage !== void 0 && (i.alphaToCoverage = e.alphaToCoverage), e.premultipliedAlpha !== void 0 && (i.premultipliedAlpha = e.premultipliedAlpha), e.visible !== void 0 && (i.visible = e.visible), e.toneMapped !== void 0 && (i.toneMapped = e.toneMapped), e.userData !== void 0 && (i.userData = e.userData), e.vertexColors !== void 0 && (typeof e.vertexColors == "number" ? i.vertexColors = e.vertexColors > 0 : i.vertexColors = e.vertexColors), e.uniforms !== void 0) for(let r in e.uniforms){ + let o = e.uniforms[r]; + switch(i.uniforms[r] = {}, o.type){ + case "t": + i.uniforms[r].value = n(o.value); + break; + case "c": + i.uniforms[r].value = new ae().setHex(o.value); + break; + case "v2": + i.uniforms[r].value = new X().fromArray(o.value); + break; + case "v3": + i.uniforms[r].value = new M().fromArray(o.value); + break; + case "v4": + i.uniforms[r].value = new Ve().fromArray(o.value); + break; + case "m3": + i.uniforms[r].value = new lt().fromArray(o.value); + break; + case "m4": + i.uniforms[r].value = new pe().fromArray(o.value); + break; + default: + i.uniforms[r].value = o.value; + } + } + if (e.defines !== void 0 && (i.defines = e.defines), e.vertexShader !== void 0 && (i.vertexShader = e.vertexShader), e.fragmentShader !== void 0 && (i.fragmentShader = e.fragmentShader), e.extensions !== void 0) for(let r in e.extensions)i.extensions[r] = e.extensions[r]; + if (e.shading !== void 0 && (i.flatShading = e.shading === 1), e.size !== void 0 && (i.size = e.size), e.sizeAttenuation !== void 0 && (i.sizeAttenuation = e.sizeAttenuation), e.map !== void 0 && (i.map = n(e.map)), e.matcap !== void 0 && (i.matcap = n(e.matcap)), e.alphaMap !== void 0 && (i.alphaMap = n(e.alphaMap)), e.bumpMap !== void 0 && (i.bumpMap = n(e.bumpMap)), e.bumpScale !== void 0 && (i.bumpScale = e.bumpScale), e.normalMap !== void 0 && (i.normalMap = n(e.normalMap)), e.normalMapType !== void 0 && (i.normalMapType = e.normalMapType), e.normalScale !== void 0) { + let r = e.normalScale; + Array.isArray(r) === !1 && (r = [ + r, + r + ]), i.normalScale = new X().fromArray(r); + } + return e.displacementMap !== void 0 && (i.displacementMap = n(e.displacementMap)), e.displacementScale !== void 0 && (i.displacementScale = e.displacementScale), e.displacementBias !== void 0 && (i.displacementBias = e.displacementBias), e.roughnessMap !== void 0 && (i.roughnessMap = n(e.roughnessMap)), e.metalnessMap !== void 0 && (i.metalnessMap = n(e.metalnessMap)), e.emissiveMap !== void 0 && (i.emissiveMap = n(e.emissiveMap)), e.emissiveIntensity !== void 0 && (i.emissiveIntensity = e.emissiveIntensity), e.specularMap !== void 0 && (i.specularMap = n(e.specularMap)), e.specularIntensityMap !== void 0 && (i.specularIntensityMap = n(e.specularIntensityMap)), e.specularColorMap !== void 0 && (i.specularColorMap = n(e.specularColorMap)), e.envMap !== void 0 && (i.envMap = n(e.envMap)), e.envMapIntensity !== void 0 && (i.envMapIntensity = e.envMapIntensity), e.reflectivity !== void 0 && (i.reflectivity = e.reflectivity), e.refractionRatio !== void 0 && (i.refractionRatio = e.refractionRatio), e.lightMap !== void 0 && (i.lightMap = n(e.lightMap)), e.lightMapIntensity !== void 0 && (i.lightMapIntensity = e.lightMapIntensity), e.aoMap !== void 0 && (i.aoMap = n(e.aoMap)), e.aoMapIntensity !== void 0 && (i.aoMapIntensity = e.aoMapIntensity), e.gradientMap !== void 0 && (i.gradientMap = n(e.gradientMap)), e.clearcoatMap !== void 0 && (i.clearcoatMap = n(e.clearcoatMap)), e.clearcoatRoughnessMap !== void 0 && (i.clearcoatRoughnessMap = n(e.clearcoatRoughnessMap)), e.clearcoatNormalMap !== void 0 && (i.clearcoatNormalMap = n(e.clearcoatNormalMap)), e.clearcoatNormalScale !== void 0 && (i.clearcoatNormalScale = new X().fromArray(e.clearcoatNormalScale)), e.transmissionMap !== void 0 && (i.transmissionMap = n(e.transmissionMap)), e.thicknessMap !== void 0 && (i.thicknessMap = n(e.thicknessMap)), e.sheenColorMap !== void 0 && (i.sheenColorMap = n(e.sheenColorMap)), e.sheenRoughnessMap !== void 0 && (i.sheenRoughnessMap = n(e.sheenRoughnessMap)), i; + } + setTextures(e) { + return this.textures = e, this; + } +}, Gs = class { + static decodeText(e) { + if (typeof TextDecoder < "u") return new TextDecoder().decode(e); + let t = ""; + for(let n = 0, i = e.length; n < i; n++)t += String.fromCharCode(e[n]); + try { + return decodeURIComponent(escape(t)); + } catch { + return t; + } + } + static extractUrlBase(e) { + let t = e.lastIndexOf("/"); + return t === -1 ? "./" : e.substr(0, t + 1); + } + static resolveURL(e, t) { + return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e); + } +}, Ya = class extends _e { + constructor(){ + super(); + this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0; + } + copy(e) { + return super.copy(e), this.instanceCount = e.instanceCount, this; + } + clone() { + return new this.constructor().copy(this); + } + toJSON() { + let e = super.toJSON(this); + return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e; + } +}; +Ya.prototype.isInstancedBufferGeometry = !0; +var Uh = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = new Yt(r.manager); + o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { + try { + t(r.parse(JSON.parse(a))); + } catch (l) { + i ? i(l) : console.error(l), r.manager.itemError(e); + } + }, n, i); + } + parse(e) { + let t = {}, n = {}; + function i(f, m) { + if (t[m] !== void 0) return t[m]; + let v = f.interleavedBuffers[m], g = r(f, v.buffer), p = wi(v.type, g), _ = new $n(p, v.stride); + return _.uuid = v.uuid, t[m] = _, _; + } + function r(f, m) { + if (n[m] !== void 0) return n[m]; + let v = f.arrayBuffers[m], g = new Uint32Array(v).buffer; + return n[m] = g, g; + } + let o = e.isInstancedBufferGeometry ? new Ya : new _e, a = e.data.index; + if (a !== void 0) { + let f = wi(a.type, a.array); + o.setIndex(new Ue(f, 1)); + } + let l = e.data.attributes; + for(let f in l){ + let m = l[f], x; + if (m.isInterleavedBufferAttribute) { + let v = i(e.data, m.data); + x = new Sn(v, m.itemSize, m.offset, m.normalized); + } else { + let v = wi(m.type, m.array), g = m.isInstancedBufferAttribute ? Xn : Ue; + x = new g(v, m.itemSize, m.normalized); + } + m.name !== void 0 && (x.name = m.name), m.usage !== void 0 && x.setUsage(m.usage), m.updateRange !== void 0 && (x.updateRange.offset = m.updateRange.offset, x.updateRange.count = m.updateRange.count), o.setAttribute(f, x); + } + let c = e.data.morphAttributes; + if (c) for(let f in c){ + let m = c[f], x = []; + for(let v = 0, g = m.length; v < g; v++){ + let p = m[v], _; + if (p.isInterleavedBufferAttribute) { + let y = i(e.data, p.data); + _ = new Sn(y, p.itemSize, p.offset, p.normalized); + } else { + let y = wi(p.type, p.array); + _ = new Ue(y, p.itemSize, p.normalized); + } + p.name !== void 0 && (_.name = p.name), x.push(_); + } + o.morphAttributes[f] = x; + } + e.data.morphTargetsRelative && (o.morphTargetsRelative = !0); + let u = e.data.groups || e.data.drawcalls || e.data.offsets; + if (u !== void 0) for(let f = 0, m = u.length; f !== m; ++f){ + let x = u[f]; + o.addGroup(x.start, x.count, x.materialIndex); + } + let d = e.data.boundingSphere; + if (d !== void 0) { + let f = new M; + d.center !== void 0 && f.fromArray(d.center), o.boundingSphere = new An(f, d.radius); + } + return e.name && (o.name = e.name), e.userData && (o.userData = e.userData), o; + } +}, uy = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = this.path === "" ? Gs.extractUrlBase(e) : this.path; + this.resourcePath = this.resourcePath || o; + let a = new Yt(this.manager); + a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(l) { + let c = null; + try { + c = JSON.parse(l); + } catch (u) { + i !== void 0 && i(u), console.error("THREE:ObjectLoader: Can't parse " + e + ".", u.message); + return; + } + let h = c.metadata; + if (h === void 0 || h.type === void 0 || h.type.toLowerCase() === "geometry") { + console.error("THREE.ObjectLoader: Can't load " + e); + return; + } + r.parse(c, t); + }, n, i); + } + async loadAsync(e, t) { + let n = this, i = this.path === "" ? Gs.extractUrlBase(e) : this.path; + this.resourcePath = this.resourcePath || i; + let r = new Yt(this.manager); + r.setPath(this.path), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials); + let o = await r.loadAsync(e, t), a = JSON.parse(o), l = a.metadata; + if (l === void 0 || l.type === void 0 || l.type.toLowerCase() === "geometry") throw new Error("THREE.ObjectLoader: Can't load " + e); + return await n.parseAsync(a); + } + parse(e, t) { + let n = this.parseAnimations(e.animations), i = this.parseShapes(e.shapes), r = this.parseGeometries(e.geometries, i), o = this.parseImages(e.images, function() { + t !== void 0 && t(c); + }), a = this.parseTextures(e.textures, o), l = this.parseMaterials(e.materials, a), c = this.parseObject(e.object, r, l, a, n), h = this.parseSkeletons(e.skeletons, c); + if (this.bindSkeletons(c, h), t !== void 0) { + let u = !1; + for(let d in o)if (o[d] instanceof HTMLImageElement) { + u = !0; + break; + } + u === !1 && t(c); + } + return c; + } + async parseAsync(e) { + let t = this.parseAnimations(e.animations), n = this.parseShapes(e.shapes), i = this.parseGeometries(e.geometries, n), r = await this.parseImagesAsync(e.images), o = this.parseTextures(e.textures, r), a = this.parseMaterials(e.materials, o), l = this.parseObject(e.object, i, a, o, t), c = this.parseSkeletons(e.skeletons, l); + return this.bindSkeletons(l, c), l; + } + parseShapes(e) { + let t = {}; + if (e !== void 0) for(let n = 0, i = e.length; n < i; n++){ + let r = new Xt().fromJSON(e[n]); + t[r.uuid] = r; + } + return t; + } + parseSkeletons(e, t) { + let n = {}, i = {}; + if (t.traverse(function(r) { + r.isBone && (i[r.uuid] = r); + }), e !== void 0) for(let r = 0, o = e.length; r < o; r++){ + let a = new ao().fromJSON(e[r], i); + n[a.uuid] = a; + } + return n; + } + parseGeometries(e, t) { + let n = {}; + if (e !== void 0) { + let i = new Uh; + for(let r = 0, o = e.length; r < o; r++){ + let a, l = e[r]; + switch(l.type){ + case "BufferGeometry": + case "InstancedBufferGeometry": + a = i.parse(l); + break; + case "Geometry": + console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported."); + break; + default: + l.type in vc ? a = vc[l.type].fromJSON(l, t) : console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`); + } + a.uuid = l.uuid, l.name !== void 0 && (a.name = l.name), a.isBufferGeometry === !0 && l.userData !== void 0 && (a.userData = l.userData), n[l.uuid] = a; + } + } + return n; + } + parseMaterials(e, t) { + let n = {}, i = {}; + if (e !== void 0) { + let r = new zh; + r.setTextures(t); + for(let o = 0, a = e.length; o < a; o++){ + let l = e[o]; + if (l.type === "MultiMaterial") { + let c = []; + for(let h = 0; h < l.materials.length; h++){ + let u = l.materials[h]; + n[u.uuid] === void 0 && (n[u.uuid] = r.parse(u)), c.push(n[u.uuid]); + } + i[l.uuid] = c; + } else n[l.uuid] === void 0 && (n[l.uuid] = r.parse(l)), i[l.uuid] = n[l.uuid]; + } + } + return i; + } + parseAnimations(e) { + let t = {}; + if (e !== void 0) for(let n = 0; n < e.length; n++){ + let i = e[n], r = Lr.parse(i); + t[r.uuid] = r; + } + return t; + } + parseImages(e, t) { + let n = this, i = {}, r; + function o(l) { + return n.manager.itemStart(l), r.load(l, function() { + n.manager.itemEnd(l); + }, void 0, function() { + n.manager.itemError(l), n.manager.itemEnd(l); + }); + } + function a(l) { + if (typeof l == "string") { + let c = l, h = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(c) ? c : n.resourcePath + c; + return o(h); + } else return l.data ? { + data: wi(l.type, l.data), + width: l.width, + height: l.height + } : null; + } + if (e !== void 0 && e.length > 0) { + let l = new za(t); + r = new Rr(l), r.setCrossOrigin(this.crossOrigin); + for(let c = 0, h = e.length; c < h; c++){ + let u = e[c], d = u.url; + if (Array.isArray(d)) { + i[u.uuid] = []; + for(let f = 0, m = d.length; f < m; f++){ + let x = d[f], v = a(x); + v !== null && (v instanceof HTMLImageElement ? i[u.uuid].push(v) : i[u.uuid].push(new qn(v.data, v.width, v.height))); + } + } else { + let f = a(u.url); + f !== null && (i[u.uuid] = f); + } + } + } + return i; + } + async parseImagesAsync(e) { + let t = this, n = {}, i; + async function r(o) { + if (typeof o == "string") { + let a = o, l = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(a) ? a : t.resourcePath + a; + return await i.loadAsync(l); + } else return o.data ? { + data: wi(o.type, o.data), + width: o.width, + height: o.height + } : null; + } + if (e !== void 0 && e.length > 0) { + i = new Rr(this.manager), i.setCrossOrigin(this.crossOrigin); + for(let o = 0, a = e.length; o < a; o++){ + let l = e[o], c = l.url; + if (Array.isArray(c)) { + n[l.uuid] = []; + for(let h = 0, u = c.length; h < u; h++){ + let d = c[h], f = await r(d); + f !== null && (f instanceof HTMLImageElement ? n[l.uuid].push(f) : n[l.uuid].push(new qn(f.data, f.width, f.height))); + } + } else { + let h = await r(l.url); + h !== null && (n[l.uuid] = h); + } + } + } + return n; + } + parseTextures(e, t) { + function n(r, o) { + return typeof r == "number" ? r : (console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", r), o[r]); + } + let i = {}; + if (e !== void 0) for(let r = 0, o = e.length; r < o; r++){ + let a = e[r]; + a.image === void 0 && console.warn('THREE.ObjectLoader: No "image" specified for', a.uuid), t[a.image] === void 0 && console.warn("THREE.ObjectLoader: Undefined image", a.image); + let l, c = t[a.image]; + Array.isArray(c) ? (l = new ki(c), c.length === 6 && (l.needsUpdate = !0)) : (c && c.data ? l = new qn(c.data, c.width, c.height) : l = new ot(c), c && (l.needsUpdate = !0)), l.uuid = a.uuid, a.name !== void 0 && (l.name = a.name), a.mapping !== void 0 && (l.mapping = n(a.mapping, dy)), a.offset !== void 0 && l.offset.fromArray(a.offset), a.repeat !== void 0 && l.repeat.fromArray(a.repeat), a.center !== void 0 && l.center.fromArray(a.center), a.rotation !== void 0 && (l.rotation = a.rotation), a.wrap !== void 0 && (l.wrapS = n(a.wrap[0], Sc), l.wrapT = n(a.wrap[1], Sc)), a.format !== void 0 && (l.format = a.format), a.type !== void 0 && (l.type = a.type), a.encoding !== void 0 && (l.encoding = a.encoding), a.minFilter !== void 0 && (l.minFilter = n(a.minFilter, Tc)), a.magFilter !== void 0 && (l.magFilter = n(a.magFilter, Tc)), a.anisotropy !== void 0 && (l.anisotropy = a.anisotropy), a.flipY !== void 0 && (l.flipY = a.flipY), a.premultiplyAlpha !== void 0 && (l.premultiplyAlpha = a.premultiplyAlpha), a.unpackAlignment !== void 0 && (l.unpackAlignment = a.unpackAlignment), a.userData !== void 0 && (l.userData = a.userData), i[a.uuid] = l; + } + return i; + } + parseObject(e, t, n, i, r) { + let o; + function a(d) { + return t[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined geometry", d), t[d]; + } + function l(d) { + if (d !== void 0) { + if (Array.isArray(d)) { + let f = []; + for(let m = 0, x = d.length; m < x; m++){ + let v = d[m]; + n[v] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", v), f.push(n[v]); + } + return f; + } + return n[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", d), n[d]; + } + } + function c(d) { + return i[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined texture", d), i[d]; + } + let h, u; + switch(e.type){ + case "Scene": + o = new no, e.background !== void 0 && (Number.isInteger(e.background) ? o.background = new ae(e.background) : o.background = c(e.background)), e.environment !== void 0 && (o.environment = c(e.environment)), e.fog !== void 0 && (e.fog.type === "Fog" ? o.fog = new Br(e.fog.color, e.fog.near, e.fog.far) : e.fog.type === "FogExp2" && (o.fog = new Nr(e.fog.color, e.fog.density))); + break; + case "PerspectiveCamera": + o = new ut(e.fov, e.aspect, e.near, e.far), e.focus !== void 0 && (o.focus = e.focus), e.zoom !== void 0 && (o.zoom = e.zoom), e.filmGauge !== void 0 && (o.filmGauge = e.filmGauge), e.filmOffset !== void 0 && (o.filmOffset = e.filmOffset), e.view !== void 0 && (o.view = Object.assign({}, e.view)); + break; + case "OrthographicCamera": + o = new Fr(e.left, e.right, e.top, e.bottom, e.near, e.far), e.zoom !== void 0 && (o.zoom = e.zoom), e.view !== void 0 && (o.view = Object.assign({}, e.view)); + break; + case "AmbientLight": + o = new qa(e.color, e.intensity); + break; + case "DirectionalLight": + o = new Wa(e.color, e.intensity); + break; + case "PointLight": + o = new Ga(e.color, e.intensity, e.distance, e.decay); + break; + case "RectAreaLight": + o = new Xa(e.color, e.intensity, e.width, e.height); + break; + case "SpotLight": + o = new Ha(e.color, e.intensity, e.distance, e.angle, e.penumbra, e.decay); + break; + case "HemisphereLight": + o = new Ua(e.color, e.groundColor, e.intensity); + break; + case "LightProbe": + o = new Hr().fromJSON(e); + break; + case "SkinnedMesh": + h = a(e.geometry), u = l(e.material), o = new so(h, u), e.bindMode !== void 0 && (o.bindMode = e.bindMode), e.bindMatrix !== void 0 && o.bindMatrix.fromArray(e.bindMatrix), e.skeleton !== void 0 && (o.skeleton = e.skeleton); + break; + case "Mesh": + h = a(e.geometry), u = l(e.material), o = new st(h, u); + break; + case "InstancedMesh": + h = a(e.geometry), u = l(e.material); + let d = e.count, f = e.instanceMatrix, m = e.instanceColor; + o = new xa(h, u, d), o.instanceMatrix = new Xn(new Float32Array(f.array), 16), m !== void 0 && (o.instanceColor = new Xn(new Float32Array(m.array), m.itemSize)); + break; + case "LOD": + o = new bh; + break; + case "Line": + o = new on(a(e.geometry), l(e.material)); + break; + case "LineLoop": + o = new ya(a(e.geometry), l(e.material)); + break; + case "LineSegments": + o = new wt(a(e.geometry), l(e.material)); + break; + case "PointCloud": + case "Points": + o = new zr(a(e.geometry), l(e.material)); + break; + case "Sprite": + o = new ro(l(e.material)); + break; + case "Group": + o = new Hn; + break; + case "Bone": + o = new oo; + break; + default: + o = new Ne; + } + if (o.uuid = e.uuid, e.name !== void 0 && (o.name = e.name), e.matrix !== void 0 ? (o.matrix.fromArray(e.matrix), e.matrixAutoUpdate !== void 0 && (o.matrixAutoUpdate = e.matrixAutoUpdate), o.matrixAutoUpdate && o.matrix.decompose(o.position, o.quaternion, o.scale)) : (e.position !== void 0 && o.position.fromArray(e.position), e.rotation !== void 0 && o.rotation.fromArray(e.rotation), e.quaternion !== void 0 && o.quaternion.fromArray(e.quaternion), e.scale !== void 0 && o.scale.fromArray(e.scale)), e.castShadow !== void 0 && (o.castShadow = e.castShadow), e.receiveShadow !== void 0 && (o.receiveShadow = e.receiveShadow), e.shadow && (e.shadow.bias !== void 0 && (o.shadow.bias = e.shadow.bias), e.shadow.normalBias !== void 0 && (o.shadow.normalBias = e.shadow.normalBias), e.shadow.radius !== void 0 && (o.shadow.radius = e.shadow.radius), e.shadow.mapSize !== void 0 && o.shadow.mapSize.fromArray(e.shadow.mapSize), e.shadow.camera !== void 0 && (o.shadow.camera = this.parseObject(e.shadow.camera))), e.visible !== void 0 && (o.visible = e.visible), e.frustumCulled !== void 0 && (o.frustumCulled = e.frustumCulled), e.renderOrder !== void 0 && (o.renderOrder = e.renderOrder), e.userData !== void 0 && (o.userData = e.userData), e.layers !== void 0 && (o.layers.mask = e.layers), e.children !== void 0) { + let d = e.children; + for(let f = 0; f < d.length; f++)o.add(this.parseObject(d[f], t, n, i, r)); + } + if (e.animations !== void 0) { + let d = e.animations; + for(let f = 0; f < d.length; f++){ + let m = d[f]; + o.animations.push(r[m]); + } + } + if (e.type === "LOD") { + e.autoUpdate !== void 0 && (o.autoUpdate = e.autoUpdate); + let d = e.levels; + for(let f = 0; f < d.length; f++){ + let m = d[f], x = o.getObjectByProperty("uuid", m.object); + x !== void 0 && o.addLevel(x, m.distance); + } + } + return o; + } + bindSkeletons(e, t) { + Object.keys(t).length !== 0 && e.traverse(function(n) { + if (n.isSkinnedMesh === !0 && n.skeleton !== void 0) { + let i = t[n.skeleton]; + i === void 0 ? console.warn("THREE.ObjectLoader: No skeleton found with UUID:", n.skeleton) : n.bind(i, n.bindMatrix); + } + }); + } + setTexturePath(e) { + return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."), this.setResourcePath(e); + } +}, dy = { + UVMapping: ha, + CubeReflectionMapping: Bi, + CubeRefractionMapping: zi, + EquirectangularReflectionMapping: Ds, + EquirectangularRefractionMapping: Fs, + CubeUVReflectionMapping: Pr, + CubeUVRefractionMapping: Ws +}, Sc = { + RepeatWrapping: Ns, + ClampToEdgeWrapping: vt, + MirroredRepeatWrapping: Bs +}, Tc = { + NearestFilter: rt, + NearestMipmapNearestFilter: ta, + NearestMipmapLinearFilter: na, + LinearFilter: tt, + LinearMipmapNearestFilter: Wc, + LinearMipmapLinearFilter: Ui +}, Oh = class extends bt { + constructor(e){ + super(e); + typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { + premultiplyAlpha: "none" + }; + } + setOptions(e) { + return this.options = e, this; + } + load(e, t, n, i) { + e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); + let r = this, o = Ni.get(e); + if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { + t && t(o), r.manager.itemEnd(e); + }, 0), o; + let a = {}; + a.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", a.headers = this.requestHeader, fetch(e, a).then(function(l) { + return l.blob(); + }).then(function(l) { + return createImageBitmap(l, Object.assign(r.options, { + colorSpaceConversion: "none" + })); + }).then(function(l) { + Ni.add(e, l), t && t(l), r.manager.itemEnd(e); + }).catch(function(l) { + i && i(l), r.manager.itemError(e), r.manager.itemEnd(e); + }), r.manager.itemStart(e); + } +}; +Oh.prototype.isImageBitmapLoader = !0; +var Ss, Hh = { + getContext: function() { + return Ss === void 0 && (Ss = new (window.AudioContext || window.webkitAudioContext)), Ss; + }, + setContext: function(s) { + Ss = s; + } +}, kh = class extends bt { + constructor(e){ + super(e); + } + load(e, t, n, i) { + let r = this, o = new Yt(this.manager); + o.setResponseType("arraybuffer"), o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { + try { + let l = a.slice(0); + Hh.getContext().decodeAudioData(l, function(h) { + t(h); + }); + } catch (l) { + i ? i(l) : console.error(l), r.manager.itemError(e); + } + }, n, i); + } +}, Gh = class extends Hr { + constructor(e, t, n = 1){ + super(void 0, n); + let i = new ae().set(e), r = new ae().set(t), o = new M(i.r, i.g, i.b), a = new M(r.r, r.g, r.b), l = Math.sqrt(Math.PI), c = l * Math.sqrt(.75); + this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l), this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c); + } +}; +Gh.prototype.isHemisphereLightProbe = !0; +var Vh = class extends Hr { + constructor(e, t = 1){ + super(void 0, t); + let n = new ae().set(e); + this.sh.coefficients[0].set(n.r, n.g, n.b).multiplyScalar(2 * Math.sqrt(Math.PI)); + } +}; +Vh.prototype.isAmbientLightProbe = !0; +var Ec = new pe, Ac = new pe, Fn = new pe, fy = class { + constructor(){ + this.type = "StereoCamera", this.aspect = 1, this.eyeSep = .064, this.cameraL = new ut, this.cameraL.layers.enable(1), this.cameraL.matrixAutoUpdate = !1, this.cameraR = new ut, this.cameraR.layers.enable(2), this.cameraR.matrixAutoUpdate = !1, this._cache = { + focus: null, + fov: null, + aspect: null, + near: null, + far: null, + zoom: null, + eyeSep: null + }; + } + update(e) { + let t = this._cache; + if (t.focus !== e.focus || t.fov !== e.fov || t.aspect !== e.aspect * this.aspect || t.near !== e.near || t.far !== e.far || t.zoom !== e.zoom || t.eyeSep !== this.eyeSep) { + t.focus = e.focus, t.fov = e.fov, t.aspect = e.aspect * this.aspect, t.near = e.near, t.far = e.far, t.zoom = e.zoom, t.eyeSep = this.eyeSep, Fn.copy(e.projectionMatrix); + let i = t.eyeSep / 2, r = i * t.near / t.focus, o = t.near * Math.tan(Wn * t.fov * .5) / t.zoom, a, l; + Ac.elements[12] = -i, Ec.elements[12] = i, a = -o * t.aspect + r, l = o * t.aspect + r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraL.projectionMatrix.copy(Fn), a = -o * t.aspect - r, l = o * t.aspect - r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraR.projectionMatrix.copy(Fn); + } + this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ac), this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ec); + } +}, Wh = class { + constructor(e = !0){ + this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1; + } + start() { + this.startTime = Cc(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0; + } + stop() { + this.getElapsedTime(), this.running = !1, this.autoStart = !1; + } + getElapsedTime() { + return this.getDelta(), this.elapsedTime; + } + getDelta() { + let e = 0; + if (this.autoStart && !this.running) return this.start(), 0; + if (this.running) { + let t = Cc(); + e = (t - this.oldTime) / 1e3, this.oldTime = t, this.elapsedTime += e; + } + return e; + } +}; +function Cc() { + return (typeof performance > "u" ? Date : performance).now(); +} +var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { + constructor(){ + super(); + this.type = "AudioListener", this.context = Hh.getContext(), this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.filter = null, this.timeDelta = 0, this._clock = new Wh; + } + getInput() { + return this.gain; + } + removeFilter() { + return this.filter !== null && (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination), this.gain.connect(this.context.destination), this.filter = null), this; + } + getFilter() { + return this.filter; + } + setFilter(e) { + return this.filter !== null ? (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination)) : this.gain.disconnect(this.context.destination), this.filter = e, this.gain.connect(this.filter), this.filter.connect(this.context.destination), this; + } + getMasterVolume() { + return this.gain.gain.value; + } + setMasterVolume(e) { + return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; + } + updateMatrixWorld(e) { + super.updateMatrixWorld(e); + let t = this.context.listener, n = this.up; + if (this.timeDelta = this._clock.getDelta(), this.matrixWorld.decompose(Nn, Lc, py), Bn.set(0, 0, -1).applyQuaternion(Lc), t.positionX) { + let i = this.context.currentTime + this.timeDelta; + t.positionX.linearRampToValueAtTime(Nn.x, i), t.positionY.linearRampToValueAtTime(Nn.y, i), t.positionZ.linearRampToValueAtTime(Nn.z, i), t.forwardX.linearRampToValueAtTime(Bn.x, i), t.forwardY.linearRampToValueAtTime(Bn.y, i), t.forwardZ.linearRampToValueAtTime(Bn.z, i), t.upX.linearRampToValueAtTime(n.x, i), t.upY.linearRampToValueAtTime(n.y, i), t.upZ.linearRampToValueAtTime(n.z, i); + } else t.setPosition(Nn.x, Nn.y, Nn.z), t.setOrientation(Bn.x, Bn.y, Bn.z, n.x, n.y, n.z); + } +}, Za = class extends Ne { + constructor(e){ + super(); + this.type = "Audio", this.listener = e, this.context = e.context, this.gain = this.context.createGain(), this.gain.connect(e.getInput()), this.autoplay = !1, this.buffer = null, this.detune = 0, this.loop = !1, this.loopStart = 0, this.loopEnd = 0, this.offset = 0, this.duration = void 0, this.playbackRate = 1, this.isPlaying = !1, this.hasPlaybackControl = !0, this.source = null, this.sourceType = "empty", this._startedAt = 0, this._progress = 0, this._connected = !1, this.filters = []; + } + getOutput() { + return this.gain; + } + setNodeSource(e) { + return this.hasPlaybackControl = !1, this.sourceType = "audioNode", this.source = e, this.connect(), this; + } + setMediaElementSource(e) { + return this.hasPlaybackControl = !1, this.sourceType = "mediaNode", this.source = this.context.createMediaElementSource(e), this.connect(), this; + } + setMediaStreamSource(e) { + return this.hasPlaybackControl = !1, this.sourceType = "mediaStreamNode", this.source = this.context.createMediaStreamSource(e), this.connect(), this; + } + setBuffer(e) { + return this.buffer = e, this.sourceType = "buffer", this.autoplay && this.play(), this; + } + play(e = 0) { + if (this.isPlaying === !0) { + console.warn("THREE.Audio: Audio is already playing."); + return; + } + if (this.hasPlaybackControl === !1) { + console.warn("THREE.Audio: this Audio has no playback control."); + return; + } + this._startedAt = this.context.currentTime + e; + let t = this.context.createBufferSource(); + return t.buffer = this.buffer, t.loop = this.loop, t.loopStart = this.loopStart, t.loopEnd = this.loopEnd, t.onended = this.onEnded.bind(this), t.start(this._startedAt, this._progress + this.offset, this.duration), this.isPlaying = !0, this.source = t, this.setDetune(this.detune), this.setPlaybackRate(this.playbackRate), this.connect(); + } + pause() { + if (this.hasPlaybackControl === !1) { + console.warn("THREE.Audio: this Audio has no playback control."); + return; + } + return this.isPlaying === !0 && (this._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate, this.loop === !0 && (this._progress = this._progress % (this.duration || this.buffer.duration)), this.source.stop(), this.source.onended = null, this.isPlaying = !1), this; + } + stop() { + if (this.hasPlaybackControl === !1) { + console.warn("THREE.Audio: this Audio has no playback control."); + return; + } + return this._progress = 0, this.source.stop(), this.source.onended = null, this.isPlaying = !1, this; + } + connect() { + if (this.filters.length > 0) { + this.source.connect(this.filters[0]); + for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].connect(this.filters[e]); + this.filters[this.filters.length - 1].connect(this.getOutput()); + } else this.source.connect(this.getOutput()); + return this._connected = !0, this; + } + disconnect() { + if (this.filters.length > 0) { + this.source.disconnect(this.filters[0]); + for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].disconnect(this.filters[e]); + this.filters[this.filters.length - 1].disconnect(this.getOutput()); + } else this.source.disconnect(this.getOutput()); + return this._connected = !1, this; + } + getFilters() { + return this.filters; + } + setFilters(e) { + return e || (e = []), this._connected === !0 ? (this.disconnect(), this.filters = e.slice(), this.connect()) : this.filters = e.slice(), this; + } + setDetune(e) { + if (this.detune = e, this.source.detune !== void 0) return this.isPlaying === !0 && this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, .01), this; + } + getDetune() { + return this.detune; + } + getFilter() { + return this.getFilters()[0]; + } + setFilter(e) { + return this.setFilters(e ? [ + e + ] : []); + } + setPlaybackRate(e) { + if (this.hasPlaybackControl === !1) { + console.warn("THREE.Audio: this Audio has no playback control."); + return; + } + return this.playbackRate = e, this.isPlaying === !0 && this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, .01), this; + } + getPlaybackRate() { + return this.playbackRate; + } + onEnded() { + this.isPlaying = !1; + } + getLoop() { + return this.hasPlaybackControl === !1 ? (console.warn("THREE.Audio: this Audio has no playback control."), !1) : this.loop; + } + setLoop(e) { + if (this.hasPlaybackControl === !1) { + console.warn("THREE.Audio: this Audio has no playback control."); + return; + } + return this.loop = e, this.isPlaying === !0 && (this.source.loop = this.loop), this; + } + setLoopStart(e) { + return this.loopStart = e, this; + } + setLoopEnd(e) { + return this.loopEnd = e, this; + } + getVolume() { + return this.gain.gain.value; + } + setVolume(e) { + return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; + } +}, zn = new M, Rc = new gt, gy = new M, Un = new M, xy = class extends Za { + constructor(e){ + super(e); + this.panner = this.context.createPanner(), this.panner.panningModel = "HRTF", this.panner.connect(this.gain); + } + getOutput() { + return this.panner; + } + getRefDistance() { + return this.panner.refDistance; + } + setRefDistance(e) { + return this.panner.refDistance = e, this; + } + getRolloffFactor() { + return this.panner.rolloffFactor; + } + setRolloffFactor(e) { + return this.panner.rolloffFactor = e, this; + } + getDistanceModel() { + return this.panner.distanceModel; + } + setDistanceModel(e) { + return this.panner.distanceModel = e, this; + } + getMaxDistance() { + return this.panner.maxDistance; + } + setMaxDistance(e) { + return this.panner.maxDistance = e, this; + } + setDirectionalCone(e, t, n) { + return this.panner.coneInnerAngle = e, this.panner.coneOuterAngle = t, this.panner.coneOuterGain = n, this; + } + updateMatrixWorld(e) { + if (super.updateMatrixWorld(e), this.hasPlaybackControl === !0 && this.isPlaying === !1) return; + this.matrixWorld.decompose(zn, Rc, gy), Un.set(0, 0, 1).applyQuaternion(Rc); + let t = this.panner; + if (t.positionX) { + let n = this.context.currentTime + this.listener.timeDelta; + t.positionX.linearRampToValueAtTime(zn.x, n), t.positionY.linearRampToValueAtTime(zn.y, n), t.positionZ.linearRampToValueAtTime(zn.z, n), t.orientationX.linearRampToValueAtTime(Un.x, n), t.orientationY.linearRampToValueAtTime(Un.y, n), t.orientationZ.linearRampToValueAtTime(Un.z, n); + } else t.setPosition(zn.x, zn.y, zn.z), t.setOrientation(Un.x, Un.y, Un.z); + } +}, qh = class { + constructor(e, t = 2048){ + this.analyser = e.context.createAnalyser(), this.analyser.fftSize = t, this.data = new Uint8Array(this.analyser.frequencyBinCount), e.getOutput().connect(this.analyser); + } + getFrequencyData() { + return this.analyser.getByteFrequencyData(this.data), this.data; + } + getAverageFrequency() { + let e = 0, t = this.getFrequencyData(); + for(let n = 0; n < t.length; n++)e += t[n]; + return e / t.length; + } +}, Xh = class { + constructor(e, t, n){ + this.binding = e, this.valueSize = n; + let i, r, o; + switch(t){ + case "quaternion": + i = this._slerp, r = this._slerpAdditive, o = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5; + break; + case "string": + case "bool": + i = this._select, r = this._select, o = this._setAdditiveIdentityOther, this.buffer = new Array(n * 5); + break; + default: + i = this._lerp, r = this._lerpAdditive, o = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5); + } + this._mixBufferRegion = i, this._mixBufferRegionAdditive = r, this._setIdentity = o, this._origIndex = 3, this._addIndex = 4, this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, this.useCount = 0, this.referenceCount = 0; + } + accumulate(e, t) { + let n = this.buffer, i = this.valueSize, r = e * i + i, o = this.cumulativeWeight; + if (o === 0) { + for(let a = 0; a !== i; ++a)n[r + a] = n[a]; + o = t; + } else { + o += t; + let a = t / o; + this._mixBufferRegion(n, r, 0, a, i); + } + this.cumulativeWeight = o; + } + accumulateAdditive(e) { + let t = this.buffer, n = this.valueSize, i = n * this._addIndex; + this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(t, i, 0, e, n), this.cumulativeWeightAdditive += e; + } + apply(e) { + let t = this.valueSize, n = this.buffer, i = e * t + t, r = this.cumulativeWeight, o = this.cumulativeWeightAdditive, a = this.binding; + if (this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, r < 1) { + let l = t * this._origIndex; + this._mixBufferRegion(n, i, l, 1 - r, t); + } + o > 0 && this._mixBufferRegionAdditive(n, i, this._addIndex * t, 1, t); + for(let l = t, c = t + t; l !== c; ++l)if (n[l] !== n[l + t]) { + a.setValue(n, i); + break; + } + } + saveOriginalState() { + let e = this.binding, t = this.buffer, n = this.valueSize, i = n * this._origIndex; + e.getValue(t, i); + for(let r = n, o = i; r !== o; ++r)t[r] = t[i + r % n]; + this._setIdentity(), this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0; + } + restoreOriginalState() { + let e = this.valueSize * 3; + this.binding.setValue(this.buffer, e); + } + _setAdditiveIdentityNumeric() { + let e = this._addIndex * this.valueSize, t = e + this.valueSize; + for(let n = e; n < t; n++)this.buffer[n] = 0; + } + _setAdditiveIdentityQuaternion() { + this._setAdditiveIdentityNumeric(), this.buffer[this._addIndex * this.valueSize + 3] = 1; + } + _setAdditiveIdentityOther() { + let e = this._origIndex * this.valueSize, t = this._addIndex * this.valueSize; + for(let n = 0; n < this.valueSize; n++)this.buffer[t + n] = this.buffer[e + n]; + } + _select(e, t, n, i, r) { + if (i >= .5) for(let o = 0; o !== r; ++o)e[t + o] = e[n + o]; + } + _slerp(e, t, n, i) { + gt.slerpFlat(e, t, e, t, e, n, i); + } + _slerpAdditive(e, t, n, i, r) { + let o = this._workIndex * r; + gt.multiplyQuaternionsFlat(e, o, e, t, e, n), gt.slerpFlat(e, t, e, t, e, o, i); + } + _lerp(e, t, n, i, r) { + let o = 1 - i; + for(let a = 0; a !== r; ++a){ + let l = t + a; + e[l] = e[l] * o + e[n + a] * i; + } + } + _lerpAdditive(e, t, n, i, r) { + for(let o = 0; o !== r; ++o){ + let a = t + o; + e[a] = e[a] + e[n + o] * i; + } + } +}, $a = "\\[\\]\\.:\\/", yy = new RegExp("[" + $a + "]", "g"), ja = "[^" + $a + "]", vy = "[^" + $a.replace("\\.", "") + "]", _y = /((?:WC+[\/:])*)/.source.replace("WC", ja), My = /(WCOD+)?/.source.replace("WCOD", vy), by = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", ja), wy = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", ja), Sy = new RegExp("^" + _y + My + by + wy + "$"), Ty = [ + "material", + "materials", + "bones" +], Jh = class { + constructor(e, t, n){ + let i = n || ke.parseTrackName(t); + this._targetGroup = e, this._bindings = e.subscribe_(t, i); + } + getValue(e, t) { + this.bind(); + let n = this._targetGroup.nCachedObjects_, i = this._bindings[n]; + i !== void 0 && i.getValue(e, t); + } + setValue(e, t) { + let n = this._bindings; + for(let i = this._targetGroup.nCachedObjects_, r = n.length; i !== r; ++i)n[i].setValue(e, t); + } + bind() { + let e = this._bindings; + for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].bind(); + } + unbind() { + let e = this._bindings; + for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].unbind(); + } +}, ke = class { + constructor(e, t, n){ + this.path = t, this.parsedPath = n || ke.parseTrackName(t), this.node = ke.findNode(e, this.parsedPath.nodeName) || e, this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; + } + static create(e, t, n) { + return e && e.isAnimationObjectGroup ? new ke.Composite(e, t, n) : new ke(e, t, n); + } + static sanitizeNodeName(e) { + return e.replace(/\s/g, "_").replace(yy, ""); + } + static parseTrackName(e) { + let t = Sy.exec(e); + if (!t) throw new Error("PropertyBinding: Cannot parse trackName: " + e); + let n = { + nodeName: t[2], + objectName: t[3], + objectIndex: t[4], + propertyName: t[5], + propertyIndex: t[6] + }, i = n.nodeName && n.nodeName.lastIndexOf("."); + if (i !== void 0 && i !== -1) { + let r = n.nodeName.substring(i + 1); + Ty.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, i), n.objectName = r); + } + if (n.propertyName === null || n.propertyName.length === 0) throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e); + return n; + } + static findNode(e, t) { + if (!t || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; + if (e.skeleton) { + let n = e.skeleton.getBoneByName(t); + if (n !== void 0) return n; + } + if (e.children) { + let n = function(r) { + for(let o = 0; o < r.length; o++){ + let a = r[o]; + if (a.name === t || a.uuid === t) return a; + let l = n(a.children); + if (l) return l; + } + return null; + }, i = n(e.children); + if (i) return i; + } + return null; + } + _getValue_unavailable() {} + _setValue_unavailable() {} + _getValue_direct(e, t) { + e[t] = this.targetObject[this.propertyName]; + } + _getValue_array(e, t) { + let n = this.resolvedProperty; + for(let i = 0, r = n.length; i !== r; ++i)e[t++] = n[i]; + } + _getValue_arrayElement(e, t) { + e[t] = this.resolvedProperty[this.propertyIndex]; + } + _getValue_toArray(e, t) { + this.resolvedProperty.toArray(e, t); + } + _setValue_direct(e, t) { + this.targetObject[this.propertyName] = e[t]; + } + _setValue_direct_setNeedsUpdate(e, t) { + this.targetObject[this.propertyName] = e[t], this.targetObject.needsUpdate = !0; + } + _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { + this.targetObject[this.propertyName] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; + } + _setValue_array(e, t) { + let n = this.resolvedProperty; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + } + _setValue_array_setNeedsUpdate(e, t) { + let n = this.resolvedProperty; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + this.targetObject.needsUpdate = !0; + } + _setValue_array_setMatrixWorldNeedsUpdate(e, t) { + let n = this.resolvedProperty; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + this.targetObject.matrixWorldNeedsUpdate = !0; + } + _setValue_arrayElement(e, t) { + this.resolvedProperty[this.propertyIndex] = e[t]; + } + _setValue_arrayElement_setNeedsUpdate(e, t) { + this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.needsUpdate = !0; + } + _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { + this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; + } + _setValue_fromArray(e, t) { + this.resolvedProperty.fromArray(e, t); + } + _setValue_fromArray_setNeedsUpdate(e, t) { + this.resolvedProperty.fromArray(e, t), this.targetObject.needsUpdate = !0; + } + _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { + this.resolvedProperty.fromArray(e, t), this.targetObject.matrixWorldNeedsUpdate = !0; + } + _getValue_unbound(e, t) { + this.bind(), this.getValue(e, t); + } + _setValue_unbound(e, t) { + this.bind(), this.setValue(e, t); + } + bind() { + let e = this.node, t = this.parsedPath, n = t.objectName, i = t.propertyName, r = t.propertyIndex; + if (e || (e = ke.findNode(this.rootNode, t.nodeName) || this.rootNode, this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) { + console.error("THREE.PropertyBinding: Trying to update node for track: " + this.path + " but it wasn't found."); + return; + } + if (n) { + let c = t.objectIndex; + switch(n){ + case "materials": + if (!e.material) { + console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); + return; + } + if (!e.material.materials) { + console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this); + return; + } + e = e.material.materials; + break; + case "bones": + if (!e.skeleton) { + console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this); + return; + } + e = e.skeleton.bones; + for(let h = 0; h < e.length; h++)if (e[h].name === c) { + c = h; + break; + } + break; + default: + if (e[n] === void 0) { + console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this); + return; + } + e = e[n]; + } + if (c !== void 0) { + if (e[c] === void 0) { + console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e); + return; + } + e = e[c]; + } + } + let o = e[i]; + if (o === void 0) { + let c = t.nodeName; + console.error("THREE.PropertyBinding: Trying to update property for track: " + c + "." + i + " but it wasn't found.", e); + return; + } + let a = this.Versioning.None; + this.targetObject = e, e.needsUpdate !== void 0 ? a = this.Versioning.NeedsUpdate : e.matrixWorldNeedsUpdate !== void 0 && (a = this.Versioning.MatrixWorldNeedsUpdate); + let l = this.BindingType.Direct; + if (r !== void 0) { + if (i === "morphTargetInfluences") { + if (!e.geometry) { + console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this); + return; + } + if (e.geometry.isBufferGeometry) { + if (!e.geometry.morphAttributes) { + console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); + return; + } + e.morphTargetDictionary[r] !== void 0 && (r = e.morphTargetDictionary[r]); + } else { + console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.", this); + return; + } + } + l = this.BindingType.ArrayElement, this.resolvedProperty = o, this.propertyIndex = r; + } else o.fromArray !== void 0 && o.toArray !== void 0 ? (l = this.BindingType.HasFromToArray, this.resolvedProperty = o) : Array.isArray(o) ? (l = this.BindingType.EntireArray, this.resolvedProperty = o) : this.propertyName = i; + this.getValue = this.GetterByBindingType[l], this.setValue = this.SetterByBindingTypeAndVersioning[l][a]; + } + unbind() { + this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; + } +}; +ke.Composite = Jh; +ke.prototype.BindingType = { + Direct: 0, + EntireArray: 1, + ArrayElement: 2, + HasFromToArray: 3 +}; +ke.prototype.Versioning = { + None: 0, + NeedsUpdate: 1, + MatrixWorldNeedsUpdate: 2 +}; +ke.prototype.GetterByBindingType = [ + ke.prototype._getValue_direct, + ke.prototype._getValue_array, + ke.prototype._getValue_arrayElement, + ke.prototype._getValue_toArray +]; +ke.prototype.SetterByBindingTypeAndVersioning = [ + [ + ke.prototype._setValue_direct, + ke.prototype._setValue_direct_setNeedsUpdate, + ke.prototype._setValue_direct_setMatrixWorldNeedsUpdate + ], + [ + ke.prototype._setValue_array, + ke.prototype._setValue_array_setNeedsUpdate, + ke.prototype._setValue_array_setMatrixWorldNeedsUpdate + ], + [ + ke.prototype._setValue_arrayElement, + ke.prototype._setValue_arrayElement_setNeedsUpdate, + ke.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate + ], + [ + ke.prototype._setValue_fromArray, + ke.prototype._setValue_fromArray_setNeedsUpdate, + ke.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate + ] +]; +var Yh = class { + constructor(){ + this.uuid = Et(), this._objects = Array.prototype.slice.call(arguments), this.nCachedObjects_ = 0; + let e = {}; + this._indicesByUUID = e; + for(let n = 0, i = arguments.length; n !== i; ++n)e[arguments[n].uuid] = n; + this._paths = [], this._parsedPaths = [], this._bindings = [], this._bindingsIndicesByPath = {}; + let t = this; + this.stats = { + objects: { + get total () { + return t._objects.length; + }, + get inUse () { + return this.total - t.nCachedObjects_; + } + }, + get bindingsPerObject () { + return t._bindings.length; + } + }; + } + add() { + let e = this._objects, t = this._indicesByUUID, n = this._paths, i = this._parsedPaths, r = this._bindings, o = r.length, a, l = e.length, c = this.nCachedObjects_; + for(let h = 0, u = arguments.length; h !== u; ++h){ + let d = arguments[h], f = d.uuid, m = t[f]; + if (m === void 0) { + m = l++, t[f] = m, e.push(d); + for(let x = 0, v = o; x !== v; ++x)r[x].push(new ke(d, n[x], i[x])); + } else if (m < c) { + a = e[m]; + let x = --c, v = e[x]; + t[v.uuid] = m, e[m] = v, t[f] = x, e[x] = d; + for(let g = 0, p = o; g !== p; ++g){ + let _ = r[g], y = _[x], b = _[m]; + _[m] = y, b === void 0 && (b = new ke(d, n[g], i[g])), _[x] = b; + } + } else e[m] !== a && console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes."); + } + this.nCachedObjects_ = c; + } + remove() { + let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_; + for(let o = 0, a = arguments.length; o !== a; ++o){ + let l = arguments[o], c = l.uuid, h = t[c]; + if (h !== void 0 && h >= r) { + let u = r++, d = e[u]; + t[d.uuid] = h, e[h] = d, t[c] = u, e[u] = l; + for(let f = 0, m = i; f !== m; ++f){ + let x = n[f], v = x[u], g = x[h]; + x[h] = v, x[u] = g; + } + } + } + this.nCachedObjects_ = r; + } + uncache() { + let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_, o = e.length; + for(let a = 0, l = arguments.length; a !== l; ++a){ + let c = arguments[a], h = c.uuid, u = t[h]; + if (u !== void 0) if (delete t[h], u < r) { + let d = --r, f = e[d], m = --o, x = e[m]; + t[f.uuid] = u, e[u] = f, t[x.uuid] = d, e[d] = x, e.pop(); + for(let v = 0, g = i; v !== g; ++v){ + let p = n[v], _ = p[d], y = p[m]; + p[u] = _, p[d] = y, p.pop(); + } + } else { + let d = --o, f = e[d]; + d > 0 && (t[f.uuid] = u), e[u] = f, e.pop(); + for(let m = 0, x = i; m !== x; ++m){ + let v = n[m]; + v[u] = v[d], v.pop(); + } + } + } + this.nCachedObjects_ = r; + } + subscribe_(e, t) { + let n = this._bindingsIndicesByPath, i = n[e], r = this._bindings; + if (i !== void 0) return r[i]; + let o = this._paths, a = this._parsedPaths, l = this._objects, c = l.length, h = this.nCachedObjects_, u = new Array(c); + i = r.length, n[e] = i, o.push(e), a.push(t), r.push(u); + for(let d = h, f = l.length; d !== f; ++d){ + let m = l[d]; + u[d] = new ke(m, e, t); + } + return u; + } + unsubscribe_(e) { + let t = this._bindingsIndicesByPath, n = t[e]; + if (n !== void 0) { + let i = this._paths, r = this._parsedPaths, o = this._bindings, a = o.length - 1, l = o[a], c = e[a]; + t[c] = n, o[n] = l, o.pop(), r[n] = r[a], r.pop(), i[n] = i[a], i.pop(); + } + } +}; +Yh.prototype.isAnimationObjectGroup = !0; +var Zh = class { + constructor(e, t, n = null, i = t.blendMode){ + this._mixer = e, this._clip = t, this._localRoot = n, this.blendMode = i; + let r = t.tracks, o = r.length, a = new Array(o), l = { + endingStart: Mi, + endingEnd: Mi + }; + for(let c = 0; c !== o; ++c){ + let h = r[c].createInterpolant(null); + a[c] = h, h.settings = l; + } + this._interpolantSettings = l, this._interpolants = a, this._propertyBindings = new Array(o), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._weightInterpolant = null, this.loop = Id, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = 1 / 0, this.paused = !1, this.enabled = !0, this.clampWhenFinished = !1, this.zeroSlopeAtStart = !0, this.zeroSlopeAtEnd = !0; + } + play() { + return this._mixer._activateAction(this), this; + } + stop() { + return this._mixer._deactivateAction(this), this.reset(); + } + reset() { + return this.paused = !1, this.enabled = !0, this.time = 0, this._loopCount = -1, this._startTime = null, this.stopFading().stopWarping(); + } + isRunning() { + return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this); + } + isScheduled() { + return this._mixer._isActiveAction(this); + } + startAt(e) { + return this._startTime = e, this; + } + setLoop(e, t) { + return this.loop = e, this.repetitions = t, this; + } + setEffectiveWeight(e) { + return this.weight = e, this._effectiveWeight = this.enabled ? e : 0, this.stopFading(); + } + getEffectiveWeight() { + return this._effectiveWeight; + } + fadeIn(e) { + return this._scheduleFading(e, 0, 1); + } + fadeOut(e) { + return this._scheduleFading(e, 1, 0); + } + crossFadeFrom(e, t, n) { + if (e.fadeOut(t), this.fadeIn(t), n) { + let i = this._clip.duration, r = e._clip.duration, o = r / i, a = i / r; + e.warp(1, o, t), this.warp(a, 1, t); + } + return this; + } + crossFadeTo(e, t, n) { + return e.crossFadeFrom(this, t, n); + } + stopFading() { + let e = this._weightInterpolant; + return e !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; + } + setEffectiveTimeScale(e) { + return this.timeScale = e, this._effectiveTimeScale = this.paused ? 0 : e, this.stopWarping(); + } + getEffectiveTimeScale() { + return this._effectiveTimeScale; + } + setDuration(e) { + return this.timeScale = this._clip.duration / e, this.stopWarping(); + } + syncWith(e) { + return this.time = e.time, this.timeScale = e.timeScale, this.stopWarping(); + } + halt(e) { + return this.warp(this._effectiveTimeScale, 0, e); + } + warp(e, t, n) { + let i = this._mixer, r = i.time, o = this.timeScale, a = this._timeScaleInterpolant; + a === null && (a = i._lendControlInterpolant(), this._timeScaleInterpolant = a); + let l = a.parameterPositions, c = a.sampleValues; + return l[0] = r, l[1] = r + n, c[0] = e / o, c[1] = t / o, this; + } + stopWarping() { + let e = this._timeScaleInterpolant; + return e !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; + } + getMixer() { + return this._mixer; + } + getClip() { + return this._clip; + } + getRoot() { + return this._localRoot || this._mixer._root; + } + _update(e, t, n, i) { + if (!this.enabled) { + this._updateWeight(e); + return; + } + let r = this._startTime; + if (r !== null) { + let l = (e - r) * n; + if (l < 0 || n === 0) return; + this._startTime = null, t = n * l; + } + t *= this._updateTimeScale(e); + let o = this._updateTime(t), a = this._updateWeight(e); + if (a > 0) { + let l = this._interpolants, c = this._propertyBindings; + switch(this.blendMode){ + case qc: + for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulateAdditive(a); + break; + case ua: + default: + for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulate(i, a); + } + } + } + _updateWeight(e) { + let t = 0; + if (this.enabled) { + t = this.weight; + let n = this._weightInterpolant; + if (n !== null) { + let i = n.evaluate(e)[0]; + t *= i, e > n.parameterPositions[1] && (this.stopFading(), i === 0 && (this.enabled = !1)); + } + } + return this._effectiveWeight = t, t; + } + _updateTimeScale(e) { + let t = 0; + if (!this.paused) { + t = this.timeScale; + let n = this._timeScaleInterpolant; + n !== null && (t *= n.evaluate(e)[0], e > n.parameterPositions[1] && (this.stopWarping(), t === 0 ? this.paused = !0 : this.timeScale = t)); + } + return this._effectiveTimeScale = t, t; + } + _updateTime(e) { + let t = this._clip.duration, n = this.loop, i = this.time + e, r = this._loopCount, o = n === Dd; + if (e === 0) return r === -1 ? i : o && (r & 1) === 1 ? t - i : i; + if (n === Pd) { + r === -1 && (this._loopCount = 0, this._setEndings(!0, !0, !1)); + e: { + if (i >= t) i = t; + else if (i < 0) i = 0; + else { + this.time = i; + break e; + } + this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, this.time = i, this._mixer.dispatchEvent({ + type: "finished", + action: this, + direction: e < 0 ? -1 : 1 + }); + } + } else { + if (r === -1 && (e >= 0 ? (r = 0, this._setEndings(!0, this.repetitions === 0, o)) : this._setEndings(this.repetitions === 0, !0, o)), i >= t || i < 0) { + let a = Math.floor(i / t); + i -= t * a, r += Math.abs(a); + let l = this.repetitions - r; + if (l <= 0) this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, i = e > 0 ? t : 0, this.time = i, this._mixer.dispatchEvent({ + type: "finished", + action: this, + direction: e > 0 ? 1 : -1 + }); + else { + if (l === 1) { + let c = e < 0; + this._setEndings(c, !c, o); + } else this._setEndings(!1, !1, o); + this._loopCount = r, this.time = i, this._mixer.dispatchEvent({ + type: "loop", + action: this, + loopDelta: a + }); + } + } else this.time = i; + if (o && (r & 1) === 1) return t - i; + } + return i; + } + _setEndings(e, t, n) { + let i = this._interpolantSettings; + n ? (i.endingStart = bi, i.endingEnd = bi) : (e ? i.endingStart = this.zeroSlopeAtStart ? bi : Mi : i.endingStart = Os, t ? i.endingEnd = this.zeroSlopeAtEnd ? bi : Mi : i.endingEnd = Os); + } + _scheduleFading(e, t, n) { + let i = this._mixer, r = i.time, o = this._weightInterpolant; + o === null && (o = i._lendControlInterpolant(), this._weightInterpolant = o); + let a = o.parameterPositions, l = o.sampleValues; + return a[0] = r, l[0] = t, a[1] = r + e, l[1] = n, this; + } +}, $h = class extends En { + constructor(e){ + super(); + this._root = e, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1; + } + _bindAction(e, t) { + let n = e._localRoot || this._root, i = e._clip.tracks, r = i.length, o = e._propertyBindings, a = e._interpolants, l = n.uuid, c = this._bindingsByRootAndName, h = c[l]; + h === void 0 && (h = {}, c[l] = h); + for(let u = 0; u !== r; ++u){ + let d = i[u], f = d.name, m = h[f]; + if (m !== void 0) o[u] = m; + else { + if (m = o[u], m !== void 0) { + m._cacheIndex === null && (++m.referenceCount, this._addInactiveBinding(m, l, f)); + continue; + } + let x = t && t._propertyBindings[u].binding.parsedPath; + m = new Xh(ke.create(n, f, x), d.ValueTypeName, d.getValueSize()), ++m.referenceCount, this._addInactiveBinding(m, l, f), o[u] = m; + } + a[u].resultBuffer = m.buffer; + } + } + _activateAction(e) { + if (!this._isActiveAction(e)) { + if (e._cacheIndex === null) { + let n = (e._localRoot || this._root).uuid, i = e._clip.uuid, r = this._actionsByClip[i]; + this._bindAction(e, r && r.knownActions[0]), this._addInactiveAction(e, i, n); + } + let t = e._propertyBindings; + for(let n = 0, i = t.length; n !== i; ++n){ + let r = t[n]; + r.useCount++ === 0 && (this._lendBinding(r), r.saveOriginalState()); + } + this._lendAction(e); + } + } + _deactivateAction(e) { + if (this._isActiveAction(e)) { + let t = e._propertyBindings; + for(let n = 0, i = t.length; n !== i; ++n){ + let r = t[n]; + --r.useCount === 0 && (r.restoreOriginalState(), this._takeBackBinding(r)); + } + this._takeBackAction(e); + } + } + _initMemoryManager() { + this._actions = [], this._nActiveActions = 0, this._actionsByClip = {}, this._bindings = [], this._nActiveBindings = 0, this._bindingsByRootAndName = {}, this._controlInterpolants = [], this._nActiveControlInterpolants = 0; + let e = this; + this.stats = { + actions: { + get total () { + return e._actions.length; + }, + get inUse () { + return e._nActiveActions; + } + }, + bindings: { + get total () { + return e._bindings.length; + }, + get inUse () { + return e._nActiveBindings; + } + }, + controlInterpolants: { + get total () { + return e._controlInterpolants.length; + }, + get inUse () { + return e._nActiveControlInterpolants; + } + } + }; + } + _isActiveAction(e) { + let t = e._cacheIndex; + return t !== null && t < this._nActiveActions; + } + _addInactiveAction(e, t, n) { + let i = this._actions, r = this._actionsByClip, o = r[t]; + if (o === void 0) o = { + knownActions: [ + e + ], + actionByRoot: {} + }, e._byClipCacheIndex = 0, r[t] = o; + else { + let a = o.knownActions; + e._byClipCacheIndex = a.length, a.push(e); + } + e._cacheIndex = i.length, i.push(e), o.actionByRoot[n] = e; + } + _removeInactiveAction(e) { + let t = this._actions, n = t[t.length - 1], i = e._cacheIndex; + n._cacheIndex = i, t[i] = n, t.pop(), e._cacheIndex = null; + let r = e._clip.uuid, o = this._actionsByClip, a = o[r], l = a.knownActions, c = l[l.length - 1], h = e._byClipCacheIndex; + c._byClipCacheIndex = h, l[h] = c, l.pop(), e._byClipCacheIndex = null; + let u = a.actionByRoot, d = (e._localRoot || this._root).uuid; + delete u[d], l.length === 0 && delete o[r], this._removeInactiveBindingsForAction(e); + } + _removeInactiveBindingsForAction(e) { + let t = e._propertyBindings; + for(let n = 0, i = t.length; n !== i; ++n){ + let r = t[n]; + --r.referenceCount === 0 && this._removeInactiveBinding(r); + } + } + _lendAction(e) { + let t = this._actions, n = e._cacheIndex, i = this._nActiveActions++, r = t[i]; + e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + } + _takeBackAction(e) { + let t = this._actions, n = e._cacheIndex, i = --this._nActiveActions, r = t[i]; + e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + } + _addInactiveBinding(e, t, n) { + let i = this._bindingsByRootAndName, r = this._bindings, o = i[t]; + o === void 0 && (o = {}, i[t] = o), o[n] = e, e._cacheIndex = r.length, r.push(e); + } + _removeInactiveBinding(e) { + let t = this._bindings, n = e.binding, i = n.rootNode.uuid, r = n.path, o = this._bindingsByRootAndName, a = o[i], l = t[t.length - 1], c = e._cacheIndex; + l._cacheIndex = c, t[c] = l, t.pop(), delete a[r], Object.keys(a).length === 0 && delete o[i]; + } + _lendBinding(e) { + let t = this._bindings, n = e._cacheIndex, i = this._nActiveBindings++, r = t[i]; + e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + } + _takeBackBinding(e) { + let t = this._bindings, n = e._cacheIndex, i = --this._nActiveBindings, r = t[i]; + e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + } + _lendControlInterpolant() { + let e = this._controlInterpolants, t = this._nActiveControlInterpolants++, n = e[t]; + return n === void 0 && (n = new Na(new Float32Array(2), new Float32Array(2), 1, this._controlInterpolantsResultBuffer), n.__cacheIndex = t, e[t] = n), n; + } + _takeBackControlInterpolant(e) { + let t = this._controlInterpolants, n = e.__cacheIndex, i = --this._nActiveControlInterpolants, r = t[i]; + e.__cacheIndex = i, t[i] = e, r.__cacheIndex = n, t[n] = r; + } + clipAction(e, t, n) { + let i = t || this._root, r = i.uuid, o = typeof e == "string" ? Lr.findByName(i, e) : e, a = o !== null ? o.uuid : e, l = this._actionsByClip[a], c = null; + if (n === void 0 && (o !== null ? n = o.blendMode : n = ua), l !== void 0) { + let u = l.actionByRoot[r]; + if (u !== void 0 && u.blendMode === n) return u; + c = l.knownActions[0], o === null && (o = c._clip); + } + if (o === null) return null; + let h = new Zh(this, o, t, n); + return this._bindAction(h, c), this._addInactiveAction(h, a, r), h; + } + existingAction(e, t) { + let n = t || this._root, i = n.uuid, r = typeof e == "string" ? Lr.findByName(n, e) : e, o = r ? r.uuid : e, a = this._actionsByClip[o]; + return a !== void 0 && a.actionByRoot[i] || null; + } + stopAllAction() { + let e = this._actions, t = this._nActiveActions; + for(let n = t - 1; n >= 0; --n)e[n].stop(); + return this; + } + update(e) { + e *= this.timeScale; + let t = this._actions, n = this._nActiveActions, i = this.time += e, r = Math.sign(e), o = this._accuIndex ^= 1; + for(let c = 0; c !== n; ++c)t[c]._update(i, e, r, o); + let a = this._bindings, l = this._nActiveBindings; + for(let c = 0; c !== l; ++c)a[c].apply(o); + return this; + } + setTime(e) { + this.time = 0; + for(let t = 0; t < this._actions.length; t++)this._actions[t].time = 0; + return this.update(e); + } + getRoot() { + return this._root; + } + uncacheClip(e) { + let t = this._actions, n = e.uuid, i = this._actionsByClip, r = i[n]; + if (r !== void 0) { + let o = r.knownActions; + for(let a = 0, l = o.length; a !== l; ++a){ + let c = o[a]; + this._deactivateAction(c); + let h = c._cacheIndex, u = t[t.length - 1]; + c._cacheIndex = null, c._byClipCacheIndex = null, u._cacheIndex = h, t[h] = u, t.pop(), this._removeInactiveBindingsForAction(c); + } + delete i[n]; + } + } + uncacheRoot(e) { + let t = e.uuid, n = this._actionsByClip; + for(let o in n){ + let a = n[o].actionByRoot, l = a[t]; + l !== void 0 && (this._deactivateAction(l), this._removeInactiveAction(l)); + } + let i = this._bindingsByRootAndName, r = i[t]; + if (r !== void 0) for(let o in r){ + let a = r[o]; + a.restoreOriginalState(), this._removeInactiveBinding(a); + } + } + uncacheAction(e, t) { + let n = this.existingAction(e, t); + n !== null && (this._deactivateAction(n), this._removeInactiveAction(n)); + } +}; +$h.prototype._controlInterpolantsResultBuffer = new Float32Array(1); +var go = class { + constructor(e){ + typeof e == "string" && (console.warn("THREE.Uniform: Type parameter is no longer needed."), e = arguments[1]), this.value = e; + } + clone() { + return new go(this.value.clone === void 0 ? this.value : this.value.clone()); + } +}, jh = class extends $n { + constructor(e, t, n = 1){ + super(e, t); + this.meshPerAttribute = n; + } + copy(e) { + return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; + } + clone(e) { + let t = super.clone(e); + return t.meshPerAttribute = this.meshPerAttribute, t; + } + toJSON(e) { + let t = super.toJSON(e); + return t.isInstancedInterleavedBuffer = !0, t.meshPerAttribute = this.meshPerAttribute, t; + } +}; +jh.prototype.isInstancedInterleavedBuffer = !0; +var Qh = class { + constructor(e, t, n, i, r){ + this.buffer = e, this.type = t, this.itemSize = n, this.elementSize = i, this.count = r, this.version = 0; + } + set needsUpdate(e) { + e === !0 && this.version++; + } + setBuffer(e) { + return this.buffer = e, this; + } + setType(e, t) { + return this.type = e, this.elementSize = t, this; + } + setItemSize(e) { + return this.itemSize = e, this; + } + setCount(e) { + return this.count = e, this; + } +}; +Qh.prototype.isGLBufferAttribute = !0; +var Ey = class { + constructor(e, t, n = 0, i = 1 / 0){ + this.ray = new Cn(e, t), this.near = n, this.far = i, this.camera = null, this.layers = new Js, this.params = { + Mesh: {}, + Line: { + threshold: 1 + }, + LOD: {}, + Points: { + threshold: 1 + }, + Sprite: {} + }; + } + set(e, t) { + this.ray.set(e, t); + } + setFromCamera(e, t) { + t && t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, .5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t) : t && t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t) : console.error("THREE.Raycaster: Unsupported camera type: " + t.type); + } + intersectObject(e, t = !0, n = []) { + return la(e, this, n, t), n.sort(Pc), n; + } + intersectObjects(e, t = !0, n = []) { + for(let i = 0, r = e.length; i < r; i++)la(e[i], this, n, t); + return n.sort(Pc), n; + } +}; +function Pc(s, e) { + return s.distance - e.distance; +} +function la(s, e, t, n) { + if (s.layers.test(e.layers) && s.raycast(e, t), n === !0) { + let i = s.children; + for(let r = 0, o = i.length; r < o; r++)la(i[r], e, t, !0); + } +} +var Ay = class { + constructor(e = 1, t = 0, n = 0){ + return this.radius = e, this.phi = t, this.theta = n, this; + } + set(e, t, n) { + return this.radius = e, this.phi = t, this.theta = n, this; + } + copy(e) { + return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; + } + makeSafe() { + return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this; + } + setFromVector3(e) { + return this.setFromCartesianCoords(e.x, e.y, e.z); + } + setFromCartesianCoords(e, t, n) { + return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(mt(t / this.radius, -1, 1))), this; + } + clone() { + return new this.constructor().copy(this); + } +}, Cy = class { + constructor(e = 1, t = 0, n = 0){ + return this.radius = e, this.theta = t, this.y = n, this; + } + set(e, t, n) { + return this.radius = e, this.theta = t, this.y = n, this; + } + copy(e) { + return this.radius = e.radius, this.theta = e.theta, this.y = e.y, this; + } + setFromVector3(e) { + return this.setFromCartesianCoords(e.x, e.y, e.z); + } + setFromCartesianCoords(e, t, n) { + return this.radius = Math.sqrt(e * e + n * n), this.theta = Math.atan2(e, n), this.y = t, this; + } + clone() { + return new this.constructor().copy(this); + } +}, Ic = new X, qi = class { + constructor(e = new X(1 / 0, 1 / 0), t = new X(-1 / 0, -1 / 0)){ + this.min = e, this.max = t; + } + set(e, t) { + return this.min.copy(e), this.max.copy(t), this; + } + setFromPoints(e) { + this.makeEmpty(); + for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); + return this; + } + setFromCenterAndSize(e, t) { + let n = Ic.copy(t).multiplyScalar(.5); + return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; + } + clone() { + return new this.constructor().copy(this); + } + copy(e) { + return this.min.copy(e.min), this.max.copy(e.max), this; + } + makeEmpty() { + return this.min.x = this.min.y = 1 / 0, this.max.x = this.max.y = -1 / 0, this; + } + isEmpty() { + return this.max.x < this.min.x || this.max.y < this.min.y; + } + getCenter(e) { + return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); + } + getSize(e) { + return this.isEmpty() ? e.set(0, 0) : e.subVectors(this.max, this.min); + } + expandByPoint(e) { + return this.min.min(e), this.max.max(e), this; + } + expandByVector(e) { + return this.min.sub(e), this.max.add(e), this; + } + expandByScalar(e) { + return this.min.addScalar(-e), this.max.addScalar(e), this; + } + containsPoint(e) { + return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y); + } + containsBox(e) { + return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y; + } + getParameter(e, t) { + return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y)); + } + intersectsBox(e) { + return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y); + } + clampPoint(e, t) { + return t.copy(e).clamp(this.min, this.max); + } + distanceToPoint(e) { + return Ic.copy(e).clamp(this.min, this.max).sub(e).length(); + } + intersect(e) { + return this.min.max(e.min), this.max.min(e.max), this; + } + union(e) { + return this.min.min(e.min), this.max.max(e.max), this; + } + translate(e) { + return this.min.add(e), this.max.add(e), this; + } + equals(e) { + return e.min.equals(this.min) && e.max.equals(this.max); + } +}; +qi.prototype.isBox2 = !0; +var Dc = new M, Ts = new M, Kh = class { + constructor(e = new M, t = new M){ + this.start = e, this.end = t; + } + set(e, t) { + return this.start.copy(e), this.end.copy(t), this; + } + copy(e) { + return this.start.copy(e.start), this.end.copy(e.end), this; + } + getCenter(e) { + return e.addVectors(this.start, this.end).multiplyScalar(.5); + } + delta(e) { + return e.subVectors(this.end, this.start); + } + distanceSq() { + return this.start.distanceToSquared(this.end); + } + distance() { + return this.start.distanceTo(this.end); + } + at(e, t) { + return this.delta(t).multiplyScalar(e).add(this.start); + } + closestPointToPointParameter(e, t) { + Dc.subVectors(e, this.start), Ts.subVectors(this.end, this.start); + let n = Ts.dot(Ts), r = Ts.dot(Dc) / n; + return t && (r = mt(r, 0, 1)), r; + } + closestPointToPoint(e, t, n) { + let i = this.closestPointToPointParameter(e, t); + return this.delta(n).multiplyScalar(i).add(this.start); + } + applyMatrix4(e) { + return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this; + } + equals(e) { + return e.start.equals(this.start) && e.end.equals(this.end); + } + clone() { + return new this.constructor().copy(this); + } +}, Fc = new M, Ly = class extends Ne { + constructor(e, t){ + super(); + this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = t; + let n = new _e, i = [ + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + -1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + -1, + 1 + ]; + for(let o = 0, a = 1, l = 32; o < l; o++, a++){ + let c = o / l * Math.PI * 2, h = a / l * Math.PI * 2; + i.push(Math.cos(c), Math.sin(c), 1, Math.cos(h), Math.sin(h), 1); + } + n.setAttribute("position", new de(i, 3)); + let r = new ft({ + fog: !1, + toneMapped: !1 + }); + this.cone = new wt(n, r), this.add(this.cone), this.update(); + } + dispose() { + this.cone.geometry.dispose(), this.cone.material.dispose(); + } + update() { + this.light.updateMatrixWorld(); + let e = this.light.distance ? this.light.distance : 1e3, t = e * Math.tan(this.light.angle); + this.cone.scale.set(t, t, e), Fc.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(Fc), this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color); + } +}, yn = new M, Es = new pe, Qo = new pe, eu = class extends wt { + constructor(e){ + let t = tu(e), n = new _e, i = [], r = [], o = new ae(0, 0, 1), a = new ae(0, 1, 0); + for(let c = 0; c < t.length; c++){ + let h = t[c]; + h.parent && h.parent.isBone && (i.push(0, 0, 0), i.push(0, 0, 0), r.push(o.r, o.g, o.b), r.push(a.r, a.g, a.b)); + } + n.setAttribute("position", new de(i, 3)), n.setAttribute("color", new de(r, 3)); + let l = new ft({ + vertexColors: !0, + depthTest: !1, + depthWrite: !1, + toneMapped: !1, + transparent: !0 + }); + super(n, l); + this.type = "SkeletonHelper", this.isSkeletonHelper = !0, this.root = e, this.bones = t, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1; + } + updateMatrixWorld(e) { + let t = this.bones, n = this.geometry, i = n.getAttribute("position"); + Qo.copy(this.root.matrixWorld).invert(); + for(let r = 0, o = 0; r < t.length; r++){ + let a = t[r]; + a.parent && a.parent.isBone && (Es.multiplyMatrices(Qo, a.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o, yn.x, yn.y, yn.z), Es.multiplyMatrices(Qo, a.parent.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o + 1, yn.x, yn.y, yn.z), o += 2); + } + n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(e); + } +}; +function tu(s) { + let e = []; + s && s.isBone && e.push(s); + for(let t = 0; t < s.children.length; t++)e.push.apply(e, tu(s.children[t])); + return e; +} +var Ry = class extends st { + constructor(e, t, n){ + let i = new Fi(t, 4, 2), r = new hn({ + wireframe: !0, + fog: !1, + toneMapped: !1 + }); + super(i, r); + this.light = e, this.light.updateMatrixWorld(), this.color = n, this.type = "PointLightHelper", this.matrix = this.light.matrixWorld, this.matrixAutoUpdate = !1, this.update(); + } + dispose() { + this.geometry.dispose(), this.material.dispose(); + } + update() { + this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color); + } +}, Py = new M, Nc = new ae, Bc = new ae, Iy = class extends Ne { + constructor(e, t, n){ + super(); + this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n; + let i = new Ii(t); + i.rotateY(Math.PI * .5), this.material = new hn({ + wireframe: !0, + fog: !1, + toneMapped: !1 + }), this.color === void 0 && (this.material.vertexColors = !0); + let r = i.getAttribute("position"), o = new Float32Array(r.count * 3); + i.setAttribute("color", new Ue(o, 3)), this.add(new st(i, this.material)), this.update(); + } + dispose() { + this.children[0].geometry.dispose(), this.children[0].material.dispose(); + } + update() { + let e = this.children[0]; + if (this.color !== void 0) this.material.color.set(this.color); + else { + let t = e.geometry.getAttribute("color"); + Nc.copy(this.light.color), Bc.copy(this.light.groundColor); + for(let n = 0, i = t.count; n < i; n++){ + let r = n < i / 2 ? Nc : Bc; + t.setXYZ(n, r.r, r.g, r.b); + } + t.needsUpdate = !0; + } + e.lookAt(Py.setFromMatrixPosition(this.light.matrixWorld).negate()); + } +}, nu = class extends wt { + constructor(e = 10, t = 10, n = 4473924, i = 8947848){ + n = new ae(n), i = new ae(i); + let r = t / 2, o = e / t, a = e / 2, l = [], c = []; + for(let d = 0, f = 0, m = -a; d <= t; d++, m += o){ + l.push(-a, 0, m, a, 0, m), l.push(m, 0, -a, m, 0, a); + let x = d === r ? n : i; + x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3; + } + let h = new _e; + h.setAttribute("position", new de(l, 3)), h.setAttribute("color", new de(c, 3)); + let u = new ft({ + vertexColors: !0, + toneMapped: !1 + }); + super(h, u); + this.type = "GridHelper"; + } +}, Dy = class extends wt { + constructor(e = 10, t = 16, n = 8, i = 64, r = 4473924, o = 8947848){ + r = new ae(r), o = new ae(o); + let a = [], l = []; + for(let u = 0; u <= t; u++){ + let d = u / t * (Math.PI * 2), f = Math.sin(d) * e, m = Math.cos(d) * e; + a.push(0, 0, 0), a.push(f, 0, m); + let x = u & 1 ? r : o; + l.push(x.r, x.g, x.b), l.push(x.r, x.g, x.b); + } + for(let u = 0; u <= n; u++){ + let d = u & 1 ? r : o, f = e - e / n * u; + for(let m = 0; m < i; m++){ + let x = m / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f; + a.push(v, 0, g), l.push(d.r, d.g, d.b), x = (m + 1) / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f, a.push(v, 0, g), l.push(d.r, d.g, d.b); + } + } + let c = new _e; + c.setAttribute("position", new de(a, 3)), c.setAttribute("color", new de(l, 3)); + let h = new ft({ + vertexColors: !0, + toneMapped: !1 + }); + super(c, h); + this.type = "PolarGridHelper"; + } +}, zc = new M, As = new M, Uc = new M, Fy = class extends Ne { + constructor(e, t, n){ + super(); + this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, t === void 0 && (t = 1); + let i = new _e; + i.setAttribute("position", new de([ + -t, + t, + 0, + t, + t, + 0, + t, + -t, + 0, + -t, + -t, + 0, + -t, + t, + 0 + ], 3)); + let r = new ft({ + fog: !1, + toneMapped: !1 + }); + this.lightPlane = new on(i, r), this.add(this.lightPlane), i = new _e, i.setAttribute("position", new de([ + 0, + 0, + 0, + 0, + 0, + 1 + ], 3)), this.targetLine = new on(i, r), this.add(this.targetLine), this.update(); + } + dispose() { + this.lightPlane.geometry.dispose(), this.lightPlane.material.dispose(), this.targetLine.geometry.dispose(), this.targetLine.material.dispose(); + } + update() { + zc.setFromMatrixPosition(this.light.matrixWorld), As.setFromMatrixPosition(this.light.target.matrixWorld), Uc.subVectors(As, zc), this.lightPlane.lookAt(As), this.color !== void 0 ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)) : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)), this.targetLine.lookAt(As), this.targetLine.scale.z = Uc.length(); + } +}, Cs = new M, Qe = new Ir, Ny = class extends wt { + constructor(e){ + let t = new _e, n = new ft({ + color: 16777215, + vertexColors: !0, + toneMapped: !1 + }), i = [], r = [], o = {}, a = new ae(16755200), l = new ae(16711680), c = new ae(43775), h = new ae(16777215), u = new ae(3355443); + d("n1", "n2", a), d("n2", "n4", a), d("n4", "n3", a), d("n3", "n1", a), d("f1", "f2", a), d("f2", "f4", a), d("f4", "f3", a), d("f3", "f1", a), d("n1", "f1", a), d("n2", "f2", a), d("n3", "f3", a), d("n4", "f4", a), d("p", "n1", l), d("p", "n2", l), d("p", "n3", l), d("p", "n4", l), d("u1", "u2", c), d("u2", "u3", c), d("u3", "u1", c), d("c", "t", h), d("p", "c", u), d("cn1", "cn2", u), d("cn3", "cn4", u), d("cf1", "cf2", u), d("cf3", "cf4", u); + function d(m, x, v) { + f(m, v), f(x, v); + } + function f(m, x) { + i.push(0, 0, 0), r.push(x.r, x.g, x.b), o[m] === void 0 && (o[m] = []), o[m].push(i.length / 3 - 1); + } + t.setAttribute("position", new de(i, 3)), t.setAttribute("color", new de(r, 3)); + super(t, n); + this.type = "CameraHelper", this.camera = e, this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.pointMap = o, this.update(); + } + update() { + let e = this.geometry, t = this.pointMap, n = 1, i = 1; + Qe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), et("c", t, e, Qe, 0, 0, -1), et("t", t, e, Qe, 0, 0, 1), et("n1", t, e, Qe, -n, -i, -1), et("n2", t, e, Qe, n, -i, -1), et("n3", t, e, Qe, -n, i, -1), et("n4", t, e, Qe, n, i, -1), et("f1", t, e, Qe, -n, -i, 1), et("f2", t, e, Qe, n, -i, 1), et("f3", t, e, Qe, -n, i, 1), et("f4", t, e, Qe, n, i, 1), et("u1", t, e, Qe, n * .7, i * 1.1, -1), et("u2", t, e, Qe, -n * .7, i * 1.1, -1), et("u3", t, e, Qe, 0, i * 2, -1), et("cf1", t, e, Qe, -n, 0, 1), et("cf2", t, e, Qe, n, 0, 1), et("cf3", t, e, Qe, 0, -i, 1), et("cf4", t, e, Qe, 0, i, 1), et("cn1", t, e, Qe, -n, 0, -1), et("cn2", t, e, Qe, n, 0, -1), et("cn3", t, e, Qe, 0, -i, -1), et("cn4", t, e, Qe, 0, i, -1), e.getAttribute("position").needsUpdate = !0; + } + dispose() { + this.geometry.dispose(), this.material.dispose(); + } +}; +function et(s, e, t, n, i, r, o) { + Cs.set(i, r, o).unproject(n); + let a = e[s]; + if (a !== void 0) { + let l = t.getAttribute("position"); + for(let c = 0, h = a.length; c < h; c++)l.setXYZ(a[c], Cs.x, Cs.y, Cs.z); + } +} +var Ls = new Lt, iu = class extends wt { + constructor(e, t = 16776960){ + let n = new Uint16Array([ + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 0, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 4, + 0, + 4, + 1, + 5, + 2, + 6, + 3, + 7 + ]), i = new Float32Array(8 * 3), r = new _e; + r.setIndex(new Ue(n, 1)), r.setAttribute("position", new Ue(i, 3)); + super(r, new ft({ + color: t, + toneMapped: !1 + })); + this.object = e, this.type = "BoxHelper", this.matrixAutoUpdate = !1, this.update(); + } + update(e) { + if (e !== void 0 && console.warn("THREE.BoxHelper: .update() has no longer arguments."), this.object !== void 0 && Ls.setFromObject(this.object), Ls.isEmpty()) return; + let t = Ls.min, n = Ls.max, i = this.geometry.attributes.position, r = i.array; + r[0] = n.x, r[1] = n.y, r[2] = n.z, r[3] = t.x, r[4] = n.y, r[5] = n.z, r[6] = t.x, r[7] = t.y, r[8] = n.z, r[9] = n.x, r[10] = t.y, r[11] = n.z, r[12] = n.x, r[13] = n.y, r[14] = t.z, r[15] = t.x, r[16] = n.y, r[17] = t.z, r[18] = t.x, r[19] = t.y, r[20] = t.z, r[21] = n.x, r[22] = t.y, r[23] = t.z, i.needsUpdate = !0, this.geometry.computeBoundingSphere(); + } + setFromObject(e) { + return this.object = e, this.update(), this; + } + copy(e) { + return wt.prototype.copy.call(this, e), this.object = e.object, this; + } +}, By = class extends wt { + constructor(e, t = 16776960){ + let n = new Uint16Array([ + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 0, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 4, + 0, + 4, + 1, + 5, + 2, + 6, + 3, + 7 + ]), i = [ + 1, + 1, + 1, + -1, + 1, + 1, + -1, + -1, + 1, + 1, + -1, + 1, + 1, + 1, + -1, + -1, + 1, + -1, + -1, + -1, + -1, + 1, + -1, + -1 + ], r = new _e; + r.setIndex(new Ue(n, 1)), r.setAttribute("position", new de(i, 3)); + super(r, new ft({ + color: t, + toneMapped: !1 + })); + this.box = e, this.type = "Box3Helper", this.geometry.computeBoundingSphere(); + } + updateMatrixWorld(e) { + let t = this.box; + t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(.5), super.updateMatrixWorld(e)); + } +}, zy = class extends on { + constructor(e, t = 1, n = 16776960){ + let i = n, r = [ + 1, + -1, + 1, + -1, + 1, + 1, + -1, + -1, + 1, + 1, + 1, + 1, + -1, + 1, + 1, + -1, + -1, + 1, + 1, + -1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 0 + ], o = new _e; + o.setAttribute("position", new de(r, 3)), o.computeBoundingSphere(); + super(o, new ft({ + color: i, + toneMapped: !1 + })); + this.type = "PlaneHelper", this.plane = e, this.size = t; + let a = [ + 1, + 1, + 1, + -1, + 1, + 1, + -1, + -1, + 1, + 1, + 1, + 1, + -1, + -1, + 1, + 1, + -1, + 1 + ], l = new _e; + l.setAttribute("position", new de(a, 3)), l.computeBoundingSphere(), this.add(new st(l, new hn({ + color: i, + opacity: .2, + transparent: !0, + depthWrite: !1, + toneMapped: !1 + }))); + } + updateMatrixWorld(e) { + let t = -this.plane.constant; + Math.abs(t) < 1e-8 && (t = 1e-8), this.scale.set(.5 * this.size, .5 * this.size, t), this.children[0].material.side = t < 0 ? it : Ai, this.lookAt(this.plane.normal), super.updateMatrixWorld(e); + } +}, Oc = new M, Rs, Ko, Uy = class extends Ne { + constructor(e = new M(0, 0, 1), t = new M(0, 0, 0), n = 1, i = 16776960, r = n * .2, o = r * .2){ + super(); + this.type = "ArrowHelper", Rs === void 0 && (Rs = new _e, Rs.setAttribute("position", new de([ + 0, + 0, + 0, + 0, + 1, + 0 + ], 3)), Ko = new Jn(0, .5, 1, 5, 1), Ko.translate(0, -.5, 0)), this.position.copy(t), this.line = new on(Rs, new ft({ + color: i, + toneMapped: !1 + })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new st(Ko, new hn({ + color: i, + toneMapped: !1 + })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(e), this.setLength(n, r, o); + } + setDirection(e) { + if (e.y > .99999) this.quaternion.set(0, 0, 0, 1); + else if (e.y < -.99999) this.quaternion.set(1, 0, 0, 0); + else { + Oc.set(e.z, 0, -e.x).normalize(); + let t = Math.acos(e.y); + this.quaternion.setFromAxisAngle(Oc, t); + } + } + setLength(e, t = e * .2, n = t * .2) { + this.line.scale.set(1, Math.max(1e-4, e - t), 1), this.line.updateMatrix(), this.cone.scale.set(n, t, n), this.cone.position.y = e, this.cone.updateMatrix(); + } + setColor(e) { + this.line.material.color.set(e), this.cone.material.color.set(e); + } + copy(e) { + return super.copy(e, !1), this.line.copy(e.line), this.cone.copy(e.cone), this; + } +}, ru = class extends wt { + constructor(e = 1){ + let t = [ + 0, + 0, + 0, + e, + 0, + 0, + 0, + 0, + 0, + 0, + e, + 0, + 0, + 0, + 0, + 0, + 0, + e + ], n = [ + 1, + 0, + 0, + 1, + .6, + 0, + 0, + 1, + 0, + .6, + 1, + 0, + 0, + 0, + 1, + 0, + .6, + 1 + ], i = new _e; + i.setAttribute("position", new de(t, 3)), i.setAttribute("color", new de(n, 3)); + let r = new ft({ + vertexColors: !0, + toneMapped: !1 + }); + super(i, r); + this.type = "AxesHelper"; + } + setColors(e, t, n) { + let i = new ae, r = this.geometry.attributes.color.array; + return i.set(e), i.toArray(r, 0), i.toArray(r, 3), i.set(t), i.toArray(r, 6), i.toArray(r, 9), i.set(n), i.toArray(r, 12), i.toArray(r, 15), this.geometry.attributes.color.needsUpdate = !0, this; + } + dispose() { + this.geometry.dispose(), this.material.dispose(); + } +}, Oy = class { + constructor(){ + this.type = "ShapePath", this.color = new ae, this.subPaths = [], this.currentPath = null; + } + moveTo(e, t) { + return this.currentPath = new gr, this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this; + } + lineTo(e, t) { + return this.currentPath.lineTo(e, t), this; + } + quadraticCurveTo(e, t, n, i) { + return this.currentPath.quadraticCurveTo(e, t, n, i), this; + } + bezierCurveTo(e, t, n, i, r, o) { + return this.currentPath.bezierCurveTo(e, t, n, i, r, o), this; + } + splineThru(e) { + return this.currentPath.splineThru(e), this; + } + toShapes(e, t) { + function n(p) { + let _ = []; + for(let y = 0, b = p.length; y < b; y++){ + let A = p[y], L = new Xt; + L.curves = A.curves, _.push(L); + } + return _; + } + function i(p, _) { + let y = _.length, b = !1; + for(let A = y - 1, L = 0; L < y; A = L++){ + let I = _[A], k = _[L], B = k.x - I.x, P = k.y - I.y; + if (Math.abs(P) > Number.EPSILON) { + if (P < 0 && (I = _[L], B = -B, k = _[A], P = -P), p.y < I.y || p.y > k.y) continue; + if (p.y === I.y) { + if (p.x === I.x) return !0; + } else { + let w = P * (p.x - I.x) - B * (p.y - I.y); + if (w === 0) return !0; + if (w < 0) continue; + b = !b; + } + } else { + if (p.y !== I.y) continue; + if (k.x <= p.x && p.x <= I.x || I.x <= p.x && p.x <= k.x) return !0; + } + } + return b; + } + let r = Jt.isClockWise, o = this.subPaths; + if (o.length === 0) return []; + if (t === !0) return n(o); + let a, l, c, h = []; + if (o.length === 1) return l = o[0], c = new Xt, c.curves = l.curves, h.push(c), h; + let u = !r(o[0].getPoints()); + u = e ? !u : u; + let d = [], f = [], m = [], x = 0, v; + f[x] = void 0, m[x] = []; + for(let p = 0, _ = o.length; p < _; p++)l = o[p], v = l.getPoints(), a = r(v), a = e ? !a : a, a ? (!u && f[x] && x++, f[x] = { + s: new Xt, + p: v + }, f[x].s.curves = l.curves, u && x++, m[x] = []) : m[x].push({ + h: l, + p: v[0] + }); + if (!f[0]) return n(o); + if (f.length > 1) { + let p = !1, _ = []; + for(let y = 0, b = f.length; y < b; y++)d[y] = []; + for(let y = 0, b = f.length; y < b; y++){ + let A = m[y]; + for(let L = 0; L < A.length; L++){ + let I = A[L], k = !0; + for(let B = 0; B < f.length; B++)i(I.p, f[B].p) && (y !== B && _.push({ + froms: y, + tos: B, + hole: L + }), k ? (k = !1, d[B].push(I)) : p = !0); + k && d[y].push(I); + } + } + _.length > 0 && (p || (m = d)); + } + let g; + for(let p = 0, _ = f.length; p < _; p++){ + c = f[p].s, h.push(c), g = m[p]; + for(let y = 0, b = g.length; y < b; y++)c.holes.push(g[y].h); + } + return h; + } +}, su = new Float32Array(1), Hy = new Int32Array(su.buffer), ky = class { + static toHalfFloat(e) { + e > 65504 && (console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."), e = 65504), su[0] = e; + let t = Hy[0], n = t >> 16 & 32768, i = t >> 12 & 2047, r = t >> 23 & 255; + return r < 103 ? n : r > 142 ? (n |= 31744, n |= (r == 255 ? 0 : 1) && t & 8388607, n) : r < 113 ? (i |= 2048, n |= (i >> 114 - r) + (i >> 113 - r & 1), n) : (n |= r - 112 << 10 | i >> 1, n += i & 1, n); + } +}, b0 = 0, w0 = 1, S0 = 0, T0 = 1, E0 = 2; +function A0(s) { + return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."), s; +} +function C0(s = []) { + return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."), s.isMultiMaterial = !0, s.materials = s, s.clone = function() { + return s.slice(); + }, s; +} +function L0(s, e) { + return console.warn("THREE.PointCloud has been renamed to THREE.Points."), new zr(s, e); +} +function R0(s) { + return console.warn("THREE.Particle has been renamed to THREE.Sprite."), new ro(s); +} +function P0(s, e) { + return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."), new zr(s, e); +} +function I0(s) { + return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."), new jn(s); +} +function D0(s) { + return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."), new jn(s); +} +function F0(s) { + return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."), new jn(s); +} +function N0(s, e, t) { + return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."), new M(s, e, t); +} +function B0(s, e) { + return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."), new Ue(s, e).setUsage(ur); +} +function z0(s, e) { + return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."), new jc(s, e); +} +function U0(s, e) { + return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."), new Qc(s, e); +} +function O0(s, e) { + return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."), new Kc(s, e); +} +function H0(s, e) { + return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."), new eh(s, e); +} +function k0(s, e) { + return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."), new Ys(s, e); +} +function G0(s, e) { + return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."), new th(s, e); +} +function V0(s, e) { + return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."), new Zs(s, e); +} +function W0(s, e) { + return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."), new de(s, e); +} +function q0(s, e) { + return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."), new ih(s, e); +} +Ct.create = function(s, e) { + return console.log("THREE.Curve.create() has been deprecated"), s.prototype = Object.create(Ct.prototype), s.prototype.constructor = s, s.prototype.getPoint = e, s; +}; +gr.prototype.fromPoints = function(s) { + return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."), this.setFromPoints(s); +}; +function X0(s) { + return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."), new ru(s); +} +function J0(s, e) { + return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."), new iu(s, e); +} +function Y0(s, e) { + return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."), new wt(new _a(s.geometry), new ft({ + color: e !== void 0 ? e : 16777215 + })); +} +nu.prototype.setColors = function() { + console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead."); +}; +eu.prototype.update = function() { + console.error("THREE.SkeletonHelper: update() no longer needs to be called."); +}; +function Z0(s, e) { + return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."), new wt(new Ea(s.geometry), new ft({ + color: e !== void 0 ? e : 16777215 + })); +} +bt.prototype.extractUrlBase = function(s) { + return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."), Gs.extractUrlBase(s); +}; +bt.Handlers = { + add: function() { + console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead."); + }, + get: function() { + console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead."); + } +}; +function $0(s) { + return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."), new Yt(s); +} +function j0(s) { + return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."), new Nh(s); +} +qi.prototype.center = function(s) { + return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."), this.getCenter(s); +}; +qi.prototype.empty = function() { + return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."), this.isEmpty(); +}; +qi.prototype.isIntersectionBox = function(s) { + return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); +}; +qi.prototype.size = function(s) { + return console.warn("THREE.Box2: .size() has been renamed to .getSize()."), this.getSize(s); +}; +Lt.prototype.center = function(s) { + return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."), this.getCenter(s); +}; +Lt.prototype.empty = function() { + return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."), this.isEmpty(); +}; +Lt.prototype.isIntersectionBox = function(s) { + return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); +}; +Lt.prototype.isIntersectionSphere = function(s) { + return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); +}; +Lt.prototype.size = function(s) { + return console.warn("THREE.Box3: .size() has been renamed to .getSize()."), this.getSize(s); +}; +An.prototype.empty = function() { + return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."), this.isEmpty(); +}; +Dr.prototype.setFromMatrix = function(s) { + return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."), this.setFromProjectionMatrix(s); +}; +Kh.prototype.center = function(s) { + return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."), this.getCenter(s); +}; +lt.prototype.flattenToArrayOffset = function(s, e) { + return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); +}; +lt.prototype.multiplyVector3 = function(s) { + return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); +}; +lt.prototype.multiplyVector3Array = function() { + console.error("THREE.Matrix3: .multiplyVector3Array() has been removed."); +}; +lt.prototype.applyToBufferAttribute = function(s) { + return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); +}; +lt.prototype.applyToVector3Array = function() { + console.error("THREE.Matrix3: .applyToVector3Array() has been removed."); +}; +lt.prototype.getInverse = function(s) { + return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); +}; +pe.prototype.extractPosition = function(s) { + return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."), this.copyPosition(s); +}; +pe.prototype.flattenToArrayOffset = function(s, e) { + return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); +}; +pe.prototype.getPosition = function() { + return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."), new M().setFromMatrixColumn(this, 3); +}; +pe.prototype.setRotationFromQuaternion = function(s) { + return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."), this.makeRotationFromQuaternion(s); +}; +pe.prototype.multiplyToArray = function() { + console.warn("THREE.Matrix4: .multiplyToArray() has been removed."); +}; +pe.prototype.multiplyVector3 = function(s) { + return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); +}; +pe.prototype.multiplyVector4 = function(s) { + return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); +}; +pe.prototype.multiplyVector3Array = function() { + console.error("THREE.Matrix4: .multiplyVector3Array() has been removed."); +}; +pe.prototype.rotateAxis = function(s) { + console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."), s.transformDirection(this); +}; +pe.prototype.crossVector = function(s) { + return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); +}; +pe.prototype.translate = function() { + console.error("THREE.Matrix4: .translate() has been removed."); +}; +pe.prototype.rotateX = function() { + console.error("THREE.Matrix4: .rotateX() has been removed."); +}; +pe.prototype.rotateY = function() { + console.error("THREE.Matrix4: .rotateY() has been removed."); +}; +pe.prototype.rotateZ = function() { + console.error("THREE.Matrix4: .rotateZ() has been removed."); +}; +pe.prototype.rotateByAxis = function() { + console.error("THREE.Matrix4: .rotateByAxis() has been removed."); +}; +pe.prototype.applyToBufferAttribute = function(s) { + return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); +}; +pe.prototype.applyToVector3Array = function() { + console.error("THREE.Matrix4: .applyToVector3Array() has been removed."); +}; +pe.prototype.makeFrustum = function(s, e, t, n, i, r) { + return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."), this.makePerspective(s, e, n, t, i, r); +}; +pe.prototype.getInverse = function(s) { + return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); +}; +Wt.prototype.isIntersectionLine = function(s) { + return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."), this.intersectsLine(s); +}; +gt.prototype.multiplyVector3 = function(s) { + return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."), s.applyQuaternion(this); +}; +gt.prototype.inverse = function() { + return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."), this.invert(); +}; +Cn.prototype.isIntersectionBox = function(s) { + return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); +}; +Cn.prototype.isIntersectionPlane = function(s) { + return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."), this.intersectsPlane(s); +}; +Cn.prototype.isIntersectionSphere = function(s) { + return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); +}; +nt.prototype.area = function() { + return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."), this.getArea(); +}; +nt.prototype.barycoordFromPoint = function(s, e) { + return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), this.getBarycoord(s, e); +}; +nt.prototype.midpoint = function(s) { + return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."), this.getMidpoint(s); +}; +nt.prototypenormal = function(s) { + return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), this.getNormal(s); +}; +nt.prototype.plane = function(s) { + return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."), this.getPlane(s); +}; +nt.barycoordFromPoint = function(s, e, t, n, i) { + return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), nt.getBarycoord(s, e, t, n, i); +}; +nt.normal = function(s, e, t, n) { + return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), nt.getNormal(s, e, t, n); +}; +Xt.prototype.extractAllPoints = function(s) { + return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."), this.extractPoints(s); +}; +Xt.prototype.extrude = function(s) { + return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."), new ln(this, s); +}; +Xt.prototype.makeGeometry = function(s) { + return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."), new Di(this, s); +}; +X.prototype.fromAttribute = function(s, e, t) { + return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); +}; +X.prototype.distanceToManhattan = function(s) { + return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); +}; +X.prototype.lengthManhattan = function() { + return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); +}; +M.prototype.setEulerFromRotationMatrix = function() { + console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead."); +}; +M.prototype.setEulerFromQuaternion = function() { + console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead."); +}; +M.prototype.getPositionFromMatrix = function(s) { + return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."), this.setFromMatrixPosition(s); +}; +M.prototype.getScaleFromMatrix = function(s) { + return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."), this.setFromMatrixScale(s); +}; +M.prototype.getColumnFromMatrix = function(s, e) { + return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."), this.setFromMatrixColumn(e, s); +}; +M.prototype.applyProjection = function(s) { + return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."), this.applyMatrix4(s); +}; +M.prototype.fromAttribute = function(s, e, t) { + return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); +}; +M.prototype.distanceToManhattan = function(s) { + return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); +}; +M.prototype.lengthManhattan = function() { + return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); +}; +Ve.prototype.fromAttribute = function(s, e, t) { + return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); +}; +Ve.prototype.lengthManhattan = function() { + return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); +}; +Ne.prototype.getChildByName = function(s) { + return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."), this.getObjectByName(s); +}; +Ne.prototype.renderDepth = function() { + console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead."); +}; +Ne.prototype.translate = function(s, e) { + return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."), this.translateOnAxis(e, s); +}; +Ne.prototype.getWorldRotation = function() { + console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead."); +}; +Ne.prototype.applyMatrix = function(s) { + return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); +}; +Object.defineProperties(Ne.prototype, { + eulerOrder: { + get: function() { + return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order; + }, + set: function(s) { + console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order = s; + } + }, + useQuaternion: { + get: function() { + console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); + }, + set: function() { + console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); + } + } +}); +st.prototype.setDrawMode = function() { + console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); +}; +Object.defineProperties(st.prototype, { + drawMode: { + get: function() { + return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."), Fd; + }, + set: function() { + console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); + } + } +}); +so.prototype.initBones = function() { + console.error("THREE.SkinnedMesh: initBones() has been removed."); +}; +ut.prototype.setLens = function(s, e) { + console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."), e !== void 0 && (this.filmGauge = e), this.setFocalLength(s); +}; +Object.defineProperties(Bt.prototype, { + onlyShadow: { + set: function() { + console.warn("THREE.Light: .onlyShadow has been removed."); + } + }, + shadowCameraFov: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."), this.shadow.camera.fov = s; + } + }, + shadowCameraLeft: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."), this.shadow.camera.left = s; + } + }, + shadowCameraRight: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."), this.shadow.camera.right = s; + } + }, + shadowCameraTop: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."), this.shadow.camera.top = s; + } + }, + shadowCameraBottom: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."), this.shadow.camera.bottom = s; + } + }, + shadowCameraNear: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."), this.shadow.camera.near = s; + } + }, + shadowCameraFar: { + set: function(s) { + console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."), this.shadow.camera.far = s; + } + }, + shadowCameraVisible: { + set: function() { + console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead."); + } + }, + shadowBias: { + set: function(s) { + console.warn("THREE.Light: .shadowBias is now .shadow.bias."), this.shadow.bias = s; + } + }, + shadowDarkness: { + set: function() { + console.warn("THREE.Light: .shadowDarkness has been removed."); + } + }, + shadowMapWidth: { + set: function(s) { + console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."), this.shadow.mapSize.width = s; + } + }, + shadowMapHeight: { + set: function(s) { + console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."), this.shadow.mapSize.height = s; + } + } +}); +Object.defineProperties(Ue.prototype, { + length: { + get: function() { + return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."), this.array.length; + } + }, + dynamic: { + get: function() { + return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.usage === ur; + }, + set: function() { + console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.setUsage(ur); + } + } +}); +Ue.prototype.setDynamic = function(s) { + return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; +}; +Ue.prototype.copyIndicesArray = function() { + console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed."); +}, Ue.prototype.setArray = function() { + console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); +}; +_e.prototype.addIndex = function(s) { + console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."), this.setIndex(s); +}; +_e.prototype.addAttribute = function(s, e) { + return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."), !(e && e.isBufferAttribute) && !(e && e.isInterleavedBufferAttribute) ? (console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."), this.setAttribute(s, new Ue(arguments[1], arguments[2]))) : s === "index" ? (console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."), this.setIndex(e), this) : this.setAttribute(s, e); +}; +_e.prototype.addDrawCall = function(s, e, t) { + t !== void 0 && console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."), console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."), this.addGroup(s, e); +}; +_e.prototype.clearDrawCalls = function() { + console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."), this.clearGroups(); +}; +_e.prototype.computeOffsets = function() { + console.warn("THREE.BufferGeometry: .computeOffsets() has been removed."); +}; +_e.prototype.removeAttribute = function(s) { + return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."), this.deleteAttribute(s); +}; +_e.prototype.applyMatrix = function(s) { + return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); +}; +Object.defineProperties(_e.prototype, { + drawcalls: { + get: function() { + return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."), this.groups; + } + }, + offsets: { + get: function() { + return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."), this.groups; + } + } +}); +$n.prototype.setDynamic = function(s) { + return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; +}; +$n.prototype.setArray = function() { + console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); +}; +ln.prototype.getArrays = function() { + console.error("THREE.ExtrudeGeometry: .getArrays() has been removed."); +}; +ln.prototype.addShapeList = function() { + console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed."); +}; +ln.prototype.addShape = function() { + console.error("THREE.ExtrudeGeometry: .addShape() has been removed."); +}; +no.prototype.dispose = function() { + console.error("THREE.Scene: .dispose() has been removed."); +}; +go.prototype.onUpdate = function() { + return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."), this; +}; +Object.defineProperties(dt.prototype, { + wrapAround: { + get: function() { + console.warn("THREE.Material: .wrapAround has been removed."); + }, + set: function() { + console.warn("THREE.Material: .wrapAround has been removed."); + } + }, + overdraw: { + get: function() { + console.warn("THREE.Material: .overdraw has been removed."); + }, + set: function() { + console.warn("THREE.Material: .overdraw has been removed."); + } + }, + wrapRGB: { + get: function() { + return console.warn("THREE.Material: .wrapRGB has been removed."), new ae; + } + }, + shading: { + get: function() { + console.error("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."); + }, + set: function(s) { + console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = s === kc; + } + }, + stencilMask: { + get: function() { + return console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask; + }, + set: function(s) { + console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask = s; + } + }, + vertexTangents: { + get: function() { + console.warn("THREE." + this.type + ": .vertexTangents has been removed."); + }, + set: function() { + console.warn("THREE." + this.type + ": .vertexTangents has been removed."); + } + } +}); +Object.defineProperties(sn.prototype, { + derivatives: { + get: function() { + return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives; + }, + set: function(s) { + console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives = s; + } + } +}); +qe.prototype.clearTarget = function(s, e, t, n) { + console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."), this.setRenderTarget(s), this.clear(e, t, n); +}; +qe.prototype.animate = function(s) { + console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."), this.setAnimationLoop(s); +}; +qe.prototype.getCurrentRenderTarget = function() { + return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."), this.getRenderTarget(); +}; +qe.prototype.getMaxAnisotropy = function() { + return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."), this.capabilities.getMaxAnisotropy(); +}; +qe.prototype.getPrecision = function() { + return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."), this.capabilities.precision; +}; +qe.prototype.resetGLState = function() { + return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."), this.state.reset(); +}; +qe.prototype.supportsFloatTextures = function() { + return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."), this.extensions.get("OES_texture_float"); +}; +qe.prototype.supportsHalfFloatTextures = function() { + return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."), this.extensions.get("OES_texture_half_float"); +}; +qe.prototype.supportsStandardDerivatives = function() { + return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."), this.extensions.get("OES_standard_derivatives"); +}; +qe.prototype.supportsCompressedTextureS3TC = function() { + return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."), this.extensions.get("WEBGL_compressed_texture_s3tc"); +}; +qe.prototype.supportsCompressedTexturePVRTC = function() { + return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."), this.extensions.get("WEBGL_compressed_texture_pvrtc"); +}; +qe.prototype.supportsBlendMinMax = function() { + return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."), this.extensions.get("EXT_blend_minmax"); +}; +qe.prototype.supportsVertexTextures = function() { + return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."), this.capabilities.vertexTextures; +}; +qe.prototype.supportsInstancedArrays = function() { + return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."), this.extensions.get("ANGLE_instanced_arrays"); +}; +qe.prototype.enableScissorTest = function(s) { + console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."), this.setScissorTest(s); +}; +qe.prototype.initMaterial = function() { + console.warn("THREE.WebGLRenderer: .initMaterial() has been removed."); +}; +qe.prototype.addPrePlugin = function() { + console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed."); +}; +qe.prototype.addPostPlugin = function() { + console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed."); +}; +qe.prototype.updateShadowMap = function() { + console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed."); +}; +qe.prototype.setFaceCulling = function() { + console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed."); +}; +qe.prototype.allocTextureUnit = function() { + console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed."); +}; +qe.prototype.setTexture = function() { + console.warn("THREE.WebGLRenderer: .setTexture() has been removed."); +}; +qe.prototype.setTexture2D = function() { + console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed."); +}; +qe.prototype.setTextureCube = function() { + console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed."); +}; +qe.prototype.getActiveMipMapLevel = function() { + return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."), this.getActiveMipmapLevel(); +}; +Object.defineProperties(qe.prototype, { + shadowMapEnabled: { + get: function() { + return this.shadowMap.enabled; + }, + set: function(s) { + console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."), this.shadowMap.enabled = s; + } + }, + shadowMapType: { + get: function() { + return this.shadowMap.type; + }, + set: function(s) { + console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."), this.shadowMap.type = s; + } + }, + shadowMapCullFace: { + get: function() { + console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); + }, + set: function() { + console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); + } + }, + context: { + get: function() { + return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."), this.getContext(); + } + }, + vr: { + get: function() { + return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"), this.xr; + } + }, + gammaInput: { + get: function() { + return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."), !1; + }, + set: function() { + console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."); + } + }, + gammaOutput: { + get: function() { + return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), !1; + }, + set: function(s) { + console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), this.outputEncoding = s === !0 ? Oi : Nt; + } + }, + toneMappingWhitePoint: { + get: function() { + return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."), 1; + }, + set: function() { + console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."); + } + }, + gammaFactor: { + get: function() { + return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."), 2; + }, + set: function() { + console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."); + } + } +}); +Object.defineProperties(yh.prototype, { + cullFace: { + get: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); + }, + set: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); + } + }, + renderReverseSided: { + get: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); + }, + set: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); + } + }, + renderSingleSided: { + get: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); + }, + set: function() { + console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); + } + } +}); +function Q0(s, e, t) { + return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."), new js(s, t); +} +Object.defineProperties(At.prototype, { + wrapS: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS = s; + } + }, + wrapT: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT = s; + } + }, + magFilter: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter = s; + } + }, + minFilter: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter = s; + } + }, + anisotropy: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy = s; + } + }, + offset: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset = s; + } + }, + repeat: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat = s; + } + }, + format: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format = s; + } + }, + type: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type = s; + } + }, + generateMipmaps: { + get: function() { + return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps; + }, + set: function(s) { + console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps = s; + } + } +}); +Za.prototype.load = function(s) { + console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead."); + let e = this; + return new kh().load(s, function(n) { + e.setBuffer(n); + }), this; +}; +qh.prototype.getData = function() { + return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."), this.getFrequencyData(); +}; +$s.prototype.updateCubeMap = function(s, e) { + return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."), this.update(s, e); +}; +$s.prototype.clear = function(s, e, t, n) { + return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."), this.renderTarget.clear(s, e, t, n); +}; +Yn.crossOrigin = void 0; +Yn.loadTexture = function(s, e, t, n) { + console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead."); + let i = new Bh; + i.setCrossOrigin(this.crossOrigin); + let r = i.load(s, t, void 0, n); + return e && (r.mapping = e), r; +}; +Yn.loadTextureCube = function(s, e, t, n) { + console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead."); + let i = new Fh; + i.setCrossOrigin(this.crossOrigin); + let r = i.load(s, t, void 0, n); + return e && (r.mapping = e), r; +}; +Yn.loadCompressedTexture = function() { + console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead."); +}; +Yn.loadCompressedTextureCube = function() { + console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead."); +}; +function K0() { + console.error("THREE.CanvasRenderer has been removed"); +} +function ev() { + console.error("THREE.JSONLoader has been removed."); +} +var tv = { + createMultiMaterialObject: function() { + console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); + }, + detach: function() { + console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); + }, + attach: function() { + console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); + } +}; +function nv() { + console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js"); +} +function iv() { + return console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"), new _e; +} +function rv() { + return console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"), new _e; +} +function sv() { + console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js"); +} +function ov() { + console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js"); +} +function av() { + console.error("THREE.ImmediateRenderObject has been removed."); +} +typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { + detail: { + revision: ca + } +})); +typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = ca); +const mod = { + ACESFilmicToneMapping: Uu, + AddEquation: _i, + AddOperation: Fu, + AdditiveAnimationBlendMode: qc, + AdditiveBlending: nl, + AlphaFormat: Xu, + AlwaysDepth: Au, + AlwaysStencilFunc: Ud, + AmbientLight: qa, + AmbientLightProbe: Vh, + AnimationClip: Lr, + AnimationLoader: cy, + AnimationMixer: $h, + AnimationObjectGroup: Yh, + AnimationUtils: Ze, + ArcCurve: Ma, + ArrayCamera: ga, + ArrowHelper: Uy, + Audio: Za, + AudioAnalyser: qh, + AudioContext: Hh, + AudioListener: my, + AudioLoader: kh, + AxesHelper: ru, + AxisHelper: X0, + BackSide: it, + BasicDepthPacking: Nd, + BasicShadowMap: qy, + BinaryTextureLoader: j0, + Bone: oo, + BooleanKeyframeTrack: Qn, + BoundingBoxHelper: J0, + Box2: qi, + Box3: Lt, + Box3Helper: By, + BoxBufferGeometry: wn, + BoxGeometry: wn, + BoxHelper: iu, + BufferAttribute: Ue, + BufferGeometry: _e, + BufferGeometryLoader: Uh, + ByteType: Hu, + Cache: Ni, + Camera: Ir, + CameraHelper: Ny, + CanvasRenderer: K0, + CanvasTexture: Th, + CatmullRomCurve3: wa, + CineonToneMapping: zu, + CircleBufferGeometry: fr, + CircleGeometry: fr, + ClampToEdgeWrapping: vt, + Clock: Wh, + Color: ae, + ColorKeyframeTrack: Ba, + CompressedTexture: va, + CompressedTextureLoader: hy, + ConeBufferGeometry: pr, + ConeGeometry: pr, + CubeCamera: $s, + CubeReflectionMapping: Bi, + CubeRefractionMapping: zi, + CubeTexture: ki, + CubeTextureLoader: Fh, + CubeUVReflectionMapping: Pr, + CubeUVRefractionMapping: Ws, + CubicBezierCurve: lo, + CubicBezierCurve3: Sa, + CubicInterpolant: Ph, + CullFaceBack: tl, + CullFaceFront: du, + CullFaceFrontBack: Wy, + CullFaceNone: uu, + Curve: Ct, + CurvePath: Ah, + CustomBlending: pu, + CustomToneMapping: Ou, + CylinderBufferGeometry: Jn, + CylinderGeometry: Jn, + Cylindrical: Cy, + DataTexture: qn, + DataTexture2DArray: Qs, + DataTexture3D: ma, + DataTextureLoader: Nh, + DataUtils: ky, + DecrementStencilOp: n0, + DecrementWrapStencilOp: r0, + DefaultLoadingManager: ly, + DepthFormat: Vn, + DepthStencilFormat: Li, + DepthTexture: ks, + DirectionalLight: Wa, + DirectionalLightHelper: Fy, + DiscreteInterpolant: Ih, + DodecahedronBufferGeometry: mr, + DodecahedronGeometry: mr, + DoubleSide: Ci, + DstAlphaFactor: Mu, + DstColorFactor: wu, + DynamicBufferAttribute: B0, + DynamicCopyUsage: y0, + DynamicDrawUsage: ur, + DynamicReadUsage: m0, + EdgesGeometry: _a, + EdgesHelper: Y0, + EllipseCurve: Ur, + EqualDepth: Lu, + EqualStencilFunc: l0, + EquirectangularReflectionMapping: Ds, + EquirectangularRefractionMapping: Fs, + Euler: Zn, + EventDispatcher: En, + ExtrudeBufferGeometry: ln, + ExtrudeGeometry: ln, + FaceColors: T0, + FileLoader: Yt, + FlatShading: kc, + Float16BufferAttribute: nh, + Float32Attribute: W0, + Float32BufferAttribute: de, + Float64Attribute: q0, + Float64BufferAttribute: ih, + FloatType: nn, + Fog: Br, + FogExp2: Nr, + Font: ov, + FontLoader: sv, + FramebufferTexture: Sh, + FrontSide: Ai, + Frustum: Dr, + GLBufferAttribute: Qh, + GLSL1: _0, + GLSL3: xl, + GreaterDepth: Pu, + GreaterEqualDepth: Ru, + GreaterEqualStencilFunc: d0, + GreaterStencilFunc: h0, + GridHelper: nu, + Group: Hn, + HalfFloatType: kn, + HemisphereLight: Ua, + HemisphereLightHelper: Iy, + HemisphereLightProbe: Gh, + IcosahedronBufferGeometry: _r, + IcosahedronGeometry: _r, + ImageBitmapLoader: Oh, + ImageLoader: Rr, + ImageUtils: Yn, + ImmediateRenderObject: av, + IncrementStencilOp: t0, + IncrementWrapStencilOp: i0, + InstancedBufferAttribute: Xn, + InstancedBufferGeometry: Ya, + InstancedInterleavedBuffer: jh, + InstancedMesh: xa, + Int16Attribute: H0, + Int16BufferAttribute: eh, + Int32Attribute: G0, + Int32BufferAttribute: th, + Int8Attribute: z0, + Int8BufferAttribute: jc, + IntType: Gu, + InterleavedBuffer: $n, + InterleavedBufferAttribute: Sn, + Interpolant: cn, + InterpolateDiscrete: zs, + InterpolateLinear: Us, + InterpolateSmooth: yo, + InvertStencilOp: s0, + JSONLoader: ev, + KeepStencilOp: vo, + KeyframeTrack: zt, + LOD: bh, + LatheBufferGeometry: Mr, + LatheGeometry: Mr, + Layers: Js, + LensFlare: nv, + LessDepth: Cu, + LessEqualDepth: ea, + LessEqualStencilFunc: c0, + LessStencilFunc: a0, + Light: Bt, + LightProbe: Hr, + Line: on, + Line3: Kh, + LineBasicMaterial: ft, + LineCurve: Or, + LineCurve3: Eh, + LineDashedMaterial: Fa, + LineLoop: ya, + LinePieces: w0, + LineSegments: wt, + LineStrip: b0, + LinearEncoding: Nt, + LinearFilter: tt, + LinearInterpolant: Na, + LinearMipMapLinearFilter: $y, + LinearMipMapNearestFilter: Zy, + LinearMipmapLinearFilter: Ui, + LinearMipmapNearestFilter: Wc, + LinearToneMapping: Nu, + Loader: bt, + LoaderUtils: Gs, + LoadingManager: za, + LoopOnce: Pd, + LoopPingPong: Dd, + LoopRepeat: Id, + LuminanceAlphaFormat: Yu, + LuminanceFormat: Ju, + MOUSE: Gy, + Material: dt, + MaterialLoader: zh, + Math: M0, + MathUtils: M0, + Matrix3: lt, + Matrix4: pe, + MaxEquation: ol, + Mesh: st, + MeshBasicMaterial: hn, + MeshDepthMaterial: eo, + MeshDistanceMaterial: to, + MeshFaceMaterial: A0, + MeshLambertMaterial: Ia, + MeshMatcapMaterial: Da, + MeshNormalMaterial: Pa, + MeshPhongMaterial: La, + MeshPhysicalMaterial: Ca, + MeshStandardMaterial: po, + MeshToonMaterial: Ra, + MinEquation: sl, + MirroredRepeatWrapping: Bs, + MixOperation: Du, + MultiMaterial: C0, + MultiplyBlending: rl, + MultiplyOperation: Vs, + NearestFilter: rt, + NearestMipMapLinearFilter: Yy, + NearestMipMapNearestFilter: Jy, + NearestMipmapLinearFilter: na, + NearestMipmapNearestFilter: ta, + NeverDepth: Eu, + NeverStencilFunc: o0, + NoBlending: vn, + NoColors: S0, + NoToneMapping: _n, + NormalAnimationBlendMode: ua, + NormalBlending: sr, + NotEqualDepth: Iu, + NotEqualStencilFunc: u0, + NumberKeyframeTrack: Ar, + Object3D: Ne, + ObjectLoader: uy, + ObjectSpaceNormalMap: zd, + OctahedronBufferGeometry: Ii, + OctahedronGeometry: Ii, + OneFactor: yu, + OneMinusDstAlphaFactor: bu, + OneMinusDstColorFactor: Su, + OneMinusSrcAlphaFactor: Vc, + OneMinusSrcColorFactor: _u, + OrthographicCamera: Fr, + PCFShadowMap: Hc, + PCFSoftShadowMap: fu, + PMREMGenerator: ah, + ParametricGeometry: iv, + Particle: R0, + ParticleBasicMaterial: D0, + ParticleSystem: P0, + ParticleSystemMaterial: F0, + Path: gr, + PerspectiveCamera: ut, + Plane: Wt, + PlaneBufferGeometry: Pi, + PlaneGeometry: Pi, + PlaneHelper: zy, + PointCloud: L0, + PointCloudMaterial: I0, + PointLight: Ga, + PointLightHelper: Ry, + Points: zr, + PointsMaterial: jn, + PolarGridHelper: Dy, + PolyhedronBufferGeometry: an, + PolyhedronGeometry: an, + PositionalAudio: xy, + PropertyBinding: ke, + PropertyMixer: Xh, + QuadraticBezierCurve: co, + QuadraticBezierCurve3: ho, + Quaternion: gt, + QuaternionKeyframeTrack: Wi, + QuaternionLinearInterpolant: Dh, + REVISION: ca, + RGBADepthPacking: Bd, + RGBAFormat: ct, + RGBAIntegerFormat: ed, + RGBA_ASTC_10x10_Format: fd, + RGBA_ASTC_10x5_Format: hd, + RGBA_ASTC_10x6_Format: ud, + RGBA_ASTC_10x8_Format: dd, + RGBA_ASTC_12x10_Format: pd, + RGBA_ASTC_12x12_Format: md, + RGBA_ASTC_4x4_Format: nd, + RGBA_ASTC_5x4_Format: id, + RGBA_ASTC_5x5_Format: rd, + RGBA_ASTC_6x5_Format: sd, + RGBA_ASTC_6x6_Format: od, + RGBA_ASTC_8x5_Format: ad, + RGBA_ASTC_8x6_Format: ld, + RGBA_ASTC_8x8_Format: cd, + RGBA_BPTC_Format: gd, + RGBA_ETC2_EAC_Format: gl, + RGBA_PVRTC_2BPPV1_Format: pl, + RGBA_PVRTC_4BPPV1_Format: fl, + RGBA_S3TC_DXT1_Format: ll, + RGBA_S3TC_DXT3_Format: cl, + RGBA_S3TC_DXT5_Format: hl, + RGBFormat: Gn, + RGBIntegerFormat: Ku, + RGB_ETC1_Format: td, + RGB_ETC2_Format: ml, + RGB_PVRTC_2BPPV1_Format: dl, + RGB_PVRTC_4BPPV1_Format: ul, + RGB_S3TC_DXT1_Format: al, + RGFormat: ju, + RGIntegerFormat: Qu, + RawShaderMaterial: Gi, + Ray: Cn, + Raycaster: Ey, + RectAreaLight: Xa, + RedFormat: Zu, + RedIntegerFormat: $u, + ReinhardToneMapping: Bu, + RepeatWrapping: Ns, + ReplaceStencilOp: e0, + ReverseSubtractEquation: gu, + RingBufferGeometry: br, + RingGeometry: br, + SRGB8_ALPHA8_ASTC_10x10_Format: Cd, + SRGB8_ALPHA8_ASTC_10x5_Format: Td, + SRGB8_ALPHA8_ASTC_10x6_Format: Ed, + SRGB8_ALPHA8_ASTC_10x8_Format: Ad, + SRGB8_ALPHA8_ASTC_12x10_Format: Ld, + SRGB8_ALPHA8_ASTC_12x12_Format: Rd, + SRGB8_ALPHA8_ASTC_4x4_Format: xd, + SRGB8_ALPHA8_ASTC_5x4_Format: yd, + SRGB8_ALPHA8_ASTC_5x5_Format: vd, + SRGB8_ALPHA8_ASTC_6x5_Format: _d, + SRGB8_ALPHA8_ASTC_6x6_Format: Md, + SRGB8_ALPHA8_ASTC_8x5_Format: bd, + SRGB8_ALPHA8_ASTC_8x6_Format: wd, + SRGB8_ALPHA8_ASTC_8x8_Format: Sd, + Scene: no, + SceneUtils: tv, + ShaderChunk: Fe, + ShaderLib: qt, + ShaderMaterial: sn, + ShadowMaterial: Aa, + Shape: Xt, + ShapeBufferGeometry: Di, + ShapeGeometry: Di, + ShapePath: Oy, + ShapeUtils: Jt, + ShortType: ku, + Skeleton: ao, + SkeletonHelper: eu, + SkinnedMesh: so, + SmoothShading: Xy, + Sphere: An, + SphereBufferGeometry: Fi, + SphereGeometry: Fi, + Spherical: Ay, + SphericalHarmonics3: Ja, + SplineCurve: uo, + SpotLight: Ha, + SpotLightHelper: Ly, + Sprite: ro, + SpriteMaterial: io, + SrcAlphaFactor: Gc, + SrcAlphaSaturateFactor: Tu, + SrcColorFactor: vu, + StaticCopyUsage: x0, + StaticDrawUsage: hr, + StaticReadUsage: p0, + StereoCamera: fy, + StreamCopyUsage: v0, + StreamDrawUsage: f0, + StreamReadUsage: g0, + StringKeyframeTrack: Kn, + SubtractEquation: mu, + SubtractiveBlending: il, + TOUCH: Vy, + TangentSpaceNormalMap: Hi, + TetrahedronBufferGeometry: wr, + TetrahedronGeometry: wr, + TextGeometry: rv, + Texture: ot, + TextureLoader: Bh, + TorusBufferGeometry: Sr, + TorusGeometry: Sr, + TorusKnotBufferGeometry: Tr, + TorusKnotGeometry: Tr, + Triangle: nt, + TriangleFanDrawMode: Qy, + TriangleStripDrawMode: jy, + TrianglesDrawMode: Fd, + TubeBufferGeometry: Er, + TubeGeometry: Er, + UVMapping: ha, + Uint16Attribute: k0, + Uint16BufferAttribute: Ys, + Uint32Attribute: V0, + Uint32BufferAttribute: Zs, + Uint8Attribute: U0, + Uint8BufferAttribute: Qc, + Uint8ClampedAttribute: O0, + Uint8ClampedBufferAttribute: Kc, + Uniform: go, + UniformsLib: ie, + UniformsUtils: uf, + UnsignedByteType: rn, + UnsignedInt248Type: Ti, + UnsignedIntType: Ps, + UnsignedShort4444Type: Vu, + UnsignedShort5551Type: Wu, + UnsignedShort565Type: qu, + UnsignedShortType: cr, + VSMShadowMap: ir, + Vector2: X, + Vector3: M, + Vector4: Ve, + VectorKeyframeTrack: Cr, + Vertex: N0, + VertexColors: E0, + VideoTexture: wh, + WebGL1Renderer: _h, + WebGLCubeRenderTarget: js, + WebGLMultipleRenderTargets: Zc, + WebGLMultisampleRenderTarget: Xs, + WebGLRenderTarget: At, + WebGLRenderTargetCube: Q0, + WebGLRenderer: qe, + WebGLUtils: Ex, + WireframeGeometry: Ea, + WireframeHelper: Z0, + WrapAroundEnding: Os, + XHRLoader: $0, + ZeroCurvatureEnding: Mi, + ZeroFactor: xu, + ZeroSlopeEnding: bi, + ZeroStencilOp: Ky, + sRGBEncoding: Oi +}; +function getWebGLErrorMessage() { + return getErrorMessage(1); +} +function getErrorMessage(version) { + var names = { + 1: "WebGL", + 2: "WebGL 2" + }; + var contexts = { + 1: window.WebGLRenderingContext, + 2: window.WebGL2RenderingContext + }; + var message = 'Your $0 does not seem to support $1'; + var element = document.createElement("div"); + element.id = "webglmessage"; + element.style.fontFamily = "monospace"; + element.style.fontSize = "13px"; + element.style.fontWeight = "normal"; + element.style.textAlign = "center"; + element.style.background = "#fff"; + element.style.color = "#000"; + element.style.padding = "1.5em"; + element.style.width = "400px"; + element.style.margin = "5em auto 0"; + if (contexts[version]) { + message = message.replace("$0", "graphics card"); + } else { + message = message.replace("$0", "browser"); + } + message = message.replace("$1", names[version]); + element.innerHTML = message; + return element; +} +function typedarray_to_vectype(typedArray, ndim) { + if (ndim === 1) { + return "float"; + } else if (typedArray instanceof Float32Array) { + return "vec" + ndim; + } else if (typedArray instanceof Int32Array) { + return "ivec" + ndim; + } else if (typedArray instanceof Uint32Array) { + return "uvec" + ndim; + } else { + return; + } +} +function attribute_type(attribute) { + if (attribute) { + return typedarray_to_vectype(attribute.array, attribute.itemSize); + } else { + return; + } +} +function uniform_type(obj) { + if (obj instanceof THREE.Uniform) { + return uniform_type(obj.value); + } else if (typeof obj === "number") { + return "float"; + } else if (typeof obj === "boolean") { + return "bool"; + } else if (obj instanceof THREE.Vector2) { + return "vec2"; + } else if (obj instanceof THREE.Vector3) { + return "vec3"; + } else if (obj instanceof THREE.Vector4) { + return "vec4"; + } else if (obj instanceof THREE.Color) { + return "vec4"; + } else if (obj instanceof THREE.Matrix3) { + return "mat3"; + } else if (obj instanceof THREE.Matrix4) { + return "mat4"; + } else if (obj instanceof THREE.Texture) { + return "sampler2D"; + } else { + return; + } +} +function uniforms_to_type_declaration(uniform_dict) { + let result = ""; + for(const name in uniform_dict){ + const uniform = uniform_dict[name]; + const type = uniform_type(uniform); + result += `uniform ${type} ${name};\n`; + } + return result; +} +function attributes_to_type_declaration(attributes_dict) { + let result = ""; + for(const name in attributes_dict){ + const attribute = attributes_dict[name]; + const type = attribute_type(attribute); + result += `in ${type} ${name};\n`; + } + return result; +} +const pixelRatio1 = window.devicePixelRatio || 1.0; +function event2scene_pixel(scene, event) { + const { canvas } = scene.screen; + const rect = canvas.getBoundingClientRect(); + const x = (event.clientX - rect.left) * pixelRatio1; + const y = (rect.height - (event.clientY - rect.top)) * pixelRatio1; + return [ + x, + y + ]; +} +function Identity4x4() { + return new pe(); +} +function in_scene(scene, mouse_event) { + const [x, y] = event2scene_pixel(scene, mouse_event); + const [sx, sy, sw, sh] = scene.pixelarea.value; + return x >= sx && x < sx + sw && y >= sy && y < sy + sh; +} +function attach_3d_camera(canvas, makie_camera, cam3d, scene) { + if (cam3d === undefined) { + return; + } + const [w, h] = makie_camera.resolution.value; + const camera = new ut(cam3d.fov, w / h, cam3d.near, cam3d.far); + const center = new M(...cam3d.lookat); + camera.up = new M(...cam3d.upvector); + camera.position.set(...cam3d.eyeposition); + camera.lookAt(center); + function update() { + const view = camera.matrixWorldInverse; + const projection = camera.projectionMatrix; + const [width, height] = cam3d.resolution.value; + const [x, y, z] = camera.position; + camera.aspect = width / height; + camera.updateProjectionMatrix(); + camera.updateWorldMatrix(); + makie_camera.update_matrices(view.elements, projection.elements, [ + width, + height + ], [ + x, + y, + z + ]); + } + cam3d.resolution.on(update); + function addMouseHandler(domObject, drag, zoomIn, zoomOut) { + let startDragX = null; + let startDragY = null; + function mouseWheelHandler(e) { + e = window.event || e; + if (!in_scene(scene, e)) { + return; + } + const delta = Math.sign(e.deltaY); + if (delta == -1) { + zoomOut(); + } else if (delta == 1) { + zoomIn(); + } + e.preventDefault(); + } + function mouseDownHandler(e) { + if (!in_scene(scene, e)) { + return; + } + startDragX = e.clientX; + startDragY = e.clientY; + e.preventDefault(); + } + function mouseMoveHandler(e) { + if (!in_scene(scene, e)) { + return; + } + if (startDragX === null || startDragY === null) return; + if (drag) drag(e.clientX - startDragX, e.clientY - startDragY); + startDragX = e.clientX; + startDragY = e.clientY; + e.preventDefault(); + } + function mouseUpHandler(e) { + if (!in_scene(scene, e)) { + return; + } + mouseMoveHandler.call(this, e); + startDragX = null; + startDragY = null; + e.preventDefault(); + } + domObject.addEventListener("wheel", mouseWheelHandler); + domObject.addEventListener("mousedown", mouseDownHandler); + domObject.addEventListener("mousemove", mouseMoveHandler); + domObject.addEventListener("mouseup", mouseUpHandler); + } + function drag(deltaX, deltaY) { + const radPerPixel = Math.PI / 450; + const deltaPhi = radPerPixel * deltaX; + const deltaTheta = radPerPixel * deltaY; + const pos = camera.position.sub(center); + const radius = pos.length(); + let theta = Math.acos(pos.z / radius); + let phi = Math.atan2(pos.y, pos.x); + theta = Math.min(Math.max(theta - deltaTheta, 0), Math.PI); + phi -= deltaPhi; + pos.x = radius * Math.sin(theta) * Math.cos(phi); + pos.y = radius * Math.sin(theta) * Math.sin(phi); + pos.z = radius * Math.cos(theta); + camera.position.add(center); + camera.lookAt(center); + update(); + } + function zoomIn() { + camera.position.sub(center).multiplyScalar(0.9).add(center); + update(); + } + function zoomOut() { + camera.position.sub(center).multiplyScalar(1.1).add(center); + update(); + } + addMouseHandler(canvas, drag, zoomIn, zoomOut); +} +function mul(a, b) { + return b.clone().multiply(a); +} +function orthographicprojection(left, right, bottom, top, znear, zfar) { + return [ + 2 / (right - left), + 0, + 0, + 0, + 0, + 2 / (top - bottom), + 0, + 0, + 0, + 0, + -2 / (zfar - znear), + 0, + -(right + left) / (right - left), + -(top + bottom) / (top - bottom), + -(zfar + znear) / (zfar - znear), + 1 + ]; +} +function pixel_space_inverse(w, h, near) { + return [ + 0.5 * w, + 0, + 0, + 0, + 0, + 0.5 * h, + 0, + 0, + 0, + 0, + near, + 0, + 0.5 * w, + 0.5 * h, + 0, + 1 + ]; +} +function relative_space() { + const relative = Identity4x4(); + relative.fromArray([ + 2, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 1, + 0, + -1, + -1, + 0, + 1 + ]); + return relative; +} +class MakieCamera { + constructor(){ + this.view = new go(Identity4x4()); + this.projection = new go(Identity4x4()); + this.projectionview = new go(Identity4x4()); + this.pixel_space = new go(Identity4x4()); + this.pixel_space_inverse = new go(Identity4x4()); + this.projectionview_inverse = new go(Identity4x4()); + this.relative_space = new go(relative_space()); + this.relative_inverse = new go(relative_space().invert()); + this.clip_space = new go(Identity4x4()); + this.resolution = new go(new X()); + this.eyeposition = new go(new M()); + this.preprojections = {}; + } + calculate_matrices() { + const [w, h] = this.resolution.value; + const nearclip = -10_000; + this.pixel_space.value.fromArray(orthographicprojection(0, w, 0, h, nearclip, 10_000)); + this.pixel_space_inverse.value.fromArray(pixel_space_inverse(w, h, nearclip)); + const proj_view = mul(this.view.value, this.projection.value); + this.projectionview.value = proj_view; + this.projectionview_inverse.value = proj_view.clone().invert(); + Object.keys(this.preprojections).forEach((key)=>{ + const [space, markerspace] = key.split(","); + this.preprojections[key].value = this.calculate_preprojection_matrix(space, markerspace); + }); + } + update_matrices(view, projection, resolution, eyepos) { + this.view.value.fromArray(view); + this.projection.value.fromArray(projection); + this.resolution.value.fromArray(resolution); + this.eyeposition.value.fromArray(eyepos); + this.calculate_matrices(); + return; + } + clip_to_space(space) { + if (space === "data") { + return this.projectionview_inverse.value; + } else if (space === "pixel") { + return this.pixel_space_inverse.value; + } else if (space === "relative") { + return this.relative_inverse.value; + } else if (space === "clip") { + return this.clip_space.value; + } else { + throw new Error(`Space ${space} not recognized`); + } + } + space_to_clip(space) { + if (space === "data") { + return this.projectionview.value; + } else if (space === "pixel") { + return this.pixel_space.value; + } else if (space === "relative") { + return this.relative_space.value; + } else if (space === "clip") { + return this.clip_space.value; + } else { + throw new Error(`Space ${space} not recognized`); + } + } + calculate_preprojection_matrix(space, markerspace) { + const cp = this.clip_to_space(markerspace); + const sc = this.space_to_clip(space); + return mul(sc, cp); + } + preprojection_matrix(space, markerspace) { + const key = [ + space, + markerspace + ]; + const matrix_uniform = this.preprojections[key]; + if (matrix_uniform) { + return matrix_uniform; + } else { + const matrix = this.calculate_preprojection_matrix(space, markerspace); + const uniform = new go(matrix); + this.preprojections[key] = uniform; + return uniform; + } + } +} +const scene_cache = {}; +function filter_by_key(dict, keys, default_value = false) { + const result = {}; + keys.forEach((key)=>{ + const val = dict[key]; + if (val) { + result[key] = val; + } else { + result[key] = default_value; + } + }); + return result; +} +const plot_cache = {}; +const TEXTURE_ATLAS = [ + undefined +]; +function add_scene(scene_id, three_scene) { + scene_cache[scene_id] = three_scene; +} +function find_scene(scene_id) { + return scene_cache[scene_id]; +} +function delete_scene(scene_id) { + const scene = scene_cache[scene_id]; + if (!scene) { + return; + } + while(scene.children.length > 0){ + scene.remove(scene.children[0]); + } + delete scene_cache[scene_id]; +} +function find_plots(plot_uuids) { + const plots = []; + plot_uuids.forEach((id)=>{ + const plot = plot_cache[id]; + if (plot) { + plots.push(plot); + } + }); + return plots; +} +function delete_scenes(scene_uuids, plot_uuids) { + plot_uuids.forEach((plot_id)=>{ + delete plot_cache[plot_id]; + }); + scene_uuids.forEach((scene_id)=>{ + delete_scene(scene_id); + }); +} +function insert_plot(scene_id, plot_data) { + const scene = find_scene(scene_id); + plot_data.forEach((plot)=>{ + add_plot(scene, plot); + }); +} +function delete_plots(scene_id, plot_uuids) { + console.log(`deleting plots!: ${plot_uuids}`); + const scene = find_scene(scene_id); + const plots = find_plots(plot_uuids); + plots.forEach((p)=>{ + scene.remove(p); + delete plot_cache[p]; + }); +} +function convert_texture(data) { + const tex = create_texture(data); + tex.needsUpdate = true; + tex.minFilter = mod[data.minFilter]; + tex.magFilter = mod[data.magFilter]; + tex.anisotropy = data.anisotropy; + tex.wrapS = mod[data.wrapS]; + if (data.size.length > 1) { + tex.wrapT = mod[data.wrapT]; + } + if (data.size.length > 2) { + tex.wrapR = mod[data.wrapR]; + } + return tex; +} +function is_three_fixed_array(value) { + return value instanceof mod.Vector2 || value instanceof mod.Vector3 || value instanceof mod.Vector4 || value instanceof mod.Matrix4; +} +function to_uniform(data) { + if (data.type !== undefined) { + if (data.type == "Sampler") { + return convert_texture(data); + } + throw new Error(`Type ${data.type} not known`); + } + if (Array.isArray(data) || ArrayBuffer.isView(data)) { + if (!data.every((x)=>typeof x === "number")) { + return data; + } + if (data.length == 2) { + return new mod.Vector2().fromArray(data); + } + if (data.length == 3) { + return new mod.Vector3().fromArray(data); + } + if (data.length == 4) { + return new mod.Vector4().fromArray(data); + } + if (data.length == 16) { + const mat = new mod.Matrix4(); + mat.fromArray(data); + return mat; + } + } + return data; +} +function deserialize_uniforms(data) { + const result = {}; + for(const name in data){ + const value = data[name]; + if (value instanceof mod.Uniform) { + result[name] = value; + } else { + const ser = to_uniform(value); + result[name] = new mod.Uniform(ser); + } + } + return result; +} +function linesegments_vertex_shader(uniforms, attributes) { + const attribute_decl = attributes_to_type_declaration(attributes); + const uniform_decl = uniforms_to_type_declaration(uniforms); + const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); + return `#version 300 es + precision mediump int; + precision highp float; + + ${attribute_decl} + ${uniform_decl} + + out vec2 f_uv; + out ${color} f_color; + + vec2 get_resolution() { + // 2 * px_per_unit doesn't make any sense, but works + // TODO, figure out what's going on! + return resolution / 2.0 * px_per_unit; + } + + vec3 screen_space(vec3 point) { + vec4 vertex = projectionview * model * vec4(point, 1); + return vec3(vertex.xy * get_resolution() , vertex.z) / vertex.w; + } + + vec3 screen_space(vec2 point) { + return screen_space(vec3(point, 0)); + } + + void main() { + vec3 p_a = screen_space(linepoint_start); + vec3 p_b = screen_space(linepoint_end); + float width = (px_per_unit * (position.x == 1.0 ? linewidth_end : linewidth_start)); + f_color = position.x == 1.0 ? color_end : color_start; + f_uv = vec2(position.x, position.y + 0.5); + + vec2 pointA = p_a.xy; + vec2 pointB = p_b.xy; + + vec2 xBasis = pointB - pointA; + vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); + vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; + + gl_Position = vec4(point.xy / get_resolution(), p_a.z, 1.0); + } + `; +} +function lines_fragment_shader(uniforms, attributes) { + const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); + const color_uniforms = filter_by_key(uniforms, [ + "colorrange", + "colormap", + "nan_color", + "highclip", + "lowclip" + ]); + const uniform_decl = uniforms_to_type_declaration(color_uniforms); + return `#version 300 es + #extension GL_OES_standard_derivatives : enable + + precision mediump int; + precision highp float; + precision mediump sampler2D; + precision mediump sampler3D; + + in vec2 f_uv; + in ${color} f_color; + ${uniform_decl} + + out vec4 fragment_color; + + // Half width of antialiasing smoothstep + #define ANTIALIAS_RADIUS 0.7071067811865476 + + vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { + float cmin = colorrange.x; + float cmax = colorrange.y; + if (value <= cmax && value >= cmin) { + // in value range, continue! + } else if (value < cmin) { + return lowclip; + } else if (value > cmax) { + return highclip; + } else { + // isnan CAN be broken (of course) -.- + // so if outside value range and not smaller/bigger min/max we assume NaN + return nan_color; + } + float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); + // 1/0 corresponds to the corner of the colormap, so to properly interpolate + // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). + float stepsize = 1.0 / float(textureSize(colormap, 0)); + i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; + return texture(colormap, vec2(i01, 0.0)); + } + + vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { + return get_color_from_cmap(color, colormap, colorrange); + } + + vec4 get_color(vec4 color, bool colormap, bool colorrange) { + return color; + } + vec4 get_color(vec3 color, bool colormap, bool colorrange) { + return vec4(color, 1.0); + } + + float aastep(float threshold, float value) { + float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; + return smoothstep(threshold-afwidth, threshold+afwidth, value); + } + + float aastep(float threshold1, float threshold2, float dist) { + return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); + } + + void main(){ + float xalpha = aastep(0.0, 0.0, f_uv.x); + float yalpha = aastep(0.0, 0.0, f_uv.y); + vec4 color = get_color(f_color, colormap, colorrange); + fragment_color = vec4(color.rgb, color.a); + } + `; +} +function create_line_material(uniforms, attributes) { + const uniforms_des = deserialize_uniforms(uniforms); + return new THREE.RawShaderMaterial({ + uniforms: uniforms_des, + vertexShader: linesegments_vertex_shader(uniforms_des, attributes), + fragmentShader: lines_fragment_shader(uniforms_des, attributes), + transparent: true + }); +} +function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { + const skip_elems = is_segments ? 2 * ndim : ndim; + const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); + if (!is_segments) { + buffer.count = points.length / ndim - 1; + } + geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); + geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); + return buffer; +} +function create_line_buffer(buffers, geometry, name, attr, is_segments) { + const flat_buffer = attr.value.flat; + const ndims = attr.value.type_length; + const linebuffer = attach_interleaved_line_buffer(name, geometry, flat_buffer, ndims, is_segments); + buffers[name] = linebuffer; + attr.on((new_points)=>{ + const buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + if (old_count < new_line_points.length) { + buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims, is_segments); + } else { + buff.updateRange.count = new_line_points.length; + buff.set(new_line_points, 0); + } + buffers[name].needsUpdate = true; + }); + return flat_buffer; +} +function create_line_geometry(attributes, is_segments) { + function geometry_buffer() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, + -0.5, + 1, + -0.5, + 1, + 0.5, + 0, + -0.5, + 1, + 0.5, + 0, + 0.5 + ]; + geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); + return geometry; + } + const geometry = geometry_buffer(); + const buffers = {}; + for(let name in attributes){ + const attr = attributes[name]; + create_line_buffer(buffers, geometry, name, attr, is_segments); + } + geometry.boundingSphere = new THREE.Sphere(); + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} +function create_line(line_data) { + const geometry = create_line_geometry(line_data.attributes, false); + const material = create_line_material(line_data.uniforms, geometry.attributes); + return new THREE.Mesh(geometry, material); +} +function create_linesegments(line_data) { + const geometry = create_line_geometry(line_data.attributes, true); + const material = create_line_material(line_data.uniforms, geometry.attributes); + return new THREE.Mesh(geometry, material); +} +function deserialize_plot(data) { + let mesh; + const update_visible = (v)=>{ + mesh.visible = v; + return; + }; + if (data.plot_type === "lines") { + mesh = create_line(data); + } else if (data.plot_type === "linesegments") { + mesh = create_linesegments(data); + } else if ("instance_attributes" in data) { + mesh = create_instanced_mesh(data); + } else { + mesh = create_mesh(data); + } + mesh.name = data.name; + mesh.frustumCulled = false; + mesh.matrixAutoUpdate = false; + mesh.plot_uuid = data.uuid; + update_visible(data.visible.value); + data.visible.on(update_visible); + connect_uniforms(mesh, data.uniform_updater); + if (!(data.plot_type === "lines" || data.plot_type === "linesegments")) { + connect_attributes(mesh, data.attribute_updater); + } + return mesh; +} +const ON_NEXT_INSERT = new Set(); +function on_next_insert(f) { + ON_NEXT_INSERT.add(f); +} +function add_plot(scene, plot_data) { + const cam = scene.wgl_camera; + const identity = new mod.Uniform(new mod.Matrix4()); + if (plot_data.cam_space == "data") { + plot_data.uniforms.view = cam.view; + plot_data.uniforms.projection = cam.projection; + plot_data.uniforms.projectionview = cam.projectionview; + plot_data.uniforms.eyeposition = cam.eyeposition; + } else if (plot_data.cam_space == "pixel") { + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = cam.pixel_space; + plot_data.uniforms.projectionview = cam.pixel_space; + } else if (plot_data.cam_space == "relative") { + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = cam.relative_space; + plot_data.uniforms.projectionview = cam.relative_space; + } else { + plot_data.uniforms.view = identity; + plot_data.uniforms.projection = identity; + plot_data.uniforms.projectionview = identity; + } + const { px_per_unit } = scene.screen; + plot_data.uniforms.resolution = cam.resolution; + plot_data.uniforms.px_per_unit = new mod.Uniform(px_per_unit); + if (plot_data.uniforms.preprojection) { + const { space , markerspace } = plot_data; + plot_data.uniforms.preprojection = cam.preprojection_matrix(space.value, markerspace.value); + } + const p = deserialize_plot(plot_data); + plot_cache[plot_data.uuid] = p; + scene.add(p); + const next_insert = new Set(ON_NEXT_INSERT); + next_insert.forEach((f)=>f()); +} +function connect_uniforms(mesh, updater) { + updater.on(([name, data])=>{ + if (name === "none") { + return; + } + const uniform = mesh.material.uniforms[name]; + if (uniform.value.isTexture) { + const im_data = uniform.value.image; + const [size, tex_data] = data; + if (tex_data.length == im_data.data.length) { + im_data.data.set(tex_data); + } else { + const old_texture = uniform.value; + uniform.value = re_create_texture(old_texture, tex_data, size); + old_texture.dispose(); + } + uniform.value.needsUpdate = true; + } else { + if (is_three_fixed_array(uniform.value)) { + uniform.value.fromArray(data); + } else { + uniform.value = data; + } + } + }); +} +function create_texture(data) { + const buffer = data.data; + if (data.size.length == 3) { + const tex = new mod.DataTexture3D(buffer, data.size[0], data.size[1], data.size[2]); + tex.format = mod[data.three_format]; + tex.type = mod[data.three_type]; + return tex; + } else { + const tex_data = buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; + return new mod.DataTexture(tex_data, data.size[0], data.size[1], mod[data.three_format], mod[data.three_type]); + } +} +function re_create_texture(old_texture, buffer, size) { + if (size.length == 3) { + const tex = new mod.DataTexture3D(buffer, size[0], size[1], size[2]); + tex.format = old_texture.format; + tex.type = old_texture.type; + return tex; + } else { + return new mod.DataTexture(buffer, size[0], size[1] ? size[1] : 1, old_texture.format, old_texture.type); + } +} +function BufferAttribute(buffer) { + const jsbuff = new mod.BufferAttribute(buffer.flat, buffer.type_length); + jsbuff.setUsage(mod.DynamicDrawUsage); + return jsbuff; +} +function InstanceBufferAttribute(buffer) { + const jsbuff = new mod.InstancedBufferAttribute(buffer.flat, buffer.type_length); + jsbuff.setUsage(mod.DynamicDrawUsage); + return jsbuff; +} +function attach_geometry(buffer_geometry, vertexarrays, faces) { + for(const name in vertexarrays){ + const buff = vertexarrays[name]; + let buffer; + if (buff.to_update) { + buffer = new mod.BufferAttribute(buff.to_update, buff.itemSize); + } else { + buffer = BufferAttribute(buff); + } + buffer_geometry.setAttribute(name, buffer); + } + buffer_geometry.setIndex(faces); + buffer_geometry.boundingSphere = new mod.Sphere(); + buffer_geometry.boundingSphere.radius = 10000000000000; + buffer_geometry.frustumCulled = false; + return buffer_geometry; +} +function attach_instanced_geometry(buffer_geometry, instance_attributes) { + for(const name in instance_attributes){ + const buffer = InstanceBufferAttribute(instance_attributes[name]); + buffer_geometry.setAttribute(name, buffer); + } +} +function recreate_geometry(mesh, vertexarrays, faces) { + const buffer_geometry = new mod.BufferGeometry(); + attach_geometry(buffer_geometry, vertexarrays, faces); + mesh.geometry.dispose(); + mesh.geometry = buffer_geometry; + mesh.needsUpdate = true; +} +function recreate_instanced_geometry(mesh) { + const buffer_geometry = new mod.InstancedBufferGeometry(); + const vertexarrays = {}; + const instance_attributes = {}; + const faces = [ + ...mesh.geometry.index.array + ]; + Object.keys(mesh.geometry.attributes).forEach((name)=>{ + const buffer = mesh.geometry.attributes[name]; + const copy = buffer.to_update ? buffer.to_update : buffer.array.map((x)=>x); + if (buffer.isInstancedBufferAttribute) { + instance_attributes[name] = { + flat: copy, + type_length: buffer.itemSize + }; + } else { + vertexarrays[name] = { + flat: copy, + type_length: buffer.itemSize + }; + } + }); + attach_geometry(buffer_geometry, vertexarrays, faces); + attach_instanced_geometry(buffer_geometry, instance_attributes); + mesh.geometry.dispose(); + mesh.geometry = buffer_geometry; + mesh.needsUpdate = true; +} +function create_material(program) { + const is_volume = "volumedata" in program.uniforms; + return new mod.RawShaderMaterial({ + uniforms: deserialize_uniforms(program.uniforms), + vertexShader: program.vertex_source, + fragmentShader: program.fragment_source, + side: is_volume ? mod.BackSide : mod.DoubleSide, + transparent: true, + depthTest: !program.overdraw.value, + depthWrite: !program.transparency.value + }); +} +function create_mesh(program) { + const buffer_geometry = new mod.BufferGeometry(); + const faces = new mod.BufferAttribute(program.faces.value, 1); + attach_geometry(buffer_geometry, program.vertexarrays, faces); + const material = create_material(program); + const mesh = new mod.Mesh(buffer_geometry, material); + program.faces.on((x)=>{ + mesh.geometry.setIndex(new mod.BufferAttribute(x, 1)); + }); + return mesh; +} +function create_instanced_mesh(program) { + const buffer_geometry = new mod.InstancedBufferGeometry(); + const faces = new mod.BufferAttribute(program.faces.value, 1); + attach_geometry(buffer_geometry, program.vertexarrays, faces); + attach_instanced_geometry(buffer_geometry, program.instance_attributes); + const material = create_material(program); + const mesh = new mod.Mesh(buffer_geometry, material); + program.faces.on((x)=>{ + mesh.geometry.setIndex(new mod.BufferAttribute(x, 1)); + }); + return mesh; +} +function first(x) { + return x[Object.keys(x)[0]]; +} +function connect_attributes(mesh, updater) { + const instance_buffers = {}; + const geometry_buffers = {}; + let first_instance_buffer; + const real_instance_length = [ + 0 + ]; + let first_geometry_buffer; + const real_geometry_length = [ + 0 + ]; + function re_assign_buffers() { + const attributes = mesh.geometry.attributes; + Object.keys(attributes).forEach((name)=>{ + const buffer = attributes[name]; + if (buffer.isInstancedBufferAttribute) { + instance_buffers[name] = buffer; + } else { + geometry_buffers[name] = buffer; + } + }); + first_instance_buffer = first(instance_buffers); + if (first_instance_buffer) { + real_instance_length[0] = first_instance_buffer.count; + } + first_geometry_buffer = first(geometry_buffers); + real_geometry_length[0] = first_geometry_buffer.count; + } + re_assign_buffers(); + updater.on(([name, new_values, length])=>{ + const buffer = mesh.geometry.attributes[name]; + let buffers; + let real_length; + let is_instance = false; + if (name in instance_buffers) { + buffers = instance_buffers; + first_instance_buffer; + real_length = real_instance_length; + is_instance = true; + } else { + buffers = geometry_buffers; + first_geometry_buffer; + real_length = real_geometry_length; + } + if (length <= real_length[0]) { + buffer.set(new_values); + buffer.needsUpdate = true; + if (is_instance) { + mesh.geometry.instanceCount = length; + } + } else { + buffer.to_update = new_values; + const all_have_same_length = Object.values(buffers).every((x)=>x.to_update && x.to_update.length / x.itemSize == length); + if (all_have_same_length) { + if (is_instance) { + recreate_instanced_geometry(mesh); + re_assign_buffers(); + mesh.geometry.instanceCount = new_values.length / buffer.itemSize; + } else { + recreate_geometry(mesh, buffers, mesh.geometry.index); + re_assign_buffers(); + } + } + } + }); +} +function deserialize_scene(data, screen) { + const scene = new mod.Scene(); + scene.screen = screen; + const { canvas } = screen; + add_scene(data.uuid, scene); + scene.scene_uuid = data.uuid; + scene.frustumCulled = false; + scene.pixelarea = data.pixelarea; + scene.backgroundcolor = data.backgroundcolor; + scene.clearscene = data.clearscene; + scene.visible = data.visible; + const camera = new MakieCamera(); + scene.wgl_camera = camera; + function update_cam(camera_matrices) { + const [view, projection, resolution, eyepos] = camera_matrices; + camera.update_matrices(view, projection, resolution, eyepos); + } + update_cam(data.camera.value); + if (data.cam3d_state) { + attach_3d_camera(canvas, camera, data.cam3d_state, scene); + } else { + data.camera.on(update_cam); + } + data.plots.forEach((plot_data)=>{ + add_plot(scene, plot_data); + }); + scene.scene_children = data.children.map((child)=>deserialize_scene(child, screen)); + return scene; +} +function delete_plot(plot) { + delete plot_cache[plot.plot_uuid]; + const { parent } = plot; + if (parent) { + parent.remove(plot); + } + plot.geometry.dispose(); + plot.material.dispose(); +} +function delete_three_scene(scene) { + delete scene_cache[scene.scene_uuid]; + scene.scene_children.forEach(delete_three_scene); + while(scene.children.length > 0){ + delete_plot(scene.children[0]); + } +} +window.THREE = mod; +function render_scene(scene, picking = false) { + const { camera , renderer , scalefactor } = scene.screen; + const canvas = renderer.domElement; + if (!document.body.contains(canvas)) { + console.log("EXITING WGL"); + renderer.state.reset(); + renderer.dispose(); + delete_three_scene(scene); + return false; + } + if (!scene.visible.value) { + return true; + } + renderer.autoClear = scene.clearscene.value; + const area = scene.pixelarea.value; + window.devicePixelRatio || 1.0; + if (area) { + const [x, y, w, h] = area.map((x)=>x * scalefactor); + renderer.setViewport(x, y, w, h); + renderer.setScissor(x, y, w, h); + renderer.setScissorTest(true); + if (picking) { + renderer.setClearAlpha(0); + renderer.setClearColor(new mod.Color(0), 0.0); + } else { + renderer.setClearColor(scene.backgroundcolor.value); + } + renderer.render(scene, camera); + } + return scene.scene_children.every((x)=>render_scene(x, picking)); +} +function start_renderloop(three_scene) { + const { fps } = three_scene.screen; + const time_per_frame = 1 / fps * 1000; + let last_time_stamp = performance.now(); + function renderloop(timestamp) { + if (timestamp - last_time_stamp > time_per_frame) { + const all_rendered = render_scene(three_scene); + if (!all_rendered) { + return; + } + last_time_stamp = performance.now(); + } + window.requestAnimationFrame(renderloop); + } + render_scene(three_scene); + renderloop(); +} +function throttle_function(func, delay) { + let prev = 0; + let future_id = undefined; + function inner_throttle(...args) { + const now = new Date().getTime(); + if (future_id !== undefined) { + clearTimeout(future_id); + future_id = undefined; + } + if (now - prev > delay) { + prev = now; + return func(...args); + } else { + future_id = setTimeout(()=>inner_throttle(...args), now - prev + 1); + } + } + return inner_throttle; +} +function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor) { + let context = canvas.getContext("webgl2", { + preserveDrawingBuffer: true + }); + if (!context) { + console.warn("WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)"); + context = canvas.getContext("webgl", { + preserveDrawingBuffer: true + }); + } + if (!context) { + return; + } + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; + const renderer = new mod.WebGLRenderer({ + antialias: true, + canvas: canvas, + context: context, + powerPreference: "high-performance" + }); + renderer.setClearColor("#ffffff"); + const [swidth, sheight] = [ + winscale * width, + winscale * height + ]; + renderer._width = width; + renderer._height = height; + canvas.width = Math.floor(width * scalefactor); + canvas.height = Math.floor(height * scalefactor); + canvas.style.width = swidth + "px"; + canvas.style.height = sheight + "px"; + renderer.setViewport(0, 0, swidth, sheight); + const mouse_callback = (x, y)=>comm.notify({ + mouseposition: [ + x, + y + ] + }); + const notify_mouse_throttled = throttle_function(mouse_callback, 40); + function mousemove(event) { + var rect = canvas.getBoundingClientRect(); + var x = (event.clientX - rect.left) * px_per_unit; + var y = (event.clientY - rect.top) * px_per_unit; + notify_mouse_throttled(x, y); + return false; + } + canvas.addEventListener("mousemove", mousemove); + function mousedown(event) { + comm.notify({ + mousedown: event.buttons + }); + return false; + } + canvas.addEventListener("mousedown", mousedown); + function mouseup(event) { + comm.notify({ + mouseup: event.buttons + }); + return false; + } + canvas.addEventListener("mouseup", mouseup); + function wheel(event) { + comm.notify({ + scroll: [ + event.deltaX, + -event.deltaY + ] + }); + event.preventDefault(); + return false; + } + canvas.addEventListener("wheel", wheel); + function keydown(event) { + comm.notify({ + keydown: event.code + }); + return false; + } + canvas.addEventListener("keydown", keydown); + function keyup(event) { + comm.notify({ + keyup: event.code + }); + return false; + } + canvas.addEventListener("keyup", keyup); + function contextmenu(event) { + comm.notify({ + keyup: "delete_keys" + }); + return false; + } + canvas.addEventListener("contextmenu", (e)=>e.preventDefault()); + canvas.addEventListener("focusout", contextmenu); + function resize_callback() { + const bodyStyle = window.getComputedStyle(document.body); + const width_padding = parseInt(bodyStyle.paddingLeft, 10) + parseInt(bodyStyle.paddingRight, 10) + parseInt(bodyStyle.marginLeft, 10) + parseInt(bodyStyle.marginRight, 10); + const height_padding = parseInt(bodyStyle.paddingTop, 10) + parseInt(bodyStyle.paddingBottom, 10) + parseInt(bodyStyle.marginTop, 10) + parseInt(bodyStyle.marginBottom, 10); + const width = (window.innerWidth - width_padding) * pixelRatio; + const height = (window.innerHeight - height_padding) * pixelRatio; + comm.notify({ + resize: [ + width, + height + ] + }); + } + if (resize_to_body) { + const resize_callback_throttled = throttle_function(resize_callback, 100); + window.addEventListener("resize", (event)=>resize_callback_throttled()); + resize_callback_throttled(); + } + return renderer; +} +function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height, texture_atlas_obs, fps, resize_to_body, px_per_unit, scalefactor) { + if (!scalefactor) { + scalefactor = window.devicePixelRatio || 1.0; + } + if (!px_per_unit) { + px_per_unit = scalefactor; + } + const renderer = threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor); + TEXTURE_ATLAS[0] = texture_atlas_obs; + if (renderer) { + const camera = new mod.PerspectiveCamera(45, 1, 0, 100); + camera.updateProjectionMatrix(); + const size = new mod.Vector2(); + renderer.getDrawingBufferSize(size); + console.log("----"); + console.log(size); + const picking_target = new mod.WebGLRenderTarget(size.x, size.y); + const screen = { + renderer, + picking_target, + camera, + fps, + canvas, + px_per_unit, + scalefactor + }; + const three_scene = deserialize_scene(scenes, screen); + start_renderloop(three_scene); + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; + canvas_width.on((w_h)=>{ + renderer.setSize(Math.round(winscale * w_h[0]), Math.round(winscale * w_h[1])); + }); + } else { + const warning = getWebGLErrorMessage(); + wrapper.appendChild(warning); + } +} +function set_picking_uniforms(scene, last_id, picking, picked_plots, plots, id_to_plot) { + scene.children.forEach((plot, index)=>{ + const { material } = plot; + const { uniforms } = material; + if (picking) { + uniforms.object_id.value = last_id + index; + uniforms.picking.value = true; + material.blending = mod.NoBlending; + } else { + uniforms.picking.value = false; + material.blending = mod.NormalBlending; + const id = uniforms.object_id.value; + if (id in picked_plots) { + plots.push([ + plot, + picked_plots[id] + ]); + id_to_plot[id] = plot; + } + } + }); + let next_id = last_id + scene.children.length; + scene.scene_children.forEach((scene)=>{ + next_id = set_picking_uniforms(scene, next_id, picking, picked_plots, plots, id_to_plot); + }); + return next_id; +} +function pick_native(scene, x, y, w, h) { + const { renderer , picking_target } = scene.screen; + renderer.setRenderTarget(picking_target); + set_picking_uniforms(scene, 1, true); + render_scene(scene, true); + renderer.setRenderTarget(null); + const nbytes = w * h * 4; + const pixel_bytes = new Uint8Array(nbytes); + renderer.readRenderTargetPixels(picking_target, x, y, w, h, pixel_bytes); + const picked_plots = {}; + const picked_plots_array = []; + const reinterpret_view = new DataView(pixel_bytes.buffer); + for(let i = 0; i < pixel_bytes.length / 4; i++){ + const id = reinterpret_view.getUint16(i * 4); + const index = reinterpret_view.getUint16(i * 4 + 2); + picked_plots_array.push([ + id, + index + ]); + picked_plots[id] = index; + } + const plots = []; + const id_to_plot = {}; + set_picking_uniforms(scene, 0, false, picked_plots, plots, id_to_plot); + const picked_plots_matrix = picked_plots_array.map(([id, index])=>{ + const p = id_to_plot[id]; + return [ + p ? p.plot_uuid : null, + index + ]; + }); + const plot_matrix = { + data: picked_plots_matrix, + size: [ + w, + h + ] + }; + return [ + plot_matrix, + plots + ]; +} +function pick_closest(scene, xy, range) { + const { picking_target } = scene.screen; + const { width , height } = picking_target; + if (!(1.0 <= xy[0] <= width && 1.0 <= xy[1] <= height)) { + return [ + null, + 0 + ]; + } + const x0 = Math.max(1, xy[0] - range); + const y0 = Math.max(1, xy[1] - range); + const x1 = Math.min(width, Math.floor(xy[0] + range)); + const y1 = Math.min(height, Math.floor(xy[1] + range)); + const dx = x1 - x0; + const dy = y1 - y0; + const [plot_data, _] = pick_native(scene, x0, y0, dx, dy); + const plot_matrix = plot_data.data; + let min_dist = range ^ 2; + let selection = [ + null, + 0 + ]; + const x = xy[0] + 1 - x0; + const y = xy[1] + 1 - y0; + let pindex = 0; + for(let i = 1; i <= dx; i++){ + for(let j = 1; j <= dx; j++){ + const d = x - i ^ 2 + (y - j) ^ 2; + const [plot_uuid, index] = plot_matrix[pindex]; + pindex = pindex + 1; + if (d < min_dist && plot_uuid) { + min_dist = d; + selection = [ + plot_uuid, + index + ]; + } + } + } + return selection; +} +function pick_sorted(scene, xy, range) { + const { picking_target } = scene.screen; + const { width , height } = picking_target; + if (!(1.0 <= xy[0] <= width && 1.0 <= xy[1] <= height)) { + return null; + } + const x0 = Math.max(1, xy[0] - range); + const y0 = Math.max(1, xy[1] - range); + const x1 = Math.min(width, Math.floor(xy[0] + range)); + const y1 = Math.min(height, Math.floor(xy[1] + range)); + const dx = x1 - x0; + const dy = y1 - y0; + const [plot_data, selected] = pick_native(scene, x0, y0, dx, dy); + if (selected.length == 0) { + return null; + } + const plot_matrix = plot_data.data; + const distances = selected.map((x)=>range ^ 2); + const x = xy[0] + 1 - x0; + const y = xy[1] + 1 - y0; + let pindex = 0; + for(let i = 1; i <= dx; i++){ + for(let j = 1; j <= dx; j++){ + const d = x - i ^ 2 + (y - j) ^ 2; + const [plot_uuid, index] = plot_matrix[pindex]; + pindex = pindex + 1; + const plot_index = selected.findIndex((x)=>x[0].plot_uuid == plot_uuid); + if (plot_index >= 0 && d < distances[plot_index]) { + distances[plot_index] = d; + } + } + } + const sorted_indices = Array.from(Array(distances.length).keys()).sort((a, b)=>distances[a] < distances[b] ? -1 : distances[b] < distances[a] | 0); + return sorted_indices.map((idx)=>{ + const [plot, index] = selected[idx]; + return [ + plot.plot_uuid, + index + ]; + }); +} +function pick_native_uuid(scene, x, y, w, h) { + const [_, picked_plots] = pick_native(scene, x, y, w, h); + return picked_plots.map(([p, index])=>[ + p.plot_uuid, + index + ]); +} +function pick_native_matrix(scene, x, y, w, h) { + const [matrix, _] = pick_native(scene, x, y, w, h); + return matrix; +} +function register_popup(popup, scene, plots_to_pick, callback) { + if (!scene || !scene.screen) { + return; + } + const { canvas } = scene.screen; + canvas.addEventListener("mousedown", (event)=>{ + if (!popup.classList.contains("show")) { + popup.classList.add("show"); + } + popup.style.left = event.pageX + "px"; + popup.style.top = event.pageY + "px"; + const [x, y] = event2scene_pixel(scene, event); + const [_, picks] = pick_native(scene, x, y, 1, 1); + if (picks.length == 1) { + const [plot, index] = picks[0]; + if (plots_to_pick.has(plot.plot_uuid)) { + const result = callback(plot, index); + if (typeof result === "string" || result instanceof String) { + popup.innerText = result; + } else { + popup.innerHTML = result; + } + } + } else { + popup.classList.remove("show"); + } + }); + canvas.addEventListener("keyup", (event)=>{ + if (event.key === "Escape") { + popup.classList.remove("show"); + } + }); +} +window.WGL = { + deserialize_scene, + threejs_module, + start_renderloop, + delete_plots, + insert_plot, + find_plots, + delete_scene, + find_scene, + scene_cache, + plot_cache, + delete_scenes, + create_scene, + event2scene_pixel, + on_next_insert, + register_popup, + render_scene +}; +export { deserialize_scene as deserialize_scene, threejs_module as threejs_module, start_renderloop as start_renderloop, delete_plots as delete_plots, insert_plot as insert_plot, find_plots as find_plots, delete_scene as delete_scene, find_scene as find_scene, scene_cache as scene_cache, plot_cache as plot_cache, delete_scenes as delete_scenes, create_scene as create_scene, event2scene_pixel as event2scene_pixel, on_next_insert as on_next_insert }; +export { render_scene as render_scene }; +export { pick_native as pick_native }; +export { pick_closest as pick_closest }; +export { pick_sorted as pick_sorted }; +export { pick_native_uuid as pick_native_uuid }; +export { pick_native_matrix as pick_native_matrix }; +export { register_popup as register_popup }; + diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index 43e9c52ac8b..8a780dd0cb3 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -19,10 +19,8 @@ import { event2scene_pixel } from "./Camera.js"; window.THREE = THREE; -const pixelRatio = window.devicePixelRatio || 1.0; - export function render_scene(scene, picking = false) { - const { camera, renderer } = scene.screen; + const { camera, renderer, scalefactor } = scene.screen; const canvas = renderer.domElement; if (!document.body.contains(canvas)) { console.log("EXITING WGL"); @@ -37,8 +35,10 @@ export function render_scene(scene, picking = false) { } renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; if (area) { - const [x, y, w, h] = area.map((t) => Math.ceil(t)); + const [x, y, w, h] = area.map((x) => x * scalefactor); renderer.setViewport(x, y, w, h); renderer.setScissor(x, y, w, h); renderer.setScissorTest(true); @@ -112,7 +112,8 @@ function throttle_function(func, delay) { return inner_throttle; } -function threejs_module(canvas, comm, width, height, resize_to_body) { +function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor) { + let context = canvas.getContext("webgl2", { preserveDrawingBuffer: true, }); @@ -129,6 +130,9 @@ function threejs_module(canvas, comm, width, height, resize_to_body) { // we return nothing which will be handled by caller return; } + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; + const renderer = new THREE.WebGLRenderer({ antialias: true, canvas: canvas, @@ -138,18 +142,23 @@ function threejs_module(canvas, comm, width, height, resize_to_body) { renderer.setClearColor("#ffffff"); - // The following handles high-DPI devices - // `renderer.setSize` also updates `canvas` size - renderer.setPixelRatio(pixelRatio); - renderer.setSize(width, height); + const [swidth, sheight] = [winscale * width, winscale * height]; + + renderer._width = width; + renderer._height = height; + canvas.width = Math.floor(width * scalefactor); + canvas.height = Math.floor(height * scalefactor); + canvas.style.width = swidth + "px"; + canvas.style.height = sheight + "px"; + renderer.setViewport(0, 0, swidth, sheight); const mouse_callback = (x, y) => comm.notify({ mouseposition: [x, y] }); const notify_mouse_throttled = throttle_function(mouse_callback, 40); function mousemove(event) { var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) * pixelRatio; - var y = (event.clientY - rect.top) * pixelRatio; + var x = (event.clientX - rect.left) * px_per_unit; + var y = (event.clientY - rect.top) * px_per_unit; notify_mouse_throttled(x, y); return false; @@ -255,14 +264,25 @@ function create_scene( height, texture_atlas_obs, fps, - resize_to_body + resize_to_body, + px_per_unit, + scalefactor ) { + if (!scalefactor) { + scalefactor = window.devicePixelRatio || 1.0; + } + if (!px_per_unit) { + px_per_unit = scalefactor; + } + const renderer = threejs_module( canvas, comm, width, height, - resize_to_body + resize_to_body, + px_per_unit, + scalefactor ); TEXTURE_ATLAS[0] = texture_atlas_obs; @@ -281,17 +301,27 @@ function create_scene( // 2) Only Area we pick // It's currently not as easy to change the offset + area of the camera // So, we'll need to make that easier first + console.log("----") + console.log(size); const picking_target = new THREE.WebGLRenderTarget(size.x, size.y); - const screen = { renderer, picking_target, camera, fps, canvas }; + const screen = { + renderer, + picking_target, + camera, + fps, + canvas, + px_per_unit, + scalefactor, + }; const three_scene = deserialize_scene(scenes, screen); - console.log(three_scene); - start_renderloop(three_scene); + start_renderloop(three_scene); + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; canvas_width.on((w_h) => { // `renderer.setSize` correctly updates `canvas` dimensions - const pixelRatio = renderer.getPixelRatio(); - renderer.setSize(Math.ceil(w_h[0]), Math.ceil(w_h[1])); + renderer.setSize(Math.round(winscale * w_h[0]), Math.round(winscale * w_h[1])); }); } else { const warning = getWebGLErrorMessage(); diff --git a/src/theming.jl b/src/theming.jl index 0a9ef6fc613..a730815cc4e 100644 --- a/src/theming.jl +++ b/src/theming.jl @@ -88,6 +88,7 @@ const MAKIE_DEFAULT_THEME = Attributes( render_on_demand = true, framerate = 30.0, px_per_unit = automatic, + scalefactor = automatic, # GLFW window attributes float = false, @@ -98,7 +99,6 @@ const MAKIE_DEFAULT_THEME = Attributes( debugging = false, monitor = nothing, visible = true, - scalefactor = automatic, # Postproccessor oit = true, @@ -112,7 +112,9 @@ const MAKIE_DEFAULT_THEME = Attributes( WGLMakie = Attributes( framerate = 30.0, - resize_to_body = false + resize_to_body = false, + px_per_unit = automatic, + scalefactor = automatic ), RPRMakie = Attributes( From a55483621a14cb929731f6446c5e8136eaeeb692 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Wed, 9 Aug 2023 18:13:14 +0200 Subject: [PATCH 15/28] fix screen for inline JSServe rendering --- WGLMakie/src/display.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/WGLMakie/src/display.jl b/WGLMakie/src/display.jl index 61a0c719294..cd4a0cd0aa3 100644 --- a/WGLMakie/src/display.jl +++ b/WGLMakie/src/display.jl @@ -18,11 +18,12 @@ function Base.size(screen::ThreeDisplay) end function JSServe.jsrender(session::Session, scene::Scene) - three, canvas, on_init = three_display(Screen(scene), session, scene) + screen = Screen(scene) + screen.session = session + screen.display = true + three, canvas, on_init = three_display(screen, session, scene) c = Channel{ThreeDisplay}(1) put!(c, three) - screen = Screen(c, true, scene) - screen.session = session Makie.push_screen!(scene, screen) on(session, on_init) do i mark_as_displayed!(screen, scene) From 52a7bb2874bfc6523b5b6aa945ebd2811377e267 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 11 Aug 2023 15:53:12 +0200 Subject: [PATCH 16/28] fix line length updates --- WGLMakie/src/Lines.js | 128 +++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index 536401f4e32..a3d38ddd5ba 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -186,8 +186,25 @@ function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_se return buffer; } +function create_line_instance_geometry() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, -0.5, 1, -0.5, 1, 0.5, -function create_line_buffer(buffers, geometry, name, attr, is_segments) { + 0, -0.5, 1, 0.5, 0, 0.5, + ]; + geometry.setAttribute( + "position", + new THREE.Float32BufferAttribute(instance_positions, 2) + ); + geometry.boundingSphere = new THREE.Sphere(); + // don't use intersection / culling + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} + +function create_line_buffer(geometry, buffers, name, attr, is_segments) { const flat_buffer = attr.value.flat; const ndims = attr.value.type_length; const linebuffer = attach_interleaved_line_buffer( @@ -198,81 +215,74 @@ function create_line_buffer(buffers, geometry, name, attr, is_segments) { is_segments ); buffers[name] = linebuffer; - attr.on((new_points) => { - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - // instanceBuffer.dispose(); - buffers[name] = attach_interleaved_line_buffer( - name, - geometry, - new_line_points, - ndims, - is_segments - ); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - - // geometry.instanceCount = (new_line_points.length - 4) / 4; - buffers[name].needsUpdate = true; - }); return flat_buffer; } -function create_line_geometry(attributes, is_segments) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [ - 0, -0.5, - 1, -0.5, - 1, 0.5, - - 0, -0.5, - 1, 0.5, - 0, 0.5, - ]; - geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 2) - ); - return geometry; +function create_line_buffers(geometry, buffers, attributes, is_segments) { + for (let name in attributes) { + const attr = attributes[name]; + create_line_buffer(geometry, buffers, name, attr, is_segments); } +} - const geometry = geometry_buffer(); - const buffers = {}; - +function attach_updates(mesh, buffers, attributes, is_segments) { + let geometry = mesh.geometry; for (let name in attributes) { const attr = attributes[name]; - create_line_buffer(buffers, geometry, name, attr, is_segments); + attr.on((new_points) => { + let buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + console.log(old_count); + if (old_count < new_line_points.length) { + mesh.geometry.dispose(); + geometry = create_line_instance_geometry(); + buff = attach_interleaved_line_buffer( + name, + geometry, + new_line_points, + ndims, + is_segments + ); + mesh.geometry = geometry; + buffers[name] = buff; + } else { + buff.set(new_line_points, 0); + } + // buff.updateRange.count = new_line_points.length / ndims; + geometry.instanceCount = new_line_points.length / ndims; + buff.needsUpdate = true; + mesh.needsUpdate = true; + }); } - - geometry.boundingSphere = new THREE.Sphere(); - // don't use intersection / culling - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - return geometry; } -export function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes, false); +export function _create_line(line_data, is_segments) { + const geometry = create_line_instance_geometry(); + const buffers = {}; + create_line_buffers( + geometry, + buffers, + line_data.attributes, + is_segments + ); const material = create_line_material( line_data.uniforms, geometry.attributes ); - return new THREE.Mesh(geometry, material); + + const mesh = new THREE.Mesh(geometry, material); + attach_updates(mesh, buffers, line_data.attributes, is_segments); + return mesh; +} + +export function create_line(line_data) { + return _create_line(line_data, false) } export function create_linesegments(line_data) { - const geometry = create_line_geometry(line_data.attributes, true); - const material = create_line_material( - line_data.uniforms, - geometry.attributes - ); - return new THREE.Mesh(geometry, material); + return _create_line(line_data, true) } function interpolate(p1, p2, t) { From fc24b5f3255e4f5e0d3ca47ee9f94a27d2926fbc Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 11 Aug 2023 15:53:24 +0200 Subject: [PATCH 17/28] clean up initialization --- WGLMakie/src/display.jl | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/WGLMakie/src/display.jl b/WGLMakie/src/display.jl index cd4a0cd0aa3..a298f1b587e 100644 --- a/WGLMakie/src/display.jl +++ b/WGLMakie/src/display.jl @@ -17,17 +17,23 @@ function Base.size(screen::ThreeDisplay) return (width, height) end -function JSServe.jsrender(session::Session, scene::Scene) - screen = Screen(scene) +function render_with_init(screen, session, scene) screen.session = session - screen.display = true + @assert isready(screen.three) three, canvas, on_init = three_display(screen, session, scene) - c = Channel{ThreeDisplay}(1) - put!(c, three) + screen.display = true Makie.push_screen!(scene, screen) on(session, on_init) do i + put!(screen.three, three) mark_as_displayed!(screen, scene) + return end + return three, canvas, on_init +end + +function JSServe.jsrender(session::Session, scene::Scene) + screen = Screen(scene) + three, canvas, on_init = render_with_init(screen, session, scene) return canvas end @@ -99,18 +105,13 @@ function mark_as_displayed!(screen::Screen, scene::Scene) return end + + for M in Makie.WEB_MIMES @eval begin function Makie.backend_show(screen::Screen, io::IO, m::$M, scene::Scene) inline_display = App() do session::Session - screen.session = session - three, canvas, init_obs = three_display(screen, session, scene) - Makie.push_screen!(scene, screen) - on(session, init_obs) do _ - put!(screen.three, three) - mark_as_displayed!(screen, scene) - return - end + three, canvas, init_obs = render_with_init(screen, session, scene) return canvas end Base.show(io, m, inline_display) From 92ec9d322c6ea91f834d696c8034944356367c71 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 11 Aug 2023 15:53:33 +0200 Subject: [PATCH 18/28] fix mouse coordinates --- WGLMakie/src/wglmakie.bundled.js | 117 ++++++++++++++++++------------- WGLMakie/src/wglmakie.js | 13 ++-- 2 files changed, 76 insertions(+), 54 deletions(-) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index c1e79fc67ff..82c6a79c969 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20126,66 +20126,80 @@ function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_se geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); return buffer; } -function create_line_buffer(buffers, geometry, name, attr, is_segments) { +function create_line_instance_geometry() { + const geometry = new THREE.InstancedBufferGeometry(); + const instance_positions = [ + 0, + -0.5, + 1, + -0.5, + 1, + 0.5, + 0, + -0.5, + 1, + 0.5, + 0, + 0.5 + ]; + geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); + geometry.boundingSphere = new THREE.Sphere(); + geometry.boundingSphere.radius = 10000000000000; + geometry.frustumCulled = false; + return geometry; +} +function create_line_buffer(geometry, buffers, name, attr, is_segments) { const flat_buffer = attr.value.flat; const ndims = attr.value.type_length; const linebuffer = attach_interleaved_line_buffer(name, geometry, flat_buffer, ndims, is_segments); buffers[name] = linebuffer; - attr.on((new_points)=>{ - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - buffers[name] = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims, is_segments); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - buffers[name].needsUpdate = true; - }); return flat_buffer; } -function create_line_geometry(attributes, is_segments) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [ - 0, - -0.5, - 1, - -0.5, - 1, - 0.5, - 0, - -0.5, - 1, - 0.5, - 0, - 0.5 - ]; - geometry.setAttribute("position", new THREE.Float32BufferAttribute(instance_positions, 2)); - return geometry; +function create_line_buffers(geometry, buffers, attributes, is_segments) { + for(let name in attributes){ + const attr = attributes[name]; + create_line_buffer(geometry, buffers, name, attr, is_segments); } - const geometry = geometry_buffer(); - const buffers = {}; +} +function attach_updates(mesh, buffers, attributes, is_segments) { + let geometry = mesh.geometry; for(let name in attributes){ const attr = attributes[name]; - create_line_buffer(buffers, geometry, name, attr, is_segments); + attr.on((new_points)=>{ + let buff = buffers[name]; + const ndims = new_points.type_length; + const new_line_points = new_points.flat; + const old_count = buff.updateRange.count; + console.log(old_count); + if (old_count < new_line_points.length) { + mesh.geometry.dispose(); + geometry = create_line_instance_geometry(); + buff = attach_interleaved_line_buffer(name, geometry, new_line_points, ndims, is_segments); + mesh.geometry = geometry; + buffers[name] = buff; + } else { + buff.set(new_line_points, 0); + } + geometry.instanceCount = new_line_points.length / ndims; + buff.needsUpdate = true; + mesh.needsUpdate = true; + }); } - geometry.boundingSphere = new THREE.Sphere(); - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - return geometry; } -function create_line(line_data) { - const geometry = create_line_geometry(line_data.attributes, false); +function _create_line(line_data, is_segments) { + const geometry = create_line_instance_geometry(); + const buffers = {}; + create_line_buffers(geometry, buffers, line_data.attributes, is_segments); const material = create_line_material(line_data.uniforms, geometry.attributes); - return new THREE.Mesh(geometry, material); + const mesh = new THREE.Mesh(geometry, material); + attach_updates(mesh, buffers, line_data.attributes, is_segments); + return mesh; +} +function create_line(line_data) { + return _create_line(line_data, false); } function create_linesegments(line_data) { - const geometry = create_line_geometry(line_data.attributes, true); - const material = create_line_material(line_data.uniforms, geometry.attributes); - return new THREE.Mesh(geometry, material); + return _create_line(line_data, true); } function deserialize_plot(data) { let mesh; @@ -20533,7 +20547,6 @@ function render_scene(scene, picking = false) { } renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; - window.devicePixelRatio || 1.0; if (area) { const [x, y, w, h] = area.map((x)=>x * scalefactor); renderer.setViewport(x, y, w, h); @@ -20626,8 +20639,14 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit const notify_mouse_throttled = throttle_function(mouse_callback, 40); function mousemove(event) { var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) * px_per_unit; - var y = (event.clientY - rect.top) * px_per_unit; + var x = (event.clientX - rect.left) / winscale; + var y = (event.clientY - rect.top) / winscale; + console.log("-----------------"); + console.log(event.clientX); + console.log(event.clientY); + console.log(rect); + console.log(x); + console.log(y); notify_mouse_throttled(x, y); return false; } diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index 8a780dd0cb3..d951a750a6f 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -35,8 +35,6 @@ export function render_scene(scene, picking = false) { } renderer.autoClear = scene.clearscene.value; const area = scene.pixelarea.value; - const pixel_ratio = window.devicePixelRatio || 1.0; - const winscale = scalefactor / pixel_ratio; if (area) { const [x, y, w, h] = area.map((x) => x * scalefactor); renderer.setViewport(x, y, w, h); @@ -157,9 +155,14 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit function mousemove(event) { var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) * px_per_unit; - var y = (event.clientY - rect.top) * px_per_unit; - + var x = (event.clientX - rect.left) / winscale; + var y = (event.clientY - rect.top) / winscale; + console.log("-----------------"); + console.log(event.clientX); + console.log(event.clientY); + console.log(rect); + console.log(x) + console.log(y); notify_mouse_throttled(x, y); return false; } From 60d912b2deac66992a2b9c9911f9d058be8b21cc Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 11 Aug 2023 15:55:08 +0200 Subject: [PATCH 19/28] remove logging --- WGLMakie/src/wglmakie.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index d951a750a6f..90562eddc5a 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -157,12 +157,6 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit var rect = canvas.getBoundingClientRect(); var x = (event.clientX - rect.left) / winscale; var y = (event.clientY - rect.top) / winscale; - console.log("-----------------"); - console.log(event.clientX); - console.log(event.clientY); - console.log(rect); - console.log(x) - console.log(y); notify_mouse_throttled(x, y); return false; } From 15873c2b6f58cc776ee6068f5fd407f6e97bf340 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 11 Aug 2023 19:17:50 +0200 Subject: [PATCH 20/28] cleanup and fixes --- WGLMakie/assets/lines.frag | 1 - WGLMakie/assets/lines.vert | 2 - WGLMakie/src/Camera.js | 4 +- WGLMakie/src/Lines.js | 7 +- WGLMakie/src/Linesegments.js | 247 - WGLMakie/src/Serialization.js | 6 +- WGLMakie/src/Serialization2.js | 767 - WGLMakie/src/THREE.js | 3561 +++++ WGLMakie/src/display.jl | 5 +- WGLMakie/src/serialization.jl | 6 +- WGLMakie/src/wglmakie.bundled.js | 23682 +++++++++++++++-------------- WGLMakie/src/wglmakie.js | 2 +- 12 files changed, 15727 insertions(+), 12563 deletions(-) delete mode 100644 WGLMakie/src/Linesegments.js delete mode 100644 WGLMakie/src/Serialization2.js create mode 100644 WGLMakie/src/THREE.js diff --git a/WGLMakie/assets/lines.frag b/WGLMakie/assets/lines.frag index 01081ed98af..b146e66af6c 100644 --- a/WGLMakie/assets/lines.frag +++ b/WGLMakie/assets/lines.frag @@ -1,4 +1,3 @@ -#version 300 es precision mediump int; precision mediump float; precision mediump sampler2D; diff --git a/WGLMakie/assets/lines.vert b/WGLMakie/assets/lines.vert index c0dbdfabdc1..bb22d732b75 100644 --- a/WGLMakie/assets/lines.vert +++ b/WGLMakie/assets/lines.vert @@ -1,5 +1,3 @@ -#version 300 es - in float position; in vec2 linepoint_prev; in vec2 linepoint_start; diff --git a/WGLMakie/src/Camera.js b/WGLMakie/src/Camera.js index 25223aca629..4f912ff15b3 100644 --- a/WGLMakie/src/Camera.js +++ b/WGLMakie/src/Camera.js @@ -1,4 +1,4 @@ -import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; +import * as THREE from "./THREE.js"; const pixelRatio = window.devicePixelRatio || 1.0; @@ -69,7 +69,7 @@ export function attach_3d_camera(canvas, makie_camera, cam3d, scene) { projection.elements, [width, height], [x, y, z] - ); + ); } cam3d.resolution.on(update); diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index a3d38ddd5ba..ee49f41eddc 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -33,8 +33,7 @@ function linesegments_vertex_shader(uniforms, attributes) { attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); - return `#version 300 es - precision mediump int; + return `precision mediump int; precision highp float; ${attribute_decl} @@ -90,8 +89,7 @@ function lines_fragment_shader(uniforms, attributes) { ]); const uniform_decl = uniforms_to_type_declaration(color_uniforms); - return `#version 300 es - #extension GL_OES_standard_derivatives : enable + return `#extension GL_OES_standard_derivatives : enable precision mediump int; precision highp float; @@ -163,6 +161,7 @@ function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, + glslVersion: THREE.GLSL3, vertexShader: linesegments_vertex_shader(uniforms_des, attributes), fragmentShader: lines_fragment_shader(uniforms_des, attributes), transparent: true, diff --git a/WGLMakie/src/Linesegments.js b/WGLMakie/src/Linesegments.js deleted file mode 100644 index 03ec5c5e525..00000000000 --- a/WGLMakie/src/Linesegments.js +++ /dev/null @@ -1,247 +0,0 @@ -import { - attributes_to_type_declaration, - uniforms_to_type_declaration, - uniform_type, - attribute_type -} from "./Shaders.js"; -import { deserialize_uniforms } from "./Serialization.js"; - - -function filter_by_key(dict, keys, default_value=false) { - const result = {}; - keys.forEach(key => { - const val = dict[key]; - if (val) { - result[key] = val; - } else { - result[key] = default_value; - } - }) - return result; -} - -// https://github.com/glslify/glsl-aastep -// https://wwwtyro.net/2019/11/18/instanced-lines.html -// https://github.com/mrdoob/three.js/blob/dev/examples/jsm/lines/LineMaterial.js -// https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf -// https://github.com/gameofbombs/pixi-candles/tree/master/src -// https://github.com/wwwtyro/instanced-lines-demos/tree/master - -function lines_vertex_shader(uniforms, attributes) { - const attribute_decl = attributes_to_type_declaration(attributes); - const uniform_decl = uniforms_to_type_declaration(uniforms); - const color = - attribute_type(attributes.color_start) || - uniform_type(uniforms.color_start); - - return `#version 300 es - precision mediump int; - precision highp float; - - ${attribute_decl} - ${uniform_decl} - - out vec2 f_uv; - out ${color} f_color; - - vec3 screen_space(vec3 point) { - vec4 vertex = projectionview * model * vec4(point, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; - } - - vec3 screen_space(vec2 point) { - return screen_space(vec3(point, 0)); - } - - void main() { - vec3 p_a = screen_space(linepoint_start); - vec3 p_b = screen_space(linepoint_end); - float width = position.x == 1.0 ? linewidth_end : linewidth_start ; - - vec2 pointA = p_a.xy; - vec2 pointB = p_b.xy; - - vec2 xBasis = pointB - pointA; - vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); - vec2 point = pointA + xBasis * position.x + yBasis * width * position.y; - - gl_Position = vec4((point.xy / resolution), p_a.z, 1.0); - f_color = position.x == 1.0 ? color_end : color_start; - f_uv = vec2(position.x, position.y + 0.5); - } - `; -} - -function lines_fragment_shader(uniforms, attributes) { - const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); - const color_uniforms = filter_by_key(uniforms, ["colorrange", "colormap", "nan_color", "highclip", "lowclip"]); - const uniform_decl = uniforms_to_type_declaration(color_uniforms); - - return `#version 300 es - #extension GL_OES_standard_derivatives : enable - - precision mediump int; - precision highp float; - precision mediump sampler2D; - precision mediump sampler3D; - - in vec2 f_uv; - in ${color} f_color; - ${uniform_decl} - - out vec4 fragment_color; - - // Half width of antialiasing smoothstep - #define ANTIALIAS_RADIUS 1.0 - - vec4 get_color_from_cmap(float value, sampler2D colormap, vec2 colorrange) { - float cmin = colorrange.x; - float cmax = colorrange.y; - if (value <= cmax && value >= cmin) { - // in value range, continue! - } else if (value < cmin) { - return lowclip; - } else if (value > cmax) { - return highclip; - } else { - // isnan CAN be broken (of course) -.- - // so if outside value range and not smaller/bigger min/max we assume NaN - return nan_color; - } - float i01 = clamp((value - cmin) / (cmax - cmin), 0.0, 1.0); - // 1/0 corresponds to the corner of the colormap, so to properly interpolate - // between the colors, we need to scale it, so that the ends are at 1 - (stepsize/2) and 0+(stepsize/2). - float stepsize = 1.0 / float(textureSize(colormap, 0)); - i01 = (1.0 - stepsize) * i01 + 0.5 * stepsize; - return texture(colormap, vec2(i01, 0.0)); - } - - vec4 get_color(float color, sampler2D colormap, vec2 colorrange) { - return get_color_from_cmap(color, colormap, colorrange); - } - - vec4 get_color(vec4 color, bool colormap, bool colorrange) { - return color; - } - vec4 get_color(vec3 color, bool colormap, bool colorrange) { - return vec4(color, 1.0); - } - - float aastep(float threshold, float value) { - float afwidth = length(vec2(dFdx(value), dFdy(value))) * ANTIALIAS_RADIUS; - return smoothstep(threshold-afwidth, threshold+afwidth, value); - } - - float aastep(float threshold1, float threshold2, float dist) { - return aastep(threshold1, dist) * aastep(threshold2, 1.0 - dist); - } - - void main(){ - float xalpha = aastep(0.0, 0.0, f_uv.x); - float yalpha = aastep(0.0, 0.0, f_uv.y); - vec4 color = get_color(f_color, colormap, colorrange); - fragment_color = vec4(color.rgb, color.a); - } - `; -} - -function create_line_material(uniforms, attributes) { - const uniforms_des = deserialize_uniforms(uniforms); - const fragi = lines_fragment_shader(uniforms_des, attributes); - return new THREE.RawShaderMaterial({ - uniforms: uniforms_des, - vertexShader: lines_vertex_shader(uniforms_des, attributes), - fragmentShader: fragi, - transparent: true, - }); -} - -function attach_interleaved_line_buffer(attr_name, geometry, points, ndim) { - const buffer = new THREE.InstancedInterleavedBuffer(points, 2 * ndim, 1); - geometry.setAttribute( - attr_name + "_start", - new THREE.InterleavedBufferAttribute(buffer, ndim, 0) - ); // xyz1 - geometry.setAttribute( - attr_name + "_end", - new THREE.InterleavedBufferAttribute(buffer, ndim, ndim) - ); // xyz1 - return buffer; -} - -function create_linesegment_geometry(attributes) { - function geometry_buffer() { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [ - 0, -0.5, 1, -0.5, 1, 0.5, 0, -0.5, 1, 0.5, 0, 0.5, - ]; - geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 2) - ); - return geometry; - } - - const geometry = geometry_buffer(); - const buffers = {}; - function create_line_buffer(name, attr) { - const flat_buffer = attr.value.flat; - const ndims = attr.value.type_length; - const buffer = flat_buffer; - const linebuffer = attach_interleaved_line_buffer( - name, - geometry, - buffer, - ndims - ); - buffers[name] = linebuffer; - attr.on((new_points) => { - const buff = buffers[name]; - const ndims = new_points.type_length; - const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - if (old_count < new_line_points.length) { - // instanceBuffer.dispose(); - buffers[name] = attach_interleaved_line_buffer( - name, - geometry, - new_line_points, - ndims - ); - } else { - buff.updateRange.count = new_line_points.length; - buff.set(new_line_points, 0); - } - buffers[name].needsUpdate = true; - }); - return buffer; - } - let points; - for (let name in attributes) { - const attr = attributes[name]; - points = create_line_buffer(name, attr); - } - geometry.boundingSphere = new THREE.Sphere(); - // don't use intersection / culling - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - return geometry; -} - -export function create_linesegments(line_data) { - const geometry = create_linesegment_geometry(line_data.attributes); - const material = create_line_material( - line_data.uniforms, - geometry.attributes - ); - return new THREE.Mesh(geometry, material); -} - -export function create_linesegments(line_data) { - const geometry = create_linesegment_geometry(line_data.attributes); - const material = create_line_material( - line_data.uniforms, - geometry.attributes - ); - return new THREE.Mesh(geometry, material); -} diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index eff37e17949..6c66a0fd50d 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -1,10 +1,7 @@ +import * as THREE from "./THREE.js"; import * as Camera from "./Camera.js"; import { create_line, create_linesegments } from "./Lines.js"; -import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; - - - // global scene cache to look them up for dynamic operations in Makie // e.g. insert!(scene, plot) / delete!(scene, plot) const scene_cache = {}; @@ -378,6 +375,7 @@ function create_material(program) { fragmentShader: program.fragment_source, side: is_volume ? THREE.BackSide : THREE.DoubleSide, transparent: true, + glslVersion: THREE.GLSL3, depthTest: !program.overdraw.value, depthWrite: !program.transparency.value, }); diff --git a/WGLMakie/src/Serialization2.js b/WGLMakie/src/Serialization2.js deleted file mode 100644 index 6da7f2131a1..00000000000 --- a/WGLMakie/src/Serialization2.js +++ /dev/null @@ -1,767 +0,0 @@ -import * as Camera from "./Camera.js"; -import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; - -const LINES_VERT = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -in float position; - -in vec2 linepoint_prev; // start of previous segment -in vec2 linepoint_start; // end of previous segment, start of current segment -in vec2 linepoint_end; // end of current segment, start of next segment -in vec2 linepoint_next; // end of next segment - -uniform vec4 is_valid; // start of previous segment - -uniform vec4 color_start; // end of previous segment, start of current segment -uniform vec4 color_end; // end of current segment, start of next segment - -uniform float thickness_start; -uniform float thickness_end; - -uniform vec2 resolution; -uniform mat4 projectionview; -uniform mat4 model; -uniform float pattern_length; - -flat out vec2 f_uv_minmax; -out vec2 f_uv; -out vec4 f_color; -out float f_thickness; - -#define MITER_LIMIT -0.4 -#define AA_THICKNESS 4.0 - -vec3 screen_space(vec2 point) { - vec4 vertex = projectionview * model * vec4(point, 0, 1); - return vec3(vertex.xy * resolution, vertex.z) / vertex.w; -} - -void emit_vertex(vec3 position, vec2 uv, bool is_start) { - - f_uv = uv; - - f_color = is_start ? color_start : color_end; - - gl_Position = vec4((position.xy / resolution), position.z, 1.0); - f_thickness = is_start ? thickness_start : thickness_end; -} - -void main() { - vec3 p0 = screen_space(linepoint_prev); - vec3 p1 = screen_space(linepoint_start); - vec3 p2 = screen_space(linepoint_end); - vec3 p3 = screen_space(linepoint_next); - vec2 dir = p1.xy - p2.xy; - dir = normalize(dir); - vec2 line_normal = vec2(dir.y, -dir.x); - vec2 line_offset = line_normal * (thickness_start / 2.0); - - vec2 tangent = normalize(normalize(p2 - p1) + normalize(p1 - p0)); - - vec2 miter = vec2(-tangent.y, tangent.x); - // triangle 1 - vec3 v0 = vec3(p1.xy - line_offset, p1.z); - if (position == 0.0) { - emit_vertex(v0, vec2(0.0, 0.0), true); - return; - } - vec3 v2 = vec3(p2.xy - line_offset, p2.z); - if (position == 1.0) { - emit_vertex(v2, vec2(0.0, 0.0), true); - return; - } - vec3 v1 = vec3(p1.xy + line_offset, p1.z); - if (position == 2.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } - - // triangle 2 - if (position == 3.0) { - emit_vertex(v2, vec2(0.0, 0.0), false); - return; - } - vec3 v3 = vec3(p2.xy + line_offset, p2.z); - if (position == 4.0) { - emit_vertex(v3, vec2(0.0, 0.0), false); - return; - } - if (position == 5.0) { - emit_vertex(v1, vec2(0.0, 0.0), false); - return; - } -} -`; - -const LINES_FRAG = `#version 300 es -precision mediump int; -precision highp float; -precision mediump sampler2D; -precision mediump sampler3D; - -flat in vec2 f_uv_minmax; -in vec2 f_uv; -in vec4 f_color; -in float f_thickness; - -uniform float pattern_length; - -out vec4 fragment_color; - -// Half width of antialiasing smoothstep -#define ANTIALIAS_RADIUS 0.8 - -float aastep(float threshold1, float dist) { - return smoothstep(threshold1-ANTIALIAS_RADIUS, threshold1+ANTIALIAS_RADIUS, dist); -} - -float aastep(float threshold1, float threshold2, float dist) { - // We use 2x pixel space in the geometry shaders which passes through - // in uv.y, so we need to treat it here by using 2 * ANTIALIAS_RADIUS - float AA = 2.0 * ANTIALIAS_RADIUS; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -float aastep_scaled(float threshold1, float threshold2, float dist) { - float AA = ANTIALIAS_RADIUS / pattern_length; - return smoothstep(threshold1 - AA, threshold1 + AA, dist) - - smoothstep(threshold2 - AA, threshold2 + AA, dist); -} - -void main(){ - // vec4 color = vec4(f_color.rgb, 0.0); - // vec2 xy = f_uv; - - // float alpha = aastep(0.0, xy.x); - // float alpha2 = aastep(-f_thickness, f_thickness, xy.y); - // float alpha3 = aastep_scaled(f_uv_minmax.x, f_uv_minmax.y, f_uv.x); - - // color = vec4(f_color.rgb, f_color.a * alpha * alpha2 * alpha3); - - fragment_color = f_color; -} -`; - -function create_line_material(uniforms) { - return new THREE.RawShaderMaterial({ - uniforms: deserialize_uniforms(uniforms), - vertexShader: LINES_VERT, - fragmentShader: LINES_FRAG, - transparent: true, - }); -} - -function create_line_geometry(linepoints, linesegments) { - const geometry = new THREE.InstancedBufferGeometry(); - const instance_positions = [0, 1, 2, 3, 4, 5]; - geometry.setAttribute( - "position", - new THREE.Float32BufferAttribute(instance_positions, 1) - ); - const N = linepoints.length; - let points; - if (linesegments) { - const N2 = linepoints.length + 4; - points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - points.set(linepoints, 2); - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - } else { - const N2 = linepoints.length * 2 + 4; - points = new Float32Array(N2); - points[0] = linepoints[0]; - points[1] = linepoints[1]; - for (let i = 0; i < linepoints.length; i += 2) { - points[2 * i + 2] = linepoints[i]; - points[2 * i + 3] = linepoints[i + 1]; - - points[2 * i + 4] = linepoints[i + 2]; - points[2 * i + 5] = linepoints[i + 3]; - } - - points[N2 - 2] = linepoints[N - 2]; - points[N2 - 1] = linepoints[N - 1]; - } - - const instanceBuffer = new THREE.InstancedInterleavedBuffer(points, 4, 1); // xy1, xy2 - - geometry.setAttribute( - "linepoint_prev", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 0) - ); // xyz1 - geometry.setAttribute( - "linepoint_start", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 2) - ); // xyz1 - geometry.setAttribute( - "linepoint_end", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 4) - ); // xyz1 - geometry.setAttribute( - "linepoint_next", - new THREE.InterleavedBufferAttribute(instanceBuffer, 2, 6) - ); // xyz2 - - geometry.boundingSphere = new THREE.Sphere(); - // don't use intersection / culling - geometry.boundingSphere.radius = 10000000000000; - geometry.frustumCulled = false; - geometry.instanceCount = (points.length - 4) / 4; - - return geometry; -} - -export function create_line(line_data) { - const geometry = create_line_geometry( - line_data.positions, - line_data.is_linesegments - ); - const material = create_line_material(line_data.uniforms); - console.log(material); - return new THREE.Mesh(geometry, material); -} - -// global scene cache to look them up for dynamic operations in Makie -// e.g. insert!(scene, plot) / delete!(scene, plot) -const scene_cache = {}; -const plot_cache = {}; -const TEXTURE_ATLAS = [undefined]; - -function add_scene(scene_id, three_scene) { - scene_cache[scene_id] = three_scene; -} - -export function find_scene(scene_id) { - return scene_cache[scene_id]; -} - -export function delete_scene(scene_id) { - const scene = scene_cache[scene_id]; - if (!scene) { - return; - } - while (scene.children.length > 0) { - scene.remove(scene.children[0]); - } - delete scene_cache[scene_id]; -} - -export function find_plots(plot_uuids) { - const plots = []; - plot_uuids.forEach((id) => { - const plot = plot_cache[id]; - if (plot) { - plots.push(plot); - } - }); - return plots; -} - -export function delete_scenes(scene_uuids, plot_uuids) { - plot_uuids.forEach((plot_id) => { - delete plot_cache[plot_id]; - }); - scene_uuids.forEach((scene_id) => { - delete_scene(scene_id); - }); -} - -export function insert_plot(scene_id, plot_data) { - const scene = find_scene(scene_id); - plot_data.forEach((plot) => { - add_plot(scene, plot); - }); -} - -export function delete_plots(scene_id, plot_uuids) { - console.log(`deleting plots!: ${plot_uuids}`); - const scene = find_scene(scene_id); - const plots = find_plots(plot_uuids); - plots.forEach((p) => { - scene.remove(p); - delete plot_cache[p]; - }); -} - -function convert_texture(data) { - const tex = create_texture(data); - tex.needsUpdate = true; - tex.minFilter = THREE[data.minFilter]; - tex.magFilter = THREE[data.magFilter]; - tex.anisotropy = data.anisotropy; - tex.wrapS = THREE[data.wrapS]; - if (data.size.length > 1) { - tex.wrapT = THREE[data.wrapT]; - } - if (data.size.length > 2) { - tex.wrapR = THREE[data.wrapR]; - } - return tex; -} - -function is_three_fixed_array(value) { - return ( - value instanceof THREE.Vector2 || - value instanceof THREE.Vector3 || - value instanceof THREE.Vector4 || - value instanceof THREE.Matrix4 - ); -} - -function to_uniform(data) { - if (data.type !== undefined) { - if (data.type == "Sampler") { - return convert_texture(data); - } - throw new Error(`Type ${data.type} not known`); - } - if (Array.isArray(data) || ArrayBuffer.isView(data)) { - if (!data.every((x) => typeof x === "number")) { - // if not all numbers, we just leave it - return data; - } - // else, we convert it to THREE vector/matrix types - if (data.length == 2) { - return new THREE.Vector2().fromArray(data); - } - if (data.length == 3) { - return new THREE.Vector3().fromArray(data); - } - if (data.length == 4) { - return new THREE.Vector4().fromArray(data); - } - if (data.length == 16) { - const mat = new THREE.Matrix4(); - mat.fromArray(data); - return mat; - } - } - // else, leave unchanged - return data; -} - -function deserialize_uniforms(data) { - const result = {}; - // Deno may change constructor names..so... - - for (const name in data) { - const value = data[name]; - // this is already a uniform - happens when we attach additional - // uniforms like the camera matrices in a later stage! - if (value instanceof THREE.Uniform) { - // nothing needs to be converted - result[name] = value; - } else { - const ser = to_uniform(value); - result[name] = new THREE.Uniform(ser); - } - } - return result; -} - -export function deserialize_plot(data) { - if (data.plot_type === "lines") { - return create_line(data); - } - let mesh; - if ("instance_attributes" in data) { - mesh = create_instanced_mesh(data); - } else { - mesh = create_mesh(data); - } - mesh.name = data.name; - mesh.frustumCulled = false; - mesh.matrixAutoUpdate = false; - mesh.plot_uuid = data.uuid; - const update_visible = (v) => { - mesh.visible = v; - // don't return anything, since that will disable on_update callback - return; - }; - update_visible(data.visible.value); - data.visible.on(update_visible); - connect_uniforms(mesh, data.uniform_updater); - connect_attributes(mesh, data.attribute_updater); - return mesh; -} - -const ON_NEXT_INSERT = new Set(); - -export function on_next_insert(f) { - ON_NEXT_INSERT.add(f); -} - -export function add_plot(scene, plot_data) { - // fill in the camera uniforms, that we don't sent in serialization per plot - const cam = scene.wgl_camera; - const identity = new THREE.Uniform(new THREE.Matrix4()); - if (plot_data.cam_space == "data") { - plot_data.uniforms.view = cam.view; - plot_data.uniforms.projection = cam.projection; - plot_data.uniforms.projectionview = cam.projectionview; - plot_data.uniforms.eyeposition = cam.eyeposition; - } else if (plot_data.cam_space == "pixel") { - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = cam.pixel_space; - plot_data.uniforms.projectionview = cam.pixel_space; - } else if (plot_data.cam_space == "relative") { - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = cam.relative_space; - plot_data.uniforms.projectionview = cam.relative_space; - } else { - // clip space - plot_data.uniforms.view = identity; - plot_data.uniforms.projection = identity; - plot_data.uniforms.projectionview = identity; - } - - plot_data.uniforms.resolution = cam.resolution; - - if (plot_data.uniforms.preprojection) { - const { space, markerspace } = plot_data; - plot_data.uniforms.preprojection = cam.preprojection_matrix( - space.value, - markerspace.value - ); - } - const p = deserialize_plot(plot_data); - plot_cache[plot_data.uuid] = p; - scene.add(p); - // execute all next insert callbacks - const next_insert = new Set(ON_NEXT_INSERT); // copy - next_insert.forEach((f) => f()); -} - -function connect_uniforms(mesh, updater) { - updater.on(([name, data]) => { - // this is the initial value, which shouldn't end up getting updated - - // TODO, figure out why this gets pushed!! - if (name === "none") { - return; - } - const uniform = mesh.material.uniforms[name]; - if (uniform.value.isTexture) { - const im_data = uniform.value.image; - const [size, tex_data] = data; - if (tex_data.length == im_data.data.length) { - im_data.data.set(tex_data); - } else { - const old_texture = uniform.value; - uniform.value = re_create_texture(old_texture, tex_data, size); - old_texture.dispose(); - } - uniform.value.needsUpdate = true; - } else { - if (is_three_fixed_array(uniform.value)) { - uniform.value.fromArray(data); - } else { - uniform.value = data; - } - } - }); -} - -function create_texture(data) { - const buffer = data.data; - if (data.size.length == 3) { - const tex = new THREE.DataTexture3D( - buffer, - data.size[0], - data.size[1], - data.size[2] - ); - tex.format = THREE[data.three_format]; - tex.type = THREE[data.three_type]; - return tex; - } else { - // a little optimization to not send the texture atlas over & over again - const tex_data = - buffer == "texture_atlas" ? TEXTURE_ATLAS[0].value : buffer; - return new THREE.DataTexture( - tex_data, - data.size[0], - data.size[1], - THREE[data.three_format], - THREE[data.three_type] - ); - } -} - -function re_create_texture(old_texture, buffer, size) { - if (size.length == 3) { - const tex = new THREE.DataTexture3D(buffer, size[0], size[1], size[2]); - tex.format = old_texture.format; - tex.type = old_texture.type; - return tex; - } else { - return new THREE.DataTexture( - buffer, - size[0], - size[1] ? size[1] : 1, - old_texture.format, - old_texture.type - ); - } -} -function BufferAttribute(buffer) { - const jsbuff = new THREE.BufferAttribute(buffer.flat, buffer.type_length); - jsbuff.setUsage(THREE.DynamicDrawUsage); - return jsbuff; -} - -function InstanceBufferAttribute(buffer) { - const jsbuff = new THREE.InstancedBufferAttribute( - buffer.flat, - buffer.type_length - ); - jsbuff.setUsage(THREE.DynamicDrawUsage); - return jsbuff; -} - -function attach_geometry(buffer_geometry, vertexarrays, faces) { - for (const name in vertexarrays) { - const buff = vertexarrays[name]; - let buffer; - if (buff.to_update) { - buffer = new THREE.BufferAttribute(buff.to_update, buff.itemSize); - } else { - buffer = BufferAttribute(buff); - } - buffer_geometry.setAttribute(name, buffer); - } - buffer_geometry.setIndex(faces); - buffer_geometry.boundingSphere = new THREE.Sphere(); - // don't use intersection / culling - buffer_geometry.boundingSphere.radius = 10000000000000; - buffer_geometry.frustumCulled = false; - return buffer_geometry; -} - -function attach_instanced_geometry(buffer_geometry, instance_attributes) { - for (const name in instance_attributes) { - const buffer = InstanceBufferAttribute(instance_attributes[name]); - buffer_geometry.setAttribute(name, buffer); - } -} - -function recreate_geometry(mesh, vertexarrays, faces) { - const buffer_geometry = new THREE.BufferGeometry(); - attach_geometry(buffer_geometry, vertexarrays, faces); - mesh.geometry.dispose(); - mesh.geometry = buffer_geometry; - mesh.needsUpdate = true; -} - -function recreate_instanced_geometry(mesh) { - const buffer_geometry = new THREE.InstancedBufferGeometry(); - const vertexarrays = {}; - const instance_attributes = {}; - const faces = [...mesh.geometry.index.array]; - Object.keys(mesh.geometry.attributes).forEach((name) => { - const buffer = mesh.geometry.attributes[name]; - // really dont know why copying an array is considered rocket science in JS - const copy = buffer.to_update - ? buffer.to_update - : buffer.array.map((x) => x); - if (buffer.isInstancedBufferAttribute) { - instance_attributes[name] = { - flat: copy, - type_length: buffer.itemSize, - }; - } else { - vertexarrays[name] = { - flat: copy, - type_length: buffer.itemSize, - }; - } - }); - attach_geometry(buffer_geometry, vertexarrays, faces); - attach_instanced_geometry(buffer_geometry, instance_attributes); - mesh.geometry.dispose(); - mesh.geometry = buffer_geometry; - mesh.needsUpdate = true; -} - -function create_material(program) { - const is_volume = "volumedata" in program.uniforms; - return new THREE.RawShaderMaterial({ - uniforms: deserialize_uniforms(program.uniforms), - vertexShader: program.vertex_source, - fragmentShader: program.fragment_source, - side: is_volume ? THREE.BackSide : THREE.DoubleSide, - transparent: true, - depthTest: !program.overdraw.value, - depthWrite: !program.transparency.value, - }); -} - -function create_mesh(program) { - const buffer_geometry = new THREE.BufferGeometry(); - const faces = new THREE.BufferAttribute(program.faces.value, 1); - attach_geometry(buffer_geometry, program.vertexarrays, faces); - const material = create_material(program); - const mesh = new THREE.Mesh(buffer_geometry, material); - program.faces.on((x) => { - mesh.geometry.setIndex(new THREE.BufferAttribute(x, 1)); - }); - return mesh; -} - -function create_instanced_mesh(program) { - const buffer_geometry = new THREE.InstancedBufferGeometry(); - const faces = new THREE.BufferAttribute(program.faces.value, 1); - attach_geometry(buffer_geometry, program.vertexarrays, faces); - attach_instanced_geometry(buffer_geometry, program.instance_attributes); - const material = create_material(program); - const mesh = new THREE.Mesh(buffer_geometry, material); - program.faces.on((x) => { - mesh.geometry.setIndex(new THREE.BufferAttribute(x, 1)); - }); - return mesh; -} - -function first(x) { - return x[Object.keys(x)[0]]; -} - -function connect_attributes(mesh, updater) { - const instance_buffers = {}; - const geometry_buffers = {}; - let first_instance_buffer; - const real_instance_length = [0]; - let first_geometry_buffer; - const real_geometry_length = [0]; - - function re_assign_buffers() { - const attributes = mesh.geometry.attributes; - Object.keys(attributes).forEach((name) => { - const buffer = attributes[name]; - if (buffer.isInstancedBufferAttribute) { - instance_buffers[name] = buffer; - } else { - geometry_buffers[name] = buffer; - } - }); - first_instance_buffer = first(instance_buffers); - // not all meshes have instances! - if (first_instance_buffer) { - real_instance_length[0] = first_instance_buffer.count; - } - first_geometry_buffer = first(geometry_buffers); - real_geometry_length[0] = first_geometry_buffer.count; - } - - re_assign_buffers(); - - updater.on(([name, new_values, length]) => { - const buffer = mesh.geometry.attributes[name]; - let buffers; - let first_buffer; - let real_length; - let is_instance = false; - // First, we need to figure out if this is an instance / geometry buffer - if (name in instance_buffers) { - buffers = instance_buffers; - first_buffer = first_instance_buffer; - real_length = real_instance_length; - is_instance = true; - } else { - buffers = geometry_buffers; - first_buffer = first_geometry_buffer; - real_length = real_geometry_length; - } - if (length <= real_length[0]) { - // this is simple - we can just update the values - buffer.set(new_values); - buffer.needsUpdate = true; - if (is_instance) { - mesh.geometry.instanceCount = length; - } - } else { - // resizing is a bit more complex - // first we directly overwrite the array - this - // won't have any effect, but like this we can collect the - // newly sized arrays untill all of them have the same length - buffer.to_update = new_values; - const all_have_same_length = Object.values(buffers).every( - (x) => x.to_update && x.to_update.length / x.itemSize == length - ); - if (all_have_same_length) { - if (is_instance) { - recreate_instanced_geometry(mesh); - // we just replaced geometry & all buffers, so we need to update these - re_assign_buffers(); - mesh.geometry.instanceCount = - new_values.length / buffer.itemSize; - } else { - recreate_geometry(mesh, buffers, mesh.geometry.index); - re_assign_buffers(); - } - } - } - }); -} - -export function deserialize_scene(data, screen) { - const scene = new THREE.Scene(); - scene.screen = screen; - const { canvas } = screen; - add_scene(data.uuid, scene); - scene.scene_uuid = data.uuid; - scene.frustumCulled = false; - scene.pixelarea = data.pixelarea; - scene.backgroundcolor = data.backgroundcolor; - scene.clearscene = data.clearscene; - scene.visible = data.visible; - - const camera = new Camera.MakieCamera(); - - scene.wgl_camera = camera; - - function update_cam(camera_matrices) { - const [view, projection, resolution, eyepos] = camera_matrices; - camera.update_matrices(view, projection, resolution, eyepos); - } - - update_cam(data.camera.value); - - if (data.cam3d_state) { - Camera.attach_3d_camera(canvas, camera, data.cam3d_state, scene); - } else { - data.camera.on(update_cam); - } - data.plots.forEach((plot_data) => { - add_plot(scene, plot_data); - }); - scene.scene_children = data.children.map((child) => - deserialize_scene(child, screen) - ); - return scene; -} - -export function delete_plot(plot) { - delete plot_cache[plot.plot_uuid]; - const { parent } = plot; - if (parent) { - parent.remove(plot); - } - plot.geometry.dispose(); - plot.material.dispose(); -} - -export function delete_three_scene(scene) { - delete scene_cache[scene.scene_uuid]; - scene.scene_children.forEach(delete_three_scene); - while (scene.children.length > 0) { - delete_plot(scene.children[0]); - } -} - -export { TEXTURE_ATLAS, scene_cache, plot_cache }; diff --git a/WGLMakie/src/THREE.js b/WGLMakie/src/THREE.js new file mode 100644 index 00000000000..9dc2a6d435f --- /dev/null +++ b/WGLMakie/src/THREE.js @@ -0,0 +1,3561 @@ +/* esm.sh - esbuild bundle(three@0.155.0) es2022 production */ +var Fc="155",Ox={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Bx={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nd=0,tl=1,Fd=2,zx=3,kx=0,nd=1,Od=2,pn=3,On=0,De=1,gn=2,Vx=2,Un=0,Wi=1,el=2,nl=3,il=4,Bd=5,Bi=100,zd=101,kd=102,sl=103,rl=104,Vd=200,Hd=201,Gd=202,Wd=203,id=204,sd=205,Xd=206,qd=207,Yd=208,Zd=209,Jd=210,$d=0,Kd=1,Qd=2,ao=3,jd=4,tf=5,ef=6,nf=7,pa=0,sf=1,rf=2,Dn=0,af=1,of=2,cf=3,lf=4,hf=5,Oc=300,Bn=301,ci=302,Ur=303,Dr=304,Hs=306,Nr=1e3,Ce=1001,Fr=1002,fe=1003,oo=1004,Hx=1004,Ir=1005,Gx=1005,pe=1006,rd=1007,Wx=1007,li=1008,Xx=1008,Nn=1009,uf=1010,df=1011,Bc=1012,ad=1013,Pn=1014,xn=1015,Ts=1016,od=1017,cd=1018,ni=1020,ff=1021,He=1023,pf=1024,mf=1025,ii=1026,Yi=1027,gf=1028,ld=1029,_f=1030,hd=1031,ud=1033,Ma=33776,Sa=33777,ba=33778,Ea=33779,al=35840,ol=35841,cl=35842,ll=35843,xf=36196,hl=37492,ul=37496,dl=37808,fl=37809,pl=37810,ml=37811,gl=37812,_l=37813,xl=37814,vl=37815,yl=37816,Ml=37817,Sl=37818,bl=37819,El=37820,Tl=37821,Ta=36492,vf=36283,wl=36284,Al=36285,Rl=36286,yf=2200,Mf=2201,Sf=2202,Or=2300,Br=2301,wa=2302,zi=2400,ki=2401,zr=2402,zc=2500,dd=2501,qx=0,Yx=1,Zx=2,fd=3e3,si=3001,bf=3200,Ef=3201,mi=0,Tf=1,ri="",Nt="srgb",nn="srgb-linear",pd="display-p3",Jx=0,Aa=7680,$x=7681,Kx=7682,Qx=7683,jx=34055,tv=34056,ev=5386,nv=512,iv=513,sv=514,rv=515,av=516,ov=517,cv=518,wf=519,Af=512,Rf=513,Cf=514,Pf=515,Lf=516,If=517,Uf=518,Df=519,kr=35044,lv=35048,hv=35040,uv=35045,dv=35049,fv=35041,pv=35046,mv=35050,gv=35042,_v="100",Cl="300 es",co=1035,vn=2e3,Vr=2001,sn=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){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let i=this._listeners[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let r=0,a=i.length;r>8&255]+Se[s>>16&255]+Se[s>>24&255]+"-"+Se[t&255]+Se[t>>8&255]+"-"+Se[t>>16&15|64]+Se[t>>24&255]+"-"+Se[e&63|128]+Se[e>>8&255]+"-"+Se[e>>16&255]+Se[e>>24&255]+Se[n&255]+Se[n>>8&255]+Se[n>>16&255]+Se[n>>24&255]).toLowerCase()}function ae(s,t,e){return Math.max(t,Math.min(e,s))}function kc(s,t){return(s%t+t)%t}function Nf(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function Ff(s,t,e){return s!==t?(e-s)/(t-s):0}function ys(s,t,e){return(1-e)*s+e*t}function Of(s,t,e,n){return ys(s,t,1-Math.exp(-e*n))}function Bf(s,t=1){return t-Math.abs(kc(s,t*2)-t)}function zf(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function kf(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Vf(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Hf(s,t){return s+Math.random()*(t-s)}function Gf(s){return s*(.5-Math.random())}function Wf(s){s!==void 0&&(Pl=s);let t=Pl+=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 Xf(s){return s*ai}function qf(s){return s*Zi}function lo(s){return(s&s-1)===0&&s!==0}function md(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Hr(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Yf(s,t,e,n,i){let r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),m=a((n-t)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*m,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*m,o*l);break;case"ZYZ":s.set(c*m,c*f,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ue(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Ft(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var xv={DEG2RAD:ai,RAD2DEG:Zi,generateUUID:Be,clamp:ae,euclideanModulo:kc,mapLinear:Nf,inverseLerp:Ff,lerp:ys,damp:Of,pingpong:Bf,smoothstep:zf,smootherstep:kf,randInt:Vf,randFloat:Hf,randFloatSpread:Gf,seededRandom:Wf,degToRad:Xf,radToDeg:qf,isPowerOfTwo:lo,ceilPowerOfTwo:md,floorPowerOfTwo:Hr,setQuaternionFromProperEuler:Yf,normalize:Ft,denormalize:Ue},J=class s{constructor(t=0,e=0){s.prototype.isVector2=!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("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("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,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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(ae(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),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},kt=class s{constructor(t,e,n,i,r,a,o,c,l){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,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,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],x=i[0],g=i[3],p=i[6],v=i[1],_=i[4],y=i[7],b=i[2],w=i[5],R=i[8];return r[0]=a*x+o*v+c*b,r[3]=a*g+o*_+c*w,r[6]=a*p+o*y+c*R,r[1]=l*x+h*v+u*b,r[4]=l*g+h*_+u*w,r[7]=l*p+h*y+u*R,r[2]=d*x+f*v+m*b,r[5]=d*g+f*_+m*w,r[8]=d*p+f*y+m*R,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],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,m=e*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/m;return t[0]=u*x,t[1]=(i*l-h*n)*x,t[2]=(o*n-i*a)*x,t[3]=d*x,t[4]=(h*e-i*c)*x,t[5]=(i*r-o*e)*x,t[6]=f*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,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,i,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Ra.makeScale(t,e)),this}rotate(t){return this.premultiply(Ra.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ra.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 i=0;i<9;i++)if(e[i]!==n[i])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)}},Ra=new kt;function gd(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}var Zf={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Vi(s,t){return new Zf[s](t)}function ws(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}var Ll={};function Ms(s){s in Ll||(Ll[s]=!0,console.warn(s))}function Xi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ca(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var Jf=new kt().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),$f=new kt().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function Kf(s){return s.convertSRGBToLinear().applyMatrix3($f)}function Qf(s){return s.applyMatrix3(Jf).convertLinearToSRGB()}var jf={[nn]:s=>s,[Nt]:s=>s.convertSRGBToLinear(),[pd]:Kf},tp={[nn]:s=>s,[Nt]:s=>s.convertLinearToSRGB(),[pd]:Qf},Ye={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(s){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!s},get workingColorSpace(){return nn},set workingColorSpace(s){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(s,t,e){if(this.enabled===!1||t===e||!t||!e)return s;let n=jf[t],i=tp[e];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${t}" to "${e}".`);return i(n(s))},fromWorkingColorSpace:function(s,t){return this.convert(s,this.workingColorSpace,t)},toWorkingColorSpace:function(s,t){return this.convert(s,t,this.workingColorSpace)}},gi,Gr=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{gi===void 0&&(gi=ws("canvas")),gi.width=t.width,gi.height=t.height;let n=gi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=gi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ws("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Oc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Nr:t.x=t.x-Math.floor(t.x);break;case Ce:t.x=t.x<0?0:1;break;case Fr: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 Nr:t.y=t.y-Math.floor(t.y);break;case Ce:t.y=t.y<0?0:1;break;case Fr: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)}get encoding(){return Ms("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Nt?si:fd}set encoding(t){Ms("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===si?Nt:ri}};ye.DEFAULT_IMAGE=null;ye.DEFAULT_MAPPING=Oc;ye.DEFAULT_ANISOTROPY=1;var $t=class s{constructor(t=0,e=0,n=0,i=1){s.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}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,i){return this.x=t,this.y=e,this.z=n,this.w=i,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("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("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,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,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,i,r,c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],m=c[9],x=c[2],g=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(m+g)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let _=(l+1)/2,y=(f+1)/2,b=(p+1)/2,w=(h+d)/4,R=(u+x)/4,L=(m+g)/4;return _>y&&_>b?_<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(_),i=w/n,r=R/n):y>b?y<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(y),n=w/i,r=L/i):b<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(b),n=R/r,i=L/r),this.set(n,i,r,e),this}let v=Math.sqrt((g-m)*(g-m)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(u-x)/v,this.z=(d-h)/v,this.w=Math.acos((l+f+p-1)/2),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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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}},ho=class extends sn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new $t(0,0,t,e),this.scissorTest=!1,this.viewport=new $t(0,0,t,e);let i={width:t,height:e,depth:1};n.encoding!==void 0&&(Ms("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===si?Nt:ri),this.texture=new ye(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:pe,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,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.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new Ln(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ge=class extends ho{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},As=class extends ye{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=fe,this.minFilter=fe,this.wrapR=Ce,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Il=class extends Ge{constructor(t=1,e=1,n=1){super(t,e),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new As(null,t,e,n),this.texture.isRenderTargetTexture=!0}},Wr=class extends ye{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=fe,this.minFilter=fe,this.wrapR=Ce,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Ul=class extends Ge{constructor(t=1,e=1,n=1){super(t,e),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Wr(null,t,e,n),this.texture.isRenderTargetTexture=!0}},Dl=class extends Ge{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLMultipleRenderTargets=!0;let r=this.texture;this.texture=[];for(let a=0;a=0?1:-1,_=1-p*p;if(_>Number.EPSILON){let b=Math.sqrt(_),w=Math.atan2(b,p*v);g=Math.sin(g*w)/b,o=Math.sin(o*w)/b}let y=o*v;if(c=c*g+d*y,l=l*g+f*y,h=h*g+m*y,u=u*g+x*y,g===1-o){let b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){let o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return t[e]=o*m+h*u+c*f-l*d,t[e+1]=c*m+h*d+l*u-o*f,t[e+2]=l*m+h*f+o*d-c*u,t[e+3]=h*m-o*u-c*d-l*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,i){return this._x=t,this._y=e,this._z=n,this._w=i,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){let n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),m=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"YZX":this._x=d*h*u+l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u-d*f*m;break;case"XZY":this._x=d*h*u-l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){let f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){let f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{let f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.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(ae(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),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,i=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,i=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*i+e*this._y,this._z=f*r+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),u=Math.sin((1-e)*h)/l,d=Math.sin(e*h)/l;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(i),n*Math.sin(r),n*Math.cos(r),e*Math.sin(i))}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}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}},A=class s{constructor(t=0,e=0,n=0){s.prototype.isVector3=!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("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("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(Nl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Nl.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=c*e+a*i-o*n,h=c*n+o*e-r*i,u=c*i+r*n-a*e,d=-r*e-a*n-o*i;return this.x=l*c+d*-r+h*-o-u*-a,this.y=h*c+d*-a+u*-r-l*-o,this.z=u*c+d*-o+l*-a-h*-r,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,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,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 La.copy(this).projectOnVector(t),this.sub(La)}reflect(t){return this.sub(La.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(ae(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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 i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*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(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()-.5)*2,e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},La=new A,Nl=new Pe,Ke=class{constructor(t=new A(1/0,1/0,1/0),e=new A(-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;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,cn),cn.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(cs),Xs.subVectors(this.max,cs),xi.subVectors(t.a,cs),vi.subVectors(t.b,cs),yi.subVectors(t.c,cs),Tn.subVectors(vi,xi),wn.subVectors(yi,vi),Gn.subVectors(xi,yi);let e=[0,-Tn.z,Tn.y,0,-wn.z,wn.y,0,-Gn.z,Gn.y,Tn.z,0,-Tn.x,wn.z,0,-wn.x,Gn.z,0,-Gn.x,-Tn.y,Tn.x,0,-wn.y,wn.x,0,-Gn.y,Gn.x,0];return!Ia(e,xi,vi,yi,Xs)||(e=[1,0,0,0,1,0,0,0,1],!Ia(e,xi,vi,yi,Xs))?!1:(qs.crossVectors(Tn,wn),e=[qs.x,qs.y,qs.z],Ia(e,xi,vi,yi,Xs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,cn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(cn).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:(on[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),on[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),on[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),on[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),on[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),on[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),on[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),on[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(on),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)}},on=[new A,new A,new A,new A,new A,new A,new A,new A],cn=new A,_i=new Ke,xi=new A,vi=new A,yi=new A,Tn=new A,wn=new A,Gn=new A,cs=new A,Xs=new A,qs=new A,Wn=new A;function Ia(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){Wn.fromArray(s,r);let o=i.x*Math.abs(Wn.x)+i.y*Math.abs(Wn.y)+i.z*Math.abs(Wn.z),c=t.dot(Wn),l=e.dot(Wn),h=n.dot(Wn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var ip=new Ke,ls=new A,Ua=new A,We=class{constructor(t=new A,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):ip.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;rthis.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;ls.subVectors(t,this.center);let e=ls.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(ls,i/n),this.radius+=i}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):(Ua.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ls.copy(t.center).add(Ua)),this.expandByPoint(ls.copy(t.center).sub(Ua))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},ln=new A,Da=new A,Ys=new A,An=new A,Na=new A,Zs=new A,Fa=new A,hi=class{constructor(t=new A,e=new A(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,ln)),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=ln.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ln.copy(this.origin).addScaledVector(this.direction,e),ln.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Da.copy(t).add(e).multiplyScalar(.5),Ys.copy(e).sub(t).normalize(),An.copy(this.origin).sub(Da);let r=t.distanceTo(e)*.5,a=-this.direction.dot(Ys),o=An.dot(this.direction),c=-An.dot(Ys),l=An.lengthSq(),h=Math.abs(1-a*a),u,d,f,m;if(h>0)if(u=a*c-o,d=a*o-c,m=r*h,u>=0)if(d>=-m)if(d<=m){let x=1/h;u*=x,d*=x,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=m?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Da).addScaledVector(Ys,d),f}intersectSphere(t,e){ln.subVectors(t.center,this.origin);let n=ln.dot(this.direction),i=ln.dot(ln)-n*n,r=t.radius*t.radius;if(i>r)return null;let a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return 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,i,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,ln)!==null}intersectTriangle(t,e,n,i,r){Na.subVectors(e,t),Zs.subVectors(n,t),Fa.crossVectors(Na,Zs);let a=this.direction.dot(Fa),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;An.subVectors(this.origin,t);let c=o*this.direction.dot(Zs.crossVectors(An,Zs));if(c<0)return null;let l=o*this.direction.dot(Na.cross(An));if(l<0||c+l>a)return null;let h=-o*An.dot(Fa);return h<0?null:this.at(h/a,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)}},Ot=class s{constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,m,x,g){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l,h,u,d,f,m,x,g)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,m,x,g){let p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=x,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new s().fromArray(this.elements)}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],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/Mi.setFromMatrixColumn(t,0).length(),r=1/Mi.setFromMatrixColumn(t,1).length(),a=1/Mi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){let d=a*h,f=a*u,m=o*h,x=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+m*l,e[5]=d-x*l,e[9]=-o*c,e[2]=x-d*l,e[6]=m+f*l,e[10]=a*c}else if(t.order==="YXZ"){let d=c*h,f=c*u,m=l*h,x=l*u;e[0]=d+x*o,e[4]=m*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=x+d*o,e[10]=a*c}else if(t.order==="ZXY"){let d=c*h,f=c*u,m=l*h,x=l*u;e[0]=d-x*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let d=a*h,f=a*u,m=o*h,x=o*u;e[0]=c*h,e[4]=m*l-f,e[8]=d*l+x,e[1]=c*u,e[5]=x*l+d,e[9]=f*l-m,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let d=a*c,f=a*l,m=o*c,x=o*l;e[0]=c*h,e[4]=x-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+m,e[10]=d-x*u}else if(t.order==="XZY"){let d=a*c,f=a*l,m=o*c,x=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+x,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(sp,t,rp)}lookAt(t,e,n){let i=this.elements;return Fe.subVectors(t,e),Fe.lengthSq()===0&&(Fe.z=1),Fe.normalize(),Rn.crossVectors(n,Fe),Rn.lengthSq()===0&&(Math.abs(n.z)===1?Fe.x+=1e-4:Fe.z+=1e-4,Fe.normalize(),Rn.crossVectors(n,Fe)),Rn.normalize(),Js.crossVectors(Fe,Rn),i[0]=Rn.x,i[4]=Js.x,i[8]=Fe.x,i[1]=Rn.y,i[5]=Js.y,i[9]=Fe.y,i[2]=Rn.z,i[6]=Js.z,i[10]=Fe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],x=n[6],g=n[10],p=n[14],v=n[3],_=n[7],y=n[11],b=n[15],w=i[0],R=i[4],L=i[8],M=i[12],E=i[1],V=i[5],$=i[9],F=i[13],O=i[2],z=i[6],K=i[10],X=i[14],Y=i[3],j=i[7],tt=i[11],N=i[15];return r[0]=a*w+o*E+c*O+l*Y,r[4]=a*R+o*V+c*z+l*j,r[8]=a*L+o*$+c*K+l*tt,r[12]=a*M+o*F+c*X+l*N,r[1]=h*w+u*E+d*O+f*Y,r[5]=h*R+u*V+d*z+f*j,r[9]=h*L+u*$+d*K+f*tt,r[13]=h*M+u*F+d*X+f*N,r[2]=m*w+x*E+g*O+p*Y,r[6]=m*R+x*V+g*z+p*j,r[10]=m*L+x*$+g*K+p*tt,r[14]=m*M+x*F+g*X+p*N,r[3]=v*w+_*E+y*O+b*Y,r[7]=v*R+_*V+y*z+b*j,r[11]=v*L+_*$+y*K+b*tt,r[15]=v*M+_*F+y*X+b*N,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],x=t[7],g=t[11],p=t[15];return m*(+r*c*u-i*l*u-r*o*d+n*l*d+i*o*f-n*c*f)+x*(+e*c*f-e*l*d+r*a*d-i*a*f+i*l*h-r*c*h)+g*(+e*l*u-e*o*f-r*a*u+n*a*f+r*o*h-n*l*h)+p*(-i*o*h-e*c*u+e*o*d+i*a*u-n*a*d+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],x=t[13],g=t[14],p=t[15],v=u*g*l-x*d*l+x*c*f-o*g*f-u*c*p+o*d*p,_=m*d*l-h*g*l-m*c*f+a*g*f+h*c*p-a*d*p,y=h*x*l-m*u*l+m*o*f-a*x*f-h*o*p+a*u*p,b=m*u*c-h*x*c-m*o*d+a*x*d+h*o*g-a*u*g,w=e*v+n*_+i*y+r*b;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/w;return t[0]=v*R,t[1]=(x*d*r-u*g*r-x*i*f+n*g*f+u*i*p-n*d*p)*R,t[2]=(o*g*r-x*c*r+x*i*l-n*g*l-o*i*p+n*c*p)*R,t[3]=(u*c*r-o*d*r-u*i*l+n*d*l+o*i*f-n*c*f)*R,t[4]=_*R,t[5]=(h*g*r-m*d*r+m*i*f-e*g*f-h*i*p+e*d*p)*R,t[6]=(m*c*r-a*g*r-m*i*l+e*g*l+a*i*p-e*c*p)*R,t[7]=(a*d*r-h*c*r+h*i*l-e*d*l-a*i*f+e*c*f)*R,t[8]=y*R,t[9]=(m*u*r-h*x*r-m*n*f+e*x*f+h*n*p-e*u*p)*R,t[10]=(a*x*r-m*o*r+m*n*l-e*x*l-a*n*p+e*o*p)*R,t[11]=(h*o*r-a*u*r-h*n*l+e*u*l+a*n*f-e*o*f)*R,t[12]=b*R,t[13]=(h*x*i-m*u*i+m*n*d-e*x*d-h*n*g+e*u*g)*R,t[14]=(m*o*i-a*x*i-m*n*c+e*x*c+a*n*g-e*o*g)*R,t[15]=(a*u*i-h*o*i+h*n*c-e*u*c-a*n*d+e*o*d)*R,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,m=r*u,x=a*h,g=a*u,p=o*u,v=c*l,_=c*h,y=c*u,b=n.x,w=n.y,R=n.z;return i[0]=(1-(x+p))*b,i[1]=(f+y)*b,i[2]=(m-_)*b,i[3]=0,i[4]=(f-y)*w,i[5]=(1-(d+p))*w,i[6]=(g+v)*w,i[7]=0,i[8]=(m+_)*R,i[9]=(g-v)*R,i[10]=(1-(d+x))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=Mi.set(i[0],i[1],i[2]).length(),a=Mi.set(i[4],i[5],i[6]).length(),o=Mi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],Ze.copy(this);let l=1/r,h=1/a,u=1/o;return Ze.elements[0]*=l,Ze.elements[1]*=l,Ze.elements[2]*=l,Ze.elements[4]*=h,Ze.elements[5]*=h,Ze.elements[6]*=h,Ze.elements[8]*=u,Ze.elements[9]*=u,Ze.elements[10]*=u,e.setFromRotationMatrix(Ze),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,r,a,o=vn){let c=this.elements,l=2*r/(e-t),h=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i),f,m;if(o===vn)f=-(a+r)/(a-r),m=-2*a*r/(a-r);else if(o===Vr)f=-a/(a-r),m=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=vn){let c=this.elements,l=1/(e-t),h=1/(n-i),u=1/(a-r),d=(e+t)*l,f=(n+i)*h,m,x;if(o===vn)m=(a+r)*u,x=-2*u;else if(o===Vr)m=r*u,x=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=x,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;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[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Mi=new A,Ze=new Ot,sp=new A(0,0,0),rp=new A(1,1,1),Rn=new A,Js=new A,Fe=new A,Fl=new Ot,Ol=new Pe,Xr=class s{constructor(t=0,e=0,n=0,i=s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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 order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(ae(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ae(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ae(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-ae(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ae(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-ae(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Fl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Fl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ol.setFromEuler(this),this.setFromQuaternion(Ol,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[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._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Xr.DEFAULT_ORDER="XYZ";var Rs=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(n=n.concat(a))}return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,t,op),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hs,cp,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}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.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Je.subVectors(i,e),un.subVectors(n,e),Oa.subVectors(t,e);let a=Je.dot(Je),o=Je.dot(un),c=Je.dot(Oa),l=un.dot(un),h=un.dot(Oa),u=a*l-o*o;if(u===0)return r.set(-2,-1,-1);let d=1/u,f=(l*c-o*h)*d,m=(a*h-o*c)*d;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,dn),dn.x>=0&&dn.y>=0&&dn.x+dn.y<=1}static getUV(t,e,n,i,r,a,o,c){return Ks===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ks=!0),this.getInterpolation(t,e,n,i,r,a,o,c)}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,dn),c.setScalar(0),c.addScaledVector(r,dn.x),c.addScaledVector(a,dn.y),c.addScaledVector(o,dn.z),c}static isFrontFacing(t,e,n,i){return Je.subVectors(n,e),un.subVectors(t,e),Je.cross(un).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 Je.subVectors(this.c,this.b),un.subVectors(this.a,this.b),Je.cross(un).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return s.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,i,r){return Ks===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Ks=!0),s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}getInterpolation(t,e,n,i,r){return s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,a,o;bi.subVectors(i,n),Ei.subVectors(r,n),Ba.subVectors(t,n);let c=bi.dot(Ba),l=Ei.dot(Ba);if(c<=0&&l<=0)return e.copy(n);za.subVectors(t,i);let h=bi.dot(za),u=Ei.dot(za);if(h>=0&&u<=h)return e.copy(i);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(bi,a);ka.subVectors(t,r);let f=bi.dot(ka),m=Ei.dot(ka);if(m>=0&&f<=m)return e.copy(r);let x=f*l-c*m;if(x<=0&&l>=0&&m<=0)return o=l/(l-m),e.copy(n).addScaledVector(Ei,o);let g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return Gl.subVectors(r,i),o=(u-h)/(u-h+(f-m)),e.copy(i).addScaledVector(Gl,o);let p=1/(g+x+d);return a=x*p,o=d*p,e.copy(n).addScaledVector(bi,a).addScaledVector(Ei,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},hp=0,Me=class extends sn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hp++}),this.uuid=Be(),this.name="",this.type="Material",this.blending=Wi,this.side=On,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=id,this.blendDst=sd,this.blendEquation=Bi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=ao,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Aa,this.stencilZFail=Aa,this.stencilZPass=Aa,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.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}onBuild(){}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){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(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&&this.emissiveIntensity!==1&&(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.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.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&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Wi&&(n.blending=this.blending),this.side!==On&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,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,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),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.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}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.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 i=e.length;n=new Array(i);for(let r=0;r!==i;++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.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++}},_d={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},$e={h:0,s:0,l:0},Qs={h:0,s:0,l:0};function Va(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}var ft=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 i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Nt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Ye.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Ye.workingColorSpace){return this.r=t,this.g=e,this.b=n,Ye.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Ye.workingColorSpace){if(t=kc(t,1),e=ae(e,0,1),n=ae(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Va(a,r,t+1/3),this.g=Va(a,r,t),this.b=Va(a,r,t-1/3)}return Ye.toWorkingColorSpace(this,i),this}setStyle(t,e=Nt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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(o))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(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Nt){let n=_d[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.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=Xi(t.r),this.g=Xi(t.g),this.b=Xi(t.b),this}copyLinearToSRGB(t){return this.r=Ca(t.r),this.g=Ca(t.g),this.b=Ca(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Nt){return Ye.fromWorkingColorSpace(be.copy(this),t),Math.round(ae(be.r*255,0,255))*65536+Math.round(ae(be.g*255,0,255))*256+Math.round(ae(be.b*255,0,255))}getHexString(t=Nt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ye.workingColorSpace){Ye.fromWorkingColorSpace(be.copy(this),e);let n=be.r,i=be.g,r=be.b,a=Math.max(n,i,r),o=Math.min(n,i,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}let r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;!(l&8388608);)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Ie(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=ae(s,-65504,65504),_n.floatView[0]=s;let t=_n.uint32View[0],e=t>>23&511;return _n.baseTable[e]+((t&8388607)>>_n.shiftTable[e])}function xs(s){let t=s>>10;return _n.uint32View[0]=_n.mantissaTable[_n.offsetTable[t]+(s&1023)]+_n.exponentTable[t],_n.floatView[0]}var vv={toHalfFloat:Ie,fromHalfFloat:xs},de=new A,js=new J,Kt=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=kr,this.updateRange={offset:0,count:-1},this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}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 i=0,r=this.itemSize;i0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);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 c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),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(e));let i=t.attributes;for(let l in i){let h=i[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],u=r[l];for(let d=0,f=u.length;d0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r(t.far-t.near)**2))&&(Kl.copy(r).invert(),Xn.copy(t.ray).applyMatrix4(Kl),!(n.boundingBox!==null&&Xn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Xn)))}_computeIntersections(t,e,n){let i,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,x=d.length;me.far?null:{distance:l,point:ar.clone(),object:s}}function or(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,wi),s.getVertexPosition(c,Ai),s.getVertexPosition(l,Ri);let h=fp(s,t,e,n,wi,Ai,Ri,rr);if(h){i&&(nr.fromBufferAttribute(i,o),ir.fromBufferAttribute(i,c),sr.fromBufferAttribute(i,l),h.uv=In.getInterpolation(rr,wi,Ai,Ri,nr,ir,sr,new J)),r&&(nr.fromBufferAttribute(r,o),ir.fromBufferAttribute(r,c),sr.fromBufferAttribute(r,l),h.uv1=In.getInterpolation(rr,wi,Ai,Ri,nr,ir,sr,new J),h.uv2=h.uv1),a&&(jl.fromBufferAttribute(a,o),th.fromBufferAttribute(a,c),eh.fromBufferAttribute(a,l),h.normal=In.getInterpolation(rr,wi,Ai,Ri,jl,th,eh,new A),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new A,materialIndex:0};In.getNormal(wi,Ai,Ri,u.normal),h.face=u}return h}var Ji=class s extends Vt{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],u=[],d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,r,0),m("z","y","x",1,-1,n,e,-t,a,r,1),m("x","z","y",1,1,t,n,e,i,a,2),m("x","z","y",1,-1,t,n,-e,i,a,3),m("x","y","z",1,-1,t,e,n,i,r,4),m("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new _t(l,3)),this.setAttribute("normal",new _t(h,3)),this.setAttribute("uv",new _t(u,2));function m(x,g,p,v,_,y,b,w,R,L,M){let E=y/R,V=b/L,$=y/2,F=b/2,O=w/2,z=R+1,K=L+1,X=0,Y=0,j=new A;for(let tt=0;tt0?1:-1,h.push(j.x,j.y,j.z),u.push(q/R),u.push(1-tt/L),X+=1}}for(let tt=0;tt0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Cs=class extends Zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ot,this.projectionMatrix=new Ot,this.projectionMatrixInverse=new Ot,this.coordinateSystem=vn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},xe=class extends Cs{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Zi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(ai*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Zi*2*Math.atan(Math.tan(ai*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(ai*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},Ci=-90,Pi=1,uo=class extends Zt{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let i=new xe(Ci,Pi,t,e);i.layers=this.layers,this.add(i);let r=new xe(Ci,Pi,t,e);r.layers=this.layers,this.add(r);let a=new xe(Ci,Pi,t,e);a.layers=this.layers,this.add(a);let o=new xe(Ci,Pi,t,e);o.layers=this.layers,this.add(o);let c=new xe(Ci,Pi,t,e);c.layers=this.layers,this.add(c);let l=new xe(Ci,Pi,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===vn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Vr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[i,r,a,o,c,l]=this.children,h=t.getRenderTarget(),u=t.xr.enabled;t.xr.enabled=!1;let d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,i),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,c),n.texture.generateMipmaps=d,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.xr.enabled=u,n.texture.needsPMREMUpdate=!0}},Ki=class extends ye{constructor(t,e,n,i,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:Bn,super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},fo=class extends Ge{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];e.encoding!==void 0&&(Ms("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===si?Nt:ri),this.texture=new Ki(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:pe}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; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new Ji(5,5,5),r=new Qe({name:"CubemapFromEquirect",uniforms:$i(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:De,blending:Un});r.uniforms.tEquirect.value=e;let a=new ve(i,r),o=e.minFilter;return e.minFilter===li&&(e.minFilter=pe),new uo(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}},Wa=new A,xp=new A,vp=new kt,mn=class{constructor(t=new A(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=Wa.subVectors(n,e).cross(xp.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Wa),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}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||vp.getNormalMatrix(t),i=this.coplanarPoint(Wa).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}},qn=new We,cr=new A,Ps=class{constructor(t=new mn,e=new mn,n=new mn,i=new mn,r=new mn,a=new mn){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=vn){let n=this.planes,i=t.elements,r=i[0],a=i[1],o=i[2],c=i[3],l=i[4],h=i[5],u=i[6],d=i[7],f=i[8],m=i[9],x=i[10],g=i[11],p=i[12],v=i[13],_=i[14],y=i[15];if(n[0].setComponents(c-r,d-l,g-f,y-p).normalize(),n[1].setComponents(c+r,d+l,g+f,y+p).normalize(),n[2].setComponents(c+a,d+h,g+m,y+v).normalize(),n[3].setComponents(c-a,d-h,g-m,y-v).normalize(),n[4].setComponents(c-o,d-u,g-x,y-_).normalize(),e===vn)n[5].setComponents(c+o,d+u,g+x,y+_).normalize();else if(e===Vr)n[5].setComponents(o,u,x,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),qn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),qn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(qn)}intersectsSprite(t){return qn.center.set(0,0,0),qn.radius=.7071067811865476,qn.applyMatrix4(t.matrixWorld),this.intersectsSphere(qn)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,cr.y=i.normal.y>0?t.max.y:t.min.y,cr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(cr)<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)}};function vd(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function yp(s,t){let e=t.isWebGL2,n=new WeakMap;function i(l,h){let u=l.array,d=l.usage,f=s.createBuffer();s.bindBuffer(h,f),s.bufferData(h,u,d),l.onUploadCallback();let m;if(u instanceof Float32Array)m=s.FLOAT;else if(u instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(e)m=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=s.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=s.SHORT;else if(u instanceof Uint32Array)m=s.UNSIGNED_INT;else if(u instanceof Int32Array)m=s.INT;else if(u instanceof Int8Array)m=s.BYTE;else if(u instanceof Uint8Array)m=s.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,u){let d=h.array,f=h.updateRange;s.bindBuffer(u,l),f.count===-1?s.bufferSubData(u,0,d):(e?s.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):s.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),h.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);let h=n.get(l);h&&(s.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){let d=n.get(l);(!d||d.version 0 + vec4 plane; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif +#endif`,Np=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,Fp=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,Op=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,Bp=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,zp=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,kp=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,Vp=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`,Hp=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +struct GeometricContext { + vec3 position; + vec3 normal; + vec3 viewDir; +#ifdef USE_CLEARCOAT + vec3 clearcoatNormal; +#endif +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,Gp=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_v0 0.339 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_v1 0.276 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_v4 0.046 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_v5 0.016 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_v6 0.0038 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Wp=`vec3 transformedNormal = objectNormal; +#ifdef USE_INSTANCING + mat3 m = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); + transformedNormal = m * transformedNormal; +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,Xp=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,qp=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Yp=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Zp=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Jp="gl_FragColor = linearToOutputTexel( gl_FragColor );",$p=`vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( 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 ); +}`,Kp=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,Qp=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,jp=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,tm=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,em=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,nm=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,im=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,sm=`#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`,rm=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,am=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,om=`#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`,cm=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lm=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,hm=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,um=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +uniform vec3 lightProbe[ 9 ]; +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometry.position; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometry.position; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,dm=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,fm=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,pm=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,mm=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,gm=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_m=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y; +#endif`,xm=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecular = vec3( 0.0 ); +vec3 sheenSpecular = vec3( 0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometry.normal; + vec3 viewDir = geometry.viewDir; + vec3 position = geometry.position; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,vm=` +GeometricContext geometry; +geometry.position = - vViewPosition; +geometry.normal = normal; +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +#ifdef USE_CLEARCOAT + geometry.clearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometry.viewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometry, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,ym=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometry.normal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,Mm=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); +#endif`,Sm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,bm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Em=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`,Tm=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + #else + if ( isPerspectiveMatrix( projectionMatrix ) ) { + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + gl_Position.z *= gl_Position.w; + } + #endif +#endif`,wm=`#ifdef USE_MAP + diffuseColor *= texture2D( map, vMapUv ); +#endif`,Am=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,Rm=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,Cm=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,Pm=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,Lm=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,Im=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,Um=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`,Dm=`#ifdef USE_MORPHTARGETS + uniform float morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`,Nm=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`,Fm=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 geometryNormal = normal;`,Om=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,Bm=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,zm=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,km=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Vm=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Hm=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = geometryNormal; +#endif`,Gm=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Wm=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Xm=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,qm=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ym=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,Zm=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Jm=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,$m=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Km=`#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`,Qm=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,jm=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,tg=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + vec3 lightToPosition = shadowCoord.xyz; + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } +#endif`,eg=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,ng=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,ig=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,sg=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,rg=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + mat4 getBoneMatrix( const in float i ) { + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + y = dy * ( y + 0.5 ); + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + mat4 bone = mat4( v1, v2, v3, v4 ); + return bone; + } +#endif`,ag=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,og=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,cg=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,lg=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,hg=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,ug=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,dg=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,fg=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,pg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,mg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,gg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,_g=`#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_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,xg=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,vg=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,yg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Mg=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Sg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,bg=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,Eg=`#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,Tg=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + vec4 diffuseColor = vec4( 1.0 ); + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,wg=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,Ag=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + #include + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,Rg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,Cg=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,Pg=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Lg=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Ig=`#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Ug=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,Dg=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Ng=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Fg=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,Og=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,Bg=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,zg=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,kg=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Vg=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Hg=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Gg=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Wg=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Xg=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,qg=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Yg=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Zg=`#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Jg=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,$g=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Kg=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,zt={alphahash_fragment:Mp,alphahash_pars_fragment:Sp,alphamap_fragment:bp,alphamap_pars_fragment:Ep,alphatest_fragment:Tp,alphatest_pars_fragment:wp,aomap_fragment:Ap,aomap_pars_fragment:Rp,begin_vertex:Cp,beginnormal_vertex:Pp,bsdfs:Lp,iridescence_fragment:Ip,bumpmap_pars_fragment:Up,clipping_planes_fragment:Dp,clipping_planes_pars_fragment:Np,clipping_planes_pars_vertex:Fp,clipping_planes_vertex:Op,color_fragment:Bp,color_pars_fragment:zp,color_pars_vertex:kp,color_vertex:Vp,common:Hp,cube_uv_reflection_fragment:Gp,defaultnormal_vertex:Wp,displacementmap_pars_vertex:Xp,displacementmap_vertex:qp,emissivemap_fragment:Yp,emissivemap_pars_fragment:Zp,colorspace_fragment:Jp,colorspace_pars_fragment:$p,envmap_fragment:Kp,envmap_common_pars_fragment:Qp,envmap_pars_fragment:jp,envmap_pars_vertex:tm,envmap_physical_pars_fragment:dm,envmap_vertex:em,fog_vertex:nm,fog_pars_vertex:im,fog_fragment:sm,fog_pars_fragment:rm,gradientmap_pars_fragment:am,lightmap_fragment:om,lightmap_pars_fragment:cm,lights_lambert_fragment:lm,lights_lambert_pars_fragment:hm,lights_pars_begin:um,lights_toon_fragment:fm,lights_toon_pars_fragment:pm,lights_phong_fragment:mm,lights_phong_pars_fragment:gm,lights_physical_fragment:_m,lights_physical_pars_fragment:xm,lights_fragment_begin:vm,lights_fragment_maps:ym,lights_fragment_end:Mm,logdepthbuf_fragment:Sm,logdepthbuf_pars_fragment:bm,logdepthbuf_pars_vertex:Em,logdepthbuf_vertex:Tm,map_fragment:wm,map_pars_fragment:Am,map_particle_fragment:Rm,map_particle_pars_fragment:Cm,metalnessmap_fragment:Pm,metalnessmap_pars_fragment:Lm,morphcolor_vertex:Im,morphnormal_vertex:Um,morphtarget_pars_vertex:Dm,morphtarget_vertex:Nm,normal_fragment_begin:Fm,normal_fragment_maps:Om,normal_pars_fragment:Bm,normal_pars_vertex:zm,normal_vertex:km,normalmap_pars_fragment:Vm,clearcoat_normal_fragment_begin:Hm,clearcoat_normal_fragment_maps:Gm,clearcoat_pars_fragment:Wm,iridescence_pars_fragment:Xm,opaque_fragment:qm,packing:Ym,premultiplied_alpha_fragment:Zm,project_vertex:Jm,dithering_fragment:$m,dithering_pars_fragment:Km,roughnessmap_fragment:Qm,roughnessmap_pars_fragment:jm,shadowmap_pars_fragment:tg,shadowmap_pars_vertex:eg,shadowmap_vertex:ng,shadowmask_pars_fragment:ig,skinbase_vertex:sg,skinning_pars_vertex:rg,skinning_vertex:ag,skinnormal_vertex:og,specularmap_fragment:cg,specularmap_pars_fragment:lg,tonemapping_fragment:hg,tonemapping_pars_fragment:ug,transmission_fragment:dg,transmission_pars_fragment:fg,uv_pars_fragment:pg,uv_pars_vertex:mg,uv_vertex:gg,worldpos_vertex:_g,background_vert:xg,background_frag:vg,backgroundCube_vert:yg,backgroundCube_frag:Mg,cube_vert:Sg,cube_frag:bg,depth_vert:Eg,depth_frag:Tg,distanceRGBA_vert:wg,distanceRGBA_frag:Ag,equirect_vert:Rg,equirect_frag:Cg,linedashed_vert:Pg,linedashed_frag:Lg,meshbasic_vert:Ig,meshbasic_frag:Ug,meshlambert_vert:Dg,meshlambert_frag:Ng,meshmatcap_vert:Fg,meshmatcap_frag:Og,meshnormal_vert:Bg,meshnormal_frag:zg,meshphong_vert:kg,meshphong_frag:Vg,meshphysical_vert:Hg,meshphysical_frag:Gg,meshtoon_vert:Wg,meshtoon_frag:Xg,points_vert:qg,points_frag:Yg,shadow_vert:Zg,shadow_frag:Jg,sprite_vert:$g,sprite_frag:Kg},ct={common:{diffuse:{value:new ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new kt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new kt},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0},uvTransform:{value:new kt}},sprite:{diffuse:{value:new ft(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}}},en={basic:{uniforms:Re([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.fog]),vertexShader:zt.meshbasic_vert,fragmentShader:zt.meshbasic_frag},lambert:{uniforms:Re([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new ft(0)}}]),vertexShader:zt.meshlambert_vert,fragmentShader:zt.meshlambert_frag},phong:{uniforms:Re([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new ft(0)},specular:{value:new ft(1118481)},shininess:{value:30}}]),vertexShader:zt.meshphong_vert,fragmentShader:zt.meshphong_frag},standard:{uniforms:Re([ct.common,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.roughnessmap,ct.metalnessmap,ct.fog,ct.lights,{emissive:{value:new ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag},toon:{uniforms:Re([ct.common,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.gradientmap,ct.fog,ct.lights,{emissive:{value:new ft(0)}}]),vertexShader:zt.meshtoon_vert,fragmentShader:zt.meshtoon_frag},matcap:{uniforms:Re([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,{matcap:{value:null}}]),vertexShader:zt.meshmatcap_vert,fragmentShader:zt.meshmatcap_frag},points:{uniforms:Re([ct.points,ct.fog]),vertexShader:zt.points_vert,fragmentShader:zt.points_frag},dashed:{uniforms:Re([ct.common,ct.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zt.linedashed_vert,fragmentShader:zt.linedashed_frag},depth:{uniforms:Re([ct.common,ct.displacementmap]),vertexShader:zt.depth_vert,fragmentShader:zt.depth_frag},normal:{uniforms:Re([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,{opacity:{value:1}}]),vertexShader:zt.meshnormal_vert,fragmentShader:zt.meshnormal_frag},sprite:{uniforms:Re([ct.sprite,ct.fog]),vertexShader:zt.sprite_vert,fragmentShader:zt.sprite_frag},background:{uniforms:{uvTransform:{value:new kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zt.background_vert,fragmentShader:zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:zt.backgroundCube_vert,fragmentShader:zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zt.cube_vert,fragmentShader:zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zt.equirect_vert,fragmentShader:zt.equirect_frag},distanceRGBA:{uniforms:Re([ct.common,ct.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zt.distanceRGBA_vert,fragmentShader:zt.distanceRGBA_frag},shadow:{uniforms:Re([ct.lights,ct.fog,{color:{value:new ft(0)},opacity:{value:1}}]),vertexShader:zt.shadow_vert,fragmentShader:zt.shadow_frag}};en.physical={uniforms:Re([en.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new kt},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new kt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new kt},sheen:{value:0},sheenColor:{value:new ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new kt},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new kt},attenuationDistance:{value:0},attenuationColor:{value:new ft(0)},specularColor:{value:new ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new kt},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new kt}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag};var lr={r:0,b:0,g:0};function Qg(s,t,e,n,i,r,a){let o=new ft(0),c=r===!0?0:1,l,h,u=null,d=0,f=null;function m(g,p){let v=!1,_=p.isScene===!0?p.background:null;switch(_&&_.isTexture&&(_=(p.backgroundBlurriness>0?e:t).get(_)),_===null?x(o,c):_&&_.isColor&&(x(_,1),v=!0),s.xr.getEnvironmentBlendMode()){case"opaque":v=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),v=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),v=!0;break}(s.autoClear||v)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),_&&(_.isCubeTexture||_.mapping===Hs)?(h===void 0&&(h=new ve(new Ji(1,1,1),new Qe({name:"BackgroundCubeMaterial",uniforms:$i(en.backgroundCube.uniforms),vertexShader:en.backgroundCube.vertexShader,fragmentShader:en.backgroundCube.fragmentShader,side:De,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,R,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,h.material.toneMapped=_.colorSpace!==Nt,(u!==_||d!==_.version||f!==s.toneMapping)&&(h.material.needsUpdate=!0,u=_,d=_.version,f=s.toneMapping),h.layers.enableAll(),g.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new ve(new Zr(2,2),new Qe({name:"BackgroundMaterial",uniforms:$i(en.background.uniforms),vertexShader:en.background.vertexShader,fragmentShader:en.background.fragmentShader,side:On,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Nt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(u!==_||d!==_.version||f!==s.toneMapping)&&(l.material.needsUpdate=!0,u=_,d=_.version,f=s.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function x(g,p){g.getRGB(lr,xd(s)),n.buffers.color.setClear(lr.r,lr.g,lr.b,p,a)}return{getClearColor:function(){return o},setClearColor:function(g,p=1){o.set(g),c=p,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,x(o,c)},render:m}}function jg(s,t,e,n){let i=s.getParameter(s.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||r!==null,o={},c=g(null),l=c,h=!1;function u(O,z,K,X,Y){let j=!1;if(a){let tt=x(X,K,z);l!==tt&&(l=tt,f(l.object)),j=p(O,X,K,Y),j&&v(O,X,K,Y)}else{let tt=z.wireframe===!0;(l.geometry!==X.id||l.program!==K.id||l.wireframe!==tt)&&(l.geometry=X.id,l.program=K.id,l.wireframe=tt,j=!0)}Y!==null&&e.update(Y,s.ELEMENT_ARRAY_BUFFER),(j||h)&&(h=!1,L(O,z,K,X),Y!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function d(){return n.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}function f(O){return n.isWebGL2?s.bindVertexArray(O):r.bindVertexArrayOES(O)}function m(O){return n.isWebGL2?s.deleteVertexArray(O):r.deleteVertexArrayOES(O)}function x(O,z,K){let X=K.wireframe===!0,Y=o[O.id];Y===void 0&&(Y={},o[O.id]=Y);let j=Y[z.id];j===void 0&&(j={},Y[z.id]=j);let tt=j[X];return tt===void 0&&(tt=g(d()),j[X]=tt),tt}function g(O){let z=[],K=[],X=[];for(let Y=0;Y=0){let ut=Y[q],pt=j[q];if(pt===void 0&&(q==="instanceMatrix"&&O.instanceMatrix&&(pt=O.instanceMatrix),q==="instanceColor"&&O.instanceColor&&(pt=O.instanceColor)),ut===void 0||ut.attribute!==pt||pt&&ut.data!==pt.data)return!0;tt++}return l.attributesNum!==tt||l.index!==X}function v(O,z,K,X){let Y={},j=z.attributes,tt=0,N=K.getAttributes();for(let q in N)if(N[q].location>=0){let ut=j[q];ut===void 0&&(q==="instanceMatrix"&&O.instanceMatrix&&(ut=O.instanceMatrix),q==="instanceColor"&&O.instanceColor&&(ut=O.instanceColor));let pt={};pt.attribute=ut,ut&&ut.data&&(pt.data=ut.data),Y[q]=pt,tt++}l.attributes=Y,l.attributesNum=tt,l.index=X}function _(){let O=l.newAttributes;for(let z=0,K=O.length;z=0){let lt=Y[N];if(lt===void 0&&(N==="instanceMatrix"&&O.instanceMatrix&&(lt=O.instanceMatrix),N==="instanceColor"&&O.instanceColor&&(lt=O.instanceColor)),lt!==void 0){let ut=lt.normalized,pt=lt.itemSize,Et=e.get(lt);if(Et===void 0)continue;let Tt=Et.buffer,wt=Et.type,Yt=Et.bytesPerElement,te=n.isWebGL2===!0&&(wt===s.INT||wt===s.UNSIGNED_INT||lt.gpuType===ad);if(lt.isInterleavedBufferAttribute){let Pt=lt.data,P=Pt.stride,at=lt.offset;if(Pt.isInstancedInterleavedBuffer){for(let Z=0;Z0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext",o=e.precision!==void 0?e.precision:"highp",c=r(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);let l=a||t.has("WEBGL_draw_buffers"),h=e.logarithmicDepthBuffer===!0,u=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),d=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),x=s.getParameter(s.MAX_VERTEX_ATTRIBS),g=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),p=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),_=d>0,y=a||t.has("OES_texture_float"),b=_&&y,w=a?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:x,maxVertexUniforms:g,maxVaryings:p,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:w}}function n_(s){let t=this,e=null,n=0,i=!1,r=!1,a=new mn,o=new kt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){let m=u.clippingPlanes,x=u.clipIntersection,g=u.clipShadows,p=s.get(u);if(!i||m===null||m.length===0||r&&!g)r?h(null):l();else{let v=r?0:n,_=v*4,y=p.clippingState||null;c.value=y,y=h(m,d,_,f);for(let b=0;b!==_;++b)y[b]=e[b];p.clippingState=y,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){let x=u!==null?u.length:0,g=null;if(x!==0){if(g=c.value,m!==!0||g===null){let p=f+x*4,v=d.matrixWorldInverse;o.getNormalMatrix(v),(g===null||g.length0){let l=new fo(c.height/2);return l.fromEquirectangularTexture(s,a),t.set(a,l),a.addEventListener("dispose",i),e(l.texture,a.mapping)}else return null}}return a}function i(a){let o=a.target;o.removeEventListener("dispose",i);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var Ls=class extends Cs{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,a=n+t,o=i+e,c=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},Hi=4,nh=[.125,.215,.35,.446,.526,.582],jn=20,Xa=new Ls,ih=new ft,qa=null,Qn=(1+Math.sqrt(5))/2,Li=1/Qn,sh=[new A(1,1,1),new A(-1,1,1),new A(1,1,-1),new A(-1,1,-1),new A(0,Qn,Li),new A(0,Qn,-Li),new A(Li,0,Qn),new A(-Li,0,Qn),new A(Qn,Li,0),new A(-Qn,Li,0)],Jr=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){qa=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=oh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ah(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?_:0,_,_),h.setRenderTarget(i),x&&h.render(m,o),h.render(t,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=g}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===Bn||t.mapping===ci;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=oh()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ah());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new ve(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;hr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Xa)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let i=1;ijn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${jn}`);let p=[],v=0;for(let R=0;R_-Hi?i-_+Hi:0),w=4*(this._cubeSize-y);hr(e,b,w,3*y,2*y),c.setRenderTarget(e),c.render(u,Xa)}};function s_(s){let t=[],e=[],n=[],i=s,r=s-Hi+1+nh.length;for(let a=0;as-Hi?c=nh[a-s+Hi-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,x=3,g=2,p=1,v=new Float32Array(x*m*f),_=new Float32Array(g*m*f),y=new Float32Array(p*m*f);for(let w=0;w2?0:-1,M=[R,L,0,R+2/3,L,0,R+2/3,L+1,0,R,L,0,R+2/3,L+1,0,R,L+1,0];v.set(M,x*m*w),_.set(d,g*m*w);let E=[w,w,w,w,w,w];y.set(E,p*m*w)}let b=new Vt;b.setAttribute("position",new Kt(v,x)),b.setAttribute("uv",new Kt(_,g)),b.setAttribute("faceIndex",new Kt(y,p)),t.push(b),i>Hi&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function rh(s,t,e){let n=new Ge(s,t,e);return n.texture.mapping=Hs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function hr(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function r_(s,t,e){let n=new Float32Array(jn),i=new A(0,1,0);return new Qe({name:"SphericalGaussianBlur",defines:{n:jn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Vc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:Un,depthTest:!1,depthWrite:!1})}function ah(){return new Qe({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Vc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:Un,depthTest:!1,depthWrite:!1})}function oh(){return new Qe({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Vc(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:Un,depthTest:!1,depthWrite:!1})}function Vc(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function a_(s){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Ur||c===Dr,h=c===Bn||c===ci;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=t.get(o);return e===null&&(e=new Jr(s)),u=l?e.fromEquirectangular(o,u):e.fromCubemap(o,u),t.set(o,u),u.texture}else{if(t.has(o))return t.get(o).texture;{let u=o.image;if(l&&u&&u.height>0||h&&u&&i(u)){e===null&&(e=new Jr(s));let d=l?e.fromEquirectangular(o):e.fromCubemap(o);return t.set(o,d),o.addEventListener("dispose",r),d.texture}else return null}}}return o}function i(o){let c=0,l=6;for(let h=0;ht.maxTextureSize&&(E=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);let V=new Float32Array(M*E*4*m),$=new As(V,M,E,m);$.type=xn,$.needsUpdate=!0;let F=L*4;for(let z=0;z0)return s;let i=t*e,r=ch[i];if(r===void 0&&(r=new Float32Array(i),ch[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function me(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e":" "} ${o}: ${e[a]}`)}return n.join(` +`)}function s0(s){switch(s){case nn:return["Linear","( value )"];case Nt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),["Linear","( value )"]}}function mh(s,t,e){let n=s.getShaderParameter(t,s.COMPILE_STATUS),i=s.getShaderInfoLog(t).trim();if(n&&i==="")return"";let r=/ERROR: 0:(\d+)/.exec(i);if(r){let a=parseInt(r[1]);return e.toUpperCase()+` + +`+i+` + +`+i0(s.getShaderSource(t),a)}else return i}function r0(s,t){let e=s0(t);return"vec4 "+s+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function a0(s,t){let e;switch(t){case af:e="Linear";break;case of:e="Reinhard";break;case cf:e="OptimizedCineon";break;case lf:e="ACESFilmic";break;case hf:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function o0(s){return[s.extensionDerivatives||s.envMapCubeUVHeight||s.bumpMap||s.normalMapTangentSpace||s.clearcoatNormalMap||s.flatShading||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(vs).join(` +`)}function c0(s){let t=[];for(let e in s){let n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` +`)}function l0(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function _o(s){return s.replace(h0,d0)}var u0=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function d0(s,t){let e=zt[t];if(e===void 0){let n=u0.get(t);if(n!==void 0)e=zt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return _o(e)}var f0=/#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 xh(s){return s.replace(f0,p0)}function p0(s,t,e,n){let i="";for(let r=parseInt(t);r0&&(g+=` +`),p=[f,"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(vs).join(` +`),p.length>0&&(p+=` +`)):(g=[vh(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",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.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.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&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(vs).join(` +`),p=[f,vh(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.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.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.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?"#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 "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Dn?"#define TONE_MAPPING":"",e.toneMapping!==Dn?zt.tonemapping_pars_fragment:"",e.toneMapping!==Dn?a0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",zt.colorspace_pars_fragment,r0("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(vs).join(` +`)),a=_o(a),a=gh(a,e),a=_h(a,e),o=_o(o),o=gh(o,e),o=_h(o,e),a=xh(a),o=xh(o),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,p=["#define varying in",e.glslVersion===Cl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Cl?"":"#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 _=v+g+a,y=v+p+o,b=ph(i,i.VERTEX_SHADER,_),w=ph(i,i.FRAGMENT_SHADER,y);if(i.attachShader(x,b),i.attachShader(x,w),e.index0AttributeName!==void 0?i.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x),s.debug.checkShaderErrors){let M=i.getProgramInfoLog(x).trim(),E=i.getShaderInfoLog(b).trim(),V=i.getShaderInfoLog(w).trim(),$=!0,F=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if($=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,x,b,w);else{let O=mh(i,b,"vertex"),z=mh(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+` + +Program Info Log: `+M+` +`+O+` +`+z)}else M!==""?console.warn("THREE.WebGLProgram: Program Info Log:",M):(E===""||V==="")&&(F=!1);F&&(this.diagnostics={runnable:$,programLog:M,vertexShader:{log:E,prefix:g},fragmentShader:{log:V,prefix:p}})}i.deleteShader(b),i.deleteShader(w);let R;this.getUniforms=function(){return R===void 0&&(R=new qi(i,x)),R};let L;return this.getAttributes=function(){return L===void 0&&(L=l0(i,x)),L},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=n0++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=w,this}var M0=0,xo=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.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}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let 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 vo(t),e.set(t,n)),n}},vo=class{constructor(t){this.id=M0++,this.code=t,this.usedTimes=0}};function S0(s,t,e,n,i,r,a){let o=new Rs,c=new xo,l=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 x(M){return M===0?"uv":`uv${M}`}function g(M,E,V,$,F){let O=$.fog,z=F.geometry,K=M.isMeshStandardMaterial?$.environment:null,X=(M.isMeshStandardMaterial?e:t).get(M.envMap||K),Y=X&&X.mapping===Hs?X.image.height:null,j=m[M.type];M.precision!==null&&(f=i.getMaxPrecision(M.precision),f!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",f,"instead."));let tt=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,N=tt!==void 0?tt.length:0,q=0;z.morphAttributes.position!==void 0&&(q=1),z.morphAttributes.normal!==void 0&&(q=2),z.morphAttributes.color!==void 0&&(q=3);let lt,ut,pt,Et;if(j){let jt=en[j];lt=jt.vertexShader,ut=jt.fragmentShader}else lt=M.vertexShader,ut=M.fragmentShader,c.update(M),pt=c.getVertexShaderID(M),Et=c.getFragmentShaderID(M);let Tt=s.getRenderTarget(),wt=F.isInstancedMesh===!0,Yt=!!M.map,te=!!M.matcap,Pt=!!X,P=!!M.aoMap,at=!!M.lightMap,Z=!!M.bumpMap,st=!!M.normalMap,Q=!!M.displacementMap,St=!!M.emissiveMap,mt=!!M.metalnessMap,xt=!!M.roughnessMap,Dt=M.anisotropy>0,Xt=M.clearcoat>0,ie=M.iridescence>0,C=M.sheen>0,S=M.transmission>0,B=Dt&&!!M.anisotropyMap,nt=Xt&&!!M.clearcoatMap,et=Xt&&!!M.clearcoatNormalMap,it=Xt&&!!M.clearcoatRoughnessMap,Mt=ie&&!!M.iridescenceMap,rt=ie&&!!M.iridescenceThicknessMap,k=C&&!!M.sheenColorMap,Rt=C&&!!M.sheenRoughnessMap,bt=!!M.specularMap,At=!!M.specularColorMap,vt=!!M.specularIntensityMap,yt=S&&!!M.transmissionMap,Ht=S&&!!M.thicknessMap,Qt=!!M.gradientMap,I=!!M.alphaMap,ht=M.alphaTest>0,H=!!M.alphaHash,ot=!!M.extensions,dt=!!z.attributes.uv1,qt=!!z.attributes.uv2,ee=!!z.attributes.uv3,le=Dn;return M.toneMapped&&(Tt===null||Tt.isXRRenderTarget===!0)&&(le=s.toneMapping),{isWebGL2:h,shaderID:j,shaderType:M.type,shaderName:M.name,vertexShader:lt,fragmentShader:ut,defines:M.defines,customVertexShaderID:pt,customFragmentShaderID:Et,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:f,instancing:wt,instancingColor:wt&&F.instanceColor!==null,supportsVertexTextures:d,outputColorSpace:Tt===null?s.outputColorSpace:Tt.isXRRenderTarget===!0?Tt.texture.colorSpace:nn,map:Yt,matcap:te,envMap:Pt,envMapMode:Pt&&X.mapping,envMapCubeUVHeight:Y,aoMap:P,lightMap:at,bumpMap:Z,normalMap:st,displacementMap:d&&Q,emissiveMap:St,normalMapObjectSpace:st&&M.normalMapType===Tf,normalMapTangentSpace:st&&M.normalMapType===mi,metalnessMap:mt,roughnessMap:xt,anisotropy:Dt,anisotropyMap:B,clearcoat:Xt,clearcoatMap:nt,clearcoatNormalMap:et,clearcoatRoughnessMap:it,iridescence:ie,iridescenceMap:Mt,iridescenceThicknessMap:rt,sheen:C,sheenColorMap:k,sheenRoughnessMap:Rt,specularMap:bt,specularColorMap:At,specularIntensityMap:vt,transmission:S,transmissionMap:yt,thicknessMap:Ht,gradientMap:Qt,opaque:M.transparent===!1&&M.blending===Wi,alphaMap:I,alphaTest:ht,alphaHash:H,combine:M.combine,mapUv:Yt&&x(M.map.channel),aoMapUv:P&&x(M.aoMap.channel),lightMapUv:at&&x(M.lightMap.channel),bumpMapUv:Z&&x(M.bumpMap.channel),normalMapUv:st&&x(M.normalMap.channel),displacementMapUv:Q&&x(M.displacementMap.channel),emissiveMapUv:St&&x(M.emissiveMap.channel),metalnessMapUv:mt&&x(M.metalnessMap.channel),roughnessMapUv:xt&&x(M.roughnessMap.channel),anisotropyMapUv:B&&x(M.anisotropyMap.channel),clearcoatMapUv:nt&&x(M.clearcoatMap.channel),clearcoatNormalMapUv:et&&x(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&x(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Mt&&x(M.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&x(M.iridescenceThicknessMap.channel),sheenColorMapUv:k&&x(M.sheenColorMap.channel),sheenRoughnessMapUv:Rt&&x(M.sheenRoughnessMap.channel),specularMapUv:bt&&x(M.specularMap.channel),specularColorMapUv:At&&x(M.specularColorMap.channel),specularIntensityMapUv:vt&&x(M.specularIntensityMap.channel),transmissionMapUv:yt&&x(M.transmissionMap.channel),thicknessMapUv:Ht&&x(M.thicknessMap.channel),alphaMapUv:I&&x(M.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(st||Dt),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,vertexUv1s:dt,vertexUv2s:qt,vertexUv3s:ee,pointsUvs:F.isPoints===!0&&!!z.attributes.uv&&(Yt||I),fog:!!O,useFog:M.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:F.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:N,morphTextureStride:q,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&V.length>0,shadowMapType:s.shadowMap.type,toneMapping:le,useLegacyLights:s._useLegacyLights,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===gn,flipSided:M.side===De,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:ot&&M.extensions.derivatives===!0,extensionFragDepth:ot&&M.extensions.fragDepth===!0,extensionDrawBuffers:ot&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:ot&&M.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:M.customProgramCacheKey()}}function p(M){let E=[];if(M.shaderID?E.push(M.shaderID):(E.push(M.customVertexShaderID),E.push(M.customFragmentShaderID)),M.defines!==void 0)for(let V in M.defines)E.push(V),E.push(M.defines[V]);return M.isRawShaderMaterial===!1&&(v(E,M),_(E,M),E.push(s.outputColorSpace)),E.push(M.customProgramCacheKey),E.join()}function v(M,E){M.push(E.precision),M.push(E.outputColorSpace),M.push(E.envMapMode),M.push(E.envMapCubeUVHeight),M.push(E.mapUv),M.push(E.alphaMapUv),M.push(E.lightMapUv),M.push(E.aoMapUv),M.push(E.bumpMapUv),M.push(E.normalMapUv),M.push(E.displacementMapUv),M.push(E.emissiveMapUv),M.push(E.metalnessMapUv),M.push(E.roughnessMapUv),M.push(E.anisotropyMapUv),M.push(E.clearcoatMapUv),M.push(E.clearcoatNormalMapUv),M.push(E.clearcoatRoughnessMapUv),M.push(E.iridescenceMapUv),M.push(E.iridescenceThicknessMapUv),M.push(E.sheenColorMapUv),M.push(E.sheenRoughnessMapUv),M.push(E.specularMapUv),M.push(E.specularColorMapUv),M.push(E.specularIntensityMapUv),M.push(E.transmissionMapUv),M.push(E.thicknessMapUv),M.push(E.combine),M.push(E.fogExp2),M.push(E.sizeAttenuation),M.push(E.morphTargetsCount),M.push(E.morphAttributeCount),M.push(E.numDirLights),M.push(E.numPointLights),M.push(E.numSpotLights),M.push(E.numSpotLightMaps),M.push(E.numHemiLights),M.push(E.numRectAreaLights),M.push(E.numDirLightShadows),M.push(E.numPointLightShadows),M.push(E.numSpotLightShadows),M.push(E.numSpotLightShadowsWithMaps),M.push(E.shadowMapType),M.push(E.toneMapping),M.push(E.numClippingPlanes),M.push(E.numClipIntersection),M.push(E.depthPacking)}function _(M,E){o.disableAll(),E.isWebGL2&&o.enable(0),E.supportsVertexTextures&&o.enable(1),E.instancing&&o.enable(2),E.instancingColor&&o.enable(3),E.matcap&&o.enable(4),E.envMap&&o.enable(5),E.normalMapObjectSpace&&o.enable(6),E.normalMapTangentSpace&&o.enable(7),E.clearcoat&&o.enable(8),E.iridescence&&o.enable(9),E.alphaTest&&o.enable(10),E.vertexColors&&o.enable(11),E.vertexAlphas&&o.enable(12),E.vertexUv1s&&o.enable(13),E.vertexUv2s&&o.enable(14),E.vertexUv3s&&o.enable(15),E.vertexTangents&&o.enable(16),E.anisotropy&&o.enable(17),M.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.skinning&&o.enable(4),E.morphTargets&&o.enable(5),E.morphNormals&&o.enable(6),E.morphColors&&o.enable(7),E.premultipliedAlpha&&o.enable(8),E.shadowMapEnabled&&o.enable(9),E.useLegacyLights&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.transmission&&o.enable(15),E.sheen&&o.enable(16),E.opaque&&o.enable(17),E.pointsUvs&&o.enable(18),M.push(o.mask)}function y(M){let E=m[M.type],V;if(E){let $=en[E];V=mp.clone($.uniforms)}else V=M.uniforms;return V}function b(M,E){let V;for(let $=0,F=l.length;$0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function c(u,d,f,m,x,g){let p=a(u,d,f,m,x,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function l(u,d){e.length>1&&e.sort(u||E0),n.length>1&&n.sort(d||yh),i.length>1&&i.sort(d||yh)}function h(){for(let u=t,d=s.length;u=r.length?(a=new Mh,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function w0(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new A,color:new ft};break;case"SpotLight":e={position:new A,direction:new A,color:new ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new A,color:new ft,distance:0,decay:0};break;case"HemisphereLight":e={direction:new A,skyColor:new ft,groundColor:new ft};break;case"RectAreaLight":e={color:new ft,position:new A,halfWidth:new A,halfHeight:new A};break}return s[t.id]=e,e}}}function A0(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new J,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var R0=0;function C0(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function P0(s,t){let e=new w0,n=A0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let h=0;h<9;h++)i.probe.push(new A);let r=new A,a=new Ot,o=new Ot;function c(h,u){let d=0,f=0,m=0;for(let V=0;V<9;V++)i.probe[V].set(0,0,0);let x=0,g=0,p=0,v=0,_=0,y=0,b=0,w=0,R=0,L=0;h.sort(C0);let M=u===!0?Math.PI:1;for(let V=0,$=h.length;V<$;V++){let F=h[V],O=F.color,z=F.intensity,K=F.distance,X=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=O.r*z*M,f+=O.g*z*M,m+=O.b*z*M;else if(F.isLightProbe)for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(F.sh.coefficients[Y],z);else if(F.isDirectionalLight){let Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity*M),F.castShadow){let j=F.shadow,tt=n.get(F);tt.shadowBias=j.bias,tt.shadowNormalBias=j.normalBias,tt.shadowRadius=j.radius,tt.shadowMapSize=j.mapSize,i.directionalShadow[x]=tt,i.directionalShadowMap[x]=X,i.directionalShadowMatrix[x]=F.shadow.matrix,y++}i.directional[x]=Y,x++}else if(F.isSpotLight){let Y=e.get(F);Y.position.setFromMatrixPosition(F.matrixWorld),Y.color.copy(O).multiplyScalar(z*M),Y.distance=K,Y.coneCos=Math.cos(F.angle),Y.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),Y.decay=F.decay,i.spot[p]=Y;let j=F.shadow;if(F.map&&(i.spotLightMap[R]=F.map,R++,j.updateMatrices(F),F.castShadow&&L++),i.spotLightMatrix[p]=j.matrix,F.castShadow){let tt=n.get(F);tt.shadowBias=j.bias,tt.shadowNormalBias=j.normalBias,tt.shadowRadius=j.radius,tt.shadowMapSize=j.mapSize,i.spotShadow[p]=tt,i.spotShadowMap[p]=X,w++}p++}else if(F.isRectAreaLight){let Y=e.get(F);Y.color.copy(O).multiplyScalar(z),Y.halfWidth.set(F.width*.5,0,0),Y.halfHeight.set(0,F.height*.5,0),i.rectArea[v]=Y,v++}else if(F.isPointLight){let Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity*M),Y.distance=F.distance,Y.decay=F.decay,F.castShadow){let j=F.shadow,tt=n.get(F);tt.shadowBias=j.bias,tt.shadowNormalBias=j.normalBias,tt.shadowRadius=j.radius,tt.shadowMapSize=j.mapSize,tt.shadowCameraNear=j.camera.near,tt.shadowCameraFar=j.camera.far,i.pointShadow[g]=tt,i.pointShadowMap[g]=X,i.pointShadowMatrix[g]=F.shadow.matrix,b++}i.point[g]=Y,g++}else if(F.isHemisphereLight){let Y=e.get(F);Y.skyColor.copy(F.color).multiplyScalar(z*M),Y.groundColor.copy(F.groundColor).multiplyScalar(z*M),i.hemi[_]=Y,_++}}v>0&&(t.isWebGL2||s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ct.LTC_FLOAT_1,i.rectAreaLTC2=ct.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ct.LTC_HALF_1,i.rectAreaLTC2=ct.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=m;let E=i.hash;(E.directionalLength!==x||E.pointLength!==g||E.spotLength!==p||E.rectAreaLength!==v||E.hemiLength!==_||E.numDirectionalShadows!==y||E.numPointShadows!==b||E.numSpotShadows!==w||E.numSpotMaps!==R)&&(i.directional.length=x,i.spot.length=p,i.rectArea.length=v,i.point.length=g,i.hemi.length=_,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=w+R-L,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=L,E.directionalLength=x,E.pointLength=g,E.spotLength=p,E.rectAreaLength=v,E.hemiLength=_,E.numDirectionalShadows=y,E.numPointShadows=b,E.numSpotShadows=w,E.numSpotMaps=R,i.version=R0++)}function l(h,u){let d=0,f=0,m=0,x=0,g=0,p=u.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){let y=h[v];if(y.isDirectionalLight){let b=i.directional[d];b.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(p),d++}else if(y.isSpotLight){let b=i.spot[m];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(p),b.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(p),m++}else if(y.isRectAreaLight){let b=i.rectArea[x];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(p),o.identity(),a.copy(y.matrixWorld),a.premultiply(p),o.extractRotation(a),b.halfWidth.set(y.width*.5,0,0),b.halfHeight.set(0,y.height*.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),x++}else if(y.isPointLight){let b=i.point[f];b.position.setFromMatrixPosition(y.matrixWorld),b.position.applyMatrix4(p),f++}else if(y.isHemisphereLight){let b=i.hemi[g];b.direction.setFromMatrixPosition(y.matrixWorld),b.direction.transformDirection(p),g++}}}return{setup:c,setupView:l,state:i}}function Sh(s,t){let e=new P0(s,t),n=[],i=[];function r(){n.length=0,i.length=0}function a(u){n.push(u)}function o(u){i.push(u)}function c(u){e.setup(n,u)}function l(u){e.setupView(n,u)}return{init:r,state:{lightsArray:n,shadowsArray:i,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function L0(s,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new Sh(s,t),e.set(r,[c])):a>=o.length?(c=new Sh(s,t),o.push(c)):c=o[a],c}function i(){e=new WeakMap}return{get:n,dispose:i}}var $r=class extends Me{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bf,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}},Kr=class extends Me{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}},I0=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,U0=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function D0(s,t,e){let n=new Ps,i=new J,r=new J,a=new $t,o=new $r({depthPacking:Ef}),c=new Kr,l={},h=e.maxTextureSize,u={[On]:De,[De]:On,[gn]:gn},d=new Qe({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:I0,fragmentShader:U0}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Vt;m.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new ve(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nd;let p=this.type;this.render=function(b,w,R){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let L=s.getRenderTarget(),M=s.getActiveCubeFace(),E=s.getActiveMipmapLevel(),V=s.state;V.setBlending(Un),V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let $=p!==pn&&this.type===pn,F=p===pn&&this.type!==pn;for(let O=0,z=b.length;Oh||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,X.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,X.mapSize.y=r.y)),X.map===null||$===!0||F===!0){let tt=this.type!==pn?{minFilter:fe,magFilter:fe}:{};X.map!==null&&X.map.dispose(),X.map=new Ge(i.x,i.y,tt),X.map.texture.name=K.name+".shadowMap",X.camera.updateProjectionMatrix()}s.setRenderTarget(X.map),s.clear();let j=X.getViewportCount();for(let tt=0;tt0||w.map&&w.alphaTest>0){let V=M.uuid,$=w.uuid,F=l[V];F===void 0&&(F={},l[V]=F);let O=F[$];O===void 0&&(O=M.clone(),F[$]=O),M=O}if(M.visible=w.visible,M.wireframe=w.wireframe,L===pn?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:u[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,R.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let V=s.properties.get(M);V.light=R}return M}function y(b,w,R,L,M){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&M===pn)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,b.matrixWorld);let $=t.update(b),F=b.material;if(Array.isArray(F)){let O=$.groups;for(let z=0,K=O.length;z=1):Y.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),K=X>=2);let j=null,tt={},N=s.getParameter(s.SCISSOR_BOX),q=s.getParameter(s.VIEWPORT),lt=new $t().fromArray(N),ut=new $t().fromArray(q);function pt(I,ht,H,ot){let dt=new Uint8Array(4),qt=s.createTexture();s.bindTexture(I,qt),s.texParameteri(I,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(I,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ee=0;ee"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,x,g=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(C,S){return p?new OffscreenCanvas(C,S):ws("canvas")}function _(C,S,B,nt){let et=1;if((C.width>nt||C.height>nt)&&(et=nt/Math.max(C.width,C.height)),et<1||S===!0)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap){let it=S?Hr:Math.floor,Mt=it(et*C.width),rt=it(et*C.height);x===void 0&&(x=v(Mt,rt));let k=B?v(Mt,rt):x;return k.width=Mt,k.height=rt,k.getContext("2d").drawImage(C,0,0,Mt,rt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+C.width+"x"+C.height+") to ("+Mt+"x"+rt+")."),k}else return"data"in C&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+C.width+"x"+C.height+")."),C;return C}function y(C){return lo(C.width)&&lo(C.height)}function b(C){return o?!1:C.wrapS!==Ce||C.wrapT!==Ce||C.minFilter!==fe&&C.minFilter!==pe}function w(C,S){return C.generateMipmaps&&S&&C.minFilter!==fe&&C.minFilter!==pe}function R(C){s.generateMipmap(C)}function L(C,S,B,nt,et=!1){if(o===!1)return S;if(C!==null){if(s[C]!==void 0)return s[C];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let it=S;return S===s.RED&&(B===s.FLOAT&&(it=s.R32F),B===s.HALF_FLOAT&&(it=s.R16F),B===s.UNSIGNED_BYTE&&(it=s.R8)),S===s.RED_INTEGER&&(B===s.UNSIGNED_BYTE&&(it=s.R8UI),B===s.UNSIGNED_SHORT&&(it=s.R16UI),B===s.UNSIGNED_INT&&(it=s.R32UI),B===s.BYTE&&(it=s.R8I),B===s.SHORT&&(it=s.R16I),B===s.INT&&(it=s.R32I)),S===s.RG&&(B===s.FLOAT&&(it=s.RG32F),B===s.HALF_FLOAT&&(it=s.RG16F),B===s.UNSIGNED_BYTE&&(it=s.RG8)),S===s.RGBA&&(B===s.FLOAT&&(it=s.RGBA32F),B===s.HALF_FLOAT&&(it=s.RGBA16F),B===s.UNSIGNED_BYTE&&(it=nt===Nt&&et===!1?s.SRGB8_ALPHA8:s.RGBA8),B===s.UNSIGNED_SHORT_4_4_4_4&&(it=s.RGBA4),B===s.UNSIGNED_SHORT_5_5_5_1&&(it=s.RGB5_A1)),(it===s.R16F||it===s.R32F||it===s.RG16F||it===s.RG32F||it===s.RGBA16F||it===s.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function M(C,S,B){return w(C,B)===!0||C.isFramebufferTexture&&C.minFilter!==fe&&C.minFilter!==pe?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function E(C){return C===fe||C===oo||C===Ir?s.NEAREST:s.LINEAR}function V(C){let S=C.target;S.removeEventListener("dispose",V),F(S),S.isVideoTexture&&m.delete(S)}function $(C){let S=C.target;S.removeEventListener("dispose",$),z(S)}function F(C){let S=n.get(C);if(S.__webglInit===void 0)return;let B=C.source,nt=g.get(B);if(nt){let et=nt[S.__cacheKey];et.usedTimes--,et.usedTimes===0&&O(C),Object.keys(nt).length===0&&g.delete(B)}n.remove(C)}function O(C){let S=n.get(C);s.deleteTexture(S.__webglTexture);let B=C.source,nt=g.get(B);delete nt[S.__cacheKey],a.memory.textures--}function z(C){let S=C.texture,B=n.get(C),nt=n.get(S);if(nt.__webglTexture!==void 0&&(s.deleteTexture(nt.__webglTexture),a.memory.textures--),C.depthTexture&&C.depthTexture.dispose(),C.isWebGLCubeRenderTarget)for(let et=0;et<6;et++){if(Array.isArray(B.__webglFramebuffer[et]))for(let it=0;it=c&&console.warn("THREE.WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+c),K+=1,C}function j(C){let S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function tt(C,S){let B=n.get(C);if(C.isVideoTexture&&Xt(C),C.isRenderTargetTexture===!1&&C.version>0&&B.__version!==C.version){let nt=C.image;if(nt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(nt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Yt(B,C,S);return}}e.bindTexture(s.TEXTURE_2D,B.__webglTexture,s.TEXTURE0+S)}function N(C,S){let B=n.get(C);if(C.version>0&&B.__version!==C.version){Yt(B,C,S);return}e.bindTexture(s.TEXTURE_2D_ARRAY,B.__webglTexture,s.TEXTURE0+S)}function q(C,S){let B=n.get(C);if(C.version>0&&B.__version!==C.version){Yt(B,C,S);return}e.bindTexture(s.TEXTURE_3D,B.__webglTexture,s.TEXTURE0+S)}function lt(C,S){let B=n.get(C);if(C.version>0&&B.__version!==C.version){te(B,C,S);return}e.bindTexture(s.TEXTURE_CUBE_MAP,B.__webglTexture,s.TEXTURE0+S)}let ut={[Nr]:s.REPEAT,[Ce]:s.CLAMP_TO_EDGE,[Fr]:s.MIRRORED_REPEAT},pt={[fe]:s.NEAREST,[oo]:s.NEAREST_MIPMAP_NEAREST,[Ir]:s.NEAREST_MIPMAP_LINEAR,[pe]:s.LINEAR,[rd]:s.LINEAR_MIPMAP_NEAREST,[li]:s.LINEAR_MIPMAP_LINEAR},Et={[Af]:s.NEVER,[Df]:s.ALWAYS,[Rf]:s.LESS,[Pf]:s.LEQUAL,[Cf]:s.EQUAL,[Uf]:s.GEQUAL,[Lf]:s.GREATER,[If]:s.NOTEQUAL};function Tt(C,S,B){if(B?(s.texParameteri(C,s.TEXTURE_WRAP_S,ut[S.wrapS]),s.texParameteri(C,s.TEXTURE_WRAP_T,ut[S.wrapT]),(C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY)&&s.texParameteri(C,s.TEXTURE_WRAP_R,ut[S.wrapR]),s.texParameteri(C,s.TEXTURE_MAG_FILTER,pt[S.magFilter]),s.texParameteri(C,s.TEXTURE_MIN_FILTER,pt[S.minFilter])):(s.texParameteri(C,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(C,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY)&&s.texParameteri(C,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(S.wrapS!==Ce||S.wrapT!==Ce)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(C,s.TEXTURE_MAG_FILTER,E(S.magFilter)),s.texParameteri(C,s.TEXTURE_MIN_FILTER,E(S.minFilter)),S.minFilter!==fe&&S.minFilter!==pe&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(s.texParameteri(C,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(C,s.TEXTURE_COMPARE_FUNC,Et[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let nt=t.get("EXT_texture_filter_anisotropic");if(S.magFilter===fe||S.minFilter!==Ir&&S.minFilter!==li||S.type===xn&&t.has("OES_texture_float_linear")===!1||o===!1&&S.type===Ts&&t.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(s.texParameterf(C,nt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function wt(C,S){let B=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",V));let nt=S.source,et=g.get(nt);et===void 0&&(et={},g.set(nt,et));let it=j(S);if(it!==C.__cacheKey){et[it]===void 0&&(et[it]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,B=!0),et[it].usedTimes++;let Mt=et[C.__cacheKey];Mt!==void 0&&(et[C.__cacheKey].usedTimes--,Mt.usedTimes===0&&O(S)),C.__cacheKey=it,C.__webglTexture=et[it].texture}return B}function Yt(C,S,B){let nt=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(nt=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(nt=s.TEXTURE_3D);let et=wt(C,S),it=S.source;e.bindTexture(nt,C.__webglTexture,s.TEXTURE0+B);let Mt=n.get(it);if(it.version!==Mt.__version||et===!0){e.activeTexture(s.TEXTURE0+B),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE);let rt=b(S)&&y(S.image)===!1,k=_(S.image,rt,!1,h);k=ie(S,k);let Rt=y(k)||o,bt=r.convert(S.format,S.colorSpace),At=r.convert(S.type),vt=L(S.internalFormat,bt,At,S.colorSpace);Tt(nt,S,Rt);let yt,Ht=S.mipmaps,Qt=o&&S.isVideoTexture!==!0,I=Mt.__version===void 0||et===!0,ht=M(S,k,Rt);if(S.isDepthTexture)vt=s.DEPTH_COMPONENT,o?S.type===xn?vt=s.DEPTH_COMPONENT32F:S.type===Pn?vt=s.DEPTH_COMPONENT24:S.type===ni?vt=s.DEPTH24_STENCIL8:vt=s.DEPTH_COMPONENT16:S.type===xn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===ii&&vt===s.DEPTH_COMPONENT&&S.type!==Bc&&S.type!==Pn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=Pn,At=r.convert(S.type)),S.format===Yi&&vt===s.DEPTH_COMPONENT&&(vt=s.DEPTH_STENCIL,S.type!==ni&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=ni,At=r.convert(S.type))),I&&(Qt?e.texStorage2D(s.TEXTURE_2D,1,vt,k.width,k.height):e.texImage2D(s.TEXTURE_2D,0,vt,k.width,k.height,0,bt,At,null));else if(S.isDataTexture)if(Ht.length>0&&Rt){Qt&&I&&e.texStorage2D(s.TEXTURE_2D,ht,vt,Ht[0].width,Ht[0].height);for(let H=0,ot=Ht.length;H>=1,ot>>=1}}else if(Ht.length>0&&Rt){Qt&&I&&e.texStorage2D(s.TEXTURE_2D,ht,vt,Ht[0].width,Ht[0].height);for(let H=0,ot=Ht.length;H0&&I++,e.texStorage2D(s.TEXTURE_CUBE_MAP,I,yt,k[0].width,k[0].height));for(let H=0;H<6;H++)if(rt){Ht?e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,0,0,k[H].width,k[H].height,At,vt,k[H].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,yt,k[H].width,k[H].height,0,At,vt,k[H].data);for(let ot=0;ot>it),At=Math.max(1,S.height>>it);et===s.TEXTURE_3D||et===s.TEXTURE_2D_ARRAY?e.texImage3D(et,it,k,bt,At,S.depth,0,Mt,rt,null):e.texImage2D(et,it,k,bt,At,0,Mt,rt,null)}e.bindFramebuffer(s.FRAMEBUFFER,C),Dt(S)?d.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,nt,et,n.get(B).__webglTexture,0,xt(S)):(et===s.TEXTURE_2D||et>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&et<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,nt,et,n.get(B).__webglTexture,it),e.bindFramebuffer(s.FRAMEBUFFER,null)}function P(C,S,B){if(s.bindRenderbuffer(s.RENDERBUFFER,C),S.depthBuffer&&!S.stencilBuffer){let nt=s.DEPTH_COMPONENT16;if(B||Dt(S)){let et=S.depthTexture;et&&et.isDepthTexture&&(et.type===xn?nt=s.DEPTH_COMPONENT32F:et.type===Pn&&(nt=s.DEPTH_COMPONENT24));let it=xt(S);Dt(S)?d.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,it,nt,S.width,S.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,it,nt,S.width,S.height)}else s.renderbufferStorage(s.RENDERBUFFER,nt,S.width,S.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,C)}else if(S.depthBuffer&&S.stencilBuffer){let nt=xt(S);B&&Dt(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,nt,s.DEPTH24_STENCIL8,S.width,S.height):Dt(S)?d.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,nt,s.DEPTH24_STENCIL8,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,C)}else{let nt=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let et=0;et0){B.__webglFramebuffer[rt]=[];for(let k=0;k0){B.__webglFramebuffer=[];for(let rt=0;rt0&&Dt(C)===!1){let rt=it?S:[S];B.__webglMultisampledFramebuffer=s.createFramebuffer(),B.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let k=0;k0)for(let k=0;k0)for(let k=0;k0&&Dt(C)===!1){let S=C.isWebGLMultipleRenderTargets?C.texture:[C.texture],B=C.width,nt=C.height,et=s.COLOR_BUFFER_BIT,it=[],Mt=C.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,rt=n.get(C),k=C.isWebGLMultipleRenderTargets===!0;if(k)for(let Rt=0;Rt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Xt(C){let S=a.render.frame;m.get(C)!==S&&(m.set(C,S),C.update())}function ie(C,S){let B=C.colorSpace,nt=C.format,et=C.type;return C.isCompressedTexture===!0||C.format===co||B!==nn&&B!==ri&&(B===Nt?o===!1?t.has("EXT_sRGB")===!0&&nt===He?(C.format=co,C.minFilter=pe,C.generateMipmaps=!1):S=Gr.sRGBToLinear(S):(nt!==He||et!==Nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",B)),S}this.allocateTextureUnit=Y,this.resetTextureUnits=X,this.setTexture2D=tt,this.setTexture2DArray=N,this.setTexture3D=q,this.setTextureCube=lt,this.rebindTextures=st,this.setupRenderTarget=Q,this.updateRenderTargetMipmap=St,this.updateMultisampleRenderTarget=mt,this.setupDepthRenderbuffer=Z,this.setupFrameBufferTexture=Pt,this.useMultisampledRTT=Dt}function O0(s,t,e){let n=e.isWebGL2;function i(r,a=ri){let o;if(r===Nn)return s.UNSIGNED_BYTE;if(r===od)return s.UNSIGNED_SHORT_4_4_4_4;if(r===cd)return s.UNSIGNED_SHORT_5_5_5_1;if(r===uf)return s.BYTE;if(r===df)return s.SHORT;if(r===Bc)return s.UNSIGNED_SHORT;if(r===ad)return s.INT;if(r===Pn)return s.UNSIGNED_INT;if(r===xn)return s.FLOAT;if(r===Ts)return n?s.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===ff)return s.ALPHA;if(r===He)return s.RGBA;if(r===pf)return s.LUMINANCE;if(r===mf)return s.LUMINANCE_ALPHA;if(r===ii)return s.DEPTH_COMPONENT;if(r===Yi)return s.DEPTH_STENCIL;if(r===co)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===gf)return s.RED;if(r===ld)return s.RED_INTEGER;if(r===_f)return s.RG;if(r===hd)return s.RG_INTEGER;if(r===ud)return s.RGBA_INTEGER;if(r===Ma||r===Sa||r===ba||r===Ea)if(a===Nt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===Ma)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Sa)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===ba)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Ea)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===Ma)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Sa)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===ba)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Ea)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===al||r===ol||r===cl||r===ll)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===al)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===ol)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===cl)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===ll)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===xf)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===hl||r===ul)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===hl)return a===Nt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===ul)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===dl||r===fl||r===pl||r===ml||r===gl||r===_l||r===xl||r===vl||r===yl||r===Ml||r===Sl||r===bl||r===El||r===Tl)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===dl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===fl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===pl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===ml)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===gl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===_l)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===xl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===vl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===yl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Ml)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Sl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===bl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===El)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Tl)return a===Nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Ta)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(r===Ta)return a===Nt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===vf||r===wl||r===Al||r===Rl)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===Ta)return o.COMPRESSED_RED_RGTC1_EXT;if(r===wl)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Al)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Rl)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===ni?n?s.UNSIGNED_INT_24_8:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):s[r]!==void 0?s[r]:null}return{convert:i}}var yo=class extends xe{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ti=class extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}},B0={type:"move"},Ss=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ti,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ti,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ti,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let x of t.hand.values()){let g=e.getJointPose(x,n),p=this._getHandJoint(l,x);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;l.inputState.pinching&&d>f+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(B0)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new ti;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Mo=class extends ye{constructor(t,e,n,i,r,a,o,c,l,h){if(h=h!==void 0?h:ii,h!==ii&&h!==Yi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===ii&&(n=Pn),n===void 0&&h===Yi&&(n=ni),super(null,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:fe,this.minFilter=c!==void 0?c:fe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},So=class extends sn{constructor(t,e){super();let n=this,i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,m=null,x=e.getContextAttributes(),g=null,p=null,v=[],_=[],y=new xe;y.layers.enable(1),y.viewport=new $t;let b=new xe;b.layers.enable(2),b.viewport=new $t;let w=[y,b],R=new yo;R.layers.enable(1),R.layers.enable(2);let L=null,M=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let q=v[N];return q===void 0&&(q=new Ss,v[N]=q),q.getTargetRaySpace()},this.getControllerGrip=function(N){let q=v[N];return q===void 0&&(q=new Ss,v[N]=q),q.getGripSpace()},this.getHand=function(N){let q=v[N];return q===void 0&&(q=new Ss,v[N]=q),q.getHandSpace()};function E(N){let q=_.indexOf(N.inputSource);if(q===-1)return;let lt=v[q];lt!==void 0&&(lt.update(N.inputSource,N.frame,l||a),lt.dispatchEvent({type:N.type,data:N.inputSource}))}function V(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",$);for(let N=0;N=0&&(_[ut]=null,v[ut].disconnect(lt))}for(let q=0;q=_.length){_.push(lt),ut=Et;break}else if(_[Et]===null){_[Et]=lt,ut=Et;break}if(ut===-1)break}let pt=v[ut];pt&&pt.connect(lt)}}let F=new A,O=new A;function z(N,q,lt){F.setFromMatrixPosition(q.matrixWorld),O.setFromMatrixPosition(lt.matrixWorld);let ut=F.distanceTo(O),pt=q.projectionMatrix.elements,Et=lt.projectionMatrix.elements,Tt=pt[14]/(pt[10]-1),wt=pt[14]/(pt[10]+1),Yt=(pt[9]+1)/pt[5],te=(pt[9]-1)/pt[5],Pt=(pt[8]-1)/pt[0],P=(Et[8]+1)/Et[0],at=Tt*Pt,Z=Tt*P,st=ut/(-Pt+P),Q=st*-Pt;q.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Q),N.translateZ(st),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let St=Tt+st,mt=wt+st,xt=at-Q,Dt=Z+(ut-Q),Xt=Yt*wt/mt*St,ie=te*wt/mt*St;N.projectionMatrix.makePerspective(xt,Dt,Xt,ie,St,mt),N.projectionMatrixInverse.copy(N.projectionMatrix).invert()}function K(N,q){q===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(q.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(i===null)return;R.near=b.near=y.near=N.near,R.far=b.far=y.far=N.far,(L!==R.near||M!==R.far)&&(i.updateRenderState({depthNear:R.near,depthFar:R.far}),L=R.near,M=R.far);let q=N.parent,lt=R.cameras;K(R,q);for(let ut=0;ut0&&(g.alphaTest.value=p.alphaTest);let v=t.get(p).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap){g.lightMap.value=p.lightMap;let _=s._useLegacyLights===!0?Math.PI:1;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 a(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 o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,v,_){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=_*.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 l(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 u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(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)),t.get(p).envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,v){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===De&&g.clearcoatNormalScale.value.negate())),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=v.texture,g.transmissionSamplerSize.value.set(v.width,v.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 x(g,p){let v=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function k0(s,t,e,n){let i={},r={},a=[],o=e.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(v,_){let y=_.program;n.uniformBlockBinding(v,y)}function l(v,_){let y=i[v.id];y===void 0&&(m(v),y=h(v),i[v.id]=y,v.addEventListener("dispose",g));let b=_.program;n.updateUBOMapping(v,b);let w=t.render.frame;r[v.id]!==w&&(d(v),r[v.id]=w)}function h(v){let _=u();v.__bindingPointIndex=_;let y=s.createBuffer(),b=v.__size,w=v.usage;return s.bindBuffer(s.UNIFORM_BUFFER,y),s.bufferData(s.UNIFORM_BUFFER,b,w),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,y),y}function u(){for(let v=0;v0){w=y%b;let $=b-w;w!==0&&$-E.boundary<0&&(y+=b-w,M.__offset=y)}y+=E.storage}return w=y%b,w>0&&(y+=b-w),v.__size=y,v.__cache={},this}function x(v){let _={boundary:0,storage:0};return typeof v=="number"?(_.boundary=4,_.storage=4):v.isVector2?(_.boundary=8,_.storage=8):v.isVector3||v.isColor?(_.boundary=16,_.storage=12):v.isVector4?(_.boundary=16,_.storage=16):v.isMatrix3?(_.boundary=48,_.storage=48):v.isMatrix4?(_.boundary=64,_.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),_}function g(v){let _=v.target;_.removeEventListener("dispose",g);let y=a.indexOf(_.__bindingPointIndex);a.splice(y,1),s.deleteBuffer(i[_.id]),delete i[_.id],delete r[_.id]}function p(){for(let v in i)s.deleteBuffer(i[v]);a=[],i={},r={}}return{bind:c,update:l,dispose:p}}function V0(){let s=ws("canvas");return s.style.display="block",s}var bo=class{constructor(t={}){let{canvas:e=V0(),context:n=null,depth:i=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;n!==null?d=n.getContextAttributes().alpha:d=a;let f=new Uint32Array(4),m=new Int32Array(4),x=null,g=null,p=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Nt,this._useLegacyLights=!1,this.toneMapping=Dn,this.toneMappingExposure=1;let _=this,y=!1,b=0,w=0,R=null,L=-1,M=null,E=new $t,V=new $t,$=null,F=new ft(0),O=0,z=e.width,K=e.height,X=1,Y=null,j=null,tt=new $t(0,0,z,K),N=new $t(0,0,z,K),q=!1,lt=new Ps,ut=!1,pt=!1,Et=null,Tt=new Ot,wt=new J,Yt=new A,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Pt(){return R===null?X:1}let P=n;function at(T,D){for(let W=0;W0?g=v[v.length-1]:g=null,p.pop(),p.length>0?x=p[p.length-1]:x=null};function Zc(T,D,W,U){if(T.visible===!1)return;if(T.layers.test(D.layers)){if(T.isGroup)W=T.renderOrder;else if(T.isLOD)T.autoUpdate===!0&&T.update(D);else if(T.isLight)g.pushLight(T),T.castShadow&&g.pushShadow(T);else if(T.isSprite){if(!T.frustumCulled||lt.intersectsSprite(T)){U&&Yt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(Tt);let Ct=S.update(T),It=T.material;It.visible&&x.push(T,Ct,It,W,Yt.z,null)}}else if((T.isMesh||T.isLine||T.isPoints)&&(!T.frustumCulled||lt.intersectsObject(T))){let Ct=S.update(T),It=T.material;if(U&&(T.boundingSphere!==void 0?(T.boundingSphere===null&&T.computeBoundingSphere(),Yt.copy(T.boundingSphere.center)):(Ct.boundingSphere===null&&Ct.computeBoundingSphere(),Yt.copy(Ct.boundingSphere.center)),Yt.applyMatrix4(T.matrixWorld).applyMatrix4(Tt)),Array.isArray(It)){let Ut=Ct.groups;for(let Gt=0,Lt=Ut.length;Gt0&&Pd(G,gt,D,W),U&&Q.viewport(E.copy(U)),G.length>0&&Gs(G,D,W),gt.length>0&&Gs(gt,D,W),Ct.length>0&&Gs(Ct,D,W),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Pd(T,D,W,U){let G=st.isWebGL2;Et===null&&(Et=new Ge(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Ts:Nn,minFilter:li,samples:G?4:0})),_.getDrawingBufferSize(wt),G?Et.setSize(wt.x,wt.y):Et.setSize(Hr(wt.x),Hr(wt.y));let gt=_.getRenderTarget();_.setRenderTarget(Et),_.getClearColor(F),O=_.getClearAlpha(),O<1&&_.setClearColor(16777215,.5),_.clear();let Ct=_.toneMapping;_.toneMapping=Dn,Gs(T,W,U),xt.updateMultisampleRenderTarget(Et),xt.updateRenderTargetMipmap(Et);let It=!1;for(let Ut=0,Gt=D.length;Ut0),Bt=!!W.morphAttributes.position,se=!!W.morphAttributes.normal,oe=!!W.morphAttributes.color,ze=Dn;U.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(ze=_.toneMapping);let an=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,he=an!==void 0?an.length:0,Wt=mt.get(U),_a=g.state.lights;if(ut===!0&&(pt===!0||T!==M)){let Ne=T===M&&U.id===L;Mt.setState(U,T,Ne)}let ue=!1;U.version===Wt.__version?(Wt.needsLights&&Wt.lightsStateVersion!==_a.state.version||Wt.outputColorSpace!==It||G.isInstancedMesh&&Wt.instancing===!1||!G.isInstancedMesh&&Wt.instancing===!0||G.isSkinnedMesh&&Wt.skinning===!1||!G.isSkinnedMesh&&Wt.skinning===!0||G.isInstancedMesh&&Wt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Wt.instancingColor===!1&&G.instanceColor!==null||Wt.envMap!==Ut||U.fog===!0&&Wt.fog!==gt||Wt.numClippingPlanes!==void 0&&(Wt.numClippingPlanes!==Mt.numPlanes||Wt.numIntersection!==Mt.numIntersection)||Wt.vertexAlphas!==Gt||Wt.vertexTangents!==Lt||Wt.morphTargets!==Bt||Wt.morphNormals!==se||Wt.morphColors!==oe||Wt.toneMapping!==ze||st.isWebGL2===!0&&Wt.morphTargetsCount!==he)&&(ue=!0):(ue=!0,Wt.__version=U.version);let Vn=Wt.currentProgram;ue===!0&&(Vn=Ws(U,D,G));let Qc=!1,os=!1,xa=!1,we=Vn.getUniforms(),Hn=Wt.uniforms;if(Q.useProgram(Vn.program)&&(Qc=!0,os=!0,xa=!0),U.id!==L&&(L=U.id,os=!0),Qc||M!==T){if(we.setValue(P,"projectionMatrix",T.projectionMatrix),st.logarithmicDepthBuffer&&we.setValue(P,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2)),M!==T&&(M=T,os=!0,xa=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let Ne=we.map.cameraPosition;Ne!==void 0&&Ne.setValue(P,Yt.setFromMatrixPosition(T.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&we.setValue(P,"isOrthographic",T.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||G.isSkinnedMesh)&&we.setValue(P,"viewMatrix",T.matrixWorldInverse)}if(G.isSkinnedMesh){we.setOptional(P,G,"bindMatrix"),we.setOptional(P,G,"bindMatrixInverse");let Ne=G.skeleton;Ne&&(st.floatVertexTextures?(Ne.boneTexture===null&&Ne.computeBoneTexture(),we.setValue(P,"boneTexture",Ne.boneTexture,xt),we.setValue(P,"boneTextureSize",Ne.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let va=W.morphAttributes;if((va.position!==void 0||va.normal!==void 0||va.color!==void 0&&st.isWebGL2===!0)&&Rt.update(G,W,Vn),(os||Wt.receiveShadow!==G.receiveShadow)&&(Wt.receiveShadow=G.receiveShadow,we.setValue(P,"receiveShadow",G.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Hn.envMap.value=Ut,Hn.flipEnvMap.value=Ut.isCubeTexture&&Ut.isRenderTargetTexture===!1?-1:1),os&&(we.setValue(P,"toneMappingExposure",_.toneMappingExposure),Wt.needsLights&&Id(Hn,xa),gt&&U.fog===!0&&nt.refreshFogUniforms(Hn,gt),nt.refreshMaterialUniforms(Hn,U,X,K,Et),qi.upload(P,Wt.uniformsList,Hn,xt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(qi.upload(P,Wt.uniformsList,Hn,xt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&we.setValue(P,"center",G.center),we.setValue(P,"modelViewMatrix",G.modelViewMatrix),we.setValue(P,"normalMatrix",G.normalMatrix),we.setValue(P,"modelMatrix",G.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Ne=U.uniformsGroups;for(let ya=0,Dd=Ne.length;ya0&&xt.useMultisampledRTT(T)===!1?G=mt.get(T).__webglMultisampledFramebuffer:Array.isArray(Lt)?G=Lt[W]:G=Lt,E.copy(T.viewport),V.copy(T.scissor),$=T.scissorTest}else E.copy(tt).multiplyScalar(X).floor(),V.copy(N).multiplyScalar(X).floor(),$=q;if(Q.bindFramebuffer(P.FRAMEBUFFER,G)&&st.drawBuffers&&U&&Q.drawBuffers(T,G),Q.viewport(E),Q.scissor(V),Q.setScissorTest($),gt){let Ut=mt.get(T.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+D,Ut.__webglTexture,W)}else if(Ct){let Ut=mt.get(T.texture),Gt=D||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Ut.__webglTexture,W||0,Gt)}L=-1},this.readRenderTargetPixels=function(T,D,W,U,G,gt,Ct){if(!(T&&T.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let It=mt.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&Ct!==void 0&&(It=It[Ct]),It){Q.bindFramebuffer(P.FRAMEBUFFER,It);try{let Ut=T.texture,Gt=Ut.format,Lt=Ut.type;if(Gt!==He&&vt.convert(Gt)!==P.getParameter(P.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Bt=Lt===Ts&&(Z.has("EXT_color_buffer_half_float")||st.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Lt!==Nn&&vt.convert(Lt)!==P.getParameter(P.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Lt===xn&&(st.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Bt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}D>=0&&D<=T.width-U&&W>=0&&W<=T.height-G&&P.readPixels(D,W,U,G,vt.convert(Gt),vt.convert(Lt),gt)}finally{let Ut=R!==null?mt.get(R).__webglFramebuffer:null;Q.bindFramebuffer(P.FRAMEBUFFER,Ut)}}},this.copyFramebufferToTexture=function(T,D,W=0){let U=Math.pow(2,-W),G=Math.floor(D.image.width*U),gt=Math.floor(D.image.height*U);xt.setTexture2D(D,0),P.copyTexSubImage2D(P.TEXTURE_2D,W,0,0,T.x,T.y,G,gt),Q.unbindTexture()},this.copyTextureToTexture=function(T,D,W,U=0){let G=D.image.width,gt=D.image.height,Ct=vt.convert(W.format),It=vt.convert(W.type);xt.setTexture2D(W,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,W.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,W.unpackAlignment),D.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,U,T.x,T.y,G,gt,Ct,It,D.image.data):D.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,U,T.x,T.y,D.mipmaps[0].width,D.mipmaps[0].height,Ct,D.mipmaps[0].data):P.texSubImage2D(P.TEXTURE_2D,U,T.x,T.y,Ct,It,D.image),U===0&&W.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(T,D,W,U,G=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let gt=T.max.x-T.min.x+1,Ct=T.max.y-T.min.y+1,It=T.max.z-T.min.z+1,Ut=vt.convert(U.format),Gt=vt.convert(U.type),Lt;if(U.isData3DTexture)xt.setTexture3D(U,0),Lt=P.TEXTURE_3D;else if(U.isDataArrayTexture)xt.setTexture2DArray(U,0),Lt=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);let Bt=P.getParameter(P.UNPACK_ROW_LENGTH),se=P.getParameter(P.UNPACK_IMAGE_HEIGHT),oe=P.getParameter(P.UNPACK_SKIP_PIXELS),ze=P.getParameter(P.UNPACK_SKIP_ROWS),an=P.getParameter(P.UNPACK_SKIP_IMAGES),he=W.isCompressedTexture?W.mipmaps[0]:W.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,he.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,he.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,T.min.x),P.pixelStorei(P.UNPACK_SKIP_ROWS,T.min.y),P.pixelStorei(P.UNPACK_SKIP_IMAGES,T.min.z),W.isDataTexture||W.isData3DTexture?P.texSubImage3D(Lt,G,D.x,D.y,D.z,gt,Ct,It,Ut,Gt,he.data):W.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),P.compressedTexSubImage3D(Lt,G,D.x,D.y,D.z,gt,Ct,It,Ut,he.data)):P.texSubImage3D(Lt,G,D.x,D.y,D.z,gt,Ct,It,Ut,Gt,he),P.pixelStorei(P.UNPACK_ROW_LENGTH,Bt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,se),P.pixelStorei(P.UNPACK_SKIP_PIXELS,oe),P.pixelStorei(P.UNPACK_SKIP_ROWS,ze),P.pixelStorei(P.UNPACK_SKIP_IMAGES,an),G===0&&U.generateMipmaps&&P.generateMipmap(Lt),Q.unbindTexture()},this.initTexture=function(T){T.isCubeTexture?xt.setTextureCube(T,0):T.isData3DTexture?xt.setTexture3D(T,0):T.isDataArrayTexture||T.isCompressedArrayTexture?xt.setTexture2DArray(T,0):xt.setTexture2D(T,0),Q.unbindTexture()},this.resetState=function(){b=0,w=0,R=null,Q.reset(),yt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vn}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Nt?si:fd}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===si?Nt:nn}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},Eo=class extends bo{};Eo.prototype.isWebGL1Renderer=!0;var To=class s{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ft(t),this.density=e}clone(){return new s(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},wo=class s{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ft(t),this.near=e,this.far=n}clone(){return new s(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ao=class extends Zt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}},Is=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=kr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Be()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:c,point:ds.clone(),uv:In.getInterpolation(ds,ur,ps,dr,bh,Za,Eh,new J),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};function fr(s,t,e,n,i,r){Ni.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(fs.x=r*Ni.x-i*Ni.y,fs.y=i*Ni.x+r*Ni.y):fs.copy(Ni),s.copy(t),s.x+=fs.x,s.y+=fs.y,s.applyMatrix4(Ed)}var pr=new A,Th=new A,Co=class extends Zt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let n=0,i=e.length;n0){let n,i;for(n=1,i=e.length;n0){pr.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(pr);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){pr.setFromMatrixPosition(t.matrixWorld),Th.setFromMatrixPosition(this.matrixWorld);let n=pr.distanceTo(Th)/t.zoom;e[0].object.visible=!0;let i,r;for(i=1,r=e.length;i=a)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;ic)continue;d.applyMatrix4(this.matrixWorld);let L=t.ray.origin.distanceTo(d);Lt.far||e.push({distance:L,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}else{let p=Math.max(0,a.start),v=Math.min(g.count,a.start+a.count);for(let _=p,y=v-1;_c)continue;d.applyMatrix4(this.matrixWorld);let w=t.ray.origin.distanceTo(d);wt.far||e.push({distance:w,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;ri.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,object:a})}}var Vh=class extends ye{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:pe,this.magFilter=r!==void 0?r:pe,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Hh=class extends ye{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=fe,this.minFilter=fe,this.generateMipmaps=!1,this.needsUpdate=!0}},Us=class extends ye{constructor(t,e,n,i,r,a,o,c,l,h,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}},Gh=class extends Us{constructor(t,e,n,i,r,a){super(t,e,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ce}},Wh=class extends Us{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Bn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},Xh=class extends ye{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Xe=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,r=n.length,a;e?a=e:a=t*n[r-1];let o=0,c=r-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-a,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===a)return i/(r-1);let h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),o=this.getPoint(r),c=e||(a.isVector2?new J:new A);return c.copy(o).sub(a).normalize(),c}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],r=[],a=[],o=new A,c=new Ot;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new A)}r[0]=new A,a[0]=new A;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let f=1;f<=t;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();let m=Math.acos(ae(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(c.makeRotationAxis(o,m))}a[f].crossVectors(i[f],r[f])}if(e===!0){let f=Math.acos(ae(r[0].dot(r[t]),-1,1));f/=t,i[0].dot(o.crossVectors(r[0],r[t]))>0&&(f=-f);for(let m=1;m<=t;m++)r[m].applyMatrix4(c.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],r[m])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Ds=class extends Xe{constructor(t=0,e=0,n=1,i=1,r=0,a=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=c}getPoint(t,e){let n=e||new J,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:c===0&&o===r-1&&(o=r-2,c=1);let l,h;this.closed||o>0?l=i[(o-1)%r]:(vr.subVectors(i[0],i[1]).add(i[0]),l=vr);let u=i[o%r],d=i[(o+1)%r];if(this.closed||o+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(qh(o,c.x,l.x,h.x,u.x),qh(o,c.y,l.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){let a=i[r]-n,o=this.curves[r],c=o.getLength(),l=c===0?0:1-a/c;return o.getPointAt(l,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},ra=class s extends Vt{constructor(t=[new J(0,-.5),new J(.5,0),new J(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ae(i,0,Math.PI*2);let r=[],a=[],o=[],c=[],l=[],h=1/e,u=new A,d=new J,f=new A,m=new A,x=new A,g=0,p=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,x.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(x.x,x.y,x.z);break;default:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=x.x,f.y+=x.y,f.z+=x.z,f.normalize(),c.push(f.x,f.y,f.z),x.copy(m)}for(let v=0;v<=e;v++){let _=n+v*h*i,y=Math.sin(_),b=Math.cos(_);for(let w=0;w<=t.length-1;w++){u.x=t[w].x*y,u.y=t[w].y,u.z=t[w].x*b,a.push(u.x,u.y,u.z),d.x=v/e,d.y=w/(t.length-1),o.push(d.x,d.y);let R=c[3*w+0]*y,L=c[3*w+1],M=c[3*w+0]*b;l.push(R,L,M)}}for(let v=0;v0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new _t(u,3)),this.setAttribute("normal",new _t(d,3)),this.setAttribute("uv",new _t(f,2));function v(){let y=new A,b=new A,w=0,R=(e-t)/n;for(let L=0;L<=r;L++){let M=[],E=L/r,V=E*(e-t)+t;for(let $=0;$<=i;$++){let F=$/i,O=F*c+o,z=Math.sin(O),K=Math.cos(O);b.x=V*z,b.y=-E*n+g,b.z=V*K,u.push(b.x,b.y,b.z),y.set(z,R,K).normalize(),d.push(y.x,y.y,y.z),f.push(F,1-E),M.push(m++)}x.push(M)}for(let L=0;L.9&&R<.1&&(_<.2&&(a[v+0]+=1),y<.2&&(a[v+2]+=1),b<.2&&(a[v+4]+=1))}}function d(v){r.push(v.x,v.y,v.z)}function f(v,_){let y=v*3;_.x=t[y+0],_.y=t[y+1],_.z=t[y+2]}function m(){let v=new A,_=new A,y=new A,b=new A,w=new J,R=new J,L=new J;for(let M=0,E=0;M80*e){o=l=s[0],c=h=s[1];for(let m=e;ml&&(l=u),d>h&&(h=d);f=Math.max(l-o,h-c),f=f!==0?32767/f:0}return Os(r,a,e,o,c,f,0),a}};function Td(s,t,e,n,i){let r,a;if(i===px(s,t,e,n)>0)for(r=t;r=t;r-=n)a=Yh(r,s[r],s[r+1],a);return a&&ga(a,a.next)&&(zs(a),a=a.next),a}function fi(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(ga(e,e.next)||ne(e.prev,e,e.next)===0)){if(zs(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Os(s,t,e,n,i,r,a){if(!s)return;!a&&r&&cx(s,n,i,r);let o=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?tx(s,n,i,r):j0(s)){t.push(c.i/e|0),t.push(s.i/e|0),t.push(l.i/e|0),zs(s),s=l.next,o=l.next;continue}if(s=l,s===o){a?a===1?(s=ex(fi(s),t,e),Os(s,t,e,n,i,r,2)):a===2&&nx(s,t,e,n,i,r):Os(fi(s),t,e,n,i,r,1);break}}}function j0(s){let t=s.prev,e=s,n=s.next;if(ne(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,o=t.y,c=e.y,l=n.y,h=ir?i>a?i:a:r>a?r:a,f=o>c?o>l?o:l:c>l?c:l,m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&Gi(i,o,r,c,a,l,m.x,m.y)&&ne(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function tx(s,t,e,n){let i=s.prev,r=s,a=s.next;if(ne(i,r,a)>=0)return!1;let o=i.x,c=r.x,l=a.x,h=i.y,u=r.y,d=a.y,f=oc?o>l?o:l:c>l?c:l,g=h>u?h>d?h:d:u>d?u:d,p=qo(f,m,t,e,n),v=qo(x,g,t,e,n),_=s.prevZ,y=s.nextZ;for(;_&&_.z>=p&&y&&y.z<=v;){if(_.x>=f&&_.x<=x&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&Gi(o,h,c,u,l,d,_.x,_.y)&&ne(_.prev,_,_.next)>=0||(_=_.prevZ,y.x>=f&&y.x<=x&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&Gi(o,h,c,u,l,d,y.x,y.y)&&ne(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;_&&_.z>=p;){if(_.x>=f&&_.x<=x&&_.y>=m&&_.y<=g&&_!==i&&_!==a&&Gi(o,h,c,u,l,d,_.x,_.y)&&ne(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=x&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&Gi(o,h,c,u,l,d,y.x,y.y)&&ne(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function ex(s,t,e){let n=s;do{let i=n.prev,r=n.next.next;!ga(i,r)&&wd(i,n,n.next,r)&&Bs(i,r)&&Bs(r,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(r.i/e|0),zs(n),zs(n.next),n=s=r),n=n.next}while(n!==s);return fi(n)}function nx(s,t,e,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&ux(a,o)){let c=Ad(a,o);a=fi(a,a.next),c=fi(c,c.next),Os(a,t,e,n,i,r,0),Os(c,t,e,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function ix(s,t,e,n){let i=[],r,a,o,c,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){let d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=r&&d>n&&(n=d,i=e.x=e.x&&e.x>=c&&r!==e.x&&Gi(ai.x||e.x===i.x&&ox(i,e)))&&(i=e,h=u)),e=e.next;while(e!==o);return i}function ox(s,t){return ne(s.prev,s,t.prev)<0&&ne(t.next,s,s.next)<0}function cx(s,t,e,n){let i=s;do i.z===0&&(i.z=qo(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,lx(i)}function lx(s){let t,e,n,i,r,a,o,c,l=1;do{for(e=s,s=null,r=null,a=0;e;){for(a++,n=e,o=0,t=0;t0||c>0&&n;)o!==0&&(c===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,o--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;e=n}r.nextZ=null,l*=2}while(a>1);return s}function qo(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function hx(s){let t=s,e=s;do(t.x=(s-a)*(r-o)&&(s-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(i-a)*(n-o)}function ux(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!dx(s,t)&&(Bs(s,t)&&Bs(t,s)&&fx(s,t)&&(ne(s.prev,s,t.prev)||ne(s,t.prev,t))||ga(s,t)&&ne(s.prev,s,s.next)>0&&ne(t.prev,t,t.next)>0)}function ne(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ga(s,t){return s.x===t.x&&s.y===t.y}function wd(s,t,e,n){let i=Er(ne(s,t,e)),r=Er(ne(s,t,n)),a=Er(ne(e,n,s)),o=Er(ne(e,n,t));return!!(i!==r&&a!==o||i===0&&br(s,e,t)||r===0&&br(s,n,t)||a===0&&br(e,s,n)||o===0&&br(e,t,n))}function br(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Er(s){return s>0?1:s<0?-1:0}function dx(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&wd(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Bs(s,t){return ne(s.prev,s,s.next)<0?ne(s,t,s.next)>=0&&ne(s,s.prev,t)>=0:ne(s,t,s.prev)<0||ne(s,s.next,t)<0}function fx(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function Ad(s,t){let e=new Yo(s.i,s.x,s.y),n=new Yo(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function Yh(s,t,e,n){let i=new Yo(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function zs(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Yo(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function px(s,t,e,n){let i=0;for(let r=t,a=e-n;r2&&s[t-1].equals(s[0])&&s.pop()}function Jh(s,t){for(let e=0;eNumber.EPSILON){let S=Math.sqrt(ie),B=Math.sqrt(Dt*Dt+Xt*Xt),nt=at.x-xt/S,et=at.y+mt/S,it=Z.x-Xt/B,Mt=Z.y+Dt/B,rt=((it-nt)*Xt-(Mt-et)*Dt)/(mt*Xt-xt*Dt);st=nt+mt*rt-P.x,Q=et+xt*rt-P.y;let k=st*st+Q*Q;if(k<=2)return new J(st,Q);St=Math.sqrt(k/2)}else{let S=!1;mt>Number.EPSILON?Dt>Number.EPSILON&&(S=!0):mt<-Number.EPSILON?Dt<-Number.EPSILON&&(S=!0):Math.sign(xt)===Math.sign(Xt)&&(S=!0),S?(st=-xt,Q=mt,St=Math.sqrt(ie)):(st=mt,Q=xt,St=Math.sqrt(ie/2))}return new J(st/St,Q/St)}let j=[];for(let P=0,at=O.length,Z=at-1,st=P+1;P=0;P--){let at=P/g,Z=f*Math.cos(at*Math.PI/2),st=m*Math.sin(at*Math.PI/2)+x;for(let Q=0,St=O.length;Q=0;){let st=Z,Q=Z-1;Q<0&&(Q=P.length-1);for(let St=0,mt=h+g*2;St0)&&f.push(_,y,w),(p!==n-1||c0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}},ac=class extends Me{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ft(16777215),this.specular=new ft(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mi,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=pa,this.reflectivity=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.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.flatShading=t.flatShading,this.fog=t.fog,this}},oc=class extends Me{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ft(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mi,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=t.gradientMap,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.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},cc=class extends Me{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mi,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),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.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}},lc=class extends Me{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mi,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=pa,this.reflectivity=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.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.flatShading=t.flatShading,this.fog=t.fog,this}},hc=class extends Me{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ft(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mi,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,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.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}},uc=class extends Ee{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}};function Ve(s,t,e){return Wc(s)?new s.constructor(s.subarray(t,e!==void 0?e:s.length)):s.slice(t,e)}function ei(s,t,e){return!s||!e&&s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function Wc(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Rd(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function dc(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){let o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function Xc(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push.apply(e,a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}function xx(s,t,e,n,i=30){let r=s.clone();r.name=t;let a=[];for(let c=0;c=n)){u.push(l.times[f]);for(let x=0;xr.tracks[c].times[0]&&(o=r.tracks[c].times[0]);for(let c=0;c=o.times[m]){let p=m*u+h,v=p+u-h;x=Ve(o.values,p,v)}else{let p=o.createInterpolant(),v=h,_=u-h;p.evaluate(r),x=Ve(p.resultBuffer,v,_)}c==="quaternion"&&new Pe().fromArray(x).normalize().conjugate().toArray(x);let g=l.times.length;for(let p=0;p=r)){let o=e[1];t=r)break e}a=n,n=0;break n}break t}for(;n>>1;te;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=Ve(n,r,a),this.values=Ve(this.values,r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(i!==void 0&&Wc(i))for(let o=0,c=i.length;o!==c;++o){let l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=Ve(this.times),e=Ve(this.values),n=this.getValueSize(),i=this.getInterpolation()===wa,r=t.length-1,a=1;for(let o=1;o0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=Ve(t,0,a),this.values=Ve(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=Ve(this.times,0),e=Ve(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};qe.prototype.TimeBufferType=Float32Array;qe.prototype.ValueBufferType=Float32Array;qe.prototype.DefaultInterpolation=Br;var zn=class extends qe{};zn.prototype.ValueTypeName="bool";zn.prototype.ValueBufferType=Array;zn.prototype.DefaultInterpolation=Or;zn.prototype.InterpolantFactoryMethodLinear=void 0;zn.prototype.InterpolantFactoryMethodSmooth=void 0;var ha=class extends qe{};ha.prototype.ValueTypeName="color";var es=class extends qe{};es.prototype.ValueTypeName="number";var mc=class extends ts{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e),l=t*o;for(let h=l+o;l!==h;l+=4)Pe.slerpFlat(r,0,a,l-o,a,l,c);return r}},pi=class extends qe{InterpolantFactoryMethodLinear(t){return new mc(this.times,this.values,this.getValueSize(),t)}};pi.prototype.ValueTypeName="quaternion";pi.prototype.DefaultInterpolation=Br;pi.prototype.InterpolantFactoryMethodSmooth=void 0;var kn=class extends qe{};kn.prototype.ValueTypeName="string";kn.prototype.ValueBufferType=Array;kn.prototype.DefaultInterpolation=Or;kn.prototype.InterpolantFactoryMethodLinear=void 0;kn.prototype.InterpolantFactoryMethodSmooth=void 0;var ns=class extends qe{};ns.prototype.ValueTypeName="vector";var is=class{constructor(t,e=-1,n,i=zc){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Be(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(Mx(n[a]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,a=n.length;r!==a;++r)e.push(qe.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,a=[];for(let o=0;o1){let u=h[1],d=i[u];d||(i[u]=d=[]),d.push(l)}}let a=[];for(let o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,d,f,m,x){if(f.length!==0){let g=[],p=[];Xc(f,g,p,m),g.length!==0&&x.push(new u(d,g,p))}},i=[],r=t.name||"default",a=t.fps||30,o=t.blendMode,c=t.length||-1,l=t.hierarchy||[];for(let u=0;u{e&&e(r),this.manager.itemEnd(t)},0),r;if(fn[t]!==void 0){fn[t].push({onLoad:e,onProgress:n,onError:i});return}fn[t]=[],fn[t].push({onLoad:e,onProgress:n,onError:i});let a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=fn[t],u=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),f=d?parseInt(d):0,m=f!==0,x=0,g=new ReadableStream({start(p){v();function v(){u.read().then(({done:_,value:y})=>{if(_)p.close();else{x+=y.byteLength;let b=new ProgressEvent("progress",{lengthComputable:m,loaded:x,total:f});for(let w=0,R=h.length;w{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o===void 0)return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(m=>f.decode(m))}}}).then(l=>{ss.add(t,l);let h=fn[t];delete fn[t];for(let u=0,d=h.length;u{let h=fn[t];if(h===void 0)throw this.manager.itemError(t),l;delete fn[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}},Qh=class extends Le{constructor(t){super(t)}load(t,e,n,i){let r=this,a=new rn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){try{e(r.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let r in t.uniforms){let a=t.uniforms[r];switch(i.uniforms[r]={},a.type){case"t":i.uniforms[r].value=n(a.value);break;case"c":i.uniforms[r].value=new ft().setHex(a.value);break;case"v2":i.uniforms[r].value=new J().fromArray(a.value);break;case"v3":i.uniforms[r].value=new A().fromArray(a.value);break;case"v4":i.uniforms[r].value=new $t().fromArray(a.value);break;case"m3":i.uniforms[r].value=new kt().fromArray(a.value);break;case"m4":i.uniforms[r].value=new Ot().fromArray(a.value);break;default:i.uniforms[r].value=a.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let r in t.extensions)i.extensions[r]=t.extensions[r];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let r=t.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new J().fromArray(r)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new J().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){let e={ShadowMaterial:ic,SpriteMaterial:Qr,RawShaderMaterial:sc,ShaderMaterial:Qe,PointsMaterial:ta,MeshPhysicalMaterial:rc,MeshStandardMaterial:ca,MeshPhongMaterial:ac,MeshToonMaterial:oc,MeshNormalMaterial:cc,MeshLambertMaterial:lc,MeshDepthMaterial:$r,MeshDistanceMaterial:Kr,MeshBasicMaterial:Mn,MeshMatcapMaterial:hc,LineDashedMaterial:uc,LineBasicMaterial:Ee,Material:Me};return new e[t]}},da=class{static decodeText(t){if(typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n0){let c=new ua(e);r=new rs(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,h=t.length;l0){i=new rs(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=t.length;a"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,a=ss.get(t);if(a!==void 0)return r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0),a;let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){ss.add(t,c),e&&e(c),r.manager.itemEnd(t)}).catch(function(c){i&&i(c),r.manager.itemError(t),r.manager.itemEnd(t)}),r.manager.itemStart(t)}},Tr,fa=class{static getContext(){return Tr===void 0&&(Tr=new(window.AudioContext||window.webkitAudioContext)),Tr}static setContext(t){Tr=t}},hu=class extends Le{constructor(t){super(t)}load(t,e,n,i){let r=this,a=new rn(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(c){try{let l=c.slice(0);fa.getContext().decodeAudioData(l,function(u){e(u)},o)}catch(l){o(l)}},n,i);function o(c){i?i(c):console.error(c),r.manager.itemError(t)}}},uu=class extends Vs{constructor(t,e,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;let i=new ft().set(t),r=new ft().set(e),a=new A(i.r,i.g,i.b),o=new A(r.r,r.g,r.b),c=Math.sqrt(Math.PI),l=c*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(c),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(l)}},du=class extends Vs{constructor(t,e=1){super(void 0,e),this.isAmbientLightProbe=!0;let n=new ft().set(t);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}},fu=new Ot,pu=new Ot,Yn=new Ot,mu=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new xe,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new xe,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Yn.copy(t.projectionMatrix);let i=e.eyeSep/2,r=i*e.near/e.focus,a=e.near*Math.tan(ai*e.fov*.5)/e.zoom,o,c;pu.elements[12]=-i,fu.elements[12]=i,o=-a*e.aspect+r,c=a*e.aspect+r,Yn.elements[0]=2*e.near/(c-o),Yn.elements[8]=(c+o)/(c-o),this.cameraL.projectionMatrix.copy(Yn),o=-a*e.aspect-r,c=a*e.aspect-r,Yn.elements[0]=2*e.near/(c-o),Yn.elements[8]=(c+o)/(c-o),this.cameraR.projectionMatrix.copy(Yn)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(pu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(fu)}},Pc=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=gu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function gu(){return(typeof performance>"u"?Date:performance).now()}var Zn=new A,_u=new Pe,Ex=new A,Jn=new A,xu=class extends Zt{constructor(){super(),this.type="AudioListener",this.context=fa.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Pc}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Zn,_u,Ex),Jn.set(0,0,-1).applyQuaternion(_u),e.positionX){let i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Zn.x,i),e.positionY.linearRampToValueAtTime(Zn.y,i),e.positionZ.linearRampToValueAtTime(Zn.z,i),e.forwardX.linearRampToValueAtTime(Jn.x,i),e.forwardY.linearRampToValueAtTime(Jn.y,i),e.forwardZ.linearRampToValueAtTime(Jn.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(Zn.x,Zn.y,Zn.z),e.setOrientation(Jn.x,Jn.y,Jn.z,n.x,n.y,n.z)}},Lc=class extends Zt{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(n[c]!==n[c+e]){o.setValue(n,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,a=i;r!==a;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let a=0;a!==r;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){Pe.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){let a=this._workIndex*r;Pe.multiplyQuaternionsFlat(t,a,t,e,t,n),Pe.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,r){let a=1-i;for(let o=0;o!==r;++o){let c=e+o;t[c]=t[c]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,r){for(let a=0;a!==r;++a){let o=e+a;t[o]=t[o]+t[n+a]*i}}},qc="\\[\\]\\.:\\/",wx=new RegExp("["+qc+"]","g"),Yc="[^"+qc+"]",Ax="[^"+qc.replace("\\.","")+"]",Rx=/((?:WC+[\/:])*)/.source.replace("WC",Yc),Cx=/(WCOD+)?/.source.replace("WCOD",Ax),Px=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yc),Lx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yc),Ix=new RegExp("^"+Rx+Cx+Px+Lx+"$"),Ux=["material","materials","bones","map"],Uc=class{constructor(t,e,n){let i=n||Jt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Jt=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(wx,"")}static parseTrackName(t){let e=Ix.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);Ux.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a=r){let u=r++,d=t[u];e[d.uuid]=h,t[h]=d,e[l]=u,t[u]=c;for(let f=0,m=i;f!==m;++f){let x=n[f],g=x[u],p=x[h];x[h]=g,x[u]=p}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=t.length;for(let o=0,c=arguments.length;o!==c;++o){let l=arguments[o],h=l.uuid,u=e[h];if(u!==void 0)if(delete e[h],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,x=i;m!==x;++m){let g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(i!==void 0)return r[i];let a=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,h=this.nCachedObjects_,u=new Array(l);i=r.length,n[t]=i,a.push(t),o.push(e),r.push(u);for(let d=h,f=c.length;d!==f;++d){let m=c[d];u[d]=new Jt(m,t,e)}return u}unsubscribe_(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,c=a[o],l=t[o];e[l]=n,a[n]=c,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}},Dc=class{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;let r=e.tracks,a=r.length,o=new Array(a),c={endingStart:zi,endingEnd:zi};for(let l=0;l!==a;++l){let h=r[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Mf,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let i=this._clip.duration,r=t._clip.duration,a=r/i,o=i/r;t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let i=this._mixer,r=i.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);let c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+n,l[0]=t/a,l[1]=e/a,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}let r=this._startTime;if(r!==null){let c=(t-r)*n;c<0||n===0?e=0:(this._startTime=null,e=n*c)}e*=this._updateTimeScale(t);let a=this._updateTime(e),o=this._updateWeight(t);if(o>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case dd:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case zc:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,i=this.time+t,r=this._loopCount,a=n===Sf;if(t===0)return r===-1?i:a&&(r&1)===1?e-i:i;if(n===yf){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){let o=Math.floor(i/e);i-=e*o,r+=Math.abs(o);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){let l=t<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){let i=this._interpolantSettings;n?(i.endingStart=ki,i.endingEnd=ki):(t?i.endingStart=this.zeroSlopeAtStart?ki:zi:i.endingStart=zr,e?i.endingEnd=this.zeroSlopeAtEnd?ki:zi:i.endingEnd=zr)}_scheduleFading(t,e,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=e,o[1]=r+t,c[1]=n,this}},Dx=new Float32Array(1),bu=class extends sn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,o=t._interpolants,c=n.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){let d=i[u],f=d.name,m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,f));continue}let x=e&&e._propertyBindings[u].binding.parsedPath;m=new Ic(Jt.create(n,f,x),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1;for(let l=0;l!==n;++l)e[l]._update(i,t,r,a);let o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(t){this.time=0;for(let e=0;ethis.max.x||t.ythis.max.y)}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}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))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Iu).distanceTo(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}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)}},Du=new A,wr=new A,Nu=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Du.subVectors(t,this.start),wr.subVectors(this.end,this.start);let n=wr.dot(wr),r=wr.dot(Du)/n;return e&&(r=ae(r,0,1)),r}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Fu=new A,Ou=class extends Zt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Vt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,c=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Qu.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Qu,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},td=class extends je{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Vt;i.setAttribute("position",new _t(e,3)),i.setAttribute("color",new _t(n,3));let r=new Ee({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new ft,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},ed=class{constructor(){this.type="ShapePath",this.color=new ft,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new ji,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,a){return this.currentPath.bezierCurveTo(t,e,n,i,r,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){let v=[];for(let _=0,y=p.length;_Number.EPSILON){if(E<0&&(R=v[w],M=-M,L=v[b],E=-E),p.yL.y)continue;if(p.y===R.y){if(p.x===R.x)return!0}else{let V=E*(p.x-R.x)-M*(p.y-R.y);if(V===0)return!0;if(V<0)continue;y=!y}}else{if(p.y!==R.y)continue;if(L.x<=p.x&&p.x<=R.x||R.x<=p.x&&p.x<=L.x)return!0}}return y}let i=yn.isClockWise,r=this.subPaths;if(r.length===0)return[];let a,o,c,l=[];if(r.length===1)return o=r[0],c=new Fn,c.curves=o.curves,l.push(c),l;let h=!i(r[0].getPoints());h=t?!h:h;let u=[],d=[],f=[],m=0,x;d[m]=void 0,f[m]=[];for(let p=0,v=r.length;p1){let p=!1,v=0;for(let _=0,y=d.length;_0&&p===!1&&(f=u)}let g;for(let p=0,v=d.length;p "") + return Dict(:vertexarrays => serialize_named_buffer(program.vertexarray), :faces => indices, :uniforms => uniforms, - :vertex_source => program.vertex_source, - :fragment_source => program.fragment_source, + :vertex_source => update_shader(program.vertex_source), + :fragment_source => update_shader(program.fragment_source), :uniform_updater => uniform_updater(program.uniforms), :attribute_updater => attribute_updater) end diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 82c6a79c969..1598d73f3fe 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -2,266 +2,564 @@ // deno-lint-ignore-file // This code was bundled using `deno bundle` and it's not recommended to edit it manually -var ca = "136", Gy = { +var Fc = "155", Ox = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 -}, Vy = { +}, Bx = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 -}, uu = 0, tl = 1, du = 2, Wy = 3, qy = 0, Hc = 1, fu = 2, ir = 3, Ai = 0, it = 1, Ci = 2, kc = 1, Xy = 2, vn = 0, sr = 1, nl = 2, il = 3, rl = 4, pu = 5, _i = 100, mu = 101, gu = 102, sl = 103, ol = 104, xu = 200, yu = 201, vu = 202, _u = 203, Gc = 204, Vc = 205, Mu = 206, bu = 207, wu = 208, Su = 209, Tu = 210, Eu = 0, Au = 1, Cu = 2, ea = 3, Lu = 4, Ru = 5, Pu = 6, Iu = 7, Vs = 0, Du = 1, Fu = 2, _n = 0, Nu = 1, Bu = 2, zu = 3, Uu = 4, Ou = 5, ha = 300, Bi = 301, zi = 302, Ds = 303, Fs = 304, Pr = 306, Ws = 307, Ns = 1e3, vt = 1001, Bs = 1002, rt = 1003, ta = 1004, Jy = 1004, na = 1005, Yy = 1005, tt = 1006, Wc = 1007, Zy = 1007, Ui = 1008, $y = 1008, rn = 1009, Hu = 1010, ku = 1011, cr = 1012, Gu = 1013, Ps = 1014, nn = 1015, kn = 1016, Vu = 1017, Wu = 1018, qu = 1019, Ti = 1020, Xu = 1021, Gn = 1022, ct = 1023, Ju = 1024, Yu = 1025, Vn = 1026, Li = 1027, Zu = 1028, $u = 1029, ju = 1030, Qu = 1031, Ku = 1032, ed = 1033, al = 33776, ll = 33777, cl = 33778, hl = 33779, ul = 35840, dl = 35841, fl = 35842, pl = 35843, td = 36196, ml = 37492, gl = 37496, nd = 37808, id = 37809, rd = 37810, sd = 37811, od = 37812, ad = 37813, ld = 37814, cd = 37815, hd = 37816, ud = 37817, dd = 37818, fd = 37819, pd = 37820, md = 37821, gd = 36492, xd = 37840, yd = 37841, vd = 37842, _d = 37843, Md = 37844, bd = 37845, wd = 37846, Sd = 37847, Td = 37848, Ed = 37849, Ad = 37850, Cd = 37851, Ld = 37852, Rd = 37853, Pd = 2200, Id = 2201, Dd = 2202, zs = 2300, Us = 2301, yo = 2302, Mi = 2400, bi = 2401, Os = 2402, ua = 2500, qc = 2501, Fd = 0, jy = 1, Qy = 2, Nt = 3e3, Oi = 3001, Nd = 3200, Bd = 3201, Hi = 0, zd = 1, Ky = 0, vo = 7680, e0 = 7681, t0 = 7682, n0 = 7683, i0 = 34055, r0 = 34056, s0 = 5386, o0 = 512, a0 = 513, l0 = 514, c0 = 515, h0 = 516, u0 = 517, d0 = 518, Ud = 519, hr = 35044, ur = 35048, f0 = 35040, p0 = 35045, m0 = 35049, g0 = 35041, x0 = 35046, y0 = 35050, v0 = 35042, _0 = "100", xl = "300 es", En = class { - addEventListener(e, t) { +}, Nd = 0, tl = 1, Fd = 2, zx = 3, kx = 0, nd = 1, Od = 2, pn = 3, On = 0, De = 1, gn = 2, Vx = 2, Un = 0, Wi = 1, el = 2, nl = 3, il = 4, Bd = 5, Bi = 100, zd = 101, kd = 102, sl = 103, rl = 104, Vd = 200, Hd = 201, Gd = 202, Wd = 203, id = 204, sd = 205, Xd = 206, qd = 207, Yd = 208, Zd = 209, Jd = 210, $d = 0, Kd = 1, Qd = 2, ao = 3, jd = 4, tf = 5, ef = 6, nf = 7, pa = 0, sf = 1, rf = 2, Dn = 0, af = 1, of = 2, cf = 3, lf = 4, hf = 5, Oc = 300, Bn = 301, ci = 302, Ur = 303, Dr = 304, Hs = 306, Nr = 1e3, Ce = 1001, Fr = 1002, fe = 1003, oo = 1004, Hx = 1004, Ir = 1005, Gx = 1005, pe = 1006, rd = 1007, Wx = 1007, li = 1008, Xx = 1008, Nn = 1009, uf = 1010, df = 1011, Bc = 1012, ad = 1013, Pn = 1014, xn = 1015, Ts = 1016, od = 1017, cd = 1018, ni = 1020, ff = 1021, He = 1023, pf = 1024, mf = 1025, ii = 1026, Yi = 1027, gf = 1028, ld = 1029, _f = 1030, hd = 1031, ud = 1033, Ma = 33776, Sa = 33777, ba = 33778, Ea = 33779, al = 35840, ol = 35841, cl = 35842, ll = 35843, xf = 36196, hl = 37492, ul = 37496, dl = 37808, fl = 37809, pl = 37810, ml = 37811, gl = 37812, _l = 37813, xl = 37814, vl = 37815, yl = 37816, Ml = 37817, Sl = 37818, bl = 37819, El = 37820, Tl = 37821, Ta = 36492, vf = 36283, wl = 36284, Al = 36285, Rl = 36286, yf = 2200, Mf = 2201, Sf = 2202, Or = 2300, Br = 2301, wa = 2302, zi = 2400, ki = 2401, zr = 2402, zc = 2500, dd = 2501, qx = 0, Yx = 1, Zx = 2, fd = 3e3, si = 3001, bf = 3200, Ef = 3201, mi = 0, Tf = 1, ri = "", Nt = "srgb", nn = "srgb-linear", pd = "display-p3", Jx = 0, Aa = 7680, $x = 7681, Kx = 7682, Qx = 7683, jx = 34055, tv = 34056, ev = 5386, nv = 512, iv = 513, sv = 514, rv = 515, av = 516, ov = 517, cv = 518, wf = 519, Af = 512, Rf = 513, Cf = 514, Pf = 515, Lf = 516, If = 517, Uf = 518, Df = 519, kr = 35044, lv = 35048, hv = 35040, uv = 35045, dv = 35049, fv = 35041, pv = 35046, mv = 35050, gv = 35042, _v = "100", Cl = "300 es", co = 1035, vn = 2e3, Vr = 2001, sn = class { + addEventListener(t, e) { this._listeners === void 0 && (this._listeners = {}); let n = this._listeners; - n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); + n[t] === void 0 && (n[t] = []), n[t].indexOf(e) === -1 && n[t].push(e); } - hasEventListener(e, t) { + hasEventListener(t, e) { if (this._listeners === void 0) return !1; let n = this._listeners; - return n[e] !== void 0 && n[e].indexOf(t) !== -1; + return n[t] !== void 0 && n[t].indexOf(e) !== -1; } - removeEventListener(e, t) { + removeEventListener(t, e) { if (this._listeners === void 0) return; - let i = this._listeners[e]; + let i = this._listeners[t]; if (i !== void 0) { - let r = i.indexOf(t); + let r = i.indexOf(e); r !== -1 && i.splice(r, 1); } } - dispatchEvent(e) { + dispatchEvent(t) { if (this._listeners === void 0) return; - let n = this._listeners[e.type]; + let n = this._listeners[t.type]; if (n !== void 0) { - e.target = this; + t.target = this; let i = n.slice(0); - for(let r = 0, o = i.length; r < o; r++)i[r].call(this, e); - e.target = null; - } - } -}, pt = []; -for(let s = 0; s < 256; s++)pt[s] = (s < 16 ? "0" : "") + s.toString(16); -var Vr = 1234567, Wn = Math.PI / 180, dr = 180 / Math.PI; -function Et() { - let s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; - return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[e & 255] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 15 | 64] + pt[e >> 24 & 255] + "-" + pt[t & 63 | 128] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 255] + pt[t >> 24 & 255] + pt[n & 255] + pt[n >> 8 & 255] + pt[n >> 16 & 255] + pt[n >> 24 & 255]).toUpperCase(); -} -function mt(s, e, t) { - return Math.max(e, Math.min(t, s)); -} -function da(s, e) { - return (s % e + e) % e; -} -function Od(s, e, t, n, i) { - return n + (s - e) * (i - n) / (t - e); -} -function Hd(s, e, t) { - return s !== e ? (t - s) / (e - s) : 0; -} -function or(s, e, t) { - return (1 - t) * s + t * e; -} -function kd(s, e, t, n) { - return or(s, e, 1 - Math.exp(-t * n)); -} -function Gd(s, e = 1) { - return e - Math.abs(da(s, e * 2) - e); -} -function Vd(s, e, t) { - return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s)); -} -function Wd(s, e, t) { - return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10)); -} -function qd(s, e) { - return s + Math.floor(Math.random() * (e - s + 1)); -} -function Xd(s, e) { - return s + Math.random() * (e - s); -} -function Jd(s) { - return s * (.5 - Math.random()); -} -function Yd(s) { - return s !== void 0 && (Vr = s % 2147483647), Vr = Vr * 16807 % 2147483647, (Vr - 1) / 2147483646; -} -function Zd(s) { - return s * Wn; -} -function $d(s) { - return s * dr; -} -function ia(s) { - return (s & s - 1) === 0 && s !== 0; -} -function Xc(s) { - return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2)); -} -function Jc(s) { - return Math.pow(2, Math.floor(Math.log(s) / Math.LN2)); -} -function jd(s, e, t, n, i) { - let r = Math.cos, o = Math.sin, a = r(t / 2), l = o(t / 2), c = r((e + n) / 2), h = o((e + n) / 2), u = r((e - n) / 2), d = o((e - n) / 2), f = r((n - e) / 2), m = o((n - e) / 2); + for(let r = 0, a = i.length; r < a; r++)i[r].call(this, t); + t.target = null; + } + } +}, Se = [ + "00", + "01", + "02", + "03", + "04", + "05", + "06", + "07", + "08", + "09", + "0a", + "0b", + "0c", + "0d", + "0e", + "0f", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "1a", + "1b", + "1c", + "1d", + "1e", + "1f", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "2a", + "2b", + "2c", + "2d", + "2e", + "2f", + "30", + "31", + "32", + "33", + "34", + "35", + "36", + "37", + "38", + "39", + "3a", + "3b", + "3c", + "3d", + "3e", + "3f", + "40", + "41", + "42", + "43", + "44", + "45", + "46", + "47", + "48", + "49", + "4a", + "4b", + "4c", + "4d", + "4e", + "4f", + "50", + "51", + "52", + "53", + "54", + "55", + "56", + "57", + "58", + "59", + "5a", + "5b", + "5c", + "5d", + "5e", + "5f", + "60", + "61", + "62", + "63", + "64", + "65", + "66", + "67", + "68", + "69", + "6a", + "6b", + "6c", + "6d", + "6e", + "6f", + "70", + "71", + "72", + "73", + "74", + "75", + "76", + "77", + "78", + "79", + "7a", + "7b", + "7c", + "7d", + "7e", + "7f", + "80", + "81", + "82", + "83", + "84", + "85", + "86", + "87", + "88", + "89", + "8a", + "8b", + "8c", + "8d", + "8e", + "8f", + "90", + "91", + "92", + "93", + "94", + "95", + "96", + "97", + "98", + "99", + "9a", + "9b", + "9c", + "9d", + "9e", + "9f", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "a8", + "a9", + "aa", + "ab", + "ac", + "ad", + "ae", + "af", + "b0", + "b1", + "b2", + "b3", + "b4", + "b5", + "b6", + "b7", + "b8", + "b9", + "ba", + "bb", + "bc", + "bd", + "be", + "bf", + "c0", + "c1", + "c2", + "c3", + "c4", + "c5", + "c6", + "c7", + "c8", + "c9", + "ca", + "cb", + "cc", + "cd", + "ce", + "cf", + "d0", + "d1", + "d2", + "d3", + "d4", + "d5", + "d6", + "d7", + "d8", + "d9", + "da", + "db", + "dc", + "dd", + "de", + "df", + "e0", + "e1", + "e2", + "e3", + "e4", + "e5", + "e6", + "e7", + "e8", + "e9", + "ea", + "eb", + "ec", + "ed", + "ee", + "ef", + "f0", + "f1", + "f2", + "f3", + "f4", + "f5", + "f6", + "f7", + "f8", + "f9", + "fa", + "fb", + "fc", + "fd", + "fe", + "ff" +], Pl = 1234567, ai = Math.PI / 180, Zi = 180 / Math.PI; +function Be() { + let s1 = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0; + return (Se[s1 & 255] + Se[s1 >> 8 & 255] + Se[s1 >> 16 & 255] + Se[s1 >> 24 & 255] + "-" + Se[t & 255] + Se[t >> 8 & 255] + "-" + Se[t >> 16 & 15 | 64] + Se[t >> 24 & 255] + "-" + Se[e & 63 | 128] + Se[e >> 8 & 255] + "-" + Se[e >> 16 & 255] + Se[e >> 24 & 255] + Se[n & 255] + Se[n >> 8 & 255] + Se[n >> 16 & 255] + Se[n >> 24 & 255]).toLowerCase(); +} +function ae(s1, t, e) { + return Math.max(t, Math.min(e, s1)); +} +function kc(s1, t) { + return (s1 % t + t) % t; +} +function Nf(s1, t, e, n, i) { + return n + (s1 - t) * (i - n) / (e - t); +} +function Ff(s1, t, e) { + return s1 !== t ? (e - s1) / (t - s1) : 0; +} +function ys(s1, t, e) { + return (1 - e) * s1 + e * t; +} +function Of(s1, t, e, n) { + return ys(s1, t, 1 - Math.exp(-e * n)); +} +function Bf(s1, t = 1) { + return t - Math.abs(kc(s1, t * 2) - t); +} +function zf(s1, t, e) { + return s1 <= t ? 0 : s1 >= e ? 1 : (s1 = (s1 - t) / (e - t), s1 * s1 * (3 - 2 * s1)); +} +function kf(s1, t, e) { + return s1 <= t ? 0 : s1 >= e ? 1 : (s1 = (s1 - t) / (e - t), s1 * s1 * s1 * (s1 * (s1 * 6 - 15) + 10)); +} +function Vf(s1, t) { + return s1 + Math.floor(Math.random() * (t - s1 + 1)); +} +function Hf(s1, t) { + return s1 + Math.random() * (t - s1); +} +function Gf(s1) { + return s1 * (.5 - Math.random()); +} +function Wf(s1) { + s1 !== void 0 && (Pl = s1); + let t = Pl += 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 Xf(s1) { + return s1 * ai; +} +function qf(s1) { + return s1 * Zi; +} +function lo(s1) { + return (s1 & s1 - 1) === 0 && s1 !== 0; +} +function md(s1) { + return Math.pow(2, Math.ceil(Math.log(s1) / Math.LN2)); +} +function Hr(s1) { + return Math.pow(2, Math.floor(Math.log(s1) / Math.LN2)); +} +function Yf(s1, t, e, n, i) { + let r = Math.cos, a = Math.sin, o = r(e / 2), c = a(e / 2), l = r((t + n) / 2), h = a((t + n) / 2), u = r((t - n) / 2), d = a((t - n) / 2), f = r((n - t) / 2), m = a((n - t) / 2); switch(i){ case "XYX": - s.set(a * h, l * u, l * d, a * c); + s1.set(o * h, c * u, c * d, o * l); break; case "YZY": - s.set(l * d, a * h, l * u, a * c); + s1.set(c * d, o * h, c * u, o * l); break; case "ZXZ": - s.set(l * u, l * d, a * h, a * c); + s1.set(c * u, c * d, o * h, o * l); break; case "XZX": - s.set(a * h, l * m, l * f, a * c); + s1.set(o * h, c * m, c * f, o * l); break; case "YXY": - s.set(l * f, a * h, l * m, a * c); + s1.set(c * f, o * h, c * m, o * l); break; case "ZYZ": - s.set(l * m, l * f, a * h, a * c); + s1.set(c * m, c * f, o * h, o * l); break; default: console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); } } -var M0 = Object.freeze({ - __proto__: null, - DEG2RAD: Wn, - RAD2DEG: dr, - generateUUID: Et, - clamp: mt, - euclideanModulo: da, - mapLinear: Od, - inverseLerp: Hd, - lerp: or, - damp: kd, - pingpong: Gd, - smoothstep: Vd, - smootherstep: Wd, - randInt: qd, - randFloat: Xd, - randFloatSpread: Jd, - seededRandom: Yd, - degToRad: Zd, - radToDeg: $d, - isPowerOfTwo: ia, - ceilPowerOfTwo: Xc, - floorPowerOfTwo: Jc, - setQuaternionFromProperEuler: jd -}), X = class { - constructor(e = 0, t = 0){ - this.x = e, this.y = t; +function Ue(s1, t) { + switch(t.constructor){ + case Float32Array: + return s1; + case Uint32Array: + return s1 / 4294967295; + case Uint16Array: + return s1 / 65535; + case Uint8Array: + return s1 / 255; + case Int32Array: + return Math.max(s1 / 2147483647, -1); + case Int16Array: + return Math.max(s1 / 32767, -1); + case Int8Array: + return Math.max(s1 / 127, -1); + default: + throw new Error("Invalid component type."); + } +} +function Ft(s1, t) { + switch(t.constructor){ + case Float32Array: + return s1; + case Uint32Array: + return Math.round(s1 * 4294967295); + case Uint16Array: + return Math.round(s1 * 65535); + case Uint8Array: + return Math.round(s1 * 255); + case Int32Array: + return Math.round(s1 * 2147483647); + case Int16Array: + return Math.round(s1 * 32767); + case Int8Array: + return Math.round(s1 * 127); + default: + throw new Error("Invalid component type."); + } +} +var xv = { + DEG2RAD: ai, + RAD2DEG: Zi, + generateUUID: Be, + clamp: ae, + euclideanModulo: kc, + mapLinear: Nf, + inverseLerp: Ff, + lerp: ys, + damp: Of, + pingpong: Bf, + smoothstep: zf, + smootherstep: kf, + randInt: Vf, + randFloat: Hf, + randFloatSpread: Gf, + seededRandom: Wf, + degToRad: Xf, + radToDeg: qf, + isPowerOfTwo: lo, + ceilPowerOfTwo: md, + floorPowerOfTwo: Hr, + setQuaternionFromProperEuler: Yf, + normalize: Ft, + denormalize: Ue +}, J = class s1 { + constructor(t = 0, e = 0){ + s1.prototype.isVector2 = !0, this.x = t, this.y = e; } get width() { return this.x; } - set width(e) { - this.x = e; + set width(t) { + this.x = t; } get height() { return this.y; } - set height(e) { - this.y = e; + set height(t) { + this.y = t; } - set(e, t) { - return this.x = e, this.y = t, this; + set(t, e) { + return this.x = t, this.y = e, this; } - setScalar(e) { - return this.x = e, this.y = e, this; + setScalar(t) { + return this.x = t, this.y = t, this; } - setX(e) { - return this.x = e, this; + setX(t) { + return this.x = t, this; } - setY(e) { - return this.y = e, this; + setY(t) { + return this.y = t, this; } - setComponent(e, t) { - switch(e){ + setComponent(t, e) { + switch(t){ case 0: - this.x = t; + this.x = e; break; case 1: - this.y = t; + this.y = e; break; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } return this; } - getComponent(e) { - switch(e){ + getComponent(t) { + switch(t){ case 0: return this.x; case 1: return this.y; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } } clone() { return new this.constructor(this.x, this.y); } - copy(e) { - return this.x = e.x, this.y = e.y, this; + copy(t) { + return this.x = t.x, this.y = t.y, this; } - add(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this); + add(t) { + return this.x += t.x, this.y += t.y, this; } - addScalar(e) { - return this.x += e, this.y += e, this; + addScalar(t) { + return this.x += t, this.y += t, this; } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this; + addVectors(t, e) { + return this.x = t.x + e.x, this.y = t.y + e.y, this; } - addScaledVector(e, t) { - return this.x += e.x * t, this.y += e.y * t, this; + addScaledVector(t, e) { + return this.x += t.x * e, this.y += t.y * e, this; } - sub(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this); + sub(t) { + return this.x -= t.x, this.y -= t.y, this; } - subScalar(e) { - return this.x -= e, this.y -= e, this; + subScalar(t) { + return this.x -= t, this.y -= t, this; } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this; + subVectors(t, e) { + return this.x = t.x - e.x, this.y = t.y - e.y, this; } - multiply(e) { - return this.x *= e.x, this.y *= e.y, this; + multiply(t) { + return this.x *= t.x, this.y *= t.y, this; } - multiplyScalar(e) { - return this.x *= e, this.y *= e, this; + multiplyScalar(t) { + return this.x *= t, this.y *= t, this; } - divide(e) { - return this.x /= e.x, this.y /= e.y, this; + divide(t) { + return this.x /= t.x, this.y /= t.y, this; } - divideScalar(e) { - return this.multiplyScalar(1 / e); + divideScalar(t) { + return this.multiplyScalar(1 / t); } - applyMatrix3(e) { - let t = this.x, n = this.y, i = e.elements; - return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this; + applyMatrix3(t) { + let e = this.x, n = this.y, i = t.elements; + return this.x = i[0] * e + i[3] * n + i[6], this.y = i[1] * e + i[4] * n + i[7], this; } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; + min(t) { + return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this; } - max(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; + max(t) { + return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this; } - clamp(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this; + clamp(t, e) { + return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this; } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this; + clampScalar(t, e) { + return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this; } - clampLength(e, t) { + clampLength(t, e) { let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n))); } floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this; @@ -278,11 +576,11 @@ var M0 = Object.freeze({ negate() { return this.x = -this.x, this.y = -this.y, this; } - dot(e) { - return this.x * e.x + this.y * e.y; + dot(t) { + return this.x * t.x + this.y * t.y; } - cross(e) { - return this.x * e.y - this.y * e.x; + cross(t) { + return this.x * t.y - this.y * t.x; } lengthSq() { return this.x * this.x + this.y * this.y; @@ -299,40 +597,46 @@ var M0 = Object.freeze({ angle() { return Math.atan2(-this.y, -this.x) + Math.PI; } - distanceTo(e) { - return Math.sqrt(this.distanceToSquared(e)); + 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(ae(n, -1, 1)); } - distanceToSquared(e) { - let t = this.x - e.x, n = this.y - e.y; - return t * t + n * n; + distanceTo(t) { + return Math.sqrt(this.distanceToSquared(t)); } - manhattanDistanceTo(e) { - return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); + distanceToSquared(t) { + let e = this.x - t.x, n = this.y - t.y; + return e * e + n * n; } - setLength(e) { - return this.normalize().multiplyScalar(e); + manhattanDistanceTo(t) { + return Math.abs(this.x - t.x) + Math.abs(this.y - t.y); } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; + setLength(t) { + return this.normalize().multiplyScalar(t); } - lerpVectors(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; + lerp(t, e) { + return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this; } - equals(e) { - return e.x === this.x && e.y === this.y; + lerpVectors(t, e, n) { + return this.x = t.x + (e.x - t.x) * n, this.y = t.y + (e.y - t.y) * n, this; } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this; + equals(t) { + return t.x === this.x && t.y === this.y; } - toArray(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e; + fromArray(t, e = 0) { + return this.x = t[e], this.y = t[e + 1], this; } - fromBufferAttribute(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this; + toArray(t = [], e = 0) { + return t[e] = this.x, t[e + 1] = this.y, t; } - rotateAround(e, t) { - let n = Math.cos(t), i = Math.sin(t), r = this.x - e.x, o = this.y - e.y; - return this.x = r * n - o * i + e.x, this.y = r * i + o * n + e.y, this; + fromBufferAttribute(t, e) { + return this.x = t.getX(e), this.y = t.getY(e), this; + } + rotateAround(t, e) { + let n = Math.cos(e), i = Math.sin(e), r = this.x - t.x, a = this.y - t.y; + return this.x = r * n - a * i + t.x, this.y = r * i + a * n + t.y, this; } random() { return this.x = Math.random(), this.y = Math.random(), this; @@ -340,11 +644,9 @@ var M0 = Object.freeze({ *[Symbol.iterator]() { yield this.x, yield this.y; } -}; -X.prototype.isVector2 = !0; -var lt = class { - constructor(){ - this.elements = [ +}, kt = class s1 { + constructor(t, e, n, i, r, a, o, c, l){ + s1.prototype.isMatrix3 = !0, this.elements = [ 1, 0, 0, @@ -354,102 +656,106 @@ var lt = class { 0, 0, 1 - ], arguments.length > 0 && console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead."); + ], t !== void 0 && this.set(t, e, n, i, r, a, o, c, l); } - set(e, t, n, i, r, o, a, l, c) { + set(t, e, n, i, r, a, o, c, l) { let h = this.elements; - return h[0] = e, h[1] = i, h[2] = a, h[3] = t, h[4] = r, h[5] = l, h[6] = n, h[7] = o, h[8] = c, this; + return h[0] = t, h[1] = i, h[2] = o, h[3] = e, h[4] = r, h[5] = c, h[6] = n, h[7] = a, h[8] = l, this; } identity() { return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; } - copy(e) { - let t = this.elements, n = e.elements; - return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], 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(e, t, n) { - return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; + extractBasis(t, e, n) { + return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; } - setFromMatrix4(e) { - let t = e.elements; - return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), 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(e) { - return this.multiplyMatrices(this, e); + multiply(t) { + return this.multiplyMatrices(this, t); } - premultiply(e) { - return this.multiplyMatrices(e, this); + premultiply(t) { + return this.multiplyMatrices(t, this); } - multiplyMatrices(e, t) { - let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[3], l = n[6], c = n[1], h = n[4], u = n[7], d = n[2], f = n[5], m = n[8], x = i[0], v = i[3], g = i[6], p = i[1], _ = i[4], y = i[7], b = i[2], A = i[5], L = i[8]; - return r[0] = o * x + a * p + l * b, r[3] = o * v + a * _ + l * A, r[6] = o * g + a * y + l * L, r[1] = c * x + h * p + u * b, r[4] = c * v + h * _ + u * A, r[7] = c * g + h * y + u * L, r[2] = d * x + f * p + m * b, r[5] = d * v + f * _ + m * A, r[8] = d * g + f * y + m * L, this; + multiplyMatrices(t, e) { + let n = t.elements, i = e.elements, r = this.elements, a = n[0], o = n[3], c = n[6], l = n[1], h = n[4], u = n[7], d = n[2], f = n[5], m = n[8], x = i[0], g = i[3], p = i[6], v = i[1], _ = i[4], y = i[7], b = i[2], w = i[5], R = i[8]; + return r[0] = a * x + o * v + c * b, r[3] = a * g + o * _ + c * w, r[6] = a * p + o * y + c * R, r[1] = l * x + h * v + u * b, r[4] = l * g + h * _ + u * w, r[7] = l * p + h * y + u * R, r[2] = d * x + f * v + m * b, r[5] = d * g + f * _ + m * w, r[8] = d * p + f * y + m * R, this; } - multiplyScalar(e) { - let t = this.elements; - return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, 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 e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8]; - return t * o * h - t * a * c - n * r * h + n * a * l + i * r * c - i * o * l; + let t = this.elements, e = t[0], n = t[1], i = t[2], r = t[3], a = t[4], o = t[5], c = t[6], l = t[7], h = t[8]; + return e * a * h - e * o * l - n * r * h + n * o * c + i * r * l - i * a * c; } invert() { - let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = h * o - a * c, d = a * l - h * r, f = c * r - o * l, m = t * u + n * d + i * f; + let t = this.elements, e = t[0], n = t[1], i = t[2], r = t[3], a = t[4], o = t[5], c = t[6], l = t[7], h = t[8], u = h * a - o * l, d = o * c - h * r, f = l * r - a * c, m = e * u + n * d + i * f; if (m === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); let x = 1 / m; - return e[0] = u * x, e[1] = (i * c - h * n) * x, e[2] = (a * n - i * o) * x, e[3] = d * x, e[4] = (h * t - i * l) * x, e[5] = (i * r - a * t) * x, e[6] = f * x, e[7] = (n * l - c * t) * x, e[8] = (o * t - n * r) * x, this; + return t[0] = u * x, t[1] = (i * l - h * n) * x, t[2] = (o * n - i * a) * x, t[3] = d * x, t[4] = (h * e - i * c) * x, t[5] = (i * r - o * e) * x, t[6] = f * x, t[7] = (n * c - l * e) * x, t[8] = (a * e - n * r) * x, this; } transpose() { - let e, t = this.elements; - return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this; + 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(e) { - return this.setFromMatrix4(e).invert().transpose(); + getNormalMatrix(t) { + return this.setFromMatrix4(t).invert().transpose(); } - transposeIntoArray(e) { - let t = this.elements; - return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this; + 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(e, t, n, i, 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 + e, -i * c, i * l, -i * (-c * o + l * a) + a + t, 0, 0, 1), this; + setUvTransform(t, e, n, i, r, a, o) { + let c = Math.cos(r), l = Math.sin(r); + return this.set(n * c, n * l, -n * (c * a + l * o) + a + t, -i * l, i * c, -i * (-l * a + c * o) + o + e, 0, 0, 1), this; } - scale(e, t) { - let n = this.elements; - return n[0] *= e, n[3] *= e, n[6] *= e, n[1] *= t, n[4] *= t, n[7] *= t, this; + scale(t, e) { + return this.premultiply(Ra.makeScale(t, e)), this; } - rotate(e) { - let t = Math.cos(e), n = Math.sin(e), i = this.elements, r = i[0], o = i[3], a = i[6], l = i[1], c = i[4], h = i[7]; - return i[0] = t * r + n * l, i[3] = t * o + n * c, i[6] = t * a + n * h, i[1] = -n * r + t * l, i[4] = -n * o + t * c, i[7] = -n * a + t * h, this; + rotate(t) { + return this.premultiply(Ra.makeRotation(-t)), this; } - translate(e, t) { - let n = this.elements; - return n[0] += e * n[2], n[3] += e * n[5], n[6] += e * n[8], n[1] += t * n[2], n[4] += t * n[5], n[7] += t * n[8], this; + translate(t, e) { + return this.premultiply(Ra.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(e) { - let t = this.elements, n = e.elements; - for(let i = 0; i < 9; i++)if (t[i] !== n[i]) return !1; + equals(t) { + let e = this.elements, n = t.elements; + for(let i = 0; i < 9; i++)if (e[i] !== n[i]) return !1; return !0; } - fromArray(e, t = 0) { - for(let n = 0; n < 9; n++)this.elements[n] = e[n + t]; + fromArray(t, e = 0) { + for(let n = 0; n < 9; n++)this.elements[n] = t[n + e]; return this; } - toArray(e = [], t = 0) { + toArray(t = [], e = 0) { let n = this.elements; - return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; + 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); } -}; -lt.prototype.isMatrix3 = !0; -function Yc(s) { - if (s.length === 0) return -1 / 0; - let e = s[0]; - for(let t = 1, n = s.length; t < n; ++t)s[t] > e && (e = s[t]); - return e; +}, Ra = new kt; +function gd(s1) { + for(let t = s1.length - 1; t >= 0; --t)if (s1[t] >= 65535) return !0; + return !1; } -var Qd = { +var Zf = { Int8Array, Uint8Array, Uint8ClampedArray, @@ -460,30 +766,160 @@ var Qd = { Float32Array, Float64Array }; -function wi(s, e) { - return new Qd[s](e); -} -function qs(s) { - return document.createElementNS("http://www.w3.org/1999/xhtml", s); -} -var ti, Yn = class { - static getDataURL(e) { - if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; - let t; - if (e instanceof HTMLCanvasElement) t = e; +function Vi(s1, t) { + return new Zf[s1](t); +} +function ws(s1) { + return document.createElementNS("http://www.w3.org/1999/xhtml", s1); +} +var Ll = {}; +function Ms(s1) { + s1 in Ll || (Ll[s1] = !0, console.warn(s1)); +} +function Xi(s1) { + return s1 < .04045 ? s1 * .0773993808 : Math.pow(s1 * .9478672986 + .0521327014, 2.4); +} +function Ca(s1) { + return s1 < .0031308 ? s1 * 12.92 : 1.055 * Math.pow(s1, .41666) - .055; +} +var Jf = new kt().fromArray([ + .8224621, + .0331941, + .0170827, + .177538, + .9668058, + .0723974, + -1e-7, + 1e-7, + .9105199 +]), $f = new kt().fromArray([ + 1.2249401, + -.0420569, + -.0196376, + -.2249404, + 1.0420571, + -.0786361, + 1e-7, + 0, + 1.0982735 +]); +function Kf(s1) { + return s1.convertSRGBToLinear().applyMatrix3($f); +} +function Qf(s1) { + return s1.applyMatrix3(Jf).convertLinearToSRGB(); +} +var jf = { + [nn]: (s1)=>s1, + [Nt]: (s1)=>s1.convertSRGBToLinear(), + [pd]: Kf +}, tp = { + [nn]: (s1)=>s1, + [Nt]: (s1)=>s1.convertLinearToSRGB(), + [pd]: Qf +}, Ye = { + enabled: !0, + get legacyMode () { + return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."), !this.enabled; + }, + set legacyMode (s){ + console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."), this.enabled = !s; + }, + get workingColorSpace () { + return nn; + }, + set workingColorSpace (s){ + console.warn("THREE.ColorManagement: .workingColorSpace is readonly."); + }, + convert: function(s1, t, e) { + if (this.enabled === !1 || t === e || !t || !e) return s1; + let n = jf[t], i = tp[e]; + if (n === void 0 || i === void 0) throw new Error(`Unsupported color space conversion, "${t}" to "${e}".`); + return i(n(s1)); + }, + fromWorkingColorSpace: function(s1, t) { + return this.convert(s1, this.workingColorSpace, t); + }, + toWorkingColorSpace: function(s1, t) { + return this.convert(s1, t, this.workingColorSpace); + } +}, gi, Gr = class { + static getDataURL(t) { + if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u") return t.src; + let e; + if (t instanceof HTMLCanvasElement) e = t; else { - ti === void 0 && (ti = qs("canvas")), ti.width = e.width, ti.height = e.height; - let n = ti.getContext("2d"); - e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = ti; - } - return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", .6)) : t.toDataURL("image/png"); + gi === void 0 && (gi = ws("canvas")), gi.width = t.width, gi.height = t.height; + let n = gi.getContext("2d"); + t instanceof ImageData ? n.putImageData(t, 0, 0) : n.drawImage(t, 0, 0, t.width, t.height), e = gi; + } + return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), e.toDataURL("image/jpeg", .6)) : e.toDataURL("image/png"); + } + static sRGBToLinear(t) { + if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) { + let e = ws("canvas"); + e.width = t.width, e.height = t.height; + let n = e.getContext("2d"); + n.drawImage(t, 0, 0, t.width, t.height); + let i = n.getImageData(0, 0, t.width, t.height), r = i.data; + for(let a = 0; a < r.length; a++)r[a] = Xi(r[a] / 255) * 255; + return n.putImageData(i, 0, 0), e; + } else if (t.data) { + let e = t.data.slice(0); + for(let n = 0; n < e.length; n++)e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[n] = Math.floor(Xi(e[n] / 255) * 255) : e[n] = Xi(e[n]); + return { + data: e, + width: t.width, + height: t.height + }; + } else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t; } -}, Kd = 0, ot = class extends En { - constructor(e = ot.DEFAULT_IMAGE, t = ot.DEFAULT_MAPPING, n = vt, i = vt, r = tt, o = Ui, a = ct, l = rn, c = 1, h = Nt){ - super(); - Object.defineProperty(this, "id", { - value: Kd++ - }), this.uuid = Et(), this.name = "", this.image = e, this.mipmaps = [], this.mapping = t, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = o, this.anisotropy = c, this.format = a, this.internalFormat = null, this.type = l, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new lt, this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.encoding = h, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1; +}, ep = 0, Ln = class { + constructor(t = null){ + this.isSource = !0, Object.defineProperty(this, "id", { + value: ep++ + }), this.uuid = Be(), this.data = t, this.version = 0; + } + set needsUpdate(t) { + t === !0 && this.version++; + } + toJSON(t) { + let e = t === void 0 || typeof t == "string"; + if (!e && t.images[this.uuid] !== void 0) return t.images[this.uuid]; + let n = { + uuid: this.uuid, + url: "" + }, i = this.data; + if (i !== null) { + let r; + if (Array.isArray(i)) { + r = []; + for(let a = 0, o = i.length; a < o; a++)i[a].isDataTexture ? r.push(Pa(i[a].image)) : r.push(Pa(i[a])); + } else r = Pa(i); + n.url = r; + } + return e || (t.images[this.uuid] = n), n; + } +}; +function Pa(s1) { + return typeof HTMLImageElement < "u" && s1 instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s1 instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s1 instanceof ImageBitmap ? Gr.getDataURL(s1) : s1.data ? { + data: Array.from(s1.data), + width: s1.width, + height: s1.height, + type: s1.data.constructor.name + } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); +} +var np = 0, ye = class s1 extends sn { + constructor(t = s1.DEFAULT_IMAGE, e = s1.DEFAULT_MAPPING, n = Ce, i = Ce, r = pe, a = li, o = He, c = Nn, l = s1.DEFAULT_ANISOTROPY, h = ri){ + super(), this.isTexture = !0, Object.defineProperty(this, "id", { + value: np++ + }), this.uuid = Be(), this.name = "", this.source = new Ln(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = n, this.wrapT = i, this.magFilter = r, this.minFilter = a, this.anisotropy = l, this.format = o, this.internalFormat = null, this.type = c, this.offset = new J(0, 0), this.repeat = new J(1, 1), this.center = new J(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new kt, this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, typeof h == "string" ? this.colorSpace = h : (Ms("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = h === si ? Nt : ri), this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.needsPMREMUpdate = !1; + } + get image() { + return this.source.data; + } + set image(t = null) { + 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); @@ -491,21 +927,23 @@ var ti, Yn = class { clone() { return new this.constructor().copy(this); } - copy(e) { - return this.name = e.name, this.image = e.image, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.encoding = e.encoding, this.userData = JSON.parse(JSON.stringify(e.userData)), 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.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.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this; } - toJSON(e) { - let t = e === void 0 || typeof e == "string"; - if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; + 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.5, + version: 4.6, 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 @@ -524,133 +962,118 @@ var ti, Yn = class { this.wrapT ], format: this.format, + internalFormat: this.internalFormat, type: this.type, - encoding: this.encoding, + colorSpace: this.colorSpace, minFilter: this.minFilter, magFilter: this.magFilter, anisotropy: this.anisotropy, flipY: this.flipY, + generateMipmaps: this.generateMipmaps, premultiplyAlpha: this.premultiplyAlpha, unpackAlignment: this.unpackAlignment }; - if (this.image !== void 0) { - let i = this.image; - if (i.uuid === void 0 && (i.uuid = Et()), !t && e.images[i.uuid] === void 0) { - let r; - if (Array.isArray(i)) { - r = []; - for(let o = 0, a = i.length; o < a; o++)i[o].isDataTexture ? r.push(_o(i[o].image)) : r.push(_o(i[o])); - } else r = _o(i); - e.images[i.uuid] = { - uuid: i.uuid, - url: r - }; - } - n.image = i.uuid; - } - return JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; + return Object.keys(this.userData).length > 0 && (n.userData = this.userData), e || (t.textures[this.uuid] = n), n; } dispose() { this.dispatchEvent({ type: "dispose" }); } - transformUv(e) { - if (this.mapping !== ha) return e; - if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch(this.wrapS){ - case Ns: - e.x = e.x - Math.floor(e.x); + transformUv(t) { + if (this.mapping !== Oc) return t; + if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1) switch(this.wrapS){ + case Nr: + t.x = t.x - Math.floor(t.x); break; - case vt: - e.x = e.x < 0 ? 0 : 1; + case Ce: + t.x = t.x < 0 ? 0 : 1; break; - case Bs: - Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x); + case Fr: + 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 (e.y < 0 || e.y > 1) switch(this.wrapT){ - case Ns: - e.y = e.y - Math.floor(e.y); + if (t.y < 0 || t.y > 1) switch(this.wrapT){ + case Nr: + t.y = t.y - Math.floor(t.y); break; - case vt: - e.y = e.y < 0 ? 0 : 1; + case Ce: + t.y = t.y < 0 ? 0 : 1; break; - case Bs: - Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y); + case Fr: + 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 && (e.y = 1 - e.y), e; + return this.flipY && (t.y = 1 - t.y), t; + } + set needsUpdate(t) { + t === !0 && (this.version++, this.source.needsUpdate = !0); + } + get encoding() { + return Ms("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace === Nt ? si : fd; } - set needsUpdate(e) { - e === !0 && this.version++; + set encoding(t) { + Ms("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = t === si ? Nt : ri; } }; -ot.DEFAULT_IMAGE = void 0; -ot.DEFAULT_MAPPING = ha; -ot.prototype.isTexture = !0; -function _o(s) { - return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? Yn.getDataURL(s) : s.data ? { - data: Array.prototype.slice.call(s.data), - width: s.width, - height: s.height, - type: s.data.constructor.name - } : (console.warn("THREE.Texture: Unable to serialize Texture."), {}); -} -var Ve = class { - constructor(e = 0, t = 0, n = 0, i = 1){ - this.x = e, this.y = t, this.z = n, this.w = i; +ye.DEFAULT_IMAGE = null; +ye.DEFAULT_MAPPING = Oc; +ye.DEFAULT_ANISOTROPY = 1; +var $t = class s1 { + constructor(t = 0, e = 0, n = 0, i = 1){ + s1.prototype.isVector4 = !0, this.x = t, this.y = e, this.z = n, this.w = i; } get width() { return this.z; } - set width(e) { - this.z = e; + set width(t) { + this.z = t; } get height() { return this.w; } - set height(e) { - this.w = e; + set height(t) { + this.w = t; } - set(e, t, n, i) { - return this.x = e, this.y = t, this.z = n, this.w = i, this; + set(t, e, n, i) { + return this.x = t, this.y = e, this.z = n, this.w = i, this; } - setScalar(e) { - return this.x = e, this.y = e, this.z = e, this.w = e, this; + setScalar(t) { + return this.x = t, this.y = t, this.z = t, this.w = t, this; } - setX(e) { - return this.x = e, this; + setX(t) { + return this.x = t, this; } - setY(e) { - return this.y = e, this; + setY(t) { + return this.y = t, this; } - setZ(e) { - return this.z = e, this; + setZ(t) { + return this.z = t, this; } - setW(e) { - return this.w = e, this; + setW(t) { + return this.w = t, this; } - setComponent(e, t) { - switch(e){ + setComponent(t, e) { + switch(t){ case 0: - this.x = t; + this.x = e; break; case 1: - this.y = t; + this.y = e; break; case 2: - this.z = t; + this.z = e; break; case 3: - this.w = t; + this.w = e; break; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } return this; } - getComponent(e) { - switch(e){ + getComponent(t) { + switch(t){ case 0: return this.x; case 1: @@ -660,80 +1083,80 @@ var Ve = class { case 3: return this.w; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } } clone() { return new this.constructor(this.x, this.y, this.z, this.w); } - copy(e) { - return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this; + 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(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this); + add(t) { + return this.x += t.x, this.y += t.y, this.z += t.z, this.w += t.w, this; } - addScalar(e) { - return this.x += e, this.y += e, this.z += e, this.w += e, this; + addScalar(t) { + return this.x += t, this.y += t, this.z += t, this.w += t, this; } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, 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(e, t) { - return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, 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(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this); + sub(t) { + return this.x -= t.x, this.y -= t.y, this.z -= t.z, this.w -= t.w, this; } - subScalar(e) { - return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; + subScalar(t) { + return this.x -= t, this.y -= t, this.z -= t, this.w -= t, this; } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, 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(e) { - return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.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(e) { - return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; + multiplyScalar(t) { + return this.x *= t, this.y *= t, this.z *= t, this.w *= t, this; } - applyMatrix4(e) { - let t = this.x, n = this.y, i = this.z, r = this.w, o = e.elements; - return this.x = o[0] * t + o[4] * n + o[8] * i + o[12] * r, this.y = o[1] * t + o[5] * n + o[9] * i + o[13] * r, this.z = o[2] * t + o[6] * n + o[10] * i + o[14] * r, this.w = o[3] * t + o[7] * n + o[11] * i + o[15] * r, this; + applyMatrix4(t) { + let e = this.x, n = this.y, i = this.z, r = this.w, a = t.elements; + return this.x = a[0] * e + a[4] * n + a[8] * i + a[12] * r, this.y = a[1] * e + a[5] * n + a[9] * i + a[13] * r, this.z = a[2] * e + a[6] * n + a[10] * i + a[14] * r, this.w = a[3] * e + a[7] * n + a[11] * i + a[15] * r, this; } - divideScalar(e) { - return this.multiplyScalar(1 / e); + divideScalar(t) { + return this.multiplyScalar(1 / t); } - setAxisAngleFromQuaternion(e) { - this.w = 2 * Math.acos(e.w); - let t = Math.sqrt(1 - e.w * e.w); - return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this; + 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(e) { - let t, n, i, r, l = e.elements, c = l[0], h = l[4], u = l[8], d = l[1], f = l[5], m = l[9], x = l[2], v = l[6], g = l[10]; - if (Math.abs(h - d) < .01 && Math.abs(u - x) < .01 && Math.abs(m - v) < .01) { - if (Math.abs(h + d) < .1 && Math.abs(u + x) < .1 && Math.abs(m + v) < .1 && Math.abs(c + f + g - 3) < .1) return this.set(1, 0, 0, 0), this; - t = Math.PI; - let _ = (c + 1) / 2, y = (f + 1) / 2, b = (g + 1) / 2, A = (h + d) / 4, L = (u + x) / 4, I = (m + v) / 4; - return _ > y && _ > b ? _ < .01 ? (n = 0, i = .707106781, r = .707106781) : (n = Math.sqrt(_), i = A / n, r = L / n) : y > b ? y < .01 ? (n = .707106781, i = 0, r = .707106781) : (i = Math.sqrt(y), n = A / i, r = I / i) : b < .01 ? (n = .707106781, i = .707106781, r = 0) : (r = Math.sqrt(b), n = L / r, i = I / r), this.set(n, i, r, t), this; + setAxisAngleFromRotationMatrix(t) { + let e, n, i, r, c = t.elements, l = c[0], h = c[4], u = c[8], d = c[1], f = c[5], m = c[9], x = c[2], g = c[6], p = c[10]; + if (Math.abs(h - d) < .01 && Math.abs(u - x) < .01 && Math.abs(m - g) < .01) { + if (Math.abs(h + d) < .1 && Math.abs(u + x) < .1 && Math.abs(m + g) < .1 && Math.abs(l + f + p - 3) < .1) return this.set(1, 0, 0, 0), this; + e = Math.PI; + let _ = (l + 1) / 2, y = (f + 1) / 2, b = (p + 1) / 2, w = (h + d) / 4, R = (u + x) / 4, L = (m + g) / 4; + return _ > y && _ > b ? _ < .01 ? (n = 0, i = .707106781, r = .707106781) : (n = Math.sqrt(_), i = w / n, r = R / n) : y > b ? y < .01 ? (n = .707106781, i = 0, r = .707106781) : (i = Math.sqrt(y), n = w / i, r = L / i) : b < .01 ? (n = .707106781, i = .707106781, r = 0) : (r = Math.sqrt(b), n = R / r, i = L / r), this.set(n, i, r, e), this; } - let p = Math.sqrt((v - m) * (v - m) + (u - x) * (u - x) + (d - h) * (d - h)); - return Math.abs(p) < .001 && (p = 1), this.x = (v - m) / p, this.y = (u - x) / p, this.z = (d - h) / p, this.w = Math.acos((c + f + g - 1) / 2), this; + let v = Math.sqrt((g - m) * (g - m) + (u - x) * (u - x) + (d - h) * (d - h)); + return Math.abs(v) < .001 && (v = 1), this.x = (g - m) / v, this.y = (u - x) / v, this.z = (d - h) / v, this.w = Math.acos((l + f + p - 1) / 2), this; } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), 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(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.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(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this; + clamp(t, e) { + return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this.w = Math.max(t.w, Math.min(e.w, this.w)), this; } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this; + clampScalar(t, e) { + return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this.w = Math.max(t, Math.min(e, this.w)), this; } - clampLength(e, t) { + clampLength(t, e) { let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n))); } 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; @@ -750,8 +1173,8 @@ var Ve = class { negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; } - dot(e) { - return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; + 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; @@ -765,26 +1188,26 @@ var Ve = class { normalize() { return this.divideScalar(this.length() || 1); } - setLength(e) { - return this.normalize().multiplyScalar(e); + setLength(t) { + return this.normalize().multiplyScalar(t); } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this; + 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(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, 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(e) { - return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; + equals(t) { + return t.x === this.x && t.y === this.y && t.z === this.z && t.w === this.w; } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; + 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(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; + 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(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this; + 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; @@ -792,202 +1215,206 @@ var Ve = class { *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z, yield this.w; } -}; -Ve.prototype.isVector4 = !0; -var At = class extends En { - constructor(e, t, n = {}){ - super(); - this.width = e, this.height = t, this.depth = 1, this.scissor = new Ve(0, 0, e, t), this.scissorTest = !1, this.viewport = new Ve(0, 0, e, t), this.texture = new ot(void 0, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.encoding), this.texture.isRenderTargetTexture = !0, this.texture.image = { - width: e, - height: t, +}, ho = class extends sn { + constructor(t = 1, e = 1, n = {}){ + super(), this.isRenderTarget = !0, this.width = t, this.height = e, this.depth = 1, this.scissor = new $t(0, 0, t, e), this.scissorTest = !1, this.viewport = new $t(0, 0, t, e); + let i = { + width: t, + height: e, depth: 1 - }, this.texture.generateMipmaps = n.generateMipmaps !== void 0 ? n.generateMipmaps : !1, this.texture.internalFormat = n.internalFormat !== void 0 ? n.internalFormat : null, this.texture.minFilter = n.minFilter !== void 0 ? n.minFilter : tt, this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0, this.stencilBuffer = n.stencilBuffer !== void 0 ? n.stencilBuffer : !1, this.depthTexture = n.depthTexture !== void 0 ? n.depthTexture : null; - } - setTexture(e) { - e.image = { - width: this.width, - height: this.height, - depth: this.depth - }, this.texture = e; + }; + n.encoding !== void 0 && (Ms("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."), n.colorSpace = n.encoding === si ? Nt : ri), this.texture = new ye(i, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.flipY = !1, this.texture.generateMipmaps = n.generateMipmaps !== void 0 ? n.generateMipmaps : !1, this.texture.internalFormat = n.internalFormat !== void 0 ? n.internalFormat : null, this.texture.minFilter = n.minFilter !== void 0 ? n.minFilter : pe, this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0, this.stencilBuffer = n.stencilBuffer !== void 0 ? n.stencilBuffer : !1, this.depthTexture = n.depthTexture !== void 0 ? n.depthTexture : null, this.samples = n.samples !== void 0 ? n.samples : 0; } - setSize(e, t, n = 1) { - (this.width !== e || this.height !== t || this.depth !== n) && (this.width = e, this.height = t, this.depth = n, this.texture.image.width = e, this.texture.image.height = t, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); + setSize(t, e, n = 1) { + (this.width !== t || this.height !== e || this.depth !== n) && (this.width = t, this.height = e, this.depth = n, this.texture.image.width = t, this.texture.image.height = e, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, t, e), this.scissor.set(0, 0, t, e); } clone() { return new this.constructor().copy(this); } - copy(e) { - return this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.copy(e.viewport), this.texture = e.texture.clone(), this.texture.image = { - ...this.texture.image - }, this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, 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.texture = t.texture.clone(), this.texture.isRenderTargetTexture = !0; + let e = Object.assign({}, t.texture.image); + return this.texture.source = new Ln(e), this.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, t.depthTexture !== null && (this.depthTexture = t.depthTexture.clone()), this.samples = t.samples, this; } dispose() { this.dispatchEvent({ type: "dispose" }); } -}; -At.prototype.isWebGLRenderTarget = !0; -var Zc = class extends At { - constructor(e, t, n){ - super(e, t); - let i = this.texture; +}, Ge = class extends ho { + constructor(t = 1, e = 1, n = {}){ + super(t, e, n), this.isWebGLRenderTarget = !0; + } +}, As = class extends ye { + constructor(t = null, e = 1, n = 1, i = 1){ + super(null), this.isDataArrayTexture = !0, this.image = { + data: t, + width: e, + height: n, + depth: i + }, this.magFilter = fe, this.minFilter = fe, this.wrapR = Ce, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +}, Il = class extends Ge { + constructor(t = 1, e = 1, n = 1){ + super(t, e), this.isWebGLArrayRenderTarget = !0, this.depth = n, this.texture = new As(null, t, e, n), this.texture.isRenderTargetTexture = !0; + } +}, Wr = class extends ye { + constructor(t = null, e = 1, n = 1, i = 1){ + super(null), this.isData3DTexture = !0, this.image = { + data: t, + width: e, + height: n, + depth: i + }, this.magFilter = fe, this.minFilter = fe, this.wrapR = Ce, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + } +}, Ul = class extends Ge { + constructor(t = 1, e = 1, n = 1){ + super(t, e), this.isWebGL3DRenderTarget = !0, this.depth = n, this.texture = new Wr(null, t, e, n), this.texture.isRenderTargetTexture = !0; + } +}, Dl = class extends Ge { + constructor(t = 1, e = 1, n = 1, i = {}){ + super(t, e, i), this.isWebGLMultipleRenderTargets = !0; + let r = this.texture; this.texture = []; - for(let r = 0; r < n; r++)this.texture[r] = i.clone(); + for(let a = 0; a < n; a++)this.texture[a] = r.clone(), this.texture[a].isRenderTargetTexture = !0; } - setSize(e, t, n = 1) { - if (this.width !== e || this.height !== t || this.depth !== n) { - this.width = e, this.height = t, this.depth = n; - for(let i = 0, r = this.texture.length; i < r; i++)this.texture[i].image.width = e, this.texture[i].image.height = t, this.texture[i].image.depth = n; + setSize(t, e, n = 1) { + if (this.width !== t || this.height !== e || this.depth !== n) { + this.width = t, this.height = e, this.depth = n; + for(let i = 0, r = this.texture.length; i < r; i++)this.texture[i].image.width = t, this.texture[i].image.height = e, this.texture[i].image.depth = n; this.dispose(); } - return this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t), this; + this.viewport.set(0, 0, t, e), this.scissor.set(0, 0, t, e); } - copy(e) { - this.dispose(), this.width = e.width, this.height = e.height, this.depth = e.depth, this.viewport.set(0, 0, this.width, this.height), this.scissor.set(0, 0, this.width, this.height), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.depthTexture = e.depthTexture, this.texture.length = 0; - for(let t = 0, n = e.texture.length; t < n; t++)this.texture[t] = e.texture[t].clone(); + copy(t) { + this.dispose(), 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.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, t.depthTexture !== null && (this.depthTexture = t.depthTexture.clone()), this.texture.length = 0; + for(let e = 0, n = t.texture.length; e < n; e++)this.texture[e] = t.texture[e].clone(), this.texture[e].isRenderTargetTexture = !0; return this; } -}; -Zc.prototype.isWebGLMultipleRenderTargets = !0; -var Xs = class extends At { - constructor(e, t, n = {}){ - super(e, t, n); - this.samples = 4, this.ignoreDepthForMultisampleCopy = n.ignoreDepth !== void 0 ? n.ignoreDepth : !0, this.useRenderToTexture = n.useRenderToTexture !== void 0 ? n.useRenderToTexture : !1, this.useRenderbuffer = this.useRenderToTexture === !1; - } - copy(e) { - return super.copy.call(this, e), this.samples = e.samples, this.useRenderToTexture = e.useRenderToTexture, this.useRenderbuffer = e.useRenderbuffer, this; - } -}; -Xs.prototype.isWebGLMultisampleRenderTarget = !0; -var gt = class { - constructor(e = 0, t = 0, n = 0, i = 1){ - this._x = e, this._y = t, this._z = n, this._w = i; - } - static slerp(e, t, n, i) { - return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."), n.slerpQuaternions(e, t, i); +}, Pe = class { + constructor(t = 0, e = 0, n = 0, i = 1){ + this.isQuaternion = !0, this._x = t, this._y = e, this._z = n, this._w = i; } - static slerpFlat(e, t, n, i, r, o, a) { - let l = n[i + 0], c = n[i + 1], h = n[i + 2], u = n[i + 3], d = r[o + 0], f = r[o + 1], m = r[o + 2], x = r[o + 3]; - if (a === 0) { - e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; + static slerpFlat(t, e, n, i, r, a, o) { + let c = n[i + 0], l = n[i + 1], h = n[i + 2], u = n[i + 3], d = r[a + 0], f = r[a + 1], m = r[a + 2], x = r[a + 3]; + if (o === 0) { + t[e + 0] = c, t[e + 1] = l, t[e + 2] = h, t[e + 3] = u; return; } - if (a === 1) { - e[t + 0] = d, e[t + 1] = f, e[t + 2] = m, e[t + 3] = x; + if (o === 1) { + t[e + 0] = d, t[e + 1] = f, t[e + 2] = m, t[e + 3] = x; return; } - if (u !== x || l !== d || c !== f || h !== m) { - let v = 1 - a, g = l * d + c * f + h * m + u * x, p = g >= 0 ? 1 : -1, _ = 1 - g * g; + if (u !== x || c !== d || l !== f || h !== m) { + let g = 1 - o, p = c * d + l * f + h * m + u * x, v = p >= 0 ? 1 : -1, _ = 1 - p * p; if (_ > Number.EPSILON) { - let b = Math.sqrt(_), A = Math.atan2(b, g * p); - v = Math.sin(v * A) / b, a = Math.sin(a * A) / b; + let b = Math.sqrt(_), w = Math.atan2(b, p * v); + g = Math.sin(g * w) / b, o = Math.sin(o * w) / b; } - let y = a * p; - if (l = l * v + d * y, c = c * v + f * y, h = h * v + m * y, u = u * v + x * y, v === 1 - a) { - let b = 1 / Math.sqrt(l * l + c * c + h * h + u * u); - l *= b, c *= b, h *= b, u *= b; + let y = o * v; + if (c = c * g + d * y, l = l * g + f * y, h = h * g + m * y, u = u * g + x * y, g === 1 - o) { + let b = 1 / Math.sqrt(c * c + l * l + h * h + u * u); + c *= b, l *= b, h *= b, u *= b; } } - e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u; + t[e] = c, t[e + 1] = l, t[e + 2] = h, t[e + 3] = u; } - static multiplyQuaternionsFlat(e, t, n, i, r, o) { - let a = n[i], l = n[i + 1], c = n[i + 2], h = n[i + 3], u = r[o], d = r[o + 1], f = r[o + 2], m = r[o + 3]; - return e[t] = a * m + h * u + l * f - c * d, e[t + 1] = l * m + h * d + c * u - a * f, e[t + 2] = c * m + h * f + a * d - l * u, e[t + 3] = h * m - a * u - l * d - c * f, e; + static multiplyQuaternionsFlat(t, e, n, i, r, a) { + let o = n[i], c = n[i + 1], l = n[i + 2], h = n[i + 3], u = r[a], d = r[a + 1], f = r[a + 2], m = r[a + 3]; + return t[e] = o * m + h * u + c * f - l * d, t[e + 1] = c * m + h * d + l * u - o * f, t[e + 2] = l * m + h * f + o * d - c * u, t[e + 3] = h * m - o * u - c * d - l * f, t; } get x() { return this._x; } - set x(e) { - this._x = e, this._onChangeCallback(); + set x(t) { + this._x = t, this._onChangeCallback(); } get y() { return this._y; } - set y(e) { - this._y = e, this._onChangeCallback(); + set y(t) { + this._y = t, this._onChangeCallback(); } get z() { return this._z; } - set z(e) { - this._z = e, this._onChangeCallback(); + set z(t) { + this._z = t, this._onChangeCallback(); } get w() { return this._w; } - set w(e) { - this._w = e, this._onChangeCallback(); + set w(t) { + this._w = t, this._onChangeCallback(); } - set(e, t, n, i) { - return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this; + set(t, e, n, i) { + return this._x = t, this._y = e, this._z = n, this._w = i, this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._w); } - copy(e) { - return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; + copy(t) { + return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this; } - setFromEuler(e, t) { - if (!(e && e.isEuler)) throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order."); - let n = e._x, i = e._y, r = e._z, o = e._order, a = Math.cos, l = Math.sin, c = a(n / 2), h = a(i / 2), u = a(r / 2), d = l(n / 2), f = l(i / 2), m = l(r / 2); - switch(o){ + setFromEuler(t, e) { + let n = t._x, i = t._y, r = t._z, a = t._order, o = Math.cos, c = Math.sin, l = o(n / 2), h = o(i / 2), u = o(r / 2), d = c(n / 2), f = c(i / 2), m = c(r / 2); + switch(a){ case "XYZ": - this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; + this._x = d * h * u + l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u - d * f * m; break; case "YXZ": - this._x = d * h * u + c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; + this._x = d * h * u + l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u + d * f * m; break; case "ZXY": - this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u - d * f * m; + this._x = d * h * u - l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u - d * f * m; break; case "ZYX": - this._x = d * h * u - c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u + d * f * m; + this._x = d * h * u - l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u + d * f * m; break; case "YZX": - this._x = d * h * u + c * f * m, this._y = c * f * u + d * h * m, this._z = c * h * m - d * f * u, this._w = c * h * u - d * f * m; + this._x = d * h * u + l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u - d * f * m; break; case "XZY": - this._x = d * h * u - c * f * m, this._y = c * f * u - d * h * m, this._z = c * h * m + d * f * u, this._w = c * h * u + d * f * m; + this._x = d * h * u - l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u + d * f * m; break; default: - console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o); + console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a); } - return t !== !1 && this._onChangeCallback(), this; + return e !== !1 && this._onChangeCallback(), this; } - setFromAxisAngle(e, t) { - let n = t / 2, i = Math.sin(n); - return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; + setFromAxisAngle(t, e) { + let n = e / 2, i = Math.sin(n); + return this._x = t.x * i, this._y = t.y * i, this._z = t.z * i, this._w = Math.cos(n), this._onChangeCallback(), this; } - setFromRotationMatrix(e) { - let t = e.elements, n = t[0], i = t[4], r = t[8], o = t[1], a = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = n + a + u; + setFromRotationMatrix(t) { + let e = t.elements, n = e[0], i = e[4], r = e[8], a = e[1], o = e[5], c = e[9], l = e[2], h = e[6], u = e[10], d = n + o + u; if (d > 0) { let f = .5 / Math.sqrt(d + 1); - this._w = .25 / f, this._x = (h - l) * f, this._y = (r - c) * f, this._z = (o - i) * f; - } else if (n > a && n > u) { - let f = 2 * Math.sqrt(1 + n - a - u); - this._w = (h - l) / f, this._x = .25 * f, this._y = (i + o) / f, this._z = (r + c) / f; - } else if (a > u) { - let f = 2 * Math.sqrt(1 + a - n - u); - this._w = (r - c) / f, this._x = (i + o) / f, this._y = .25 * f, this._z = (l + h) / f; + this._w = .25 / f, this._x = (h - c) * f, this._y = (r - l) * f, this._z = (a - i) * f; + } else if (n > o && n > u) { + let f = 2 * Math.sqrt(1 + n - o - u); + this._w = (h - c) / f, this._x = .25 * f, this._y = (i + a) / f, this._z = (r + l) / f; + } else if (o > u) { + let f = 2 * Math.sqrt(1 + o - n - u); + this._w = (r - l) / f, this._x = (i + a) / f, this._y = .25 * f, this._z = (c + h) / f; } else { - let f = 2 * Math.sqrt(1 + u - n - a); - this._w = (o - i) / f, this._x = (r + c) / f, this._y = (l + h) / f, this._z = .25 * f; + let f = 2 * Math.sqrt(1 + u - n - o); + this._w = (a - i) / f, this._x = (r + l) / f, this._y = (c + h) / f, this._z = .25 * f; } return this._onChangeCallback(), this; } - setFromUnitVectors(e, t) { - let n = e.dot(t) + 1; - return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); + setFromUnitVectors(t, e) { + let n = t.dot(e) + 1; + return n < Number.EPSILON ? (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(e) { - return 2 * Math.acos(Math.abs(mt(this.dot(e), -1, 1))); + angleTo(t) { + return 2 * Math.acos(Math.abs(ae(this.dot(t), -1, 1))); } - rotateTowards(e, t) { - let n = this.angleTo(e); + rotateTowards(t, e) { + let n = this.angleTo(t); if (n === 0) return this; - let i = Math.min(1, t / n); - return this.slerp(e, i), this; + let i = Math.min(1, e / n); + return this.slerp(t, i), this; } identity() { return this.set(0, 0, 0, 1); @@ -998,8 +1425,8 @@ var gt = class { conjugate() { return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this; } - dot(e) { - return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w; + 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; @@ -1008,94 +1435,98 @@ var gt = class { return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); } normalize() { - let e = this.length(); - return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this; + 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(e, t) { - return t !== void 0 ? (console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), this.multiplyQuaternions(e, t)) : this.multiplyQuaternions(this, e); + multiply(t) { + return this.multiplyQuaternions(this, t); } - premultiply(e) { - return this.multiplyQuaternions(e, this); + premultiply(t) { + return this.multiplyQuaternions(t, this); } - multiplyQuaternions(e, t) { - let n = e._x, i = e._y, r = e._z, o = e._w, a = t._x, l = t._y, c = t._z, h = t._w; - return this._x = n * h + o * a + i * c - r * l, this._y = i * h + o * l + r * a - n * c, this._z = r * h + o * c + n * l - i * a, this._w = o * h - n * a - i * l - r * c, this._onChangeCallback(), this; + multiplyQuaternions(t, e) { + let n = t._x, i = t._y, r = t._z, a = t._w, o = e._x, c = e._y, l = e._z, h = e._w; + return this._x = n * h + a * o + i * l - r * c, this._y = i * h + a * c + r * o - n * l, this._z = r * h + a * l + n * c - i * o, this._w = a * h - n * o - i * c - r * l, this._onChangeCallback(), this; } - slerp(e, t) { - if (t === 0) return this; - if (t === 1) return this.copy(e); - let n = this._x, i = this._y, r = this._z, o = this._w, a = o * e._w + n * e._x + i * e._y + r * e._z; - if (a < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, a = -a) : this.copy(e), a >= 1) return this._w = o, this._x = n, this._y = i, this._z = r, this; - let l = 1 - a * a; - if (l <= Number.EPSILON) { - let f = 1 - t; - return this._w = f * o + t * this._w, this._x = f * n + t * this._x, this._y = f * i + t * this._y, this._z = f * r + t * this._z, this.normalize(), this._onChangeCallback(), this; + slerp(t, e) { + if (e === 0) return this; + if (e === 1) return this.copy(t); + let n = this._x, i = this._y, r = this._z, a = this._w, o = a * t._w + n * t._x + i * t._y + r * t._z; + if (o < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, o = -o) : this.copy(t), o >= 1) return this._w = a, this._x = n, this._y = i, this._z = r, this; + let c = 1 - o * o; + if (c <= Number.EPSILON) { + let f = 1 - e; + return this._w = f * a + e * this._w, this._x = f * n + e * this._x, this._y = f * i + e * this._y, this._z = f * r + e * this._z, this.normalize(), this._onChangeCallback(), this; } - let c = Math.sqrt(l), h = Math.atan2(c, a), u = Math.sin((1 - t) * h) / c, d = Math.sin(t * h) / c; - return this._w = o * u + this._w * d, this._x = n * u + this._x * d, this._y = i * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; + let l = Math.sqrt(c), h = Math.atan2(l, o), u = Math.sin((1 - e) * h) / l, d = Math.sin(e * h) / l; + return this._w = a * u + this._w * d, this._x = n * u + this._x * d, this._y = i * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this; } - slerpQuaternions(e, t, n) { - this.copy(e).slerp(t, n); + slerpQuaternions(t, e, n) { + return this.copy(t).slerp(e, n); } random() { - let e = Math.random(), t = Math.sqrt(1 - e), n = Math.sqrt(e), i = 2 * Math.PI * Math.random(), r = 2 * Math.PI * Math.random(); - return this.set(t * Math.cos(i), n * Math.sin(r), n * Math.cos(r), t * Math.sin(i)); + let t = Math.random(), e = Math.sqrt(1 - t), n = Math.sqrt(t), i = 2 * Math.PI * Math.random(), r = 2 * Math.PI * Math.random(); + return this.set(e * Math.cos(i), n * Math.sin(r), n * Math.cos(r), e * Math.sin(i)); } - equals(e) { - return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; + equals(t) { + return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w; } - fromArray(e, t = 0) { - return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; + 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(e = [], t = 0) { - return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; + 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(e, t) { - return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this; + 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; } - _onChange(e) { - return this._onChangeCallback = e, this; + toJSON() { + return this.toArray(); + } + _onChange(t) { + return this._onChangeCallback = t, this; } _onChangeCallback() {} -}; -gt.prototype.isQuaternion = !0; -var M = class { - constructor(e = 0, t = 0, n = 0){ - this.x = e, this.y = t, this.z = n; + *[Symbol.iterator]() { + yield this._x, yield this._y, yield this._z, yield this._w; } - set(e, t, n) { - return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; +}, A = class s1 { + constructor(t = 0, e = 0, n = 0){ + s1.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = n; } - setScalar(e) { - return this.x = e, this.y = e, this.z = e, this; + set(t, e, n) { + return n === void 0 && (n = this.z), this.x = t, this.y = e, this.z = n, this; } - setX(e) { - return this.x = e, this; + setScalar(t) { + return this.x = t, this.y = t, this.z = t, this; } - setY(e) { - return this.y = e, this; + setX(t) { + return this.x = t, this; } - setZ(e) { - return this.z = e, this; + setY(t) { + return this.y = t, this; } - setComponent(e, t) { - switch(e){ + setZ(t) { + return this.z = t, this; + } + setComponent(t, e) { + switch(t){ case 0: - this.x = t; + this.x = e; break; case 1: - this.y = t; + this.y = e; break; case 2: - this.z = t; + this.z = e; break; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } return this; } - getComponent(e) { - switch(e){ + getComponent(t) { + switch(t){ case 0: return this.x; case 1: @@ -1103,97 +1534,97 @@ var M = class { case 2: return this.z; default: - throw new Error("index is out of range: " + e); + throw new Error("index is out of range: " + t); } } clone() { return new this.constructor(this.x, this.y, this.z); } - copy(e) { - return this.x = e.x, this.y = e.y, this.z = e.z, this; + copy(t) { + return this.x = t.x, this.y = t.y, this.z = t.z, this; } - add(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(e, t)) : (this.x += e.x, this.y += e.y, this.z += e.z, this); + add(t) { + return this.x += t.x, this.y += t.y, this.z += t.z, this; } - addScalar(e) { - return this.x += e, this.y += e, this.z += e, this; + addScalar(t) { + return this.x += t, this.y += t, this.z += t, this; } - addVectors(e, t) { - return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, 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(e, t) { - return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; + addScaledVector(t, e) { + return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this; } - sub(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), this.subVectors(e, t)) : (this.x -= e.x, this.y -= e.y, this.z -= e.z, this); + sub(t) { + return this.x -= t.x, this.y -= t.y, this.z -= t.z, this; } - subScalar(e) { - return this.x -= e, this.y -= e, this.z -= e, this; + subScalar(t) { + return this.x -= t, this.y -= t, this.z -= t, this; } - subVectors(e, t) { - return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, 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(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), this.multiplyVectors(e, t)) : (this.x *= e.x, this.y *= e.y, this.z *= e.z, this); + multiply(t) { + return this.x *= t.x, this.y *= t.y, this.z *= t.z, this; } - multiplyScalar(e) { - return this.x *= e, this.y *= e, this.z *= e, this; + multiplyScalar(t) { + return this.x *= t, this.y *= t, this.z *= t, this; } - multiplyVectors(e, t) { - return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, 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(e) { - return e && e.isEuler || console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."), this.applyQuaternion(yl.setFromEuler(e)); + applyEuler(t) { + return this.applyQuaternion(Nl.setFromEuler(t)); } - applyAxisAngle(e, t) { - return this.applyQuaternion(yl.setFromAxisAngle(e, t)); + applyAxisAngle(t, e) { + return this.applyQuaternion(Nl.setFromAxisAngle(t, e)); } - applyMatrix3(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements; - return this.x = r[0] * t + r[3] * n + r[6] * i, this.y = r[1] * t + r[4] * n + r[7] * i, this.z = r[2] * t + r[5] * n + r[8] * i, this; + applyMatrix3(t) { + let e = this.x, n = this.y, i = this.z, r = t.elements; + return this.x = r[0] * e + r[3] * n + r[6] * i, this.y = r[1] * e + r[4] * n + r[7] * i, this.z = r[2] * e + r[5] * n + r[8] * i, this; } - applyNormalMatrix(e) { - return this.applyMatrix3(e).normalize(); + applyNormalMatrix(t) { + return this.applyMatrix3(t).normalize(); } - applyMatrix4(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements, o = 1 / (r[3] * t + r[7] * n + r[11] * i + r[15]); - return this.x = (r[0] * t + r[4] * n + r[8] * i + r[12]) * o, this.y = (r[1] * t + r[5] * n + r[9] * i + r[13]) * o, this.z = (r[2] * t + r[6] * n + r[10] * i + r[14]) * o, this; + applyMatrix4(t) { + let e = this.x, n = this.y, i = this.z, r = t.elements, a = 1 / (r[3] * e + r[7] * n + r[11] * i + r[15]); + return this.x = (r[0] * e + r[4] * n + r[8] * i + r[12]) * a, this.y = (r[1] * e + r[5] * n + r[9] * i + r[13]) * a, this.z = (r[2] * e + r[6] * n + r[10] * i + r[14]) * a, this; } - applyQuaternion(e) { - let t = this.x, n = this.y, i = this.z, r = e.x, o = e.y, a = e.z, l = e.w, c = l * t + o * i - a * n, h = l * n + a * t - r * i, u = l * i + r * n - o * t, d = -r * t - o * n - a * i; - return this.x = c * l + d * -r + h * -a - u * -o, this.y = h * l + d * -o + u * -r - c * -a, this.z = u * l + d * -a + c * -o - h * -r, this; + applyQuaternion(t) { + let e = this.x, n = this.y, i = this.z, r = t.x, a = t.y, o = t.z, c = t.w, l = c * e + a * i - o * n, h = c * n + o * e - r * i, u = c * i + r * n - a * e, d = -r * e - a * n - o * i; + return this.x = l * c + d * -r + h * -o - u * -a, this.y = h * c + d * -a + u * -r - l * -o, this.z = u * c + d * -o + l * -a - h * -r, this; } - project(e) { - return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); + project(t) { + return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix); } - unproject(e) { - return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); + unproject(t) { + return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld); } - transformDirection(e) { - let t = this.x, n = this.y, i = this.z, r = e.elements; - return this.x = r[0] * t + r[4] * n + r[8] * i, this.y = r[1] * t + r[5] * n + r[9] * i, this.z = r[2] * t + r[6] * n + r[10] * i, this.normalize(); + transformDirection(t) { + let e = this.x, n = this.y, i = this.z, r = t.elements; + return this.x = r[0] * e + r[4] * n + r[8] * i, this.y = r[1] * e + r[5] * n + r[9] * i, this.z = r[2] * e + r[6] * n + r[10] * i, this.normalize(); } - divide(e) { - return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; + divide(t) { + return this.x /= t.x, this.y /= t.y, this.z /= t.z, this; } - divideScalar(e) { - return this.multiplyScalar(1 / e); + divideScalar(t) { + return this.multiplyScalar(1 / t); } - min(e) { - return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), 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; } - max(e) { - return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.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(e, t) { - return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this; + clamp(t, e) { + return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this; } - clampScalar(e, t) { - return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this; + clampScalar(t, e) { + return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this; } - clampLength(e, t) { + clampLength(t, e) { let n = this.length(); - return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n))); + return this.divideScalar(n || 1).multiplyScalar(Math.max(t, Math.min(e, n))); } floor() { return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this; @@ -1210,8 +1641,8 @@ var M = class { negate() { return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; } - dot(e) { - return this.x * e.x + this.y * e.y + this.z * e.z; + 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; @@ -1225,141 +1656,139 @@ var M = class { normalize() { return this.divideScalar(this.length() || 1); } - setLength(e) { - return this.normalize().multiplyScalar(e); + 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; } - lerp(e, t) { - return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, 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; } - lerpVectors(e, t, n) { - return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; + cross(t) { + return this.crossVectors(this, t); } - cross(e, t) { - return t !== void 0 ? (console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."), this.crossVectors(e, t)) : this.crossVectors(this, e); + crossVectors(t, e) { + let n = t.x, i = t.y, r = t.z, a = e.x, o = e.y, c = e.z; + return this.x = i * c - r * o, this.y = r * a - n * c, this.z = n * o - i * a, this; } - crossVectors(e, t) { - let n = e.x, i = e.y, r = e.z, o = t.x, a = t.y, l = t.z; - return this.x = i * l - r * a, this.y = r * o - n * l, this.z = n * a - i * 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); } - projectOnVector(e) { - let t = e.lengthSq(); - if (t === 0) return this.set(0, 0, 0); - let n = e.dot(this) / t; - return this.copy(e).multiplyScalar(n); + projectOnPlane(t) { + return La.copy(this).projectOnVector(t), this.sub(La); } - projectOnPlane(e) { - return Mo.copy(this).projectOnVector(e), this.sub(Mo); + reflect(t) { + return this.sub(La.copy(t).multiplyScalar(2 * this.dot(t))); } - reflect(e) { - return this.sub(Mo.copy(e).multiplyScalar(2 * this.dot(e))); + 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(ae(n, -1, 1)); } - angleTo(e) { - let t = Math.sqrt(this.lengthSq() * e.lengthSq()); - if (t === 0) return Math.PI / 2; - let n = this.dot(e) / t; - return Math.acos(mt(n, -1, 1)); + distanceTo(t) { + return Math.sqrt(this.distanceToSquared(t)); } - distanceTo(e) { - return Math.sqrt(this.distanceToSquared(e)); + distanceToSquared(t) { + let e = this.x - t.x, n = this.y - t.y, i = this.z - t.z; + return e * e + n * n + i * i; } - distanceToSquared(e) { - let t = this.x - e.x, n = this.y - e.y, i = this.z - e.z; - return t * t + n * n + i * i; + manhattanDistanceTo(t) { + return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z); } - manhattanDistanceTo(e) { - return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); + setFromSpherical(t) { + return this.setFromSphericalCoords(t.radius, t.phi, t.theta); } - setFromSpherical(e) { - return this.setFromSphericalCoords(e.radius, e.phi, e.theta); + setFromSphericalCoords(t, e, n) { + let i = Math.sin(e) * t; + return this.x = i * Math.sin(n), this.y = Math.cos(e) * t, this.z = i * Math.cos(n), this; } - setFromSphericalCoords(e, t, n) { - let i = Math.sin(t) * e; - return this.x = i * Math.sin(n), this.y = Math.cos(t) * e, this.z = i * Math.cos(n), this; + setFromCylindrical(t) { + return this.setFromCylindricalCoords(t.radius, t.theta, t.y); } - setFromCylindrical(e) { - return this.setFromCylindricalCoords(e.radius, e.theta, e.y); + setFromCylindricalCoords(t, e, n) { + return this.x = t * Math.sin(e), this.y = n, this.z = t * Math.cos(e), this; } - setFromCylindricalCoords(e, t, n) { - return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; + setFromMatrixPosition(t) { + let e = t.elements; + return this.x = e[12], this.y = e[13], this.z = e[14], this; } - setFromMatrixPosition(e) { - let t = e.elements; - return this.x = t[12], this.y = t[13], this.z = t[14], this; + setFromMatrixScale(t) { + let e = this.setFromMatrixColumn(t, 0).length(), n = this.setFromMatrixColumn(t, 1).length(), i = this.setFromMatrixColumn(t, 2).length(); + return this.x = e, this.y = n, this.z = i, this; } - setFromMatrixScale(e) { - let t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), i = this.setFromMatrixColumn(e, 2).length(); - return this.x = t, this.y = n, this.z = i, this; + setFromMatrixColumn(t, e) { + return this.fromArray(t.elements, e * 4); } - setFromMatrixColumn(e, t) { - return this.fromArray(e.elements, t * 4); + setFromMatrix3Column(t, e) { + return this.fromArray(t.elements, e * 3); } - setFromMatrix3Column(e, t) { - return this.fromArray(e.elements, t * 3); + setFromEuler(t) { + return this.x = t._x, this.y = t._y, this.z = t._z, this; } - equals(e) { - return e.x === this.x && e.y === this.y && e.z === this.z; + setFromColor(t) { + return this.x = t.r, this.y = t.g, this.z = t.b, this; } - fromArray(e, t = 0) { - return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; + equals(t) { + return t.x === this.x && t.y === this.y && t.z === this.z; } - toArray(e = [], t = 0) { - return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; + fromArray(t, e = 0) { + return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this; } - fromBufferAttribute(e, t, n) { - return n !== void 0 && console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."), this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), 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 e = (Math.random() - .5) * 2, t = Math.random() * Math.PI * 2, n = Math.sqrt(1 - e ** 2); - return this.x = n * Math.cos(t), this.y = n * Math.sin(t), this.z = e, this; + let t = (Math.random() - .5) * 2, e = Math.random() * Math.PI * 2, n = Math.sqrt(1 - t ** 2); + return this.x = n * Math.cos(e), this.y = n * Math.sin(e), this.z = t, this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z; } -}; -M.prototype.isVector3 = !0; -var Mo = new M, yl = new gt, Lt = class { - constructor(e = new M(1 / 0, 1 / 0, 1 / 0), t = new M(-1 / 0, -1 / 0, -1 / 0)){ - this.min = e, this.max = t; +}, La = new A, Nl = new Pe, Ke = class { + constructor(t = new A(1 / 0, 1 / 0, 1 / 0), e = new A(-1 / 0, -1 / 0, -1 / 0)){ + this.isBox3 = !0, this.min = t, this.max = e; } - set(e, t) { - return this.min.copy(e), this.max.copy(t), this; + set(t, e) { + return this.min.copy(t), this.max.copy(e), this; } - setFromArray(e) { - let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; - for(let l = 0, c = e.length; l < c; l += 3){ - let h = e[l], u = e[l + 1], d = e[l + 2]; - h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); - } - return this.min.set(t, n, i), this.max.set(r, o, a), this; + setFromArray(t) { + this.makeEmpty(); + for(let e = 0, n = t.length; e < n; e += 3)this.expandByPoint(cn.fromArray(t, e)); + return this; } - setFromBufferAttribute(e) { - let t = 1 / 0, n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0, a = -1 / 0; - for(let l = 0, c = e.count; l < c; l++){ - let h = e.getX(l), u = e.getY(l), d = e.getZ(l); - h < t && (t = h), u < n && (n = u), d < i && (i = d), h > r && (r = h), u > o && (o = u), d > a && (a = d); - } - return this.min.set(t, n, i), this.max.set(r, o, a), this; + setFromBufferAttribute(t) { + this.makeEmpty(); + for(let e = 0, n = t.count; e < n; e++)this.expandByPoint(cn.fromBufferAttribute(t, e)); + return this; } - setFromPoints(e) { + setFromPoints(t) { this.makeEmpty(); - for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); + for(let e = 0, n = t.length; e < n; e++)this.expandByPoint(t[e]); return this; } - setFromCenterAndSize(e, t) { - let n = Ji.copy(t).multiplyScalar(.5); - return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; + setFromCenterAndSize(t, e) { + let n = cn.copy(e).multiplyScalar(.5); + return this.min.copy(t).sub(n), this.max.copy(t).add(n), this; } - setFromObject(e) { - return this.makeEmpty(), this.expandByObject(e); + setFromObject(t, e = !1) { + return this.makeEmpty(), this.expandByObject(t, e); } clone() { return new this.constructor().copy(this); } - copy(e) { - return this.min.copy(e.min), this.max.copy(e.max), this; + copy(t) { + return this.min.copy(t.min), this.max.copy(t.max), this; } makeEmpty() { return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this; @@ -1367,81 +1796,86 @@ var Mo = new M, yl = new gt, Lt = class { isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; } - getCenter(e) { - return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); + getCenter(t) { + return this.isEmpty() ? t.set(0, 0, 0) : t.addVectors(this.min, this.max).multiplyScalar(.5); } - getSize(e) { - return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); + getSize(t) { + return this.isEmpty() ? t.set(0, 0, 0) : t.subVectors(this.max, this.min); } - expandByPoint(e) { - return this.min.min(e), this.max.max(e), this; + expandByPoint(t) { + return this.min.min(t), this.max.max(t), this; } - expandByVector(e) { - return this.min.sub(e), this.max.add(e), this; + expandByVector(t) { + return this.min.sub(t), this.max.add(t), this; } - expandByScalar(e) { - return this.min.addScalar(-e), this.max.addScalar(e), this; + expandByScalar(t) { + return this.min.addScalar(-t), this.max.addScalar(t), this; } - expandByObject(e) { - e.updateWorldMatrix(!1, !1); - let t = e.geometry; - t !== void 0 && (t.boundingBox === null && t.computeBoundingBox(), bo.copy(t.boundingBox), bo.applyMatrix4(e.matrixWorld), this.union(bo)); - let n = e.children; - for(let i = 0, r = n.length; i < r; i++)this.expandByObject(n[i]); + expandByObject(t, e = !1) { + if (t.updateWorldMatrix(!1, !1), t.boundingBox !== void 0) t.boundingBox === null && t.computeBoundingBox(), _i.copy(t.boundingBox), _i.applyMatrix4(t.matrixWorld), this.union(_i); + else { + let i = t.geometry; + if (i !== void 0) if (e && i.attributes !== void 0 && i.attributes.position !== void 0) { + let r = i.attributes.position; + for(let a = 0, o = r.count; a < o; a++)cn.fromBufferAttribute(r, a).applyMatrix4(t.matrixWorld), this.expandByPoint(cn); + } else i.boundingBox === null && i.computeBoundingBox(), _i.copy(i.boundingBox), _i.applyMatrix4(t.matrixWorld), this.union(_i); + } + let n = t.children; + for(let i = 0, r = n.length; i < r; i++)this.expandByObject(n[i], e); return this; } - containsPoint(e) { - return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z); + containsPoint(t) { + return !(t.x < 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(e) { - return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.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(e, t) { - return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y), (e.z - this.min.z) / (this.max.z - this.min.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(e) { - return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.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(e) { - return this.clampPoint(e.center, Ji), Ji.distanceToSquared(e.center) <= e.radius * e.radius; + intersectsSphere(t) { + return this.clampPoint(t.center, cn), cn.distanceToSquared(t.center) <= t.radius * t.radius; } - intersectsPlane(e) { - let t, n; - return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; + 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(e) { + intersectsTriangle(t) { if (this.isEmpty()) return !1; - this.getCenter(Yi), Wr.subVectors(this.max, Yi), ni.subVectors(e.a, Yi), ii.subVectors(e.b, Yi), ri.subVectors(e.c, Yi), un.subVectors(ii, ni), dn.subVectors(ri, ii), Pn.subVectors(ni, ri); - let t = [ + this.getCenter(cs), Xs.subVectors(this.max, cs), xi.subVectors(t.a, cs), vi.subVectors(t.b, cs), yi.subVectors(t.c, cs), Tn.subVectors(vi, xi), wn.subVectors(yi, vi), Gn.subVectors(xi, yi); + let e = [ 0, - -un.z, - un.y, + -Tn.z, + Tn.y, 0, - -dn.z, - dn.y, + -wn.z, + wn.y, 0, - -Pn.z, - Pn.y, - un.z, + -Gn.z, + Gn.y, + Tn.z, 0, - -un.x, - dn.z, + -Tn.x, + wn.z, 0, - -dn.x, - Pn.z, + -wn.x, + Gn.z, 0, - -Pn.x, - -un.y, - un.x, + -Gn.x, + -Tn.y, + Tn.x, 0, - -dn.y, - dn.x, + -wn.y, + wn.x, 0, - -Pn.y, - Pn.x, + -Gn.y, + Gn.x, 0 ]; - return !wo(t, ni, ii, ri, Wr) || (t = [ + return !Ia(e, xi, vi, yi, Xs) || (e = [ 1, 0, 0, @@ -1451,72 +1885,70 @@ var Mo = new M, yl = new gt, Lt = class { 0, 0, 1 - ], !wo(t, ni, ii, ri, Wr)) ? !1 : (qr.crossVectors(un, dn), t = [ - qr.x, - qr.y, - qr.z - ], wo(t, ni, ii, ri, Wr)); - } - clampPoint(e, t) { - return t.copy(e).clamp(this.min, this.max); - } - distanceToPoint(e) { - return Ji.copy(e).clamp(this.min, this.max).sub(e).length(); - } - getBoundingSphere(e) { - return this.getCenter(e.center), e.radius = this.getSize(Ji).length() * .5, e; - } - intersect(e) { - return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; - } - union(e) { - return this.min.min(e.min), this.max.max(e.max), this; - } - applyMatrix4(e) { - return this.isEmpty() ? this : ($t[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), $t[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), $t[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), $t[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), $t[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), $t[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), $t[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), $t[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints($t), this); - } - translate(e) { - return this.min.add(e), this.max.add(e), this; - } - equals(e) { - return e.min.equals(this.min) && e.max.equals(this.max); - } -}; -Lt.prototype.isBox3 = !0; -var $t = [ - new M, - new M, - new M, - new M, - new M, - new M, - new M, - new M -], Ji = new M, bo = new Lt, ni = new M, ii = new M, ri = new M, un = new M, dn = new M, Pn = new M, Yi = new M, Wr = new M, qr = new M, In = new M; -function wo(s, e, t, n, i) { - for(let r = 0, o = s.length - 3; r <= o; r += 3){ - In.fromArray(s, r); - let a = i.x * Math.abs(In.x) + i.y * Math.abs(In.y) + i.z * Math.abs(In.z), l = e.dot(In), c = t.dot(In), h = n.dot(In); - if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > a) return !1; + ], !Ia(e, xi, vi, yi, Xs)) ? !1 : (qs.crossVectors(Tn, wn), e = [ + qs.x, + qs.y, + qs.z + ], Ia(e, xi, vi, yi, Xs)); + } + clampPoint(t, e) { + return e.copy(t).clamp(this.min, this.max); + } + distanceToPoint(t) { + return this.clampPoint(t, cn).distanceTo(t); + } + getBoundingSphere(t) { + return this.isEmpty() ? t.makeEmpty() : (this.getCenter(t.center), t.radius = this.getSize(cn).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 : (on[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), on[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), on[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), on[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), on[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), on[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), on[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), on[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(on), 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); + } +}, on = [ + new A, + new A, + new A, + new A, + new A, + new A, + new A, + new A +], cn = new A, _i = new Ke, xi = new A, vi = new A, yi = new A, Tn = new A, wn = new A, Gn = new A, cs = new A, Xs = new A, qs = new A, Wn = new A; +function Ia(s1, t, e, n, i) { + for(let r = 0, a = s1.length - 3; r <= a; r += 3){ + Wn.fromArray(s1, r); + let o = i.x * Math.abs(Wn.x) + i.y * Math.abs(Wn.y) + i.z * Math.abs(Wn.z), c = t.dot(Wn), l = e.dot(Wn), h = n.dot(Wn); + if (Math.max(-Math.max(c, l, h), Math.min(c, l, h)) > o) return !1; } return !0; } -var ef = new Lt, vl = new M, Xr = new M, So = new M, An = class { - constructor(e = new M, t = -1){ - this.center = e, this.radius = t; +var ip = new Ke, ls = new A, Ua = new A, We = class { + constructor(t = new A, e = -1){ + this.center = t, this.radius = e; } - set(e, t) { - return this.center.copy(e), this.radius = t, this; + set(t, e) { + return this.center.copy(t), this.radius = e, this; } - setFromPoints(e, t) { + setFromPoints(t, e) { let n = this.center; - t !== void 0 ? n.copy(t) : ef.setFromPoints(e).getCenter(n); + e !== void 0 ? n.copy(e) : ip.setFromPoints(t).getCenter(n); let i = 0; - for(let r = 0, o = e.length; r < o; r++)i = Math.max(i, n.distanceToSquared(e[r])); + for(let r = 0, a = t.length; r < a; r++)i = Math.max(i, n.distanceToSquared(t[r])); return this.radius = Math.sqrt(i), this; } - copy(e) { - return this.center.copy(e.center), this.radius = e.radius, this; + copy(t) { + return this.center.copy(t.center), this.radius = t.radius, this; } isEmpty() { return this.radius < 0; @@ -1524,155 +1956,156 @@ var ef = new Lt, vl = new M, Xr = new M, So = new M, An = class { makeEmpty() { return this.center.set(0, 0, 0), this.radius = -1, this; } - containsPoint(e) { - return e.distanceToSquared(this.center) <= this.radius * this.radius; + containsPoint(t) { + return t.distanceToSquared(this.center) <= this.radius * this.radius; } - distanceToPoint(e) { - return e.distanceTo(this.center) - this.radius; + distanceToPoint(t) { + return t.distanceTo(this.center) - this.radius; } - intersectsSphere(e) { - let t = this.radius + e.radius; - return e.center.distanceToSquared(this.center) <= t * t; + intersectsSphere(t) { + let e = this.radius + t.radius; + return t.center.distanceToSquared(this.center) <= e * e; } - intersectsBox(e) { - return e.intersectsSphere(this); + intersectsBox(t) { + return t.intersectsSphere(this); } - intersectsPlane(e) { - return Math.abs(e.distanceToPoint(this.center)) <= this.radius; + intersectsPlane(t) { + return Math.abs(t.distanceToPoint(this.center)) <= this.radius; } - clampPoint(e, t) { - let n = this.center.distanceToSquared(e); - return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t; + clampPoint(t, e) { + let n = this.center.distanceToSquared(t); + return e.copy(t), n > this.radius * this.radius && (e.sub(this.center).normalize(), e.multiplyScalar(this.radius).add(this.center)), e; } - getBoundingBox(e) { - return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); + getBoundingBox(t) { + return this.isEmpty() ? (t.makeEmpty(), t) : (t.set(this.center, this.center), t.expandByScalar(this.radius), t); } - applyMatrix4(e) { - return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this; + applyMatrix4(t) { + return this.center.applyMatrix4(t), this.radius = this.radius * t.getMaxScaleOnAxis(), this; } - translate(e) { - return this.center.add(e), this; + translate(t) { + return this.center.add(t), this; } - expandByPoint(e) { - So.subVectors(e, this.center); - let t = So.lengthSq(); - if (t > this.radius * this.radius) { - let n = Math.sqrt(t), i = (n - this.radius) * .5; - this.center.add(So.multiplyScalar(i / n)), this.radius += i; + expandByPoint(t) { + if (this.isEmpty()) return this.center.copy(t), this.radius = 0, this; + ls.subVectors(t, this.center); + let e = ls.lengthSq(); + if (e > this.radius * this.radius) { + let n = Math.sqrt(e), i = (n - this.radius) * .5; + this.center.addScaledVector(ls, i / n), this.radius += i; } return this; } - union(e) { - return this.center.equals(e.center) === !0 ? Xr.set(0, 0, 1).multiplyScalar(e.radius) : Xr.subVectors(e.center, this.center).normalize().multiplyScalar(e.radius), this.expandByPoint(vl.copy(e.center).add(Xr)), this.expandByPoint(vl.copy(e.center).sub(Xr)), 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) : (Ua.subVectors(t.center, this.center).setLength(t.radius), this.expandByPoint(ls.copy(t.center).add(Ua)), this.expandByPoint(ls.copy(t.center).sub(Ua))), this); } - equals(e) { - return e.center.equals(this.center) && e.radius === this.radius; + equals(t) { + return t.center.equals(this.center) && t.radius === this.radius; } clone() { return new this.constructor().copy(this); } -}, jt = new M, To = new M, Jr = new M, fn = new M, Eo = new M, Yr = new M, Ao = new M, Cn = class { - constructor(e = new M, t = new M(0, 0, -1)){ - this.origin = e, this.direction = t; +}, ln = new A, Da = new A, Ys = new A, An = new A, Na = new A, Zs = new A, Fa = new A, hi = class { + constructor(t = new A, e = new A(0, 0, -1)){ + this.origin = t, this.direction = e; } - set(e, t) { - return this.origin.copy(e), this.direction.copy(t), this; + set(t, e) { + return this.origin.copy(t), this.direction.copy(e), this; } - copy(e) { - return this.origin.copy(e.origin), this.direction.copy(e.direction), this; + copy(t) { + return this.origin.copy(t.origin), this.direction.copy(t.direction), this; } - at(e, t) { - return t.copy(this.direction).multiplyScalar(e).add(this.origin); + at(t, e) { + return e.copy(this.origin).addScaledVector(this.direction, t); } - lookAt(e) { - return this.direction.copy(e).sub(this.origin).normalize(), this; + lookAt(t) { + return this.direction.copy(t).sub(this.origin).normalize(), this; } - recast(e) { - return this.origin.copy(this.at(e, jt)), this; + recast(t) { + return this.origin.copy(this.at(t, ln)), this; } - closestPointToPoint(e, t) { - t.subVectors(e, this.origin); - let n = t.dot(this.direction); - return n < 0 ? t.copy(this.origin) : t.copy(this.direction).multiplyScalar(n).add(this.origin); + 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(e) { - return Math.sqrt(this.distanceSqToPoint(e)); + distanceToPoint(t) { + return Math.sqrt(this.distanceSqToPoint(t)); } - distanceSqToPoint(e) { - let t = jt.subVectors(e, this.origin).dot(this.direction); - return t < 0 ? this.origin.distanceToSquared(e) : (jt.copy(this.direction).multiplyScalar(t).add(this.origin), jt.distanceToSquared(e)); + distanceSqToPoint(t) { + let e = ln.subVectors(t, this.origin).dot(this.direction); + return e < 0 ? this.origin.distanceToSquared(t) : (ln.copy(this.origin).addScaledVector(this.direction, e), ln.distanceToSquared(t)); } - distanceSqToSegment(e, t, n, i) { - To.copy(e).add(t).multiplyScalar(.5), Jr.copy(t).sub(e).normalize(), fn.copy(this.origin).sub(To); - let r = e.distanceTo(t) * .5, o = -this.direction.dot(Jr), a = fn.dot(this.direction), l = -fn.dot(Jr), c = fn.lengthSq(), h = Math.abs(1 - o * o), u, d, f, m; - if (h > 0) if (u = o * l - a, d = o * a - l, m = r * h, u >= 0) if (d >= -m) if (d <= m) { + distanceSqToSegment(t, e, n, i) { + Da.copy(t).add(e).multiplyScalar(.5), Ys.copy(e).sub(t).normalize(), An.copy(this.origin).sub(Da); + let r = t.distanceTo(e) * .5, a = -this.direction.dot(Ys), o = An.dot(this.direction), c = -An.dot(Ys), l = An.lengthSq(), h = Math.abs(1 - a * a), u, d, f, m; + if (h > 0) if (u = a * c - o, d = a * o - c, m = r * h, u >= 0) if (d >= -m) if (d <= m) { let x = 1 / h; - u *= x, d *= x, f = u * (u + o * d + 2 * a) + d * (o * u + d + 2 * l) + c; - } else d = r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - else d = -r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - else d <= -m ? (u = Math.max(0, -(-o * r + a)), d = u > 0 ? -r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c) : d <= m ? (u = 0, d = Math.min(Math.max(-r, -l), r), f = d * (d + 2 * l) + c) : (u = Math.max(0, -(o * r + a)), d = u > 0 ? r : Math.min(Math.max(-r, -l), r), f = -u * u + d * (d + 2 * l) + c); - else d = o > 0 ? -r : r, u = Math.max(0, -(o * d + a)), f = -u * u + d * (d + 2 * l) + c; - return n && n.copy(this.direction).multiplyScalar(u).add(this.origin), i && i.copy(Jr).multiplyScalar(d).add(To), f; - } - intersectSphere(e, t) { - jt.subVectors(e.center, this.origin); - let n = jt.dot(this.direction), i = jt.dot(jt) - n * n, r = e.radius * e.radius; + u *= x, d *= x, f = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * c) + l; + } else d = r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l; + else d = -r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l; + else d <= -m ? (u = Math.max(0, -(-a * r + o)), d = u > 0 ? -r : Math.min(Math.max(-r, -c), r), f = -u * u + d * (d + 2 * c) + l) : d <= m ? (u = 0, d = Math.min(Math.max(-r, -c), r), f = d * (d + 2 * c) + l) : (u = Math.max(0, -(a * r + o)), d = u > 0 ? r : Math.min(Math.max(-r, -c), r), f = -u * u + d * (d + 2 * c) + l); + else d = a > 0 ? -r : r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l; + return n && n.copy(this.origin).addScaledVector(this.direction, u), i && i.copy(Da).addScaledVector(Ys, d), f; + } + intersectSphere(t, e) { + ln.subVectors(t.center, this.origin); + let n = ln.dot(this.direction), i = ln.dot(ln) - n * n, r = t.radius * t.radius; if (i > r) return null; - let o = Math.sqrt(r - i), a = n - o, l = n + o; - return a < 0 && l < 0 ? null : a < 0 ? this.at(l, t) : this.at(a, t); + let a = Math.sqrt(r - i), o = n - a, c = n + a; + return c < 0 ? null : o < 0 ? this.at(c, e) : this.at(o, e); } - intersectsSphere(e) { - return this.distanceSqToPoint(e.center) <= e.radius * e.radius; + intersectsSphere(t) { + return this.distanceSqToPoint(t.center) <= t.radius * t.radius; } - distanceToPlane(e) { - let t = e.normal.dot(this.direction); - if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; - let n = -(this.origin.dot(e.normal) + e.constant) / t; + 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(e, t) { - let n = this.distanceToPlane(e); - return n === null ? null : this.at(n, t); + intersectPlane(t, e) { + let n = this.distanceToPlane(t); + return n === null ? null : this.at(n, e); } - intersectsPlane(e) { - let t = e.distanceToPoint(this.origin); - return t === 0 || e.normal.dot(this.direction) * t < 0; + intersectsPlane(t) { + let e = t.distanceToPoint(this.origin); + return e === 0 || t.normal.dot(this.direction) * e < 0; } - intersectBox(e, t) { - let n, i, r, o, a, l, c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin; - return c >= 0 ? (n = (e.min.x - d.x) * c, i = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, i = (e.min.x - d.x) * c), h >= 0 ? (r = (e.min.y - d.y) * h, o = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, o = (e.min.y - d.y) * h), n > o || r > i || ((r > n || n !== n) && (n = r), (o < i || i !== i) && (i = o), u >= 0 ? (a = (e.min.z - d.z) * u, l = (e.max.z - d.z) * u) : (a = (e.max.z - d.z) * u, l = (e.min.z - d.z) * u), n > l || a > i) || ((a > n || n !== n) && (n = a), (l < i || i !== i) && (i = l), i < 0) ? null : this.at(n >= 0 ? n : i, t); + intersectBox(t, e) { + let n, i, r, a, o, c, l = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin; + return l >= 0 ? (n = (t.min.x - d.x) * l, i = (t.max.x - d.x) * l) : (n = (t.max.x - d.x) * l, i = (t.min.x - d.x) * l), h >= 0 ? (r = (t.min.y - d.y) * h, a = (t.max.y - d.y) * h) : (r = (t.max.y - d.y) * h, a = (t.min.y - d.y) * h), n > a || r > i || ((r > n || isNaN(n)) && (n = r), (a < i || isNaN(i)) && (i = a), u >= 0 ? (o = (t.min.z - d.z) * u, c = (t.max.z - d.z) * u) : (o = (t.max.z - d.z) * u, c = (t.min.z - d.z) * u), n > c || o > i) || ((o > n || n !== n) && (n = o), (c < i || i !== i) && (i = c), i < 0) ? null : this.at(n >= 0 ? n : i, e); } - intersectsBox(e) { - return this.intersectBox(e, jt) !== null; + intersectsBox(t) { + return this.intersectBox(t, ln) !== null; } - intersectTriangle(e, t, n, i, r) { - Eo.subVectors(t, e), Yr.subVectors(n, e), Ao.crossVectors(Eo, Yr); - let o = this.direction.dot(Ao), a; - if (o > 0) { + intersectTriangle(t, e, n, i, r) { + Na.subVectors(e, t), Zs.subVectors(n, t), Fa.crossVectors(Na, Zs); + let a = this.direction.dot(Fa), o; + if (a > 0) { if (i) return null; - a = 1; - } else if (o < 0) a = -1, o = -o; + o = 1; + } else if (a < 0) o = -1, a = -a; else return null; - fn.subVectors(this.origin, e); - let l = a * this.direction.dot(Yr.crossVectors(fn, Yr)); - if (l < 0) return null; - let c = a * this.direction.dot(Eo.cross(fn)); - if (c < 0 || l + c > o) return null; - let h = -a * fn.dot(Ao); - return h < 0 ? null : this.at(h / o, r); + An.subVectors(this.origin, t); + let c = o * this.direction.dot(Zs.crossVectors(An, Zs)); + if (c < 0) return null; + let l = o * this.direction.dot(Na.cross(An)); + if (l < 0 || c + l > a) return null; + let h = -o * An.dot(Fa); + return h < 0 ? null : this.at(h / a, r); } - applyMatrix4(e) { - return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; + applyMatrix4(t) { + return this.origin.applyMatrix4(t), this.direction.transformDirection(t), this; } - equals(e) { - return e.origin.equals(this.origin) && e.direction.equals(this.direction); + equals(t) { + return t.origin.equals(this.origin) && t.direction.equals(this.direction); } clone() { return new this.constructor().copy(this); } -}, pe = class { - constructor(){ - this.elements = [ +}, Ot = class s1 { + constructor(t, e, n, i, r, a, o, c, l, h, u, d, f, m, x, g){ + s1.prototype.isMatrix4 = !0, this.elements = [ 1, 0, 0, @@ -1689,324 +2122,316 @@ var ef = new Lt, vl = new M, Xr = new M, So = new M, An = class { 0, 0, 1 - ], arguments.length > 0 && console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead."); + ], t !== void 0 && this.set(t, e, n, i, r, a, o, c, l, h, u, d, f, m, x, g); } - set(e, t, n, i, r, o, a, l, c, h, u, d, f, m, x, v) { - let g = this.elements; - return g[0] = e, g[4] = t, g[8] = n, g[12] = i, g[1] = r, g[5] = o, g[9] = a, g[13] = l, g[2] = c, g[6] = h, g[10] = u, g[14] = d, g[3] = f, g[7] = m, g[11] = x, g[15] = v, this; + set(t, e, n, i, r, a, o, c, l, h, u, d, f, m, x, g) { + let p = this.elements; + return p[0] = t, p[4] = e, p[8] = n, p[12] = i, p[1] = r, p[5] = a, p[9] = o, p[13] = c, p[2] = l, p[6] = h, p[10] = u, p[14] = d, p[3] = f, p[7] = m, p[11] = x, p[15] = g, this; } identity() { return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; } clone() { - return new pe().fromArray(this.elements); - } - copy(e) { - let t = this.elements, n = e.elements; - return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; - } - copyPosition(e) { - let t = this.elements, n = e.elements; - return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; - } - setFromMatrix3(e) { - let t = e.elements; - return this.set(t[0], t[3], t[6], 0, t[1], t[4], t[7], 0, t[2], t[5], t[8], 0, 0, 0, 0, 1), this; - } - extractBasis(e, t, n) { - return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; - } - makeBasis(e, t, n) { - return this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this; - } - extractRotation(e) { - let t = this.elements, n = e.elements, i = 1 / si.setFromMatrixColumn(e, 0).length(), r = 1 / si.setFromMatrixColumn(e, 1).length(), o = 1 / si.setFromMatrixColumn(e, 2).length(); - return t[0] = n[0] * i, t[1] = n[1] * i, t[2] = n[2] * i, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, t[7] = 0, t[8] = n[8] * o, t[9] = n[9] * o, t[10] = n[10] * o, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; - } - makeRotationFromEuler(e) { - e && e.isEuler || console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."); - let t = this.elements, n = e.x, i = e.y, r = e.z, o = Math.cos(n), a = Math.sin(n), l = Math.cos(i), c = Math.sin(i), h = Math.cos(r), u = Math.sin(r); - if (e.order === "XYZ") { - let d = o * h, f = o * u, m = a * h, x = a * u; - t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = f + m * c, t[5] = d - x * c, t[9] = -a * l, t[2] = x - d * c, t[6] = m + f * c, t[10] = o * l; - } else if (e.order === "YXZ") { - let d = l * h, f = l * u, m = c * h, x = c * u; - t[0] = d + x * a, t[4] = m * a - f, t[8] = o * c, t[1] = o * u, t[5] = o * h, t[9] = -a, t[2] = f * a - m, t[6] = x + d * a, t[10] = o * l; - } else if (e.order === "ZXY") { - let d = l * h, f = l * u, m = c * h, x = c * u; - t[0] = d - x * a, t[4] = -o * u, t[8] = m + f * a, t[1] = f + m * a, t[5] = o * h, t[9] = x - d * a, t[2] = -o * c, t[6] = a, t[10] = o * l; - } else if (e.order === "ZYX") { - let d = o * h, f = o * u, m = a * h, x = a * u; - t[0] = l * h, t[4] = m * c - f, t[8] = d * c + x, t[1] = l * u, t[5] = x * c + d, t[9] = f * c - m, t[2] = -c, t[6] = a * l, t[10] = o * l; - } else if (e.order === "YZX") { - let d = o * l, f = o * c, m = a * l, x = a * c; - t[0] = l * h, t[4] = x - d * u, t[8] = m * u + f, t[1] = u, t[5] = o * h, t[9] = -a * h, t[2] = -c * h, t[6] = f * u + m, t[10] = d - x * u; - } else if (e.order === "XZY") { - let d = o * l, f = o * c, m = a * l, x = a * c; - t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = d * u + x, t[5] = o * h, t[9] = f * u - m, t[2] = m * u - f, t[6] = a * h, t[10] = x * u + d; - } - return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; - } - makeRotationFromQuaternion(e) { - return this.compose(tf, e, nf); - } - lookAt(e, t, n) { + return new s1().fromArray(this.elements); + } + 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], e[9] = n[9], e[10] = n[10], e[11] = n[11], e[12] = n[12], e[13] = n[13], e[14] = n[14], e[15] = n[15], this; + } + copyPosition(t) { + let e = this.elements, n = t.elements; + return e[12] = n[12], e[13] = n[13], e[14] = n[14], this; + } + setFromMatrix3(t) { + let e = t.elements; + return this.set(e[0], e[3], e[6], 0, e[1], e[4], e[7], 0, e[2], e[5], e[8], 0, 0, 0, 0, 1), this; + } + extractBasis(t, e, n) { + return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this; + } + makeBasis(t, e, n) { + return this.set(t.x, e.x, n.x, 0, t.y, e.y, n.y, 0, t.z, e.z, n.z, 0, 0, 0, 0, 1), this; + } + extractRotation(t) { + let e = this.elements, n = t.elements, i = 1 / Mi.setFromMatrixColumn(t, 0).length(), r = 1 / Mi.setFromMatrixColumn(t, 1).length(), a = 1 / Mi.setFromMatrixColumn(t, 2).length(); + return e[0] = n[0] * i, e[1] = n[1] * i, e[2] = n[2] * i, e[3] = 0, e[4] = n[4] * r, e[5] = n[5] * r, e[6] = n[6] * r, e[7] = 0, e[8] = n[8] * a, e[9] = n[9] * a, e[10] = n[10] * a, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this; + } + makeRotationFromEuler(t) { + let e = this.elements, n = t.x, i = t.y, r = t.z, a = Math.cos(n), o = Math.sin(n), c = Math.cos(i), l = Math.sin(i), h = Math.cos(r), u = Math.sin(r); + if (t.order === "XYZ") { + let d = a * h, f = a * u, m = o * h, x = o * u; + e[0] = c * h, e[4] = -c * u, e[8] = l, e[1] = f + m * l, e[5] = d - x * l, e[9] = -o * c, e[2] = x - d * l, e[6] = m + f * l, e[10] = a * c; + } else if (t.order === "YXZ") { + let d = c * h, f = c * u, m = l * h, x = l * u; + e[0] = d + x * o, e[4] = m * o - f, e[8] = a * l, e[1] = a * u, e[5] = a * h, e[9] = -o, e[2] = f * o - m, e[6] = x + d * o, e[10] = a * c; + } else if (t.order === "ZXY") { + let d = c * h, f = c * u, m = l * h, x = l * u; + e[0] = d - x * o, e[4] = -a * u, e[8] = m + f * o, e[1] = f + m * o, e[5] = a * h, e[9] = x - d * o, e[2] = -a * l, e[6] = o, e[10] = a * c; + } else if (t.order === "ZYX") { + let d = a * h, f = a * u, m = o * h, x = o * u; + e[0] = c * h, e[4] = m * l - f, e[8] = d * l + x, e[1] = c * u, e[5] = x * l + d, e[9] = f * l - m, e[2] = -l, e[6] = o * c, e[10] = a * c; + } else if (t.order === "YZX") { + let d = a * c, f = a * l, m = o * c, x = o * l; + e[0] = c * h, e[4] = x - d * u, e[8] = m * u + f, e[1] = u, e[5] = a * h, e[9] = -o * h, e[2] = -l * h, e[6] = f * u + m, e[10] = d - x * u; + } else if (t.order === "XZY") { + let d = a * c, f = a * l, m = o * c, x = o * l; + e[0] = c * h, e[4] = -u, e[8] = l * h, e[1] = d * u + x, e[5] = a * h, e[9] = f * u - m, e[2] = m * u - f, e[6] = o * h, e[10] = x * u + d; + } + return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this; + } + makeRotationFromQuaternion(t) { + return this.compose(sp, t, rp); + } + lookAt(t, e, n) { let i = this.elements; - return St.subVectors(e, t), St.lengthSq() === 0 && (St.z = 1), St.normalize(), pn.crossVectors(n, St), pn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? St.x += 1e-4 : St.z += 1e-4, St.normalize(), pn.crossVectors(n, St)), pn.normalize(), Zr.crossVectors(St, pn), i[0] = pn.x, i[4] = Zr.x, i[8] = St.x, i[1] = pn.y, i[5] = Zr.y, i[9] = St.y, i[2] = pn.z, i[6] = Zr.z, i[10] = St.z, this; + return Fe.subVectors(t, e), Fe.lengthSq() === 0 && (Fe.z = 1), Fe.normalize(), Rn.crossVectors(n, Fe), Rn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? Fe.x += 1e-4 : Fe.z += 1e-4, Fe.normalize(), Rn.crossVectors(n, Fe)), Rn.normalize(), Js.crossVectors(Fe, Rn), i[0] = Rn.x, i[4] = Js.x, i[8] = Fe.x, i[1] = Rn.y, i[5] = Js.y, i[9] = Fe.y, i[2] = Rn.z, i[6] = Js.z, i[10] = Fe.z, this; } - multiply(e, t) { - return t !== void 0 ? (console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), this.multiplyMatrices(e, t)) : this.multiplyMatrices(this, e); + multiply(t) { + return this.multiplyMatrices(this, t); } - premultiply(e) { - return this.multiplyMatrices(e, this); + premultiply(t) { + return this.multiplyMatrices(t, this); } - multiplyMatrices(e, t) { - let n = e.elements, i = t.elements, r = this.elements, o = n[0], a = n[4], l = n[8], c = n[12], h = n[1], u = n[5], d = n[9], f = n[13], m = n[2], x = n[6], v = n[10], g = n[14], p = n[3], _ = n[7], y = n[11], b = n[15], A = i[0], L = i[4], I = i[8], k = i[12], B = i[1], P = i[5], w = i[9], E = i[13], D = i[2], U = i[6], F = i[10], O = i[14], ne = i[3], ce = i[7], V = i[11], W = i[15]; - return r[0] = o * A + a * B + l * D + c * ne, r[4] = o * L + a * P + l * U + c * ce, r[8] = o * I + a * w + l * F + c * V, r[12] = o * k + a * E + l * O + c * W, r[1] = h * A + u * B + d * D + f * ne, r[5] = h * L + u * P + d * U + f * ce, r[9] = h * I + u * w + d * F + f * V, r[13] = h * k + u * E + d * O + f * W, r[2] = m * A + x * B + v * D + g * ne, r[6] = m * L + x * P + v * U + g * ce, r[10] = m * I + x * w + v * F + g * V, r[14] = m * k + x * E + v * O + g * W, r[3] = p * A + _ * B + y * D + b * ne, r[7] = p * L + _ * P + y * U + b * ce, r[11] = p * I + _ * w + y * F + b * V, r[15] = p * k + _ * E + y * O + b * W, this; + multiplyMatrices(t, e) { + let n = t.elements, i = e.elements, r = this.elements, a = n[0], o = n[4], c = n[8], l = n[12], h = n[1], u = n[5], d = n[9], f = n[13], m = n[2], x = n[6], g = n[10], p = n[14], v = n[3], _ = n[7], y = n[11], b = n[15], w = i[0], R = i[4], L = i[8], M = i[12], E = i[1], V = i[5], $ = i[9], F = i[13], O = i[2], z = i[6], K = i[10], X = i[14], Y = i[3], j = i[7], tt = i[11], N = i[15]; + return r[0] = a * w + o * E + c * O + l * Y, r[4] = a * R + o * V + c * z + l * j, r[8] = a * L + o * $ + c * K + l * tt, r[12] = a * M + o * F + c * X + l * N, r[1] = h * w + u * E + d * O + f * Y, r[5] = h * R + u * V + d * z + f * j, r[9] = h * L + u * $ + d * K + f * tt, r[13] = h * M + u * F + d * X + f * N, r[2] = m * w + x * E + g * O + p * Y, r[6] = m * R + x * V + g * z + p * j, r[10] = m * L + x * $ + g * K + p * tt, r[14] = m * M + x * F + g * X + p * N, r[3] = v * w + _ * E + y * O + b * Y, r[7] = v * R + _ * V + y * z + b * j, r[11] = v * L + _ * $ + y * K + b * tt, r[15] = v * M + _ * F + y * X + b * N, this; } - multiplyScalar(e) { - let t = this.elements; - return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this; + multiplyScalar(t) { + let e = this.elements; + return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this; } determinant() { - let e = this.elements, t = e[0], n = e[4], i = e[8], r = e[12], o = e[1], a = e[5], l = e[9], c = e[13], h = e[2], u = e[6], d = e[10], f = e[14], m = e[3], x = e[7], v = e[11], g = e[15]; - return m * (+r * l * u - i * c * u - r * a * d + n * c * d + i * a * f - n * l * f) + x * (+t * l * f - t * c * d + r * o * d - i * o * f + i * c * h - r * l * h) + v * (+t * c * u - t * a * f - r * o * u + n * o * f + r * a * h - n * c * h) + g * (-i * a * h - t * l * u + t * a * d + i * o * u - n * o * d + n * l * h); + let t = this.elements, e = t[0], n = t[4], i = t[8], r = t[12], a = t[1], o = t[5], c = t[9], l = t[13], h = t[2], u = t[6], d = t[10], f = t[14], m = t[3], x = t[7], g = t[11], p = t[15]; + return m * (+r * c * u - i * l * u - r * o * d + n * l * d + i * o * f - n * c * f) + x * (+e * c * f - e * l * d + r * a * d - i * a * f + i * l * h - r * c * h) + g * (+e * l * u - e * o * f - r * a * u + n * a * f + r * o * h - n * l * h) + p * (-i * o * h - e * c * u + e * o * d + i * a * u - n * a * d + n * c * h); } transpose() { - let e = this.elements, t; - return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this; + let t = this.elements, e; + return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this; } - setPosition(e, t, n) { + setPosition(t, e, n) { let i = this.elements; - return e.isVector3 ? (i[12] = e.x, i[13] = e.y, i[14] = e.z) : (i[12] = e, i[13] = t, i[14] = n), this; + return t.isVector3 ? (i[12] = t.x, i[13] = t.y, i[14] = t.z) : (i[12] = t, i[13] = e, i[14] = n), this; } invert() { - let e = this.elements, t = e[0], n = e[1], i = e[2], r = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], u = e[9], d = e[10], f = e[11], m = e[12], x = e[13], v = e[14], g = e[15], p = u * v * c - x * d * c + x * l * f - a * v * f - u * l * g + a * d * g, _ = m * d * c - h * v * c - m * l * f + o * v * f + h * l * g - o * d * g, y = h * x * c - m * u * c + m * a * f - o * x * f - h * a * g + o * u * g, b = m * u * l - h * x * l - m * a * d + o * x * d + h * a * v - o * u * v, A = t * p + n * _ + i * y + r * b; - if (A === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - let L = 1 / A; - return e[0] = p * L, e[1] = (x * d * r - u * v * r - x * i * f + n * v * f + u * i * g - n * d * g) * L, e[2] = (a * v * r - x * l * r + x * i * c - n * v * c - a * i * g + n * l * g) * L, e[3] = (u * l * r - a * d * r - u * i * c + n * d * c + a * i * f - n * l * f) * L, e[4] = _ * L, e[5] = (h * v * r - m * d * r + m * i * f - t * v * f - h * i * g + t * d * g) * L, e[6] = (m * l * r - o * v * r - m * i * c + t * v * c + o * i * g - t * l * g) * L, e[7] = (o * d * r - h * l * r + h * i * c - t * d * c - o * i * f + t * l * f) * L, e[8] = y * L, e[9] = (m * u * r - h * x * r - m * n * f + t * x * f + h * n * g - t * u * g) * L, e[10] = (o * x * r - m * a * r + m * n * c - t * x * c - o * n * g + t * a * g) * L, e[11] = (h * a * r - o * u * r - h * n * c + t * u * c + o * n * f - t * a * f) * L, e[12] = b * L, e[13] = (h * x * i - m * u * i + m * n * d - t * x * d - h * n * v + t * u * v) * L, e[14] = (m * a * i - o * x * i - m * n * l + t * x * l + o * n * v - t * a * v) * L, e[15] = (o * u * i - h * a * i + h * n * l - t * u * l - o * n * d + t * a * d) * L, this; + let t = this.elements, e = t[0], n = t[1], i = t[2], r = t[3], a = t[4], o = t[5], c = t[6], l = t[7], h = t[8], u = t[9], d = t[10], f = t[11], m = t[12], x = t[13], g = t[14], p = t[15], v = u * g * l - x * d * l + x * c * f - o * g * f - u * c * p + o * d * p, _ = m * d * l - h * g * l - m * c * f + a * g * f + h * c * p - a * d * p, y = h * x * l - m * u * l + m * o * f - a * x * f - h * o * p + a * u * p, b = m * u * c - h * x * c - m * o * d + a * x * d + h * o * g - a * u * g, w = e * v + n * _ + i * y + r * b; + if (w === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + let R = 1 / w; + return t[0] = v * R, t[1] = (x * d * r - u * g * r - x * i * f + n * g * f + u * i * p - n * d * p) * R, t[2] = (o * g * r - x * c * r + x * i * l - n * g * l - o * i * p + n * c * p) * R, t[3] = (u * c * r - o * d * r - u * i * l + n * d * l + o * i * f - n * c * f) * R, t[4] = _ * R, t[5] = (h * g * r - m * d * r + m * i * f - e * g * f - h * i * p + e * d * p) * R, t[6] = (m * c * r - a * g * r - m * i * l + e * g * l + a * i * p - e * c * p) * R, t[7] = (a * d * r - h * c * r + h * i * l - e * d * l - a * i * f + e * c * f) * R, t[8] = y * R, t[9] = (m * u * r - h * x * r - m * n * f + e * x * f + h * n * p - e * u * p) * R, t[10] = (a * x * r - m * o * r + m * n * l - e * x * l - a * n * p + e * o * p) * R, t[11] = (h * o * r - a * u * r - h * n * l + e * u * l + a * n * f - e * o * f) * R, t[12] = b * R, t[13] = (h * x * i - m * u * i + m * n * d - e * x * d - h * n * g + e * u * g) * R, t[14] = (m * o * i - a * x * i - m * n * c + e * x * c + a * n * g - e * o * g) * R, t[15] = (a * u * i - h * o * i + h * n * c - e * u * c - a * n * d + e * o * d) * R, this; } - scale(e) { - let t = this.elements, n = e.x, i = e.y, r = e.z; - return t[0] *= n, t[4] *= i, t[8] *= r, t[1] *= n, t[5] *= i, t[9] *= r, t[2] *= n, t[6] *= i, t[10] *= r, t[3] *= n, t[7] *= i, t[11] *= r, this; + scale(t) { + let e = this.elements, n = t.x, i = t.y, r = t.z; + return e[0] *= n, e[4] *= i, e[8] *= r, e[1] *= n, e[5] *= i, e[9] *= r, e[2] *= n, e[6] *= i, e[10] *= r, e[3] *= n, e[7] *= i, e[11] *= r, this; } getMaxScaleOnAxis() { - let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; - return Math.sqrt(Math.max(t, n, i)); - } - makeTranslation(e, t, n) { - return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, n, 0, 0, 0, 1), this; - } - makeRotationX(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this; - } - makeRotationY(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this; - } - makeRotationZ(e) { - let t = Math.cos(e), n = Math.sin(e); - return this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; - } - makeRotationAxis(e, t) { - let n = Math.cos(t), i = Math.sin(t), r = 1 - n, o = e.x, a = e.y, l = e.z, c = r * o, h = r * a; - return this.set(c * o + n, c * a - i * l, c * l + i * a, 0, c * a + i * l, h * a + n, h * l - i * o, 0, c * l - i * a, h * l + i * o, r * l * l + n, 0, 0, 0, 0, 1), this; - } - makeScale(e, t, n) { - return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this; - } - makeShear(e, t, n, i, r, o) { - return this.set(1, n, r, 0, e, 1, o, 0, t, i, 1, 0, 0, 0, 0, 1), this; - } - compose(e, t, n) { - let i = this.elements, r = t._x, o = t._y, a = t._z, l = t._w, c = r + r, h = o + o, u = a + a, d = r * c, f = r * h, m = r * u, x = o * h, v = o * u, g = a * u, p = l * c, _ = l * h, y = l * u, b = n.x, A = n.y, L = n.z; - return i[0] = (1 - (x + g)) * b, i[1] = (f + y) * b, i[2] = (m - _) * b, i[3] = 0, i[4] = (f - y) * A, i[5] = (1 - (d + g)) * A, i[6] = (v + p) * A, i[7] = 0, i[8] = (m + _) * L, i[9] = (v - p) * L, i[10] = (1 - (d + x)) * L, i[11] = 0, i[12] = e.x, i[13] = e.y, i[14] = e.z, i[15] = 1, this; - } - decompose(e, t, n) { - let i = this.elements, r = si.set(i[0], i[1], i[2]).length(), o = si.set(i[4], i[5], i[6]).length(), a = si.set(i[8], i[9], i[10]).length(); - this.determinant() < 0 && (r = -r), e.x = i[12], e.y = i[13], e.z = i[14], It.copy(this); - let c = 1 / r, h = 1 / o, u = 1 / a; - return It.elements[0] *= c, It.elements[1] *= c, It.elements[2] *= c, It.elements[4] *= h, It.elements[5] *= h, It.elements[6] *= h, It.elements[8] *= u, It.elements[9] *= u, It.elements[10] *= u, t.setFromRotationMatrix(It), n.x = r, n.y = o, n.z = a, this; - } - makePerspective(e, t, n, i, r, o) { - o === void 0 && console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."); - let a = this.elements, l = 2 * r / (t - e), c = 2 * r / (n - i), h = (t + e) / (t - e), u = (n + i) / (n - i), d = -(o + r) / (o - r), f = -2 * o * r / (o - r); - return a[0] = l, a[4] = 0, a[8] = h, a[12] = 0, a[1] = 0, a[5] = c, a[9] = u, a[13] = 0, a[2] = 0, a[6] = 0, a[10] = d, a[14] = f, a[3] = 0, a[7] = 0, a[11] = -1, a[15] = 0, this; - } - makeOrthographic(e, t, n, i, r, o) { - let a = this.elements, l = 1 / (t - e), c = 1 / (n - i), h = 1 / (o - r), u = (t + e) * l, d = (n + i) * c, f = (o + r) * h; - return a[0] = 2 * l, a[4] = 0, a[8] = 0, a[12] = -u, a[1] = 0, a[5] = 2 * c, a[9] = 0, a[13] = -d, a[2] = 0, a[6] = 0, a[10] = -2 * h, a[14] = -f, a[3] = 0, a[7] = 0, a[11] = 0, a[15] = 1, this; - } - equals(e) { - let t = this.elements, n = e.elements; - for(let i = 0; i < 16; i++)if (t[i] !== n[i]) return !1; + let t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], n = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], i = t[8] * t[8] + t[9] * t[9] + t[10] * t[10]; + return Math.sqrt(Math.max(e, n, i)); + } + makeTranslation(t, e, n) { + return t.isVector3 ? this.set(1, 0, 0, t.x, 0, 1, 0, t.y, 0, 0, 1, t.z, 0, 0, 0, 1) : this.set(1, 0, 0, t, 0, 1, 0, e, 0, 0, 1, n, 0, 0, 0, 1), this; + } + makeRotationX(t) { + let e = Math.cos(t), n = Math.sin(t); + return this.set(1, 0, 0, 0, 0, e, -n, 0, 0, n, e, 0, 0, 0, 0, 1), this; + } + makeRotationY(t) { + let e = Math.cos(t), n = Math.sin(t); + return this.set(e, 0, n, 0, 0, 1, 0, 0, -n, 0, e, 0, 0, 0, 0, 1), this; + } + makeRotationZ(t) { + let e = Math.cos(t), n = Math.sin(t); + return this.set(e, -n, 0, 0, n, e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; + } + makeRotationAxis(t, e) { + let n = Math.cos(e), i = Math.sin(e), r = 1 - n, a = t.x, o = t.y, c = t.z, l = r * a, h = r * o; + return this.set(l * a + n, l * o - i * c, l * c + i * o, 0, l * o + i * c, h * o + n, h * c - i * a, 0, l * c - i * o, h * c + i * a, r * c * c + n, 0, 0, 0, 0, 1), this; + } + makeScale(t, e, n) { + return this.set(t, 0, 0, 0, 0, e, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this; + } + makeShear(t, e, n, i, r, a) { + return this.set(1, n, r, 0, t, 1, a, 0, e, i, 1, 0, 0, 0, 0, 1), this; + } + compose(t, e, n) { + let i = this.elements, r = e._x, a = e._y, o = e._z, c = e._w, l = r + r, h = a + a, u = o + o, d = r * l, f = r * h, m = r * u, x = a * h, g = a * u, p = o * u, v = c * l, _ = c * h, y = c * u, b = n.x, w = n.y, R = n.z; + return i[0] = (1 - (x + p)) * b, i[1] = (f + y) * b, i[2] = (m - _) * b, i[3] = 0, i[4] = (f - y) * w, i[5] = (1 - (d + p)) * w, i[6] = (g + v) * w, i[7] = 0, i[8] = (m + _) * R, i[9] = (g - v) * R, i[10] = (1 - (d + x)) * R, i[11] = 0, i[12] = t.x, i[13] = t.y, i[14] = t.z, i[15] = 1, this; + } + decompose(t, e, n) { + let i = this.elements, r = Mi.set(i[0], i[1], i[2]).length(), a = Mi.set(i[4], i[5], i[6]).length(), o = Mi.set(i[8], i[9], i[10]).length(); + this.determinant() < 0 && (r = -r), t.x = i[12], t.y = i[13], t.z = i[14], Ze.copy(this); + let l = 1 / r, h = 1 / a, u = 1 / o; + return Ze.elements[0] *= l, Ze.elements[1] *= l, Ze.elements[2] *= l, Ze.elements[4] *= h, Ze.elements[5] *= h, Ze.elements[6] *= h, Ze.elements[8] *= u, Ze.elements[9] *= u, Ze.elements[10] *= u, e.setFromRotationMatrix(Ze), n.x = r, n.y = a, n.z = o, this; + } + makePerspective(t, e, n, i, r, a, o = vn) { + let c = this.elements, l = 2 * r / (e - t), h = 2 * r / (n - i), u = (e + t) / (e - t), d = (n + i) / (n - i), f, m; + if (o === vn) f = -(a + r) / (a - r), m = -2 * a * r / (a - r); + else if (o === Vr) f = -a / (a - r), m = -a * r / (a - r); + else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o); + return c[0] = l, c[4] = 0, c[8] = u, c[12] = 0, c[1] = 0, c[5] = h, c[9] = d, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = f, c[14] = m, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this; + } + makeOrthographic(t, e, n, i, r, a, o = vn) { + let c = this.elements, l = 1 / (e - t), h = 1 / (n - i), u = 1 / (a - r), d = (e + t) * l, f = (n + i) * h, m, x; + if (o === vn) m = (a + r) * u, x = -2 * u; + else if (o === Vr) m = r * u, x = -1 * u; + else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o); + return c[0] = 2 * l, c[4] = 0, c[8] = 0, c[12] = -d, c[1] = 0, c[5] = 2 * h, c[9] = 0, c[13] = -f, c[2] = 0, c[6] = 0, c[10] = x, c[14] = -m, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this; + } + equals(t) { + let e = this.elements, n = t.elements; + for(let i = 0; i < 16; i++)if (e[i] !== n[i]) return !1; return !0; } - fromArray(e, t = 0) { - for(let n = 0; n < 16; n++)this.elements[n] = e[n + t]; + fromArray(t, e = 0) { + for(let n = 0; n < 16; n++)this.elements[n] = t[n + e]; return this; } - toArray(e = [], t = 0) { + toArray(t = [], e = 0) { let n = this.elements; - return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; + 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[e + 9] = n[9], t[e + 10] = n[10], t[e + 11] = n[11], t[e + 12] = n[12], t[e + 13] = n[13], t[e + 14] = n[14], t[e + 15] = n[15], t; } -}; -pe.prototype.isMatrix4 = !0; -var si = new M, It = new pe, tf = new M(0, 0, 0), nf = new M(1, 1, 1), pn = new M, Zr = new M, St = new M, _l = new pe, Ml = new gt, Zn = class { - constructor(e = 0, t = 0, n = 0, i = Zn.DefaultOrder){ - this._x = e, this._y = t, this._z = n, this._order = i; +}, Mi = new A, Ze = new Ot, sp = new A(0, 0, 0), rp = new A(1, 1, 1), Rn = new A, Js = new A, Fe = new A, Fl = new Ot, Ol = new Pe, Xr = class s1 { + constructor(t = 0, e = 0, n = 0, i = s1.DEFAULT_ORDER){ + this.isEuler = !0, this._x = t, this._y = e, this._z = n, this._order = i; } get x() { return this._x; } - set x(e) { - this._x = e, this._onChangeCallback(); + set x(t) { + this._x = t, this._onChangeCallback(); } get y() { return this._y; } - set y(e) { - this._y = e, this._onChangeCallback(); + set y(t) { + this._y = t, this._onChangeCallback(); } get z() { return this._z; } - set z(e) { - this._z = e, this._onChangeCallback(); + set z(t) { + this._z = t, this._onChangeCallback(); } get order() { return this._order; } - set order(e) { - this._order = e, this._onChangeCallback(); + set order(t) { + this._order = t, this._onChangeCallback(); } - set(e, t, n, i = this._order) { - return this._x = e, this._y = t, this._z = n, this._order = i, this._onChangeCallback(), this; + set(t, e, n, i = this._order) { + return this._x = t, this._y = e, this._z = n, this._order = i, this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._order); } - copy(e) { - return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; + copy(t) { + return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this; } - setFromRotationMatrix(e, t = this._order, n = !0) { - let i = e.elements, r = i[0], o = i[4], a = i[8], l = i[1], c = i[5], h = i[9], u = i[2], d = i[6], f = i[10]; - switch(t){ + setFromRotationMatrix(t, e = this._order, n = !0) { + let i = t.elements, r = i[0], a = i[4], o = i[8], c = i[1], l = i[5], h = i[9], u = i[2], d = i[6], f = i[10]; + switch(e){ case "XYZ": - this._y = Math.asin(mt(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(-h, f), this._z = Math.atan2(-o, r)) : (this._x = Math.atan2(d, c), this._z = 0); + this._y = Math.asin(ae(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(-h, f), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(d, l), this._z = 0); break; case "YXZ": - this._x = Math.asin(-mt(h, -1, 1)), Math.abs(h) < .9999999 ? (this._y = Math.atan2(a, f), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0); + this._x = Math.asin(-ae(h, -1, 1)), Math.abs(h) < .9999999 ? (this._y = Math.atan2(o, f), this._z = Math.atan2(c, l)) : (this._y = Math.atan2(-u, r), this._z = 0); break; case "ZXY": - this._x = Math.asin(mt(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-o, c)) : (this._y = 0, this._z = Math.atan2(l, r)); + this._x = Math.asin(ae(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-a, l)) : (this._y = 0, this._z = Math.atan2(c, r)); break; case "ZYX": - this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-o, c)); + this._y = Math.asin(-ae(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(c, r)) : (this._x = 0, this._z = Math.atan2(-a, l)); break; case "YZX": - this._z = Math.asin(mt(l, -1, 1)), Math.abs(l) < .9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(a, f)); + this._z = Math.asin(ae(c, -1, 1)), Math.abs(c) < .9999999 ? (this._x = Math.atan2(-h, l), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, f)); break; case "XZY": - this._z = Math.asin(-mt(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(a, r)) : (this._x = Math.atan2(-h, f), this._y = 0); + this._z = Math.asin(-ae(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(d, l), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-h, f), this._y = 0); break; default: - console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t); + console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e); } - return this._order = t, n === !0 && this._onChangeCallback(), this; - } - setFromQuaternion(e, t, n) { - return _l.makeRotationFromQuaternion(e), this.setFromRotationMatrix(_l, t, n); + return this._order = e, n === !0 && this._onChangeCallback(), this; } - setFromVector3(e, t = this._order) { - return this.set(e.x, e.y, e.z, t); + setFromQuaternion(t, e, n) { + return Fl.makeRotationFromQuaternion(t), this.setFromRotationMatrix(Fl, e, n); } - reorder(e) { - return Ml.setFromEuler(this), this.setFromQuaternion(Ml, e); + setFromVector3(t, e = this._order) { + return this.set(t.x, t.y, t.z, e); } - equals(e) { - return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; + reorder(t) { + return Ol.setFromEuler(this), this.setFromQuaternion(Ol, t); } - fromArray(e) { - return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; + equals(t) { + return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order; } - toArray(e = [], t = 0) { - return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e; + fromArray(t) { + return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this; } - toVector3(e) { - return e ? e.set(this._x, this._y, this._z) : new M(this._x, this._y, this._z); + toArray(t = [], e = 0) { + return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t; } - _onChange(e) { - return this._onChangeCallback = e, this; + _onChange(t) { + return this._onChangeCallback = t, this; } _onChangeCallback() {} + *[Symbol.iterator]() { + yield this._x, yield this._y, yield this._z, yield this._order; + } }; -Zn.prototype.isEuler = !0; -Zn.DefaultOrder = "XYZ"; -Zn.RotationOrders = [ - "XYZ", - "YZX", - "ZXY", - "XZY", - "YXZ", - "ZYX" -]; -var Js = class { +Xr.DEFAULT_ORDER = "XYZ"; +var Rs = class { constructor(){ this.mask = 1; } - set(e) { - this.mask = (1 << e | 0) >>> 0; + set(t) { + this.mask = (1 << t | 0) >>> 0; } - enable(e) { - this.mask |= 1 << e | 0; + enable(t) { + this.mask |= 1 << t | 0; } enableAll() { this.mask = -1; } - toggle(e) { - this.mask ^= 1 << e | 0; + toggle(t) { + this.mask ^= 1 << t | 0; } - disable(e) { - this.mask &= ~(1 << e | 0); + disable(t) { + this.mask &= ~(1 << t | 0); } disableAll() { this.mask = 0; } - test(e) { - return (this.mask & e.mask) !== 0; + test(t) { + return (this.mask & t.mask) !== 0; } - isEnabled(e) { - return (this.mask & (1 << e | 0)) !== 0; + isEnabled(t) { + return (this.mask & (1 << t | 0)) !== 0; } -}, rf = 0, bl = new M, oi = new gt, Qt = new pe, $r = new M, Zi = new M, sf = new M, of = new gt, wl = new M(1, 0, 0), Sl = new M(0, 1, 0), Tl = new M(0, 0, 1), af = { +}, ap = 0, Bl = new A, Si = new Pe, hn = new Ot, $s = new A, hs = new A, op = new A, cp = new Pe, zl = new A(1, 0, 0), kl = new A(0, 1, 0), Vl = new A(0, 0, 1), lp = { type: "added" -}, El = { +}, Hl = { type: "removed" -}, Ne = class extends En { +}, Zt = class s1 extends sn { constructor(){ - super(); - Object.defineProperty(this, "id", { - value: rf++ - }), this.uuid = Et(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Ne.DefaultUp.clone(); - let e = new M, t = new Zn, n = new gt, i = new M(1, 1, 1); + super(), this.isObject3D = !0, Object.defineProperty(this, "id", { + value: ap++ + }), this.uuid = Be(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = s1.DEFAULT_UP.clone(); + let t = new A, e = new Xr, n = new Pe, i = new A(1, 1, 1); function r() { - n.setFromEuler(t, !1); + n.setFromEuler(e, !1); } - function o() { - t.setFromQuaternion(n, void 0, !1); + function a() { + e.setFromQuaternion(n, void 0, !1); } - t._onChange(r), n._onChange(o), Object.defineProperties(this, { + e._onChange(r), n._onChange(a), Object.defineProperties(this, { position: { configurable: !0, enumerable: !0, - value: e + value: t }, rotation: { configurable: !0, enumerable: !0, - value: t + value: e }, quaternion: { configurable: !0, @@ -2019,337 +2444,358 @@ var Js = class { value: i }, modelViewMatrix: { - value: new pe + value: new Ot }, normalMatrix: { - value: new lt + value: new kt } - }), this.matrix = new pe, this.matrixWorld = new pe, this.matrixAutoUpdate = Ne.DefaultMatrixAutoUpdate, this.matrixWorldNeedsUpdate = !1, this.layers = new Js, this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}; + }), this.matrix = new Ot, this.matrixWorld = new Ot, this.matrixAutoUpdate = s1.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.matrixWorldAutoUpdate = s1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.layers = new Rs, this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {}; } onBeforeRender() {} onAfterRender() {} - applyMatrix4(e) { - this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); + applyMatrix4(t) { + this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale); } - applyQuaternion(e) { - return this.quaternion.premultiply(e), this; + applyQuaternion(t) { + return this.quaternion.premultiply(t), this; } - setRotationFromAxisAngle(e, t) { - this.quaternion.setFromAxisAngle(e, t); + setRotationFromAxisAngle(t, e) { + this.quaternion.setFromAxisAngle(t, e); } - setRotationFromEuler(e) { - this.quaternion.setFromEuler(e, !0); + setRotationFromEuler(t) { + this.quaternion.setFromEuler(t, !0); } - setRotationFromMatrix(e) { - this.quaternion.setFromRotationMatrix(e); + setRotationFromMatrix(t) { + this.quaternion.setFromRotationMatrix(t); } - setRotationFromQuaternion(e) { - this.quaternion.copy(e); + setRotationFromQuaternion(t) { + this.quaternion.copy(t); } - rotateOnAxis(e, t) { - return oi.setFromAxisAngle(e, t), this.quaternion.multiply(oi), this; + rotateOnAxis(t, e) { + return Si.setFromAxisAngle(t, e), this.quaternion.multiply(Si), this; } - rotateOnWorldAxis(e, t) { - return oi.setFromAxisAngle(e, t), this.quaternion.premultiply(oi), this; + rotateOnWorldAxis(t, e) { + return Si.setFromAxisAngle(t, e), this.quaternion.premultiply(Si), this; } - rotateX(e) { - return this.rotateOnAxis(wl, e); + rotateX(t) { + return this.rotateOnAxis(zl, t); } - rotateY(e) { - return this.rotateOnAxis(Sl, e); + rotateY(t) { + return this.rotateOnAxis(kl, t); } - rotateZ(e) { - return this.rotateOnAxis(Tl, e); + rotateZ(t) { + return this.rotateOnAxis(Vl, t); } - translateOnAxis(e, t) { - return bl.copy(e).applyQuaternion(this.quaternion), this.position.add(bl.multiplyScalar(t)), this; + translateOnAxis(t, e) { + return Bl.copy(t).applyQuaternion(this.quaternion), this.position.add(Bl.multiplyScalar(e)), this; } - translateX(e) { - return this.translateOnAxis(wl, e); + translateX(t) { + return this.translateOnAxis(zl, t); } - translateY(e) { - return this.translateOnAxis(Sl, e); + translateY(t) { + return this.translateOnAxis(kl, t); } - translateZ(e) { - return this.translateOnAxis(Tl, e); + translateZ(t) { + return this.translateOnAxis(Vl, t); } - localToWorld(e) { - return e.applyMatrix4(this.matrixWorld); + localToWorld(t) { + return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld); } - worldToLocal(e) { - return e.applyMatrix4(Qt.copy(this.matrixWorld).invert()); + worldToLocal(t) { + return this.updateWorldMatrix(!0, !1), t.applyMatrix4(hn.copy(this.matrixWorld).invert()); } - lookAt(e, t, n) { - e.isVector3 ? $r.copy(e) : $r.set(e, t, n); + lookAt(t, e, n) { + t.isVector3 ? $s.copy(t) : $s.set(t, e, n); let i = this.parent; - this.updateWorldMatrix(!0, !1), Zi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Qt.lookAt(Zi, $r, this.up) : Qt.lookAt($r, Zi, this.up), this.quaternion.setFromRotationMatrix(Qt), i && (Qt.extractRotation(i.matrixWorld), oi.setFromRotationMatrix(Qt), this.quaternion.premultiply(oi.invert())); + this.updateWorldMatrix(!0, !1), hs.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? hn.lookAt(hs, $s, this.up) : hn.lookAt($s, hs, this.up), this.quaternion.setFromRotationMatrix(hn), i && (hn.extractRotation(i.matrixWorld), Si.setFromRotationMatrix(hn), this.quaternion.premultiply(Si.invert())); } - add(e) { + add(t) { if (arguments.length > 1) { - for(let t = 0; t < arguments.length; t++)this.add(arguments[t]); + for(let e = 0; e < arguments.length; e++)this.add(arguments[e]); return this; } - return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), e.parent = this, this.children.push(e), e.dispatchEvent(af)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this); + return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.parent !== null && t.parent.remove(t), t.parent = this, this.children.push(t), t.dispatchEvent(lp)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this); } - remove(e) { + remove(t) { if (arguments.length > 1) { for(let n = 0; n < arguments.length; n++)this.remove(arguments[n]); return this; } - let t = this.children.indexOf(e); - return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(El)), this; + let e = this.children.indexOf(t); + return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(Hl)), this; } removeFromParent() { - let e = this.parent; - return e !== null && e.remove(this), this; + let t = this.parent; + return t !== null && t.remove(this), this; } clear() { - for(let e = 0; e < this.children.length; e++){ - let t = this.children[e]; - t.parent = null, t.dispatchEvent(El); + for(let t = 0; t < this.children.length; t++){ + let e = this.children[t]; + e.parent = null, e.dispatchEvent(Hl); } return this.children.length = 0, this; } - attach(e) { - return this.updateWorldMatrix(!0, !1), Qt.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Qt.multiply(e.parent.matrixWorld)), e.applyMatrix4(Qt), this.add(e), e.updateWorldMatrix(!1, !0), this; + attach(t) { + return this.updateWorldMatrix(!0, !1), hn.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), hn.multiply(t.parent.matrixWorld)), t.applyMatrix4(hn), this.add(t), t.updateWorldMatrix(!1, !0), this; } - getObjectById(e) { - return this.getObjectByProperty("id", e); + getObjectById(t) { + return this.getObjectByProperty("id", t); } - getObjectByName(e) { - return this.getObjectByProperty("name", e); + getObjectByName(t) { + return this.getObjectByProperty("name", t); } - getObjectByProperty(e, t) { - if (this[e] === t) return this; + getObjectByProperty(t, e) { + if (this[t] === e) return this; for(let n = 0, i = this.children.length; n < i; n++){ - let o = this.children[n].getObjectByProperty(e, t); - if (o !== void 0) return o; + let a = this.children[n].getObjectByProperty(t, e); + if (a !== void 0) return a; + } + } + getObjectsByProperty(t, e) { + let n = []; + this[t] === e && n.push(this); + for(let i = 0, r = this.children.length; i < r; i++){ + let a = this.children[i].getObjectsByProperty(t, e); + a.length > 0 && (n = n.concat(a)); } + return n; } - getWorldPosition(e) { - return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); + getWorldPosition(t) { + return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld); } - getWorldQuaternion(e) { - return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, e, sf), e; + getWorldQuaternion(t) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(hs, t, op), t; } - getWorldScale(e) { - return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, of, e), e; + getWorldScale(t) { + return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(hs, cp, t), t; } - getWorldDirection(e) { + getWorldDirection(t) { this.updateWorldMatrix(!0, !1); - let t = this.matrixWorld.elements; - return e.set(t[8], t[9], t[10]).normalize(); + let e = this.matrixWorld.elements; + return t.set(e[8], e[9], e[10]).normalize(); } raycast() {} - traverse(e) { - e(this); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].traverse(e); + traverse(t) { + t(this); + let e = this.children; + for(let n = 0, i = e.length; n < i; n++)e[n].traverse(t); } - traverseVisible(e) { + traverseVisible(t) { if (this.visible === !1) return; - e(this); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].traverseVisible(e); + t(this); + let e = this.children; + for(let n = 0, i = e.length; n < i; n++)e[n].traverseVisible(t); } - traverseAncestors(e) { - let t = this.parent; - t !== null && (e(t), t.traverseAncestors(e)); + traverseAncestors(t) { + let e = this.parent; + e !== null && (t(e), e.traverseAncestors(t)); } updateMatrix() { this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0; } - updateMatrixWorld(e) { - this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0); - let t = this.children; - for(let n = 0, i = t.length; n < i; n++)t[n].updateMatrixWorld(e); + updateMatrixWorld(t) { + this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, t = !0); + let e = this.children; + for(let n = 0, i = e.length; n < i; n++){ + let r = e[n]; + (r.matrixWorldAutoUpdate === !0 || t === !0) && r.updateMatrixWorld(t); + } } - updateWorldMatrix(e, t) { + updateWorldMatrix(t, e) { let n = this.parent; - if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) { + if (t === !0 && n !== null && n.matrixWorldAutoUpdate === !0 && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), e === !0) { let i = this.children; - for(let r = 0, o = i.length; r < o; r++)i[r].updateWorldMatrix(!1, !0); + for(let r = 0, a = i.length; r < a; r++){ + let o = i[r]; + o.matrixWorldAutoUpdate === !0 && o.updateWorldMatrix(!1, !0); + } } } - toJSON(e) { - let t = e === void 0 || typeof e == "string", n = {}; - t && (e = { + toJSON(t) { + let e = t === void 0 || typeof t == "string", n = {}; + e && (t = { geometries: {}, materials: {}, textures: {}, images: {}, shapes: {}, skeletons: {}, - animations: {} + animations: {}, + nodes: {} }, n.metadata = { - version: 4.5, + version: 4.6, type: "Object", generator: "Object3D.toJSON" }); let i = {}; - i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.castShadow === !0 && (i.castShadow = !0), this.receiveShadow === !0 && (i.receiveShadow = !0), this.visible === !1 && (i.visible = !1), this.frustumCulled === !1 && (i.frustumCulled = !1), this.renderOrder !== 0 && (i.renderOrder = this.renderOrder), JSON.stringify(this.userData) !== "{}" && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (i.instanceColor = this.instanceColor.toJSON())); - function r(a, l) { - return a[l.uuid] === void 0 && (a[l.uuid] = l.toJSON(e)), l.uuid; + i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.castShadow === !0 && (i.castShadow = !0), this.receiveShadow === !0 && (i.receiveShadow = !0), this.visible === !1 && (i.visible = !1), this.frustumCulled === !1 && (i.frustumCulled = !1), this.renderOrder !== 0 && (i.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (i.userData = this.userData), i.layers = this.layers.mask, i.matrix = this.matrix.toArray(), i.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1), this.isInstancedMesh && (i.type = "InstancedMesh", i.count = this.count, i.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (i.instanceColor = this.instanceColor.toJSON())); + function r(o, c) { + return o[c.uuid] === void 0 && (o[c.uuid] = c.toJSON(t)), c.uuid; } - if (this.isScene) this.background && (this.background.isColor ? i.background = this.background.toJSON() : this.background.isTexture && (i.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && (i.environment = this.environment.toJSON(e).uuid); + if (this.isScene) this.background && (this.background.isColor ? i.background = this.background.toJSON() : this.background.isTexture && (i.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (i.environment = this.environment.toJSON(t).uuid); else if (this.isMesh || this.isLine || this.isPoints) { - i.geometry = r(e.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; c < h; c++){ - let u = l[c]; - r(e.shapes, u); + i.geometry = r(t.geometries, this.geometry); + let o = this.geometry.parameters; + if (o !== void 0 && o.shapes !== void 0) { + let c = o.shapes; + if (Array.isArray(c)) for(let l = 0, h = c.length; l < h; l++){ + let u = c[l]; + r(t.shapes, u); } - else r(e.shapes, l); + else r(t.shapes, c); } } - if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(e.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { - let a = []; - for(let l = 0, c = this.material.length; l < c; l++)a.push(r(e.materials, this.material[l])); - i.material = a; - } else i.material = r(e.materials, this.material); + if (this.isSkinnedMesh && (i.bindMode = this.bindMode, i.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(t.skeletons, this.skeleton), i.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { + let o = []; + for(let c = 0, l = this.material.length; c < l; c++)o.push(r(t.materials, this.material[c])); + i.material = o; + } else i.material = r(t.materials, this.material); if (this.children.length > 0) { i.children = []; - for(let a = 0; a < this.children.length; a++)i.children.push(this.children[a].toJSON(e).object); + for(let o = 0; o < this.children.length; o++)i.children.push(this.children[o].toJSON(t).object); } if (this.animations.length > 0) { i.animations = []; - for(let a = 0; a < this.animations.length; a++){ - let l = this.animations[a]; - i.animations.push(r(e.animations, l)); + for(let o = 0; o < this.animations.length; o++){ + let c = this.animations[o]; + i.animations.push(r(t.animations, c)); } } - if (t) { - let a = o(e.geometries), l = o(e.materials), c = o(e.textures), h = o(e.images), u = o(e.shapes), d = o(e.skeletons), f = o(e.animations); - a.length > 0 && (n.geometries = a), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), d.length > 0 && (n.skeletons = d), f.length > 0 && (n.animations = f); + if (e) { + let o = a(t.geometries), c = a(t.materials), l = a(t.textures), h = a(t.images), u = a(t.shapes), d = a(t.skeletons), f = a(t.animations), m = a(t.nodes); + o.length > 0 && (n.geometries = o), c.length > 0 && (n.materials = c), l.length > 0 && (n.textures = l), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), d.length > 0 && (n.skeletons = d), f.length > 0 && (n.animations = f), m.length > 0 && (n.nodes = m); } return n.object = i, n; - function o(a) { - let l = []; - for(let c in a){ - let h = a[c]; - delete h.metadata, l.push(h); + function a(o) { + let c = []; + for(let l in o){ + let h = o[l]; + delete h.metadata, c.push(h); } - return l; + return c; } } - clone(e) { - return new this.constructor().copy(this, e); + clone(t) { + return new this.constructor().copy(this, t); } - copy(e, t = !0) { - if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for(let n = 0; n < e.children.length; n++){ - let i = e.children[n]; + 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.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, 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.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), e === !0) for(let n = 0; n < t.children.length; n++){ + let i = t.children[n]; this.add(i.clone()); } return this; } }; -Ne.DefaultUp = new M(0, 1, 0); -Ne.DefaultMatrixAutoUpdate = !0; -Ne.prototype.isObject3D = !0; -var Dt = new M, Kt = new M, Co = new M, en = new M, ai = new M, li = new M, Al = new M, Lo = new M, Ro = new M, Po = new M, nt = class { - constructor(e = new M, t = new M, n = new M){ - this.a = e, this.b = t, this.c = n; - } - static getNormal(e, t, n, i) { - i.subVectors(n, t), Dt.subVectors(e, t), i.cross(Dt); +Zt.DEFAULT_UP = new A(0, 1, 0); +Zt.DEFAULT_MATRIX_AUTO_UPDATE = !0; +Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; +var Je = new A, un = new A, Oa = new A, dn = new A, bi = new A, Ei = new A, Gl = new A, Ba = new A, za = new A, ka = new A, Ks = !1, In = class s1 { + constructor(t = new A, e = new A, n = new A){ + this.a = t, this.b = e, this.c = n; + } + static getNormal(t, e, n, i) { + i.subVectors(n, e), Je.subVectors(t, e), i.cross(Je); let r = i.lengthSq(); return r > 0 ? i.multiplyScalar(1 / Math.sqrt(r)) : i.set(0, 0, 0); } - static getBarycoord(e, t, n, i, r) { - Dt.subVectors(i, t), Kt.subVectors(n, t), Co.subVectors(e, t); - let o = Dt.dot(Dt), a = Dt.dot(Kt), l = Dt.dot(Co), c = Kt.dot(Kt), h = Kt.dot(Co), u = o * c - a * a; + static getBarycoord(t, e, n, i, r) { + Je.subVectors(i, e), un.subVectors(n, e), Oa.subVectors(t, e); + let a = Je.dot(Je), o = Je.dot(un), c = Je.dot(Oa), l = un.dot(un), h = un.dot(Oa), u = a * l - o * o; if (u === 0) return r.set(-2, -1, -1); - let d = 1 / u, f = (c * l - a * h) * d, m = (o * h - a * l) * d; + let d = 1 / u, f = (l * c - o * h) * d, m = (a * h - o * c) * d; return r.set(1 - f - m, m, f); } - static containsPoint(e, t, n, i) { - return this.getBarycoord(e, t, n, i, en), en.x >= 0 && en.y >= 0 && en.x + en.y <= 1; + static containsPoint(t, e, n, i) { + return this.getBarycoord(t, e, n, i, dn), dn.x >= 0 && dn.y >= 0 && dn.x + dn.y <= 1; + } + static getUV(t, e, n, i, r, a, o, c) { + return Ks === !1 && (console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."), Ks = !0), this.getInterpolation(t, e, n, i, r, a, o, c); } - static getUV(e, t, n, i, r, o, a, l) { - return this.getBarycoord(e, t, n, i, en), l.set(0, 0), l.addScaledVector(r, en.x), l.addScaledVector(o, en.y), l.addScaledVector(a, en.z), l; + static getInterpolation(t, e, n, i, r, a, o, c) { + return this.getBarycoord(t, e, n, i, dn), c.setScalar(0), c.addScaledVector(r, dn.x), c.addScaledVector(a, dn.y), c.addScaledVector(o, dn.z), c; } - static isFrontFacing(e, t, n, i) { - return Dt.subVectors(n, t), Kt.subVectors(e, t), Dt.cross(Kt).dot(i) < 0; + static isFrontFacing(t, e, n, i) { + return Je.subVectors(n, e), un.subVectors(t, e), Je.cross(un).dot(i) < 0; } - set(e, t, n) { - return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; + set(t, e, n) { + return this.a.copy(t), this.b.copy(e), this.c.copy(n), this; } - setFromPointsAndIndices(e, t, n, i) { - return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this; + setFromPointsAndIndices(t, e, n, i) { + return this.a.copy(t[e]), this.b.copy(t[n]), this.c.copy(t[i]), this; } - setFromAttributeAndIndices(e, t, n, i) { - return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, i), this; + setFromAttributeAndIndices(t, e, n, i) { + return this.a.fromBufferAttribute(t, e), this.b.fromBufferAttribute(t, n), this.c.fromBufferAttribute(t, i), this; } clone() { return new this.constructor().copy(this); } - copy(e) { - return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; + copy(t) { + return this.a.copy(t.a), this.b.copy(t.b), this.c.copy(t.c), this; } getArea() { - return Dt.subVectors(this.c, this.b), Kt.subVectors(this.a, this.b), Dt.cross(Kt).length() * .5; - } - getMidpoint(e) { - return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); - } - getNormal(e) { - return nt.getNormal(this.a, this.b, this.c, e); - } - getPlane(e) { - return e.setFromCoplanarPoints(this.a, this.b, this.c); - } - getBarycoord(e, t) { - return nt.getBarycoord(e, this.a, this.b, this.c, t); - } - getUV(e, t, n, i, r) { - return nt.getUV(e, this.a, this.b, this.c, t, n, i, r); - } - containsPoint(e) { - return nt.containsPoint(e, this.a, this.b, this.c); - } - isFrontFacing(e) { - return nt.isFrontFacing(this.a, this.b, this.c, e); - } - intersectsBox(e) { - return e.intersectsTriangle(this); - } - closestPointToPoint(e, t) { - let n = this.a, i = this.b, r = this.c, o, a; - ai.subVectors(i, n), li.subVectors(r, n), Lo.subVectors(e, n); - let l = ai.dot(Lo), c = li.dot(Lo); - if (l <= 0 && c <= 0) return t.copy(n); - Ro.subVectors(e, i); - let h = ai.dot(Ro), u = li.dot(Ro); - if (h >= 0 && u <= h) return t.copy(i); - let d = l * u - h * c; - if (d <= 0 && l >= 0 && h <= 0) return o = l / (l - h), t.copy(n).addScaledVector(ai, o); - Po.subVectors(e, r); - let f = ai.dot(Po), m = li.dot(Po); - if (m >= 0 && f <= m) return t.copy(r); - let x = f * c - l * m; - if (x <= 0 && c >= 0 && m <= 0) return a = c / (c - m), t.copy(n).addScaledVector(li, a); - let v = h * m - f * u; - if (v <= 0 && u - h >= 0 && f - m >= 0) return Al.subVectors(r, i), a = (u - h) / (u - h + (f - m)), t.copy(i).addScaledVector(Al, a); - let g = 1 / (v + x + d); - return o = x * g, a = d * g, t.copy(n).addScaledVector(ai, o).addScaledVector(li, a); - } - equals(e) { - return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); - } -}, lf = 0, dt = class extends En { + return Je.subVectors(this.c, this.b), un.subVectors(this.a, this.b), Je.cross(un).length() * .5; + } + getMidpoint(t) { + return t.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); + } + getNormal(t) { + return s1.getNormal(this.a, this.b, this.c, t); + } + getPlane(t) { + return t.setFromCoplanarPoints(this.a, this.b, this.c); + } + getBarycoord(t, e) { + return s1.getBarycoord(t, this.a, this.b, this.c, e); + } + getUV(t, e, n, i, r) { + return Ks === !1 && (console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."), Ks = !0), s1.getInterpolation(t, this.a, this.b, this.c, e, n, i, r); + } + getInterpolation(t, e, n, i, r) { + return s1.getInterpolation(t, this.a, this.b, this.c, e, n, i, r); + } + containsPoint(t) { + return s1.containsPoint(t, this.a, this.b, this.c); + } + isFrontFacing(t) { + return s1.isFrontFacing(this.a, this.b, this.c, t); + } + intersectsBox(t) { + return t.intersectsTriangle(this); + } + closestPointToPoint(t, e) { + let n = this.a, i = this.b, r = this.c, a, o; + bi.subVectors(i, n), Ei.subVectors(r, n), Ba.subVectors(t, n); + let c = bi.dot(Ba), l = Ei.dot(Ba); + if (c <= 0 && l <= 0) return e.copy(n); + za.subVectors(t, i); + let h = bi.dot(za), u = Ei.dot(za); + if (h >= 0 && u <= h) return e.copy(i); + let d = c * u - h * l; + if (d <= 0 && c >= 0 && h <= 0) return a = c / (c - h), e.copy(n).addScaledVector(bi, a); + ka.subVectors(t, r); + let f = bi.dot(ka), m = Ei.dot(ka); + if (m >= 0 && f <= m) return e.copy(r); + let x = f * l - c * m; + if (x <= 0 && l >= 0 && m <= 0) return o = l / (l - m), e.copy(n).addScaledVector(Ei, o); + let g = h * m - f * u; + if (g <= 0 && u - h >= 0 && f - m >= 0) return Gl.subVectors(r, i), o = (u - h) / (u - h + (f - m)), e.copy(i).addScaledVector(Gl, o); + let p = 1 / (g + x + d); + return a = x * p, o = d * p, e.copy(n).addScaledVector(bi, a).addScaledVector(Ei, o); + } + equals(t) { + return t.a.equals(this.a) && t.b.equals(this.b) && t.c.equals(this.c); + } +}, hp = 0, Me = class extends sn { constructor(){ - super(); - Object.defineProperty(this, "id", { - value: lf++ - }), this.uuid = Et(), this.name = "", this.type = "Material", this.fog = !0, this.blending = sr, this.side = Ai, this.vertexColors = !1, this.opacity = 1, this.format = ct, this.transparent = !1, this.blendSrc = Gc, this.blendDst = Vc, this.blendEquation = _i, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.depthFunc = ea, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Ud, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = vo, this.stencilZFail = vo, this.stencilZPass = vo, 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.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; + super(), this.isMaterial = !0, Object.defineProperty(this, "id", { + value: hp++ + }), this.uuid = Be(), this.name = "", this.type = "Material", this.blending = Wi, this.side = On, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = id, this.blendDst = sd, this.blendEquation = Bi, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.depthFunc = ao, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = wf, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = Aa, this.stencilZFail = Aa, this.stencilZPass = Aa, 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.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; } get alphaTest() { return this._alphaTest; } - set alphaTest(e) { - this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; + set alphaTest(t) { + this._alphaTest > 0 != t > 0 && this.version++, this._alphaTest = t; } onBuild() {} onBeforeRender() {} @@ -2357,77 +2803,71 @@ var Dt = new M, Kt = new M, Co = new M, en = new M, ai = new M, li = new M, Al = customProgramCacheKey() { return this.onBeforeCompile.toString(); } - setValues(e) { - if (e !== void 0) for(let t in e){ - let n = e[t]; + setValues(t) { + if (t !== void 0) for(let e in t){ + let n = t[e]; if (n === void 0) { - console.warn("THREE.Material: '" + t + "' parameter is undefined."); - continue; - } - if (t === "shading") { - console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = n === kc; + console.warn(`THREE.Material: parameter '${e}' has value of undefined.`); continue; } - let i = this[t]; + let i = this[e]; if (i === void 0) { - console.warn("THREE." + this.type + ": '" + t + "' is not a property of this material."); + console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`); continue; } - i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[t] = n; + i && i.isColor ? i.set(n) : i && i.isVector3 && n && n.isVector3 ? i.copy(n) : this[e] = n; } } - toJSON(e) { - let t = e === void 0 || typeof e == "string"; - t && (e = { + toJSON(t) { + let e = t === void 0 || typeof t == "string"; + e && (t = { textures: {}, images: {} }); let n = { metadata: { - version: 4.5, + version: 4.6, type: "Material", generator: "Material.toJSON" } }; - n.uuid = this.uuid, n.type = this.type, this.name !== "" && (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 && this.emissiveIntensity !== 1 && (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(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), 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(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).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.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== sr && (n.blending = this.blending), this.side !== Ai && (n.side = this.side), this.vertexColors && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.format !== ct && (n.format = this.format), this.transparent === !0 && (n.transparent = this.transparent), n.depthFunc = this.depthFunc, n.depthTest = this.depthTest, n.depthWrite = this.depthWrite, n.colorWrite = this.colorWrite, n.stencilWrite = this.stencilWrite, 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, this.rotation && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth && this.linewidth !== 1 && (n.linewidth = this.linewidth), 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.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaToCoverage === !0 && (n.alphaToCoverage = this.alphaToCoverage), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = this.premultipliedAlpha), this.wireframe === !0 && (n.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = this.flatShading), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), JSON.stringify(this.userData) !== "{}" && (n.userData = this.userData); + n.uuid = this.uuid, n.type = this.type, this.name !== "" && (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 && this.emissiveIntensity !== 1 && (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.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.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 && this.attenuationDistance !== 1 / 0 && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== Wi && (n.blending = this.blending), this.side !== On && (n.side = this.side), this.vertexColors && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = this.transparent), n.depthFunc = this.depthFunc, n.depthTest = this.depthTest, n.depthWrite = this.depthWrite, n.colorWrite = this.colorWrite, n.stencilWrite = this.stencilWrite, 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, this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), 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.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = this.alphaHash), this.alphaToCoverage === !0 && (n.alphaToCoverage = this.alphaToCoverage), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = this.premultipliedAlpha), this.forceSinglePass === !0 && (n.forceSinglePass = this.forceSinglePass), this.wireframe === !0 && (n.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = this.flatShading), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData); function i(r) { - let o = []; - for(let a in r){ - let l = r[a]; - delete l.metadata, o.push(l); + let a = []; + for(let o in r){ + let c = r[o]; + delete c.metadata, a.push(c); } - return o; + return a; } - if (t) { - let r = i(e.textures), o = i(e.images); - r.length > 0 && (n.textures = r), o.length > 0 && (n.images = o); + if (e) { + let r = i(t.textures), a = i(t.images); + r.length > 0 && (n.textures = r), a.length > 0 && (n.images = a); } return n; } clone() { return new this.constructor().copy(this); } - copy(e) { - this.name = e.name, this.fog = e.fog, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.format = e.format, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; - let t = e.clippingPlanes, n = null; - if (t !== null) { - let i = t.length; + 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.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 i = e.length; n = new Array(i); - for(let r = 0; r !== i; ++r)n[r] = t[r].clone(); + for(let r = 0; r !== i; ++r)n[r] = e[r].clone(); } - return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; + 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.visible = t.visible, this.toneMapped = t.toneMapped, this.userData = JSON.parse(JSON.stringify(t.userData)), this; } dispose() { this.dispatchEvent({ type: "dispose" }); } - set needsUpdate(e) { - e === !0 && this.version++; + set needsUpdate(t) { + t === !0 && this.version++; } -}; -dt.prototype.isMaterial = !0; -var $c = { +}, _d = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, @@ -2576,91 +3016,89 @@ var $c = { whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 -}, Ft = { +}, $e = { h: 0, s: 0, l: 0 -}, jr = { +}, Qs = { h: 0, s: 0, l: 0 }; -function Io(s, e, t) { - return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? s + (e - s) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? s + (e - s) * 6 * (2 / 3 - t) : s; -} -function Do(s) { - return s < .04045 ? s * .0773993808 : Math.pow(s * .9478672986 + .0521327014, 2.4); +function Va(s1, t, e) { + return e < 0 && (e += 1), e > 1 && (e -= 1), e < 1 / 6 ? s1 + (t - s1) * 6 * e : e < 1 / 2 ? t : e < 2 / 3 ? s1 + (t - s1) * 6 * (2 / 3 - e) : s1; } -function Fo(s) { - return s < .0031308 ? s * 12.92 : 1.055 * Math.pow(s, .41666) - .055; -} -var ae = class { - constructor(e, t, n){ - return t === void 0 && n === void 0 ? this.set(e) : this.setRGB(e, t, n); +var ft = class { + constructor(t, e, n){ + return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, n); } - set(e) { - return e && e.isColor ? this.copy(e) : typeof e == "number" ? this.setHex(e) : typeof e == "string" && this.setStyle(e), this; + set(t, e, n) { + if (e === void 0 && n === void 0) { + let i = t; + i && i.isColor ? this.copy(i) : typeof i == "number" ? this.setHex(i) : typeof i == "string" && this.setStyle(i); + } else this.setRGB(t, e, n); + return this; } - setScalar(e) { - return this.r = e, this.g = e, this.b = e, this; + setScalar(t) { + return this.r = t, this.g = t, this.b = t, this; } - setHex(e) { - return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, this; + setHex(t, e = Nt) { + return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, Ye.toWorkingColorSpace(this, e), this; } - setRGB(e, t, n) { - return this.r = e, this.g = t, this.b = n, this; + setRGB(t, e, n, i = Ye.workingColorSpace) { + return this.r = t, this.g = e, this.b = n, Ye.toWorkingColorSpace(this, i), this; } - setHSL(e, t, n) { - if (e = da(e, 1), t = mt(t, 0, 1), n = mt(n, 0, 1), t === 0) this.r = this.g = this.b = n; + setHSL(t, e, n, i = Ye.workingColorSpace) { + if (t = kc(t, 1), e = ae(e, 0, 1), n = ae(n, 0, 1), e === 0) this.r = this.g = this.b = n; else { - let i = n <= .5 ? n * (1 + t) : n + t - n * t, r = 2 * n - i; - this.r = Io(r, i, e + 1 / 3), this.g = Io(r, i, e), this.b = Io(r, i, e - 1 / 3); + let r = n <= .5 ? n * (1 + e) : n + e - n * e, a = 2 * n - r; + this.r = Va(a, r, t + 1 / 3), this.g = Va(a, r, t), this.b = Va(a, r, t - 1 / 3); } - return this; + return Ye.toWorkingColorSpace(this, i), this; } - setStyle(e) { - function t(i) { - i !== void 0 && parseFloat(i) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored."); + setStyle(t, e = Nt) { + function n(r) { + r !== void 0 && parseFloat(r) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored."); } - let n; - if (n = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)) { - let i, r = n[1], o = n[2]; - switch(r){ + let i; + if (i = /^(\w+)\(([^\)]*)\)/.exec(t)) { + let r, a = i[1], o = i[2]; + switch(a){ case "rgb": case "rgba": - if (i = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(255, parseInt(i[1], 10)) / 255, this.g = Math.min(255, parseInt(i[2], 10)) / 255, this.b = Math.min(255, parseInt(i[3], 10)) / 255, t(i[4]), this; - if (i = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return this.r = Math.min(100, parseInt(i[1], 10)) / 100, this.g = Math.min(100, parseInt(i[2], 10)) / 100, this.b = Math.min(100, parseInt(i[3], 10)) / 100, t(i[4]), this; + if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) 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(o)) 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 (i = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) { - let a = parseFloat(i[1]) / 360, l = parseInt(i[2], 10) / 100, c = parseInt(i[3], 10) / 100; - return t(i[4]), this.setHSL(a, l, c); - } + if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(r[4]), this.setHSL(parseFloat(r[1]) / 360, parseFloat(r[2]) / 100, parseFloat(r[3]) / 100, e); break; + default: + console.warn("THREE.Color: Unknown color model " + t); } - } else if (n = /^\#([A-Fa-f\d]+)$/.exec(e)) { - let i = n[1], r = i.length; - if (r === 3) return this.r = parseInt(i.charAt(0) + i.charAt(0), 16) / 255, this.g = parseInt(i.charAt(1) + i.charAt(1), 16) / 255, this.b = parseInt(i.charAt(2) + i.charAt(2), 16) / 255, this; - if (r === 6) return this.r = parseInt(i.charAt(0) + i.charAt(1), 16) / 255, this.g = parseInt(i.charAt(2) + i.charAt(3), 16) / 255, this.b = parseInt(i.charAt(4) + i.charAt(5), 16) / 255, this; - } - return e && e.length > 0 ? this.setColorName(e) : this; + } else if (i = /^\#([A-Fa-f\d]+)$/.exec(t)) { + let r = i[1], a = r.length; + if (a === 3) return this.setRGB(parseInt(r.charAt(0), 16) / 15, parseInt(r.charAt(1), 16) / 15, parseInt(r.charAt(2), 16) / 15, e); + if (a === 6) return this.setHex(parseInt(r, 16), e); + console.warn("THREE.Color: Invalid hex color " + t); + } else if (t && t.length > 0) return this.setColorName(t, e); + return this; } - setColorName(e) { - let t = $c[e.toLowerCase()]; - return t !== void 0 ? this.setHex(t) : console.warn("THREE.Color: Unknown color " + e), this; + setColorName(t, e = Nt) { + let n = _d[t.toLowerCase()]; + return n !== void 0 ? this.setHex(n, e) : console.warn("THREE.Color: Unknown color " + t), this; } clone() { return new this.constructor(this.r, this.g, this.b); } - copy(e) { - return this.r = e.r, this.g = e.g, this.b = e.b, this; + copy(t) { + return this.r = t.r, this.g = t.g, this.b = t.b, this; } - copySRGBToLinear(e) { - return this.r = Do(e.r), this.g = Do(e.g), this.b = Do(e.b), this; + copySRGBToLinear(t) { + return this.r = Xi(t.r), this.g = Xi(t.g), this.b = Xi(t.b), this; } - copyLinearToSRGB(e) { - return this.r = Fo(e.r), this.g = Fo(e.g), this.b = Fo(e.b), this; + copyLinearToSRGB(t) { + return this.r = Ca(t.r), this.g = Ca(t.g), this.b = Ca(t.b), this; } convertSRGBToLinear() { return this.copySRGBToLinear(this), this; @@ -2668,274 +3106,335 @@ var ae = class { convertLinearToSRGB() { return this.copyLinearToSRGB(this), this; } - getHex() { - return this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0; + getHex(t = Nt) { + return Ye.fromWorkingColorSpace(be.copy(this), t), Math.round(ae(be.r * 255, 0, 255)) * 65536 + Math.round(ae(be.g * 255, 0, 255)) * 256 + Math.round(ae(be.b * 255, 0, 255)); } - getHexString() { - return ("000000" + this.getHex().toString(16)).slice(-6); + getHexString(t = Nt) { + return ("000000" + this.getHex(t).toString(16)).slice(-6); } - getHSL(e) { - let t = this.r, n = this.g, i = this.b, r = Math.max(t, n, i), o = Math.min(t, n, i), a, l, c = (o + r) / 2; - if (o === r) a = 0, l = 0; + getHSL(t, e = Ye.workingColorSpace) { + Ye.fromWorkingColorSpace(be.copy(this), e); + let n = be.r, i = be.g, r = be.b, a = Math.max(n, i, r), o = Math.min(n, i, r), c, l, h = (o + a) / 2; + if (o === a) c = 0, l = 0; else { - let h = r - o; - switch(l = c <= .5 ? h / (r + o) : h / (2 - r - o), r){ - case t: - a = (n - i) / h + (n < i ? 6 : 0); - break; + let u = a - o; + switch(l = h <= .5 ? u / (a + o) : u / (2 - a - o), a){ case n: - a = (i - t) / h + 2; + c = (i - r) / u + (i < r ? 6 : 0); break; case i: - a = (t - n) / h + 4; + c = (r - n) / u + 2; + break; + case r: + c = (n - i) / u + 4; break; } - a /= 6; + c /= 6; } - return e.h = a, e.s = l, e.l = c, e; + return t.h = c, t.s = l, t.l = h, t; + } + getRGB(t, e = Ye.workingColorSpace) { + return Ye.fromWorkingColorSpace(be.copy(this), e), t.r = be.r, t.g = be.g, t.b = be.b, t; } - getStyle() { - return "rgb(" + (this.r * 255 | 0) + "," + (this.g * 255 | 0) + "," + (this.b * 255 | 0) + ")"; + getStyle(t = Nt) { + Ye.fromWorkingColorSpace(be.copy(this), t); + let e = be.r, n = be.g, i = be.b; + return t !== Nt ? `color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(n * 255)},${Math.round(i * 255)})`; } - offsetHSL(e, t, n) { - return this.getHSL(Ft), Ft.h += e, Ft.s += t, Ft.l += n, this.setHSL(Ft.h, Ft.s, Ft.l), this; + offsetHSL(t, e, n) { + return this.getHSL($e), $e.h += t, $e.s += e, $e.l += n, this.setHSL($e.h, $e.s, $e.l), this; } - add(e) { - return this.r += e.r, this.g += e.g, this.b += e.b, this; + add(t) { + return this.r += t.r, this.g += t.g, this.b += t.b, this; } - addColors(e, t) { - return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; + addColors(t, e) { + return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this; } - addScalar(e) { - return this.r += e, this.g += e, this.b += e, this; + addScalar(t) { + return this.r += t, this.g += t, this.b += t, this; } - sub(e) { - return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this; + sub(t) { + return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this; } - multiply(e) { - return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; + multiply(t) { + return this.r *= t.r, this.g *= t.g, this.b *= t.b, this; } - multiplyScalar(e) { - return this.r *= e, this.g *= e, this.b *= e, this; + multiplyScalar(t) { + return this.r *= t, this.g *= t, this.b *= t, this; } - lerp(e, t) { - return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this; + lerp(t, e) { + return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this; } - lerpColors(e, t, n) { - return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; + lerpColors(t, e, n) { + return this.r = t.r + (e.r - t.r) * n, this.g = t.g + (e.g - t.g) * n, this.b = t.b + (e.b - t.b) * n, this; } - lerpHSL(e, t) { - this.getHSL(Ft), e.getHSL(jr); - let n = or(Ft.h, jr.h, t), i = or(Ft.s, jr.s, t), r = or(Ft.l, jr.l, t); + lerpHSL(t, e) { + this.getHSL($e), t.getHSL(Qs); + let n = ys($e.h, Qs.h, e), i = ys($e.s, Qs.s, e), r = ys($e.l, Qs.l, e); return this.setHSL(n, i, r), this; } - equals(e) { - return e.r === this.r && e.g === this.g && e.b === this.b; + setFromVector3(t) { + return this.r = t.x, this.g = t.y, this.b = t.z, this; } - fromArray(e, t = 0) { - return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; + applyMatrix3(t) { + let e = this.r, n = this.g, i = this.b, r = t.elements; + return this.r = r[0] * e + r[3] * n + r[6] * i, this.g = r[1] * e + r[4] * n + r[7] * i, this.b = r[2] * e + r[5] * n + r[8] * i, this; } - toArray(e = [], t = 0) { - return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; + equals(t) { + return t.r === this.r && t.g === this.g && t.b === this.b; } - fromBufferAttribute(e, t) { - return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), e.normalized === !0 && (this.r /= 255, this.g /= 255, this.b /= 255), this; + fromArray(t, e = 0) { + return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this; } - toJSON() { - return this.getHex(); + toArray(t = [], e = 0) { + return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t; } -}; -ae.NAMES = $c; -ae.prototype.isColor = !0; -ae.prototype.r = 1; -ae.prototype.g = 1; -ae.prototype.b = 1; -var hn = class extends dt { - constructor(e){ - super(); - this.type = "MeshBasicMaterial", this.color = new ae(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.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); + fromBufferAttribute(t, e) { + return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), this; } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + toJSON() { + return this.getHex(); } -}; -hn.prototype.isMeshBasicMaterial = !0; -var Je = new M, Qr = new X, Ue = class { - constructor(e, t, n){ - if (Array.isArray(e)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); - this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n === !0, this.usage = hr, this.updateRange = { + *[Symbol.iterator]() { + yield this.r, yield this.g, yield this.b; + } +}, be = new ft; +ft.NAMES = _d; +var Mn = class extends Me { + constructor(t){ + super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new ft(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.combine = pa, 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.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; + } +}, _n = up(); +function up() { + let s1 = new ArrayBuffer(4), t = new Float32Array(s1), e = new Uint32Array(s1), n = new Uint32Array(512), i = new Uint32Array(512); + for(let c = 0; c < 256; ++c){ + let l = c - 127; + l < -27 ? (n[c] = 0, n[c | 256] = 32768, i[c] = 24, i[c | 256] = 24) : l < -14 ? (n[c] = 1024 >> -l - 14, n[c | 256] = 1024 >> -l - 14 | 32768, i[c] = -l - 1, i[c | 256] = -l - 1) : l <= 15 ? (n[c] = l + 15 << 10, n[c | 256] = l + 15 << 10 | 32768, i[c] = 13, i[c | 256] = 13) : l < 128 ? (n[c] = 31744, n[c | 256] = 64512, i[c] = 24, i[c | 256] = 24) : (n[c] = 31744, n[c | 256] = 64512, i[c] = 13, i[c | 256] = 13); + } + let r = new Uint32Array(2048), a = new Uint32Array(64), o = new Uint32Array(64); + for(let c = 1; c < 1024; ++c){ + let l = c << 13, h = 0; + for(; !(l & 8388608);)l <<= 1, h -= 8388608; + l &= -8388609, h += 947912704, r[c] = l | h; + } + for(let c = 1024; c < 2048; ++c)r[c] = 939524096 + (c - 1024 << 13); + for(let c = 1; c < 31; ++c)a[c] = c << 23; + a[31] = 1199570944, a[32] = 2147483648; + for(let c = 33; c < 63; ++c)a[c] = 2147483648 + (c - 32 << 23); + a[63] = 3347054592; + for(let c = 1; c < 64; ++c)c !== 32 && (o[c] = 1024); + return { + floatView: t, + uint32View: e, + baseTable: n, + shiftTable: i, + mantissaTable: r, + exponentTable: a, + offsetTable: o + }; +} +function Ie(s1) { + Math.abs(s1) > 65504 && console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."), s1 = ae(s1, -65504, 65504), _n.floatView[0] = s1; + let t = _n.uint32View[0], e = t >> 23 & 511; + return _n.baseTable[e] + ((t & 8388607) >> _n.shiftTable[e]); +} +function xs(s1) { + let t = s1 >> 10; + return _n.uint32View[0] = _n.mantissaTable[_n.offsetTable[t] + (s1 & 1023)] + _n.exponentTable[t], _n.floatView[0]; +} +var vv = { + toHalfFloat: Ie, + fromHalfFloat: xs +}, de = new A, js = new J, Kt = class { + constructor(t, e, n = !1){ + if (Array.isArray(t)) throw new TypeError("THREE.BufferAttribute: array should be a Typed Array."); + this.isBufferAttribute = !0, this.name = "", this.array = t, this.itemSize = e, this.count = t !== void 0 ? t.length / e : 0, this.normalized = n, this.usage = kr, this.updateRange = { offset: 0, count: -1 - }, this.version = 0; + }, this.gpuType = xn, this.version = 0; } onUploadCallback() {} - set needsUpdate(e) { - e === !0 && this.version++; - } - setUsage(e) { - return this.usage = e, this; + set needsUpdate(t) { + t === !0 && this.version++; } - copy(e) { - return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this; + setUsage(t) { + return this.usage = t, this; } - copyAt(e, t, n) { - e *= this.itemSize, n *= t.itemSize; - for(let i = 0, r = this.itemSize; i < r; i++)this.array[e + i] = t.array[n + i]; - return this; - } - copyArray(e) { - return this.array.set(e), this; + 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; } - copyColorsArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined", i), o = new ae), t[n++] = o.r, t[n++] = o.g, t[n++] = o.b; - } + copyAt(t, e, n) { + t *= this.itemSize, n *= e.itemSize; + for(let i = 0, r = this.itemSize; i < r; i++)this.array[t + i] = e.array[n + i]; return this; } - copyVector2sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined", i), o = new X), t[n++] = o.x, t[n++] = o.y; - } - return this; + copyArray(t) { + return this.array.set(t), this; } - copyVector3sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined", i), o = new M), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z; - } + applyMatrix3(t) { + if (this.itemSize === 2) for(let e = 0, n = this.count; e < n; e++)js.fromBufferAttribute(this, e), js.applyMatrix3(t), this.setXY(e, js.x, js.y); + else if (this.itemSize === 3) for(let e = 0, n = this.count; e < n; e++)de.fromBufferAttribute(this, e), de.applyMatrix3(t), this.setXYZ(e, de.x, de.y, de.z); return this; } - copyVector4sArray(e) { - let t = this.array, n = 0; - for(let i = 0, r = e.length; i < r; i++){ - let o = e[i]; - o === void 0 && (console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined", i), o = new Ve), t[n++] = o.x, t[n++] = o.y, t[n++] = o.z, t[n++] = o.w; - } + applyMatrix4(t) { + for(let e = 0, n = this.count; e < n; e++)de.fromBufferAttribute(this, e), de.applyMatrix4(t), this.setXYZ(e, de.x, de.y, de.z); return this; } - applyMatrix3(e) { - if (this.itemSize === 2) for(let t = 0, n = this.count; t < n; t++)Qr.fromBufferAttribute(this, t), Qr.applyMatrix3(e), this.setXY(t, Qr.x, Qr.y); - else if (this.itemSize === 3) for(let t = 0, n = this.count; t < n; t++)Je.fromBufferAttribute(this, t), Je.applyMatrix3(e), this.setXYZ(t, Je.x, Je.y, Je.z); + applyNormalMatrix(t) { + for(let e = 0, n = this.count; e < n; e++)de.fromBufferAttribute(this, e), de.applyNormalMatrix(t), this.setXYZ(e, de.x, de.y, de.z); return this; } - applyMatrix4(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyMatrix4(e), this.setXYZ(t, Je.x, Je.y, Je.z); + transformDirection(t) { + for(let e = 0, n = this.count; e < n; e++)de.fromBufferAttribute(this, e), de.transformDirection(t), this.setXYZ(e, de.x, de.y, de.z); return this; } - applyNormalMatrix(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.applyNormalMatrix(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; + set(t, e = 0) { + return this.array.set(t, e), this; } - transformDirection(e) { - for(let t = 0, n = this.count; t < n; t++)Je.x = this.getX(t), Je.y = this.getY(t), Je.z = this.getZ(t), Je.transformDirection(e), this.setXYZ(t, Je.x, Je.y, Je.z); - return this; + getComponent(t, e) { + let n = this.array[t * this.itemSize + e]; + return this.normalized && (n = Ue(n, this.array)), n; } - set(e, t = 0) { - return this.array.set(e, t), this; + setComponent(t, e, n) { + return this.normalized && (n = Ft(n, this.array)), this.array[t * this.itemSize + e] = n, this; } - getX(e) { - return this.array[e * this.itemSize]; + getX(t) { + let e = this.array[t * this.itemSize]; + return this.normalized && (e = Ue(e, this.array)), e; } - setX(e, t) { - return this.array[e * this.itemSize] = t, this; + setX(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize] = e, this; } - getY(e) { - return this.array[e * this.itemSize + 1]; + getY(t) { + let e = this.array[t * this.itemSize + 1]; + return this.normalized && (e = Ue(e, this.array)), e; } - setY(e, t) { - return this.array[e * this.itemSize + 1] = t, this; + setY(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 1] = e, this; } - getZ(e) { - return this.array[e * this.itemSize + 2]; + getZ(t) { + let e = this.array[t * this.itemSize + 2]; + return this.normalized && (e = Ue(e, this.array)), e; } - setZ(e, t) { - return this.array[e * this.itemSize + 2] = t, this; + setZ(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 2] = e, this; } - getW(e) { - return this.array[e * this.itemSize + 3]; + getW(t) { + let e = this.array[t * this.itemSize + 3]; + return this.normalized && (e = Ue(e, this.array)), e; } - setW(e, t) { - return this.array[e * this.itemSize + 3] = t, this; + setW(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 3] = e, this; } - setXY(e, t, n) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this; + setXY(t, e, n) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array)), this.array[t + 0] = e, this.array[t + 1] = n, this; } - setXYZ(e, t, n, i) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this; + setXYZ(t, e, n, i) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array)), this.array[t + 0] = e, this.array[t + 1] = n, this.array[t + 2] = i, this; } - setXYZW(e, t, n, i, r) { - return e *= this.itemSize, this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = i, this.array[e + 3] = r, this; + setXYZW(t, e, n, i, r) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array), r = Ft(r, this.array)), this.array[t + 0] = e, this.array[t + 1] = n, this.array[t + 2] = i, this.array[t + 3] = r, this; } - onUpload(e) { - return this.onUploadCallback = e, this; + onUpload(t) { + return this.onUploadCallback = t, this; } clone() { return new this.constructor(this.array, this.itemSize).copy(this); } toJSON() { - let e = { + let t = { itemSize: this.itemSize, type: this.array.constructor.name, - array: Array.prototype.slice.call(this.array), + array: Array.from(this.array), normalized: this.normalized }; - return this.name !== "" && (e.name = this.name), this.usage !== hr && (e.usage = this.usage), (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (e.updateRange = this.updateRange), e; + return this.name !== "" && (t.name = this.name), this.usage !== kr && (t.usage = this.usage), (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (t.updateRange = this.updateRange), t; } -}; -Ue.prototype.isBufferAttribute = !0; -var jc = class extends Ue { - constructor(e, t, n){ - super(new Int8Array(e), t, n); +}, Wl = class extends Kt { + constructor(t, e, n){ + super(new Int8Array(t), e, n); } -}, Qc = class extends Ue { - constructor(e, t, n){ - super(new Uint8Array(e), t, n); +}, Xl = class extends Kt { + constructor(t, e, n){ + super(new Uint8Array(t), e, n); } -}, Kc = class extends Ue { - constructor(e, t, n){ - super(new Uint8ClampedArray(e), t, n); +}, ql = class extends Kt { + constructor(t, e, n){ + super(new Uint8ClampedArray(t), e, n); } -}, eh = class extends Ue { - constructor(e, t, n){ - super(new Int16Array(e), t, n); +}, Yl = class extends Kt { + constructor(t, e, n){ + super(new Int16Array(t), e, n); } -}, Ys = class extends Ue { - constructor(e, t, n){ - super(new Uint16Array(e), t, n); +}, qr = class extends Kt { + constructor(t, e, n){ + super(new Uint16Array(t), e, n); } -}, th = class extends Ue { - constructor(e, t, n){ - super(new Int32Array(e), t, n); +}, Zl = class extends Kt { + constructor(t, e, n){ + super(new Int32Array(t), e, n); } -}, Zs = class extends Ue { - constructor(e, t, n){ - super(new Uint32Array(e), t, n); +}, Yr = class extends Kt { + constructor(t, e, n){ + super(new Uint32Array(t), e, n); } -}, nh = class extends Ue { - constructor(e, t, n){ - super(new Uint16Array(e), t, n); +}, Jl = class extends Kt { + constructor(t, e, n){ + super(new Uint16Array(t), e, n), this.isFloat16BufferAttribute = !0; } -}; -nh.prototype.isFloat16BufferAttribute = !0; -var de = class extends Ue { - constructor(e, t, n){ - super(new Float32Array(e), t, n); + getX(t) { + let e = xs(this.array[t * this.itemSize]); + return this.normalized && (e = Ue(e, this.array)), e; + } + setX(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize] = Ie(e), this; + } + getY(t) { + let e = xs(this.array[t * this.itemSize + 1]); + return this.normalized && (e = Ue(e, this.array)), e; + } + setY(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 1] = Ie(e), this; } -}, ih = class extends Ue { - constructor(e, t, n){ - super(new Float64Array(e), t, n); + getZ(t) { + let e = xs(this.array[t * this.itemSize + 2]); + return this.normalized && (e = Ue(e, this.array)), e; } -}, cf = 0, Rt = new pe, No = new Ne, ci = new M, Tt = new Lt, $i = new Lt, ht = new M, _e = class extends En { + setZ(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 2] = Ie(e), this; + } + getW(t) { + let e = xs(this.array[t * this.itemSize + 3]); + return this.normalized && (e = Ue(e, this.array)), e; + } + setW(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.array[t * this.itemSize + 3] = Ie(e), this; + } + setXY(t, e, n) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array)), this.array[t + 0] = Ie(e), this.array[t + 1] = Ie(n), this; + } + setXYZ(t, e, n, i) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array)), this.array[t + 0] = Ie(e), this.array[t + 1] = Ie(n), this.array[t + 2] = Ie(i), this; + } + setXYZW(t, e, n, i, r) { + return t *= this.itemSize, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array), r = Ft(r, this.array)), this.array[t + 0] = Ie(e), this.array[t + 1] = Ie(n), this.array[t + 2] = Ie(i), this.array[t + 3] = Ie(r), this; + } +}, _t = class extends Kt { + constructor(t, e, n){ + super(new Float32Array(t), e, n); + } +}, $l = class extends Kt { + constructor(t, e, n){ + super(new Float64Array(t), e, n); + } +}, dp = 0, ke = new Ot, Ha = new Zt, Ti = new A, Oe = new Ke, us = new Ke, _e = new A, Vt = class s1 extends sn { constructor(){ - super(); - Object.defineProperty(this, "id", { - value: cf++ - }), this.uuid = Et(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { + super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { + value: dp++ + }), this.uuid = Be(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {}; @@ -2943,130 +3442,130 @@ var de = class extends Ue { getIndex() { return this.index; } - setIndex(e) { - return Array.isArray(e) ? this.index = new (Yc(e) > 65535 ? Zs : Ys)(e, 1) : this.index = e, this; + setIndex(t) { + return Array.isArray(t) ? this.index = new (gd(t) ? Yr : qr)(t, 1) : this.index = t, this; } - getAttribute(e) { - return this.attributes[e]; + getAttribute(t) { + return this.attributes[t]; } - setAttribute(e, t) { - return this.attributes[e] = t, this; + setAttribute(t, e) { + return this.attributes[t] = e, this; } - deleteAttribute(e) { - return delete this.attributes[e], this; + deleteAttribute(t) { + return delete this.attributes[t], this; } - hasAttribute(e) { - return this.attributes[e] !== void 0; + hasAttribute(t) { + return this.attributes[t] !== void 0; } - addGroup(e, t, n = 0) { + addGroup(t, e, n = 0) { this.groups.push({ - start: e, - count: t, + start: t, + count: e, materialIndex: n }); } clearGroups() { this.groups = []; } - setDrawRange(e, t) { - this.drawRange.start = e, this.drawRange.count = t; + setDrawRange(t, e) { + this.drawRange.start = t, this.drawRange.count = e; } - applyMatrix4(e) { - let t = this.attributes.position; - t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); + 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 lt().getNormalMatrix(e); + let r = new kt().getNormalMatrix(t); n.applyNormalMatrix(r), n.needsUpdate = !0; } let i = this.attributes.tangent; - return i !== void 0 && (i.transformDirection(e), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; + return i !== void 0 && (i.transformDirection(t), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; } - applyQuaternion(e) { - return Rt.makeRotationFromQuaternion(e), this.applyMatrix4(Rt), this; + applyQuaternion(t) { + return ke.makeRotationFromQuaternion(t), this.applyMatrix4(ke), this; } - rotateX(e) { - return Rt.makeRotationX(e), this.applyMatrix4(Rt), this; + rotateX(t) { + return ke.makeRotationX(t), this.applyMatrix4(ke), this; } - rotateY(e) { - return Rt.makeRotationY(e), this.applyMatrix4(Rt), this; + rotateY(t) { + return ke.makeRotationY(t), this.applyMatrix4(ke), this; } - rotateZ(e) { - return Rt.makeRotationZ(e), this.applyMatrix4(Rt), this; + rotateZ(t) { + return ke.makeRotationZ(t), this.applyMatrix4(ke), this; } - translate(e, t, n) { - return Rt.makeTranslation(e, t, n), this.applyMatrix4(Rt), this; + translate(t, e, n) { + return ke.makeTranslation(t, e, n), this.applyMatrix4(ke), this; } - scale(e, t, n) { - return Rt.makeScale(e, t, n), this.applyMatrix4(Rt), this; + scale(t, e, n) { + return ke.makeScale(t, e, n), this.applyMatrix4(ke), this; } - lookAt(e) { - return No.lookAt(e), No.updateMatrix(), this.applyMatrix4(No.matrix), this; + lookAt(t) { + return Ha.lookAt(t), Ha.updateMatrix(), this.applyMatrix4(Ha.matrix), this; } center() { - return this.computeBoundingBox(), this.boundingBox.getCenter(ci).negate(), this.translate(ci.x, ci.y, ci.z), this; + return this.computeBoundingBox(), this.boundingBox.getCenter(Ti).negate(), this.translate(Ti.x, Ti.y, Ti.z), this; } - setFromPoints(e) { - let t = []; - for(let n = 0, i = e.length; n < i; n++){ - let r = e[n]; - t.push(r.x, r.y, r.z || 0); + setFromPoints(t) { + let e = []; + for(let n = 0, i = t.length; n < i; n++){ + let r = t[n]; + e.push(r.x, r.y, r.z || 0); } - return this.setAttribute("position", new de(t, 3)), this; + return this.setAttribute("position", new _t(e, 3)), this; } computeBoundingBox() { - this.boundingBox === null && (this.boundingBox = new Lt); - let e = this.attributes.position, t = this.morphAttributes.position; - if (e && e.isGLBufferAttribute) { - console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingBox.set(new M(-1 / 0, -1 / 0, -1 / 0), new M(1 / 0, 1 / 0, 1 / 0)); + this.boundingBox === null && (this.boundingBox = new Ke); + let t = this.attributes.position, e = this.morphAttributes.position; + if (t && t.isGLBufferAttribute) { + console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingBox.set(new A(-1 / 0, -1 / 0, -1 / 0), new A(1 / 0, 1 / 0, 1 / 0)); return; } - if (e !== void 0) { - if (this.boundingBox.setFromBufferAttribute(e), t) for(let n = 0, i = t.length; n < i; n++){ - let r = t[n]; - Tt.setFromBufferAttribute(r), this.morphTargetsRelative ? (ht.addVectors(this.boundingBox.min, Tt.min), this.boundingBox.expandByPoint(ht), ht.addVectors(this.boundingBox.max, Tt.max), this.boundingBox.expandByPoint(ht)) : (this.boundingBox.expandByPoint(Tt.min), this.boundingBox.expandByPoint(Tt.max)); + if (t !== void 0) { + if (this.boundingBox.setFromBufferAttribute(t), e) for(let n = 0, i = e.length; n < i; n++){ + let r = e[n]; + Oe.setFromBufferAttribute(r), this.morphTargetsRelative ? (_e.addVectors(this.boundingBox.min, Oe.min), this.boundingBox.expandByPoint(_e), _e.addVectors(this.boundingBox.max, Oe.max), this.boundingBox.expandByPoint(_e)) : (this.boundingBox.expandByPoint(Oe.min), this.boundingBox.expandByPoint(Oe.max)); } } else this.boundingBox.makeEmpty(); (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this); } computeBoundingSphere() { - this.boundingSphere === null && (this.boundingSphere = new An); - let e = this.attributes.position, t = this.morphAttributes.position; - if (e && e.isGLBufferAttribute) { - console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingSphere.set(new M, 1 / 0); + this.boundingSphere === null && (this.boundingSphere = new We); + let t = this.attributes.position, e = this.morphAttributes.position; + if (t && t.isGLBufferAttribute) { + console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingSphere.set(new A, 1 / 0); return; } - if (e) { + if (t) { let n = this.boundingSphere.center; - if (Tt.setFromBufferAttribute(e), t) for(let r = 0, o = t.length; r < o; r++){ - let a = t[r]; - $i.setFromBufferAttribute(a), this.morphTargetsRelative ? (ht.addVectors(Tt.min, $i.min), Tt.expandByPoint(ht), ht.addVectors(Tt.max, $i.max), Tt.expandByPoint(ht)) : (Tt.expandByPoint($i.min), Tt.expandByPoint($i.max)); + if (Oe.setFromBufferAttribute(t), e) for(let r = 0, a = e.length; r < a; r++){ + let o = e[r]; + us.setFromBufferAttribute(o), this.morphTargetsRelative ? (_e.addVectors(Oe.min, us.min), Oe.expandByPoint(_e), _e.addVectors(Oe.max, us.max), Oe.expandByPoint(_e)) : (Oe.expandByPoint(us.min), Oe.expandByPoint(us.max)); } - Tt.getCenter(n); + Oe.getCenter(n); let i = 0; - for(let r = 0, o = e.count; r < o; r++)ht.fromBufferAttribute(e, r), i = Math.max(i, n.distanceToSquared(ht)); - if (t) for(let r = 0, o = t.length; r < o; r++){ - let a = t[r], l = this.morphTargetsRelative; - for(let c = 0, h = a.count; c < h; c++)ht.fromBufferAttribute(a, c), l && (ci.fromBufferAttribute(e, c), ht.add(ci)), i = Math.max(i, n.distanceToSquared(ht)); + for(let r = 0, a = t.count; r < a; r++)_e.fromBufferAttribute(t, r), i = Math.max(i, n.distanceToSquared(_e)); + if (e) for(let r = 0, a = e.length; r < a; r++){ + let o = e[r], c = this.morphTargetsRelative; + for(let l = 0, h = o.count; l < h; l++)_e.fromBufferAttribute(o, l), c && (Ti.fromBufferAttribute(t, l), _e.add(Ti)), i = Math.max(i, n.distanceToSquared(_e)); } this.boundingSphere.radius = Math.sqrt(i), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this); } } computeTangents() { - let e = this.index, t = this.attributes; - if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { + let t = this.index, e = this.attributes; + if (t === null || e.position === void 0 || e.normal === void 0 || e.uv === void 0) { console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); return; } - let n = e.array, i = t.position.array, r = t.normal.array, o = t.uv.array, a = i.length / 3; - t.tangent === void 0 && this.setAttribute("tangent", new Ue(new Float32Array(4 * a), 4)); - let l = t.tangent.array, c = [], h = []; - for(let B = 0; B < a; B++)c[B] = new M, h[B] = new M; - let u = new M, d = new M, f = new M, m = new X, x = new X, v = new X, g = new M, p = new M; - function _(B, P, w) { - u.fromArray(i, B * 3), d.fromArray(i, P * 3), f.fromArray(i, w * 3), m.fromArray(o, B * 2), x.fromArray(o, P * 2), v.fromArray(o, w * 2), d.sub(u), f.sub(u), x.sub(m), v.sub(m); - let E = 1 / (x.x * v.y - v.x * x.y); - !isFinite(E) || (g.copy(d).multiplyScalar(v.y).addScaledVector(f, -x.y).multiplyScalar(E), p.copy(f).multiplyScalar(x.x).addScaledVector(d, -v.x).multiplyScalar(E), c[B].add(g), c[P].add(g), c[w].add(g), h[B].add(p), h[P].add(p), h[w].add(p)); + let n = t.array, i = e.position.array, r = e.normal.array, a = e.uv.array, o = i.length / 3; + this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Kt(new Float32Array(4 * o), 4)); + let c = this.getAttribute("tangent").array, l = [], h = []; + for(let E = 0; E < o; E++)l[E] = new A, h[E] = new A; + let u = new A, d = new A, f = new A, m = new J, x = new J, g = new J, p = new A, v = new A; + function _(E, V, $) { + u.fromArray(i, E * 3), d.fromArray(i, V * 3), f.fromArray(i, $ * 3), m.fromArray(a, E * 2), x.fromArray(a, V * 2), g.fromArray(a, $ * 2), d.sub(u), f.sub(u), x.sub(m), g.sub(m); + let F = 1 / (x.x * g.y - g.x * x.y); + isFinite(F) && (p.copy(d).multiplyScalar(g.y).addScaledVector(f, -x.y).multiplyScalar(F), v.copy(f).multiplyScalar(x.x).addScaledVector(d, -g.x).multiplyScalar(F), l[E].add(p), l[V].add(p), l[$].add(p), h[E].add(v), h[V].add(v), h[$].add(v)); } let y = this.groups; y.length === 0 && (y = [ @@ -3075,337 +3574,325 @@ var de = class extends Ue { count: n.length } ]); - for(let B = 0, P = y.length; B < P; ++B){ - let w = y[B], E = w.start, D = w.count; - for(let U = E, F = E + D; U < F; U += 3)_(n[U + 0], n[U + 1], n[U + 2]); + for(let E = 0, V = y.length; E < V; ++E){ + let $ = y[E], F = $.start, O = $.count; + for(let z = F, K = F + O; z < K; z += 3)_(n[z + 0], n[z + 1], n[z + 2]); } - let b = new M, A = new M, L = new M, I = new M; - function k(B) { - L.fromArray(r, B * 3), I.copy(L); - let P = c[B]; - b.copy(P), b.sub(L.multiplyScalar(L.dot(P))).normalize(), A.crossVectors(I, P); - let E = A.dot(h[B]) < 0 ? -1 : 1; - l[B * 4] = b.x, l[B * 4 + 1] = b.y, l[B * 4 + 2] = b.z, l[B * 4 + 3] = E; + let b = new A, w = new A, R = new A, L = new A; + function M(E) { + R.fromArray(r, E * 3), L.copy(R); + let V = l[E]; + b.copy(V), b.sub(R.multiplyScalar(R.dot(V))).normalize(), w.crossVectors(L, V); + let F = w.dot(h[E]) < 0 ? -1 : 1; + c[E * 4] = b.x, c[E * 4 + 1] = b.y, c[E * 4 + 2] = b.z, c[E * 4 + 3] = F; } - for(let B = 0, P = y.length; B < P; ++B){ - let w = y[B], E = w.start, D = w.count; - for(let U = E, F = E + D; U < F; U += 3)k(n[U + 0]), k(n[U + 1]), k(n[U + 2]); + for(let E = 0, V = y.length; E < V; ++E){ + let $ = y[E], F = $.start, O = $.count; + for(let z = F, K = F + O; z < K; z += 3)M(n[z + 0]), M(n[z + 1]), M(n[z + 2]); } } computeVertexNormals() { - let e = this.index, t = this.getAttribute("position"); - if (t !== void 0) { + let t = this.index, e = this.getAttribute("position"); + if (e !== void 0) { let n = this.getAttribute("normal"); - if (n === void 0) n = new Ue(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); + if (n === void 0) n = new Kt(new Float32Array(e.count * 3), 3), this.setAttribute("normal", n); else for(let d = 0, f = n.count; d < f; d++)n.setXYZ(d, 0, 0, 0); - let i = new M, r = new M, o = new M, a = new M, l = new M, c = new M, h = new M, u = new M; - if (e) for(let d = 0, f = e.count; d < f; d += 3){ - let m = e.getX(d + 0), x = e.getX(d + 1), v = e.getX(d + 2); - i.fromBufferAttribute(t, m), r.fromBufferAttribute(t, x), o.fromBufferAttribute(t, v), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), a.fromBufferAttribute(n, m), l.fromBufferAttribute(n, x), c.fromBufferAttribute(n, v), a.add(h), l.add(h), c.add(h), n.setXYZ(m, a.x, a.y, a.z), n.setXYZ(x, l.x, l.y, l.z), n.setXYZ(v, c.x, c.y, c.z); + let i = new A, r = new A, a = new A, o = new A, c = new A, l = new A, h = new A, u = new A; + if (t) for(let d = 0, f = t.count; d < f; d += 3){ + let m = t.getX(d + 0), x = t.getX(d + 1), g = t.getX(d + 2); + i.fromBufferAttribute(e, m), r.fromBufferAttribute(e, x), a.fromBufferAttribute(e, g), h.subVectors(a, r), u.subVectors(i, r), h.cross(u), o.fromBufferAttribute(n, m), c.fromBufferAttribute(n, x), l.fromBufferAttribute(n, g), o.add(h), c.add(h), l.add(h), n.setXYZ(m, o.x, o.y, o.z), n.setXYZ(x, c.x, c.y, c.z), n.setXYZ(g, l.x, l.y, l.z); } - else for(let d = 0, f = t.count; d < f; d += 3)i.fromBufferAttribute(t, d + 0), r.fromBufferAttribute(t, d + 1), o.fromBufferAttribute(t, d + 2), h.subVectors(o, r), u.subVectors(i, r), h.cross(u), n.setXYZ(d + 0, h.x, h.y, h.z), n.setXYZ(d + 1, h.x, h.y, h.z), n.setXYZ(d + 2, h.x, h.y, h.z); + else for(let d = 0, f = e.count; d < f; d += 3)i.fromBufferAttribute(e, d + 0), r.fromBufferAttribute(e, d + 1), a.fromBufferAttribute(e, d + 2), h.subVectors(a, r), u.subVectors(i, r), h.cross(u), n.setXYZ(d + 0, h.x, h.y, h.z), n.setXYZ(d + 1, h.x, h.y, h.z), n.setXYZ(d + 2, h.x, h.y, h.z); this.normalizeNormals(), n.needsUpdate = !0; } } - merge(e, t) { - if (!(e && e.isBufferGeometry)) { - console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.", e); - return; - } - t === void 0 && (t = 0, console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.")); - let n = this.attributes; - for(let i in n){ - if (e.attributes[i] === void 0) continue; - let o = n[i].array, a = e.attributes[i], l = a.array, c = a.itemSize * t, h = Math.min(l.length, o.length - c); - for(let u = 0, d = c; u < h; u++, d++)o[d] = l[u]; - } - return this; - } normalizeNormals() { - let e = this.attributes.normal; - for(let t = 0, n = e.count; t < n; t++)ht.fromBufferAttribute(e, t), ht.normalize(), e.setXYZ(t, ht.x, ht.y, ht.z); + let t = this.attributes.normal; + for(let e = 0, n = t.count; e < n; e++)_e.fromBufferAttribute(t, e), _e.normalize(), t.setXYZ(e, _e.x, _e.y, _e.z); } toNonIndexed() { - function e(a, l) { - let c = a.array, h = a.itemSize, u = a.normalized, d = new c.constructor(l.length * h), f = 0, m = 0; - for(let x = 0, v = l.length; x < v; x++){ - a.isInterleavedBufferAttribute ? f = l[x] * a.data.stride + a.offset : f = l[x] * h; - for(let g = 0; g < h; g++)d[m++] = c[f++]; + function t(o, c) { + let l = o.array, h = o.itemSize, u = o.normalized, d = new l.constructor(c.length * h), f = 0, m = 0; + for(let x = 0, g = c.length; x < g; x++){ + o.isInterleavedBufferAttribute ? f = c[x] * o.data.stride + o.offset : f = c[x] * h; + for(let p = 0; p < h; p++)d[m++] = l[f++]; } - return new Ue(d, h, u); + return new Kt(d, h, u); } if (this.index === null) return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; - let t = new _e, n = this.index.array, i = this.attributes; - for(let a in i){ - let l = i[a], c = e(l, n); - t.setAttribute(a, c); + let e = new s1, n = this.index.array, i = this.attributes; + for(let o in i){ + let c = i[o], l = t(c, n); + e.setAttribute(o, l); } let r = this.morphAttributes; - for(let a in r){ - let l = [], c = r[a]; - for(let h = 0, u = c.length; h < u; h++){ - let d = c[h], f = e(d, n); - l.push(f); + for(let o in r){ + let c = [], l = r[o]; + for(let h = 0, u = l.length; h < u; h++){ + let d = l[h], f = t(d, n); + c.push(f); } - t.morphAttributes[a] = l; + e.morphAttributes[o] = c; } - t.morphTargetsRelative = this.morphTargetsRelative; - let o = this.groups; - for(let a = 0, l = o.length; a < l; a++){ - let c = o[a]; - t.addGroup(c.start, c.count, c.materialIndex); + e.morphTargetsRelative = this.morphTargetsRelative; + let a = this.groups; + for(let o = 0, c = a.length; o < c; o++){ + let l = a[o]; + e.addGroup(l.start, l.count, l.materialIndex); } - return t; + return e; } toJSON() { - let e = { + let t = { metadata: { - version: 4.5, + version: 4.6, type: "BufferGeometry", generator: "BufferGeometry.toJSON" } }; - if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) { - let l = this.parameters; - for(let c in l)l[c] !== void 0 && (e[c] = l[c]); - return e; + if (t.uuid = this.uuid, t.type = this.type, this.name !== "" && (t.name = this.name), Object.keys(this.userData).length > 0 && (t.userData = this.userData), this.parameters !== void 0) { + let c = this.parameters; + for(let l in c)c[l] !== void 0 && (t[l] = c[l]); + return t; } - e.data = { + t.data = { attributes: {} }; - let t = this.index; - t !== null && (e.data.index = { - type: t.array.constructor.name, - array: Array.prototype.slice.call(t.array) + 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]; - e.data.attributes[l] = c.toJSON(e.data); + for(let c in n){ + let l = n[c]; + t.data.attributes[c] = l.toJSON(t.data); } let i = {}, r = !1; - for(let l in this.morphAttributes){ - let c = this.morphAttributes[l], h = []; - for(let u = 0, d = c.length; u < d; u++){ - let f = c[u]; - h.push(f.toJSON(e.data)); + for(let c in this.morphAttributes){ + let l = this.morphAttributes[c], h = []; + for(let u = 0, d = l.length; u < d; u++){ + let f = l[u]; + h.push(f.toJSON(t.data)); } - h.length > 0 && (i[l] = h, r = !0); + h.length > 0 && (i[c] = h, r = !0); } - r && (e.data.morphAttributes = i, e.data.morphTargetsRelative = this.morphTargetsRelative); - let o = this.groups; - o.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(o))); - let a = this.boundingSphere; - return a !== null && (e.data.boundingSphere = { - center: a.center.toArray(), - radius: a.radius - }), e; + r && (t.data.morphAttributes = i, t.data.morphTargetsRelative = this.morphTargetsRelative); + let a = this.groups; + a.length > 0 && (t.data.groups = JSON.parse(JSON.stringify(a))); + let o = this.boundingSphere; + return o !== null && (t.data.boundingSphere = { + center: o.center.toArray(), + radius: o.radius + }), t; } clone() { return new this.constructor().copy(this); } - copy(e) { + copy(t) { this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; - let t = {}; - this.name = e.name; - let n = e.index; - n !== null && this.setIndex(n.clone(t)); - let i = e.attributes; - for(let c in i){ - let h = i[c]; - this.setAttribute(c, h.clone(t)); - } - let r = e.morphAttributes; - for(let c in r){ - let h = [], u = r[c]; - for(let d = 0, f = u.length; d < f; d++)h.push(u[d].clone(t)); - this.morphAttributes[c] = h; - } - this.morphTargetsRelative = e.morphTargetsRelative; - let o = e.groups; - for(let c = 0, h = o.length; c < h; c++){ - let u = o[c]; + let e = {}; + this.name = t.name; + let n = t.index; + n !== null && this.setIndex(n.clone(e)); + let i = t.attributes; + for(let l in i){ + let h = i[l]; + this.setAttribute(l, h.clone(e)); + } + let r = t.morphAttributes; + for(let l in r){ + let h = [], u = r[l]; + for(let d = 0, f = u.length; d < f; d++)h.push(u[d].clone(e)); + this.morphAttributes[l] = h; + } + this.morphTargetsRelative = t.morphTargetsRelative; + let a = t.groups; + for(let l = 0, h = a.length; l < h; l++){ + let u = a[l]; this.addGroup(u.start, u.count, u.materialIndex); } - let a = e.boundingBox; - a !== null && (this.boundingBox = a.clone()); - let l = e.boundingSphere; - return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, e.parameters !== void 0 && (this.parameters = Object.assign({}, e.parameters)), this; + let o = t.boundingBox; + o !== null && (this.boundingBox = o.clone()); + let c = t.boundingSphere; + return c !== null && (this.boundingSphere = c.clone()), this.drawRange.start = t.drawRange.start, this.drawRange.count = t.drawRange.count, this.userData = t.userData, this; } dispose() { this.dispatchEvent({ type: "dispose" }); } -}; -_e.prototype.isBufferGeometry = !0; -var Cl = new pe, hi = new Cn, Bo = new An, mn = new M, gn = new M, xn = new M, zo = new M, Uo = new M, Oo = new M, Kr = new M, es = new M, ts = new M, ns = new X, is = new X, rs = new X, Ho = new M, ss = new M, st = class extends Ne { - constructor(e = new _e, t = new hn){ - super(); - this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets(); +}, Kl = new Ot, Xn = new hi, tr = new We, Ql = new A, wi = new A, Ai = new A, Ri = new A, Ga = new A, er = new A, nr = new J, ir = new J, sr = new J, jl = new A, th = new A, eh = new A, rr = new A, ar = new A, ve = class extends Zt { + constructor(t = new Vt, e = new Mn){ + super(), this.isMesh = !0, this.type = "Mesh", this.geometry = t, this.material = e, this.updateMorphTargets(); } - copy(e) { - return super.copy(e), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = e.material, this.geometry = e.geometry, this; + 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 = t.material, this.geometry = t.geometry, this; } updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } + let e = this.geometry.morphAttributes, n = Object.keys(e); + if (n.length > 0) { + let i = e[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, a = i.length; r < a; r++){ + let o = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); } } - raycast(e, t) { + getVertexPosition(t, e) { + let n = this.geometry, i = n.attributes.position, r = n.morphAttributes.position, a = n.morphTargetsRelative; + e.fromBufferAttribute(i, t); + let o = this.morphTargetInfluences; + if (r && o) { + er.set(0, 0, 0); + for(let c = 0, l = r.length; c < l; c++){ + let h = o[c], u = r[c]; + h !== 0 && (Ga.fromBufferAttribute(u, t), a ? er.addScaledVector(Ga, h) : er.addScaledVector(Ga.sub(e), h)); + } + e.add(er); + } + return e; + } + raycast(t, e) { let n = this.geometry, i = this.material, r = this.matrixWorld; - if (i === void 0 || (n.boundingSphere === null && n.computeBoundingSphere(), Bo.copy(n.boundingSphere), Bo.applyMatrix4(r), e.ray.intersectsSphere(Bo) === !1) || (Cl.copy(r).invert(), hi.copy(e.ray).applyMatrix4(Cl), n.boundingBox !== null && hi.intersectsBox(n.boundingBox) === !1)) return; - let o; - if (n.isBufferGeometry) { - let a = n.index, l = n.attributes.position, c = n.morphAttributes.position, h = n.morphTargetsRelative, u = n.attributes.uv, d = n.attributes.uv2, f = n.groups, m = n.drawRange; - if (a !== null) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ - let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(a.count, Math.min(g.start + g.count, m.start + m.count)); - for(let b = _, A = y; b < A; b += 3){ - let L = a.getX(b), I = a.getX(b + 1), k = a.getX(b + 2); - o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); - } + i !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), tr.copy(n.boundingSphere), tr.applyMatrix4(r), Xn.copy(t.ray).recast(t.near), !(tr.containsPoint(Xn.origin) === !1 && (Xn.intersectSphere(tr, Ql) === null || Xn.origin.distanceToSquared(Ql) > (t.far - t.near) ** 2)) && (Kl.copy(r).invert(), Xn.copy(t.ray).applyMatrix4(Kl), !(n.boundingBox !== null && Xn.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(t, e, Xn))); + } + _computeIntersections(t, e, n) { + let i, r = this.geometry, a = this.material, o = r.index, c = r.attributes.position, l = r.attributes.uv, h = r.attributes.uv1, u = r.attributes.normal, d = r.groups, f = r.drawRange; + if (o !== null) if (Array.isArray(a)) for(let m = 0, x = d.length; m < x; m++){ + let g = d[m], p = a[g.materialIndex], v = Math.max(g.start, f.start), _ = Math.min(o.count, Math.min(g.start + g.count, f.start + f.count)); + for(let y = v, b = _; y < b; y += 3){ + let w = o.getX(y), R = o.getX(y + 1), L = o.getX(y + 2); + i = or(this, p, t, n, l, h, u, w, R, L), i && (i.faceIndex = Math.floor(y / 3), i.face.materialIndex = g.materialIndex, e.push(i)); } - else { - let x = Math.max(0, m.start), v = Math.min(a.count, m.start + m.count); - for(let g = x, p = v; g < p; g += 3){ - let _ = a.getX(g), y = a.getX(g + 1), b = a.getX(g + 2); - o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); - } + } + else { + let m = Math.max(0, f.start), x = Math.min(o.count, f.start + f.count); + for(let g = m, p = x; g < p; g += 3){ + let v = o.getX(g), _ = o.getX(g + 1), y = o.getX(g + 2); + i = or(this, a, t, n, l, h, u, v, _, y), i && (i.faceIndex = Math.floor(g / 3), e.push(i)); } - else if (l !== void 0) if (Array.isArray(i)) for(let x = 0, v = f.length; x < v; x++){ - let g = f[x], p = i[g.materialIndex], _ = Math.max(g.start, m.start), y = Math.min(l.count, Math.min(g.start + g.count, m.start + m.count)); - for(let b = _, A = y; b < A; b += 3){ - let L = b, I = b + 1, k = b + 2; - o = os(this, p, e, hi, l, c, h, u, d, L, I, k), o && (o.faceIndex = Math.floor(b / 3), o.face.materialIndex = g.materialIndex, t.push(o)); - } + } + else if (c !== void 0) if (Array.isArray(a)) for(let m = 0, x = d.length; m < x; m++){ + let g = d[m], p = a[g.materialIndex], v = Math.max(g.start, f.start), _ = Math.min(c.count, Math.min(g.start + g.count, f.start + f.count)); + for(let y = v, b = _; y < b; y += 3){ + let w = y, R = y + 1, L = y + 2; + i = or(this, p, t, n, l, h, u, w, R, L), i && (i.faceIndex = Math.floor(y / 3), i.face.materialIndex = g.materialIndex, e.push(i)); } - else { - let x = Math.max(0, m.start), v = Math.min(l.count, m.start + m.count); - for(let g = x, p = v; g < p; g += 3){ - let _ = g, y = g + 1, b = g + 2; - o = os(this, i, e, hi, l, c, h, u, d, _, y, b), o && (o.faceIndex = Math.floor(g / 3), t.push(o)); - } + } + else { + let m = Math.max(0, f.start), x = Math.min(c.count, f.start + f.count); + for(let g = m, p = x; g < p; g += 3){ + let v = g, _ = g + 1, y = g + 2; + i = or(this, a, t, n, l, h, u, v, _, y), i && (i.faceIndex = Math.floor(g / 3), e.push(i)); } - } else n.isGeometry && console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } } }; -st.prototype.isMesh = !0; -function hf(s, e, t, n, i, r, o, a) { - let l; - if (e.side === it ? l = n.intersectTriangle(o, r, i, !0, a) : l = n.intersectTriangle(i, r, o, e.side !== Ci, a), l === null) return null; - ss.copy(a), ss.applyMatrix4(s.matrixWorld); - let c = t.ray.origin.distanceTo(ss); - return c < t.near || c > t.far ? null : { - distance: c, - point: ss.clone(), - object: s +function fp(s1, t, e, n, i, r, a, o) { + let c; + if (t.side === De ? c = n.intersectTriangle(a, r, i, !0, o) : c = n.intersectTriangle(i, r, a, t.side === On, o), c === null) return null; + ar.copy(o), ar.applyMatrix4(s1.matrixWorld); + let l = e.ray.origin.distanceTo(ar); + return l < e.near || l > e.far ? null : { + distance: l, + point: ar.clone(), + object: s1 }; } -function os(s, e, t, n, i, r, o, a, l, c, h, u) { - mn.fromBufferAttribute(i, c), gn.fromBufferAttribute(i, h), xn.fromBufferAttribute(i, u); - let d = s.morphTargetInfluences; - if (r && d) { - Kr.set(0, 0, 0), es.set(0, 0, 0), ts.set(0, 0, 0); - for(let m = 0, x = r.length; m < x; m++){ - let v = d[m], g = r[m]; - v !== 0 && (zo.fromBufferAttribute(g, c), Uo.fromBufferAttribute(g, h), Oo.fromBufferAttribute(g, u), o ? (Kr.addScaledVector(zo, v), es.addScaledVector(Uo, v), ts.addScaledVector(Oo, v)) : (Kr.addScaledVector(zo.sub(mn), v), es.addScaledVector(Uo.sub(gn), v), ts.addScaledVector(Oo.sub(xn), v))); - } - mn.add(Kr), gn.add(es), xn.add(ts); - } - s.isSkinnedMesh && (s.boneTransform(c, mn), s.boneTransform(h, gn), s.boneTransform(u, xn)); - let f = hf(s, e, t, n, mn, gn, xn, Ho); - if (f) { - a && (ns.fromBufferAttribute(a, c), is.fromBufferAttribute(a, h), rs.fromBufferAttribute(a, u), f.uv = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)), l && (ns.fromBufferAttribute(l, c), is.fromBufferAttribute(l, h), rs.fromBufferAttribute(l, u), f.uv2 = nt.getUV(Ho, mn, gn, xn, ns, is, rs, new X)); - let m = { - a: c, - b: h, - c: u, - normal: new M, +function or(s1, t, e, n, i, r, a, o, c, l) { + s1.getVertexPosition(o, wi), s1.getVertexPosition(c, Ai), s1.getVertexPosition(l, Ri); + let h = fp(s1, t, e, n, wi, Ai, Ri, rr); + if (h) { + i && (nr.fromBufferAttribute(i, o), ir.fromBufferAttribute(i, c), sr.fromBufferAttribute(i, l), h.uv = In.getInterpolation(rr, wi, Ai, Ri, nr, ir, sr, new J)), r && (nr.fromBufferAttribute(r, o), ir.fromBufferAttribute(r, c), sr.fromBufferAttribute(r, l), h.uv1 = In.getInterpolation(rr, wi, Ai, Ri, nr, ir, sr, new J), h.uv2 = h.uv1), a && (jl.fromBufferAttribute(a, o), th.fromBufferAttribute(a, c), eh.fromBufferAttribute(a, l), h.normal = In.getInterpolation(rr, wi, Ai, Ri, jl, th, eh, new A), h.normal.dot(n.direction) > 0 && h.normal.multiplyScalar(-1)); + let u = { + a: o, + b: c, + c: l, + normal: new A, materialIndex: 0 }; - nt.getNormal(mn, gn, xn, m.normal), f.face = m; + In.getNormal(wi, Ai, Ri, u.normal), h.face = u; } - return f; + return h; } -var wn = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 1, r = 1, o = 1){ - super(); - this.type = "BoxGeometry", this.parameters = { - width: e, - height: t, +var Ji = class s1 extends Vt { + constructor(t = 1, e = 1, n = 1, i = 1, r = 1, a = 1){ + super(), this.type = "BoxGeometry", this.parameters = { + width: t, + height: e, depth: n, widthSegments: i, heightSegments: r, - depthSegments: o + depthSegments: a }; - let a = this; - i = Math.floor(i), r = Math.floor(r), o = Math.floor(o); - let l = [], c = [], h = [], u = [], d = 0, f = 0; - m("z", "y", "x", -1, -1, n, t, e, o, r, 0), m("z", "y", "x", 1, -1, n, t, -e, o, r, 1), m("x", "z", "y", 1, 1, e, n, t, i, o, 2), m("x", "z", "y", 1, -1, e, n, -t, i, o, 3), m("x", "y", "z", 1, -1, e, t, n, i, r, 4), m("x", "y", "z", -1, -1, e, t, -n, i, r, 5), this.setIndex(l), this.setAttribute("position", new de(c, 3)), this.setAttribute("normal", new de(h, 3)), this.setAttribute("uv", new de(u, 2)); - function m(x, v, g, p, _, y, b, A, L, I, k) { - let B = y / L, P = b / I, w = y / 2, E = b / 2, D = A / 2, U = L + 1, F = I + 1, O = 0, ne = 0, ce = new M; - for(let V = 0; V < F; V++){ - let W = V * P - E; - for(let he = 0; he < U; he++){ - let le = he * B - w; - ce[x] = le * p, ce[v] = W * _, ce[g] = D, c.push(ce.x, ce.y, ce.z), ce[x] = 0, ce[v] = 0, ce[g] = A > 0 ? 1 : -1, h.push(ce.x, ce.y, ce.z), u.push(he / L), u.push(1 - V / I), O += 1; + let o = this; + i = Math.floor(i), r = Math.floor(r), a = Math.floor(a); + let c = [], l = [], h = [], u = [], d = 0, f = 0; + m("z", "y", "x", -1, -1, n, e, t, a, r, 0), m("z", "y", "x", 1, -1, n, e, -t, a, r, 1), m("x", "z", "y", 1, 1, t, n, e, i, a, 2), m("x", "z", "y", 1, -1, t, n, -e, i, a, 3), m("x", "y", "z", 1, -1, t, e, n, i, r, 4), m("x", "y", "z", -1, -1, t, e, -n, i, r, 5), this.setIndex(c), this.setAttribute("position", new _t(l, 3)), this.setAttribute("normal", new _t(h, 3)), this.setAttribute("uv", new _t(u, 2)); + function m(x, g, p, v, _, y, b, w, R, L, M) { + let E = y / R, V = b / L, $ = y / 2, F = b / 2, O = w / 2, z = R + 1, K = L + 1, X = 0, Y = 0, j = new A; + for(let tt = 0; tt < K; tt++){ + let N = tt * V - F; + for(let q = 0; q < z; q++){ + let lt = q * E - $; + j[x] = lt * v, j[g] = N * _, j[p] = O, l.push(j.x, j.y, j.z), j[x] = 0, j[g] = 0, j[p] = w > 0 ? 1 : -1, h.push(j.x, j.y, j.z), u.push(q / R), u.push(1 - tt / L), X += 1; } } - for(let V = 0; V < I; V++)for(let W = 0; W < L; W++){ - let he = d + W + U * V, le = d + W + U * (V + 1), fe = d + (W + 1) + U * (V + 1), Be = d + (W + 1) + U * V; - l.push(he, le, Be), l.push(le, fe, Be), ne += 6; + for(let tt = 0; tt < L; tt++)for(let N = 0; N < R; N++){ + let q = d + N + z * tt, lt = d + N + z * (tt + 1), ut = d + (N + 1) + z * (tt + 1), pt = d + (N + 1) + z * tt; + c.push(q, lt, pt), c.push(lt, ut, pt), Y += 6; } - a.addGroup(f, ne, k), f += ne, d += O; + o.addGroup(f, Y, M), f += Y, d += X; } } - static fromJSON(e) { - return new wn(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } + static fromJSON(t) { + return new s1(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments); } }; -function Ri(s) { - let e = {}; - for(let t in s){ - e[t] = {}; - for(let n in s[t]){ - let i = s[t][n]; - i && (i.isColor || i.isMatrix3 || i.isMatrix4 || i.isVector2 || i.isVector3 || i.isVector4 || i.isTexture || i.isQuaternion) ? e[t][n] = i.clone() : Array.isArray(i) ? e[t][n] = i.slice() : e[t][n] = i; +function $i(s1) { + let t = {}; + for(let e in s1){ + t[e] = {}; + for(let n in s1[e]){ + let i = s1[e][n]; + i && (i.isColor || i.isMatrix3 || i.isMatrix4 || i.isVector2 || i.isVector3 || i.isVector4 || i.isTexture || i.isQuaternion) ? i.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[e][n] = null) : t[e][n] = i.clone() : Array.isArray(i) ? t[e][n] = i.slice() : t[e][n] = i; } } - return e; + return t; } -function yt(s) { - let e = {}; - for(let t = 0; t < s.length; t++){ - let n = Ri(s[t]); - for(let i in n)e[i] = n[i]; +function Re(s1) { + let t = {}; + for(let e = 0; e < s1.length; e++){ + let n = $i(s1[e]); + for(let i in n)t[i] = n[i]; } - return e; + return t; +} +function pp(s1) { + let t = []; + for(let e = 0; e < s1.length; e++)t.push(s1[e].clone()); + return t; } -var uf = { - clone: Ri, - merge: yt -}, df = `void main() { +function xd(s1) { + return s1.getRenderTarget() === null ? s1.outputColorSpace : nn; +} +var mp = { + clone: $i, + merge: Re +}, gp = `void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); -}`, ff = `void main() { +}`, _p = `void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); -}`, sn = class extends dt { - constructor(e){ - super(); - this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.vertexShader = df, this.fragmentShader = ff, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.extensions = { +}`, Qe = class extends Me { + constructor(t){ + super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = gp, this.fragmentShader = _p, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = { derivatives: !1, fragDepth: !1, drawBuffers: !1, @@ -3420,94 +3907,88 @@ var uf = { 0, 0 ], - uv2: [ + uv1: [ 0, 0 ] - }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && (e.attributes !== void 0 && console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."), this.setValues(e)); + }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, t !== void 0 && this.setValues(t); } - copy(e) { - return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Ri(e.uniforms), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this; + copy(t) { + return super.copy(t), this.fragmentShader = t.fragmentShader, this.vertexShader = t.vertexShader, this.uniforms = $i(t.uniforms), this.uniformsGroups = pp(t.uniformsGroups), this.defines = Object.assign({}, t.defines), this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.fog = t.fog, this.lights = t.lights, this.clipping = t.clipping, this.extensions = Object.assign({}, t.extensions), this.glslVersion = t.glslVersion, this; } - toJSON(e) { - let t = super.toJSON(e); - t.glslVersion = this.glslVersion, t.uniforms = {}; + toJSON(t) { + let e = super.toJSON(t); + e.glslVersion = this.glslVersion, e.uniforms = {}; for(let i in this.uniforms){ - let o = this.uniforms[i].value; - o && o.isTexture ? t.uniforms[i] = { + let a = this.uniforms[i].value; + a && a.isTexture ? e.uniforms[i] = { type: "t", - value: o.toJSON(e).uuid - } : o && o.isColor ? t.uniforms[i] = { + value: a.toJSON(t).uuid + } : a && a.isColor ? e.uniforms[i] = { type: "c", - value: o.getHex() - } : o && o.isVector2 ? t.uniforms[i] = { + value: a.getHex() + } : a && a.isVector2 ? e.uniforms[i] = { type: "v2", - value: o.toArray() - } : o && o.isVector3 ? t.uniforms[i] = { + value: a.toArray() + } : a && a.isVector3 ? e.uniforms[i] = { type: "v3", - value: o.toArray() - } : o && o.isVector4 ? t.uniforms[i] = { + value: a.toArray() + } : a && a.isVector4 ? e.uniforms[i] = { type: "v4", - value: o.toArray() - } : o && o.isMatrix3 ? t.uniforms[i] = { + value: a.toArray() + } : a && a.isMatrix3 ? e.uniforms[i] = { type: "m3", - value: o.toArray() - } : o && o.isMatrix4 ? t.uniforms[i] = { + value: a.toArray() + } : a && a.isMatrix4 ? e.uniforms[i] = { type: "m4", - value: o.toArray() - } : t.uniforms[i] = { - value: o + value: a.toArray() + } : e.uniforms[i] = { + value: a }; } - Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader; + Object.keys(this.defines).length > 0 && (e.defines = this.defines), e.vertexShader = this.vertexShader, e.fragmentShader = this.fragmentShader, e.lights = this.lights, e.clipping = this.clipping; let n = {}; for(let i in this.extensions)this.extensions[i] === !0 && (n[i] = !0); - return Object.keys(n).length > 0 && (t.extensions = n), t; + return Object.keys(n).length > 0 && (e.extensions = n), e; } -}; -sn.prototype.isShaderMaterial = !0; -var Ir = class extends Ne { +}, Cs = class extends Zt { constructor(){ - super(); - this.type = "Camera", this.matrixWorldInverse = new pe, this.projectionMatrix = new pe, this.projectionMatrixInverse = new pe; + super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Ot, this.projectionMatrix = new Ot, this.projectionMatrixInverse = new Ot, this.coordinateSystem = vn; } - copy(e, t) { - return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this; + copy(t, e) { + return super.copy(t, e), this.matrixWorldInverse.copy(t.matrixWorldInverse), this.projectionMatrix.copy(t.projectionMatrix), this.projectionMatrixInverse.copy(t.projectionMatrixInverse), this.coordinateSystem = t.coordinateSystem, this; } - getWorldDirection(e) { + getWorldDirection(t) { this.updateWorldMatrix(!0, !1); - let t = this.matrixWorld.elements; - return e.set(-t[8], -t[9], -t[10]).normalize(); + let e = this.matrixWorld.elements; + return t.set(-e[8], -e[9], -e[10]).normalize(); } - updateMatrixWorld(e) { - super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + updateMatrixWorld(t) { + super.updateMatrixWorld(t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } - updateWorldMatrix(e, t) { - super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); + updateWorldMatrix(t, e) { + super.updateWorldMatrix(t, e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } clone() { return new this.constructor().copy(this); } -}; -Ir.prototype.isCamera = !0; -var ut = class extends Ir { - constructor(e = 50, t = 1, n = .1, i = 2e3){ - super(); - this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); +}, xe = class extends Cs { + constructor(t = 50, e = 1, n = .1, i = 2e3){ + super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = t, this.zoom = 1, this.near = n, this.far = i, this.focus = 10, this.aspect = e, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); } - copy(e, t) { - return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; + copy(t, e) { + return super.copy(t, e), this.fov = t.fov, this.zoom = t.zoom, this.near = t.near, this.far = t.far, this.focus = t.focus, this.aspect = t.aspect, this.view = t.view === null ? null : Object.assign({}, t.view), this.filmGauge = t.filmGauge, this.filmOffset = t.filmOffset, this; } - setFocalLength(e) { - let t = .5 * this.getFilmHeight() / e; - this.fov = dr * 2 * Math.atan(t), this.updateProjectionMatrix(); + setFocalLength(t) { + let e = .5 * this.getFilmHeight() / t; + this.fov = Zi * 2 * Math.atan(e), this.updateProjectionMatrix(); } getFocalLength() { - let e = Math.tan(Wn * .5 * this.fov); - return .5 * this.getFilmHeight() / e; + let t = Math.tan(ai * .5 * this.fov); + return .5 * this.getFilmHeight() / t; } getEffectiveFOV() { - return dr * 2 * Math.atan(Math.tan(Wn * .5 * this.fov) / this.zoom); + return Zi * 2 * Math.atan(Math.tan(ai * .5 * this.fov) / this.zoom); } getFilmWidth() { return this.filmGauge * Math.min(this.aspect, 1); @@ -3515,8 +3996,8 @@ var ut = class extends Ir { getFilmHeight() { return this.filmGauge / Math.max(this.aspect, 1); } - setViewOffset(e, t, n, i, r, o) { - this.aspect = e / t, this.view === null && (this.view = { + setViewOffset(t, e, n, i, r, a) { + this.aspect = t / e, this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, @@ -3524,76 +4005,86 @@ var ut = class extends Ir { offsetY: 0, width: 1, height: 1 - }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); + }), this.view.enabled = !0, this.view.fullWidth = t, this.view.fullHeight = e, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = a, this.updateProjectionMatrix(); } clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } updateProjectionMatrix() { - let e = this.near, t = e * Math.tan(Wn * .5 * this.fov) / this.zoom, n = 2 * t, i = this.aspect * n, r = -.5 * i, o = this.view; + let t = this.near, e = t * Math.tan(ai * .5 * this.fov) / this.zoom, n = 2 * e, i = this.aspect * n, r = -.5 * i, a = this.view; if (this.view !== null && this.view.enabled) { - let l = o.fullWidth, c = o.fullHeight; - r += o.offsetX * i / l, t -= o.offsetY * n / c, i *= o.width / l, n *= o.height / c; - } - let a = this.filmOffset; - a !== 0 && (r += e * a / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, t, t - n, e, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); - } - toJSON(e) { - let t = super.toJSON(e); - return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; - } -}; -ut.prototype.isPerspectiveCamera = !0; -var ui = 90, di = 1, $s = class extends Ne { - constructor(e, t, n){ - super(); - if (this.type = "CubeCamera", n.isWebGLCubeRenderTarget !== !0) { - console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."); - return; - } - this.renderTarget = n; - let i = new ut(ui, di, e, t); - i.layers = this.layers, i.up.set(0, -1, 0), i.lookAt(new M(1, 0, 0)), this.add(i); - let r = new ut(ui, di, e, t); - r.layers = this.layers, r.up.set(0, -1, 0), r.lookAt(new M(-1, 0, 0)), this.add(r); - let o = new ut(ui, di, e, t); - o.layers = this.layers, o.up.set(0, 0, 1), o.lookAt(new M(0, 1, 0)), this.add(o); - let a = new ut(ui, di, e, t); - a.layers = this.layers, a.up.set(0, 0, -1), a.lookAt(new M(0, -1, 0)), this.add(a); - let l = new ut(ui, di, e, t); - l.layers = this.layers, l.up.set(0, -1, 0), l.lookAt(new M(0, 0, 1)), this.add(l); - let c = new ut(ui, di, e, t); - c.layers = this.layers, c.up.set(0, -1, 0), c.lookAt(new M(0, 0, -1)), this.add(c); - } - update(e, t) { + let c = a.fullWidth, l = a.fullHeight; + r += a.offsetX * i / c, e -= a.offsetY * n / l, i *= a.width / c, n *= a.height / l; + } + let o = this.filmOffset; + o !== 0 && (r += t * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + i, e, e - n, t, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + toJSON(t) { + let e = super.toJSON(t); + return e.object.fov = this.fov, e.object.zoom = this.zoom, e.object.near = this.near, e.object.far = this.far, e.object.focus = this.focus, e.object.aspect = this.aspect, this.view !== null && (e.object.view = Object.assign({}, this.view)), e.object.filmGauge = this.filmGauge, e.object.filmOffset = this.filmOffset, e; + } +}, Ci = -90, Pi = 1, uo = class extends Zt { + constructor(t, e, n){ + super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null; + let i = new xe(Ci, Pi, t, e); + i.layers = this.layers, this.add(i); + let r = new xe(Ci, Pi, t, e); + r.layers = this.layers, this.add(r); + let a = new xe(Ci, Pi, t, e); + a.layers = this.layers, this.add(a); + let o = new xe(Ci, Pi, t, e); + o.layers = this.layers, this.add(o); + let c = new xe(Ci, Pi, t, e); + c.layers = this.layers, this.add(c); + let l = new xe(Ci, Pi, t, e); + l.layers = this.layers, this.add(l); + } + updateCoordinateSystem() { + let t = this.coordinateSystem, e = this.children.concat(), [n, i, r, a, o, c] = e; + for (let l of e)this.remove(l); + if (t === vn) n.up.set(0, 1, 0), n.lookAt(1, 0, 0), i.up.set(0, 1, 0), i.lookAt(-1, 0, 0), r.up.set(0, 0, -1), r.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), c.up.set(0, 1, 0), c.lookAt(0, 0, -1); + else if (t === Vr) n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), i.up.set(0, -1, 0), i.lookAt(1, 0, 0), r.up.set(0, 0, 1), r.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), c.up.set(0, -1, 0), c.lookAt(0, 0, -1); + else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + t); + for (let l of e)this.add(l), l.updateMatrixWorld(); + } + update(t, e) { this.parent === null && this.updateMatrixWorld(); - let n = this.renderTarget, [i, r, o, a, l, c] = this.children, h = e.xr.enabled, u = e.getRenderTarget(); - e.xr.enabled = !1; + let n = this.renderTarget; + this.coordinateSystem !== t.coordinateSystem && (this.coordinateSystem = t.coordinateSystem, this.updateCoordinateSystem()); + let [i, r, a, o, c, l] = this.children, h = t.getRenderTarget(), u = t.xr.enabled; + t.xr.enabled = !1; let d = n.texture.generateMipmaps; - n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0), e.render(t, i), e.setRenderTarget(n, 1), e.render(t, r), e.setRenderTarget(n, 2), e.render(t, o), e.setRenderTarget(n, 3), e.render(t, a), e.setRenderTarget(n, 4), e.render(t, l), n.texture.generateMipmaps = d, e.setRenderTarget(n, 5), e.render(t, c), e.setRenderTarget(u), e.xr.enabled = h; + n.texture.generateMipmaps = !1, t.setRenderTarget(n, 0), t.render(e, i), t.setRenderTarget(n, 1), t.render(e, r), t.setRenderTarget(n, 2), t.render(e, a), t.setRenderTarget(n, 3), t.render(e, o), t.setRenderTarget(n, 4), t.render(e, c), n.texture.generateMipmaps = d, t.setRenderTarget(n, 5), t.render(e, l), t.setRenderTarget(h), t.xr.enabled = u, n.texture.needsPMREMUpdate = !0; } -}, ki = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h){ - e = e !== void 0 ? e : [], t = t !== void 0 ? t : Bi; - super(e, t, n, i, r, o, a, l, c, h); - this.flipY = !1; +}, Ki = class extends ye { + constructor(t, e, n, i, r, a, o, c, l, h){ + t = t !== void 0 ? t : [], e = e !== void 0 ? e : Bn, super(t, e, n, i, r, a, o, c, l, h), this.isCubeTexture = !0, this.flipY = !1; } get images() { return this.image; } - set images(e) { - this.image = e; + set images(t) { + this.image = t; } -}; -ki.prototype.isCubeTexture = !0; -var js = class extends At { - constructor(e, t, n){ - Number.isInteger(t) && (console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"), t = n); - super(e, e, t); - t = t || {}, this.texture = new ki(void 0, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.encoding), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : tt, this.texture._needsFlipEnvMap = !1; - } - fromEquirectangularTexture(e, t) { - this.texture.type = t.type, this.texture.format = ct, this.texture.encoding = t.encoding, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; +}, fo = class extends Ge { + constructor(t = 1, e = {}){ + super(t, t, e), this.isWebGLCubeRenderTarget = !0; + let n = { + width: t, + height: t, + depth: 1 + }, i = [ + n, + n, + n, + n, + n, + n + ]; + e.encoding !== void 0 && (Ms("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."), e.colorSpace = e.encoding === si ? Nt : ri), this.texture = new Ki(i, e.mapping, e.wrapS, e.wrapT, e.magFilter, e.minFilter, e.format, e.type, e.anisotropy, e.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = e.generateMipmaps !== void 0 ? e.generateMipmaps : !1, this.texture.minFilter = e.minFilter !== void 0 ? e.minFilter : pe; + } + 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: { @@ -3637,340 +4128,318 @@ var js = class extends At { } ` - }, i = new wn(5, 5, 5), r = new sn({ + }, i = new Ji(5, 5, 5), r = new Qe({ name: "CubemapFromEquirect", - uniforms: Ri(n.uniforms), + uniforms: $i(n.uniforms), vertexShader: n.vertexShader, fragmentShader: n.fragmentShader, - side: it, - blending: vn + side: De, + blending: Un }); - r.uniforms.tEquirect.value = t; - let o = new st(i, r), a = t.minFilter; - return t.minFilter === Ui && (t.minFilter = tt), new $s(1, 10, this).update(e, o), t.minFilter = a, o.geometry.dispose(), o.material.dispose(), this; + r.uniforms.tEquirect.value = e; + let a = new ve(i, r), o = e.minFilter; + return e.minFilter === li && (e.minFilter = pe), new uo(1, 10, this).update(t, a), e.minFilter = o, a.geometry.dispose(), a.material.dispose(), this; } - clear(e, t, n, i) { - let r = e.getRenderTarget(); - for(let o = 0; o < 6; o++)e.setRenderTarget(this, o), e.clear(t, n, i); - e.setRenderTarget(r); + clear(t, e, n, i) { + let r = t.getRenderTarget(); + for(let a = 0; a < 6; a++)t.setRenderTarget(this, a), t.clear(e, n, i); + t.setRenderTarget(r); } -}; -js.prototype.isWebGLCubeRenderTarget = !0; -var ko = new M, pf = new M, mf = new lt, Wt = class { - constructor(e = new M(1, 0, 0), t = 0){ - this.normal = e, this.constant = t; +}, Wa = new A, xp = new A, vp = new kt, mn = class { + constructor(t = new A(1, 0, 0), e = 0){ + this.isPlane = !0, this.normal = t, this.constant = e; } - set(e, t) { - return this.normal.copy(e), this.constant = t, this; + set(t, e) { + return this.normal.copy(t), this.constant = e, this; } - setComponents(e, t, n, i) { - return this.normal.set(e, t, n), this.constant = i, this; + setComponents(t, e, n, i) { + return this.normal.set(t, e, n), this.constant = i, this; } - setFromNormalAndCoplanarPoint(e, t) { - return this.normal.copy(e), this.constant = -t.dot(this.normal), this; + setFromNormalAndCoplanarPoint(t, e) { + return this.normal.copy(t), this.constant = -e.dot(this.normal), this; } - setFromCoplanarPoints(e, t, n) { - let i = ko.subVectors(n, t).cross(pf.subVectors(e, t)).normalize(); - return this.setFromNormalAndCoplanarPoint(i, e), this; + setFromCoplanarPoints(t, e, n) { + let i = Wa.subVectors(n, e).cross(xp.subVectors(t, e)).normalize(); + return this.setFromNormalAndCoplanarPoint(i, t), this; } - copy(e) { - return this.normal.copy(e.normal), this.constant = e.constant, this; + copy(t) { + return this.normal.copy(t.normal), this.constant = t.constant, this; } normalize() { - let e = 1 / this.normal.length(); - return this.normal.multiplyScalar(e), this.constant *= e, this; + let t = 1 / this.normal.length(); + return this.normal.multiplyScalar(t), this.constant *= t, this; } negate() { return this.constant *= -1, this.normal.negate(), this; } - distanceToPoint(e) { - return this.normal.dot(e) + this.constant; + distanceToPoint(t) { + return this.normal.dot(t) + this.constant; } - distanceToSphere(e) { - return this.distanceToPoint(e.center) - e.radius; + distanceToSphere(t) { + return this.distanceToPoint(t.center) - t.radius; } - projectPoint(e, t) { - return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e); + projectPoint(t, e) { + return e.copy(t).addScaledVector(this.normal, -this.distanceToPoint(t)); } - intersectLine(e, t) { - let n = e.delta(ko), i = this.normal.dot(n); - if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; - let r = -(e.start.dot(this.normal) + this.constant) / i; - return r < 0 || r > 1 ? null : t.copy(n).multiplyScalar(r).add(e.start); + intersectLine(t, e) { + let n = t.delta(Wa), i = this.normal.dot(n); + if (i === 0) return this.distanceToPoint(t.start) === 0 ? e.copy(t.start) : null; + let r = -(t.start.dot(this.normal) + this.constant) / i; + return r < 0 || r > 1 ? null : e.copy(t.start).addScaledVector(n, r); } - intersectsLine(e) { - let t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); - return t < 0 && n > 0 || n < 0 && t > 0; + intersectsLine(t) { + let e = this.distanceToPoint(t.start), n = this.distanceToPoint(t.end); + return e < 0 && n > 0 || n < 0 && e > 0; } - intersectsBox(e) { - return e.intersectsPlane(this); + intersectsBox(t) { + return t.intersectsPlane(this); } - intersectsSphere(e) { - return e.intersectsPlane(this); + intersectsSphere(t) { + return t.intersectsPlane(this); } - coplanarPoint(e) { - return e.copy(this.normal).multiplyScalar(-this.constant); + coplanarPoint(t) { + return t.copy(this.normal).multiplyScalar(-this.constant); } - applyMatrix4(e, t) { - let n = t || mf.getNormalMatrix(e), i = this.coplanarPoint(ko).applyMatrix4(e), r = this.normal.applyMatrix3(n).normalize(); + applyMatrix4(t, e) { + let n = e || vp.getNormalMatrix(t), i = this.coplanarPoint(Wa).applyMatrix4(t), r = this.normal.applyMatrix3(n).normalize(); return this.constant = -i.dot(r), this; } - translate(e) { - return this.constant -= e.dot(this.normal), this; + translate(t) { + return this.constant -= t.dot(this.normal), this; } - equals(e) { - return e.normal.equals(this.normal) && e.constant === this.constant; + equals(t) { + return t.normal.equals(this.normal) && t.constant === this.constant; } clone() { return new this.constructor().copy(this); } -}; -Wt.prototype.isPlane = !0; -var fi = new An, as = new M, Dr = class { - constructor(e = new Wt, t = new Wt, n = new Wt, i = new Wt, r = new Wt, o = new Wt){ +}, qn = new We, cr = new A, Ps = class { + constructor(t = new mn, e = new mn, n = new mn, i = new mn, r = new mn, a = new mn){ this.planes = [ - e, t, + e, n, i, r, - o + a ]; } - set(e, t, n, i, r, o) { - let a = this.planes; - return a[0].copy(e), a[1].copy(t), a[2].copy(n), a[3].copy(i), a[4].copy(r), a[5].copy(o), this; + set(t, e, n, i, r, a) { + let o = this.planes; + return o[0].copy(t), o[1].copy(e), o[2].copy(n), o[3].copy(i), o[4].copy(r), o[5].copy(a), this; } - copy(e) { - let t = this.planes; - for(let n = 0; n < 6; n++)t[n].copy(e.planes[n]); + copy(t) { + let e = this.planes; + for(let n = 0; n < 6; n++)e[n].copy(t.planes[n]); return this; } - setFromProjectionMatrix(e) { - let t = this.planes, n = e.elements, i = n[0], r = n[1], o = n[2], a = n[3], l = n[4], c = n[5], h = n[6], u = n[7], d = n[8], f = n[9], m = n[10], x = n[11], v = n[12], g = n[13], p = n[14], _ = n[15]; - return t[0].setComponents(a - i, u - l, x - d, _ - v).normalize(), t[1].setComponents(a + i, u + l, x + d, _ + v).normalize(), t[2].setComponents(a + r, u + c, x + f, _ + g).normalize(), t[3].setComponents(a - r, u - c, x - f, _ - g).normalize(), t[4].setComponents(a - o, u - h, x - m, _ - p).normalize(), t[5].setComponents(a + o, u + h, x + m, _ + p).normalize(), this; + setFromProjectionMatrix(t, e = vn) { + let n = this.planes, i = t.elements, r = i[0], a = i[1], o = i[2], c = i[3], l = i[4], h = i[5], u = i[6], d = i[7], f = i[8], m = i[9], x = i[10], g = i[11], p = i[12], v = i[13], _ = i[14], y = i[15]; + if (n[0].setComponents(c - r, d - l, g - f, y - p).normalize(), n[1].setComponents(c + r, d + l, g + f, y + p).normalize(), n[2].setComponents(c + a, d + h, g + m, y + v).normalize(), n[3].setComponents(c - a, d - h, g - m, y - v).normalize(), n[4].setComponents(c - o, d - u, g - x, y - _).normalize(), e === vn) n[5].setComponents(c + o, d + u, g + x, y + _).normalize(); + else if (e === Vr) n[5].setComponents(o, u, x, _).normalize(); + else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + e); + return this; } - intersectsObject(e) { - let t = e.geometry; - return t.boundingSphere === null && t.computeBoundingSphere(), fi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); + intersectsObject(t) { + if (t.boundingSphere !== void 0) t.boundingSphere === null && t.computeBoundingSphere(), qn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld); + else { + let e = t.geometry; + e.boundingSphere === null && e.computeBoundingSphere(), qn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld); + } + return this.intersectsSphere(qn); } - intersectsSprite(e) { - return fi.center.set(0, 0, 0), fi.radius = .7071067811865476, fi.applyMatrix4(e.matrixWorld), this.intersectsSphere(fi); + intersectsSprite(t) { + return qn.center.set(0, 0, 0), qn.radius = .7071067811865476, qn.applyMatrix4(t.matrixWorld), this.intersectsSphere(qn); } - intersectsSphere(e) { - let t = this.planes, n = e.center, i = -e.radius; - for(let r = 0; r < 6; r++)if (t[r].distanceToPoint(n) < i) return !1; + intersectsSphere(t) { + let e = this.planes, n = t.center, i = -t.radius; + for(let r = 0; r < 6; r++)if (e[r].distanceToPoint(n) < i) return !1; return !0; } - intersectsBox(e) { - let t = this.planes; + intersectsBox(t) { + let e = this.planes; for(let n = 0; n < 6; n++){ - let i = t[n]; - if (as.x = i.normal.x > 0 ? e.max.x : e.min.x, as.y = i.normal.y > 0 ? e.max.y : e.min.y, as.z = i.normal.z > 0 ? e.max.z : e.min.z, i.distanceToPoint(as) < 0) return !1; + let i = e[n]; + if (cr.x = i.normal.x > 0 ? t.max.x : t.min.x, cr.y = i.normal.y > 0 ? t.max.y : t.min.y, cr.z = i.normal.z > 0 ? t.max.z : t.min.z, i.distanceToPoint(cr) < 0) return !1; } return !0; } - containsPoint(e) { - let t = this.planes; - for(let n = 0; n < 6; n++)if (t[n].distanceToPoint(e) < 0) return !1; + 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); } }; -function rh() { - let s = null, e = !1, t = null, n = null; - function i(r, o) { - t(r, o), n = s.requestAnimationFrame(i); +function vd() { + let s1 = null, t = !1, e = null, n = null; + function i(r, a) { + e(r, a), n = s1.requestAnimationFrame(i); } return { start: function() { - e !== !0 && t !== null && (n = s.requestAnimationFrame(i), e = !0); + t !== !0 && e !== null && (n = s1.requestAnimationFrame(i), t = !0); }, stop: function() { - s.cancelAnimationFrame(n), e = !1; + s1.cancelAnimationFrame(n), t = !1; }, setAnimationLoop: function(r) { - t = r; + e = r; }, setContext: function(r) { - s = r; + s1 = r; } }; } -function gf(s, e) { - let t = e.isWebGL2, n = new WeakMap; - function i(c, h) { - let u = c.array, d = c.usage, f = s.createBuffer(); - s.bindBuffer(h, f), s.bufferData(h, u, d), c.onUploadCallback(); - let m = 5126; - return u instanceof Float32Array ? m = 5126 : u instanceof Float64Array ? console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.") : u instanceof Uint16Array ? c.isFloat16BufferAttribute ? t ? m = 5131 : console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.") : m = 5123 : u instanceof Int16Array ? m = 5122 : u instanceof Uint32Array ? m = 5125 : u instanceof Int32Array ? m = 5124 : u instanceof Int8Array ? m = 5120 : (u instanceof Uint8Array || u instanceof Uint8ClampedArray) && (m = 5121), { +function yp(s1, t) { + let e = t.isWebGL2, n = new WeakMap; + function i(l, h) { + let u = l.array, d = l.usage, f = s1.createBuffer(); + s1.bindBuffer(h, f), s1.bufferData(h, u, d), l.onUploadCallback(); + let m; + if (u instanceof Float32Array) m = s1.FLOAT; + else if (u instanceof Uint16Array) if (l.isFloat16BufferAttribute) if (e) m = s1.HALF_FLOAT; + else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."); + else m = s1.UNSIGNED_SHORT; + else if (u instanceof Int16Array) m = s1.SHORT; + else if (u instanceof Uint32Array) m = s1.UNSIGNED_INT; + else if (u instanceof Int32Array) m = s1.INT; + else if (u instanceof Int8Array) m = s1.BYTE; + else if (u instanceof Uint8Array) m = s1.UNSIGNED_BYTE; + else if (u instanceof Uint8ClampedArray) m = s1.UNSIGNED_BYTE; + else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + u); + return { buffer: f, type: m, bytesPerElement: u.BYTES_PER_ELEMENT, - version: c.version + version: l.version }; } - function r(c, h, u) { + function r(l, h, u) { let d = h.array, f = h.updateRange; - s.bindBuffer(u, c), f.count === -1 ? s.bufferSubData(u, 0, d) : (t ? s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d, f.offset, f.count) : s.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d.subarray(f.offset, f.offset + f.count)), f.count = -1); + s1.bindBuffer(u, l), f.count === -1 ? s1.bufferSubData(u, 0, d) : (e ? s1.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d, f.offset, f.count) : s1.bufferSubData(u, f.offset * d.BYTES_PER_ELEMENT, d.subarray(f.offset, f.offset + f.count)), f.count = -1), h.onUploadCallback(); } - function o(c) { - return c.isInterleavedBufferAttribute && (c = c.data), n.get(c); - } - function a(c) { - c.isInterleavedBufferAttribute && (c = c.data); - let h = n.get(c); - h && (s.deleteBuffer(h.buffer), n.delete(c)); - } - function l(c, h) { - if (c.isGLBufferAttribute) { - let d = n.get(c); - (!d || d.version < c.version) && n.set(c, { - buffer: c.buffer, - type: c.type, - bytesPerElement: c.elementSize, - version: c.version + function a(l) { + return l.isInterleavedBufferAttribute && (l = l.data), n.get(l); + } + function o(l) { + l.isInterleavedBufferAttribute && (l = l.data); + let h = n.get(l); + h && (s1.deleteBuffer(h.buffer), n.delete(l)); + } + function c(l, h) { + if (l.isGLBufferAttribute) { + let d = n.get(l); + (!d || d.version < l.version) && n.set(l, { + buffer: l.buffer, + type: l.type, + bytesPerElement: l.elementSize, + version: l.version }); return; } - c.isInterleavedBufferAttribute && (c = c.data); - let u = n.get(c); - u === void 0 ? n.set(c, i(c, h)) : u.version < c.version && (r(u.buffer, c, h), u.version = c.version); + l.isInterleavedBufferAttribute && (l = l.data); + let u = n.get(l); + u === void 0 ? n.set(l, i(l, h)) : u.version < l.version && (r(u.buffer, l, h), u.version = l.version); } return { - get: o, - remove: a, - update: l + get: a, + remove: o, + update: c }; } -var Pi = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 1){ - super(); - this.type = "PlaneGeometry", this.parameters = { - width: e, - height: t, +var Zr = class s1 extends Vt { + constructor(t = 1, e = 1, n = 1, i = 1){ + super(), this.type = "PlaneGeometry", this.parameters = { + width: t, + height: e, widthSegments: n, heightSegments: i }; - let r = e / 2, o = t / 2, a = Math.floor(n), l = Math.floor(i), c = a + 1, h = l + 1, u = e / a, d = t / l, f = [], m = [], x = [], v = []; - for(let g = 0; g < h; g++){ - let p = g * d - o; - for(let _ = 0; _ < c; _++){ + let r = t / 2, a = e / 2, o = Math.floor(n), c = Math.floor(i), l = o + 1, h = c + 1, u = t / o, d = e / c, f = [], m = [], x = [], g = []; + for(let p = 0; p < h; p++){ + let v = p * d - a; + for(let _ = 0; _ < l; _++){ let y = _ * u - r; - m.push(y, -p, 0), x.push(0, 0, 1), v.push(_ / a), v.push(1 - g / l); + m.push(y, -v, 0), x.push(0, 0, 1), g.push(_ / o), g.push(1 - p / c); } } - for(let g = 0; g < l; g++)for(let p = 0; p < a; p++){ - let _ = p + c * g, y = p + c * (g + 1), b = p + 1 + c * (g + 1), A = p + 1 + c * g; - f.push(_, y, A), f.push(y, b, A); + for(let p = 0; p < c; p++)for(let v = 0; v < o; v++){ + let _ = v + l * p, y = v + l * (p + 1), b = v + 1 + l * (p + 1), w = v + 1 + l * p; + f.push(_, y, w), f.push(y, b, w); } - this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); + this.setIndex(f), this.setAttribute("position", new _t(m, 3)), this.setAttribute("normal", new _t(x, 3)), this.setAttribute("uv", new _t(g, 2)); } - static fromJSON(e) { - return new Pi(e.width, e.height, e.widthSegments, e.heightSegments); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, xf = `#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, vUv ).g; -#endif`, yf = `#ifdef USE_ALPHAMAP + static fromJSON(t) { + return new s1(t.width, t.height, t.widthSegments, t.heightSegments); + } +}, Mp = `#ifdef USE_ALPHAHASH + if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; +#endif`, Sp = `#ifdef USE_ALPHAHASH + const float ALPHA_HASH_SCALE = 0.05; + float hash2D( vec2 value ) { + return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); + } + float hash3D( vec3 value ) { + return hash2D( vec2( hash2D( value.xy ), value.z ) ); + } + float getAlphaHashThreshold( vec3 position ) { + float maxDeriv = max( + length( dFdx( position.xyz ) ), + length( dFdy( position.xyz ) ) + ); + float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); + vec2 pixScales = vec2( + exp2( floor( log2( pixScale ) ) ), + exp2( ceil( log2( pixScale ) ) ) + ); + vec2 alpha = vec2( + hash3D( floor( pixScales.x * position.xyz ) ), + hash3D( floor( pixScales.y * position.xyz ) ) + ); + float lerpFactor = fract( log2( pixScale ) ); + float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; + float a = min( lerpFactor, 1.0 - lerpFactor ); + vec3 cases = vec3( + x * x / ( 2.0 * a * ( 1.0 - a ) ), + ( x - 0.5 * a ) / ( 1.0 - a ), + 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) + ); + float threshold = ( x < ( 1.0 - a ) ) + ? ( ( x < a ) ? cases.x : cases.y ) + : cases.z; + return clamp( threshold , 1.0e-6, 1.0 ); + } +#endif`, bp = `#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; +#endif`, Ep = `#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`, vf = `#ifdef USE_ALPHATEST +#endif`, Tp = `#ifdef USE_ALPHATEST if ( diffuseColor.a < alphaTest ) discard; -#endif`, _f = `#ifdef USE_ALPHATEST +#endif`, wp = `#ifdef USE_ALPHATEST uniform float alphaTest; -#endif`, Mf = `#ifdef USE_AOMAP - float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; +#endif`, Ap = `#ifdef USE_AOMAP + float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_ENVMAP ) && defined( STANDARD ) float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif -#endif`, bf = `#ifdef USE_AOMAP +#endif`, Rp = `#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; -#endif`, wf = "vec3 transformed = vec3( position );", Sf = `vec3 objectNormal = vec3( normal ); +#endif`, Cp = `vec3 transformed = vec3( position ); +#ifdef USE_ALPHAHASH + vPosition = vec3( position ); +#endif`, Pp = `vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); -#endif`, Tf = `vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) { - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -float G_BlinnPhong_Implicit( ) { +#endif`, Lp = `float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { @@ -3984,41 +4453,83 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif`, Ef = `#ifdef USE_BUMPMAP +} // validated`, Ip = `#ifdef USE_IRIDESCENCE + const mat3 XYZ_TO_REC709 = mat3( + 3.2404542, -0.9692660, 0.0556434, + -1.5371385, 1.8760108, -0.2040259, + -0.4985314, 0.0415560, 1.0572252 + ); + vec3 Fresnel0ToIor( vec3 fresnel0 ) { + vec3 sqrtF0 = sqrt( fresnel0 ); + return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); + } + vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); + } + float IorToFresnel0( float transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); + } + vec3 evalSensitivity( float OPD, vec3 shift ) { + float phase = 2.0 * PI * OPD * 1.0e-9; + vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); + vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); + vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); + vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); + xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); + xyz /= 1.0685e-7; + vec3 rgb = XYZ_TO_REC709 * xyz; + return rgb; + } + vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { + vec3 I; + float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); + float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); + float cosTheta2Sq = 1.0 - sinTheta2Sq; + if ( cosTheta2Sq < 0.0 ) { + return vec3( 1.0 ); + } + float cosTheta2 = sqrt( cosTheta2Sq ); + float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); + float R12 = F_Schlick( R0, 1.0, cosTheta1 ); + float T121 = 1.0 - R12; + float phi12 = 0.0; + if ( iridescenceIOR < outsideIOR ) phi12 = PI; + float phi21 = PI - phi12; + vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); + vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); + vec3 phi23 = vec3( 0.0 ); + if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; + if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; + if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; + float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; + vec3 phi = vec3( phi21 ) + phi23; + vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); + vec3 r123 = sqrt( R123 ); + vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); + vec3 C0 = R12 + Rs; + I = C0; + vec3 Cm = Rs - T121; + for ( int m = 1; m <= 2; ++ m ) { + Cm *= r123; + vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); + I += Cm * Sm; + } + return max( I, vec3( 0.0 ) ); + } +#endif`, Up = `#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { - vec2 dSTdx = dFdx( vUv ); - vec2 dSTdy = dFdy( vUv ); - float Hll = bumpScale * texture2D( bumpMap, vUv ).x; - float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; - float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; + vec2 dSTdx = dFdx( vBumpMapUv ); + vec2 dSTdy = dFdy( vBumpMapUv ); + float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; + float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; + float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { - vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); - vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); + vec3 vSigmaX = dFdx( surf_pos.xyz ); + vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); @@ -4026,7 +4537,7 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } -#endif`, Af = `#if NUM_CLIPPING_PLANES > 0 +#endif`, Dp = `#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { @@ -4044,26 +4555,26 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no #pragma unroll_loop_end if ( clipped ) discard; #endif -#endif`, Cf = `#if NUM_CLIPPING_PLANES > 0 +#endif`, Np = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`, Lf = `#if NUM_CLIPPING_PLANES > 0 +#endif`, Fp = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`, Rf = `#if NUM_CLIPPING_PLANES > 0 +#endif`, Op = `#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`, Pf = `#if defined( USE_COLOR_ALPHA ) +#endif`, Bp = `#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; -#endif`, If = `#if defined( USE_COLOR_ALPHA ) +#endif`, zp = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; -#endif`, Df = `#if defined( USE_COLOR_ALPHA ) +#endif`, kp = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; -#endif`, Ff = `#if defined( USE_COLOR_ALPHA ) +#endif`, Vp = `#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); @@ -4073,7 +4584,7 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; -#endif`, Nf = `#define PI 3.141592653589793 +#endif`, Hp = `#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -4084,10 +4595,11 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); @@ -4120,6 +4632,9 @@ struct GeometricContext { vec3 clearcoatNormal; #endif }; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } @@ -4133,9 +4648,9 @@ mat3 transposeMat3( const in mat3 m ) { tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } -float linearToRelativeLuminance( const in vec3 color ) { - vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); - return dot( weights, color.rgb ); +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; @@ -4144,10 +4659,19 @@ vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); -}`, Bf = `#ifdef ENVMAP_TYPE_CUBE_UV - #define cubeUV_maxMipLevel 8.0 +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`, Gp = `#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 - #define cubeUV_maxTileSize 256.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); @@ -4187,52 +4711,53 @@ vec2 equirectUv( in vec3 dir ) { float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); - float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); - vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5; + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; - if ( mipInt < cubeUV_maxMipLevel ) { - uv.y += 2.0 * cubeUV_maxTileSize; - } - uv.y += filterInt * 2.0 * cubeUV_minTileSize; - uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); - uv *= texelSize; - return texture2D( envMap, uv ).rgb; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif } - #define r0 1.0 - #define v0 0.339 - #define m0 - 2.0 - #define r1 0.8 - #define v1 0.276 - #define m1 - 1.0 - #define r4 0.4 - #define v4 0.046 - #define m4 2.0 - #define r5 0.305 - #define v5 0.016 - #define m5 3.0 - #define r6 0.21 - #define v6 0.0038 - #define m6 4.0 + #define cubeUV_r0 1.0 + #define cubeUV_v0 0.339 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_v1 0.276 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_v4 0.046 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_v5 0.016 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_v6 0.0038 + #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; - if ( roughness >= r1 ) { - mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; - } else if ( roughness >= r4 ) { - mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; - } else if ( roughness >= r5 ) { - mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; - } else if ( roughness >= r6 ) { - mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { - float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); @@ -4243,7 +4768,7 @@ vec2 equirectUv( in vec3 dir ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`, zf = `vec3 transformedNormal = objectNormal; +#endif`, Wp = `vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); @@ -4258,27 +4783,23 @@ transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif -#endif`, Uf = `#ifdef USE_DISPLACEMENTMAP +#endif`, Xp = `#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`, Of = `#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); -#endif`, Hf = `#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vUv ); - emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; +#endif`, qp = `#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`, Yp = `#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; -#endif`, kf = `#ifdef USE_EMISSIVEMAP +#endif`, Zp = `#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`, Gf = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Vf = `vec4 LinearToLinear( in vec4 value ) { +#endif`, Jp = "gl_FragColor = linearToOutputTexel( gl_FragColor );", $p = `vec4 LinearToLinear( in vec4 value ) { return value; } -vec4 sRGBToLinear( in vec4 value ) { - return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); -} vec4 LinearTosRGB( 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 ); -}`, Wf = `#ifdef USE_ENVMAP +}`, Kp = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -4297,9 +4818,6 @@ vec4 LinearTosRGB( in vec4 value ) { #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); - envColor = envMapTexelToLinear( envColor ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); #else vec4 envColor = vec4( 0.0 ); #endif @@ -4310,7 +4828,7 @@ vec4 LinearTosRGB( in vec4 value ) { #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif -#endif`, qf = `#ifdef USE_ENVMAP +#endif`, Qp = `#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE @@ -4319,9 +4837,9 @@ vec4 LinearTosRGB( in vec4 value ) { uniform sampler2D envMap; #endif -#endif`, Xf = `#ifdef USE_ENVMAP +#endif`, jp = `#ifdef USE_ENVMAP uniform float reflectivity; - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS @@ -4330,8 +4848,8 @@ vec4 LinearTosRGB( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`, Jf = `#ifdef USE_ENVMAP - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) +#endif`, tm = `#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS @@ -4341,7 +4859,7 @@ vec4 LinearTosRGB( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`, Yf = `#ifdef USE_ENVMAP +#endif`, em = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -4358,18 +4876,18 @@ vec4 LinearTosRGB( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`, Zf = `#ifdef USE_FOG +#endif`, nm = `#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`, $f = `#ifdef USE_FOG +#endif`, im = `#ifdef USE_FOG varying float vFogDepth; -#endif`, jf = `#ifdef USE_FOG +#endif`, sm = `#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`, Qf = `#ifdef USE_FOG +#endif`, rm = `#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -4378,7 +4896,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`, Kf = `#ifdef USE_GRADIENTMAP +#endif`, am = `#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -4387,91 +4905,33 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else - return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); - #endif -}`, ep = `#ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vUv2 ); - vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; - #ifndef PHYSICALLY_CORRECT_LIGHTS - lightMapIrradiance *= PI; + 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 +}`, om = `#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; -#endif`, tp = `#ifdef USE_LIGHTMAP +#endif`, cm = `#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`, np = `vec3 diffuse = vec3( 1.0 ); -GeometricContext geometry; -geometry.position = mvPosition.xyz; -geometry.normal = normalize( transformedNormal ); -geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); -GeometricContext backGeometry; -backGeometry.position = geometry.position; -backGeometry.normal = -geometry.normal; -backGeometry.viewDir = geometry.viewDir; -vLightFront = vec3( 0.0 ); -vIndirectFront = vec3( 0.0 ); -#ifdef DOUBLE_SIDED - vLightBack = vec3( 0.0 ); - vIndirectBack = vec3( 0.0 ); -#endif -IncidentLight directLight; -float dotNL; -vec3 directLightColor_Diffuse; -vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); -vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); -#ifdef DOUBLE_SIDED - vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); - vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); -#endif -#if NUM_POINT_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - getPointLightInfo( pointLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_SPOT_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - getSpotLightInfo( spotLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_DIR_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); - dotNL = dot( geometry.normal, directLight.direction ); - directLightColor_Diffuse = directLight.color; - vLightFront += saturate( dotNL ) * directLightColor_Diffuse; - #ifdef DOUBLE_SIDED - vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; - #endif - } - #pragma unroll_loop_end -#endif -#if NUM_HEMI_LIGHTS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); - #ifdef DOUBLE_SIDED - vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); - #endif - } - #pragma unroll_loop_end -#endif`, ip = `uniform bool receiveShadow; +#endif`, lm = `LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`, hm = `varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`, um = `uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { @@ -4497,17 +4957,17 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - #if defined ( PHYSICALLY_CORRECT_LIGHTS ) + #if defined ( LEGACY_LIGHTS ) + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #else float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; - #else - if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { - return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); - } - return 1.0; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { @@ -4592,12 +5052,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } -#endif`, rp = `#if defined( USE_ENVMAP ) - #ifdef ENVMAP_MODE_REFRACTION - uniform float refractionRatio; - #endif +#endif`, dm = `#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { - #if defined( ENVMAP_TYPE_CUBE_UV ) + #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; @@ -4606,14 +5063,9 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #if defined( ENVMAP_TYPE_CUBE_UV ) - vec3 reflectVec; - #ifdef ENVMAP_MODE_REFLECTION - reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); - #else - reflectVec = refract( - viewDir, normal, refractionRatio ); - #endif + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; @@ -4621,8 +5073,20 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi return vec3( 0.0 ); #endif } -#endif`, sp = `ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`, op = `varying vec3 vViewPosition; + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`, fm = `ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`, pm = `varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -4634,12 +5098,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContex reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon -#define Material_LightProbeLOD( material ) (0)`, ap = `BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`, mm = `BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`, lp = `varying vec3 vViewPosition; +material.specularStrength = specularStrength;`, gm = `varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -4656,22 +5119,22 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in Geometric reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong -#define Material_LightProbeLOD( material ) (0)`, cp = `PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`, _m = `PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR - #ifdef SPECULAR + material.ior = ior; + #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULARINTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif - #ifdef USE_SPECULARCOLORMAP - specularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb; + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else @@ -4679,7 +5142,7 @@ material.roughness = min( material.roughness, 1.0 ); vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif - material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; @@ -4690,25 +5153,52 @@ material.roughness = min( material.roughness, 1.0 ); material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vUv ).x; + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif #ifdef USE_SHEEN material.sheenColor = sheenColor; - #ifdef USE_SHEENCOLORMAP - material.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); - #ifdef USE_SHEENROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; #endif -#endif`, hp = `struct PhysicalMaterial { + material.anisotropy = length( anisotropyV ); + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y; +#endif`, xm = `struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; @@ -4719,14 +5209,184 @@ material.roughness = min( material.roughness, 1.0 ); vec3 clearcoatF0; float clearcoatF90; #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) { +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; @@ -4747,12 +5407,21 @@ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif vec2 fab = DFGApprox( normal, viewDir, roughness ); - vec3 FssEss = specularColor * fab.x + specularF90 * fab.y; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; - vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } @@ -4789,12 +5458,12 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { @@ -4810,8 +5479,13 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); - vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; @@ -4822,7 +5496,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 ); -}`, up = ` +}`, vm = ` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; @@ -4830,6 +5504,18 @@ geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPositi #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometry.viewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; @@ -4842,7 +5528,7 @@ IncidentLight directLight; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } @@ -4850,6 +5536,9 @@ IncidentLight directLight; #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif @@ -4857,9 +5546,23 @@ IncidentLight directLight; for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } @@ -4876,7 +5579,7 @@ IncidentLight directLight; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } @@ -4906,13 +5609,10 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`, dp = `#if defined( RE_IndirectDiffuse ) +#endif`, ym = `#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vUv2 ); - vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; - #ifndef PHYSICALLY_CORRECT_LIGHTS - lightMapIrradiance *= PI; - #endif + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) @@ -4920,29 +5620,33 @@ IncidentLight directLight; #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif -#endif`, fp = `#if defined( RE_IndirectDiffuse ) +#endif`, Mm = `#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); -#endif`, pp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`, Sm = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`, mp = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`, bm = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`, gp = `#ifdef USE_LOGDEPTHBUF +#endif`, Em = `#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif -#endif`, xp = `#ifdef USE_LOGDEPTHBUF +#endif`, Tm = `#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); @@ -4952,40 +5656,54 @@ IncidentLight directLight; gl_Position.z *= gl_Position.w; } #endif -#endif`, yp = `#ifdef USE_MAP - vec4 texelColor = texture2D( map, vUv ); - texelColor = mapTexelToLinear( texelColor ); - diffuseColor *= texelColor; -#endif`, vp = `#ifdef USE_MAP +#endif`, wm = `#ifdef USE_MAP + diffuseColor *= texture2D( map, vMapUv ); +#endif`, Am = `#ifdef USE_MAP uniform sampler2D map; -#endif`, _p = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; +#endif`, Rm = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif #endif #ifdef USE_MAP - vec4 mapTexel = texture2D( map, uv ); - diffuseColor *= mapTexelToLinear( mapTexel ); + diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`, Mp = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - uniform mat3 uvTransform; +#endif`, Cm = `#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`, bp = `float metalnessFactor = metalness; +#endif`, Pm = `float metalnessFactor = metalness; #ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vUv ); + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`, wp = `#ifdef USE_METALNESSMAP +#endif`, Lm = `#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`, Sp = `#ifdef USE_MORPHNORMALS +#endif`, Im = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`, Um = `#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ]; + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; @@ -4993,18 +5711,18 @@ IncidentLight directLight; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif -#endif`, Tp = `#ifdef USE_MORPHTARGETS +#endif`, Dm = `#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; - uniform vec2 morphTargetsTextureSize; - vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) { - float texelIndex = float( vertexIndex * stride + offset ); - float y = floor( texelIndex / morphTargetsTextureSize.x ); - float x = texelIndex - y * morphTargetsTextureSize.x; - vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex ); - return texture( morphTargetsTexture, morphUV ).xyz; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS @@ -5013,15 +5731,11 @@ IncidentLight directLight; uniform float morphTargetInfluences[ 4 ]; #endif #endif -#endif`, Ep = `#ifdef USE_MORPHTARGETS +#endif`, Nm = `#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - #ifndef USE_MORPHNORMALS - if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ]; - #else - if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ]; - #endif + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; @@ -5035,30 +5749,49 @@ IncidentLight directLight; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif -#endif`, Ap = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`, Fm = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED - vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); - vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED - normal = normal * faceDirection; + normal *= faceDirection; #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT - vec3 tangent = normalize( vTangent ); - vec3 bitangent = normalize( vBitangent ); - #ifdef DOUBLE_SIDED - tangent = tangent * faceDirection; - bitangent = bitangent * faceDirection; - #endif - #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) - mat3 vTBN = mat3( tangent, bitangent, normal ); + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; #endif #endif -vec3 geometryNormal = normal;`, Cp = `#ifdef OBJECTSPACE_NORMALMAP - normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; +vec3 geometryNormal = normal;`, Om = `#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif @@ -5066,82 +5799,79 @@ vec3 geometryNormal = normal;`, Cp = `#ifdef OBJECTSPACE_NORMALMAP normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); -#elif defined( TANGENTSPACE_NORMALMAP ) - vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; - #ifdef USE_TANGENT - normal = normalize( vTBN * mapN ); - #else - normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); - #endif + normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`, Lp = `#ifndef FLAT_SHADED +#endif`, Bm = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`, Rp = `#ifndef FLAT_SHADED +#endif`, zm = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`, Pp = `#ifndef FLAT_SHADED +#endif`, km = `#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif -#endif`, Ip = `#ifdef USE_NORMALMAP +#endif`, Vm = `#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif -#ifdef OBJECTSPACE_NORMALMAP +#ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif -#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) - vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { - vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); - vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); - vec2 st0 = dFdx( vUv.st ); - vec2 st1 = dFdy( vUv.st ); +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); - float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); - return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); } -#endif`, Dp = `#ifdef USE_CLEARCOAT +#endif`, Hm = `#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; -#endif`, Fp = `#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; +#endif`, Gm = `#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; - #ifdef USE_TANGENT - clearcoatNormal = normalize( vTBN * clearcoatMapN ); - #else - clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); - #endif -#endif`, Np = `#ifdef USE_CLEARCOATMAP + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`, Wm = `#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform sampler2D clearcoatRoughnessMap; -#endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; -#endif`, Bp = `#ifdef OPAQUE +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`, Xm = `#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`, qm = `#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION -diffuseColor.a *= transmissionAlpha + 0.1; +diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, zp = `vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Ym = `vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -5158,6 +5888,12 @@ vec4 packDepthToRGBA( const in float v ) { float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); @@ -5168,37 +5904,43 @@ vec2 unpackRGBATo2Half( vec4 v ) { float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } -float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { - return linearClipZ * ( near - far ) - near; +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } -float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { - return ( near * far ) / ( ( far - near ) * invClipZ - far ); -}`, Up = `#ifdef PREMULTIPLIED_ALPHA +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`, Zm = `#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`, Op = `vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`, Jm = `vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`, $m = `#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`, kp = `#ifdef DITHERING +#endif`, Km = `#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`, Gp = `float roughnessFactor = roughness; +#endif`, Qm = `float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vUv ); + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`, Vp = `#ifdef USE_ROUGHNESSMAP +#endif`, jm = `#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`, Wp = `#ifdef USE_SHADOWMAP +#endif`, tg = `#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; @@ -5212,7 +5954,6 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; @@ -5255,10 +5996,8 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; - bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); - bool inFrustum = all( inFrustumVec ); - bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); - bool frustumTest = all( frustumTestVec ); + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; @@ -5301,22 +6040,22 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + - mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + - mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) @@ -5372,7 +6111,11 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } -#endif`, qp = `#ifdef USE_SHADOWMAP +#endif`, eg = `#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; @@ -5385,8 +6128,6 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; - varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; @@ -5408,36 +6149,39 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`, Xp = `#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 - vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - vec4 shadowWorldPosition; - #endif +#endif`, ng = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); - vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end - #endif -#endif`, Jp = `float getShadowMask() { +#endif`, ig = `float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 @@ -5454,7 +6198,7 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif @@ -5469,39 +6213,31 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING #endif #endif return shadow; -}`, Yp = `#ifdef USE_SKINNING +}`, sg = `#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`, Zp = `#ifdef USE_SKINNING +#endif`, rg = `#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; - #ifdef BONE_TEXTURE - uniform highp sampler2D boneTexture; - uniform int boneTextureSize; - mat4 getBoneMatrix( const in float i ) { - float j = i * 4.0; - float x = mod( j, float( boneTextureSize ) ); - float y = floor( j / float( boneTextureSize ) ); - float dx = 1.0 / float( boneTextureSize ); - float dy = 1.0 / float( boneTextureSize ); - y = dy * ( y + 0.5 ); - vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); - vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); - vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); - vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); - mat4 bone = mat4( v1, v2, v3, v4 ); - return bone; - } - #else - uniform mat4 boneMatrices[ MAX_BONES ]; - mat4 getBoneMatrix( const in float i ) { - mat4 bone = boneMatrices[ int(i) ]; - return bone; - } - #endif -#endif`, $p = `#ifdef USE_SKINNING + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + mat4 getBoneMatrix( const in float i ) { + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + y = dy * ( y + 0.5 ); + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + mat4 bone = mat4( v1, v2, v3, v4 ); + return bone; + } +#endif`, ag = `#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -5509,7 +6245,7 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`, jp = `#ifdef USE_SKINNING +#endif`, og = `#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -5520,22 +6256,22 @@ gl_Position = projectionMatrix * mvPosition;`, Hp = `#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`, Qp = `float specularStrength; +#endif`, cg = `float specularStrength; #ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vUv ); + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`, Kp = `#ifdef USE_SPECULARMAP +#endif`, lg = `#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`, em = `#if defined( TONE_MAPPING ) +#endif`, hg = `#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`, tm = `#ifndef saturate +#endif`, ug = `#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { - return toneMappingExposure * color; + return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; @@ -5566,26 +6302,28 @@ vec3 ACESFilmicToneMapping( vec3 color ) { color = ACESOutputMat * color; return saturate( color ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSMISSION - float transmissionAlpha = 1.0; - float transmissionFactor = transmission; - float thicknessFactor = thickness; +vec3 CustomToneMapping( vec3 color ) { return color; }`, dg = `#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP - transmissionFactor *= texture2D( transmissionMap, vUv ).r; + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP - thicknessFactor *= texture2D( thicknessMap, vUv ).g; + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); - vec4 transmission = getIBLVolumeRefraction( - n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor, - attenuationColor, attenuationDistance ); - totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor ); - transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor ); -#endif`, im = `#ifdef USE_TRANSMISSION + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`, fg = `#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -5601,7 +6339,57 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSM uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; - vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); @@ -5609,28 +6397,25 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSM modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } - float applyIorToRoughness( float roughness, float ior ) { + float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } - vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) { - float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); - #ifdef TEXTURE_LOD_EXT - return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); - #else - return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); - #endif + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } - vec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) { - if ( attenuationDistance == 0.0 ) { - return radiance; + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; - vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } - vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90, - vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, - vec3 attenuationColor, float attenuationDistance ) { + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); @@ -5638,79 +6423,327 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`, nm = `#ifdef USE_TRANSM refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); - vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); - return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`, rm = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) +#endif`, pg = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; -#endif`, sm = `#ifdef USE_UV - #ifdef UVS_VERTEX_ONLY - vec2 vUv; - #else - varying vec2 vUv; - #endif - uniform mat3 uvTransform; -#endif`, om = `#ifdef USE_UV - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; -#endif`, am = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - varying vec2 vUv2; -#endif`, lm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - attribute vec2 uv2; - varying vec2 vUv2; - uniform mat3 uv2Transform; -#endif`, cm = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) - vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; -#endif`, hm = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`, um = `varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`, dm = `uniform sampler2D t2D; -varying vec2 vUv; -void main() { - vec4 texColor = texture2D( t2D, vUv ); - gl_FragColor = mapTexelToLinear( texColor ); - #include - #include -}`, fm = `varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`, pm = `#include -uniform float opacity; -varying vec3 vWorldDirection; -#include -void main() { - vec3 vReflect = vWorldDirection; - #include - gl_FragColor = envColor; - gl_FragColor.a *= opacity; - #include - #include -}`, mm = `#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`, mg = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`, gg = `#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`, _g = `#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_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`, xg = `varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`, vg = `uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`, yg = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`, Mg = `#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`, Sg = `varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`, bg = `uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`, Eg = `#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include #include #endif #include @@ -5721,7 +6754,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`, gm = `#if DEPTH_PACKING == 3200 +}`, Tg = `#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -5730,6 +6763,7 @@ void main() { #include #include #include +#include #include #include varying vec2 vHighPrecisionZW; @@ -5742,6 +6776,7 @@ void main() { #include #include #include + #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 @@ -5749,7 +6784,7 @@ void main() { #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif -}`, xm = `#define DISTANCE +}`, wg = `#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -5773,7 +6808,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`, ym = `#define DISTANCE +}`, Ag = `#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -5784,6 +6819,7 @@ varying vec3 vWorldPosition; #include #include #include +#include #include void main () { #include @@ -5791,30 +6827,31 @@ void main () { #include #include #include + #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); -}`, vm = `varying vec3 vWorldDirection; +}`, Rg = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`, _m = `uniform sampler2D tEquirect; +}`, Cg = `uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); - vec4 texColor = texture2D( tEquirect, sampleUV ); - gl_FragColor = mapTexelToLinear( texColor ); + gl_FragColor = texture2D( tEquirect, sampleUV ); #include - #include -}`, Mm = `uniform float scale; + #include +}`, Pg = `uniform float scale; attribute float lineDistance; varying float vLineDistance; #include +#include #include #include #include @@ -5822,20 +6859,24 @@ varying float vLineDistance; #include void main() { vLineDistance = scale * lineDistance; + #include #include + #include #include #include #include #include #include #include -}`, bm = `uniform vec3 diffuse; +}`, Lg = `uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include +#include +#include #include #include #include @@ -5847,16 +6888,16 @@ void main() { vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include + #include #include outgoingLight = diffuseColor.rgb; - #include + #include #include - #include + #include #include #include -}`, wm = `#include +}`, Ig = `#include #include -#include #include #include #include @@ -5866,8 +6907,8 @@ void main() { #include void main() { #include - #include #include + #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include @@ -5884,7 +6925,7 @@ void main() { #include #include #include -}`, Sm = `uniform vec3 diffuse; +}`, Ug = `uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -5893,15 +6934,14 @@ uniform float opacity; #include #include #include -#include #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -5914,11 +6954,12 @@ void main() { #include #include #include + #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP - vec4 lightMapTexel= texture2D( lightMap, vUv2 ); - reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif @@ -5926,27 +6967,21 @@ void main() { reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include - #include + #include #include - #include + #include #include #include #include -}`, Tm = `#define LAMBERT -varying vec3 vLightFront; -varying vec3 vIndirectFront; -#ifdef DOUBLE_SIDED - varying vec3 vLightBack; - varying vec3 vIndirectBack; -#endif +}`, Dg = `#define LAMBERT +varying vec3 vViewPosition; #include #include -#include +#include #include -#include -#include #include #include +#include #include #include #include @@ -5954,53 +6989,52 @@ varying vec3 vIndirectFront; #include void main() { #include - #include #include + #include #include #include #include #include #include + #include #include #include #include + #include #include #include #include + vViewPosition = - mvPosition.xyz; #include #include - #include #include #include -}`, Em = `uniform vec3 diffuse; +}`, Ng = `#define LAMBERT +uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; -varying vec3 vLightFront; -varying vec3 vIndirectFront; -#ifdef DOUBLE_SIDED - varying vec3 vLightBack; - varying vec3 vIndirectBack; -#endif #include #include #include #include #include -#include #include #include #include +#include #include #include #include #include #include -#include +#include #include #include -#include +#include +#include #include -#include +#include +#include #include #include #include @@ -6014,31 +7048,25 @@ void main() { #include #include #include + #include #include + #include + #include #include - #ifdef DOUBLE_SIDED - reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; - #else - reflectedLight.indirectDiffuse += vIndirectFront; - #endif - #include - reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb ); - #ifdef DOUBLE_SIDED - reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; - #else - reflectedLight.directDiffuse = vLightFront; - #endif - reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask(); + #include + #include + #include + #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include - #include + #include #include - #include + #include #include #include #include -}`, Am = `#define MATCAP +}`, Fg = `#define MATCAP varying vec3 vViewPosition; #include #include @@ -6053,6 +7081,7 @@ varying vec3 vViewPosition; void main() { #include #include + #include #include #include #include @@ -6068,7 +7097,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`, Cm = `#define MATCAP +}`, Og = `#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -6080,6 +7109,7 @@ varying vec3 vViewPosition; #include #include #include +#include #include #include #include @@ -6094,6 +7124,7 @@ void main() { #include #include #include + #include #include #include vec3 viewDir = normalize( vViewPosition ); @@ -6102,19 +7133,18 @@ void main() { vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); - matcapColor = matcapTexelToLinear( matcapColor ); #else - vec4 matcapColor = vec4( 1.0 ); + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; - #include + #include #include - #include + #include #include #include #include -}`, Lm = `#define NORMAL -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) +}`, Bg = `#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include @@ -6140,12 +7170,12 @@ void main() { #include #include #include -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`, Rm = `#define NORMAL +}`, zg = `#define NORMAL uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include @@ -6161,11 +7191,13 @@ void main() { #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); -}`, Pm = `#define PHONG + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`, kg = `#define PHONG varying vec3 vViewPosition; #include #include -#include #include #include #include @@ -6178,8 +7210,8 @@ varying vec3 vViewPosition; #include void main() { #include - #include #include + #include #include #include #include @@ -6198,7 +7230,7 @@ void main() { #include #include #include -}`, Im = `#define PHONG +}`, Vg = `#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -6209,16 +7241,15 @@ uniform float opacity; #include #include #include -#include #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -6240,6 +7271,7 @@ void main() { #include #include #include + #include #include #include #include @@ -6251,20 +7283,19 @@ void main() { #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include - #include + #include #include - #include + #include #include #include #include -}`, Dm = `#define STANDARD +}`, Hg = `#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include -#include #include #include #include @@ -6276,8 +7307,8 @@ varying vec3 vViewPosition; #include void main() { #include - #include #include + #include #include #include #include @@ -6298,10 +7329,10 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`, Fm = `#define STANDARD +}`, Gg = `#define STANDARD #ifdef PHYSICAL #define IOR - #define SPECULAR + #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; @@ -6311,44 +7342,56 @@ uniform float opacity; #ifdef IOR uniform float ior; #endif -#ifdef SPECULAR +#ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; - #ifdef USE_SPECULARINTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif - #ifdef USE_SPECULARCOLORMAP + #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; - #ifdef USE_SHEENCOLORMAP + #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif - #ifdef USE_SHEENROUGHNESSMAP + #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif varying vec3 vViewPosition; #include #include #include #include #include -#include #include #include #include +#include #include #include #include -#include +#include #include #include #include @@ -6361,6 +7404,7 @@ varying vec3 vViewPosition; #include #include #include +#include #include #include #include @@ -6375,6 +7419,7 @@ void main() { #include #include #include + #include #include #include #include @@ -6400,17 +7445,16 @@ void main() { vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif - #include + #include #include - #include + #include #include #include #include -}`, Nm = `#define TOON +}`, Wg = `#define TOON varying vec3 vViewPosition; #include #include -#include #include #include #include @@ -6422,8 +7466,8 @@ varying vec3 vViewPosition; #include void main() { #include - #include #include + #include #include #include #include @@ -6441,7 +7485,7 @@ void main() { #include #include #include -}`, Bm = `#define TOON +}`, Xg = `#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -6450,10 +7494,10 @@ uniform float opacity; #include #include #include -#include #include #include #include +#include #include #include #include @@ -6478,6 +7522,7 @@ void main() { #include #include #include + #include #include #include #include @@ -6487,13 +7532,13 @@ void main() { #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include + #include #include - #include + #include #include #include #include -}`, zm = `uniform float size; +}`, qg = `uniform float size; uniform float scale; #include #include @@ -6501,8 +7546,16 @@ uniform float scale; #include #include #include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif #include + #include #include #include #include @@ -6515,12 +7568,13 @@ void main() { #include #include #include -}`, Um = `uniform vec3 diffuse; +}`, Yg = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include +#include #include #include #include @@ -6532,16 +7586,18 @@ void main() { #include #include #include + #include outgoingLight = diffuseColor.rgb; - #include + #include #include - #include + #include #include #include -}`, Om = `#include +}`, Zg = `#include #include #include #include +#include #include void main() { #include @@ -6553,24 +7609,27 @@ void main() { #include #include #include + #include #include #include #include -}`, Hm = `uniform vec3 color; +}`, Jg = `uniform vec3 color; uniform float opacity; #include #include #include #include #include +#include #include #include void main() { + #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include - #include + #include #include -}`, km = `uniform float rotation; +}`, $g = `uniform float rotation; uniform vec2 center; #include #include @@ -6596,13 +7655,14 @@ void main() { #include #include #include -}`, Gm = `uniform vec3 diffuse; +}`, Kg = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include +#include #include #include #include @@ -6614,150 +7674,156 @@ void main() { #include #include #include + #include outgoingLight = diffuseColor.rgb; - #include + #include #include - #include + #include #include -}`, Fe = { - alphamap_fragment: xf, - alphamap_pars_fragment: yf, - alphatest_fragment: vf, - alphatest_pars_fragment: _f, - aomap_fragment: Mf, - aomap_pars_fragment: bf, - begin_vertex: wf, - beginnormal_vertex: Sf, - bsdfs: Tf, - bumpmap_pars_fragment: Ef, - clipping_planes_fragment: Af, - clipping_planes_pars_fragment: Cf, - clipping_planes_pars_vertex: Lf, - clipping_planes_vertex: Rf, - color_fragment: Pf, - color_pars_fragment: If, - color_pars_vertex: Df, - color_vertex: Ff, - common: Nf, - cube_uv_reflection_fragment: Bf, - defaultnormal_vertex: zf, - displacementmap_pars_vertex: Uf, - displacementmap_vertex: Of, - emissivemap_fragment: Hf, - emissivemap_pars_fragment: kf, - encodings_fragment: Gf, - encodings_pars_fragment: Vf, - envmap_fragment: Wf, - envmap_common_pars_fragment: qf, - envmap_pars_fragment: Xf, - envmap_pars_vertex: Jf, - envmap_physical_pars_fragment: rp, - envmap_vertex: Yf, - fog_vertex: Zf, - fog_pars_vertex: $f, - fog_fragment: jf, - fog_pars_fragment: Qf, - gradientmap_pars_fragment: Kf, - lightmap_fragment: ep, - lightmap_pars_fragment: tp, - lights_lambert_vertex: np, - lights_pars_begin: ip, - lights_toon_fragment: sp, - lights_toon_pars_fragment: op, - lights_phong_fragment: ap, - lights_phong_pars_fragment: lp, - lights_physical_fragment: cp, - lights_physical_pars_fragment: hp, - lights_fragment_begin: up, - lights_fragment_maps: dp, - lights_fragment_end: fp, - logdepthbuf_fragment: pp, - logdepthbuf_pars_fragment: mp, - logdepthbuf_pars_vertex: gp, - logdepthbuf_vertex: xp, - map_fragment: yp, - map_pars_fragment: vp, - map_particle_fragment: _p, - map_particle_pars_fragment: Mp, - metalnessmap_fragment: bp, - metalnessmap_pars_fragment: wp, - morphnormal_vertex: Sp, - morphtarget_pars_vertex: Tp, - morphtarget_vertex: Ep, - normal_fragment_begin: Ap, - normal_fragment_maps: Cp, - normal_pars_fragment: Lp, - normal_pars_vertex: Rp, - normal_vertex: Pp, - normalmap_pars_fragment: Ip, - clearcoat_normal_fragment_begin: Dp, - clearcoat_normal_fragment_maps: Fp, - clearcoat_pars_fragment: Np, - output_fragment: Bp, - packing: zp, - premultiplied_alpha_fragment: Up, - project_vertex: Op, - dithering_fragment: Hp, - dithering_pars_fragment: kp, - roughnessmap_fragment: Gp, - roughnessmap_pars_fragment: Vp, - shadowmap_pars_fragment: Wp, - shadowmap_pars_vertex: qp, - shadowmap_vertex: Xp, - shadowmask_pars_fragment: Jp, - skinbase_vertex: Yp, - skinning_pars_vertex: Zp, - skinning_vertex: $p, - skinnormal_vertex: jp, - specularmap_fragment: Qp, - specularmap_pars_fragment: Kp, - tonemapping_fragment: em, - tonemapping_pars_fragment: tm, - transmission_fragment: nm, - transmission_pars_fragment: im, - uv_pars_fragment: rm, - uv_pars_vertex: sm, - uv_vertex: om, - uv2_pars_fragment: am, - uv2_pars_vertex: lm, - uv2_vertex: cm, - worldpos_vertex: hm, - background_vert: um, - background_frag: dm, - cube_vert: fm, - cube_frag: pm, - depth_vert: mm, - depth_frag: gm, - distanceRGBA_vert: xm, - distanceRGBA_frag: ym, - equirect_vert: vm, - equirect_frag: _m, - linedashed_vert: Mm, - linedashed_frag: bm, - meshbasic_vert: wm, - meshbasic_frag: Sm, - meshlambert_vert: Tm, - meshlambert_frag: Em, - meshmatcap_vert: Am, - meshmatcap_frag: Cm, - meshnormal_vert: Lm, - meshnormal_frag: Rm, - meshphong_vert: Pm, - meshphong_frag: Im, - meshphysical_vert: Dm, - meshphysical_frag: Fm, - meshtoon_vert: Nm, - meshtoon_frag: Bm, - points_vert: zm, - points_frag: Um, - shadow_vert: Om, - shadow_frag: Hm, - sprite_vert: km, - sprite_frag: Gm -}, ie = { +}`, zt = { + alphahash_fragment: Mp, + alphahash_pars_fragment: Sp, + alphamap_fragment: bp, + alphamap_pars_fragment: Ep, + alphatest_fragment: Tp, + alphatest_pars_fragment: wp, + aomap_fragment: Ap, + aomap_pars_fragment: Rp, + begin_vertex: Cp, + beginnormal_vertex: Pp, + bsdfs: Lp, + iridescence_fragment: Ip, + bumpmap_pars_fragment: Up, + clipping_planes_fragment: Dp, + clipping_planes_pars_fragment: Np, + clipping_planes_pars_vertex: Fp, + clipping_planes_vertex: Op, + color_fragment: Bp, + color_pars_fragment: zp, + color_pars_vertex: kp, + color_vertex: Vp, + common: Hp, + cube_uv_reflection_fragment: Gp, + defaultnormal_vertex: Wp, + displacementmap_pars_vertex: Xp, + displacementmap_vertex: qp, + emissivemap_fragment: Yp, + emissivemap_pars_fragment: Zp, + colorspace_fragment: Jp, + colorspace_pars_fragment: $p, + envmap_fragment: Kp, + envmap_common_pars_fragment: Qp, + envmap_pars_fragment: jp, + envmap_pars_vertex: tm, + envmap_physical_pars_fragment: dm, + envmap_vertex: em, + fog_vertex: nm, + fog_pars_vertex: im, + fog_fragment: sm, + fog_pars_fragment: rm, + gradientmap_pars_fragment: am, + lightmap_fragment: om, + lightmap_pars_fragment: cm, + lights_lambert_fragment: lm, + lights_lambert_pars_fragment: hm, + lights_pars_begin: um, + lights_toon_fragment: fm, + lights_toon_pars_fragment: pm, + lights_phong_fragment: mm, + lights_phong_pars_fragment: gm, + lights_physical_fragment: _m, + lights_physical_pars_fragment: xm, + lights_fragment_begin: vm, + lights_fragment_maps: ym, + lights_fragment_end: Mm, + logdepthbuf_fragment: Sm, + logdepthbuf_pars_fragment: bm, + logdepthbuf_pars_vertex: Em, + logdepthbuf_vertex: Tm, + map_fragment: wm, + map_pars_fragment: Am, + map_particle_fragment: Rm, + map_particle_pars_fragment: Cm, + metalnessmap_fragment: Pm, + metalnessmap_pars_fragment: Lm, + morphcolor_vertex: Im, + morphnormal_vertex: Um, + morphtarget_pars_vertex: Dm, + morphtarget_vertex: Nm, + normal_fragment_begin: Fm, + normal_fragment_maps: Om, + normal_pars_fragment: Bm, + normal_pars_vertex: zm, + normal_vertex: km, + normalmap_pars_fragment: Vm, + clearcoat_normal_fragment_begin: Hm, + clearcoat_normal_fragment_maps: Gm, + clearcoat_pars_fragment: Wm, + iridescence_pars_fragment: Xm, + opaque_fragment: qm, + packing: Ym, + premultiplied_alpha_fragment: Zm, + project_vertex: Jm, + dithering_fragment: $m, + dithering_pars_fragment: Km, + roughnessmap_fragment: Qm, + roughnessmap_pars_fragment: jm, + shadowmap_pars_fragment: tg, + shadowmap_pars_vertex: eg, + shadowmap_vertex: ng, + shadowmask_pars_fragment: ig, + skinbase_vertex: sg, + skinning_pars_vertex: rg, + skinning_vertex: ag, + skinnormal_vertex: og, + specularmap_fragment: cg, + specularmap_pars_fragment: lg, + tonemapping_fragment: hg, + tonemapping_pars_fragment: ug, + transmission_fragment: dg, + transmission_pars_fragment: fg, + uv_pars_fragment: pg, + uv_pars_vertex: mg, + uv_vertex: gg, + worldpos_vertex: _g, + background_vert: xg, + background_frag: vg, + backgroundCube_vert: yg, + backgroundCube_frag: Mg, + cube_vert: Sg, + cube_frag: bg, + depth_vert: Eg, + depth_frag: Tg, + distanceRGBA_vert: wg, + distanceRGBA_frag: Ag, + equirect_vert: Rg, + equirect_frag: Cg, + linedashed_vert: Pg, + linedashed_frag: Lg, + meshbasic_vert: Ig, + meshbasic_frag: Ug, + meshlambert_vert: Dg, + meshlambert_frag: Ng, + meshmatcap_vert: Fg, + meshmatcap_frag: Og, + meshnormal_vert: Bg, + meshnormal_frag: zg, + meshphong_vert: kg, + meshphong_frag: Vg, + meshphysical_vert: Hg, + meshphysical_frag: Gg, + meshtoon_vert: Wg, + meshtoon_frag: Xg, + points_vert: qg, + points_frag: Yg, + shadow_vert: Zg, + shadow_frag: Jg, + sprite_vert: $g, + sprite_frag: Kg +}, ct = { common: { diffuse: { - value: new ae(16777215) + value: new ft(16777215) }, opacity: { value: 1 @@ -6765,15 +7831,15 @@ void main() { map: { value: null }, - uvTransform: { - value: new lt - }, - uv2Transform: { - value: new lt + mapTransform: { + value: new kt }, alphaMap: { value: null }, + alphaMapTransform: { + value: new kt + }, alphaTest: { value: 0 } @@ -6781,6 +7847,9 @@ void main() { specularmap: { specularMap: { value: null + }, + specularMapTransform: { + value: new kt } }, envmap: { @@ -6806,6 +7875,9 @@ void main() { }, aoMapIntensity: { value: 1 + }, + aoMapTransform: { + value: new kt } }, lightmap: { @@ -6814,17 +7886,18 @@ void main() { }, lightMapIntensity: { value: 1 - } - }, - emissivemap: { - emissiveMap: { - value: null + }, + lightMapTransform: { + value: new kt } }, bumpmap: { bumpMap: { value: null }, + bumpMapTransform: { + value: new kt + }, bumpScale: { value: 1 } @@ -6833,14 +7906,20 @@ void main() { normalMap: { value: null }, + normalMapTransform: { + value: new kt + }, normalScale: { - value: new X(1, 1) + value: new J(1, 1) } }, displacementmap: { displacementMap: { value: null }, + displacementMapTransform: { + value: new kt + }, displacementScale: { value: 1 }, @@ -6848,14 +7927,28 @@ void main() { value: 0 } }, - roughnessmap: { - roughnessMap: { + emissivemap: { + emissiveMap: { value: null + }, + emissiveMapTransform: { + value: new kt } }, metalnessmap: { metalnessMap: { value: null + }, + metalnessMapTransform: { + value: new kt + } + }, + roughnessmap: { + roughnessMap: { + value: null + }, + roughnessMapTransform: { + value: new kt } }, gradientmap: { @@ -6874,7 +7967,7 @@ void main() { value: 2e3 }, fogColor: { - value: new ae(16777215) + value: new ft(16777215) } }, lights: { @@ -6927,10 +8020,13 @@ void main() { shadowMapSize: {} } }, + spotLightMap: { + value: [] + }, spotShadowMap: { value: [] }, - spotShadowMatrix: { + spotLightMatrix: { value: [] }, pointLights: { @@ -6985,7 +8081,7 @@ void main() { }, points: { diffuse: { - value: new ae(16777215) + value: new ft(16777215) }, opacity: { value: 1 @@ -7002,22 +8098,25 @@ void main() { alphaMap: { value: null }, + alphaMapTransform: { + value: new kt + }, alphaTest: { value: 0 }, uvTransform: { - value: new lt + value: new kt } }, sprite: { diffuse: { - value: new ae(16777215) + value: new ft(16777215) }, opacity: { value: 1 }, center: { - value: new X(.5, .5) + value: new J(.5, .5) }, rotation: { value: 0 @@ -7025,93 +8124,99 @@ void main() { map: { value: null }, + mapTransform: { + value: new kt + }, alphaMap: { value: null }, + alphaMapTransform: { + value: new kt + }, alphaTest: { value: 0 - }, - uvTransform: { - value: new lt } } -}, qt = { +}, en = { basic: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.fog + uniforms: Re([ + ct.common, + ct.specularmap, + ct.envmap, + ct.aomap, + ct.lightmap, + ct.fog ]), - vertexShader: Fe.meshbasic_vert, - fragmentShader: Fe.meshbasic_frag + vertexShader: zt.meshbasic_vert, + fragmentShader: zt.meshbasic_frag }, lambert: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.fog, - ie.lights, + uniforms: Re([ + ct.common, + ct.specularmap, + ct.envmap, + ct.aomap, + ct.lightmap, + ct.emissivemap, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, + ct.fog, + ct.lights, { emissive: { - value: new ae(0) + value: new ft(0) } } ]), - vertexShader: Fe.meshlambert_vert, - fragmentShader: Fe.meshlambert_frag + vertexShader: zt.meshlambert_vert, + fragmentShader: zt.meshlambert_frag }, phong: { - uniforms: yt([ - ie.common, - ie.specularmap, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.fog, - ie.lights, + uniforms: Re([ + ct.common, + ct.specularmap, + ct.envmap, + ct.aomap, + ct.lightmap, + ct.emissivemap, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, + ct.fog, + ct.lights, { emissive: { - value: new ae(0) + value: new ft(0) }, specular: { - value: new ae(1118481) + value: new ft(1118481) }, shininess: { value: 30 } } ]), - vertexShader: Fe.meshphong_vert, - fragmentShader: Fe.meshphong_frag + vertexShader: zt.meshphong_vert, + fragmentShader: zt.meshphong_frag }, standard: { - uniforms: yt([ - ie.common, - ie.envmap, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.roughnessmap, - ie.metalnessmap, - ie.fog, - ie.lights, + uniforms: Re([ + ct.common, + ct.envmap, + ct.aomap, + ct.lightmap, + ct.emissivemap, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, + ct.roughnessmap, + ct.metalnessmap, + ct.fog, + ct.lights, { emissive: { - value: new ae(0) + value: new ft(0) }, roughness: { value: 1 @@ -7124,58 +8229,58 @@ void main() { } } ]), - vertexShader: Fe.meshphysical_vert, - fragmentShader: Fe.meshphysical_frag + vertexShader: zt.meshphysical_vert, + fragmentShader: zt.meshphysical_frag }, toon: { - uniforms: yt([ - ie.common, - ie.aomap, - ie.lightmap, - ie.emissivemap, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.gradientmap, - ie.fog, - ie.lights, + uniforms: Re([ + ct.common, + ct.aomap, + ct.lightmap, + ct.emissivemap, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, + ct.gradientmap, + ct.fog, + ct.lights, { emissive: { - value: new ae(0) + value: new ft(0) } } ]), - vertexShader: Fe.meshtoon_vert, - fragmentShader: Fe.meshtoon_frag + vertexShader: zt.meshtoon_vert, + fragmentShader: zt.meshtoon_frag }, matcap: { - uniforms: yt([ - ie.common, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, - ie.fog, + uniforms: Re([ + ct.common, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, + ct.fog, { matcap: { value: null } } ]), - vertexShader: Fe.meshmatcap_vert, - fragmentShader: Fe.meshmatcap_frag + vertexShader: zt.meshmatcap_vert, + fragmentShader: zt.meshmatcap_frag }, points: { - uniforms: yt([ - ie.points, - ie.fog + uniforms: Re([ + ct.points, + ct.fog ]), - vertexShader: Fe.points_vert, - fragmentShader: Fe.points_frag + vertexShader: zt.points_vert, + fragmentShader: zt.points_frag }, dashed: { - uniforms: yt([ - ie.common, - ie.fog, + uniforms: Re([ + ct.common, + ct.fog, { scale: { value: 1 @@ -7188,63 +8293,87 @@ void main() { } } ]), - vertexShader: Fe.linedashed_vert, - fragmentShader: Fe.linedashed_frag + vertexShader: zt.linedashed_vert, + fragmentShader: zt.linedashed_frag }, depth: { - uniforms: yt([ - ie.common, - ie.displacementmap + uniforms: Re([ + ct.common, + ct.displacementmap ]), - vertexShader: Fe.depth_vert, - fragmentShader: Fe.depth_frag + vertexShader: zt.depth_vert, + fragmentShader: zt.depth_frag }, normal: { - uniforms: yt([ - ie.common, - ie.bumpmap, - ie.normalmap, - ie.displacementmap, + uniforms: Re([ + ct.common, + ct.bumpmap, + ct.normalmap, + ct.displacementmap, { opacity: { value: 1 } } ]), - vertexShader: Fe.meshnormal_vert, - fragmentShader: Fe.meshnormal_frag + vertexShader: zt.meshnormal_vert, + fragmentShader: zt.meshnormal_frag }, sprite: { - uniforms: yt([ - ie.sprite, - ie.fog + uniforms: Re([ + ct.sprite, + ct.fog ]), - vertexShader: Fe.sprite_vert, - fragmentShader: Fe.sprite_frag + vertexShader: zt.sprite_vert, + fragmentShader: zt.sprite_frag }, background: { uniforms: { uvTransform: { - value: new lt + value: new kt }, t2D: { value: null + }, + backgroundIntensity: { + value: 1 + } + }, + vertexShader: zt.background_vert, + fragmentShader: zt.background_frag + }, + backgroundCube: { + uniforms: { + envMap: { + value: null + }, + flipEnvMap: { + value: -1 + }, + backgroundBlurriness: { + value: 0 + }, + backgroundIntensity: { + value: 1 } }, - vertexShader: Fe.background_vert, - fragmentShader: Fe.background_frag + vertexShader: zt.backgroundCube_vert, + fragmentShader: zt.backgroundCube_frag }, cube: { - uniforms: yt([ - ie.envmap, - { - opacity: { - value: 1 - } + uniforms: { + tCube: { + value: null + }, + tFlip: { + value: -1 + }, + opacity: { + value: 1 } - ]), - vertexShader: Fe.cube_vert, - fragmentShader: Fe.cube_frag + }, + vertexShader: zt.cube_vert, + fragmentShader: zt.cube_frag }, equirect: { uniforms: { @@ -7252,16 +8381,16 @@ void main() { value: null } }, - vertexShader: Fe.equirect_vert, - fragmentShader: Fe.equirect_frag + vertexShader: zt.equirect_vert, + fragmentShader: zt.equirect_frag }, distanceRGBA: { - uniforms: yt([ - ie.common, - ie.displacementmap, + uniforms: Re([ + ct.common, + ct.displacementmap, { referencePosition: { - value: new M + value: new A }, nearDistance: { value: 1 @@ -7271,29 +8400,29 @@ void main() { } } ]), - vertexShader: Fe.distanceRGBA_vert, - fragmentShader: Fe.distanceRGBA_frag + vertexShader: zt.distanceRGBA_vert, + fragmentShader: zt.distanceRGBA_frag }, shadow: { - uniforms: yt([ - ie.lights, - ie.fog, + uniforms: Re([ + ct.lights, + ct.fog, { color: { - value: new ae(0) + value: new ft(0) }, opacity: { value: 1 } } ]), - vertexShader: Fe.shadow_vert, - fragmentShader: Fe.shadow_frag + vertexShader: zt.shadow_vert, + fragmentShader: zt.shadow_frag } }; -qt.physical = { - uniforms: yt([ - qt.standard.uniforms, +en.physical = { + uniforms: Re([ + en.standard.uniforms, { clearcoat: { value: 0 @@ -7301,41 +8430,83 @@ qt.physical = { clearcoatMap: { value: null }, - clearcoatRoughness: { - value: 0 + clearcoatMapTransform: { + value: new kt }, - clearcoatRoughnessMap: { + clearcoatNormalMap: { value: null }, + clearcoatNormalMapTransform: { + value: new kt + }, clearcoatNormalScale: { - value: new X(1, 1) + value: new J(1, 1) }, - clearcoatNormalMap: { + clearcoatRoughness: { + value: 0 + }, + clearcoatRoughnessMap: { + value: null + }, + clearcoatRoughnessMapTransform: { + value: new kt + }, + iridescence: { + value: 0 + }, + iridescenceMap: { + value: null + }, + iridescenceMapTransform: { + value: new kt + }, + iridescenceIOR: { + value: 1.3 + }, + iridescenceThicknessMinimum: { + value: 100 + }, + iridescenceThicknessMaximum: { + value: 400 + }, + iridescenceThicknessMap: { value: null }, + iridescenceThicknessMapTransform: { + value: new kt + }, sheen: { value: 0 }, sheenColor: { - value: new ae(0) + value: new ft(0) }, sheenColorMap: { value: null }, + sheenColorMapTransform: { + value: new kt + }, sheenRoughness: { - value: 0 + value: 1 }, sheenRoughnessMap: { value: null }, + sheenRoughnessMapTransform: { + value: new kt + }, transmission: { value: 0 }, transmissionMap: { value: null }, + transmissionMapTransform: { + value: new kt + }, transmissionSamplerSize: { - value: new X + value: new J }, transmissionSamplerMap: { value: null @@ -7346,404 +8517,439 @@ qt.physical = { thicknessMap: { value: null }, + thicknessMapTransform: { + value: new kt + }, attenuationDistance: { value: 0 }, attenuationColor: { - value: new ae(0) + value: new ft(0) + }, + specularColor: { + value: new ft(1, 1, 1) + }, + specularColorMap: { + value: null + }, + specularColorMapTransform: { + value: new kt }, specularIntensity: { - value: 0 + value: 1 }, specularIntensityMap: { value: null }, - specularColor: { - value: new ae(1, 1, 1) + specularIntensityMapTransform: { + value: new kt }, - specularColorMap: { + anisotropyVector: { + value: new J + }, + anisotropyMap: { value: null + }, + anisotropyMapTransform: { + value: new kt } } ]), - vertexShader: Fe.meshphysical_vert, - fragmentShader: Fe.meshphysical_frag + vertexShader: zt.meshphysical_vert, + fragmentShader: zt.meshphysical_frag }; -function Vm(s, e, t, n, i) { - let r = new ae(0), o = 0, a, l, c = null, h = 0, u = null; - function d(m, x) { - let v = !1, g = x.isScene === !0 ? x.background : null; - g && g.isTexture && (g = e.get(g)); - let p = s.xr, _ = p.getSession && p.getSession(); - _ && _.environmentBlendMode === "additive" && (g = null), g === null ? f(r, o) : g && g.isColor && (f(g, 1), v = !0), (s.autoClear || v) && s.clear(s.autoClearColor, s.autoClearDepth, s.autoClearStencil), g && (g.isCubeTexture || g.mapping === Pr) ? (l === void 0 && (l = new st(new wn(1, 1, 1), new sn({ +var lr = { + r: 0, + b: 0, + g: 0 +}; +function Qg(s1, t, e, n, i, r, a) { + let o = new ft(0), c = r === !0 ? 0 : 1, l, h, u = null, d = 0, f = null; + function m(g, p) { + let v = !1, _ = p.isScene === !0 ? p.background : null; + switch(_ && _.isTexture && (_ = (p.backgroundBlurriness > 0 ? e : t).get(_)), _ === null ? x(o, c) : _ && _.isColor && (x(_, 1), v = !0), s1.xr.getEnvironmentBlendMode()){ + case "opaque": + v = !0; + break; + case "additive": + n.buffers.color.setClear(0, 0, 0, 1, a), v = !0; + break; + case "alpha-blend": + n.buffers.color.setClear(0, 0, 0, 0, a), v = !0; + break; + } + (s1.autoClear || v) && s1.clear(s1.autoClearColor, s1.autoClearDepth, s1.autoClearStencil), _ && (_.isCubeTexture || _.mapping === Hs) ? (h === void 0 && (h = new ve(new Ji(1, 1, 1), new Qe({ name: "BackgroundCubeMaterial", - uniforms: Ri(qt.cube.uniforms), - vertexShader: qt.cube.vertexShader, - fragmentShader: qt.cube.fragmentShader, - side: it, + uniforms: $i(en.backgroundCube.uniforms), + vertexShader: en.backgroundCube.vertexShader, + fragmentShader: en.backgroundCube.fragmentShader, + side: De, depthTest: !1, depthWrite: !1, fog: !1 - })), l.geometry.deleteAttribute("normal"), l.geometry.deleteAttribute("uv"), l.onBeforeRender = function(y, b, A) { - this.matrixWorld.copyPosition(A.matrixWorld); - }, Object.defineProperty(l.material, "envMap", { + })), h.geometry.deleteAttribute("normal"), h.geometry.deleteAttribute("uv"), h.onBeforeRender = function(w, R, L) { + this.matrixWorld.copyPosition(L.matrixWorld); + }, Object.defineProperty(h.material, "envMap", { get: function() { return this.uniforms.envMap.value; } - }), n.update(l)), l.material.uniforms.envMap.value = g, l.material.uniforms.flipEnvMap.value = g.isCubeTexture && g.isRenderTargetTexture === !1 ? -1 : 1, (c !== g || h !== g.version || u !== s.toneMapping) && (l.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(l, l.geometry, l.material, 0, 0, null)) : g && g.isTexture && (a === void 0 && (a = new st(new Pi(2, 2), new sn({ + }), i.update(h)), h.material.uniforms.envMap.value = _, h.material.uniforms.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, h.material.uniforms.backgroundBlurriness.value = p.backgroundBlurriness, h.material.uniforms.backgroundIntensity.value = p.backgroundIntensity, h.material.toneMapped = _.colorSpace !== Nt, (u !== _ || d !== _.version || f !== s1.toneMapping) && (h.material.needsUpdate = !0, u = _, d = _.version, f = s1.toneMapping), h.layers.enableAll(), g.unshift(h, h.geometry, h.material, 0, 0, null)) : _ && _.isTexture && (l === void 0 && (l = new ve(new Zr(2, 2), new Qe({ name: "BackgroundMaterial", - uniforms: Ri(qt.background.uniforms), - vertexShader: qt.background.vertexShader, - fragmentShader: qt.background.fragmentShader, - side: Ai, + uniforms: $i(en.background.uniforms), + vertexShader: en.background.vertexShader, + fragmentShader: en.background.fragmentShader, + side: On, depthTest: !1, depthWrite: !1, fog: !1 - })), a.geometry.deleteAttribute("normal"), Object.defineProperty(a.material, "map", { + })), l.geometry.deleteAttribute("normal"), Object.defineProperty(l.material, "map", { get: function() { return this.uniforms.t2D.value; } - }), n.update(a)), a.material.uniforms.t2D.value = g, g.matrixAutoUpdate === !0 && g.updateMatrix(), a.material.uniforms.uvTransform.value.copy(g.matrix), (c !== g || h !== g.version || u !== s.toneMapping) && (a.material.needsUpdate = !0, c = g, h = g.version, u = s.toneMapping), m.unshift(a, a.geometry, a.material, 0, 0, null)); + }), i.update(l)), l.material.uniforms.t2D.value = _, l.material.uniforms.backgroundIntensity.value = p.backgroundIntensity, l.material.toneMapped = _.colorSpace !== Nt, _.matrixAutoUpdate === !0 && _.updateMatrix(), l.material.uniforms.uvTransform.value.copy(_.matrix), (u !== _ || d !== _.version || f !== s1.toneMapping) && (l.material.needsUpdate = !0, u = _, d = _.version, f = s1.toneMapping), l.layers.enableAll(), g.unshift(l, l.geometry, l.material, 0, 0, null)); } - function f(m, x) { - t.buffers.color.setClear(m.r, m.g, m.b, x, i); + function x(g, p) { + g.getRGB(lr, xd(s1)), n.buffers.color.setClear(lr.r, lr.g, lr.b, p, a); } return { getClearColor: function() { - return r; + return o; }, - setClearColor: function(m, x = 1) { - r.set(m), o = x, f(r, o); + setClearColor: function(g, p = 1) { + o.set(g), c = p, x(o, c); }, getClearAlpha: function() { - return o; + return c; }, - setClearAlpha: function(m) { - o = m, f(r, o); + setClearAlpha: function(g) { + c = g, x(o, c); }, - render: d + render: m }; } -function Wm(s, e, t, n) { - let i = s.getParameter(34921), r = n.isWebGL2 ? null : e.get("OES_vertex_array_object"), o = n.isWebGL2 || r !== null, a = {}, l = x(null), c = l; - function h(E, D, U, F, O) { - let ne = !1; - if (o) { - let ce = m(F, U, D); - c !== ce && (c = ce, d(c.object)), ne = v(F, O), ne && g(F, O); +function jg(s1, t, e, n) { + let i = s1.getParameter(s1.MAX_VERTEX_ATTRIBS), r = n.isWebGL2 ? null : t.get("OES_vertex_array_object"), a = n.isWebGL2 || r !== null, o = {}, c = g(null), l = c, h = !1; + function u(O, z, K, X, Y) { + let j = !1; + if (a) { + let tt = x(X, K, z); + l !== tt && (l = tt, f(l.object)), j = p(O, X, K, Y), j && v(O, X, K, Y); } else { - let ce = D.wireframe === !0; - (c.geometry !== F.id || c.program !== U.id || c.wireframe !== ce) && (c.geometry = F.id, c.program = U.id, c.wireframe = ce, ne = !0); + let tt = z.wireframe === !0; + (l.geometry !== X.id || l.program !== K.id || l.wireframe !== tt) && (l.geometry = X.id, l.program = K.id, l.wireframe = tt, j = !0); } - E.isInstancedMesh === !0 && (ne = !0), O !== null && t.update(O, 34963), ne && (L(E, D, U, F), O !== null && s.bindBuffer(34963, t.get(O).buffer)); + Y !== null && e.update(Y, s1.ELEMENT_ARRAY_BUFFER), (j || h) && (h = !1, L(O, z, K, X), Y !== null && s1.bindBuffer(s1.ELEMENT_ARRAY_BUFFER, e.get(Y).buffer)); } - function u() { - return n.isWebGL2 ? s.createVertexArray() : r.createVertexArrayOES(); + function d() { + return n.isWebGL2 ? s1.createVertexArray() : r.createVertexArrayOES(); } - function d(E) { - return n.isWebGL2 ? s.bindVertexArray(E) : r.bindVertexArrayOES(E); + function f(O) { + return n.isWebGL2 ? s1.bindVertexArray(O) : r.bindVertexArrayOES(O); } - function f(E) { - return n.isWebGL2 ? s.deleteVertexArray(E) : r.deleteVertexArrayOES(E); + function m(O) { + return n.isWebGL2 ? s1.deleteVertexArray(O) : r.deleteVertexArrayOES(O); } - function m(E, D, U) { - let F = U.wireframe === !0, O = a[E.id]; - O === void 0 && (O = {}, a[E.id] = O); - let ne = O[D.id]; - ne === void 0 && (ne = {}, O[D.id] = ne); - let ce = ne[F]; - return ce === void 0 && (ce = x(u()), ne[F] = ce), ce; + function x(O, z, K) { + let X = K.wireframe === !0, Y = o[O.id]; + Y === void 0 && (Y = {}, o[O.id] = Y); + let j = Y[z.id]; + j === void 0 && (j = {}, Y[z.id] = j); + let tt = j[X]; + return tt === void 0 && (tt = g(d()), j[X] = tt), tt; } - function x(E) { - let D = [], U = [], F = []; - for(let O = 0; O < i; O++)D[O] = 0, U[O] = 0, F[O] = 0; + function g(O) { + let z = [], K = [], X = []; + for(let Y = 0; Y < i; Y++)z[Y] = 0, K[Y] = 0, X[Y] = 0; return { geometry: null, program: null, wireframe: !1, - newAttributes: D, - enabledAttributes: U, - attributeDivisors: F, - object: E, + newAttributes: z, + enabledAttributes: K, + attributeDivisors: X, + object: O, attributes: {}, index: null }; } - function v(E, D) { - let U = c.attributes, F = E.attributes, O = 0; - for(let ne in F){ - let ce = U[ne], V = F[ne]; - if (ce === void 0 || ce.attribute !== V || ce.data !== V.data) return !0; - O++; + function p(O, z, K, X) { + let Y = l.attributes, j = z.attributes, tt = 0, N = K.getAttributes(); + for(let q in N)if (N[q].location >= 0) { + let ut = Y[q], pt = j[q]; + if (pt === void 0 && (q === "instanceMatrix" && O.instanceMatrix && (pt = O.instanceMatrix), q === "instanceColor" && O.instanceColor && (pt = O.instanceColor)), ut === void 0 || ut.attribute !== pt || pt && ut.data !== pt.data) return !0; + tt++; } - return c.attributesNum !== O || c.index !== D; + return l.attributesNum !== tt || l.index !== X; } - function g(E, D) { - let U = {}, F = E.attributes, O = 0; - for(let ne in F){ - let ce = F[ne], V = {}; - V.attribute = ce, ce.data && (V.data = ce.data), U[ne] = V, O++; + function v(O, z, K, X) { + let Y = {}, j = z.attributes, tt = 0, N = K.getAttributes(); + for(let q in N)if (N[q].location >= 0) { + let ut = j[q]; + ut === void 0 && (q === "instanceMatrix" && O.instanceMatrix && (ut = O.instanceMatrix), q === "instanceColor" && O.instanceColor && (ut = O.instanceColor)); + let pt = {}; + pt.attribute = ut, ut && ut.data && (pt.data = ut.data), Y[q] = pt, tt++; } - c.attributes = U, c.attributesNum = O, c.index = D; + l.attributes = Y, l.attributesNum = tt, l.index = X; } - function p() { - let E = c.newAttributes; - for(let D = 0, U = E.length; D < U; D++)E[D] = 0; - } - function _(E) { - y(E, 0); - } - function y(E, D) { - let U = c.newAttributes, F = c.enabledAttributes, O = c.attributeDivisors; - U[E] = 1, F[E] === 0 && (s.enableVertexAttribArray(E), F[E] = 1), O[E] !== D && ((n.isWebGL2 ? s : e.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](E, D), O[E] = D); - } - function b() { - let E = c.newAttributes, D = c.enabledAttributes; - for(let U = 0, F = D.length; U < F; U++)D[U] !== E[U] && (s.disableVertexAttribArray(U), D[U] = 0); - } - function A(E, D, U, F, O, ne) { - n.isWebGL2 === !0 && (U === 5124 || U === 5125) ? s.vertexAttribIPointer(E, D, U, O, ne) : s.vertexAttribPointer(E, D, U, F, O, ne); - } - function L(E, D, U, F) { - if (n.isWebGL2 === !1 && (E.isInstancedMesh || F.isInstancedBufferGeometry) && e.get("ANGLE_instanced_arrays") === null) return; - p(); - let O = F.attributes, ne = U.getAttributes(), ce = D.defaultAttributeValues; - for(let V in ne){ - let W = ne[V]; - if (W.location >= 0) { - let he = O[V]; - if (he === void 0 && (V === "instanceMatrix" && E.instanceMatrix && (he = E.instanceMatrix), V === "instanceColor" && E.instanceColor && (he = E.instanceColor)), he !== void 0) { - let le = he.normalized, fe = he.itemSize, Be = t.get(he); - if (Be === void 0) continue; - let Y = Be.buffer, Ce = Be.type, ye = Be.bytesPerElement; - if (he.isInterleavedBufferAttribute) { - let ge = he.data, xe = ge.stride, Oe = he.offset; - if (ge && ge.isInstancedInterleavedBuffer) { - for(let G = 0; G < W.locationSize; G++)y(W.location + G, ge.meshPerAttribute); - E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = ge.meshPerAttribute * ge.count); - } else for(let G = 0; G < W.locationSize; G++)_(W.location + G); - s.bindBuffer(34962, Y); - for(let G = 0; G < W.locationSize; G++)A(W.location + G, fe / W.locationSize, Ce, le, xe * ye, (Oe + fe / W.locationSize * G) * ye); + function _() { + let O = l.newAttributes; + for(let z = 0, K = O.length; z < K; z++)O[z] = 0; + } + function y(O) { + b(O, 0); + } + function b(O, z) { + let K = l.newAttributes, X = l.enabledAttributes, Y = l.attributeDivisors; + K[O] = 1, X[O] === 0 && (s1.enableVertexAttribArray(O), X[O] = 1), Y[O] !== z && ((n.isWebGL2 ? s1 : t.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](O, z), Y[O] = z); + } + function w() { + let O = l.newAttributes, z = l.enabledAttributes; + for(let K = 0, X = z.length; K < X; K++)z[K] !== O[K] && (s1.disableVertexAttribArray(K), z[K] = 0); + } + function R(O, z, K, X, Y, j, tt) { + tt === !0 ? s1.vertexAttribIPointer(O, z, K, Y, j) : s1.vertexAttribPointer(O, z, K, X, Y, j); + } + function L(O, z, K, X) { + if (n.isWebGL2 === !1 && (O.isInstancedMesh || X.isInstancedBufferGeometry) && t.get("ANGLE_instanced_arrays") === null) return; + _(); + let Y = X.attributes, j = K.getAttributes(), tt = z.defaultAttributeValues; + for(let N in j){ + let q = j[N]; + if (q.location >= 0) { + let lt = Y[N]; + if (lt === void 0 && (N === "instanceMatrix" && O.instanceMatrix && (lt = O.instanceMatrix), N === "instanceColor" && O.instanceColor && (lt = O.instanceColor)), lt !== void 0) { + let ut = lt.normalized, pt = lt.itemSize, Et = e.get(lt); + if (Et === void 0) continue; + let Tt = Et.buffer, wt = Et.type, Yt = Et.bytesPerElement, te = n.isWebGL2 === !0 && (wt === s1.INT || wt === s1.UNSIGNED_INT || lt.gpuType === ad); + if (lt.isInterleavedBufferAttribute) { + let Pt = lt.data, P = Pt.stride, at = lt.offset; + if (Pt.isInstancedInterleavedBuffer) { + for(let Z = 0; Z < q.locationSize; Z++)b(q.location + Z, Pt.meshPerAttribute); + O.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = Pt.meshPerAttribute * Pt.count); + } else for(let Z = 0; Z < q.locationSize; Z++)y(q.location + Z); + s1.bindBuffer(s1.ARRAY_BUFFER, Tt); + for(let Z = 0; Z < q.locationSize; Z++)R(q.location + Z, pt / q.locationSize, wt, ut, P * Yt, (at + pt / q.locationSize * Z) * Yt, te); } else { - if (he.isInstancedBufferAttribute) { - for(let ge = 0; ge < W.locationSize; ge++)y(W.location + ge, he.meshPerAttribute); - E.isInstancedMesh !== !0 && F._maxInstanceCount === void 0 && (F._maxInstanceCount = he.meshPerAttribute * he.count); - } else for(let ge = 0; ge < W.locationSize; ge++)_(W.location + ge); - s.bindBuffer(34962, Y); - for(let ge = 0; ge < W.locationSize; ge++)A(W.location + ge, fe / W.locationSize, Ce, le, fe * ye, fe / W.locationSize * ge * ye); + if (lt.isInstancedBufferAttribute) { + for(let Pt = 0; Pt < q.locationSize; Pt++)b(q.location + Pt, lt.meshPerAttribute); + O.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = lt.meshPerAttribute * lt.count); + } else for(let Pt = 0; Pt < q.locationSize; Pt++)y(q.location + Pt); + s1.bindBuffer(s1.ARRAY_BUFFER, Tt); + for(let Pt = 0; Pt < q.locationSize; Pt++)R(q.location + Pt, pt / q.locationSize, wt, ut, pt * Yt, pt / q.locationSize * Pt * Yt, te); } - } else if (ce !== void 0) { - let le = ce[V]; - if (le !== void 0) switch(le.length){ + } else if (tt !== void 0) { + let ut = tt[N]; + if (ut !== void 0) switch(ut.length){ case 2: - s.vertexAttrib2fv(W.location, le); + s1.vertexAttrib2fv(q.location, ut); break; case 3: - s.vertexAttrib3fv(W.location, le); + s1.vertexAttrib3fv(q.location, ut); break; case 4: - s.vertexAttrib4fv(W.location, le); + s1.vertexAttrib4fv(q.location, ut); break; default: - s.vertexAttrib1fv(W.location, le); + s1.vertexAttrib1fv(q.location, ut); } } } } - b(); + w(); } - function I() { - P(); - for(let E in a){ - let D = a[E]; - for(let U in D){ - let F = D[U]; - for(let O in F)f(F[O].object), delete F[O]; - delete D[U]; + function M() { + $(); + for(let O in o){ + let z = o[O]; + for(let K in z){ + let X = z[K]; + for(let Y in X)m(X[Y].object), delete X[Y]; + delete z[K]; } - delete a[E]; + delete o[O]; } } - function k(E) { - if (a[E.id] === void 0) return; - let D = a[E.id]; - for(let U in D){ - let F = D[U]; - for(let O in F)f(F[O].object), delete F[O]; - delete D[U]; + function E(O) { + if (o[O.id] === void 0) return; + let z = o[O.id]; + for(let K in z){ + let X = z[K]; + for(let Y in X)m(X[Y].object), delete X[Y]; + delete z[K]; } - delete a[E.id]; + delete o[O.id]; } - function B(E) { - for(let D in a){ - let U = a[D]; - if (U[E.id] === void 0) continue; - let F = U[E.id]; - for(let O in F)f(F[O].object), delete F[O]; - delete U[E.id]; + function V(O) { + for(let z in o){ + let K = o[z]; + if (K[O.id] === void 0) continue; + let X = K[O.id]; + for(let Y in X)m(X[Y].object), delete X[Y]; + delete K[O.id]; } } - function P() { - w(), c !== l && (c = l, d(c.object)); + function $() { + F(), h = !0, l !== c && (l = c, f(l.object)); } - function w() { - l.geometry = null, l.program = null, l.wireframe = !1; + function F() { + c.geometry = null, c.program = null, c.wireframe = !1; } return { - setup: h, - reset: P, - resetDefaultState: w, - dispose: I, - releaseStatesOfGeometry: k, - releaseStatesOfProgram: B, - initAttributes: p, - enableAttribute: _, - disableUnusedAttributes: b + setup: u, + reset: $, + resetDefaultState: F, + dispose: M, + releaseStatesOfGeometry: E, + releaseStatesOfProgram: V, + initAttributes: _, + enableAttribute: y, + disableUnusedAttributes: w }; } -function qm(s, e, t, n) { +function t_(s1, t, e, n) { let i = n.isWebGL2, r; - function o(c) { - r = c; + function a(l) { + r = l; } - function a(c, h) { - s.drawArrays(r, c, h), t.update(h, r, 1); + function o(l, h) { + s1.drawArrays(r, l, h), e.update(h, r, 1); } - function l(c, h, u) { + function c(l, h, u) { if (u === 0) return; let d, f; - if (i) d = s, f = "drawArraysInstanced"; - else if (d = e.get("ANGLE_instanced_arrays"), f = "drawArraysInstancedANGLE", d === null) { + if (i) d = s1, f = "drawArraysInstanced"; + else if (d = t.get("ANGLE_instanced_arrays"), f = "drawArraysInstancedANGLE", d === null) { console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); return; } - d[f](r, c, h, u), t.update(h, r, u); + d[f](r, l, h, u), e.update(h, r, u); } - this.setMode = o, this.render = a, this.renderInstances = l; + this.setMode = a, this.render = o, this.renderInstances = c; } -function Xm(s, e, t) { +function e_(s1, t, e) { let n; function i() { if (n !== void 0) return n; - if (e.has("EXT_texture_filter_anisotropic") === !0) { - let L = e.get("EXT_texture_filter_anisotropic"); - n = s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + if (t.has("EXT_texture_filter_anisotropic") === !0) { + let R = t.get("EXT_texture_filter_anisotropic"); + n = s1.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT); } else n = 0; return n; } - function r(L) { - if (L === "highp") { - if (s.getShaderPrecisionFormat(35633, 36338).precision > 0 && s.getShaderPrecisionFormat(35632, 36338).precision > 0) return "highp"; - L = "mediump"; + function r(R) { + if (R === "highp") { + if (s1.getShaderPrecisionFormat(s1.VERTEX_SHADER, s1.HIGH_FLOAT).precision > 0 && s1.getShaderPrecisionFormat(s1.FRAGMENT_SHADER, s1.HIGH_FLOAT).precision > 0) return "highp"; + R = "mediump"; } - return L === "mediump" && s.getShaderPrecisionFormat(35633, 36337).precision > 0 && s.getShaderPrecisionFormat(35632, 36337).precision > 0 ? "mediump" : "lowp"; + return R === "mediump" && s1.getShaderPrecisionFormat(s1.VERTEX_SHADER, s1.MEDIUM_FLOAT).precision > 0 && s1.getShaderPrecisionFormat(s1.FRAGMENT_SHADER, s1.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp"; } - let o = typeof WebGL2RenderingContext < "u" && s instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext < "u" && s instanceof WebGL2ComputeRenderingContext, a = t.precision !== void 0 ? t.precision : "highp", l = r(a); - l !== a && (console.warn("THREE.WebGLRenderer:", a, "not supported, using", l, "instead."), a = l); - let c = o || e.has("WEBGL_draw_buffers"), h = t.logarithmicDepthBuffer === !0, u = s.getParameter(34930), d = s.getParameter(35660), f = s.getParameter(3379), m = s.getParameter(34076), x = s.getParameter(34921), v = s.getParameter(36347), g = s.getParameter(36348), p = s.getParameter(36349), _ = d > 0, y = o || e.has("OES_texture_float"), b = _ && y, A = o ? s.getParameter(36183) : 0; + let a = typeof WebGL2RenderingContext < "u" && s1.constructor.name === "WebGL2RenderingContext", o = e.precision !== void 0 ? e.precision : "highp", c = r(o); + c !== o && (console.warn("THREE.WebGLRenderer:", o, "not supported, using", c, "instead."), o = c); + let l = a || t.has("WEBGL_draw_buffers"), h = e.logarithmicDepthBuffer === !0, u = s1.getParameter(s1.MAX_TEXTURE_IMAGE_UNITS), d = s1.getParameter(s1.MAX_VERTEX_TEXTURE_IMAGE_UNITS), f = s1.getParameter(s1.MAX_TEXTURE_SIZE), m = s1.getParameter(s1.MAX_CUBE_MAP_TEXTURE_SIZE), x = s1.getParameter(s1.MAX_VERTEX_ATTRIBS), g = s1.getParameter(s1.MAX_VERTEX_UNIFORM_VECTORS), p = s1.getParameter(s1.MAX_VARYING_VECTORS), v = s1.getParameter(s1.MAX_FRAGMENT_UNIFORM_VECTORS), _ = d > 0, y = a || t.has("OES_texture_float"), b = _ && y, w = a ? s1.getParameter(s1.MAX_SAMPLES) : 0; return { - isWebGL2: o, - drawBuffers: c, + isWebGL2: a, + drawBuffers: l, getMaxAnisotropy: i, getMaxPrecision: r, - precision: a, + precision: o, logarithmicDepthBuffer: h, maxTextures: u, maxVertexTextures: d, maxTextureSize: f, maxCubemapSize: m, maxAttributes: x, - maxVertexUniforms: v, - maxVaryings: g, - maxFragmentUniforms: p, + maxVertexUniforms: g, + maxVaryings: p, + maxFragmentUniforms: v, vertexTextures: _, floatFragmentTextures: y, floatVertexTextures: b, - maxSamples: A + maxSamples: w }; } -function Jm(s) { - let e = this, t = null, n = 0, i = !1, r = !1, o = new Wt, a = new lt, l = { +function n_(s1) { + let t = this, e = null, n = 0, i = !1, r = !1, a = new mn, o = new kt, c = { value: null, needsUpdate: !1 }; - this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, d, f) { - let m = u.length !== 0 || d || n !== 0 || i; - return i = d, t = h(u, f, 0), n = u.length, m; + this.uniform = c, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, d) { + let f = u.length !== 0 || d || n !== 0 || i; + return i = d, n = u.length, f; }, this.beginShadows = function() { r = !0, h(null); }, this.endShadows = function() { - r = !1, c(); + r = !1; + }, this.setGlobalState = function(u, d) { + e = h(u, d, 0); }, this.setState = function(u, d, f) { - let m = u.clippingPlanes, x = u.clipIntersection, v = u.clipShadows, g = s.get(u); - if (!i || m === null || m.length === 0 || r && !v) r ? h(null) : c(); + let m = u.clippingPlanes, x = u.clipIntersection, g = u.clipShadows, p = s1.get(u); + if (!i || m === null || m.length === 0 || r && !g) r ? h(null) : l(); else { - let p = r ? 0 : n, _ = p * 4, y = g.clippingState || null; - l.value = y, y = h(m, d, _, f); - for(let b = 0; b !== _; ++b)y[b] = t[b]; - g.clippingState = y, this.numIntersection = x ? this.numPlanes : 0, this.numPlanes += p; + let v = r ? 0 : n, _ = v * 4, y = p.clippingState || null; + c.value = y, y = h(m, d, _, f); + for(let b = 0; b !== _; ++b)y[b] = e[b]; + p.clippingState = y, this.numIntersection = x ? this.numPlanes : 0, this.numPlanes += v; } }; - function c() { - l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0; + function l() { + c.value !== e && (c.value = e, c.needsUpdate = n > 0), t.numPlanes = n, t.numIntersection = 0; } function h(u, d, f, m) { - let x = u !== null ? u.length : 0, v = null; + let x = u !== null ? u.length : 0, g = null; if (x !== 0) { - if (v = l.value, m !== !0 || v === null) { - let g = f + x * 4, p = d.matrixWorldInverse; - a.getNormalMatrix(p), (v === null || v.length < g) && (v = new Float32Array(g)); - for(let _ = 0, y = f; _ !== x; ++_, y += 4)o.copy(u[_]).applyMatrix4(p, a), o.normal.toArray(v, y), v[y + 3] = o.constant; + if (g = c.value, m !== !0 || g === null) { + let p = f + x * 4, v = d.matrixWorldInverse; + o.getNormalMatrix(v), (g === null || g.length < p) && (g = new Float32Array(p)); + for(let _ = 0, y = f; _ !== x; ++_, y += 4)a.copy(u[_]).applyMatrix4(v, o), a.normal.toArray(g, y), g[y + 3] = a.constant; } - l.value = v, l.needsUpdate = !0; + c.value = g, c.needsUpdate = !0; } - return e.numPlanes = x, e.numIntersection = 0, v; + return t.numPlanes = x, t.numIntersection = 0, g; } } -function Ym(s) { - let e = new WeakMap; - function t(o, a) { - return a === Ds ? o.mapping = Bi : a === Fs && (o.mapping = zi), o; +function i_(s1) { + let t = new WeakMap; + function e(a, o) { + return o === Ur ? a.mapping = Bn : o === Dr && (a.mapping = ci), a; } - function n(o) { - if (o && o.isTexture && o.isRenderTargetTexture === !1) { - let a = o.mapping; - if (a === Ds || a === Fs) if (e.has(o)) { - let l = e.get(o).texture; - return t(l, o.mapping); + function n(a) { + if (a && a.isTexture && a.isRenderTargetTexture === !1) { + let o = a.mapping; + if (o === Ur || o === Dr) if (t.has(a)) { + let c = t.get(a).texture; + return e(c, a.mapping); } else { - let l = o.image; - if (l && l.height > 0) { - let c = s.getRenderTarget(), h = new js(l.height / 2); - return h.fromEquirectangularTexture(s, o), e.set(o, h), s.setRenderTarget(c), o.addEventListener("dispose", i), t(h.texture, o.mapping); + let c = a.image; + if (c && c.height > 0) { + let l = new fo(c.height / 2); + return l.fromEquirectangularTexture(s1, a), t.set(a, l), a.addEventListener("dispose", i), e(l.texture, a.mapping); } else return null; } } - return o; + return a; } - function i(o) { - let a = o.target; - a.removeEventListener("dispose", i); - let l = e.get(a); - l !== void 0 && (e.delete(a), l.dispose()); + function i(a) { + let o = a.target; + o.removeEventListener("dispose", i); + let c = t.get(o); + c !== void 0 && (t.delete(o), c.dispose()); } function r() { - e = new WeakMap; + t = new WeakMap; } return { get: n, dispose: r }; } -var Fr = class extends Ir { - constructor(e = -1, t = 1, n = 1, i = -1, r = .1, o = 2e3){ - super(); - this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = i, this.near = r, this.far = o, this.updateProjectionMatrix(); +var Ls = class extends Cs { + constructor(t = -1, e = 1, n = 1, i = -1, r = .1, a = 2e3){ + super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = t, this.right = e, this.top = n, this.bottom = i, this.near = r, this.far = a, this.updateProjectionMatrix(); } - copy(e, t) { - return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; + copy(t, e) { + return super.copy(t, e), this.left = t.left, this.right = t.right, this.top = t.top, this.bottom = t.bottom, this.near = t.near, this.far = t.far, this.zoom = t.zoom, this.view = t.view === null ? null : Object.assign({}, t.view), this; } - setViewOffset(e, t, n, i, r, o) { + setViewOffset(t, e, n, i, r, a) { this.view === null && (this.view = { enabled: !0, fullWidth: 1, @@ -7752,111 +8958,110 @@ var Fr = class extends Ir { offsetY: 0, width: 1, height: 1 - }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = o, this.updateProjectionMatrix(); + }), this.view.enabled = !0, this.view.fullWidth = t, this.view.fullHeight = e, this.view.offsetX = n, this.view.offsetY = i, this.view.width = r, this.view.height = a, this.updateProjectionMatrix(); } clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } updateProjectionMatrix() { - let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2, r = n - e, o = n + e, a = i + t, l = i - t; + let t = (this.right - this.left) / (2 * this.zoom), e = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, i = (this.top + this.bottom) / 2, r = n - t, a = n + t, o = i + e, c = i - e; if (this.view !== null && this.view.enabled) { - let c = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; - r += c * this.view.offsetX, o = r + c * this.view.width, a -= h * this.view.offsetY, l = a - h * this.view.height; + let l = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; + r += l * this.view.offsetX, a = r + l * this.view.width, o -= h * this.view.offsetY, c = o - h * this.view.height; } - this.projectionMatrix.makeOrthographic(r, o, a, l, this.near, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + this.projectionMatrix.makeOrthographic(r, a, o, c, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); } - toJSON(e) { - let t = super.toJSON(e); - return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; + toJSON(t) { + let e = super.toJSON(t); + return e.object.zoom = this.zoom, e.object.left = this.left, e.object.right = this.right, e.object.top = this.top, e.object.bottom = this.bottom, e.object.near = this.near, e.object.far = this.far, this.view !== null && (e.object.view = Object.assign({}, this.view)), e; } -}; -Fr.prototype.isOrthographicCamera = !0; -var Gi = class extends sn { - constructor(e){ - super(e); - this.type = "RawShaderMaterial"; - } -}; -Gi.prototype.isRawShaderMaterial = !0; -var Ei = 4, Mn = 8, Vt = Math.pow(2, Mn), sh = [ +}, Hi = 4, nh = [ .125, .215, .35, .446, .526, .582 -], oh = Mn - Ei + 1 + sh.length, pi = 20, Hs = { - [Nt]: 0, - [Oi]: 1 -}, Go = new Fr, { _lodPlanes: ji , _sizeLods: Ll , _sigmas: ls } = Zm(), Rl = new ae, Vo = null, On = (1 + Math.sqrt(5)) / 2, mi = 1 / On, Pl = [ - new M(1, 1, 1), - new M(-1, 1, 1), - new M(1, 1, -1), - new M(-1, 1, -1), - new M(0, On, mi), - new M(0, On, -mi), - new M(mi, 0, On), - new M(-mi, 0, On), - new M(On, mi, 0), - new M(-On, mi, 0) -], ah = class { - constructor(e){ - this._renderer = e, this._pingPongRenderTarget = null, this._blurMaterial = $m(pi), this._equirectShader = null, this._cubemapShader = null, this._compileMaterial(this._blurMaterial); - } - fromScene(e, t = 0, n = .1, i = 100) { - Vo = this._renderer.getRenderTarget(); +], jn = 20, Xa = new Ls, ih = new ft, qa = null, Qn = (1 + Math.sqrt(5)) / 2, Li = 1 / Qn, sh = [ + new A(1, 1, 1), + new A(-1, 1, 1), + new A(1, 1, -1), + new A(-1, 1, -1), + new A(0, Qn, Li), + new A(0, Qn, -Li), + new A(Li, 0, Qn), + new A(-Li, 0, Qn), + new A(Qn, Li, 0), + new A(-Qn, Li, 0) +], Jr = class { + constructor(t){ + this._renderer = t, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial); + } + fromScene(t, e = 0, n = .1, i = 100) { + qa = this._renderer.getRenderTarget(), this._setSize(256); let r = this._allocateTargets(); - return this._sceneToCubeUV(e, n, i, r), t > 0 && this._blur(r, 0, 0, t), this._applyPMREM(r), this._cleanup(r), r; + return r.depthBuffer = !0, this._sceneToCubeUV(t, n, i, r), e > 0 && this._blur(r, 0, 0, e), this._applyPMREM(r), this._cleanup(r), r; } - fromEquirectangular(e) { - return this._fromTexture(e); + fromEquirectangular(t, e = null) { + return this._fromTexture(t, e); } - fromCubemap(e) { - return this._fromTexture(e); + fromCubemap(t, e = null) { + return this._fromTexture(t, e); } compileCubemapShader() { - this._cubemapShader === null && (this._cubemapShader = Fl(), this._compileMaterial(this._cubemapShader)); + this._cubemapMaterial === null && (this._cubemapMaterial = oh(), this._compileMaterial(this._cubemapMaterial)); } compileEquirectangularShader() { - this._equirectShader === null && (this._equirectShader = Dl(), this._compileMaterial(this._equirectShader)); + this._equirectMaterial === null && (this._equirectMaterial = ah(), this._compileMaterial(this._equirectMaterial)); } dispose() { - this._blurMaterial.dispose(), this._cubemapShader !== null && this._cubemapShader.dispose(), this._equirectShader !== null && this._equirectShader.dispose(); - for(let e = 0; e < ji.length; e++)ji[e].dispose(); + this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(); } - _cleanup(e) { - this._pingPongRenderTarget.dispose(), this._renderer.setRenderTarget(Vo), e.scissorTest = !1, cs(e, 0, 0, e.width, e.height); + _setSize(t) { + this._lodMax = Math.floor(Math.log2(t)), this._cubeSize = Math.pow(2, this._lodMax); } - _fromTexture(e) { - Vo = this._renderer.getRenderTarget(); - let t = this._allocateTargets(e); - return this._textureToCubeUV(e, t), this._applyPMREM(t), this._cleanup(t), t; + _dispose() { + this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose(); + for(let t = 0; t < this._lodPlanes.length; t++)this._lodPlanes[t].dispose(); } - _allocateTargets(e) { - let t = { - magFilter: tt, - minFilter: tt, + _cleanup(t) { + this._renderer.setRenderTarget(qa), t.scissorTest = !1, hr(t, 0, 0, t.width, t.height); + } + _fromTexture(t, e) { + t.mapping === Bn || t.mapping === ci ? this._setSize(t.image.length === 0 ? 16 : t.image[0].width || t.image[0].image.width) : this._setSize(t.image.width / 4), qa = this._renderer.getRenderTarget(); + let n = e || this._allocateTargets(); + return this._textureToCubeUV(t, n), this._applyPMREM(n), this._cleanup(n), n; + } + _allocateTargets() { + let t = 3 * Math.max(this._cubeSize, 112), e = 4 * this._cubeSize, n = { + magFilter: pe, + minFilter: pe, generateMipmaps: !1, - type: kn, - format: ct, - encoding: Nt, + type: Ts, + format: He, + colorSpace: nn, depthBuffer: !1 - }, n = Il(t); - return n.depthBuffer = !e, this._pingPongRenderTarget = Il(t), n; + }, i = rh(t, e, n); + if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== t || this._pingPongRenderTarget.height !== e) { + this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = rh(t, e, n); + let { _lodMax: r } = this; + ({ sizeLods: this._sizeLods , lodPlanes: this._lodPlanes , sigmas: this._sigmas } = s_(r)), this._blurMaterial = r_(r, t, e); + } + return i; } - _compileMaterial(e) { - let t = new st(ji[0], e); - this._renderer.compile(t, Go); + _compileMaterial(t) { + let e = new ve(this._lodPlanes[0], t); + this._renderer.compile(e, Xa); } - _sceneToCubeUV(e, t, n, i) { - let a = new ut(90, 1, t, n), l = [ + _sceneToCubeUV(t, e, n, i) { + let o = new xe(90, 1, e, n), c = [ 1, -1, 1, 1, 1, 1 - ], c = [ + ], l = [ 1, 1, 1, @@ -7864,133 +9069,139 @@ var Ei = 4, Mn = 8, Vt = Math.pow(2, Mn), sh = [ -1, -1 ], h = this._renderer, u = h.autoClear, d = h.toneMapping; - h.getClearColor(Rl), h.toneMapping = _n, h.autoClear = !1; - let f = new hn({ + h.getClearColor(ih), h.toneMapping = Dn, h.autoClear = !1; + let f = new Mn({ name: "PMREM.Background", - side: it, + side: De, depthWrite: !1, depthTest: !1 - }), m = new st(new wn, f), x = !1, v = e.background; - v ? v.isColor && (f.color.copy(v), e.background = null, x = !0) : (f.color.copy(Rl), x = !0); - for(let g = 0; g < 6; g++){ - let p = g % 3; - p == 0 ? (a.up.set(0, l[g], 0), a.lookAt(c[g], 0, 0)) : p == 1 ? (a.up.set(0, 0, l[g]), a.lookAt(0, c[g], 0)) : (a.up.set(0, l[g], 0), a.lookAt(0, 0, c[g])), cs(i, p * Vt, g > 2 ? Vt : 0, Vt, Vt), h.setRenderTarget(i), x && h.render(m, a), h.render(e, a); - } - m.geometry.dispose(), m.material.dispose(), h.toneMapping = d, h.autoClear = u, e.background = v; - } - _setEncoding(e, t) { - this._renderer.capabilities.isWebGL2 === !0 && t.format === ct && t.type === rn && t.encoding === Oi ? e.value = Hs[Nt] : e.value = Hs[t.encoding]; - } - _textureToCubeUV(e, t) { - let n = this._renderer, i = e.mapping === Bi || e.mapping === zi; - i ? this._cubemapShader == null && (this._cubemapShader = Fl()) : this._equirectShader == null && (this._equirectShader = Dl()); - let r = i ? this._cubemapShader : this._equirectShader, o = new st(ji[0], r), a = r.uniforms; - a.envMap.value = e, i || a.texelSize.value.set(1 / e.image.width, 1 / e.image.height), this._setEncoding(a.inputEncoding, e), cs(t, 0, 0, 3 * Vt, 2 * Vt), n.setRenderTarget(t), n.render(o, Go); - } - _applyPMREM(e) { - let t = this._renderer, n = t.autoClear; - t.autoClear = !1; - for(let i = 1; i < oh; i++){ - let r = Math.sqrt(ls[i] * ls[i] - ls[i - 1] * ls[i - 1]), o = Pl[(i - 1) % Pl.length]; - this._blur(e, i - 1, i, r, o); - } - t.autoClear = n; - } - _blur(e, t, n, i, r) { - let o = this._pingPongRenderTarget; - this._halfBlur(e, o, t, n, i, "latitudinal", r), this._halfBlur(o, e, n, n, i, "longitudinal", r); - } - _halfBlur(e, t, n, i, r, o, a) { - let l = this._renderer, c = this._blurMaterial; - o !== "latitudinal" && o !== "longitudinal" && console.error("blur direction must be either latitudinal or longitudinal!"); - let h = 3, u = new st(ji[i], c), d = c.uniforms, f = Ll[n] - 1, m = isFinite(r) ? Math.PI / (2 * f) : 2 * Math.PI / (2 * pi - 1), x = r / m, v = isFinite(r) ? 1 + Math.floor(h * x) : pi; - v > pi && console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${pi}`); - let g = [], p = 0; - for(let A = 0; A < pi; ++A){ - let L = A / x, I = Math.exp(-L * L / 2); - g.push(I), A == 0 ? p += I : A < v && (p += 2 * I); - } - for(let A = 0; A < g.length; A++)g[A] = g[A] / p; - d.envMap.value = e.texture, d.samples.value = v, d.weights.value = g, d.latitudinal.value = o === "latitudinal", a && (d.poleAxis.value = a), d.dTheta.value = m, d.mipInt.value = Mn - n; - let _ = Ll[i], y = 3 * Math.max(0, Vt - 2 * _), b = (i === 0 ? 0 : 2 * Vt) + 2 * _ * (i > Mn - Ei ? i - Mn + Ei : 0); - cs(t, y, b, 3 * _, 2 * _), l.setRenderTarget(t), l.render(u, Go); - } -}; -function Zm() { - let s = [], e = [], t = [], n = Mn; - for(let i = 0; i < oh; i++){ - let r = Math.pow(2, n); - e.push(r); - let o = 1 / r; - i > Mn - Ei ? o = sh[i - Mn + Ei - 1] : i == 0 && (o = 0), t.push(o); - let a = 1 / (r - 1), l = -a / 2, c = 1 + a / 2, h = [ - l, - l, - c, - l, - c, - c, - l, - l, - c, - c, - l, - c - ], u = 6, d = 6, f = 3, m = 2, x = 1, v = new Float32Array(f * d * u), g = new Float32Array(m * d * u), p = new Float32Array(x * d * u); - for(let y = 0; y < u; y++){ - let b = y % 3 * 2 / 3 - 1, A = y > 2 ? 0 : -1, L = [ - b, - A, + }), m = new ve(new Ji, f), x = !1, g = t.background; + g ? g.isColor && (f.color.copy(g), t.background = null, x = !0) : (f.color.copy(ih), x = !0); + for(let p = 0; p < 6; p++){ + let v = p % 3; + v === 0 ? (o.up.set(0, c[p], 0), o.lookAt(l[p], 0, 0)) : v === 1 ? (o.up.set(0, 0, c[p]), o.lookAt(0, l[p], 0)) : (o.up.set(0, c[p], 0), o.lookAt(0, 0, l[p])); + let _ = this._cubeSize; + hr(i, v * _, p > 2 ? _ : 0, _, _), h.setRenderTarget(i), x && h.render(m, o), h.render(t, o); + } + m.geometry.dispose(), m.material.dispose(), h.toneMapping = d, h.autoClear = u, t.background = g; + } + _textureToCubeUV(t, e) { + let n = this._renderer, i = t.mapping === Bn || t.mapping === ci; + i ? (this._cubemapMaterial === null && (this._cubemapMaterial = oh()), this._cubemapMaterial.uniforms.flipEnvMap.value = t.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = ah()); + let r = i ? this._cubemapMaterial : this._equirectMaterial, a = new ve(this._lodPlanes[0], r), o = r.uniforms; + o.envMap.value = t; + let c = this._cubeSize; + hr(e, 0, 0, 3 * c, 2 * c), n.setRenderTarget(e), n.render(a, Xa); + } + _applyPMREM(t) { + let e = this._renderer, n = e.autoClear; + e.autoClear = !1; + for(let i = 1; i < this._lodPlanes.length; i++){ + let r = Math.sqrt(this._sigmas[i] * this._sigmas[i] - this._sigmas[i - 1] * this._sigmas[i - 1]), a = sh[(i - 1) % sh.length]; + this._blur(t, i - 1, i, r, a); + } + e.autoClear = n; + } + _blur(t, e, n, i, r) { + let a = this._pingPongRenderTarget; + this._halfBlur(t, a, e, n, i, "latitudinal", r), this._halfBlur(a, t, n, n, i, "longitudinal", r); + } + _halfBlur(t, e, n, i, r, a, o) { + let c = this._renderer, l = this._blurMaterial; + a !== "latitudinal" && a !== "longitudinal" && console.error("blur direction must be either latitudinal or longitudinal!"); + let h = 3, u = new ve(this._lodPlanes[i], l), d = l.uniforms, f = this._sizeLods[n] - 1, m = isFinite(r) ? Math.PI / (2 * f) : 2 * Math.PI / (2 * jn - 1), x = r / m, g = isFinite(r) ? 1 + Math.floor(h * x) : jn; + g > jn && console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${jn}`); + let p = [], v = 0; + for(let R = 0; R < jn; ++R){ + let L = R / x, M = Math.exp(-L * L / 2); + p.push(M), R === 0 ? v += M : R < g && (v += 2 * M); + } + for(let R = 0; R < p.length; R++)p[R] = p[R] / v; + d.envMap.value = t.texture, d.samples.value = g, d.weights.value = p, d.latitudinal.value = a === "latitudinal", o && (d.poleAxis.value = o); + let { _lodMax: _ } = this; + d.dTheta.value = m, d.mipInt.value = _ - n; + let y = this._sizeLods[i], b = 3 * y * (i > _ - Hi ? i - _ + Hi : 0), w = 4 * (this._cubeSize - y); + hr(e, b, w, 3 * y, 2 * y), c.setRenderTarget(e), c.render(u, Xa); + } +}; +function s_(s1) { + let t = [], e = [], n = [], i = s1, r = s1 - Hi + 1 + nh.length; + for(let a = 0; a < r; a++){ + let o = Math.pow(2, i); + e.push(o); + let c = 1 / o; + a > s1 - Hi ? c = nh[a - s1 + Hi - 1] : a === 0 && (c = 0), n.push(c); + let l = 1 / (o - 2), h = -l, u = 1 + l, d = [ + h, + h, + u, + h, + u, + u, + h, + h, + u, + u, + h, + u + ], f = 6, m = 6, x = 3, g = 2, p = 1, v = new Float32Array(x * m * f), _ = new Float32Array(g * m * f), y = new Float32Array(p * m * f); + for(let w = 0; w < f; w++){ + let R = w % 3 * 2 / 3 - 1, L = w > 2 ? 0 : -1, M = [ + R, + L, 0, - b + 2 / 3, - A, + R + 2 / 3, + L, 0, - b + 2 / 3, - A + 1, + R + 2 / 3, + L + 1, 0, - b, - A, + R, + L, 0, - b + 2 / 3, - A + 1, + R + 2 / 3, + L + 1, 0, - b, - A + 1, + R, + L + 1, 0 ]; - v.set(L, f * d * y), g.set(h, m * d * y); - let I = [ - y, - y, - y, - y, - y, - y + v.set(M, x * m * w), _.set(d, g * m * w); + let E = [ + w, + w, + w, + w, + w, + w ]; - p.set(I, x * d * y); + y.set(E, p * m * w); } - let _ = new _e; - _.setAttribute("position", new Ue(v, f)), _.setAttribute("uv", new Ue(g, m)), _.setAttribute("faceIndex", new Ue(p, x)), s.push(_), n > Ei && n--; + let b = new Vt; + b.setAttribute("position", new Kt(v, x)), b.setAttribute("uv", new Kt(_, g)), b.setAttribute("faceIndex", new Kt(y, p)), t.push(b), i > Hi && i--; } return { - _lodPlanes: s, - _sizeLods: e, - _sigmas: t + lodPlanes: t, + sizeLods: e, + sigmas: n }; } -function Il(s) { - let e = new At(3 * Vt, 3 * Vt, s); - return e.texture.mapping = Pr, e.texture.name = "PMREM.cubeUv", e.scissorTest = !0, e; +function rh(s1, t, e) { + let n = new Ge(s1, t, e); + return n.texture.mapping = Hs, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n; } -function cs(s, e, t, n, i) { - s.viewport.set(e, t, n, i), s.scissor.set(e, t, n, i); +function hr(s1, t, e, n, i) { + s1.viewport.set(t, e, n, i), s1.scissor.set(t, e, n, i); } -function $m(s) { - let e = new Float32Array(s), t = new M(0, 1, 0); - return new Gi({ +function r_(s1, t, e) { + let n = new Float32Array(jn), i = new A(0, 1, 0); + return new Qe({ name: "SphericalGaussianBlur", defines: { - n: s + n: jn, + CUBEUV_TEXEL_WIDTH: 1 / t, + CUBEUV_TEXEL_HEIGHT: 1 / e, + CUBEUV_MAX_MIP: `${s1}.0` }, uniforms: { envMap: { @@ -8000,7 +9211,7 @@ function $m(s) { value: 1 }, weights: { - value: e + value: n }, latitudinal: { value: !1 @@ -8012,10 +9223,10 @@ function $m(s) { value: 0 }, poleAxis: { - value: t + value: i } }, - vertexShader: fa(), + vertexShader: Vc(), fragmentShader: ` precision mediump float; @@ -8031,8 +9242,6 @@ function $m(s) { uniform float mipInt; uniform vec3 poleAxis; - ${pa()} - #define ENVMAP_TYPE_CUBE_UV #include @@ -8079,27 +9288,20 @@ function $m(s) { } `, - blending: vn, + blending: Un, depthTest: !1, depthWrite: !1 }); } -function Dl() { - let s = new X(1, 1); - return new Gi({ +function ah() { + return new Qe({ name: "EquirectangularToCubeUV", uniforms: { envMap: { value: null - }, - texelSize: { - value: s - }, - inputEncoding: { - value: Hs[Nt] } }, - vertexShader: fa(), + vertexShader: Vc(), fragmentShader: ` precision mediump float; @@ -8108,82 +9310,63 @@ function Dl() { varying vec3 vOutputDirection; uniform sampler2D envMap; - uniform vec2 texelSize; - - ${pa()} #include void main() { - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); - vec2 f = fract( uv / texelSize - 0.5 ); - uv -= f * texelSize; - vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.x += texelSize.x; - vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.y += texelSize.y; - vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - uv.x -= texelSize.x; - vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb; - - vec3 tm = mix( tl, tr, f.x ); - vec3 bm = mix( bl, br, f.x ); - gl_FragColor.rgb = mix( tm, bm, f.y ); + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `, - blending: vn, + blending: Un, depthTest: !1, depthWrite: !1 }); } -function Fl() { - return new Gi({ +function oh() { + return new Qe({ name: "CubemapToCubeUV", uniforms: { envMap: { value: null }, - inputEncoding: { - value: Hs[Nt] + flipEnvMap: { + value: -1 } }, - vertexShader: fa(), + vertexShader: Vc(), fragmentShader: ` precision mediump float; precision mediump int; + uniform float flipEnvMap; + varying vec3 vOutputDirection; uniform samplerCube envMap; - ${pa()} - void main() { - gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ); + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `, - blending: vn, + blending: Un, depthTest: !1, depthWrite: !1 }); } -function fa() { +function Vc() { return ` precision mediump float; precision mediump int; - attribute vec3 position; - attribute vec2 uv; attribute float faceIndex; varying vec3 vOutputDirection; @@ -8236,986 +9419,1032 @@ function fa() { } `; } -function pa() { - return ` - - uniform int inputEncoding; - - #include - - vec4 inputTexelToLinear( vec4 value ) { - - if ( inputEncoding == 0 ) { - - return value; - - } else { - - return sRGBToLinear( value ); - - } - - } - - vec4 envMapTexelToLinear( vec4 color ) { - - return inputTexelToLinear( color ); - - } - `; -} -function jm(s) { - let e = new WeakMap, t = null; - function n(a) { - if (a && a.isTexture && a.isRenderTargetTexture === !1) { - let l = a.mapping, c = l === Ds || l === Fs, h = l === Bi || l === zi; - if (c || h) { - if (e.has(a)) return e.get(a).texture; +function a_(s1) { + let t = new WeakMap, e = null; + function n(o) { + if (o && o.isTexture) { + let c = o.mapping, l = c === Ur || c === Dr, h = c === Bn || c === ci; + if (l || h) if (o.isRenderTargetTexture && o.needsPMREMUpdate === !0) { + o.needsPMREMUpdate = !1; + let u = t.get(o); + return e === null && (e = new Jr(s1)), u = l ? e.fromEquirectangular(o, u) : e.fromCubemap(o, u), t.set(o, u), u.texture; + } else { + if (t.has(o)) return t.get(o).texture; { - let u = a.image; - if (c && u && u.height > 0 || h && u && i(u)) { - let d = s.getRenderTarget(); - t === null && (t = new ah(s)); - let f = c ? t.fromEquirectangular(a) : t.fromCubemap(a); - return e.set(a, f), s.setRenderTarget(d), a.addEventListener("dispose", r), f.texture; + let u = o.image; + if (l && u && u.height > 0 || h && u && i(u)) { + e === null && (e = new Jr(s1)); + let d = l ? e.fromEquirectangular(o) : e.fromCubemap(o); + return t.set(o, d), o.addEventListener("dispose", r), d.texture; } else return null; } } } - return a; + return o; } - function i(a) { - let l = 0, c = 6; - for(let h = 0; h < c; h++)a[h] !== void 0 && l++; - return l === c; + function i(o) { + let c = 0, l = 6; + for(let h = 0; h < l; h++)o[h] !== void 0 && c++; + return c === l; } - function r(a) { - let l = a.target; - l.removeEventListener("dispose", r); - let c = e.get(l); - c !== void 0 && (e.delete(l), c.dispose()); + function r(o) { + let c = o.target; + c.removeEventListener("dispose", r); + let l = t.get(c); + l !== void 0 && (t.delete(c), l.dispose()); } - function o() { - e = new WeakMap, t !== null && (t.dispose(), t = null); + function a() { + t = new WeakMap, e !== null && (e.dispose(), e = null); } return { get: n, - dispose: o + dispose: a }; } -function Qm(s) { - let e = {}; - function t(n) { - if (e[n] !== void 0) return e[n]; +function o_(s1) { + let t = {}; + function e(n) { + if (t[n] !== void 0) return t[n]; let i; switch(n){ case "WEBGL_depth_texture": - i = s.getExtension("WEBGL_depth_texture") || s.getExtension("MOZ_WEBGL_depth_texture") || s.getExtension("WEBKIT_WEBGL_depth_texture"); + i = s1.getExtension("WEBGL_depth_texture") || s1.getExtension("MOZ_WEBGL_depth_texture") || s1.getExtension("WEBKIT_WEBGL_depth_texture"); break; case "EXT_texture_filter_anisotropic": - i = s.getExtension("EXT_texture_filter_anisotropic") || s.getExtension("MOZ_EXT_texture_filter_anisotropic") || s.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); + i = s1.getExtension("EXT_texture_filter_anisotropic") || s1.getExtension("MOZ_EXT_texture_filter_anisotropic") || s1.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); break; case "WEBGL_compressed_texture_s3tc": - i = s.getExtension("WEBGL_compressed_texture_s3tc") || s.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); + i = s1.getExtension("WEBGL_compressed_texture_s3tc") || s1.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || s1.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"); break; case "WEBGL_compressed_texture_pvrtc": - i = s.getExtension("WEBGL_compressed_texture_pvrtc") || s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); + i = s1.getExtension("WEBGL_compressed_texture_pvrtc") || s1.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); break; default: - i = s.getExtension(n); + i = s1.getExtension(n); } - return e[n] = i, i; + return t[n] = i, i; } return { has: function(n) { - return t(n) !== null; + return e(n) !== null; }, init: function(n) { - n.isWebGL2 ? t("EXT_color_buffer_float") : (t("WEBGL_depth_texture"), t("OES_texture_float"), t("OES_texture_half_float"), t("OES_texture_half_float_linear"), t("OES_standard_derivatives"), t("OES_element_index_uint"), t("OES_vertex_array_object"), t("ANGLE_instanced_arrays")), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"); + n.isWebGL2 ? e("EXT_color_buffer_float") : (e("WEBGL_depth_texture"), e("OES_texture_float"), e("OES_texture_half_float"), e("OES_texture_half_float_linear"), e("OES_standard_derivatives"), e("OES_element_index_uint"), e("OES_vertex_array_object"), e("ANGLE_instanced_arrays")), e("OES_texture_float_linear"), e("EXT_color_buffer_half_float"), e("WEBGL_multisampled_render_to_texture"); }, get: function(n) { - let i = t(n); + let i = e(n); return i === null && console.warn("THREE.WebGLRenderer: " + n + " extension not supported."), i; } }; } -function Km(s, e, t, n) { +function c_(s1, t, e, n) { let i = {}, r = new WeakMap; - function o(u) { + function a(u) { let d = u.target; - d.index !== null && e.remove(d.index); - for(let m in d.attributes)e.remove(d.attributes[m]); - d.removeEventListener("dispose", o), delete i[d.id]; + d.index !== null && t.remove(d.index); + for(let m in d.attributes)t.remove(d.attributes[m]); + for(let m in d.morphAttributes){ + let x = d.morphAttributes[m]; + for(let g = 0, p = x.length; g < p; g++)t.remove(x[g]); + } + d.removeEventListener("dispose", a), delete i[d.id]; let f = r.get(d); - f && (e.remove(f), r.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--; + f && (t.remove(f), r.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, e.memory.geometries--; } - function a(u, d) { - return i[d.id] === !0 || (d.addEventListener("dispose", o), i[d.id] = !0, t.memory.geometries++), d; + function o(u, d) { + return i[d.id] === !0 || (d.addEventListener("dispose", a), i[d.id] = !0, e.memory.geometries++), d; } - function l(u) { + function c(u) { let d = u.attributes; - for(let m in d)e.update(d[m], 34962); + for(let m in d)t.update(d[m], s1.ARRAY_BUFFER); let f = u.morphAttributes; for(let m in f){ let x = f[m]; - for(let v = 0, g = x.length; v < g; v++)e.update(x[v], 34962); + for(let g = 0, p = x.length; g < p; g++)t.update(x[g], s1.ARRAY_BUFFER); } } - function c(u) { + function l(u) { let d = [], f = u.index, m = u.attributes.position, x = 0; if (f !== null) { - let p = f.array; + let v = f.array; x = f.version; - for(let _ = 0, y = p.length; _ < y; _ += 3){ - let b = p[_ + 0], A = p[_ + 1], L = p[_ + 2]; - d.push(b, A, A, L, L, b); + for(let _ = 0, y = v.length; _ < y; _ += 3){ + let b = v[_ + 0], w = v[_ + 1], R = v[_ + 2]; + d.push(b, w, w, R, R, b); } - } else { - let p = m.array; + } else if (m !== void 0) { + let v = m.array; x = m.version; - for(let _ = 0, y = p.length / 3 - 1; _ < y; _ += 3){ - let b = _ + 0, A = _ + 1, L = _ + 2; - d.push(b, A, A, L, L, b); + for(let _ = 0, y = v.length / 3 - 1; _ < y; _ += 3){ + let b = _ + 0, w = _ + 1, R = _ + 2; + d.push(b, w, w, R, R, b); } - } - let v = new (Yc(d) > 65535 ? Zs : Ys)(d, 1); - v.version = x; - let g = r.get(u); - g && e.remove(g), r.set(u, v); + } else return; + let g = new (gd(d) ? Yr : qr)(d, 1); + g.version = x; + let p = r.get(u); + p && t.remove(p), r.set(u, g); } function h(u) { let d = r.get(u); if (d) { let f = u.index; - f !== null && d.version < f.version && c(u); - } else c(u); + f !== null && d.version < f.version && l(u); + } else l(u); return r.get(u); } return { - get: a, - update: l, + get: o, + update: c, getWireframeAttribute: h }; } -function eg(s, e, t, n) { +function l_(s1, t, e, n) { let i = n.isWebGL2, r; - function o(d) { + function a(d) { r = d; } - let a, l; - function c(d) { - a = d.type, l = d.bytesPerElement; + let o, c; + function l(d) { + o = d.type, c = d.bytesPerElement; } function h(d, f) { - s.drawElements(r, f, a, d * l), t.update(f, r, 1); + s1.drawElements(r, f, o, d * c), e.update(f, r, 1); } function u(d, f, m) { if (m === 0) return; - let x, v; - if (i) x = s, v = "drawElementsInstanced"; - else if (x = e.get("ANGLE_instanced_arrays"), v = "drawElementsInstancedANGLE", x === null) { + let x, g; + if (i) x = s1, g = "drawElementsInstanced"; + else if (x = t.get("ANGLE_instanced_arrays"), g = "drawElementsInstancedANGLE", x === null) { console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); return; } - x[v](r, f, a, d * l, m), t.update(f, r, m); + x[g](r, f, o, d * c, m), e.update(f, r, m); } - this.setMode = o, this.setIndex = c, this.render = h, this.renderInstances = u; + this.setMode = a, this.setIndex = l, this.render = h, this.renderInstances = u; } -function tg(s) { - let e = { +function h_(s1) { + let t = { geometries: 0, textures: 0 - }, t = { + }, e = { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 }; - function n(r, o, a) { - switch(t.calls++, o){ - case 4: - t.triangles += a * (r / 3); + function n(r, a, o) { + switch(e.calls++, a){ + case s1.TRIANGLES: + e.triangles += o * (r / 3); break; - case 1: - t.lines += a * (r / 2); + case s1.LINES: + e.lines += o * (r / 2); break; - case 3: - t.lines += a * (r - 1); + case s1.LINE_STRIP: + e.lines += o * (r - 1); break; - case 2: - t.lines += a * r; + case s1.LINE_LOOP: + e.lines += o * r; break; - case 0: - t.points += a * r; + case s1.POINTS: + e.points += o * r; break; default: - console.error("THREE.WebGLInfo: Unknown draw mode:", o); + console.error("THREE.WebGLInfo: Unknown draw mode:", a); break; } } function i() { - t.frame++, t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0; + e.calls = 0, e.triangles = 0, e.points = 0, e.lines = 0; } return { - memory: e, - render: t, + memory: t, + render: e, programs: null, autoReset: !0, reset: i, update: n }; } -var Qs = class extends ot { - constructor(e = null, t = 1, n = 1, i = 1){ - super(null); - this.image = { - data: e, - width: t, - height: n, - depth: i - }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; - } -}; -Qs.prototype.isDataTexture2DArray = !0; -function ng(s, e) { - return s[0] - e[0]; -} -function ig(s, e) { - return Math.abs(e[1]) - Math.abs(s[1]); +function u_(s1, t) { + return s1[0] - t[0]; } -function Nl(s, e) { - let t = 1, n = e.isInterleavedBufferAttribute ? e.data.array : e.array; - n instanceof Int8Array ? t = 127 : n instanceof Int16Array ? t = 32767 : n instanceof Int32Array ? t = 2147483647 : console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ", n), s.divideScalar(t); +function d_(s1, t) { + return Math.abs(t[1]) - Math.abs(s1[1]); } -function rg(s, e, t) { - let n = {}, i = new Float32Array(8), r = new WeakMap, o = new M, a = []; - for(let c = 0; c < 8; c++)a[c] = [ - c, +function f_(s1, t, e) { + let n = {}, i = new Float32Array(8), r = new WeakMap, a = new $t, o = []; + for(let l = 0; l < 8; l++)o[l] = [ + l, 0 ]; - function l(c, h, u, d) { - let f = c.morphTargetInfluences; - if (e.isWebGL2 === !0) { - let m = h.morphAttributes.position.length, x = r.get(h); + function c(l, h, u) { + let d = l.morphTargetInfluences; + if (t.isWebGL2 === !0) { + let f = h.morphAttributes.position || h.morphAttributes.normal || h.morphAttributes.color, m = f !== void 0 ? f.length : 0, x = r.get(h); if (x === void 0 || x.count !== m) { + let O = function() { + $.dispose(), r.delete(h), h.removeEventListener("dispose", O); + }; x !== void 0 && x.texture.dispose(); - let p = h.morphAttributes.normal !== void 0, _ = h.morphAttributes.position, y = h.morphAttributes.normal || [], b = h.attributes.position.count, A = p === !0 ? 2 : 1, L = b * A, I = 1; - L > e.maxTextureSize && (I = Math.ceil(L / e.maxTextureSize), L = e.maxTextureSize); - let k = new Float32Array(L * I * 4 * m), B = new Qs(k, L, I, m); - B.format = ct, B.type = nn, B.needsUpdate = !0; - let P = A * 4; - for(let w = 0; w < m; w++){ - let E = _[w], D = y[w], U = L * I * 4 * w; - for(let F = 0; F < E.count; F++){ - o.fromBufferAttribute(E, F), E.normalized === !0 && Nl(o, E); - let O = F * P; - k[U + O + 0] = o.x, k[U + O + 1] = o.y, k[U + O + 2] = o.z, k[U + O + 3] = 0, p === !0 && (o.fromBufferAttribute(D, F), D.normalized === !0 && Nl(o, D), k[U + O + 4] = o.x, k[U + O + 5] = o.y, k[U + O + 6] = o.z, k[U + O + 7] = 0); + let v = h.morphAttributes.position !== void 0, _ = h.morphAttributes.normal !== void 0, y = h.morphAttributes.color !== void 0, b = h.morphAttributes.position || [], w = h.morphAttributes.normal || [], R = h.morphAttributes.color || [], L = 0; + v === !0 && (L = 1), _ === !0 && (L = 2), y === !0 && (L = 3); + let M = h.attributes.position.count * L, E = 1; + M > t.maxTextureSize && (E = Math.ceil(M / t.maxTextureSize), M = t.maxTextureSize); + let V = new Float32Array(M * E * 4 * m), $ = new As(V, M, E, m); + $.type = xn, $.needsUpdate = !0; + let F = L * 4; + for(let z = 0; z < m; z++){ + let K = b[z], X = w[z], Y = R[z], j = M * E * 4 * z; + for(let tt = 0; tt < K.count; tt++){ + let N = tt * F; + v === !0 && (a.fromBufferAttribute(K, tt), V[j + N + 0] = a.x, V[j + N + 1] = a.y, V[j + N + 2] = a.z, V[j + N + 3] = 0), _ === !0 && (a.fromBufferAttribute(X, tt), V[j + N + 4] = a.x, V[j + N + 5] = a.y, V[j + N + 6] = a.z, V[j + N + 7] = 0), y === !0 && (a.fromBufferAttribute(Y, tt), V[j + N + 8] = a.x, V[j + N + 9] = a.y, V[j + N + 10] = a.z, V[j + N + 11] = Y.itemSize === 4 ? a.w : 1); } } x = { count: m, - texture: B, - size: new X(L, I) - }, r.set(h, x); + texture: $, + size: new J(M, E) + }, r.set(h, x), h.addEventListener("dispose", O); } - let v = 0; - for(let p = 0; p < f.length; p++)v += f[p]; - let g = h.morphTargetsRelative ? 1 : 1 - v; - d.getUniforms().setValue(s, "morphTargetBaseInfluence", g), d.getUniforms().setValue(s, "morphTargetInfluences", f), d.getUniforms().setValue(s, "morphTargetsTexture", x.texture, t), d.getUniforms().setValue(s, "morphTargetsTextureSize", x.size); + let g = 0; + for(let v = 0; v < d.length; v++)g += d[v]; + let p = h.morphTargetsRelative ? 1 : 1 - g; + u.getUniforms().setValue(s1, "morphTargetBaseInfluence", p), u.getUniforms().setValue(s1, "morphTargetInfluences", d), u.getUniforms().setValue(s1, "morphTargetsTexture", x.texture, e), u.getUniforms().setValue(s1, "morphTargetsTextureSize", x.size); } else { - let m = f === void 0 ? 0 : f.length, x = n[h.id]; - if (x === void 0 || x.length !== m) { - x = []; - for(let y = 0; y < m; y++)x[y] = [ - y, + let f = d === void 0 ? 0 : d.length, m = n[h.id]; + if (m === void 0 || m.length !== f) { + m = []; + for(let _ = 0; _ < f; _++)m[_] = [ + _, 0 ]; - n[h.id] = x; + n[h.id] = m; } - for(let y = 0; y < m; y++){ - let b = x[y]; - b[0] = y, b[1] = f[y]; + for(let _ = 0; _ < f; _++){ + let y = m[_]; + y[0] = _, y[1] = d[_]; } - x.sort(ig); - for(let y = 0; y < 8; y++)y < m && x[y][1] ? (a[y][0] = x[y][0], a[y][1] = x[y][1]) : (a[y][0] = Number.MAX_SAFE_INTEGER, a[y][1] = 0); - a.sort(ng); - let v = h.morphAttributes.position, g = h.morphAttributes.normal, p = 0; - for(let y = 0; y < 8; y++){ - let b = a[y], A = b[0], L = b[1]; - A !== Number.MAX_SAFE_INTEGER && L ? (v && h.getAttribute("morphTarget" + y) !== v[A] && h.setAttribute("morphTarget" + y, v[A]), g && h.getAttribute("morphNormal" + y) !== g[A] && h.setAttribute("morphNormal" + y, g[A]), i[y] = L, p += L) : (v && h.hasAttribute("morphTarget" + y) === !0 && h.deleteAttribute("morphTarget" + y), g && h.hasAttribute("morphNormal" + y) === !0 && h.deleteAttribute("morphNormal" + y), i[y] = 0); + m.sort(d_); + for(let _ = 0; _ < 8; _++)_ < f && m[_][1] ? (o[_][0] = m[_][0], o[_][1] = m[_][1]) : (o[_][0] = Number.MAX_SAFE_INTEGER, o[_][1] = 0); + o.sort(u_); + let x = h.morphAttributes.position, g = h.morphAttributes.normal, p = 0; + for(let _ = 0; _ < 8; _++){ + let y = o[_], b = y[0], w = y[1]; + b !== Number.MAX_SAFE_INTEGER && w ? (x && h.getAttribute("morphTarget" + _) !== x[b] && h.setAttribute("morphTarget" + _, x[b]), g && h.getAttribute("morphNormal" + _) !== g[b] && h.setAttribute("morphNormal" + _, g[b]), i[_] = w, p += w) : (x && h.hasAttribute("morphTarget" + _) === !0 && h.deleteAttribute("morphTarget" + _), g && h.hasAttribute("morphNormal" + _) === !0 && h.deleteAttribute("morphNormal" + _), i[_] = 0); } - let _ = h.morphTargetsRelative ? 1 : 1 - p; - d.getUniforms().setValue(s, "morphTargetBaseInfluence", _), d.getUniforms().setValue(s, "morphTargetInfluences", i); + let v = h.morphTargetsRelative ? 1 : 1 - p; + u.getUniforms().setValue(s1, "morphTargetBaseInfluence", v), u.getUniforms().setValue(s1, "morphTargetInfluences", i); } } return { - update: l + update: c }; } -function sg(s, e, t, n) { +function p_(s1, t, e, n) { let i = new WeakMap; - function r(l) { - let c = n.render.frame, h = l.geometry, u = e.get(l, h); - return i.get(u) !== c && (e.update(u), i.set(u, c)), l.isInstancedMesh && (l.hasEventListener("dispose", a) === !1 && l.addEventListener("dispose", a), t.update(l.instanceMatrix, 34962), l.instanceColor !== null && t.update(l.instanceColor, 34962)), u; + function r(c) { + let l = n.render.frame, h = c.geometry, u = t.get(c, h); + if (i.get(u) !== l && (t.update(u), i.set(u, l)), c.isInstancedMesh && (c.hasEventListener("dispose", o) === !1 && c.addEventListener("dispose", o), i.get(c) !== l && (e.update(c.instanceMatrix, s1.ARRAY_BUFFER), c.instanceColor !== null && e.update(c.instanceColor, s1.ARRAY_BUFFER), i.set(c, l))), c.isSkinnedMesh) { + let d = c.skeleton; + i.get(d) !== l && (d.update(), i.set(d, l)); + } + return u; } - function o() { + function a() { i = new WeakMap; } - function a(l) { - let c = l.target; - c.removeEventListener("dispose", a), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor); + function o(c) { + let l = c.target; + l.removeEventListener("dispose", o), e.remove(l.instanceMatrix), l.instanceColor !== null && e.remove(l.instanceColor); } return { update: r, - dispose: o + dispose: a }; } -var ma = class extends ot { - constructor(e = null, t = 1, n = 1, i = 1){ - super(null); - this.image = { - data: e, - width: t, - height: n, - depth: i - }, this.magFilter = rt, this.minFilter = rt, this.wrapR = vt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; - } -}; -ma.prototype.isDataTexture3D = !0; -var lh = new ot, ch = new Qs, hh = new ma, uh = new ki, Bl = [], zl = [], Ul = new Float32Array(16), Ol = new Float32Array(9), Hl = new Float32Array(4); -function Vi(s, e, t) { - let n = s[0]; - if (n <= 0 || n > 0) return s; - let i = e * t, r = Bl[i]; - if (r === void 0 && (r = new Float32Array(i), Bl[i] = r), e !== 0) { +var yd = new ye, Md = new As, Sd = new Wr, bd = new Ki, ch = [], lh = [], hh = new Float32Array(16), uh = new Float32Array(9), dh = new Float32Array(4); +function as(s1, t, e) { + let n = s1[0]; + if (n <= 0 || n > 0) return s1; + let i = t * e, r = ch[i]; + if (r === void 0 && (r = new Float32Array(i), ch[i] = r), t !== 0) { n.toArray(r, 0); - for(let o = 1, a = 0; o !== e; ++o)a += t, s[o].toArray(r, a); + for(let a = 1, o = 0; a !== t; ++a)o += e, s1[a].toArray(r, o); } return r; } -function Mt(s, e) { - if (s.length !== e.length) return !1; - for(let t = 0, n = s.length; t < n; t++)if (s[t] !== e[t]) return !1; +function me(s1, t) { + if (s1.length !== t.length) return !1; + for(let e = 0, n = s1.length; e < n; e++)if (s1[e] !== t[e]) return !1; return !0; } -function _t(s, e) { - for(let t = 0, n = e.length; t < n; t++)s[t] = e[t]; +function ge(s1, t) { + for(let e = 0, n = t.length; e < n; e++)s1[e] = t[e]; } -function Ks(s, e) { - let t = zl[e]; - t === void 0 && (t = new Int32Array(e), zl[e] = t); - for(let n = 0; n !== e; ++n)t[n] = s.allocateTextureUnit(); - return t; +function ma(s1, t) { + let e = lh[t]; + e === void 0 && (e = new Int32Array(t), lh[t] = e); + for(let n = 0; n !== t; ++n)e[n] = s1.allocateTextureUnit(); + return e; } -function og(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1f(this.addr, e), t[0] = e); +function m_(s1, t) { + let e = this.cache; + e[0] !== t && (s1.uniform1f(this.addr, t), e[0] = t); } -function ag(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y) && (s.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y); +function g_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y) && (s1.uniform2f(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y); else { - if (Mt(t, e)) return; - s.uniform2fv(this.addr, e), _t(t, e); + if (me(e, t)) return; + s1.uniform2fv(this.addr, t), ge(e, t); } } -function lg(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (s.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z); - else if (e.r !== void 0) (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (s.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b); +function __(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (s1.uniform3f(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z); + else if (t.r !== void 0) (e[0] !== t.r || e[1] !== t.g || e[2] !== t.b) && (s1.uniform3f(this.addr, t.r, t.g, t.b), e[0] = t.r, e[1] = t.g, e[2] = t.b); else { - if (Mt(t, e)) return; - s.uniform3fv(this.addr, e), _t(t, e); + if (me(e, t)) return; + s1.uniform3fv(this.addr, t), ge(e, t); } } -function cg(s, e) { - let t = this.cache; - if (e.x !== void 0) (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (s.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w); +function x_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (s1.uniform4f(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w); else { - if (Mt(t, e)) return; - s.uniform4fv(this.addr, e), _t(t, e); + if (me(e, t)) return; + s1.uniform4fv(this.addr, t), ge(e, t); } } -function hg(s, e) { - let t = this.cache, n = e.elements; +function v_(s1, t) { + let e = this.cache, n = t.elements; if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix2fv(this.addr, !1, e), _t(t, e); + if (me(e, t)) return; + s1.uniformMatrix2fv(this.addr, !1, t), ge(e, t); } else { - if (Mt(t, n)) return; - Hl.set(n), s.uniformMatrix2fv(this.addr, !1, Hl), _t(t, n); + if (me(e, n)) return; + dh.set(n), s1.uniformMatrix2fv(this.addr, !1, dh), ge(e, n); } } -function ug(s, e) { - let t = this.cache, n = e.elements; +function y_(s1, t) { + let e = this.cache, n = t.elements; if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix3fv(this.addr, !1, e), _t(t, e); + if (me(e, t)) return; + s1.uniformMatrix3fv(this.addr, !1, t), ge(e, t); } else { - if (Mt(t, n)) return; - Ol.set(n), s.uniformMatrix3fv(this.addr, !1, Ol), _t(t, n); + if (me(e, n)) return; + uh.set(n), s1.uniformMatrix3fv(this.addr, !1, uh), ge(e, n); } } -function dg(s, e) { - let t = this.cache, n = e.elements; +function M_(s1, t) { + let e = this.cache, n = t.elements; if (n === void 0) { - if (Mt(t, e)) return; - s.uniformMatrix4fv(this.addr, !1, e), _t(t, e); + if (me(e, t)) return; + s1.uniformMatrix4fv(this.addr, !1, t), ge(e, t); } else { - if (Mt(t, n)) return; - Ul.set(n), s.uniformMatrix4fv(this.addr, !1, Ul), _t(t, n); + if (me(e, n)) return; + hh.set(n), s1.uniformMatrix4fv(this.addr, !1, hh), ge(e, n); } } -function fg(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1i(this.addr, e), t[0] = e); +function S_(s1, t) { + let e = this.cache; + e[0] !== t && (s1.uniform1i(this.addr, t), e[0] = t); } -function pg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform2iv(this.addr, e), _t(t, e)); +function b_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y) && (s1.uniform2i(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y); + else { + if (me(e, t)) return; + s1.uniform2iv(this.addr, t), ge(e, t); + } } -function mg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform3iv(this.addr, e), _t(t, e)); +function E_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (s1.uniform3i(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z); + else { + if (me(e, t)) return; + s1.uniform3iv(this.addr, t), ge(e, t); + } } -function gg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform4iv(this.addr, e), _t(t, e)); +function T_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (s1.uniform4i(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w); + else { + if (me(e, t)) return; + s1.uniform4iv(this.addr, t), ge(e, t); + } } -function xg(s, e) { - let t = this.cache; - t[0] !== e && (s.uniform1ui(this.addr, e), t[0] = e); +function w_(s1, t) { + let e = this.cache; + e[0] !== t && (s1.uniform1ui(this.addr, t), e[0] = t); } -function yg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform2uiv(this.addr, e), _t(t, e)); +function A_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y) && (s1.uniform2ui(this.addr, t.x, t.y), e[0] = t.x, e[1] = t.y); + else { + if (me(e, t)) return; + s1.uniform2uiv(this.addr, t), ge(e, t); + } } -function vg(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform3uiv(this.addr, e), _t(t, e)); +function R_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z) && (s1.uniform3ui(this.addr, t.x, t.y, t.z), e[0] = t.x, e[1] = t.y, e[2] = t.z); + else { + if (me(e, t)) return; + s1.uniform3uiv(this.addr, t), ge(e, t); + } } -function _g(s, e) { - let t = this.cache; - Mt(t, e) || (s.uniform4uiv(this.addr, e), _t(t, e)); +function C_(s1, t) { + let e = this.cache; + if (t.x !== void 0) (e[0] !== t.x || e[1] !== t.y || e[2] !== t.z || e[3] !== t.w) && (s1.uniform4ui(this.addr, t.x, t.y, t.z, t.w), e[0] = t.x, e[1] = t.y, e[2] = t.z, e[3] = t.w); + else { + if (me(e, t)) return; + s1.uniform4uiv(this.addr, t), ge(e, t); + } } -function Mg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTexture2D(e || lh, i); +function P_(s1, t, e) { + let n = this.cache, i = e.allocateTextureUnit(); + n[0] !== i && (s1.uniform1i(this.addr, i), n[0] = i), e.setTexture2D(t || yd, i); } -function bg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture3D(e || hh, i); +function L_(s1, t, e) { + let n = this.cache, i = e.allocateTextureUnit(); + n[0] !== i && (s1.uniform1i(this.addr, i), n[0] = i), e.setTexture3D(t || Sd, i); } -function wg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.safeSetTextureCube(e || uh, i); +function I_(s1, t, e) { + let n = this.cache, i = e.allocateTextureUnit(); + n[0] !== i && (s1.uniform1i(this.addr, i), n[0] = i), e.setTextureCube(t || bd, i); } -function Sg(s, e, t) { - let n = this.cache, i = t.allocateTextureUnit(); - n[0] !== i && (s.uniform1i(this.addr, i), n[0] = i), t.setTexture2DArray(e || ch, i); +function U_(s1, t, e) { + let n = this.cache, i = e.allocateTextureUnit(); + n[0] !== i && (s1.uniform1i(this.addr, i), n[0] = i), e.setTexture2DArray(t || Md, i); } -function Tg(s) { - switch(s){ +function D_(s1) { + switch(s1){ case 5126: - return og; + return m_; case 35664: - return ag; + return g_; case 35665: - return lg; + return __; case 35666: - return cg; + return x_; case 35674: - return hg; + return v_; case 35675: - return ug; + return y_; case 35676: - return dg; + return M_; case 5124: case 35670: - return fg; + return S_; case 35667: case 35671: - return pg; + return b_; case 35668: case 35672: - return mg; + return E_; case 35669: case 35673: - return gg; + return T_; case 5125: - return xg; + return w_; case 36294: - return yg; + return A_; case 36295: - return vg; + return R_; case 36296: - return _g; + return C_; case 35678: case 36198: case 36298: case 36306: case 35682: - return Mg; + return P_; case 35679: case 36299: case 36307: - return bg; + return L_; case 35680: case 36300: case 36308: case 36293: - return wg; + return I_; case 36289: case 36303: case 36311: case 36292: - return Sg; + return U_; } } -function Eg(s, e) { - s.uniform1fv(this.addr, e); +function N_(s1, t) { + s1.uniform1fv(this.addr, t); } -function Ag(s, e) { - let t = Vi(e, this.size, 2); - s.uniform2fv(this.addr, t); +function F_(s1, t) { + let e = as(t, this.size, 2); + s1.uniform2fv(this.addr, e); } -function Cg(s, e) { - let t = Vi(e, this.size, 3); - s.uniform3fv(this.addr, t); +function O_(s1, t) { + let e = as(t, this.size, 3); + s1.uniform3fv(this.addr, e); } -function Lg(s, e) { - let t = Vi(e, this.size, 4); - s.uniform4fv(this.addr, t); +function B_(s1, t) { + let e = as(t, this.size, 4); + s1.uniform4fv(this.addr, e); } -function Rg(s, e) { - let t = Vi(e, this.size, 4); - s.uniformMatrix2fv(this.addr, !1, t); +function z_(s1, t) { + let e = as(t, this.size, 4); + s1.uniformMatrix2fv(this.addr, !1, e); } -function Pg(s, e) { - let t = Vi(e, this.size, 9); - s.uniformMatrix3fv(this.addr, !1, t); +function k_(s1, t) { + let e = as(t, this.size, 9); + s1.uniformMatrix3fv(this.addr, !1, e); } -function Ig(s, e) { - let t = Vi(e, this.size, 16); - s.uniformMatrix4fv(this.addr, !1, t); +function V_(s1, t) { + let e = as(t, this.size, 16); + s1.uniformMatrix4fv(this.addr, !1, e); } -function Dg(s, e) { - s.uniform1iv(this.addr, e); +function H_(s1, t) { + s1.uniform1iv(this.addr, t); } -function Fg(s, e) { - s.uniform2iv(this.addr, e); +function G_(s1, t) { + s1.uniform2iv(this.addr, t); } -function Ng(s, e) { - s.uniform3iv(this.addr, e); +function W_(s1, t) { + s1.uniform3iv(this.addr, t); } -function Bg(s, e) { - s.uniform4iv(this.addr, e); +function X_(s1, t) { + s1.uniform4iv(this.addr, t); } -function zg(s, e) { - s.uniform1uiv(this.addr, e); +function q_(s1, t) { + s1.uniform1uiv(this.addr, t); } -function Ug(s, e) { - s.uniform2uiv(this.addr, e); +function Y_(s1, t) { + s1.uniform2uiv(this.addr, t); } -function Og(s, e) { - s.uniform3uiv(this.addr, e); +function Z_(s1, t) { + s1.uniform3uiv(this.addr, t); } -function Hg(s, e) { - s.uniform4uiv(this.addr, e); +function J_(s1, t) { + s1.uniform4uiv(this.addr, t); } -function kg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.safeSetTexture2D(e[r] || lh, i[r]); +function $_(s1, t, e) { + let n = this.cache, i = t.length, r = ma(e, i); + me(n, r) || (s1.uniform1iv(this.addr, r), ge(n, r)); + for(let a = 0; a !== i; ++a)e.setTexture2D(t[a] || yd, r[a]); } -function Gg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.setTexture3D(e[r] || hh, i[r]); +function K_(s1, t, e) { + let n = this.cache, i = t.length, r = ma(e, i); + me(n, r) || (s1.uniform1iv(this.addr, r), ge(n, r)); + for(let a = 0; a !== i; ++a)e.setTexture3D(t[a] || Sd, r[a]); } -function Vg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.safeSetTextureCube(e[r] || uh, i[r]); +function Q_(s1, t, e) { + let n = this.cache, i = t.length, r = ma(e, i); + me(n, r) || (s1.uniform1iv(this.addr, r), ge(n, r)); + for(let a = 0; a !== i; ++a)e.setTextureCube(t[a] || bd, r[a]); } -function Wg(s, e, t) { - let n = e.length, i = Ks(t, n); - s.uniform1iv(this.addr, i); - for(let r = 0; r !== n; ++r)t.setTexture2DArray(e[r] || ch, i[r]); +function j_(s1, t, e) { + let n = this.cache, i = t.length, r = ma(e, i); + me(n, r) || (s1.uniform1iv(this.addr, r), ge(n, r)); + for(let a = 0; a !== i; ++a)e.setTexture2DArray(t[a] || Md, r[a]); } -function qg(s) { - switch(s){ +function t0(s1) { + switch(s1){ case 5126: - return Eg; + return N_; case 35664: - return Ag; + return F_; case 35665: - return Cg; + return O_; case 35666: - return Lg; + return B_; case 35674: - return Rg; + return z_; case 35675: - return Pg; + return k_; case 35676: - return Ig; + return V_; case 5124: case 35670: - return Dg; + return H_; case 35667: case 35671: - return Fg; + return G_; case 35668: case 35672: - return Ng; + return W_; case 35669: case 35673: - return Bg; + return X_; case 5125: - return zg; + return q_; case 36294: - return Ug; + return Y_; case 36295: - return Og; + return Z_; case 36296: - return Hg; + return J_; case 35678: case 36198: case 36298: case 36306: case 35682: - return kg; + return $_; case 35679: case 36299: case 36307: - return Gg; + return K_; case 35680: case 36300: case 36308: case 36293: - return Vg; + return Q_; case 36289: case 36303: case 36311: case 36292: - return Wg; + return j_; } } -function Xg(s, e, t) { - this.id = s, this.addr = t, this.cache = [], this.setValue = Tg(e.type); -} -function dh(s, e, t) { - this.id = s, this.addr = t, this.cache = [], this.size = e.size, this.setValue = qg(e.type); -} -dh.prototype.updateCache = function(s) { - let e = this.cache; - s instanceof Float32Array && e.length !== s.length && (this.cache = new Float32Array(s.length)), _t(e, s); -}; -function fh(s) { - this.id = s, this.seq = [], this.map = {}; -} -fh.prototype.setValue = function(s, e, t) { - let n = this.seq; - for(let i = 0, r = n.length; i !== r; ++i){ - let o = n[i]; - o.setValue(s, e[o.id], t); +var po = class { + constructor(t, e, n){ + this.id = t, this.addr = n, this.cache = [], this.setValue = D_(e.type); } -}; -var Wo = /(\w+)(\])?(\[|\.)?/g; -function kl(s, e) { - s.seq.push(e), s.map[e.id] = e; -} -function Jg(s, e, t) { - let n = s.name, i = n.length; - for(Wo.lastIndex = 0;;){ - let r = Wo.exec(n), o = Wo.lastIndex, a = r[1], l = r[2] === "]", c = r[3]; - if (l && (a = a | 0), c === void 0 || c === "[" && o + 2 === i) { - kl(t, c === void 0 ? new Xg(a, s, e) : new dh(a, s, e)); +}, mo = class { + constructor(t, e, n){ + this.id = t, this.addr = n, this.cache = [], this.size = e.size, this.setValue = t0(e.type); + } +}, go = class { + constructor(t){ + this.id = t, this.seq = [], this.map = {}; + } + setValue(t, e, n) { + let i = this.seq; + for(let r = 0, a = i.length; r !== a; ++r){ + let o = i[r]; + o.setValue(t, e[o.id], n); + } + } +}, Ya = /(\w+)(\])?(\[|\.)?/g; +function fh(s1, t) { + s1.seq.push(t), s1.map[t.id] = t; +} +function e0(s1, t, e) { + let n = s1.name, i = n.length; + for(Ya.lastIndex = 0;;){ + let r = Ya.exec(n), a = Ya.lastIndex, o = r[1], c = r[2] === "]", l = r[3]; + if (c && (o = o | 0), l === void 0 || l === "[" && a + 2 === i) { + fh(e, l === void 0 ? new po(o, s1, t) : new mo(o, s1, t)); break; } else { - let u = t.map[a]; - u === void 0 && (u = new fh(a), kl(t, u)), t = u; + let u = e.map[o]; + u === void 0 && (u = new go(o), fh(e, u)), e = u; } } } -function bn(s, e) { - this.seq = [], this.map = {}; - let t = s.getProgramParameter(e, 35718); - for(let n = 0; n < t; ++n){ - let i = s.getActiveUniform(e, n), r = s.getUniformLocation(e, i.name); - Jg(i, r, this); +var qi = class { + constructor(t, e){ + this.seq = [], this.map = {}; + let n = t.getProgramParameter(e, t.ACTIVE_UNIFORMS); + for(let i = 0; i < n; ++i){ + let r = t.getActiveUniform(e, i), a = t.getUniformLocation(e, r.name); + e0(r, a, this); + } } -} -bn.prototype.setValue = function(s, e, t, n) { - let i = this.map[e]; - i !== void 0 && i.setValue(s, t, n); -}; -bn.prototype.setOptional = function(s, e, t) { - let n = e[t]; - n !== void 0 && this.setValue(s, t, n); -}; -bn.upload = function(s, e, t, n) { - for(let i = 0, r = e.length; i !== r; ++i){ - let o = e[i], a = t[o.id]; - a.needsUpdate !== !1 && o.setValue(s, a.value, n); + setValue(t, e, n, i) { + let r = this.map[e]; + r !== void 0 && r.setValue(t, n, i); } -}; -bn.seqWithValue = function(s, e) { - let t = []; - for(let n = 0, i = s.length; n !== i; ++n){ - let r = s[n]; - r.id in e && t.push(r); + setOptional(t, e, n) { + let i = e[n]; + i !== void 0 && this.setValue(t, n, i); + } + static upload(t, e, n, i) { + for(let r = 0, a = e.length; r !== a; ++r){ + let o = e[r], c = n[o.id]; + c.needsUpdate !== !1 && o.setValue(t, c.value, i); + } + } + static seqWithValue(t, e) { + let n = []; + for(let i = 0, r = t.length; i !== r; ++i){ + let a = t[i]; + a.id in e && n.push(a); + } + return n; } - return t; }; -function Gl(s, e, t) { - let n = s.createShader(e); - return s.shaderSource(n, t), s.compileShader(n), n; +function ph(s1, t, e) { + let n = s1.createShader(t); + return s1.shaderSource(n, e), s1.compileShader(n), n; } -var Yg = 0; -function Zg(s) { - let e = s.split(` -`); - for(let t = 0; t < e.length; t++)e[t] = t + 1 + ": " + e[t]; - return e.join(` +var n0 = 0; +function i0(s1, t) { + let e = s1.split(` +`), n = [], i = Math.max(t - 6, 0), r = Math.min(t + 6, e.length); + for(let a = i; a < r; a++){ + let o = a + 1; + n.push(`${o === t ? ">" : " "} ${o}: ${e[a]}`); + } + return n.join(` `); } -function ph(s) { - switch(s){ - case Nt: +function s0(s1) { + switch(s1){ + case nn: return [ "Linear", "( value )" ]; - case Oi: + case Nt: return [ "sRGB", "( value )" ]; default: - return console.warn("THREE.WebGLProgram: Unsupported encoding:", s), [ + return console.warn("THREE.WebGLProgram: Unsupported color space:", s1), [ "Linear", "( value )" ]; } } -function Vl(s, e, t) { - let n = s.getShaderParameter(e, 35713), i = s.getShaderInfoLog(e).trim(); - return n && i === "" ? "" : t.toUpperCase() + ` +function mh(s1, t, e) { + let n = s1.getShaderParameter(t, s1.COMPILE_STATUS), i = s1.getShaderInfoLog(t).trim(); + if (n && i === "") return ""; + let r = /ERROR: 0:(\d+)/.exec(i); + if (r) { + let a = parseInt(r[1]); + return e.toUpperCase() + ` ` + i + ` -` + Zg(s.getShaderSource(e)); -} -function Dn(s, e) { - let t = ph(e); - return "vec4 " + s + "( vec4 value ) { return " + t[0] + "ToLinear" + t[1] + "; }"; -} -function $g(s, e) { - let t = ph(e); - return "vec4 " + s + "( vec4 value ) { return LinearTo" + t[0] + t[1] + "; }"; -} -function jg(s, e) { - let t; - switch(e){ - case Nu: - t = "Linear"; +` + i0(s1.getShaderSource(t), a); + } else return i; +} +function r0(s1, t) { + let e = s0(t); + return "vec4 " + s1 + "( vec4 value ) { return LinearTo" + e[0] + e[1] + "; }"; +} +function a0(s1, t) { + let e; + switch(t){ + case af: + e = "Linear"; break; - case Bu: - t = "Reinhard"; + case of: + e = "Reinhard"; break; - case zu: - t = "OptimizedCineon"; + case cf: + e = "OptimizedCineon"; break; - case Uu: - t = "ACESFilmic"; + case lf: + e = "ACESFilmic"; break; - case Ou: - t = "Custom"; + case hf: + e = "Custom"; break; default: - console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear"; + console.warn("THREE.WebGLProgram: Unsupported toneMapping:", t), e = "Linear"; } - return "vec3 " + s + "( vec3 color ) { return " + t + "ToneMapping( color ); }"; + return "vec3 " + s1 + "( vec3 color ) { return " + e + "ToneMapping( color ); }"; } -function Qg(s) { +function o0(s1) { return [ - s.extensionDerivatives || s.envMapCubeUV || s.bumpMap || s.tangentSpaceNormalMap || s.clearcoatNormalMap || s.flatShading || s.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "", - (s.extensionFragDepth || s.logarithmicDepthBuffer) && s.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "", - s.extensionDrawBuffers && s.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "", - (s.extensionShaderTextureLOD || s.envMap || s.transmission) && s.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : "" - ].filter(rr).join(` + s1.extensionDerivatives || s1.envMapCubeUVHeight || s1.bumpMap || s1.normalMapTangentSpace || s1.clearcoatNormalMap || s1.flatShading || s1.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "", + (s1.extensionFragDepth || s1.logarithmicDepthBuffer) && s1.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "", + s1.extensionDrawBuffers && s1.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "", + (s1.extensionShaderTextureLOD || s1.envMap || s1.transmission) && s1.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : "" + ].filter(vs).join(` `); } -function Kg(s) { - let e = []; - for(let t in s){ - let n = s[t]; - n !== !1 && e.push("#define " + t + " " + n); +function c0(s1) { + let t = []; + for(let e in s1){ + let n = s1[e]; + n !== !1 && t.push("#define " + e + " " + n); } - return e.join(` + return t.join(` `); } -function ex(s, e) { - let t = {}, n = s.getProgramParameter(e, 35721); +function l0(s1, t) { + let e = {}, n = s1.getProgramParameter(t, s1.ACTIVE_ATTRIBUTES); for(let i = 0; i < n; i++){ - let r = s.getActiveAttrib(e, i), o = r.name, a = 1; - r.type === 35674 && (a = 2), r.type === 35675 && (a = 3), r.type === 35676 && (a = 4), t[o] = { + let r = s1.getActiveAttrib(t, i), a = r.name, o = 1; + r.type === s1.FLOAT_MAT2 && (o = 2), r.type === s1.FLOAT_MAT3 && (o = 3), r.type === s1.FLOAT_MAT4 && (o = 4), e[a] = { type: r.type, - location: s.getAttribLocation(e, o), - locationSize: a + location: s1.getAttribLocation(t, a), + locationSize: o }; } - return t; -} -function rr(s) { - return s !== ""; + return e; } -function Wl(s, e) { - return s.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows); +function vs(s1) { + return s1 !== ""; } -function ql(s, e) { - return s.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection); +function gh(s1, t) { + let e = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps; + return s1.replace(/NUM_DIR_LIGHTS/g, t.numDirLights).replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, e).replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, t.numPointLights).replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows); } -var tx = /^[ \t]*#include +<([\w\d./]+)>/gm; -function ra(s) { - return s.replace(tx, nx); +function _h(s1, t) { + return s1.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection); } -function nx(s, e) { - let t = Fe[e]; - if (t === void 0) throw new Error("Can not resolve #include <" + e + ">"); - return ra(t); +var h0 = /^[ \t]*#include +<([\w\d./]+)>/gm; +function _o(s1) { + return s1.replace(h0, d0); } -var ix = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g, rx = /#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 Xl(s) { - return s.replace(rx, mh).replace(ix, sx); +var u0 = new Map([ + [ + "encodings_fragment", + "colorspace_fragment" + ], + [ + "encodings_pars_fragment", + "colorspace_pars_fragment" + ], + [ + "output_fragment", + "opaque_fragment" + ] +]); +function d0(s1, t) { + let e = zt[t]; + if (e === void 0) { + let n = u0.get(t); + if (n !== void 0) e = zt[n], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', t, n); + else throw new Error("Can not resolve #include <" + t + ">"); + } + return _o(e); } -function sx(s, e, t, n) { - return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."), mh(s, e, t, n); +var f0 = /#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 xh(s1) { + return s1.replace(f0, p0); } -function mh(s, e, t, n) { +function p0(s1, t, e, n) { let i = ""; - for(let r = parseInt(e); r < parseInt(t); r++)i += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); + for(let r = parseInt(t); r < parseInt(e); r++)i += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r); return i; } -function Jl(s) { - let e = "precision " + s.precision + ` float; -precision ` + s.precision + " int;"; - return s.precision === "highp" ? e += ` -#define HIGH_PRECISION` : s.precision === "mediump" ? e += ` -#define MEDIUM_PRECISION` : s.precision === "lowp" && (e += ` -#define LOW_PRECISION`), e; -} -function ox(s) { - let e = "SHADOWMAP_TYPE_BASIC"; - return s.shadowMapType === Hc ? e = "SHADOWMAP_TYPE_PCF" : s.shadowMapType === fu ? e = "SHADOWMAP_TYPE_PCF_SOFT" : s.shadowMapType === ir && (e = "SHADOWMAP_TYPE_VSM"), e; -} -function ax(s) { - let e = "ENVMAP_TYPE_CUBE"; - if (s.envMap) switch(s.envMapMode){ - case Bi: - case zi: - e = "ENVMAP_TYPE_CUBE"; +function vh(s1) { + let t = "precision " + s1.precision + ` float; +precision ` + s1.precision + " int;"; + return s1.precision === "highp" ? t += ` +#define HIGH_PRECISION` : s1.precision === "mediump" ? t += ` +#define MEDIUM_PRECISION` : s1.precision === "lowp" && (t += ` +#define LOW_PRECISION`), t; +} +function m0(s1) { + let t = "SHADOWMAP_TYPE_BASIC"; + return s1.shadowMapType === nd ? t = "SHADOWMAP_TYPE_PCF" : s1.shadowMapType === Od ? t = "SHADOWMAP_TYPE_PCF_SOFT" : s1.shadowMapType === pn && (t = "SHADOWMAP_TYPE_VSM"), t; +} +function g0(s1) { + let t = "ENVMAP_TYPE_CUBE"; + if (s1.envMap) switch(s1.envMapMode){ + case Bn: + case ci: + t = "ENVMAP_TYPE_CUBE"; break; - case Pr: - case Ws: - e = "ENVMAP_TYPE_CUBE_UV"; + case Hs: + t = "ENVMAP_TYPE_CUBE_UV"; break; } - return e; + return t; } -function lx(s) { - let e = "ENVMAP_MODE_REFLECTION"; - if (s.envMap) switch(s.envMapMode){ - case zi: - case Ws: - e = "ENVMAP_MODE_REFRACTION"; +function _0(s1) { + let t = "ENVMAP_MODE_REFLECTION"; + if (s1.envMap) switch(s1.envMapMode){ + case ci: + t = "ENVMAP_MODE_REFRACTION"; break; } - return e; + return t; } -function cx(s) { - let e = "ENVMAP_BLENDING_NONE"; - if (s.envMap) switch(s.combine){ - case Vs: - e = "ENVMAP_BLENDING_MULTIPLY"; +function x0(s1) { + let t = "ENVMAP_BLENDING_NONE"; + if (s1.envMap) switch(s1.combine){ + case pa: + t = "ENVMAP_BLENDING_MULTIPLY"; break; - case Du: - e = "ENVMAP_BLENDING_MIX"; + case sf: + t = "ENVMAP_BLENDING_MIX"; break; - case Fu: - e = "ENVMAP_BLENDING_ADD"; + case rf: + t = "ENVMAP_BLENDING_ADD"; break; } - return e; + return t; +} +function v0(s1) { + let t = s1.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), 7 * 16)), + texelHeight: n, + maxMip: e + }; } -function hx(s, e, t, n) { - let i = s.getContext(), r = t.defines, o = t.vertexShader, a = t.fragmentShader, l = ox(t), c = ax(t), h = lx(t), u = cx(t), d = t.isWebGL2 ? "" : Qg(t), f = Kg(r), m = i.createProgram(), x, v, g = t.glslVersion ? "#version " + t.glslVersion + ` +function y0(s1, t, e, n) { + let i = s1.getContext(), r = e.defines, a = e.vertexShader, o = e.fragmentShader, c = m0(e), l = g0(e), h = _0(e), u = x0(e), d = v0(e), f = e.isWebGL2 ? "" : o0(e), m = c0(r), x = i.createProgram(), g, p, v = e.glslVersion ? "#version " + e.glslVersion + ` ` : ""; - t.isRawShaderMaterial ? (x = [ - f - ].filter(rr).join(` -`), x.length > 0 && (x += ` -`), v = [ - d, - f - ].filter(rr).join(` -`), v.length > 0 && (v += ` -`)) : (x = [ - Jl(t), - "#define SHADER_NAME " + t.shaderName, + e.isRawShaderMaterial ? (g = [ + "#define SHADER_TYPE " + e.shaderType, + "#define SHADER_NAME " + e.shaderName, + m + ].filter(vs).join(` +`), g.length > 0 && (g += ` +`), p = [ f, - t.instancing ? "#define USE_INSTANCING" : "", - t.instancingColor ? "#define USE_INSTANCING_COLOR" : "", - t.supportsVertexTextures ? "#define VERTEX_TEXTURES" : "", - "#define MAX_BONES " + t.maxBones, - t.useFog && t.fog ? "#define USE_FOG" : "", - t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", - t.map ? "#define USE_MAP" : "", - t.envMap ? "#define USE_ENVMAP" : "", - t.envMap ? "#define " + h : "", - t.lightMap ? "#define USE_LIGHTMAP" : "", - t.aoMap ? "#define USE_AOMAP" : "", - t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", - t.bumpMap ? "#define USE_BUMPMAP" : "", - t.normalMap ? "#define USE_NORMALMAP" : "", - t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", - t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", - t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", - t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", - t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", - t.displacementMap && t.supportsVertexTextures ? "#define USE_DISPLACEMENTMAP" : "", - t.specularMap ? "#define USE_SPECULARMAP" : "", - t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", - t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", - t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", - t.metalnessMap ? "#define USE_METALNESSMAP" : "", - t.alphaMap ? "#define USE_ALPHAMAP" : "", - t.transmission ? "#define USE_TRANSMISSION" : "", - t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", - t.thicknessMap ? "#define USE_THICKNESSMAP" : "", - t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", - t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", - t.vertexTangents ? "#define USE_TANGENT" : "", - t.vertexColors ? "#define USE_COLOR" : "", - t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", - t.vertexUvs ? "#define USE_UV" : "", - t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", - t.flatShading ? "#define FLAT_SHADED" : "", - t.skinning ? "#define USE_SKINNING" : "", - t.useVertexTexture ? "#define BONE_TEXTURE" : "", - t.morphTargets ? "#define USE_MORPHTARGETS" : "", - t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", - t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "", - t.morphTargets && t.isWebGL2 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "", - t.doubleSided ? "#define DOUBLE_SIDED" : "", - t.flipSided ? "#define FLIP_SIDED" : "", - t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", - t.shadowMapEnabled ? "#define " + l : "", - t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", - t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", - t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", + "#define SHADER_TYPE " + e.shaderType, + "#define SHADER_NAME " + e.shaderName, + m + ].filter(vs).join(` +`), p.length > 0 && (p += ` +`)) : (g = [ + vh(e), + "#define SHADER_TYPE " + e.shaderType, + "#define SHADER_NAME " + e.shaderName, + m, + e.instancing ? "#define USE_INSTANCING" : "", + e.instancingColor ? "#define USE_INSTANCING_COLOR" : "", + 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.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.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 && e.isWebGL2 ? "#define USE_MORPHCOLORS" : "", + e.morphTargetsCount > 0 && e.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "", + e.morphTargetsCount > 0 && e.isWebGL2 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + e.morphTextureStride : "", + e.morphTargetsCount > 0 && e.isWebGL2 ? "#define MORPHTARGETS_COUNT " + e.morphTargetsCount : "", + e.doubleSided ? "#define DOUBLE_SIDED" : "", + e.flipSided ? "#define FLIP_SIDED" : "", + e.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", + e.shadowMapEnabled ? "#define " + c : "", + e.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", + e.useLegacyLights ? "#define LEGACY_LIGHTS" : "", + e.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + e.logarithmicDepthBuffer && e.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", "uniform mat4 modelMatrix;", "uniform mat4 modelViewMatrix;", "uniform mat4 projectionMatrix;", @@ -9232,6 +10461,15 @@ function hx(s, e, t, n) { "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", @@ -9263,93 +10501,97 @@ function hx(s, e, t, n) { "#endif", ` ` - ].filter(rr).join(` -`), v = [ - d, - Jl(t), - "#define SHADER_NAME " + t.shaderName, + ].filter(vs).join(` +`), p = [ f, - t.useFog && t.fog ? "#define USE_FOG" : "", - t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "", - t.map ? "#define USE_MAP" : "", - t.matcap ? "#define USE_MATCAP" : "", - t.envMap ? "#define USE_ENVMAP" : "", - t.envMap ? "#define " + c : "", - t.envMap ? "#define " + h : "", - t.envMap ? "#define " + u : "", - t.lightMap ? "#define USE_LIGHTMAP" : "", - t.aoMap ? "#define USE_AOMAP" : "", - t.emissiveMap ? "#define USE_EMISSIVEMAP" : "", - t.bumpMap ? "#define USE_BUMPMAP" : "", - t.normalMap ? "#define USE_NORMALMAP" : "", - t.normalMap && t.objectSpaceNormalMap ? "#define OBJECTSPACE_NORMALMAP" : "", - t.normalMap && t.tangentSpaceNormalMap ? "#define TANGENTSPACE_NORMALMAP" : "", - t.clearcoat ? "#define USE_CLEARCOAT" : "", - t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", - t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", - t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", - t.specularMap ? "#define USE_SPECULARMAP" : "", - t.specularIntensityMap ? "#define USE_SPECULARINTENSITYMAP" : "", - t.specularColorMap ? "#define USE_SPECULARCOLORMAP" : "", - t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", - t.metalnessMap ? "#define USE_METALNESSMAP" : "", - t.alphaMap ? "#define USE_ALPHAMAP" : "", - t.alphaTest ? "#define USE_ALPHATEST" : "", - t.sheen ? "#define USE_SHEEN" : "", - t.sheenColorMap ? "#define USE_SHEENCOLORMAP" : "", - t.sheenRoughnessMap ? "#define USE_SHEENROUGHNESSMAP" : "", - t.transmission ? "#define USE_TRANSMISSION" : "", - t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", - t.thicknessMap ? "#define USE_THICKNESSMAP" : "", - t.vertexTangents ? "#define USE_TANGENT" : "", - t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "", - t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", - t.vertexUvs ? "#define USE_UV" : "", - t.uvsVertexOnly ? "#define UVS_VERTEX_ONLY" : "", - t.gradientMap ? "#define USE_GRADIENTMAP" : "", - t.flatShading ? "#define FLAT_SHADED" : "", - t.doubleSided ? "#define DOUBLE_SIDED" : "", - t.flipSided ? "#define FLIP_SIDED" : "", - t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", - t.shadowMapEnabled ? "#define " + l : "", - t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", - t.physicallyCorrectLights ? "#define PHYSICALLY_CORRECT_LIGHTS" : "", - t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", - t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", - (t.extensionShaderTextureLOD || t.envMap) && t.rendererExtensionShaderTextureLod ? "#define TEXTURE_LOD_EXT" : "", + vh(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.map ? "#define USE_MAP" : "", + e.matcap ? "#define USE_MATCAP" : "", + e.envMap ? "#define USE_ENVMAP" : "", + e.envMap ? "#define " + l : "", + e.envMap ? "#define " + h : "", + e.envMap ? "#define " + u : "", + d ? "#define CUBEUV_TEXEL_WIDTH " + d.texelWidth : "", + d ? "#define CUBEUV_TEXEL_HEIGHT " + d.texelHeight : "", + d ? "#define CUBEUV_MAX_MIP " + d.maxMip + ".0" : "", + e.lightMap ? "#define USE_LIGHTMAP" : "", + e.aoMap ? "#define USE_AOMAP" : "", + e.bumpMap ? "#define USE_BUMPMAP" : "", + e.normalMap ? "#define USE_NORMALMAP" : "", + e.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", + e.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", + e.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.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 ? "#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 " + c : "", + e.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", + e.useLegacyLights ? "#define LEGACY_LIGHTS" : "", + e.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "", + e.logarithmicDepthBuffer && e.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "", "uniform mat4 viewMatrix;", "uniform vec3 cameraPosition;", "uniform bool isOrthographic;", - t.toneMapping !== _n ? "#define TONE_MAPPING" : "", - t.toneMapping !== _n ? Fe.tonemapping_pars_fragment : "", - t.toneMapping !== _n ? jg("toneMapping", t.toneMapping) : "", - t.dithering ? "#define DITHERING" : "", - t.format === Gn ? "#define OPAQUE" : "", - Fe.encodings_pars_fragment, - t.map ? Dn("mapTexelToLinear", t.mapEncoding) : "", - t.matcap ? Dn("matcapTexelToLinear", t.matcapEncoding) : "", - t.envMap ? Dn("envMapTexelToLinear", t.envMapEncoding) : "", - t.emissiveMap ? Dn("emissiveMapTexelToLinear", t.emissiveMapEncoding) : "", - t.specularColorMap ? Dn("specularColorMapTexelToLinear", t.specularColorMapEncoding) : "", - t.sheenColorMap ? Dn("sheenColorMapTexelToLinear", t.sheenColorMapEncoding) : "", - t.lightMap ? Dn("lightMapTexelToLinear", t.lightMapEncoding) : "", - $g("linearToOutputTexel", t.outputEncoding), - t.depthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "", + e.toneMapping !== Dn ? "#define TONE_MAPPING" : "", + e.toneMapping !== Dn ? zt.tonemapping_pars_fragment : "", + e.toneMapping !== Dn ? a0("toneMapping", e.toneMapping) : "", + e.dithering ? "#define DITHERING" : "", + e.opaque ? "#define OPAQUE" : "", + zt.colorspace_pars_fragment, + r0("linearToOutputTexel", e.outputColorSpace), + e.useDepthPacking ? "#define DEPTH_PACKING " + e.depthPacking : "", ` ` - ].filter(rr).join(` -`)), o = ra(o), o = Wl(o, t), o = ql(o, t), a = ra(a), a = Wl(a, t), a = ql(a, t), o = Xl(o), a = Xl(a), t.isWebGL2 && t.isRawShaderMaterial !== !0 && (g = `#version 300 es -`, x = [ + ].filter(vs).join(` +`)), a = _o(a), a = gh(a, e), a = _h(a, e), o = _o(o), o = gh(o, e), o = _h(o, e), a = xh(a), o = xh(o), e.isWebGL2 && e.isRawShaderMaterial !== !0 && (v = `#version 300 es +`, g = [ "precision mediump sampler2DArray;", "#define attribute in", "#define varying out", "#define texture2D texture" ].join(` `) + ` -` + x, v = [ +` + g, p = [ "#define varying in", - t.glslVersion === xl ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", - t.glslVersion === xl ? "" : "#define gl_FragColor pc_fragColor", + e.glslVersion === Cl ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", + e.glslVersion === Cl ? "" : "#define gl_FragColor pc_fragColor", "#define gl_FragDepthEXT gl_FragDepth", "#define texture2D texture", "#define textureCube texture", @@ -9362,85 +10604,82 @@ function hx(s, e, t, n) { "#define textureCubeGradEXT textureGrad" ].join(` `) + ` -` + v); - let p = g + x + o, _ = g + v + a, y = Gl(i, 35633, p), b = Gl(i, 35632, _); - if (i.attachShader(m, y), i.attachShader(m, b), t.index0AttributeName !== void 0 ? i.bindAttribLocation(m, 0, t.index0AttributeName) : t.morphTargets === !0 && i.bindAttribLocation(m, 0, "position"), i.linkProgram(m), s.debug.checkShaderErrors) { - let I = i.getProgramInfoLog(m).trim(), k = i.getShaderInfoLog(y).trim(), B = i.getShaderInfoLog(b).trim(), P = !0, w = !0; - if (i.getProgramParameter(m, 35714) === !1) { - P = !1; - let E = Vl(i, y, "vertex"), D = Vl(i, b, "fragment"); - console.error("THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(m, 35715) + ` +` + p); + let _ = v + g + a, y = v + p + o, b = ph(i, i.VERTEX_SHADER, _), w = ph(i, i.FRAGMENT_SHADER, y); + if (i.attachShader(x, b), i.attachShader(x, w), e.index0AttributeName !== void 0 ? i.bindAttribLocation(x, 0, e.index0AttributeName) : e.morphTargets === !0 && i.bindAttribLocation(x, 0, "position"), i.linkProgram(x), s1.debug.checkShaderErrors) { + let M = i.getProgramInfoLog(x).trim(), E = i.getShaderInfoLog(b).trim(), V = i.getShaderInfoLog(w).trim(), $ = !0, F = !0; + if (i.getProgramParameter(x, i.LINK_STATUS) === !1) if ($ = !1, typeof s1.debug.onShaderError == "function") s1.debug.onShaderError(i, x, b, w); + else { + let O = mh(i, b, "vertex"), z = mh(i, w, "fragment"); + console.error("THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(x, i.VALIDATE_STATUS) + ` -Program Info Log: ` + I + ` -` + E + ` -` + D); - } else I !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", I) : (k === "" || B === "") && (w = !1); - w && (this.diagnostics = { - runnable: P, - programLog: I, +Program Info Log: ` + M + ` +` + O + ` +` + z); + } + else M !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", M) : (E === "" || V === "") && (F = !1); + F && (this.diagnostics = { + runnable: $, + programLog: M, vertexShader: { - log: k, - prefix: x + log: E, + prefix: g }, fragmentShader: { - log: B, - prefix: v + log: V, + prefix: p } }); } - i.deleteShader(y), i.deleteShader(b); - let A; + i.deleteShader(b), i.deleteShader(w); + let R; this.getUniforms = function() { - return A === void 0 && (A = new bn(i, m)), A; + return R === void 0 && (R = new qi(i, x)), R; }; let L; return this.getAttributes = function() { - return L === void 0 && (L = ex(i, m)), L; + return L === void 0 && (L = l0(i, x)), L; }, this.destroy = function() { - n.releaseStatesOfProgram(this), i.deleteProgram(m), this.program = void 0; - }, this.name = t.shaderName, this.id = Yg++, this.cacheKey = e, this.usedTimes = 1, this.program = m, this.vertexShader = y, this.fragmentShader = b, this; + n.releaseStatesOfProgram(this), i.deleteProgram(x), this.program = void 0; + }, this.type = e.shaderType, this.name = e.shaderName, this.id = n0++, this.cacheKey = t, this.usedTimes = 1, this.program = x, this.vertexShader = b, this.fragmentShader = w, this; } -var ux = 0, gh = class { +var M0 = 0, xo = class { constructor(){ this.shaderCache = new Map, this.materialCache = new Map; } - update(e) { - let t = e.vertexShader, n = e.fragmentShader, i = this._getShaderStage(t), r = this._getShaderStage(n), o = this._getShaderCacheForMaterial(e); - return o.has(i) === !1 && (o.add(i), i.usedTimes++), o.has(r) === !1 && (o.add(r), r.usedTimes++), this; + update(t) { + let e = t.vertexShader, n = t.fragmentShader, i = this._getShaderStage(e), r = this._getShaderStage(n), a = this._getShaderCacheForMaterial(t); + return a.has(i) === !1 && (a.add(i), i.usedTimes++), a.has(r) === !1 && (a.add(r), r.usedTimes++), this; } - remove(e) { - let t = this.materialCache.get(e); - for (let n of t)n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n); - return this.materialCache.delete(e), 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; } - getVertexShaderID(e) { - return this._getShaderStage(e.vertexShader).id; + getVertexShaderID(t) { + return this._getShaderStage(t.vertexShader).id; } - getFragmentShaderID(e) { - return this._getShaderStage(e.fragmentShader).id; + getFragmentShaderID(t) { + return this._getShaderStage(t.fragmentShader).id; } dispose() { this.shaderCache.clear(), this.materialCache.clear(); } - _getShaderCacheForMaterial(e) { - let t = this.materialCache; - return t.has(e) === !1 && t.set(e, new Set), t.get(e); + _getShaderCacheForMaterial(t) { + let e = this.materialCache, n = e.get(t); + return n === void 0 && (n = new Set, e.set(t, n)), n; } - _getShaderStage(e) { - let t = this.shaderCache; - if (t.has(e) === !1) { - let n = new xh; - t.set(e, n); - } - return t.get(e); + _getShaderStage(t) { + let e = this.shaderCache, n = e.get(t); + return n === void 0 && (n = new vo(t), e.set(t, n)), n; } -}, xh = class { - constructor(){ - this.id = ux++, this.usedTimes = 0; +}, vo = class { + constructor(t){ + this.id = M0++, this.code = t, this.usedTimes = 0; } }; -function dx(s, e, t, n, i, r, o) { - let a = new Js, l = new gh, c = [], h = i.isWebGL2, u = i.logarithmicDepthBuffer, d = i.floatVertexTextures, f = i.maxVertexUniforms, m = i.vertexTextures, x = i.precision, v = { +function S0(s1, t, e, n, i, r, a) { + let o = new Rs, c = new xo, l = [], h = i.isWebGL2, u = i.logarithmicDepthBuffer, d = i.vertexTextures, f = i.precision, m = { MeshDepthMaterial: "depth", MeshDistanceMaterial: "distanceRGBA", MeshNormalMaterial: "normal", @@ -9457,219 +10696,240 @@ function dx(s, e, t, n, i, r, o) { ShadowMaterial: "shadow", SpriteMaterial: "sprite" }; - function g(w) { - let D = w.skeleton.bones; - if (d) return 1024; - { - let F = Math.floor((f - 20) / 4), O = Math.min(F, D.length); - return O < D.length ? (console.warn("THREE.WebGLRenderer: Skeleton has " + D.length + " bones. This GPU supports " + O + "."), 0) : O; - } - } - function p(w) { - let E; - return w && w.isTexture ? E = w.encoding : w && w.isWebGLRenderTarget ? (console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."), E = w.texture.encoding) : E = Nt, h && w && w.isTexture && w.format === ct && w.type === rn && w.encoding === Oi && (E = Nt), E; - } - function _(w, E, D, U, F) { - let O = U.fog, ne = w.isMeshStandardMaterial ? U.environment : null, ce = (w.isMeshStandardMaterial ? t : e).get(w.envMap || ne), V = v[w.type], W = F.isSkinnedMesh ? g(F) : 0; - w.precision !== null && (x = i.getMaxPrecision(w.precision), x !== w.precision && console.warn("THREE.WebGLProgram.getParameters:", w.precision, "not supported, using", x, "instead.")); - let he, le, fe, Be; - if (V) { - let xe = qt[V]; - he = xe.vertexShader, le = xe.fragmentShader; - } else he = w.vertexShader, le = w.fragmentShader, l.update(w), fe = l.getVertexShaderID(w), Be = l.getFragmentShaderID(w); - let Y = s.getRenderTarget(), Ce = w.alphaTest > 0, ye = w.clearcoat > 0; - return { + function x(M) { + return M === 0 ? "uv" : `uv${M}`; + } + function g(M, E, V, $, F) { + let O = $.fog, z = F.geometry, K = M.isMeshStandardMaterial ? $.environment : null, X = (M.isMeshStandardMaterial ? e : t).get(M.envMap || K), Y = X && X.mapping === Hs ? X.image.height : null, j = m[M.type]; + M.precision !== null && (f = i.getMaxPrecision(M.precision), f !== M.precision && console.warn("THREE.WebGLProgram.getParameters:", M.precision, "not supported, using", f, "instead.")); + let tt = z.morphAttributes.position || z.morphAttributes.normal || z.morphAttributes.color, N = tt !== void 0 ? tt.length : 0, q = 0; + z.morphAttributes.position !== void 0 && (q = 1), z.morphAttributes.normal !== void 0 && (q = 2), z.morphAttributes.color !== void 0 && (q = 3); + let lt, ut, pt, Et; + if (j) { + let jt = en[j]; + lt = jt.vertexShader, ut = jt.fragmentShader; + } else lt = M.vertexShader, ut = M.fragmentShader, c.update(M), pt = c.getVertexShaderID(M), Et = c.getFragmentShaderID(M); + let Tt = s1.getRenderTarget(), wt = F.isInstancedMesh === !0, Yt = !!M.map, te = !!M.matcap, Pt = !!X, P = !!M.aoMap, at = !!M.lightMap, Z = !!M.bumpMap, st = !!M.normalMap, Q = !!M.displacementMap, St = !!M.emissiveMap, mt = !!M.metalnessMap, xt = !!M.roughnessMap, Dt = M.anisotropy > 0, Xt = M.clearcoat > 0, ie = M.iridescence > 0, C = M.sheen > 0, S = M.transmission > 0, B = Dt && !!M.anisotropyMap, nt = Xt && !!M.clearcoatMap, et = Xt && !!M.clearcoatNormalMap, it = Xt && !!M.clearcoatRoughnessMap, Mt = ie && !!M.iridescenceMap, rt = ie && !!M.iridescenceThicknessMap, k = C && !!M.sheenColorMap, Rt = C && !!M.sheenRoughnessMap, bt = !!M.specularMap, At = !!M.specularColorMap, vt = !!M.specularIntensityMap, yt = S && !!M.transmissionMap, Ht = S && !!M.thicknessMap, Qt = !!M.gradientMap, I = !!M.alphaMap, ht = M.alphaTest > 0, H = !!M.alphaHash, ot = !!M.extensions, dt = !!z.attributes.uv1, qt = !!z.attributes.uv2, ee = !!z.attributes.uv3, le = Dn; + return M.toneMapped && (Tt === null || Tt.isXRRenderTarget === !0) && (le = s1.toneMapping), { isWebGL2: h, - shaderID: V, - shaderName: w.type, - vertexShader: he, - fragmentShader: le, - defines: w.defines, - customVertexShaderID: fe, - customFragmentShaderID: Be, - isRawShaderMaterial: w.isRawShaderMaterial === !0, - glslVersion: w.glslVersion, - precision: x, - instancing: F.isInstancedMesh === !0, - instancingColor: F.isInstancedMesh === !0 && F.instanceColor !== null, - supportsVertexTextures: m, - outputEncoding: Y !== null ? p(Y.texture) : s.outputEncoding, - map: !!w.map, - mapEncoding: p(w.map), - matcap: !!w.matcap, - matcapEncoding: p(w.matcap), - envMap: !!ce, - envMapMode: ce && ce.mapping, - envMapEncoding: p(ce), - envMapCubeUV: !!ce && (ce.mapping === Pr || ce.mapping === Ws), - lightMap: !!w.lightMap, - lightMapEncoding: p(w.lightMap), - aoMap: !!w.aoMap, - emissiveMap: !!w.emissiveMap, - emissiveMapEncoding: p(w.emissiveMap), - bumpMap: !!w.bumpMap, - normalMap: !!w.normalMap, - objectSpaceNormalMap: w.normalMapType === zd, - tangentSpaceNormalMap: w.normalMapType === Hi, - clearcoat: ye, - clearcoatMap: ye && !!w.clearcoatMap, - clearcoatRoughnessMap: ye && !!w.clearcoatRoughnessMap, - clearcoatNormalMap: ye && !!w.clearcoatNormalMap, - displacementMap: !!w.displacementMap, - roughnessMap: !!w.roughnessMap, - metalnessMap: !!w.metalnessMap, - specularMap: !!w.specularMap, - specularIntensityMap: !!w.specularIntensityMap, - specularColorMap: !!w.specularColorMap, - specularColorMapEncoding: p(w.specularColorMap), - alphaMap: !!w.alphaMap, - alphaTest: Ce, - gradientMap: !!w.gradientMap, - sheen: w.sheen > 0, - sheenColorMap: !!w.sheenColorMap, - sheenColorMapEncoding: p(w.sheenColorMap), - sheenRoughnessMap: !!w.sheenRoughnessMap, - transmission: w.transmission > 0, - transmissionMap: !!w.transmissionMap, - thicknessMap: !!w.thicknessMap, - combine: w.combine, - vertexTangents: !!w.normalMap && !!F.geometry && !!F.geometry.attributes.tangent, - vertexColors: w.vertexColors, - vertexAlphas: w.vertexColors === !0 && !!F.geometry && !!F.geometry.attributes.color && F.geometry.attributes.color.itemSize === 4, - vertexUvs: !!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatMap || !!w.clearcoatRoughnessMap || !!w.clearcoatNormalMap || !!w.displacementMap || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || !!w.sheenColorMap || !!w.sheenRoughnessMap, - uvsVertexOnly: !(!!w.map || !!w.bumpMap || !!w.normalMap || !!w.specularMap || !!w.alphaMap || !!w.emissiveMap || !!w.roughnessMap || !!w.metalnessMap || !!w.clearcoatNormalMap || w.transmission > 0 || !!w.transmissionMap || !!w.thicknessMap || !!w.specularIntensityMap || !!w.specularColorMap || w.sheen > 0 || !!w.sheenColorMap || !!w.sheenRoughnessMap) && !!w.displacementMap, + shaderID: j, + shaderType: M.type, + shaderName: M.name, + vertexShader: lt, + fragmentShader: ut, + defines: M.defines, + customVertexShaderID: pt, + customFragmentShaderID: Et, + isRawShaderMaterial: M.isRawShaderMaterial === !0, + glslVersion: M.glslVersion, + precision: f, + instancing: wt, + instancingColor: wt && F.instanceColor !== null, + supportsVertexTextures: d, + outputColorSpace: Tt === null ? s1.outputColorSpace : Tt.isXRRenderTarget === !0 ? Tt.texture.colorSpace : nn, + map: Yt, + matcap: te, + envMap: Pt, + envMapMode: Pt && X.mapping, + envMapCubeUVHeight: Y, + aoMap: P, + lightMap: at, + bumpMap: Z, + normalMap: st, + displacementMap: d && Q, + emissiveMap: St, + normalMapObjectSpace: st && M.normalMapType === Tf, + normalMapTangentSpace: st && M.normalMapType === mi, + metalnessMap: mt, + roughnessMap: xt, + anisotropy: Dt, + anisotropyMap: B, + clearcoat: Xt, + clearcoatMap: nt, + clearcoatNormalMap: et, + clearcoatRoughnessMap: it, + iridescence: ie, + iridescenceMap: Mt, + iridescenceThicknessMap: rt, + sheen: C, + sheenColorMap: k, + sheenRoughnessMap: Rt, + specularMap: bt, + specularColorMap: At, + specularIntensityMap: vt, + transmission: S, + transmissionMap: yt, + thicknessMap: Ht, + gradientMap: Qt, + opaque: M.transparent === !1 && M.blending === Wi, + alphaMap: I, + alphaTest: ht, + alphaHash: H, + combine: M.combine, + mapUv: Yt && x(M.map.channel), + aoMapUv: P && x(M.aoMap.channel), + lightMapUv: at && x(M.lightMap.channel), + bumpMapUv: Z && x(M.bumpMap.channel), + normalMapUv: st && x(M.normalMap.channel), + displacementMapUv: Q && x(M.displacementMap.channel), + emissiveMapUv: St && x(M.emissiveMap.channel), + metalnessMapUv: mt && x(M.metalnessMap.channel), + roughnessMapUv: xt && x(M.roughnessMap.channel), + anisotropyMapUv: B && x(M.anisotropyMap.channel), + clearcoatMapUv: nt && x(M.clearcoatMap.channel), + clearcoatNormalMapUv: et && x(M.clearcoatNormalMap.channel), + clearcoatRoughnessMapUv: it && x(M.clearcoatRoughnessMap.channel), + iridescenceMapUv: Mt && x(M.iridescenceMap.channel), + iridescenceThicknessMapUv: rt && x(M.iridescenceThicknessMap.channel), + sheenColorMapUv: k && x(M.sheenColorMap.channel), + sheenRoughnessMapUv: Rt && x(M.sheenRoughnessMap.channel), + specularMapUv: bt && x(M.specularMap.channel), + specularColorMapUv: At && x(M.specularColorMap.channel), + specularIntensityMapUv: vt && x(M.specularIntensityMap.channel), + transmissionMapUv: yt && x(M.transmissionMap.channel), + thicknessMapUv: Ht && x(M.thicknessMap.channel), + alphaMapUv: I && x(M.alphaMap.channel), + vertexTangents: !!z.attributes.tangent && (st || Dt), + vertexColors: M.vertexColors, + vertexAlphas: M.vertexColors === !0 && !!z.attributes.color && z.attributes.color.itemSize === 4, + vertexUv1s: dt, + vertexUv2s: qt, + vertexUv3s: ee, + pointsUvs: F.isPoints === !0 && !!z.attributes.uv && (Yt || I), fog: !!O, - useFog: w.fog, + useFog: M.fog === !0, fogExp2: O && O.isFogExp2, - flatShading: !!w.flatShading, - sizeAttenuation: w.sizeAttenuation, + flatShading: M.flatShading === !0, + sizeAttenuation: M.sizeAttenuation === !0, logarithmicDepthBuffer: u, - skinning: F.isSkinnedMesh === !0 && W > 0, - maxBones: W, - useVertexTexture: d, - morphTargets: !!F.geometry && !!F.geometry.morphAttributes.position, - morphNormals: !!F.geometry && !!F.geometry.morphAttributes.normal, - morphTargetsCount: !!F.geometry && !!F.geometry.morphAttributes.position ? F.geometry.morphAttributes.position.length : 0, + skinning: F.isSkinnedMesh === !0, + morphTargets: z.morphAttributes.position !== void 0, + morphNormals: z.morphAttributes.normal !== void 0, + morphColors: z.morphAttributes.color !== void 0, + morphTargetsCount: N, + morphTextureStride: q, numDirLights: E.directional.length, numPointLights: E.point.length, numSpotLights: E.spot.length, + numSpotLightMaps: E.spotLightMap.length, numRectAreaLights: E.rectArea.length, numHemiLights: E.hemi.length, numDirLightShadows: E.directionalShadowMap.length, numPointLightShadows: E.pointShadowMap.length, numSpotLightShadows: E.spotShadowMap.length, - numClippingPlanes: o.numPlanes, - numClipIntersection: o.numIntersection, - format: w.format, - dithering: w.dithering, - shadowMapEnabled: s.shadowMap.enabled && D.length > 0, - shadowMapType: s.shadowMap.type, - toneMapping: w.toneMapped ? s.toneMapping : _n, - physicallyCorrectLights: s.physicallyCorrectLights, - premultipliedAlpha: w.premultipliedAlpha, - doubleSided: w.side === Ci, - flipSided: w.side === it, - depthPacking: w.depthPacking !== void 0 ? w.depthPacking : !1, - index0AttributeName: w.index0AttributeName, - extensionDerivatives: w.extensions && w.extensions.derivatives, - extensionFragDepth: w.extensions && w.extensions.fragDepth, - extensionDrawBuffers: w.extensions && w.extensions.drawBuffers, - extensionShaderTextureLOD: w.extensions && w.extensions.shaderTextureLOD, + numSpotLightShadowsWithMaps: E.numSpotLightShadowsWithMaps, + numClippingPlanes: a.numPlanes, + numClipIntersection: a.numIntersection, + dithering: M.dithering, + shadowMapEnabled: s1.shadowMap.enabled && V.length > 0, + shadowMapType: s1.shadowMap.type, + toneMapping: le, + useLegacyLights: s1._useLegacyLights, + premultipliedAlpha: M.premultipliedAlpha, + doubleSided: M.side === gn, + flipSided: M.side === De, + useDepthPacking: M.depthPacking >= 0, + depthPacking: M.depthPacking || 0, + index0AttributeName: M.index0AttributeName, + extensionDerivatives: ot && M.extensions.derivatives === !0, + extensionFragDepth: ot && M.extensions.fragDepth === !0, + extensionDrawBuffers: ot && M.extensions.drawBuffers === !0, + extensionShaderTextureLOD: ot && M.extensions.shaderTextureLOD === !0, rendererExtensionFragDepth: h || n.has("EXT_frag_depth"), rendererExtensionDrawBuffers: h || n.has("WEBGL_draw_buffers"), rendererExtensionShaderTextureLod: h || n.has("EXT_shader_texture_lod"), - customProgramCacheKey: w.customProgramCacheKey() + customProgramCacheKey: M.customProgramCacheKey() }; } - function y(w) { + function p(M) { let E = []; - if (w.shaderID ? E.push(w.shaderID) : (E.push(w.customVertexShaderID), E.push(w.customFragmentShaderID)), w.defines !== void 0) for(let D in w.defines)E.push(D), E.push(w.defines[D]); - return w.isRawShaderMaterial === !1 && (b(E, w), A(E, w), E.push(s.outputEncoding)), E.push(w.customProgramCacheKey), E.join(); + if (M.shaderID ? E.push(M.shaderID) : (E.push(M.customVertexShaderID), E.push(M.customFragmentShaderID)), M.defines !== void 0) for(let V in M.defines)E.push(V), E.push(M.defines[V]); + return M.isRawShaderMaterial === !1 && (v(E, M), _(E, M), E.push(s1.outputColorSpace)), E.push(M.customProgramCacheKey), E.join(); } - function b(w, E) { - w.push(E.precision), w.push(E.outputEncoding), w.push(E.mapEncoding), w.push(E.matcapEncoding), w.push(E.envMapMode), w.push(E.envMapEncoding), w.push(E.lightMapEncoding), w.push(E.emissiveMapEncoding), w.push(E.combine), w.push(E.vertexUvs), w.push(E.fogExp2), w.push(E.sizeAttenuation), w.push(E.maxBones), w.push(E.morphTargetsCount), w.push(E.numDirLights), w.push(E.numPointLights), w.push(E.numSpotLights), w.push(E.numHemiLights), w.push(E.numRectAreaLights), w.push(E.numDirLightShadows), w.push(E.numPointLightShadows), w.push(E.numSpotLightShadows), w.push(E.shadowMapType), w.push(E.toneMapping), w.push(E.numClippingPlanes), w.push(E.numClipIntersection), w.push(E.format), w.push(E.specularColorMapEncoding), w.push(E.sheenColorMapEncoding); + function v(M, E) { + M.push(E.precision), M.push(E.outputColorSpace), M.push(E.envMapMode), M.push(E.envMapCubeUVHeight), M.push(E.mapUv), M.push(E.alphaMapUv), M.push(E.lightMapUv), M.push(E.aoMapUv), M.push(E.bumpMapUv), M.push(E.normalMapUv), M.push(E.displacementMapUv), M.push(E.emissiveMapUv), M.push(E.metalnessMapUv), M.push(E.roughnessMapUv), M.push(E.anisotropyMapUv), M.push(E.clearcoatMapUv), M.push(E.clearcoatNormalMapUv), M.push(E.clearcoatRoughnessMapUv), M.push(E.iridescenceMapUv), M.push(E.iridescenceThicknessMapUv), M.push(E.sheenColorMapUv), M.push(E.sheenRoughnessMapUv), M.push(E.specularMapUv), M.push(E.specularColorMapUv), M.push(E.specularIntensityMapUv), M.push(E.transmissionMapUv), M.push(E.thicknessMapUv), M.push(E.combine), M.push(E.fogExp2), M.push(E.sizeAttenuation), M.push(E.morphTargetsCount), M.push(E.morphAttributeCount), M.push(E.numDirLights), M.push(E.numPointLights), M.push(E.numSpotLights), M.push(E.numSpotLightMaps), M.push(E.numHemiLights), M.push(E.numRectAreaLights), M.push(E.numDirLightShadows), M.push(E.numPointLightShadows), M.push(E.numSpotLightShadows), M.push(E.numSpotLightShadowsWithMaps), M.push(E.shadowMapType), M.push(E.toneMapping), M.push(E.numClippingPlanes), M.push(E.numClipIntersection), M.push(E.depthPacking); } - function A(w, E) { - a.disableAll(), E.isWebGL2 && a.enable(0), E.supportsVertexTextures && a.enable(1), E.instancing && a.enable(2), E.instancingColor && a.enable(3), E.map && a.enable(4), E.matcap && a.enable(5), E.envMap && a.enable(6), E.envMapCubeUV && a.enable(7), E.lightMap && a.enable(8), E.aoMap && a.enable(9), E.emissiveMap && a.enable(10), E.bumpMap && a.enable(11), E.normalMap && a.enable(12), E.objectSpaceNormalMap && a.enable(13), E.tangentSpaceNormalMap && a.enable(14), E.clearcoat && a.enable(15), E.clearcoatMap && a.enable(16), E.clearcoatRoughnessMap && a.enable(17), E.clearcoatNormalMap && a.enable(18), E.displacementMap && a.enable(19), E.specularMap && a.enable(20), E.roughnessMap && a.enable(21), E.metalnessMap && a.enable(22), E.gradientMap && a.enable(23), E.alphaMap && a.enable(24), E.alphaTest && a.enable(25), E.vertexColors && a.enable(26), E.vertexAlphas && a.enable(27), E.vertexUvs && a.enable(28), E.vertexTangents && a.enable(29), E.uvsVertexOnly && a.enable(30), E.fog && a.enable(31), w.push(a.mask), a.disableAll(), E.useFog && a.enable(0), E.flatShading && a.enable(1), E.logarithmicDepthBuffer && a.enable(2), E.skinning && a.enable(3), E.useVertexTexture && a.enable(4), E.morphTargets && a.enable(5), E.morphNormals && a.enable(6), E.premultipliedAlpha && a.enable(7), E.shadowMapEnabled && a.enable(8), E.physicallyCorrectLights && a.enable(9), E.doubleSided && a.enable(10), E.flipSided && a.enable(11), E.depthPacking && a.enable(12), E.dithering && a.enable(13), E.specularIntensityMap && a.enable(14), E.specularColorMap && a.enable(15), E.transmission && a.enable(16), E.transmissionMap && a.enable(17), E.thicknessMap && a.enable(18), E.sheen && a.enable(19), E.sheenColorMap && a.enable(20), E.sheenRoughnessMap && a.enable(21), w.push(a.mask); + function _(M, E) { + o.disableAll(), E.isWebGL2 && o.enable(0), E.supportsVertexTextures && o.enable(1), E.instancing && o.enable(2), E.instancingColor && o.enable(3), E.matcap && o.enable(4), E.envMap && o.enable(5), E.normalMapObjectSpace && o.enable(6), E.normalMapTangentSpace && o.enable(7), E.clearcoat && o.enable(8), E.iridescence && o.enable(9), E.alphaTest && o.enable(10), E.vertexColors && o.enable(11), E.vertexAlphas && o.enable(12), E.vertexUv1s && o.enable(13), E.vertexUv2s && o.enable(14), E.vertexUv3s && o.enable(15), E.vertexTangents && o.enable(16), E.anisotropy && o.enable(17), M.push(o.mask), o.disableAll(), E.fog && o.enable(0), E.useFog && o.enable(1), E.flatShading && o.enable(2), E.logarithmicDepthBuffer && o.enable(3), E.skinning && o.enable(4), E.morphTargets && o.enable(5), E.morphNormals && o.enable(6), E.morphColors && o.enable(7), E.premultipliedAlpha && o.enable(8), E.shadowMapEnabled && o.enable(9), E.useLegacyLights && o.enable(10), E.doubleSided && o.enable(11), E.flipSided && o.enable(12), E.useDepthPacking && o.enable(13), E.dithering && o.enable(14), E.transmission && o.enable(15), E.sheen && o.enable(16), E.opaque && o.enable(17), E.pointsUvs && o.enable(18), M.push(o.mask); } - function L(w) { - let E = v[w.type], D; + function y(M) { + let E = m[M.type], V; if (E) { - let U = qt[E]; - D = uf.clone(U.uniforms); - } else D = w.uniforms; - return D; - } - function I(w, E) { - let D; - for(let U = 0, F = c.length; U < F; U++){ - let O = c[U]; + let $ = en[E]; + V = mp.clone($.uniforms); + } else V = M.uniforms; + return V; + } + function b(M, E) { + let V; + for(let $ = 0, F = l.length; $ < F; $++){ + let O = l[$]; if (O.cacheKey === E) { - D = O, ++D.usedTimes; + V = O, ++V.usedTimes; break; } } - return D === void 0 && (D = new hx(s, E, w, r), c.push(D)), D; + return V === void 0 && (V = new y0(s1, E, M, r), l.push(V)), V; } - function k(w) { - if (--w.usedTimes === 0) { - let E = c.indexOf(w); - c[E] = c[c.length - 1], c.pop(), w.destroy(); + function w(M) { + if (--M.usedTimes === 0) { + let E = l.indexOf(M); + l[E] = l[l.length - 1], l.pop(), M.destroy(); } } - function B(w) { - l.remove(w); + function R(M) { + c.remove(M); } - function P() { - l.dispose(); + function L() { + c.dispose(); } return { - getParameters: _, - getProgramCacheKey: y, - getUniforms: L, - acquireProgram: I, - releaseProgram: k, - releaseShaderCache: B, - programs: c, - dispose: P + getParameters: g, + getProgramCacheKey: p, + getUniforms: y, + acquireProgram: b, + releaseProgram: w, + releaseShaderCache: R, + programs: l, + dispose: L }; } -function fx() { - let s = new WeakMap; - function e(r) { - let o = s.get(r); - return o === void 0 && (o = {}, s.set(r, o)), o; - } +function b0() { + let s1 = new WeakMap; function t(r) { - s.delete(r); + let a = s1.get(r); + return a === void 0 && (a = {}, s1.set(r, a)), a; + } + function e(r) { + s1.delete(r); } - function n(r, o, a) { - s.get(r)[o] = a; + function n(r, a, o) { + s1.get(r)[a] = o; } function i() { - s = new WeakMap; + s1 = new WeakMap; } return { - get: e, - remove: t, + get: t, + remove: e, update: n, dispose: i }; } -function px(s, e) { - return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.material.id !== e.material.id ? s.material.id - e.material.id : s.z !== e.z ? s.z - e.z : s.id - e.id; +function E0(s1, t) { + return s1.groupOrder !== t.groupOrder ? s1.groupOrder - t.groupOrder : s1.renderOrder !== t.renderOrder ? s1.renderOrder - t.renderOrder : s1.material.id !== t.material.id ? s1.material.id - t.material.id : s1.z !== t.z ? s1.z - t.z : s1.id - t.id; } -function Yl(s, e) { - return s.groupOrder !== e.groupOrder ? s.groupOrder - e.groupOrder : s.renderOrder !== e.renderOrder ? s.renderOrder - e.renderOrder : s.z !== e.z ? e.z - s.z : s.id - e.id; +function yh(s1, t) { + return s1.groupOrder !== t.groupOrder ? s1.groupOrder - t.groupOrder : s1.renderOrder !== t.renderOrder ? s1.renderOrder - t.renderOrder : s1.z !== t.z ? t.z - s1.z : s1.id - t.id; } -function Zl() { - let s = [], e = 0, t = [], n = [], i = []; +function Mh() { + let s1 = [], t = 0, e = [], n = [], i = []; function r() { - e = 0, t.length = 0, n.length = 0, i.length = 0; + t = 0, e.length = 0, n.length = 0, i.length = 0; } - function o(u, d, f, m, x, v) { - let g = s[e]; - return g === void 0 ? (g = { + function a(u, d, f, m, x, g) { + let p = s1[t]; + return p === void 0 ? (p = { id: u.id, object: u, geometry: d, @@ -9677,72 +10937,72 @@ function Zl() { groupOrder: m, renderOrder: u.renderOrder, z: x, - group: v - }, s[e] = g) : (g.id = u.id, g.object = u, g.geometry = d, g.material = f, g.groupOrder = m, g.renderOrder = u.renderOrder, g.z = x, g.group = v), e++, g; + group: g + }, s1[t] = p) : (p.id = u.id, p.object = u, p.geometry = d, p.material = f, p.groupOrder = m, p.renderOrder = u.renderOrder, p.z = x, p.group = g), t++, p; } - function a(u, d, f, m, x, v) { - let g = o(u, d, f, m, x, v); - f.transmission > 0 ? n.push(g) : f.transparent === !0 ? i.push(g) : t.push(g); + function o(u, d, f, m, x, g) { + let p = a(u, d, f, m, x, g); + f.transmission > 0 ? n.push(p) : f.transparent === !0 ? i.push(p) : e.push(p); } - function l(u, d, f, m, x, v) { - let g = o(u, d, f, m, x, v); - f.transmission > 0 ? n.unshift(g) : f.transparent === !0 ? i.unshift(g) : t.unshift(g); + function c(u, d, f, m, x, g) { + let p = a(u, d, f, m, x, g); + f.transmission > 0 ? n.unshift(p) : f.transparent === !0 ? i.unshift(p) : e.unshift(p); } - function c(u, d) { - t.length > 1 && t.sort(u || px), n.length > 1 && n.sort(d || Yl), i.length > 1 && i.sort(d || Yl); + function l(u, d) { + e.length > 1 && e.sort(u || E0), n.length > 1 && n.sort(d || yh), i.length > 1 && i.sort(d || yh); } function h() { - for(let u = e, d = s.length; u < d; u++){ - let f = s[u]; + for(let u = t, d = s1.length; u < d; u++){ + let f = s1[u]; if (f.id === null) break; f.id = null, f.object = null, f.geometry = null, f.material = null, f.group = null; } } return { - opaque: t, + opaque: e, transmissive: n, transparent: i, init: r, - push: a, - unshift: l, + push: o, + unshift: c, finish: h, - sort: c + sort: l }; } -function mx() { - let s = new WeakMap; - function e(n, i) { - let r; - return s.has(n) === !1 ? (r = new Zl, s.set(n, [ - r - ])) : i >= s.get(n).length ? (r = new Zl, s.get(n).push(r)) : r = s.get(n)[i], r; +function T0() { + let s1 = new WeakMap; + function t(n, i) { + let r = s1.get(n), a; + return r === void 0 ? (a = new Mh, s1.set(n, [ + a + ])) : i >= r.length ? (a = new Mh, r.push(a)) : a = r[i], a; } - function t() { - s = new WeakMap; + function e() { + s1 = new WeakMap; } return { - get: e, - dispose: t + get: t, + dispose: e }; } -function gx() { - let s = {}; +function w0() { + let s1 = {}; return { - get: function(e) { - if (s[e.id] !== void 0) return s[e.id]; - let t; - switch(e.type){ + get: function(t) { + if (s1[t.id] !== void 0) return s1[t.id]; + let e; + switch(t.type){ case "DirectionalLight": - t = { - direction: new M, - color: new ae + e = { + direction: new A, + color: new ft }; break; case "SpotLight": - t = { - position: new M, - direction: new M, - color: new ae, + e = { + position: new A, + direction: new A, + color: new ft, distance: 0, coneCos: 0, penumbraCos: 0, @@ -9750,77 +11010,77 @@ function gx() { }; break; case "PointLight": - t = { - position: new M, - color: new ae, + e = { + position: new A, + color: new ft, distance: 0, decay: 0 }; break; case "HemisphereLight": - t = { - direction: new M, - skyColor: new ae, - groundColor: new ae + e = { + direction: new A, + skyColor: new ft, + groundColor: new ft }; break; case "RectAreaLight": - t = { - color: new ae, - position: new M, - halfWidth: new M, - halfHeight: new M + e = { + color: new ft, + position: new A, + halfWidth: new A, + halfHeight: new A }; break; } - return s[e.id] = t, t; + return s1[t.id] = e, e; } }; } -function xx() { - let s = {}; +function A0() { + let s1 = {}; return { - get: function(e) { - if (s[e.id] !== void 0) return s[e.id]; - let t; - switch(e.type){ + get: function(t) { + if (s1[t.id] !== void 0) return s1[t.id]; + let e; + switch(t.type){ case "DirectionalLight": - t = { + e = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, - shadowMapSize: new X + shadowMapSize: new J }; break; case "SpotLight": - t = { + e = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, - shadowMapSize: new X + shadowMapSize: new J }; break; case "PointLight": - t = { + e = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, - shadowMapSize: new X, + shadowMapSize: new J, shadowCameraNear: 1, shadowCameraFar: 1e3 }; break; } - return s[e.id] = t, t; + return s1[t.id] = e, e; } }; } -var yx = 0; -function vx(s, e) { - return (e.castShadow ? 1 : 0) - (s.castShadow ? 1 : 0); +var R0 = 0; +function C0(s1, t) { + return (t.castShadow ? 2 : 0) - (s1.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (s1.map ? 1 : 0); } -function _x(s, e) { - let t = new gx, n = xx(), i = { +function P0(s1, t) { + let e = new w0, n = A0(), i = { version: 0, hash: { directionalLength: -1, @@ -9830,7 +11090,8 @@ function _x(s, e) { hemiLength: -1, numDirectionalShadows: -1, numPointShadows: -1, - numSpotShadows: -1 + numSpotShadows: -1, + numSpotMaps: -1 }, ambient: [ 0, @@ -9843,9 +11104,10 @@ function _x(s, e) { directionalShadowMap: [], directionalShadowMatrix: [], spot: [], + spotLightMap: [], spotShadow: [], spotShadowMap: [], - spotShadowMatrix: [], + spotLightMatrix: [], rectArea: [], rectAreaLTC1: null, rectAreaLTC2: null, @@ -9853,150 +11115,147 @@ function _x(s, e) { pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], - hemi: [] + hemi: [], + numSpotLightShadowsWithMaps: 0 }; - for(let h = 0; h < 9; h++)i.probe.push(new M); - let r = new M, o = new pe, a = new pe; - function l(h, u) { + for(let h = 0; h < 9; h++)i.probe.push(new A); + let r = new A, a = new Ot, o = new Ot; + function c(h, u) { let d = 0, f = 0, m = 0; - for(let k = 0; k < 9; k++)i.probe[k].set(0, 0, 0); - let x = 0, v = 0, g = 0, p = 0, _ = 0, y = 0, b = 0, A = 0; - h.sort(vx); - let L = u !== !0 ? Math.PI : 1; - for(let k = 0, B = h.length; k < B; k++){ - let P = h[k], w = P.color, E = P.intensity, D = P.distance, U = P.shadow && P.shadow.map ? P.shadow.map.texture : null; - if (P.isAmbientLight) d += w.r * E * L, f += w.g * E * L, m += w.b * E * L; - else if (P.isLightProbe) for(let F = 0; F < 9; F++)i.probe[F].addScaledVector(P.sh.coefficients[F], E); - else if (P.isDirectionalLight) { - let F = t.get(P); - if (F.color.copy(P.color).multiplyScalar(P.intensity * L), P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.directionalShadow[x] = ne, i.directionalShadowMap[x] = U, i.directionalShadowMatrix[x] = P.shadow.matrix, y++; + for(let V = 0; V < 9; V++)i.probe[V].set(0, 0, 0); + let x = 0, g = 0, p = 0, v = 0, _ = 0, y = 0, b = 0, w = 0, R = 0, L = 0; + h.sort(C0); + let M = u === !0 ? Math.PI : 1; + for(let V = 0, $ = h.length; V < $; V++){ + let F = h[V], O = F.color, z = F.intensity, K = F.distance, X = F.shadow && F.shadow.map ? F.shadow.map.texture : null; + if (F.isAmbientLight) d += O.r * z * M, f += O.g * z * M, m += O.b * z * M; + else if (F.isLightProbe) for(let Y = 0; Y < 9; Y++)i.probe[Y].addScaledVector(F.sh.coefficients[Y], z); + else if (F.isDirectionalLight) { + let Y = e.get(F); + if (Y.color.copy(F.color).multiplyScalar(F.intensity * M), F.castShadow) { + let j = F.shadow, tt = n.get(F); + tt.shadowBias = j.bias, tt.shadowNormalBias = j.normalBias, tt.shadowRadius = j.radius, tt.shadowMapSize = j.mapSize, i.directionalShadow[x] = tt, i.directionalShadowMap[x] = X, i.directionalShadowMatrix[x] = F.shadow.matrix, y++; } - i.directional[x] = F, x++; - } else if (P.isSpotLight) { - let F = t.get(P); - if (F.position.setFromMatrixPosition(P.matrixWorld), F.color.copy(w).multiplyScalar(E * L), F.distance = D, F.coneCos = Math.cos(P.angle), F.penumbraCos = Math.cos(P.angle * (1 - P.penumbra)), F.decay = P.decay, P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, i.spotShadow[g] = ne, i.spotShadowMap[g] = U, i.spotShadowMatrix[g] = P.shadow.matrix, A++; + i.directional[x] = Y, x++; + } else if (F.isSpotLight) { + let Y = e.get(F); + Y.position.setFromMatrixPosition(F.matrixWorld), Y.color.copy(O).multiplyScalar(z * M), Y.distance = K, Y.coneCos = Math.cos(F.angle), Y.penumbraCos = Math.cos(F.angle * (1 - F.penumbra)), Y.decay = F.decay, i.spot[p] = Y; + let j = F.shadow; + if (F.map && (i.spotLightMap[R] = F.map, R++, j.updateMatrices(F), F.castShadow && L++), i.spotLightMatrix[p] = j.matrix, F.castShadow) { + let tt = n.get(F); + tt.shadowBias = j.bias, tt.shadowNormalBias = j.normalBias, tt.shadowRadius = j.radius, tt.shadowMapSize = j.mapSize, i.spotShadow[p] = tt, i.spotShadowMap[p] = X, w++; } - i.spot[g] = F, g++; - } else if (P.isRectAreaLight) { - let F = t.get(P); - F.color.copy(w).multiplyScalar(E), F.halfWidth.set(P.width * .5, 0, 0), F.halfHeight.set(0, P.height * .5, 0), i.rectArea[p] = F, p++; - } else if (P.isPointLight) { - let F = t.get(P); - if (F.color.copy(P.color).multiplyScalar(P.intensity * L), F.distance = P.distance, F.decay = P.decay, P.castShadow) { - let O = P.shadow, ne = n.get(P); - ne.shadowBias = O.bias, ne.shadowNormalBias = O.normalBias, ne.shadowRadius = O.radius, ne.shadowMapSize = O.mapSize, ne.shadowCameraNear = O.camera.near, ne.shadowCameraFar = O.camera.far, i.pointShadow[v] = ne, i.pointShadowMap[v] = U, i.pointShadowMatrix[v] = P.shadow.matrix, b++; + p++; + } else if (F.isRectAreaLight) { + let Y = e.get(F); + Y.color.copy(O).multiplyScalar(z), Y.halfWidth.set(F.width * .5, 0, 0), Y.halfHeight.set(0, F.height * .5, 0), i.rectArea[v] = Y, v++; + } else if (F.isPointLight) { + let Y = e.get(F); + if (Y.color.copy(F.color).multiplyScalar(F.intensity * M), Y.distance = F.distance, Y.decay = F.decay, F.castShadow) { + let j = F.shadow, tt = n.get(F); + tt.shadowBias = j.bias, tt.shadowNormalBias = j.normalBias, tt.shadowRadius = j.radius, tt.shadowMapSize = j.mapSize, tt.shadowCameraNear = j.camera.near, tt.shadowCameraFar = j.camera.far, i.pointShadow[g] = tt, i.pointShadowMap[g] = X, i.pointShadowMatrix[g] = F.shadow.matrix, b++; } - i.point[v] = F, v++; - } else if (P.isHemisphereLight) { - let F = t.get(P); - F.skyColor.copy(P.color).multiplyScalar(E * L), F.groundColor.copy(P.groundColor).multiplyScalar(E * L), i.hemi[_] = F, _++; + i.point[g] = Y, g++; + } else if (F.isHemisphereLight) { + let Y = e.get(F); + Y.skyColor.copy(F.color).multiplyScalar(z * M), Y.groundColor.copy(F.groundColor).multiplyScalar(z * M), i.hemi[_] = Y, _++; } } - p > 0 && (e.isWebGL2 || s.has("OES_texture_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_FLOAT_1, i.rectAreaLTC2 = ie.LTC_FLOAT_2) : s.has("OES_texture_half_float_linear") === !0 ? (i.rectAreaLTC1 = ie.LTC_HALF_1, i.rectAreaLTC2 = ie.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), i.ambient[0] = d, i.ambient[1] = f, i.ambient[2] = m; - let I = i.hash; - (I.directionalLength !== x || I.pointLength !== v || I.spotLength !== g || I.rectAreaLength !== p || I.hemiLength !== _ || I.numDirectionalShadows !== y || I.numPointShadows !== b || I.numSpotShadows !== A) && (i.directional.length = x, i.spot.length = g, i.rectArea.length = p, i.point.length = v, i.hemi.length = _, i.directionalShadow.length = y, i.directionalShadowMap.length = y, i.pointShadow.length = b, i.pointShadowMap.length = b, i.spotShadow.length = A, i.spotShadowMap.length = A, i.directionalShadowMatrix.length = y, i.pointShadowMatrix.length = b, i.spotShadowMatrix.length = A, I.directionalLength = x, I.pointLength = v, I.spotLength = g, I.rectAreaLength = p, I.hemiLength = _, I.numDirectionalShadows = y, I.numPointShadows = b, I.numSpotShadows = A, i.version = yx++); + v > 0 && (t.isWebGL2 || s1.has("OES_texture_float_linear") === !0 ? (i.rectAreaLTC1 = ct.LTC_FLOAT_1, i.rectAreaLTC2 = ct.LTC_FLOAT_2) : s1.has("OES_texture_half_float_linear") === !0 ? (i.rectAreaLTC1 = ct.LTC_HALF_1, i.rectAreaLTC2 = ct.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), i.ambient[0] = d, i.ambient[1] = f, i.ambient[2] = m; + let E = i.hash; + (E.directionalLength !== x || E.pointLength !== g || E.spotLength !== p || E.rectAreaLength !== v || E.hemiLength !== _ || E.numDirectionalShadows !== y || E.numPointShadows !== b || E.numSpotShadows !== w || E.numSpotMaps !== R) && (i.directional.length = x, i.spot.length = p, i.rectArea.length = v, i.point.length = g, i.hemi.length = _, i.directionalShadow.length = y, i.directionalShadowMap.length = y, i.pointShadow.length = b, i.pointShadowMap.length = b, i.spotShadow.length = w, i.spotShadowMap.length = w, i.directionalShadowMatrix.length = y, i.pointShadowMatrix.length = b, i.spotLightMatrix.length = w + R - L, i.spotLightMap.length = R, i.numSpotLightShadowsWithMaps = L, E.directionalLength = x, E.pointLength = g, E.spotLength = p, E.rectAreaLength = v, E.hemiLength = _, E.numDirectionalShadows = y, E.numPointShadows = b, E.numSpotShadows = w, E.numSpotMaps = R, i.version = R0++); } - function c(h, u) { - let d = 0, f = 0, m = 0, x = 0, v = 0, g = u.matrixWorldInverse; - for(let p = 0, _ = h.length; p < _; p++){ - let y = h[p]; + function l(h, u) { + let d = 0, f = 0, m = 0, x = 0, g = 0, p = u.matrixWorldInverse; + for(let v = 0, _ = h.length; v < _; v++){ + let y = h[v]; if (y.isDirectionalLight) { let b = i.directional[d]; - b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), d++; + b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(p), d++; } else if (y.isSpotLight) { let b = i.spot[m]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(g), m++; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(p), b.direction.setFromMatrixPosition(y.matrixWorld), r.setFromMatrixPosition(y.target.matrixWorld), b.direction.sub(r), b.direction.transformDirection(p), m++; } else if (y.isRectAreaLight) { let b = i.rectArea[x]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), a.identity(), o.copy(y.matrixWorld), o.premultiply(g), a.extractRotation(o), b.halfWidth.set(y.width * .5, 0, 0), b.halfHeight.set(0, y.height * .5, 0), b.halfWidth.applyMatrix4(a), b.halfHeight.applyMatrix4(a), x++; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(p), o.identity(), a.copy(y.matrixWorld), a.premultiply(p), o.extractRotation(a), b.halfWidth.set(y.width * .5, 0, 0), b.halfHeight.set(0, y.height * .5, 0), b.halfWidth.applyMatrix4(o), b.halfHeight.applyMatrix4(o), x++; } else if (y.isPointLight) { let b = i.point[f]; - b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(g), f++; + b.position.setFromMatrixPosition(y.matrixWorld), b.position.applyMatrix4(p), f++; } else if (y.isHemisphereLight) { - let b = i.hemi[v]; - b.direction.setFromMatrixPosition(y.matrixWorld), b.direction.transformDirection(g), b.direction.normalize(), v++; + let b = i.hemi[g]; + b.direction.setFromMatrixPosition(y.matrixWorld), b.direction.transformDirection(p), g++; } } } return { - setup: l, - setupView: c, + setup: c, + setupView: l, state: i }; } -function $l(s, e) { - let t = new _x(s, e), n = [], i = []; +function Sh(s1, t) { + let e = new P0(s1, t), n = [], i = []; function r() { n.length = 0, i.length = 0; } - function o(u) { + function a(u) { n.push(u); } - function a(u) { + function o(u) { i.push(u); } - function l(u) { - t.setup(n, u); - } function c(u) { - t.setupView(n, u); + e.setup(n, u); + } + function l(u) { + e.setupView(n, u); } return { init: r, state: { lightsArray: n, shadowsArray: i, - lights: t + lights: e }, - setupLights: l, - setupLightsView: c, - pushLight: o, - pushShadow: a + setupLights: c, + setupLightsView: l, + pushLight: a, + pushShadow: o }; } -function Mx(s, e) { - let t = new WeakMap; - function n(r, o = 0) { - let a; - return t.has(r) === !1 ? (a = new $l(s, e), t.set(r, [ - a - ])) : o >= t.get(r).length ? (a = new $l(s, e), t.get(r).push(a)) : a = t.get(r)[o], a; +function L0(s1, t) { + let e = new WeakMap; + function n(r, a = 0) { + let o = e.get(r), c; + return o === void 0 ? (c = new Sh(s1, t), e.set(r, [ + c + ])) : a >= o.length ? (c = new Sh(s1, t), o.push(c)) : c = o[a], c; } function i() { - t = new WeakMap; + e = new WeakMap; } return { get: n, dispose: i }; } -var eo = class extends dt { - constructor(e){ - super(); - this.type = "MeshDepthMaterial", this.depthPacking = Nd, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.setValues(e); +var $r = class extends Me { + constructor(t){ + super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = bf, 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(e) { - return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this; + 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; } -}; -eo.prototype.isMeshDepthMaterial = !0; -var to = class extends dt { - constructor(e){ - super(); - this.type = "MeshDistanceMaterial", this.referencePosition = new M, this.nearDistance = 1, this.farDistance = 1e3, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.fog = !1, this.setValues(e); +}, Kr = class extends Me { + 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(e) { - return super.copy(e), this.referencePosition.copy(e.referencePosition), this.nearDistance = e.nearDistance, this.farDistance = e.farDistance, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this; + 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; } -}; -to.prototype.isMeshDistanceMaterial = !0; -var bx = `void main() { +}, I0 = `void main() { gl_Position = vec4( position, 1.0 ); -}`, wx = `uniform sampler2D shadow_pass; +}`, U0 = `uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include @@ -10023,14 +11282,14 @@ void main() { float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`; -function yh(s, e, t) { - let n = new Dr, i = new X, r = new X, o = new Ve, a = new eo({ - depthPacking: Bd - }), l = new to, c = {}, h = t.maxTextureSize, u = { - 0: it, - 1: Ai, - 2: Ci - }, d = new sn({ +function D0(s1, t, e) { + let n = new Ps, i = new J, r = new J, a = new $t, o = new $r({ + depthPacking: Ef + }), c = new Kr, l = {}, h = e.maxTextureSize, u = { + [On]: De, + [De]: On, + [gn]: gn + }, d = new Qe({ defines: { VSM_SAMPLES: 8 }, @@ -10039,18 +11298,18 @@ function yh(s, e, t) { value: null }, resolution: { - value: new X + value: new J }, radius: { value: 4 } }, - vertexShader: bx, - fragmentShader: wx + vertexShader: I0, + fragmentShader: U0 }), f = d.clone(); f.defines.HORIZONTAL_PASS = 1; - let m = new _e; - m.setAttribute("position", new Ue(new Float32Array([ + let m = new Vt; + m.setAttribute("position", new Kt(new Float32Array([ -1, -1, .5, @@ -10061,1547 +11320,1892 @@ function yh(s, e, t) { 3, .5 ]), 3)); - let x = new st(m, d), v = this; - this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Hc, this.render = function(y, b, A) { - if (v.enabled === !1 || v.autoUpdate === !1 && v.needsUpdate === !1 || y.length === 0) return; - let L = s.getRenderTarget(), I = s.getActiveCubeFace(), k = s.getActiveMipmapLevel(), B = s.state; - B.setBlending(vn), B.buffers.color.setClear(1, 1, 1, 1), B.buffers.depth.setTest(!0), B.setScissorTest(!1); - for(let P = 0, w = y.length; P < w; P++){ - let E = y[P], D = E.shadow; - if (D === void 0) { - console.warn("THREE.WebGLShadowMap:", E, "has no shadow."); + let x = new ve(m, d), g = this; + this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = nd; + let p = this.type; + this.render = function(b, w, R) { + if (g.enabled === !1 || g.autoUpdate === !1 && g.needsUpdate === !1 || b.length === 0) return; + let L = s1.getRenderTarget(), M = s1.getActiveCubeFace(), E = s1.getActiveMipmapLevel(), V = s1.state; + V.setBlending(Un), V.buffers.color.setClear(1, 1, 1, 1), V.buffers.depth.setTest(!0), V.setScissorTest(!1); + let $ = p !== pn && this.type === pn, F = p === pn && this.type !== pn; + for(let O = 0, z = b.length; O < z; O++){ + let K = b[O], X = K.shadow; + if (X === void 0) { + console.warn("THREE.WebGLShadowMap:", K, "has no shadow."); continue; } - if (D.autoUpdate === !1 && D.needsUpdate === !1) continue; - i.copy(D.mapSize); - let U = D.getFrameExtents(); - if (i.multiply(U), r.copy(D.mapSize), (i.x > h || i.y > h) && (i.x > h && (r.x = Math.floor(h / U.x), i.x = r.x * U.x, D.mapSize.x = r.x), i.y > h && (r.y = Math.floor(h / U.y), i.y = r.y * U.y, D.mapSize.y = r.y)), D.map === null && !D.isPointLightShadow && this.type === ir) { - let O = { - minFilter: tt, - magFilter: tt, - format: ct - }; - D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.mapPass = new At(i.x, i.y, O), D.camera.updateProjectionMatrix(); - } - if (D.map === null) { - let O = { - minFilter: rt, - magFilter: rt, - format: ct - }; - D.map = new At(i.x, i.y, O), D.map.texture.name = E.name + ".shadowMap", D.camera.updateProjectionMatrix(); + if (X.autoUpdate === !1 && X.needsUpdate === !1) continue; + i.copy(X.mapSize); + let Y = X.getFrameExtents(); + if (i.multiply(Y), r.copy(X.mapSize), (i.x > h || i.y > h) && (i.x > h && (r.x = Math.floor(h / Y.x), i.x = r.x * Y.x, X.mapSize.x = r.x), i.y > h && (r.y = Math.floor(h / Y.y), i.y = r.y * Y.y, X.mapSize.y = r.y)), X.map === null || $ === !0 || F === !0) { + let tt = this.type !== pn ? { + minFilter: fe, + magFilter: fe + } : {}; + X.map !== null && X.map.dispose(), X.map = new Ge(i.x, i.y, tt), X.map.texture.name = K.name + ".shadowMap", X.camera.updateProjectionMatrix(); } - s.setRenderTarget(D.map), s.clear(); - let F = D.getViewportCount(); - for(let O = 0; O < F; O++){ - let ne = D.getViewport(O); - o.set(r.x * ne.x, r.y * ne.y, r.x * ne.z, r.y * ne.w), B.viewport(o), D.updateMatrices(E, O), n = D.getFrustum(), _(b, A, D.camera, E, this.type); + s1.setRenderTarget(X.map), s1.clear(); + let j = X.getViewportCount(); + for(let tt = 0; tt < j; tt++){ + let N = X.getViewport(tt); + a.set(r.x * N.x, r.y * N.y, r.x * N.z, r.y * N.w), V.viewport(a), X.updateMatrices(K, tt), n = X.getFrustum(), y(w, R, X.camera, K, this.type); } - !D.isPointLightShadow && this.type === ir && g(D, A), D.needsUpdate = !1; + X.isPointLightShadow !== !0 && this.type === pn && v(X, R), X.needsUpdate = !1; } - v.needsUpdate = !1, s.setRenderTarget(L, I, k); + p = this.type, g.needsUpdate = !1, s1.setRenderTarget(L, M, E); }; - function g(y, b) { - let A = e.update(x); - d.defines.VSM_SAMPLES !== y.blurSamples && (d.defines.VSM_SAMPLES = y.blurSamples, f.defines.VSM_SAMPLES = y.blurSamples, d.needsUpdate = !0, f.needsUpdate = !0), d.uniforms.shadow_pass.value = y.map.texture, d.uniforms.resolution.value = y.mapSize, d.uniforms.radius.value = y.radius, s.setRenderTarget(y.mapPass), s.clear(), s.renderBufferDirect(b, null, A, d, x, null), f.uniforms.shadow_pass.value = y.mapPass.texture, f.uniforms.resolution.value = y.mapSize, f.uniforms.radius.value = y.radius, s.setRenderTarget(y.map), s.clear(), s.renderBufferDirect(b, null, A, f, x, null); - } - function p(y, b, A, L, I, k, B) { - let P = null, w = L.isPointLight === !0 ? y.customDistanceMaterial : y.customDepthMaterial; - if (w !== void 0 ? P = w : P = L.isPointLight === !0 ? l : a, s.localClippingEnabled && A.clipShadows === !0 && A.clippingPlanes.length !== 0 || A.displacementMap && A.displacementScale !== 0 || A.alphaMap && A.alphaTest > 0) { - let E = P.uuid, D = A.uuid, U = c[E]; - U === void 0 && (U = {}, c[E] = U); - let F = U[D]; - F === void 0 && (F = P.clone(), U[D] = F), P = F; - } - return P.visible = A.visible, P.wireframe = A.wireframe, B === ir ? P.side = A.shadowSide !== null ? A.shadowSide : A.side : P.side = A.shadowSide !== null ? A.shadowSide : u[A.side], P.alphaMap = A.alphaMap, P.alphaTest = A.alphaTest, P.clipShadows = A.clipShadows, P.clippingPlanes = A.clippingPlanes, P.clipIntersection = A.clipIntersection, P.displacementMap = A.displacementMap, P.displacementScale = A.displacementScale, P.displacementBias = A.displacementBias, P.wireframeLinewidth = A.wireframeLinewidth, P.linewidth = A.linewidth, L.isPointLight === !0 && P.isMeshDistanceMaterial === !0 && (P.referencePosition.setFromMatrixPosition(L.matrixWorld), P.nearDistance = I, P.farDistance = k), P; - } - function _(y, b, A, L, I) { - if (y.visible === !1) return; - if (y.layers.test(b.layers) && (y.isMesh || y.isLine || y.isPoints) && (y.castShadow || y.receiveShadow && I === ir) && (!y.frustumCulled || n.intersectsObject(y))) { - y.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse, y.matrixWorld); - let P = e.update(y), w = y.material; - if (Array.isArray(w)) { - let E = P.groups; - for(let D = 0, U = E.length; D < U; D++){ - let F = E[D], O = w[F.materialIndex]; - if (O && O.visible) { - let ne = p(y, P, O, L, A.near, A.far, I); - s.renderBufferDirect(A, null, P, ne, y, F); + function v(b, w) { + let R = t.update(x); + d.defines.VSM_SAMPLES !== b.blurSamples && (d.defines.VSM_SAMPLES = b.blurSamples, f.defines.VSM_SAMPLES = b.blurSamples, d.needsUpdate = !0, f.needsUpdate = !0), b.mapPass === null && (b.mapPass = new Ge(i.x, i.y)), d.uniforms.shadow_pass.value = b.map.texture, d.uniforms.resolution.value = b.mapSize, d.uniforms.radius.value = b.radius, s1.setRenderTarget(b.mapPass), s1.clear(), s1.renderBufferDirect(w, null, R, d, x, null), f.uniforms.shadow_pass.value = b.mapPass.texture, f.uniforms.resolution.value = b.mapSize, f.uniforms.radius.value = b.radius, s1.setRenderTarget(b.map), s1.clear(), s1.renderBufferDirect(w, null, R, f, x, null); + } + function _(b, w, R, L) { + let M = null, E = R.isPointLight === !0 ? b.customDistanceMaterial : b.customDepthMaterial; + if (E !== void 0) M = E; + else if (M = R.isPointLight === !0 ? c : o, s1.localClippingEnabled && w.clipShadows === !0 && Array.isArray(w.clippingPlanes) && w.clippingPlanes.length !== 0 || w.displacementMap && w.displacementScale !== 0 || w.alphaMap && w.alphaTest > 0 || w.map && w.alphaTest > 0) { + let V = M.uuid, $ = w.uuid, F = l[V]; + F === void 0 && (F = {}, l[V] = F); + let O = F[$]; + O === void 0 && (O = M.clone(), F[$] = O), M = O; + } + if (M.visible = w.visible, M.wireframe = w.wireframe, L === pn ? M.side = w.shadowSide !== null ? w.shadowSide : w.side : M.side = w.shadowSide !== null ? w.shadowSide : u[w.side], M.alphaMap = w.alphaMap, M.alphaTest = w.alphaTest, M.map = w.map, M.clipShadows = w.clipShadows, M.clippingPlanes = w.clippingPlanes, M.clipIntersection = w.clipIntersection, M.displacementMap = w.displacementMap, M.displacementScale = w.displacementScale, M.displacementBias = w.displacementBias, M.wireframeLinewidth = w.wireframeLinewidth, M.linewidth = w.linewidth, R.isPointLight === !0 && M.isMeshDistanceMaterial === !0) { + let V = s1.properties.get(M); + V.light = R; + } + return M; + } + function y(b, w, R, L, M) { + if (b.visible === !1) return; + if (b.layers.test(w.layers) && (b.isMesh || b.isLine || b.isPoints) && (b.castShadow || b.receiveShadow && M === pn) && (!b.frustumCulled || n.intersectsObject(b))) { + b.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse, b.matrixWorld); + let $ = t.update(b), F = b.material; + if (Array.isArray(F)) { + let O = $.groups; + for(let z = 0, K = O.length; z < K; z++){ + let X = O[z], Y = F[X.materialIndex]; + if (Y && Y.visible) { + let j = _(b, Y, L, M); + s1.renderBufferDirect(R, null, $, j, b, X); } } - } else if (w.visible) { - let E = p(y, P, w, L, A.near, A.far, I); - s.renderBufferDirect(A, null, P, E, y, null); + } else if (F.visible) { + let O = _(b, F, L, M); + s1.renderBufferDirect(R, null, $, O, b, null); } } - let B = y.children; - for(let P = 0, w = B.length; P < w; P++)_(B[P], b, A, L, I); + let V = b.children; + for(let $ = 0, F = V.length; $ < F; $++)y(V[$], w, R, L, M); } } -function Sx(s, e, t) { - let n = t.isWebGL2; +function N0(s1, t, e) { + let n = e.isWebGL2; function i() { - let R = !1, ee = new Ve, Q = null, Ee = new Ve(0, 0, 0, 0); + let I = !1, ht = new $t, H = null, ot = new $t(0, 0, 0, 0); return { - setMask: function(me) { - Q !== me && !R && (s.colorMask(me, me, me, me), Q = me); + setMask: function(dt) { + H !== dt && !I && (s1.colorMask(dt, dt, dt, dt), H = dt); }, - setLocked: function(me) { - R = me; + setLocked: function(dt) { + I = dt; }, - setClear: function(me, Re, oe, Le, Xe) { - Xe === !0 && (me *= Le, Re *= Le, oe *= Le), ee.set(me, Re, oe, Le), Ee.equals(ee) === !1 && (s.clearColor(me, Re, oe, Le), Ee.copy(ee)); + setClear: function(dt, qt, ee, le, En) { + En === !0 && (dt *= le, qt *= le, ee *= le), ht.set(dt, qt, ee, le), ot.equals(ht) === !1 && (s1.clearColor(dt, qt, ee, le), ot.copy(ht)); }, reset: function() { - R = !1, Q = null, Ee.set(-1, 0, 0, 0); + I = !1, H = null, ot.set(-1, 0, 0, 0); } }; } function r() { - let R = !1, ee = null, Q = null, Ee = null; + let I = !1, ht = null, H = null, ot = null; return { - setTest: function(me) { - me ? le(2929) : fe(2929); + setTest: function(dt) { + dt ? Tt(s1.DEPTH_TEST) : wt(s1.DEPTH_TEST); }, - setMask: function(me) { - ee !== me && !R && (s.depthMask(me), ee = me); + setMask: function(dt) { + ht !== dt && !I && (s1.depthMask(dt), ht = dt); }, - setFunc: function(me) { - if (Q !== me) { - if (me) switch(me){ - case Eu: - s.depthFunc(512); + setFunc: function(dt) { + if (H !== dt) { + switch(dt){ + case $d: + s1.depthFunc(s1.NEVER); break; - case Au: - s.depthFunc(519); + case Kd: + s1.depthFunc(s1.ALWAYS); break; - case Cu: - s.depthFunc(513); + case Qd: + s1.depthFunc(s1.LESS); break; - case ea: - s.depthFunc(515); + case ao: + s1.depthFunc(s1.LEQUAL); break; - case Lu: - s.depthFunc(514); + case jd: + s1.depthFunc(s1.EQUAL); break; - case Ru: - s.depthFunc(518); + case tf: + s1.depthFunc(s1.GEQUAL); break; - case Pu: - s.depthFunc(516); + case ef: + s1.depthFunc(s1.GREATER); break; - case Iu: - s.depthFunc(517); + case nf: + s1.depthFunc(s1.NOTEQUAL); break; default: - s.depthFunc(515); + s1.depthFunc(s1.LEQUAL); } - else s.depthFunc(515); - Q = me; + H = dt; } }, - setLocked: function(me) { - R = me; + setLocked: function(dt) { + I = dt; }, - setClear: function(me) { - Ee !== me && (s.clearDepth(me), Ee = me); + setClear: function(dt) { + ot !== dt && (s1.clearDepth(dt), ot = dt); }, reset: function() { - R = !1, ee = null, Q = null, Ee = null; + I = !1, ht = null, H = null, ot = null; } }; } - function o() { - let R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; + function a() { + let I = !1, ht = null, H = null, ot = null, dt = null, qt = null, ee = null, le = null, En = null; return { - setTest: function(We) { - R || (We ? le(2960) : fe(2960)); + setTest: function(jt) { + I || (jt ? Tt(s1.STENCIL_TEST) : wt(s1.STENCIL_TEST)); }, - setMask: function(We) { - ee !== We && !R && (s.stencilMask(We), ee = We); + setMask: function(jt) { + ht !== jt && !I && (s1.stencilMask(jt), ht = jt); }, - setFunc: function(We, Ut, Ot) { - (Q !== We || Ee !== Ut || me !== Ot) && (s.stencilFunc(We, Ut, Ot), Q = We, Ee = Ut, me = Ot); + setFunc: function(jt, tn, Te) { + (H !== jt || ot !== tn || dt !== Te) && (s1.stencilFunc(jt, tn, Te), H = jt, ot = tn, dt = Te); }, - setOp: function(We, Ut, Ot) { - (Re !== We || oe !== Ut || Le !== Ot) && (s.stencilOp(We, Ut, Ot), Re = We, oe = Ut, Le = Ot); + setOp: function(jt, tn, Te) { + (qt !== jt || ee !== tn || le !== Te) && (s1.stencilOp(jt, tn, Te), qt = jt, ee = tn, le = Te); }, - setLocked: function(We) { - R = We; + setLocked: function(jt) { + I = jt; }, - setClear: function(We) { - Xe !== We && (s.clearStencil(We), Xe = We); + setClear: function(jt) { + En !== jt && (s1.clearStencil(jt), En = jt); }, reset: function() { - R = !1, ee = null, Q = null, Ee = null, me = null, Re = null, oe = null, Le = null, Xe = null; + I = !1, ht = null, H = null, ot = null, dt = null, qt = null, ee = null, le = null, En = null; } }; } - let a = new i, l = new r, c = new o, h = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, P = s.getParameter(35661), w = !1, E = 0, D = s.getParameter(7938); - D.indexOf("WebGL") !== -1 ? (E = parseFloat(/^WebGL (\d)/.exec(D)[1]), w = E >= 1) : D.indexOf("OpenGL ES") !== -1 && (E = parseFloat(/^OpenGL ES (\d)/.exec(D)[1]), w = E >= 2); - let U = null, F = {}, O = s.getParameter(3088), ne = s.getParameter(2978), ce = new Ve().fromArray(O), V = new Ve().fromArray(ne); - function W(R, ee, Q) { - let Ee = new Uint8Array(4), me = s.createTexture(); - s.bindTexture(R, me), s.texParameteri(R, 10241, 9728), s.texParameteri(R, 10240, 9728); - for(let Re = 0; Re < Q; Re++)s.texImage2D(ee + Re, 0, 6408, 1, 1, 0, 6408, 5121, Ee); - return me; - } - let he = {}; - he[3553] = W(3553, 3553, 1), he[34067] = W(34067, 34069, 6), a.setClear(0, 0, 0, 1), l.setClear(1), c.setClear(0), le(2929), l.setFunc(ea), Oe(!1), G(tl), le(2884), ge(vn); - function le(R) { - h[R] !== !0 && (s.enable(R), h[R] = !0); - } - function fe(R) { - h[R] !== !1 && (s.disable(R), h[R] = !1); - } - function Be(R, ee) { - return u[R] !== ee ? (s.bindFramebuffer(R, ee), u[R] = ee, n && (R === 36009 && (u[36160] = ee), R === 36160 && (u[36009] = ee)), !0) : !1; - } - function Y(R) { - return d !== R ? (s.useProgram(R), d = R, !0) : !1; - } - let Ce = { - [_i]: 32774, - [mu]: 32778, - [gu]: 32779 + let o = new i, c = new r, l = new a, h = new WeakMap, u = new WeakMap, d = {}, f = {}, m = new WeakMap, x = [], g = null, p = !1, v = null, _ = null, y = null, b = null, w = null, R = null, L = null, M = !1, E = null, V = null, $ = null, F = null, O = null, z = s1.getParameter(s1.MAX_COMBINED_TEXTURE_IMAGE_UNITS), K = !1, X = 0, Y = s1.getParameter(s1.VERSION); + Y.indexOf("WebGL") !== -1 ? (X = parseFloat(/^WebGL (\d)/.exec(Y)[1]), K = X >= 1) : Y.indexOf("OpenGL ES") !== -1 && (X = parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]), K = X >= 2); + let j = null, tt = {}, N = s1.getParameter(s1.SCISSOR_BOX), q = s1.getParameter(s1.VIEWPORT), lt = new $t().fromArray(N), ut = new $t().fromArray(q); + function pt(I, ht, H, ot) { + let dt = new Uint8Array(4), qt = s1.createTexture(); + s1.bindTexture(I, qt), s1.texParameteri(I, s1.TEXTURE_MIN_FILTER, s1.NEAREST), s1.texParameteri(I, s1.TEXTURE_MAG_FILTER, s1.NEAREST); + for(let ee = 0; ee < H; ee++)n && (I === s1.TEXTURE_3D || I === s1.TEXTURE_2D_ARRAY) ? s1.texImage3D(ht, 0, s1.RGBA, 1, 1, ot, 0, s1.RGBA, s1.UNSIGNED_BYTE, dt) : s1.texImage2D(ht + ee, 0, s1.RGBA, 1, 1, 0, s1.RGBA, s1.UNSIGNED_BYTE, dt); + return qt; + } + let Et = {}; + Et[s1.TEXTURE_2D] = pt(s1.TEXTURE_2D, s1.TEXTURE_2D, 1), Et[s1.TEXTURE_CUBE_MAP] = pt(s1.TEXTURE_CUBE_MAP, s1.TEXTURE_CUBE_MAP_POSITIVE_X, 6), n && (Et[s1.TEXTURE_2D_ARRAY] = pt(s1.TEXTURE_2D_ARRAY, s1.TEXTURE_2D_ARRAY, 1, 1), Et[s1.TEXTURE_3D] = pt(s1.TEXTURE_3D, s1.TEXTURE_3D, 1, 1)), o.setClear(0, 0, 0, 1), c.setClear(1), l.setClear(0), Tt(s1.DEPTH_TEST), c.setFunc(ao), Q(!1), St(tl), Tt(s1.CULL_FACE), Z(Un); + function Tt(I) { + d[I] !== !0 && (s1.enable(I), d[I] = !0); + } + function wt(I) { + d[I] !== !1 && (s1.disable(I), d[I] = !1); + } + function Yt(I, ht) { + return f[I] !== ht ? (s1.bindFramebuffer(I, ht), f[I] = ht, n && (I === s1.DRAW_FRAMEBUFFER && (f[s1.FRAMEBUFFER] = ht), I === s1.FRAMEBUFFER && (f[s1.DRAW_FRAMEBUFFER] = ht)), !0) : !1; + } + function te(I, ht) { + let H = x, ot = !1; + if (I) if (H = m.get(ht), H === void 0 && (H = [], m.set(ht, H)), I.isWebGLMultipleRenderTargets) { + let dt = I.texture; + if (H.length !== dt.length || H[0] !== s1.COLOR_ATTACHMENT0) { + for(let qt = 0, ee = dt.length; qt < ee; qt++)H[qt] = s1.COLOR_ATTACHMENT0 + qt; + H.length = dt.length, ot = !0; + } + } else H[0] !== s1.COLOR_ATTACHMENT0 && (H[0] = s1.COLOR_ATTACHMENT0, ot = !0); + else H[0] !== s1.BACK && (H[0] = s1.BACK, ot = !0); + ot && (e.isWebGL2 ? s1.drawBuffers(H) : t.get("WEBGL_draw_buffers").drawBuffersWEBGL(H)); + } + function Pt(I) { + return g !== I ? (s1.useProgram(I), g = I, !0) : !1; + } + let P = { + [Bi]: s1.FUNC_ADD, + [zd]: s1.FUNC_SUBTRACT, + [kd]: s1.FUNC_REVERSE_SUBTRACT }; - if (n) Ce[sl] = 32775, Ce[ol] = 32776; + if (n) P[sl] = s1.MIN, P[rl] = s1.MAX; else { - let R = e.get("EXT_blend_minmax"); - R !== null && (Ce[sl] = R.MIN_EXT, Ce[ol] = R.MAX_EXT); - } - let ye = { - [xu]: 0, - [yu]: 1, - [vu]: 768, - [Gc]: 770, - [Tu]: 776, - [wu]: 774, - [Mu]: 772, - [_u]: 769, - [Vc]: 771, - [Su]: 775, - [bu]: 773 + let I = t.get("EXT_blend_minmax"); + I !== null && (P[sl] = I.MIN_EXT, P[rl] = I.MAX_EXT); + } + let at = { + [Vd]: s1.ZERO, + [Hd]: s1.ONE, + [Gd]: s1.SRC_COLOR, + [id]: s1.SRC_ALPHA, + [Jd]: s1.SRC_ALPHA_SATURATE, + [Yd]: s1.DST_COLOR, + [Xd]: s1.DST_ALPHA, + [Wd]: s1.ONE_MINUS_SRC_COLOR, + [sd]: s1.ONE_MINUS_SRC_ALPHA, + [Zd]: s1.ONE_MINUS_DST_COLOR, + [qd]: s1.ONE_MINUS_DST_ALPHA }; - function ge(R, ee, Q, Ee, me, Re, oe, Le) { - if (R === vn) { - f === !0 && (fe(3042), f = !1); + function Z(I, ht, H, ot, dt, qt, ee, le) { + if (I === Un) { + p === !0 && (wt(s1.BLEND), p = !1); return; } - if (f === !1 && (le(3042), f = !0), R !== pu) { - if (R !== m || Le !== b) { - if ((x !== _i || p !== _i) && (s.blendEquation(32774), x = _i, p = _i), Le) switch(R){ - case sr: - s.blendFuncSeparate(1, 771, 1, 771); + if (p === !1 && (Tt(s1.BLEND), p = !0), I !== Bd) { + if (I !== v || le !== M) { + if ((_ !== Bi || w !== Bi) && (s1.blendEquation(s1.FUNC_ADD), _ = Bi, w = Bi), le) switch(I){ + case Wi: + s1.blendFuncSeparate(s1.ONE, s1.ONE_MINUS_SRC_ALPHA, s1.ONE, s1.ONE_MINUS_SRC_ALPHA); + break; + case el: + s1.blendFunc(s1.ONE, s1.ONE); break; case nl: - s.blendFunc(1, 1); + s1.blendFuncSeparate(s1.ZERO, s1.ONE_MINUS_SRC_COLOR, s1.ZERO, s1.ONE); break; case il: - s.blendFuncSeparate(0, 0, 769, 771); - break; - case rl: - s.blendFuncSeparate(0, 768, 0, 770); + s1.blendFuncSeparate(s1.ZERO, s1.SRC_COLOR, s1.ZERO, s1.SRC_ALPHA); break; default: - console.error("THREE.WebGLState: Invalid blending: ", R); + console.error("THREE.WebGLState: Invalid blending: ", I); break; } - else switch(R){ - case sr: - s.blendFuncSeparate(770, 771, 1, 771); + else switch(I){ + case Wi: + s1.blendFuncSeparate(s1.SRC_ALPHA, s1.ONE_MINUS_SRC_ALPHA, s1.ONE, s1.ONE_MINUS_SRC_ALPHA); + break; + case el: + s1.blendFunc(s1.SRC_ALPHA, s1.ONE); break; case nl: - s.blendFunc(770, 1); + s1.blendFuncSeparate(s1.ZERO, s1.ONE_MINUS_SRC_COLOR, s1.ZERO, s1.ONE); break; case il: - s.blendFunc(0, 769); - break; - case rl: - s.blendFunc(0, 768); + s1.blendFunc(s1.ZERO, s1.SRC_COLOR); break; default: - console.error("THREE.WebGLState: Invalid blending: ", R); + console.error("THREE.WebGLState: Invalid blending: ", I); break; } - v = null, g = null, _ = null, y = null, m = R, b = Le; + y = null, b = null, R = null, L = null, v = I, M = le; } return; } - me = me || ee, Re = Re || Q, oe = oe || Ee, (ee !== x || me !== p) && (s.blendEquationSeparate(Ce[ee], Ce[me]), x = ee, p = me), (Q !== v || Ee !== g || Re !== _ || oe !== y) && (s.blendFuncSeparate(ye[Q], ye[Ee], ye[Re], ye[oe]), v = Q, g = Ee, _ = Re, y = oe), m = R, b = null; + dt = dt || ht, qt = qt || H, ee = ee || ot, (ht !== _ || dt !== w) && (s1.blendEquationSeparate(P[ht], P[dt]), _ = ht, w = dt), (H !== y || ot !== b || qt !== R || ee !== L) && (s1.blendFuncSeparate(at[H], at[ot], at[qt], at[ee]), y = H, b = ot, R = qt, L = ee), v = I, M = !1; } - function xe(R, ee) { - R.side === Ci ? fe(2884) : le(2884); - let Q = R.side === it; - ee && (Q = !Q), Oe(Q), R.blending === sr && R.transparent === !1 ? ge(vn) : ge(R.blending, R.blendEquation, R.blendSrc, R.blendDst, R.blendEquationAlpha, R.blendSrcAlpha, R.blendDstAlpha, R.premultipliedAlpha), l.setFunc(R.depthFunc), l.setTest(R.depthTest), l.setMask(R.depthWrite), a.setMask(R.colorWrite); - let Ee = R.stencilWrite; - c.setTest(Ee), Ee && (c.setMask(R.stencilWriteMask), c.setFunc(R.stencilFunc, R.stencilRef, R.stencilFuncMask), c.setOp(R.stencilFail, R.stencilZFail, R.stencilZPass)), K(R.polygonOffset, R.polygonOffsetFactor, R.polygonOffsetUnits), R.alphaToCoverage === !0 ? le(32926) : fe(32926); + function st(I, ht) { + I.side === gn ? wt(s1.CULL_FACE) : Tt(s1.CULL_FACE); + let H = I.side === De; + ht && (H = !H), Q(H), I.blending === Wi && I.transparent === !1 ? Z(Un) : Z(I.blending, I.blendEquation, I.blendSrc, I.blendDst, I.blendEquationAlpha, I.blendSrcAlpha, I.blendDstAlpha, I.premultipliedAlpha), c.setFunc(I.depthFunc), c.setTest(I.depthTest), c.setMask(I.depthWrite), o.setMask(I.colorWrite); + let ot = I.stencilWrite; + l.setTest(ot), ot && (l.setMask(I.stencilWriteMask), l.setFunc(I.stencilFunc, I.stencilRef, I.stencilFuncMask), l.setOp(I.stencilFail, I.stencilZFail, I.stencilZPass)), xt(I.polygonOffset, I.polygonOffsetFactor, I.polygonOffsetUnits), I.alphaToCoverage === !0 ? Tt(s1.SAMPLE_ALPHA_TO_COVERAGE) : wt(s1.SAMPLE_ALPHA_TO_COVERAGE); } - function Oe(R) { - A !== R && (R ? s.frontFace(2304) : s.frontFace(2305), A = R); + function Q(I) { + E !== I && (I ? s1.frontFace(s1.CW) : s1.frontFace(s1.CCW), E = I); } - function G(R) { - R !== uu ? (le(2884), R !== L && (R === tl ? s.cullFace(1029) : R === du ? s.cullFace(1028) : s.cullFace(1032))) : fe(2884), L = R; + function St(I) { + I !== Nd ? (Tt(s1.CULL_FACE), I !== V && (I === tl ? s1.cullFace(s1.BACK) : I === Fd ? s1.cullFace(s1.FRONT) : s1.cullFace(s1.FRONT_AND_BACK))) : wt(s1.CULL_FACE), V = I; } - function j(R) { - R !== I && (w && s.lineWidth(R), I = R); + function mt(I) { + I !== $ && (K && s1.lineWidth(I), $ = I); } - function K(R, ee, Q) { - R ? (le(32823), (k !== ee || B !== Q) && (s.polygonOffset(ee, Q), k = ee, B = Q)) : fe(32823); + function xt(I, ht, H) { + I ? (Tt(s1.POLYGON_OFFSET_FILL), (F !== ht || O !== H) && (s1.polygonOffset(ht, H), F = ht, O = H)) : wt(s1.POLYGON_OFFSET_FILL); } - function ue(R) { - R ? le(3089) : fe(3089); + function Dt(I) { + I ? Tt(s1.SCISSOR_TEST) : wt(s1.SCISSOR_TEST); } - function se(R) { - R === void 0 && (R = 33984 + P - 1), U !== R && (s.activeTexture(R), U = R); + function Xt(I) { + I === void 0 && (I = s1.TEXTURE0 + z - 1), j !== I && (s1.activeTexture(I), j = I); } - function Se(R, ee) { - U === null && se(); - let Q = F[U]; - Q === void 0 && (Q = { + function ie(I, ht, H) { + H === void 0 && (j === null ? H = s1.TEXTURE0 + z - 1 : H = j); + let ot = tt[H]; + ot === void 0 && (ot = { type: void 0, texture: void 0 - }, F[U] = Q), (Q.type !== R || Q.texture !== ee) && (s.bindTexture(R, ee || he[R]), Q.type = R, Q.texture = ee); + }, tt[H] = ot), (ot.type !== I || ot.texture !== ht) && (j !== H && (s1.activeTexture(H), j = H), s1.bindTexture(I, ht || Et[I]), ot.type = I, ot.texture = ht); } - function Te() { - let R = F[U]; - R !== void 0 && R.type !== void 0 && (s.bindTexture(R.type, null), R.type = void 0, R.texture = void 0); + function C() { + let I = tt[j]; + I !== void 0 && I.type !== void 0 && (s1.bindTexture(I.type, null), I.type = void 0, I.texture = void 0); } - function Pe() { + function S() { try { - s.compressedTexImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.compressedTexImage2D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function Ye() { + function B() { try { - s.texSubImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.compressedTexImage3D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function C() { + function nt() { try { - s.texSubImage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.texSubImage2D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function T() { + function et() { try { - s.compressedTexSubImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.texSubImage3D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function J() { + function it() { try { - s.texStorage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.compressedTexSubImage2D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function $() { + function Mt() { + try { + s1.compressedTexSubImage3D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); + } + } + function rt() { try { - s.texStorage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.texStorage2D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function re() { + function k() { try { - s.texImage2D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.texStorage3D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function Z() { + function Rt() { try { - s.texImage3D.apply(s, arguments); - } catch (R) { - console.error("THREE.WebGLState:", R); + s1.texImage2D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); } } - function Me(R) { - ce.equals(R) === !1 && (s.scissor(R.x, R.y, R.z, R.w), ce.copy(R)); + function bt() { + try { + s1.texImage3D.apply(s1, arguments); + } catch (I) { + console.error("THREE.WebGLState:", I); + } + } + function At(I) { + lt.equals(I) === !1 && (s1.scissor(I.x, I.y, I.z, I.w), lt.copy(I)); + } + function vt(I) { + ut.equals(I) === !1 && (s1.viewport(I.x, I.y, I.z, I.w), ut.copy(I)); } - function ve(R) { - V.equals(R) === !1 && (s.viewport(R.x, R.y, R.z, R.w), V.copy(R)); + function yt(I, ht) { + let H = u.get(ht); + H === void 0 && (H = new WeakMap, u.set(ht, H)); + let ot = H.get(I); + ot === void 0 && (ot = s1.getUniformBlockIndex(ht, I.name), H.set(I, ot)); } - function te() { - s.disable(3042), s.disable(2884), s.disable(2929), s.disable(32823), s.disable(3089), s.disable(2960), s.disable(32926), s.blendEquation(32774), s.blendFunc(1, 0), s.blendFuncSeparate(1, 0, 1, 0), s.colorMask(!0, !0, !0, !0), s.clearColor(0, 0, 0, 0), s.depthMask(!0), s.depthFunc(513), s.clearDepth(1), s.stencilMask(4294967295), s.stencilFunc(519, 0, 4294967295), s.stencilOp(7680, 7680, 7680), s.clearStencil(0), s.cullFace(1029), s.frontFace(2305), s.polygonOffset(0, 0), s.activeTexture(33984), s.bindFramebuffer(36160, null), n === !0 && (s.bindFramebuffer(36009, null), s.bindFramebuffer(36008, null)), s.useProgram(null), s.lineWidth(1), s.scissor(0, 0, s.canvas.width, s.canvas.height), s.viewport(0, 0, s.canvas.width, s.canvas.height), h = {}, U = null, F = {}, u = {}, d = null, f = !1, m = null, x = null, v = null, g = null, p = null, _ = null, y = null, b = !1, A = null, L = null, I = null, k = null, B = null, ce.set(0, 0, s.canvas.width, s.canvas.height), V.set(0, 0, s.canvas.width, s.canvas.height), a.reset(), l.reset(), c.reset(); + function Ht(I, ht) { + let ot = u.get(ht).get(I); + h.get(ht) !== ot && (s1.uniformBlockBinding(ht, ot, I.__bindingPointIndex), h.set(ht, ot)); + } + function Qt() { + s1.disable(s1.BLEND), s1.disable(s1.CULL_FACE), s1.disable(s1.DEPTH_TEST), s1.disable(s1.POLYGON_OFFSET_FILL), s1.disable(s1.SCISSOR_TEST), s1.disable(s1.STENCIL_TEST), s1.disable(s1.SAMPLE_ALPHA_TO_COVERAGE), s1.blendEquation(s1.FUNC_ADD), s1.blendFunc(s1.ONE, s1.ZERO), s1.blendFuncSeparate(s1.ONE, s1.ZERO, s1.ONE, s1.ZERO), s1.colorMask(!0, !0, !0, !0), s1.clearColor(0, 0, 0, 0), s1.depthMask(!0), s1.depthFunc(s1.LESS), s1.clearDepth(1), s1.stencilMask(4294967295), s1.stencilFunc(s1.ALWAYS, 0, 4294967295), s1.stencilOp(s1.KEEP, s1.KEEP, s1.KEEP), s1.clearStencil(0), s1.cullFace(s1.BACK), s1.frontFace(s1.CCW), s1.polygonOffset(0, 0), s1.activeTexture(s1.TEXTURE0), s1.bindFramebuffer(s1.FRAMEBUFFER, null), n === !0 && (s1.bindFramebuffer(s1.DRAW_FRAMEBUFFER, null), s1.bindFramebuffer(s1.READ_FRAMEBUFFER, null)), s1.useProgram(null), s1.lineWidth(1), s1.scissor(0, 0, s1.canvas.width, s1.canvas.height), s1.viewport(0, 0, s1.canvas.width, s1.canvas.height), d = {}, j = null, tt = {}, f = {}, m = new WeakMap, x = [], g = null, p = !1, v = null, _ = null, y = null, b = null, w = null, R = null, L = null, M = !1, E = null, V = null, $ = null, F = null, O = null, lt.set(0, 0, s1.canvas.width, s1.canvas.height), ut.set(0, 0, s1.canvas.width, s1.canvas.height), o.reset(), c.reset(), l.reset(); } return { buffers: { - color: a, - depth: l, - stencil: c + color: o, + depth: c, + stencil: l }, - enable: le, - disable: fe, - bindFramebuffer: Be, - useProgram: Y, - setBlending: ge, - setMaterial: xe, - setFlipSided: Oe, - setCullFace: G, - setLineWidth: j, - setPolygonOffset: K, - setScissorTest: ue, - activeTexture: se, - bindTexture: Se, - unbindTexture: Te, - compressedTexImage2D: Pe, - texImage2D: re, - texImage3D: Z, - texStorage2D: J, - texStorage3D: $, - texSubImage2D: Ye, - texSubImage3D: C, - compressedTexSubImage2D: T, - scissor: Me, - viewport: ve, - reset: te + enable: Tt, + disable: wt, + bindFramebuffer: Yt, + drawBuffers: te, + useProgram: Pt, + setBlending: Z, + setMaterial: st, + setFlipSided: Q, + setCullFace: St, + setLineWidth: mt, + setPolygonOffset: xt, + setScissorTest: Dt, + activeTexture: Xt, + bindTexture: ie, + unbindTexture: C, + compressedTexImage2D: S, + compressedTexImage3D: B, + texImage2D: Rt, + texImage3D: bt, + updateUBOMapping: yt, + uniformBlockBinding: Ht, + texStorage2D: rt, + texStorage3D: k, + texSubImage2D: nt, + texSubImage3D: et, + compressedTexSubImage2D: it, + compressedTexSubImage3D: Mt, + scissor: At, + viewport: vt, + reset: Qt }; } -function Tx(s, e, t, n, i, r, o) { - let a = i.isWebGL2, l = i.maxTextures, c = i.maxCubemapSize, h = i.maxTextureSize, u = i.maxSamples, f = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : void 0, m = new WeakMap, x, v = !1; +function F0(s1, t, e, n, i, r, a) { + let o = i.isWebGL2, c = i.maxTextures, l = i.maxCubemapSize, h = i.maxTextureSize, u = i.maxSamples, d = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, f = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), m = new WeakMap, x, g = new WeakMap, p = !1; try { - v = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; + p = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; } catch {} - function g(C, T) { - return v ? new OffscreenCanvas(C, T) : qs("canvas"); - } - function p(C, T, J, $) { - let re = 1; - if ((C.width > $ || C.height > $) && (re = $ / Math.max(C.width, C.height)), re < 1 || T === !0) if (typeof HTMLImageElement < "u" && C instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && C instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && C instanceof ImageBitmap) { - let Z = T ? Jc : Math.floor, Me = Z(re * C.width), ve = Z(re * C.height); - x === void 0 && (x = g(Me, ve)); - let te = J ? g(Me, ve) : x; - return te.width = Me, te.height = ve, te.getContext("2d").drawImage(C, 0, 0, Me, ve), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + C.width + "x" + C.height + ") to (" + Me + "x" + ve + ")."), te; + function v(C, S) { + return p ? new OffscreenCanvas(C, S) : ws("canvas"); + } + function _(C, S, B, nt) { + let et = 1; + if ((C.width > nt || C.height > nt) && (et = nt / Math.max(C.width, C.height)), et < 1 || S === !0) if (typeof HTMLImageElement < "u" && C instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && C instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && C instanceof ImageBitmap) { + let it = S ? Hr : Math.floor, Mt = it(et * C.width), rt = it(et * C.height); + x === void 0 && (x = v(Mt, rt)); + let k = B ? v(Mt, rt) : x; + return k.width = Mt, k.height = rt, k.getContext("2d").drawImage(C, 0, 0, Mt, rt), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + C.width + "x" + C.height + ") to (" + Mt + "x" + rt + ")."), k; } else return "data" in C && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + C.width + "x" + C.height + ")."), C; return C; } - function _(C) { - return ia(C.width) && ia(C.height); - } function y(C) { - return a ? !1 : C.wrapS !== vt || C.wrapT !== vt || C.minFilter !== rt && C.minFilter !== tt; + return lo(C.width) && lo(C.height); } - function b(C, T) { - return C.generateMipmaps && T && C.minFilter !== rt && C.minFilter !== tt; + function b(C) { + return o ? !1 : C.wrapS !== Ce || C.wrapT !== Ce || C.minFilter !== fe && C.minFilter !== pe; } - function A(C) { - s.generateMipmap(C); + function w(C, S) { + return C.generateMipmaps && S && C.minFilter !== fe && C.minFilter !== pe; } - function L(C, T, J, $) { - if (a === !1) return T; + function R(C) { + s1.generateMipmap(C); + } + function L(C, S, B, nt, et = !1) { + if (o === !1) return S; if (C !== null) { - if (s[C] !== void 0) return s[C]; + if (s1[C] !== void 0) return s1[C]; console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + C + "'"); } - let re = T; - return T === 6403 && (J === 5126 && (re = 33326), J === 5131 && (re = 33325), J === 5121 && (re = 33321)), T === 6407 && (J === 5126 && (re = 34837), J === 5131 && (re = 34843), J === 5121 && (re = 32849)), T === 6408 && (J === 5126 && (re = 34836), J === 5131 && (re = 34842), J === 5121 && (re = $ === Oi ? 35907 : 32856)), (re === 33325 || re === 33326 || re === 34842 || re === 34836) && e.get("EXT_color_buffer_float"), re; - } - function I(C, T, J) { - return b(C, J) === !0 || C.isFramebufferTexture && C.minFilter !== rt && C.minFilter !== tt ? Math.log2(Math.max(T.width, T.height)) + 1 : C.mipmaps !== void 0 && C.mipmaps.length > 0 ? C.mipmaps.length : C.isCompressedTexture && Array.isArray(C.image) ? T.mipmaps.length : 1; + let it = S; + return S === s1.RED && (B === s1.FLOAT && (it = s1.R32F), B === s1.HALF_FLOAT && (it = s1.R16F), B === s1.UNSIGNED_BYTE && (it = s1.R8)), S === s1.RED_INTEGER && (B === s1.UNSIGNED_BYTE && (it = s1.R8UI), B === s1.UNSIGNED_SHORT && (it = s1.R16UI), B === s1.UNSIGNED_INT && (it = s1.R32UI), B === s1.BYTE && (it = s1.R8I), B === s1.SHORT && (it = s1.R16I), B === s1.INT && (it = s1.R32I)), S === s1.RG && (B === s1.FLOAT && (it = s1.RG32F), B === s1.HALF_FLOAT && (it = s1.RG16F), B === s1.UNSIGNED_BYTE && (it = s1.RG8)), S === s1.RGBA && (B === s1.FLOAT && (it = s1.RGBA32F), B === s1.HALF_FLOAT && (it = s1.RGBA16F), B === s1.UNSIGNED_BYTE && (it = nt === Nt && et === !1 ? s1.SRGB8_ALPHA8 : s1.RGBA8), B === s1.UNSIGNED_SHORT_4_4_4_4 && (it = s1.RGBA4), B === s1.UNSIGNED_SHORT_5_5_5_1 && (it = s1.RGB5_A1)), (it === s1.R16F || it === s1.R32F || it === s1.RG16F || it === s1.RG32F || it === s1.RGBA16F || it === s1.RGBA32F) && t.get("EXT_color_buffer_float"), it; } - function k(C) { - return C === rt || C === ta || C === na ? 9728 : 9729; - } - function B(C) { - let T = C.target; - T.removeEventListener("dispose", B), w(T), T.isVideoTexture && m.delete(T), o.memory.textures--; - } - function P(C) { - let T = C.target; - T.removeEventListener("dispose", P), E(T); - } - function w(C) { - let T = n.get(C); - T.__webglInit !== void 0 && (s.deleteTexture(T.__webglTexture), n.remove(C)); + function M(C, S, B) { + return w(C, B) === !0 || C.isFramebufferTexture && C.minFilter !== fe && C.minFilter !== pe ? Math.log2(Math.max(S.width, S.height)) + 1 : C.mipmaps !== void 0 && C.mipmaps.length > 0 ? C.mipmaps.length : C.isCompressedTexture && Array.isArray(C.image) ? S.mipmaps.length : 1; } function E(C) { - let T = C.texture, J = n.get(C), $ = n.get(T); - if (!!C) { - if ($.__webglTexture !== void 0 && (s.deleteTexture($.__webglTexture), o.memory.textures--), C.depthTexture && C.depthTexture.dispose(), C.isWebGLCubeRenderTarget) for(let re = 0; re < 6; re++)s.deleteFramebuffer(J.__webglFramebuffer[re]), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer[re]); - else s.deleteFramebuffer(J.__webglFramebuffer), J.__webglDepthbuffer && s.deleteRenderbuffer(J.__webglDepthbuffer), J.__webglMultisampledFramebuffer && s.deleteFramebuffer(J.__webglMultisampledFramebuffer), J.__webglColorRenderbuffer && s.deleteRenderbuffer(J.__webglColorRenderbuffer), J.__webglDepthRenderbuffer && s.deleteRenderbuffer(J.__webglDepthRenderbuffer); - if (C.isWebGLMultipleRenderTargets) for(let re = 0, Z = T.length; re < Z; re++){ - let Me = n.get(T[re]); - Me.__webglTexture && (s.deleteTexture(Me.__webglTexture), o.memory.textures--), n.remove(T[re]); - } - n.remove(T), n.remove(C); + return C === fe || C === oo || C === Ir ? s1.NEAREST : s1.LINEAR; + } + function V(C) { + let S = C.target; + S.removeEventListener("dispose", V), F(S), S.isVideoTexture && m.delete(S); + } + function $(C) { + let S = C.target; + S.removeEventListener("dispose", $), z(S); + } + function F(C) { + let S = n.get(C); + if (S.__webglInit === void 0) return; + let B = C.source, nt = g.get(B); + if (nt) { + let et = nt[S.__cacheKey]; + et.usedTimes--, et.usedTimes === 0 && O(C), Object.keys(nt).length === 0 && g.delete(B); + } + n.remove(C); + } + function O(C) { + let S = n.get(C); + s1.deleteTexture(S.__webglTexture); + let B = C.source, nt = g.get(B); + delete nt[S.__cacheKey], a.memory.textures--; + } + function z(C) { + let S = C.texture, B = n.get(C), nt = n.get(S); + if (nt.__webglTexture !== void 0 && (s1.deleteTexture(nt.__webglTexture), a.memory.textures--), C.depthTexture && C.depthTexture.dispose(), C.isWebGLCubeRenderTarget) for(let et = 0; et < 6; et++){ + if (Array.isArray(B.__webglFramebuffer[et])) for(let it = 0; it < B.__webglFramebuffer[et].length; it++)s1.deleteFramebuffer(B.__webglFramebuffer[et][it]); + else s1.deleteFramebuffer(B.__webglFramebuffer[et]); + B.__webglDepthbuffer && s1.deleteRenderbuffer(B.__webglDepthbuffer[et]); } + else { + if (Array.isArray(B.__webglFramebuffer)) for(let et = 0; et < B.__webglFramebuffer.length; et++)s1.deleteFramebuffer(B.__webglFramebuffer[et]); + else s1.deleteFramebuffer(B.__webglFramebuffer); + if (B.__webglDepthbuffer && s1.deleteRenderbuffer(B.__webglDepthbuffer), B.__webglMultisampledFramebuffer && s1.deleteFramebuffer(B.__webglMultisampledFramebuffer), B.__webglColorRenderbuffer) for(let et = 0; et < B.__webglColorRenderbuffer.length; et++)B.__webglColorRenderbuffer[et] && s1.deleteRenderbuffer(B.__webglColorRenderbuffer[et]); + B.__webglDepthRenderbuffer && s1.deleteRenderbuffer(B.__webglDepthRenderbuffer); + } + if (C.isWebGLMultipleRenderTargets) for(let et = 0, it = S.length; et < it; et++){ + let Mt = n.get(S[et]); + Mt.__webglTexture && (s1.deleteTexture(Mt.__webglTexture), a.memory.textures--), n.remove(S[et]); + } + n.remove(S), n.remove(C); } - let D = 0; - function U() { - D = 0; + let K = 0; + function X() { + K = 0; } - function F() { - let C = D; - return C >= l && console.warn("THREE.WebGLTextures: Trying to use " + C + " texture units while this GPU supports only " + l), D += 1, C; - } - function O(C, T) { - let J = n.get(C); - if (C.isVideoTexture && se(C), C.version > 0 && J.__version !== C.version) { - let $ = C.image; - if ($ === void 0) console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined"); - else if ($.complete === !1) console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); + function Y() { + let C = K; + return C >= c && console.warn("THREE.WebGLTextures: Trying to use " + C + " texture units while this GPU supports only " + c), K += 1, C; + } + function j(C) { + let S = []; + return S.push(C.wrapS), S.push(C.wrapT), S.push(C.wrapR || 0), S.push(C.magFilter), S.push(C.minFilter), S.push(C.anisotropy), S.push(C.internalFormat), S.push(C.format), S.push(C.type), S.push(C.generateMipmaps), S.push(C.premultiplyAlpha), S.push(C.flipY), S.push(C.unpackAlignment), S.push(C.colorSpace), S.join(); + } + function tt(C, S) { + let B = n.get(C); + if (C.isVideoTexture && Xt(C), C.isRenderTargetTexture === !1 && C.version > 0 && B.__version !== C.version) { + let nt = C.image; + if (nt === null) console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found."); + else if (nt.complete === !1) console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete"); else { - Be(J, C, T); + Yt(B, C, S); return; } } - t.activeTexture(33984 + T), t.bindTexture(3553, J.__webglTexture); + e.bindTexture(s1.TEXTURE_2D, B.__webglTexture, s1.TEXTURE0 + S); } - function ne(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Be(J, C, T); + function N(C, S) { + let B = n.get(C); + if (C.version > 0 && B.__version !== C.version) { + Yt(B, C, S); return; } - t.activeTexture(33984 + T), t.bindTexture(35866, J.__webglTexture); + e.bindTexture(s1.TEXTURE_2D_ARRAY, B.__webglTexture, s1.TEXTURE0 + S); } - function ce(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Be(J, C, T); + function q(C, S) { + let B = n.get(C); + if (C.version > 0 && B.__version !== C.version) { + Yt(B, C, S); return; } - t.activeTexture(33984 + T), t.bindTexture(32879, J.__webglTexture); + e.bindTexture(s1.TEXTURE_3D, B.__webglTexture, s1.TEXTURE0 + S); } - function V(C, T) { - let J = n.get(C); - if (C.version > 0 && J.__version !== C.version) { - Y(J, C, T); + function lt(C, S) { + let B = n.get(C); + if (C.version > 0 && B.__version !== C.version) { + te(B, C, S); return; } - t.activeTexture(33984 + T), t.bindTexture(34067, J.__webglTexture); - } - let W = { - [Ns]: 10497, - [vt]: 33071, - [Bs]: 33648 - }, he = { - [rt]: 9728, - [ta]: 9984, - [na]: 9986, - [tt]: 9729, - [Wc]: 9985, - [Ui]: 9987 + e.bindTexture(s1.TEXTURE_CUBE_MAP, B.__webglTexture, s1.TEXTURE0 + S); + } + let ut = { + [Nr]: s1.REPEAT, + [Ce]: s1.CLAMP_TO_EDGE, + [Fr]: s1.MIRRORED_REPEAT + }, pt = { + [fe]: s1.NEAREST, + [oo]: s1.NEAREST_MIPMAP_NEAREST, + [Ir]: s1.NEAREST_MIPMAP_LINEAR, + [pe]: s1.LINEAR, + [rd]: s1.LINEAR_MIPMAP_NEAREST, + [li]: s1.LINEAR_MIPMAP_LINEAR + }, Et = { + [Af]: s1.NEVER, + [Df]: s1.ALWAYS, + [Rf]: s1.LESS, + [Pf]: s1.LEQUAL, + [Cf]: s1.EQUAL, + [Uf]: s1.GEQUAL, + [Lf]: s1.GREATER, + [If]: s1.NOTEQUAL }; - function le(C, T, J) { - if (J ? (s.texParameteri(C, 10242, W[T.wrapS]), s.texParameteri(C, 10243, W[T.wrapT]), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, W[T.wrapR]), s.texParameteri(C, 10240, he[T.magFilter]), s.texParameteri(C, 10241, he[T.minFilter])) : (s.texParameteri(C, 10242, 33071), s.texParameteri(C, 10243, 33071), (C === 32879 || C === 35866) && s.texParameteri(C, 32882, 33071), (T.wrapS !== vt || T.wrapT !== vt) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), s.texParameteri(C, 10240, k(T.magFilter)), s.texParameteri(C, 10241, k(T.minFilter)), T.minFilter !== rt && T.minFilter !== tt && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), e.has("EXT_texture_filter_anisotropic") === !0) { - let $ = e.get("EXT_texture_filter_anisotropic"); - if (T.type === nn && e.has("OES_texture_float_linear") === !1 || a === !1 && T.type === kn && e.has("OES_texture_half_float_linear") === !1) return; - (T.anisotropy > 1 || n.get(T).__currentAnisotropy) && (s.texParameterf(C, $.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(T.anisotropy, i.getMaxAnisotropy())), n.get(T).__currentAnisotropy = T.anisotropy); - } - } - function fe(C, T) { - C.__webglInit === void 0 && (C.__webglInit = !0, T.addEventListener("dispose", B), C.__webglTexture = s.createTexture(), o.memory.textures++); - } - function Be(C, T, J) { - let $ = 3553; - T.isDataTexture2DArray && ($ = 35866), T.isDataTexture3D && ($ = 32879), fe(C, T), t.activeTexture(33984 + J), t.bindTexture($, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); - let re = y(T) && _(T.image) === !1, Z = p(T.image, re, !1, h), Me = _(Z) || a, ve = r.convert(T.format), te = r.convert(T.type), R = L(T.internalFormat, ve, te, T.encoding); - le($, T, Me); - let ee, Q = T.mipmaps, Ee = a && T.isVideoTexture !== !0, me = C.__version === void 0, Re = I(T, Z, Me); - if (T.isDepthTexture) R = 6402, a ? T.type === nn ? R = 36012 : T.type === Ps ? R = 33190 : T.type === Ti ? R = 35056 : R = 33189 : T.type === nn && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), T.format === Vn && R === 6402 && T.type !== cr && T.type !== Ps && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), T.type = cr, te = r.convert(T.type)), T.format === Li && R === 6402 && (R = 34041, T.type !== Ti && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), T.type = Ti, te = r.convert(T.type))), Ee && me ? t.texStorage2D(3553, 1, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); - else if (T.isDataTexture) if (Q.length > 0 && Me) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, 0, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); - T.generateMipmaps = !1; - } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, Z.width, Z.height, ve, te, Z.data)) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, Z.data); - else if (T.isCompressedTexture) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], T.format !== ct && T.format !== Gn ? ve !== null ? Ee ? t.compressedTexSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, ee.data) : t.compressedTexImage2D(3553, oe, R, ee.width, ee.height, 0, ee.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ee ? t.texSubImage2D(3553, oe, 0, 0, ee.width, ee.height, ve, te, ee.data) : t.texImage2D(3553, oe, R, ee.width, ee.height, 0, ve, te, ee.data); - } else if (T.isDataTexture2DArray) Ee ? (me && t.texStorage3D(35866, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(35866, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(35866, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); - else if (T.isDataTexture3D) Ee ? (me && t.texStorage3D(32879, Re, R, Z.width, Z.height, Z.depth), t.texSubImage3D(32879, 0, 0, 0, 0, Z.width, Z.height, Z.depth, ve, te, Z.data)) : t.texImage3D(32879, 0, R, Z.width, Z.height, Z.depth, 0, ve, te, Z.data); - else if (T.isFramebufferTexture) Ee && me ? t.texStorage2D(3553, Re, R, Z.width, Z.height) : t.texImage2D(3553, 0, R, Z.width, Z.height, 0, ve, te, null); - else if (Q.length > 0 && Me) { - Ee && me && t.texStorage2D(3553, Re, R, Q[0].width, Q[0].height); - for(let oe = 0, Le = Q.length; oe < Le; oe++)ee = Q[oe], Ee ? t.texSubImage2D(3553, oe, 0, 0, ve, te, ee) : t.texImage2D(3553, oe, R, ve, te, ee); - T.generateMipmaps = !1; - } else Ee ? (me && t.texStorage2D(3553, Re, R, Z.width, Z.height), t.texSubImage2D(3553, 0, 0, 0, ve, te, Z)) : t.texImage2D(3553, 0, R, ve, te, Z); - b(T, Me) && A($), C.__version = T.version, T.onUpdate && T.onUpdate(T); - } - function Y(C, T, J) { - if (T.image.length !== 6) return; - fe(C, T), t.activeTexture(33984 + J), t.bindTexture(34067, C.__webglTexture), s.pixelStorei(37440, T.flipY), s.pixelStorei(37441, T.premultiplyAlpha), s.pixelStorei(3317, T.unpackAlignment), s.pixelStorei(37443, 0); - let $ = T && (T.isCompressedTexture || T.image[0].isCompressedTexture), re = T.image[0] && T.image[0].isDataTexture, Z = []; - for(let oe = 0; oe < 6; oe++)!$ && !re ? Z[oe] = p(T.image[oe], !1, !0, c) : Z[oe] = re ? T.image[oe].image : T.image[oe]; - let Me = Z[0], ve = _(Me) || a, te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = a && T.isVideoTexture !== !0, Ee = C.__version === void 0, me = I(T, Me, ve); - le(34067, T, ve); - let Re; - if ($) { - Q && Ee && t.texStorage2D(34067, me, ee, Me.width, Me.height); - for(let oe = 0; oe < 6; oe++){ - Re = Z[oe].mipmaps; - for(let Le = 0; Le < Re.length; Le++){ - let Xe = Re[Le]; - T.format !== ct && T.format !== Gn ? te !== null ? Q ? t.compressedTexSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, Xe.data) : t.compressedTexImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, Xe.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Q ? t.texSubImage2D(34069 + oe, Le, 0, 0, Xe.width, Xe.height, te, R, Xe.data) : t.texImage2D(34069 + oe, Le, ee, Xe.width, Xe.height, 0, te, R, Xe.data); - } + function Tt(C, S, B) { + if (B ? (s1.texParameteri(C, s1.TEXTURE_WRAP_S, ut[S.wrapS]), s1.texParameteri(C, s1.TEXTURE_WRAP_T, ut[S.wrapT]), (C === s1.TEXTURE_3D || C === s1.TEXTURE_2D_ARRAY) && s1.texParameteri(C, s1.TEXTURE_WRAP_R, ut[S.wrapR]), s1.texParameteri(C, s1.TEXTURE_MAG_FILTER, pt[S.magFilter]), s1.texParameteri(C, s1.TEXTURE_MIN_FILTER, pt[S.minFilter])) : (s1.texParameteri(C, s1.TEXTURE_WRAP_S, s1.CLAMP_TO_EDGE), s1.texParameteri(C, s1.TEXTURE_WRAP_T, s1.CLAMP_TO_EDGE), (C === s1.TEXTURE_3D || C === s1.TEXTURE_2D_ARRAY) && s1.texParameteri(C, s1.TEXTURE_WRAP_R, s1.CLAMP_TO_EDGE), (S.wrapS !== Ce || S.wrapT !== Ce) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), s1.texParameteri(C, s1.TEXTURE_MAG_FILTER, E(S.magFilter)), s1.texParameteri(C, s1.TEXTURE_MIN_FILTER, E(S.minFilter)), S.minFilter !== fe && S.minFilter !== pe && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), S.compareFunction && (s1.texParameteri(C, s1.TEXTURE_COMPARE_MODE, s1.COMPARE_REF_TO_TEXTURE), s1.texParameteri(C, s1.TEXTURE_COMPARE_FUNC, Et[S.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) { + let nt = t.get("EXT_texture_filter_anisotropic"); + if (S.magFilter === fe || S.minFilter !== Ir && S.minFilter !== li || S.type === xn && t.has("OES_texture_float_linear") === !1 || o === !1 && S.type === Ts && t.has("OES_texture_half_float_linear") === !1) return; + (S.anisotropy > 1 || n.get(S).__currentAnisotropy) && (s1.texParameterf(C, nt.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(S.anisotropy, i.getMaxAnisotropy())), n.get(S).__currentAnisotropy = S.anisotropy); + } + } + function wt(C, S) { + let B = !1; + C.__webglInit === void 0 && (C.__webglInit = !0, S.addEventListener("dispose", V)); + let nt = S.source, et = g.get(nt); + et === void 0 && (et = {}, g.set(nt, et)); + let it = j(S); + if (it !== C.__cacheKey) { + et[it] === void 0 && (et[it] = { + texture: s1.createTexture(), + usedTimes: 0 + }, a.memory.textures++, B = !0), et[it].usedTimes++; + let Mt = et[C.__cacheKey]; + Mt !== void 0 && (et[C.__cacheKey].usedTimes--, Mt.usedTimes === 0 && O(S)), C.__cacheKey = it, C.__webglTexture = et[it].texture; + } + return B; + } + function Yt(C, S, B) { + let nt = s1.TEXTURE_2D; + (S.isDataArrayTexture || S.isCompressedArrayTexture) && (nt = s1.TEXTURE_2D_ARRAY), S.isData3DTexture && (nt = s1.TEXTURE_3D); + let et = wt(C, S), it = S.source; + e.bindTexture(nt, C.__webglTexture, s1.TEXTURE0 + B); + let Mt = n.get(it); + if (it.version !== Mt.__version || et === !0) { + e.activeTexture(s1.TEXTURE0 + B), s1.pixelStorei(s1.UNPACK_FLIP_Y_WEBGL, S.flipY), s1.pixelStorei(s1.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), s1.pixelStorei(s1.UNPACK_ALIGNMENT, S.unpackAlignment), s1.pixelStorei(s1.UNPACK_COLORSPACE_CONVERSION_WEBGL, s1.NONE); + let rt = b(S) && y(S.image) === !1, k = _(S.image, rt, !1, h); + k = ie(S, k); + let Rt = y(k) || o, bt = r.convert(S.format, S.colorSpace), At = r.convert(S.type), vt = L(S.internalFormat, bt, At, S.colorSpace); + Tt(nt, S, Rt); + let yt, Ht = S.mipmaps, Qt = o && S.isVideoTexture !== !0, I = Mt.__version === void 0 || et === !0, ht = M(S, k, Rt); + if (S.isDepthTexture) vt = s1.DEPTH_COMPONENT, o ? S.type === xn ? vt = s1.DEPTH_COMPONENT32F : S.type === Pn ? vt = s1.DEPTH_COMPONENT24 : S.type === ni ? vt = s1.DEPTH24_STENCIL8 : vt = s1.DEPTH_COMPONENT16 : S.type === xn && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), S.format === ii && vt === s1.DEPTH_COMPONENT && S.type !== Bc && S.type !== Pn && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), S.type = Pn, At = r.convert(S.type)), S.format === Yi && vt === s1.DEPTH_COMPONENT && (vt = s1.DEPTH_STENCIL, S.type !== ni && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), S.type = ni, At = r.convert(S.type))), I && (Qt ? e.texStorage2D(s1.TEXTURE_2D, 1, vt, k.width, k.height) : e.texImage2D(s1.TEXTURE_2D, 0, vt, k.width, k.height, 0, bt, At, null)); + else if (S.isDataTexture) if (Ht.length > 0 && Rt) { + Qt && I && e.texStorage2D(s1.TEXTURE_2D, ht, vt, Ht[0].width, Ht[0].height); + for(let H = 0, ot = Ht.length; H < ot; H++)yt = Ht[H], Qt ? e.texSubImage2D(s1.TEXTURE_2D, H, 0, 0, yt.width, yt.height, bt, At, yt.data) : e.texImage2D(s1.TEXTURE_2D, H, vt, yt.width, yt.height, 0, bt, At, yt.data); + S.generateMipmaps = !1; + } else Qt ? (I && e.texStorage2D(s1.TEXTURE_2D, ht, vt, k.width, k.height), e.texSubImage2D(s1.TEXTURE_2D, 0, 0, 0, k.width, k.height, bt, At, k.data)) : e.texImage2D(s1.TEXTURE_2D, 0, vt, k.width, k.height, 0, bt, At, k.data); + else if (S.isCompressedTexture) if (S.isCompressedArrayTexture) { + Qt && I && e.texStorage3D(s1.TEXTURE_2D_ARRAY, ht, vt, Ht[0].width, Ht[0].height, k.depth); + for(let H = 0, ot = Ht.length; H < ot; H++)yt = Ht[H], S.format !== He ? bt !== null ? Qt ? e.compressedTexSubImage3D(s1.TEXTURE_2D_ARRAY, H, 0, 0, 0, yt.width, yt.height, k.depth, bt, yt.data, 0, 0) : e.compressedTexImage3D(s1.TEXTURE_2D_ARRAY, H, vt, yt.width, yt.height, k.depth, 0, yt.data, 0, 0) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Qt ? e.texSubImage3D(s1.TEXTURE_2D_ARRAY, H, 0, 0, 0, yt.width, yt.height, k.depth, bt, At, yt.data) : e.texImage3D(s1.TEXTURE_2D_ARRAY, H, vt, yt.width, yt.height, k.depth, 0, bt, At, yt.data); + } else { + Qt && I && e.texStorage2D(s1.TEXTURE_2D, ht, vt, Ht[0].width, Ht[0].height); + for(let H = 0, ot = Ht.length; H < ot; H++)yt = Ht[H], S.format !== He ? bt !== null ? Qt ? e.compressedTexSubImage2D(s1.TEXTURE_2D, H, 0, 0, yt.width, yt.height, bt, yt.data) : e.compressedTexImage2D(s1.TEXTURE_2D, H, vt, yt.width, yt.height, 0, yt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Qt ? e.texSubImage2D(s1.TEXTURE_2D, H, 0, 0, yt.width, yt.height, bt, At, yt.data) : e.texImage2D(s1.TEXTURE_2D, H, vt, yt.width, yt.height, 0, bt, At, yt.data); } - } else { - Re = T.mipmaps, Q && Ee && (Re.length > 0 && me++, t.texStorage2D(34067, me, ee, Z[0].width, Z[0].height)); - for(let oe = 0; oe < 6; oe++)if (re) { - Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, Z[oe].width, Z[oe].height, te, R, Z[oe].data) : t.texImage2D(34069 + oe, 0, ee, Z[oe].width, Z[oe].height, 0, te, R, Z[oe].data); - for(let Le = 0; Le < Re.length; Le++){ - let We = Re[Le].image[oe].image; - Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, We.width, We.height, te, R, We.data) : t.texImage2D(34069 + oe, Le + 1, ee, We.width, We.height, 0, te, R, We.data); + else if (S.isDataArrayTexture) Qt ? (I && e.texStorage3D(s1.TEXTURE_2D_ARRAY, ht, vt, k.width, k.height, k.depth), e.texSubImage3D(s1.TEXTURE_2D_ARRAY, 0, 0, 0, 0, k.width, k.height, k.depth, bt, At, k.data)) : e.texImage3D(s1.TEXTURE_2D_ARRAY, 0, vt, k.width, k.height, k.depth, 0, bt, At, k.data); + else if (S.isData3DTexture) Qt ? (I && e.texStorage3D(s1.TEXTURE_3D, ht, vt, k.width, k.height, k.depth), e.texSubImage3D(s1.TEXTURE_3D, 0, 0, 0, 0, k.width, k.height, k.depth, bt, At, k.data)) : e.texImage3D(s1.TEXTURE_3D, 0, vt, k.width, k.height, k.depth, 0, bt, At, k.data); + else if (S.isFramebufferTexture) { + if (I) if (Qt) e.texStorage2D(s1.TEXTURE_2D, ht, vt, k.width, k.height); + else { + let H = k.width, ot = k.height; + for(let dt = 0; dt < ht; dt++)e.texImage2D(s1.TEXTURE_2D, dt, vt, H, ot, 0, bt, At, null), H >>= 1, ot >>= 1; + } + } else if (Ht.length > 0 && Rt) { + Qt && I && e.texStorage2D(s1.TEXTURE_2D, ht, vt, Ht[0].width, Ht[0].height); + for(let H = 0, ot = Ht.length; H < ot; H++)yt = Ht[H], Qt ? e.texSubImage2D(s1.TEXTURE_2D, H, 0, 0, bt, At, yt) : e.texImage2D(s1.TEXTURE_2D, H, vt, bt, At, yt); + S.generateMipmaps = !1; + } else Qt ? (I && e.texStorage2D(s1.TEXTURE_2D, ht, vt, k.width, k.height), e.texSubImage2D(s1.TEXTURE_2D, 0, 0, 0, bt, At, k)) : e.texImage2D(s1.TEXTURE_2D, 0, vt, bt, At, k); + w(S, Rt) && R(nt), Mt.__version = it.version, S.onUpdate && S.onUpdate(S); + } + C.__version = S.version; + } + function te(C, S, B) { + if (S.image.length !== 6) return; + let nt = wt(C, S), et = S.source; + e.bindTexture(s1.TEXTURE_CUBE_MAP, C.__webglTexture, s1.TEXTURE0 + B); + let it = n.get(et); + if (et.version !== it.__version || nt === !0) { + e.activeTexture(s1.TEXTURE0 + B), s1.pixelStorei(s1.UNPACK_FLIP_Y_WEBGL, S.flipY), s1.pixelStorei(s1.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), s1.pixelStorei(s1.UNPACK_ALIGNMENT, S.unpackAlignment), s1.pixelStorei(s1.UNPACK_COLORSPACE_CONVERSION_WEBGL, s1.NONE); + let Mt = S.isCompressedTexture || S.image[0].isCompressedTexture, rt = S.image[0] && S.image[0].isDataTexture, k = []; + for(let H = 0; H < 6; H++)!Mt && !rt ? k[H] = _(S.image[H], !1, !0, l) : k[H] = rt ? S.image[H].image : S.image[H], k[H] = ie(S, k[H]); + let Rt = k[0], bt = y(Rt) || o, At = r.convert(S.format, S.colorSpace), vt = r.convert(S.type), yt = L(S.internalFormat, At, vt, S.colorSpace), Ht = o && S.isVideoTexture !== !0, Qt = it.__version === void 0 || nt === !0, I = M(S, Rt, bt); + Tt(s1.TEXTURE_CUBE_MAP, S, bt); + let ht; + if (Mt) { + Ht && Qt && e.texStorage2D(s1.TEXTURE_CUBE_MAP, I, yt, Rt.width, Rt.height); + for(let H = 0; H < 6; H++){ + ht = k[H].mipmaps; + for(let ot = 0; ot < ht.length; ot++){ + let dt = ht[ot]; + S.format !== He ? At !== null ? Ht ? e.compressedTexSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot, 0, 0, dt.width, dt.height, At, dt.data) : e.compressedTexImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot, yt, dt.width, dt.height, 0, dt.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Ht ? e.texSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot, 0, 0, dt.width, dt.height, At, vt, dt.data) : e.texImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot, yt, dt.width, dt.height, 0, At, vt, dt.data); + } } } else { - Q ? t.texSubImage2D(34069 + oe, 0, 0, 0, te, R, Z[oe]) : t.texImage2D(34069 + oe, 0, ee, te, R, Z[oe]); - for(let Le = 0; Le < Re.length; Le++){ - let Xe = Re[Le]; - Q ? t.texSubImage2D(34069 + oe, Le + 1, 0, 0, te, R, Xe.image[oe]) : t.texImage2D(34069 + oe, Le + 1, ee, te, R, Xe.image[oe]); + ht = S.mipmaps, Ht && Qt && (ht.length > 0 && I++, e.texStorage2D(s1.TEXTURE_CUBE_MAP, I, yt, k[0].width, k[0].height)); + for(let H = 0; H < 6; H++)if (rt) { + Ht ? e.texSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, 0, 0, 0, k[H].width, k[H].height, At, vt, k[H].data) : e.texImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, 0, yt, k[H].width, k[H].height, 0, At, vt, k[H].data); + for(let ot = 0; ot < ht.length; ot++){ + let qt = ht[ot].image[H].image; + Ht ? e.texSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot + 1, 0, 0, qt.width, qt.height, At, vt, qt.data) : e.texImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot + 1, yt, qt.width, qt.height, 0, At, vt, qt.data); + } + } else { + Ht ? e.texSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, 0, 0, 0, At, vt, k[H]) : e.texImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, 0, yt, At, vt, k[H]); + for(let ot = 0; ot < ht.length; ot++){ + let dt = ht[ot]; + Ht ? e.texSubImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot + 1, 0, 0, At, vt, dt.image[H]) : e.texImage2D(s1.TEXTURE_CUBE_MAP_POSITIVE_X + H, ot + 1, yt, At, vt, dt.image[H]); + } } } - } - b(T, ve) && A(34067), C.__version = T.version, T.onUpdate && T.onUpdate(T); - } - function Ce(C, T, J, $, re) { - let Z = r.convert(J.format), Me = r.convert(J.type), ve = L(J.internalFormat, Z, Me, J.encoding); - n.get(T).__hasExternalTextures || (re === 32879 || re === 35866 ? t.texImage3D(re, 0, ve, T.width, T.height, T.depth, 0, Z, Me, null) : t.texImage2D(re, 0, ve, T.width, T.height, 0, Z, Me, null)), t.bindFramebuffer(36160, C), T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, $, re, n.get(J).__webglTexture, 0, ue(T)) : s.framebufferTexture2D(36160, $, re, n.get(J).__webglTexture, 0), t.bindFramebuffer(36160, null); - } - function ye(C, T, J) { - if (s.bindRenderbuffer(36161, C), T.depthBuffer && !T.stencilBuffer) { - let $ = 33189; - if (J || T.useRenderToTexture) { - let re = T.depthTexture; - re && re.isDepthTexture && (re.type === nn ? $ = 36012 : re.type === Ps && ($ = 33190)); - let Z = ue(T); - T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, Z, $, T.width, T.height) : s.renderbufferStorageMultisample(36161, Z, $, T.width, T.height); - } else s.renderbufferStorage(36161, $, T.width, T.height); - s.framebufferRenderbuffer(36160, 36096, 36161, C); - } else if (T.depthBuffer && T.stencilBuffer) { - let $ = ue(T); - J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, $, 35056, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, $, 35056, T.width, T.height) : s.renderbufferStorage(36161, 34041, T.width, T.height), s.framebufferRenderbuffer(36160, 33306, 36161, C); + w(S, bt) && R(s1.TEXTURE_CUBE_MAP), it.__version = et.version, S.onUpdate && S.onUpdate(S); + } + C.__version = S.version; + } + function Pt(C, S, B, nt, et, it) { + let Mt = r.convert(B.format, B.colorSpace), rt = r.convert(B.type), k = L(B.internalFormat, Mt, rt, B.colorSpace); + if (!n.get(S).__hasExternalTextures) { + let bt = Math.max(1, S.width >> it), At = Math.max(1, S.height >> it); + et === s1.TEXTURE_3D || et === s1.TEXTURE_2D_ARRAY ? e.texImage3D(et, it, k, bt, At, S.depth, 0, Mt, rt, null) : e.texImage2D(et, it, k, bt, At, 0, Mt, rt, null); + } + e.bindFramebuffer(s1.FRAMEBUFFER, C), Dt(S) ? d.framebufferTexture2DMultisampleEXT(s1.FRAMEBUFFER, nt, et, n.get(B).__webglTexture, 0, xt(S)) : (et === s1.TEXTURE_2D || et >= s1.TEXTURE_CUBE_MAP_POSITIVE_X && et <= s1.TEXTURE_CUBE_MAP_NEGATIVE_Z) && s1.framebufferTexture2D(s1.FRAMEBUFFER, nt, et, n.get(B).__webglTexture, it), e.bindFramebuffer(s1.FRAMEBUFFER, null); + } + function P(C, S, B) { + if (s1.bindRenderbuffer(s1.RENDERBUFFER, C), S.depthBuffer && !S.stencilBuffer) { + let nt = s1.DEPTH_COMPONENT16; + if (B || Dt(S)) { + let et = S.depthTexture; + et && et.isDepthTexture && (et.type === xn ? nt = s1.DEPTH_COMPONENT32F : et.type === Pn && (nt = s1.DEPTH_COMPONENT24)); + let it = xt(S); + Dt(S) ? d.renderbufferStorageMultisampleEXT(s1.RENDERBUFFER, it, nt, S.width, S.height) : s1.renderbufferStorageMultisample(s1.RENDERBUFFER, it, nt, S.width, S.height); + } else s1.renderbufferStorage(s1.RENDERBUFFER, nt, S.width, S.height); + s1.framebufferRenderbuffer(s1.FRAMEBUFFER, s1.DEPTH_ATTACHMENT, s1.RENDERBUFFER, C); + } else if (S.depthBuffer && S.stencilBuffer) { + let nt = xt(S); + B && Dt(S) === !1 ? s1.renderbufferStorageMultisample(s1.RENDERBUFFER, nt, s1.DEPTH24_STENCIL8, S.width, S.height) : Dt(S) ? d.renderbufferStorageMultisampleEXT(s1.RENDERBUFFER, nt, s1.DEPTH24_STENCIL8, S.width, S.height) : s1.renderbufferStorage(s1.RENDERBUFFER, s1.DEPTH_STENCIL, S.width, S.height), s1.framebufferRenderbuffer(s1.FRAMEBUFFER, s1.DEPTH_STENCIL_ATTACHMENT, s1.RENDERBUFFER, C); } else { - let $ = T.isWebGLMultipleRenderTargets === !0 ? T.texture[0] : T.texture, re = r.convert($.format), Z = r.convert($.type), Me = L($.internalFormat, re, Z, $.encoding), ve = ue(T); - J && T.useRenderbuffer ? s.renderbufferStorageMultisample(36161, ve, Me, T.width, T.height) : T.useRenderToTexture ? f.renderbufferStorageMultisampleEXT(36161, ve, Me, T.width, T.height) : s.renderbufferStorage(36161, Me, T.width, T.height); - } - s.bindRenderbuffer(36161, null); - } - function ge(C, T) { - if (T && T.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported"); - if (t.bindFramebuffer(36160, C), !(T.depthTexture && T.depthTexture.isDepthTexture)) throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); - (!n.get(T.depthTexture).__webglTexture || T.depthTexture.image.width !== T.width || T.depthTexture.image.height !== T.height) && (T.depthTexture.image.width = T.width, T.depthTexture.image.height = T.height, T.depthTexture.needsUpdate = !0), O(T.depthTexture, 0); - let $ = n.get(T.depthTexture).__webglTexture, re = ue(T); - if (T.depthTexture.format === Vn) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 36096, 3553, $, 0, re) : s.framebufferTexture2D(36160, 36096, 3553, $, 0); - else if (T.depthTexture.format === Li) T.useRenderToTexture ? f.framebufferTexture2DMultisampleEXT(36160, 33306, 3553, $, 0, re) : s.framebufferTexture2D(36160, 33306, 3553, $, 0); + let nt = S.isWebGLMultipleRenderTargets === !0 ? S.texture : [ + S.texture + ]; + for(let et = 0; et < nt.length; et++){ + let it = nt[et], Mt = r.convert(it.format, it.colorSpace), rt = r.convert(it.type), k = L(it.internalFormat, Mt, rt, it.colorSpace), Rt = xt(S); + B && Dt(S) === !1 ? s1.renderbufferStorageMultisample(s1.RENDERBUFFER, Rt, k, S.width, S.height) : Dt(S) ? d.renderbufferStorageMultisampleEXT(s1.RENDERBUFFER, Rt, k, S.width, S.height) : s1.renderbufferStorage(s1.RENDERBUFFER, k, S.width, S.height); + } + } + s1.bindRenderbuffer(s1.RENDERBUFFER, null); + } + function at(C, S) { + if (S && S.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported"); + if (e.bindFramebuffer(s1.FRAMEBUFFER, C), !(S.depthTexture && S.depthTexture.isDepthTexture)) throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); + (!n.get(S.depthTexture).__webglTexture || S.depthTexture.image.width !== S.width || S.depthTexture.image.height !== S.height) && (S.depthTexture.image.width = S.width, S.depthTexture.image.height = S.height, S.depthTexture.needsUpdate = !0), tt(S.depthTexture, 0); + let nt = n.get(S.depthTexture).__webglTexture, et = xt(S); + if (S.depthTexture.format === ii) Dt(S) ? d.framebufferTexture2DMultisampleEXT(s1.FRAMEBUFFER, s1.DEPTH_ATTACHMENT, s1.TEXTURE_2D, nt, 0, et) : s1.framebufferTexture2D(s1.FRAMEBUFFER, s1.DEPTH_ATTACHMENT, s1.TEXTURE_2D, nt, 0); + else if (S.depthTexture.format === Yi) Dt(S) ? d.framebufferTexture2DMultisampleEXT(s1.FRAMEBUFFER, s1.DEPTH_STENCIL_ATTACHMENT, s1.TEXTURE_2D, nt, 0, et) : s1.framebufferTexture2D(s1.FRAMEBUFFER, s1.DEPTH_STENCIL_ATTACHMENT, s1.TEXTURE_2D, nt, 0); else throw new Error("Unknown depthTexture format"); } - function xe(C) { - let T = n.get(C), J = C.isWebGLCubeRenderTarget === !0; - if (C.depthTexture && !T.__autoAllocateDepthBuffer) { - if (J) throw new Error("target.depthTexture not supported in Cube render targets"); - ge(T.__webglFramebuffer, C); - } else if (J) { - T.__webglDepthbuffer = []; - for(let $ = 0; $ < 6; $++)t.bindFramebuffer(36160, T.__webglFramebuffer[$]), T.__webglDepthbuffer[$] = s.createRenderbuffer(), ye(T.__webglDepthbuffer[$], C, !1); - } else t.bindFramebuffer(36160, T.__webglFramebuffer), T.__webglDepthbuffer = s.createRenderbuffer(), ye(T.__webglDepthbuffer, C, !1); - t.bindFramebuffer(36160, null); - } - function Oe(C, T, J) { - let $ = n.get(C); - T !== void 0 && Ce($.__webglFramebuffer, C, C.texture, 36064, 3553), J !== void 0 && xe(C); - } - function G(C) { - let T = C.texture, J = n.get(C), $ = n.get(T); - C.addEventListener("dispose", P), C.isWebGLMultipleRenderTargets !== !0 && ($.__webglTexture === void 0 && ($.__webglTexture = s.createTexture()), $.__version = T.version, o.memory.textures++); - let re = C.isWebGLCubeRenderTarget === !0, Z = C.isWebGLMultipleRenderTargets === !0, Me = T.isDataTexture3D || T.isDataTexture2DArray, ve = _(C) || a; - if (a && T.format === Gn && (T.type === nn || T.type === kn) && (T.format = ct, console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")), re) { - J.__webglFramebuffer = []; - for(let te = 0; te < 6; te++)J.__webglFramebuffer[te] = s.createFramebuffer(); - } else if (J.__webglFramebuffer = s.createFramebuffer(), Z) if (i.drawBuffers) { - let te = C.texture; - for(let R = 0, ee = te.length; R < ee; R++){ - let Q = n.get(te[R]); - Q.__webglTexture === void 0 && (Q.__webglTexture = s.createTexture(), o.memory.textures++); + function Z(C) { + let S = n.get(C), B = C.isWebGLCubeRenderTarget === !0; + if (C.depthTexture && !S.__autoAllocateDepthBuffer) { + if (B) throw new Error("target.depthTexture not supported in Cube render targets"); + at(S.__webglFramebuffer, C); + } else if (B) { + S.__webglDepthbuffer = []; + for(let nt = 0; nt < 6; nt++)e.bindFramebuffer(s1.FRAMEBUFFER, S.__webglFramebuffer[nt]), S.__webglDepthbuffer[nt] = s1.createRenderbuffer(), P(S.__webglDepthbuffer[nt], C, !1); + } else e.bindFramebuffer(s1.FRAMEBUFFER, S.__webglFramebuffer), S.__webglDepthbuffer = s1.createRenderbuffer(), P(S.__webglDepthbuffer, C, !1); + e.bindFramebuffer(s1.FRAMEBUFFER, null); + } + function st(C, S, B) { + let nt = n.get(C); + S !== void 0 && Pt(nt.__webglFramebuffer, C, C.texture, s1.COLOR_ATTACHMENT0, s1.TEXTURE_2D, 0), B !== void 0 && Z(C); + } + function Q(C) { + let S = C.texture, B = n.get(C), nt = n.get(S); + C.addEventListener("dispose", $), C.isWebGLMultipleRenderTargets !== !0 && (nt.__webglTexture === void 0 && (nt.__webglTexture = s1.createTexture()), nt.__version = S.version, a.memory.textures++); + let et = C.isWebGLCubeRenderTarget === !0, it = C.isWebGLMultipleRenderTargets === !0, Mt = y(C) || o; + if (et) { + B.__webglFramebuffer = []; + for(let rt = 0; rt < 6; rt++)if (o && S.mipmaps && S.mipmaps.length > 0) { + B.__webglFramebuffer[rt] = []; + for(let k = 0; k < S.mipmaps.length; k++)B.__webglFramebuffer[rt][k] = s1.createFramebuffer(); + } else B.__webglFramebuffer[rt] = s1.createFramebuffer(); + } else { + if (o && S.mipmaps && S.mipmaps.length > 0) { + B.__webglFramebuffer = []; + for(let rt = 0; rt < S.mipmaps.length; rt++)B.__webglFramebuffer[rt] = s1.createFramebuffer(); + } else B.__webglFramebuffer = s1.createFramebuffer(); + if (it) if (i.drawBuffers) { + let rt = C.texture; + for(let k = 0, Rt = rt.length; k < Rt; k++){ + let bt = n.get(rt[k]); + bt.__webglTexture === void 0 && (bt.__webglTexture = s1.createTexture(), a.memory.textures++); + } + } else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension."); + if (o && C.samples > 0 && Dt(C) === !1) { + let rt = it ? S : [ + S + ]; + B.__webglMultisampledFramebuffer = s1.createFramebuffer(), B.__webglColorRenderbuffer = [], e.bindFramebuffer(s1.FRAMEBUFFER, B.__webglMultisampledFramebuffer); + for(let k = 0; k < rt.length; k++){ + let Rt = rt[k]; + B.__webglColorRenderbuffer[k] = s1.createRenderbuffer(), s1.bindRenderbuffer(s1.RENDERBUFFER, B.__webglColorRenderbuffer[k]); + let bt = r.convert(Rt.format, Rt.colorSpace), At = r.convert(Rt.type), vt = L(Rt.internalFormat, bt, At, Rt.colorSpace, C.isXRRenderTarget === !0), yt = xt(C); + s1.renderbufferStorageMultisample(s1.RENDERBUFFER, yt, vt, C.width, C.height), s1.framebufferRenderbuffer(s1.FRAMEBUFFER, s1.COLOR_ATTACHMENT0 + k, s1.RENDERBUFFER, B.__webglColorRenderbuffer[k]); + } + s1.bindRenderbuffer(s1.RENDERBUFFER, null), C.depthBuffer && (B.__webglDepthRenderbuffer = s1.createRenderbuffer(), P(B.__webglDepthRenderbuffer, C, !0)), e.bindFramebuffer(s1.FRAMEBUFFER, null); } - } else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension."); - else if (C.useRenderbuffer) if (a) { - J.__webglMultisampledFramebuffer = s.createFramebuffer(), J.__webglColorRenderbuffer = s.createRenderbuffer(), s.bindRenderbuffer(36161, J.__webglColorRenderbuffer); - let te = r.convert(T.format), R = r.convert(T.type), ee = L(T.internalFormat, te, R, T.encoding), Q = ue(C); - s.renderbufferStorageMultisample(36161, Q, ee, C.width, C.height), t.bindFramebuffer(36160, J.__webglMultisampledFramebuffer), s.framebufferRenderbuffer(36160, 36064, 36161, J.__webglColorRenderbuffer), s.bindRenderbuffer(36161, null), C.depthBuffer && (J.__webglDepthRenderbuffer = s.createRenderbuffer(), ye(J.__webglDepthRenderbuffer, C, !0)), t.bindFramebuffer(36160, null); - } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); - if (re) { - t.bindTexture(34067, $.__webglTexture), le(34067, T, ve); - for(let te = 0; te < 6; te++)Ce(J.__webglFramebuffer[te], C, T, 36064, 34069 + te); - b(T, ve) && A(34067), t.unbindTexture(); - } else if (Z) { - let te = C.texture; - for(let R = 0, ee = te.length; R < ee; R++){ - let Q = te[R], Ee = n.get(Q); - t.bindTexture(3553, Ee.__webglTexture), le(3553, Q, ve), Ce(J.__webglFramebuffer, C, Q, 36064 + R, 3553), b(Q, ve) && A(3553); + } + if (et) { + e.bindTexture(s1.TEXTURE_CUBE_MAP, nt.__webglTexture), Tt(s1.TEXTURE_CUBE_MAP, S, Mt); + for(let rt = 0; rt < 6; rt++)if (o && S.mipmaps && S.mipmaps.length > 0) for(let k = 0; k < S.mipmaps.length; k++)Pt(B.__webglFramebuffer[rt][k], C, S, s1.COLOR_ATTACHMENT0, s1.TEXTURE_CUBE_MAP_POSITIVE_X + rt, k); + else Pt(B.__webglFramebuffer[rt], C, S, s1.COLOR_ATTACHMENT0, s1.TEXTURE_CUBE_MAP_POSITIVE_X + rt, 0); + w(S, Mt) && R(s1.TEXTURE_CUBE_MAP), e.unbindTexture(); + } else if (it) { + let rt = C.texture; + for(let k = 0, Rt = rt.length; k < Rt; k++){ + let bt = rt[k], At = n.get(bt); + e.bindTexture(s1.TEXTURE_2D, At.__webglTexture), Tt(s1.TEXTURE_2D, bt, Mt), Pt(B.__webglFramebuffer, C, bt, s1.COLOR_ATTACHMENT0 + k, s1.TEXTURE_2D, 0), w(bt, Mt) && R(s1.TEXTURE_2D); } - t.unbindTexture(); + e.unbindTexture(); } else { - let te = 3553; - Me && (a ? te = T.isDataTexture3D ? 32879 : 35866 : console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")), t.bindTexture(te, $.__webglTexture), le(te, T, ve), Ce(J.__webglFramebuffer, C, T, 36064, te), b(T, ve) && A(te), t.unbindTexture(); + let rt = s1.TEXTURE_2D; + if ((C.isWebGL3DRenderTarget || C.isWebGLArrayRenderTarget) && (o ? rt = C.isWebGL3DRenderTarget ? s1.TEXTURE_3D : s1.TEXTURE_2D_ARRAY : console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")), e.bindTexture(rt, nt.__webglTexture), Tt(rt, S, Mt), o && S.mipmaps && S.mipmaps.length > 0) for(let k = 0; k < S.mipmaps.length; k++)Pt(B.__webglFramebuffer[k], C, S, s1.COLOR_ATTACHMENT0, rt, k); + else Pt(B.__webglFramebuffer, C, S, s1.COLOR_ATTACHMENT0, rt, 0); + w(S, Mt) && R(rt), e.unbindTexture(); } - C.depthBuffer && xe(C); + C.depthBuffer && Z(C); } - function j(C) { - let T = _(C) || a, J = C.isWebGLMultipleRenderTargets === !0 ? C.texture : [ + function St(C) { + let S = y(C) || o, B = C.isWebGLMultipleRenderTargets === !0 ? C.texture : [ C.texture ]; - for(let $ = 0, re = J.length; $ < re; $++){ - let Z = J[$]; - if (b(Z, T)) { - let Me = C.isWebGLCubeRenderTarget ? 34067 : 3553, ve = n.get(Z).__webglTexture; - t.bindTexture(Me, ve), A(Me), t.unbindTexture(); + for(let nt = 0, et = B.length; nt < et; nt++){ + let it = B[nt]; + if (w(it, S)) { + let Mt = C.isWebGLCubeRenderTarget ? s1.TEXTURE_CUBE_MAP : s1.TEXTURE_2D, rt = n.get(it).__webglTexture; + e.bindTexture(Mt, rt), R(Mt), e.unbindTexture(); } } } - function K(C) { - if (C.useRenderbuffer) if (a) { - let T = C.width, J = C.height, $ = 16384, re = [ - 36064 - ], Z = C.stencilBuffer ? 33306 : 36096; - C.depthBuffer && re.push(Z), C.ignoreDepthForMultisampleCopy || (C.depthBuffer && ($ |= 256), C.stencilBuffer && ($ |= 1024)); - let Me = n.get(C); - t.bindFramebuffer(36008, Me.__webglMultisampledFramebuffer), t.bindFramebuffer(36009, Me.__webglFramebuffer), C.ignoreDepthForMultisampleCopy && (s.invalidateFramebuffer(36008, [ - Z - ]), s.invalidateFramebuffer(36009, [ - Z - ])), s.blitFramebuffer(0, 0, T, J, 0, 0, T, J, $, 9728), s.invalidateFramebuffer(36008, re), t.bindFramebuffer(36008, null), t.bindFramebuffer(36009, Me.__webglMultisampledFramebuffer); - } else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); + function mt(C) { + if (o && C.samples > 0 && Dt(C) === !1) { + let S = C.isWebGLMultipleRenderTargets ? C.texture : [ + C.texture + ], B = C.width, nt = C.height, et = s1.COLOR_BUFFER_BIT, it = [], Mt = C.stencilBuffer ? s1.DEPTH_STENCIL_ATTACHMENT : s1.DEPTH_ATTACHMENT, rt = n.get(C), k = C.isWebGLMultipleRenderTargets === !0; + if (k) for(let Rt = 0; Rt < S.length; Rt++)e.bindFramebuffer(s1.FRAMEBUFFER, rt.__webglMultisampledFramebuffer), s1.framebufferRenderbuffer(s1.FRAMEBUFFER, s1.COLOR_ATTACHMENT0 + Rt, s1.RENDERBUFFER, null), e.bindFramebuffer(s1.FRAMEBUFFER, rt.__webglFramebuffer), s1.framebufferTexture2D(s1.DRAW_FRAMEBUFFER, s1.COLOR_ATTACHMENT0 + Rt, s1.TEXTURE_2D, null, 0); + e.bindFramebuffer(s1.READ_FRAMEBUFFER, rt.__webglMultisampledFramebuffer), e.bindFramebuffer(s1.DRAW_FRAMEBUFFER, rt.__webglFramebuffer); + for(let Rt = 0; Rt < S.length; Rt++){ + it.push(s1.COLOR_ATTACHMENT0 + Rt), C.depthBuffer && it.push(Mt); + let bt = rt.__ignoreDepthValues !== void 0 ? rt.__ignoreDepthValues : !1; + if (bt === !1 && (C.depthBuffer && (et |= s1.DEPTH_BUFFER_BIT), C.stencilBuffer && (et |= s1.STENCIL_BUFFER_BIT)), k && s1.framebufferRenderbuffer(s1.READ_FRAMEBUFFER, s1.COLOR_ATTACHMENT0, s1.RENDERBUFFER, rt.__webglColorRenderbuffer[Rt]), bt === !0 && (s1.invalidateFramebuffer(s1.READ_FRAMEBUFFER, [ + Mt + ]), s1.invalidateFramebuffer(s1.DRAW_FRAMEBUFFER, [ + Mt + ])), k) { + let At = n.get(S[Rt]).__webglTexture; + s1.framebufferTexture2D(s1.DRAW_FRAMEBUFFER, s1.COLOR_ATTACHMENT0, s1.TEXTURE_2D, At, 0); + } + s1.blitFramebuffer(0, 0, B, nt, 0, 0, B, nt, et, s1.NEAREST), f && s1.invalidateFramebuffer(s1.READ_FRAMEBUFFER, it); + } + if (e.bindFramebuffer(s1.READ_FRAMEBUFFER, null), e.bindFramebuffer(s1.DRAW_FRAMEBUFFER, null), k) for(let Rt = 0; Rt < S.length; Rt++){ + e.bindFramebuffer(s1.FRAMEBUFFER, rt.__webglMultisampledFramebuffer), s1.framebufferRenderbuffer(s1.FRAMEBUFFER, s1.COLOR_ATTACHMENT0 + Rt, s1.RENDERBUFFER, rt.__webglColorRenderbuffer[Rt]); + let bt = n.get(S[Rt]).__webglTexture; + e.bindFramebuffer(s1.FRAMEBUFFER, rt.__webglFramebuffer), s1.framebufferTexture2D(s1.DRAW_FRAMEBUFFER, s1.COLOR_ATTACHMENT0 + Rt, s1.TEXTURE_2D, bt, 0); + } + e.bindFramebuffer(s1.DRAW_FRAMEBUFFER, rt.__webglMultisampledFramebuffer); + } } - function ue(C) { - return a && (C.useRenderbuffer || C.useRenderToTexture) ? Math.min(u, C.samples) : 0; + function xt(C) { + return Math.min(u, C.samples); } - function se(C) { - let T = o.render.frame; - m.get(C) !== T && (m.set(C, T), C.update()); + function Dt(C) { + let S = n.get(C); + return o && C.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && S.__useRenderToTexture !== !1; } - let Se = !1, Te = !1; - function Pe(C, T) { - C && C.isWebGLRenderTarget && (Se === !1 && (console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."), Se = !0), C = C.texture), O(C, T); + function Xt(C) { + let S = a.render.frame; + m.get(C) !== S && (m.set(C, S), C.update()); } - function Ye(C, T) { - C && C.isWebGLCubeRenderTarget && (Te === !1 && (console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."), Te = !0), C = C.texture), V(C, T); + function ie(C, S) { + let B = C.colorSpace, nt = C.format, et = C.type; + return C.isCompressedTexture === !0 || C.format === co || B !== nn && B !== ri && (B === Nt ? o === !1 ? t.has("EXT_sRGB") === !0 && nt === He ? (C.format = co, C.minFilter = pe, C.generateMipmaps = !1) : S = Gr.sRGBToLinear(S) : (nt !== He || et !== Nn) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", B)), S; } - this.allocateTextureUnit = F, this.resetTextureUnits = U, this.setTexture2D = O, this.setTexture2DArray = ne, this.setTexture3D = ce, this.setTextureCube = V, this.rebindTextures = Oe, this.setupRenderTarget = G, this.updateRenderTargetMipmap = j, this.updateMultisampleRenderTarget = K, this.setupDepthRenderbuffer = xe, this.setupFrameBufferTexture = Ce, this.safeSetTexture2D = Pe, this.safeSetTextureCube = Ye; + this.allocateTextureUnit = Y, this.resetTextureUnits = X, this.setTexture2D = tt, this.setTexture2DArray = N, this.setTexture3D = q, this.setTextureCube = lt, this.rebindTextures = st, this.setupRenderTarget = Q, this.updateRenderTargetMipmap = St, this.updateMultisampleRenderTarget = mt, this.setupDepthRenderbuffer = Z, this.setupFrameBufferTexture = Pt, this.useMultisampledRTT = Dt; } -function Ex(s, e, t) { - let n = t.isWebGL2; - function i(r) { +function O0(s1, t, e) { + let n = e.isWebGL2; + function i(r, a = ri) { let o; - if (r === rn) return 5121; - if (r === Vu) return 32819; - if (r === Wu) return 32820; - if (r === qu) return 33635; - if (r === Hu) return 5120; - if (r === ku) return 5122; - if (r === cr) return 5123; - if (r === Gu) return 5124; - if (r === Ps) return 5125; - if (r === nn) return 5126; - if (r === kn) return n ? 5131 : (o = e.get("OES_texture_half_float"), o !== null ? o.HALF_FLOAT_OES : null); - if (r === Xu) return 6406; - if (r === Gn) return 6407; - if (r === ct) return 6408; - if (r === Ju) return 6409; - if (r === Yu) return 6410; - if (r === Vn) return 6402; - if (r === Li) return 34041; - if (r === Zu) return 6403; - if (r === $u) return 36244; - if (r === ju) return 33319; - if (r === Qu) return 33320; - if (r === Ku) return 36248; - if (r === ed) return 36249; - if (r === al || r === ll || r === cl || r === hl) if (o = e.get("WEBGL_compressed_texture_s3tc"), o !== null) { - if (r === al) return o.COMPRESSED_RGB_S3TC_DXT1_EXT; - if (r === ll) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; - if (r === cl) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; - if (r === hl) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; + if (r === Nn) return s1.UNSIGNED_BYTE; + if (r === od) return s1.UNSIGNED_SHORT_4_4_4_4; + if (r === cd) return s1.UNSIGNED_SHORT_5_5_5_1; + if (r === uf) return s1.BYTE; + if (r === df) return s1.SHORT; + if (r === Bc) return s1.UNSIGNED_SHORT; + if (r === ad) return s1.INT; + if (r === Pn) return s1.UNSIGNED_INT; + if (r === xn) return s1.FLOAT; + if (r === Ts) return n ? s1.HALF_FLOAT : (o = t.get("OES_texture_half_float"), o !== null ? o.HALF_FLOAT_OES : null); + if (r === ff) return s1.ALPHA; + if (r === He) return s1.RGBA; + if (r === pf) return s1.LUMINANCE; + if (r === mf) return s1.LUMINANCE_ALPHA; + if (r === ii) return s1.DEPTH_COMPONENT; + if (r === Yi) return s1.DEPTH_STENCIL; + if (r === co) return o = t.get("EXT_sRGB"), o !== null ? o.SRGB_ALPHA_EXT : null; + if (r === gf) return s1.RED; + if (r === ld) return s1.RED_INTEGER; + if (r === _f) return s1.RG; + if (r === hd) return s1.RG_INTEGER; + if (r === ud) return s1.RGBA_INTEGER; + if (r === Ma || r === Sa || r === ba || r === Ea) if (a === Nt) if (o = t.get("WEBGL_compressed_texture_s3tc_srgb"), o !== null) { + if (r === Ma) return o.COMPRESSED_SRGB_S3TC_DXT1_EXT; + if (r === Sa) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + if (r === ba) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + if (r === Ea) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; } else return null; - if (r === ul || r === dl || r === fl || r === pl) if (o = e.get("WEBGL_compressed_texture_pvrtc"), o !== null) { - if (r === ul) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - if (r === dl) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - if (r === fl) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - if (r === pl) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + else if (o = t.get("WEBGL_compressed_texture_s3tc"), o !== null) { + if (r === Ma) return o.COMPRESSED_RGB_S3TC_DXT1_EXT; + if (r === Sa) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if (r === ba) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if (r === Ea) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; } else return null; - if (r === td) return o = e.get("WEBGL_compressed_texture_etc1"), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; - if ((r === ml || r === gl) && (o = e.get("WEBGL_compressed_texture_etc"), o !== null)) { - if (r === ml) return o.COMPRESSED_RGB8_ETC2; - if (r === gl) return o.COMPRESSED_RGBA8_ETC2_EAC; - } - if (r === nd || r === id || r === rd || r === sd || r === od || r === ad || r === ld || r === cd || r === hd || r === ud || r === dd || r === fd || r === pd || r === md || r === xd || r === yd || r === vd || r === _d || r === Md || r === bd || r === wd || r === Sd || r === Td || r === Ed || r === Ad || r === Cd || r === Ld || r === Rd) return o = e.get("WEBGL_compressed_texture_astc"), o !== null ? r : null; - if (r === gd) return o = e.get("EXT_texture_compression_bptc"), o !== null ? r : null; - if (r === Ti) return n ? 34042 : (o = e.get("WEBGL_depth_texture"), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null); + if (r === al || r === ol || r === cl || r === ll) if (o = t.get("WEBGL_compressed_texture_pvrtc"), o !== null) { + if (r === al) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if (r === ol) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if (r === cl) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if (r === ll) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + } else return null; + if (r === xf) return o = t.get("WEBGL_compressed_texture_etc1"), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; + if (r === hl || r === ul) if (o = t.get("WEBGL_compressed_texture_etc"), o !== null) { + if (r === hl) return a === Nt ? o.COMPRESSED_SRGB8_ETC2 : o.COMPRESSED_RGB8_ETC2; + if (r === ul) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : o.COMPRESSED_RGBA8_ETC2_EAC; + } else return null; + if (r === dl || r === fl || r === pl || r === ml || r === gl || r === _l || r === xl || r === vl || r === yl || r === Ml || r === Sl || r === bl || r === El || r === Tl) if (o = t.get("WEBGL_compressed_texture_astc"), o !== null) { + if (r === dl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : o.COMPRESSED_RGBA_ASTC_4x4_KHR; + if (r === fl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : o.COMPRESSED_RGBA_ASTC_5x4_KHR; + if (r === pl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : o.COMPRESSED_RGBA_ASTC_5x5_KHR; + if (r === ml) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : o.COMPRESSED_RGBA_ASTC_6x5_KHR; + if (r === gl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : o.COMPRESSED_RGBA_ASTC_6x6_KHR; + if (r === _l) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : o.COMPRESSED_RGBA_ASTC_8x5_KHR; + if (r === xl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : o.COMPRESSED_RGBA_ASTC_8x6_KHR; + if (r === vl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : o.COMPRESSED_RGBA_ASTC_8x8_KHR; + if (r === yl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : o.COMPRESSED_RGBA_ASTC_10x5_KHR; + if (r === Ml) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : o.COMPRESSED_RGBA_ASTC_10x6_KHR; + if (r === Sl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : o.COMPRESSED_RGBA_ASTC_10x8_KHR; + if (r === bl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : o.COMPRESSED_RGBA_ASTC_10x10_KHR; + if (r === El) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : o.COMPRESSED_RGBA_ASTC_12x10_KHR; + if (r === Tl) return a === Nt ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : o.COMPRESSED_RGBA_ASTC_12x12_KHR; + } else return null; + if (r === Ta) if (o = t.get("EXT_texture_compression_bptc"), o !== null) { + if (r === Ta) return a === Nt ? o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : o.COMPRESSED_RGBA_BPTC_UNORM_EXT; + } else return null; + if (r === vf || r === wl || r === Al || r === Rl) if (o = t.get("EXT_texture_compression_rgtc"), o !== null) { + if (r === Ta) return o.COMPRESSED_RED_RGTC1_EXT; + if (r === wl) return o.COMPRESSED_SIGNED_RED_RGTC1_EXT; + if (r === Al) return o.COMPRESSED_RED_GREEN_RGTC2_EXT; + if (r === Rl) return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; + } else return null; + return r === ni ? n ? s1.UNSIGNED_INT_24_8 : (o = t.get("WEBGL_depth_texture"), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null) : s1[r] !== void 0 ? s1[r] : null; } return { convert: i }; } -var ga = class extends ut { - constructor(e = []){ - super(); - this.cameras = e; +var yo = class extends xe { + constructor(t = []){ + super(), this.isArrayCamera = !0, this.cameras = t; } -}; -ga.prototype.isArrayCamera = !0; -var Hn = class extends Ne { +}, ti = class extends Zt { constructor(){ - super(); - this.type = "Group"; + super(), this.isGroup = !0, this.type = "Group"; } -}; -Hn.prototype.isGroup = !0; -var Ax = { +}, B0 = { type: "move" -}, Is = class { +}, Ss = class { constructor(){ this._targetRay = null, this._grip = null, this._hand = null; } getHandSpace() { - return this._hand === null && (this._hand = new Hn, this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { + return this._hand === null && (this._hand = new ti, this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand; } getTargetRaySpace() { - return this._targetRay === null && (this._targetRay = new Hn, this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new M, this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new M), this._targetRay; + return this._targetRay === null && (this._targetRay = new ti, this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new A, this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new A), this._targetRay; } getGripSpace() { - return this._grip === null && (this._grip = new Hn, this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new M, this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new M), this._grip; + return this._grip === null && (this._grip = new ti, this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new A, this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new A), this._grip; + } + dispatchEvent(t) { + return this._targetRay !== null && this._targetRay.dispatchEvent(t), this._grip !== null && this._grip.dispatchEvent(t), this._hand !== null && this._hand.dispatchEvent(t), this; } - dispatchEvent(e) { - return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this; + connect(t) { + if (t && t.hand) { + let e = this._hand; + if (e) for (let n of t.hand.values())this._getHandJoint(e, n); + } + return this.dispatchEvent({ + type: "connected", + data: t + }), this; } - disconnect(e) { + disconnect(t) { return this.dispatchEvent({ type: "disconnected", - data: e + data: t }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this; } - update(e, t, n) { - let i = null, r = null, o = null, a = this._targetRay, l = this._grip, c = this._hand; - if (e && t.session.visibilityState !== "visible-blurred") if (a !== null && (i = t.getPose(e.targetRaySpace, n), i !== null && (a.matrix.fromArray(i.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), i.linearVelocity ? (a.hasLinearVelocity = !0, a.linearVelocity.copy(i.linearVelocity)) : a.hasLinearVelocity = !1, i.angularVelocity ? (a.hasAngularVelocity = !0, a.angularVelocity.copy(i.angularVelocity)) : a.hasAngularVelocity = !1, this.dispatchEvent(Ax))), c && e.hand) { - o = !0; - for (let x of e.hand.values()){ - let v = t.getJointPose(x, n); - if (c.joints[x.jointName] === void 0) { - let p = new Hn; - p.matrixAutoUpdate = !1, p.visible = !1, c.joints[x.jointName] = p, c.add(p); + update(t, e, n) { + let i = null, r = null, a = null, o = this._targetRay, c = this._grip, l = this._hand; + if (t && e.session.visibilityState !== "visible-blurred") { + if (l && t.hand) { + a = !0; + for (let x of t.hand.values()){ + let g = e.getJointPose(x, n), p = this._getHandJoint(l, x); + g !== null && (p.matrix.fromArray(g.transform.matrix), p.matrix.decompose(p.position, p.rotation, p.scale), p.matrixWorldNeedsUpdate = !0, p.jointRadius = g.radius), p.visible = g !== null; } - let g = c.joints[x.jointName]; - v !== null && (g.matrix.fromArray(v.transform.matrix), g.matrix.decompose(g.position, g.rotation, g.scale), g.jointRadius = v.radius), g.visible = v !== null; - } - let h = c.joints["index-finger-tip"], u = c.joints["thumb-tip"], d = h.position.distanceTo(u.position), f = .02, m = .005; - c.inputState.pinching && d > f + m ? (c.inputState.pinching = !1, this.dispatchEvent({ - type: "pinchend", - handedness: e.handedness, - target: this - })) : !c.inputState.pinching && d <= f - m && (c.inputState.pinching = !0, this.dispatchEvent({ - type: "pinchstart", - handedness: e.handedness, - target: this - })); - } else l !== null && e.gripSpace && (r = t.getPose(e.gripSpace, n), r !== null && (l.matrix.fromArray(r.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), 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)); - return a !== null && (a.visible = i !== null), l !== null && (l.visible = r !== null), c !== null && (c.visible = o !== null), this; - } -}, ks = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h){ - if (h = h !== void 0 ? h : Vn, h !== Vn && h !== Li) throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); - n === void 0 && h === Vn && (n = cr), n === void 0 && h === Li && (n = Ti); - super(null, i, r, o, a, l, h, n, c); - this.image = { - width: e, - height: t - }, this.magFilter = a !== void 0 ? a : rt, this.minFilter = l !== void 0 ? l : rt, this.flipY = !1, this.generateMipmaps = !1; + let h = l.joints["index-finger-tip"], u = l.joints["thumb-tip"], d = h.position.distanceTo(u.position), f = .02, m = .005; + l.inputState.pinching && d > f + m ? (l.inputState.pinching = !1, this.dispatchEvent({ + type: "pinchend", + handedness: t.handedness, + target: this + })) : !l.inputState.pinching && d <= f - m && (l.inputState.pinching = !0, this.dispatchEvent({ + type: "pinchstart", + handedness: t.handedness, + target: this + })); + } else c !== null && t.gripSpace && (r = e.getPose(t.gripSpace, n), r !== null && (c.matrix.fromArray(r.transform.matrix), c.matrix.decompose(c.position, c.rotation, c.scale), c.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (c.hasLinearVelocity = !0, c.linearVelocity.copy(r.linearVelocity)) : c.hasLinearVelocity = !1, r.angularVelocity ? (c.hasAngularVelocity = !0, c.angularVelocity.copy(r.angularVelocity)) : c.hasAngularVelocity = !1)); + o !== null && (i = e.getPose(t.targetRaySpace, n), i === null && r !== null && (i = r), i !== null && (o.matrix.fromArray(i.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, i.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(i.linearVelocity)) : o.hasLinearVelocity = !1, i.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(i.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(B0))); + } + return o !== null && (o.visible = i !== null), c !== null && (c.visible = r !== null), l !== null && (l.visible = a !== null), this; + } + _getHandJoint(t, e) { + if (t.joints[e.jointName] === void 0) { + let n = new ti; + n.matrixAutoUpdate = !1, n.visible = !1, t.joints[e.jointName] = n, t.add(n); + } + return t.joints[e.jointName]; + } +}, Mo = class extends ye { + constructor(t, e, n, i, r, a, o, c, l, h){ + if (h = h !== void 0 ? h : ii, h !== ii && h !== Yi) throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); + n === void 0 && h === ii && (n = Pn), n === void 0 && h === Yi && (n = ni), super(null, i, r, a, o, c, h, n, l), this.isDepthTexture = !0, this.image = { + width: t, + height: e + }, this.magFilter = o !== void 0 ? o : fe, this.minFilter = c !== void 0 ? c : fe, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null; } -}; -ks.prototype.isDepthTexture = !0; -var vh = class extends En { - constructor(e, t){ + copy(t) { + return super.copy(t), this.compareFunction = t.compareFunction, this; + } + toJSON(t) { + let e = super.toJSON(t); + return this.compareFunction !== null && (e.compareFunction = this.compareFunction), e; + } +}, So = class extends sn { + constructor(t, e){ super(); - let n = this, i = null, r = 1, o = null, a = "local-floor", l = e.extensions.has("WEBGL_multisampled_render_to_texture"), c = null, h = null, u = null, d = null, f = !1, m = null, x = t.getContextAttributes(), v = null, g = null, p = [], _ = new Map, y = new ut; - y.layers.enable(1), y.viewport = new Ve; - let b = new ut; - b.layers.enable(2), b.viewport = new Ve; - let A = [ + let n = this, i = null, r = 1, a = null, o = "local-floor", c = 1, l = null, h = null, u = null, d = null, f = null, m = null, x = e.getContextAttributes(), g = null, p = null, v = [], _ = [], y = new xe; + y.layers.enable(1), y.viewport = new $t; + let b = new xe; + b.layers.enable(2), b.viewport = new $t; + let w = [ y, b - ], L = new ga; - L.layers.enable(1), L.layers.enable(2); - let I = null, k = null; - this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getTargetRaySpace(); - }, this.getControllerGrip = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getGripSpace(); - }, this.getHand = function(V) { - let W = p[V]; - return W === void 0 && (W = new Is, p[V] = W), W.getHandSpace(); + ], R = new yo; + R.layers.enable(1), R.layers.enable(2); + let L = null, M = null; + this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(N) { + let q = v[N]; + return q === void 0 && (q = new Ss, v[N] = q), q.getTargetRaySpace(); + }, this.getControllerGrip = function(N) { + let q = v[N]; + return q === void 0 && (q = new Ss, v[N] = q), q.getGripSpace(); + }, this.getHand = function(N) { + let q = v[N]; + return q === void 0 && (q = new Ss, v[N] = q), q.getHandSpace(); }; - function B(V) { - let W = _.get(V.inputSource); - W && W.dispatchEvent({ - type: V.type, - data: V.inputSource - }); + function E(N) { + let q = _.indexOf(N.inputSource); + if (q === -1) return; + let lt = v[q]; + lt !== void 0 && (lt.update(N.inputSource, N.frame, l || a), lt.dispatchEvent({ + type: N.type, + data: N.inputSource + })); } - function P() { - _.forEach(function(V, W) { - V.disconnect(W); - }), _.clear(), I = null, k = null, e.setRenderTarget(v), d = null, u = null, h = null, i = null, g = null, ce.stop(), n.isPresenting = !1, n.dispatchEvent({ + function V() { + i.removeEventListener("select", E), i.removeEventListener("selectstart", E), i.removeEventListener("selectend", E), i.removeEventListener("squeeze", E), i.removeEventListener("squeezestart", E), i.removeEventListener("squeezeend", E), i.removeEventListener("end", V), i.removeEventListener("inputsourceschange", $); + for(let N = 0; N < v.length; N++){ + let q = _[N]; + q !== null && (_[N] = null, v[N].disconnect(q)); + } + L = null, M = null, t.setRenderTarget(g), f = null, d = null, u = null, i = null, p = null, tt.stop(), n.isPresenting = !1, n.dispatchEvent({ type: "sessionend" }); } - this.setFramebufferScaleFactor = function(V) { - r = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); - }, this.setReferenceSpaceType = function(V) { - a = V, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); + this.setFramebufferScaleFactor = function(N) { + r = N, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting."); + }, this.setReferenceSpaceType = function(N) { + o = N, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting."); }, this.getReferenceSpace = function() { - return o; + return l || a; + }, this.setReferenceSpace = function(N) { + l = N; }, this.getBaseLayer = function() { - return u !== null ? u : d; + return d !== null ? d : f; }, this.getBinding = function() { - return h; + return u; }, this.getFrame = function() { return m; }, this.getSession = function() { return i; - }, this.setSession = async function(V) { - if (i = V, i !== null) { - if (v = e.getRenderTarget(), i.addEventListener("select", B), i.addEventListener("selectstart", B), i.addEventListener("selectend", B), i.addEventListener("squeeze", B), i.addEventListener("squeezestart", B), i.addEventListener("squeezeend", B), i.addEventListener("end", P), i.addEventListener("inputsourceschange", w), x.xrCompatible !== !0 && await t.makeXRCompatible(), i.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) { - let W = { + }, this.setSession = async function(N) { + if (i = N, i !== null) { + if (g = t.getRenderTarget(), i.addEventListener("select", E), i.addEventListener("selectstart", E), i.addEventListener("selectend", E), i.addEventListener("squeeze", E), i.addEventListener("squeezestart", E), i.addEventListener("squeezeend", E), i.addEventListener("end", V), i.addEventListener("inputsourceschange", $), x.xrCompatible !== !0 && await e.makeXRCompatible(), i.renderState.layers === void 0 || t.capabilities.isWebGL2 === !1) { + let q = { antialias: i.renderState.layers === void 0 ? x.antialias : !0, - alpha: x.alpha, + alpha: !0, depth: x.depth, stencil: x.stencil, framebufferScaleFactor: r }; - d = new XRWebGLLayer(i, t, W), i.updateRenderState({ - baseLayer: d - }), g = new At(d.framebufferWidth, d.framebufferHeight, { - format: ct, - type: rn, - encoding: e.outputEncoding + f = new XRWebGLLayer(i, e, q), i.updateRenderState({ + baseLayer: f + }), p = new Ge(f.framebufferWidth, f.framebufferHeight, { + format: He, + type: Nn, + colorSpace: t.outputColorSpace, + stencilBuffer: x.stencil }); } else { - f = x.antialias; - let W = null, he = null, le = null; - x.depth && (le = x.stencil ? 35056 : 33190, W = x.stencil ? Li : Vn, he = x.stencil ? Ti : cr); - let fe = { - colorFormat: x.alpha || f ? 32856 : 32849, - depthFormat: le, + let q = null, lt = null, ut = null; + x.depth && (ut = x.stencil ? e.DEPTH24_STENCIL8 : e.DEPTH_COMPONENT24, q = x.stencil ? Yi : ii, lt = x.stencil ? ni : Pn); + let pt = { + colorFormat: e.RGBA8, + depthFormat: ut, scaleFactor: r }; - h = new XRWebGLBinding(i, t), u = h.createProjectionLayer(fe), i.updateRenderState({ + u = new XRWebGLBinding(i, e), d = u.createProjectionLayer(pt), i.updateRenderState({ layers: [ - u + d ] - }), f ? g = new Xs(u.textureWidth, u.textureHeight, { - format: ct, - type: rn, - depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), - stencilBuffer: x.stencil, - ignoreDepth: u.ignoreDepthValues, - useRenderToTexture: l, - encoding: e.outputEncoding - }) : g = new At(u.textureWidth, u.textureHeight, { - format: x.alpha ? ct : Gn, - type: rn, - depthTexture: new ks(u.textureWidth, u.textureHeight, he, void 0, void 0, void 0, void 0, void 0, void 0, W), + }), p = new Ge(d.textureWidth, d.textureHeight, { + format: He, + type: Nn, + depthTexture: new Mo(d.textureWidth, d.textureHeight, lt, void 0, void 0, void 0, void 0, void 0, void 0, q), stencilBuffer: x.stencil, - ignoreDepth: u.ignoreDepthValues, - encoding: e.outputEncoding + colorSpace: t.outputColorSpace, + samples: x.antialias ? 4 : 0 }); + let Et = t.properties.get(p); + Et.__ignoreDepthValues = d.ignoreDepthValues; } - this.setFoveation(1), o = await i.requestReferenceSpace(a), ce.setContext(i), ce.start(), n.isPresenting = !0, n.dispatchEvent({ + p.isXRRenderTarget = !0, this.setFoveation(c), l = null, a = await i.requestReferenceSpace(o), tt.setContext(i), tt.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" }); } + }, this.getEnvironmentBlendMode = function() { + if (i !== null) return i.environmentBlendMode; }; - function w(V) { - let W = i.inputSources; - for(let he = 0; he < p.length; he++)_.set(W[he], p[he]); - for(let he = 0; he < V.removed.length; he++){ - let le = V.removed[he], fe = _.get(le); - fe && (fe.dispatchEvent({ - type: "disconnected", - data: le - }), _.delete(le)); + function $(N) { + for(let q = 0; q < N.removed.length; q++){ + let lt = N.removed[q], ut = _.indexOf(lt); + ut >= 0 && (_[ut] = null, v[ut].disconnect(lt)); } - for(let he = 0; he < V.added.length; he++){ - let le = V.added[he], fe = _.get(le); - fe && fe.dispatchEvent({ - type: "connected", - data: le - }); + for(let q = 0; q < N.added.length; q++){ + let lt = N.added[q], ut = _.indexOf(lt); + if (ut === -1) { + for(let Et = 0; Et < v.length; Et++)if (Et >= _.length) { + _.push(lt), ut = Et; + break; + } else if (_[Et] === null) { + _[Et] = lt, ut = Et; + break; + } + if (ut === -1) break; + } + let pt = v[ut]; + pt && pt.connect(lt); } } - let E = new M, D = new M; - function U(V, W, he) { - E.setFromMatrixPosition(W.matrixWorld), D.setFromMatrixPosition(he.matrixWorld); - let le = E.distanceTo(D), fe = W.projectionMatrix.elements, Be = he.projectionMatrix.elements, Y = fe[14] / (fe[10] - 1), Ce = fe[14] / (fe[10] + 1), ye = (fe[9] + 1) / fe[5], ge = (fe[9] - 1) / fe[5], xe = (fe[8] - 1) / fe[0], Oe = (Be[8] + 1) / Be[0], G = Y * xe, j = Y * Oe, K = le / (-xe + Oe), ue = K * -xe; - W.matrixWorld.decompose(V.position, V.quaternion, V.scale), V.translateX(ue), V.translateZ(K), V.matrixWorld.compose(V.position, V.quaternion, V.scale), V.matrixWorldInverse.copy(V.matrixWorld).invert(); - let se = Y + K, Se = Ce + K, Te = G - ue, Pe = j + (le - ue), Ye = ye * Ce / Se * se, C = ge * Ce / Se * se; - V.projectionMatrix.makePerspective(Te, Pe, Ye, C, se, Se); + let F = new A, O = new A; + function z(N, q, lt) { + F.setFromMatrixPosition(q.matrixWorld), O.setFromMatrixPosition(lt.matrixWorld); + let ut = F.distanceTo(O), pt = q.projectionMatrix.elements, Et = lt.projectionMatrix.elements, Tt = pt[14] / (pt[10] - 1), wt = pt[14] / (pt[10] + 1), Yt = (pt[9] + 1) / pt[5], te = (pt[9] - 1) / pt[5], Pt = (pt[8] - 1) / pt[0], P = (Et[8] + 1) / Et[0], at = Tt * Pt, Z = Tt * P, st = ut / (-Pt + P), Q = st * -Pt; + q.matrixWorld.decompose(N.position, N.quaternion, N.scale), N.translateX(Q), N.translateZ(st), N.matrixWorld.compose(N.position, N.quaternion, N.scale), N.matrixWorldInverse.copy(N.matrixWorld).invert(); + let St = Tt + st, mt = wt + st, xt = at - Q, Dt = Z + (ut - Q), Xt = Yt * wt / mt * St, ie = te * wt / mt * St; + N.projectionMatrix.makePerspective(xt, Dt, Xt, ie, St, mt), N.projectionMatrixInverse.copy(N.projectionMatrix).invert(); } - function F(V, W) { - W === null ? V.matrixWorld.copy(V.matrix) : V.matrixWorld.multiplyMatrices(W.matrixWorld, V.matrix), V.matrixWorldInverse.copy(V.matrixWorld).invert(); + function K(N, q) { + q === null ? N.matrixWorld.copy(N.matrix) : N.matrixWorld.multiplyMatrices(q.matrixWorld, N.matrix), N.matrixWorldInverse.copy(N.matrixWorld).invert(); } - this.updateCamera = function(V) { + this.updateCamera = function(N) { if (i === null) return; - L.near = b.near = y.near = V.near, L.far = b.far = y.far = V.far, (I !== L.near || k !== L.far) && (i.updateRenderState({ - depthNear: L.near, - depthFar: L.far - }), I = L.near, k = L.far); - let W = V.parent, he = L.cameras; - F(L, W); - for(let fe = 0; fe < he.length; fe++)F(he[fe], W); - L.matrixWorld.decompose(L.position, L.quaternion, L.scale), V.position.copy(L.position), V.quaternion.copy(L.quaternion), V.scale.copy(L.scale), V.matrix.copy(L.matrix), V.matrixWorld.copy(L.matrixWorld); - let le = V.children; - for(let fe = 0, Be = le.length; fe < Be; fe++)le[fe].updateMatrixWorld(!0); - he.length === 2 ? U(L, y, b) : L.projectionMatrix.copy(y.projectionMatrix); - }, this.getCamera = function() { - return L; + R.near = b.near = y.near = N.near, R.far = b.far = y.far = N.far, (L !== R.near || M !== R.far) && (i.updateRenderState({ + depthNear: R.near, + depthFar: R.far + }), L = R.near, M = R.far); + let q = N.parent, lt = R.cameras; + K(R, q); + for(let ut = 0; ut < lt.length; ut++)K(lt[ut], q); + lt.length === 2 ? z(R, y, b) : R.projectionMatrix.copy(y.projectionMatrix), X(N, R, q); + }; + function X(N, q, lt) { + lt === null ? N.matrix.copy(q.matrixWorld) : (N.matrix.copy(lt.matrixWorld), N.matrix.invert(), N.matrix.multiply(q.matrixWorld)), N.matrix.decompose(N.position, N.quaternion, N.scale), N.updateMatrixWorld(!0); + let ut = N.children; + for(let pt = 0, Et = ut.length; pt < Et; pt++)ut[pt].updateMatrixWorld(!0); + N.projectionMatrix.copy(q.projectionMatrix), N.projectionMatrixInverse.copy(q.projectionMatrixInverse), N.isPerspectiveCamera && (N.fov = Zi * 2 * Math.atan(1 / N.projectionMatrix.elements[5]), N.zoom = 1); + } + this.getCamera = function() { + return R; }, this.getFoveation = function() { - if (u !== null) return u.fixedFoveation; - if (d !== null) return d.fixedFoveation; - }, this.setFoveation = function(V) { - u !== null && (u.fixedFoveation = V), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = V); + if (!(d === null && f === null)) return c; + }, this.setFoveation = function(N) { + c = N, d !== null && (d.fixedFoveation = N), f !== null && f.fixedFoveation !== void 0 && (f.fixedFoveation = N); }; - let O = null; - function ne(V, W) { - if (c = W.getViewerPose(o), m = W, c !== null) { - let le = c.views; - d !== null && (e.setRenderTargetFramebuffer(g, d.framebuffer), e.setRenderTarget(g)); - let fe = !1; - le.length !== L.cameras.length && (L.cameras.length = 0, fe = !0); - for(let Be = 0; Be < le.length; Be++){ - let Y = le[Be], Ce = null; - if (d !== null) Ce = d.getViewport(Y); + let Y = null; + function j(N, q) { + if (h = q.getViewerPose(l || a), m = q, h !== null) { + let lt = h.views; + f !== null && (t.setRenderTargetFramebuffer(p, f.framebuffer), t.setRenderTarget(p)); + let ut = !1; + lt.length !== R.cameras.length && (R.cameras.length = 0, ut = !0); + for(let pt = 0; pt < lt.length; pt++){ + let Et = lt[pt], Tt = null; + if (f !== null) Tt = f.getViewport(Et); else { - let ge = h.getViewSubImage(u, Y); - Ce = ge.viewport, Be === 0 && (e.setRenderTargetTextures(g, ge.colorTexture, u.ignoreDepthValues ? void 0 : ge.depthStencilTexture), e.setRenderTarget(g)); + let Yt = u.getViewSubImage(d, Et); + Tt = Yt.viewport, pt === 0 && (t.setRenderTargetTextures(p, Yt.colorTexture, d.ignoreDepthValues ? void 0 : Yt.depthStencilTexture), t.setRenderTarget(p)); } - let ye = A[Be]; - ye.matrix.fromArray(Y.transform.matrix), ye.projectionMatrix.fromArray(Y.projectionMatrix), ye.viewport.set(Ce.x, Ce.y, Ce.width, Ce.height), Be === 0 && L.matrix.copy(ye.matrix), fe === !0 && L.cameras.push(ye); + let wt = w[pt]; + wt === void 0 && (wt = new xe, wt.layers.enable(pt), wt.viewport = new $t, w[pt] = wt), wt.matrix.fromArray(Et.transform.matrix), wt.matrix.decompose(wt.position, wt.quaternion, wt.scale), wt.projectionMatrix.fromArray(Et.projectionMatrix), wt.projectionMatrixInverse.copy(wt.projectionMatrix).invert(), wt.viewport.set(Tt.x, Tt.y, Tt.width, Tt.height), pt === 0 && (R.matrix.copy(wt.matrix), R.matrix.decompose(R.position, R.quaternion, R.scale)), ut === !0 && R.cameras.push(wt); } } - let he = i.inputSources; - for(let le = 0; le < p.length; le++){ - let fe = p[le], Be = he[le]; - fe.update(Be, W, o); + for(let lt = 0; lt < v.length; lt++){ + let ut = _[lt], pt = v[lt]; + ut !== null && pt !== void 0 && pt.update(ut, q, l || a); } - O && O(V, W), m = null; - } - let ce = new rh; - ce.setAnimationLoop(ne), this.setAnimationLoop = function(V) { - O = V; + Y && Y(N, q), q.detectedPlanes && n.dispatchEvent({ + type: "planesdetected", + data: q + }), m = null; + } + let tt = new vd; + tt.setAnimationLoop(j), this.setAnimationLoop = function(N) { + Y = N; }, this.dispose = function() {}; } }; -function Cx(s) { +function z0(s1, t) { function e(g, p) { - g.fogColor.value.copy(p.color), p.isFog ? (g.fogNear.value = p.near, g.fogFar.value = p.far) : p.isFogExp2 && (g.fogDensity.value = p.density); - } - function t(g, p, _, y, b) { - p.isMeshBasicMaterial ? n(g, p) : p.isMeshLambertMaterial ? (n(g, p), l(g, p)) : p.isMeshToonMaterial ? (n(g, p), h(g, p)) : p.isMeshPhongMaterial ? (n(g, p), c(g, p)) : p.isMeshStandardMaterial ? (n(g, p), p.isMeshPhysicalMaterial ? d(g, p, b) : u(g, p)) : p.isMeshMatcapMaterial ? (n(g, p), f(g, p)) : p.isMeshDepthMaterial ? (n(g, p), m(g, p)) : p.isMeshDistanceMaterial ? (n(g, p), x(g, p)) : p.isMeshNormalMaterial ? (n(g, p), v(g, p)) : p.isLineBasicMaterial ? (i(g, p), p.isLineDashedMaterial && r(g, p)) : p.isPointsMaterial ? o(g, p, _, y) : p.isSpriteMaterial ? a(g, p) : p.isShadowMaterial ? (g.color.value.copy(p.color), g.opacity.value = p.opacity) : p.isShaderMaterial && (p.uniformsNeedUpdate = !1); + g.matrixAutoUpdate === !0 && g.updateMatrix(), p.value.copy(g.matrix); } function n(g, p) { - g.opacity.value = p.opacity, p.color && g.diffuse.value.copy(p.color), p.emissive && g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity), p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.specularMap && (g.specularMap.value = p.specularMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let _ = s.get(p).envMap; - _ && (g.envMap.value = _, g.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, 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), p.aoMap && (g.aoMap.value = p.aoMap, g.aoMapIntensity.value = p.aoMapIntensity); - let y; - p.map ? y = p.map : p.specularMap ? y = p.specularMap : p.displacementMap ? y = p.displacementMap : p.normalMap ? y = p.normalMap : p.bumpMap ? y = p.bumpMap : p.roughnessMap ? y = p.roughnessMap : p.metalnessMap ? y = p.metalnessMap : p.alphaMap ? y = p.alphaMap : p.emissiveMap ? y = p.emissiveMap : p.clearcoatMap ? y = p.clearcoatMap : p.clearcoatNormalMap ? y = p.clearcoatNormalMap : p.clearcoatRoughnessMap ? y = p.clearcoatRoughnessMap : p.specularIntensityMap ? y = p.specularIntensityMap : p.specularColorMap ? y = p.specularColorMap : p.transmissionMap ? y = p.transmissionMap : p.thicknessMap ? y = p.thicknessMap : p.sheenColorMap ? y = p.sheenColorMap : p.sheenRoughnessMap && (y = p.sheenRoughnessMap), y !== void 0 && (y.isWebGLRenderTarget && (y = y.texture), y.matrixAutoUpdate === !0 && y.updateMatrix(), g.uvTransform.value.copy(y.matrix)); - let b; - p.aoMap ? b = p.aoMap : p.lightMap && (b = p.lightMap), b !== void 0 && (b.isWebGLRenderTarget && (b = b.texture), b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uv2Transform.value.copy(b.matrix)); + p.color.getRGB(g.fogColor.value, xd(s1)), p.isFog ? (g.fogNear.value = p.near, g.fogFar.value = p.far) : p.isFogExp2 && (g.fogDensity.value = p.density); } - function i(g, p) { - g.diffuse.value.copy(p.color), g.opacity.value = p.opacity; + function i(g, p, v, _, y) { + p.isMeshBasicMaterial || p.isMeshLambertMaterial ? r(g, p) : p.isMeshToonMaterial ? (r(g, p), u(g, p)) : p.isMeshPhongMaterial ? (r(g, p), h(g, p)) : p.isMeshStandardMaterial ? (r(g, p), d(g, p), p.isMeshPhysicalMaterial && f(g, p, y)) : p.isMeshMatcapMaterial ? (r(g, p), m(g, p)) : p.isMeshDepthMaterial ? r(g, p) : p.isMeshDistanceMaterial ? (r(g, p), x(g, p)) : p.isMeshNormalMaterial ? r(g, p) : p.isLineBasicMaterial ? (a(g, p), p.isLineDashedMaterial && o(g, p)) : p.isPointsMaterial ? c(g, p, v, _) : p.isSpriteMaterial ? l(g, p) : p.isShadowMaterial ? (g.color.value.copy(p.color), g.opacity.value = p.opacity) : p.isShaderMaterial && (p.uniformsNeedUpdate = !1); } function r(g, p) { - g.dashSize.value = p.dashSize, g.totalSize.value = p.dashSize + p.gapSize, g.scale.value = p.scale; - } - function o(g, p, _, y) { - g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.size.value = p.size * _, g.scale.value = y * .5, p.map && (g.map.value = p.map), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let b; - p.map ? b = p.map : p.alphaMap && (b = p.alphaMap), b !== void 0 && (b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uvTransform.value.copy(b.matrix)); + g.opacity.value = p.opacity, p.color && g.diffuse.value.copy(p.color), p.emissive && g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity), 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.bumpMap && (g.bumpMap.value = p.bumpMap, e(p.bumpMap, g.bumpMapTransform), g.bumpScale.value = p.bumpScale, p.side === De && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, e(p.normalMap, g.normalMapTransform), g.normalScale.value.copy(p.normalScale), p.side === De && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, e(p.displacementMap, g.displacementMapTransform), g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap, e(p.emissiveMap, g.emissiveMapTransform)), p.specularMap && (g.specularMap.value = p.specularMap, e(p.specularMap, g.specularMapTransform)), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); + let v = t.get(p).envMap; + if (v && (g.envMap.value = v, g.flipEnvMap.value = v.isCubeTexture && v.isRenderTargetTexture === !1 ? -1 : 1, g.reflectivity.value = p.reflectivity, g.ior.value = p.ior, g.refractionRatio.value = p.refractionRatio), p.lightMap) { + g.lightMap.value = p.lightMap; + let _ = s1._useLegacyLights === !0 ? Math.PI : 1; + 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 a(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), p.alphaMap && (g.alphaMap.value = p.alphaMap), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest); - let _; - p.map ? _ = p.map : p.alphaMap && (_ = p.alphaMap), _ !== void 0 && (_.matrixAutoUpdate === !0 && _.updateMatrix(), g.uvTransform.value.copy(_.matrix)); + g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, p.map && (g.map.value = p.map, e(p.map, g.mapTransform)); } - function l(g, p) { - p.emissiveMap && (g.emissiveMap.value = p.emissiveMap); + function o(g, p) { + g.dashSize.value = p.dashSize, g.totalSize.value = p.dashSize + p.gapSize, g.scale.value = p.scale; + } + function c(g, p, v, _) { + g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.size.value = p.size * v, g.scale.value = _ * .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.specular.value.copy(p.specular), g.shininess.value = Math.max(p.shininess, 1e-4), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + function l(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) { - p.gradientMap && (g.gradientMap.value = p.gradientMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + g.specular.value.copy(p.specular), g.shininess.value = Math.max(p.shininess, 1e-4); } function u(g, p) { - g.roughness.value = p.roughness, g.metalness.value = p.metalness, p.roughnessMap && (g.roughnessMap.value = p.roughnessMap), p.metalnessMap && (g.metalnessMap.value = p.metalnessMap), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), s.get(p).envMap && (g.envMapIntensity.value = p.envMapIntensity); + p.gradientMap && (g.gradientMap.value = p.gradientMap); } - function d(g, p, _) { - u(g, p), 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), p.sheenRoughnessMap && (g.sheenRoughnessMap.value = p.sheenRoughnessMap)), p.clearcoat > 0 && (g.clearcoat.value = p.clearcoat, g.clearcoatRoughness.value = p.clearcoatRoughness, p.clearcoatMap && (g.clearcoatMap.value = p.clearcoatMap), p.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = p.clearcoatRoughnessMap), p.clearcoatNormalMap && (g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale), g.clearcoatNormalMap.value = p.clearcoatNormalMap, p.side === it && g.clearcoatNormalScale.value.negate())), p.transmission > 0 && (g.transmission.value = p.transmission, g.transmissionSamplerMap.value = _.texture, g.transmissionSamplerSize.value.set(_.width, _.height), p.transmissionMap && (g.transmissionMap.value = p.transmissionMap), g.thickness.value = p.thickness, p.thicknessMap && (g.thicknessMap.value = p.thicknessMap), g.attenuationDistance.value = p.attenuationDistance, g.attenuationColor.value.copy(p.attenuationColor)), g.specularIntensity.value = p.specularIntensity, g.specularColor.value.copy(p.specularColor), p.specularIntensityMap && (g.specularIntensityMap.value = p.specularIntensityMap), p.specularColorMap && (g.specularColorMap.value = p.specularColorMap); + function d(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)), t.get(p).envMap && (g.envMapIntensity.value = p.envMapIntensity); } - function f(g, p) { - p.matcap && (g.matcap.value = p.matcap), p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + function f(g, p, v) { + 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 === De && g.clearcoatNormalScale.value.negate())), 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 = v.texture, g.transmissionSamplerSize.value.set(v.width, v.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.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + p.matcap && (g.matcap.value = p.matcap); } function x(g, p) { - p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), g.referencePosition.value.copy(p.referencePosition), g.nearDistance.value = p.nearDistance, g.farDistance.value = p.farDistance; - } - function v(g, p) { - p.bumpMap && (g.bumpMap.value = p.bumpMap, g.bumpScale.value = p.bumpScale, p.side === it && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, g.normalScale.value.copy(p.normalScale), p.side === it && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias); + let v = t.get(p).light; + g.referencePosition.value.setFromMatrixPosition(v.matrixWorld), g.nearDistance.value = v.shadow.camera.near, g.farDistance.value = v.shadow.camera.far; } return { - refreshFogUniforms: e, - refreshMaterialUniforms: t + refreshFogUniforms: n, + refreshMaterialUniforms: i }; } -function Lx() { - let s = qs("canvas"); - return s.style.display = "block", s; -} -function qe(s = {}) { - let e = s.canvas !== void 0 ? s.canvas : Lx(), t = s.context !== void 0 ? s.context : null, n = s.alpha !== void 0 ? s.alpha : !1, i = s.depth !== void 0 ? s.depth : !0, r = s.stencil !== void 0 ? s.stencil : !0, o = s.antialias !== void 0 ? s.antialias : !1, a = s.premultipliedAlpha !== void 0 ? s.premultipliedAlpha : !0, l = s.preserveDrawingBuffer !== void 0 ? s.preserveDrawingBuffer : !1, c = s.powerPreference !== void 0 ? s.powerPreference : "default", h = s.failIfMajorPerformanceCaveat !== void 0 ? s.failIfMajorPerformanceCaveat : !1, u = null, d = null, f = [], m = []; - this.domElement = e, this.debug = { - checkShaderErrors: !0 - }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.outputEncoding = Nt, this.physicallyCorrectLights = !1, this.toneMapping = _n, this.toneMappingExposure = 1; - let x = this, v = !1, g = 0, p = 0, _ = null, y = -1, b = null, A = new Ve, L = new Ve, I = null, k = e.width, B = e.height, P = 1, w = null, E = null, D = new Ve(0, 0, k, B), U = new Ve(0, 0, k, B), F = !1, O = [], ne = new Dr, ce = !1, V = !1, W = null, he = new pe, le = new M, fe = { - background: null, - fog: null, - environment: null, - overrideMaterial: null, - isScene: !0 - }; - function Be() { - return _ === null ? P : 1; +function k0(s1, t, e, n) { + let i = {}, r = {}, a = [], o = e.isWebGL2 ? s1.getParameter(s1.MAX_UNIFORM_BUFFER_BINDINGS) : 0; + function c(v, _) { + let y = _.program; + n.uniformBlockBinding(v, y); + } + function l(v, _) { + let y = i[v.id]; + y === void 0 && (m(v), y = h(v), i[v.id] = y, v.addEventListener("dispose", g)); + let b = _.program; + n.updateUBOMapping(v, b); + let w = t.render.frame; + r[v.id] !== w && (d(v), r[v.id] = w); + } + function h(v) { + let _ = u(); + v.__bindingPointIndex = _; + let y = s1.createBuffer(), b = v.__size, w = v.usage; + return s1.bindBuffer(s1.UNIFORM_BUFFER, y), s1.bufferData(s1.UNIFORM_BUFFER, b, w), s1.bindBuffer(s1.UNIFORM_BUFFER, null), s1.bindBufferBase(s1.UNIFORM_BUFFER, _, y), y; } - let Y = t; - function Ce(S, N) { - for(let H = 0; H < S.length; H++){ - let z = S[H], q = e.getContext(z, N); - if (q !== null) return q; + function u() { + for(let v = 0; v < o; v++)if (a.indexOf(v) === -1) return a.push(v), v; + return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0; + } + function d(v) { + let _ = i[v.id], y = v.uniforms, b = v.__cache; + s1.bindBuffer(s1.UNIFORM_BUFFER, _); + for(let w = 0, R = y.length; w < R; w++){ + let L = y[w]; + if (f(L, w, b) === !0) { + let M = L.__offset, E = Array.isArray(L.value) ? L.value : [ + L.value + ], V = 0; + for(let $ = 0; $ < E.length; $++){ + let F = E[$], O = x(F); + typeof F == "number" ? (L.__data[0] = F, s1.bufferSubData(s1.UNIFORM_BUFFER, M + V, L.__data)) : F.isMatrix3 ? (L.__data[0] = F.elements[0], L.__data[1] = F.elements[1], L.__data[2] = F.elements[2], L.__data[3] = F.elements[0], L.__data[4] = F.elements[3], L.__data[5] = F.elements[4], L.__data[6] = F.elements[5], L.__data[7] = F.elements[0], L.__data[8] = F.elements[6], L.__data[9] = F.elements[7], L.__data[10] = F.elements[8], L.__data[11] = F.elements[0]) : (F.toArray(L.__data, V), V += O.storage / Float32Array.BYTES_PER_ELEMENT); + } + s1.bufferSubData(s1.UNIFORM_BUFFER, M, L.__data); + } } - return null; + s1.bindBuffer(s1.UNIFORM_BUFFER, null); } - try { - let S = { - alpha: n, - depth: i, - stencil: r, - antialias: o, - premultipliedAlpha: a, - preserveDrawingBuffer: l, - powerPreference: c, - failIfMajorPerformanceCaveat: h - }; - if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${ca}`), e.addEventListener("webglcontextlost", Ee, !1), e.addEventListener("webglcontextrestored", me, !1), Y === null) { - let N = [ - "webgl2", - "webgl", - "experimental-webgl" + function f(v, _, y) { + let b = v.value; + if (y[_] === void 0) { + if (typeof b == "number") y[_] = b; + else { + let w = Array.isArray(b) ? b : [ + b + ], R = []; + for(let L = 0; L < w.length; L++)R.push(w[L].clone()); + y[_] = R; + } + return !0; + } else if (typeof b == "number") { + if (y[_] !== b) return y[_] = b, !0; + } else { + let w = Array.isArray(y[_]) ? y[_] : [ + y[_] + ], R = Array.isArray(b) ? b : [ + b ]; - if (x.isWebGL1Renderer === !0 && N.shift(), Y = Ce(N, S), Y === null) throw Ce(N) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); + for(let L = 0; L < w.length; L++){ + let M = w[L]; + if (M.equals(R[L]) === !1) return M.copy(R[L]), !0; + } } - Y.getShaderPrecisionFormat === void 0 && (Y.getShaderPrecisionFormat = function() { - return { - rangeMin: 1, - rangeMax: 1, - precision: 1 - }; - }); - } catch (S) { - throw console.error("THREE.WebGLRenderer: " + S.message), S; - } - let ye, ge, xe, Oe, G, j, K, ue, se, Se, Te, Pe, Ye, C, T, J, $, re, Z, Me, ve, te, R; - function ee() { - ye = new Qm(Y), ge = new Xm(Y, ye, s), ye.init(ge), te = new Ex(Y, ye, ge), xe = new Sx(Y, ye, ge), O[0] = 1029, Oe = new tg(Y), G = new fx, j = new Tx(Y, ye, xe, G, ge, te, Oe), K = new Ym(x), ue = new jm(x), se = new gf(Y, ge), R = new Wm(Y, ye, se, ge), Se = new Km(Y, se, Oe, R), Te = new sg(Y, Se, se, Oe), Z = new rg(Y, ge, j), J = new Jm(G), Pe = new dx(x, K, ue, ye, ge, R, J), Ye = new Cx(G), C = new mx, T = new Mx(ye, ge), re = new Vm(x, K, xe, Te, a), $ = new yh(x, Te, ge), Me = new qm(Y, ye, Oe, ge), ve = new eg(Y, ye, Oe, ge), Oe.programs = Pe.programs, x.capabilities = ge, x.extensions = ye, x.properties = G, x.renderLists = C, x.shadowMap = $, x.state = xe, x.info = Oe; - } - ee(); - let Q = new vh(x, Y); - this.xr = Q, this.getContext = function() { - return Y; - }, this.getContextAttributes = function() { - return Y.getContextAttributes(); - }, this.forceContextLoss = function() { - let S = ye.get("WEBGL_lose_context"); - S && S.loseContext(); - }, this.forceContextRestore = function() { - let S = ye.get("WEBGL_lose_context"); - S && S.restoreContext(); - }, this.getPixelRatio = function() { - return P; - }, this.setPixelRatio = function(S) { - S !== void 0 && (P = S, this.setSize(k, B, !1)); - }, this.getSize = function(S) { - return S.set(k, B); - }, this.setSize = function(S, N, H) { - if (Q.isPresenting) { - console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); - return; + return !1; + } + function m(v) { + let _ = v.uniforms, y = 0, b = 16, w = 0; + for(let R = 0, L = _.length; R < L; R++){ + let M = _[R], E = { + boundary: 0, + storage: 0 + }, V = Array.isArray(M.value) ? M.value : [ + M.value + ]; + for(let $ = 0, F = V.length; $ < F; $++){ + let O = V[$], z = x(O); + E.boundary += z.boundary, E.storage += z.storage; + } + if (M.__data = new Float32Array(E.storage / Float32Array.BYTES_PER_ELEMENT), M.__offset = y, R > 0) { + w = y % b; + let $ = b - w; + w !== 0 && $ - E.boundary < 0 && (y += b - w, M.__offset = y); + } + y += E.storage; } - k = S, B = N, e.width = Math.floor(S * P), e.height = Math.floor(N * P), H !== !1 && (e.style.width = S + "px", e.style.height = N + "px"), this.setViewport(0, 0, S, N); - }, this.getDrawingBufferSize = function(S) { - return S.set(k * P, B * P).floor(); - }, this.setDrawingBufferSize = function(S, N, H) { - k = S, B = N, P = H, e.width = Math.floor(S * H), e.height = Math.floor(N * H), this.setViewport(0, 0, S, N); - }, this.getCurrentViewport = function(S) { - return S.copy(A); - }, this.getViewport = function(S) { - return S.copy(D); - }, this.setViewport = function(S, N, H, z) { - S.isVector4 ? D.set(S.x, S.y, S.z, S.w) : D.set(S, N, H, z), xe.viewport(A.copy(D).multiplyScalar(P).floor()); - }, this.getScissor = function(S) { - return S.copy(U); - }, this.setScissor = function(S, N, H, z) { - S.isVector4 ? U.set(S.x, S.y, S.z, S.w) : U.set(S, N, H, z), xe.scissor(L.copy(U).multiplyScalar(P).floor()); - }, this.getScissorTest = function() { - return F; - }, this.setScissorTest = function(S) { - xe.setScissorTest(F = S); - }, this.setOpaqueSort = function(S) { - w = S; - }, this.setTransparentSort = function(S) { - E = S; - }, this.getClearColor = function(S) { - return S.copy(re.getClearColor()); - }, this.setClearColor = function() { - re.setClearColor.apply(re, arguments); - }, this.getClearAlpha = function() { - return re.getClearAlpha(); - }, this.setClearAlpha = function() { - re.setClearAlpha.apply(re, arguments); - }, this.clear = function(S, N, H) { - let z = 0; - (S === void 0 || S) && (z |= 16384), (N === void 0 || N) && (z |= 256), (H === void 0 || H) && (z |= 1024), Y.clear(z); - }, this.clearColor = function() { - this.clear(!0, !1, !1); - }, this.clearDepth = function() { - this.clear(!1, !0, !1); - }, this.clearStencil = function() { - this.clear(!1, !1, !0); - }, this.dispose = function() { - e.removeEventListener("webglcontextlost", Ee, !1), e.removeEventListener("webglcontextrestored", me, !1), C.dispose(), T.dispose(), G.dispose(), K.dispose(), ue.dispose(), Te.dispose(), R.dispose(), Pe.dispose(), Q.dispose(), Q.removeEventListener("sessionstart", Ut), Q.removeEventListener("sessionend", Ot), W && (W.dispose(), W = null), Ln.stop(); + return w = y % b, w > 0 && (y += b - w), v.__size = y, v.__cache = {}, this; + } + function x(v) { + let _ = { + boundary: 0, + storage: 0 + }; + return typeof v == "number" ? (_.boundary = 4, _.storage = 4) : v.isVector2 ? (_.boundary = 8, _.storage = 8) : v.isVector3 || v.isColor ? (_.boundary = 16, _.storage = 12) : v.isVector4 ? (_.boundary = 16, _.storage = 16) : v.isMatrix3 ? (_.boundary = 48, _.storage = 48) : v.isMatrix4 ? (_.boundary = 64, _.storage = 64) : v.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", v), _; + } + function g(v) { + let _ = v.target; + _.removeEventListener("dispose", g); + let y = a.indexOf(_.__bindingPointIndex); + a.splice(y, 1), s1.deleteBuffer(i[_.id]), delete i[_.id], delete r[_.id]; + } + function p() { + for(let v in i)s1.deleteBuffer(i[v]); + a = [], i = {}, r = {}; + } + return { + bind: c, + update: l, + dispose: p }; - function Ee(S) { - S.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), v = !0; - } - function me() { - console.log("THREE.WebGLRenderer: Context Restored."), v = !1; - let S = Oe.autoReset, N = $.enabled, H = $.autoUpdate, z = $.needsUpdate, q = $.type; - ee(), Oe.autoReset = S, $.enabled = N, $.autoUpdate = H, $.needsUpdate = z, $.type = q; - } - function Re(S) { - let N = S.target; - N.removeEventListener("dispose", Re), oe(N); - } - function oe(S) { - Le(S), G.remove(S); - } - function Le(S) { - let N = G.get(S).programs; - N !== void 0 && (N.forEach(function(H) { - Pe.releaseProgram(H); - }), S.isShaderMaterial && Pe.releaseShaderCache(S)); - } - this.renderBufferDirect = function(S, N, H, z, q, be) { - N === null && (N = fe); - let Ae = q.isMesh && q.matrixWorld.determinant() < 0, Ie = lu(S, N, H, z, q); - xe.setMaterial(z, Ae); - let we = H.index, He = H.attributes.position; - if (we === null) { - if (He === void 0 || He.count === 0) return; - } else if (we.count === 0) return; - let De = 1; - z.wireframe === !0 && (we = Se.getWireframeAttribute(H), De = 2), R.setup(q, z, Ie, H, we); - let ze, je = Me; - we !== null && (ze = se.get(we), je = ve, je.setIndex(ze)); - let Rn = we !== null ? we.count : He.count, ei = H.drawRange.start * De, Ge = H.drawRange.count * De, Ht = be !== null ? be.start * De : 0, at = be !== null ? be.count * De : 1 / 0, kt = Math.max(ei, Ht), Gr = Math.min(Rn, ei + Ge, Ht + at) - 1, Gt = Math.max(0, Gr - kt + 1); - if (Gt !== 0) { - if (q.isMesh) z.wireframe === !0 ? (xe.setLineWidth(z.wireframeLinewidth * Be()), je.setMode(1)) : je.setMode(4); - else if (q.isLine) { - let Zt = z.linewidth; - Zt === void 0 && (Zt = 1), xe.setLineWidth(Zt * Be()), q.isLineSegments ? je.setMode(1) : q.isLineLoop ? je.setMode(2) : je.setMode(3); - } else q.isPoints ? je.setMode(0) : q.isSprite && je.setMode(4); - if (q.isInstancedMesh) je.renderInstances(kt, Gt, q.count); - else if (H.isInstancedBufferGeometry) { - let Zt = Math.min(H.instanceCount, H._maxInstanceCount); - je.renderInstances(kt, Gt, Zt); - } else je.render(kt, Gt); - } - }, this.compile = function(S, N) { - d = T.get(S), d.init(), m.push(d), S.traverseVisible(function(H) { - H.isLight && H.layers.test(N.layers) && (d.pushLight(H), H.castShadow && d.pushShadow(H)); - }), d.setupLights(x.physicallyCorrectLights), S.traverse(function(H) { - let z = H.material; - if (z) if (Array.isArray(z)) for(let q = 0; q < z.length; q++){ - let be = z[q]; - xo(be, S, H); +} +function V0() { + let s1 = ws("canvas"); + return s1.style.display = "block", s1; +} +var bo = class { + constructor(t = {}){ + let { canvas: e = V0() , context: n = null , depth: i = !0 , stencil: r = !0 , alpha: a = !1 , antialias: o = !1 , premultipliedAlpha: c = !0 , preserveDrawingBuffer: l = !1 , powerPreference: h = "default" , failIfMajorPerformanceCaveat: u = !1 } = t; + this.isWebGLRenderer = !0; + let d; + n !== null ? d = n.getContextAttributes().alpha : d = a; + let f = new Uint32Array(4), m = new Int32Array(4), x = null, g = null, p = [], v = []; + this.domElement = e, this.debug = { + checkShaderErrors: !0, + onShaderError: null + }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.outputColorSpace = Nt, this._useLegacyLights = !1, this.toneMapping = Dn, this.toneMappingExposure = 1; + let _ = this, y = !1, b = 0, w = 0, R = null, L = -1, M = null, E = new $t, V = new $t, $ = null, F = new ft(0), O = 0, z = e.width, K = e.height, X = 1, Y = null, j = null, tt = new $t(0, 0, z, K), N = new $t(0, 0, z, K), q = !1, lt = new Ps, ut = !1, pt = !1, Et = null, Tt = new Ot, wt = new J, Yt = new A, te = { + background: null, + fog: null, + environment: null, + overrideMaterial: null, + isScene: !0 + }; + function Pt() { + return R === null ? X : 1; + } + let P = n; + function at(T, D) { + for(let W = 0; W < T.length; W++){ + let U = T[W], G = e.getContext(U, D); + if (G !== null) return G; } - else xo(z, S, H); - }), m.pop(), d = null; - }; - let Xe = null; - function We(S) { - Xe && Xe(S); - } - function Ut() { - Ln.stop(); - } - function Ot() { - Ln.start(); - } - let Ln = new rh; - Ln.setAnimationLoop(We), typeof window < "u" && Ln.setContext(window), this.setAnimationLoop = function(S) { - Xe = S, Q.setAnimationLoop(S), S === null ? Ln.stop() : Ln.start(); - }, Q.addEventListener("sessionstart", Ut), Q.addEventListener("sessionend", Ot), this.render = function(S, N) { - if (N !== void 0 && N.isCamera !== !0) { - console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); - return; + return null; } - if (v === !0) return; - S.autoUpdate === !0 && S.updateMatrixWorld(), N.parent === null && N.updateMatrixWorld(), Q.enabled === !0 && Q.isPresenting === !0 && (Q.cameraAutoUpdate === !0 && Q.updateCamera(N), N = Q.getCamera()), S.isScene === !0 && S.onBeforeRender(x, S, N, _), d = T.get(S, m.length), d.init(), m.push(d), he.multiplyMatrices(N.projectionMatrix, N.matrixWorldInverse), ne.setFromProjectionMatrix(he), V = this.localClippingEnabled, ce = J.init(this.clippingPlanes, V, N), u = C.get(S, f.length), u.init(), f.push(u), Qa(S, N, 0, x.sortObjects), u.finish(), x.sortObjects === !0 && u.sort(w, E), ce === !0 && J.beginShadows(); - let H = d.state.shadowsArray; - if ($.render(H, S, N), ce === !0 && J.endShadows(), this.info.autoReset === !0 && this.info.reset(), re.render(u, S), d.setupLights(x.physicallyCorrectLights), N.isArrayCamera) { - let z = N.cameras; - for(let q = 0, be = z.length; q < be; q++){ - let Ae = z[q]; - Ka(u, S, Ae, Ae.viewport); + try { + let T = { + alpha: !0, + depth: i, + stencil: r, + antialias: o, + premultipliedAlpha: c, + preserveDrawingBuffer: l, + powerPreference: h, + failIfMajorPerformanceCaveat: u + }; + if ("setAttribute" in e && e.setAttribute("data-engine", `three.js r${Fc}`), e.addEventListener("webglcontextlost", ht, !1), e.addEventListener("webglcontextrestored", H, !1), e.addEventListener("webglcontextcreationerror", ot, !1), P === null) { + let D = [ + "webgl2", + "webgl", + "experimental-webgl" + ]; + if (_.isWebGL1Renderer === !0 && D.shift(), P = at(D, T), P === null) throw at(D) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context."); } - } else Ka(u, S, N); - _ !== null && (j.updateMultisampleRenderTarget(_), j.updateRenderTargetMipmap(_)), S.isScene === !0 && S.onAfterRender(x, S, N), xe.buffers.depth.setTest(!0), xe.buffers.depth.setMask(!0), xe.buffers.color.setMask(!0), xe.setPolygonOffset(!1), R.resetDefaultState(), y = -1, b = null, m.pop(), m.length > 0 ? d = m[m.length - 1] : d = null, f.pop(), f.length > 0 ? u = f[f.length - 1] : u = null; - }; - function Qa(S, N, H, z) { - if (S.visible === !1) return; - if (S.layers.test(N.layers)) { - if (S.isGroup) H = S.renderOrder; - else if (S.isLOD) S.autoUpdate === !0 && S.update(N); - else if (S.isLight) d.pushLight(S), S.castShadow && d.pushShadow(S); - else if (S.isSprite) { - if (!S.frustumCulled || ne.intersectsSprite(S)) { - z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); - let Ae = Te.update(S), Ie = S.material; - Ie.visible && u.push(S, Ae, Ie, H, le.z, null); + typeof WebGLRenderingContext < "u" && P instanceof WebGLRenderingContext && console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."), P.getShaderPrecisionFormat === void 0 && (P.getShaderPrecisionFormat = function() { + return { + rangeMin: 1, + rangeMax: 1, + precision: 1 + }; + }); + } catch (T) { + throw console.error("THREE.WebGLRenderer: " + T.message), T; + } + let Z, st, Q, St, mt, xt, Dt, Xt, ie, C, S, B, nt, et, it, Mt, rt, k, Rt, bt, At, vt, yt, Ht; + function Qt() { + Z = new o_(P), st = new e_(P, Z, t), Z.init(st), vt = new O0(P, Z, st), Q = new N0(P, Z, st), St = new h_(P), mt = new b0, xt = new F0(P, Z, Q, mt, st, vt, St), Dt = new i_(_), Xt = new a_(_), ie = new yp(P, st), yt = new jg(P, Z, ie, st), C = new c_(P, ie, St, yt), S = new p_(P, C, ie, St), Rt = new f_(P, st, xt), Mt = new n_(mt), B = new S0(_, Dt, Xt, Z, st, yt, Mt), nt = new z0(_, mt), et = new T0, it = new L0(Z, st), k = new Qg(_, Dt, Xt, Q, S, d, c), rt = new D0(_, S, st), Ht = new k0(P, St, st, Q), bt = new t_(P, Z, St, st), At = new l_(P, Z, St, st), St.programs = B.programs, _.capabilities = st, _.extensions = Z, _.properties = mt, _.renderLists = et, _.shadowMap = rt, _.state = Q, _.info = St; + } + Qt(); + let I = new So(_, P); + this.xr = I, this.getContext = function() { + return P; + }, this.getContextAttributes = function() { + return P.getContextAttributes(); + }, this.forceContextLoss = function() { + let T = Z.get("WEBGL_lose_context"); + T && T.loseContext(); + }, this.forceContextRestore = function() { + let T = Z.get("WEBGL_lose_context"); + T && T.restoreContext(); + }, this.getPixelRatio = function() { + return X; + }, this.setPixelRatio = function(T) { + T !== void 0 && (X = T, this.setSize(z, K, !1)); + }, this.getSize = function(T) { + return T.set(z, K); + }, this.setSize = function(T, D, W = !0) { + if (I.isPresenting) { + console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); + return; + } + z = T, K = D, e.width = Math.floor(T * X), e.height = Math.floor(D * X), W === !0 && (e.style.width = T + "px", e.style.height = D + "px"), this.setViewport(0, 0, T, D); + }, this.getDrawingBufferSize = function(T) { + return T.set(z * X, K * X).floor(); + }, this.setDrawingBufferSize = function(T, D, W) { + z = T, K = D, X = W, e.width = Math.floor(T * W), e.height = Math.floor(D * W), this.setViewport(0, 0, T, D); + }, this.getCurrentViewport = function(T) { + return T.copy(E); + }, this.getViewport = function(T) { + return T.copy(tt); + }, this.setViewport = function(T, D, W, U) { + T.isVector4 ? tt.set(T.x, T.y, T.z, T.w) : tt.set(T, D, W, U), Q.viewport(E.copy(tt).multiplyScalar(X).floor()); + }, this.getScissor = function(T) { + return T.copy(N); + }, this.setScissor = function(T, D, W, U) { + T.isVector4 ? N.set(T.x, T.y, T.z, T.w) : N.set(T, D, W, U), Q.scissor(V.copy(N).multiplyScalar(X).floor()); + }, this.getScissorTest = function() { + return q; + }, this.setScissorTest = function(T) { + Q.setScissorTest(q = T); + }, this.setOpaqueSort = function(T) { + Y = T; + }, this.setTransparentSort = function(T) { + j = T; + }, this.getClearColor = function(T) { + return T.copy(k.getClearColor()); + }, this.setClearColor = function() { + k.setClearColor.apply(k, arguments); + }, this.getClearAlpha = function() { + return k.getClearAlpha(); + }, this.setClearAlpha = function() { + k.setClearAlpha.apply(k, arguments); + }, this.clear = function(T = !0, D = !0, W = !0) { + let U = 0; + if (T) { + let G = !1; + if (R !== null) { + let gt = R.texture.format; + G = gt === ud || gt === hd || gt === ld; + } + if (G) { + let gt = R.texture.type, Ct = gt === Nn || gt === Pn || gt === Bc || gt === ni || gt === od || gt === cd, It = k.getClearColor(), Ut = k.getClearAlpha(), Gt = It.r, Lt = It.g, Bt = It.b; + Ct ? (f[0] = Gt, f[1] = Lt, f[2] = Bt, f[3] = Ut, P.clearBufferuiv(P.COLOR, 0, f)) : (m[0] = Gt, m[1] = Lt, m[2] = Bt, m[3] = Ut, P.clearBufferiv(P.COLOR, 0, m)); + } else U |= P.COLOR_BUFFER_BIT; + } + D && (U |= P.DEPTH_BUFFER_BIT), W && (U |= P.STENCIL_BUFFER_BIT), P.clear(U); + }, this.clearColor = function() { + this.clear(!0, !1, !1); + }, this.clearDepth = function() { + this.clear(!1, !0, !1); + }, this.clearStencil = function() { + this.clear(!1, !1, !0); + }, this.dispose = function() { + e.removeEventListener("webglcontextlost", ht, !1), e.removeEventListener("webglcontextrestored", H, !1), e.removeEventListener("webglcontextcreationerror", ot, !1), et.dispose(), it.dispose(), mt.dispose(), Dt.dispose(), Xt.dispose(), S.dispose(), yt.dispose(), Ht.dispose(), B.dispose(), I.dispose(), I.removeEventListener("sessionstart", jt), I.removeEventListener("sessionend", tn), Et && (Et.dispose(), Et = null), Te.stop(); + }; + function ht(T) { + T.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), y = !0; + } + function H() { + console.log("THREE.WebGLRenderer: Context Restored."), y = !1; + let T = St.autoReset, D = rt.enabled, W = rt.autoUpdate, U = rt.needsUpdate, G = rt.type; + Qt(), St.autoReset = T, rt.enabled = D, rt.autoUpdate = W, rt.needsUpdate = U, rt.type = G; + } + function ot(T) { + console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", T.statusMessage); + } + function dt(T) { + let D = T.target; + D.removeEventListener("dispose", dt), qt(D); + } + function qt(T) { + ee(T), mt.remove(T); + } + function ee(T) { + let D = mt.get(T).programs; + D !== void 0 && (D.forEach(function(W) { + B.releaseProgram(W); + }), T.isShaderMaterial && B.releaseShaderCache(T)); + } + this.renderBufferDirect = function(T, D, W, U, G, gt) { + D === null && (D = te); + let Ct = G.isMesh && G.matrixWorld.determinant() < 0, It = Ld(T, D, W, U, G); + Q.setMaterial(U, Ct); + let Ut = W.index, Gt = 1; + if (U.wireframe === !0) { + if (Ut = C.getWireframeAttribute(W), Ut === void 0) return; + Gt = 2; + } + let Lt = W.drawRange, Bt = W.attributes.position, se = Lt.start * Gt, oe = (Lt.start + Lt.count) * Gt; + gt !== null && (se = Math.max(se, gt.start * Gt), oe = Math.min(oe, (gt.start + gt.count) * Gt)), Ut !== null ? (se = Math.max(se, 0), oe = Math.min(oe, Ut.count)) : Bt != null && (se = Math.max(se, 0), oe = Math.min(oe, Bt.count)); + let ze = oe - se; + if (ze < 0 || ze === 1 / 0) return; + yt.setup(G, U, It, W, Ut); + let an, he = bt; + if (Ut !== null && (an = ie.get(Ut), he = At, he.setIndex(an)), G.isMesh) U.wireframe === !0 ? (Q.setLineWidth(U.wireframeLinewidth * Pt()), he.setMode(P.LINES)) : he.setMode(P.TRIANGLES); + else if (G.isLine) { + let Wt = U.linewidth; + Wt === void 0 && (Wt = 1), Q.setLineWidth(Wt * Pt()), G.isLineSegments ? he.setMode(P.LINES) : G.isLineLoop ? he.setMode(P.LINE_LOOP) : he.setMode(P.LINE_STRIP); + } else G.isPoints ? he.setMode(P.POINTS) : G.isSprite && he.setMode(P.TRIANGLES); + if (G.isInstancedMesh) he.renderInstances(se, ze, G.count); + else if (W.isInstancedBufferGeometry) { + let Wt = W._maxInstanceCount !== void 0 ? W._maxInstanceCount : 1 / 0, _a = Math.min(W.instanceCount, Wt); + he.renderInstances(se, ze, _a); + } else he.render(se, ze); + }, this.compile = function(T, D) { + function W(U, G, gt) { + U.transparent === !0 && U.side === gn && U.forceSinglePass === !1 ? (U.side = De, U.needsUpdate = !0, Ws(U, G, gt), U.side = On, U.needsUpdate = !0, Ws(U, G, gt), U.side = gn) : Ws(U, G, gt); + } + g = it.get(T), g.init(), v.push(g), T.traverseVisible(function(U) { + U.isLight && U.layers.test(D.layers) && (g.pushLight(U), U.castShadow && g.pushShadow(U)); + }), g.setupLights(_._useLegacyLights), T.traverse(function(U) { + let G = U.material; + if (G) if (Array.isArray(G)) for(let gt = 0; gt < G.length; gt++){ + let Ct = G[gt]; + W(Ct, T, U); + } + else W(G, T, U); + }), v.pop(), g = null; + }; + let le = null; + function En(T) { + le && le(T); + } + function jt() { + Te.stop(); + } + function tn() { + Te.start(); + } + let Te = new vd; + Te.setAnimationLoop(En), typeof self < "u" && Te.setContext(self), this.setAnimationLoop = function(T) { + le = T, I.setAnimationLoop(T), T === null ? Te.stop() : Te.start(); + }, I.addEventListener("sessionstart", jt), I.addEventListener("sessionend", tn), this.render = function(T, D) { + if (D !== void 0 && D.isCamera !== !0) { + console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera."); + return; + } + if (y === !0) return; + T.matrixWorldAutoUpdate === !0 && T.updateMatrixWorld(), D.parent === null && D.matrixWorldAutoUpdate === !0 && D.updateMatrixWorld(), I.enabled === !0 && I.isPresenting === !0 && (I.cameraAutoUpdate === !0 && I.updateCamera(D), D = I.getCamera()), T.isScene === !0 && T.onBeforeRender(_, T, D, R), g = it.get(T, v.length), g.init(), v.push(g), Tt.multiplyMatrices(D.projectionMatrix, D.matrixWorldInverse), lt.setFromProjectionMatrix(Tt), pt = this.localClippingEnabled, ut = Mt.init(this.clippingPlanes, pt), x = et.get(T, p.length), x.init(), p.push(x), Zc(T, D, 0, _.sortObjects), x.finish(), _.sortObjects === !0 && x.sort(Y, j), this.info.render.frame++, ut === !0 && Mt.beginShadows(); + let W = g.state.shadowsArray; + if (rt.render(W, T, D), ut === !0 && Mt.endShadows(), this.info.autoReset === !0 && this.info.reset(), k.render(x, T), g.setupLights(_._useLegacyLights), D.isArrayCamera) { + let U = D.cameras; + for(let G = 0, gt = U.length; G < gt; G++){ + let Ct = U[G]; + Jc(x, T, Ct, Ct.viewport); } - } else if ((S.isMesh || S.isLine || S.isPoints) && (S.isSkinnedMesh && S.skeleton.frame !== Oe.render.frame && (S.skeleton.update(), S.skeleton.frame = Oe.render.frame), !S.frustumCulled || ne.intersectsObject(S))) { - z && le.setFromMatrixPosition(S.matrixWorld).applyMatrix4(he); - let Ae = Te.update(S), Ie = S.material; - if (Array.isArray(Ie)) { - let we = Ae.groups; - for(let He = 0, De = we.length; He < De; He++){ - let ze = we[He], je = Ie[ze.materialIndex]; - je && je.visible && u.push(S, Ae, je, H, le.z, ze); + } else Jc(x, T, D); + R !== null && (xt.updateMultisampleRenderTarget(R), xt.updateRenderTargetMipmap(R)), T.isScene === !0 && T.onAfterRender(_, T, D), yt.resetDefaultState(), L = -1, M = null, v.pop(), v.length > 0 ? g = v[v.length - 1] : g = null, p.pop(), p.length > 0 ? x = p[p.length - 1] : x = null; + }; + function Zc(T, D, W, U) { + if (T.visible === !1) return; + if (T.layers.test(D.layers)) { + if (T.isGroup) W = T.renderOrder; + else if (T.isLOD) T.autoUpdate === !0 && T.update(D); + else if (T.isLight) g.pushLight(T), T.castShadow && g.pushShadow(T); + else if (T.isSprite) { + if (!T.frustumCulled || lt.intersectsSprite(T)) { + U && Yt.setFromMatrixPosition(T.matrixWorld).applyMatrix4(Tt); + let Ct = S.update(T), It = T.material; + It.visible && x.push(T, Ct, It, W, Yt.z, null); } - } else Ie.visible && u.push(S, Ae, Ie, H, le.z, null); + } else if ((T.isMesh || T.isLine || T.isPoints) && (!T.frustumCulled || lt.intersectsObject(T))) { + let Ct = S.update(T), It = T.material; + if (U && (T.boundingSphere !== void 0 ? (T.boundingSphere === null && T.computeBoundingSphere(), Yt.copy(T.boundingSphere.center)) : (Ct.boundingSphere === null && Ct.computeBoundingSphere(), Yt.copy(Ct.boundingSphere.center)), Yt.applyMatrix4(T.matrixWorld).applyMatrix4(Tt)), Array.isArray(It)) { + let Ut = Ct.groups; + for(let Gt = 0, Lt = Ut.length; Gt < Lt; Gt++){ + let Bt = Ut[Gt], se = It[Bt.materialIndex]; + se && se.visible && x.push(T, Ct, se, W, Yt.z, Bt); + } + } else It.visible && x.push(T, Ct, It, W, Yt.z, null); + } } + let gt = T.children; + for(let Ct = 0, It = gt.length; Ct < It; Ct++)Zc(gt[Ct], D, W, U); } - let be = S.children; - for(let Ae = 0, Ie = be.length; Ae < Ie; Ae++)Qa(be[Ae], N, H, z); - } - function Ka(S, N, H, z) { - let q = S.opaque, be = S.transmissive, Ae = S.transparent; - d.setupLightsView(H), be.length > 0 && ou(q, N, H), z && xe.viewport(A.copy(z)), q.length > 0 && kr(q, N, H), be.length > 0 && kr(be, N, H), Ae.length > 0 && kr(Ae, N, H); - } - function ou(S, N, H) { - if (W === null) { - let Ae = o === !0 && ge.isWebGL2 === !0 ? Xs : At; - W = new Ae(1024, 1024, { + function Jc(T, D, W, U) { + let G = T.opaque, gt = T.transmissive, Ct = T.transparent; + g.setupLightsView(W), ut === !0 && Mt.setGlobalState(_.clippingPlanes, W), gt.length > 0 && Pd(G, gt, D, W), U && Q.viewport(E.copy(U)), G.length > 0 && Gs(G, D, W), gt.length > 0 && Gs(gt, D, W), Ct.length > 0 && Gs(Ct, D, W), Q.buffers.depth.setTest(!0), Q.buffers.depth.setMask(!0), Q.buffers.color.setMask(!0), Q.setPolygonOffset(!1); + } + function Pd(T, D, W, U) { + let G = st.isWebGL2; + Et === null && (Et = new Ge(1, 1, { generateMipmaps: !0, - type: te.convert(kn) !== null ? kn : rn, - minFilter: Ui, - magFilter: rt, - wrapS: vt, - wrapT: vt, - useRenderToTexture: ye.has("WEBGL_multisampled_render_to_texture") - }); + type: Z.has("EXT_color_buffer_half_float") ? Ts : Nn, + minFilter: li, + samples: G ? 4 : 0 + })), _.getDrawingBufferSize(wt), G ? Et.setSize(wt.x, wt.y) : Et.setSize(Hr(wt.x), Hr(wt.y)); + let gt = _.getRenderTarget(); + _.setRenderTarget(Et), _.getClearColor(F), O = _.getClearAlpha(), O < 1 && _.setClearColor(16777215, .5), _.clear(); + let Ct = _.toneMapping; + _.toneMapping = Dn, Gs(T, W, U), xt.updateMultisampleRenderTarget(Et), xt.updateRenderTargetMipmap(Et); + let It = !1; + for(let Ut = 0, Gt = D.length; Ut < Gt; Ut++){ + let Lt = D[Ut], Bt = Lt.object, se = Lt.geometry, oe = Lt.material, ze = Lt.group; + if (oe.side === gn && Bt.layers.test(U.layers)) { + let an = oe.side; + oe.side = De, oe.needsUpdate = !0, $c(Bt, W, U, se, oe, ze), oe.side = an, oe.needsUpdate = !0, It = !0; + } + } + It === !0 && (xt.updateMultisampleRenderTarget(Et), xt.updateRenderTargetMipmap(Et)), _.setRenderTarget(gt), _.setClearColor(F, O), _.toneMapping = Ct; } - let z = x.getRenderTarget(); - x.setRenderTarget(W), x.clear(); - let q = x.toneMapping; - x.toneMapping = _n, kr(S, N, H), x.toneMapping = q, j.updateMultisampleRenderTarget(W), j.updateRenderTargetMipmap(W), x.setRenderTarget(z); - } - function kr(S, N, H) { - let z = N.isScene === !0 ? N.overrideMaterial : null; - for(let q = 0, be = S.length; q < be; q++){ - let Ae = S[q], Ie = Ae.object, we = Ae.geometry, He = z === null ? Ae.material : z, De = Ae.group; - Ie.layers.test(H.layers) && au(Ie, N, H, we, He, De); - } - } - function au(S, N, H, z, q, be) { - S.onBeforeRender(x, N, H, z, q, be), S.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse, S.matrixWorld), S.normalMatrix.getNormalMatrix(S.modelViewMatrix), q.onBeforeRender(x, N, H, z, S, be), q.transparent === !0 && q.side === Ci ? (q.side = it, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ai, q.needsUpdate = !0, x.renderBufferDirect(H, N, z, q, S, be), q.side = Ci) : x.renderBufferDirect(H, N, z, q, S, be), S.onAfterRender(x, N, H, z, q, be); - } - function xo(S, N, H) { - N.isScene !== !0 && (N = fe); - let z = G.get(S), q = d.state.lights, be = d.state.shadowsArray, Ae = q.state.version, Ie = Pe.getParameters(S, q.state, be, N, H), we = Pe.getProgramCacheKey(Ie), He = z.programs; - z.environment = S.isMeshStandardMaterial ? N.environment : null, z.fog = N.fog, z.envMap = (S.isMeshStandardMaterial ? ue : K).get(S.envMap || z.environment), He === void 0 && (S.addEventListener("dispose", Re), He = new Map, z.programs = He); - let De = He.get(we); - if (De !== void 0) { - if (z.currentProgram === De && z.lightsStateVersion === Ae) return el(S, Ie), De; - } else Ie.uniforms = Pe.getUniforms(S), S.onBuild(H, Ie, x), S.onBeforeCompile(Ie, x), De = Pe.acquireProgram(Ie, we), He.set(we, De), z.uniforms = Ie.uniforms; - let ze = z.uniforms; - (!S.isShaderMaterial && !S.isRawShaderMaterial || S.clipping === !0) && (ze.clippingPlanes = J.uniform), el(S, Ie), z.needsLights = hu(S), z.lightsStateVersion = Ae, z.needsLights && (ze.ambientLightColor.value = q.state.ambient, ze.lightProbe.value = q.state.probe, ze.directionalLights.value = q.state.directional, ze.directionalLightShadows.value = q.state.directionalShadow, ze.spotLights.value = q.state.spot, ze.spotLightShadows.value = q.state.spotShadow, ze.rectAreaLights.value = q.state.rectArea, ze.ltc_1.value = q.state.rectAreaLTC1, ze.ltc_2.value = q.state.rectAreaLTC2, ze.pointLights.value = q.state.point, ze.pointLightShadows.value = q.state.pointShadow, ze.hemisphereLights.value = q.state.hemi, ze.directionalShadowMap.value = q.state.directionalShadowMap, ze.directionalShadowMatrix.value = q.state.directionalShadowMatrix, ze.spotShadowMap.value = q.state.spotShadowMap, ze.spotShadowMatrix.value = q.state.spotShadowMatrix, ze.pointShadowMap.value = q.state.pointShadowMap, ze.pointShadowMatrix.value = q.state.pointShadowMatrix); - let je = De.getUniforms(), Rn = bn.seqWithValue(je.seq, ze); - return z.currentProgram = De, z.uniformsList = Rn, De; - } - function el(S, N) { - let H = G.get(S); - H.outputEncoding = N.outputEncoding, H.instancing = N.instancing, H.skinning = N.skinning, H.morphTargets = N.morphTargets, H.morphNormals = N.morphNormals, H.morphTargetsCount = N.morphTargetsCount, H.numClippingPlanes = N.numClippingPlanes, H.numIntersection = N.numClipIntersection, H.vertexAlphas = N.vertexAlphas, H.vertexTangents = N.vertexTangents, H.toneMapping = N.toneMapping; - } - function lu(S, N, H, z, q) { - N.isScene !== !0 && (N = fe), j.resetTextureUnits(); - let be = N.fog, Ae = z.isMeshStandardMaterial ? N.environment : null, Ie = _ === null ? x.outputEncoding : _.texture.encoding, we = (z.isMeshStandardMaterial ? ue : K).get(z.envMap || Ae), He = z.vertexColors === !0 && !!H.attributes.color && H.attributes.color.itemSize === 4, De = !!z.normalMap && !!H.attributes.tangent, ze = !!H.morphAttributes.position, je = !!H.morphAttributes.normal, Rn = H.morphAttributes.position ? H.morphAttributes.position.length : 0, ei = z.toneMapped ? x.toneMapping : _n, Ge = G.get(z), Ht = d.state.lights; - if (ce === !0 && (V === !0 || S !== b)) { - let Pt = S === b && z.id === y; - J.setState(z, S, Pt); - } - let at = !1; - z.version === Ge.__version ? (Ge.needsLights && Ge.lightsStateVersion !== Ht.state.version || Ge.outputEncoding !== Ie || q.isInstancedMesh && Ge.instancing === !1 || !q.isInstancedMesh && Ge.instancing === !0 || q.isSkinnedMesh && Ge.skinning === !1 || !q.isSkinnedMesh && Ge.skinning === !0 || Ge.envMap !== we || z.fog && Ge.fog !== be || Ge.numClippingPlanes !== void 0 && (Ge.numClippingPlanes !== J.numPlanes || Ge.numIntersection !== J.numIntersection) || Ge.vertexAlphas !== He || Ge.vertexTangents !== De || Ge.morphTargets !== ze || Ge.morphNormals !== je || Ge.toneMapping !== ei || ge.isWebGL2 === !0 && Ge.morphTargetsCount !== Rn) && (at = !0) : (at = !0, Ge.__version = z.version); - let kt = Ge.currentProgram; - at === !0 && (kt = xo(z, N, q)); - let Gr = !1, Gt = !1, Zt = !1, xt = kt.getUniforms(), Xi = Ge.uniforms; - if (xe.useProgram(kt.program) && (Gr = !0, Gt = !0, Zt = !0), z.id !== y && (y = z.id, Gt = !0), Gr || b !== S) { - if (xt.setValue(Y, "projectionMatrix", S.projectionMatrix), ge.logarithmicDepthBuffer && xt.setValue(Y, "logDepthBufFC", 2 / (Math.log(S.far + 1) / Math.LN2)), b !== S && (b = S, Gt = !0, Zt = !0), z.isShaderMaterial || z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshStandardMaterial || z.envMap) { - let Pt = xt.map.cameraPosition; - Pt !== void 0 && Pt.setValue(Y, le.setFromMatrixPosition(S.matrixWorld)); + function Gs(T, D, W) { + let U = D.isScene === !0 ? D.overrideMaterial : null; + for(let G = 0, gt = T.length; G < gt; G++){ + let Ct = T[G], It = Ct.object, Ut = Ct.geometry, Gt = U === null ? Ct.material : U, Lt = Ct.group; + It.layers.test(W.layers) && $c(It, D, W, Ut, Gt, Lt); } - (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial) && xt.setValue(Y, "isOrthographic", S.isOrthographicCamera === !0), (z.isMeshPhongMaterial || z.isMeshToonMaterial || z.isMeshLambertMaterial || z.isMeshBasicMaterial || z.isMeshStandardMaterial || z.isShaderMaterial || z.isShadowMaterial || q.isSkinnedMesh) && xt.setValue(Y, "viewMatrix", S.matrixWorldInverse); - } - if (q.isSkinnedMesh) { - xt.setOptional(Y, q, "bindMatrix"), xt.setOptional(Y, q, "bindMatrixInverse"); - let Pt = q.skeleton; - Pt && (ge.floatVertexTextures ? (Pt.boneTexture === null && Pt.computeBoneTexture(), xt.setValue(Y, "boneTexture", Pt.boneTexture, j), xt.setValue(Y, "boneTextureSize", Pt.boneTextureSize)) : xt.setOptional(Y, Pt, "boneMatrices")); - } - return !!H && (H.morphAttributes.position !== void 0 || H.morphAttributes.normal !== void 0) && Z.update(q, H, z, kt), (Gt || Ge.receiveShadow !== q.receiveShadow) && (Ge.receiveShadow = q.receiveShadow, xt.setValue(Y, "receiveShadow", q.receiveShadow)), Gt && (xt.setValue(Y, "toneMappingExposure", x.toneMappingExposure), Ge.needsLights && cu(Xi, Zt), be && z.fog && Ye.refreshFogUniforms(Xi, be), Ye.refreshMaterialUniforms(Xi, z, P, B, W), bn.upload(Y, Ge.uniformsList, Xi, j)), z.isShaderMaterial && z.uniformsNeedUpdate === !0 && (bn.upload(Y, Ge.uniformsList, Xi, j), z.uniformsNeedUpdate = !1), z.isSpriteMaterial && xt.setValue(Y, "center", q.center), xt.setValue(Y, "modelViewMatrix", q.modelViewMatrix), xt.setValue(Y, "normalMatrix", q.normalMatrix), xt.setValue(Y, "modelMatrix", q.matrixWorld), kt; - } - function cu(S, N) { - S.ambientLightColor.needsUpdate = N, S.lightProbe.needsUpdate = N, S.directionalLights.needsUpdate = N, S.directionalLightShadows.needsUpdate = N, S.pointLights.needsUpdate = N, S.pointLightShadows.needsUpdate = N, S.spotLights.needsUpdate = N, S.spotLightShadows.needsUpdate = N, S.rectAreaLights.needsUpdate = N, S.hemisphereLights.needsUpdate = N; - } - function hu(S) { - return S.isMeshLambertMaterial || S.isMeshToonMaterial || S.isMeshPhongMaterial || S.isMeshStandardMaterial || S.isShadowMaterial || S.isShaderMaterial && S.lights === !0; - } - this.getActiveCubeFace = function() { - return g; - }, this.getActiveMipmapLevel = function() { - return p; - }, this.getRenderTarget = function() { - return _; - }, this.setRenderTargetTextures = function(S, N, H) { - G.get(S.texture).__webglTexture = N, G.get(S.depthTexture).__webglTexture = H; - let z = G.get(S); - z.__hasExternalTextures = !0, z.__hasExternalTextures && (z.__autoAllocateDepthBuffer = H === void 0, z.__autoAllocateDepthBuffer || S.useRenderToTexture && (console.warn("render-to-texture extension was disabled because an external texture was provided"), S.useRenderToTexture = !1, S.useRenderbuffer = !0)); - }, this.setRenderTargetFramebuffer = function(S, N) { - let H = G.get(S); - H.__webglFramebuffer = N, H.__useDefaultFramebuffer = N === void 0; - }, this.setRenderTarget = function(S, N = 0, H = 0) { - _ = S, g = N, p = H; - let z = !0; - if (S) { - let we = G.get(S); - we.__useDefaultFramebuffer !== void 0 ? (xe.bindFramebuffer(36160, null), z = !1) : we.__webglFramebuffer === void 0 ? j.setupRenderTarget(S) : we.__hasExternalTextures && j.rebindTextures(S, G.get(S.texture).__webglTexture, G.get(S.depthTexture).__webglTexture); - } - let q = null, be = !1, Ae = !1; - if (S) { - let we = S.texture; - (we.isDataTexture3D || we.isDataTexture2DArray) && (Ae = !0); - let He = G.get(S).__webglFramebuffer; - S.isWebGLCubeRenderTarget ? (q = He[N], be = !0) : S.useRenderbuffer ? q = G.get(S).__webglMultisampledFramebuffer : q = He, A.copy(S.viewport), L.copy(S.scissor), I = S.scissorTest; - } else A.copy(D).multiplyScalar(P).floor(), L.copy(U).multiplyScalar(P).floor(), I = F; - if (xe.bindFramebuffer(36160, q) && ge.drawBuffers && z) { - let we = !1; - if (S) if (S.isWebGLMultipleRenderTargets) { - let He = S.texture; - if (O.length !== He.length || O[0] !== 36064) { - for(let De = 0, ze = He.length; De < ze; De++)O[De] = 36064 + De; - O.length = He.length, we = !0; - } - } else (O.length !== 1 || O[0] !== 36064) && (O[0] = 36064, O.length = 1, we = !0); - else (O.length !== 1 || O[0] !== 1029) && (O[0] = 1029, O.length = 1, we = !0); - we && (ge.isWebGL2 ? Y.drawBuffers(O) : ye.get("WEBGL_draw_buffers").drawBuffersWEBGL(O)); - } - if (xe.viewport(A), xe.scissor(L), xe.setScissorTest(I), be) { - let we = G.get(S.texture); - Y.framebufferTexture2D(36160, 36064, 34069 + N, we.__webglTexture, H); - } else if (Ae) { - let we = G.get(S.texture), He = N || 0; - Y.framebufferTextureLayer(36160, 36064, we.__webglTexture, H || 0, He); - } - y = -1; - }, this.readRenderTargetPixels = function(S, N, H, z, q, be, Ae) { - if (!(S && S.isWebGLRenderTarget)) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); - return; } - let Ie = G.get(S).__webglFramebuffer; - if (S.isWebGLCubeRenderTarget && Ae !== void 0 && (Ie = Ie[Ae]), Ie) { - xe.bindFramebuffer(36160, Ie); - try { - let we = S.texture, He = we.format, De = we.type; - if (He !== ct && te.convert(He) !== Y.getParameter(35739)) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); - return; - } - let ze = De === kn && (ye.has("EXT_color_buffer_half_float") || ge.isWebGL2 && ye.has("EXT_color_buffer_float")); - if (De !== rn && te.convert(De) !== Y.getParameter(35738) && !(De === nn && (ge.isWebGL2 || ye.has("OES_texture_float") || ye.has("WEBGL_color_buffer_float"))) && !ze) { - console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); - return; + function $c(T, D, W, U, G, gt) { + T.onBeforeRender(_, D, W, U, G, gt), T.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse, T.matrixWorld), T.normalMatrix.getNormalMatrix(T.modelViewMatrix), G.onBeforeRender(_, D, W, U, T, gt), G.transparent === !0 && G.side === gn && G.forceSinglePass === !1 ? (G.side = De, G.needsUpdate = !0, _.renderBufferDirect(W, D, U, G, T, gt), G.side = On, G.needsUpdate = !0, _.renderBufferDirect(W, D, U, G, T, gt), G.side = gn) : _.renderBufferDirect(W, D, U, G, T, gt), T.onAfterRender(_, D, W, U, G, gt); + } + function Ws(T, D, W) { + D.isScene !== !0 && (D = te); + let U = mt.get(T), G = g.state.lights, gt = g.state.shadowsArray, Ct = G.state.version, It = B.getParameters(T, G.state, gt, D, W), Ut = B.getProgramCacheKey(It), Gt = U.programs; + U.environment = T.isMeshStandardMaterial ? D.environment : null, U.fog = D.fog, U.envMap = (T.isMeshStandardMaterial ? Xt : Dt).get(T.envMap || U.environment), Gt === void 0 && (T.addEventListener("dispose", dt), Gt = new Map, U.programs = Gt); + let Lt = Gt.get(Ut); + if (Lt !== void 0) { + if (U.currentProgram === Lt && U.lightsStateVersion === Ct) return Kc(T, It), Lt; + } else It.uniforms = B.getUniforms(T), T.onBuild(W, It, _), T.onBeforeCompile(It, _), Lt = B.acquireProgram(It, Ut), Gt.set(Ut, Lt), U.uniforms = It.uniforms; + let Bt = U.uniforms; + (!T.isShaderMaterial && !T.isRawShaderMaterial || T.clipping === !0) && (Bt.clippingPlanes = Mt.uniform), Kc(T, It), U.needsLights = Ud(T), U.lightsStateVersion = Ct, U.needsLights && (Bt.ambientLightColor.value = G.state.ambient, Bt.lightProbe.value = G.state.probe, Bt.directionalLights.value = G.state.directional, Bt.directionalLightShadows.value = G.state.directionalShadow, Bt.spotLights.value = G.state.spot, Bt.spotLightShadows.value = G.state.spotShadow, Bt.rectAreaLights.value = G.state.rectArea, Bt.ltc_1.value = G.state.rectAreaLTC1, Bt.ltc_2.value = G.state.rectAreaLTC2, Bt.pointLights.value = G.state.point, Bt.pointLightShadows.value = G.state.pointShadow, Bt.hemisphereLights.value = G.state.hemi, Bt.directionalShadowMap.value = G.state.directionalShadowMap, Bt.directionalShadowMatrix.value = G.state.directionalShadowMatrix, Bt.spotShadowMap.value = G.state.spotShadowMap, Bt.spotLightMatrix.value = G.state.spotLightMatrix, Bt.spotLightMap.value = G.state.spotLightMap, Bt.pointShadowMap.value = G.state.pointShadowMap, Bt.pointShadowMatrix.value = G.state.pointShadowMatrix); + let se = Lt.getUniforms(), oe = qi.seqWithValue(se.seq, Bt); + return U.currentProgram = Lt, U.uniformsList = oe, Lt; + } + function Kc(T, D) { + let W = mt.get(T); + W.outputColorSpace = D.outputColorSpace, W.instancing = D.instancing, W.instancingColor = D.instancingColor, W.skinning = D.skinning, W.morphTargets = D.morphTargets, W.morphNormals = D.morphNormals, W.morphColors = D.morphColors, W.morphTargetsCount = D.morphTargetsCount, W.numClippingPlanes = D.numClippingPlanes, W.numIntersection = D.numClipIntersection, W.vertexAlphas = D.vertexAlphas, W.vertexTangents = D.vertexTangents, W.toneMapping = D.toneMapping; + } + function Ld(T, D, W, U, G) { + D.isScene !== !0 && (D = te), xt.resetTextureUnits(); + let gt = D.fog, Ct = U.isMeshStandardMaterial ? D.environment : null, It = R === null ? _.outputColorSpace : R.isXRRenderTarget === !0 ? R.texture.colorSpace : nn, Ut = (U.isMeshStandardMaterial ? Xt : Dt).get(U.envMap || Ct), Gt = U.vertexColors === !0 && !!W.attributes.color && W.attributes.color.itemSize === 4, Lt = !!W.attributes.tangent && (!!U.normalMap || U.anisotropy > 0), Bt = !!W.morphAttributes.position, se = !!W.morphAttributes.normal, oe = !!W.morphAttributes.color, ze = Dn; + U.toneMapped && (R === null || R.isXRRenderTarget === !0) && (ze = _.toneMapping); + let an = W.morphAttributes.position || W.morphAttributes.normal || W.morphAttributes.color, he = an !== void 0 ? an.length : 0, Wt = mt.get(U), _a = g.state.lights; + if (ut === !0 && (pt === !0 || T !== M)) { + let Ne = T === M && U.id === L; + Mt.setState(U, T, Ne); + } + let ue = !1; + U.version === Wt.__version ? (Wt.needsLights && Wt.lightsStateVersion !== _a.state.version || Wt.outputColorSpace !== It || G.isInstancedMesh && Wt.instancing === !1 || !G.isInstancedMesh && Wt.instancing === !0 || G.isSkinnedMesh && Wt.skinning === !1 || !G.isSkinnedMesh && Wt.skinning === !0 || G.isInstancedMesh && Wt.instancingColor === !0 && G.instanceColor === null || G.isInstancedMesh && Wt.instancingColor === !1 && G.instanceColor !== null || Wt.envMap !== Ut || U.fog === !0 && Wt.fog !== gt || Wt.numClippingPlanes !== void 0 && (Wt.numClippingPlanes !== Mt.numPlanes || Wt.numIntersection !== Mt.numIntersection) || Wt.vertexAlphas !== Gt || Wt.vertexTangents !== Lt || Wt.morphTargets !== Bt || Wt.morphNormals !== se || Wt.morphColors !== oe || Wt.toneMapping !== ze || st.isWebGL2 === !0 && Wt.morphTargetsCount !== he) && (ue = !0) : (ue = !0, Wt.__version = U.version); + let Vn = Wt.currentProgram; + ue === !0 && (Vn = Ws(U, D, G)); + let Qc = !1, os = !1, xa = !1, we = Vn.getUniforms(), Hn = Wt.uniforms; + if (Q.useProgram(Vn.program) && (Qc = !0, os = !0, xa = !0), U.id !== L && (L = U.id, os = !0), Qc || M !== T) { + if (we.setValue(P, "projectionMatrix", T.projectionMatrix), st.logarithmicDepthBuffer && we.setValue(P, "logDepthBufFC", 2 / (Math.log(T.far + 1) / Math.LN2)), M !== T && (M = T, os = !0, xa = !0), U.isShaderMaterial || U.isMeshPhongMaterial || U.isMeshToonMaterial || U.isMeshStandardMaterial || U.envMap) { + let Ne = we.map.cameraPosition; + Ne !== void 0 && Ne.setValue(P, Yt.setFromMatrixPosition(T.matrixWorld)); } - Y.checkFramebufferStatus(36160) === 36053 ? N >= 0 && N <= S.width - z && H >= 0 && H <= S.height - q && Y.readPixels(N, H, z, q, te.convert(He), te.convert(De), be) : console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."); - } finally{ - let we = _ !== null ? G.get(_).__webglFramebuffer : null; - xe.bindFramebuffer(36160, we); + (U.isMeshPhongMaterial || U.isMeshToonMaterial || U.isMeshLambertMaterial || U.isMeshBasicMaterial || U.isMeshStandardMaterial || U.isShaderMaterial) && we.setValue(P, "isOrthographic", T.isOrthographicCamera === !0), (U.isMeshPhongMaterial || U.isMeshToonMaterial || U.isMeshLambertMaterial || U.isMeshBasicMaterial || U.isMeshStandardMaterial || U.isShaderMaterial || U.isShadowMaterial || G.isSkinnedMesh) && we.setValue(P, "viewMatrix", T.matrixWorldInverse); } + if (G.isSkinnedMesh) { + we.setOptional(P, G, "bindMatrix"), we.setOptional(P, G, "bindMatrixInverse"); + let Ne = G.skeleton; + Ne && (st.floatVertexTextures ? (Ne.boneTexture === null && Ne.computeBoneTexture(), we.setValue(P, "boneTexture", Ne.boneTexture, xt), we.setValue(P, "boneTextureSize", Ne.boneTextureSize)) : console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.")); + } + let va = W.morphAttributes; + if ((va.position !== void 0 || va.normal !== void 0 || va.color !== void 0 && st.isWebGL2 === !0) && Rt.update(G, W, Vn), (os || Wt.receiveShadow !== G.receiveShadow) && (Wt.receiveShadow = G.receiveShadow, we.setValue(P, "receiveShadow", G.receiveShadow)), U.isMeshGouraudMaterial && U.envMap !== null && (Hn.envMap.value = Ut, Hn.flipEnvMap.value = Ut.isCubeTexture && Ut.isRenderTargetTexture === !1 ? -1 : 1), os && (we.setValue(P, "toneMappingExposure", _.toneMappingExposure), Wt.needsLights && Id(Hn, xa), gt && U.fog === !0 && nt.refreshFogUniforms(Hn, gt), nt.refreshMaterialUniforms(Hn, U, X, K, Et), qi.upload(P, Wt.uniformsList, Hn, xt)), U.isShaderMaterial && U.uniformsNeedUpdate === !0 && (qi.upload(P, Wt.uniformsList, Hn, xt), U.uniformsNeedUpdate = !1), U.isSpriteMaterial && we.setValue(P, "center", G.center), we.setValue(P, "modelViewMatrix", G.modelViewMatrix), we.setValue(P, "normalMatrix", G.normalMatrix), we.setValue(P, "modelMatrix", G.matrixWorld), U.isShaderMaterial || U.isRawShaderMaterial) { + let Ne = U.uniformsGroups; + for(let ya = 0, Dd = Ne.length; ya < Dd; ya++)if (st.isWebGL2) { + let jc = Ne[ya]; + Ht.update(jc, Vn), Ht.bind(jc, Vn); + } else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2."); + } + return Vn; } - }, this.copyFramebufferToTexture = function(S, N, H = 0) { - if (N.isFramebufferTexture !== !0) { - console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture."); - return; - } - let z = Math.pow(2, -H), q = Math.floor(N.image.width * z), be = Math.floor(N.image.height * z); - j.setTexture2D(N, 0), Y.copyTexSubImage2D(3553, H, 0, 0, S.x, S.y, q, be), xe.unbindTexture(); - }, this.copyTextureToTexture = function(S, N, H, z = 0) { - let q = N.image.width, be = N.image.height, Ae = te.convert(H.format), Ie = te.convert(H.type); - j.setTexture2D(H, 0), Y.pixelStorei(37440, H.flipY), Y.pixelStorei(37441, H.premultiplyAlpha), Y.pixelStorei(3317, H.unpackAlignment), N.isDataTexture ? Y.texSubImage2D(3553, z, S.x, S.y, q, be, Ae, Ie, N.image.data) : N.isCompressedTexture ? Y.compressedTexSubImage2D(3553, z, S.x, S.y, N.mipmaps[0].width, N.mipmaps[0].height, Ae, N.mipmaps[0].data) : Y.texSubImage2D(3553, z, S.x, S.y, Ae, Ie, N.image), z === 0 && H.generateMipmaps && Y.generateMipmap(3553), xe.unbindTexture(); - }, this.copyTextureToTexture3D = function(S, N, H, z, q = 0) { - if (x.isWebGL1Renderer) { - console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2."); - return; + function Id(T, D) { + T.ambientLightColor.needsUpdate = D, T.lightProbe.needsUpdate = D, T.directionalLights.needsUpdate = D, T.directionalLightShadows.needsUpdate = D, T.pointLights.needsUpdate = D, T.pointLightShadows.needsUpdate = D, T.spotLights.needsUpdate = D, T.spotLightShadows.needsUpdate = D, T.rectAreaLights.needsUpdate = D, T.hemisphereLights.needsUpdate = D; } - let be = S.max.x - S.min.x + 1, Ae = S.max.y - S.min.y + 1, Ie = S.max.z - S.min.z + 1, we = te.convert(z.format), He = te.convert(z.type), De; - if (z.isDataTexture3D) j.setTexture3D(z, 0), De = 32879; - else if (z.isDataTexture2DArray) j.setTexture2DArray(z, 0), De = 35866; - else { - console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray."); - return; + function Ud(T) { + return T.isMeshLambertMaterial || T.isMeshToonMaterial || T.isMeshPhongMaterial || T.isMeshStandardMaterial || T.isShadowMaterial || T.isShaderMaterial && T.lights === !0; } - Y.pixelStorei(37440, z.flipY), Y.pixelStorei(37441, z.premultiplyAlpha), Y.pixelStorei(3317, z.unpackAlignment); - let ze = Y.getParameter(3314), je = Y.getParameter(32878), Rn = Y.getParameter(3316), ei = Y.getParameter(3315), Ge = Y.getParameter(32877), Ht = H.isCompressedTexture ? H.mipmaps[0] : H.image; - Y.pixelStorei(3314, Ht.width), Y.pixelStorei(32878, Ht.height), Y.pixelStorei(3316, S.min.x), Y.pixelStorei(3315, S.min.y), Y.pixelStorei(32877, S.min.z), H.isDataTexture || H.isDataTexture3D ? Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht.data) : H.isCompressedTexture ? (console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."), Y.compressedTexSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, Ht.data)) : Y.texSubImage3D(De, q, N.x, N.y, N.z, be, Ae, Ie, we, He, Ht), Y.pixelStorei(3314, ze), Y.pixelStorei(32878, je), Y.pixelStorei(3316, Rn), Y.pixelStorei(3315, ei), Y.pixelStorei(32877, Ge), q === 0 && z.generateMipmaps && Y.generateMipmap(De), xe.unbindTexture(); - }, this.initTexture = function(S) { - j.setTexture2D(S, 0), xe.unbindTexture(); - }, this.resetState = function() { - g = 0, p = 0, _ = null, xe.reset(), R.reset(); - }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { - detail: this - })); -} -qe.prototype.isWebGLRenderer = !0; -var _h = class extends qe { + this.getActiveCubeFace = function() { + return b; + }, this.getActiveMipmapLevel = function() { + return w; + }, this.getRenderTarget = function() { + return R; + }, this.setRenderTargetTextures = function(T, D, W) { + mt.get(T.texture).__webglTexture = D, mt.get(T.depthTexture).__webglTexture = W; + let U = mt.get(T); + U.__hasExternalTextures = !0, U.__hasExternalTextures && (U.__autoAllocateDepthBuffer = W === void 0, U.__autoAllocateDepthBuffer || Z.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), U.__useRenderToTexture = !1)); + }, this.setRenderTargetFramebuffer = function(T, D) { + let W = mt.get(T); + W.__webglFramebuffer = D, W.__useDefaultFramebuffer = D === void 0; + }, this.setRenderTarget = function(T, D = 0, W = 0) { + R = T, b = D, w = W; + let U = !0, G = null, gt = !1, Ct = !1; + if (T) { + let Ut = mt.get(T); + Ut.__useDefaultFramebuffer !== void 0 ? (Q.bindFramebuffer(P.FRAMEBUFFER, null), U = !1) : Ut.__webglFramebuffer === void 0 ? xt.setupRenderTarget(T) : Ut.__hasExternalTextures && xt.rebindTextures(T, mt.get(T.texture).__webglTexture, mt.get(T.depthTexture).__webglTexture); + let Gt = T.texture; + (Gt.isData3DTexture || Gt.isDataArrayTexture || Gt.isCompressedArrayTexture) && (Ct = !0); + let Lt = mt.get(T).__webglFramebuffer; + T.isWebGLCubeRenderTarget ? (Array.isArray(Lt[D]) ? G = Lt[D][W] : G = Lt[D], gt = !0) : st.isWebGL2 && T.samples > 0 && xt.useMultisampledRTT(T) === !1 ? G = mt.get(T).__webglMultisampledFramebuffer : Array.isArray(Lt) ? G = Lt[W] : G = Lt, E.copy(T.viewport), V.copy(T.scissor), $ = T.scissorTest; + } else E.copy(tt).multiplyScalar(X).floor(), V.copy(N).multiplyScalar(X).floor(), $ = q; + if (Q.bindFramebuffer(P.FRAMEBUFFER, G) && st.drawBuffers && U && Q.drawBuffers(T, G), Q.viewport(E), Q.scissor(V), Q.setScissorTest($), gt) { + let Ut = mt.get(T.texture); + P.framebufferTexture2D(P.FRAMEBUFFER, P.COLOR_ATTACHMENT0, P.TEXTURE_CUBE_MAP_POSITIVE_X + D, Ut.__webglTexture, W); + } else if (Ct) { + let Ut = mt.get(T.texture), Gt = D || 0; + P.framebufferTextureLayer(P.FRAMEBUFFER, P.COLOR_ATTACHMENT0, Ut.__webglTexture, W || 0, Gt); + } + L = -1; + }, this.readRenderTargetPixels = function(T, D, W, U, G, gt, Ct) { + if (!(T && T.isWebGLRenderTarget)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); + return; + } + let It = mt.get(T).__webglFramebuffer; + if (T.isWebGLCubeRenderTarget && Ct !== void 0 && (It = It[Ct]), It) { + Q.bindFramebuffer(P.FRAMEBUFFER, It); + try { + let Ut = T.texture, Gt = Ut.format, Lt = Ut.type; + if (Gt !== He && vt.convert(Gt) !== P.getParameter(P.IMPLEMENTATION_COLOR_READ_FORMAT)) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); + return; + } + let Bt = Lt === Ts && (Z.has("EXT_color_buffer_half_float") || st.isWebGL2 && Z.has("EXT_color_buffer_float")); + if (Lt !== Nn && vt.convert(Lt) !== P.getParameter(P.IMPLEMENTATION_COLOR_READ_TYPE) && !(Lt === xn && (st.isWebGL2 || Z.has("OES_texture_float") || Z.has("WEBGL_color_buffer_float"))) && !Bt) { + console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); + return; + } + D >= 0 && D <= T.width - U && W >= 0 && W <= T.height - G && P.readPixels(D, W, U, G, vt.convert(Gt), vt.convert(Lt), gt); + } finally{ + let Ut = R !== null ? mt.get(R).__webglFramebuffer : null; + Q.bindFramebuffer(P.FRAMEBUFFER, Ut); + } + } + }, this.copyFramebufferToTexture = function(T, D, W = 0) { + let U = Math.pow(2, -W), G = Math.floor(D.image.width * U), gt = Math.floor(D.image.height * U); + xt.setTexture2D(D, 0), P.copyTexSubImage2D(P.TEXTURE_2D, W, 0, 0, T.x, T.y, G, gt), Q.unbindTexture(); + }, this.copyTextureToTexture = function(T, D, W, U = 0) { + let G = D.image.width, gt = D.image.height, Ct = vt.convert(W.format), It = vt.convert(W.type); + xt.setTexture2D(W, 0), P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL, W.flipY), P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL, W.premultiplyAlpha), P.pixelStorei(P.UNPACK_ALIGNMENT, W.unpackAlignment), D.isDataTexture ? P.texSubImage2D(P.TEXTURE_2D, U, T.x, T.y, G, gt, Ct, It, D.image.data) : D.isCompressedTexture ? P.compressedTexSubImage2D(P.TEXTURE_2D, U, T.x, T.y, D.mipmaps[0].width, D.mipmaps[0].height, Ct, D.mipmaps[0].data) : P.texSubImage2D(P.TEXTURE_2D, U, T.x, T.y, Ct, It, D.image), U === 0 && W.generateMipmaps && P.generateMipmap(P.TEXTURE_2D), Q.unbindTexture(); + }, this.copyTextureToTexture3D = function(T, D, W, U, G = 0) { + if (_.isWebGL1Renderer) { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2."); + return; + } + let gt = T.max.x - T.min.x + 1, Ct = T.max.y - T.min.y + 1, It = T.max.z - T.min.z + 1, Ut = vt.convert(U.format), Gt = vt.convert(U.type), Lt; + if (U.isData3DTexture) xt.setTexture3D(U, 0), Lt = P.TEXTURE_3D; + else if (U.isDataArrayTexture) xt.setTexture2DArray(U, 0), Lt = P.TEXTURE_2D_ARRAY; + else { + console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray."); + return; + } + P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL, U.flipY), P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL, U.premultiplyAlpha), P.pixelStorei(P.UNPACK_ALIGNMENT, U.unpackAlignment); + let Bt = P.getParameter(P.UNPACK_ROW_LENGTH), se = P.getParameter(P.UNPACK_IMAGE_HEIGHT), oe = P.getParameter(P.UNPACK_SKIP_PIXELS), ze = P.getParameter(P.UNPACK_SKIP_ROWS), an = P.getParameter(P.UNPACK_SKIP_IMAGES), he = W.isCompressedTexture ? W.mipmaps[0] : W.image; + P.pixelStorei(P.UNPACK_ROW_LENGTH, he.width), P.pixelStorei(P.UNPACK_IMAGE_HEIGHT, he.height), P.pixelStorei(P.UNPACK_SKIP_PIXELS, T.min.x), P.pixelStorei(P.UNPACK_SKIP_ROWS, T.min.y), P.pixelStorei(P.UNPACK_SKIP_IMAGES, T.min.z), W.isDataTexture || W.isData3DTexture ? P.texSubImage3D(Lt, G, D.x, D.y, D.z, gt, Ct, It, Ut, Gt, he.data) : W.isCompressedArrayTexture ? (console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."), P.compressedTexSubImage3D(Lt, G, D.x, D.y, D.z, gt, Ct, It, Ut, he.data)) : P.texSubImage3D(Lt, G, D.x, D.y, D.z, gt, Ct, It, Ut, Gt, he), P.pixelStorei(P.UNPACK_ROW_LENGTH, Bt), P.pixelStorei(P.UNPACK_IMAGE_HEIGHT, se), P.pixelStorei(P.UNPACK_SKIP_PIXELS, oe), P.pixelStorei(P.UNPACK_SKIP_ROWS, ze), P.pixelStorei(P.UNPACK_SKIP_IMAGES, an), G === 0 && U.generateMipmaps && P.generateMipmap(Lt), Q.unbindTexture(); + }, this.initTexture = function(T) { + T.isCubeTexture ? xt.setTextureCube(T, 0) : T.isData3DTexture ? xt.setTexture3D(T, 0) : T.isDataArrayTexture || T.isCompressedArrayTexture ? xt.setTexture2DArray(T, 0) : xt.setTexture2D(T, 0), Q.unbindTexture(); + }, this.resetState = function() { + b = 0, w = 0, R = null, Q.reset(), yt.reset(); + }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { + detail: this + })); + } + get coordinateSystem() { + return vn; + } + get physicallyCorrectLights() { + return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."), !this.useLegacyLights; + } + set physicallyCorrectLights(t) { + console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."), this.useLegacyLights = !t; + } + get outputEncoding() { + return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."), this.outputColorSpace === Nt ? si : fd; + } + set outputEncoding(t) { + console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."), this.outputColorSpace = t === si ? Nt : nn; + } + get useLegacyLights() { + return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights; + } + set useLegacyLights(t) { + console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights = t; + } +}, Eo = class extends bo { }; -_h.prototype.isWebGL1Renderer = !0; -var Nr = class { - constructor(e, t = 25e-5){ - this.name = "", this.color = new ae(e), this.density = t; +Eo.prototype.isWebGL1Renderer = !0; +var To = class s1 { + constructor(t, e = 25e-5){ + this.isFogExp2 = !0, this.name = "", this.color = new ft(t), this.density = e; } clone() { - return new Nr(this.color, this.density); + return new s1(this.color, this.density); } toJSON() { return { @@ -11610,14 +13214,12 @@ var Nr = class { density: this.density }; } -}; -Nr.prototype.isFogExp2 = !0; -var Br = class { - constructor(e, t = 1, n = 1e3){ - this.name = "", this.color = new ae(e), this.near = t, this.far = n; +}, wo = class s1 { + constructor(t, e = 1, n = 1e3){ + this.isFog = !0, this.name = "", this.color = new ft(t), this.near = e, this.far = n; } clone() { - return new Br(this.color, this.near, this.far); + return new s1(this.color, this.near, this.far); } toJSON() { return { @@ -11627,70 +13229,63 @@ var Br = class { far: this.far }; } -}; -Br.prototype.isFog = !0; -var no = class extends Ne { +}, Ao = class extends Zt { constructor(){ - super(); - this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.overrideMaterial = null, this.autoUpdate = !0, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { + super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); } - copy(e, t) { - return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.autoUpdate = e.autoUpdate, this.matrixAutoUpdate = e.matrixAutoUpdate, this; + copy(t, e) { + return super.copy(t, e), t.background !== null && (this.background = t.background.clone()), t.environment !== null && (this.environment = t.environment.clone()), t.fog !== null && (this.fog = t.fog.clone()), this.backgroundBlurriness = t.backgroundBlurriness, this.backgroundIntensity = t.backgroundIntensity, t.overrideMaterial !== null && (this.overrideMaterial = t.overrideMaterial.clone()), this.matrixAutoUpdate = t.matrixAutoUpdate, this; } - toJSON(e) { - let t = super.toJSON(e); - return this.fog !== null && (t.object.fog = this.fog.toJSON()), t; + toJSON(t) { + let e = super.toJSON(t); + return this.fog !== null && (e.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (e.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (e.object.backgroundIntensity = this.backgroundIntensity), e; } -}; -no.prototype.isScene = !0; -var $n = class { - constructor(e, t){ - this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = hr, this.updateRange = { +}, Is = class { + constructor(t, e){ + this.isInterleavedBuffer = !0, this.array = t, this.stride = e, this.count = t !== void 0 ? t.length / e : 0, this.usage = kr, this.updateRange = { offset: 0, count: -1 - }, this.version = 0, this.uuid = Et(); + }, this.version = 0, this.uuid = Be(); } onUploadCallback() {} - set needsUpdate(e) { - e === !0 && this.version++; + set needsUpdate(t) { + t === !0 && this.version++; } - setUsage(e) { - return this.usage = e, this; + setUsage(t) { + return this.usage = t, this; } - copy(e) { - return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this; + copy(t) { + return this.array = new t.array.constructor(t.array), this.count = t.count, this.stride = t.stride, this.usage = t.usage, this; } - copyAt(e, t, n) { - e *= this.stride, n *= t.stride; - for(let i = 0, r = this.stride; i < r; i++)this.array[e + i] = t.array[n + i]; + copyAt(t, e, n) { + t *= this.stride, n *= e.stride; + for(let i = 0, r = this.stride; i < r; i++)this.array[t + i] = e.array[n + i]; return this; } - set(e, t = 0) { - return this.array.set(e, t), this; + set(t, e = 0) { + return this.array.set(t, e), this; } - clone(e) { - e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); - let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); + clone(t) { + t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Be()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); + let e = new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(e, this.stride); return n.setUsage(this.usage), n; } - onUpload(e) { - return this.onUploadCallback = e, this; + onUpload(t) { + return this.onUploadCallback = t, this; } - toJSON(e) { - return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Et()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.prototype.slice.call(new Uint32Array(this.array.buffer))), { + toJSON(t) { + return t.arrayBuffers === void 0 && (t.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Be()), t.arrayBuffers[this.array.buffer._uuid] === void 0 && (t.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), { uuid: this.uuid, buffer: this.array.buffer._uuid, type: this.array.constructor.name, stride: this.stride }; } -}; -$n.prototype.isInterleavedBuffer = !0; -var Ke = new M, Sn = class { - constructor(e, t, n, i = !1){ - this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = i === !0; +}, Ae = new A, Qi = class s1 { + constructor(t, e, n, i = !1){ + this.isInterleavedBufferAttribute = !0, this.name = "", this.data = t, this.itemSize = e, this.offset = n, this.normalized = i; } get count() { return this.data.count; @@ -11698,80 +13293,84 @@ var Ke = new M, Sn = class { get array() { return this.data.array; } - set needsUpdate(e) { - this.data.needsUpdate = e; + set needsUpdate(t) { + this.data.needsUpdate = t; } - applyMatrix4(e) { - for(let t = 0, n = this.data.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyMatrix4(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + applyMatrix4(t) { + for(let e = 0, n = this.data.count; e < n; e++)Ae.fromBufferAttribute(this, e), Ae.applyMatrix4(t), this.setXYZ(e, Ae.x, Ae.y, Ae.z); return this; } - applyNormalMatrix(e) { - for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.applyNormalMatrix(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + applyNormalMatrix(t) { + for(let e = 0, n = this.count; e < n; e++)Ae.fromBufferAttribute(this, e), Ae.applyNormalMatrix(t), this.setXYZ(e, Ae.x, Ae.y, Ae.z); return this; } - transformDirection(e) { - for(let t = 0, n = this.count; t < n; t++)Ke.x = this.getX(t), Ke.y = this.getY(t), Ke.z = this.getZ(t), Ke.transformDirection(e), this.setXYZ(t, Ke.x, Ke.y, Ke.z); + transformDirection(t) { + for(let e = 0, n = this.count; e < n; e++)Ae.fromBufferAttribute(this, e), Ae.transformDirection(t), this.setXYZ(e, Ae.x, Ae.y, Ae.z); return this; } - setX(e, t) { - return this.data.array[e * this.data.stride + this.offset] = t, this; + setX(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.data.array[t * this.data.stride + this.offset] = e, this; } - setY(e, t) { - return this.data.array[e * this.data.stride + this.offset + 1] = t, this; + setY(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.data.array[t * this.data.stride + this.offset + 1] = e, this; } - setZ(e, t) { - return this.data.array[e * this.data.stride + this.offset + 2] = t, this; + setZ(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.data.array[t * this.data.stride + this.offset + 2] = e, this; } - setW(e, t) { - return this.data.array[e * this.data.stride + this.offset + 3] = t, this; + setW(t, e) { + return this.normalized && (e = Ft(e, this.array)), this.data.array[t * this.data.stride + this.offset + 3] = e, this; } - getX(e) { - return this.data.array[e * this.data.stride + this.offset]; + getX(t) { + let e = this.data.array[t * this.data.stride + this.offset]; + return this.normalized && (e = Ue(e, this.array)), e; } - getY(e) { - return this.data.array[e * this.data.stride + this.offset + 1]; + getY(t) { + let e = this.data.array[t * this.data.stride + this.offset + 1]; + return this.normalized && (e = Ue(e, this.array)), e; } - getZ(e) { - return this.data.array[e * this.data.stride + this.offset + 2]; + getZ(t) { + let e = this.data.array[t * this.data.stride + this.offset + 2]; + return this.normalized && (e = Ue(e, this.array)), e; } - getW(e) { - return this.data.array[e * this.data.stride + this.offset + 3]; + getW(t) { + let e = this.data.array[t * this.data.stride + this.offset + 3]; + return this.normalized && (e = Ue(e, this.array)), e; } - setXY(e, t, n) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this; + setXY(t, e, n) { + return t = t * this.data.stride + this.offset, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = n, this; } - setXYZ(e, t, n, i) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this; + setXYZ(t, e, n, i) { + return t = t * this.data.stride + this.offset, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = n, this.data.array[t + 2] = i, this; } - setXYZW(e, t, n, i, r) { - return e = e * this.data.stride + this.offset, this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = i, this.data.array[e + 3] = r, this; + setXYZW(t, e, n, i, r) { + return t = t * this.data.stride + this.offset, this.normalized && (e = Ft(e, this.array), n = Ft(n, this.array), i = Ft(i, this.array), r = Ft(r, this.array)), this.data.array[t + 0] = e, this.data.array[t + 1] = n, this.data.array[t + 2] = i, this.data.array[t + 3] = r, this; } - clone(e) { - if (e === void 0) { - console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data."); - let t = []; + clone(t) { + if (t === void 0) { + console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data."); + let e = []; for(let n = 0; n < this.count; n++){ let i = n * this.data.stride + this.offset; - for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); + for(let r = 0; r < this.itemSize; r++)e.push(this.data.array[i + r]); } - return new Ue(new this.array.constructor(t), this.itemSize, this.normalized); - } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new Sn(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); + return new Kt(new this.array.constructor(e), this.itemSize, this.normalized); + } else return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.clone(t)), new s1(t.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); } - toJSON(e) { - if (e === void 0) { - console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data."); - let t = []; + toJSON(t) { + if (t === void 0) { + console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data."); + let e = []; for(let n = 0; n < this.count; n++){ let i = n * this.data.stride + this.offset; - for(let r = 0; r < this.itemSize; r++)t.push(this.data.array[i + r]); + for(let r = 0; r < this.itemSize; r++)e.push(this.data.array[i + r]); } return { itemSize: this.itemSize, type: this.array.constructor.name, - array: t, + array: e, normalized: this.normalized }; - } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { + } else return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.toJSON(t)), { isInterleavedBufferAttribute: !0, itemSize: this.itemSize, data: this.data.uuid, @@ -11779,24 +13378,18 @@ var Ke = new M, Sn = class { normalized: this.normalized }; } -}; -Sn.prototype.isInterleavedBufferAttribute = !0; -var io = class extends dt { - constructor(e){ - super(); - this.type = "SpriteMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.setValues(e); +}, Qr = class extends Me { + constructor(t){ + super(), this.isSpriteMaterial = !0, this.type = "SpriteMaterial", this.color = new ft(16777215), this.map = null, this.alphaMap = null, this.rotation = 0, this.sizeAttenuation = !0, this.transparent = !0, this.fog = !0, this.setValues(t); } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.rotation = e.rotation, this.sizeAttenuation = e.sizeAttenuation, this; + copy(t) { + return super.copy(t), this.color.copy(t.color), this.map = t.map, this.alphaMap = t.alphaMap, this.rotation = t.rotation, this.sizeAttenuation = t.sizeAttenuation, this.fog = t.fog, this; } -}; -io.prototype.isSpriteMaterial = !0; -var gi, Qi = new M, xi = new M, yi = new M, vi = new X, Ki = new X, Mh = new pe, hs = new M, er = new M, us = new M, jl = new X, qo = new X, Ql = new X, ro = class extends Ne { - constructor(e){ - super(); - if (this.type = "Sprite", gi === void 0) { - gi = new _e; - let t = new Float32Array([ +}, Ii, ds = new A, Ui = new A, Di = new A, Ni = new J, fs = new J, Ed = new Ot, ur = new A, ps = new A, dr = new A, bh = new J, Za = new J, Eh = new J, Ro = class extends Zt { + constructor(t){ + if (super(), this.isSprite = !0, this.type = "Sprite", Ii === void 0) { + Ii = new Vt; + let e = new Float32Array([ -.5, -.5, 0, @@ -11817,47 +13410,45 @@ var gi, Qi = new M, xi = new M, yi = new M, vi = new X, Ki = new X, Mh = new pe, 0, 0, 1 - ]), n = new $n(t, 5); - gi.setIndex([ + ]), n = new Is(e, 5); + Ii.setIndex([ 0, 1, 2, 0, 2, 3 - ]), gi.setAttribute("position", new Sn(n, 3, 0, !1)), gi.setAttribute("uv", new Sn(n, 2, 3, !1)); + ]), Ii.setAttribute("position", new Qi(n, 3, 0, !1)), Ii.setAttribute("uv", new Qi(n, 2, 3, !1)); } - this.geometry = gi, this.material = e !== void 0 ? e : new io, this.center = new X(.5, .5); + this.geometry = Ii, this.material = t !== void 0 ? t : new Qr, this.center = new J(.5, .5); } - raycast(e, t) { - e.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), xi.setFromMatrixScale(this.matrixWorld), Mh.copy(e.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse, this.matrixWorld), yi.setFromMatrixPosition(this.modelViewMatrix), e.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && xi.multiplyScalar(-yi.z); + raycast(t, e) { + t.camera === null && console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'), Ui.setFromMatrixScale(this.matrixWorld), Ed.copy(t.camera.matrixWorld), this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse, this.matrixWorld), Di.setFromMatrixPosition(this.modelViewMatrix), t.camera.isPerspectiveCamera && this.material.sizeAttenuation === !1 && Ui.multiplyScalar(-Di.z); let n = this.material.rotation, i, r; n !== 0 && (r = Math.cos(n), i = Math.sin(n)); - let o = this.center; - ds(hs.set(-.5, -.5, 0), yi, o, xi, i, r), ds(er.set(.5, -.5, 0), yi, o, xi, i, r), ds(us.set(.5, .5, 0), yi, o, xi, i, r), jl.set(0, 0), qo.set(1, 0), Ql.set(1, 1); - let a = e.ray.intersectTriangle(hs, er, us, !1, Qi); - if (a === null && (ds(er.set(-.5, .5, 0), yi, o, xi, i, r), qo.set(0, 1), a = e.ray.intersectTriangle(hs, us, er, !1, Qi), a === null)) return; - let l = e.ray.origin.distanceTo(Qi); - l < e.near || l > e.far || t.push({ - distance: l, - point: Qi.clone(), - uv: nt.getUV(Qi, hs, er, us, jl, qo, Ql, new X), + let a = this.center; + fr(ur.set(-.5, -.5, 0), Di, a, Ui, i, r), fr(ps.set(.5, -.5, 0), Di, a, Ui, i, r), fr(dr.set(.5, .5, 0), Di, a, Ui, i, r), bh.set(0, 0), Za.set(1, 0), Eh.set(1, 1); + let o = t.ray.intersectTriangle(ur, ps, dr, !1, ds); + if (o === null && (fr(ps.set(-.5, .5, 0), Di, a, Ui, i, r), Za.set(0, 1), o = t.ray.intersectTriangle(ur, dr, ps, !1, ds), o === null)) return; + let c = t.ray.origin.distanceTo(ds); + c < t.near || c > t.far || e.push({ + distance: c, + point: ds.clone(), + uv: In.getInterpolation(ds, ur, ps, dr, bh, Za, Eh, new J), face: null, object: this }); } - copy(e) { - return super.copy(e), e.center !== void 0 && this.center.copy(e.center), this.material = e.material, this; + copy(t, e) { + return super.copy(t, e), t.center !== void 0 && this.center.copy(t.center), this.material = t.material, this; } }; -ro.prototype.isSprite = !0; -function ds(s, e, t, n, i, r) { - vi.subVectors(s, t).addScalar(.5).multiply(n), i !== void 0 ? (Ki.x = r * vi.x - i * vi.y, Ki.y = i * vi.x + r * vi.y) : Ki.copy(vi), s.copy(e), s.x += Ki.x, s.y += Ki.y, s.applyMatrix4(Mh); +function fr(s1, t, e, n, i, r) { + Ni.subVectors(s1, e).addScalar(.5).multiply(n), i !== void 0 ? (fs.x = r * Ni.x - i * Ni.y, fs.y = i * Ni.x + r * Ni.y) : fs.copy(Ni), s1.copy(t), s1.x += fs.x, s1.y += fs.y, s1.applyMatrix4(Ed); } -var fs = new M, Kl = new M, bh = class extends Ne { +var pr = new A, Th = new A, Co = class extends Zt { constructor(){ - super(); - this._currentLevel = 0, this.type = "LOD", Object.defineProperties(this, { + super(), this._currentLevel = 0, this.type = "LOD", Object.defineProperties(this, { levels: { enumerable: !0, value: [] @@ -11867,254 +13458,282 @@ var fs = new M, Kl = new M, bh = class extends Ne { } }), this.autoUpdate = !0; } - copy(e) { - super.copy(e, !1); - let t = e.levels; - for(let n = 0, i = t.length; n < i; n++){ - let r = t[n]; - this.addLevel(r.object.clone(), r.distance); + copy(t) { + super.copy(t, !1); + let e = t.levels; + for(let n = 0, i = e.length; n < i; n++){ + let r = e[n]; + this.addLevel(r.object.clone(), r.distance, r.hysteresis); } - return this.autoUpdate = e.autoUpdate, this; + return this.autoUpdate = t.autoUpdate, this; } - addLevel(e, t = 0) { - t = Math.abs(t); - let n = this.levels, i; - for(i = 0; i < n.length && !(t < n[i].distance); i++); - return n.splice(i, 0, { - distance: t, - object: e - }), this.add(e), this; + addLevel(t, e = 0, n = 0) { + e = Math.abs(e); + let i = this.levels, r; + for(r = 0; r < i.length && !(e < i[r].distance); r++); + return i.splice(r, 0, { + distance: e, + hysteresis: n, + object: t + }), this.add(t), this; } getCurrentLevel() { return this._currentLevel; } - getObjectForDistance(e) { - let t = this.levels; - if (t.length > 0) { + getObjectForDistance(t) { + let e = this.levels; + if (e.length > 0) { let n, i; - for(n = 1, i = t.length; n < i && !(e < t[n].distance); n++); - return t[n - 1].object; + for(n = 1, i = e.length; n < i; n++){ + let r = e[n].distance; + if (e[n].object.visible && (r -= r * e[n].hysteresis), t < r) break; + } + return e[n - 1].object; } return null; } - raycast(e, t) { + raycast(t, e) { if (this.levels.length > 0) { - fs.setFromMatrixPosition(this.matrixWorld); - let i = e.ray.origin.distanceTo(fs); - this.getObjectForDistance(i).raycast(e, t); + pr.setFromMatrixPosition(this.matrixWorld); + let i = t.ray.origin.distanceTo(pr); + this.getObjectForDistance(i).raycast(t, e); } } - update(e) { - let t = this.levels; - if (t.length > 1) { - fs.setFromMatrixPosition(e.matrixWorld), Kl.setFromMatrixPosition(this.matrixWorld); - let n = fs.distanceTo(Kl) / e.zoom; - t[0].object.visible = !0; + update(t) { + let e = this.levels; + if (e.length > 1) { + pr.setFromMatrixPosition(t.matrixWorld), Th.setFromMatrixPosition(this.matrixWorld); + let n = pr.distanceTo(Th) / t.zoom; + e[0].object.visible = !0; let i, r; - for(i = 1, r = t.length; i < r && n >= t[i].distance; i++)t[i - 1].object.visible = !1, t[i].object.visible = !0; - for(this._currentLevel = i - 1; i < r; i++)t[i].object.visible = !1; + for(i = 1, r = e.length; i < r; i++){ + let a = e[i].distance; + if (e[i].object.visible && (a -= a * e[i].hysteresis), n >= a) e[i - 1].object.visible = !1, e[i].object.visible = !0; + else break; + } + for(this._currentLevel = i - 1; i < r; i++)e[i].object.visible = !1; } } - toJSON(e) { - let t = super.toJSON(e); - this.autoUpdate === !1 && (t.object.autoUpdate = !1), t.object.levels = []; + toJSON(t) { + let e = super.toJSON(t); + this.autoUpdate === !1 && (e.object.autoUpdate = !1), e.object.levels = []; let n = this.levels; for(let i = 0, r = n.length; i < r; i++){ - let o = n[i]; - t.object.levels.push({ - object: o.object.uuid, - distance: o.distance + let a = n[i]; + e.object.levels.push({ + object: a.object.uuid, + distance: a.distance, + hysteresis: a.hysteresis }); } - return t; + return e; } -}, ec = new M, tc = new Ve, nc = new Ve, Rx = new M, ic = new pe, so = class extends st { - constructor(e, t){ - super(e, t); - this.type = "SkinnedMesh", this.bindMode = "attached", this.bindMatrix = new pe, this.bindMatrixInverse = new pe; +}, wh = new A, Ah = new $t, Rh = new $t, H0 = new A, Ch = new Ot, Fi = new A, Ja = new We, Ph = new Ot, $a = new hi, Po = class extends ve { + constructor(t, e){ + super(t, e), this.isSkinnedMesh = !0, this.type = "SkinnedMesh", this.bindMode = "attached", this.bindMatrix = new Ot, this.bindMatrixInverse = new Ot, this.boundingBox = null, this.boundingSphere = null; } - copy(e) { - return super.copy(e), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, this; + computeBoundingBox() { + let t = this.geometry; + this.boundingBox === null && (this.boundingBox = new Ke), this.boundingBox.makeEmpty(); + let e = t.getAttribute("position"); + for(let n = 0; n < e.count; n++)Fi.fromBufferAttribute(e, n), this.applyBoneTransform(n, Fi), this.boundingBox.expandByPoint(Fi); + } + computeBoundingSphere() { + let t = this.geometry; + this.boundingSphere === null && (this.boundingSphere = new We), this.boundingSphere.makeEmpty(); + let e = t.getAttribute("position"); + for(let n = 0; n < e.count; n++)Fi.fromBufferAttribute(e, n), this.applyBoneTransform(n, Fi), this.boundingSphere.expandByPoint(Fi); + } + copy(t, e) { + return super.copy(t, e), this.bindMode = t.bindMode, this.bindMatrix.copy(t.bindMatrix), this.bindMatrixInverse.copy(t.bindMatrixInverse), this.skeleton = t.skeleton, t.boundingBox !== null && (this.boundingBox = t.boundingBox.clone()), t.boundingSphere !== null && (this.boundingSphere = t.boundingSphere.clone()), this; } - bind(e, t) { - this.skeleton = e, t === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), t = this.matrixWorld), this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert(); + raycast(t, e) { + let n = this.material, i = this.matrixWorld; + n !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), Ja.copy(this.boundingSphere), Ja.applyMatrix4(i), t.ray.intersectsSphere(Ja) !== !1 && (Ph.copy(i).invert(), $a.copy(t.ray).applyMatrix4(Ph), !(this.boundingBox !== null && $a.intersectsBox(this.boundingBox) === !1) && this._computeIntersections(t, e, $a))); + } + getVertexPosition(t, e) { + return super.getVertexPosition(t, e), this.applyBoneTransform(t, e), e; + } + bind(t, e) { + this.skeleton = t, e === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), e = this.matrixWorld), this.bindMatrix.copy(e), this.bindMatrixInverse.copy(e).invert(); } pose() { this.skeleton.pose(); } normalizeSkinWeights() { - let e = new Ve, t = this.geometry.attributes.skinWeight; - for(let n = 0, i = t.count; n < i; n++){ - e.x = t.getX(n), e.y = t.getY(n), e.z = t.getZ(n), e.w = t.getW(n); - let r = 1 / e.manhattanLength(); - r !== 1 / 0 ? e.multiplyScalar(r) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w); + let t = new $t, e = this.geometry.attributes.skinWeight; + for(let n = 0, i = e.count; n < i; n++){ + t.fromBufferAttribute(e, n); + let r = 1 / t.manhattanLength(); + r !== 1 / 0 ? t.multiplyScalar(r) : t.set(1, 0, 0, 0), e.setXYZW(n, t.x, t.y, t.z, t.w); } } - updateMatrixWorld(e) { - super.updateMatrixWorld(e), this.bindMode === "attached" ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === "detached" ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode); + updateMatrixWorld(t) { + super.updateMatrixWorld(t), this.bindMode === "attached" ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === "detached" ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode); } - boneTransform(e, t) { + applyBoneTransform(t, e) { let n = this.skeleton, i = this.geometry; - tc.fromBufferAttribute(i.attributes.skinIndex, e), nc.fromBufferAttribute(i.attributes.skinWeight, e), ec.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0); + Ah.fromBufferAttribute(i.attributes.skinIndex, t), Rh.fromBufferAttribute(i.attributes.skinWeight, t), wh.copy(e).applyMatrix4(this.bindMatrix), e.set(0, 0, 0); for(let r = 0; r < 4; r++){ - let o = nc.getComponent(r); - if (o !== 0) { - let a = tc.getComponent(r); - ic.multiplyMatrices(n.bones[a].matrixWorld, n.boneInverses[a]), t.addScaledVector(Rx.copy(ec).applyMatrix4(ic), o); + let a = Rh.getComponent(r); + if (a !== 0) { + let o = Ah.getComponent(r); + Ch.multiplyMatrices(n.bones[o].matrixWorld, n.boneInverses[o]), e.addScaledVector(H0.copy(wh).applyMatrix4(Ch), a); } } - return t.applyMatrix4(this.bindMatrixInverse); + return e.applyMatrix4(this.bindMatrixInverse); } -}; -so.prototype.isSkinnedMesh = !0; -var oo = class extends Ne { + boneTransform(t, e) { + return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."), this.applyBoneTransform(t, e); + } +}, jr = class extends Zt { constructor(){ - super(); - this.type = "Bone"; + super(), this.isBone = !0, this.type = "Bone"; } -}; -oo.prototype.isBone = !0; -var qn = class extends ot { - constructor(e = null, t = 1, n = 1, i, r, o, a, l, c = rt, h = rt, u, d){ - super(null, o, a, l, c, h, i, r, u, d); - this.image = { - data: e, - width: t, +}, oi = class extends ye { + constructor(t = null, e = 1, n = 1, i, r, a, o, c, l = fe, h = fe, u, d){ + super(null, a, o, c, l, h, i, r, u, d), this.isDataTexture = !0, this.image = { + data: t, + width: e, height: n - }, this.magFilter = c, this.minFilter = h, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; + }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; } -}; -qn.prototype.isDataTexture = !0; -var rc = new pe, Px = new pe, ao = class { - constructor(e = [], t = []){ - this.uuid = Et(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.boneTextureSize = 0, this.frame = -1, this.init(); +}, Lh = new Ot, G0 = new Ot, Lo = class s1 { + constructor(t = [], e = []){ + this.uuid = Be(), this.bones = t.slice(0), this.boneInverses = e, this.boneMatrices = null, this.boneTexture = null, this.boneTextureSize = 0, this.init(); } init() { - let e = this.bones, t = this.boneInverses; - if (this.boneMatrices = new Float32Array(e.length * 16), t.length === 0) this.calculateInverses(); - else if (e.length !== t.length) { + let t = this.bones, e = this.boneInverses; + if (this.boneMatrices = new Float32Array(t.length * 16), e.length === 0) this.calculateInverses(); + else if (t.length !== e.length) { console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = []; - for(let n = 0, i = this.bones.length; n < i; n++)this.boneInverses.push(new pe); + for(let n = 0, i = this.bones.length; n < i; n++)this.boneInverses.push(new Ot); } } calculateInverses() { this.boneInverses.length = 0; - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = new pe; - this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n); + for(let t = 0, e = this.bones.length; t < e; t++){ + let n = new Ot; + this.bones[t] && n.copy(this.bones[t].matrixWorld).invert(), this.boneInverses.push(n); } } pose() { - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = this.bones[e]; - n && n.matrixWorld.copy(this.boneInverses[e]).invert(); + for(let t = 0, e = this.bones.length; t < e; t++){ + let n = this.bones[t]; + n && n.matrixWorld.copy(this.boneInverses[t]).invert(); } - for(let e = 0, t = this.bones.length; e < t; e++){ - let n = this.bones[e]; + for(let t = 0, e = this.bones.length; t < e; t++){ + let n = this.bones[t]; n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale)); } } update() { - let e = this.bones, t = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; - for(let r = 0, o = e.length; r < o; r++){ - let a = e[r] ? e[r].matrixWorld : Px; - rc.multiplyMatrices(a, t[r]), rc.toArray(n, r * 16); + let t = this.bones, e = this.boneInverses, n = this.boneMatrices, i = this.boneTexture; + for(let r = 0, a = t.length; r < a; r++){ + let o = t[r] ? t[r].matrixWorld : G0; + Lh.multiplyMatrices(o, e[r]), Lh.toArray(n, r * 16); } i !== null && (i.needsUpdate = !0); } clone() { - return new ao(this.bones, this.boneInverses); + return new s1(this.bones, this.boneInverses); } computeBoneTexture() { - let e = Math.sqrt(this.bones.length * 4); - e = Xc(e), e = Math.max(e, 4); - let t = new Float32Array(e * e * 4); - t.set(this.boneMatrices); - let n = new qn(t, e, e, ct, nn); - return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this.boneTextureSize = e, this; + let t = Math.sqrt(this.bones.length * 4); + t = md(t), t = Math.max(t, 4); + let e = new Float32Array(t * t * 4); + e.set(this.boneMatrices); + let n = new oi(e, t, t, He, xn); + return n.needsUpdate = !0, this.boneMatrices = e, this.boneTexture = n, this.boneTextureSize = t, this; } - getBoneByName(e) { - for(let t = 0, n = this.bones.length; t < n; t++){ - let i = this.bones[t]; - if (i.name === e) return i; + getBoneByName(t) { + for(let e = 0, n = this.bones.length; e < n; e++){ + let i = this.bones[e]; + if (i.name === t) return i; } } dispose() { this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null); } - fromJSON(e, t) { - this.uuid = e.uuid; - for(let n = 0, i = e.bones.length; n < i; n++){ - let r = e.bones[n], o = t[r]; - o === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", r), o = new oo), this.bones.push(o), this.boneInverses.push(new pe().fromArray(e.boneInverses[n])); + fromJSON(t, e) { + this.uuid = t.uuid; + for(let n = 0, i = t.bones.length; n < i; n++){ + let r = t.bones[n], a = e[r]; + a === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", r), a = new jr), this.bones.push(a), this.boneInverses.push(new Ot().fromArray(t.boneInverses[n])); } return this.init(), this; } toJSON() { - let e = { + let t = { metadata: { - version: 4.5, + version: 4.6, type: "Skeleton", generator: "Skeleton.toJSON" }, bones: [], boneInverses: [] }; - e.uuid = this.uuid; - let t = this.bones, n = this.boneInverses; - for(let i = 0, r = t.length; i < r; i++){ - let o = t[i]; - e.bones.push(o.uuid); - let a = n[i]; - e.boneInverses.push(a.toArray()); + t.uuid = this.uuid; + let e = this.bones, n = this.boneInverses; + for(let i = 0, r = e.length; i < r; i++){ + let a = e[i]; + t.bones.push(a.uuid); + let o = n[i]; + t.boneInverses.push(o.toArray()); } - return e; + return t; } -}, Xn = class extends Ue { - constructor(e, t, n, i = 1){ - typeof n == "number" && (i = n, n = !1, console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")); - super(e, t, n); - this.meshPerAttribute = i; +}, ui = class extends Kt { + constructor(t, e, n, i = 1){ + super(t, e, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = i; } - copy(e) { - return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; + copy(t) { + return super.copy(t), this.meshPerAttribute = t.meshPerAttribute, this; } toJSON() { - let e = super.toJSON(); - return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e; + let t = super.toJSON(); + return t.meshPerAttribute = this.meshPerAttribute, t.isInstancedBufferAttribute = !0, t; } -}; -Xn.prototype.isInstancedBufferAttribute = !0; -var sc = new pe, oc = new pe, ps = [], tr = new st, xa = class extends st { - constructor(e, t, n){ - super(e, t); - this.instanceMatrix = new Xn(new Float32Array(n * 16), 16), this.instanceColor = null, this.count = n, this.frustumCulled = !1; +}, Oi = new Ot, Ih = new Ot, mr = [], Uh = new Ke, W0 = new Ot, ms = new ve, gs = new We, Io = class extends ve { + constructor(t, e, n){ + super(t, e), this.isInstancedMesh = !0, this.instanceMatrix = new ui(new Float32Array(n * 16), 16), this.instanceColor = null, this.count = n, this.boundingBox = null, this.boundingSphere = null; + for(let i = 0; i < n; i++)this.setMatrixAt(i, W0); } - copy(e) { - return super.copy(e), this.instanceMatrix.copy(e.instanceMatrix), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, this; + computeBoundingBox() { + let t = this.geometry, e = this.count; + this.boundingBox === null && (this.boundingBox = new Ke), t.boundingBox === null && t.computeBoundingBox(), this.boundingBox.makeEmpty(); + for(let n = 0; n < e; n++)this.getMatrixAt(n, Oi), Uh.copy(t.boundingBox).applyMatrix4(Oi), this.boundingBox.union(Uh); } - getColorAt(e, t) { - t.fromArray(this.instanceColor.array, e * 3); + computeBoundingSphere() { + let t = this.geometry, e = this.count; + this.boundingSphere === null && (this.boundingSphere = new We), t.boundingSphere === null && t.computeBoundingSphere(), this.boundingSphere.makeEmpty(); + for(let n = 0; n < e; n++)this.getMatrixAt(n, Oi), gs.copy(t.boundingSphere).applyMatrix4(Oi), this.boundingSphere.union(gs); } - getMatrixAt(e, t) { - t.fromArray(this.instanceMatrix.array, e * 16); + copy(t, e) { + return super.copy(t, e), this.instanceMatrix.copy(t.instanceMatrix), t.instanceColor !== null && (this.instanceColor = t.instanceColor.clone()), this.count = t.count, t.boundingBox !== null && (this.boundingBox = t.boundingBox.clone()), t.boundingSphere !== null && (this.boundingSphere = t.boundingSphere.clone()), this; } - raycast(e, t) { - let n = this.matrixWorld, i = this.count; - if (tr.geometry = this.geometry, tr.material = this.material, tr.material !== void 0) for(let r = 0; r < i; r++){ - this.getMatrixAt(r, sc), oc.multiplyMatrices(n, sc), tr.matrixWorld = oc, tr.raycast(e, ps); - for(let o = 0, a = ps.length; o < a; o++){ - let l = ps[o]; - l.instanceId = r, l.object = this, t.push(l); + getColorAt(t, e) { + e.fromArray(this.instanceColor.array, t * 3); + } + getMatrixAt(t, e) { + e.fromArray(this.instanceMatrix.array, t * 16); + } + raycast(t, e) { + let n = this.matrixWorld, i = this.count; + if (ms.geometry = this.geometry, ms.material = this.material, ms.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), gs.copy(this.boundingSphere), gs.applyMatrix4(n), t.ray.intersectsSphere(gs) !== !1)) for(let r = 0; r < i; r++){ + this.getMatrixAt(r, Oi), Ih.multiplyMatrices(n, Oi), ms.matrixWorld = Ih, ms.raycast(t, mr); + for(let a = 0, o = mr.length; a < o; a++){ + let c = mr[a]; + c.instanceId = r, c.object = this, e.push(c); } - ps.length = 0; + mr.length = 0; } } - setColorAt(e, t) { - this.instanceColor === null && (this.instanceColor = new Xn(new Float32Array(this.instanceMatrix.count * 3), 3)), t.toArray(this.instanceColor.array, e * 3); + setColorAt(t, e) { + this.instanceColor === null && (this.instanceColor = new ui(new Float32Array(this.instanceMatrix.count * 3), 3)), e.toArray(this.instanceColor.array, t * 3); } - setMatrixAt(e, t) { - t.toArray(this.instanceMatrix.array, e * 16); + setMatrixAt(t, e) { + e.toArray(this.instanceMatrix.array, t * 16); } updateMorphTargets() {} dispose() { @@ -12122,424 +13741,983 @@ var sc = new pe, oc = new pe, ps = [], tr = new st, xa = class extends st { type: "dispose" }); } -}; -xa.prototype.isInstancedMesh = !0; -var ft = class extends dt { - constructor(e){ - super(); - this.type = "LineBasicMaterial", this.color = new ae(16777215), this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.setValues(e); +}, Ee = class extends Me { + constructor(t){ + super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new ft(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(t); } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this; + 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; } -}; -ft.prototype.isLineBasicMaterial = !0; -var ac = new M, lc = new M, cc = new pe, Xo = new Cn, ms = new An, on = class extends Ne { - constructor(e = new _e, t = new ft){ - super(); - this.type = "Line", this.geometry = e, this.material = t, this.updateMorphTargets(); +}, Dh = new A, Nh = new A, Fh = new Ot, Ka = new hi, gr = new We, Sn = class extends Zt { + constructor(t = new Vt, e = new Ee){ + super(), this.isLine = !0, this.type = "Line", this.geometry = t, this.material = e, this.updateMorphTargets(); } - copy(e) { - return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; + copy(t, e) { + return super.copy(t, e), this.material = t.material, this.geometry = t.geometry, this; } computeLineDistances() { - let e = this.geometry; - if (e.isBufferGeometry) if (e.index === null) { - let t = e.attributes.position, n = [ + let t = this.geometry; + if (t.index === null) { + let e = t.attributes.position, n = [ 0 ]; - for(let i = 1, r = t.count; i < r; i++)ac.fromBufferAttribute(t, i - 1), lc.fromBufferAttribute(t, i), n[i] = n[i - 1], n[i] += ac.distanceTo(lc); - e.setAttribute("lineDistance", new de(n, 1)); + for(let i = 1, r = e.count; i < r; i++)Dh.fromBufferAttribute(e, i - 1), Nh.fromBufferAttribute(e, i), n[i] = n[i - 1], n[i] += Dh.distanceTo(Nh); + t.setAttribute("lineDistance", new _t(n, 1)); } else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); - else e.isGeometry && console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); return this; } - raycast(e, t) { - let n = this.geometry, i = this.matrixWorld, r = e.params.Line.threshold, o = n.drawRange; - if (n.boundingSphere === null && n.computeBoundingSphere(), ms.copy(n.boundingSphere), ms.applyMatrix4(i), ms.radius += r, e.ray.intersectsSphere(ms) === !1) return; - cc.copy(i).invert(), Xo.copy(e.ray).applyMatrix4(cc); - let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a, c = new M, h = new M, u = new M, d = new M, f = this.isLineSegments ? 2 : 1; - if (n.isBufferGeometry) { - let m = n.index, v = n.attributes.position; - if (m !== null) { - let g = Math.max(0, o.start), p = Math.min(m.count, o.start + o.count); - for(let _ = g, y = p - 1; _ < y; _ += f){ - let b = m.getX(_), A = m.getX(_ + 1); - if (c.fromBufferAttribute(v, b), h.fromBufferAttribute(v, A), Xo.distanceSqToSegment(c, h, d, u) > l) continue; - d.applyMatrix4(this.matrixWorld); - let I = e.ray.origin.distanceTo(d); - I < e.near || I > e.far || t.push({ - distance: I, - point: u.clone().applyMatrix4(this.matrixWorld), - index: _, - face: null, - faceIndex: null, - object: this - }); - } - } else { - let g = Math.max(0, o.start), p = Math.min(v.count, o.start + o.count); - for(let _ = g, y = p - 1; _ < y; _ += f){ - if (c.fromBufferAttribute(v, _), h.fromBufferAttribute(v, _ + 1), Xo.distanceSqToSegment(c, h, d, u) > l) continue; - d.applyMatrix4(this.matrixWorld); - let A = e.ray.origin.distanceTo(d); - A < e.near || A > e.far || t.push({ - distance: A, - point: u.clone().applyMatrix4(this.matrixWorld), - index: _, - face: null, - faceIndex: null, - object: this - }); - } + raycast(t, e) { + let n = this.geometry, i = this.matrixWorld, r = t.params.Line.threshold, a = n.drawRange; + if (n.boundingSphere === null && n.computeBoundingSphere(), gr.copy(n.boundingSphere), gr.applyMatrix4(i), gr.radius += r, t.ray.intersectsSphere(gr) === !1) return; + Fh.copy(i).invert(), Ka.copy(t.ray).applyMatrix4(Fh); + let o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), c = o * o, l = new A, h = new A, u = new A, d = new A, f = this.isLineSegments ? 2 : 1, m = n.index, g = n.attributes.position; + if (m !== null) { + let p = Math.max(0, a.start), v = Math.min(m.count, a.start + a.count); + for(let _ = p, y = v - 1; _ < y; _ += f){ + let b = m.getX(_), w = m.getX(_ + 1); + if (l.fromBufferAttribute(g, b), h.fromBufferAttribute(g, w), Ka.distanceSqToSegment(l, h, d, u) > c) continue; + d.applyMatrix4(this.matrixWorld); + let L = t.ray.origin.distanceTo(d); + L < t.near || L > t.far || e.push({ + distance: L, + point: u.clone().applyMatrix4(this.matrixWorld), + index: _, + face: null, + faceIndex: null, + object: this + }); + } + } else { + let p = Math.max(0, a.start), v = Math.min(g.count, a.start + a.count); + for(let _ = p, y = v - 1; _ < y; _ += f){ + if (l.fromBufferAttribute(g, _), h.fromBufferAttribute(g, _ + 1), Ka.distanceSqToSegment(l, h, d, u) > c) continue; + d.applyMatrix4(this.matrixWorld); + let w = t.ray.origin.distanceTo(d); + w < t.near || w > t.far || e.push({ + distance: w, + point: u.clone().applyMatrix4(this.matrixWorld), + index: _, + face: null, + faceIndex: null, + object: this + }); } - } else n.isGeometry && console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } } updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } + let e = this.geometry.morphAttributes, n = Object.keys(e); + if (n.length > 0) { + let i = e[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, a = i.length; r < a; r++){ + let o = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); } } -}; -on.prototype.isLine = !0; -var hc = new M, uc = new M, wt = class extends on { - constructor(e, t){ - super(e, t); - this.type = "LineSegments"; +}, Oh = new A, Bh = new A, je = class extends Sn { + constructor(t, e){ + super(t, e), this.isLineSegments = !0, this.type = "LineSegments"; } computeLineDistances() { - let e = this.geometry; - if (e.isBufferGeometry) if (e.index === null) { - let t = e.attributes.position, n = []; - for(let i = 0, r = t.count; i < r; i += 2)hc.fromBufferAttribute(t, i), uc.fromBufferAttribute(t, i + 1), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + hc.distanceTo(uc); - e.setAttribute("lineDistance", new de(n, 1)); + let t = this.geometry; + if (t.index === null) { + let e = t.attributes.position, n = []; + for(let i = 0, r = e.count; i < r; i += 2)Oh.fromBufferAttribute(e, i), Bh.fromBufferAttribute(e, i + 1), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + Oh.distanceTo(Bh); + t.setAttribute("lineDistance", new _t(n, 1)); } else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); - else e.isGeometry && console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); return this; } -}; -wt.prototype.isLineSegments = !0; -var ya = class extends on { - constructor(e, t){ - super(e, t); - this.type = "LineLoop"; - } -}; -ya.prototype.isLineLoop = !0; -var jn = class extends dt { - constructor(e){ - super(); - this.type = "PointsMaterial", this.color = new ae(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this; - } -}; -jn.prototype.isPointsMaterial = !0; -var dc = new pe, sa = new Cn, gs = new An, xs = new M, zr = class extends Ne { - constructor(e = new _e, t = new jn){ - super(); - this.type = "Points", this.geometry = e, this.material = t, this.updateMorphTargets(); - } - copy(e) { - return super.copy(e), this.material = e.material, this.geometry = e.geometry, this; - } - raycast(e, t) { - let n = this.geometry, i = this.matrixWorld, r = e.params.Points.threshold, o = n.drawRange; - if (n.boundingSphere === null && n.computeBoundingSphere(), gs.copy(n.boundingSphere), gs.applyMatrix4(i), gs.radius += r, e.ray.intersectsSphere(gs) === !1) return; - dc.copy(i).invert(), sa.copy(e.ray).applyMatrix4(dc); - let a = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), l = a * a; - if (n.isBufferGeometry) { - let c = n.index, u = n.attributes.position; - if (c !== null) { - let d = Math.max(0, o.start), f = Math.min(c.count, o.start + o.count); - for(let m = d, x = f; m < x; m++){ - let v = c.getX(m); - xs.fromBufferAttribute(u, v), fc(xs, v, l, i, e, t, this); - } - } else { - let d = Math.max(0, o.start), f = Math.min(u.count, o.start + o.count); - for(let m = d, x = f; m < x; m++)xs.fromBufferAttribute(u, m), fc(xs, m, l, i, e, t, this); +}, Uo = class extends Sn { + constructor(t, e){ + super(t, e), this.isLineLoop = !0, this.type = "LineLoop"; + } +}, ta = class extends Me { + constructor(t){ + super(), this.isPointsMaterial = !0, this.type = "PointsMaterial", this.color = new ft(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.fog = !0, this.setValues(t); + } + copy(t) { + return super.copy(t), this.color.copy(t.color), this.map = t.map, this.alphaMap = t.alphaMap, this.size = t.size, this.sizeAttenuation = t.sizeAttenuation, this.fog = t.fog, this; + } +}, zh = new Ot, Do = new hi, _r = new We, xr = new A, No = class extends Zt { + constructor(t = new Vt, e = new ta){ + super(), this.isPoints = !0, this.type = "Points", this.geometry = t, this.material = e, this.updateMorphTargets(); + } + copy(t, e) { + return super.copy(t, e), this.material = t.material, this.geometry = t.geometry, this; + } + raycast(t, e) { + let n = this.geometry, i = this.matrixWorld, r = t.params.Points.threshold, a = n.drawRange; + if (n.boundingSphere === null && n.computeBoundingSphere(), _r.copy(n.boundingSphere), _r.applyMatrix4(i), _r.radius += r, t.ray.intersectsSphere(_r) === !1) return; + zh.copy(i).invert(), Do.copy(t.ray).applyMatrix4(zh); + let o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), c = o * o, l = n.index, u = n.attributes.position; + if (l !== null) { + let d = Math.max(0, a.start), f = Math.min(l.count, a.start + a.count); + for(let m = d, x = f; m < x; m++){ + let g = l.getX(m); + xr.fromBufferAttribute(u, g), kh(xr, g, c, i, t, e, this); } - } else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."); + } else { + let d = Math.max(0, a.start), f = Math.min(u.count, a.start + a.count); + for(let m = d, x = f; m < x; m++)xr.fromBufferAttribute(u, m), kh(xr, m, c, i, t, e, this); + } } updateMorphTargets() { - let e = this.geometry; - if (e.isBufferGeometry) { - let t = e.morphAttributes, n = Object.keys(t); - if (n.length > 0) { - let i = t[n[0]]; - if (i !== void 0) { - this.morphTargetInfluences = [], this.morphTargetDictionary = {}; - for(let r = 0, o = i.length; r < o; r++){ - let a = i[r].name || String(r); - this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = r; - } + let e = this.geometry.morphAttributes, n = Object.keys(e); + if (n.length > 0) { + let i = e[n[0]]; + if (i !== void 0) { + this.morphTargetInfluences = [], this.morphTargetDictionary = {}; + for(let r = 0, a = i.length; r < a; r++){ + let o = i[r].name || String(r); + this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r; } } - } else { - let t = e.morphTargets; - t !== void 0 && t.length > 0 && console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead."); } } }; -zr.prototype.isPoints = !0; -function fc(s, e, t, n, i, r, o) { - let a = sa.distanceSqToPoint(s); - if (a < t) { - let l = new M; - sa.closestPointToPoint(s, l), l.applyMatrix4(n); - let c = i.ray.origin.distanceTo(l); - if (c < i.near || c > i.far) return; +function kh(s1, t, e, n, i, r, a) { + let o = Do.distanceSqToPoint(s1); + if (o < e) { + let c = new A; + Do.closestPointToPoint(s1, c), c.applyMatrix4(n); + let l = i.ray.origin.distanceTo(c); + if (l < i.near || l > i.far) return; r.push({ - distance: c, - distanceToRay: Math.sqrt(a), - point: l, - index: e, + distance: l, + distanceToRay: Math.sqrt(o), + point: c, + index: t, face: null, - object: o + object: a }); } } -var wh = class extends ot { - constructor(e, t, n, i, r, o, a, l, c){ - super(e, t, n, i, r, o, a, l, c); - this.format = a !== void 0 ? a : Gn, this.minFilter = o !== void 0 ? o : tt, this.magFilter = r !== void 0 ? r : tt, this.generateMipmaps = !1; +var Vh = class extends ye { + constructor(t, e, n, i, r, a, o, c, l){ + super(t, e, n, i, r, a, o, c, l), this.isVideoTexture = !0, this.minFilter = a !== void 0 ? a : pe, this.magFilter = r !== void 0 ? r : pe, this.generateMipmaps = !1; let h = this; function u() { - h.needsUpdate = !0, e.requestVideoFrameCallback(u); + h.needsUpdate = !0, t.requestVideoFrameCallback(u); } - "requestVideoFrameCallback" in e && e.requestVideoFrameCallback(u); + "requestVideoFrameCallback" in t && t.requestVideoFrameCallback(u); } clone() { return new this.constructor(this.image).copy(this); } update() { - let e = this.image; - "requestVideoFrameCallback" in e === !1 && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0); + let t = this.image; + "requestVideoFrameCallback" in t === !1 && t.readyState >= t.HAVE_CURRENT_DATA && (this.needsUpdate = !0); } -}; -wh.prototype.isVideoTexture = !0; -var Sh = class extends ot { - constructor(e, t, n){ +}, Hh = class extends ye { + constructor(t, e){ super({ - width: e, - height: t - }); - this.format = n, this.magFilter = rt, this.minFilter = rt, this.generateMipmaps = !1, this.needsUpdate = !0; - } -}; -Sh.prototype.isFramebufferTexture = !0; -var va = class extends ot { - constructor(e, t, n, i, r, o, a, l, c, h, u, d){ - super(null, o, a, l, c, h, i, r, u, d); - this.image = { width: t, + height: e + }), this.isFramebufferTexture = !0, this.magFilter = fe, this.minFilter = fe, this.generateMipmaps = !1, this.needsUpdate = !0; + } +}, Us = class extends ye { + constructor(t, e, n, i, r, a, o, c, l, h, u, d){ + super(null, a, o, c, l, h, i, r, u, d), this.isCompressedTexture = !0, this.image = { + width: e, height: n - }, this.mipmaps = e, this.flipY = !1, this.generateMipmaps = !1; + }, this.mipmaps = t, this.flipY = !1, this.generateMipmaps = !1; } -}; -va.prototype.isCompressedTexture = !0; -var Th = class extends ot { - constructor(e, t, n, i, r, o, a, l, c){ - super(e, t, n, i, r, o, a, l, c); - this.needsUpdate = !0; +}, Gh = class extends Us { + constructor(t, e, n, i, r, a){ + super(t, e, n, r, a), this.isCompressedArrayTexture = !0, this.image.depth = i, this.wrapR = Ce; } -}; -Th.prototype.isCanvasTexture = !0; -var fr = class extends _e { - constructor(e = 1, t = 8, n = 0, i = Math.PI * 2){ - super(); - this.type = "CircleGeometry", this.parameters = { - radius: e, - segments: t, - thetaStart: n, - thetaLength: i - }, t = Math.max(3, t); - let r = [], o = [], a = [], l = [], c = new M, h = new X; - o.push(0, 0, 0), a.push(0, 0, 1), l.push(.5, .5); - for(let u = 0, d = 3; u <= t; u++, d += 3){ - let f = n + u / t * i; - c.x = e * Math.cos(f), c.y = e * Math.sin(f), o.push(c.x, c.y, c.z), a.push(0, 0, 1), h.x = (o[d] / e + 1) / 2, h.y = (o[d + 1] / e + 1) / 2, l.push(h.x, h.y); - } - for(let u = 1; u <= t; u++)r.push(u, u + 1, 0); - this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("normal", new de(a, 3)), this.setAttribute("uv", new de(l, 2)); +}, Wh = class extends Us { + constructor(t, e, n){ + super(void 0, t[0].width, t[0].height, e, n, Bn), this.isCompressedCubeTexture = !0, this.isCubeTexture = !0, this.image = t; } - static fromJSON(e) { - return new fr(e.radius, e.segments, e.thetaStart, e.thetaLength); +}, Xh = class extends ye { + constructor(t, e, n, i, r, a, o, c, l){ + super(t, e, n, i, r, a, o, c, l), this.isCanvasTexture = !0, this.needsUpdate = !0; } -}, Jn = class extends _e { - constructor(e = 1, t = 1, n = 1, i = 8, r = 1, o = !1, a = 0, l = Math.PI * 2){ - super(); - this.type = "CylinderGeometry", this.parameters = { - radiusTop: e, - radiusBottom: t, - height: n, - radialSegments: i, - heightSegments: r, - openEnded: o, - thetaStart: a, - thetaLength: l - }; - let c = this; - i = Math.floor(i), r = Math.floor(r); - let h = [], u = [], d = [], f = [], m = 0, x = [], v = n / 2, g = 0; - p(), o === !1 && (e > 0 && _(!0), t > 0 && _(!1)), this.setIndex(h), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); - function p() { - let y = new M, b = new M, A = 0, L = (t - e) / n; - for(let I = 0; I <= r; I++){ - let k = [], B = I / r, P = B * (t - e) + e; - for(let w = 0; w <= i; w++){ - let E = w / i, D = E * l + a, U = Math.sin(D), F = Math.cos(D); - b.x = P * U, b.y = -B * n + v, b.z = P * F, u.push(b.x, b.y, b.z), y.set(U, L, F).normalize(), d.push(y.x, y.y, y.z), f.push(E, 1 - B), k.push(m++); - } - x.push(k); - } - for(let I = 0; I < i; I++)for(let k = 0; k < r; k++){ - let B = x[k][I], P = x[k + 1][I], w = x[k + 1][I + 1], E = x[k][I + 1]; - h.push(B, P, E), h.push(P, w, E), A += 6; - } - c.addGroup(g, A, 0), g += A; +}, Xe = class { + constructor(){ + this.type = "Curve", this.arcLengthDivisions = 200; + } + getPoint() { + return console.warn("THREE.Curve: .getPoint() not implemented."), null; + } + getPointAt(t, e) { + let n = this.getUtoTmapping(t); + return this.getPoint(n, e); + } + getPoints(t = 5) { + let e = []; + for(let n = 0; n <= t; n++)e.push(this.getPoint(n / t)); + return e; + } + getSpacedPoints(t = 5) { + let e = []; + for(let n = 0; n <= t; n++)e.push(this.getPointAt(n / t)); + return e; + } + getLength() { + let t = this.getLengths(); + return t[t.length - 1]; + } + getLengths(t = this.arcLengthDivisions) { + if (this.cacheArcLengths && this.cacheArcLengths.length === t + 1 && !this.needsUpdate) return this.cacheArcLengths; + this.needsUpdate = !1; + let e = [], n, i = this.getPoint(0), r = 0; + e.push(0); + for(let a = 1; a <= t; a++)n = this.getPoint(a / t), r += n.distanceTo(i), e.push(r), i = n; + return this.cacheArcLengths = e, e; + } + updateArcLengths() { + this.needsUpdate = !0, this.getLengths(); + } + getUtoTmapping(t, e) { + let n = this.getLengths(), i = 0, r = n.length, a; + e ? a = e : a = t * n[r - 1]; + let o = 0, c = r - 1, l; + for(; o <= c;)if (i = Math.floor(o + (c - o) / 2), l = n[i] - a, l < 0) o = i + 1; + else if (l > 0) c = i - 1; + else { + c = i; + break; } - function _(y) { - let b = m, A = new X, L = new M, I = 0, k = y === !0 ? e : t, B = y === !0 ? 1 : -1; - for(let w = 1; w <= i; w++)u.push(0, v * B, 0), d.push(0, B, 0), f.push(.5, .5), m++; - let P = m; - for(let w = 0; w <= i; w++){ - let D = w / i * l + a, U = Math.cos(D), F = Math.sin(D); - L.x = k * F, L.y = v * B, L.z = k * U, u.push(L.x, L.y, L.z), d.push(0, B, 0), A.x = U * .5 + .5, A.y = F * .5 * B + .5, f.push(A.x, A.y), m++; - } - for(let w = 0; w < i; w++){ - let E = b + w, D = P + w; - y === !0 ? h.push(D, D + 1, E) : h.push(D + 1, D, E), I += 3; + if (i = c, n[i] === a) return i / (r - 1); + let h = n[i], d = n[i + 1] - h, f = (a - h) / d; + return (i + f) / (r - 1); + } + getTangent(t, e) { + let i = t - 1e-4, r = t + 1e-4; + i < 0 && (i = 0), r > 1 && (r = 1); + let a = this.getPoint(i), o = this.getPoint(r), c = e || (a.isVector2 ? new J : new A); + return c.copy(o).sub(a).normalize(), c; + } + getTangentAt(t, e) { + let n = this.getUtoTmapping(t); + return this.getTangent(n, e); + } + computeFrenetFrames(t, e) { + let n = new A, i = [], r = [], a = [], o = new A, c = new Ot; + for(let f = 0; f <= t; f++){ + let m = f / t; + i[f] = this.getTangentAt(m, new A); + } + r[0] = new A, a[0] = new A; + let l = Number.MAX_VALUE, h = Math.abs(i[0].x), u = Math.abs(i[0].y), d = Math.abs(i[0].z); + h <= l && (l = h, n.set(1, 0, 0)), u <= l && (l = u, n.set(0, 1, 0)), d <= l && n.set(0, 0, 1), o.crossVectors(i[0], n).normalize(), r[0].crossVectors(i[0], o), a[0].crossVectors(i[0], r[0]); + for(let f = 1; f <= t; f++){ + if (r[f] = r[f - 1].clone(), a[f] = a[f - 1].clone(), o.crossVectors(i[f - 1], i[f]), o.length() > Number.EPSILON) { + o.normalize(); + let m = Math.acos(ae(i[f - 1].dot(i[f]), -1, 1)); + r[f].applyMatrix4(c.makeRotationAxis(o, m)); } - c.addGroup(g, I, y === !0 ? 1 : 2), g += I; + a[f].crossVectors(i[f], r[f]); } + if (e === !0) { + let f = Math.acos(ae(r[0].dot(r[t]), -1, 1)); + f /= t, i[0].dot(o.crossVectors(r[0], r[t])) > 0 && (f = -f); + for(let m = 1; m <= t; m++)r[m].applyMatrix4(c.makeRotationAxis(i[m], f * m)), a[m].crossVectors(i[m], r[m]); + } + return { + tangents: i, + normals: r, + binormals: a + }; } - static fromJSON(e) { - return new Jn(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + clone() { + return new this.constructor().copy(this); } -}, pr = class extends Jn { - constructor(e = 1, t = 1, n = 8, i = 1, r = !1, o = 0, a = Math.PI * 2){ - super(0, e, t, n, i, r, o, a); - this.type = "ConeGeometry", this.parameters = { - radius: e, - height: t, - radialSegments: n, - heightSegments: i, - openEnded: r, - thetaStart: o, - thetaLength: a + copy(t) { + return this.arcLengthDivisions = t.arcLengthDivisions, this; + } + toJSON() { + let t = { + metadata: { + version: 4.6, + type: "Curve", + generator: "Curve.toJSON" + } }; + return t.arcLengthDivisions = this.arcLengthDivisions, t.type = this.type, t; } - static fromJSON(e) { - return new pr(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); + fromJSON(t) { + return this.arcLengthDivisions = t.arcLengthDivisions, this; } -}, an = class extends _e { - constructor(e = [], t = [], n = 1, i = 0){ - super(); - this.type = "PolyhedronGeometry", this.parameters = { - vertices: e, - indices: t, - radius: n, - detail: i - }; - let r = [], o = []; - a(i), c(n), h(), this.setAttribute("position", new de(r, 3)), this.setAttribute("normal", new de(r.slice(), 3)), this.setAttribute("uv", new de(o, 2)), i === 0 ? this.computeVertexNormals() : this.normalizeNormals(); - function a(p) { - let _ = new M, y = new M, b = new M; - for(let A = 0; A < t.length; A += 3)f(t[A + 0], _), f(t[A + 1], y), f(t[A + 2], b), l(_, y, b, p); - } - function l(p, _, y, b) { - let A = b + 1, L = []; - for(let I = 0; I <= A; I++){ - L[I] = []; - let k = p.clone().lerp(y, I / A), B = _.clone().lerp(y, I / A), P = A - I; - for(let w = 0; w <= P; w++)w === 0 && I === A ? L[I][w] = k : L[I][w] = k.clone().lerp(B, w / P); - } - for(let I = 0; I < A; I++)for(let k = 0; k < 2 * (A - I) - 1; k++){ - let B = Math.floor(k / 2); - k % 2 === 0 ? (d(L[I][B + 1]), d(L[I + 1][B]), d(L[I][B])) : (d(L[I][B + 1]), d(L[I + 1][B + 1]), d(L[I + 1][B])); - } +}, Ds = class extends Xe { + constructor(t = 0, e = 0, n = 1, i = 1, r = 0, a = Math.PI * 2, o = !1, c = 0){ + super(), this.isEllipseCurve = !0, this.type = "EllipseCurve", this.aX = t, this.aY = e, this.xRadius = n, this.yRadius = i, this.aStartAngle = r, this.aEndAngle = a, this.aClockwise = o, this.aRotation = c; + } + getPoint(t, e) { + let n = e || new J, i = Math.PI * 2, r = this.aEndAngle - this.aStartAngle, a = Math.abs(r) < Number.EPSILON; + for(; r < 0;)r += i; + for(; r > i;)r -= i; + r < Number.EPSILON && (a ? r = 0 : r = i), this.aClockwise === !0 && !a && (r === i ? r = -i : r = r - i); + let o = this.aStartAngle + t * r, c = this.aX + this.xRadius * Math.cos(o), l = this.aY + this.yRadius * Math.sin(o); + if (this.aRotation !== 0) { + let h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), d = c - this.aX, f = l - this.aY; + c = d * h - f * u + this.aX, l = d * u + f * h + this.aY; + } + return n.set(c, l); + } + copy(t) { + return super.copy(t), this.aX = t.aX, this.aY = t.aY, this.xRadius = t.xRadius, this.yRadius = t.yRadius, this.aStartAngle = t.aStartAngle, this.aEndAngle = t.aEndAngle, this.aClockwise = t.aClockwise, this.aRotation = t.aRotation, this; + } + toJSON() { + let t = super.toJSON(); + return t.aX = this.aX, t.aY = this.aY, t.xRadius = this.xRadius, t.yRadius = this.yRadius, t.aStartAngle = this.aStartAngle, t.aEndAngle = this.aEndAngle, t.aClockwise = this.aClockwise, t.aRotation = this.aRotation, t; + } + fromJSON(t) { + return super.fromJSON(t), this.aX = t.aX, this.aY = t.aY, this.xRadius = t.xRadius, this.yRadius = t.yRadius, this.aStartAngle = t.aStartAngle, this.aEndAngle = t.aEndAngle, this.aClockwise = t.aClockwise, this.aRotation = t.aRotation, this; + } +}, Fo = class extends Ds { + constructor(t, e, n, i, r, a){ + super(t, e, n, n, i, r, a), this.isArcCurve = !0, this.type = "ArcCurve"; + } +}; +function Hc() { + let s1 = 0, t = 0, e = 0, n = 0; + function i(r, a, o, c) { + s1 = r, t = o, e = -3 * r + 3 * a - 2 * o - c, n = 2 * r - 2 * a + o + c; + } + return { + initCatmullRom: function(r, a, o, c, l) { + i(a, o, l * (o - r), l * (c - a)); + }, + initNonuniformCatmullRom: function(r, a, o, c, l, h, u) { + let d = (a - r) / l - (o - r) / (l + h) + (o - a) / h, f = (o - a) / h - (c - a) / (h + u) + (c - o) / u; + d *= h, f *= h, i(a, o, d, f); + }, + calc: function(r) { + let a = r * r, o = a * r; + return s1 + t * r + e * a + n * o; } - function c(p) { - let _ = new M; - for(let y = 0; y < r.length; y += 3)_.x = r[y + 0], _.y = r[y + 1], _.z = r[y + 2], _.normalize().multiplyScalar(p), r[y + 0] = _.x, r[y + 1] = _.y, r[y + 2] = _.z; + }; +} +var vr = new A, Qa = new Hc, ja = new Hc, to = new Hc, Oo = class extends Xe { + constructor(t = [], e = !1, n = "centripetal", i = .5){ + super(), this.isCatmullRomCurve3 = !0, this.type = "CatmullRomCurve3", this.points = t, this.closed = e, this.curveType = n, this.tension = i; + } + getPoint(t, e = new A) { + let n = e, i = this.points, r = i.length, a = (r - (this.closed ? 0 : 1)) * t, o = Math.floor(a), c = a - o; + this.closed ? o += o > 0 ? 0 : (Math.floor(Math.abs(o) / r) + 1) * r : c === 0 && o === r - 1 && (o = r - 2, c = 1); + let l, h; + this.closed || o > 0 ? l = i[(o - 1) % r] : (vr.subVectors(i[0], i[1]).add(i[0]), l = vr); + let u = i[o % r], d = i[(o + 1) % r]; + if (this.closed || o + 2 < r ? h = i[(o + 2) % r] : (vr.subVectors(i[r - 1], i[r - 2]).add(i[r - 1]), h = vr), this.curveType === "centripetal" || this.curveType === "chordal") { + let f = this.curveType === "chordal" ? .5 : .25, m = Math.pow(l.distanceToSquared(u), f), x = Math.pow(u.distanceToSquared(d), f), g = Math.pow(d.distanceToSquared(h), f); + x < 1e-4 && (x = 1), m < 1e-4 && (m = x), g < 1e-4 && (g = x), Qa.initNonuniformCatmullRom(l.x, u.x, d.x, h.x, m, x, g), ja.initNonuniformCatmullRom(l.y, u.y, d.y, h.y, m, x, g), to.initNonuniformCatmullRom(l.z, u.z, d.z, h.z, m, x, g); + } else this.curveType === "catmullrom" && (Qa.initCatmullRom(l.x, u.x, d.x, h.x, this.tension), ja.initCatmullRom(l.y, u.y, d.y, h.y, this.tension), to.initCatmullRom(l.z, u.z, d.z, h.z, this.tension)); + return n.set(Qa.calc(c), ja.calc(c), to.calc(c)), n; + } + copy(t) { + super.copy(t), this.points = []; + for(let e = 0, n = t.points.length; e < n; e++){ + let i = t.points[e]; + this.points.push(i.clone()); } - function h() { - let p = new M; - for(let _ = 0; _ < r.length; _ += 3){ - p.x = r[_ + 0], p.y = r[_ + 1], p.z = r[_ + 2]; - let y = v(p) / 2 / Math.PI + .5, b = g(p) / Math.PI + .5; - o.push(y, 1 - b); - } - m(), u(); + return this.closed = t.closed, this.curveType = t.curveType, this.tension = t.tension, this; + } + toJSON() { + let t = super.toJSON(); + t.points = []; + for(let e = 0, n = this.points.length; e < n; e++){ + let i = this.points[e]; + t.points.push(i.toArray()); } - function u() { - for(let p = 0; p < o.length; p += 6){ - let _ = o[p + 0], y = o[p + 2], b = o[p + 4], A = Math.max(_, y, b), L = Math.min(_, y, b); - A > .9 && L < .1 && (_ < .2 && (o[p + 0] += 1), y < .2 && (o[p + 2] += 1), b < .2 && (o[p + 4] += 1)); - } + return t.closed = this.closed, t.curveType = this.curveType, t.tension = this.tension, t; + } + fromJSON(t) { + super.fromJSON(t), this.points = []; + for(let e = 0, n = t.points.length; e < n; e++){ + let i = t.points[e]; + this.points.push(new A().fromArray(i)); + } + return this.closed = t.closed, this.curveType = t.curveType, this.tension = t.tension, this; + } +}; +function qh(s1, t, e, n, i) { + let r = (n - t) * .5, a = (i - e) * .5, o = s1 * s1, c = s1 * o; + return (2 * e - 2 * n + r + a) * c + (-3 * e + 3 * n - 2 * r - a) * o + r * s1 + e; +} +function X0(s1, t) { + let e = 1 - s1; + return e * e * t; +} +function q0(s1, t) { + return 2 * (1 - s1) * s1 * t; +} +function Y0(s1, t) { + return s1 * s1 * t; +} +function bs(s1, t, e, n) { + return X0(s1, t) + q0(s1, e) + Y0(s1, n); +} +function Z0(s1, t) { + let e = 1 - s1; + return e * e * e * t; +} +function J0(s1, t) { + let e = 1 - s1; + return 3 * e * e * s1 * t; +} +function $0(s1, t) { + return 3 * (1 - s1) * s1 * s1 * t; +} +function K0(s1, t) { + return s1 * s1 * s1 * t; +} +function Es(s1, t, e, n, i) { + return Z0(s1, t) + J0(s1, e) + $0(s1, n) + K0(s1, i); +} +var ea = class extends Xe { + constructor(t = new J, e = new J, n = new J, i = new J){ + super(), this.isCubicBezierCurve = !0, this.type = "CubicBezierCurve", this.v0 = t, this.v1 = e, this.v2 = n, this.v3 = i; + } + getPoint(t, e = new J) { + let n = e, i = this.v0, r = this.v1, a = this.v2, o = this.v3; + return n.set(Es(t, i.x, r.x, a.x, o.x), Es(t, i.y, r.y, a.y, o.y)), n; + } + copy(t) { + return super.copy(t), this.v0.copy(t.v0), this.v1.copy(t.v1), this.v2.copy(t.v2), this.v3.copy(t.v3), this; + } + toJSON() { + let t = super.toJSON(); + return t.v0 = this.v0.toArray(), t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t.v3 = this.v3.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v0.fromArray(t.v0), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this.v3.fromArray(t.v3), this; + } +}, Bo = class extends Xe { + constructor(t = new A, e = new A, n = new A, i = new A){ + super(), this.isCubicBezierCurve3 = !0, this.type = "CubicBezierCurve3", this.v0 = t, this.v1 = e, this.v2 = n, this.v3 = i; + } + getPoint(t, e = new A) { + let n = e, i = this.v0, r = this.v1, a = this.v2, o = this.v3; + return n.set(Es(t, i.x, r.x, a.x, o.x), Es(t, i.y, r.y, a.y, o.y), Es(t, i.z, r.z, a.z, o.z)), n; + } + copy(t) { + return super.copy(t), this.v0.copy(t.v0), this.v1.copy(t.v1), this.v2.copy(t.v2), this.v3.copy(t.v3), this; + } + toJSON() { + let t = super.toJSON(); + return t.v0 = this.v0.toArray(), t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t.v3 = this.v3.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v0.fromArray(t.v0), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this.v3.fromArray(t.v3), this; + } +}, Ns = class extends Xe { + constructor(t = new J, e = new J){ + super(), this.isLineCurve = !0, this.type = "LineCurve", this.v1 = t, this.v2 = e; + } + getPoint(t, e = new J) { + let n = e; + return t === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(t).add(this.v1)), n; + } + getPointAt(t, e) { + return this.getPoint(t, e); + } + getTangent(t, e = new J) { + return e.subVectors(this.v2, this.v1).normalize(); + } + getTangentAt(t, e) { + return this.getTangent(t, e); + } + copy(t) { + return super.copy(t), this.v1.copy(t.v1), this.v2.copy(t.v2), this; + } + toJSON() { + let t = super.toJSON(); + return t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this; + } +}, zo = class extends Xe { + constructor(t = new A, e = new A){ + super(), this.isLineCurve3 = !0, this.type = "LineCurve3", this.v1 = t, this.v2 = e; + } + getPoint(t, e = new A) { + let n = e; + return t === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(t).add(this.v1)), n; + } + getPointAt(t, e) { + return this.getPoint(t, e); + } + getTangent(t, e = new A) { + return e.subVectors(this.v2, this.v1).normalize(); + } + getTangentAt(t, e) { + return this.getTangent(t, e); + } + copy(t) { + return super.copy(t), this.v1.copy(t.v1), this.v2.copy(t.v2), this; + } + toJSON() { + let t = super.toJSON(); + return t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this; + } +}, na = class extends Xe { + constructor(t = new J, e = new J, n = new J){ + super(), this.isQuadraticBezierCurve = !0, this.type = "QuadraticBezierCurve", this.v0 = t, this.v1 = e, this.v2 = n; + } + getPoint(t, e = new J) { + let n = e, i = this.v0, r = this.v1, a = this.v2; + return n.set(bs(t, i.x, r.x, a.x), bs(t, i.y, r.y, a.y)), n; + } + copy(t) { + return super.copy(t), this.v0.copy(t.v0), this.v1.copy(t.v1), this.v2.copy(t.v2), this; + } + toJSON() { + let t = super.toJSON(); + return t.v0 = this.v0.toArray(), t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v0.fromArray(t.v0), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this; + } +}, ia = class extends Xe { + constructor(t = new A, e = new A, n = new A){ + super(), this.isQuadraticBezierCurve3 = !0, this.type = "QuadraticBezierCurve3", this.v0 = t, this.v1 = e, this.v2 = n; + } + getPoint(t, e = new A) { + let n = e, i = this.v0, r = this.v1, a = this.v2; + return n.set(bs(t, i.x, r.x, a.x), bs(t, i.y, r.y, a.y), bs(t, i.z, r.z, a.z)), n; + } + copy(t) { + return super.copy(t), this.v0.copy(t.v0), this.v1.copy(t.v1), this.v2.copy(t.v2), this; + } + toJSON() { + let t = super.toJSON(); + return t.v0 = this.v0.toArray(), t.v1 = this.v1.toArray(), t.v2 = this.v2.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.v0.fromArray(t.v0), this.v1.fromArray(t.v1), this.v2.fromArray(t.v2), this; + } +}, sa = class extends Xe { + constructor(t = []){ + super(), this.isSplineCurve = !0, this.type = "SplineCurve", this.points = t; + } + getPoint(t, e = new J) { + let n = e, i = this.points, r = (i.length - 1) * t, a = Math.floor(r), o = r - a, c = i[a === 0 ? a : a - 1], l = i[a], h = i[a > i.length - 2 ? i.length - 1 : a + 1], u = i[a > i.length - 3 ? i.length - 1 : a + 2]; + return n.set(qh(o, c.x, l.x, h.x, u.x), qh(o, c.y, l.y, h.y, u.y)), n; + } + copy(t) { + super.copy(t), this.points = []; + for(let e = 0, n = t.points.length; e < n; e++){ + let i = t.points[e]; + this.points.push(i.clone()); } - function d(p) { - r.push(p.x, p.y, p.z); + return this; + } + toJSON() { + let t = super.toJSON(); + t.points = []; + for(let e = 0, n = this.points.length; e < n; e++){ + let i = this.points[e]; + t.points.push(i.toArray()); } - function f(p, _) { - let y = p * 3; - _.x = e[y + 0], _.y = e[y + 1], _.z = e[y + 2]; + return t; + } + fromJSON(t) { + super.fromJSON(t), this.points = []; + for(let e = 0, n = t.points.length; e < n; e++){ + let i = t.points[e]; + this.points.push(new J().fromArray(i)); } - function m() { - let p = new M, _ = new M, y = new M, b = new M, A = new X, L = new X, I = new X; - for(let k = 0, B = 0; k < r.length; k += 9, B += 6){ - p.set(r[k + 0], r[k + 1], r[k + 2]), _.set(r[k + 3], r[k + 4], r[k + 5]), y.set(r[k + 6], r[k + 7], r[k + 8]), A.set(o[B + 0], o[B + 1]), L.set(o[B + 2], o[B + 3]), I.set(o[B + 4], o[B + 5]), b.copy(p).add(_).add(y).divideScalar(3); - let P = v(b); - x(A, B + 0, p, P), x(L, B + 2, _, P), x(I, B + 4, y, P); + return this; + } +}, Gc = Object.freeze({ + __proto__: null, + ArcCurve: Fo, + CatmullRomCurve3: Oo, + CubicBezierCurve: ea, + CubicBezierCurve3: Bo, + EllipseCurve: Ds, + LineCurve: Ns, + LineCurve3: zo, + QuadraticBezierCurve: na, + QuadraticBezierCurve3: ia, + SplineCurve: sa +}), ko = class extends Xe { + constructor(){ + super(), this.type = "CurvePath", this.curves = [], this.autoClose = !1; + } + add(t) { + this.curves.push(t); + } + closePath() { + let t = this.curves[0].getPoint(0), e = this.curves[this.curves.length - 1].getPoint(1); + t.equals(e) || this.curves.push(new Ns(e, t)); + } + getPoint(t, e) { + let n = t * this.getLength(), i = this.getCurveLengths(), r = 0; + for(; r < i.length;){ + if (i[r] >= n) { + let a = i[r] - n, o = this.curves[r], c = o.getLength(), l = c === 0 ? 0 : 1 - a / c; + return o.getPointAt(l, e); } + r++; } - function x(p, _, y, b) { - b < 0 && p.x === 1 && (o[_] = p.x - 1), y.x === 0 && y.z === 0 && (o[_] = b / 2 / Math.PI + .5); + return null; + } + getLength() { + let t = this.getCurveLengths(); + return t[t.length - 1]; + } + updateArcLengths() { + this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths(); + } + getCurveLengths() { + if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; + let t = [], e = 0; + for(let n = 0, i = this.curves.length; n < i; n++)e += this.curves[n].getLength(), t.push(e); + return this.cacheLengths = t, t; + } + getSpacedPoints(t = 40) { + let e = []; + for(let n = 0; n <= t; n++)e.push(this.getPoint(n / t)); + return this.autoClose && e.push(e[0]), e; + } + getPoints(t = 12) { + let e = [], n; + for(let i = 0, r = this.curves; i < r.length; i++){ + let a = r[i], o = a.isEllipseCurve ? t * 2 : a.isLineCurve || a.isLineCurve3 ? 1 : a.isSplineCurve ? t * a.points.length : t, c = a.getPoints(o); + for(let l = 0; l < c.length; l++){ + let h = c[l]; + n && n.equals(h) || (e.push(h), n = h); + } } - function v(p) { - return Math.atan2(p.z, -p.x); + return this.autoClose && e.length > 1 && !e[e.length - 1].equals(e[0]) && e.push(e[0]), e; + } + copy(t) { + super.copy(t), this.curves = []; + for(let e = 0, n = t.curves.length; e < n; e++){ + let i = t.curves[e]; + this.curves.push(i.clone()); } - function g(p) { - return Math.atan2(-p.y, Math.sqrt(p.x * p.x + p.z * p.z)); + return this.autoClose = t.autoClose, this; + } + toJSON() { + let t = super.toJSON(); + t.autoClose = this.autoClose, t.curves = []; + for(let e = 0, n = this.curves.length; e < n; e++){ + let i = this.curves[e]; + t.curves.push(i.toJSON()); } + return t; } - static fromJSON(e) { - return new an(e.vertices, e.indices, e.radius, e.details); + fromJSON(t) { + super.fromJSON(t), this.autoClose = t.autoClose, this.curves = []; + for(let e = 0, n = t.curves.length; e < n; e++){ + let i = t.curves[e]; + this.curves.push(new Gc[i.type]().fromJSON(i)); + } + return this; } -}, mr = class extends an { - constructor(e = 1, t = 0){ - let n = (1 + Math.sqrt(5)) / 2, i = 1 / n, r = [ - -1, - -1, - -1, - -1, - -1, - 1, - -1, - 1, - -1, - -1, - 1, - 1, - 1, - -1, +}, ji = class extends ko { + constructor(t){ + super(), this.type = "Path", this.currentPoint = new J, t && this.setFromPoints(t); + } + setFromPoints(t) { + this.moveTo(t[0].x, t[0].y); + for(let e = 1, n = t.length; e < n; e++)this.lineTo(t[e].x, t[e].y); + return this; + } + moveTo(t, e) { + return this.currentPoint.set(t, e), this; + } + lineTo(t, e) { + let n = new Ns(this.currentPoint.clone(), new J(t, e)); + return this.curves.push(n), this.currentPoint.set(t, e), this; + } + quadraticCurveTo(t, e, n, i) { + let r = new na(this.currentPoint.clone(), new J(t, e), new J(n, i)); + return this.curves.push(r), this.currentPoint.set(n, i), this; + } + bezierCurveTo(t, e, n, i, r, a) { + let o = new ea(this.currentPoint.clone(), new J(t, e), new J(n, i), new J(r, a)); + return this.curves.push(o), this.currentPoint.set(r, a), this; + } + splineThru(t) { + let e = [ + this.currentPoint.clone() + ].concat(t), n = new sa(e); + return this.curves.push(n), this.currentPoint.copy(t[t.length - 1]), this; + } + arc(t, e, n, i, r, a) { + let o = this.currentPoint.x, c = this.currentPoint.y; + return this.absarc(t + o, e + c, n, i, r, a), this; + } + absarc(t, e, n, i, r, a) { + return this.absellipse(t, e, n, n, i, r, a), this; + } + ellipse(t, e, n, i, r, a, o, c) { + let l = this.currentPoint.x, h = this.currentPoint.y; + return this.absellipse(t + l, e + h, n, i, r, a, o, c), this; + } + absellipse(t, e, n, i, r, a, o, c) { + let l = new Ds(t, e, n, i, r, a, o, c); + if (this.curves.length > 0) { + let u = l.getPoint(0); + u.equals(this.currentPoint) || this.lineTo(u.x, u.y); + } + this.curves.push(l); + let h = l.getPoint(1); + return this.currentPoint.copy(h), this; + } + copy(t) { + return super.copy(t), this.currentPoint.copy(t.currentPoint), this; + } + toJSON() { + let t = super.toJSON(); + return t.currentPoint = this.currentPoint.toArray(), t; + } + fromJSON(t) { + return super.fromJSON(t), this.currentPoint.fromArray(t.currentPoint), this; + } +}, ra = class s1 extends Vt { + constructor(t = [ + new J(0, -.5), + new J(.5, 0), + new J(0, .5) + ], e = 12, n = 0, i = Math.PI * 2){ + super(), this.type = "LatheGeometry", this.parameters = { + points: t, + segments: e, + phiStart: n, + phiLength: i + }, e = Math.floor(e), i = ae(i, 0, Math.PI * 2); + let r = [], a = [], o = [], c = [], l = [], h = 1 / e, u = new A, d = new J, f = new A, m = new A, x = new A, g = 0, p = 0; + for(let v = 0; v <= t.length - 1; v++)switch(v){ + case 0: + g = t[v + 1].x - t[v].x, p = t[v + 1].y - t[v].y, f.x = p * 1, f.y = -g, f.z = p * 0, x.copy(f), f.normalize(), c.push(f.x, f.y, f.z); + break; + case t.length - 1: + c.push(x.x, x.y, x.z); + break; + default: + g = t[v + 1].x - t[v].x, p = t[v + 1].y - t[v].y, f.x = p * 1, f.y = -g, f.z = p * 0, m.copy(f), f.x += x.x, f.y += x.y, f.z += x.z, f.normalize(), c.push(f.x, f.y, f.z), x.copy(m); + } + for(let v = 0; v <= e; v++){ + let _ = n + v * h * i, y = Math.sin(_), b = Math.cos(_); + for(let w = 0; w <= t.length - 1; w++){ + u.x = t[w].x * y, u.y = t[w].y, u.z = t[w].x * b, a.push(u.x, u.y, u.z), d.x = v / e, d.y = w / (t.length - 1), o.push(d.x, d.y); + let R = c[3 * w + 0] * y, L = c[3 * w + 1], M = c[3 * w + 0] * b; + l.push(R, L, M); + } + } + for(let v = 0; v < e; v++)for(let _ = 0; _ < t.length - 1; _++){ + let y = _ + v * t.length, b = y, w = y + t.length, R = y + t.length + 1, L = y + 1; + r.push(b, w, L), r.push(R, L, w); + } + this.setIndex(r), this.setAttribute("position", new _t(a, 3)), this.setAttribute("uv", new _t(o, 2)), this.setAttribute("normal", new _t(l, 3)); + } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } + static fromJSON(t) { + return new s1(t.points, t.segments, t.phiStart, t.phiLength); + } +}, Vo = class s1 extends ra { + constructor(t = 1, e = 1, n = 4, i = 8){ + let r = new ji; + r.absarc(0, -e / 2, t, Math.PI * 1.5, 0), r.absarc(0, e / 2, t, 0, Math.PI * .5), super(r.getPoints(n), i), this.type = "CapsuleGeometry", this.parameters = { + radius: t, + length: e, + capSegments: n, + radialSegments: i + }; + } + static fromJSON(t) { + return new s1(t.radius, t.length, t.capSegments, t.radialSegments); + } +}, Ho = class s1 extends Vt { + constructor(t = 1, e = 32, n = 0, i = Math.PI * 2){ + super(), this.type = "CircleGeometry", this.parameters = { + radius: t, + segments: e, + thetaStart: n, + thetaLength: i + }, e = Math.max(3, e); + let r = [], a = [], o = [], c = [], l = new A, h = new J; + a.push(0, 0, 0), o.push(0, 0, 1), c.push(.5, .5); + for(let u = 0, d = 3; u <= e; u++, d += 3){ + let f = n + u / e * i; + l.x = t * Math.cos(f), l.y = t * Math.sin(f), a.push(l.x, l.y, l.z), o.push(0, 0, 1), h.x = (a[d] / t + 1) / 2, h.y = (a[d + 1] / t + 1) / 2, c.push(h.x, h.y); + } + for(let u = 1; u <= e; u++)r.push(u, u + 1, 0); + this.setIndex(r), this.setAttribute("position", new _t(a, 3)), this.setAttribute("normal", new _t(o, 3)), this.setAttribute("uv", new _t(c, 2)); + } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } + static fromJSON(t) { + return new s1(t.radius, t.segments, t.thetaStart, t.thetaLength); + } +}, Fs = class s1 extends Vt { + constructor(t = 1, e = 1, n = 1, i = 32, r = 1, a = !1, o = 0, c = Math.PI * 2){ + super(), this.type = "CylinderGeometry", this.parameters = { + radiusTop: t, + radiusBottom: e, + height: n, + radialSegments: i, + heightSegments: r, + openEnded: a, + thetaStart: o, + thetaLength: c + }; + let l = this; + i = Math.floor(i), r = Math.floor(r); + let h = [], u = [], d = [], f = [], m = 0, x = [], g = n / 2, p = 0; + v(), a === !1 && (t > 0 && _(!0), e > 0 && _(!1)), this.setIndex(h), this.setAttribute("position", new _t(u, 3)), this.setAttribute("normal", new _t(d, 3)), this.setAttribute("uv", new _t(f, 2)); + function v() { + let y = new A, b = new A, w = 0, R = (e - t) / n; + for(let L = 0; L <= r; L++){ + let M = [], E = L / r, V = E * (e - t) + t; + for(let $ = 0; $ <= i; $++){ + let F = $ / i, O = F * c + o, z = Math.sin(O), K = Math.cos(O); + b.x = V * z, b.y = -E * n + g, b.z = V * K, u.push(b.x, b.y, b.z), y.set(z, R, K).normalize(), d.push(y.x, y.y, y.z), f.push(F, 1 - E), M.push(m++); + } + x.push(M); + } + for(let L = 0; L < i; L++)for(let M = 0; M < r; M++){ + let E = x[M][L], V = x[M + 1][L], $ = x[M + 1][L + 1], F = x[M][L + 1]; + h.push(E, V, F), h.push(V, $, F), w += 6; + } + l.addGroup(p, w, 0), p += w; + } + function _(y) { + let b = m, w = new J, R = new A, L = 0, M = y === !0 ? t : e, E = y === !0 ? 1 : -1; + for(let $ = 1; $ <= i; $++)u.push(0, g * E, 0), d.push(0, E, 0), f.push(.5, .5), m++; + let V = m; + for(let $ = 0; $ <= i; $++){ + let O = $ / i * c + o, z = Math.cos(O), K = Math.sin(O); + R.x = M * K, R.y = g * E, R.z = M * z, u.push(R.x, R.y, R.z), d.push(0, E, 0), w.x = z * .5 + .5, w.y = K * .5 * E + .5, f.push(w.x, w.y), m++; + } + for(let $ = 0; $ < i; $++){ + let F = b + $, O = V + $; + y === !0 ? h.push(O, O + 1, F) : h.push(O + 1, O, F), L += 3; + } + l.addGroup(p, L, y === !0 ? 1 : 2), p += L; + } + } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } + static fromJSON(t) { + return new s1(t.radiusTop, t.radiusBottom, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength); + } +}, Go = class s1 extends Fs { + constructor(t = 1, e = 1, n = 32, i = 1, r = !1, a = 0, o = Math.PI * 2){ + super(0, t, e, n, i, r, a, o), this.type = "ConeGeometry", this.parameters = { + radius: t, + height: e, + radialSegments: n, + heightSegments: i, + openEnded: r, + thetaStart: a, + thetaLength: o + }; + } + static fromJSON(t) { + return new s1(t.radius, t.height, t.radialSegments, t.heightSegments, t.openEnded, t.thetaStart, t.thetaLength); + } +}, di = class s1 extends Vt { + constructor(t = [], e = [], n = 1, i = 0){ + super(), this.type = "PolyhedronGeometry", this.parameters = { + vertices: t, + indices: e, + radius: n, + detail: i + }; + let r = [], a = []; + o(i), l(n), h(), this.setAttribute("position", new _t(r, 3)), this.setAttribute("normal", new _t(r.slice(), 3)), this.setAttribute("uv", new _t(a, 2)), i === 0 ? this.computeVertexNormals() : this.normalizeNormals(); + function o(v) { + let _ = new A, y = new A, b = new A; + for(let w = 0; w < e.length; w += 3)f(e[w + 0], _), f(e[w + 1], y), f(e[w + 2], b), c(_, y, b, v); + } + function c(v, _, y, b) { + let w = b + 1, R = []; + for(let L = 0; L <= w; L++){ + R[L] = []; + let M = v.clone().lerp(y, L / w), E = _.clone().lerp(y, L / w), V = w - L; + for(let $ = 0; $ <= V; $++)$ === 0 && L === w ? R[L][$] = M : R[L][$] = M.clone().lerp(E, $ / V); + } + for(let L = 0; L < w; L++)for(let M = 0; M < 2 * (w - L) - 1; M++){ + let E = Math.floor(M / 2); + M % 2 === 0 ? (d(R[L][E + 1]), d(R[L + 1][E]), d(R[L][E])) : (d(R[L][E + 1]), d(R[L + 1][E + 1]), d(R[L + 1][E])); + } + } + function l(v) { + let _ = new A; + for(let y = 0; y < r.length; y += 3)_.x = r[y + 0], _.y = r[y + 1], _.z = r[y + 2], _.normalize().multiplyScalar(v), r[y + 0] = _.x, r[y + 1] = _.y, r[y + 2] = _.z; + } + function h() { + let v = new A; + for(let _ = 0; _ < r.length; _ += 3){ + v.x = r[_ + 0], v.y = r[_ + 1], v.z = r[_ + 2]; + let y = g(v) / 2 / Math.PI + .5, b = p(v) / Math.PI + .5; + a.push(y, 1 - b); + } + m(), u(); + } + function u() { + for(let v = 0; v < a.length; v += 6){ + let _ = a[v + 0], y = a[v + 2], b = a[v + 4], w = Math.max(_, y, b), R = Math.min(_, y, b); + w > .9 && R < .1 && (_ < .2 && (a[v + 0] += 1), y < .2 && (a[v + 2] += 1), b < .2 && (a[v + 4] += 1)); + } + } + function d(v) { + r.push(v.x, v.y, v.z); + } + function f(v, _) { + let y = v * 3; + _.x = t[y + 0], _.y = t[y + 1], _.z = t[y + 2]; + } + function m() { + let v = new A, _ = new A, y = new A, b = new A, w = new J, R = new J, L = new J; + for(let M = 0, E = 0; M < r.length; M += 9, E += 6){ + v.set(r[M + 0], r[M + 1], r[M + 2]), _.set(r[M + 3], r[M + 4], r[M + 5]), y.set(r[M + 6], r[M + 7], r[M + 8]), w.set(a[E + 0], a[E + 1]), R.set(a[E + 2], a[E + 3]), L.set(a[E + 4], a[E + 5]), b.copy(v).add(_).add(y).divideScalar(3); + let V = g(b); + x(w, E + 0, v, V), x(R, E + 2, _, V), x(L, E + 4, y, V); + } + } + function x(v, _, y, b) { + b < 0 && v.x === 1 && (a[_] = v.x - 1), y.x === 0 && y.z === 0 && (a[_] = b / 2 / Math.PI + .5); + } + function g(v) { + return Math.atan2(v.z, -v.x); + } + function p(v) { + return Math.atan2(-v.y, Math.sqrt(v.x * v.x + v.z * v.z)); + } + } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } + static fromJSON(t) { + return new s1(t.vertices, t.indices, t.radius, t.details); + } +}, Wo = class s1 extends di { + constructor(t = 1, e = 0){ + let n = (1 + Math.sqrt(5)) / 2, i = 1 / n, r = [ + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + -1, + -1, + 1, + 1, + 1, + -1, -1, 1, -1, @@ -12586,7 +14764,7 @@ var fr = class extends _e { n, 0, i - ], o = [ + ], a = [ 3, 11, 7, @@ -12696,23 +14874,21 @@ var fr = class extends _e { 5, 9 ]; - super(r, o, e, t); - this.type = "DodecahedronGeometry", this.parameters = { - radius: e, - detail: t + super(r, a, t, e), this.type = "DodecahedronGeometry", this.parameters = { + radius: t, + detail: e }; } - static fromJSON(e) { - return new mr(e.radius, e.detail); + static fromJSON(t) { + return new s1(t.radius, t.detail); } -}, ys = new M, vs = new M, Jo = new M, _s = new nt, _a = class extends _e { - constructor(e = null, t = 1){ - super(); - if (this.type = "EdgesGeometry", this.parameters = { - geometry: e, - thresholdAngle: t - }, e !== null) { - let i = Math.pow(10, 4), r = Math.cos(Wn * t), o = e.getIndex(), a = e.getAttribute("position"), l = o ? o.count : a.count, c = [ +}, yr = new A, Mr = new A, eo = new A, Sr = new In, Xo = class extends Vt { + constructor(t = null, e = 1){ + if (super(), this.type = "EdgesGeometry", this.parameters = { + geometry: t, + thresholdAngle: e + }, t !== null) { + let i = Math.pow(10, 4), r = Math.cos(ai * e), a = t.getIndex(), o = t.getAttribute("position"), c = a ? a.count : o.count, l = [ 0, 0, 0 @@ -12721,1094 +14897,528 @@ var fr = class extends _e { "b", "c" ], u = new Array(3), d = {}, f = []; - for(let m = 0; m < l; m += 3){ - o ? (c[0] = o.getX(m), c[1] = o.getX(m + 1), c[2] = o.getX(m + 2)) : (c[0] = m, c[1] = m + 1, c[2] = m + 2); - let { a: x , b: v , c: g } = _s; - if (x.fromBufferAttribute(a, c[0]), v.fromBufferAttribute(a, c[1]), g.fromBufferAttribute(a, c[2]), _s.getNormal(Jo), u[0] = `${Math.round(x.x * i)},${Math.round(x.y * i)},${Math.round(x.z * i)}`, u[1] = `${Math.round(v.x * i)},${Math.round(v.y * i)},${Math.round(v.z * i)}`, u[2] = `${Math.round(g.x * i)},${Math.round(g.y * i)},${Math.round(g.z * i)}`, !(u[0] === u[1] || u[1] === u[2] || u[2] === u[0])) for(let p = 0; p < 3; p++){ - let _ = (p + 1) % 3, y = u[p], b = u[_], A = _s[h[p]], L = _s[h[_]], I = `${y}_${b}`, k = `${b}_${y}`; - k in d && d[k] ? (Jo.dot(d[k].normal) <= r && (f.push(A.x, A.y, A.z), f.push(L.x, L.y, L.z)), d[k] = null) : I in d || (d[I] = { - index0: c[p], - index1: c[_], - normal: Jo.clone() + for(let m = 0; m < c; m += 3){ + a ? (l[0] = a.getX(m), l[1] = a.getX(m + 1), l[2] = a.getX(m + 2)) : (l[0] = m, l[1] = m + 1, l[2] = m + 2); + let { a: x , b: g , c: p } = Sr; + if (x.fromBufferAttribute(o, l[0]), g.fromBufferAttribute(o, l[1]), p.fromBufferAttribute(o, l[2]), Sr.getNormal(eo), u[0] = `${Math.round(x.x * i)},${Math.round(x.y * i)},${Math.round(x.z * i)}`, u[1] = `${Math.round(g.x * i)},${Math.round(g.y * i)},${Math.round(g.z * i)}`, u[2] = `${Math.round(p.x * i)},${Math.round(p.y * i)},${Math.round(p.z * i)}`, !(u[0] === u[1] || u[1] === u[2] || u[2] === u[0])) for(let v = 0; v < 3; v++){ + let _ = (v + 1) % 3, y = u[v], b = u[_], w = Sr[h[v]], R = Sr[h[_]], L = `${y}_${b}`, M = `${b}_${y}`; + M in d && d[M] ? (eo.dot(d[M].normal) <= r && (f.push(w.x, w.y, w.z), f.push(R.x, R.y, R.z)), d[M] = null) : L in d || (d[L] = { + index0: l[v], + index1: l[_], + normal: eo.clone() }); } } for(let m in d)if (d[m]) { - let { index0: x , index1: v } = d[m]; - ys.fromBufferAttribute(a, x), vs.fromBufferAttribute(a, v), f.push(ys.x, ys.y, ys.z), f.push(vs.x, vs.y, vs.z); + let { index0: x , index1: g } = d[m]; + yr.fromBufferAttribute(o, x), Mr.fromBufferAttribute(o, g), f.push(yr.x, yr.y, yr.z), f.push(Mr.x, Mr.y, Mr.z); } - this.setAttribute("position", new de(f, 3)); + this.setAttribute("position", new _t(f, 3)); } } -}, Ct = class { - constructor(){ - this.type = "Curve", this.arcLengthDivisions = 200; - } - getPoint() { - return console.warn("THREE.Curve: .getPoint() not implemented."), null; - } - getPointAt(e, t) { - let n = this.getUtoTmapping(e); - return this.getPoint(n, t); - } - getPoints(e = 5) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); - return t; - } - getSpacedPoints(e = 5) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPointAt(n / e)); - return t; - } - getLength() { - let e = this.getLengths(); - return e[e.length - 1]; - } - getLengths(e = this.arcLengthDivisions) { - if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; - this.needsUpdate = !1; - let t = [], n, i = this.getPoint(0), r = 0; - t.push(0); - for(let o = 1; o <= e; o++)n = this.getPoint(o / e), r += n.distanceTo(i), t.push(r), i = n; - return this.cacheArcLengths = t, t; + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } - updateArcLengths() { - this.needsUpdate = !0, this.getLengths(); +}, Fn = class extends ji { + constructor(t){ + super(t), this.uuid = Be(), this.type = "Shape", this.holes = []; } - getUtoTmapping(e, t) { - let n = this.getLengths(), i = 0, r = n.length, o; - t ? o = t : o = e * n[r - 1]; - let a = 0, l = r - 1, c; - for(; a <= l;)if (i = Math.floor(a + (l - a) / 2), c = n[i] - o, c < 0) a = i + 1; - else if (c > 0) l = i - 1; - else { - l = i; - break; - } - if (i = l, n[i] === o) return i / (r - 1); - let h = n[i], d = n[i + 1] - h, f = (o - h) / d; - return (i + f) / (r - 1); + getPointsHoles(t) { + let e = []; + for(let n = 0, i = this.holes.length; n < i; n++)e[n] = this.holes[n].getPoints(t); + return e; } - getTangent(e, t) { - let i = e - 1e-4, r = e + 1e-4; - i < 0 && (i = 0), r > 1 && (r = 1); - let o = this.getPoint(i), a = this.getPoint(r), l = t || (o.isVector2 ? new X : new M); - return l.copy(a).sub(o).normalize(), l; - } - getTangentAt(e, t) { - let n = this.getUtoTmapping(e); - return this.getTangent(n, t); - } - computeFrenetFrames(e, t) { - let n = new M, i = [], r = [], o = [], a = new M, l = new pe; - for(let f = 0; f <= e; f++){ - let m = f / e; - i[f] = this.getTangentAt(m, new M); - } - r[0] = new M, o[0] = new M; - let c = Number.MAX_VALUE, h = Math.abs(i[0].x), u = Math.abs(i[0].y), d = Math.abs(i[0].z); - h <= c && (c = h, n.set(1, 0, 0)), u <= c && (c = u, n.set(0, 1, 0)), d <= c && n.set(0, 0, 1), a.crossVectors(i[0], n).normalize(), r[0].crossVectors(i[0], a), o[0].crossVectors(i[0], r[0]); - for(let f = 1; f <= e; f++){ - if (r[f] = r[f - 1].clone(), o[f] = o[f - 1].clone(), a.crossVectors(i[f - 1], i[f]), a.length() > Number.EPSILON) { - a.normalize(); - let m = Math.acos(mt(i[f - 1].dot(i[f]), -1, 1)); - r[f].applyMatrix4(l.makeRotationAxis(a, m)); - } - o[f].crossVectors(i[f], r[f]); - } - if (t === !0) { - let f = Math.acos(mt(r[0].dot(r[e]), -1, 1)); - f /= e, i[0].dot(a.crossVectors(r[0], r[e])) > 0 && (f = -f); - for(let m = 1; m <= e; m++)r[m].applyMatrix4(l.makeRotationAxis(i[m], f * m)), o[m].crossVectors(i[m], r[m]); - } + extractPoints(t) { return { - tangents: i, - normals: r, - binormals: o + shape: this.getPoints(t), + holes: this.getPointsHoles(t) }; } - clone() { - return new this.constructor().copy(this); - } - copy(e) { - return this.arcLengthDivisions = e.arcLengthDivisions, this; + copy(t) { + super.copy(t), this.holes = []; + for(let e = 0, n = t.holes.length; e < n; e++){ + let i = t.holes[e]; + this.holes.push(i.clone()); + } + return this; } toJSON() { - let e = { - metadata: { - version: 4.5, - type: "Curve", - generator: "Curve.toJSON" - } - }; - return e.arcLengthDivisions = this.arcLengthDivisions, e.type = this.type, e; - } - fromJSON(e) { - return this.arcLengthDivisions = e.arcLengthDivisions, this; - } -}, Ur = class extends Ct { - constructor(e = 0, t = 0, n = 1, i = 1, r = 0, o = Math.PI * 2, a = !1, l = 0){ - super(); - this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = n, this.yRadius = i, this.aStartAngle = r, this.aEndAngle = o, this.aClockwise = a, this.aRotation = l; + let t = super.toJSON(); + t.uuid = this.uuid, t.holes = []; + for(let e = 0, n = this.holes.length; e < n; e++){ + let i = this.holes[e]; + t.holes.push(i.toJSON()); + } + return t; } - getPoint(e, t) { - let n = t || new X, i = Math.PI * 2, r = this.aEndAngle - this.aStartAngle, o = Math.abs(r) < Number.EPSILON; - for(; r < 0;)r += i; - for(; r > i;)r -= i; - r < Number.EPSILON && (o ? r = 0 : r = i), this.aClockwise === !0 && !o && (r === i ? r = -i : r = r - i); - let a = this.aStartAngle + e * r, l = this.aX + this.xRadius * Math.cos(a), c = this.aY + this.yRadius * Math.sin(a); - if (this.aRotation !== 0) { - let h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), d = l - this.aX, f = c - this.aY; - l = d * h - f * u + this.aX, c = d * u + f * h + this.aY; + fromJSON(t) { + super.fromJSON(t), this.uuid = t.uuid, this.holes = []; + for(let e = 0, n = t.holes.length; e < n; e++){ + let i = t.holes[e]; + this.holes.push(new ji().fromJSON(i)); } - return n.set(l, c); + return this; } - copy(e) { - return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; +}, Q0 = { + triangulate: function(s1, t, e = 2) { + let n = t && t.length, i = n ? t[0] * e : s1.length, r = Td(s1, 0, i, e, !0), a = []; + if (!r || r.next === r.prev) return a; + let o, c, l, h, u, d, f; + if (n && (r = ix(s1, t, r, e)), s1.length > 80 * e) { + o = l = s1[0], c = h = s1[1]; + for(let m = e; m < i; m += e)u = s1[m], d = s1[m + 1], u < o && (o = u), d < c && (c = d), u > l && (l = u), d > h && (h = d); + f = Math.max(l - o, h - c), f = f !== 0 ? 32767 / f : 0; + } + return Os(r, a, e, o, c, f, 0), a; + } +}; +function Td(s1, t, e, n, i) { + let r, a; + if (i === px(s1, t, e, n) > 0) for(r = t; r < e; r += n)a = Yh(r, s1[r], s1[r + 1], a); + else for(r = e - n; r >= t; r -= n)a = Yh(r, s1[r], s1[r + 1], a); + return a && ga(a, a.next) && (zs(a), a = a.next), a; +} +function fi(s1, t) { + if (!s1) return s1; + t || (t = s1); + let e = s1, n; + do if (n = !1, !e.steiner && (ga(e, e.next) || ne(e.prev, e, e.next) === 0)) { + if (zs(e), e = t = e.prev, e === e.next) break; + n = !0; + } else e = e.next; + while (n || e !== t) + return t; +} +function Os(s1, t, e, n, i, r, a) { + if (!s1) return; + !a && r && cx(s1, n, i, r); + let o = s1, c, l; + for(; s1.prev !== s1.next;){ + if (c = s1.prev, l = s1.next, r ? tx(s1, n, i, r) : j0(s1)) { + t.push(c.i / e | 0), t.push(s1.i / e | 0), t.push(l.i / e | 0), zs(s1), s1 = l.next, o = l.next; + continue; + } + if (s1 = l, s1 === o) { + a ? a === 1 ? (s1 = ex(fi(s1), t, e), Os(s1, t, e, n, i, r, 2)) : a === 2 && nx(s1, t, e, n, i, r) : Os(fi(s1), t, e, n, i, r, 1); + break; + } } - toJSON() { - let e = super.toJSON(); - return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e; +} +function j0(s1) { + let t = s1.prev, e = s1, n = s1.next; + if (ne(t, e, n) >= 0) return !1; + let i = t.x, r = e.x, a = n.x, o = t.y, c = e.y, l = n.y, h = i < r ? i < a ? i : a : r < a ? r : a, u = o < c ? o < l ? o : l : c < l ? c : l, d = i > r ? i > a ? i : a : r > a ? r : a, f = o > c ? o > l ? o : l : c > l ? c : l, m = n.next; + for(; m !== t;){ + if (m.x >= h && m.x <= d && m.y >= u && m.y <= f && Gi(i, o, r, c, a, l, m.x, m.y) && ne(m.prev, m, m.next) >= 0) return !1; + m = m.next; } - fromJSON(e) { - return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this; + return !0; +} +function tx(s1, t, e, n) { + let i = s1.prev, r = s1, a = s1.next; + if (ne(i, r, a) >= 0) return !1; + let o = i.x, c = r.x, l = a.x, h = i.y, u = r.y, d = a.y, f = o < c ? o < l ? o : l : c < l ? c : l, m = h < u ? h < d ? h : d : u < d ? u : d, x = o > c ? o > l ? o : l : c > l ? c : l, g = h > u ? h > d ? h : d : u > d ? u : d, p = qo(f, m, t, e, n), v = qo(x, g, t, e, n), _ = s1.prevZ, y = s1.nextZ; + for(; _ && _.z >= p && y && y.z <= v;){ + if (_.x >= f && _.x <= x && _.y >= m && _.y <= g && _ !== i && _ !== a && Gi(o, h, c, u, l, d, _.x, _.y) && ne(_.prev, _, _.next) >= 0 || (_ = _.prevZ, y.x >= f && y.x <= x && y.y >= m && y.y <= g && y !== i && y !== a && Gi(o, h, c, u, l, d, y.x, y.y) && ne(y.prev, y, y.next) >= 0)) return !1; + y = y.nextZ; } -}; -Ur.prototype.isEllipseCurve = !0; -var Ma = class extends Ur { - constructor(e, t, n, i, r, o){ - super(e, t, n, n, i, r, o); - this.type = "ArcCurve"; + for(; _ && _.z >= p;){ + if (_.x >= f && _.x <= x && _.y >= m && _.y <= g && _ !== i && _ !== a && Gi(o, h, c, u, l, d, _.x, _.y) && ne(_.prev, _, _.next) >= 0) return !1; + _ = _.prevZ; } -}; -Ma.prototype.isArcCurve = !0; -function ba() { - let s = 0, e = 0, t = 0, n = 0; - function i(r, o, a, l) { - s = r, e = a, t = -3 * r + 3 * o - 2 * a - l, n = 2 * r - 2 * o + a + l; + for(; y && y.z <= v;){ + if (y.x >= f && y.x <= x && y.y >= m && y.y <= g && y !== i && y !== a && Gi(o, h, c, u, l, d, y.x, y.y) && ne(y.prev, y, y.next) >= 0) return !1; + y = y.nextZ; } - return { - initCatmullRom: function(r, o, a, l, c) { - i(o, a, c * (a - r), c * (l - o)); - }, - initNonuniformCatmullRom: function(r, o, a, l, c, h, u) { - let d = (o - r) / c - (a - r) / (c + h) + (a - o) / h, f = (a - o) / h - (l - o) / (h + u) + (l - a) / u; - d *= h, f *= h, i(o, a, d, f); - }, - calc: function(r) { - let o = r * r, a = o * r; - return s + e * r + t * o + n * a; - } - }; + return !0; } -var Ms = new M, Yo = new ba, Zo = new ba, $o = new ba, wa = class extends Ct { - constructor(e = [], t = !1, n = "centripetal", i = .5){ - super(); - this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = n, this.tension = i; - } - getPoint(e, t = new M) { - let n = t, i = this.points, r = i.length, o = (r - (this.closed ? 0 : 1)) * e, a = Math.floor(o), l = o - a; - this.closed ? a += a > 0 ? 0 : (Math.floor(Math.abs(a) / r) + 1) * r : l === 0 && a === r - 1 && (a = r - 2, l = 1); - let c, h; - this.closed || a > 0 ? c = i[(a - 1) % r] : (Ms.subVectors(i[0], i[1]).add(i[0]), c = Ms); - let u = i[a % r], d = i[(a + 1) % r]; - if (this.closed || a + 2 < r ? h = i[(a + 2) % r] : (Ms.subVectors(i[r - 1], i[r - 2]).add(i[r - 1]), h = Ms), this.curveType === "centripetal" || this.curveType === "chordal") { - let f = this.curveType === "chordal" ? .5 : .25, m = Math.pow(c.distanceToSquared(u), f), x = Math.pow(u.distanceToSquared(d), f), v = Math.pow(d.distanceToSquared(h), f); - x < 1e-4 && (x = 1), m < 1e-4 && (m = x), v < 1e-4 && (v = x), Yo.initNonuniformCatmullRom(c.x, u.x, d.x, h.x, m, x, v), Zo.initNonuniformCatmullRom(c.y, u.y, d.y, h.y, m, x, v), $o.initNonuniformCatmullRom(c.z, u.z, d.z, h.z, m, x, v); - } else this.curveType === "catmullrom" && (Yo.initCatmullRom(c.x, u.x, d.x, h.x, this.tension), Zo.initCatmullRom(c.y, u.y, d.y, h.y, this.tension), $o.initCatmullRom(c.z, u.z, d.z, h.z, this.tension)); - return n.set(Yo.calc(l), Zo.calc(l), $o.calc(l)), n; - } - copy(e) { - super.copy(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(i.clone()); - } - return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; - } - toJSON() { - let e = super.toJSON(); - e.points = []; - for(let t = 0, n = this.points.length; t < n; t++){ - let i = this.points[t]; - e.points.push(i.toArray()); - } - return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e; - } - fromJSON(e) { - super.fromJSON(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(new M().fromArray(i)); +function ex(s1, t, e) { + let n = s1; + do { + let i = n.prev, r = n.next.next; + !ga(i, r) && wd(i, n, n.next, r) && Bs(i, r) && Bs(r, i) && (t.push(i.i / e | 0), t.push(n.i / e | 0), t.push(r.i / e | 0), zs(n), zs(n.next), n = s1 = r), n = n.next; + }while (n !== s1) + return fi(n); +} +function nx(s1, t, e, n, i, r) { + let a = s1; + do { + let o = a.next.next; + for(; o !== a.prev;){ + if (a.i !== o.i && ux(a, o)) { + let c = Ad(a, o); + a = fi(a, a.next), c = fi(c, c.next), Os(a, t, e, n, i, r, 0), Os(c, t, e, n, i, r, 0); + return; + } + o = o.next; } - return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this; - } -}; -wa.prototype.isCatmullRomCurve3 = !0; -function pc(s, e, t, n, i) { - let r = (n - e) * .5, o = (i - t) * .5, a = s * s, l = s * a; - return (2 * t - 2 * n + r + o) * l + (-3 * t + 3 * n - 2 * r - o) * a + r * s + t; + a = a.next; + }while (a !== s1) +} +function ix(s1, t, e, n) { + let i = [], r, a, o, c, l; + for(r = 0, a = t.length; r < a; r++)o = t[r] * n, c = r < a - 1 ? t[r + 1] * n : s1.length, l = Td(s1, o, c, n, !1), l === l.next && (l.steiner = !0), i.push(hx(l)); + for(i.sort(sx), r = 0; r < i.length; r++)e = rx(i[r], e); + return e; } -function Ix(s, e) { - let t = 1 - s; - return t * t * e; +function sx(s1, t) { + return s1.x - t.x; } -function Dx(s, e) { - return 2 * (1 - s) * s * e; +function rx(s1, t) { + let e = ax(s1, t); + if (!e) return t; + let n = Ad(e, s1); + return fi(n, n.next), fi(e, e.next); } -function Fx(s, e) { - return s * s * e; +function ax(s1, t) { + let e = t, n = -1 / 0, i, r = s1.x, a = s1.y; + do { + if (a <= e.y && a >= e.next.y && e.next.y !== e.y) { + let d = e.x + (a - e.y) * (e.next.x - e.x) / (e.next.y - e.y); + if (d <= r && d > n && (n = d, i = e.x < e.next.x ? e : e.next, d === r)) return i; + } + e = e.next; + }while (e !== t) + if (!i) return null; + let o = i, c = i.x, l = i.y, h = 1 / 0, u; + e = i; + do r >= e.x && e.x >= c && r !== e.x && Gi(a < l ? r : n, a, c, l, a < l ? n : r, a, e.x, e.y) && (u = Math.abs(a - e.y) / (r - e.x), Bs(e, s1) && (u < h || u === h && (e.x > i.x || e.x === i.x && ox(i, e))) && (i = e, h = u)), e = e.next; + while (e !== o) + return i; } -function ar(s, e, t, n) { - return Ix(s, e) + Dx(s, t) + Fx(s, n); +function ox(s1, t) { + return ne(s1.prev, s1, t.prev) < 0 && ne(t.next, s1, s1.next) < 0; } -function Nx(s, e) { - let t = 1 - s; - return t * t * t * e; +function cx(s1, t, e, n) { + let i = s1; + do i.z === 0 && (i.z = qo(i.x, i.y, t, e, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next; + while (i !== s1) + i.prevZ.nextZ = null, i.prevZ = null, lx(i); } -function Bx(s, e) { - let t = 1 - s; - return 3 * t * t * s * e; +function lx(s1) { + let t, e, n, i, r, a, o, c, l = 1; + do { + for(e = s1, s1 = null, r = null, a = 0; e;){ + for(a++, n = e, o = 0, t = 0; t < l && (o++, n = n.nextZ, !!n); t++); + for(c = l; o > 0 || c > 0 && n;)o !== 0 && (c === 0 || !n || e.z <= n.z) ? (i = e, e = e.nextZ, o--) : (i = n, n = n.nextZ, c--), r ? r.nextZ = i : s1 = i, i.prevZ = r, r = i; + e = n; + } + r.nextZ = null, l *= 2; + }while (a > 1) + return s1; +} +function qo(s1, t, e, n, i) { + return s1 = (s1 - e) * i | 0, t = (t - n) * i | 0, s1 = (s1 | s1 << 8) & 16711935, s1 = (s1 | s1 << 4) & 252645135, s1 = (s1 | s1 << 2) & 858993459, s1 = (s1 | s1 << 1) & 1431655765, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, s1 | t << 1; +} +function hx(s1) { + let t = s1, e = s1; + do (t.x < e.x || t.x === e.x && t.y < e.y) && (e = t), t = t.next; + while (t !== s1) + return e; } -function zx(s, e) { - return 3 * (1 - s) * s * s * e; +function Gi(s1, t, e, n, i, r, a, o) { + return (i - a) * (t - o) >= (s1 - a) * (r - o) && (s1 - a) * (n - o) >= (e - a) * (t - o) && (e - a) * (r - o) >= (i - a) * (n - o); } -function Ux(s, e) { - return s * s * s * e; +function ux(s1, t) { + return s1.next.i !== t.i && s1.prev.i !== t.i && !dx(s1, t) && (Bs(s1, t) && Bs(t, s1) && fx(s1, t) && (ne(s1.prev, s1, t.prev) || ne(s1, t.prev, t)) || ga(s1, t) && ne(s1.prev, s1, s1.next) > 0 && ne(t.prev, t, t.next) > 0); } -function lr(s, e, t, n, i) { - return Nx(s, e) + Bx(s, t) + zx(s, n) + Ux(s, i); +function ne(s1, t, e) { + return (t.y - s1.y) * (e.x - t.x) - (t.x - s1.x) * (e.y - t.y); } -var lo = class extends Ct { - constructor(e = new X, t = new X, n = new X, i = new X){ - super(); - this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; - } - getPoint(e, t = new X) { - let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; - return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; - } -}; -lo.prototype.isCubicBezierCurve = !0; -var Sa = class extends Ct { - constructor(e = new M, t = new M, n = new M, i = new M){ - super(); - this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n, this.v3 = i; - } - getPoint(e, t = new M) { - let n = t, i = this.v0, r = this.v1, o = this.v2, a = this.v3; - return n.set(lr(e, i.x, r.x, o.x, a.x), lr(e, i.y, r.y, o.y, a.y), lr(e, i.z, r.z, o.z, a.z)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; - } -}; -Sa.prototype.isCubicBezierCurve3 = !0; -var Or = class extends Ct { - constructor(e = new X, t = new X){ - super(); - this.type = "LineCurve", this.v1 = e, this.v2 = t; - } - getPoint(e, t = new X) { - let n = t; - return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; - } - getPointAt(e, t) { - return this.getPoint(e, t); - } - getTangent(e, t) { - let n = t || new X; - return n.copy(this.v2).sub(this.v1).normalize(), n; - } - copy(e) { - return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; +function ga(s1, t) { + return s1.x === t.x && s1.y === t.y; +} +function wd(s1, t, e, n) { + let i = Er(ne(s1, t, e)), r = Er(ne(s1, t, n)), a = Er(ne(e, n, s1)), o = Er(ne(e, n, t)); + return !!(i !== r && a !== o || i === 0 && br(s1, e, t) || r === 0 && br(s1, n, t) || a === 0 && br(e, s1, n) || o === 0 && br(e, t, n)); +} +function br(s1, t, e) { + return t.x <= Math.max(s1.x, e.x) && t.x >= Math.min(s1.x, e.x) && t.y <= Math.max(s1.y, e.y) && t.y >= Math.min(s1.y, e.y); +} +function Er(s1) { + return s1 > 0 ? 1 : s1 < 0 ? -1 : 0; +} +function dx(s1, t) { + let e = s1; + do { + if (e.i !== s1.i && e.next.i !== s1.i && e.i !== t.i && e.next.i !== t.i && wd(e, e.next, s1, t)) return !0; + e = e.next; + }while (e !== s1) + return !1; +} +function Bs(s1, t) { + return ne(s1.prev, s1, s1.next) < 0 ? ne(s1, t, s1.next) >= 0 && ne(s1, s1.prev, t) >= 0 : ne(s1, t, s1.prev) < 0 || ne(s1, s1.next, t) < 0; +} +function fx(s1, t) { + let e = s1, n = !1, i = (s1.x + t.x) / 2, r = (s1.y + t.y) / 2; + do e.y > r != e.next.y > r && e.next.y !== e.y && i < (e.next.x - e.x) * (r - e.y) / (e.next.y - e.y) + e.x && (n = !n), e = e.next; + while (e !== s1) + return n; +} +function Ad(s1, t) { + let e = new Yo(s1.i, s1.x, s1.y), n = new Yo(t.i, t.x, t.y), i = s1.next, r = t.prev; + return s1.next = t, t.prev = s1, e.next = i, i.prev = e, n.next = e, e.prev = n, r.next = n, n.prev = r, n; +} +function Yh(s1, t, e, n) { + let i = new Yo(s1, t, e); + return n ? (i.next = n.next, i.prev = n, n.next.prev = i, n.next = i) : (i.prev = i, i.next = i), i; +} +function zs(s1) { + s1.next.prev = s1.prev, s1.prev.next = s1.next, s1.prevZ && (s1.prevZ.nextZ = s1.nextZ), s1.nextZ && (s1.nextZ.prevZ = s1.prevZ); +} +function Yo(s1, t, e) { + this.i = s1, this.x = t, this.y = e, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1; +} +function px(s1, t, e, n) { + let i = 0; + for(let r = t, a = e - n; r < e; r += n)i += (s1[a] - s1[r]) * (s1[r + 1] + s1[a + 1]), a = r; + return i; +} +var yn = class s1 { + static area(t) { + let e = t.length, n = 0; + for(let i = e - 1, r = 0; r < e; i = r++)n += t[i].x * t[r].y - t[r].x * t[i].y; + return n * .5; } - toJSON() { - let e = super.toJSON(); - return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; + static isClockWise(t) { + return s1.area(t) < 0; } - fromJSON(e) { - return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; + static triangulateShape(t, e) { + let n = [], i = [], r = []; + Zh(t), Jh(n, t); + let a = t.length; + e.forEach(Zh); + for(let c = 0; c < e.length; c++)i.push(a), a += e[c].length, Jh(n, e[c]); + let o = Q0.triangulate(n, i); + for(let c = 0; c < o.length; c += 3)r.push(o.slice(c, c + 3)); + return r; } }; -Or.prototype.isLineCurve = !0; -var Eh = class extends Ct { - constructor(e = new M, t = new M){ - super(); - this.type = "LineCurve3", this.isLineCurve3 = !0, this.v1 = e, this.v2 = t; - } - getPoint(e, t = new M) { - let n = t; - return e === 1 ? n.copy(this.v2) : (n.copy(this.v2).sub(this.v1), n.multiplyScalar(e).add(this.v1)), n; - } - getPointAt(e, t) { - return this.getPoint(e, t); - } - copy(e) { - return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}, co = class extends Ct { - constructor(e = new X, t = new X, n = new X){ - super(); - this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = n; - } - getPoint(e, t = new X) { - let n = t, i = this.v0, r = this.v1, o = this.v2; - return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}; -co.prototype.isQuadraticBezierCurve = !0; -var ho = class extends Ct { - constructor(e = new M, t = new M, n = new M){ - super(); - this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = n; - } - getPoint(e, t = new M) { - let n = t, i = this.v0, r = this.v1, o = this.v2; - return n.set(ar(e, i.x, r.x, o.x), ar(e, i.y, r.y, o.y), ar(e, i.z, r.z, o.z)), n; - } - copy(e) { - return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; - } - toJSON() { - let e = super.toJSON(); - return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; - } -}; -ho.prototype.isQuadraticBezierCurve3 = !0; -var uo = class extends Ct { - constructor(e = []){ - super(); - this.type = "SplineCurve", this.points = e; - } - getPoint(e, t = new X) { - let n = t, i = this.points, r = (i.length - 1) * e, o = Math.floor(r), a = r - o, l = i[o === 0 ? o : o - 1], c = i[o], h = i[o > i.length - 2 ? i.length - 1 : o + 1], u = i[o > i.length - 3 ? i.length - 1 : o + 2]; - return n.set(pc(a, l.x, c.x, h.x, u.x), pc(a, l.y, c.y, h.y, u.y)), n; - } - copy(e) { - super.copy(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(i.clone()); - } - return this; - } - toJSON() { - let e = super.toJSON(); - e.points = []; - for(let t = 0, n = this.points.length; t < n; t++){ - let i = this.points[t]; - e.points.push(i.toArray()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.points = []; - for(let t = 0, n = e.points.length; t < n; t++){ - let i = e.points[t]; - this.points.push(new X().fromArray(i)); - } - return this; - } -}; -uo.prototype.isSplineCurve = !0; -var Ta = Object.freeze({ - __proto__: null, - ArcCurve: Ma, - CatmullRomCurve3: wa, - CubicBezierCurve: lo, - CubicBezierCurve3: Sa, - EllipseCurve: Ur, - LineCurve: Or, - LineCurve3: Eh, - QuadraticBezierCurve: co, - QuadraticBezierCurve3: ho, - SplineCurve: uo -}), Ah = class extends Ct { - constructor(){ - super(); - this.type = "CurvePath", this.curves = [], this.autoClose = !1; - } - add(e) { - this.curves.push(e); - } - closePath() { - let e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1); - e.equals(t) || this.curves.push(new Or(t, e)); - } - getPoint(e, t) { - let n = e * this.getLength(), i = this.getCurveLengths(), r = 0; - for(; r < i.length;){ - if (i[r] >= n) { - let o = i[r] - n, a = this.curves[r], l = a.getLength(), c = l === 0 ? 0 : 1 - o / l; - return a.getPointAt(c, t); - } - r++; - } - return null; - } - getLength() { - let e = this.getCurveLengths(); - return e[e.length - 1]; - } - updateArcLengths() { - this.needsUpdate = !0, this.cacheLengths = null, this.getCurveLengths(); - } - getCurveLengths() { - if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; - let e = [], t = 0; - for(let n = 0, i = this.curves.length; n < i; n++)t += this.curves[n].getLength(), e.push(t); - return this.cacheLengths = e, e; - } - getSpacedPoints(e = 40) { - let t = []; - for(let n = 0; n <= e; n++)t.push(this.getPoint(n / e)); - return this.autoClose && t.push(t[0]), t; - } - getPoints(e = 12) { - let t = [], n; - for(let i = 0, r = this.curves; i < r.length; i++){ - let o = r[i], a = o && o.isEllipseCurve ? e * 2 : o && (o.isLineCurve || o.isLineCurve3) ? 1 : o && o.isSplineCurve ? e * o.points.length : e, l = o.getPoints(a); - for(let c = 0; c < l.length; c++){ - let h = l[c]; - n && n.equals(h) || (t.push(h), n = h); - } - } - return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; - } - copy(e) { - super.copy(e), this.curves = []; - for(let t = 0, n = e.curves.length; t < n; t++){ - let i = e.curves[t]; - this.curves.push(i.clone()); - } - return this.autoClose = e.autoClose, this; - } - toJSON() { - let e = super.toJSON(); - e.autoClose = this.autoClose, e.curves = []; - for(let t = 0, n = this.curves.length; t < n; t++){ - let i = this.curves[t]; - e.curves.push(i.toJSON()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.autoClose = e.autoClose, this.curves = []; - for(let t = 0, n = e.curves.length; t < n; t++){ - let i = e.curves[t]; - this.curves.push(new Ta[i.type]().fromJSON(i)); - } - return this; - } -}, gr = class extends Ah { - constructor(e){ - super(); - this.type = "Path", this.currentPoint = new X, e && this.setFromPoints(e); - } - setFromPoints(e) { - this.moveTo(e[0].x, e[0].y); - for(let t = 1, n = e.length; t < n; t++)this.lineTo(e[t].x, e[t].y); - return this; - } - moveTo(e, t) { - return this.currentPoint.set(e, t), this; - } - lineTo(e, t) { - let n = new Or(this.currentPoint.clone(), new X(e, t)); - return this.curves.push(n), this.currentPoint.set(e, t), this; - } - quadraticCurveTo(e, t, n, i) { - let r = new co(this.currentPoint.clone(), new X(e, t), new X(n, i)); - return this.curves.push(r), this.currentPoint.set(n, i), this; - } - bezierCurveTo(e, t, n, i, r, o) { - let a = new lo(this.currentPoint.clone(), new X(e, t), new X(n, i), new X(r, o)); - return this.curves.push(a), this.currentPoint.set(r, o), this; - } - splineThru(e) { - let t = [ - this.currentPoint.clone() - ].concat(e), n = new uo(t); - return this.curves.push(n), this.currentPoint.copy(e[e.length - 1]), this; - } - arc(e, t, n, i, r, o) { - let a = this.currentPoint.x, l = this.currentPoint.y; - return this.absarc(e + a, t + l, n, i, r, o), this; - } - absarc(e, t, n, i, r, o) { - return this.absellipse(e, t, n, n, i, r, o), this; - } - ellipse(e, t, n, i, r, o, a, l) { - let c = this.currentPoint.x, h = this.currentPoint.y; - return this.absellipse(e + c, t + h, n, i, r, o, a, l), this; - } - absellipse(e, t, n, i, r, o, a, l) { - let c = new Ur(e, t, n, i, r, o, a, l); - if (this.curves.length > 0) { - let u = c.getPoint(0); - u.equals(this.currentPoint) || this.lineTo(u.x, u.y); - } - this.curves.push(c); - let h = c.getPoint(1); - return this.currentPoint.copy(h), this; - } - copy(e) { - return super.copy(e), this.currentPoint.copy(e.currentPoint), this; - } - toJSON() { - let e = super.toJSON(); - return e.currentPoint = this.currentPoint.toArray(), e; - } - fromJSON(e) { - return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this; - } -}, Xt = class extends gr { - constructor(e){ - super(e); - this.uuid = Et(), this.type = "Shape", this.holes = []; - } - getPointsHoles(e) { - let t = []; - for(let n = 0, i = this.holes.length; n < i; n++)t[n] = this.holes[n].getPoints(e); - return t; - } - extractPoints(e) { - return { - shape: this.getPoints(e), - holes: this.getPointsHoles(e) - }; - } - copy(e) { - super.copy(e), this.holes = []; - for(let t = 0, n = e.holes.length; t < n; t++){ - let i = e.holes[t]; - this.holes.push(i.clone()); - } - return this; - } - toJSON() { - let e = super.toJSON(); - e.uuid = this.uuid, e.holes = []; - for(let t = 0, n = this.holes.length; t < n; t++){ - let i = this.holes[t]; - e.holes.push(i.toJSON()); - } - return e; - } - fromJSON(e) { - super.fromJSON(e), this.uuid = e.uuid, this.holes = []; - for(let t = 0, n = e.holes.length; t < n; t++){ - let i = e.holes[t]; - this.holes.push(new gr().fromJSON(i)); - } - return this; - } -}, Ox = { - triangulate: function(s, e, t = 2) { - let n = e && e.length, i = n ? e[0] * t : s.length, r = Ch(s, 0, i, t, !0), o = []; - if (!r || r.next === r.prev) return o; - let a, l, c, h, u, d, f; - if (n && (r = Wx(s, e, r, t)), s.length > 80 * t) { - a = c = s[0], l = h = s[1]; - for(let m = t; m < i; m += t)u = s[m], d = s[m + 1], u < a && (a = u), d < l && (l = d), u > c && (c = u), d > h && (h = d); - f = Math.max(c - a, h - l), f = f !== 0 ? 1 / f : 0; - } - return xr(r, o, t, a, l, f), o; - } -}; -function Ch(s, e, t, n, i) { - let r, o; - if (i === ty(s, e, t, n) > 0) for(r = e; r < t; r += n)o = mc(r, s[r], s[r + 1], o); - else for(r = t - n; r >= e; r -= n)o = mc(r, s[r], s[r + 1], o); - return o && fo(o, o.next) && (vr(o), o = o.next), o; -} -function Tn(s, e) { - if (!s) return s; - e || (e = s); - let t = s, n; - do if (n = !1, !t.steiner && (fo(t, t.next) || $e(t.prev, t, t.next) === 0)) { - if (vr(t), t = e = t.prev, t === t.next) break; - n = !0; - } else t = t.next; - while (n || t !== e) - return e; -} -function xr(s, e, t, n, i, r, o) { - if (!s) return; - !o && r && Zx(s, n, i, r); - let a = s, l, c; - for(; s.prev !== s.next;){ - if (l = s.prev, c = s.next, r ? kx(s, n, i, r) : Hx(s)) { - e.push(l.i / t), e.push(s.i / t), e.push(c.i / t), vr(s), s = c.next, a = c.next; - continue; - } - if (s = c, s === a) { - o ? o === 1 ? (s = Gx(Tn(s), e, t), xr(s, e, t, n, i, r, 2)) : o === 2 && Vx(s, e, t, n, i, r) : xr(Tn(s), e, t, n, i, r, 1); - break; - } - } -} -function Hx(s) { - let e = s.prev, t = s, n = s.next; - if ($e(e, t, n) >= 0) return !1; - let i = s.next.next; - for(; i !== s.prev;){ - if (Si(e.x, e.y, t.x, t.y, n.x, n.y, i.x, i.y) && $e(i.prev, i, i.next) >= 0) return !1; - i = i.next; - } - return !0; -} -function kx(s, e, t, n) { - let i = s.prev, r = s, o = s.next; - if ($e(i, r, o) >= 0) return !1; - let a = i.x < r.x ? i.x < o.x ? i.x : o.x : r.x < o.x ? r.x : o.x, l = i.y < r.y ? i.y < o.y ? i.y : o.y : r.y < o.y ? r.y : o.y, c = i.x > r.x ? i.x > o.x ? i.x : o.x : r.x > o.x ? r.x : o.x, h = i.y > r.y ? i.y > o.y ? i.y : o.y : r.y > o.y ? r.y : o.y, u = oa(a, l, e, t, n), d = oa(c, h, e, t, n), f = s.prevZ, m = s.nextZ; - for(; f && f.z >= u && m && m.z <= d;){ - if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0 || (f = f.prevZ, m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0)) return !1; - m = m.nextZ; - } - for(; f && f.z >= u;){ - if (f !== s.prev && f !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, f.x, f.y) && $e(f.prev, f, f.next) >= 0) return !1; - f = f.prevZ; - } - for(; m && m.z <= d;){ - if (m !== s.prev && m !== s.next && Si(i.x, i.y, r.x, r.y, o.x, o.y, m.x, m.y) && $e(m.prev, m, m.next) >= 0) return !1; - m = m.nextZ; - } - return !0; -} -function Gx(s, e, t) { - let n = s; - do { - let i = n.prev, r = n.next.next; - !fo(i, r) && Lh(i, n, n.next, r) && yr(i, r) && yr(r, i) && (e.push(i.i / t), e.push(n.i / t), e.push(r.i / t), vr(n), vr(n.next), n = s = r), n = n.next; - }while (n !== s) - return Tn(n); -} -function Vx(s, e, t, n, i, r) { - let o = s; - do { - let a = o.next.next; - for(; a !== o.prev;){ - if (o.i !== a.i && Qx(o, a)) { - let l = Rh(o, a); - o = Tn(o, o.next), l = Tn(l, l.next), xr(o, e, t, n, i, r), xr(l, e, t, n, i, r); - return; - } - a = a.next; - } - o = o.next; - }while (o !== s) -} -function Wx(s, e, t, n) { - let i = [], r, o, a, l, c; - for(r = 0, o = e.length; r < o; r++)a = e[r] * n, l = r < o - 1 ? e[r + 1] * n : s.length, c = Ch(s, a, l, n, !1), c === c.next && (c.steiner = !0), i.push(jx(c)); - for(i.sort(qx), r = 0; r < i.length; r++)Xx(i[r], t), t = Tn(t, t.next); - return t; -} -function qx(s, e) { - return s.x - e.x; -} -function Xx(s, e) { - if (e = Jx(s, e), e) { - let t = Rh(e, s); - Tn(e, e.next), Tn(t, t.next); - } -} -function Jx(s, e) { - let t = e, n = s.x, i = s.y, r = -1 / 0, o; - do { - if (i <= t.y && i >= t.next.y && t.next.y !== t.y) { - let d = t.x + (i - t.y) * (t.next.x - t.x) / (t.next.y - t.y); - if (d <= n && d > r) { - if (r = d, d === n) { - if (i === t.y) return t; - if (i === t.next.y) return t.next; - } - o = t.x < t.next.x ? t : t.next; - } - } - t = t.next; - }while (t !== e) - if (!o) return null; - if (n === r) return o; - let a = o, l = o.x, c = o.y, h = 1 / 0, u; - t = o; - do n >= t.x && t.x >= l && n !== t.x && Si(i < c ? n : r, i, l, c, i < c ? r : n, i, t.x, t.y) && (u = Math.abs(i - t.y) / (n - t.x), yr(t, s) && (u < h || u === h && (t.x > o.x || t.x === o.x && Yx(o, t))) && (o = t, h = u)), t = t.next; - while (t !== a) - return o; -} -function Yx(s, e) { - return $e(s.prev, s, e.prev) < 0 && $e(e.next, s, s.next) < 0; -} -function Zx(s, e, t, n) { - let i = s; - do i.z === null && (i.z = oa(i.x, i.y, e, t, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next; - while (i !== s) - i.prevZ.nextZ = null, i.prevZ = null, $x(i); -} -function $x(s) { - let e, t, n, i, r, o, a, l, c = 1; - do { - for(t = s, s = null, r = null, o = 0; t;){ - for(o++, n = t, a = 0, e = 0; e < c && (a++, n = n.nextZ, !!n); e++); - for(l = c; a > 0 || l > 0 && n;)a !== 0 && (l === 0 || !n || t.z <= n.z) ? (i = t, t = t.nextZ, a--) : (i = n, n = n.nextZ, l--), r ? r.nextZ = i : s = i, i.prevZ = r, r = i; - t = n; - } - r.nextZ = null, c *= 2; - }while (o > 1) - return s; -} -function oa(s, e, t, n, i) { - return s = 32767 * (s - t) * i, e = 32767 * (e - n) * i, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, s | e << 1; -} -function jx(s) { - let e = s, t = s; - do (e.x < t.x || e.x === t.x && e.y < t.y) && (t = e), e = e.next; - while (e !== s) - return t; -} -function Si(s, e, t, n, i, r, o, a) { - return (i - o) * (e - a) - (s - o) * (r - a) >= 0 && (s - o) * (n - a) - (t - o) * (e - a) >= 0 && (t - o) * (r - a) - (i - o) * (n - a) >= 0; -} -function Qx(s, e) { - return s.next.i !== e.i && s.prev.i !== e.i && !Kx(s, e) && (yr(s, e) && yr(e, s) && ey(s, e) && ($e(s.prev, s, e.prev) || $e(s, e.prev, e)) || fo(s, e) && $e(s.prev, s, s.next) > 0 && $e(e.prev, e, e.next) > 0); -} -function $e(s, e, t) { - return (e.y - s.y) * (t.x - e.x) - (e.x - s.x) * (t.y - e.y); -} -function fo(s, e) { - return s.x === e.x && s.y === e.y; -} -function Lh(s, e, t, n) { - let i = ws($e(s, e, t)), r = ws($e(s, e, n)), o = ws($e(t, n, s)), a = ws($e(t, n, e)); - return !!(i !== r && o !== a || i === 0 && bs(s, t, e) || r === 0 && bs(s, n, e) || o === 0 && bs(t, s, n) || a === 0 && bs(t, e, n)); -} -function bs(s, e, t) { - return e.x <= Math.max(s.x, t.x) && e.x >= Math.min(s.x, t.x) && e.y <= Math.max(s.y, t.y) && e.y >= Math.min(s.y, t.y); -} -function ws(s) { - return s > 0 ? 1 : s < 0 ? -1 : 0; -} -function Kx(s, e) { - let t = s; - do { - if (t.i !== s.i && t.next.i !== s.i && t.i !== e.i && t.next.i !== e.i && Lh(t, t.next, s, e)) return !0; - t = t.next; - }while (t !== s) - return !1; -} -function yr(s, e) { - return $e(s.prev, s, s.next) < 0 ? $e(s, e, s.next) >= 0 && $e(s, s.prev, e) >= 0 : $e(s, e, s.prev) < 0 || $e(s, s.next, e) < 0; -} -function ey(s, e) { - let t = s, n = !1, i = (s.x + e.x) / 2, r = (s.y + e.y) / 2; - do t.y > r != t.next.y > r && t.next.y !== t.y && i < (t.next.x - t.x) * (r - t.y) / (t.next.y - t.y) + t.x && (n = !n), t = t.next; - while (t !== s) - return n; -} -function Rh(s, e) { - let t = new aa(s.i, s.x, s.y), n = new aa(e.i, e.x, e.y), i = s.next, r = e.prev; - return s.next = e, e.prev = s, t.next = i, i.prev = t, n.next = t, t.prev = n, r.next = n, n.prev = r, n; -} -function mc(s, e, t, n) { - let i = new aa(s, e, t); - return n ? (i.next = n.next, i.prev = n, n.next.prev = i, n.next = i) : (i.prev = i, i.next = i), i; -} -function vr(s) { - s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ); -} -function aa(s, e, t) { - this.i = s, this.x = e, this.y = t, this.prev = null, this.next = null, this.z = null, this.prevZ = null, this.nextZ = null, this.steiner = !1; -} -function ty(s, e, t, n) { - let i = 0; - for(let r = e, o = t - n; r < t; r += n)i += (s[o] - s[r]) * (s[r + 1] + s[o + 1]), o = r; - return i; -} -var Jt = class { - static area(e) { - let t = e.length, n = 0; - for(let i = t - 1, r = 0; r < t; i = r++)n += e[i].x * e[r].y - e[r].x * e[i].y; - return n * .5; - } - static isClockWise(e) { - return Jt.area(e) < 0; - } - static triangulateShape(e, t) { - let n = [], i = [], r = []; - gc(e), xc(n, e); - let o = e.length; - t.forEach(gc); - for(let l = 0; l < t.length; l++)i.push(o), o += t[l].length, xc(n, t[l]); - let a = Ox.triangulate(n, i); - for(let l = 0; l < a.length; l += 3)r.push(a.slice(l, l + 3)); - return r; - } -}; -function gc(s) { - let e = s.length; - e > 2 && s[e - 1].equals(s[0]) && s.pop(); -} -function xc(s, e) { - for(let t = 0; t < e.length; t++)s.push(e[t].x), s.push(e[t].y); -} -var ln = class extends _e { - constructor(e = new Xt([ - new X(.5, .5), - new X(-.5, .5), - new X(-.5, -.5), - new X(.5, -.5) - ]), t = {}){ - super(); - this.type = "ExtrudeGeometry", this.parameters = { - shapes: e, - options: t - }, e = Array.isArray(e) ? e : [ - e +function Zh(s1) { + let t = s1.length; + t > 2 && s1[t - 1].equals(s1[0]) && s1.pop(); +} +function Jh(s1, t) { + for(let e = 0; e < t.length; e++)s1.push(t[e].x), s1.push(t[e].y); +} +var Zo = class s1 extends Vt { + constructor(t = new Fn([ + new J(.5, .5), + new J(-.5, .5), + new J(-.5, -.5), + new J(.5, -.5) + ]), e = {}){ + super(), this.type = "ExtrudeGeometry", this.parameters = { + shapes: t, + options: e + }, t = Array.isArray(t) ? t : [ + t ]; let n = this, i = [], r = []; - for(let a = 0, l = e.length; a < l; a++){ - let c = e[a]; - o(c); - } - this.setAttribute("position", new de(i, 3)), this.setAttribute("uv", new de(r, 2)), this.computeVertexNormals(); - function o(a) { - let l = [], c = t.curveSegments !== void 0 ? t.curveSegments : 12, h = t.steps !== void 0 ? t.steps : 1, u = t.depth !== void 0 ? t.depth : 1, d = t.bevelEnabled !== void 0 ? t.bevelEnabled : !0, f = t.bevelThickness !== void 0 ? t.bevelThickness : .2, m = t.bevelSize !== void 0 ? t.bevelSize : f - .1, x = t.bevelOffset !== void 0 ? t.bevelOffset : 0, v = t.bevelSegments !== void 0 ? t.bevelSegments : 3, g = t.extrudePath, p = t.UVGenerator !== void 0 ? t.UVGenerator : ny; - t.amount !== void 0 && (console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."), u = t.amount); - let _, y = !1, b, A, L, I; - g && (_ = g.getSpacedPoints(h), y = !0, d = !1, b = g.computeFrenetFrames(h, !1), A = new M, L = new M, I = new M), d || (v = 0, f = 0, m = 0, x = 0); - let k = a.extractPoints(c), B = k.shape, P = k.holes; - if (!Jt.isClockWise(B)) { - B = B.reverse(); - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - Jt.isClockWise(K) && (P[G] = K.reverse()); + for(let o = 0, c = t.length; o < c; o++){ + let l = t[o]; + a(l); + } + this.setAttribute("position", new _t(i, 3)), this.setAttribute("uv", new _t(r, 2)), this.computeVertexNormals(); + function a(o) { + let c = [], l = e.curveSegments !== void 0 ? e.curveSegments : 12, h = e.steps !== void 0 ? e.steps : 1, u = e.depth !== void 0 ? e.depth : 1, d = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, f = e.bevelThickness !== void 0 ? e.bevelThickness : .2, m = e.bevelSize !== void 0 ? e.bevelSize : f - .1, x = e.bevelOffset !== void 0 ? e.bevelOffset : 0, g = e.bevelSegments !== void 0 ? e.bevelSegments : 3, p = e.extrudePath, v = e.UVGenerator !== void 0 ? e.UVGenerator : mx, _, y = !1, b, w, R, L; + p && (_ = p.getSpacedPoints(h), y = !0, d = !1, b = p.computeFrenetFrames(h, !1), w = new A, R = new A, L = new A), d || (g = 0, f = 0, m = 0, x = 0); + let M = o.extractPoints(l), E = M.shape, V = M.holes; + if (!yn.isClockWise(E)) { + E = E.reverse(); + for(let P = 0, at = V.length; P < at; P++){ + let Z = V[P]; + yn.isClockWise(Z) && (V[P] = Z.reverse()); } } - let E = Jt.triangulateShape(B, P), D = B; - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - B = B.concat(K); + let F = yn.triangulateShape(E, V), O = E; + for(let P = 0, at = V.length; P < at; P++){ + let Z = V[P]; + E = E.concat(Z); } - function U(G, j, K) { - return j || console.error("THREE.ExtrudeGeometry: vec does not exist"), j.clone().multiplyScalar(K).add(G); + function z(P, at, Z) { + return at || console.error("THREE.ExtrudeGeometry: vec does not exist"), P.clone().addScaledVector(at, Z); } - let F = B.length, O = E.length; - function ne(G, j, K) { - let ue, se, Se, Te = G.x - j.x, Pe = G.y - j.y, Ye = K.x - G.x, C = K.y - G.y, T = Te * Te + Pe * Pe, J = Te * C - Pe * Ye; - if (Math.abs(J) > Number.EPSILON) { - let $ = Math.sqrt(T), re = Math.sqrt(Ye * Ye + C * C), Z = j.x - Pe / $, Me = j.y + Te / $, ve = K.x - C / re, te = K.y + Ye / re, R = ((ve - Z) * C - (te - Me) * Ye) / (Te * C - Pe * Ye); - ue = Z + Te * R - G.x, se = Me + Pe * R - G.y; - let ee = ue * ue + se * se; - if (ee <= 2) return new X(ue, se); - Se = Math.sqrt(ee / 2); + let K = E.length, X = F.length; + function Y(P, at, Z) { + let st, Q, St, mt = P.x - at.x, xt = P.y - at.y, Dt = Z.x - P.x, Xt = Z.y - P.y, ie = mt * mt + xt * xt, C = mt * Xt - xt * Dt; + if (Math.abs(C) > Number.EPSILON) { + let S = Math.sqrt(ie), B = Math.sqrt(Dt * Dt + Xt * Xt), nt = at.x - xt / S, et = at.y + mt / S, it = Z.x - Xt / B, Mt = Z.y + Dt / B, rt = ((it - nt) * Xt - (Mt - et) * Dt) / (mt * Xt - xt * Dt); + st = nt + mt * rt - P.x, Q = et + xt * rt - P.y; + let k = st * st + Q * Q; + if (k <= 2) return new J(st, Q); + St = Math.sqrt(k / 2); } else { - let $ = !1; - Te > Number.EPSILON ? Ye > Number.EPSILON && ($ = !0) : Te < -Number.EPSILON ? Ye < -Number.EPSILON && ($ = !0) : Math.sign(Pe) === Math.sign(C) && ($ = !0), $ ? (ue = -Pe, se = Te, Se = Math.sqrt(T)) : (ue = Te, se = Pe, Se = Math.sqrt(T / 2)); + let S = !1; + mt > Number.EPSILON ? Dt > Number.EPSILON && (S = !0) : mt < -Number.EPSILON ? Dt < -Number.EPSILON && (S = !0) : Math.sign(xt) === Math.sign(Xt) && (S = !0), S ? (st = -xt, Q = mt, St = Math.sqrt(ie)) : (st = mt, Q = xt, St = Math.sqrt(ie / 2)); } - return new X(ue / Se, se / Se); + return new J(st / St, Q / St); } - let ce = []; - for(let G = 0, j = D.length, K = j - 1, ue = G + 1; G < j; G++, K++, ue++)K === j && (K = 0), ue === j && (ue = 0), ce[G] = ne(D[G], D[K], D[ue]); - let V = [], W, he = ce.concat(); - for(let G = 0, j = P.length; G < j; G++){ - let K = P[G]; - W = []; - for(let ue = 0, se = K.length, Se = se - 1, Te = ue + 1; ue < se; ue++, Se++, Te++)Se === se && (Se = 0), Te === se && (Te = 0), W[ue] = ne(K[ue], K[Se], K[Te]); - V.push(W), he = he.concat(W); + let j = []; + for(let P = 0, at = O.length, Z = at - 1, st = P + 1; P < at; P++, Z++, st++)Z === at && (Z = 0), st === at && (st = 0), j[P] = Y(O[P], O[Z], O[st]); + let tt = [], N, q = j.concat(); + for(let P = 0, at = V.length; P < at; P++){ + let Z = V[P]; + N = []; + for(let st = 0, Q = Z.length, St = Q - 1, mt = st + 1; st < Q; st++, St++, mt++)St === Q && (St = 0), mt === Q && (mt = 0), N[st] = Y(Z[st], Z[St], Z[mt]); + tt.push(N), q = q.concat(N); } - for(let G = 0; G < v; G++){ - let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; - for(let se = 0, Se = D.length; se < Se; se++){ - let Te = U(D[se], ce[se], ue); - Ce(Te.x, Te.y, -K); + for(let P = 0; P < g; P++){ + let at = P / g, Z = f * Math.cos(at * Math.PI / 2), st = m * Math.sin(at * Math.PI / 2) + x; + for(let Q = 0, St = O.length; Q < St; Q++){ + let mt = z(O[Q], j[Q], st); + Tt(mt.x, mt.y, -Z); } - for(let se = 0, Se = P.length; se < Se; se++){ - let Te = P[se]; - W = V[se]; - for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ - let C = U(Te[Pe], W[Pe], ue); - Ce(C.x, C.y, -K); + for(let Q = 0, St = V.length; Q < St; Q++){ + let mt = V[Q]; + N = tt[Q]; + for(let xt = 0, Dt = mt.length; xt < Dt; xt++){ + let Xt = z(mt[xt], N[xt], st); + Tt(Xt.x, Xt.y, -Z); } } } - let le = m + x; - for(let G = 0; G < F; G++){ - let j = d ? U(B[G], he[G], le) : B[G]; - y ? (L.copy(b.normals[0]).multiplyScalar(j.x), A.copy(b.binormals[0]).multiplyScalar(j.y), I.copy(_[0]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(j.x, j.y, 0); + let lt = m + x; + for(let P = 0; P < K; P++){ + let at = d ? z(E[P], q[P], lt) : E[P]; + y ? (R.copy(b.normals[0]).multiplyScalar(at.x), w.copy(b.binormals[0]).multiplyScalar(at.y), L.copy(_[0]).add(R).add(w), Tt(L.x, L.y, L.z)) : Tt(at.x, at.y, 0); } - for(let G = 1; G <= h; G++)for(let j = 0; j < F; j++){ - let K = d ? U(B[j], he[j], le) : B[j]; - y ? (L.copy(b.normals[G]).multiplyScalar(K.x), A.copy(b.binormals[G]).multiplyScalar(K.y), I.copy(_[G]).add(L).add(A), Ce(I.x, I.y, I.z)) : Ce(K.x, K.y, u / h * G); + for(let P = 1; P <= h; P++)for(let at = 0; at < K; at++){ + let Z = d ? z(E[at], q[at], lt) : E[at]; + y ? (R.copy(b.normals[P]).multiplyScalar(Z.x), w.copy(b.binormals[P]).multiplyScalar(Z.y), L.copy(_[P]).add(R).add(w), Tt(L.x, L.y, L.z)) : Tt(Z.x, Z.y, u / h * P); } - for(let G = v - 1; G >= 0; G--){ - let j = G / v, K = f * Math.cos(j * Math.PI / 2), ue = m * Math.sin(j * Math.PI / 2) + x; - for(let se = 0, Se = D.length; se < Se; se++){ - let Te = U(D[se], ce[se], ue); - Ce(Te.x, Te.y, u + K); + for(let P = g - 1; P >= 0; P--){ + let at = P / g, Z = f * Math.cos(at * Math.PI / 2), st = m * Math.sin(at * Math.PI / 2) + x; + for(let Q = 0, St = O.length; Q < St; Q++){ + let mt = z(O[Q], j[Q], st); + Tt(mt.x, mt.y, u + Z); } - for(let se = 0, Se = P.length; se < Se; se++){ - let Te = P[se]; - W = V[se]; - for(let Pe = 0, Ye = Te.length; Pe < Ye; Pe++){ - let C = U(Te[Pe], W[Pe], ue); - y ? Ce(C.x, C.y + _[h - 1].y, _[h - 1].x + K) : Ce(C.x, C.y, u + K); + for(let Q = 0, St = V.length; Q < St; Q++){ + let mt = V[Q]; + N = tt[Q]; + for(let xt = 0, Dt = mt.length; xt < Dt; xt++){ + let Xt = z(mt[xt], N[xt], st); + y ? Tt(Xt.x, Xt.y + _[h - 1].y, _[h - 1].x + Z) : Tt(Xt.x, Xt.y, u + Z); } } } - fe(), Be(); - function fe() { - let G = i.length / 3; + ut(), pt(); + function ut() { + let P = i.length / 3; if (d) { - let j = 0, K = F * j; - for(let ue = 0; ue < O; ue++){ - let se = E[ue]; - ye(se[2] + K, se[1] + K, se[0] + K); + let at = 0, Z = K * at; + for(let st = 0; st < X; st++){ + let Q = F[st]; + wt(Q[2] + Z, Q[1] + Z, Q[0] + Z); } - j = h + v * 2, K = F * j; - for(let ue = 0; ue < O; ue++){ - let se = E[ue]; - ye(se[0] + K, se[1] + K, se[2] + K); + at = h + g * 2, Z = K * at; + for(let st = 0; st < X; st++){ + let Q = F[st]; + wt(Q[0] + Z, Q[1] + Z, Q[2] + Z); } } else { - for(let j = 0; j < O; j++){ - let K = E[j]; - ye(K[2], K[1], K[0]); + for(let at = 0; at < X; at++){ + let Z = F[at]; + wt(Z[2], Z[1], Z[0]); } - for(let j = 0; j < O; j++){ - let K = E[j]; - ye(K[0] + F * h, K[1] + F * h, K[2] + F * h); + for(let at = 0; at < X; at++){ + let Z = F[at]; + wt(Z[0] + K * h, Z[1] + K * h, Z[2] + K * h); } } - n.addGroup(G, i.length / 3 - G, 0); + n.addGroup(P, i.length / 3 - P, 0); } - function Be() { - let G = i.length / 3, j = 0; - Y(D, j), j += D.length; - for(let K = 0, ue = P.length; K < ue; K++){ - let se = P[K]; - Y(se, j), j += se.length; + function pt() { + let P = i.length / 3, at = 0; + Et(O, at), at += O.length; + for(let Z = 0, st = V.length; Z < st; Z++){ + let Q = V[Z]; + Et(Q, at), at += Q.length; } - n.addGroup(G, i.length / 3 - G, 1); + n.addGroup(P, i.length / 3 - P, 1); } - function Y(G, j) { - let K = G.length; - for(; --K >= 0;){ - let ue = K, se = K - 1; - se < 0 && (se = G.length - 1); - for(let Se = 0, Te = h + v * 2; Se < Te; Se++){ - let Pe = F * Se, Ye = F * (Se + 1), C = j + ue + Pe, T = j + se + Pe, J = j + se + Ye, $ = j + ue + Ye; - ge(C, T, J, $); + function Et(P, at) { + let Z = P.length; + for(; --Z >= 0;){ + let st = Z, Q = Z - 1; + Q < 0 && (Q = P.length - 1); + for(let St = 0, mt = h + g * 2; St < mt; St++){ + let xt = K * St, Dt = K * (St + 1), Xt = at + st + xt, ie = at + Q + xt, C = at + Q + Dt, S = at + st + Dt; + Yt(Xt, ie, C, S); } } } - function Ce(G, j, K) { - l.push(G), l.push(j), l.push(K); + function Tt(P, at, Z) { + c.push(P), c.push(at), c.push(Z); } - function ye(G, j, K) { - xe(G), xe(j), xe(K); - let ue = i.length / 3, se = p.generateTopUV(n, i, ue - 3, ue - 2, ue - 1); - Oe(se[0]), Oe(se[1]), Oe(se[2]); + function wt(P, at, Z) { + te(P), te(at), te(Z); + let st = i.length / 3, Q = v.generateTopUV(n, i, st - 3, st - 2, st - 1); + Pt(Q[0]), Pt(Q[1]), Pt(Q[2]); } - function ge(G, j, K, ue) { - xe(G), xe(j), xe(ue), xe(j), xe(K), xe(ue); - let se = i.length / 3, Se = p.generateSideWallUV(n, i, se - 6, se - 3, se - 2, se - 1); - Oe(Se[0]), Oe(Se[1]), Oe(Se[3]), Oe(Se[1]), Oe(Se[2]), Oe(Se[3]); + function Yt(P, at, Z, st) { + te(P), te(at), te(st), te(at), te(Z), te(st); + let Q = i.length / 3, St = v.generateSideWallUV(n, i, Q - 6, Q - 3, Q - 2, Q - 1); + Pt(St[0]), Pt(St[1]), Pt(St[3]), Pt(St[1]), Pt(St[2]), Pt(St[3]); } - function xe(G) { - i.push(l[G * 3 + 0]), i.push(l[G * 3 + 1]), i.push(l[G * 3 + 2]); + function te(P) { + i.push(c[P * 3 + 0]), i.push(c[P * 3 + 1]), i.push(c[P * 3 + 2]); } - function Oe(G) { - r.push(G.x), r.push(G.y); + function Pt(P) { + r.push(P.x), r.push(P.y); } } } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } toJSON() { - let e = super.toJSON(), t = this.parameters.shapes, n = this.parameters.options; - return iy(t, n, e); + let t = super.toJSON(), e = this.parameters.shapes, n = this.parameters.options; + return gx(e, n, t); } - static fromJSON(e, t) { + static fromJSON(t, e) { let n = []; - for(let r = 0, o = e.shapes.length; r < o; r++){ - let a = t[e.shapes[r]]; - n.push(a); + for(let r = 0, a = t.shapes.length; r < a; r++){ + let o = e[t.shapes[r]]; + n.push(o); } - let i = e.options.extrudePath; - return i !== void 0 && (e.options.extrudePath = new Ta[i.type]().fromJSON(i)), new ln(n, e.options); + let i = t.options.extrudePath; + return i !== void 0 && (t.options.extrudePath = new Gc[i.type]().fromJSON(i)), new s1(n, t.options); } -}, ny = { - generateTopUV: function(s, e, t, n, i) { - let r = e[t * 3], o = e[t * 3 + 1], a = e[n * 3], l = e[n * 3 + 1], c = e[i * 3], h = e[i * 3 + 1]; +}, mx = { + generateTopUV: function(s1, t, e, n, i) { + let r = t[e * 3], a = t[e * 3 + 1], o = t[n * 3], c = t[n * 3 + 1], l = t[i * 3], h = t[i * 3 + 1]; return [ - new X(r, o), - new X(a, l), - new X(c, h) + new J(r, a), + new J(o, c), + new J(l, h) ]; }, - generateSideWallUV: function(s, e, t, n, i, r) { - let o = e[t * 3], a = e[t * 3 + 1], l = e[t * 3 + 2], c = e[n * 3], h = e[n * 3 + 1], u = e[n * 3 + 2], d = e[i * 3], f = e[i * 3 + 1], m = e[i * 3 + 2], x = e[r * 3], v = e[r * 3 + 1], g = e[r * 3 + 2]; - return Math.abs(a - h) < Math.abs(o - c) ? [ - new X(o, 1 - l), - new X(c, 1 - u), - new X(d, 1 - m), - new X(x, 1 - g) + generateSideWallUV: function(s1, t, e, n, i, r) { + let a = t[e * 3], o = t[e * 3 + 1], c = t[e * 3 + 2], l = t[n * 3], h = t[n * 3 + 1], u = t[n * 3 + 2], d = t[i * 3], f = t[i * 3 + 1], m = t[i * 3 + 2], x = t[r * 3], g = t[r * 3 + 1], p = t[r * 3 + 2]; + return Math.abs(o - h) < Math.abs(a - l) ? [ + new J(a, 1 - c), + new J(l, 1 - u), + new J(d, 1 - m), + new J(x, 1 - p) ] : [ - new X(a, 1 - l), - new X(h, 1 - u), - new X(f, 1 - m), - new X(v, 1 - g) + new J(o, 1 - c), + new J(h, 1 - u), + new J(f, 1 - m), + new J(g, 1 - p) ]; } }; -function iy(s, e, t) { - if (t.shapes = [], Array.isArray(s)) for(let n = 0, i = s.length; n < i; n++){ - let r = s[n]; - t.shapes.push(r.uuid); +function gx(s1, t, e) { + if (e.shapes = [], Array.isArray(s1)) for(let n = 0, i = s1.length; n < i; n++){ + let r = s1[n]; + e.shapes.push(r.uuid); } - else t.shapes.push(s.uuid); - return e.extrudePath !== void 0 && (t.options.extrudePath = e.extrudePath.toJSON()), t; + else e.shapes.push(s1.uuid); + return e.options = Object.assign({}, t), t.extrudePath !== void 0 && (e.options.extrudePath = t.extrudePath.toJSON()), e; } -var _r = class extends an { - constructor(e = 1, t = 0){ +var Jo = class s1 extends di { + constructor(t = 1, e = 0){ let n = (1 + Math.sqrt(5)) / 2, i = [ -1, n, @@ -13908,58 +15518,16 @@ var _r = class extends an { 8, 1 ]; - super(i, r, e, t); - this.type = "IcosahedronGeometry", this.parameters = { - radius: e, - detail: t + super(i, r, t, e), this.type = "IcosahedronGeometry", this.parameters = { + radius: t, + detail: e }; } - static fromJSON(e) { - return new _r(e.radius, e.detail); - } -}, Mr = class extends _e { - constructor(e = [ - new X(0, .5), - new X(.5, 0), - new X(0, -.5) - ], t = 12, n = 0, i = Math.PI * 2){ - super(); - this.type = "LatheGeometry", this.parameters = { - points: e, - segments: t, - phiStart: n, - phiLength: i - }, t = Math.floor(t), i = mt(i, 0, Math.PI * 2); - let r = [], o = [], a = [], l = [], c = [], h = 1 / t, u = new M, d = new X, f = new M, m = new M, x = new M, v = 0, g = 0; - for(let p = 0; p <= e.length - 1; p++)switch(p){ - case 0: - v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, x.copy(f), f.normalize(), l.push(f.x, f.y, f.z); - break; - case e.length - 1: - l.push(x.x, x.y, x.z); - break; - default: - v = e[p + 1].x - e[p].x, g = e[p + 1].y - e[p].y, f.x = g * 1, f.y = -v, f.z = g * 0, m.copy(f), f.x += x.x, f.y += x.y, f.z += x.z, f.normalize(), l.push(f.x, f.y, f.z), x.copy(m); - } - for(let p = 0; p <= t; p++){ - let _ = n + p * h * i, y = Math.sin(_), b = Math.cos(_); - for(let A = 0; A <= e.length - 1; A++){ - u.x = e[A].x * y, u.y = e[A].y, u.z = e[A].x * b, o.push(u.x, u.y, u.z), d.x = p / t, d.y = A / (e.length - 1), a.push(d.x, d.y); - let L = l[3 * A + 0] * y, I = l[3 * A + 1], k = l[3 * A + 0] * b; - c.push(L, I, k); - } - } - for(let p = 0; p < t; p++)for(let _ = 0; _ < e.length - 1; _++){ - let y = _ + p * e.length, b = y, A = y + e.length, L = y + e.length + 1, I = y + 1; - r.push(b, A, I), r.push(A, L, I); - } - this.setIndex(r), this.setAttribute("position", new de(o, 3)), this.setAttribute("uv", new de(a, 2)), this.setAttribute("normal", new de(c, 3)); + static fromJSON(t) { + return new s1(t.radius, t.detail); } - static fromJSON(e) { - return new Mr(e.points, e.segments, e.phiStart, e.phiLength); - } -}, Ii = class extends an { - constructor(e = 1, t = 0){ +}, aa = class s1 extends di { + constructor(t = 1, e = 0){ let n = [ 1, 0, @@ -14005,137 +15573,142 @@ var _r = class extends an { 4, 2 ]; - super(n, i, e, t); - this.type = "OctahedronGeometry", this.parameters = { - radius: e, - detail: t + super(n, i, t, e), this.type = "OctahedronGeometry", this.parameters = { + radius: t, + detail: e }; } - static fromJSON(e) { - return new Ii(e.radius, e.detail); + static fromJSON(t) { + return new s1(t.radius, t.detail); } -}, br = class extends _e { - constructor(e = .5, t = 1, n = 8, i = 1, r = 0, o = Math.PI * 2){ - super(); - this.type = "RingGeometry", this.parameters = { - innerRadius: e, - outerRadius: t, +}, $o = class s1 extends Vt { + constructor(t = .5, e = 1, n = 32, i = 1, r = 0, a = Math.PI * 2){ + super(), this.type = "RingGeometry", this.parameters = { + innerRadius: t, + outerRadius: e, thetaSegments: n, phiSegments: i, thetaStart: r, - thetaLength: o + thetaLength: a }, n = Math.max(3, n), i = Math.max(1, i); - let a = [], l = [], c = [], h = [], u = e, d = (t - e) / i, f = new M, m = new X; + let o = [], c = [], l = [], h = [], u = t, d = (e - t) / i, f = new A, m = new J; for(let x = 0; x <= i; x++){ - for(let v = 0; v <= n; v++){ - let g = r + v / n * o; - f.x = u * Math.cos(g), f.y = u * Math.sin(g), l.push(f.x, f.y, f.z), c.push(0, 0, 1), m.x = (f.x / t + 1) / 2, m.y = (f.y / t + 1) / 2, h.push(m.x, m.y); + for(let g = 0; g <= n; g++){ + let p = r + g / n * a; + f.x = u * Math.cos(p), f.y = u * Math.sin(p), c.push(f.x, f.y, f.z), l.push(0, 0, 1), m.x = (f.x / e + 1) / 2, m.y = (f.y / e + 1) / 2, h.push(m.x, m.y); } u += d; } for(let x = 0; x < i; x++){ - let v = x * (n + 1); - for(let g = 0; g < n; g++){ - let p = g + v, _ = p, y = p + n + 1, b = p + n + 2, A = p + 1; - a.push(_, y, A), a.push(y, b, A); + let g = x * (n + 1); + for(let p = 0; p < n; p++){ + let v = p + g, _ = v, y = v + n + 1, b = v + n + 2, w = v + 1; + o.push(_, y, w), o.push(y, b, w); } } - this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); + this.setIndex(o), this.setAttribute("position", new _t(c, 3)), this.setAttribute("normal", new _t(l, 3)), this.setAttribute("uv", new _t(h, 2)); } - static fromJSON(e) { - return new br(e.innerRadius, e.outerRadius, e.thetaSegments, e.phiSegments, e.thetaStart, e.thetaLength); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, Di = class extends _e { - constructor(e = new Xt([ - new X(0, .5), - new X(-.5, -.5), - new X(.5, -.5) - ]), t = 12){ - super(); - this.type = "ShapeGeometry", this.parameters = { - shapes: e, - curveSegments: t + static fromJSON(t) { + return new s1(t.innerRadius, t.outerRadius, t.thetaSegments, t.phiSegments, t.thetaStart, t.thetaLength); + } +}, Ko = class s1 extends Vt { + constructor(t = new Fn([ + new J(0, .5), + new J(-.5, -.5), + new J(.5, -.5) + ]), e = 12){ + super(), this.type = "ShapeGeometry", this.parameters = { + shapes: t, + curveSegments: e }; - let n = [], i = [], r = [], o = [], a = 0, l = 0; - if (Array.isArray(e) === !1) c(e); - else for(let h = 0; h < e.length; h++)c(e[h]), this.addGroup(a, l, h), a += l, l = 0; - this.setIndex(n), this.setAttribute("position", new de(i, 3)), this.setAttribute("normal", new de(r, 3)), this.setAttribute("uv", new de(o, 2)); - function c(h) { - let u = i.length / 3, d = h.extractPoints(t), f = d.shape, m = d.holes; - Jt.isClockWise(f) === !1 && (f = f.reverse()); - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v]; - Jt.isClockWise(p) === !0 && (m[v] = p.reverse()); + let n = [], i = [], r = [], a = [], o = 0, c = 0; + if (Array.isArray(t) === !1) l(t); + else for(let h = 0; h < t.length; h++)l(t[h]), this.addGroup(o, c, h), o += c, c = 0; + this.setIndex(n), this.setAttribute("position", new _t(i, 3)), this.setAttribute("normal", new _t(r, 3)), this.setAttribute("uv", new _t(a, 2)); + function l(h) { + let u = i.length / 3, d = h.extractPoints(e), f = d.shape, m = d.holes; + yn.isClockWise(f) === !1 && (f = f.reverse()); + for(let g = 0, p = m.length; g < p; g++){ + let v = m[g]; + yn.isClockWise(v) === !0 && (m[g] = v.reverse()); } - let x = Jt.triangulateShape(f, m); - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v]; - f = f.concat(p); + let x = yn.triangulateShape(f, m); + for(let g = 0, p = m.length; g < p; g++){ + let v = m[g]; + f = f.concat(v); } - for(let v = 0, g = f.length; v < g; v++){ - let p = f[v]; - i.push(p.x, p.y, 0), r.push(0, 0, 1), o.push(p.x, p.y); + for(let g = 0, p = f.length; g < p; g++){ + let v = f[g]; + i.push(v.x, v.y, 0), r.push(0, 0, 1), a.push(v.x, v.y); } - for(let v = 0, g = x.length; v < g; v++){ - let p = x[v], _ = p[0] + u, y = p[1] + u, b = p[2] + u; - n.push(_, y, b), l += 3; + for(let g = 0, p = x.length; g < p; g++){ + let v = x[g], _ = v[0] + u, y = v[1] + u, b = v[2] + u; + n.push(_, y, b), c += 3; } } } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } toJSON() { - let e = super.toJSON(), t = this.parameters.shapes; - return ry(t, e); + let t = super.toJSON(), e = this.parameters.shapes; + return _x(e, t); } - static fromJSON(e, t) { + static fromJSON(t, e) { let n = []; - for(let i = 0, r = e.shapes.length; i < r; i++){ - let o = t[e.shapes[i]]; - n.push(o); + for(let i = 0, r = t.shapes.length; i < r; i++){ + let a = e[t.shapes[i]]; + n.push(a); } - return new Di(n, e.curveSegments); + return new s1(n, t.curveSegments); } }; -function ry(s, e) { - if (e.shapes = [], Array.isArray(s)) for(let t = 0, n = s.length; t < n; t++){ - let i = s[t]; - e.shapes.push(i.uuid); +function _x(s1, t) { + if (t.shapes = [], Array.isArray(s1)) for(let e = 0, n = s1.length; e < n; e++){ + let i = s1[e]; + t.shapes.push(i.uuid); } - else e.shapes.push(s.uuid); - return e; + else t.shapes.push(s1.uuid); + return t; } -var Fi = class extends _e { - constructor(e = 1, t = 32, n = 16, i = 0, r = Math.PI * 2, o = 0, a = Math.PI){ - super(); - this.type = "SphereGeometry", this.parameters = { - radius: e, - widthSegments: t, +var oa = class s1 extends Vt { + constructor(t = 1, e = 32, n = 16, i = 0, r = Math.PI * 2, a = 0, o = Math.PI){ + super(), this.type = "SphereGeometry", this.parameters = { + radius: t, + widthSegments: e, heightSegments: n, phiStart: i, phiLength: r, - thetaStart: o, - thetaLength: a - }, t = Math.max(3, Math.floor(t)), n = Math.max(2, Math.floor(n)); - let l = Math.min(o + a, Math.PI), c = 0, h = [], u = new M, d = new M, f = [], m = [], x = [], v = []; - for(let g = 0; g <= n; g++){ - let p = [], _ = g / n, y = 0; - g == 0 && o == 0 ? y = .5 / t : g == n && l == Math.PI && (y = -.5 / t); - for(let b = 0; b <= t; b++){ - let A = b / t; - u.x = -e * Math.cos(i + A * r) * Math.sin(o + _ * a), u.y = e * Math.cos(o + _ * a), u.z = e * Math.sin(i + A * r) * Math.sin(o + _ * a), m.push(u.x, u.y, u.z), d.copy(u).normalize(), x.push(d.x, d.y, d.z), v.push(A + y, 1 - _), p.push(c++); + thetaStart: a, + thetaLength: o + }, e = Math.max(3, Math.floor(e)), n = Math.max(2, Math.floor(n)); + let c = Math.min(a + o, Math.PI), l = 0, h = [], u = new A, d = new A, f = [], m = [], x = [], g = []; + for(let p = 0; p <= n; p++){ + let v = [], _ = p / n, y = 0; + p === 0 && a === 0 ? y = .5 / e : p === n && c === Math.PI && (y = -.5 / e); + for(let b = 0; b <= e; b++){ + let w = b / e; + u.x = -t * Math.cos(i + w * r) * Math.sin(a + _ * o), u.y = t * Math.cos(a + _ * o), u.z = t * Math.sin(i + w * r) * Math.sin(a + _ * o), m.push(u.x, u.y, u.z), d.copy(u).normalize(), x.push(d.x, d.y, d.z), g.push(w + y, 1 - _), v.push(l++); } - h.push(p); + h.push(v); } - for(let g = 0; g < n; g++)for(let p = 0; p < t; p++){ - let _ = h[g][p + 1], y = h[g][p], b = h[g + 1][p], A = h[g + 1][p + 1]; - (g !== 0 || o > 0) && f.push(_, y, A), (g !== n - 1 || l < Math.PI) && f.push(y, b, A); + for(let p = 0; p < n; p++)for(let v = 0; v < e; v++){ + let _ = h[p][v + 1], y = h[p][v], b = h[p + 1][v], w = h[p + 1][v + 1]; + (p !== 0 || a > 0) && f.push(_, y, w), (p !== n - 1 || c < Math.PI) && f.push(y, b, w); } - this.setIndex(f), this.setAttribute("position", new de(m, 3)), this.setAttribute("normal", new de(x, 3)), this.setAttribute("uv", new de(v, 2)); + this.setIndex(f), this.setAttribute("position", new _t(m, 3)), this.setAttribute("normal", new _t(x, 3)), this.setAttribute("uv", new _t(g, 2)); } - static fromJSON(e) { - return new Fi(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, wr = class extends an { - constructor(e = 1, t = 0){ + static fromJSON(t) { + return new s1(t.radius, t.widthSegments, t.heightSegments, t.phiStart, t.phiLength, t.thetaStart, t.thetaLength); + } +}, Qo = class s1 extends di { + constructor(t = 1, e = 0){ let n = [ 1, 1, @@ -14163,1205 +15736,1190 @@ var Fi = class extends _e { 3, 1 ]; - super(n, i, e, t); - this.type = "TetrahedronGeometry", this.parameters = { - radius: e, - detail: t + super(n, i, t, e), this.type = "TetrahedronGeometry", this.parameters = { + radius: t, + detail: e }; } - static fromJSON(e) { - return new wr(e.radius, e.detail); + static fromJSON(t) { + return new s1(t.radius, t.detail); } -}, Sr = class extends _e { - constructor(e = 1, t = .4, n = 8, i = 6, r = Math.PI * 2){ - super(); - this.type = "TorusGeometry", this.parameters = { - radius: e, - tube: t, +}, jo = class s1 extends Vt { + constructor(t = 1, e = .4, n = 12, i = 48, r = Math.PI * 2){ + super(), this.type = "TorusGeometry", this.parameters = { + radius: t, + tube: e, radialSegments: n, tubularSegments: i, arc: r }, n = Math.floor(n), i = Math.floor(i); - let o = [], a = [], l = [], c = [], h = new M, u = new M, d = new M; + let a = [], o = [], c = [], l = [], h = new A, u = new A, d = new A; for(let f = 0; f <= n; f++)for(let m = 0; m <= i; m++){ - let x = m / i * r, v = f / n * Math.PI * 2; - u.x = (e + t * Math.cos(v)) * Math.cos(x), u.y = (e + t * Math.cos(v)) * Math.sin(x), u.z = t * Math.sin(v), a.push(u.x, u.y, u.z), h.x = e * Math.cos(x), h.y = e * Math.sin(x), d.subVectors(u, h).normalize(), l.push(d.x, d.y, d.z), c.push(m / i), c.push(f / n); + let x = m / i * r, g = f / n * Math.PI * 2; + u.x = (t + e * Math.cos(g)) * Math.cos(x), u.y = (t + e * Math.cos(g)) * Math.sin(x), u.z = e * Math.sin(g), o.push(u.x, u.y, u.z), h.x = t * Math.cos(x), h.y = t * Math.sin(x), d.subVectors(u, h).normalize(), c.push(d.x, d.y, d.z), l.push(m / i), l.push(f / n); } for(let f = 1; f <= n; f++)for(let m = 1; m <= i; m++){ - let x = (i + 1) * f + m - 1, v = (i + 1) * (f - 1) + m - 1, g = (i + 1) * (f - 1) + m, p = (i + 1) * f + m; - o.push(x, v, p), o.push(v, g, p); + let x = (i + 1) * f + m - 1, g = (i + 1) * (f - 1) + m - 1, p = (i + 1) * (f - 1) + m, v = (i + 1) * f + m; + a.push(x, g, v), a.push(g, p, v); } - this.setIndex(o), this.setAttribute("position", new de(a, 3)), this.setAttribute("normal", new de(l, 3)), this.setAttribute("uv", new de(c, 2)); + this.setIndex(a), this.setAttribute("position", new _t(o, 3)), this.setAttribute("normal", new _t(c, 3)), this.setAttribute("uv", new _t(l, 2)); } - static fromJSON(e) { - return new Sr(e.radius, e.tube, e.radialSegments, e.tubularSegments, e.arc); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, Tr = class extends _e { - constructor(e = 1, t = .4, n = 64, i = 8, r = 2, o = 3){ - super(); - this.type = "TorusKnotGeometry", this.parameters = { - radius: e, - tube: t, + static fromJSON(t) { + return new s1(t.radius, t.tube, t.radialSegments, t.tubularSegments, t.arc); + } +}, tc = class s1 extends Vt { + constructor(t = 1, e = .4, n = 64, i = 8, r = 2, a = 3){ + super(), this.type = "TorusKnotGeometry", this.parameters = { + radius: t, + tube: e, tubularSegments: n, radialSegments: i, p: r, - q: o + q: a }, n = Math.floor(n), i = Math.floor(i); - let a = [], l = [], c = [], h = [], u = new M, d = new M, f = new M, m = new M, x = new M, v = new M, g = new M; + let o = [], c = [], l = [], h = [], u = new A, d = new A, f = new A, m = new A, x = new A, g = new A, p = new A; for(let _ = 0; _ <= n; ++_){ let y = _ / n * r * Math.PI * 2; - p(y, r, o, e, f), p(y + .01, r, o, e, m), v.subVectors(m, f), g.addVectors(m, f), x.crossVectors(v, g), g.crossVectors(x, v), x.normalize(), g.normalize(); + v(y, r, a, t, f), v(y + .01, r, a, t, m), g.subVectors(m, f), p.addVectors(m, f), x.crossVectors(g, p), p.crossVectors(x, g), x.normalize(), p.normalize(); for(let b = 0; b <= i; ++b){ - let A = b / i * Math.PI * 2, L = -t * Math.cos(A), I = t * Math.sin(A); - u.x = f.x + (L * g.x + I * x.x), u.y = f.y + (L * g.y + I * x.y), u.z = f.z + (L * g.z + I * x.z), l.push(u.x, u.y, u.z), d.subVectors(u, f).normalize(), c.push(d.x, d.y, d.z), h.push(_ / n), h.push(b / i); + let w = b / i * Math.PI * 2, R = -e * Math.cos(w), L = e * Math.sin(w); + u.x = f.x + (R * p.x + L * x.x), u.y = f.y + (R * p.y + L * x.y), u.z = f.z + (R * p.z + L * x.z), c.push(u.x, u.y, u.z), d.subVectors(u, f).normalize(), l.push(d.x, d.y, d.z), h.push(_ / n), h.push(b / i); } } for(let _ = 1; _ <= n; _++)for(let y = 1; y <= i; y++){ - let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; - a.push(b, A, I), a.push(A, L, I); + let b = (i + 1) * (_ - 1) + (y - 1), w = (i + 1) * _ + (y - 1), R = (i + 1) * _ + y, L = (i + 1) * (_ - 1) + y; + o.push(b, w, L), o.push(w, R, L); } - this.setIndex(a), this.setAttribute("position", new de(l, 3)), this.setAttribute("normal", new de(c, 3)), this.setAttribute("uv", new de(h, 2)); - function p(_, y, b, A, L) { - let I = Math.cos(_), k = Math.sin(_), B = b / y * _, P = Math.cos(B); - L.x = A * (2 + P) * .5 * I, L.y = A * (2 + P) * k * .5, L.z = A * Math.sin(B) * .5; + this.setIndex(o), this.setAttribute("position", new _t(c, 3)), this.setAttribute("normal", new _t(l, 3)), this.setAttribute("uv", new _t(h, 2)); + function v(_, y, b, w, R) { + let L = Math.cos(_), M = Math.sin(_), E = b / y * _, V = Math.cos(E); + R.x = w * (2 + V) * .5 * L, R.y = w * (2 + V) * M * .5, R.z = w * Math.sin(E) * .5; } } - static fromJSON(e) { - return new Tr(e.radius, e.tube, e.tubularSegments, e.radialSegments, e.p, e.q); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, Er = class extends _e { - constructor(e = new ho(new M(-1, -1, 0), new M(-1, 1, 0), new M(1, 1, 0)), t = 64, n = 1, i = 8, r = !1){ - super(); - this.type = "TubeGeometry", this.parameters = { - path: e, - tubularSegments: t, + static fromJSON(t) { + return new s1(t.radius, t.tube, t.tubularSegments, t.radialSegments, t.p, t.q); + } +}, ec = class s1 extends Vt { + constructor(t = new ia(new A(-1, -1, 0), new A(-1, 1, 0), new A(1, 1, 0)), e = 64, n = 1, i = 8, r = !1){ + super(), this.type = "TubeGeometry", this.parameters = { + path: t, + tubularSegments: e, radius: n, radialSegments: i, closed: r }; - let o = e.computeFrenetFrames(t, r); - this.tangents = o.tangents, this.normals = o.normals, this.binormals = o.binormals; - let a = new M, l = new M, c = new X, h = new M, u = [], d = [], f = [], m = []; - x(), this.setIndex(m), this.setAttribute("position", new de(u, 3)), this.setAttribute("normal", new de(d, 3)), this.setAttribute("uv", new de(f, 2)); + let a = t.computeFrenetFrames(e, r); + this.tangents = a.tangents, this.normals = a.normals, this.binormals = a.binormals; + let o = new A, c = new A, l = new J, h = new A, u = [], d = [], f = [], m = []; + x(), this.setIndex(m), this.setAttribute("position", new _t(u, 3)), this.setAttribute("normal", new _t(d, 3)), this.setAttribute("uv", new _t(f, 2)); function x() { - for(let _ = 0; _ < t; _++)v(_); - v(r === !1 ? t : 0), p(), g(); - } - function v(_) { - h = e.getPointAt(_ / t, h); - let y = o.normals[_], b = o.binormals[_]; - for(let A = 0; A <= i; A++){ - let L = A / i * Math.PI * 2, I = Math.sin(L), k = -Math.cos(L); - l.x = k * y.x + I * b.x, l.y = k * y.y + I * b.y, l.z = k * y.z + I * b.z, l.normalize(), d.push(l.x, l.y, l.z), a.x = h.x + n * l.x, a.y = h.y + n * l.y, a.z = h.z + n * l.z, u.push(a.x, a.y, a.z); - } + for(let _ = 0; _ < e; _++)g(_); + g(r === !1 ? e : 0), v(), p(); } - function g() { - for(let _ = 1; _ <= t; _++)for(let y = 1; y <= i; y++){ - let b = (i + 1) * (_ - 1) + (y - 1), A = (i + 1) * _ + (y - 1), L = (i + 1) * _ + y, I = (i + 1) * (_ - 1) + y; - m.push(b, A, I), m.push(A, L, I); + function g(_) { + h = t.getPointAt(_ / e, h); + let y = a.normals[_], b = a.binormals[_]; + for(let w = 0; w <= i; w++){ + let R = w / i * Math.PI * 2, L = Math.sin(R), M = -Math.cos(R); + c.x = M * y.x + L * b.x, c.y = M * y.y + L * b.y, c.z = M * y.z + L * b.z, c.normalize(), d.push(c.x, c.y, c.z), o.x = h.x + n * c.x, o.y = h.y + n * c.y, o.z = h.z + n * c.z, u.push(o.x, o.y, o.z); } } function p() { - for(let _ = 0; _ <= t; _++)for(let y = 0; y <= i; y++)c.x = _ / t, c.y = y / i, f.push(c.x, c.y); + for(let _ = 1; _ <= e; _++)for(let y = 1; y <= i; y++){ + let b = (i + 1) * (_ - 1) + (y - 1), w = (i + 1) * _ + (y - 1), R = (i + 1) * _ + y, L = (i + 1) * (_ - 1) + y; + m.push(b, w, L), m.push(w, R, L); + } + } + function v() { + for(let _ = 0; _ <= e; _++)for(let y = 0; y <= i; y++)l.x = _ / e, l.y = y / i, f.push(l.x, l.y); } } - toJSON() { - let e = super.toJSON(); - return e.path = this.parameters.path.toJSON(), e; - } - static fromJSON(e) { - return new Er(new Ta[e.path.type]().fromJSON(e.path), e.tubularSegments, e.radius, e.radialSegments, e.closed); + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; } -}, Ea = class extends _e { - constructor(e = null){ - super(); - if (this.type = "WireframeGeometry", this.parameters = { - geometry: e - }, e !== null) { - let t = [], n = new Set, i = new M, r = new M; - if (e.index !== null) { - let o = e.attributes.position, a = e.index, l = e.groups; - l.length === 0 && (l = [ + toJSON() { + let t = super.toJSON(); + return t.path = this.parameters.path.toJSON(), t; + } + static fromJSON(t) { + return new s1(new Gc[t.path.type]().fromJSON(t.path), t.tubularSegments, t.radius, t.radialSegments, t.closed); + } +}, nc = class extends Vt { + constructor(t = null){ + if (super(), this.type = "WireframeGeometry", this.parameters = { + geometry: t + }, t !== null) { + let e = [], n = new Set, i = new A, r = new A; + if (t.index !== null) { + let a = t.attributes.position, o = t.index, c = t.groups; + c.length === 0 && (c = [ { start: 0, - count: a.count, + count: o.count, materialIndex: 0 } ]); - for(let c = 0, h = l.length; c < h; ++c){ - let u = l[c], d = u.start, f = u.count; - for(let m = d, x = d + f; m < x; m += 3)for(let v = 0; v < 3; v++){ - let g = a.getX(m + v), p = a.getX(m + (v + 1) % 3); - i.fromBufferAttribute(o, g), r.fromBufferAttribute(o, p), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); + for(let l = 0, h = c.length; l < h; ++l){ + let u = c[l], d = u.start, f = u.count; + for(let m = d, x = d + f; m < x; m += 3)for(let g = 0; g < 3; g++){ + let p = o.getX(m + g), v = o.getX(m + (g + 1) % 3); + i.fromBufferAttribute(a, p), r.fromBufferAttribute(a, v), $h(i, r, n) === !0 && (e.push(i.x, i.y, i.z), e.push(r.x, r.y, r.z)); } } } else { - let o = e.attributes.position; - for(let a = 0, l = o.count / 3; a < l; a++)for(let c = 0; c < 3; c++){ - let h = 3 * a + c, u = 3 * a + (c + 1) % 3; - i.fromBufferAttribute(o, h), r.fromBufferAttribute(o, u), yc(i, r, n) === !0 && (t.push(i.x, i.y, i.z), t.push(r.x, r.y, r.z)); + let a = t.attributes.position; + for(let o = 0, c = a.count / 3; o < c; o++)for(let l = 0; l < 3; l++){ + let h = 3 * o + l, u = 3 * o + (l + 1) % 3; + i.fromBufferAttribute(a, h), r.fromBufferAttribute(a, u), $h(i, r, n) === !0 && (e.push(i.x, i.y, i.z), e.push(r.x, r.y, r.z)); } } - this.setAttribute("position", new de(t, 3)); + this.setAttribute("position", new _t(e, 3)); } } + copy(t) { + return super.copy(t), this.parameters = Object.assign({}, t.parameters), this; + } }; -function yc(s, e, t) { - let n = `${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`, i = `${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`; - return t.has(n) === !0 || t.has(i) === !0 ? !1 : (t.add(n, i), !0); +function $h(s1, t, e) { + let n = `${s1.x},${s1.y},${s1.z}-${t.x},${t.y},${t.z}`, i = `${t.x},${t.y},${t.z}-${s1.x},${s1.y},${s1.z}`; + return e.has(n) === !0 || e.has(i) === !0 ? !1 : (e.add(n), e.add(i), !0); } -var vc = Object.freeze({ +var Kh = Object.freeze({ __proto__: null, - BoxGeometry: wn, - BoxBufferGeometry: wn, - CircleGeometry: fr, - CircleBufferGeometry: fr, - ConeGeometry: pr, - ConeBufferGeometry: pr, - CylinderGeometry: Jn, - CylinderBufferGeometry: Jn, - DodecahedronGeometry: mr, - DodecahedronBufferGeometry: mr, - EdgesGeometry: _a, - ExtrudeGeometry: ln, - ExtrudeBufferGeometry: ln, - IcosahedronGeometry: _r, - IcosahedronBufferGeometry: _r, - LatheGeometry: Mr, - LatheBufferGeometry: Mr, - OctahedronGeometry: Ii, - OctahedronBufferGeometry: Ii, - PlaneGeometry: Pi, - PlaneBufferGeometry: Pi, - PolyhedronGeometry: an, - PolyhedronBufferGeometry: an, - RingGeometry: br, - RingBufferGeometry: br, - ShapeGeometry: Di, - ShapeBufferGeometry: Di, - SphereGeometry: Fi, - SphereBufferGeometry: Fi, - TetrahedronGeometry: wr, - TetrahedronBufferGeometry: wr, - TorusGeometry: Sr, - TorusBufferGeometry: Sr, - TorusKnotGeometry: Tr, - TorusKnotBufferGeometry: Tr, - TubeGeometry: Er, - TubeBufferGeometry: Er, - WireframeGeometry: Ea -}), Aa = class extends dt { - constructor(e){ - super(); - this.type = "ShadowMaterial", this.color = new ae(0), this.transparent = !0, this.setValues(e); - } - copy(e) { - return super.copy(e), this.color.copy(e.color), this; - } -}; -Aa.prototype.isShadowMaterial = !0; -var po = class extends dt { - constructor(e){ - super(); - this.defines = { + BoxGeometry: Ji, + CapsuleGeometry: Vo, + CircleGeometry: Ho, + ConeGeometry: Go, + CylinderGeometry: Fs, + DodecahedronGeometry: Wo, + EdgesGeometry: Xo, + ExtrudeGeometry: Zo, + IcosahedronGeometry: Jo, + LatheGeometry: ra, + OctahedronGeometry: aa, + PlaneGeometry: Zr, + PolyhedronGeometry: di, + RingGeometry: $o, + ShapeGeometry: Ko, + SphereGeometry: oa, + TetrahedronGeometry: Qo, + TorusGeometry: jo, + TorusKnotGeometry: tc, + TubeGeometry: ec, + WireframeGeometry: nc +}), ic = class extends Me { + constructor(t){ + super(), this.isShadowMaterial = !0, this.type = "ShadowMaterial", this.color = new ft(0), this.transparent = !0, this.fog = !0, this.setValues(t); + } + copy(t) { + return super.copy(t), this.color.copy(t.color), this.fog = t.fog, this; + } +}, sc = class extends Qe { + constructor(t){ + super(t), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial"; + } +}, ca = class extends Me { + constructor(t){ + super(), this.isMeshStandardMaterial = !0, this.defines = { STANDARD: "" - }, this.type = "MeshStandardMaterial", this.color = new ae(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapIntensity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); + }, this.type = "MeshStandardMaterial", this.color = new ft(16777215), this.roughness = 1, this.metalness = 0, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ft(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapIntensity = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(t); } - copy(e) { - return super.copy(e), this.defines = { + copy(t) { + return super.copy(t), this.defines = { STANDARD: "" - }, this.color.copy(e.color), this.roughness = e.roughness, this.metalness = e.metalness, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.roughnessMap = e.roughnessMap, this.metalnessMap = e.metalnessMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapIntensity = e.envMapIntensity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; + }, this.color.copy(t.color), this.roughness = t.roughness, this.metalness = t.metalness, this.map = t.map, this.lightMap = t.lightMap, this.lightMapIntensity = t.lightMapIntensity, this.aoMap = t.aoMap, this.aoMapIntensity = t.aoMapIntensity, this.emissive.copy(t.emissive), this.emissiveMap = t.emissiveMap, this.emissiveIntensity = t.emissiveIntensity, this.bumpMap = t.bumpMap, this.bumpScale = t.bumpScale, this.normalMap = t.normalMap, this.normalMapType = t.normalMapType, this.normalScale.copy(t.normalScale), this.displacementMap = t.displacementMap, this.displacementScale = t.displacementScale, this.displacementBias = t.displacementBias, this.roughnessMap = t.roughnessMap, this.metalnessMap = t.metalnessMap, this.alphaMap = t.alphaMap, this.envMap = t.envMap, this.envMapIntensity = t.envMapIntensity, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.flatShading = t.flatShading, this.fog = t.fog, this; } -}; -po.prototype.isMeshStandardMaterial = !0; -var Ca = class extends po { - constructor(e){ - super(); - this.defines = { +}, rc = class extends ca { + constructor(t){ + super(), this.isMeshPhysicalMaterial = !0, this.defines = { STANDARD: "", PHYSICAL: "" - }, this.type = "MeshPhysicalMaterial", this.clearcoatMap = null, this.clearcoatRoughness = 0, this.clearcoatRoughnessMap = null, this.clearcoatNormalScale = new X(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", { + }, this.type = "MeshPhysicalMaterial", this.anisotropyRotation = 0, this.anisotropyMap = null, this.clearcoatMap = null, this.clearcoatRoughness = 0, this.clearcoatRoughnessMap = null, this.clearcoatNormalScale = new J(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", { get: function() { - return mt(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1); + return ae(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1); }, - set: function(t) { - this.ior = (1 + .4 * t) / (1 - .4 * t); + set: function(e) { + this.ior = (1 + .4 * e) / (1 - .4 * e); } - }), this.sheenColor = new ae(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 0, this.attenuationColor = new ae(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new ae(1, 1, 1), this.specularColorMap = null, this._sheen = 0, this._clearcoat = 0, this._transmission = 0, this.setValues(e); + }), this.iridescenceMap = null, this.iridescenceIOR = 1.3, this.iridescenceThicknessRange = [ + 100, + 400 + ], this.iridescenceThicknessMap = null, this.sheenColor = new ft(0), this.sheenColorMap = null, this.sheenRoughness = 1, this.sheenRoughnessMap = null, this.transmissionMap = null, this.thickness = 0, this.thicknessMap = null, this.attenuationDistance = 1 / 0, this.attenuationColor = new ft(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new ft(1, 1, 1), this.specularColorMap = null, this._anisotropy = 0, this._clearcoat = 0, this._iridescence = 0, this._sheen = 0, this._transmission = 0, this.setValues(t); } - get sheen() { - return this._sheen; + get anisotropy() { + return this._anisotropy; } - set sheen(e) { - this._sheen > 0 != e > 0 && this.version++, this._sheen = e; + set anisotropy(t) { + this._anisotropy > 0 != t > 0 && this.version++, this._anisotropy = t; } get clearcoat() { return this._clearcoat; } - set clearcoat(e) { - this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e; + set clearcoat(t) { + this._clearcoat > 0 != t > 0 && this.version++, this._clearcoat = t; + } + get iridescence() { + return this._iridescence; + } + set iridescence(t) { + this._iridescence > 0 != t > 0 && this.version++, this._iridescence = t; + } + get sheen() { + return this._sheen; + } + set sheen(t) { + this._sheen > 0 != t > 0 && this.version++, this._sheen = t; } get transmission() { return this._transmission; } - set transmission(e) { - this._transmission > 0 != e > 0 && this.version++, this._transmission = e; + set transmission(t) { + this._transmission > 0 != t > 0 && this.version++, this._transmission = t; } - copy(e) { - return super.copy(e), this.defines = { + copy(t) { + return super.copy(t), this.defines = { STANDARD: "", PHYSICAL: "" - }, this.clearcoat = e.clearcoat, this.clearcoatMap = e.clearcoatMap, this.clearcoatRoughness = e.clearcoatRoughness, this.clearcoatRoughnessMap = e.clearcoatRoughnessMap, this.clearcoatNormalMap = e.clearcoatNormalMap, this.clearcoatNormalScale.copy(e.clearcoatNormalScale), this.ior = e.ior, this.sheen = e.sheen, this.sheenColor.copy(e.sheenColor), this.sheenColorMap = e.sheenColorMap, this.sheenRoughness = e.sheenRoughness, this.sheenRoughnessMap = e.sheenRoughnessMap, this.transmission = e.transmission, this.transmissionMap = e.transmissionMap, this.thickness = e.thickness, this.thicknessMap = e.thicknessMap, this.attenuationDistance = e.attenuationDistance, this.attenuationColor.copy(e.attenuationColor), this.specularIntensity = e.specularIntensity, this.specularIntensityMap = e.specularIntensityMap, this.specularColor.copy(e.specularColor), this.specularColorMap = e.specularColorMap, this; + }, this.anisotropy = t.anisotropy, this.anisotropyRotation = t.anisotropyRotation, this.anisotropyMap = t.anisotropyMap, this.clearcoat = t.clearcoat, this.clearcoatMap = t.clearcoatMap, this.clearcoatRoughness = t.clearcoatRoughness, this.clearcoatRoughnessMap = t.clearcoatRoughnessMap, this.clearcoatNormalMap = t.clearcoatNormalMap, this.clearcoatNormalScale.copy(t.clearcoatNormalScale), this.ior = t.ior, this.iridescence = t.iridescence, this.iridescenceMap = t.iridescenceMap, this.iridescenceIOR = t.iridescenceIOR, this.iridescenceThicknessRange = [ + ...t.iridescenceThicknessRange + ], this.iridescenceThicknessMap = t.iridescenceThicknessMap, this.sheen = t.sheen, this.sheenColor.copy(t.sheenColor), this.sheenColorMap = t.sheenColorMap, this.sheenRoughness = t.sheenRoughness, this.sheenRoughnessMap = t.sheenRoughnessMap, this.transmission = t.transmission, this.transmissionMap = t.transmissionMap, this.thickness = t.thickness, this.thicknessMap = t.thicknessMap, this.attenuationDistance = t.attenuationDistance, this.attenuationColor.copy(t.attenuationColor), this.specularIntensity = t.specularIntensity, this.specularIntensityMap = t.specularIntensityMap, this.specularColor.copy(t.specularColor), this.specularColorMap = t.specularColorMap, this; } -}; -Ca.prototype.isMeshPhysicalMaterial = !0; -var La = class extends dt { - constructor(e){ - super(); - this.type = "MeshPhongMaterial", this.color = new ae(16777215), this.specular = new ae(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.setValues(e); +}, ac = class extends Me { + constructor(t){ + super(), this.isMeshPhongMaterial = !0, this.type = "MeshPhongMaterial", this.color = new ft(16777215), this.specular = new ft(1118481), this.shininess = 30, this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ft(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = pa, this.reflectivity = 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(e) { - return super.copy(e), this.color.copy(e.color), this.specular.copy(e.specular), this.shininess = e.shininess, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this; + 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.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.flatShading = t.flatShading, this.fog = t.fog, this; } -}; -La.prototype.isMeshPhongMaterial = !0; -var Ra = class extends dt { - constructor(e){ - super(); - this.defines = { +}, oc = class extends Me { + constructor(t){ + super(), this.isMeshToonMaterial = !0, this.defines = { TOON: "" - }, this.type = "MeshToonMaterial", this.color = new ae(16777215), this.map = null, this.gradientMap = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); + }, this.type = "MeshToonMaterial", this.color = new ft(16777215), this.map = null, this.gradientMap = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ft(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(t); } - copy(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.gradientMap = e.gradientMap, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + copy(t) { + return super.copy(t), this.color.copy(t.color), this.map = t.map, this.gradientMap = t.gradientMap, 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.alphaMap = t.alphaMap, this.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.wireframeLinecap = t.wireframeLinecap, this.wireframeLinejoin = t.wireframeLinejoin, this.fog = t.fog, this; } -}; -Ra.prototype.isMeshToonMaterial = !0; -var Pa = class extends dt { - constructor(e){ - super(); - this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.flatShading = !1, this.setValues(e); +}, cc = class extends Me { + constructor(t){ + super(), this.isMeshNormalMaterial = !0, this.type = "MeshNormalMaterial", this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.flatShading = !1, this.setValues(t); } - copy(e) { - return super.copy(e), this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.flatShading = e.flatShading, this; + copy(t) { + return super.copy(t), 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.wireframe = t.wireframe, this.wireframeLinewidth = t.wireframeLinewidth, this.flatShading = t.flatShading, this; } -}; -Pa.prototype.isMeshNormalMaterial = !0; -var Ia = class extends dt { - constructor(e){ - super(); - this.type = "MeshLambertMaterial", this.color = new ae(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ae(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = Vs, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.setValues(e); +}, lc = class extends Me { + constructor(t){ + super(), this.isMeshLambertMaterial = !0, this.type = "MeshLambertMaterial", this.color = new ft(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new ft(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.combine = pa, this.reflectivity = 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(e) { - return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this; + 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.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.flatShading = t.flatShading, this.fog = t.fog, this; } -}; -Ia.prototype.isMeshLambertMaterial = !0; -var Da = class extends dt { - constructor(e){ - super(); - this.defines = { +}, hc = class extends Me { + constructor(t){ + super(), this.isMeshMatcapMaterial = !0, this.defines = { MATCAP: "" - }, this.type = "MeshMatcapMaterial", this.color = new ae(16777215), this.matcap = null, this.map = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = Hi, this.normalScale = new X(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.flatShading = !1, this.setValues(e); + }, this.type = "MeshMatcapMaterial", this.color = new ft(16777215), this.matcap = null, this.map = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = mi, this.normalScale = new J(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.alphaMap = null, this.flatShading = !1, this.fog = !0, this.setValues(t); } - copy(e) { - return super.copy(e), this.defines = { + copy(t) { + return super.copy(t), this.defines = { MATCAP: "" - }, this.color.copy(e.color), this.matcap = e.matcap, this.map = e.map, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.alphaMap = e.alphaMap, this.flatShading = e.flatShading, this; + }, this.color.copy(t.color), this.matcap = t.matcap, this.map = t.map, 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.alphaMap = t.alphaMap, this.flatShading = t.flatShading, this.fog = t.fog, this; } -}; -Da.prototype.isMeshMatcapMaterial = !0; -var Fa = class extends ft { - constructor(e){ - super(); - this.type = "LineDashedMaterial", this.scale = 1, this.dashSize = 3, this.gapSize = 1, this.setValues(e); +}, uc = class extends Ee { + constructor(t){ + super(), this.isLineDashedMaterial = !0, this.type = "LineDashedMaterial", this.scale = 1, this.dashSize = 3, this.gapSize = 1, this.setValues(t); } - copy(e) { - return super.copy(e), this.scale = e.scale, this.dashSize = e.dashSize, this.gapSize = e.gapSize, this; + copy(t) { + return super.copy(t), this.scale = t.scale, this.dashSize = t.dashSize, this.gapSize = t.gapSize, this; } }; -Fa.prototype.isLineDashedMaterial = !0; -var sy = Object.freeze({ - __proto__: null, - ShadowMaterial: Aa, - SpriteMaterial: io, - RawShaderMaterial: Gi, - ShaderMaterial: sn, - PointsMaterial: jn, - MeshPhysicalMaterial: Ca, - MeshStandardMaterial: po, - MeshPhongMaterial: La, - MeshToonMaterial: Ra, - MeshNormalMaterial: Pa, - MeshLambertMaterial: Ia, - MeshDepthMaterial: eo, - MeshDistanceMaterial: to, - MeshBasicMaterial: hn, - MeshMatcapMaterial: Da, - LineDashedMaterial: Fa, - LineBasicMaterial: ft, - Material: dt -}), Ze = { - arraySlice: function(s, e, t) { - return Ze.isTypedArray(s) ? new s.constructor(s.subarray(e, t !== void 0 ? t : s.length)) : s.slice(e, t); - }, - convertArray: function(s, e, t) { - return !s || !t && s.constructor === e ? s : typeof e.BYTES_PER_ELEMENT == "number" ? new e(s) : Array.prototype.slice.call(s); - }, - isTypedArray: function(s) { - return ArrayBuffer.isView(s) && !(s instanceof DataView); - }, - getKeyframeOrder: function(s) { - function e(i, r) { - return s[i] - s[r]; - } - let t = s.length, n = new Array(t); - for(let i = 0; i !== t; ++i)n[i] = i; - return n.sort(e), n; - }, - sortedArray: function(s, e, t) { - let n = s.length, i = new s.constructor(n); - for(let r = 0, o = 0; o !== n; ++r){ - let a = t[r] * e; - for(let l = 0; l !== e; ++l)i[o++] = s[a + l]; - } - return i; - }, - flattenJSON: function(s, e, t, n) { - let i = 1, r = s[0]; - for(; r !== void 0 && r[n] === void 0;)r = s[i++]; - if (r === void 0) return; - let o = r[n]; - if (o !== void 0) if (Array.isArray(o)) do o = r[n], o !== void 0 && (e.push(r.time), t.push.apply(t, o)), r = s[i++]; - while (r !== void 0) - else if (o.toArray !== void 0) do o = r[n], o !== void 0 && (e.push(r.time), o.toArray(t, t.length)), r = s[i++]; - while (r !== void 0) - else do o = r[n], o !== void 0 && (e.push(r.time), t.push(o)), r = s[i++]; - while (r !== void 0) - }, - subclip: function(s, e, t, n, i = 30) { - let r = s.clone(); - r.name = e; - let o = []; - for(let l = 0; l < r.tracks.length; ++l){ - let c = r.tracks[l], h = c.getValueSize(), u = [], d = []; - for(let f = 0; f < c.times.length; ++f){ - let m = c.times[f] * i; - if (!(m < t || m >= n)) { - u.push(c.times[f]); - for(let x = 0; x < h; ++x)d.push(c.values[f * h + x]); - } - } - u.length !== 0 && (c.times = Ze.convertArray(u, c.times.constructor), c.values = Ze.convertArray(d, c.values.constructor), o.push(c)); - } - r.tracks = o; - let a = 1 / 0; - for(let l = 0; l < r.tracks.length; ++l)a > r.tracks[l].times[0] && (a = r.tracks[l].times[0]); - for(let l = 0; l < r.tracks.length; ++l)r.tracks[l].shift(-1 * a); - return r.resetDuration(), r; - }, - makeClipAdditive: function(s, e = 0, t = s, n = 30) { - n <= 0 && (n = 30); - let i = t.tracks.length, r = e / n; - for(let o = 0; o < i; ++o){ - let a = t.tracks[o], l = a.ValueTypeName; - if (l === "bool" || l === "string") continue; - let c = s.tracks.find(function(g) { - return g.name === a.name && g.ValueTypeName === l; - }); - if (c === void 0) continue; - let h = 0, u = a.getValueSize(); - a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (h = u / 3); - let d = 0, f = c.getValueSize(); - c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (d = f / 3); - let m = a.times.length - 1, x; - if (r <= a.times[0]) { - let g = h, p = u - h; - x = Ze.arraySlice(a.values, g, p); - } else if (r >= a.times[m]) { - let g = m * u + h, p = g + u - h; - x = Ze.arraySlice(a.values, g, p); - } else { - let g = a.createInterpolant(), p = h, _ = u - h; - g.evaluate(r), x = Ze.arraySlice(g.resultBuffer, p, _); +function Ve(s1, t, e) { + return Wc(s1) ? new s1.constructor(s1.subarray(t, e !== void 0 ? e : s1.length)) : s1.slice(t, e); +} +function ei(s1, t, e) { + return !s1 || !e && s1.constructor === t ? s1 : typeof t.BYTES_PER_ELEMENT == "number" ? new t(s1) : Array.prototype.slice.call(s1); +} +function Wc(s1) { + return ArrayBuffer.isView(s1) && !(s1 instanceof DataView); +} +function Rd(s1) { + function t(i, r) { + return s1[i] - s1[r]; + } + let e = s1.length, n = new Array(e); + for(let i = 0; i !== e; ++i)n[i] = i; + return n.sort(t), n; +} +function dc(s1, t, e) { + let n = s1.length, i = new s1.constructor(n); + for(let r = 0, a = 0; a !== n; ++r){ + let o = e[r] * t; + for(let c = 0; c !== t; ++c)i[a++] = s1[o + c]; + } + return i; +} +function Xc(s1, t, e, n) { + let i = 1, r = s1[0]; + for(; r !== void 0 && r[n] === void 0;)r = s1[i++]; + if (r === void 0) return; + let a = r[n]; + if (a !== void 0) if (Array.isArray(a)) do a = r[n], a !== void 0 && (t.push(r.time), e.push.apply(e, a)), r = s1[i++]; + while (r !== void 0) + else if (a.toArray !== void 0) do a = r[n], a !== void 0 && (t.push(r.time), a.toArray(e, e.length)), r = s1[i++]; + while (r !== void 0) + else do a = r[n], a !== void 0 && (t.push(r.time), e.push(a)), r = s1[i++]; + while (r !== void 0) +} +function xx(s1, t, e, n, i = 30) { + let r = s1.clone(); + r.name = t; + let a = []; + for(let c = 0; c < r.tracks.length; ++c){ + let l = r.tracks[c], h = l.getValueSize(), u = [], d = []; + for(let f = 0; f < l.times.length; ++f){ + let m = l.times[f] * i; + if (!(m < e || m >= n)) { + u.push(l.times[f]); + for(let x = 0; x < h; ++x)d.push(l.values[f * h + x]); } - l === "quaternion" && new gt().fromArray(x).normalize().conjugate().toArray(x); - let v = c.times.length; - for(let g = 0; g < v; ++g){ - let p = g * f + d; - if (l === "quaternion") gt.multiplyQuaternionsFlat(c.values, p, x, 0, c.values, p); - else { - let _ = f - d * 2; - for(let y = 0; y < _; ++y)c.values[p + y] -= x[y]; - } + } + u.length !== 0 && (l.times = ei(u, l.times.constructor), l.values = ei(d, l.values.constructor), a.push(l)); + } + r.tracks = a; + let o = 1 / 0; + for(let c = 0; c < r.tracks.length; ++c)o > r.tracks[c].times[0] && (o = r.tracks[c].times[0]); + for(let c = 0; c < r.tracks.length; ++c)r.tracks[c].shift(-1 * o); + return r.resetDuration(), r; +} +function vx(s1, t = 0, e = s1, n = 30) { + n <= 0 && (n = 30); + let i = e.tracks.length, r = t / n; + for(let a = 0; a < i; ++a){ + let o = e.tracks[a], c = o.ValueTypeName; + if (c === "bool" || c === "string") continue; + let l = s1.tracks.find(function(p) { + return p.name === o.name && p.ValueTypeName === c; + }); + if (l === void 0) continue; + let h = 0, u = o.getValueSize(); + o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (h = u / 3); + let d = 0, f = l.getValueSize(); + l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline && (d = f / 3); + let m = o.times.length - 1, x; + if (r <= o.times[0]) { + let p = h, v = u - h; + x = Ve(o.values, p, v); + } else if (r >= o.times[m]) { + let p = m * u + h, v = p + u - h; + x = Ve(o.values, p, v); + } else { + let p = o.createInterpolant(), v = h, _ = u - h; + p.evaluate(r), x = Ve(p.resultBuffer, v, _); + } + c === "quaternion" && new Pe().fromArray(x).normalize().conjugate().toArray(x); + let g = l.times.length; + for(let p = 0; p < g; ++p){ + let v = p * f + d; + if (c === "quaternion") Pe.multiplyQuaternionsFlat(l.values, v, x, 0, l.values, v); + else { + let _ = f - d * 2; + for(let y = 0; y < _; ++y)l.values[v + y] -= x[y]; } } - return s.blendMode = qc, s; } -}, cn = class { - constructor(e, t, n, i){ - this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = i !== void 0 ? i : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; - } - evaluate(e) { - let t = this.parameterPositions, n = this._cachedIndex, i = t[n], r = t[n - 1]; - e: { - t: { - let o; + return s1.blendMode = dd, s1; +} +var yv = { + arraySlice: Ve, + convertArray: ei, + isTypedArray: Wc, + getKeyframeOrder: Rd, + sortedArray: dc, + flattenJSON: Xc, + subclip: xx, + makeClipAdditive: vx +}, ts = class { + constructor(t, e, n, i){ + this.parameterPositions = t, this._cachedIndex = 0, this.resultBuffer = i !== void 0 ? i : new e.constructor(n), this.sampleValues = e, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; + } + evaluate(t) { + let e = this.parameterPositions, n = this._cachedIndex, i = e[n], r = e[n - 1]; + t: { + e: { + let a; n: { - i: if (!(e < i)) { - for(let a = n + 2;;){ + i: if (!(t < i)) { + for(let o = n + 2;;){ if (i === void 0) { - if (e < r) break i; - return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, e, r); + if (t < r) break i; + return n = e.length, this._cachedIndex = n, this.copySampleValue_(n - 1); } - if (n === a) break; - if (r = i, i = t[++n], e < i) break t; + if (n === o) break; + if (r = i, i = e[++n], t < i) break e; } - o = t.length; + a = e.length; break n; } - if (!(e >= r)) { - let a = t[1]; - e < a && (n = 2, r = a); - for(let l = n - 2;;){ - if (r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); - if (n === l) break; - if (i = r, r = t[--n - 1], e >= r) break t; + if (!(t >= r)) { + let o = e[1]; + t < o && (n = 2, r = o); + for(let c = n - 2;;){ + if (r === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); + if (n === c) break; + if (i = r, r = e[--n - 1], t >= r) break e; } - o = n, n = 0; + a = n, n = 0; break n; } - break e; + break t; } - for(; n < o;){ - let a = n + o >>> 1; - e < t[a] ? o = a : n = a + 1; + for(; n < a;){ + let o = n + a >>> 1; + t < e[o] ? a = o : n = o + 1; } - if (i = t[n], r = t[n - 1], r === void 0) return this._cachedIndex = 0, this.beforeStart_(0, e, i); - if (i === void 0) return n = t.length, this._cachedIndex = n, this.afterEnd_(n - 1, r, e); + if (i = e[n], r = e[n - 1], r === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); + if (i === void 0) return n = e.length, this._cachedIndex = n, this.copySampleValue_(n - 1); } this._cachedIndex = n, this.intervalChanged_(n, r, i); } - return this.interpolate_(n, r, e, i); + return this.interpolate_(n, r, t, i); } getSettings_() { return this.settings || this.DefaultSettings_; } - copySampleValue_(e) { - let t = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = e * i; - for(let o = 0; o !== i; ++o)t[o] = n[r + o]; - return t; + copySampleValue_(t) { + let e = this.resultBuffer, n = this.sampleValues, i = this.valueSize, r = t * i; + for(let a = 0; a !== i; ++a)e[a] = n[r + a]; + return e; } interpolate_() { throw new Error("call to abstract method"); } intervalChanged_() {} -}; -cn.prototype.beforeStart_ = cn.prototype.copySampleValue_; -cn.prototype.afterEnd_ = cn.prototype.copySampleValue_; -var Ph = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { - endingStart: Mi, - endingEnd: Mi +}, fc = class extends ts { + constructor(t, e, n, i){ + super(t, e, n, i), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { + endingStart: zi, + endingEnd: zi }; } - intervalChanged_(e, t, n) { - let i = this.parameterPositions, r = e - 2, o = e + 1, a = i[r], l = i[o]; - if (a === void 0) switch(this.getSettings_().endingStart){ - case bi: - r = e, a = 2 * t - n; + intervalChanged_(t, e, n) { + let i = this.parameterPositions, r = t - 2, a = t + 1, o = i[r], c = i[a]; + if (o === void 0) switch(this.getSettings_().endingStart){ + case ki: + r = t, o = 2 * e - n; break; - case Os: - r = i.length - 2, a = t + i[r] - i[r + 1]; + case zr: + r = i.length - 2, o = e + i[r] - i[r + 1]; break; default: - r = e, a = n; + r = t, o = n; } - if (l === void 0) switch(this.getSettings_().endingEnd){ - case bi: - o = e, l = 2 * n - t; + if (c === void 0) switch(this.getSettings_().endingEnd){ + case ki: + a = t, c = 2 * n - e; break; - case Os: - o = 1, l = n + i[1] - i[0]; + case zr: + a = 1, c = n + i[1] - i[0]; break; default: - o = e - 1, l = t; + a = t - 1, c = e; } - let c = (n - t) * .5, h = this.valueSize; - this._weightPrev = c / (t - a), this._weightNext = c / (l - n), this._offsetPrev = r * h, this._offsetNext = o * h; + let l = (n - e) * .5, h = this.valueSize; + this._weightPrev = l / (e - o), this._weightNext = l / (c - n), this._offsetPrev = r * h, this._offsetNext = a * h; } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, m = (n - t) / (i - t), x = m * m, v = x * m, g = -d * v + 2 * d * x - d * m, p = (1 + d) * v + (-1.5 - 2 * d) * x + (-.5 + d) * m + 1, _ = (-1 - f) * v + (1.5 + f) * x + .5 * m, y = f * v - f * x; - for(let b = 0; b !== a; ++b)r[b] = g * o[h + b] + p * o[c + b] + _ * o[l + b] + y * o[u + b]; + interpolate_(t, e, n, i) { + let r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = t * o, l = c - o, h = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, m = (n - e) / (i - e), x = m * m, g = x * m, p = -d * g + 2 * d * x - d * m, v = (1 + d) * g + (-1.5 - 2 * d) * x + (-.5 + d) * m + 1, _ = (-1 - f) * g + (1.5 + f) * x + .5 * m, y = f * g - f * x; + for(let b = 0; b !== o; ++b)r[b] = p * a[h + b] + v * a[l + b] + _ * a[c + b] + y * a[u + b]; return r; } -}, Na = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); +}, la = class extends ts { + constructor(t, e, n, i){ + super(t, e, n, i); } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = e * a, c = l - a, h = (n - t) / (i - t), u = 1 - h; - for(let d = 0; d !== a; ++d)r[d] = o[c + d] * u + o[l + d] * h; + interpolate_(t, e, n, i) { + let r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = t * o, l = c - o, h = (n - e) / (i - e), u = 1 - h; + for(let d = 0; d !== o; ++d)r[d] = a[l + d] * u + a[c + d] * h; return r; } -}, Ih = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); +}, pc = class extends ts { + constructor(t, e, n, i){ + super(t, e, n, i); } - interpolate_(e) { - return this.copySampleValue_(e - 1); + interpolate_(t) { + return this.copySampleValue_(t - 1); } -}, zt = class { - constructor(e, t, n, i){ - if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined"); - if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e); - this.name = e, this.times = Ze.convertArray(t, this.TimeBufferType), this.values = Ze.convertArray(n, this.ValueBufferType), this.setInterpolation(i || this.DefaultInterpolation); +}, qe = class { + constructor(t, e, n, i){ + if (t === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined"); + if (e === void 0 || e.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + t); + this.name = t, this.times = ei(e, this.TimeBufferType), this.values = ei(n, this.ValueBufferType), this.setInterpolation(i || this.DefaultInterpolation); } - static toJSON(e) { - let t = e.constructor, n; - if (t.toJSON !== this.toJSON) n = t.toJSON(e); + static toJSON(t) { + let e = t.constructor, n; + if (e.toJSON !== this.toJSON) n = e.toJSON(t); else { n = { - name: e.name, - times: Ze.convertArray(e.times, Array), - values: Ze.convertArray(e.values, Array) + name: t.name, + times: ei(t.times, Array), + values: ei(t.values, Array) }; - let i = e.getInterpolation(); - i !== e.DefaultInterpolation && (n.interpolation = i); + let i = t.getInterpolation(); + i !== t.DefaultInterpolation && (n.interpolation = i); } - return n.type = e.ValueTypeName, n; + return n.type = t.ValueTypeName, n; } - InterpolantFactoryMethodDiscrete(e) { - return new Ih(this.times, this.values, this.getValueSize(), e); + InterpolantFactoryMethodDiscrete(t) { + return new pc(this.times, this.values, this.getValueSize(), t); } - InterpolantFactoryMethodLinear(e) { - return new Na(this.times, this.values, this.getValueSize(), e); + InterpolantFactoryMethodLinear(t) { + return new la(this.times, this.values, this.getValueSize(), t); } - InterpolantFactoryMethodSmooth(e) { - return new Ph(this.times, this.values, this.getValueSize(), e); + InterpolantFactoryMethodSmooth(t) { + return new fc(this.times, this.values, this.getValueSize(), t); } - setInterpolation(e) { - let t; - switch(e){ - case zs: - t = this.InterpolantFactoryMethodDiscrete; + setInterpolation(t) { + let e; + switch(t){ + case Or: + e = this.InterpolantFactoryMethodDiscrete; break; - case Us: - t = this.InterpolantFactoryMethodLinear; + case Br: + e = this.InterpolantFactoryMethodLinear; break; - case yo: - t = this.InterpolantFactoryMethodSmooth; + case wa: + e = this.InterpolantFactoryMethodSmooth; break; } - if (t === void 0) { + if (e === void 0) { let n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; - if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); + if (this.createInterpolant === void 0) if (t !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); else throw new Error(n); return console.warn("THREE.KeyframeTrack:", n), this; } - return this.createInterpolant = t, this; + return this.createInterpolant = e, this; } getInterpolation() { switch(this.createInterpolant){ case this.InterpolantFactoryMethodDiscrete: - return zs; + return Or; case this.InterpolantFactoryMethodLinear: - return Us; + return Br; case this.InterpolantFactoryMethodSmooth: - return yo; + return wa; } } getValueSize() { return this.values.length / this.times.length; } - shift(e) { - if (e !== 0) { - let t = this.times; - for(let n = 0, i = t.length; n !== i; ++n)t[n] += e; + shift(t) { + if (t !== 0) { + let e = this.times; + for(let n = 0, i = e.length; n !== i; ++n)e[n] += t; } return this; } - scale(e) { - if (e !== 1) { - let t = this.times; - for(let n = 0, i = t.length; n !== i; ++n)t[n] *= e; + scale(t) { + if (t !== 1) { + let e = this.times; + for(let n = 0, i = e.length; n !== i; ++n)e[n] *= t; } return this; } - trim(e, t) { - let n = this.times, i = n.length, r = 0, o = i - 1; - for(; r !== i && n[r] < e;)++r; - for(; o !== -1 && n[o] > t;)--o; - if (++o, r !== 0 || o !== i) { - r >= o && (o = Math.max(o, 1), r = o - 1); - let a = this.getValueSize(); - this.times = Ze.arraySlice(n, r, o), this.values = Ze.arraySlice(this.values, r * a, o * a); + trim(t, e) { + let n = this.times, i = n.length, r = 0, a = i - 1; + for(; r !== i && n[r] < t;)++r; + for(; a !== -1 && n[a] > e;)--a; + if (++a, r !== 0 || a !== i) { + r >= a && (a = Math.max(a, 1), r = a - 1); + let o = this.getValueSize(); + this.times = Ve(n, r, a), this.values = Ve(this.values, r * o, a * o); } return this; } validate() { - let e = !0, t = this.getValueSize(); - t - Math.floor(t) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), e = !1); + let t = !0, e = this.getValueSize(); + e - Math.floor(e) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), t = !1); let n = this.times, i = this.values, r = n.length; - r === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), e = !1); - let o = null; - for(let a = 0; a !== r; a++){ - let l = n[a]; - if (typeof l == "number" && isNaN(l)) { - console.error("THREE.KeyframeTrack: Time is not a valid number.", this, a, l), e = !1; + r === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), t = !1); + let a = null; + for(let o = 0; o !== r; o++){ + let c = n[o]; + if (typeof c == "number" && isNaN(c)) { + console.error("THREE.KeyframeTrack: Time is not a valid number.", this, o, c), t = !1; break; } - if (o !== null && o > l) { - console.error("THREE.KeyframeTrack: Out of order keys.", this, a, l, o), e = !1; + if (a !== null && a > c) { + console.error("THREE.KeyframeTrack: Out of order keys.", this, o, c, a), t = !1; break; } - o = l; + a = c; } - if (i !== void 0 && Ze.isTypedArray(i)) for(let a = 0, l = i.length; a !== l; ++a){ - let c = i[a]; - if (isNaN(c)) { - console.error("THREE.KeyframeTrack: Value is not a valid number.", this, a, c), e = !1; + if (i !== void 0 && Wc(i)) for(let o = 0, c = i.length; o !== c; ++o){ + let l = i[o]; + if (isNaN(l)) { + console.error("THREE.KeyframeTrack: Value is not a valid number.", this, o, l), t = !1; break; } } - return e; + return t; } optimize() { - let e = Ze.arraySlice(this.times), t = Ze.arraySlice(this.values), n = this.getValueSize(), i = this.getInterpolation() === yo, r = e.length - 1, o = 1; - for(let a = 1; a < r; ++a){ - let l = !1, c = e[a], h = e[a + 1]; - if (c !== h && (a !== 1 || c !== e[0])) if (i) l = !0; + let t = Ve(this.times), e = Ve(this.values), n = this.getValueSize(), i = this.getInterpolation() === wa, r = t.length - 1, a = 1; + for(let o = 1; o < r; ++o){ + let c = !1, l = t[o], h = t[o + 1]; + if (l !== h && (o !== 1 || l !== t[0])) if (i) c = !0; else { - let u = a * n, d = u - n, f = u + n; + let u = o * n, d = u - n, f = u + n; for(let m = 0; m !== n; ++m){ - let x = t[u + m]; - if (x !== t[d + m] || x !== t[f + m]) { - l = !0; + let x = e[u + m]; + if (x !== e[d + m] || x !== e[f + m]) { + c = !0; break; } } } - if (l) { - if (a !== o) { - e[o] = e[a]; - let u = a * n, d = o * n; - for(let f = 0; f !== n; ++f)t[d + f] = t[u + f]; + if (c) { + if (o !== a) { + t[a] = t[o]; + let u = o * n, d = a * n; + for(let f = 0; f !== n; ++f)e[d + f] = e[u + f]; } - ++o; + ++a; } } if (r > 0) { - e[o] = e[r]; - for(let a = r * n, l = o * n, c = 0; c !== n; ++c)t[l + c] = t[a + c]; - ++o; + t[a] = t[r]; + for(let o = r * n, c = a * n, l = 0; l !== n; ++l)e[c + l] = e[o + l]; + ++a; } - return o !== e.length ? (this.times = Ze.arraySlice(e, 0, o), this.values = Ze.arraySlice(t, 0, o * n)) : (this.times = e, this.values = t), this; + return a !== t.length ? (this.times = Ve(t, 0, a), this.values = Ve(e, 0, a * n)) : (this.times = t, this.values = e), this; } clone() { - let e = Ze.arraySlice(this.times, 0), t = Ze.arraySlice(this.values, 0), n = this.constructor, i = new n(this.name, e, t); + let t = Ve(this.times, 0), e = Ve(this.values, 0), n = this.constructor, i = new n(this.name, t, e); return i.createInterpolant = this.createInterpolant, i; } }; -zt.prototype.TimeBufferType = Float32Array; -zt.prototype.ValueBufferType = Float32Array; -zt.prototype.DefaultInterpolation = Us; -var Qn = class extends zt { +qe.prototype.TimeBufferType = Float32Array; +qe.prototype.ValueBufferType = Float32Array; +qe.prototype.DefaultInterpolation = Br; +var zn = class extends qe { }; -Qn.prototype.ValueTypeName = "bool"; -Qn.prototype.ValueBufferType = Array; -Qn.prototype.DefaultInterpolation = zs; -Qn.prototype.InterpolantFactoryMethodLinear = void 0; -Qn.prototype.InterpolantFactoryMethodSmooth = void 0; -var Ba = class extends zt { +zn.prototype.ValueTypeName = "bool"; +zn.prototype.ValueBufferType = Array; +zn.prototype.DefaultInterpolation = Or; +zn.prototype.InterpolantFactoryMethodLinear = void 0; +zn.prototype.InterpolantFactoryMethodSmooth = void 0; +var ha = class extends qe { }; -Ba.prototype.ValueTypeName = "color"; -var Ar = class extends zt { +ha.prototype.ValueTypeName = "color"; +var es = class extends qe { }; -Ar.prototype.ValueTypeName = "number"; -var Dh = class extends cn { - constructor(e, t, n, i){ - super(e, t, n, i); - } - interpolate_(e, t, n, i) { - let r = this.resultBuffer, o = this.sampleValues, a = this.valueSize, l = (n - t) / (i - t), c = e * a; - for(let h = c + a; c !== h; c += 4)gt.slerpFlat(r, 0, o, c - a, o, c, l); - return r; +es.prototype.ValueTypeName = "number"; +var mc = class extends ts { + constructor(t, e, n, i){ + super(t, e, n, i); } -}, Wi = class extends zt { - InterpolantFactoryMethodLinear(e) { - return new Dh(this.times, this.values, this.getValueSize(), e); + interpolate_(t, e, n, i) { + let r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = (n - e) / (i - e), l = t * o; + for(let h = l + o; l !== h; l += 4)Pe.slerpFlat(r, 0, a, l - o, a, l, c); + return r; } -}; -Wi.prototype.ValueTypeName = "quaternion"; -Wi.prototype.DefaultInterpolation = Us; -Wi.prototype.InterpolantFactoryMethodSmooth = void 0; -var Kn = class extends zt { -}; -Kn.prototype.ValueTypeName = "string"; -Kn.prototype.ValueBufferType = Array; -Kn.prototype.DefaultInterpolation = zs; -Kn.prototype.InterpolantFactoryMethodLinear = void 0; -Kn.prototype.InterpolantFactoryMethodSmooth = void 0; -var Cr = class extends zt { -}; -Cr.prototype.ValueTypeName = "vector"; -var Lr = class { - constructor(e, t = -1, n, i = ua){ - this.name = e, this.tracks = n, this.duration = t, this.blendMode = i, this.uuid = Et(), this.duration < 0 && this.resetDuration(); - } - static parse(e) { - let t = [], n = e.tracks, i = 1 / (e.fps || 1); - for(let o = 0, a = n.length; o !== a; ++o)t.push(ay(n[o]).scale(i)); - let r = new this(e.name, e.duration, t, e.blendMode); - return r.uuid = e.uuid, r; - } - static toJSON(e) { - let t = [], n = e.tracks, i = { - name: e.name, - duration: e.duration, - tracks: t, - uuid: e.uuid, - blendMode: e.blendMode +}, pi = class extends qe { + InterpolantFactoryMethodLinear(t) { + return new mc(this.times, this.values, this.getValueSize(), t); + } +}; +pi.prototype.ValueTypeName = "quaternion"; +pi.prototype.DefaultInterpolation = Br; +pi.prototype.InterpolantFactoryMethodSmooth = void 0; +var kn = class extends qe { +}; +kn.prototype.ValueTypeName = "string"; +kn.prototype.ValueBufferType = Array; +kn.prototype.DefaultInterpolation = Or; +kn.prototype.InterpolantFactoryMethodLinear = void 0; +kn.prototype.InterpolantFactoryMethodSmooth = void 0; +var ns = class extends qe { +}; +ns.prototype.ValueTypeName = "vector"; +var is = class { + constructor(t, e = -1, n, i = zc){ + this.name = t, this.tracks = n, this.duration = e, this.blendMode = i, this.uuid = Be(), this.duration < 0 && this.resetDuration(); + } + static parse(t) { + let e = [], n = t.tracks, i = 1 / (t.fps || 1); + for(let a = 0, o = n.length; a !== o; ++a)e.push(Mx(n[a]).scale(i)); + let r = new this(t.name, t.duration, e, t.blendMode); + return r.uuid = t.uuid, r; + } + static toJSON(t) { + let e = [], n = t.tracks, i = { + name: t.name, + duration: t.duration, + tracks: e, + uuid: t.uuid, + blendMode: t.blendMode }; - for(let r = 0, o = n.length; r !== o; ++r)t.push(zt.toJSON(n[r])); + for(let r = 0, a = n.length; r !== a; ++r)e.push(qe.toJSON(n[r])); return i; } - static CreateFromMorphTargetSequence(e, t, n, i) { - let r = t.length, o = []; - for(let a = 0; a < r; a++){ - let l = [], c = []; - l.push((a + r - 1) % r, a, (a + 1) % r), c.push(0, 1, 0); - let h = Ze.getKeyframeOrder(l); - l = Ze.sortedArray(l, 1, h), c = Ze.sortedArray(c, 1, h), !i && l[0] === 0 && (l.push(r), c.push(c[0])), o.push(new Ar(".morphTargetInfluences[" + t[a].name + "]", l, c).scale(1 / n)); + static CreateFromMorphTargetSequence(t, e, n, i) { + let r = e.length, a = []; + for(let o = 0; o < r; o++){ + let c = [], l = []; + c.push((o + r - 1) % r, o, (o + 1) % r), l.push(0, 1, 0); + let h = Rd(c); + c = dc(c, 1, h), l = dc(l, 1, h), !i && c[0] === 0 && (c.push(r), l.push(l[0])), a.push(new es(".morphTargetInfluences[" + e[o].name + "]", c, l).scale(1 / n)); } - return new this(e, -1, o); + return new this(t, -1, a); } - static findByName(e, t) { - let n = e; - if (!Array.isArray(e)) { - let i = e; + static findByName(t, e) { + let n = t; + if (!Array.isArray(t)) { + let i = t; n = i.geometry && i.geometry.animations || i.animations; } - for(let i = 0; i < n.length; i++)if (n[i].name === t) return n[i]; + for(let i = 0; i < n.length; i++)if (n[i].name === e) return n[i]; return null; } - static CreateClipsFromMorphTargetSequences(e, t, n) { + static CreateClipsFromMorphTargetSequences(t, e, n) { let i = {}, r = /^([\w-]*?)([\d]+)$/; - for(let a = 0, l = e.length; a < l; a++){ - let c = e[a], h = c.name.match(r); + for(let o = 0, c = t.length; o < c; o++){ + let l = t[o], h = l.name.match(r); if (h && h.length > 1) { let u = h[1], d = i[u]; - d || (i[u] = d = []), d.push(c); + d || (i[u] = d = []), d.push(l); } } - let o = []; - for(let a in i)o.push(this.CreateFromMorphTargetSequence(a, i[a], t, n)); - return o; + let a = []; + for(let o in i)a.push(this.CreateFromMorphTargetSequence(o, i[o], e, n)); + return a; } - static parseAnimation(e, t) { - if (!e) return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null; + static parseAnimation(t, e) { + if (!t) return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null; let n = function(u, d, f, m, x) { if (f.length !== 0) { - let v = [], g = []; - Ze.flattenJSON(f, v, g, m), v.length !== 0 && x.push(new u(d, v, g)); + let g = [], p = []; + Xc(f, g, p, m), g.length !== 0 && x.push(new u(d, g, p)); } - }, i = [], r = e.name || "default", o = e.fps || 30, a = e.blendMode, l = e.length || -1, c = e.hierarchy || []; - for(let u = 0; u < c.length; u++){ - let d = c[u].keys; + }, i = [], r = t.name || "default", a = t.fps || 30, o = t.blendMode, c = t.length || -1, l = t.hierarchy || []; + for(let u = 0; u < l.length; u++){ + let d = l[u].keys; if (!(!d || d.length === 0)) if (d[0].morphTargets) { let f = {}, m; for(m = 0; m < d.length; m++)if (d[m].morphTargets) for(let x = 0; x < d[m].morphTargets.length; x++)f[d[m].morphTargets[x]] = -1; for(let x in f){ - let v = [], g = []; - for(let p = 0; p !== d[m].morphTargets.length; ++p){ + let g = [], p = []; + for(let v = 0; v !== d[m].morphTargets.length; ++v){ let _ = d[m]; - v.push(_.time), g.push(_.morphTarget === x ? 1 : 0); + g.push(_.time), p.push(_.morphTarget === x ? 1 : 0); } - i.push(new Ar(".morphTargetInfluence[" + x + "]", v, g)); + i.push(new es(".morphTargetInfluence[" + x + "]", g, p)); } - l = f.length * (o || 1); + c = f.length * a; } else { - let f = ".bones[" + t[u].name + "]"; - n(Cr, f + ".position", d, "pos", i), n(Wi, f + ".quaternion", d, "rot", i), n(Cr, f + ".scale", d, "scl", i); + let f = ".bones[" + e[u].name + "]"; + n(ns, f + ".position", d, "pos", i), n(pi, f + ".quaternion", d, "rot", i), n(ns, f + ".scale", d, "scl", i); } } - return i.length === 0 ? null : new this(r, l, i, a); + return i.length === 0 ? null : new this(r, c, i, o); } resetDuration() { - let e = this.tracks, t = 0; - for(let n = 0, i = e.length; n !== i; ++n){ + let t = this.tracks, e = 0; + for(let n = 0, i = t.length; n !== i; ++n){ let r = this.tracks[n]; - t = Math.max(t, r.times[r.times.length - 1]); + e = Math.max(e, r.times[r.times.length - 1]); } - return this.duration = t, this; + return this.duration = e, this; } trim() { - for(let e = 0; e < this.tracks.length; e++)this.tracks[e].trim(0, this.duration); + for(let t = 0; t < this.tracks.length; t++)this.tracks[t].trim(0, this.duration); return this; } validate() { - let e = !0; - for(let t = 0; t < this.tracks.length; t++)e = e && this.tracks[t].validate(); - return e; + let t = !0; + for(let e = 0; e < this.tracks.length; e++)t = t && this.tracks[e].validate(); + return t; } optimize() { - for(let e = 0; e < this.tracks.length; e++)this.tracks[e].optimize(); + for(let t = 0; t < this.tracks.length; t++)this.tracks[t].optimize(); return this; } clone() { - let e = []; - for(let t = 0; t < this.tracks.length; t++)e.push(this.tracks[t].clone()); - return new this.constructor(this.name, this.duration, e, this.blendMode); + let t = []; + for(let e = 0; e < this.tracks.length; e++)t.push(this.tracks[e].clone()); + return new this.constructor(this.name, this.duration, t, this.blendMode); } toJSON() { return this.constructor.toJSON(this); } }; -function oy(s) { - switch(s.toLowerCase()){ +function yx(s1) { + switch(s1.toLowerCase()){ case "scalar": case "double": case "float": case "number": case "integer": - return Ar; + return es; case "vector": case "vector2": case "vector3": case "vector4": - return Cr; + return ns; case "color": - return Ba; + return ha; case "quaternion": - return Wi; + return pi; case "bool": case "boolean": - return Qn; + return zn; case "string": - return Kn; + return kn; } - throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + s); + throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + s1); } -function ay(s) { - if (s.type === void 0) throw new Error("THREE.KeyframeTrack: track type undefined, can not parse"); - let e = oy(s.type); - if (s.times === void 0) { - let t = [], n = []; - Ze.flattenJSON(s.keys, t, n, "value"), s.times = t, s.values = n; +function Mx(s1) { + if (s1.type === void 0) throw new Error("THREE.KeyframeTrack: track type undefined, can not parse"); + let t = yx(s1.type); + if (s1.times === void 0) { + let e = [], n = []; + Xc(s1.keys, e, n, "value"), s1.times = e, s1.values = n; } - return e.parse !== void 0 ? e.parse(s) : new e(s.name, s.times, s.values, s.interpolation); + return t.parse !== void 0 ? t.parse(s1) : new t(s1.name, s1.times, s1.values, s1.interpolation); } -var Ni = { +var ss = { enabled: !1, files: {}, - add: function(s, e) { - this.enabled !== !1 && (this.files[s] = e); + add: function(s1, t) { + this.enabled !== !1 && (this.files[s1] = t); }, - get: function(s) { - if (this.enabled !== !1) return this.files[s]; + get: function(s1) { + if (this.enabled !== !1) return this.files[s1]; }, - remove: function(s) { - delete this.files[s]; + remove: function(s1) { + delete this.files[s1]; }, clear: function() { this.files = {}; } -}, za = class { - constructor(e, t, n){ - let i = this, r = !1, o = 0, a = 0, l, c = []; - this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this.itemStart = function(h) { - a++, r === !1 && i.onStart !== void 0 && i.onStart(h, o, a), r = !0; +}, ua = class { + constructor(t, e, n){ + let i = this, r = !1, a = 0, o = 0, c, l = []; + this.onStart = void 0, this.onLoad = t, this.onProgress = e, this.onError = n, this.itemStart = function(h) { + o++, r === !1 && i.onStart !== void 0 && i.onStart(h, a, o), r = !0; }, this.itemEnd = function(h) { - o++, i.onProgress !== void 0 && i.onProgress(h, o, a), o === a && (r = !1, i.onLoad !== void 0 && i.onLoad()); + a++, i.onProgress !== void 0 && i.onProgress(h, a, o), a === o && (r = !1, i.onLoad !== void 0 && i.onLoad()); }, this.itemError = function(h) { i.onError !== void 0 && i.onError(h); }, this.resolveURL = function(h) { - return l ? l(h) : h; + return c ? c(h) : h; }, this.setURLModifier = function(h) { - return l = h, this; + return c = h, this; }, this.addHandler = function(h, u) { - return c.push(h, u), this; + return l.push(h, u), this; }, this.removeHandler = function(h) { - let u = c.indexOf(h); - return u !== -1 && c.splice(u, 2), this; + let u = l.indexOf(h); + return u !== -1 && l.splice(u, 2), this; }, this.getHandler = function(h) { - for(let u = 0, d = c.length; u < d; u += 2){ - let f = c[u], m = c[u + 1]; + for(let u = 0, d = l.length; u < d; u += 2){ + let f = l[u], m = l[u + 1]; if (f.global && (f.lastIndex = 0), f.test(h)) return m; } return null; }; } -}, ly = new za, bt = class { - constructor(e){ - this.manager = e !== void 0 ? e : ly, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}; +}, Sx = new ua, Le = class { + constructor(t){ + this.manager = t !== void 0 ? t : Sx, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}; } load() {} - loadAsync(e, t) { + loadAsync(t, e) { let n = this; return new Promise(function(i, r) { - n.load(e, i, t, r); + n.load(t, i, e, r); }); } parse() {} - setCrossOrigin(e) { - return this.crossOrigin = e, this; + setCrossOrigin(t) { + return this.crossOrigin = t, this; + } + setWithCredentials(t) { + return this.withCredentials = t, this; } - setWithCredentials(e) { - return this.withCredentials = e, this; + setPath(t) { + return this.path = t, this; } - setPath(e) { - return this.path = e, this; + setResourcePath(t) { + return this.resourcePath = t, this; } - setResourcePath(e) { - return this.resourcePath = e, this; + setRequestHeader(t) { + return this.requestHeader = t, this; } - setRequestHeader(e) { - return this.requestHeader = e, this; +}; +Le.DEFAULT_MATERIAL_NAME = "__DEFAULT"; +var fn = {}, gc = class extends Error { + constructor(t, e){ + super(t), this.response = e; } -}, tn = {}, Yt = class extends bt { - constructor(e){ - super(e); +}, rn = class extends Le { + constructor(t){ + super(t); } - load(e, t, n, i) { - e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = Ni.get(e); - if (r !== void 0) return this.manager.itemStart(e), setTimeout(()=>{ - t && t(r), this.manager.itemEnd(e); + load(t, e, n, i) { + t === void 0 && (t = ""), this.path !== void 0 && (t = this.path + t), t = this.manager.resolveURL(t); + let r = ss.get(t); + if (r !== void 0) return this.manager.itemStart(t), setTimeout(()=>{ + e && e(r), this.manager.itemEnd(t); }, 0), r; - if (tn[e] !== void 0) { - tn[e].push({ - onLoad: t, + if (fn[t] !== void 0) { + fn[t].push({ + onLoad: e, onProgress: n, onError: i }); return; } - tn[e] = [], tn[e].push({ - onLoad: t, + fn[t] = [], fn[t].push({ + onLoad: e, onProgress: n, onError: i }); - let o = new Request(e, { + let a = new Request(t, { headers: new Headers(this.requestHeader), credentials: this.withCredentials ? "include" : "same-origin" - }); - fetch(o).then((a)=>{ - if (a.status === 200 || a.status === 0) { - if (a.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || a.body.getReader === void 0) return a; - let l = tn[e], c = a.body.getReader(), h = a.headers.get("Content-Length"), u = h ? parseInt(h) : 0, d = u !== 0, f = 0, m = new ReadableStream({ - start (x) { + }), o = this.mimeType, c = this.responseType; + fetch(a).then((l)=>{ + if (l.status === 200 || l.status === 0) { + if (l.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || l.body === void 0 || l.body.getReader === void 0) return l; + let h = fn[t], u = l.body.getReader(), d = l.headers.get("Content-Length") || l.headers.get("X-File-Size"), f = d ? parseInt(d) : 0, m = f !== 0, x = 0, g = new ReadableStream({ + start (p) { v(); function v() { - c.read().then(({ done: g , value: p })=>{ - if (g) x.close(); + u.read().then(({ done: _ , value: y })=>{ + if (_) p.close(); else { - f += p.byteLength; - let _ = new ProgressEvent("progress", { - lengthComputable: d, - loaded: f, - total: u + x += y.byteLength; + let b = new ProgressEvent("progress", { + lengthComputable: m, + loaded: x, + total: f }); - for(let y = 0, b = l.length; y < b; y++){ - let A = l[y]; - A.onProgress && A.onProgress(_); + for(let w = 0, R = h.length; w < R; w++){ + let L = h[w]; + L.onProgress && L.onProgress(b); } - x.enqueue(p), v(); + p.enqueue(y), v(); } }); } } }); - return new Response(m); - } else throw Error(`fetch for "${a.url}" responded with ${a.status}: ${a.statusText}`); - }).then((a)=>{ - switch(this.responseType){ + return new Response(g); + } else throw new gc(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`, l); + }).then((l)=>{ + switch(c){ case "arraybuffer": - return a.arrayBuffer(); + return l.arrayBuffer(); case "blob": - return a.blob(); + return l.blob(); case "document": - return a.text().then((l)=>new DOMParser().parseFromString(l, this.mimeType)); + return l.text().then((h)=>new DOMParser().parseFromString(h, o)); case "json": - return a.json(); + return l.json(); default: - return a.text(); + if (o === void 0) return l.text(); + { + let u = /charset="?([^;"\s]*)"?/i.exec(o), d = u && u[1] ? u[1].toLowerCase() : void 0, f = new TextDecoder(d); + return l.arrayBuffer().then((m)=>f.decode(m)); + } } - }).then((a)=>{ - Ni.add(e, a); - let l = tn[e]; - delete tn[e]; - for(let c = 0, h = l.length; c < h; c++){ - let u = l[c]; - u.onLoad && u.onLoad(a); + }).then((l)=>{ + ss.add(t, l); + let h = fn[t]; + delete fn[t]; + for(let u = 0, d = h.length; u < d; u++){ + let f = h[u]; + f.onLoad && f.onLoad(l); } - }).catch((a)=>{ - let l = tn[e]; - if (l === void 0) throw this.manager.itemError(e), a; - delete tn[e]; - for(let c = 0, h = l.length; c < h; c++){ - let u = l[c]; - u.onError && u.onError(a); + }).catch((l)=>{ + let h = fn[t]; + if (h === void 0) throw this.manager.itemError(t), l; + delete fn[t]; + for(let u = 0, d = h.length; u < d; u++){ + let f = h[u]; + f.onError && f.onError(l); } - this.manager.itemError(e); + this.manager.itemError(t); }).finally(()=>{ - this.manager.itemEnd(e); - }), this.manager.itemStart(e); + this.manager.itemEnd(t); + }), this.manager.itemStart(t); } - setResponseType(e) { - return this.responseType = e, this; + setResponseType(t) { + return this.responseType = t, this; } - setMimeType(e) { - return this.mimeType = e, this; + setMimeType(t) { + return this.mimeType = t, this; } -}, cy = class extends bt { - constructor(e){ - super(e); +}, Qh = class extends Le { + constructor(t){ + super(t); } - load(e, t, n, i) { - let r = this, o = new Yt(this.manager); - o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { + load(t, e, n, i) { + let r = this, a = new rn(this.manager); + a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(t, function(o) { try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); + e(r.parse(JSON.parse(o))); + } catch (c) { + i ? i(c) : console.error(c), r.manager.itemError(t); } }, n, i); } - parse(e) { - let t = []; - for(let n = 0; n < e.length; n++){ - let i = Lr.parse(e[n]); - t.push(i); + parse(t) { + let e = []; + for(let n = 0; n < t.length; n++){ + let i = is.parse(t[n]); + e.push(i); } - return t; + return e; } -}, hy = class extends bt { - constructor(e){ - super(e); +}, jh = class extends Le { + constructor(t){ + super(t); } - load(e, t, n, i) { - let r = this, o = [], a = new va, l = new Yt(this.manager); - l.setPath(this.path), l.setResponseType("arraybuffer"), l.setRequestHeader(this.requestHeader), l.setWithCredentials(r.withCredentials); - let c = 0; + load(t, e, n, i) { + let r = this, a = [], o = new Us, c = new rn(this.manager); + c.setPath(this.path), c.setResponseType("arraybuffer"), c.setRequestHeader(this.requestHeader), c.setWithCredentials(r.withCredentials); + let l = 0; function h(u) { - l.load(e[u], function(d) { + c.load(t[u], function(d) { let f = r.parse(d, !0); - o[u] = { + a[u] = { width: f.width, height: f.height, format: f.format, mipmaps: f.mipmaps - }, c += 1, c === 6 && (f.mipmapCount === 1 && (a.minFilter = tt), a.image = o, a.format = f.format, a.needsUpdate = !0, t && t(a)); + }, l += 1, l === 6 && (f.mipmapCount === 1 && (o.minFilter = pe), o.image = a, o.format = f.format, o.needsUpdate = !0, e && e(o)); }, n, i); } - if (Array.isArray(e)) for(let u = 0, d = e.length; u < d; ++u)h(u); - else l.load(e, function(u) { + if (Array.isArray(t)) for(let u = 0, d = t.length; u < d; ++u)h(u); + else c.load(t, function(u) { let d = r.parse(u, !0); if (d.isCubemap) { let f = d.mipmaps.length / d.mipmapCount; for(let m = 0; m < f; m++){ - o[m] = { + a[m] = { mipmaps: [] }; - for(let x = 0; x < d.mipmapCount; x++)o[m].mipmaps.push(d.mipmaps[m * d.mipmapCount + x]), o[m].format = d.format, o[m].width = d.width, o[m].height = d.height; + for(let x = 0; x < d.mipmapCount; x++)a[m].mipmaps.push(d.mipmaps[m * d.mipmapCount + x]), a[m].format = d.format, a[m].width = d.width, a[m].height = d.height; } - a.image = o; - } else a.image.width = d.width, a.image.height = d.height, a.mipmaps = d.mipmaps; - d.mipmapCount === 1 && (a.minFilter = tt), a.format = d.format, a.needsUpdate = !0, t && t(a); + o.image = a; + } else o.image.width = d.width, o.image.height = d.height, o.mipmaps = d.mipmaps; + d.mipmapCount === 1 && (o.minFilter = pe), o.format = d.format, o.needsUpdate = !0, e && e(o); }, n, i); - return a; + return o; } -}, Rr = class extends bt { - constructor(e){ - super(e); +}, rs = class extends Le { + constructor(t){ + super(t); } - load(e, t, n, i) { - this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = this, o = Ni.get(e); - if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { - t && t(o), r.manager.itemEnd(e); - }, 0), o; - let a = qs("img"); - function l() { - h(), Ni.add(e, this), t && t(this), r.manager.itemEnd(e); + load(t, e, n, i) { + this.path !== void 0 && (t = this.path + t), t = this.manager.resolveURL(t); + let r = this, a = ss.get(t); + if (a !== void 0) return r.manager.itemStart(t), setTimeout(function() { + e && e(a), r.manager.itemEnd(t); + }, 0), a; + let o = ws("img"); + function c() { + h(), ss.add(t, this), e && e(this), r.manager.itemEnd(t); } - function c(u) { - h(), i && i(u), r.manager.itemError(e), r.manager.itemEnd(e); + function l(u) { + h(), i && i(u), r.manager.itemError(t), r.manager.itemEnd(t); } function h() { - a.removeEventListener("load", l, !1), a.removeEventListener("error", c, !1); - } - return a.addEventListener("load", l, !1), a.addEventListener("error", c, !1), e.substr(0, 5) !== "data:" && this.crossOrigin !== void 0 && (a.crossOrigin = this.crossOrigin), r.manager.itemStart(e), a.src = e, a; - } -}, Fh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = new ki, o = new Rr(this.manager); - o.setCrossOrigin(this.crossOrigin), o.setPath(this.path); - let a = 0; - function l(c) { - o.load(e[c], function(h) { - r.images[c] = h, a++, a === 6 && (r.needsUpdate = !0, t && t(r)); + o.removeEventListener("load", c, !1), o.removeEventListener("error", l, !1); + } + return o.addEventListener("load", c, !1), o.addEventListener("error", l, !1), t.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (o.crossOrigin = this.crossOrigin), r.manager.itemStart(t), o.src = t, o; + } +}, tu = class extends Le { + constructor(t){ + super(t); + } + load(t, e, n, i) { + let r = new Ki; + r.colorSpace = Nt; + let a = new rs(this.manager); + a.setCrossOrigin(this.crossOrigin), a.setPath(this.path); + let o = 0; + function c(l) { + a.load(t[l], function(h) { + r.images[l] = h, o++, o === 6 && (r.needsUpdate = !0, e && e(r)); }, void 0, i); } - for(let c = 0; c < e.length; ++c)l(c); + for(let l = 0; l < t.length; ++l)c(l); return r; } -}, Nh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new qn, a = new Yt(this.manager); - return a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(r.withCredentials), a.load(e, function(l) { - let c = r.parse(l); - !c || (c.image !== void 0 ? o.image = c.image : c.data !== void 0 && (o.image.width = c.width, o.image.height = c.height, o.image.data = c.data), o.wrapS = c.wrapS !== void 0 ? c.wrapS : vt, o.wrapT = c.wrapT !== void 0 ? c.wrapT : vt, o.magFilter = c.magFilter !== void 0 ? c.magFilter : tt, o.minFilter = c.minFilter !== void 0 ? c.minFilter : tt, o.anisotropy = c.anisotropy !== void 0 ? c.anisotropy : 1, c.encoding !== void 0 && (o.encoding = c.encoding), c.flipY !== void 0 && (o.flipY = c.flipY), c.format !== void 0 && (o.format = c.format), c.type !== void 0 && (o.type = c.type), c.mipmaps !== void 0 && (o.mipmaps = c.mipmaps, o.minFilter = Ui), c.mipmapCount === 1 && (o.minFilter = tt), c.generateMipmaps !== void 0 && (o.generateMipmaps = c.generateMipmaps), o.needsUpdate = !0, t && t(o, c)); - }, n, i), o; - } -}, Bh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = new ot, o = new Rr(this.manager); - return o.setCrossOrigin(this.crossOrigin), o.setPath(this.path), o.load(e, function(a) { - r.image = a, r.needsUpdate = !0, t !== void 0 && t(r); +}, eu = class extends Le { + constructor(t){ + super(t); + } + load(t, e, n, i) { + let r = this, a = new oi, o = new rn(this.manager); + return o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(r.withCredentials), o.load(t, function(c) { + let l; + try { + l = r.parse(c); + } catch (h) { + if (i !== void 0) i(h); + else { + console.error(h); + return; + } + } + if (!l) return i(); + l.image !== void 0 ? a.image = l.image : l.data !== void 0 && (a.image.width = l.width, a.image.height = l.height, a.image.data = l.data), a.wrapS = l.wrapS !== void 0 ? l.wrapS : Ce, a.wrapT = l.wrapT !== void 0 ? l.wrapT : Ce, a.magFilter = l.magFilter !== void 0 ? l.magFilter : pe, a.minFilter = l.minFilter !== void 0 ? l.minFilter : pe, a.anisotropy = l.anisotropy !== void 0 ? l.anisotropy : 1, l.colorSpace !== void 0 ? a.colorSpace = l.colorSpace : l.encoding !== void 0 && (a.encoding = l.encoding), l.flipY !== void 0 && (a.flipY = l.flipY), l.format !== void 0 && (a.format = l.format), l.type !== void 0 && (a.type = l.type), l.mipmaps !== void 0 && (a.mipmaps = l.mipmaps, a.minFilter = li), l.mipmapCount === 1 && (a.minFilter = pe), l.generateMipmaps !== void 0 && (a.generateMipmaps = l.generateMipmaps), a.needsUpdate = !0, e && e(a, l); + }, n, i), a; + } +}, nu = class extends Le { + constructor(t){ + super(t); + } + load(t, e, n, i) { + let r = new ye, a = new rs(this.manager); + return a.setCrossOrigin(this.crossOrigin), a.setPath(this.path), a.load(t, function(o) { + r.image = o, r.needsUpdate = !0, e !== void 0 && e(r); }, n, i), r; } -}, Bt = class extends Ne { - constructor(e, t = 1){ - super(); - this.type = "Light", this.color = new ae(e), this.intensity = t; +}, bn = class extends Zt { + constructor(t, e = 1){ + super(), this.isLight = !0, this.type = "Light", this.color = new ft(t), this.intensity = e; } dispose() {} - copy(e) { - return super.copy(e), this.color.copy(e.color), this.intensity = e.intensity, this; + copy(t, e) { + return super.copy(t, e), this.color.copy(t.color), this.intensity = t.intensity, this; } - toJSON(e) { - let t = super.toJSON(e); - return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t; + toJSON(t) { + let e = super.toJSON(t); + return e.object.color = this.color.getHex(), e.object.intensity = this.intensity, this.groundColor !== void 0 && (e.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (e.object.distance = this.distance), this.angle !== void 0 && (e.object.angle = this.angle), this.decay !== void 0 && (e.object.decay = this.decay), this.penumbra !== void 0 && (e.object.penumbra = this.penumbra), this.shadow !== void 0 && (e.object.shadow = this.shadow.toJSON()), e; } -}; -Bt.prototype.isLight = !0; -var Ua = class extends Bt { - constructor(e, t, n){ - super(e, n); - this.type = "HemisphereLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.groundColor = new ae(t); +}, _c = class extends bn { + constructor(t, e, n){ + super(t, n), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(Zt.DEFAULT_UP), this.updateMatrix(), this.groundColor = new ft(e); } - copy(e) { - return Bt.prototype.copy.call(this, e), this.groundColor.copy(e.groundColor), this; + copy(t, e) { + return super.copy(t, e), this.groundColor.copy(t.groundColor), this; } -}; -Ua.prototype.isHemisphereLight = !0; -var _c = new pe, Mc = new M, bc = new M, mo = class { - constructor(e){ - this.camera = e, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new X(512, 512), this.map = null, this.mapPass = null, this.matrix = new pe, this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Dr, this._frameExtents = new X(1, 1), this._viewportCount = 1, this._viewports = [ - new Ve(0, 0, 1, 1) +}, no = new Ot, iu = new A, su = new A, ks = class { + constructor(t){ + this.camera = t, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new J(512, 512), this.map = null, this.mapPass = null, this.matrix = new Ot, this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new Ps, this._frameExtents = new J(1, 1), this._viewportCount = 1, this._viewports = [ + new $t(0, 0, 1, 1) ]; } getViewportCount() { @@ -15370,12 +16928,12 @@ var _c = new pe, Mc = new M, bc = new M, mo = class { getFrustum() { return this._frustum; } - updateMatrices(e) { - let t = this.camera, n = this.matrix; - Mc.setFromMatrixPosition(e.matrixWorld), t.position.copy(Mc), bc.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(bc), t.updateMatrixWorld(), _c.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(_c), n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), n.multiply(t.projectionMatrix), n.multiply(t.matrixWorldInverse); + updateMatrices(t) { + let e = this.camera, n = this.matrix; + iu.setFromMatrixPosition(t.matrixWorld), e.position.copy(iu), su.setFromMatrixPosition(t.target.matrixWorld), e.lookAt(su), e.updateMatrixWorld(), no.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), this._frustum.setFromProjectionMatrix(no), n.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), n.multiply(no); } - getViewport(e) { - return this._viewports[e]; + getViewport(t) { + return this._viewports[t]; } getFrameExtents() { return this._frameExtents; @@ -15383,811 +16941,783 @@ var _c = new pe, Mc = new M, bc = new M, mo = class { dispose() { this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose(); } - copy(e) { - return this.camera = e.camera.clone(), this.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this; + copy(t) { + return this.camera = t.camera.clone(), this.bias = t.bias, this.radius = t.radius, this.mapSize.copy(t.mapSize), this; } clone() { return new this.constructor().copy(this); } toJSON() { - let e = {}; - return this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e; + let t = {}; + return this.bias !== 0 && (t.bias = this.bias), this.normalBias !== 0 && (t.normalBias = this.normalBias), this.radius !== 1 && (t.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (t.mapSize = this.mapSize.toArray()), t.camera = this.camera.toJSON(!1).object, delete t.camera.matrix, t; } -}, Oa = class extends mo { +}, xc = class extends ks { constructor(){ - super(new ut(50, 1, .5, 500)); - this.focus = 1; + super(new xe(50, 1, .5, 500)), this.isSpotLightShadow = !0, this.focus = 1; } - updateMatrices(e) { - let t = this.camera, n = dr * 2 * e.angle * this.focus, i = this.mapSize.width / this.mapSize.height, r = e.distance || t.far; - (n !== t.fov || i !== t.aspect || r !== t.far) && (t.fov = n, t.aspect = i, t.far = r, t.updateProjectionMatrix()), super.updateMatrices(e); + updateMatrices(t) { + let e = this.camera, n = Zi * 2 * t.angle * this.focus, i = this.mapSize.width / this.mapSize.height, r = t.distance || e.far; + (n !== e.fov || i !== e.aspect || r !== e.far) && (e.fov = n, e.aspect = i, e.far = r, e.updateProjectionMatrix()), super.updateMatrices(t); } - copy(e) { - return super.copy(e), this.focus = e.focus, this; + copy(t) { + return super.copy(t), this.focus = t.focus, this; } -}; -Oa.prototype.isSpotLightShadow = !0; -var Ha = class extends Bt { - constructor(e, t, n = 0, i = Math.PI / 3, r = 0, o = 1){ - super(e, t); - this.type = "SpotLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.distance = n, this.angle = i, this.penumbra = r, this.decay = o, this.shadow = new Oa; +}, vc = class extends bn { + constructor(t, e, n = 0, i = Math.PI / 3, r = 0, a = 2){ + super(t, e), this.isSpotLight = !0, this.type = "SpotLight", this.position.copy(Zt.DEFAULT_UP), this.updateMatrix(), this.target = new Zt, this.distance = n, this.angle = i, this.penumbra = r, this.decay = a, this.map = null, this.shadow = new xc; } get power() { return this.intensity * Math.PI; } - set power(e) { - this.intensity = e / Math.PI; + set power(t) { + this.intensity = t / Math.PI; } dispose() { this.shadow.dispose(); } - copy(e) { - return super.copy(e), this.distance = e.distance, this.angle = e.angle, this.penumbra = e.penumbra, this.decay = e.decay, this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; + copy(t, e) { + return super.copy(t, e), this.distance = t.distance, this.angle = t.angle, this.penumbra = t.penumbra, this.decay = t.decay, this.target = t.target.clone(), this.shadow = t.shadow.clone(), this; } -}; -Ha.prototype.isSpotLight = !0; -var wc = new pe, nr = new M, jo = new M, ka = class extends mo { +}, ru = new Ot, _s = new A, io = new A, yc = class extends ks { constructor(){ - super(new ut(90, 1, .5, 500)); - this._frameExtents = new X(4, 2), this._viewportCount = 6, this._viewports = [ - new Ve(2, 1, 1, 1), - new Ve(0, 1, 1, 1), - new Ve(3, 1, 1, 1), - new Ve(1, 1, 1, 1), - new Ve(3, 0, 1, 1), - new Ve(1, 0, 1, 1) + super(new xe(90, 1, .5, 500)), this.isPointLightShadow = !0, this._frameExtents = new J(4, 2), this._viewportCount = 6, this._viewports = [ + new $t(2, 1, 1, 1), + new $t(0, 1, 1, 1), + new $t(3, 1, 1, 1), + new $t(1, 1, 1, 1), + new $t(3, 0, 1, 1), + new $t(1, 0, 1, 1) ], this._cubeDirections = [ - new M(1, 0, 0), - new M(-1, 0, 0), - new M(0, 0, 1), - new M(0, 0, -1), - new M(0, 1, 0), - new M(0, -1, 0) + new A(1, 0, 0), + new A(-1, 0, 0), + new A(0, 0, 1), + new A(0, 0, -1), + new A(0, 1, 0), + new A(0, -1, 0) ], this._cubeUps = [ - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 1, 0), - new M(0, 0, 1), - new M(0, 0, -1) + new A(0, 1, 0), + new A(0, 1, 0), + new A(0, 1, 0), + new A(0, 1, 0), + new A(0, 0, 1), + new A(0, 0, -1) ]; } - updateMatrices(e, t = 0) { - let n = this.camera, i = this.matrix, r = e.distance || n.far; - r !== n.far && (n.far = r, n.updateProjectionMatrix()), nr.setFromMatrixPosition(e.matrixWorld), n.position.copy(nr), jo.copy(n.position), jo.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(jo), n.updateMatrixWorld(), i.makeTranslation(-nr.x, -nr.y, -nr.z), wc.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(wc); + updateMatrices(t, e = 0) { + let n = this.camera, i = this.matrix, r = t.distance || n.far; + r !== n.far && (n.far = r, n.updateProjectionMatrix()), _s.setFromMatrixPosition(t.matrixWorld), n.position.copy(_s), io.copy(n.position), io.add(this._cubeDirections[e]), n.up.copy(this._cubeUps[e]), n.lookAt(io), n.updateMatrixWorld(), i.makeTranslation(-_s.x, -_s.y, -_s.z), ru.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(ru); } -}; -ka.prototype.isPointLightShadow = !0; -var Ga = class extends Bt { - constructor(e, t, n = 0, i = 1){ - super(e, t); - this.type = "PointLight", this.distance = n, this.decay = i, this.shadow = new ka; +}, Mc = class extends bn { + constructor(t, e, n = 0, i = 2){ + super(t, e), this.isPointLight = !0, this.type = "PointLight", this.distance = n, this.decay = i, this.shadow = new yc; } get power() { return this.intensity * 4 * Math.PI; } - set power(e) { - this.intensity = e / (4 * Math.PI); + set power(t) { + this.intensity = t / (4 * Math.PI); } dispose() { this.shadow.dispose(); } - copy(e) { - return super.copy(e), this.distance = e.distance, this.decay = e.decay, this.shadow = e.shadow.clone(), this; + copy(t, e) { + return super.copy(t, e), this.distance = t.distance, this.decay = t.decay, this.shadow = t.shadow.clone(), this; } -}; -Ga.prototype.isPointLight = !0; -var Va = class extends mo { +}, Sc = class extends ks { constructor(){ - super(new Fr(-5, 5, 5, -5, .5, 500)); + super(new Ls(-5, 5, 5, -5, .5, 500)), this.isDirectionalLightShadow = !0; } -}; -Va.prototype.isDirectionalLightShadow = !0; -var Wa = class extends Bt { - constructor(e, t){ - super(e, t); - this.type = "DirectionalLight", this.position.copy(Ne.DefaultUp), this.updateMatrix(), this.target = new Ne, this.shadow = new Va; +}, bc = class extends bn { + constructor(t, e){ + super(t, e), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(Zt.DEFAULT_UP), this.updateMatrix(), this.target = new Zt, this.shadow = new Sc; } dispose() { this.shadow.dispose(); } - copy(e) { - return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this; + copy(t) { + return super.copy(t), this.target = t.target.clone(), this.shadow = t.shadow.clone(), this; } -}; -Wa.prototype.isDirectionalLight = !0; -var qa = class extends Bt { - constructor(e, t){ - super(e, t); - this.type = "AmbientLight"; +}, Ec = class extends bn { + constructor(t, e){ + super(t, e), this.isAmbientLight = !0, this.type = "AmbientLight"; } -}; -qa.prototype.isAmbientLight = !0; -var Xa = class extends Bt { - constructor(e, t, n = 10, i = 10){ - super(e, t); - this.type = "RectAreaLight", this.width = n, this.height = i; +}, Tc = class extends bn { + constructor(t, e, n = 10, i = 10){ + super(t, e), this.isRectAreaLight = !0, this.type = "RectAreaLight", this.width = n, this.height = i; } get power() { return this.intensity * this.width * this.height * Math.PI; } - set power(e) { - this.intensity = e / (this.width * this.height * Math.PI); + set power(t) { + this.intensity = t / (this.width * this.height * Math.PI); } - copy(e) { - return super.copy(e), this.width = e.width, this.height = e.height, this; + copy(t) { + return super.copy(t), this.width = t.width, this.height = t.height, this; } - toJSON(e) { - let t = super.toJSON(e); - return t.object.width = this.width, t.object.height = this.height, t; + toJSON(t) { + let e = super.toJSON(t); + return e.object.width = this.width, e.object.height = this.height, e; } -}; -Xa.prototype.isRectAreaLight = !0; -var Ja = class { +}, wc = class { constructor(){ - this.coefficients = []; - for(let e = 0; e < 9; e++)this.coefficients.push(new M); + this.isSphericalHarmonics3 = !0, this.coefficients = []; + for(let t = 0; t < 9; t++)this.coefficients.push(new A); } - set(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].copy(e[t]); + set(t) { + for(let e = 0; e < 9; e++)this.coefficients[e].copy(t[e]); return this; } zero() { - for(let e = 0; e < 9; e++)this.coefficients[e].set(0, 0, 0); + for(let t = 0; t < 9; t++)this.coefficients[t].set(0, 0, 0); return this; } - getAt(e, t) { - let n = e.x, i = e.y, r = e.z, o = this.coefficients; - return t.copy(o[0]).multiplyScalar(.282095), t.addScaledVector(o[1], .488603 * i), t.addScaledVector(o[2], .488603 * r), t.addScaledVector(o[3], .488603 * n), t.addScaledVector(o[4], 1.092548 * (n * i)), t.addScaledVector(o[5], 1.092548 * (i * r)), t.addScaledVector(o[6], .315392 * (3 * r * r - 1)), t.addScaledVector(o[7], 1.092548 * (n * r)), t.addScaledVector(o[8], .546274 * (n * n - i * i)), t; + getAt(t, e) { + let n = t.x, i = t.y, r = t.z, a = this.coefficients; + return e.copy(a[0]).multiplyScalar(.282095), e.addScaledVector(a[1], .488603 * i), e.addScaledVector(a[2], .488603 * r), e.addScaledVector(a[3], .488603 * n), e.addScaledVector(a[4], 1.092548 * (n * i)), e.addScaledVector(a[5], 1.092548 * (i * r)), e.addScaledVector(a[6], .315392 * (3 * r * r - 1)), e.addScaledVector(a[7], 1.092548 * (n * r)), e.addScaledVector(a[8], .546274 * (n * n - i * i)), e; } - getIrradianceAt(e, t) { - let n = e.x, i = e.y, r = e.z, o = this.coefficients; - return t.copy(o[0]).multiplyScalar(.886227), t.addScaledVector(o[1], 2 * .511664 * i), t.addScaledVector(o[2], 2 * .511664 * r), t.addScaledVector(o[3], 2 * .511664 * n), t.addScaledVector(o[4], 2 * .429043 * n * i), t.addScaledVector(o[5], 2 * .429043 * i * r), t.addScaledVector(o[6], .743125 * r * r - .247708), t.addScaledVector(o[7], 2 * .429043 * n * r), t.addScaledVector(o[8], .429043 * (n * n - i * i)), t; + getIrradianceAt(t, e) { + let n = t.x, i = t.y, r = t.z, a = this.coefficients; + return e.copy(a[0]).multiplyScalar(.886227), e.addScaledVector(a[1], 2 * .511664 * i), e.addScaledVector(a[2], 2 * .511664 * r), e.addScaledVector(a[3], 2 * .511664 * n), e.addScaledVector(a[4], 2 * .429043 * n * i), e.addScaledVector(a[5], 2 * .429043 * i * r), e.addScaledVector(a[6], .743125 * r * r - .247708), e.addScaledVector(a[7], 2 * .429043 * n * r), e.addScaledVector(a[8], .429043 * (n * n - i * i)), e; } - add(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].add(e.coefficients[t]); + add(t) { + for(let e = 0; e < 9; e++)this.coefficients[e].add(t.coefficients[e]); return this; } - addScaledSH(e, t) { - for(let n = 0; n < 9; n++)this.coefficients[n].addScaledVector(e.coefficients[n], t); + addScaledSH(t, e) { + for(let n = 0; n < 9; n++)this.coefficients[n].addScaledVector(t.coefficients[n], e); return this; } - scale(e) { - for(let t = 0; t < 9; t++)this.coefficients[t].multiplyScalar(e); + scale(t) { + for(let e = 0; e < 9; e++)this.coefficients[e].multiplyScalar(t); return this; } - lerp(e, t) { - for(let n = 0; n < 9; n++)this.coefficients[n].lerp(e.coefficients[n], t); + lerp(t, e) { + for(let n = 0; n < 9; n++)this.coefficients[n].lerp(t.coefficients[n], e); return this; } - equals(e) { - for(let t = 0; t < 9; t++)if (!this.coefficients[t].equals(e.coefficients[t])) return !1; + equals(t) { + for(let e = 0; e < 9; e++)if (!this.coefficients[e].equals(t.coefficients[e])) return !1; return !0; } - copy(e) { - return this.set(e.coefficients); + copy(t) { + return this.set(t.coefficients); } clone() { return new this.constructor().copy(this); } - fromArray(e, t = 0) { + fromArray(t, e = 0) { let n = this.coefficients; - for(let i = 0; i < 9; i++)n[i].fromArray(e, t + i * 3); + for(let i = 0; i < 9; i++)n[i].fromArray(t, e + i * 3); return this; } - toArray(e = [], t = 0) { + toArray(t = [], e = 0) { let n = this.coefficients; - for(let i = 0; i < 9; i++)n[i].toArray(e, t + i * 3); - return e; + for(let i = 0; i < 9; i++)n[i].toArray(t, e + i * 3); + return t; } - static getBasisAt(e, t) { - let n = e.x, i = e.y, r = e.z; - t[0] = .282095, t[1] = .488603 * i, t[2] = .488603 * r, t[3] = .488603 * n, t[4] = 1.092548 * n * i, t[5] = 1.092548 * i * r, t[6] = .315392 * (3 * r * r - 1), t[7] = 1.092548 * n * r, t[8] = .546274 * (n * n - i * i); + static getBasisAt(t, e) { + let n = t.x, i = t.y, r = t.z; + e[0] = .282095, e[1] = .488603 * i, e[2] = .488603 * r, e[3] = .488603 * n, e[4] = 1.092548 * n * i, e[5] = 1.092548 * i * r, e[6] = .315392 * (3 * r * r - 1), e[7] = 1.092548 * n * r, e[8] = .546274 * (n * n - i * i); } -}; -Ja.prototype.isSphericalHarmonics3 = !0; -var Hr = class extends Bt { - constructor(e = new Ja, t = 1){ - super(void 0, t); - this.sh = e; +}, Vs = class extends bn { + constructor(t = new wc, e = 1){ + super(void 0, e), this.isLightProbe = !0, this.sh = t; } - copy(e) { - return super.copy(e), this.sh.copy(e.sh), this; + copy(t) { + return super.copy(t), this.sh.copy(t.sh), this; } - fromJSON(e) { - return this.intensity = e.intensity, this.sh.fromArray(e.sh), this; + fromJSON(t) { + return this.intensity = t.intensity, this.sh.fromArray(t.sh), this; } - toJSON(e) { - let t = super.toJSON(e); - return t.object.sh = this.sh.toArray(), t; + toJSON(t) { + let e = super.toJSON(t); + return e.object.sh = this.sh.toArray(), e; } -}; -Hr.prototype.isLightProbe = !0; -var zh = class extends bt { - constructor(e){ - super(e); - this.textures = {}; - } - load(e, t, n, i) { - let r = this, o = new Yt(r.manager); - o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { +}, Ac = class s1 extends Le { + constructor(t){ + super(t), this.textures = {}; + } + load(t, e, n, i) { + let r = this, a = new rn(r.manager); + a.setPath(r.path), a.setRequestHeader(r.requestHeader), a.setWithCredentials(r.withCredentials), a.load(t, function(o) { try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); + e(r.parse(JSON.parse(o))); + } catch (c) { + i ? i(c) : console.error(c), r.manager.itemError(t); } }, n, i); } - parse(e) { - let t = this.textures; + parse(t) { + let e = this.textures; function n(r) { - return t[r] === void 0 && console.warn("THREE.MaterialLoader: Undefined texture", r), t[r]; + return e[r] === void 0 && console.warn("THREE.MaterialLoader: Undefined texture", r), e[r]; } - let i = new sy[e.type]; - if (e.uuid !== void 0 && (i.uuid = e.uuid), e.name !== void 0 && (i.name = e.name), e.color !== void 0 && i.color !== void 0 && i.color.setHex(e.color), e.roughness !== void 0 && (i.roughness = e.roughness), e.metalness !== void 0 && (i.metalness = e.metalness), e.sheen !== void 0 && (i.sheen = e.sheen), e.sheenColor !== void 0 && (i.sheenColor = new ae().setHex(e.sheenColor)), e.sheenRoughness !== void 0 && (i.sheenRoughness = e.sheenRoughness), e.emissive !== void 0 && i.emissive !== void 0 && i.emissive.setHex(e.emissive), e.specular !== void 0 && i.specular !== void 0 && i.specular.setHex(e.specular), e.specularIntensity !== void 0 && (i.specularIntensity = e.specularIntensity), e.specularColor !== void 0 && i.specularColor !== void 0 && i.specularColor.setHex(e.specularColor), e.shininess !== void 0 && (i.shininess = e.shininess), e.clearcoat !== void 0 && (i.clearcoat = e.clearcoat), e.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = e.clearcoatRoughness), e.transmission !== void 0 && (i.transmission = e.transmission), e.thickness !== void 0 && (i.thickness = e.thickness), e.attenuationDistance !== void 0 && (i.attenuationDistance = e.attenuationDistance), e.attenuationColor !== void 0 && i.attenuationColor !== void 0 && i.attenuationColor.setHex(e.attenuationColor), e.fog !== void 0 && (i.fog = e.fog), e.flatShading !== void 0 && (i.flatShading = e.flatShading), e.blending !== void 0 && (i.blending = e.blending), e.combine !== void 0 && (i.combine = e.combine), e.side !== void 0 && (i.side = e.side), e.shadowSide !== void 0 && (i.shadowSide = e.shadowSide), e.opacity !== void 0 && (i.opacity = e.opacity), e.format !== void 0 && (i.format = e.format), e.transparent !== void 0 && (i.transparent = e.transparent), e.alphaTest !== void 0 && (i.alphaTest = e.alphaTest), e.depthTest !== void 0 && (i.depthTest = e.depthTest), e.depthWrite !== void 0 && (i.depthWrite = e.depthWrite), e.colorWrite !== void 0 && (i.colorWrite = e.colorWrite), e.stencilWrite !== void 0 && (i.stencilWrite = e.stencilWrite), e.stencilWriteMask !== void 0 && (i.stencilWriteMask = e.stencilWriteMask), e.stencilFunc !== void 0 && (i.stencilFunc = e.stencilFunc), e.stencilRef !== void 0 && (i.stencilRef = e.stencilRef), e.stencilFuncMask !== void 0 && (i.stencilFuncMask = e.stencilFuncMask), e.stencilFail !== void 0 && (i.stencilFail = e.stencilFail), e.stencilZFail !== void 0 && (i.stencilZFail = e.stencilZFail), e.stencilZPass !== void 0 && (i.stencilZPass = e.stencilZPass), e.wireframe !== void 0 && (i.wireframe = e.wireframe), e.wireframeLinewidth !== void 0 && (i.wireframeLinewidth = e.wireframeLinewidth), e.wireframeLinecap !== void 0 && (i.wireframeLinecap = e.wireframeLinecap), e.wireframeLinejoin !== void 0 && (i.wireframeLinejoin = e.wireframeLinejoin), e.rotation !== void 0 && (i.rotation = e.rotation), e.linewidth !== 1 && (i.linewidth = e.linewidth), e.dashSize !== void 0 && (i.dashSize = e.dashSize), e.gapSize !== void 0 && (i.gapSize = e.gapSize), e.scale !== void 0 && (i.scale = e.scale), e.polygonOffset !== void 0 && (i.polygonOffset = e.polygonOffset), e.polygonOffsetFactor !== void 0 && (i.polygonOffsetFactor = e.polygonOffsetFactor), e.polygonOffsetUnits !== void 0 && (i.polygonOffsetUnits = e.polygonOffsetUnits), e.dithering !== void 0 && (i.dithering = e.dithering), e.alphaToCoverage !== void 0 && (i.alphaToCoverage = e.alphaToCoverage), e.premultipliedAlpha !== void 0 && (i.premultipliedAlpha = e.premultipliedAlpha), e.visible !== void 0 && (i.visible = e.visible), e.toneMapped !== void 0 && (i.toneMapped = e.toneMapped), e.userData !== void 0 && (i.userData = e.userData), e.vertexColors !== void 0 && (typeof e.vertexColors == "number" ? i.vertexColors = e.vertexColors > 0 : i.vertexColors = e.vertexColors), e.uniforms !== void 0) for(let r in e.uniforms){ - let o = e.uniforms[r]; - switch(i.uniforms[r] = {}, o.type){ + let i = s1.createMaterialFromType(t.type); + if (t.uuid !== void 0 && (i.uuid = t.uuid), t.name !== void 0 && (i.name = t.name), t.color !== void 0 && i.color !== void 0 && i.color.setHex(t.color), t.roughness !== void 0 && (i.roughness = t.roughness), t.metalness !== void 0 && (i.metalness = t.metalness), t.sheen !== void 0 && (i.sheen = t.sheen), t.sheenColor !== void 0 && (i.sheenColor = new ft().setHex(t.sheenColor)), t.sheenRoughness !== void 0 && (i.sheenRoughness = t.sheenRoughness), t.emissive !== void 0 && i.emissive !== void 0 && i.emissive.setHex(t.emissive), t.specular !== void 0 && i.specular !== void 0 && i.specular.setHex(t.specular), t.specularIntensity !== void 0 && (i.specularIntensity = t.specularIntensity), t.specularColor !== void 0 && i.specularColor !== void 0 && i.specularColor.setHex(t.specularColor), t.shininess !== void 0 && (i.shininess = t.shininess), t.clearcoat !== void 0 && (i.clearcoat = t.clearcoat), t.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = t.clearcoatRoughness), t.iridescence !== void 0 && (i.iridescence = t.iridescence), t.iridescenceIOR !== void 0 && (i.iridescenceIOR = t.iridescenceIOR), t.iridescenceThicknessRange !== void 0 && (i.iridescenceThicknessRange = t.iridescenceThicknessRange), t.transmission !== void 0 && (i.transmission = t.transmission), t.thickness !== void 0 && (i.thickness = t.thickness), t.attenuationDistance !== void 0 && (i.attenuationDistance = t.attenuationDistance), t.attenuationColor !== void 0 && i.attenuationColor !== void 0 && i.attenuationColor.setHex(t.attenuationColor), t.anisotropy !== void 0 && (i.anisotropy = t.anisotropy), t.anisotropyRotation !== void 0 && (i.anisotropyRotation = t.anisotropyRotation), t.fog !== void 0 && (i.fog = t.fog), t.flatShading !== void 0 && (i.flatShading = t.flatShading), t.blending !== void 0 && (i.blending = t.blending), t.combine !== void 0 && (i.combine = t.combine), t.side !== void 0 && (i.side = t.side), t.shadowSide !== void 0 && (i.shadowSide = t.shadowSide), t.opacity !== void 0 && (i.opacity = t.opacity), t.transparent !== void 0 && (i.transparent = t.transparent), t.alphaTest !== void 0 && (i.alphaTest = t.alphaTest), t.alphaHash !== void 0 && (i.alphaHash = t.alphaHash), t.depthTest !== void 0 && (i.depthTest = t.depthTest), t.depthWrite !== void 0 && (i.depthWrite = t.depthWrite), t.colorWrite !== void 0 && (i.colorWrite = t.colorWrite), t.stencilWrite !== void 0 && (i.stencilWrite = t.stencilWrite), t.stencilWriteMask !== void 0 && (i.stencilWriteMask = t.stencilWriteMask), t.stencilFunc !== void 0 && (i.stencilFunc = t.stencilFunc), t.stencilRef !== void 0 && (i.stencilRef = t.stencilRef), t.stencilFuncMask !== void 0 && (i.stencilFuncMask = t.stencilFuncMask), t.stencilFail !== void 0 && (i.stencilFail = t.stencilFail), t.stencilZFail !== void 0 && (i.stencilZFail = t.stencilZFail), t.stencilZPass !== void 0 && (i.stencilZPass = t.stencilZPass), t.wireframe !== void 0 && (i.wireframe = t.wireframe), t.wireframeLinewidth !== void 0 && (i.wireframeLinewidth = t.wireframeLinewidth), t.wireframeLinecap !== void 0 && (i.wireframeLinecap = t.wireframeLinecap), t.wireframeLinejoin !== void 0 && (i.wireframeLinejoin = t.wireframeLinejoin), t.rotation !== void 0 && (i.rotation = t.rotation), t.linewidth !== 1 && (i.linewidth = t.linewidth), t.dashSize !== void 0 && (i.dashSize = t.dashSize), t.gapSize !== void 0 && (i.gapSize = t.gapSize), t.scale !== void 0 && (i.scale = t.scale), t.polygonOffset !== void 0 && (i.polygonOffset = t.polygonOffset), t.polygonOffsetFactor !== void 0 && (i.polygonOffsetFactor = t.polygonOffsetFactor), t.polygonOffsetUnits !== void 0 && (i.polygonOffsetUnits = t.polygonOffsetUnits), t.dithering !== void 0 && (i.dithering = t.dithering), t.alphaToCoverage !== void 0 && (i.alphaToCoverage = t.alphaToCoverage), t.premultipliedAlpha !== void 0 && (i.premultipliedAlpha = t.premultipliedAlpha), t.forceSinglePass !== void 0 && (i.forceSinglePass = t.forceSinglePass), t.visible !== void 0 && (i.visible = t.visible), t.toneMapped !== void 0 && (i.toneMapped = t.toneMapped), t.userData !== void 0 && (i.userData = t.userData), t.vertexColors !== void 0 && (typeof t.vertexColors == "number" ? i.vertexColors = t.vertexColors > 0 : i.vertexColors = t.vertexColors), t.uniforms !== void 0) for(let r in t.uniforms){ + let a = t.uniforms[r]; + switch(i.uniforms[r] = {}, a.type){ case "t": - i.uniforms[r].value = n(o.value); + i.uniforms[r].value = n(a.value); break; case "c": - i.uniforms[r].value = new ae().setHex(o.value); + i.uniforms[r].value = new ft().setHex(a.value); break; case "v2": - i.uniforms[r].value = new X().fromArray(o.value); + i.uniforms[r].value = new J().fromArray(a.value); break; case "v3": - i.uniforms[r].value = new M().fromArray(o.value); + i.uniforms[r].value = new A().fromArray(a.value); break; case "v4": - i.uniforms[r].value = new Ve().fromArray(o.value); + i.uniforms[r].value = new $t().fromArray(a.value); break; case "m3": - i.uniforms[r].value = new lt().fromArray(o.value); + i.uniforms[r].value = new kt().fromArray(a.value); break; case "m4": - i.uniforms[r].value = new pe().fromArray(o.value); + i.uniforms[r].value = new Ot().fromArray(a.value); break; default: - i.uniforms[r].value = o.value; + i.uniforms[r].value = a.value; } } - if (e.defines !== void 0 && (i.defines = e.defines), e.vertexShader !== void 0 && (i.vertexShader = e.vertexShader), e.fragmentShader !== void 0 && (i.fragmentShader = e.fragmentShader), e.extensions !== void 0) for(let r in e.extensions)i.extensions[r] = e.extensions[r]; - if (e.shading !== void 0 && (i.flatShading = e.shading === 1), e.size !== void 0 && (i.size = e.size), e.sizeAttenuation !== void 0 && (i.sizeAttenuation = e.sizeAttenuation), e.map !== void 0 && (i.map = n(e.map)), e.matcap !== void 0 && (i.matcap = n(e.matcap)), e.alphaMap !== void 0 && (i.alphaMap = n(e.alphaMap)), e.bumpMap !== void 0 && (i.bumpMap = n(e.bumpMap)), e.bumpScale !== void 0 && (i.bumpScale = e.bumpScale), e.normalMap !== void 0 && (i.normalMap = n(e.normalMap)), e.normalMapType !== void 0 && (i.normalMapType = e.normalMapType), e.normalScale !== void 0) { - let r = e.normalScale; + if (t.defines !== void 0 && (i.defines = t.defines), t.vertexShader !== void 0 && (i.vertexShader = t.vertexShader), t.fragmentShader !== void 0 && (i.fragmentShader = t.fragmentShader), t.glslVersion !== void 0 && (i.glslVersion = t.glslVersion), t.extensions !== void 0) for(let r in t.extensions)i.extensions[r] = t.extensions[r]; + if (t.lights !== void 0 && (i.lights = t.lights), t.clipping !== void 0 && (i.clipping = t.clipping), t.size !== void 0 && (i.size = t.size), t.sizeAttenuation !== void 0 && (i.sizeAttenuation = t.sizeAttenuation), t.map !== void 0 && (i.map = n(t.map)), t.matcap !== void 0 && (i.matcap = n(t.matcap)), t.alphaMap !== void 0 && (i.alphaMap = n(t.alphaMap)), t.bumpMap !== void 0 && (i.bumpMap = n(t.bumpMap)), t.bumpScale !== void 0 && (i.bumpScale = t.bumpScale), t.normalMap !== void 0 && (i.normalMap = n(t.normalMap)), t.normalMapType !== void 0 && (i.normalMapType = t.normalMapType), t.normalScale !== void 0) { + let r = t.normalScale; Array.isArray(r) === !1 && (r = [ r, r - ]), i.normalScale = new X().fromArray(r); + ]), i.normalScale = new J().fromArray(r); } - return e.displacementMap !== void 0 && (i.displacementMap = n(e.displacementMap)), e.displacementScale !== void 0 && (i.displacementScale = e.displacementScale), e.displacementBias !== void 0 && (i.displacementBias = e.displacementBias), e.roughnessMap !== void 0 && (i.roughnessMap = n(e.roughnessMap)), e.metalnessMap !== void 0 && (i.metalnessMap = n(e.metalnessMap)), e.emissiveMap !== void 0 && (i.emissiveMap = n(e.emissiveMap)), e.emissiveIntensity !== void 0 && (i.emissiveIntensity = e.emissiveIntensity), e.specularMap !== void 0 && (i.specularMap = n(e.specularMap)), e.specularIntensityMap !== void 0 && (i.specularIntensityMap = n(e.specularIntensityMap)), e.specularColorMap !== void 0 && (i.specularColorMap = n(e.specularColorMap)), e.envMap !== void 0 && (i.envMap = n(e.envMap)), e.envMapIntensity !== void 0 && (i.envMapIntensity = e.envMapIntensity), e.reflectivity !== void 0 && (i.reflectivity = e.reflectivity), e.refractionRatio !== void 0 && (i.refractionRatio = e.refractionRatio), e.lightMap !== void 0 && (i.lightMap = n(e.lightMap)), e.lightMapIntensity !== void 0 && (i.lightMapIntensity = e.lightMapIntensity), e.aoMap !== void 0 && (i.aoMap = n(e.aoMap)), e.aoMapIntensity !== void 0 && (i.aoMapIntensity = e.aoMapIntensity), e.gradientMap !== void 0 && (i.gradientMap = n(e.gradientMap)), e.clearcoatMap !== void 0 && (i.clearcoatMap = n(e.clearcoatMap)), e.clearcoatRoughnessMap !== void 0 && (i.clearcoatRoughnessMap = n(e.clearcoatRoughnessMap)), e.clearcoatNormalMap !== void 0 && (i.clearcoatNormalMap = n(e.clearcoatNormalMap)), e.clearcoatNormalScale !== void 0 && (i.clearcoatNormalScale = new X().fromArray(e.clearcoatNormalScale)), e.transmissionMap !== void 0 && (i.transmissionMap = n(e.transmissionMap)), e.thicknessMap !== void 0 && (i.thicknessMap = n(e.thicknessMap)), e.sheenColorMap !== void 0 && (i.sheenColorMap = n(e.sheenColorMap)), e.sheenRoughnessMap !== void 0 && (i.sheenRoughnessMap = n(e.sheenRoughnessMap)), i; + return t.displacementMap !== void 0 && (i.displacementMap = n(t.displacementMap)), t.displacementScale !== void 0 && (i.displacementScale = t.displacementScale), t.displacementBias !== void 0 && (i.displacementBias = t.displacementBias), t.roughnessMap !== void 0 && (i.roughnessMap = n(t.roughnessMap)), t.metalnessMap !== void 0 && (i.metalnessMap = n(t.metalnessMap)), t.emissiveMap !== void 0 && (i.emissiveMap = n(t.emissiveMap)), t.emissiveIntensity !== void 0 && (i.emissiveIntensity = t.emissiveIntensity), t.specularMap !== void 0 && (i.specularMap = n(t.specularMap)), t.specularIntensityMap !== void 0 && (i.specularIntensityMap = n(t.specularIntensityMap)), t.specularColorMap !== void 0 && (i.specularColorMap = n(t.specularColorMap)), t.envMap !== void 0 && (i.envMap = n(t.envMap)), t.envMapIntensity !== void 0 && (i.envMapIntensity = t.envMapIntensity), t.reflectivity !== void 0 && (i.reflectivity = t.reflectivity), t.refractionRatio !== void 0 && (i.refractionRatio = t.refractionRatio), t.lightMap !== void 0 && (i.lightMap = n(t.lightMap)), t.lightMapIntensity !== void 0 && (i.lightMapIntensity = t.lightMapIntensity), t.aoMap !== void 0 && (i.aoMap = n(t.aoMap)), t.aoMapIntensity !== void 0 && (i.aoMapIntensity = t.aoMapIntensity), t.gradientMap !== void 0 && (i.gradientMap = n(t.gradientMap)), t.clearcoatMap !== void 0 && (i.clearcoatMap = n(t.clearcoatMap)), t.clearcoatRoughnessMap !== void 0 && (i.clearcoatRoughnessMap = n(t.clearcoatRoughnessMap)), t.clearcoatNormalMap !== void 0 && (i.clearcoatNormalMap = n(t.clearcoatNormalMap)), t.clearcoatNormalScale !== void 0 && (i.clearcoatNormalScale = new J().fromArray(t.clearcoatNormalScale)), t.iridescenceMap !== void 0 && (i.iridescenceMap = n(t.iridescenceMap)), t.iridescenceThicknessMap !== void 0 && (i.iridescenceThicknessMap = n(t.iridescenceThicknessMap)), t.transmissionMap !== void 0 && (i.transmissionMap = n(t.transmissionMap)), t.thicknessMap !== void 0 && (i.thicknessMap = n(t.thicknessMap)), t.anisotropyMap !== void 0 && (i.anisotropyMap = n(t.anisotropyMap)), t.sheenColorMap !== void 0 && (i.sheenColorMap = n(t.sheenColorMap)), t.sheenRoughnessMap !== void 0 && (i.sheenRoughnessMap = n(t.sheenRoughnessMap)), i; + } + setTextures(t) { + return this.textures = t, this; } - setTextures(e) { - return this.textures = e, this; + static createMaterialFromType(t) { + let e = { + ShadowMaterial: ic, + SpriteMaterial: Qr, + RawShaderMaterial: sc, + ShaderMaterial: Qe, + PointsMaterial: ta, + MeshPhysicalMaterial: rc, + MeshStandardMaterial: ca, + MeshPhongMaterial: ac, + MeshToonMaterial: oc, + MeshNormalMaterial: cc, + MeshLambertMaterial: lc, + MeshDepthMaterial: $r, + MeshDistanceMaterial: Kr, + MeshBasicMaterial: Mn, + MeshMatcapMaterial: hc, + LineDashedMaterial: uc, + LineBasicMaterial: Ee, + Material: Me + }; + return new e[t]; } -}, Gs = class { - static decodeText(e) { - if (typeof TextDecoder < "u") return new TextDecoder().decode(e); - let t = ""; - for(let n = 0, i = e.length; n < i; n++)t += String.fromCharCode(e[n]); +}, da = class { + static decodeText(t) { + if (typeof TextDecoder < "u") return new TextDecoder().decode(t); + let e = ""; + for(let n = 0, i = t.length; n < i; n++)e += String.fromCharCode(t[n]); try { - return decodeURIComponent(escape(t)); + return decodeURIComponent(escape(e)); } catch { - return t; + return e; } } - static extractUrlBase(e) { - let t = e.lastIndexOf("/"); - return t === -1 ? "./" : e.substr(0, t + 1); + static extractUrlBase(t) { + let e = t.lastIndexOf("/"); + return e === -1 ? "./" : t.slice(0, e + 1); } - static resolveURL(e, t) { - return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e); + static resolveURL(t, e) { + return typeof t != "string" || t === "" ? "" : (/^https?:\/\//i.test(e) && /^\//.test(t) && (e = e.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(t) || /^data:.*,.*$/i.test(t) || /^blob:.*$/i.test(t) ? t : e + t); } -}, Ya = class extends _e { +}, Rc = class extends Vt { constructor(){ - super(); - this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0; - } - copy(e) { - return super.copy(e), this.instanceCount = e.instanceCount, this; + super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = 1 / 0; } - clone() { - return new this.constructor().copy(this); + copy(t) { + return super.copy(t), this.instanceCount = t.instanceCount, this; } toJSON() { - let e = super.toJSON(this); - return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e; + let t = super.toJSON(); + return t.instanceCount = this.instanceCount, t.isInstancedBufferGeometry = !0, t; } -}; -Ya.prototype.isInstancedBufferGeometry = !0; -var Uh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new Yt(r.manager); - o.setPath(r.path), o.setRequestHeader(r.requestHeader), o.setWithCredentials(r.withCredentials), o.load(e, function(a) { +}, Cc = class extends Le { + constructor(t){ + super(t); + } + load(t, e, n, i) { + let r = this, a = new rn(r.manager); + a.setPath(r.path), a.setRequestHeader(r.requestHeader), a.setWithCredentials(r.withCredentials), a.load(t, function(o) { try { - t(r.parse(JSON.parse(a))); - } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); + e(r.parse(JSON.parse(o))); + } catch (c) { + i ? i(c) : console.error(c), r.manager.itemError(t); } }, n, i); } - parse(e) { - let t = {}, n = {}; + parse(t) { + let e = {}, n = {}; function i(f, m) { - if (t[m] !== void 0) return t[m]; - let v = f.interleavedBuffers[m], g = r(f, v.buffer), p = wi(v.type, g), _ = new $n(p, v.stride); - return _.uuid = v.uuid, t[m] = _, _; + if (e[m] !== void 0) return e[m]; + let g = f.interleavedBuffers[m], p = r(f, g.buffer), v = Vi(g.type, p), _ = new Is(v, g.stride); + return _.uuid = g.uuid, e[m] = _, _; } function r(f, m) { if (n[m] !== void 0) return n[m]; - let v = f.arrayBuffers[m], g = new Uint32Array(v).buffer; - return n[m] = g, g; + let g = f.arrayBuffers[m], p = new Uint32Array(g).buffer; + return n[m] = p, p; } - let o = e.isInstancedBufferGeometry ? new Ya : new _e, a = e.data.index; - if (a !== void 0) { - let f = wi(a.type, a.array); - o.setIndex(new Ue(f, 1)); + let a = t.isInstancedBufferGeometry ? new Rc : new Vt, o = t.data.index; + if (o !== void 0) { + let f = Vi(o.type, o.array); + a.setIndex(new Kt(f, 1)); } - let l = e.data.attributes; - for(let f in l){ - let m = l[f], x; + let c = t.data.attributes; + for(let f in c){ + let m = c[f], x; if (m.isInterleavedBufferAttribute) { - let v = i(e.data, m.data); - x = new Sn(v, m.itemSize, m.offset, m.normalized); + let g = i(t.data, m.data); + x = new Qi(g, m.itemSize, m.offset, m.normalized); } else { - let v = wi(m.type, m.array), g = m.isInstancedBufferAttribute ? Xn : Ue; - x = new g(v, m.itemSize, m.normalized); + let g = Vi(m.type, m.array), p = m.isInstancedBufferAttribute ? ui : Kt; + x = new p(g, m.itemSize, m.normalized); } - m.name !== void 0 && (x.name = m.name), m.usage !== void 0 && x.setUsage(m.usage), m.updateRange !== void 0 && (x.updateRange.offset = m.updateRange.offset, x.updateRange.count = m.updateRange.count), o.setAttribute(f, x); - } - let c = e.data.morphAttributes; - if (c) for(let f in c){ - let m = c[f], x = []; - for(let v = 0, g = m.length; v < g; v++){ - let p = m[v], _; - if (p.isInterleavedBufferAttribute) { - let y = i(e.data, p.data); - _ = new Sn(y, p.itemSize, p.offset, p.normalized); + m.name !== void 0 && (x.name = m.name), m.usage !== void 0 && x.setUsage(m.usage), m.updateRange !== void 0 && (x.updateRange.offset = m.updateRange.offset, x.updateRange.count = m.updateRange.count), a.setAttribute(f, x); + } + let l = t.data.morphAttributes; + if (l) for(let f in l){ + let m = l[f], x = []; + for(let g = 0, p = m.length; g < p; g++){ + let v = m[g], _; + if (v.isInterleavedBufferAttribute) { + let y = i(t.data, v.data); + _ = new Qi(y, v.itemSize, v.offset, v.normalized); } else { - let y = wi(p.type, p.array); - _ = new Ue(y, p.itemSize, p.normalized); + let y = Vi(v.type, v.array); + _ = new Kt(y, v.itemSize, v.normalized); } - p.name !== void 0 && (_.name = p.name), x.push(_); + v.name !== void 0 && (_.name = v.name), x.push(_); } - o.morphAttributes[f] = x; + a.morphAttributes[f] = x; } - e.data.morphTargetsRelative && (o.morphTargetsRelative = !0); - let u = e.data.groups || e.data.drawcalls || e.data.offsets; + t.data.morphTargetsRelative && (a.morphTargetsRelative = !0); + let u = t.data.groups || t.data.drawcalls || t.data.offsets; if (u !== void 0) for(let f = 0, m = u.length; f !== m; ++f){ let x = u[f]; - o.addGroup(x.start, x.count, x.materialIndex); + a.addGroup(x.start, x.count, x.materialIndex); } - let d = e.data.boundingSphere; + let d = t.data.boundingSphere; if (d !== void 0) { - let f = new M; - d.center !== void 0 && f.fromArray(d.center), o.boundingSphere = new An(f, d.radius); + let f = new A; + d.center !== void 0 && f.fromArray(d.center), a.boundingSphere = new We(f, d.radius); } - return e.name && (o.name = e.name), e.userData && (o.userData = e.userData), o; + return t.name && (a.name = t.name), t.userData && (a.userData = t.userData), a; } -}, uy = class extends bt { - constructor(e){ - super(e); +}, au = class extends Le { + constructor(t){ + super(t); } - load(e, t, n, i) { - let r = this, o = this.path === "" ? Gs.extractUrlBase(e) : this.path; - this.resourcePath = this.resourcePath || o; - let a = new Yt(this.manager); - a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(l) { - let c = null; + load(t, e, n, i) { + let r = this, a = this.path === "" ? da.extractUrlBase(t) : this.path; + this.resourcePath = this.resourcePath || a; + let o = new rn(this.manager); + o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(t, function(c) { + let l = null; try { - c = JSON.parse(l); + l = JSON.parse(c); } catch (u) { - i !== void 0 && i(u), console.error("THREE:ObjectLoader: Can't parse " + e + ".", u.message); + i !== void 0 && i(u), console.error("THREE:ObjectLoader: Can't parse " + t + ".", u.message); return; } - let h = c.metadata; + let h = l.metadata; if (h === void 0 || h.type === void 0 || h.type.toLowerCase() === "geometry") { - console.error("THREE.ObjectLoader: Can't load " + e); + i !== void 0 && i(new Error("THREE.ObjectLoader: Can't load " + t)), console.error("THREE.ObjectLoader: Can't load " + t); return; } - r.parse(c, t); + r.parse(l, e); }, n, i); } - async loadAsync(e, t) { - let n = this, i = this.path === "" ? Gs.extractUrlBase(e) : this.path; + async loadAsync(t, e) { + let n = this, i = this.path === "" ? da.extractUrlBase(t) : this.path; this.resourcePath = this.resourcePath || i; - let r = new Yt(this.manager); + let r = new rn(this.manager); r.setPath(this.path), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials); - let o = await r.loadAsync(e, t), a = JSON.parse(o), l = a.metadata; - if (l === void 0 || l.type === void 0 || l.type.toLowerCase() === "geometry") throw new Error("THREE.ObjectLoader: Can't load " + e); - return await n.parseAsync(a); - } - parse(e, t) { - let n = this.parseAnimations(e.animations), i = this.parseShapes(e.shapes), r = this.parseGeometries(e.geometries, i), o = this.parseImages(e.images, function() { - t !== void 0 && t(c); - }), a = this.parseTextures(e.textures, o), l = this.parseMaterials(e.materials, a), c = this.parseObject(e.object, r, l, a, n), h = this.parseSkeletons(e.skeletons, c); - if (this.bindSkeletons(c, h), t !== void 0) { + let a = await r.loadAsync(t, e), o = JSON.parse(a), c = o.metadata; + if (c === void 0 || c.type === void 0 || c.type.toLowerCase() === "geometry") throw new Error("THREE.ObjectLoader: Can't load " + t); + return await n.parseAsync(o); + } + parse(t, e) { + let n = this.parseAnimations(t.animations), i = this.parseShapes(t.shapes), r = this.parseGeometries(t.geometries, i), a = this.parseImages(t.images, function() { + e !== void 0 && e(l); + }), o = this.parseTextures(t.textures, a), c = this.parseMaterials(t.materials, o), l = this.parseObject(t.object, r, c, o, n), h = this.parseSkeletons(t.skeletons, l); + if (this.bindSkeletons(l, h), e !== void 0) { let u = !1; - for(let d in o)if (o[d] instanceof HTMLImageElement) { + for(let d in a)if (a[d].data instanceof HTMLImageElement) { u = !0; break; } - u === !1 && t(c); + u === !1 && e(l); } - return c; + return l; } - async parseAsync(e) { - let t = this.parseAnimations(e.animations), n = this.parseShapes(e.shapes), i = this.parseGeometries(e.geometries, n), r = await this.parseImagesAsync(e.images), o = this.parseTextures(e.textures, r), a = this.parseMaterials(e.materials, o), l = this.parseObject(e.object, i, a, o, t), c = this.parseSkeletons(e.skeletons, l); - return this.bindSkeletons(l, c), l; + async parseAsync(t) { + let e = this.parseAnimations(t.animations), n = this.parseShapes(t.shapes), i = this.parseGeometries(t.geometries, n), r = await this.parseImagesAsync(t.images), a = this.parseTextures(t.textures, r), o = this.parseMaterials(t.materials, a), c = this.parseObject(t.object, i, o, a, e), l = this.parseSkeletons(t.skeletons, c); + return this.bindSkeletons(c, l), c; } - parseShapes(e) { - let t = {}; - if (e !== void 0) for(let n = 0, i = e.length; n < i; n++){ - let r = new Xt().fromJSON(e[n]); - t[r.uuid] = r; + parseShapes(t) { + let e = {}; + if (t !== void 0) for(let n = 0, i = t.length; n < i; n++){ + let r = new Fn().fromJSON(t[n]); + e[r.uuid] = r; } - return t; + return e; } - parseSkeletons(e, t) { + parseSkeletons(t, e) { let n = {}, i = {}; - if (t.traverse(function(r) { + if (e.traverse(function(r) { r.isBone && (i[r.uuid] = r); - }), e !== void 0) for(let r = 0, o = e.length; r < o; r++){ - let a = new ao().fromJSON(e[r], i); - n[a.uuid] = a; + }), t !== void 0) for(let r = 0, a = t.length; r < a; r++){ + let o = new Lo().fromJSON(t[r], i); + n[o.uuid] = o; } return n; } - parseGeometries(e, t) { + parseGeometries(t, e) { let n = {}; - if (e !== void 0) { - let i = new Uh; - for(let r = 0, o = e.length; r < o; r++){ - let a, l = e[r]; - switch(l.type){ + if (t !== void 0) { + let i = new Cc; + for(let r = 0, a = t.length; r < a; r++){ + let o, c = t[r]; + switch(c.type){ case "BufferGeometry": case "InstancedBufferGeometry": - a = i.parse(l); - break; - case "Geometry": - console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported."); + o = i.parse(c); break; default: - l.type in vc ? a = vc[l.type].fromJSON(l, t) : console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`); + c.type in Kh ? o = Kh[c.type].fromJSON(c, e) : console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`); } - a.uuid = l.uuid, l.name !== void 0 && (a.name = l.name), a.isBufferGeometry === !0 && l.userData !== void 0 && (a.userData = l.userData), n[l.uuid] = a; + o.uuid = c.uuid, c.name !== void 0 && (o.name = c.name), c.userData !== void 0 && (o.userData = c.userData), n[c.uuid] = o; } } return n; } - parseMaterials(e, t) { + parseMaterials(t, e) { let n = {}, i = {}; - if (e !== void 0) { - let r = new zh; - r.setTextures(t); - for(let o = 0, a = e.length; o < a; o++){ - let l = e[o]; - if (l.type === "MultiMaterial") { - let c = []; - for(let h = 0; h < l.materials.length; h++){ - let u = l.materials[h]; - n[u.uuid] === void 0 && (n[u.uuid] = r.parse(u)), c.push(n[u.uuid]); - } - i[l.uuid] = c; - } else n[l.uuid] === void 0 && (n[l.uuid] = r.parse(l)), i[l.uuid] = n[l.uuid]; + if (t !== void 0) { + let r = new Ac; + r.setTextures(e); + for(let a = 0, o = t.length; a < o; a++){ + let c = t[a]; + n[c.uuid] === void 0 && (n[c.uuid] = r.parse(c)), i[c.uuid] = n[c.uuid]; } } return i; } - parseAnimations(e) { - let t = {}; - if (e !== void 0) for(let n = 0; n < e.length; n++){ - let i = e[n], r = Lr.parse(i); - t[r.uuid] = r; + parseAnimations(t) { + let e = {}; + if (t !== void 0) for(let n = 0; n < t.length; n++){ + let i = t[n], r = is.parse(i); + e[r.uuid] = r; } - return t; + return e; } - parseImages(e, t) { + parseImages(t, e) { let n = this, i = {}, r; - function o(l) { - return n.manager.itemStart(l), r.load(l, function() { - n.manager.itemEnd(l); + function a(c) { + return n.manager.itemStart(c), r.load(c, function() { + n.manager.itemEnd(c); }, void 0, function() { - n.manager.itemError(l), n.manager.itemEnd(l); + n.manager.itemError(c), n.manager.itemEnd(c); }); } - function a(l) { - if (typeof l == "string") { - let c = l, h = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(c) ? c : n.resourcePath + c; - return o(h); - } else return l.data ? { - data: wi(l.type, l.data), - width: l.width, - height: l.height + function o(c) { + if (typeof c == "string") { + let l = c, h = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(l) ? l : n.resourcePath + l; + return a(h); + } else return c.data ? { + data: Vi(c.type, c.data), + width: c.width, + height: c.height } : null; } - if (e !== void 0 && e.length > 0) { - let l = new za(t); - r = new Rr(l), r.setCrossOrigin(this.crossOrigin); - for(let c = 0, h = e.length; c < h; c++){ - let u = e[c], d = u.url; + if (t !== void 0 && t.length > 0) { + let c = new ua(e); + r = new rs(c), r.setCrossOrigin(this.crossOrigin); + for(let l = 0, h = t.length; l < h; l++){ + let u = t[l], d = u.url; if (Array.isArray(d)) { - i[u.uuid] = []; - for(let f = 0, m = d.length; f < m; f++){ - let x = d[f], v = a(x); - v !== null && (v instanceof HTMLImageElement ? i[u.uuid].push(v) : i[u.uuid].push(new qn(v.data, v.width, v.height))); + let f = []; + for(let m = 0, x = d.length; m < x; m++){ + let g = d[m], p = o(g); + p !== null && (p instanceof HTMLImageElement ? f.push(p) : f.push(new oi(p.data, p.width, p.height))); } + i[u.uuid] = new Ln(f); } else { - let f = a(u.url); - f !== null && (i[u.uuid] = f); + let f = o(u.url); + i[u.uuid] = new Ln(f); } } } return i; } - async parseImagesAsync(e) { - let t = this, n = {}, i; - async function r(o) { - if (typeof o == "string") { - let a = o, l = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(a) ? a : t.resourcePath + a; - return await i.loadAsync(l); - } else return o.data ? { - data: wi(o.type, o.data), - width: o.width, - height: o.height + async parseImagesAsync(t) { + let e = this, n = {}, i; + async function r(a) { + if (typeof a == "string") { + let o = a, c = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(o) ? o : e.resourcePath + o; + return await i.loadAsync(c); + } else return a.data ? { + data: Vi(a.type, a.data), + width: a.width, + height: a.height } : null; } - if (e !== void 0 && e.length > 0) { - i = new Rr(this.manager), i.setCrossOrigin(this.crossOrigin); - for(let o = 0, a = e.length; o < a; o++){ - let l = e[o], c = l.url; - if (Array.isArray(c)) { - n[l.uuid] = []; - for(let h = 0, u = c.length; h < u; h++){ - let d = c[h], f = await r(d); - f !== null && (f instanceof HTMLImageElement ? n[l.uuid].push(f) : n[l.uuid].push(new qn(f.data, f.width, f.height))); + if (t !== void 0 && t.length > 0) { + i = new rs(this.manager), i.setCrossOrigin(this.crossOrigin); + for(let a = 0, o = t.length; a < o; a++){ + let c = t[a], l = c.url; + if (Array.isArray(l)) { + let h = []; + for(let u = 0, d = l.length; u < d; u++){ + let f = l[u], m = await r(f); + m !== null && (m instanceof HTMLImageElement ? h.push(m) : h.push(new oi(m.data, m.width, m.height))); } + n[c.uuid] = new Ln(h); } else { - let h = await r(l.url); - h !== null && (n[l.uuid] = h); + let h = await r(c.url); + n[c.uuid] = new Ln(h); } } } return n; } - parseTextures(e, t) { - function n(r, o) { - return typeof r == "number" ? r : (console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", r), o[r]); + parseTextures(t, e) { + function n(r, a) { + return typeof r == "number" ? r : (console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.", r), a[r]); } let i = {}; - if (e !== void 0) for(let r = 0, o = e.length; r < o; r++){ - let a = e[r]; - a.image === void 0 && console.warn('THREE.ObjectLoader: No "image" specified for', a.uuid), t[a.image] === void 0 && console.warn("THREE.ObjectLoader: Undefined image", a.image); - let l, c = t[a.image]; - Array.isArray(c) ? (l = new ki(c), c.length === 6 && (l.needsUpdate = !0)) : (c && c.data ? l = new qn(c.data, c.width, c.height) : l = new ot(c), c && (l.needsUpdate = !0)), l.uuid = a.uuid, a.name !== void 0 && (l.name = a.name), a.mapping !== void 0 && (l.mapping = n(a.mapping, dy)), a.offset !== void 0 && l.offset.fromArray(a.offset), a.repeat !== void 0 && l.repeat.fromArray(a.repeat), a.center !== void 0 && l.center.fromArray(a.center), a.rotation !== void 0 && (l.rotation = a.rotation), a.wrap !== void 0 && (l.wrapS = n(a.wrap[0], Sc), l.wrapT = n(a.wrap[1], Sc)), a.format !== void 0 && (l.format = a.format), a.type !== void 0 && (l.type = a.type), a.encoding !== void 0 && (l.encoding = a.encoding), a.minFilter !== void 0 && (l.minFilter = n(a.minFilter, Tc)), a.magFilter !== void 0 && (l.magFilter = n(a.magFilter, Tc)), a.anisotropy !== void 0 && (l.anisotropy = a.anisotropy), a.flipY !== void 0 && (l.flipY = a.flipY), a.premultiplyAlpha !== void 0 && (l.premultiplyAlpha = a.premultiplyAlpha), a.unpackAlignment !== void 0 && (l.unpackAlignment = a.unpackAlignment), a.userData !== void 0 && (l.userData = a.userData), i[a.uuid] = l; + if (t !== void 0) for(let r = 0, a = t.length; r < a; r++){ + let o = t[r]; + o.image === void 0 && console.warn('THREE.ObjectLoader: No "image" specified for', o.uuid), e[o.image] === void 0 && console.warn("THREE.ObjectLoader: Undefined image", o.image); + let c = e[o.image], l = c.data, h; + Array.isArray(l) ? (h = new Ki, l.length === 6 && (h.needsUpdate = !0)) : (l && l.data ? h = new oi : h = new ye, l && (h.needsUpdate = !0)), h.source = c, h.uuid = o.uuid, o.name !== void 0 && (h.name = o.name), o.mapping !== void 0 && (h.mapping = n(o.mapping, bx)), o.channel !== void 0 && (h.channel = o.channel), o.offset !== void 0 && h.offset.fromArray(o.offset), o.repeat !== void 0 && h.repeat.fromArray(o.repeat), o.center !== void 0 && h.center.fromArray(o.center), o.rotation !== void 0 && (h.rotation = o.rotation), o.wrap !== void 0 && (h.wrapS = n(o.wrap[0], ou), h.wrapT = n(o.wrap[1], ou)), o.format !== void 0 && (h.format = o.format), o.internalFormat !== void 0 && (h.internalFormat = o.internalFormat), o.type !== void 0 && (h.type = o.type), o.colorSpace !== void 0 && (h.colorSpace = o.colorSpace), o.encoding !== void 0 && (h.encoding = o.encoding), o.minFilter !== void 0 && (h.minFilter = n(o.minFilter, cu)), o.magFilter !== void 0 && (h.magFilter = n(o.magFilter, cu)), o.anisotropy !== void 0 && (h.anisotropy = o.anisotropy), o.flipY !== void 0 && (h.flipY = o.flipY), o.generateMipmaps !== void 0 && (h.generateMipmaps = o.generateMipmaps), o.premultiplyAlpha !== void 0 && (h.premultiplyAlpha = o.premultiplyAlpha), o.unpackAlignment !== void 0 && (h.unpackAlignment = o.unpackAlignment), o.compareFunction !== void 0 && (h.compareFunction = o.compareFunction), o.userData !== void 0 && (h.userData = o.userData), i[o.uuid] = h; } return i; } - parseObject(e, t, n, i, r) { - let o; - function a(d) { - return t[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined geometry", d), t[d]; + parseObject(t, e, n, i, r) { + let a; + function o(d) { + return e[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined geometry", d), e[d]; } - function l(d) { + function c(d) { if (d !== void 0) { if (Array.isArray(d)) { let f = []; for(let m = 0, x = d.length; m < x; m++){ - let v = d[m]; - n[v] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", v), f.push(n[v]); + let g = d[m]; + n[g] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", g), f.push(n[g]); } return f; } return n[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined material", d), n[d]; } } - function c(d) { + function l(d) { return i[d] === void 0 && console.warn("THREE.ObjectLoader: Undefined texture", d), i[d]; } let h, u; - switch(e.type){ + switch(t.type){ case "Scene": - o = new no, e.background !== void 0 && (Number.isInteger(e.background) ? o.background = new ae(e.background) : o.background = c(e.background)), e.environment !== void 0 && (o.environment = c(e.environment)), e.fog !== void 0 && (e.fog.type === "Fog" ? o.fog = new Br(e.fog.color, e.fog.near, e.fog.far) : e.fog.type === "FogExp2" && (o.fog = new Nr(e.fog.color, e.fog.density))); + a = new Ao, t.background !== void 0 && (Number.isInteger(t.background) ? a.background = new ft(t.background) : a.background = l(t.background)), t.environment !== void 0 && (a.environment = l(t.environment)), t.fog !== void 0 && (t.fog.type === "Fog" ? a.fog = new wo(t.fog.color, t.fog.near, t.fog.far) : t.fog.type === "FogExp2" && (a.fog = new To(t.fog.color, t.fog.density))), t.backgroundBlurriness !== void 0 && (a.backgroundBlurriness = t.backgroundBlurriness), t.backgroundIntensity !== void 0 && (a.backgroundIntensity = t.backgroundIntensity); break; case "PerspectiveCamera": - o = new ut(e.fov, e.aspect, e.near, e.far), e.focus !== void 0 && (o.focus = e.focus), e.zoom !== void 0 && (o.zoom = e.zoom), e.filmGauge !== void 0 && (o.filmGauge = e.filmGauge), e.filmOffset !== void 0 && (o.filmOffset = e.filmOffset), e.view !== void 0 && (o.view = Object.assign({}, e.view)); + a = new xe(t.fov, t.aspect, t.near, t.far), t.focus !== void 0 && (a.focus = t.focus), t.zoom !== void 0 && (a.zoom = t.zoom), t.filmGauge !== void 0 && (a.filmGauge = t.filmGauge), t.filmOffset !== void 0 && (a.filmOffset = t.filmOffset), t.view !== void 0 && (a.view = Object.assign({}, t.view)); break; case "OrthographicCamera": - o = new Fr(e.left, e.right, e.top, e.bottom, e.near, e.far), e.zoom !== void 0 && (o.zoom = e.zoom), e.view !== void 0 && (o.view = Object.assign({}, e.view)); + a = new Ls(t.left, t.right, t.top, t.bottom, t.near, t.far), t.zoom !== void 0 && (a.zoom = t.zoom), t.view !== void 0 && (a.view = Object.assign({}, t.view)); break; case "AmbientLight": - o = new qa(e.color, e.intensity); + a = new Ec(t.color, t.intensity); break; case "DirectionalLight": - o = new Wa(e.color, e.intensity); + a = new bc(t.color, t.intensity); break; case "PointLight": - o = new Ga(e.color, e.intensity, e.distance, e.decay); + a = new Mc(t.color, t.intensity, t.distance, t.decay); break; case "RectAreaLight": - o = new Xa(e.color, e.intensity, e.width, e.height); + a = new Tc(t.color, t.intensity, t.width, t.height); break; case "SpotLight": - o = new Ha(e.color, e.intensity, e.distance, e.angle, e.penumbra, e.decay); + a = new vc(t.color, t.intensity, t.distance, t.angle, t.penumbra, t.decay); break; case "HemisphereLight": - o = new Ua(e.color, e.groundColor, e.intensity); + a = new _c(t.color, t.groundColor, t.intensity); break; case "LightProbe": - o = new Hr().fromJSON(e); + a = new Vs().fromJSON(t); break; case "SkinnedMesh": - h = a(e.geometry), u = l(e.material), o = new so(h, u), e.bindMode !== void 0 && (o.bindMode = e.bindMode), e.bindMatrix !== void 0 && o.bindMatrix.fromArray(e.bindMatrix), e.skeleton !== void 0 && (o.skeleton = e.skeleton); + h = o(t.geometry), u = c(t.material), a = new Po(h, u), t.bindMode !== void 0 && (a.bindMode = t.bindMode), t.bindMatrix !== void 0 && a.bindMatrix.fromArray(t.bindMatrix), t.skeleton !== void 0 && (a.skeleton = t.skeleton); break; case "Mesh": - h = a(e.geometry), u = l(e.material), o = new st(h, u); + h = o(t.geometry), u = c(t.material), a = new ve(h, u); break; case "InstancedMesh": - h = a(e.geometry), u = l(e.material); - let d = e.count, f = e.instanceMatrix, m = e.instanceColor; - o = new xa(h, u, d), o.instanceMatrix = new Xn(new Float32Array(f.array), 16), m !== void 0 && (o.instanceColor = new Xn(new Float32Array(m.array), m.itemSize)); + h = o(t.geometry), u = c(t.material); + let d = t.count, f = t.instanceMatrix, m = t.instanceColor; + a = new Io(h, u, d), a.instanceMatrix = new ui(new Float32Array(f.array), 16), m !== void 0 && (a.instanceColor = new ui(new Float32Array(m.array), m.itemSize)); break; case "LOD": - o = new bh; + a = new Co; break; case "Line": - o = new on(a(e.geometry), l(e.material)); + a = new Sn(o(t.geometry), c(t.material)); break; case "LineLoop": - o = new ya(a(e.geometry), l(e.material)); + a = new Uo(o(t.geometry), c(t.material)); break; case "LineSegments": - o = new wt(a(e.geometry), l(e.material)); + a = new je(o(t.geometry), c(t.material)); break; case "PointCloud": case "Points": - o = new zr(a(e.geometry), l(e.material)); + a = new No(o(t.geometry), c(t.material)); break; case "Sprite": - o = new ro(l(e.material)); + a = new Ro(c(t.material)); break; case "Group": - o = new Hn; + a = new ti; break; case "Bone": - o = new oo; + a = new jr; break; default: - o = new Ne; + a = new Zt; } - if (o.uuid = e.uuid, e.name !== void 0 && (o.name = e.name), e.matrix !== void 0 ? (o.matrix.fromArray(e.matrix), e.matrixAutoUpdate !== void 0 && (o.matrixAutoUpdate = e.matrixAutoUpdate), o.matrixAutoUpdate && o.matrix.decompose(o.position, o.quaternion, o.scale)) : (e.position !== void 0 && o.position.fromArray(e.position), e.rotation !== void 0 && o.rotation.fromArray(e.rotation), e.quaternion !== void 0 && o.quaternion.fromArray(e.quaternion), e.scale !== void 0 && o.scale.fromArray(e.scale)), e.castShadow !== void 0 && (o.castShadow = e.castShadow), e.receiveShadow !== void 0 && (o.receiveShadow = e.receiveShadow), e.shadow && (e.shadow.bias !== void 0 && (o.shadow.bias = e.shadow.bias), e.shadow.normalBias !== void 0 && (o.shadow.normalBias = e.shadow.normalBias), e.shadow.radius !== void 0 && (o.shadow.radius = e.shadow.radius), e.shadow.mapSize !== void 0 && o.shadow.mapSize.fromArray(e.shadow.mapSize), e.shadow.camera !== void 0 && (o.shadow.camera = this.parseObject(e.shadow.camera))), e.visible !== void 0 && (o.visible = e.visible), e.frustumCulled !== void 0 && (o.frustumCulled = e.frustumCulled), e.renderOrder !== void 0 && (o.renderOrder = e.renderOrder), e.userData !== void 0 && (o.userData = e.userData), e.layers !== void 0 && (o.layers.mask = e.layers), e.children !== void 0) { - let d = e.children; - for(let f = 0; f < d.length; f++)o.add(this.parseObject(d[f], t, n, i, r)); + if (a.uuid = t.uuid, t.name !== void 0 && (a.name = t.name), t.matrix !== void 0 ? (a.matrix.fromArray(t.matrix), t.matrixAutoUpdate !== void 0 && (a.matrixAutoUpdate = t.matrixAutoUpdate), a.matrixAutoUpdate && a.matrix.decompose(a.position, a.quaternion, a.scale)) : (t.position !== void 0 && a.position.fromArray(t.position), t.rotation !== void 0 && a.rotation.fromArray(t.rotation), t.quaternion !== void 0 && a.quaternion.fromArray(t.quaternion), t.scale !== void 0 && a.scale.fromArray(t.scale)), t.up !== void 0 && a.up.fromArray(t.up), t.castShadow !== void 0 && (a.castShadow = t.castShadow), t.receiveShadow !== void 0 && (a.receiveShadow = t.receiveShadow), t.shadow && (t.shadow.bias !== void 0 && (a.shadow.bias = t.shadow.bias), t.shadow.normalBias !== void 0 && (a.shadow.normalBias = t.shadow.normalBias), t.shadow.radius !== void 0 && (a.shadow.radius = t.shadow.radius), t.shadow.mapSize !== void 0 && a.shadow.mapSize.fromArray(t.shadow.mapSize), t.shadow.camera !== void 0 && (a.shadow.camera = this.parseObject(t.shadow.camera))), t.visible !== void 0 && (a.visible = t.visible), t.frustumCulled !== void 0 && (a.frustumCulled = t.frustumCulled), t.renderOrder !== void 0 && (a.renderOrder = t.renderOrder), t.userData !== void 0 && (a.userData = t.userData), t.layers !== void 0 && (a.layers.mask = t.layers), t.children !== void 0) { + let d = t.children; + for(let f = 0; f < d.length; f++)a.add(this.parseObject(d[f], e, n, i, r)); } - if (e.animations !== void 0) { - let d = e.animations; + if (t.animations !== void 0) { + let d = t.animations; for(let f = 0; f < d.length; f++){ let m = d[f]; - o.animations.push(r[m]); + a.animations.push(r[m]); } } - if (e.type === "LOD") { - e.autoUpdate !== void 0 && (o.autoUpdate = e.autoUpdate); - let d = e.levels; + if (t.type === "LOD") { + t.autoUpdate !== void 0 && (a.autoUpdate = t.autoUpdate); + let d = t.levels; for(let f = 0; f < d.length; f++){ - let m = d[f], x = o.getObjectByProperty("uuid", m.object); - x !== void 0 && o.addLevel(x, m.distance); + let m = d[f], x = a.getObjectByProperty("uuid", m.object); + x !== void 0 && a.addLevel(x, m.distance, m.hysteresis); } } - return o; + return a; } - bindSkeletons(e, t) { - Object.keys(t).length !== 0 && e.traverse(function(n) { + bindSkeletons(t, e) { + Object.keys(e).length !== 0 && t.traverse(function(n) { if (n.isSkinnedMesh === !0 && n.skeleton !== void 0) { - let i = t[n.skeleton]; + let i = e[n.skeleton]; i === void 0 ? console.warn("THREE.ObjectLoader: No skeleton found with UUID:", n.skeleton) : n.bind(i, n.bindMatrix); } }); } - setTexturePath(e) { - return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."), this.setResourcePath(e); - } -}, dy = { - UVMapping: ha, - CubeReflectionMapping: Bi, - CubeRefractionMapping: zi, - EquirectangularReflectionMapping: Ds, - EquirectangularRefractionMapping: Fs, - CubeUVReflectionMapping: Pr, - CubeUVRefractionMapping: Ws -}, Sc = { - RepeatWrapping: Ns, - ClampToEdgeWrapping: vt, - MirroredRepeatWrapping: Bs -}, Tc = { - NearestFilter: rt, - NearestMipmapNearestFilter: ta, - NearestMipmapLinearFilter: na, - LinearFilter: tt, - LinearMipmapNearestFilter: Wc, - LinearMipmapLinearFilter: Ui -}, Oh = class extends bt { - constructor(e){ - super(e); - typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { +}, bx = { + UVMapping: Oc, + CubeReflectionMapping: Bn, + CubeRefractionMapping: ci, + EquirectangularReflectionMapping: Ur, + EquirectangularRefractionMapping: Dr, + CubeUVReflectionMapping: Hs +}, ou = { + RepeatWrapping: Nr, + ClampToEdgeWrapping: Ce, + MirroredRepeatWrapping: Fr +}, cu = { + NearestFilter: fe, + NearestMipmapNearestFilter: oo, + NearestMipmapLinearFilter: Ir, + LinearFilter: pe, + LinearMipmapNearestFilter: rd, + LinearMipmapLinearFilter: li +}, lu = class extends Le { + constructor(t){ + super(t), this.isImageBitmapLoader = !0, typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { premultiplyAlpha: "none" }; } - setOptions(e) { - return this.options = e, this; - } - load(e, t, n, i) { - e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e); - let r = this, o = Ni.get(e); - if (o !== void 0) return r.manager.itemStart(e), setTimeout(function() { - t && t(o), r.manager.itemEnd(e); - }, 0), o; - let a = {}; - a.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", a.headers = this.requestHeader, fetch(e, a).then(function(l) { - return l.blob(); - }).then(function(l) { - return createImageBitmap(l, Object.assign(r.options, { + setOptions(t) { + return this.options = t, this; + } + load(t, e, n, i) { + t === void 0 && (t = ""), this.path !== void 0 && (t = this.path + t), t = this.manager.resolveURL(t); + let r = this, a = ss.get(t); + if (a !== void 0) return r.manager.itemStart(t), setTimeout(function() { + e && e(a), r.manager.itemEnd(t); + }, 0), a; + let o = {}; + o.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", o.headers = this.requestHeader, fetch(t, o).then(function(c) { + return c.blob(); + }).then(function(c) { + return createImageBitmap(c, Object.assign(r.options, { colorSpaceConversion: "none" })); - }).then(function(l) { - Ni.add(e, l), t && t(l), r.manager.itemEnd(e); - }).catch(function(l) { - i && i(l), r.manager.itemError(e), r.manager.itemEnd(e); - }), r.manager.itemStart(e); - } -}; -Oh.prototype.isImageBitmapLoader = !0; -var Ss, Hh = { - getContext: function() { - return Ss === void 0 && (Ss = new (window.AudioContext || window.webkitAudioContext)), Ss; - }, - setContext: function(s) { - Ss = s; - } -}, kh = class extends bt { - constructor(e){ - super(e); - } - load(e, t, n, i) { - let r = this, o = new Yt(this.manager); - o.setResponseType("arraybuffer"), o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(a) { + }).then(function(c) { + ss.add(t, c), e && e(c), r.manager.itemEnd(t); + }).catch(function(c) { + i && i(c), r.manager.itemError(t), r.manager.itemEnd(t); + }), r.manager.itemStart(t); + } +}, Tr, fa = class { + static getContext() { + return Tr === void 0 && (Tr = new (window.AudioContext || window.webkitAudioContext)), Tr; + } + static setContext(t) { + Tr = t; + } +}, hu = class extends Le { + constructor(t){ + super(t); + } + load(t, e, n, i) { + let r = this, a = new rn(this.manager); + a.setResponseType("arraybuffer"), a.setPath(this.path), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(t, function(c) { try { - let l = a.slice(0); - Hh.getContext().decodeAudioData(l, function(h) { - t(h); - }); + let l = c.slice(0); + fa.getContext().decodeAudioData(l, function(u) { + e(u); + }, o); } catch (l) { - i ? i(l) : console.error(l), r.manager.itemError(e); + o(l); } }, n, i); + function o(c) { + i ? i(c) : console.error(c), r.manager.itemError(t); + } } -}, Gh = class extends Hr { - constructor(e, t, n = 1){ - super(void 0, n); - let i = new ae().set(e), r = new ae().set(t), o = new M(i.r, i.g, i.b), a = new M(r.r, r.g, r.b), l = Math.sqrt(Math.PI), c = l * Math.sqrt(.75); - this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l), this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c); +}, uu = class extends Vs { + constructor(t, e, n = 1){ + super(void 0, n), this.isHemisphereLightProbe = !0; + let i = new ft().set(t), r = new ft().set(e), a = new A(i.r, i.g, i.b), o = new A(r.r, r.g, r.b), c = Math.sqrt(Math.PI), l = c * Math.sqrt(.75); + this.sh.coefficients[0].copy(a).add(o).multiplyScalar(c), this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(l); } -}; -Gh.prototype.isHemisphereLightProbe = !0; -var Vh = class extends Hr { - constructor(e, t = 1){ - super(void 0, t); - let n = new ae().set(e); +}, du = class extends Vs { + constructor(t, e = 1){ + super(void 0, e), this.isAmbientLightProbe = !0; + let n = new ft().set(t); this.sh.coefficients[0].set(n.r, n.g, n.b).multiplyScalar(2 * Math.sqrt(Math.PI)); } -}; -Vh.prototype.isAmbientLightProbe = !0; -var Ec = new pe, Ac = new pe, Fn = new pe, fy = class { +}, fu = new Ot, pu = new Ot, Yn = new Ot, mu = class { constructor(){ - this.type = "StereoCamera", this.aspect = 1, this.eyeSep = .064, this.cameraL = new ut, this.cameraL.layers.enable(1), this.cameraL.matrixAutoUpdate = !1, this.cameraR = new ut, this.cameraR.layers.enable(2), this.cameraR.matrixAutoUpdate = !1, this._cache = { + this.type = "StereoCamera", this.aspect = 1, this.eyeSep = .064, this.cameraL = new xe, this.cameraL.layers.enable(1), this.cameraL.matrixAutoUpdate = !1, this.cameraR = new xe, this.cameraR.layers.enable(2), this.cameraR.matrixAutoUpdate = !1, this._cache = { focus: null, fov: null, aspect: null, @@ -16197,21 +17727,21 @@ var Ec = new pe, Ac = new pe, Fn = new pe, fy = class { eyeSep: null }; } - update(e) { - let t = this._cache; - if (t.focus !== e.focus || t.fov !== e.fov || t.aspect !== e.aspect * this.aspect || t.near !== e.near || t.far !== e.far || t.zoom !== e.zoom || t.eyeSep !== this.eyeSep) { - t.focus = e.focus, t.fov = e.fov, t.aspect = e.aspect * this.aspect, t.near = e.near, t.far = e.far, t.zoom = e.zoom, t.eyeSep = this.eyeSep, Fn.copy(e.projectionMatrix); - let i = t.eyeSep / 2, r = i * t.near / t.focus, o = t.near * Math.tan(Wn * t.fov * .5) / t.zoom, a, l; - Ac.elements[12] = -i, Ec.elements[12] = i, a = -o * t.aspect + r, l = o * t.aspect + r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraL.projectionMatrix.copy(Fn), a = -o * t.aspect - r, l = o * t.aspect - r, Fn.elements[0] = 2 * t.near / (l - a), Fn.elements[8] = (l + a) / (l - a), this.cameraR.projectionMatrix.copy(Fn); + update(t) { + let e = this._cache; + if (e.focus !== t.focus || e.fov !== t.fov || e.aspect !== t.aspect * this.aspect || e.near !== t.near || e.far !== t.far || e.zoom !== t.zoom || e.eyeSep !== this.eyeSep) { + e.focus = t.focus, e.fov = t.fov, e.aspect = t.aspect * this.aspect, e.near = t.near, e.far = t.far, e.zoom = t.zoom, e.eyeSep = this.eyeSep, Yn.copy(t.projectionMatrix); + let i = e.eyeSep / 2, r = i * e.near / e.focus, a = e.near * Math.tan(ai * e.fov * .5) / e.zoom, o, c; + pu.elements[12] = -i, fu.elements[12] = i, o = -a * e.aspect + r, c = a * e.aspect + r, Yn.elements[0] = 2 * e.near / (c - o), Yn.elements[8] = (c + o) / (c - o), this.cameraL.projectionMatrix.copy(Yn), o = -a * e.aspect - r, c = a * e.aspect - r, Yn.elements[0] = 2 * e.near / (c - o), Yn.elements[8] = (c + o) / (c - o), this.cameraR.projectionMatrix.copy(Yn); } - this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ac), this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ec); + this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(pu), this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(fu); } -}, Wh = class { - constructor(e = !0){ - this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1; +}, Pc = class { + constructor(t = !0){ + this.autoStart = t, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1; } start() { - this.startTime = Cc(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0; + this.startTime = gu(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0; } stop() { this.getElapsedTime(), this.running = !1, this.autoStart = !1; @@ -16220,22 +17750,21 @@ var Ec = new pe, Ac = new pe, Fn = new pe, fy = class { return this.getDelta(), this.elapsedTime; } getDelta() { - let e = 0; + let t = 0; if (this.autoStart && !this.running) return this.start(), 0; if (this.running) { - let t = Cc(); - e = (t - this.oldTime) / 1e3, this.oldTime = t, this.elapsedTime += e; + let e = gu(); + t = (e - this.oldTime) / 1e3, this.oldTime = e, this.elapsedTime += t; } - return e; + return t; } }; -function Cc() { +function gu() { return (typeof performance > "u" ? Date : performance).now(); } -var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { +var Zn = new A, _u = new Pe, Ex = new A, Jn = new A, xu = class extends Zt { constructor(){ - super(); - this.type = "AudioListener", this.context = Hh.getContext(), this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.filter = null, this.timeDelta = 0, this._clock = new Wh; + super(), this.type = "AudioListener", this.context = fa.getContext(), this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.filter = null, this.timeDelta = 0, this._clock = new Pc; } getInput() { return this.gain; @@ -16246,44 +17775,43 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { getFilter() { return this.filter; } - setFilter(e) { - return this.filter !== null ? (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination)) : this.gain.disconnect(this.context.destination), this.filter = e, this.gain.connect(this.filter), this.filter.connect(this.context.destination), this; + setFilter(t) { + return this.filter !== null ? (this.gain.disconnect(this.filter), this.filter.disconnect(this.context.destination)) : this.gain.disconnect(this.context.destination), this.filter = t, this.gain.connect(this.filter), this.filter.connect(this.context.destination), this; } getMasterVolume() { return this.gain.gain.value; } - setMasterVolume(e) { - return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; + setMasterVolume(t) { + return this.gain.gain.setTargetAtTime(t, this.context.currentTime, .01), this; } - updateMatrixWorld(e) { - super.updateMatrixWorld(e); - let t = this.context.listener, n = this.up; - if (this.timeDelta = this._clock.getDelta(), this.matrixWorld.decompose(Nn, Lc, py), Bn.set(0, 0, -1).applyQuaternion(Lc), t.positionX) { + updateMatrixWorld(t) { + super.updateMatrixWorld(t); + let e = this.context.listener, n = this.up; + if (this.timeDelta = this._clock.getDelta(), this.matrixWorld.decompose(Zn, _u, Ex), Jn.set(0, 0, -1).applyQuaternion(_u), e.positionX) { let i = this.context.currentTime + this.timeDelta; - t.positionX.linearRampToValueAtTime(Nn.x, i), t.positionY.linearRampToValueAtTime(Nn.y, i), t.positionZ.linearRampToValueAtTime(Nn.z, i), t.forwardX.linearRampToValueAtTime(Bn.x, i), t.forwardY.linearRampToValueAtTime(Bn.y, i), t.forwardZ.linearRampToValueAtTime(Bn.z, i), t.upX.linearRampToValueAtTime(n.x, i), t.upY.linearRampToValueAtTime(n.y, i), t.upZ.linearRampToValueAtTime(n.z, i); - } else t.setPosition(Nn.x, Nn.y, Nn.z), t.setOrientation(Bn.x, Bn.y, Bn.z, n.x, n.y, n.z); + e.positionX.linearRampToValueAtTime(Zn.x, i), e.positionY.linearRampToValueAtTime(Zn.y, i), e.positionZ.linearRampToValueAtTime(Zn.z, i), e.forwardX.linearRampToValueAtTime(Jn.x, i), e.forwardY.linearRampToValueAtTime(Jn.y, i), e.forwardZ.linearRampToValueAtTime(Jn.z, i), e.upX.linearRampToValueAtTime(n.x, i), e.upY.linearRampToValueAtTime(n.y, i), e.upZ.linearRampToValueAtTime(n.z, i); + } else e.setPosition(Zn.x, Zn.y, Zn.z), e.setOrientation(Jn.x, Jn.y, Jn.z, n.x, n.y, n.z); } -}, Za = class extends Ne { - constructor(e){ - super(); - this.type = "Audio", this.listener = e, this.context = e.context, this.gain = this.context.createGain(), this.gain.connect(e.getInput()), this.autoplay = !1, this.buffer = null, this.detune = 0, this.loop = !1, this.loopStart = 0, this.loopEnd = 0, this.offset = 0, this.duration = void 0, this.playbackRate = 1, this.isPlaying = !1, this.hasPlaybackControl = !0, this.source = null, this.sourceType = "empty", this._startedAt = 0, this._progress = 0, this._connected = !1, this.filters = []; +}, Lc = class extends Zt { + constructor(t){ + super(), this.type = "Audio", this.listener = t, this.context = t.context, this.gain = this.context.createGain(), this.gain.connect(t.getInput()), this.autoplay = !1, this.buffer = null, this.detune = 0, this.loop = !1, this.loopStart = 0, this.loopEnd = 0, this.offset = 0, this.duration = void 0, this.playbackRate = 1, this.isPlaying = !1, this.hasPlaybackControl = !0, this.source = null, this.sourceType = "empty", this._startedAt = 0, this._progress = 0, this._connected = !1, this.filters = []; } getOutput() { return this.gain; } - setNodeSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "audioNode", this.source = e, this.connect(), this; + setNodeSource(t) { + return this.hasPlaybackControl = !1, this.sourceType = "audioNode", this.source = t, this.connect(), this; } - setMediaElementSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "mediaNode", this.source = this.context.createMediaElementSource(e), this.connect(), this; + setMediaElementSource(t) { + return this.hasPlaybackControl = !1, this.sourceType = "mediaNode", this.source = this.context.createMediaElementSource(t), this.connect(), this; } - setMediaStreamSource(e) { - return this.hasPlaybackControl = !1, this.sourceType = "mediaStreamNode", this.source = this.context.createMediaStreamSource(e), this.connect(), this; + setMediaStreamSource(t) { + return this.hasPlaybackControl = !1, this.sourceType = "mediaStreamNode", this.source = this.context.createMediaStreamSource(t), this.connect(), this; } - setBuffer(e) { - return this.buffer = e, this.sourceType = "buffer", this.autoplay && this.play(), this; + setBuffer(t) { + return this.buffer = t, this.sourceType = "buffer", this.autoplay && this.play(), this; } - play(e = 0) { + play(t = 0) { if (this.isPlaying === !0) { console.warn("THREE.Audio: Audio is already playing."); return; @@ -16292,9 +17820,9 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { console.warn("THREE.Audio: this Audio has no playback control."); return; } - this._startedAt = this.context.currentTime + e; - let t = this.context.createBufferSource(); - return t.buffer = this.buffer, t.loop = this.loop, t.loopStart = this.loopStart, t.loopEnd = this.loopEnd, t.onended = this.onEnded.bind(this), t.start(this._startedAt, this._progress + this.offset, this.duration), this.isPlaying = !0, this.source = t, this.setDetune(this.detune), this.setPlaybackRate(this.playbackRate), this.connect(); + this._startedAt = this.context.currentTime + t; + let e = this.context.createBufferSource(); + return e.buffer = this.buffer, e.loop = this.loop, e.loopStart = this.loopStart, e.loopEnd = this.loopEnd, e.onended = this.onEnded.bind(this), e.start(this._startedAt, this._progress + this.offset, this.duration), this.isPlaying = !0, this.source = e, this.setDetune(this.detune), this.setPlaybackRate(this.playbackRate), this.connect(); } pause() { if (this.hasPlaybackControl === !1) { @@ -16308,12 +17836,12 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { console.warn("THREE.Audio: this Audio has no playback control."); return; } - return this._progress = 0, this.source.stop(), this.source.onended = null, this.isPlaying = !1, this; + return this._progress = 0, this.source !== null && (this.source.stop(), this.source.onended = null), this.isPlaying = !1, this; } connect() { if (this.filters.length > 0) { this.source.connect(this.filters[0]); - for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].connect(this.filters[e]); + for(let t = 1, e = this.filters.length; t < e; t++)this.filters[t - 1].connect(this.filters[t]); this.filters[this.filters.length - 1].connect(this.getOutput()); } else this.source.connect(this.getOutput()); return this._connected = !0, this; @@ -16321,7 +17849,7 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { disconnect() { if (this.filters.length > 0) { this.source.disconnect(this.filters[0]); - for(let e = 1, t = this.filters.length; e < t; e++)this.filters[e - 1].disconnect(this.filters[e]); + for(let t = 1, e = this.filters.length; t < e; t++)this.filters[t - 1].disconnect(this.filters[t]); this.filters[this.filters.length - 1].disconnect(this.getOutput()); } else this.source.disconnect(this.getOutput()); return this._connected = !1, this; @@ -16329,11 +17857,11 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { getFilters() { return this.filters; } - setFilters(e) { - return e || (e = []), this._connected === !0 ? (this.disconnect(), this.filters = e.slice(), this.connect()) : this.filters = e.slice(), this; + setFilters(t) { + return t || (t = []), this._connected === !0 ? (this.disconnect(), this.filters = t.slice(), this.connect()) : this.filters = t.slice(), this; } - setDetune(e) { - if (this.detune = e, this.source.detune !== void 0) return this.isPlaying === !0 && this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, .01), this; + setDetune(t) { + if (this.detune = t, this.source.detune !== void 0) return this.isPlaying === !0 && this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, .01), this; } getDetune() { return this.detune; @@ -16341,17 +17869,17 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { getFilter() { return this.getFilters()[0]; } - setFilter(e) { - return this.setFilters(e ? [ - e + setFilter(t) { + return this.setFilters(t ? [ + t ] : []); } - setPlaybackRate(e) { + setPlaybackRate(t) { if (this.hasPlaybackControl === !1) { console.warn("THREE.Audio: this Audio has no playback control."); return; } - return this.playbackRate = e, this.isPlaying === !0 && this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, .01), this; + return this.playbackRate = t, this.isPlaying === !0 && this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, .01), this; } getPlaybackRate() { return this.playbackRate; @@ -16362,29 +17890,34 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { getLoop() { return this.hasPlaybackControl === !1 ? (console.warn("THREE.Audio: this Audio has no playback control."), !1) : this.loop; } - setLoop(e) { + setLoop(t) { if (this.hasPlaybackControl === !1) { console.warn("THREE.Audio: this Audio has no playback control."); return; } - return this.loop = e, this.isPlaying === !0 && (this.source.loop = this.loop), this; + return this.loop = t, this.isPlaying === !0 && (this.source.loop = this.loop), this; } - setLoopStart(e) { - return this.loopStart = e, this; + setLoopStart(t) { + return this.loopStart = t, this; } - setLoopEnd(e) { - return this.loopEnd = e, this; + setLoopEnd(t) { + return this.loopEnd = t, this; } getVolume() { return this.gain.gain.value; } - setVolume(e) { - return this.gain.gain.setTargetAtTime(e, this.context.currentTime, .01), this; + setVolume(t) { + return this.gain.gain.setTargetAtTime(t, this.context.currentTime, .01), this; } -}, zn = new M, Rc = new gt, gy = new M, Un = new M, xy = class extends Za { - constructor(e){ - super(e); - this.panner = this.context.createPanner(), this.panner.panningModel = "HRTF", this.panner.connect(this.gain); +}, $n = new A, vu = new Pe, Tx = new A, Kn = new A, yu = class extends Lc { + constructor(t){ + super(t), this.panner = this.context.createPanner(), this.panner.panningModel = "HRTF", this.panner.connect(this.gain); + } + connect() { + super.connect(), this.panner.connect(this.gain); + } + disconnect() { + super.disconnect(), this.panner.disconnect(this.gain); } getOutput() { return this.panner; @@ -16392,505 +17925,514 @@ var Nn = new M, Lc = new gt, py = new M, Bn = new M, my = class extends Ne { getRefDistance() { return this.panner.refDistance; } - setRefDistance(e) { - return this.panner.refDistance = e, this; + setRefDistance(t) { + return this.panner.refDistance = t, this; } getRolloffFactor() { return this.panner.rolloffFactor; } - setRolloffFactor(e) { - return this.panner.rolloffFactor = e, this; + setRolloffFactor(t) { + return this.panner.rolloffFactor = t, this; } getDistanceModel() { return this.panner.distanceModel; } - setDistanceModel(e) { - return this.panner.distanceModel = e, this; + setDistanceModel(t) { + return this.panner.distanceModel = t, this; } getMaxDistance() { return this.panner.maxDistance; } - setMaxDistance(e) { - return this.panner.maxDistance = e, this; + setMaxDistance(t) { + return this.panner.maxDistance = t, this; } - setDirectionalCone(e, t, n) { - return this.panner.coneInnerAngle = e, this.panner.coneOuterAngle = t, this.panner.coneOuterGain = n, this; + setDirectionalCone(t, e, n) { + return this.panner.coneInnerAngle = t, this.panner.coneOuterAngle = e, this.panner.coneOuterGain = n, this; } - updateMatrixWorld(e) { - if (super.updateMatrixWorld(e), this.hasPlaybackControl === !0 && this.isPlaying === !1) return; - this.matrixWorld.decompose(zn, Rc, gy), Un.set(0, 0, 1).applyQuaternion(Rc); - let t = this.panner; - if (t.positionX) { + updateMatrixWorld(t) { + if (super.updateMatrixWorld(t), this.hasPlaybackControl === !0 && this.isPlaying === !1) return; + this.matrixWorld.decompose($n, vu, Tx), Kn.set(0, 0, 1).applyQuaternion(vu); + let e = this.panner; + if (e.positionX) { let n = this.context.currentTime + this.listener.timeDelta; - t.positionX.linearRampToValueAtTime(zn.x, n), t.positionY.linearRampToValueAtTime(zn.y, n), t.positionZ.linearRampToValueAtTime(zn.z, n), t.orientationX.linearRampToValueAtTime(Un.x, n), t.orientationY.linearRampToValueAtTime(Un.y, n), t.orientationZ.linearRampToValueAtTime(Un.z, n); - } else t.setPosition(zn.x, zn.y, zn.z), t.setOrientation(Un.x, Un.y, Un.z); + e.positionX.linearRampToValueAtTime($n.x, n), e.positionY.linearRampToValueAtTime($n.y, n), e.positionZ.linearRampToValueAtTime($n.z, n), e.orientationX.linearRampToValueAtTime(Kn.x, n), e.orientationY.linearRampToValueAtTime(Kn.y, n), e.orientationZ.linearRampToValueAtTime(Kn.z, n); + } else e.setPosition($n.x, $n.y, $n.z), e.setOrientation(Kn.x, Kn.y, Kn.z); } -}, qh = class { - constructor(e, t = 2048){ - this.analyser = e.context.createAnalyser(), this.analyser.fftSize = t, this.data = new Uint8Array(this.analyser.frequencyBinCount), e.getOutput().connect(this.analyser); +}, Mu = class { + constructor(t, e = 2048){ + this.analyser = t.context.createAnalyser(), this.analyser.fftSize = e, this.data = new Uint8Array(this.analyser.frequencyBinCount), t.getOutput().connect(this.analyser); } getFrequencyData() { return this.analyser.getByteFrequencyData(this.data), this.data; } getAverageFrequency() { - let e = 0, t = this.getFrequencyData(); - for(let n = 0; n < t.length; n++)e += t[n]; - return e / t.length; - } -}, Xh = class { - constructor(e, t, n){ - this.binding = e, this.valueSize = n; - let i, r, o; - switch(t){ + let t = 0, e = this.getFrequencyData(); + for(let n = 0; n < e.length; n++)t += e[n]; + return t / e.length; + } +}, Ic = class { + constructor(t, e, n){ + this.binding = t, this.valueSize = n; + let i, r, a; + switch(e){ case "quaternion": - i = this._slerp, r = this._slerpAdditive, o = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5; + i = this._slerp, r = this._slerpAdditive, a = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5; break; case "string": case "bool": - i = this._select, r = this._select, o = this._setAdditiveIdentityOther, this.buffer = new Array(n * 5); + i = this._select, r = this._select, a = this._setAdditiveIdentityOther, this.buffer = new Array(n * 5); break; default: - i = this._lerp, r = this._lerpAdditive, o = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5); + i = this._lerp, r = this._lerpAdditive, a = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5); } - this._mixBufferRegion = i, this._mixBufferRegionAdditive = r, this._setIdentity = o, this._origIndex = 3, this._addIndex = 4, this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, this.useCount = 0, this.referenceCount = 0; + this._mixBufferRegion = i, this._mixBufferRegionAdditive = r, this._setIdentity = a, this._origIndex = 3, this._addIndex = 4, this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, this.useCount = 0, this.referenceCount = 0; } - accumulate(e, t) { - let n = this.buffer, i = this.valueSize, r = e * i + i, o = this.cumulativeWeight; - if (o === 0) { - for(let a = 0; a !== i; ++a)n[r + a] = n[a]; - o = t; + accumulate(t, e) { + let n = this.buffer, i = this.valueSize, r = t * i + i, a = this.cumulativeWeight; + if (a === 0) { + for(let o = 0; o !== i; ++o)n[r + o] = n[o]; + a = e; } else { - o += t; - let a = t / o; - this._mixBufferRegion(n, r, 0, a, i); + a += e; + let o = e / a; + this._mixBufferRegion(n, r, 0, o, i); } - this.cumulativeWeight = o; + this.cumulativeWeight = a; } - accumulateAdditive(e) { - let t = this.buffer, n = this.valueSize, i = n * this._addIndex; - this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(t, i, 0, e, n), this.cumulativeWeightAdditive += e; + accumulateAdditive(t) { + let e = this.buffer, n = this.valueSize, i = n * this._addIndex; + this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(e, i, 0, t, n), this.cumulativeWeightAdditive += t; } - apply(e) { - let t = this.valueSize, n = this.buffer, i = e * t + t, r = this.cumulativeWeight, o = this.cumulativeWeightAdditive, a = this.binding; + apply(t) { + let e = this.valueSize, n = this.buffer, i = t * e + e, r = this.cumulativeWeight, a = this.cumulativeWeightAdditive, o = this.binding; if (this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, r < 1) { - let l = t * this._origIndex; - this._mixBufferRegion(n, i, l, 1 - r, t); + let c = e * this._origIndex; + this._mixBufferRegion(n, i, c, 1 - r, e); } - o > 0 && this._mixBufferRegionAdditive(n, i, this._addIndex * t, 1, t); - for(let l = t, c = t + t; l !== c; ++l)if (n[l] !== n[l + t]) { - a.setValue(n, i); + a > 0 && this._mixBufferRegionAdditive(n, i, this._addIndex * e, 1, e); + for(let c = e, l = e + e; c !== l; ++c)if (n[c] !== n[c + e]) { + o.setValue(n, i); break; } } saveOriginalState() { - let e = this.binding, t = this.buffer, n = this.valueSize, i = n * this._origIndex; - e.getValue(t, i); - for(let r = n, o = i; r !== o; ++r)t[r] = t[i + r % n]; + let t = this.binding, e = this.buffer, n = this.valueSize, i = n * this._origIndex; + t.getValue(e, i); + for(let r = n, a = i; r !== a; ++r)e[r] = e[i + r % n]; this._setIdentity(), this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0; } restoreOriginalState() { - let e = this.valueSize * 3; - this.binding.setValue(this.buffer, e); + let t = this.valueSize * 3; + this.binding.setValue(this.buffer, t); } _setAdditiveIdentityNumeric() { - let e = this._addIndex * this.valueSize, t = e + this.valueSize; - for(let n = e; n < t; n++)this.buffer[n] = 0; + let t = this._addIndex * this.valueSize, e = t + this.valueSize; + for(let n = t; n < e; n++)this.buffer[n] = 0; } _setAdditiveIdentityQuaternion() { this._setAdditiveIdentityNumeric(), this.buffer[this._addIndex * this.valueSize + 3] = 1; } _setAdditiveIdentityOther() { - let e = this._origIndex * this.valueSize, t = this._addIndex * this.valueSize; - for(let n = 0; n < this.valueSize; n++)this.buffer[t + n] = this.buffer[e + n]; + let t = this._origIndex * this.valueSize, e = this._addIndex * this.valueSize; + for(let n = 0; n < this.valueSize; n++)this.buffer[e + n] = this.buffer[t + n]; } - _select(e, t, n, i, r) { - if (i >= .5) for(let o = 0; o !== r; ++o)e[t + o] = e[n + o]; + _select(t, e, n, i, r) { + if (i >= .5) for(let a = 0; a !== r; ++a)t[e + a] = t[n + a]; } - _slerp(e, t, n, i) { - gt.slerpFlat(e, t, e, t, e, n, i); + _slerp(t, e, n, i) { + Pe.slerpFlat(t, e, t, e, t, n, i); } - _slerpAdditive(e, t, n, i, r) { - let o = this._workIndex * r; - gt.multiplyQuaternionsFlat(e, o, e, t, e, n), gt.slerpFlat(e, t, e, t, e, o, i); + _slerpAdditive(t, e, n, i, r) { + let a = this._workIndex * r; + Pe.multiplyQuaternionsFlat(t, a, t, e, t, n), Pe.slerpFlat(t, e, t, e, t, a, i); } - _lerp(e, t, n, i, r) { - let o = 1 - i; - for(let a = 0; a !== r; ++a){ - let l = t + a; - e[l] = e[l] * o + e[n + a] * i; + _lerp(t, e, n, i, r) { + let a = 1 - i; + for(let o = 0; o !== r; ++o){ + let c = e + o; + t[c] = t[c] * a + t[n + o] * i; } } - _lerpAdditive(e, t, n, i, r) { - for(let o = 0; o !== r; ++o){ - let a = t + o; - e[a] = e[a] + e[n + o] * i; + _lerpAdditive(t, e, n, i, r) { + for(let a = 0; a !== r; ++a){ + let o = e + a; + t[o] = t[o] + t[n + a] * i; } } -}, $a = "\\[\\]\\.:\\/", yy = new RegExp("[" + $a + "]", "g"), ja = "[^" + $a + "]", vy = "[^" + $a.replace("\\.", "") + "]", _y = /((?:WC+[\/:])*)/.source.replace("WC", ja), My = /(WCOD+)?/.source.replace("WCOD", vy), by = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", ja), wy = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", ja), Sy = new RegExp("^" + _y + My + by + wy + "$"), Ty = [ +}, qc = "\\[\\]\\.:\\/", wx = new RegExp("[" + qc + "]", "g"), Yc = "[^" + qc + "]", Ax = "[^" + qc.replace("\\.", "") + "]", Rx = /((?:WC+[\/:])*)/.source.replace("WC", Yc), Cx = /(WCOD+)?/.source.replace("WCOD", Ax), Px = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", Yc), Lx = /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", Yc), Ix = new RegExp("^" + Rx + Cx + Px + Lx + "$"), Ux = [ "material", "materials", - "bones" -], Jh = class { - constructor(e, t, n){ - let i = n || ke.parseTrackName(t); - this._targetGroup = e, this._bindings = e.subscribe_(t, i); - } - getValue(e, t) { + "bones", + "map" +], Uc = class { + constructor(t, e, n){ + let i = n || Jt.parseTrackName(e); + this._targetGroup = t, this._bindings = t.subscribe_(e, i); + } + getValue(t, e) { this.bind(); let n = this._targetGroup.nCachedObjects_, i = this._bindings[n]; - i !== void 0 && i.getValue(e, t); + i !== void 0 && i.getValue(t, e); } - setValue(e, t) { + setValue(t, e) { let n = this._bindings; - for(let i = this._targetGroup.nCachedObjects_, r = n.length; i !== r; ++i)n[i].setValue(e, t); + for(let i = this._targetGroup.nCachedObjects_, r = n.length; i !== r; ++i)n[i].setValue(t, e); } bind() { - let e = this._bindings; - for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].bind(); + let t = this._bindings; + for(let e = this._targetGroup.nCachedObjects_, n = t.length; e !== n; ++e)t[e].bind(); } unbind() { - let e = this._bindings; - for(let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)e[t].unbind(); + let t = this._bindings; + for(let e = this._targetGroup.nCachedObjects_, n = t.length; e !== n; ++e)t[e].unbind(); } -}, ke = class { - constructor(e, t, n){ - this.path = t, this.parsedPath = n || ke.parseTrackName(t), this.node = ke.findNode(e, this.parsedPath.nodeName) || e, this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; +}, Jt = class s1 { + constructor(t, e, n){ + this.path = e, this.parsedPath = n || s1.parseTrackName(e), this.node = s1.findNode(t, this.parsedPath.nodeName), this.rootNode = t, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; } - static create(e, t, n) { - return e && e.isAnimationObjectGroup ? new ke.Composite(e, t, n) : new ke(e, t, n); + static create(t, e, n) { + return t && t.isAnimationObjectGroup ? new s1.Composite(t, e, n) : new s1(t, e, n); } - static sanitizeNodeName(e) { - return e.replace(/\s/g, "_").replace(yy, ""); + static sanitizeNodeName(t) { + return t.replace(/\s/g, "_").replace(wx, ""); } - static parseTrackName(e) { - let t = Sy.exec(e); - if (!t) throw new Error("PropertyBinding: Cannot parse trackName: " + e); + static parseTrackName(t) { + let e = Ix.exec(t); + if (e === null) throw new Error("PropertyBinding: Cannot parse trackName: " + t); let n = { - nodeName: t[2], - objectName: t[3], - objectIndex: t[4], - propertyName: t[5], - propertyIndex: t[6] + nodeName: e[2], + objectName: e[3], + objectIndex: e[4], + propertyName: e[5], + propertyIndex: e[6] }, i = n.nodeName && n.nodeName.lastIndexOf("."); if (i !== void 0 && i !== -1) { let r = n.nodeName.substring(i + 1); - Ty.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, i), n.objectName = r); + Ux.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, i), n.objectName = r); } - if (n.propertyName === null || n.propertyName.length === 0) throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e); + if (n.propertyName === null || n.propertyName.length === 0) throw new Error("PropertyBinding: can not parse propertyName from trackName: " + t); return n; } - static findNode(e, t) { - if (!t || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; - if (e.skeleton) { - let n = e.skeleton.getBoneByName(t); + static findNode(t, e) { + if (e === void 0 || e === "" || e === "." || e === -1 || e === t.name || e === t.uuid) return t; + if (t.skeleton) { + let n = t.skeleton.getBoneByName(e); if (n !== void 0) return n; } - if (e.children) { + if (t.children) { let n = function(r) { - for(let o = 0; o < r.length; o++){ - let a = r[o]; - if (a.name === t || a.uuid === t) return a; - let l = n(a.children); - if (l) return l; + for(let a = 0; a < r.length; a++){ + let o = r[a]; + if (o.name === e || o.uuid === e) return o; + let c = n(o.children); + if (c) return c; } return null; - }, i = n(e.children); + }, i = n(t.children); if (i) return i; } return null; } _getValue_unavailable() {} _setValue_unavailable() {} - _getValue_direct(e, t) { - e[t] = this.targetObject[this.propertyName]; + _getValue_direct(t, e) { + t[e] = this.targetObject[this.propertyName]; } - _getValue_array(e, t) { + _getValue_array(t, e) { let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)e[t++] = n[i]; + for(let i = 0, r = n.length; i !== r; ++i)t[e++] = n[i]; } - _getValue_arrayElement(e, t) { - e[t] = this.resolvedProperty[this.propertyIndex]; + _getValue_arrayElement(t, e) { + t[e] = this.resolvedProperty[this.propertyIndex]; } - _getValue_toArray(e, t) { - this.resolvedProperty.toArray(e, t); + _getValue_toArray(t, e) { + this.resolvedProperty.toArray(t, e); } - _setValue_direct(e, t) { - this.targetObject[this.propertyName] = e[t]; + _setValue_direct(t, e) { + this.targetObject[this.propertyName] = t[e]; } - _setValue_direct_setNeedsUpdate(e, t) { - this.targetObject[this.propertyName] = e[t], this.targetObject.needsUpdate = !0; + _setValue_direct_setNeedsUpdate(t, e) { + this.targetObject[this.propertyName] = t[e], this.targetObject.needsUpdate = !0; } - _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { - this.targetObject[this.propertyName] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; + _setValue_direct_setMatrixWorldNeedsUpdate(t, e) { + this.targetObject[this.propertyName] = t[e], this.targetObject.matrixWorldNeedsUpdate = !0; } - _setValue_array(e, t) { + _setValue_array(t, e) { let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = t[e++]; } - _setValue_array_setNeedsUpdate(e, t) { + _setValue_array_setNeedsUpdate(t, e) { let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = t[e++]; this.targetObject.needsUpdate = !0; } - _setValue_array_setMatrixWorldNeedsUpdate(e, t) { + _setValue_array_setMatrixWorldNeedsUpdate(t, e) { let n = this.resolvedProperty; - for(let i = 0, r = n.length; i !== r; ++i)n[i] = e[t++]; + for(let i = 0, r = n.length; i !== r; ++i)n[i] = t[e++]; this.targetObject.matrixWorldNeedsUpdate = !0; } - _setValue_arrayElement(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t]; + _setValue_arrayElement(t, e) { + this.resolvedProperty[this.propertyIndex] = t[e]; } - _setValue_arrayElement_setNeedsUpdate(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.needsUpdate = !0; + _setValue_arrayElement_setNeedsUpdate(t, e) { + this.resolvedProperty[this.propertyIndex] = t[e], this.targetObject.needsUpdate = !0; } - _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { - this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; + _setValue_arrayElement_setMatrixWorldNeedsUpdate(t, e) { + this.resolvedProperty[this.propertyIndex] = t[e], this.targetObject.matrixWorldNeedsUpdate = !0; } - _setValue_fromArray(e, t) { - this.resolvedProperty.fromArray(e, t); + _setValue_fromArray(t, e) { + this.resolvedProperty.fromArray(t, e); } - _setValue_fromArray_setNeedsUpdate(e, t) { - this.resolvedProperty.fromArray(e, t), this.targetObject.needsUpdate = !0; + _setValue_fromArray_setNeedsUpdate(t, e) { + this.resolvedProperty.fromArray(t, e), this.targetObject.needsUpdate = !0; } - _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { - this.resolvedProperty.fromArray(e, t), this.targetObject.matrixWorldNeedsUpdate = !0; + _setValue_fromArray_setMatrixWorldNeedsUpdate(t, e) { + this.resolvedProperty.fromArray(t, e), this.targetObject.matrixWorldNeedsUpdate = !0; } - _getValue_unbound(e, t) { - this.bind(), this.getValue(e, t); + _getValue_unbound(t, e) { + this.bind(), this.getValue(t, e); } - _setValue_unbound(e, t) { - this.bind(), this.setValue(e, t); + _setValue_unbound(t, e) { + this.bind(), this.setValue(t, e); } bind() { - let e = this.node, t = this.parsedPath, n = t.objectName, i = t.propertyName, r = t.propertyIndex; - if (e || (e = ke.findNode(this.rootNode, t.nodeName) || this.rootNode, this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) { - console.error("THREE.PropertyBinding: Trying to update node for track: " + this.path + " but it wasn't found."); + let t = this.node, e = this.parsedPath, n = e.objectName, i = e.propertyName, r = e.propertyIndex; + if (t || (t = s1.findNode(this.rootNode, e.nodeName), this.node = t), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !t) { + console.warn("THREE.PropertyBinding: No target node found for track: " + this.path + "."); return; } if (n) { - let c = t.objectIndex; + let l = e.objectIndex; switch(n){ case "materials": - if (!e.material) { + if (!t.material) { console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); return; } - if (!e.material.materials) { + if (!t.material.materials) { console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this); return; } - e = e.material.materials; + t = t.material.materials; break; case "bones": - if (!e.skeleton) { + if (!t.skeleton) { console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this); return; } - e = e.skeleton.bones; - for(let h = 0; h < e.length; h++)if (e[h].name === c) { - c = h; + t = t.skeleton.bones; + for(let h = 0; h < t.length; h++)if (t[h].name === l) { + l = h; + break; + } + break; + case "map": + if ("map" in t) { + t = t.map; break; } + if (!t.material) { + console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this); + return; + } + if (!t.material.map) { + console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.", this); + return; + } + t = t.material.map; break; default: - if (e[n] === void 0) { + if (t[n] === void 0) { console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this); return; } - e = e[n]; + t = t[n]; } - if (c !== void 0) { - if (e[c] === void 0) { - console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e); + if (l !== void 0) { + if (t[l] === void 0) { + console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, t); return; } - e = e[c]; + t = t[l]; } } - let o = e[i]; - if (o === void 0) { - let c = t.nodeName; - console.error("THREE.PropertyBinding: Trying to update property for track: " + c + "." + i + " but it wasn't found.", e); + let a = t[i]; + if (a === void 0) { + let l = e.nodeName; + console.error("THREE.PropertyBinding: Trying to update property for track: " + l + "." + i + " but it wasn't found.", t); return; } - let a = this.Versioning.None; - this.targetObject = e, e.needsUpdate !== void 0 ? a = this.Versioning.NeedsUpdate : e.matrixWorldNeedsUpdate !== void 0 && (a = this.Versioning.MatrixWorldNeedsUpdate); - let l = this.BindingType.Direct; + let o = this.Versioning.None; + this.targetObject = t, t.needsUpdate !== void 0 ? o = this.Versioning.NeedsUpdate : t.matrixWorldNeedsUpdate !== void 0 && (o = this.Versioning.MatrixWorldNeedsUpdate); + let c = this.BindingType.Direct; if (r !== void 0) { if (i === "morphTargetInfluences") { - if (!e.geometry) { + if (!t.geometry) { console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this); return; } - if (e.geometry.isBufferGeometry) { - if (!e.geometry.morphAttributes) { - console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); - return; - } - e.morphTargetDictionary[r] !== void 0 && (r = e.morphTargetDictionary[r]); - } else { - console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.", this); + if (!t.geometry.morphAttributes) { + console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); return; } + t.morphTargetDictionary[r] !== void 0 && (r = t.morphTargetDictionary[r]); } - l = this.BindingType.ArrayElement, this.resolvedProperty = o, this.propertyIndex = r; - } else o.fromArray !== void 0 && o.toArray !== void 0 ? (l = this.BindingType.HasFromToArray, this.resolvedProperty = o) : Array.isArray(o) ? (l = this.BindingType.EntireArray, this.resolvedProperty = o) : this.propertyName = i; - this.getValue = this.GetterByBindingType[l], this.setValue = this.SetterByBindingTypeAndVersioning[l][a]; + c = this.BindingType.ArrayElement, this.resolvedProperty = a, this.propertyIndex = r; + } else a.fromArray !== void 0 && a.toArray !== void 0 ? (c = this.BindingType.HasFromToArray, this.resolvedProperty = a) : Array.isArray(a) ? (c = this.BindingType.EntireArray, this.resolvedProperty = a) : this.propertyName = i; + this.getValue = this.GetterByBindingType[c], this.setValue = this.SetterByBindingTypeAndVersioning[c][o]; } unbind() { this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; } }; -ke.Composite = Jh; -ke.prototype.BindingType = { +Jt.Composite = Uc; +Jt.prototype.BindingType = { Direct: 0, EntireArray: 1, ArrayElement: 2, HasFromToArray: 3 }; -ke.prototype.Versioning = { +Jt.prototype.Versioning = { None: 0, NeedsUpdate: 1, MatrixWorldNeedsUpdate: 2 }; -ke.prototype.GetterByBindingType = [ - ke.prototype._getValue_direct, - ke.prototype._getValue_array, - ke.prototype._getValue_arrayElement, - ke.prototype._getValue_toArray +Jt.prototype.GetterByBindingType = [ + Jt.prototype._getValue_direct, + Jt.prototype._getValue_array, + Jt.prototype._getValue_arrayElement, + Jt.prototype._getValue_toArray ]; -ke.prototype.SetterByBindingTypeAndVersioning = [ +Jt.prototype.SetterByBindingTypeAndVersioning = [ [ - ke.prototype._setValue_direct, - ke.prototype._setValue_direct_setNeedsUpdate, - ke.prototype._setValue_direct_setMatrixWorldNeedsUpdate + Jt.prototype._setValue_direct, + Jt.prototype._setValue_direct_setNeedsUpdate, + Jt.prototype._setValue_direct_setMatrixWorldNeedsUpdate ], [ - ke.prototype._setValue_array, - ke.prototype._setValue_array_setNeedsUpdate, - ke.prototype._setValue_array_setMatrixWorldNeedsUpdate + Jt.prototype._setValue_array, + Jt.prototype._setValue_array_setNeedsUpdate, + Jt.prototype._setValue_array_setMatrixWorldNeedsUpdate ], [ - ke.prototype._setValue_arrayElement, - ke.prototype._setValue_arrayElement_setNeedsUpdate, - ke.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate + Jt.prototype._setValue_arrayElement, + Jt.prototype._setValue_arrayElement_setNeedsUpdate, + Jt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate ], [ - ke.prototype._setValue_fromArray, - ke.prototype._setValue_fromArray_setNeedsUpdate, - ke.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate + Jt.prototype._setValue_fromArray, + Jt.prototype._setValue_fromArray_setNeedsUpdate, + Jt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate ] ]; -var Yh = class { +var Su = class { constructor(){ - this.uuid = Et(), this._objects = Array.prototype.slice.call(arguments), this.nCachedObjects_ = 0; - let e = {}; - this._indicesByUUID = e; - for(let n = 0, i = arguments.length; n !== i; ++n)e[arguments[n].uuid] = n; + this.isAnimationObjectGroup = !0, this.uuid = Be(), this._objects = Array.prototype.slice.call(arguments), this.nCachedObjects_ = 0; + let t = {}; + this._indicesByUUID = t; + for(let n = 0, i = arguments.length; n !== i; ++n)t[arguments[n].uuid] = n; this._paths = [], this._parsedPaths = [], this._bindings = [], this._bindingsIndicesByPath = {}; - let t = this; + let e = this; this.stats = { objects: { get total () { - return t._objects.length; + return e._objects.length; }, get inUse () { - return this.total - t.nCachedObjects_; + return this.total - e.nCachedObjects_; } }, get bindingsPerObject () { - return t._bindings.length; + return e._bindings.length; } }; } add() { - let e = this._objects, t = this._indicesByUUID, n = this._paths, i = this._parsedPaths, r = this._bindings, o = r.length, a, l = e.length, c = this.nCachedObjects_; + let t = this._objects, e = this._indicesByUUID, n = this._paths, i = this._parsedPaths, r = this._bindings, a = r.length, o, c = t.length, l = this.nCachedObjects_; for(let h = 0, u = arguments.length; h !== u; ++h){ - let d = arguments[h], f = d.uuid, m = t[f]; + let d = arguments[h], f = d.uuid, m = e[f]; if (m === void 0) { - m = l++, t[f] = m, e.push(d); - for(let x = 0, v = o; x !== v; ++x)r[x].push(new ke(d, n[x], i[x])); - } else if (m < c) { - a = e[m]; - let x = --c, v = e[x]; - t[v.uuid] = m, e[m] = v, t[f] = x, e[x] = d; - for(let g = 0, p = o; g !== p; ++g){ - let _ = r[g], y = _[x], b = _[m]; - _[m] = y, b === void 0 && (b = new ke(d, n[g], i[g])), _[x] = b; + m = c++, e[f] = m, t.push(d); + for(let x = 0, g = a; x !== g; ++x)r[x].push(new Jt(d, n[x], i[x])); + } else if (m < l) { + o = t[m]; + let x = --l, g = t[x]; + e[g.uuid] = m, t[m] = g, e[f] = x, t[x] = d; + for(let p = 0, v = a; p !== v; ++p){ + let _ = r[p], y = _[x], b = _[m]; + _[m] = y, b === void 0 && (b = new Jt(d, n[p], i[p])), _[x] = b; } - } else e[m] !== a && console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes."); + } else t[m] !== o && console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes."); } - this.nCachedObjects_ = c; + this.nCachedObjects_ = l; } remove() { - let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_; - for(let o = 0, a = arguments.length; o !== a; ++o){ - let l = arguments[o], c = l.uuid, h = t[c]; + let t = this._objects, e = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_; + for(let a = 0, o = arguments.length; a !== o; ++a){ + let c = arguments[a], l = c.uuid, h = e[l]; if (h !== void 0 && h >= r) { - let u = r++, d = e[u]; - t[d.uuid] = h, e[h] = d, t[c] = u, e[u] = l; + let u = r++, d = t[u]; + e[d.uuid] = h, t[h] = d, e[l] = u, t[u] = c; for(let f = 0, m = i; f !== m; ++f){ - let x = n[f], v = x[u], g = x[h]; - x[h] = v, x[u] = g; + let x = n[f], g = x[u], p = x[h]; + x[h] = g, x[u] = p; } } } this.nCachedObjects_ = r; } uncache() { - let e = this._objects, t = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_, o = e.length; - for(let a = 0, l = arguments.length; a !== l; ++a){ - let c = arguments[a], h = c.uuid, u = t[h]; - if (u !== void 0) if (delete t[h], u < r) { - let d = --r, f = e[d], m = --o, x = e[m]; - t[f.uuid] = u, e[u] = f, t[x.uuid] = d, e[d] = x, e.pop(); - for(let v = 0, g = i; v !== g; ++v){ - let p = n[v], _ = p[d], y = p[m]; - p[u] = _, p[d] = y, p.pop(); + let t = this._objects, e = this._indicesByUUID, n = this._bindings, i = n.length, r = this.nCachedObjects_, a = t.length; + for(let o = 0, c = arguments.length; o !== c; ++o){ + let l = arguments[o], h = l.uuid, u = e[h]; + if (u !== void 0) if (delete e[h], u < r) { + let d = --r, f = t[d], m = --a, x = t[m]; + e[f.uuid] = u, t[u] = f, e[x.uuid] = d, t[d] = x, t.pop(); + for(let g = 0, p = i; g !== p; ++g){ + let v = n[g], _ = v[d], y = v[m]; + v[u] = _, v[d] = y, v.pop(); } } else { - let d = --o, f = e[d]; - d > 0 && (t[f.uuid] = u), e[u] = f, e.pop(); + let d = --a, f = t[d]; + d > 0 && (e[f.uuid] = u), t[u] = f, t.pop(); for(let m = 0, x = i; m !== x; ++m){ - let v = n[m]; - v[u] = v[d], v.pop(); + let g = n[m]; + g[u] = g[d], g.pop(); } } } this.nCachedObjects_ = r; } - subscribe_(e, t) { - let n = this._bindingsIndicesByPath, i = n[e], r = this._bindings; + subscribe_(t, e) { + let n = this._bindingsIndicesByPath, i = n[t], r = this._bindings; if (i !== void 0) return r[i]; - let o = this._paths, a = this._parsedPaths, l = this._objects, c = l.length, h = this.nCachedObjects_, u = new Array(c); - i = r.length, n[e] = i, o.push(e), a.push(t), r.push(u); - for(let d = h, f = l.length; d !== f; ++d){ - let m = l[d]; - u[d] = new ke(m, e, t); + let a = this._paths, o = this._parsedPaths, c = this._objects, l = c.length, h = this.nCachedObjects_, u = new Array(l); + i = r.length, n[t] = i, a.push(t), o.push(e), r.push(u); + for(let d = h, f = c.length; d !== f; ++d){ + let m = c[d]; + u[d] = new Jt(m, t, e); } return u; } - unsubscribe_(e) { - let t = this._bindingsIndicesByPath, n = t[e]; + unsubscribe_(t) { + let e = this._bindingsIndicesByPath, n = e[t]; if (n !== void 0) { - let i = this._paths, r = this._parsedPaths, o = this._bindings, a = o.length - 1, l = o[a], c = e[a]; - t[c] = n, o[n] = l, o.pop(), r[n] = r[a], r.pop(), i[n] = i[a], i.pop(); + let i = this._paths, r = this._parsedPaths, a = this._bindings, o = a.length - 1, c = a[o], l = t[o]; + e[l] = n, a[n] = c, a.pop(), r[n] = r[o], r.pop(), i[n] = i[o], i.pop(); } } -}; -Yh.prototype.isAnimationObjectGroup = !0; -var Zh = class { - constructor(e, t, n = null, i = t.blendMode){ - this._mixer = e, this._clip = t, this._localRoot = n, this.blendMode = i; - let r = t.tracks, o = r.length, a = new Array(o), l = { - endingStart: Mi, - endingEnd: Mi +}, Dc = class { + constructor(t, e, n = null, i = e.blendMode){ + this._mixer = t, this._clip = e, this._localRoot = n, this.blendMode = i; + let r = e.tracks, a = r.length, o = new Array(a), c = { + endingStart: zi, + endingEnd: zi }; - for(let c = 0; c !== o; ++c){ - let h = r[c].createInterpolant(null); - a[c] = h, h.settings = l; + for(let l = 0; l !== a; ++l){ + let h = r[l].createInterpolant(null); + o[l] = h, h.settings = c; } - this._interpolantSettings = l, this._interpolants = a, this._propertyBindings = new Array(o), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._weightInterpolant = null, this.loop = Id, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = 1 / 0, this.paused = !1, this.enabled = !0, this.clampWhenFinished = !1, this.zeroSlopeAtStart = !0, this.zeroSlopeAtEnd = !0; + this._interpolantSettings = c, this._interpolants = o, this._propertyBindings = new Array(a), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._weightInterpolant = null, this.loop = Mf, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = 1 / 0, this.paused = !1, this.enabled = !0, this.clampWhenFinished = !1, this.zeroSlopeAtStart = !0, this.zeroSlopeAtEnd = !0; } play() { return this._mixer._activateAction(this), this; @@ -16907,62 +18449,62 @@ var Zh = class { isScheduled() { return this._mixer._isActiveAction(this); } - startAt(e) { - return this._startTime = e, this; + startAt(t) { + return this._startTime = t, this; } - setLoop(e, t) { - return this.loop = e, this.repetitions = t, this; + setLoop(t, e) { + return this.loop = t, this.repetitions = e, this; } - setEffectiveWeight(e) { - return this.weight = e, this._effectiveWeight = this.enabled ? e : 0, this.stopFading(); + setEffectiveWeight(t) { + return this.weight = t, this._effectiveWeight = this.enabled ? t : 0, this.stopFading(); } getEffectiveWeight() { return this._effectiveWeight; } - fadeIn(e) { - return this._scheduleFading(e, 0, 1); + fadeIn(t) { + return this._scheduleFading(t, 0, 1); } - fadeOut(e) { - return this._scheduleFading(e, 1, 0); + fadeOut(t) { + return this._scheduleFading(t, 1, 0); } - crossFadeFrom(e, t, n) { - if (e.fadeOut(t), this.fadeIn(t), n) { - let i = this._clip.duration, r = e._clip.duration, o = r / i, a = i / r; - e.warp(1, o, t), this.warp(a, 1, t); + crossFadeFrom(t, e, n) { + if (t.fadeOut(e), this.fadeIn(e), n) { + let i = this._clip.duration, r = t._clip.duration, a = r / i, o = i / r; + t.warp(1, a, e), this.warp(o, 1, e); } return this; } - crossFadeTo(e, t, n) { - return e.crossFadeFrom(this, t, n); + crossFadeTo(t, e, n) { + return t.crossFadeFrom(this, e, n); } stopFading() { - let e = this._weightInterpolant; - return e !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; + let t = this._weightInterpolant; + return t !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(t)), this; } - setEffectiveTimeScale(e) { - return this.timeScale = e, this._effectiveTimeScale = this.paused ? 0 : e, this.stopWarping(); + setEffectiveTimeScale(t) { + return this.timeScale = t, this._effectiveTimeScale = this.paused ? 0 : t, this.stopWarping(); } getEffectiveTimeScale() { return this._effectiveTimeScale; } - setDuration(e) { - return this.timeScale = this._clip.duration / e, this.stopWarping(); + setDuration(t) { + return this.timeScale = this._clip.duration / t, this.stopWarping(); } - syncWith(e) { - return this.time = e.time, this.timeScale = e.timeScale, this.stopWarping(); + syncWith(t) { + return this.time = t.time, this.timeScale = t.timeScale, this.stopWarping(); } - halt(e) { - return this.warp(this._effectiveTimeScale, 0, e); + halt(t) { + return this.warp(this._effectiveTimeScale, 0, t); } - warp(e, t, n) { - let i = this._mixer, r = i.time, o = this.timeScale, a = this._timeScaleInterpolant; - a === null && (a = i._lendControlInterpolant(), this._timeScaleInterpolant = a); - let l = a.parameterPositions, c = a.sampleValues; - return l[0] = r, l[1] = r + n, c[0] = e / o, c[1] = t / o, this; + warp(t, e, n) { + let i = this._mixer, r = i.time, a = this.timeScale, o = this._timeScaleInterpolant; + o === null && (o = i._lendControlInterpolant(), this._timeScaleInterpolant = o); + let c = o.parameterPositions, l = o.sampleValues; + return c[0] = r, c[1] = r + n, l[0] = t / a, l[1] = e / a, this; } stopWarping() { - let e = this._timeScaleInterpolant; - return e !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this; + let t = this._timeScaleInterpolant; + return t !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(t)), this; } getMixer() { return this._mixer; @@ -16973,363 +18515,391 @@ var Zh = class { getRoot() { return this._localRoot || this._mixer._root; } - _update(e, t, n, i) { + _update(t, e, n, i) { if (!this.enabled) { - this._updateWeight(e); + this._updateWeight(t); return; } let r = this._startTime; if (r !== null) { - let l = (e - r) * n; - if (l < 0 || n === 0) return; - this._startTime = null, t = n * l; + let c = (t - r) * n; + c < 0 || n === 0 ? e = 0 : (this._startTime = null, e = n * c); } - t *= this._updateTimeScale(e); - let o = this._updateTime(t), a = this._updateWeight(e); - if (a > 0) { - let l = this._interpolants, c = this._propertyBindings; + e *= this._updateTimeScale(t); + let a = this._updateTime(e), o = this._updateWeight(t); + if (o > 0) { + let c = this._interpolants, l = this._propertyBindings; switch(this.blendMode){ - case qc: - for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulateAdditive(a); + case dd: + for(let h = 0, u = c.length; h !== u; ++h)c[h].evaluate(a), l[h].accumulateAdditive(o); break; - case ua: + case zc: default: - for(let h = 0, u = l.length; h !== u; ++h)l[h].evaluate(o), c[h].accumulate(i, a); + for(let h = 0, u = c.length; h !== u; ++h)c[h].evaluate(a), l[h].accumulate(i, o); } } } - _updateWeight(e) { - let t = 0; + _updateWeight(t) { + let e = 0; if (this.enabled) { - t = this.weight; + e = this.weight; let n = this._weightInterpolant; if (n !== null) { - let i = n.evaluate(e)[0]; - t *= i, e > n.parameterPositions[1] && (this.stopFading(), i === 0 && (this.enabled = !1)); + let i = n.evaluate(t)[0]; + e *= i, t > n.parameterPositions[1] && (this.stopFading(), i === 0 && (this.enabled = !1)); } } - return this._effectiveWeight = t, t; + return this._effectiveWeight = e, e; } - _updateTimeScale(e) { - let t = 0; + _updateTimeScale(t) { + let e = 0; if (!this.paused) { - t = this.timeScale; + e = this.timeScale; let n = this._timeScaleInterpolant; - n !== null && (t *= n.evaluate(e)[0], e > n.parameterPositions[1] && (this.stopWarping(), t === 0 ? this.paused = !0 : this.timeScale = t)); + if (n !== null) { + let i = n.evaluate(t)[0]; + e *= i, t > n.parameterPositions[1] && (this.stopWarping(), e === 0 ? this.paused = !0 : this.timeScale = e); + } } - return this._effectiveTimeScale = t, t; + return this._effectiveTimeScale = e, e; } - _updateTime(e) { - let t = this._clip.duration, n = this.loop, i = this.time + e, r = this._loopCount, o = n === Dd; - if (e === 0) return r === -1 ? i : o && (r & 1) === 1 ? t - i : i; - if (n === Pd) { + _updateTime(t) { + let e = this._clip.duration, n = this.loop, i = this.time + t, r = this._loopCount, a = n === Sf; + if (t === 0) return r === -1 ? i : a && (r & 1) === 1 ? e - i : i; + if (n === yf) { r === -1 && (this._loopCount = 0, this._setEndings(!0, !0, !1)); - e: { - if (i >= t) i = t; + t: { + if (i >= e) i = e; else if (i < 0) i = 0; else { this.time = i; - break e; + break t; } this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, this.time = i, this._mixer.dispatchEvent({ type: "finished", action: this, - direction: e < 0 ? -1 : 1 + direction: t < 0 ? -1 : 1 }); } } else { - if (r === -1 && (e >= 0 ? (r = 0, this._setEndings(!0, this.repetitions === 0, o)) : this._setEndings(this.repetitions === 0, !0, o)), i >= t || i < 0) { - let a = Math.floor(i / t); - i -= t * a, r += Math.abs(a); - let l = this.repetitions - r; - if (l <= 0) this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, i = e > 0 ? t : 0, this.time = i, this._mixer.dispatchEvent({ + if (r === -1 && (t >= 0 ? (r = 0, this._setEndings(!0, this.repetitions === 0, a)) : this._setEndings(this.repetitions === 0, !0, a)), i >= e || i < 0) { + let o = Math.floor(i / e); + i -= e * o, r += Math.abs(o); + let c = this.repetitions - r; + if (c <= 0) this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, i = t > 0 ? e : 0, this.time = i, this._mixer.dispatchEvent({ type: "finished", action: this, - direction: e > 0 ? 1 : -1 + direction: t > 0 ? 1 : -1 }); else { - if (l === 1) { - let c = e < 0; - this._setEndings(c, !c, o); - } else this._setEndings(!1, !1, o); + if (c === 1) { + let l = t < 0; + this._setEndings(l, !l, a); + } else this._setEndings(!1, !1, a); this._loopCount = r, this.time = i, this._mixer.dispatchEvent({ type: "loop", action: this, - loopDelta: a + loopDelta: o }); } } else this.time = i; - if (o && (r & 1) === 1) return t - i; + if (a && (r & 1) === 1) return e - i; } return i; } - _setEndings(e, t, n) { + _setEndings(t, e, n) { let i = this._interpolantSettings; - n ? (i.endingStart = bi, i.endingEnd = bi) : (e ? i.endingStart = this.zeroSlopeAtStart ? bi : Mi : i.endingStart = Os, t ? i.endingEnd = this.zeroSlopeAtEnd ? bi : Mi : i.endingEnd = Os); + n ? (i.endingStart = ki, i.endingEnd = ki) : (t ? i.endingStart = this.zeroSlopeAtStart ? ki : zi : i.endingStart = zr, e ? i.endingEnd = this.zeroSlopeAtEnd ? ki : zi : i.endingEnd = zr); } - _scheduleFading(e, t, n) { - let i = this._mixer, r = i.time, o = this._weightInterpolant; - o === null && (o = i._lendControlInterpolant(), this._weightInterpolant = o); - let a = o.parameterPositions, l = o.sampleValues; - return a[0] = r, l[0] = t, a[1] = r + e, l[1] = n, this; + _scheduleFading(t, e, n) { + let i = this._mixer, r = i.time, a = this._weightInterpolant; + a === null && (a = i._lendControlInterpolant(), this._weightInterpolant = a); + let o = a.parameterPositions, c = a.sampleValues; + return o[0] = r, c[0] = e, o[1] = r + t, c[1] = n, this; } -}, $h = class extends En { - constructor(e){ - super(); - this._root = e, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1; +}, Dx = new Float32Array(1), bu = class extends sn { + constructor(t){ + super(), this._root = t, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1; } - _bindAction(e, t) { - let n = e._localRoot || this._root, i = e._clip.tracks, r = i.length, o = e._propertyBindings, a = e._interpolants, l = n.uuid, c = this._bindingsByRootAndName, h = c[l]; - h === void 0 && (h = {}, c[l] = h); + _bindAction(t, e) { + let n = t._localRoot || this._root, i = t._clip.tracks, r = i.length, a = t._propertyBindings, o = t._interpolants, c = n.uuid, l = this._bindingsByRootAndName, h = l[c]; + h === void 0 && (h = {}, l[c] = h); for(let u = 0; u !== r; ++u){ let d = i[u], f = d.name, m = h[f]; - if (m !== void 0) o[u] = m; + if (m !== void 0) ++m.referenceCount, a[u] = m; else { - if (m = o[u], m !== void 0) { - m._cacheIndex === null && (++m.referenceCount, this._addInactiveBinding(m, l, f)); + if (m = a[u], m !== void 0) { + m._cacheIndex === null && (++m.referenceCount, this._addInactiveBinding(m, c, f)); continue; } - let x = t && t._propertyBindings[u].binding.parsedPath; - m = new Xh(ke.create(n, f, x), d.ValueTypeName, d.getValueSize()), ++m.referenceCount, this._addInactiveBinding(m, l, f), o[u] = m; + let x = e && e._propertyBindings[u].binding.parsedPath; + m = new Ic(Jt.create(n, f, x), d.ValueTypeName, d.getValueSize()), ++m.referenceCount, this._addInactiveBinding(m, c, f), a[u] = m; } - a[u].resultBuffer = m.buffer; + o[u].resultBuffer = m.buffer; } } - _activateAction(e) { - if (!this._isActiveAction(e)) { - if (e._cacheIndex === null) { - let n = (e._localRoot || this._root).uuid, i = e._clip.uuid, r = this._actionsByClip[i]; - this._bindAction(e, r && r.knownActions[0]), this._addInactiveAction(e, i, n); + _activateAction(t) { + if (!this._isActiveAction(t)) { + if (t._cacheIndex === null) { + let n = (t._localRoot || this._root).uuid, i = t._clip.uuid, r = this._actionsByClip[i]; + this._bindAction(t, r && r.knownActions[0]), this._addInactiveAction(t, i, n); } - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; + let e = t._propertyBindings; + for(let n = 0, i = e.length; n !== i; ++n){ + let r = e[n]; r.useCount++ === 0 && (this._lendBinding(r), r.saveOriginalState()); } - this._lendAction(e); + this._lendAction(t); } } - _deactivateAction(e) { - if (this._isActiveAction(e)) { - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; + _deactivateAction(t) { + if (this._isActiveAction(t)) { + let e = t._propertyBindings; + for(let n = 0, i = e.length; n !== i; ++n){ + let r = e[n]; --r.useCount === 0 && (r.restoreOriginalState(), this._takeBackBinding(r)); } - this._takeBackAction(e); + this._takeBackAction(t); } } _initMemoryManager() { this._actions = [], this._nActiveActions = 0, this._actionsByClip = {}, this._bindings = [], this._nActiveBindings = 0, this._bindingsByRootAndName = {}, this._controlInterpolants = [], this._nActiveControlInterpolants = 0; - let e = this; + let t = this; this.stats = { actions: { get total () { - return e._actions.length; + return t._actions.length; }, get inUse () { - return e._nActiveActions; + return t._nActiveActions; } }, bindings: { get total () { - return e._bindings.length; + return t._bindings.length; }, get inUse () { - return e._nActiveBindings; + return t._nActiveBindings; } }, controlInterpolants: { get total () { - return e._controlInterpolants.length; + return t._controlInterpolants.length; }, get inUse () { - return e._nActiveControlInterpolants; + return t._nActiveControlInterpolants; } } }; } - _isActiveAction(e) { - let t = e._cacheIndex; - return t !== null && t < this._nActiveActions; + _isActiveAction(t) { + let e = t._cacheIndex; + return e !== null && e < this._nActiveActions; } - _addInactiveAction(e, t, n) { - let i = this._actions, r = this._actionsByClip, o = r[t]; - if (o === void 0) o = { + _addInactiveAction(t, e, n) { + let i = this._actions, r = this._actionsByClip, a = r[e]; + if (a === void 0) a = { knownActions: [ - e + t ], actionByRoot: {} - }, e._byClipCacheIndex = 0, r[t] = o; + }, t._byClipCacheIndex = 0, r[e] = a; else { - let a = o.knownActions; - e._byClipCacheIndex = a.length, a.push(e); + let o = a.knownActions; + t._byClipCacheIndex = o.length, o.push(t); } - e._cacheIndex = i.length, i.push(e), o.actionByRoot[n] = e; + t._cacheIndex = i.length, i.push(t), a.actionByRoot[n] = t; } - _removeInactiveAction(e) { - let t = this._actions, n = t[t.length - 1], i = e._cacheIndex; - n._cacheIndex = i, t[i] = n, t.pop(), e._cacheIndex = null; - let r = e._clip.uuid, o = this._actionsByClip, a = o[r], l = a.knownActions, c = l[l.length - 1], h = e._byClipCacheIndex; - c._byClipCacheIndex = h, l[h] = c, l.pop(), e._byClipCacheIndex = null; - let u = a.actionByRoot, d = (e._localRoot || this._root).uuid; - delete u[d], l.length === 0 && delete o[r], this._removeInactiveBindingsForAction(e); + _removeInactiveAction(t) { + let e = this._actions, n = e[e.length - 1], i = t._cacheIndex; + n._cacheIndex = i, e[i] = n, e.pop(), t._cacheIndex = null; + let r = t._clip.uuid, a = this._actionsByClip, o = a[r], c = o.knownActions, l = c[c.length - 1], h = t._byClipCacheIndex; + l._byClipCacheIndex = h, c[h] = l, c.pop(), t._byClipCacheIndex = null; + let u = o.actionByRoot, d = (t._localRoot || this._root).uuid; + delete u[d], c.length === 0 && delete a[r], this._removeInactiveBindingsForAction(t); } - _removeInactiveBindingsForAction(e) { - let t = e._propertyBindings; - for(let n = 0, i = t.length; n !== i; ++n){ - let r = t[n]; + _removeInactiveBindingsForAction(t) { + let e = t._propertyBindings; + for(let n = 0, i = e.length; n !== i; ++n){ + let r = e[n]; --r.referenceCount === 0 && this._removeInactiveBinding(r); } } - _lendAction(e) { - let t = this._actions, n = e._cacheIndex, i = this._nActiveActions++, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + _lendAction(t) { + let e = this._actions, n = t._cacheIndex, i = this._nActiveActions++, r = e[i]; + t._cacheIndex = i, e[i] = t, r._cacheIndex = n, e[n] = r; } - _takeBackAction(e) { - let t = this._actions, n = e._cacheIndex, i = --this._nActiveActions, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + _takeBackAction(t) { + let e = this._actions, n = t._cacheIndex, i = --this._nActiveActions, r = e[i]; + t._cacheIndex = i, e[i] = t, r._cacheIndex = n, e[n] = r; } - _addInactiveBinding(e, t, n) { - let i = this._bindingsByRootAndName, r = this._bindings, o = i[t]; - o === void 0 && (o = {}, i[t] = o), o[n] = e, e._cacheIndex = r.length, r.push(e); + _addInactiveBinding(t, e, n) { + let i = this._bindingsByRootAndName, r = this._bindings, a = i[e]; + a === void 0 && (a = {}, i[e] = a), a[n] = t, t._cacheIndex = r.length, r.push(t); } - _removeInactiveBinding(e) { - let t = this._bindings, n = e.binding, i = n.rootNode.uuid, r = n.path, o = this._bindingsByRootAndName, a = o[i], l = t[t.length - 1], c = e._cacheIndex; - l._cacheIndex = c, t[c] = l, t.pop(), delete a[r], Object.keys(a).length === 0 && delete o[i]; + _removeInactiveBinding(t) { + let e = this._bindings, n = t.binding, i = n.rootNode.uuid, r = n.path, a = this._bindingsByRootAndName, o = a[i], c = e[e.length - 1], l = t._cacheIndex; + c._cacheIndex = l, e[l] = c, e.pop(), delete o[r], Object.keys(o).length === 0 && delete a[i]; } - _lendBinding(e) { - let t = this._bindings, n = e._cacheIndex, i = this._nActiveBindings++, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + _lendBinding(t) { + let e = this._bindings, n = t._cacheIndex, i = this._nActiveBindings++, r = e[i]; + t._cacheIndex = i, e[i] = t, r._cacheIndex = n, e[n] = r; } - _takeBackBinding(e) { - let t = this._bindings, n = e._cacheIndex, i = --this._nActiveBindings, r = t[i]; - e._cacheIndex = i, t[i] = e, r._cacheIndex = n, t[n] = r; + _takeBackBinding(t) { + let e = this._bindings, n = t._cacheIndex, i = --this._nActiveBindings, r = e[i]; + t._cacheIndex = i, e[i] = t, r._cacheIndex = n, e[n] = r; } _lendControlInterpolant() { - let e = this._controlInterpolants, t = this._nActiveControlInterpolants++, n = e[t]; - return n === void 0 && (n = new Na(new Float32Array(2), new Float32Array(2), 1, this._controlInterpolantsResultBuffer), n.__cacheIndex = t, e[t] = n), n; + let t = this._controlInterpolants, e = this._nActiveControlInterpolants++, n = t[e]; + return n === void 0 && (n = new la(new Float32Array(2), new Float32Array(2), 1, Dx), n.__cacheIndex = e, t[e] = n), n; } - _takeBackControlInterpolant(e) { - let t = this._controlInterpolants, n = e.__cacheIndex, i = --this._nActiveControlInterpolants, r = t[i]; - e.__cacheIndex = i, t[i] = e, r.__cacheIndex = n, t[n] = r; + _takeBackControlInterpolant(t) { + let e = this._controlInterpolants, n = t.__cacheIndex, i = --this._nActiveControlInterpolants, r = e[i]; + t.__cacheIndex = i, e[i] = t, r.__cacheIndex = n, e[n] = r; } - clipAction(e, t, n) { - let i = t || this._root, r = i.uuid, o = typeof e == "string" ? Lr.findByName(i, e) : e, a = o !== null ? o.uuid : e, l = this._actionsByClip[a], c = null; - if (n === void 0 && (o !== null ? n = o.blendMode : n = ua), l !== void 0) { - let u = l.actionByRoot[r]; + clipAction(t, e, n) { + let i = e || this._root, r = i.uuid, a = typeof t == "string" ? is.findByName(i, t) : t, o = a !== null ? a.uuid : t, c = this._actionsByClip[o], l = null; + if (n === void 0 && (a !== null ? n = a.blendMode : n = zc), c !== void 0) { + let u = c.actionByRoot[r]; if (u !== void 0 && u.blendMode === n) return u; - c = l.knownActions[0], o === null && (o = c._clip); + l = c.knownActions[0], a === null && (a = l._clip); } - if (o === null) return null; - let h = new Zh(this, o, t, n); - return this._bindAction(h, c), this._addInactiveAction(h, a, r), h; + if (a === null) return null; + let h = new Dc(this, a, e, n); + return this._bindAction(h, l), this._addInactiveAction(h, o, r), h; } - existingAction(e, t) { - let n = t || this._root, i = n.uuid, r = typeof e == "string" ? Lr.findByName(n, e) : e, o = r ? r.uuid : e, a = this._actionsByClip[o]; - return a !== void 0 && a.actionByRoot[i] || null; + existingAction(t, e) { + let n = e || this._root, i = n.uuid, r = typeof t == "string" ? is.findByName(n, t) : t, a = r ? r.uuid : t, o = this._actionsByClip[a]; + return o !== void 0 && o.actionByRoot[i] || null; } stopAllAction() { - let e = this._actions, t = this._nActiveActions; - for(let n = t - 1; n >= 0; --n)e[n].stop(); + let t = this._actions, e = this._nActiveActions; + for(let n = e - 1; n >= 0; --n)t[n].stop(); return this; } - update(e) { - e *= this.timeScale; - let t = this._actions, n = this._nActiveActions, i = this.time += e, r = Math.sign(e), o = this._accuIndex ^= 1; - for(let c = 0; c !== n; ++c)t[c]._update(i, e, r, o); - let a = this._bindings, l = this._nActiveBindings; - for(let c = 0; c !== l; ++c)a[c].apply(o); + update(t) { + t *= this.timeScale; + let e = this._actions, n = this._nActiveActions, i = this.time += t, r = Math.sign(t), a = this._accuIndex ^= 1; + for(let l = 0; l !== n; ++l)e[l]._update(i, t, r, a); + let o = this._bindings, c = this._nActiveBindings; + for(let l = 0; l !== c; ++l)o[l].apply(a); return this; } - setTime(e) { + setTime(t) { this.time = 0; - for(let t = 0; t < this._actions.length; t++)this._actions[t].time = 0; - return this.update(e); + for(let e = 0; e < this._actions.length; e++)this._actions[e].time = 0; + return this.update(t); } getRoot() { return this._root; } - uncacheClip(e) { - let t = this._actions, n = e.uuid, i = this._actionsByClip, r = i[n]; + uncacheClip(t) { + let e = this._actions, n = t.uuid, i = this._actionsByClip, r = i[n]; if (r !== void 0) { - let o = r.knownActions; - for(let a = 0, l = o.length; a !== l; ++a){ - let c = o[a]; - this._deactivateAction(c); - let h = c._cacheIndex, u = t[t.length - 1]; - c._cacheIndex = null, c._byClipCacheIndex = null, u._cacheIndex = h, t[h] = u, t.pop(), this._removeInactiveBindingsForAction(c); + let a = r.knownActions; + for(let o = 0, c = a.length; o !== c; ++o){ + let l = a[o]; + this._deactivateAction(l); + let h = l._cacheIndex, u = e[e.length - 1]; + l._cacheIndex = null, l._byClipCacheIndex = null, u._cacheIndex = h, e[h] = u, e.pop(), this._removeInactiveBindingsForAction(l); } delete i[n]; } } - uncacheRoot(e) { - let t = e.uuid, n = this._actionsByClip; - for(let o in n){ - let a = n[o].actionByRoot, l = a[t]; - l !== void 0 && (this._deactivateAction(l), this._removeInactiveAction(l)); + uncacheRoot(t) { + let e = t.uuid, n = this._actionsByClip; + for(let a in n){ + let o = n[a].actionByRoot, c = o[e]; + c !== void 0 && (this._deactivateAction(c), this._removeInactiveAction(c)); } - let i = this._bindingsByRootAndName, r = i[t]; - if (r !== void 0) for(let o in r){ - let a = r[o]; - a.restoreOriginalState(), this._removeInactiveBinding(a); + let i = this._bindingsByRootAndName, r = i[e]; + if (r !== void 0) for(let a in r){ + let o = r[a]; + o.restoreOriginalState(), this._removeInactiveBinding(o); } } - uncacheAction(e, t) { - let n = this.existingAction(e, t); + uncacheAction(t, e) { + let n = this.existingAction(t, e); n !== null && (this._deactivateAction(n), this._removeInactiveAction(n)); } -}; -$h.prototype._controlInterpolantsResultBuffer = new Float32Array(1); -var go = class { - constructor(e){ - typeof e == "string" && (console.warn("THREE.Uniform: Type parameter is no longer needed."), e = arguments[1]), this.value = e; +}, Eu = class s1 { + constructor(t){ + this.value = t; } clone() { - return new go(this.value.clone === void 0 ? this.value : this.value.clone()); + return new s1(this.value.clone === void 0 ? this.value : this.value.clone()); } -}, jh = class extends $n { - constructor(e, t, n = 1){ - super(e, t); - this.meshPerAttribute = n; +}, Nx = 0, Tu = class extends sn { + constructor(){ + super(), this.isUniformsGroup = !0, Object.defineProperty(this, "id", { + value: Nx++ + }), this.name = "", this.usage = kr, this.uniforms = []; } - copy(e) { - return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; + add(t) { + return this.uniforms.push(t), this; } - clone(e) { - let t = super.clone(e); - return t.meshPerAttribute = this.meshPerAttribute, t; + remove(t) { + let e = this.uniforms.indexOf(t); + return e !== -1 && this.uniforms.splice(e, 1), this; } - toJSON(e) { - let t = super.toJSON(e); - return t.isInstancedInterleavedBuffer = !0, t.meshPerAttribute = this.meshPerAttribute, t; + setName(t) { + return this.name = t, this; } -}; -jh.prototype.isInstancedInterleavedBuffer = !0; -var Qh = class { - constructor(e, t, n, i, r){ - this.buffer = e, this.type = t, this.itemSize = n, this.elementSize = i, this.count = r, this.version = 0; + setUsage(t) { + return this.usage = t, this; } - set needsUpdate(e) { - e === !0 && this.version++; + dispose() { + return this.dispatchEvent({ + type: "dispose" + }), this; } - setBuffer(e) { - return this.buffer = e, this; + copy(t) { + this.name = t.name, this.usage = t.usage; + let e = t.uniforms; + this.uniforms.length = 0; + for(let n = 0, i = e.length; n < i; n++)this.uniforms.push(e[n].clone()); + return this; } - setType(e, t) { - return this.type = e, this.elementSize = t, this; + clone() { + return new this.constructor().copy(this); } - setItemSize(e) { - return this.itemSize = e, this; +}, wu = class extends Is { + constructor(t, e, n = 1){ + super(t, e), this.isInstancedInterleavedBuffer = !0, this.meshPerAttribute = n; } - setCount(e) { - return this.count = e, this; + copy(t) { + return super.copy(t), this.meshPerAttribute = t.meshPerAttribute, this; } -}; -Qh.prototype.isGLBufferAttribute = !0; -var Ey = class { - constructor(e, t, n = 0, i = 1 / 0){ - this.ray = new Cn(e, t), this.near = n, this.far = i, this.camera = null, this.layers = new Js, this.params = { + clone(t) { + let e = super.clone(t); + return e.meshPerAttribute = this.meshPerAttribute, e; + } + toJSON(t) { + let e = super.toJSON(t); + return e.isInstancedInterleavedBuffer = !0, e.meshPerAttribute = this.meshPerAttribute, e; + } +}, Au = class { + constructor(t, e, n, i, r){ + this.isGLBufferAttribute = !0, this.name = "", this.buffer = t, this.type = e, this.itemSize = n, this.elementSize = i, this.count = r, this.version = 0; + } + set needsUpdate(t) { + t === !0 && this.version++; + } + setBuffer(t) { + return this.buffer = t, this; + } + setType(t, e) { + return this.type = t, this.elementSize = e, this; + } + setItemSize(t) { + return this.itemSize = t, this; + } + setCount(t) { + return this.count = t, this; + } +}, Ru = class { + constructor(t, e, n = 0, i = 1 / 0){ + this.ray = new hi(t, e), this.near = n, this.far = i, this.camera = null, this.layers = new Rs, this.params = { Mesh: {}, Line: { threshold: 1 @@ -17341,91 +18911,91 @@ var Ey = class { Sprite: {} }; } - set(e, t) { - this.ray.set(e, t); + set(t, e) { + this.ray.set(t, e); } - setFromCamera(e, t) { - t && t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, .5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t) : t && t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t) : console.error("THREE.Raycaster: Unsupported camera type: " + t.type); + setFromCamera(t, e) { + e.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(e.matrixWorld), this.ray.direction.set(t.x, t.y, .5).unproject(e).sub(this.ray.origin).normalize(), this.camera = e) : e.isOrthographicCamera ? (this.ray.origin.set(t.x, t.y, (e.near + e.far) / (e.near - e.far)).unproject(e), this.ray.direction.set(0, 0, -1).transformDirection(e.matrixWorld), this.camera = e) : console.error("THREE.Raycaster: Unsupported camera type: " + e.type); } - intersectObject(e, t = !0, n = []) { - return la(e, this, n, t), n.sort(Pc), n; + intersectObject(t, e = !0, n = []) { + return Nc(t, this, n, e), n.sort(Cu), n; } - intersectObjects(e, t = !0, n = []) { - for(let i = 0, r = e.length; i < r; i++)la(e[i], this, n, t); - return n.sort(Pc), n; + intersectObjects(t, e = !0, n = []) { + for(let i = 0, r = t.length; i < r; i++)Nc(t[i], this, n, e); + return n.sort(Cu), n; } }; -function Pc(s, e) { - return s.distance - e.distance; +function Cu(s1, t) { + return s1.distance - t.distance; } -function la(s, e, t, n) { - if (s.layers.test(e.layers) && s.raycast(e, t), n === !0) { - let i = s.children; - for(let r = 0, o = i.length; r < o; r++)la(i[r], e, t, !0); +function Nc(s1, t, e, n) { + if (s1.layers.test(t.layers) && s1.raycast(t, e), n === !0) { + let i = s1.children; + for(let r = 0, a = i.length; r < a; r++)Nc(i[r], t, e, !0); } } -var Ay = class { - constructor(e = 1, t = 0, n = 0){ - return this.radius = e, this.phi = t, this.theta = n, this; +var Pu = class { + constructor(t = 1, e = 0, n = 0){ + return this.radius = t, this.phi = e, this.theta = n, this; } - set(e, t, n) { - return this.radius = e, this.phi = t, this.theta = n, this; + set(t, e, n) { + return this.radius = t, this.phi = e, this.theta = n, this; } - copy(e) { - return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; + copy(t) { + return this.radius = t.radius, this.phi = t.phi, this.theta = t.theta, this; } makeSafe() { return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this; } - setFromVector3(e) { - return this.setFromCartesianCoords(e.x, e.y, e.z); + setFromVector3(t) { + return this.setFromCartesianCoords(t.x, t.y, t.z); } - setFromCartesianCoords(e, t, n) { - return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(mt(t / this.radius, -1, 1))), this; + setFromCartesianCoords(t, e, n) { + return this.radius = Math.sqrt(t * t + e * e + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(t, n), this.phi = Math.acos(ae(e / this.radius, -1, 1))), this; } clone() { return new this.constructor().copy(this); } -}, Cy = class { - constructor(e = 1, t = 0, n = 0){ - return this.radius = e, this.theta = t, this.y = n, this; +}, Lu = class { + constructor(t = 1, e = 0, n = 0){ + return this.radius = t, this.theta = e, this.y = n, this; } - set(e, t, n) { - return this.radius = e, this.theta = t, this.y = n, this; + set(t, e, n) { + return this.radius = t, this.theta = e, this.y = n, this; } - copy(e) { - return this.radius = e.radius, this.theta = e.theta, this.y = e.y, this; + copy(t) { + return this.radius = t.radius, this.theta = t.theta, this.y = t.y, this; } - setFromVector3(e) { - return this.setFromCartesianCoords(e.x, e.y, e.z); + setFromVector3(t) { + return this.setFromCartesianCoords(t.x, t.y, t.z); } - setFromCartesianCoords(e, t, n) { - return this.radius = Math.sqrt(e * e + n * n), this.theta = Math.atan2(e, n), this.y = t, this; + setFromCartesianCoords(t, e, n) { + return this.radius = Math.sqrt(t * t + n * n), this.theta = Math.atan2(t, n), this.y = e, this; } clone() { return new this.constructor().copy(this); } -}, Ic = new X, qi = class { - constructor(e = new X(1 / 0, 1 / 0), t = new X(-1 / 0, -1 / 0)){ - this.min = e, this.max = t; +}, Iu = new J, Uu = class { + constructor(t = new J(1 / 0, 1 / 0), e = new J(-1 / 0, -1 / 0)){ + this.isBox2 = !0, this.min = t, this.max = e; } - set(e, t) { - return this.min.copy(e), this.max.copy(t), this; + set(t, e) { + return this.min.copy(t), this.max.copy(e), this; } - setFromPoints(e) { + setFromPoints(t) { this.makeEmpty(); - for(let t = 0, n = e.length; t < n; t++)this.expandByPoint(e[t]); + for(let e = 0, n = t.length; e < n; e++)this.expandByPoint(t[e]); return this; } - setFromCenterAndSize(e, t) { - let n = Ic.copy(t).multiplyScalar(.5); - return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; + setFromCenterAndSize(t, e) { + let n = Iu.copy(e).multiplyScalar(.5); + return this.min.copy(t).sub(n), this.max.copy(t).add(n), this; } clone() { return new this.constructor().copy(this); } - copy(e) { - return this.min.copy(e.min), this.max.copy(e.max), this; + copy(t) { + return this.min.copy(t.min), this.max.copy(t.max), this; } makeEmpty() { return this.min.x = this.min.y = 1 / 0, this.max.x = this.max.y = -1 / 0, this; @@ -17433,68 +19003,66 @@ var Ay = class { isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y; } - getCenter(e) { - return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); + getCenter(t) { + return this.isEmpty() ? t.set(0, 0) : t.addVectors(this.min, this.max).multiplyScalar(.5); } - getSize(e) { - return this.isEmpty() ? e.set(0, 0) : e.subVectors(this.max, this.min); + getSize(t) { + return this.isEmpty() ? t.set(0, 0) : t.subVectors(this.max, this.min); } - expandByPoint(e) { - return this.min.min(e), this.max.max(e), this; + expandByPoint(t) { + return this.min.min(t), this.max.max(t), this; } - expandByVector(e) { - return this.min.sub(e), this.max.add(e), this; + expandByVector(t) { + return this.min.sub(t), this.max.add(t), this; } - expandByScalar(e) { - return this.min.addScalar(-e), this.max.addScalar(e), this; + expandByScalar(t) { + return this.min.addScalar(-t), this.max.addScalar(t), this; } - containsPoint(e) { - return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y); + containsPoint(t) { + return !(t.x < this.min.x || t.x > this.max.x || t.y < this.min.y || t.y > this.max.y); } - containsBox(e) { - return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y; + 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; } - getParameter(e, t) { - return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y)); + 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)); } - intersectsBox(e) { - return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y); + 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); } - clampPoint(e, t) { - return t.copy(e).clamp(this.min, this.max); + clampPoint(t, e) { + return e.copy(t).clamp(this.min, this.max); } - distanceToPoint(e) { - return Ic.copy(e).clamp(this.min, this.max).sub(e).length(); + distanceToPoint(t) { + return this.clampPoint(t, Iu).distanceTo(t); } - intersect(e) { - return this.min.max(e.min), this.max.min(e.max), this; + intersect(t) { + return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this; } - union(e) { - return this.min.min(e.min), this.max.max(e.max), this; + union(t) { + return this.min.min(t.min), this.max.max(t.max), this; } - translate(e) { - return this.min.add(e), this.max.add(e), this; + translate(t) { + return this.min.add(t), this.max.add(t), this; } - equals(e) { - return e.min.equals(this.min) && e.max.equals(this.max); + equals(t) { + return t.min.equals(this.min) && t.max.equals(this.max); } -}; -qi.prototype.isBox2 = !0; -var Dc = new M, Ts = new M, Kh = class { - constructor(e = new M, t = new M){ - this.start = e, this.end = t; +}, Du = new A, wr = new A, Nu = class { + constructor(t = new A, e = new A){ + this.start = t, this.end = e; } - set(e, t) { - return this.start.copy(e), this.end.copy(t), this; + set(t, e) { + return this.start.copy(t), this.end.copy(e), this; } - copy(e) { - return this.start.copy(e.start), this.end.copy(e.end), this; + copy(t) { + return this.start.copy(t.start), this.end.copy(t.end), this; } - getCenter(e) { - return e.addVectors(this.start, this.end).multiplyScalar(.5); + getCenter(t) { + return t.addVectors(this.start, this.end).multiplyScalar(.5); } - delta(e) { - return e.subVectors(this.end, this.start); + delta(t) { + return t.subVectors(this.end, this.start); } distanceSq() { return this.start.distanceToSquared(this.end); @@ -17502,32 +19070,31 @@ var Dc = new M, Ts = new M, Kh = class { distance() { return this.start.distanceTo(this.end); } - at(e, t) { - return this.delta(t).multiplyScalar(e).add(this.start); + at(t, e) { + return this.delta(e).multiplyScalar(t).add(this.start); } - closestPointToPointParameter(e, t) { - Dc.subVectors(e, this.start), Ts.subVectors(this.end, this.start); - let n = Ts.dot(Ts), r = Ts.dot(Dc) / n; - return t && (r = mt(r, 0, 1)), r; + closestPointToPointParameter(t, e) { + Du.subVectors(t, this.start), wr.subVectors(this.end, this.start); + let n = wr.dot(wr), r = wr.dot(Du) / n; + return e && (r = ae(r, 0, 1)), r; } - closestPointToPoint(e, t, n) { - let i = this.closestPointToPointParameter(e, t); + closestPointToPoint(t, e, n) { + let i = this.closestPointToPointParameter(t, e); return this.delta(n).multiplyScalar(i).add(this.start); } - applyMatrix4(e) { - return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this; + applyMatrix4(t) { + return this.start.applyMatrix4(t), this.end.applyMatrix4(t), this; } - equals(e) { - return e.start.equals(this.start) && e.end.equals(this.end); + equals(t) { + return t.start.equals(this.start) && t.end.equals(this.end); } clone() { return new this.constructor().copy(this); } -}, Fc = new M, Ly = class extends Ne { - constructor(e, t){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = t; - let n = new _e, i = [ +}, Fu = new A, Ou = class extends Zt { + constructor(t, e){ + super(), this.light = t, this.matrix = t.matrixWorld, this.matrixAutoUpdate = !1, this.color = e, this.type = "SpotLightHelper"; + let n = new Vt, i = [ 0, 0, 0, @@ -17559,226 +19126,233 @@ var Dc = new M, Ts = new M, Kh = class { -1, 1 ]; - for(let o = 0, a = 1, l = 32; o < l; o++, a++){ - let c = o / l * Math.PI * 2, h = a / l * Math.PI * 2; - i.push(Math.cos(c), Math.sin(c), 1, Math.cos(h), Math.sin(h), 1); + for(let a = 0, o = 1, c = 32; a < c; a++, o++){ + let l = a / c * Math.PI * 2, h = o / c * Math.PI * 2; + i.push(Math.cos(l), Math.sin(l), 1, Math.cos(h), Math.sin(h), 1); } - n.setAttribute("position", new de(i, 3)); - let r = new ft({ + n.setAttribute("position", new _t(i, 3)); + let r = new Ee({ fog: !1, toneMapped: !1 }); - this.cone = new wt(n, r), this.add(this.cone), this.update(); + this.cone = new je(n, r), this.add(this.cone), this.update(); } dispose() { this.cone.geometry.dispose(), this.cone.material.dispose(); } update() { - this.light.updateMatrixWorld(); - let e = this.light.distance ? this.light.distance : 1e3, t = e * Math.tan(this.light.angle); - this.cone.scale.set(t, t, e), Fc.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(Fc), this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color); - } -}, yn = new M, Es = new pe, Qo = new pe, eu = class extends wt { - constructor(e){ - let t = tu(e), n = new _e, i = [], r = [], o = new ae(0, 0, 1), a = new ae(0, 1, 0); - for(let c = 0; c < t.length; c++){ - let h = t[c]; - h.parent && h.parent.isBone && (i.push(0, 0, 0), i.push(0, 0, 0), r.push(o.r, o.g, o.b), r.push(a.r, a.g, a.b)); - } - n.setAttribute("position", new de(i, 3)), n.setAttribute("color", new de(r, 3)); - let l = new ft({ + this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1); + let t = this.light.distance ? this.light.distance : 1e3, e = t * Math.tan(this.light.angle); + this.cone.scale.set(e, e, t), Fu.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(Fu), this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color); + } +}, Cn = new A, Ar = new Ot, so = new Ot, Bu = class extends je { + constructor(t){ + let e = Cd(t), n = new Vt, i = [], r = [], a = new ft(0, 0, 1), o = new ft(0, 1, 0); + for(let l = 0; l < e.length; l++){ + let h = e[l]; + h.parent && h.parent.isBone && (i.push(0, 0, 0), i.push(0, 0, 0), r.push(a.r, a.g, a.b), r.push(o.r, o.g, o.b)); + } + n.setAttribute("position", new _t(i, 3)), n.setAttribute("color", new _t(r, 3)); + let c = new Ee({ vertexColors: !0, depthTest: !1, depthWrite: !1, toneMapped: !1, transparent: !0 }); - super(n, l); - this.type = "SkeletonHelper", this.isSkeletonHelper = !0, this.root = e, this.bones = t, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1; + super(n, c), this.isSkeletonHelper = !0, this.type = "SkeletonHelper", this.root = t, this.bones = e, this.matrix = t.matrixWorld, this.matrixAutoUpdate = !1; } - updateMatrixWorld(e) { - let t = this.bones, n = this.geometry, i = n.getAttribute("position"); - Qo.copy(this.root.matrixWorld).invert(); - for(let r = 0, o = 0; r < t.length; r++){ - let a = t[r]; - a.parent && a.parent.isBone && (Es.multiplyMatrices(Qo, a.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o, yn.x, yn.y, yn.z), Es.multiplyMatrices(Qo, a.parent.matrixWorld), yn.setFromMatrixPosition(Es), i.setXYZ(o + 1, yn.x, yn.y, yn.z), o += 2); + updateMatrixWorld(t) { + let e = this.bones, n = this.geometry, i = n.getAttribute("position"); + so.copy(this.root.matrixWorld).invert(); + for(let r = 0, a = 0; r < e.length; r++){ + let o = e[r]; + o.parent && o.parent.isBone && (Ar.multiplyMatrices(so, o.matrixWorld), Cn.setFromMatrixPosition(Ar), i.setXYZ(a, Cn.x, Cn.y, Cn.z), Ar.multiplyMatrices(so, o.parent.matrixWorld), Cn.setFromMatrixPosition(Ar), i.setXYZ(a + 1, Cn.x, Cn.y, Cn.z), a += 2); } - n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(e); + n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(t); + } + dispose() { + this.geometry.dispose(), this.material.dispose(); } }; -function tu(s) { - let e = []; - s && s.isBone && e.push(s); - for(let t = 0; t < s.children.length; t++)e.push.apply(e, tu(s.children[t])); - return e; +function Cd(s1) { + let t = []; + s1.isBone === !0 && t.push(s1); + for(let e = 0; e < s1.children.length; e++)t.push.apply(t, Cd(s1.children[e])); + return t; } -var Ry = class extends st { - constructor(e, t, n){ - let i = new Fi(t, 4, 2), r = new hn({ +var zu = class extends ve { + constructor(t, e, n){ + let i = new oa(e, 4, 2), r = new Mn({ wireframe: !0, fog: !1, toneMapped: !1 }); - super(i, r); - this.light = e, this.light.updateMatrixWorld(), this.color = n, this.type = "PointLightHelper", this.matrix = this.light.matrixWorld, this.matrixAutoUpdate = !1, this.update(); + super(i, r), this.light = t, this.color = n, this.type = "PointLightHelper", this.matrix = this.light.matrixWorld, this.matrixAutoUpdate = !1, this.update(); } dispose() { this.geometry.dispose(), this.material.dispose(); } update() { - this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color); + this.light.updateWorldMatrix(!0, !1), this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color); } -}, Py = new M, Nc = new ae, Bc = new ae, Iy = class extends Ne { - constructor(e, t, n){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n; - let i = new Ii(t); - i.rotateY(Math.PI * .5), this.material = new hn({ +}, Fx = new A, ku = new ft, Vu = new ft, Hu = class extends Zt { + constructor(t, e, n){ + super(), this.light = t, this.matrix = t.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, this.type = "HemisphereLightHelper"; + let i = new aa(e); + i.rotateY(Math.PI * .5), this.material = new Mn({ wireframe: !0, fog: !1, toneMapped: !1 }), this.color === void 0 && (this.material.vertexColors = !0); - let r = i.getAttribute("position"), o = new Float32Array(r.count * 3); - i.setAttribute("color", new Ue(o, 3)), this.add(new st(i, this.material)), this.update(); + let r = i.getAttribute("position"), a = new Float32Array(r.count * 3); + i.setAttribute("color", new Kt(a, 3)), this.add(new ve(i, this.material)), this.update(); } dispose() { this.children[0].geometry.dispose(), this.children[0].material.dispose(); } update() { - let e = this.children[0]; + let t = this.children[0]; if (this.color !== void 0) this.material.color.set(this.color); else { - let t = e.geometry.getAttribute("color"); - Nc.copy(this.light.color), Bc.copy(this.light.groundColor); - for(let n = 0, i = t.count; n < i; n++){ - let r = n < i / 2 ? Nc : Bc; - t.setXYZ(n, r.r, r.g, r.b); + let e = t.geometry.getAttribute("color"); + ku.copy(this.light.color), Vu.copy(this.light.groundColor); + for(let n = 0, i = e.count; n < i; n++){ + let r = n < i / 2 ? ku : Vu; + e.setXYZ(n, r.r, r.g, r.b); } - t.needsUpdate = !0; + e.needsUpdate = !0; } - e.lookAt(Py.setFromMatrixPosition(this.light.matrixWorld).negate()); + this.light.updateWorldMatrix(!0, !1), t.lookAt(Fx.setFromMatrixPosition(this.light.matrixWorld).negate()); } -}, nu = class extends wt { - constructor(e = 10, t = 10, n = 4473924, i = 8947848){ - n = new ae(n), i = new ae(i); - let r = t / 2, o = e / t, a = e / 2, l = [], c = []; - for(let d = 0, f = 0, m = -a; d <= t; d++, m += o){ - l.push(-a, 0, m, a, 0, m), l.push(m, 0, -a, m, 0, a); +}, Gu = class extends je { + constructor(t = 10, e = 10, n = 4473924, i = 8947848){ + n = new ft(n), i = new ft(i); + let r = e / 2, a = t / e, o = t / 2, c = [], l = []; + for(let d = 0, f = 0, m = -o; d <= e; d++, m += a){ + c.push(-o, 0, m, o, 0, m), c.push(m, 0, -o, m, 0, o); let x = d === r ? n : i; - x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3, x.toArray(c, f), f += 3; + x.toArray(l, f), f += 3, x.toArray(l, f), f += 3, x.toArray(l, f), f += 3, x.toArray(l, f), f += 3; } - let h = new _e; - h.setAttribute("position", new de(l, 3)), h.setAttribute("color", new de(c, 3)); - let u = new ft({ + let h = new Vt; + h.setAttribute("position", new _t(c, 3)), h.setAttribute("color", new _t(l, 3)); + let u = new Ee({ vertexColors: !0, toneMapped: !1 }); - super(h, u); - this.type = "GridHelper"; - } -}, Dy = class extends wt { - constructor(e = 10, t = 16, n = 8, i = 64, r = 4473924, o = 8947848){ - r = new ae(r), o = new ae(o); - let a = [], l = []; - for(let u = 0; u <= t; u++){ - let d = u / t * (Math.PI * 2), f = Math.sin(d) * e, m = Math.cos(d) * e; - a.push(0, 0, 0), a.push(f, 0, m); - let x = u & 1 ? r : o; - l.push(x.r, x.g, x.b), l.push(x.r, x.g, x.b); - } - for(let u = 0; u <= n; u++){ - let d = u & 1 ? r : o, f = e - e / n * u; + super(h, u), this.type = "GridHelper"; + } + dispose() { + this.geometry.dispose(), this.material.dispose(); + } +}, Wu = class extends je { + constructor(t = 10, e = 16, n = 8, i = 64, r = 4473924, a = 8947848){ + r = new ft(r), a = new ft(a); + let o = [], c = []; + if (e > 1) for(let u = 0; u < e; u++){ + let d = u / e * (Math.PI * 2), f = Math.sin(d) * t, m = Math.cos(d) * t; + o.push(0, 0, 0), o.push(f, 0, m); + let x = u & 1 ? r : a; + c.push(x.r, x.g, x.b), c.push(x.r, x.g, x.b); + } + for(let u = 0; u < n; u++){ + let d = u & 1 ? r : a, f = t - t / n * u; for(let m = 0; m < i; m++){ - let x = m / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f; - a.push(v, 0, g), l.push(d.r, d.g, d.b), x = (m + 1) / i * (Math.PI * 2), v = Math.sin(x) * f, g = Math.cos(x) * f, a.push(v, 0, g), l.push(d.r, d.g, d.b); + let x = m / i * (Math.PI * 2), g = Math.sin(x) * f, p = Math.cos(x) * f; + o.push(g, 0, p), c.push(d.r, d.g, d.b), x = (m + 1) / i * (Math.PI * 2), g = Math.sin(x) * f, p = Math.cos(x) * f, o.push(g, 0, p), c.push(d.r, d.g, d.b); } } - let c = new _e; - c.setAttribute("position", new de(a, 3)), c.setAttribute("color", new de(l, 3)); - let h = new ft({ + let l = new Vt; + l.setAttribute("position", new _t(o, 3)), l.setAttribute("color", new _t(c, 3)); + let h = new Ee({ vertexColors: !0, toneMapped: !1 }); - super(c, h); - this.type = "PolarGridHelper"; + super(l, h), this.type = "PolarGridHelper"; } -}, zc = new M, As = new M, Uc = new M, Fy = class extends Ne { - constructor(e, t, n){ - super(); - this.light = e, this.light.updateMatrixWorld(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, t === void 0 && (t = 1); - let i = new _e; - i.setAttribute("position", new de([ - -t, - t, + dispose() { + this.geometry.dispose(), this.material.dispose(); + } +}, Xu = new A, Rr = new A, qu = new A, Yu = class extends Zt { + constructor(t, e, n){ + super(), this.light = t, this.matrix = t.matrixWorld, this.matrixAutoUpdate = !1, this.color = n, this.type = "DirectionalLightHelper", e === void 0 && (e = 1); + let i = new Vt; + i.setAttribute("position", new _t([ + -e, + e, 0, - t, - t, + e, + e, 0, - t, - -t, + e, + -e, 0, - -t, - -t, + -e, + -e, 0, - -t, - t, + -e, + e, 0 ], 3)); - let r = new ft({ + let r = new Ee({ fog: !1, toneMapped: !1 }); - this.lightPlane = new on(i, r), this.add(this.lightPlane), i = new _e, i.setAttribute("position", new de([ + this.lightPlane = new Sn(i, r), this.add(this.lightPlane), i = new Vt, i.setAttribute("position", new _t([ 0, 0, 0, 0, 0, 1 - ], 3)), this.targetLine = new on(i, r), this.add(this.targetLine), this.update(); + ], 3)), this.targetLine = new Sn(i, r), this.add(this.targetLine), this.update(); } dispose() { this.lightPlane.geometry.dispose(), this.lightPlane.material.dispose(), this.targetLine.geometry.dispose(), this.targetLine.material.dispose(); } update() { - zc.setFromMatrixPosition(this.light.matrixWorld), As.setFromMatrixPosition(this.light.target.matrixWorld), Uc.subVectors(As, zc), this.lightPlane.lookAt(As), this.color !== void 0 ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)) : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)), this.targetLine.lookAt(As), this.targetLine.scale.z = Uc.length(); + this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1), Xu.setFromMatrixPosition(this.light.matrixWorld), Rr.setFromMatrixPosition(this.light.target.matrixWorld), qu.subVectors(Rr, Xu), this.lightPlane.lookAt(Rr), this.color !== void 0 ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)) : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)), this.targetLine.lookAt(Rr), this.targetLine.scale.z = qu.length(); } -}, Cs = new M, Qe = new Ir, Ny = class extends wt { - constructor(e){ - let t = new _e, n = new ft({ +}, Cr = new A, re = new Cs, Zu = class extends je { + constructor(t){ + let e = new Vt, n = new Ee({ color: 16777215, vertexColors: !0, toneMapped: !1 - }), i = [], r = [], o = {}, a = new ae(16755200), l = new ae(16711680), c = new ae(43775), h = new ae(16777215), u = new ae(3355443); - d("n1", "n2", a), d("n2", "n4", a), d("n4", "n3", a), d("n3", "n1", a), d("f1", "f2", a), d("f2", "f4", a), d("f4", "f3", a), d("f3", "f1", a), d("n1", "f1", a), d("n2", "f2", a), d("n3", "f3", a), d("n4", "f4", a), d("p", "n1", l), d("p", "n2", l), d("p", "n3", l), d("p", "n4", l), d("u1", "u2", c), d("u2", "u3", c), d("u3", "u1", c), d("c", "t", h), d("p", "c", u), d("cn1", "cn2", u), d("cn3", "cn4", u), d("cf1", "cf2", u), d("cf3", "cf4", u); - function d(m, x, v) { - f(m, v), f(x, v); + }), i = [], r = [], a = {}; + o("n1", "n2"), o("n2", "n4"), o("n4", "n3"), o("n3", "n1"), o("f1", "f2"), o("f2", "f4"), o("f4", "f3"), o("f3", "f1"), o("n1", "f1"), o("n2", "f2"), o("n3", "f3"), o("n4", "f4"), o("p", "n1"), o("p", "n2"), o("p", "n3"), o("p", "n4"), o("u1", "u2"), o("u2", "u3"), o("u3", "u1"), o("c", "t"), o("p", "c"), o("cn1", "cn2"), o("cn3", "cn4"), o("cf1", "cf2"), o("cf3", "cf4"); + function o(m, x) { + c(m), c(x); } - function f(m, x) { - i.push(0, 0, 0), r.push(x.r, x.g, x.b), o[m] === void 0 && (o[m] = []), o[m].push(i.length / 3 - 1); + function c(m) { + i.push(0, 0, 0), r.push(0, 0, 0), a[m] === void 0 && (a[m] = []), a[m].push(i.length / 3 - 1); } - t.setAttribute("position", new de(i, 3)), t.setAttribute("color", new de(r, 3)); - super(t, n); - this.type = "CameraHelper", this.camera = e, this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1, this.pointMap = o, this.update(); + e.setAttribute("position", new _t(i, 3)), e.setAttribute("color", new _t(r, 3)), super(e, n), this.type = "CameraHelper", this.camera = t, this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), this.matrix = t.matrixWorld, this.matrixAutoUpdate = !1, this.pointMap = a, this.update(); + let l = new ft(16755200), h = new ft(16711680), u = new ft(43775), d = new ft(16777215), f = new ft(3355443); + this.setColors(l, h, u, d, f); + } + setColors(t, e, n, i, r) { + let o = this.geometry.getAttribute("color"); + o.setXYZ(0, t.r, t.g, t.b), o.setXYZ(1, t.r, t.g, t.b), o.setXYZ(2, t.r, t.g, t.b), o.setXYZ(3, t.r, t.g, t.b), o.setXYZ(4, t.r, t.g, t.b), o.setXYZ(5, t.r, t.g, t.b), o.setXYZ(6, t.r, t.g, t.b), o.setXYZ(7, t.r, t.g, t.b), o.setXYZ(8, t.r, t.g, t.b), o.setXYZ(9, t.r, t.g, t.b), o.setXYZ(10, t.r, t.g, t.b), o.setXYZ(11, t.r, t.g, t.b), o.setXYZ(12, t.r, t.g, t.b), o.setXYZ(13, t.r, t.g, t.b), o.setXYZ(14, t.r, t.g, t.b), o.setXYZ(15, t.r, t.g, t.b), o.setXYZ(16, t.r, t.g, t.b), o.setXYZ(17, t.r, t.g, t.b), o.setXYZ(18, t.r, t.g, t.b), o.setXYZ(19, t.r, t.g, t.b), o.setXYZ(20, t.r, t.g, t.b), o.setXYZ(21, t.r, t.g, t.b), o.setXYZ(22, t.r, t.g, t.b), o.setXYZ(23, t.r, t.g, t.b), o.setXYZ(24, e.r, e.g, e.b), o.setXYZ(25, e.r, e.g, e.b), o.setXYZ(26, e.r, e.g, e.b), o.setXYZ(27, e.r, e.g, e.b), o.setXYZ(28, e.r, e.g, e.b), o.setXYZ(29, e.r, e.g, e.b), o.setXYZ(30, e.r, e.g, e.b), o.setXYZ(31, e.r, e.g, e.b), o.setXYZ(32, n.r, n.g, n.b), o.setXYZ(33, n.r, n.g, n.b), o.setXYZ(34, n.r, n.g, n.b), o.setXYZ(35, n.r, n.g, n.b), o.setXYZ(36, n.r, n.g, n.b), o.setXYZ(37, n.r, n.g, n.b), o.setXYZ(38, i.r, i.g, i.b), o.setXYZ(39, i.r, i.g, i.b), o.setXYZ(40, r.r, r.g, r.b), o.setXYZ(41, r.r, r.g, r.b), o.setXYZ(42, r.r, r.g, r.b), o.setXYZ(43, r.r, r.g, r.b), o.setXYZ(44, r.r, r.g, r.b), o.setXYZ(45, r.r, r.g, r.b), o.setXYZ(46, r.r, r.g, r.b), o.setXYZ(47, r.r, r.g, r.b), o.setXYZ(48, r.r, r.g, r.b), o.setXYZ(49, r.r, r.g, r.b), o.needsUpdate = !0; } update() { - let e = this.geometry, t = this.pointMap, n = 1, i = 1; - Qe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), et("c", t, e, Qe, 0, 0, -1), et("t", t, e, Qe, 0, 0, 1), et("n1", t, e, Qe, -n, -i, -1), et("n2", t, e, Qe, n, -i, -1), et("n3", t, e, Qe, -n, i, -1), et("n4", t, e, Qe, n, i, -1), et("f1", t, e, Qe, -n, -i, 1), et("f2", t, e, Qe, n, -i, 1), et("f3", t, e, Qe, -n, i, 1), et("f4", t, e, Qe, n, i, 1), et("u1", t, e, Qe, n * .7, i * 1.1, -1), et("u2", t, e, Qe, -n * .7, i * 1.1, -1), et("u3", t, e, Qe, 0, i * 2, -1), et("cf1", t, e, Qe, -n, 0, 1), et("cf2", t, e, Qe, n, 0, 1), et("cf3", t, e, Qe, 0, -i, 1), et("cf4", t, e, Qe, 0, i, 1), et("cn1", t, e, Qe, -n, 0, -1), et("cn2", t, e, Qe, n, 0, -1), et("cn3", t, e, Qe, 0, -i, -1), et("cn4", t, e, Qe, 0, i, -1), e.getAttribute("position").needsUpdate = !0; + let t = this.geometry, e = this.pointMap, n = 1, i = 1; + re.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), ce("c", e, t, re, 0, 0, -1), ce("t", e, t, re, 0, 0, 1), ce("n1", e, t, re, -n, -i, -1), ce("n2", e, t, re, n, -i, -1), ce("n3", e, t, re, -n, i, -1), ce("n4", e, t, re, n, i, -1), ce("f1", e, t, re, -n, -i, 1), ce("f2", e, t, re, n, -i, 1), ce("f3", e, t, re, -n, i, 1), ce("f4", e, t, re, n, i, 1), ce("u1", e, t, re, n * .7, i * 1.1, -1), ce("u2", e, t, re, -n * .7, i * 1.1, -1), ce("u3", e, t, re, 0, i * 2, -1), ce("cf1", e, t, re, -n, 0, 1), ce("cf2", e, t, re, n, 0, 1), ce("cf3", e, t, re, 0, -i, 1), ce("cf4", e, t, re, 0, i, 1), ce("cn1", e, t, re, -n, 0, -1), ce("cn2", e, t, re, n, 0, -1), ce("cn3", e, t, re, 0, -i, -1), ce("cn4", e, t, re, 0, i, -1), t.getAttribute("position").needsUpdate = !0; } dispose() { this.geometry.dispose(), this.material.dispose(); } }; -function et(s, e, t, n, i, r, o) { - Cs.set(i, r, o).unproject(n); - let a = e[s]; - if (a !== void 0) { - let l = t.getAttribute("position"); - for(let c = 0, h = a.length; c < h; c++)l.setXYZ(a[c], Cs.x, Cs.y, Cs.z); +function ce(s1, t, e, n, i, r, a) { + Cr.set(i, r, a).unproject(n); + let o = t[s1]; + if (o !== void 0) { + let c = e.getAttribute("position"); + for(let l = 0, h = o.length; l < h; l++)c.setXYZ(o[l], Cr.x, Cr.y, Cr.z); } } -var Ls = new Lt, iu = class extends wt { - constructor(e, t = 16776960){ +var Pr = new Ke, Ju = class extends je { + constructor(t, e = 16776960){ let n = new Uint16Array([ 0, 1, @@ -17804,27 +19378,28 @@ var Ls = new Lt, iu = class extends wt { 6, 3, 7 - ]), i = new Float32Array(8 * 3), r = new _e; - r.setIndex(new Ue(n, 1)), r.setAttribute("position", new Ue(i, 3)); - super(r, new ft({ - color: t, + ]), i = new Float32Array(8 * 3), r = new Vt; + r.setIndex(new Kt(n, 1)), r.setAttribute("position", new Kt(i, 3)), super(r, new Ee({ + color: e, toneMapped: !1 - })); - this.object = e, this.type = "BoxHelper", this.matrixAutoUpdate = !1, this.update(); + })), this.object = t, this.type = "BoxHelper", this.matrixAutoUpdate = !1, this.update(); + } + update(t) { + if (t !== void 0 && console.warn("THREE.BoxHelper: .update() has no longer arguments."), this.object !== void 0 && Pr.setFromObject(this.object), Pr.isEmpty()) return; + let e = Pr.min, n = Pr.max, i = this.geometry.attributes.position, r = i.array; + r[0] = n.x, r[1] = n.y, r[2] = n.z, r[3] = e.x, r[4] = n.y, r[5] = n.z, r[6] = e.x, r[7] = e.y, r[8] = n.z, r[9] = n.x, r[10] = e.y, r[11] = n.z, r[12] = n.x, r[13] = n.y, r[14] = e.z, r[15] = e.x, r[16] = n.y, r[17] = e.z, r[18] = e.x, r[19] = e.y, r[20] = e.z, r[21] = n.x, r[22] = e.y, r[23] = e.z, i.needsUpdate = !0, this.geometry.computeBoundingSphere(); } - update(e) { - if (e !== void 0 && console.warn("THREE.BoxHelper: .update() has no longer arguments."), this.object !== void 0 && Ls.setFromObject(this.object), Ls.isEmpty()) return; - let t = Ls.min, n = Ls.max, i = this.geometry.attributes.position, r = i.array; - r[0] = n.x, r[1] = n.y, r[2] = n.z, r[3] = t.x, r[4] = n.y, r[5] = n.z, r[6] = t.x, r[7] = t.y, r[8] = n.z, r[9] = n.x, r[10] = t.y, r[11] = n.z, r[12] = n.x, r[13] = n.y, r[14] = t.z, r[15] = t.x, r[16] = n.y, r[17] = t.z, r[18] = t.x, r[19] = t.y, r[20] = t.z, r[21] = n.x, r[22] = t.y, r[23] = t.z, i.needsUpdate = !0, this.geometry.computeBoundingSphere(); + setFromObject(t) { + return this.object = t, this.update(), this; } - setFromObject(e) { - return this.object = e, this.update(), this; + copy(t, e) { + return super.copy(t, e), this.object = t.object, this; } - copy(e) { - return wt.prototype.copy.call(this, e), this.object = e.object, this; + dispose() { + this.geometry.dispose(), this.material.dispose(); } -}, By = class extends wt { - constructor(e, t = 16776960){ +}, $u = class extends je { + constructor(t, e = 16776960){ let n = new Uint16Array([ 0, 1, @@ -17875,79 +19450,72 @@ var Ls = new Lt, iu = class extends wt { 1, -1, -1 - ], r = new _e; - r.setIndex(new Ue(n, 1)), r.setAttribute("position", new de(i, 3)); - super(r, new ft({ - color: t, + ], r = new Vt; + r.setIndex(new Kt(n, 1)), r.setAttribute("position", new _t(i, 3)), super(r, new Ee({ + color: e, toneMapped: !1 - })); - this.box = e, this.type = "Box3Helper", this.geometry.computeBoundingSphere(); + })), this.box = t, this.type = "Box3Helper", this.geometry.computeBoundingSphere(); + } + updateMatrixWorld(t) { + let e = this.box; + e.isEmpty() || (e.getCenter(this.position), e.getSize(this.scale), this.scale.multiplyScalar(.5), super.updateMatrixWorld(t)); } - updateMatrixWorld(e) { - let t = this.box; - t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(.5), super.updateMatrixWorld(e)); + dispose() { + this.geometry.dispose(), this.material.dispose(); } -}, zy = class extends on { - constructor(e, t = 1, n = 16776960){ +}, Ku = class extends Sn { + constructor(t, e = 1, n = 16776960){ let i = n, r = [ 1, -1, - 1, + 0, -1, 1, - 1, + 0, -1, -1, + 0, 1, 1, - 1, - 1, + 0, -1, 1, - 1, + 0, -1, -1, - 1, + 0, 1, -1, + 0, 1, 1, + 0 + ], a = new Vt; + a.setAttribute("position", new _t(r, 3)), a.computeBoundingSphere(), super(a, new Ee({ + color: i, + toneMapped: !1 + })), this.type = "PlaneHelper", this.plane = t, this.size = e; + let o = [ 1, 1, 0, - 0, + -1, 1, 0, + -1, + -1, 0, - 0 - ], o = new _e; - o.setAttribute("position", new de(r, 3)), o.computeBoundingSphere(); - super(o, new ft({ - color: i, - toneMapped: !1 - })); - this.type = "PlaneHelper", this.plane = e, this.size = t; - let a = [ - 1, - 1, - 1, - -1, - 1, - 1, - -1, - -1, - 1, - 1, 1, 1, + 0, -1, -1, - 1, + 0, 1, -1, - 1 - ], l = new _e; - l.setAttribute("position", new de(a, 3)), l.computeBoundingSphere(), this.add(new st(l, new hn({ + 0 + ], c = new Vt; + c.setAttribute("position", new _t(o, 3)), c.computeBoundingSphere(), this.add(new ve(c, new Mn({ color: i, opacity: .2, transparent: !0, @@ -17955,67 +19523,71 @@ var Ls = new Lt, iu = class extends wt { toneMapped: !1 }))); } - updateMatrixWorld(e) { - let t = -this.plane.constant; - Math.abs(t) < 1e-8 && (t = 1e-8), this.scale.set(.5 * this.size, .5 * this.size, t), this.children[0].material.side = t < 0 ? it : Ai, this.lookAt(this.plane.normal), super.updateMatrixWorld(e); + updateMatrixWorld(t) { + this.position.set(0, 0, 0), this.scale.set(.5 * this.size, .5 * this.size, 1), this.lookAt(this.plane.normal), this.translateZ(-this.plane.constant), super.updateMatrixWorld(t); } -}, Oc = new M, Rs, Ko, Uy = class extends Ne { - constructor(e = new M(0, 0, 1), t = new M(0, 0, 0), n = 1, i = 16776960, r = n * .2, o = r * .2){ - super(); - this.type = "ArrowHelper", Rs === void 0 && (Rs = new _e, Rs.setAttribute("position", new de([ + dispose() { + this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose(); + } +}, Qu = new A, Lr, ro, ju = class extends Zt { + constructor(t = new A(0, 0, 1), e = new A(0, 0, 0), n = 1, i = 16776960, r = n * .2, a = r * .2){ + super(), this.type = "ArrowHelper", Lr === void 0 && (Lr = new Vt, Lr.setAttribute("position", new _t([ 0, 0, 0, 0, 1, 0 - ], 3)), Ko = new Jn(0, .5, 1, 5, 1), Ko.translate(0, -.5, 0)), this.position.copy(t), this.line = new on(Rs, new ft({ + ], 3)), ro = new Fs(0, .5, 1, 5, 1), ro.translate(0, -.5, 0)), this.position.copy(e), this.line = new Sn(Lr, new Ee({ color: i, toneMapped: !1 - })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new st(Ko, new hn({ + })), this.line.matrixAutoUpdate = !1, this.add(this.line), this.cone = new ve(ro, new Mn({ color: i, toneMapped: !1 - })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(e), this.setLength(n, r, o); + })), this.cone.matrixAutoUpdate = !1, this.add(this.cone), this.setDirection(t), this.setLength(n, r, a); } - setDirection(e) { - if (e.y > .99999) this.quaternion.set(0, 0, 0, 1); - else if (e.y < -.99999) this.quaternion.set(1, 0, 0, 0); + setDirection(t) { + if (t.y > .99999) this.quaternion.set(0, 0, 0, 1); + else if (t.y < -.99999) this.quaternion.set(1, 0, 0, 0); else { - Oc.set(e.z, 0, -e.x).normalize(); - let t = Math.acos(e.y); - this.quaternion.setFromAxisAngle(Oc, t); + Qu.set(t.z, 0, -t.x).normalize(); + let e = Math.acos(t.y); + this.quaternion.setFromAxisAngle(Qu, e); } } - setLength(e, t = e * .2, n = t * .2) { - this.line.scale.set(1, Math.max(1e-4, e - t), 1), this.line.updateMatrix(), this.cone.scale.set(n, t, n), this.cone.position.y = e, this.cone.updateMatrix(); + setLength(t, e = t * .2, n = e * .2) { + this.line.scale.set(1, Math.max(1e-4, t - e), 1), this.line.updateMatrix(), this.cone.scale.set(n, e, n), this.cone.position.y = t, this.cone.updateMatrix(); + } + setColor(t) { + this.line.material.color.set(t), this.cone.material.color.set(t); } - setColor(e) { - this.line.material.color.set(e), this.cone.material.color.set(e); + copy(t) { + return super.copy(t, !1), this.line.copy(t.line), this.cone.copy(t.cone), this; } - copy(e) { - return super.copy(e, !1), this.line.copy(e.line), this.cone.copy(e.cone), this; + dispose() { + this.line.geometry.dispose(), this.line.material.dispose(), this.cone.geometry.dispose(), this.cone.material.dispose(); } -}, ru = class extends wt { - constructor(e = 1){ - let t = [ +}, td = class extends je { + constructor(t = 1){ + let e = [ 0, 0, 0, - e, + t, 0, 0, 0, 0, 0, 0, - e, + t, 0, 0, 0, 0, 0, 0, - e + t ], n = [ 1, 0, @@ -18035,1462 +19607,516 @@ var Ls = new Lt, iu = class extends wt { 0, .6, 1 - ], i = new _e; - i.setAttribute("position", new de(t, 3)), i.setAttribute("color", new de(n, 3)); - let r = new ft({ + ], i = new Vt; + i.setAttribute("position", new _t(e, 3)), i.setAttribute("color", new _t(n, 3)); + let r = new Ee({ vertexColors: !0, toneMapped: !1 }); - super(i, r); - this.type = "AxesHelper"; + super(i, r), this.type = "AxesHelper"; } - setColors(e, t, n) { - let i = new ae, r = this.geometry.attributes.color.array; - return i.set(e), i.toArray(r, 0), i.toArray(r, 3), i.set(t), i.toArray(r, 6), i.toArray(r, 9), i.set(n), i.toArray(r, 12), i.toArray(r, 15), this.geometry.attributes.color.needsUpdate = !0, this; + setColors(t, e, n) { + let i = new ft, r = this.geometry.attributes.color.array; + return i.set(t), i.toArray(r, 0), i.toArray(r, 3), i.set(e), i.toArray(r, 6), i.toArray(r, 9), i.set(n), i.toArray(r, 12), i.toArray(r, 15), this.geometry.attributes.color.needsUpdate = !0, this; } dispose() { this.geometry.dispose(), this.material.dispose(); } -}, Oy = class { +}, ed = class { constructor(){ - this.type = "ShapePath", this.color = new ae, this.subPaths = [], this.currentPath = null; + this.type = "ShapePath", this.color = new ft, this.subPaths = [], this.currentPath = null; } - moveTo(e, t) { - return this.currentPath = new gr, this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this; + moveTo(t, e) { + return this.currentPath = new ji, this.subPaths.push(this.currentPath), this.currentPath.moveTo(t, e), this; } - lineTo(e, t) { - return this.currentPath.lineTo(e, t), this; + lineTo(t, e) { + return this.currentPath.lineTo(t, e), this; } - quadraticCurveTo(e, t, n, i) { - return this.currentPath.quadraticCurveTo(e, t, n, i), this; + quadraticCurveTo(t, e, n, i) { + return this.currentPath.quadraticCurveTo(t, e, n, i), this; } - bezierCurveTo(e, t, n, i, r, o) { - return this.currentPath.bezierCurveTo(e, t, n, i, r, o), this; + bezierCurveTo(t, e, n, i, r, a) { + return this.currentPath.bezierCurveTo(t, e, n, i, r, a), this; } - splineThru(e) { - return this.currentPath.splineThru(e), this; + splineThru(t) { + return this.currentPath.splineThru(t), this; } - toShapes(e, t) { - function n(p) { - let _ = []; - for(let y = 0, b = p.length; y < b; y++){ - let A = p[y], L = new Xt; - L.curves = A.curves, _.push(L); + toShapes(t) { + function e(p) { + let v = []; + for(let _ = 0, y = p.length; _ < y; _++){ + let b = p[_], w = new Fn; + w.curves = b.curves, v.push(w); } - return _; - } - function i(p, _) { - let y = _.length, b = !1; - for(let A = y - 1, L = 0; L < y; A = L++){ - let I = _[A], k = _[L], B = k.x - I.x, P = k.y - I.y; - if (Math.abs(P) > Number.EPSILON) { - if (P < 0 && (I = _[L], B = -B, k = _[A], P = -P), p.y < I.y || p.y > k.y) continue; - if (p.y === I.y) { - if (p.x === I.x) return !0; + return v; + } + function n(p, v) { + let _ = v.length, y = !1; + for(let b = _ - 1, w = 0; w < _; b = w++){ + let R = v[b], L = v[w], M = L.x - R.x, E = L.y - R.y; + if (Math.abs(E) > Number.EPSILON) { + if (E < 0 && (R = v[w], M = -M, L = v[b], E = -E), p.y < R.y || p.y > L.y) continue; + if (p.y === R.y) { + if (p.x === R.x) return !0; } else { - let w = P * (p.x - I.x) - B * (p.y - I.y); - if (w === 0) return !0; - if (w < 0) continue; - b = !b; + let V = E * (p.x - R.x) - M * (p.y - R.y); + if (V === 0) return !0; + if (V < 0) continue; + y = !y; } } else { - if (p.y !== I.y) continue; - if (k.x <= p.x && p.x <= I.x || I.x <= p.x && p.x <= k.x) return !0; + if (p.y !== R.y) continue; + if (L.x <= p.x && p.x <= R.x || R.x <= p.x && p.x <= L.x) return !0; } } - return b; - } - let r = Jt.isClockWise, o = this.subPaths; - if (o.length === 0) return []; - if (t === !0) return n(o); - let a, l, c, h = []; - if (o.length === 1) return l = o[0], c = new Xt, c.curves = l.curves, h.push(c), h; - let u = !r(o[0].getPoints()); - u = e ? !u : u; - let d = [], f = [], m = [], x = 0, v; - f[x] = void 0, m[x] = []; - for(let p = 0, _ = o.length; p < _; p++)l = o[p], v = l.getPoints(), a = r(v), a = e ? !a : a, a ? (!u && f[x] && x++, f[x] = { - s: new Xt, - p: v - }, f[x].s.curves = l.curves, u && x++, m[x] = []) : m[x].push({ - h: l, - p: v[0] + return y; + } + let i = yn.isClockWise, r = this.subPaths; + if (r.length === 0) return []; + let a, o, c, l = []; + if (r.length === 1) return o = r[0], c = new Fn, c.curves = o.curves, l.push(c), l; + let h = !i(r[0].getPoints()); + h = t ? !h : h; + let u = [], d = [], f = [], m = 0, x; + d[m] = void 0, f[m] = []; + for(let p = 0, v = r.length; p < v; p++)o = r[p], x = o.getPoints(), a = i(x), a = t ? !a : a, a ? (!h && d[m] && m++, d[m] = { + s: new Fn, + p: x + }, d[m].s.curves = o.curves, h && m++, f[m] = []) : f[m].push({ + h: o, + p: x[0] }); - if (!f[0]) return n(o); - if (f.length > 1) { - let p = !1, _ = []; - for(let y = 0, b = f.length; y < b; y++)d[y] = []; - for(let y = 0, b = f.length; y < b; y++){ - let A = m[y]; - for(let L = 0; L < A.length; L++){ - let I = A[L], k = !0; - for(let B = 0; B < f.length; B++)i(I.p, f[B].p) && (y !== B && _.push({ - froms: y, - tos: B, - hole: L - }), k ? (k = !1, d[B].push(I)) : p = !0); - k && d[y].push(I); + if (!d[0]) return e(r); + if (d.length > 1) { + let p = !1, v = 0; + for(let _ = 0, y = d.length; _ < y; _++)u[_] = []; + for(let _ = 0, y = d.length; _ < y; _++){ + let b = f[_]; + for(let w = 0; w < b.length; w++){ + let R = b[w], L = !0; + for(let M = 0; M < d.length; M++)n(R.p, d[M].p) && (_ !== M && v++, L ? (L = !1, u[M].push(R)) : p = !0); + L && u[_].push(R); } } - _.length > 0 && (p || (m = d)); + v > 0 && p === !1 && (f = u); } let g; - for(let p = 0, _ = f.length; p < _; p++){ - c = f[p].s, h.push(c), g = m[p]; - for(let y = 0, b = g.length; y < b; y++)c.holes.push(g[y].h); - } - return h; - } -}, su = new Float32Array(1), Hy = new Int32Array(su.buffer), ky = class { - static toHalfFloat(e) { - e > 65504 && (console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."), e = 65504), su[0] = e; - let t = Hy[0], n = t >> 16 & 32768, i = t >> 12 & 2047, r = t >> 23 & 255; - return r < 103 ? n : r > 142 ? (n |= 31744, n |= (r == 255 ? 0 : 1) && t & 8388607, n) : r < 113 ? (i |= 2048, n |= (i >> 114 - r) + (i >> 113 - r & 1), n) : (n |= r - 112 << 10 | i >> 1, n += i & 1, n); - } -}, b0 = 0, w0 = 1, S0 = 0, T0 = 1, E0 = 2; -function A0(s) { - return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."), s; -} -function C0(s = []) { - return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."), s.isMultiMaterial = !0, s.materials = s, s.clone = function() { - return s.slice(); - }, s; -} -function L0(s, e) { - return console.warn("THREE.PointCloud has been renamed to THREE.Points."), new zr(s, e); -} -function R0(s) { - return console.warn("THREE.Particle has been renamed to THREE.Sprite."), new ro(s); -} -function P0(s, e) { - return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."), new zr(s, e); -} -function I0(s) { - return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function D0(s) { - return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function F0(s) { - return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."), new jn(s); -} -function N0(s, e, t) { - return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."), new M(s, e, t); -} -function B0(s, e) { - return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."), new Ue(s, e).setUsage(ur); -} -function z0(s, e) { - return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."), new jc(s, e); -} -function U0(s, e) { - return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."), new Qc(s, e); -} -function O0(s, e) { - return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."), new Kc(s, e); -} -function H0(s, e) { - return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."), new eh(s, e); -} -function k0(s, e) { - return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."), new Ys(s, e); -} -function G0(s, e) { - return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."), new th(s, e); -} -function V0(s, e) { - return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."), new Zs(s, e); -} -function W0(s, e) { - return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."), new de(s, e); -} -function q0(s, e) { - return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."), new ih(s, e); -} -Ct.create = function(s, e) { - return console.log("THREE.Curve.create() has been deprecated"), s.prototype = Object.create(Ct.prototype), s.prototype.constructor = s, s.prototype.getPoint = e, s; -}; -gr.prototype.fromPoints = function(s) { - return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."), this.setFromPoints(s); -}; -function X0(s) { - return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."), new ru(s); -} -function J0(s, e) { - return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."), new iu(s, e); -} -function Y0(s, e) { - return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."), new wt(new _a(s.geometry), new ft({ - color: e !== void 0 ? e : 16777215 - })); -} -nu.prototype.setColors = function() { - console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead."); -}; -eu.prototype.update = function() { - console.error("THREE.SkeletonHelper: update() no longer needs to be called."); -}; -function Z0(s, e) { - return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."), new wt(new Ea(s.geometry), new ft({ - color: e !== void 0 ? e : 16777215 - })); -} -bt.prototype.extractUrlBase = function(s) { - return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."), Gs.extractUrlBase(s); -}; -bt.Handlers = { - add: function() { - console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead."); - }, - get: function() { - console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead."); - } -}; -function $0(s) { - return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."), new Yt(s); -} -function j0(s) { - return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."), new Nh(s); -} -qi.prototype.center = function(s) { - return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -qi.prototype.empty = function() { - return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -qi.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -qi.prototype.size = function(s) { - return console.warn("THREE.Box2: .size() has been renamed to .getSize()."), this.getSize(s); -}; -Lt.prototype.center = function(s) { - return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -Lt.prototype.empty = function() { - return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -Lt.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -Lt.prototype.isIntersectionSphere = function(s) { - return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); -}; -Lt.prototype.size = function(s) { - return console.warn("THREE.Box3: .size() has been renamed to .getSize()."), this.getSize(s); -}; -An.prototype.empty = function() { - return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."), this.isEmpty(); -}; -Dr.prototype.setFromMatrix = function(s) { - return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."), this.setFromProjectionMatrix(s); -}; -Kh.prototype.center = function(s) { - return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."), this.getCenter(s); -}; -lt.prototype.flattenToArrayOffset = function(s, e) { - return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); -}; -lt.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); -}; -lt.prototype.multiplyVector3Array = function() { - console.error("THREE.Matrix3: .multiplyVector3Array() has been removed."); -}; -lt.prototype.applyToBufferAttribute = function(s) { - return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."), s.applyMatrix3(this); -}; -lt.prototype.applyToVector3Array = function() { - console.error("THREE.Matrix3: .applyToVector3Array() has been removed."); -}; -lt.prototype.getInverse = function(s) { - return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); -}; -pe.prototype.extractPosition = function(s) { - return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."), this.copyPosition(s); -}; -pe.prototype.flattenToArrayOffset = function(s, e) { - return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."), this.toArray(s, e); -}; -pe.prototype.getPosition = function() { - return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."), new M().setFromMatrixColumn(this, 3); -}; -pe.prototype.setRotationFromQuaternion = function(s) { - return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."), this.makeRotationFromQuaternion(s); -}; -pe.prototype.multiplyToArray = function() { - console.warn("THREE.Matrix4: .multiplyToArray() has been removed."); -}; -pe.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.multiplyVector4 = function(s) { - return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.multiplyVector3Array = function() { - console.error("THREE.Matrix4: .multiplyVector3Array() has been removed."); -}; -pe.prototype.rotateAxis = function(s) { - console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."), s.transformDirection(this); -}; -pe.prototype.crossVector = function(s) { - return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.translate = function() { - console.error("THREE.Matrix4: .translate() has been removed."); -}; -pe.prototype.rotateX = function() { - console.error("THREE.Matrix4: .rotateX() has been removed."); -}; -pe.prototype.rotateY = function() { - console.error("THREE.Matrix4: .rotateY() has been removed."); -}; -pe.prototype.rotateZ = function() { - console.error("THREE.Matrix4: .rotateZ() has been removed."); -}; -pe.prototype.rotateByAxis = function() { - console.error("THREE.Matrix4: .rotateByAxis() has been removed."); -}; -pe.prototype.applyToBufferAttribute = function(s) { - return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."), s.applyMatrix4(this); -}; -pe.prototype.applyToVector3Array = function() { - console.error("THREE.Matrix4: .applyToVector3Array() has been removed."); -}; -pe.prototype.makeFrustum = function(s, e, t, n, i, r) { - return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."), this.makePerspective(s, e, n, t, i, r); -}; -pe.prototype.getInverse = function(s) { - return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."), this.copy(s).invert(); -}; -Wt.prototype.isIntersectionLine = function(s) { - return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."), this.intersectsLine(s); -}; -gt.prototype.multiplyVector3 = function(s) { - return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."), s.applyQuaternion(this); -}; -gt.prototype.inverse = function() { - return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."), this.invert(); -}; -Cn.prototype.isIntersectionBox = function(s) { - return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."), this.intersectsBox(s); -}; -Cn.prototype.isIntersectionPlane = function(s) { - return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."), this.intersectsPlane(s); -}; -Cn.prototype.isIntersectionSphere = function(s) { - return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."), this.intersectsSphere(s); -}; -nt.prototype.area = function() { - return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."), this.getArea(); -}; -nt.prototype.barycoordFromPoint = function(s, e) { - return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), this.getBarycoord(s, e); -}; -nt.prototype.midpoint = function(s) { - return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."), this.getMidpoint(s); -}; -nt.prototypenormal = function(s) { - return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), this.getNormal(s); -}; -nt.prototype.plane = function(s) { - return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."), this.getPlane(s); -}; -nt.barycoordFromPoint = function(s, e, t, n, i) { - return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."), nt.getBarycoord(s, e, t, n, i); -}; -nt.normal = function(s, e, t, n) { - return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."), nt.getNormal(s, e, t, n); -}; -Xt.prototype.extractAllPoints = function(s) { - return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."), this.extractPoints(s); -}; -Xt.prototype.extrude = function(s) { - return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."), new ln(this, s); -}; -Xt.prototype.makeGeometry = function(s) { - return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."), new Di(this, s); -}; -X.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -X.prototype.distanceToManhattan = function(s) { - return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); -}; -X.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -M.prototype.setEulerFromRotationMatrix = function() { - console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead."); -}; -M.prototype.setEulerFromQuaternion = function() { - console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead."); -}; -M.prototype.getPositionFromMatrix = function(s) { - return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."), this.setFromMatrixPosition(s); -}; -M.prototype.getScaleFromMatrix = function(s) { - return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."), this.setFromMatrixScale(s); -}; -M.prototype.getColumnFromMatrix = function(s, e) { - return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."), this.setFromMatrixColumn(e, s); -}; -M.prototype.applyProjection = function(s) { - return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."), this.applyMatrix4(s); -}; -M.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -M.prototype.distanceToManhattan = function(s) { - return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."), this.manhattanDistanceTo(s); -}; -M.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -Ve.prototype.fromAttribute = function(s, e, t) { - return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."), this.fromBufferAttribute(s, e, t); -}; -Ve.prototype.lengthManhattan = function() { - return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."), this.manhattanLength(); -}; -Ne.prototype.getChildByName = function(s) { - return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."), this.getObjectByName(s); -}; -Ne.prototype.renderDepth = function() { - console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead."); -}; -Ne.prototype.translate = function(s, e) { - return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."), this.translateOnAxis(e, s); -}; -Ne.prototype.getWorldRotation = function() { - console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead."); -}; -Ne.prototype.applyMatrix = function(s) { - return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); -}; -Object.defineProperties(Ne.prototype, { - eulerOrder: { - get: function() { - return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order; - }, - set: function(s) { - console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."), this.rotation.order = s; - } - }, - useQuaternion: { - get: function() { - console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); - }, - set: function() { - console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default."); - } - } -}); -st.prototype.setDrawMode = function() { - console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); -}; -Object.defineProperties(st.prototype, { - drawMode: { - get: function() { - return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."), Fd; - }, - set: function() { - console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary."); - } - } -}); -so.prototype.initBones = function() { - console.error("THREE.SkinnedMesh: initBones() has been removed."); -}; -ut.prototype.setLens = function(s, e) { - console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."), e !== void 0 && (this.filmGauge = e), this.setFocalLength(s); -}; -Object.defineProperties(Bt.prototype, { - onlyShadow: { - set: function() { - console.warn("THREE.Light: .onlyShadow has been removed."); - } - }, - shadowCameraFov: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."), this.shadow.camera.fov = s; - } - }, - shadowCameraLeft: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."), this.shadow.camera.left = s; - } - }, - shadowCameraRight: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."), this.shadow.camera.right = s; - } - }, - shadowCameraTop: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."), this.shadow.camera.top = s; - } - }, - shadowCameraBottom: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."), this.shadow.camera.bottom = s; - } - }, - shadowCameraNear: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."), this.shadow.camera.near = s; - } - }, - shadowCameraFar: { - set: function(s) { - console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."), this.shadow.camera.far = s; + for(let p = 0, v = d.length; p < v; p++){ + c = d[p].s, l.push(c), g = f[p]; + for(let _ = 0, y = g.length; _ < y; _++)c.holes.push(g[_].h); } - }, - shadowCameraVisible: { - set: function() { - console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead."); - } - }, - shadowBias: { - set: function(s) { - console.warn("THREE.Light: .shadowBias is now .shadow.bias."), this.shadow.bias = s; - } - }, - shadowDarkness: { - set: function() { - console.warn("THREE.Light: .shadowDarkness has been removed."); - } - }, - shadowMapWidth: { - set: function(s) { - console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."), this.shadow.mapSize.width = s; - } - }, - shadowMapHeight: { - set: function(s) { - console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."), this.shadow.mapSize.height = s; - } - } -}); -Object.defineProperties(Ue.prototype, { - length: { - get: function() { - return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."), this.array.length; - } - }, - dynamic: { - get: function() { - return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.usage === ur; - }, - set: function() { - console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."), this.setUsage(ur); - } - } -}); -Ue.prototype.setDynamic = function(s) { - return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; -}; -Ue.prototype.copyIndicesArray = function() { - console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed."); -}, Ue.prototype.setArray = function() { - console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); -}; -_e.prototype.addIndex = function(s) { - console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."), this.setIndex(s); -}; -_e.prototype.addAttribute = function(s, e) { - return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."), !(e && e.isBufferAttribute) && !(e && e.isInterleavedBufferAttribute) ? (console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."), this.setAttribute(s, new Ue(arguments[1], arguments[2]))) : s === "index" ? (console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."), this.setIndex(e), this) : this.setAttribute(s, e); -}; -_e.prototype.addDrawCall = function(s, e, t) { - t !== void 0 && console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."), console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."), this.addGroup(s, e); -}; -_e.prototype.clearDrawCalls = function() { - console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."), this.clearGroups(); -}; -_e.prototype.computeOffsets = function() { - console.warn("THREE.BufferGeometry: .computeOffsets() has been removed."); -}; -_e.prototype.removeAttribute = function(s) { - return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."), this.deleteAttribute(s); -}; -_e.prototype.applyMatrix = function(s) { - return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."), this.applyMatrix4(s); -}; -Object.defineProperties(_e.prototype, { - drawcalls: { - get: function() { - return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."), this.groups; - } - }, - offsets: { - get: function() { - return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."), this.groups; - } - } -}); -$n.prototype.setDynamic = function(s) { - return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."), this.setUsage(s === !0 ? ur : hr), this; -}; -$n.prototype.setArray = function() { - console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers"); -}; -ln.prototype.getArrays = function() { - console.error("THREE.ExtrudeGeometry: .getArrays() has been removed."); -}; -ln.prototype.addShapeList = function() { - console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed."); -}; -ln.prototype.addShape = function() { - console.error("THREE.ExtrudeGeometry: .addShape() has been removed."); -}; -no.prototype.dispose = function() { - console.error("THREE.Scene: .dispose() has been removed."); -}; -go.prototype.onUpdate = function() { - return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."), this; -}; -Object.defineProperties(dt.prototype, { - wrapAround: { - get: function() { - console.warn("THREE.Material: .wrapAround has been removed."); - }, - set: function() { - console.warn("THREE.Material: .wrapAround has been removed."); - } - }, - overdraw: { - get: function() { - console.warn("THREE.Material: .overdraw has been removed."); - }, - set: function() { - console.warn("THREE.Material: .overdraw has been removed."); - } - }, - wrapRGB: { - get: function() { - return console.warn("THREE.Material: .wrapRGB has been removed."), new ae; - } - }, - shading: { - get: function() { - console.error("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."); - }, - set: function(s) { - console.warn("THREE." + this.type + ": .shading has been removed. Use the boolean .flatShading instead."), this.flatShading = s === kc; - } - }, - stencilMask: { - get: function() { - return console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask; - }, - set: function(s) { - console.warn("THREE." + this.type + ": .stencilMask has been removed. Use .stencilFuncMask instead."), this.stencilFuncMask = s; - } - }, - vertexTangents: { - get: function() { - console.warn("THREE." + this.type + ": .vertexTangents has been removed."); - }, - set: function() { - console.warn("THREE." + this.type + ": .vertexTangents has been removed."); - } - } -}); -Object.defineProperties(sn.prototype, { - derivatives: { - get: function() { - return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives; - }, - set: function(s) { - console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."), this.extensions.derivatives = s; - } - } -}); -qe.prototype.clearTarget = function(s, e, t, n) { - console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."), this.setRenderTarget(s), this.clear(e, t, n); -}; -qe.prototype.animate = function(s) { - console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."), this.setAnimationLoop(s); -}; -qe.prototype.getCurrentRenderTarget = function() { - return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."), this.getRenderTarget(); -}; -qe.prototype.getMaxAnisotropy = function() { - return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."), this.capabilities.getMaxAnisotropy(); -}; -qe.prototype.getPrecision = function() { - return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."), this.capabilities.precision; -}; -qe.prototype.resetGLState = function() { - return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."), this.state.reset(); -}; -qe.prototype.supportsFloatTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."), this.extensions.get("OES_texture_float"); -}; -qe.prototype.supportsHalfFloatTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."), this.extensions.get("OES_texture_half_float"); -}; -qe.prototype.supportsStandardDerivatives = function() { - return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."), this.extensions.get("OES_standard_derivatives"); -}; -qe.prototype.supportsCompressedTextureS3TC = function() { - return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."), this.extensions.get("WEBGL_compressed_texture_s3tc"); -}; -qe.prototype.supportsCompressedTexturePVRTC = function() { - return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."), this.extensions.get("WEBGL_compressed_texture_pvrtc"); -}; -qe.prototype.supportsBlendMinMax = function() { - return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."), this.extensions.get("EXT_blend_minmax"); -}; -qe.prototype.supportsVertexTextures = function() { - return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."), this.capabilities.vertexTextures; -}; -qe.prototype.supportsInstancedArrays = function() { - return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."), this.extensions.get("ANGLE_instanced_arrays"); -}; -qe.prototype.enableScissorTest = function(s) { - console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."), this.setScissorTest(s); -}; -qe.prototype.initMaterial = function() { - console.warn("THREE.WebGLRenderer: .initMaterial() has been removed."); -}; -qe.prototype.addPrePlugin = function() { - console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed."); -}; -qe.prototype.addPostPlugin = function() { - console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed."); -}; -qe.prototype.updateShadowMap = function() { - console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed."); -}; -qe.prototype.setFaceCulling = function() { - console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed."); -}; -qe.prototype.allocTextureUnit = function() { - console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed."); -}; -qe.prototype.setTexture = function() { - console.warn("THREE.WebGLRenderer: .setTexture() has been removed."); -}; -qe.prototype.setTexture2D = function() { - console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed."); -}; -qe.prototype.setTextureCube = function() { - console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed."); -}; -qe.prototype.getActiveMipMapLevel = function() { - return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."), this.getActiveMipmapLevel(); -}; -Object.defineProperties(qe.prototype, { - shadowMapEnabled: { - get: function() { - return this.shadowMap.enabled; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."), this.shadowMap.enabled = s; - } - }, - shadowMapType: { - get: function() { - return this.shadowMap.type; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."), this.shadowMap.type = s; - } - }, - shadowMapCullFace: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead."); - } - }, - context: { - get: function() { - return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."), this.getContext(); - } - }, - vr: { - get: function() { - return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"), this.xr; - } - }, - gammaInput: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."), !1; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."); - } - }, - gammaOutput: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), !1; - }, - set: function(s) { - console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."), this.outputEncoding = s === !0 ? Oi : Nt; - } - }, - toneMappingWhitePoint: { - get: function() { - return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."), 1; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."); - } - }, - gammaFactor: { - get: function() { - return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."), 2; - }, - set: function() { - console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."); - } - } -}); -Object.defineProperties(yh.prototype, { - cullFace: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead."); - } - }, - renderReverseSided: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead."); - } - }, - renderSingleSided: { - get: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); - }, - set: function() { - console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead."); - } - } -}); -function Q0(s, e, t) { - return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."), new js(s, t); -} -Object.defineProperties(At.prototype, { - wrapS: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."), this.texture.wrapS = s; - } - }, - wrapT: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."), this.texture.wrapT = s; - } - }, - magFilter: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."), this.texture.magFilter = s; - } - }, - minFilter: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."), this.texture.minFilter = s; - } - }, - anisotropy: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."), this.texture.anisotropy = s; - } - }, - offset: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."), this.texture.offset = s; - } - }, - repeat: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."), this.texture.repeat = s; - } - }, - format: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."), this.texture.format = s; - } - }, - type: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."), this.texture.type = s; - } - }, - generateMipmaps: { - get: function() { - return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps; - }, - set: function(s) { - console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."), this.texture.generateMipmaps = s; - } - } -}); -Za.prototype.load = function(s) { - console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead."); - let e = this; - return new kh().load(s, function(n) { - e.setBuffer(n); - }), this; -}; -qh.prototype.getData = function() { - return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."), this.getFrequencyData(); -}; -$s.prototype.updateCubeMap = function(s, e) { - return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."), this.update(s, e); -}; -$s.prototype.clear = function(s, e, t, n) { - return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."), this.renderTarget.clear(s, e, t, n); -}; -Yn.crossOrigin = void 0; -Yn.loadTexture = function(s, e, t, n) { - console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead."); - let i = new Bh; - i.setCrossOrigin(this.crossOrigin); - let r = i.load(s, t, void 0, n); - return e && (r.mapping = e), r; -}; -Yn.loadTextureCube = function(s, e, t, n) { - console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead."); - let i = new Fh; - i.setCrossOrigin(this.crossOrigin); - let r = i.load(s, t, void 0, n); - return e && (r.mapping = e), r; -}; -Yn.loadCompressedTexture = function() { - console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead."); -}; -Yn.loadCompressedTextureCube = function() { - console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead."); -}; -function K0() { - console.error("THREE.CanvasRenderer has been removed"); -} -function ev() { - console.error("THREE.JSONLoader has been removed."); -} -var tv = { - createMultiMaterialObject: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); - }, - detach: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); - }, - attach: function() { - console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js"); + return l; } }; -function nv() { - console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js"); -} -function iv() { - return console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"), new _e; -} -function rv() { - return console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"), new _e; -} -function sv() { - console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js"); -} -function ov() { - console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js"); -} -function av() { - console.error("THREE.ImmediateRenderObject has been removed."); -} typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { - revision: ca + revision: Fc } })); -typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = ca); +typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = Fc); const mod = { - ACESFilmicToneMapping: Uu, - AddEquation: _i, - AddOperation: Fu, - AdditiveAnimationBlendMode: qc, - AdditiveBlending: nl, - AlphaFormat: Xu, - AlwaysDepth: Au, - AlwaysStencilFunc: Ud, - AmbientLight: qa, - AmbientLightProbe: Vh, - AnimationClip: Lr, - AnimationLoader: cy, - AnimationMixer: $h, - AnimationObjectGroup: Yh, - AnimationUtils: Ze, - ArcCurve: Ma, - ArrayCamera: ga, - ArrowHelper: Uy, - Audio: Za, - AudioAnalyser: qh, - AudioContext: Hh, - AudioListener: my, - AudioLoader: kh, - AxesHelper: ru, - AxisHelper: X0, - BackSide: it, - BasicDepthPacking: Nd, - BasicShadowMap: qy, - BinaryTextureLoader: j0, - Bone: oo, - BooleanKeyframeTrack: Qn, - BoundingBoxHelper: J0, - Box2: qi, - Box3: Lt, - Box3Helper: By, - BoxBufferGeometry: wn, - BoxGeometry: wn, - BoxHelper: iu, - BufferAttribute: Ue, - BufferGeometry: _e, - BufferGeometryLoader: Uh, - ByteType: Hu, - Cache: Ni, - Camera: Ir, - CameraHelper: Ny, - CanvasRenderer: K0, - CanvasTexture: Th, - CatmullRomCurve3: wa, - CineonToneMapping: zu, - CircleBufferGeometry: fr, - CircleGeometry: fr, - ClampToEdgeWrapping: vt, - Clock: Wh, - Color: ae, - ColorKeyframeTrack: Ba, - CompressedTexture: va, - CompressedTextureLoader: hy, - ConeBufferGeometry: pr, - ConeGeometry: pr, - CubeCamera: $s, - CubeReflectionMapping: Bi, - CubeRefractionMapping: zi, - CubeTexture: ki, - CubeTextureLoader: Fh, - CubeUVReflectionMapping: Pr, - CubeUVRefractionMapping: Ws, - CubicBezierCurve: lo, - CubicBezierCurve3: Sa, - CubicInterpolant: Ph, + ACESFilmicToneMapping: lf, + AddEquation: Bi, + AddOperation: rf, + AdditiveAnimationBlendMode: dd, + AdditiveBlending: el, + AlphaFormat: ff, + AlwaysCompare: Df, + AlwaysDepth: Kd, + AlwaysStencilFunc: wf, + AmbientLight: Ec, + AmbientLightProbe: du, + AnimationAction: Dc, + AnimationClip: is, + AnimationLoader: Qh, + AnimationMixer: bu, + AnimationObjectGroup: Su, + AnimationUtils: yv, + ArcCurve: Fo, + ArrayCamera: yo, + ArrowHelper: ju, + Audio: Lc, + AudioAnalyser: Mu, + AudioContext: fa, + AudioListener: xu, + AudioLoader: hu, + AxesHelper: td, + BackSide: De, + BasicDepthPacking: bf, + BasicShadowMap: kx, + Bone: jr, + BooleanKeyframeTrack: zn, + Box2: Uu, + Box3: Ke, + Box3Helper: $u, + BoxGeometry: Ji, + BoxHelper: Ju, + BufferAttribute: Kt, + BufferGeometry: Vt, + BufferGeometryLoader: Cc, + ByteType: uf, + Cache: ss, + Camera: Cs, + CameraHelper: Zu, + CanvasTexture: Xh, + CapsuleGeometry: Vo, + CatmullRomCurve3: Oo, + CineonToneMapping: cf, + CircleGeometry: Ho, + ClampToEdgeWrapping: Ce, + Clock: Pc, + Color: ft, + ColorKeyframeTrack: ha, + ColorManagement: Ye, + CompressedArrayTexture: Gh, + CompressedCubeTexture: Wh, + CompressedTexture: Us, + CompressedTextureLoader: jh, + ConeGeometry: Go, + CubeCamera: uo, + CubeReflectionMapping: Bn, + CubeRefractionMapping: ci, + CubeTexture: Ki, + CubeTextureLoader: tu, + CubeUVReflectionMapping: Hs, + CubicBezierCurve: ea, + CubicBezierCurve3: Bo, + CubicInterpolant: fc, CullFaceBack: tl, - CullFaceFront: du, - CullFaceFrontBack: Wy, - CullFaceNone: uu, - Curve: Ct, - CurvePath: Ah, - CustomBlending: pu, - CustomToneMapping: Ou, - CylinderBufferGeometry: Jn, - CylinderGeometry: Jn, - Cylindrical: Cy, - DataTexture: qn, - DataTexture2DArray: Qs, - DataTexture3D: ma, - DataTextureLoader: Nh, - DataUtils: ky, - DecrementStencilOp: n0, - DecrementWrapStencilOp: r0, - DefaultLoadingManager: ly, - DepthFormat: Vn, - DepthStencilFormat: Li, - DepthTexture: ks, - DirectionalLight: Wa, - DirectionalLightHelper: Fy, - DiscreteInterpolant: Ih, - DodecahedronBufferGeometry: mr, - DodecahedronGeometry: mr, - DoubleSide: Ci, - DstAlphaFactor: Mu, - DstColorFactor: wu, - DynamicBufferAttribute: B0, - DynamicCopyUsage: y0, - DynamicDrawUsage: ur, - DynamicReadUsage: m0, - EdgesGeometry: _a, - EdgesHelper: Y0, - EllipseCurve: Ur, - EqualDepth: Lu, - EqualStencilFunc: l0, - EquirectangularReflectionMapping: Ds, - EquirectangularRefractionMapping: Fs, - Euler: Zn, - EventDispatcher: En, - ExtrudeBufferGeometry: ln, - ExtrudeGeometry: ln, - FaceColors: T0, - FileLoader: Yt, - FlatShading: kc, - Float16BufferAttribute: nh, - Float32Attribute: W0, - Float32BufferAttribute: de, - Float64Attribute: q0, - Float64BufferAttribute: ih, - FloatType: nn, - Fog: Br, - FogExp2: Nr, - Font: ov, - FontLoader: sv, - FramebufferTexture: Sh, - FrontSide: Ai, - Frustum: Dr, - GLBufferAttribute: Qh, - GLSL1: _0, - GLSL3: xl, - GreaterDepth: Pu, - GreaterEqualDepth: Ru, - GreaterEqualStencilFunc: d0, - GreaterStencilFunc: h0, - GridHelper: nu, - Group: Hn, - HalfFloatType: kn, - HemisphereLight: Ua, - HemisphereLightHelper: Iy, - HemisphereLightProbe: Gh, - IcosahedronBufferGeometry: _r, - IcosahedronGeometry: _r, - ImageBitmapLoader: Oh, - ImageLoader: Rr, - ImageUtils: Yn, - ImmediateRenderObject: av, - IncrementStencilOp: t0, - IncrementWrapStencilOp: i0, - InstancedBufferAttribute: Xn, - InstancedBufferGeometry: Ya, - InstancedInterleavedBuffer: jh, - InstancedMesh: xa, - Int16Attribute: H0, - Int16BufferAttribute: eh, - Int32Attribute: G0, - Int32BufferAttribute: th, - Int8Attribute: z0, - Int8BufferAttribute: jc, - IntType: Gu, - InterleavedBuffer: $n, - InterleavedBufferAttribute: Sn, - Interpolant: cn, - InterpolateDiscrete: zs, - InterpolateLinear: Us, - InterpolateSmooth: yo, - InvertStencilOp: s0, - JSONLoader: ev, - KeepStencilOp: vo, - KeyframeTrack: zt, - LOD: bh, - LatheBufferGeometry: Mr, - LatheGeometry: Mr, - Layers: Js, - LensFlare: nv, - LessDepth: Cu, - LessEqualDepth: ea, - LessEqualStencilFunc: c0, - LessStencilFunc: a0, - Light: Bt, - LightProbe: Hr, - Line: on, - Line3: Kh, - LineBasicMaterial: ft, - LineCurve: Or, - LineCurve3: Eh, - LineDashedMaterial: Fa, - LineLoop: ya, - LinePieces: w0, - LineSegments: wt, - LineStrip: b0, - LinearEncoding: Nt, - LinearFilter: tt, - LinearInterpolant: Na, - LinearMipMapLinearFilter: $y, - LinearMipMapNearestFilter: Zy, - LinearMipmapLinearFilter: Ui, - LinearMipmapNearestFilter: Wc, - LinearToneMapping: Nu, - Loader: bt, - LoaderUtils: Gs, - LoadingManager: za, - LoopOnce: Pd, - LoopPingPong: Dd, - LoopRepeat: Id, - LuminanceAlphaFormat: Yu, - LuminanceFormat: Ju, - MOUSE: Gy, - Material: dt, - MaterialLoader: zh, - Math: M0, - MathUtils: M0, - Matrix3: lt, - Matrix4: pe, - MaxEquation: ol, - Mesh: st, - MeshBasicMaterial: hn, - MeshDepthMaterial: eo, - MeshDistanceMaterial: to, - MeshFaceMaterial: A0, - MeshLambertMaterial: Ia, - MeshMatcapMaterial: Da, - MeshNormalMaterial: Pa, - MeshPhongMaterial: La, - MeshPhysicalMaterial: Ca, - MeshStandardMaterial: po, - MeshToonMaterial: Ra, + CullFaceFront: Fd, + CullFaceFrontBack: zx, + CullFaceNone: Nd, + Curve: Xe, + CurvePath: ko, + CustomBlending: Bd, + CustomToneMapping: hf, + CylinderGeometry: Fs, + Cylindrical: Lu, + Data3DTexture: Wr, + DataArrayTexture: As, + DataTexture: oi, + DataTextureLoader: eu, + DataUtils: vv, + DecrementStencilOp: Qx, + DecrementWrapStencilOp: tv, + DefaultLoadingManager: Sx, + DepthFormat: ii, + DepthStencilFormat: Yi, + DepthTexture: Mo, + DirectionalLight: bc, + DirectionalLightHelper: Yu, + DiscreteInterpolant: pc, + DisplayP3ColorSpace: pd, + DodecahedronGeometry: Wo, + DoubleSide: gn, + DstAlphaFactor: Xd, + DstColorFactor: Yd, + DynamicCopyUsage: mv, + DynamicDrawUsage: lv, + DynamicReadUsage: dv, + EdgesGeometry: Xo, + EllipseCurve: Ds, + EqualCompare: Cf, + EqualDepth: jd, + EqualStencilFunc: sv, + EquirectangularReflectionMapping: Ur, + EquirectangularRefractionMapping: Dr, + Euler: Xr, + EventDispatcher: sn, + ExtrudeGeometry: Zo, + FileLoader: rn, + Float16BufferAttribute: Jl, + Float32BufferAttribute: _t, + Float64BufferAttribute: $l, + FloatType: xn, + Fog: wo, + FogExp2: To, + FramebufferTexture: Hh, + FrontSide: On, + Frustum: Ps, + GLBufferAttribute: Au, + GLSL1: _v, + GLSL3: Cl, + GreaterCompare: Lf, + GreaterDepth: ef, + GreaterEqualCompare: Uf, + GreaterEqualDepth: tf, + GreaterEqualStencilFunc: cv, + GreaterStencilFunc: av, + GridHelper: Gu, + Group: ti, + HalfFloatType: Ts, + HemisphereLight: _c, + HemisphereLightHelper: Hu, + HemisphereLightProbe: uu, + IcosahedronGeometry: Jo, + ImageBitmapLoader: lu, + ImageLoader: rs, + ImageUtils: Gr, + IncrementStencilOp: Kx, + IncrementWrapStencilOp: jx, + InstancedBufferAttribute: ui, + InstancedBufferGeometry: Rc, + InstancedInterleavedBuffer: wu, + InstancedMesh: Io, + Int16BufferAttribute: Yl, + Int32BufferAttribute: Zl, + Int8BufferAttribute: Wl, + IntType: ad, + InterleavedBuffer: Is, + InterleavedBufferAttribute: Qi, + Interpolant: ts, + InterpolateDiscrete: Or, + InterpolateLinear: Br, + InterpolateSmooth: wa, + InvertStencilOp: ev, + KeepStencilOp: Aa, + KeyframeTrack: qe, + LOD: Co, + LatheGeometry: ra, + Layers: Rs, + LessCompare: Rf, + LessDepth: Qd, + LessEqualCompare: Pf, + LessEqualDepth: ao, + LessEqualStencilFunc: rv, + LessStencilFunc: iv, + Light: bn, + LightProbe: Vs, + Line: Sn, + Line3: Nu, + LineBasicMaterial: Ee, + LineCurve: Ns, + LineCurve3: zo, + LineDashedMaterial: uc, + LineLoop: Uo, + LineSegments: je, + LinearEncoding: fd, + LinearFilter: pe, + LinearInterpolant: la, + LinearMipMapLinearFilter: Xx, + LinearMipMapNearestFilter: Wx, + LinearMipmapLinearFilter: li, + LinearMipmapNearestFilter: rd, + LinearSRGBColorSpace: nn, + LinearToneMapping: af, + Loader: Le, + LoaderUtils: da, + LoadingManager: ua, + LoopOnce: yf, + LoopPingPong: Sf, + LoopRepeat: Mf, + LuminanceAlphaFormat: mf, + LuminanceFormat: pf, + MOUSE: Ox, + Material: Me, + MaterialLoader: Ac, + MathUtils: xv, + Matrix3: kt, + Matrix4: Ot, + MaxEquation: rl, + Mesh: ve, + MeshBasicMaterial: Mn, + MeshDepthMaterial: $r, + MeshDistanceMaterial: Kr, + MeshLambertMaterial: lc, + MeshMatcapMaterial: hc, + MeshNormalMaterial: cc, + MeshPhongMaterial: ac, + MeshPhysicalMaterial: rc, + MeshStandardMaterial: ca, + MeshToonMaterial: oc, MinEquation: sl, - MirroredRepeatWrapping: Bs, - MixOperation: Du, - MultiMaterial: C0, - MultiplyBlending: rl, - MultiplyOperation: Vs, - NearestFilter: rt, - NearestMipMapLinearFilter: Yy, - NearestMipMapNearestFilter: Jy, - NearestMipmapLinearFilter: na, - NearestMipmapNearestFilter: ta, - NeverDepth: Eu, - NeverStencilFunc: o0, - NoBlending: vn, - NoColors: S0, - NoToneMapping: _n, - NormalAnimationBlendMode: ua, - NormalBlending: sr, - NotEqualDepth: Iu, - NotEqualStencilFunc: u0, - NumberKeyframeTrack: Ar, - Object3D: Ne, - ObjectLoader: uy, - ObjectSpaceNormalMap: zd, - OctahedronBufferGeometry: Ii, - OctahedronGeometry: Ii, - OneFactor: yu, - OneMinusDstAlphaFactor: bu, - OneMinusDstColorFactor: Su, - OneMinusSrcAlphaFactor: Vc, - OneMinusSrcColorFactor: _u, - OrthographicCamera: Fr, - PCFShadowMap: Hc, - PCFSoftShadowMap: fu, - PMREMGenerator: ah, - ParametricGeometry: iv, - Particle: R0, - ParticleBasicMaterial: D0, - ParticleSystem: P0, - ParticleSystemMaterial: F0, - Path: gr, - PerspectiveCamera: ut, - Plane: Wt, - PlaneBufferGeometry: Pi, - PlaneGeometry: Pi, - PlaneHelper: zy, - PointCloud: L0, - PointCloudMaterial: I0, - PointLight: Ga, - PointLightHelper: Ry, - Points: zr, - PointsMaterial: jn, - PolarGridHelper: Dy, - PolyhedronBufferGeometry: an, - PolyhedronGeometry: an, - PositionalAudio: xy, - PropertyBinding: ke, - PropertyMixer: Xh, - QuadraticBezierCurve: co, - QuadraticBezierCurve3: ho, - Quaternion: gt, - QuaternionKeyframeTrack: Wi, - QuaternionLinearInterpolant: Dh, - REVISION: ca, - RGBADepthPacking: Bd, - RGBAFormat: ct, - RGBAIntegerFormat: ed, - RGBA_ASTC_10x10_Format: fd, - RGBA_ASTC_10x5_Format: hd, - RGBA_ASTC_10x6_Format: ud, - RGBA_ASTC_10x8_Format: dd, - RGBA_ASTC_12x10_Format: pd, - RGBA_ASTC_12x12_Format: md, - RGBA_ASTC_4x4_Format: nd, - RGBA_ASTC_5x4_Format: id, - RGBA_ASTC_5x5_Format: rd, - RGBA_ASTC_6x5_Format: sd, - RGBA_ASTC_6x6_Format: od, - RGBA_ASTC_8x5_Format: ad, - RGBA_ASTC_8x6_Format: ld, - RGBA_ASTC_8x8_Format: cd, - RGBA_BPTC_Format: gd, - RGBA_ETC2_EAC_Format: gl, - RGBA_PVRTC_2BPPV1_Format: pl, - RGBA_PVRTC_4BPPV1_Format: fl, - RGBA_S3TC_DXT1_Format: ll, - RGBA_S3TC_DXT3_Format: cl, - RGBA_S3TC_DXT5_Format: hl, - RGBFormat: Gn, - RGBIntegerFormat: Ku, - RGB_ETC1_Format: td, - RGB_ETC2_Format: ml, - RGB_PVRTC_2BPPV1_Format: dl, - RGB_PVRTC_4BPPV1_Format: ul, - RGB_S3TC_DXT1_Format: al, - RGFormat: ju, - RGIntegerFormat: Qu, - RawShaderMaterial: Gi, - Ray: Cn, - Raycaster: Ey, - RectAreaLight: Xa, - RedFormat: Zu, - RedIntegerFormat: $u, - ReinhardToneMapping: Bu, - RepeatWrapping: Ns, - ReplaceStencilOp: e0, - ReverseSubtractEquation: gu, - RingBufferGeometry: br, - RingGeometry: br, - SRGB8_ALPHA8_ASTC_10x10_Format: Cd, - SRGB8_ALPHA8_ASTC_10x5_Format: Td, - SRGB8_ALPHA8_ASTC_10x6_Format: Ed, - SRGB8_ALPHA8_ASTC_10x8_Format: Ad, - SRGB8_ALPHA8_ASTC_12x10_Format: Ld, - SRGB8_ALPHA8_ASTC_12x12_Format: Rd, - SRGB8_ALPHA8_ASTC_4x4_Format: xd, - SRGB8_ALPHA8_ASTC_5x4_Format: yd, - SRGB8_ALPHA8_ASTC_5x5_Format: vd, - SRGB8_ALPHA8_ASTC_6x5_Format: _d, - SRGB8_ALPHA8_ASTC_6x6_Format: Md, - SRGB8_ALPHA8_ASTC_8x5_Format: bd, - SRGB8_ALPHA8_ASTC_8x6_Format: wd, - SRGB8_ALPHA8_ASTC_8x8_Format: Sd, - Scene: no, - SceneUtils: tv, - ShaderChunk: Fe, - ShaderLib: qt, - ShaderMaterial: sn, - ShadowMaterial: Aa, - Shape: Xt, - ShapeBufferGeometry: Di, - ShapeGeometry: Di, - ShapePath: Oy, - ShapeUtils: Jt, - ShortType: ku, - Skeleton: ao, - SkeletonHelper: eu, - SkinnedMesh: so, - SmoothShading: Xy, - Sphere: An, - SphereBufferGeometry: Fi, - SphereGeometry: Fi, - Spherical: Ay, - SphericalHarmonics3: Ja, - SplineCurve: uo, - SpotLight: Ha, - SpotLightHelper: Ly, - Sprite: ro, - SpriteMaterial: io, - SrcAlphaFactor: Gc, - SrcAlphaSaturateFactor: Tu, - SrcColorFactor: vu, - StaticCopyUsage: x0, - StaticDrawUsage: hr, - StaticReadUsage: p0, - StereoCamera: fy, - StreamCopyUsage: v0, - StreamDrawUsage: f0, - StreamReadUsage: g0, - StringKeyframeTrack: Kn, - SubtractEquation: mu, - SubtractiveBlending: il, - TOUCH: Vy, - TangentSpaceNormalMap: Hi, - TetrahedronBufferGeometry: wr, - TetrahedronGeometry: wr, - TextGeometry: rv, - Texture: ot, - TextureLoader: Bh, - TorusBufferGeometry: Sr, - TorusGeometry: Sr, - TorusKnotBufferGeometry: Tr, - TorusKnotGeometry: Tr, - Triangle: nt, - TriangleFanDrawMode: Qy, - TriangleStripDrawMode: jy, - TrianglesDrawMode: Fd, - TubeBufferGeometry: Er, - TubeGeometry: Er, - UVMapping: ha, - Uint16Attribute: k0, - Uint16BufferAttribute: Ys, - Uint32Attribute: V0, - Uint32BufferAttribute: Zs, - Uint8Attribute: U0, - Uint8BufferAttribute: Qc, - Uint8ClampedAttribute: O0, - Uint8ClampedBufferAttribute: Kc, - Uniform: go, - UniformsLib: ie, - UniformsUtils: uf, - UnsignedByteType: rn, - UnsignedInt248Type: Ti, - UnsignedIntType: Ps, - UnsignedShort4444Type: Vu, - UnsignedShort5551Type: Wu, - UnsignedShort565Type: qu, - UnsignedShortType: cr, - VSMShadowMap: ir, - Vector2: X, - Vector3: M, - Vector4: Ve, - VectorKeyframeTrack: Cr, - Vertex: N0, - VertexColors: E0, - VideoTexture: wh, - WebGL1Renderer: _h, - WebGLCubeRenderTarget: js, - WebGLMultipleRenderTargets: Zc, - WebGLMultisampleRenderTarget: Xs, - WebGLRenderTarget: At, - WebGLRenderTargetCube: Q0, - WebGLRenderer: qe, - WebGLUtils: Ex, - WireframeGeometry: Ea, - WireframeHelper: Z0, - WrapAroundEnding: Os, - XHRLoader: $0, - ZeroCurvatureEnding: Mi, - ZeroFactor: xu, - ZeroSlopeEnding: bi, - ZeroStencilOp: Ky, - sRGBEncoding: Oi + MirroredRepeatWrapping: Fr, + MixOperation: sf, + MultiplyBlending: il, + MultiplyOperation: pa, + NearestFilter: fe, + NearestMipMapLinearFilter: Gx, + NearestMipMapNearestFilter: Hx, + NearestMipmapLinearFilter: Ir, + NearestMipmapNearestFilter: oo, + NeverCompare: Af, + NeverDepth: $d, + NeverStencilFunc: nv, + NoBlending: Un, + NoColorSpace: ri, + NoToneMapping: Dn, + NormalAnimationBlendMode: zc, + NormalBlending: Wi, + NotEqualCompare: If, + NotEqualDepth: nf, + NotEqualStencilFunc: ov, + NumberKeyframeTrack: es, + Object3D: Zt, + ObjectLoader: au, + ObjectSpaceNormalMap: Tf, + OctahedronGeometry: aa, + OneFactor: Hd, + OneMinusDstAlphaFactor: qd, + OneMinusDstColorFactor: Zd, + OneMinusSrcAlphaFactor: sd, + OneMinusSrcColorFactor: Wd, + OrthographicCamera: Ls, + PCFShadowMap: nd, + PCFSoftShadowMap: Od, + PMREMGenerator: Jr, + Path: ji, + PerspectiveCamera: xe, + Plane: mn, + PlaneGeometry: Zr, + PlaneHelper: Ku, + PointLight: Mc, + PointLightHelper: zu, + Points: No, + PointsMaterial: ta, + PolarGridHelper: Wu, + PolyhedronGeometry: di, + PositionalAudio: yu, + PropertyBinding: Jt, + PropertyMixer: Ic, + QuadraticBezierCurve: na, + QuadraticBezierCurve3: ia, + Quaternion: Pe, + QuaternionKeyframeTrack: pi, + QuaternionLinearInterpolant: mc, + RED_GREEN_RGTC2_Format: Al, + RED_RGTC1_Format: vf, + REVISION: Fc, + RGBADepthPacking: Ef, + RGBAFormat: He, + RGBAIntegerFormat: ud, + RGBA_ASTC_10x10_Format: bl, + RGBA_ASTC_10x5_Format: yl, + RGBA_ASTC_10x6_Format: Ml, + RGBA_ASTC_10x8_Format: Sl, + RGBA_ASTC_12x10_Format: El, + RGBA_ASTC_12x12_Format: Tl, + RGBA_ASTC_4x4_Format: dl, + RGBA_ASTC_5x4_Format: fl, + RGBA_ASTC_5x5_Format: pl, + RGBA_ASTC_6x5_Format: ml, + RGBA_ASTC_6x6_Format: gl, + RGBA_ASTC_8x5_Format: _l, + RGBA_ASTC_8x6_Format: xl, + RGBA_ASTC_8x8_Format: vl, + RGBA_BPTC_Format: Ta, + RGBA_ETC2_EAC_Format: ul, + RGBA_PVRTC_2BPPV1_Format: ll, + RGBA_PVRTC_4BPPV1_Format: cl, + RGBA_S3TC_DXT1_Format: Sa, + RGBA_S3TC_DXT3_Format: ba, + RGBA_S3TC_DXT5_Format: Ea, + RGB_ETC1_Format: xf, + RGB_ETC2_Format: hl, + RGB_PVRTC_2BPPV1_Format: ol, + RGB_PVRTC_4BPPV1_Format: al, + RGB_S3TC_DXT1_Format: Ma, + RGFormat: _f, + RGIntegerFormat: hd, + RawShaderMaterial: sc, + Ray: hi, + Raycaster: Ru, + RectAreaLight: Tc, + RedFormat: gf, + RedIntegerFormat: ld, + ReinhardToneMapping: of, + RenderTarget: ho, + RepeatWrapping: Nr, + ReplaceStencilOp: $x, + ReverseSubtractEquation: kd, + RingGeometry: $o, + SIGNED_RED_GREEN_RGTC2_Format: Rl, + SIGNED_RED_RGTC1_Format: wl, + SRGBColorSpace: Nt, + Scene: Ao, + ShaderChunk: zt, + ShaderLib: en, + ShaderMaterial: Qe, + ShadowMaterial: ic, + Shape: Fn, + ShapeGeometry: Ko, + ShapePath: ed, + ShapeUtils: yn, + ShortType: df, + Skeleton: Lo, + SkeletonHelper: Bu, + SkinnedMesh: Po, + Source: Ln, + Sphere: We, + SphereGeometry: oa, + Spherical: Pu, + SphericalHarmonics3: wc, + SplineCurve: sa, + SpotLight: vc, + SpotLightHelper: Ou, + Sprite: Ro, + SpriteMaterial: Qr, + SrcAlphaFactor: id, + SrcAlphaSaturateFactor: Jd, + SrcColorFactor: Gd, + StaticCopyUsage: pv, + StaticDrawUsage: kr, + StaticReadUsage: uv, + StereoCamera: mu, + StreamCopyUsage: gv, + StreamDrawUsage: hv, + StreamReadUsage: fv, + StringKeyframeTrack: kn, + SubtractEquation: zd, + SubtractiveBlending: nl, + TOUCH: Bx, + TangentSpaceNormalMap: mi, + TetrahedronGeometry: Qo, + Texture: ye, + TextureLoader: nu, + TorusGeometry: jo, + TorusKnotGeometry: tc, + Triangle: In, + TriangleFanDrawMode: Zx, + TriangleStripDrawMode: Yx, + TrianglesDrawMode: qx, + TubeGeometry: ec, + TwoPassDoubleSide: Vx, + UVMapping: Oc, + Uint16BufferAttribute: qr, + Uint32BufferAttribute: Yr, + Uint8BufferAttribute: Xl, + Uint8ClampedBufferAttribute: ql, + Uniform: Eu, + UniformsGroup: Tu, + UniformsLib: ct, + UniformsUtils: mp, + UnsignedByteType: Nn, + UnsignedInt248Type: ni, + UnsignedIntType: Pn, + UnsignedShort4444Type: od, + UnsignedShort5551Type: cd, + UnsignedShortType: Bc, + VSMShadowMap: pn, + Vector2: J, + Vector3: A, + Vector4: $t, + VectorKeyframeTrack: ns, + VideoTexture: Vh, + WebGL1Renderer: Eo, + WebGL3DRenderTarget: Ul, + WebGLArrayRenderTarget: Il, + WebGLCoordinateSystem: vn, + WebGLCubeRenderTarget: fo, + WebGLMultipleRenderTargets: Dl, + WebGLRenderTarget: Ge, + WebGLRenderer: bo, + WebGLUtils: O0, + WebGPUCoordinateSystem: Vr, + WireframeGeometry: nc, + WrapAroundEnding: zr, + ZeroCurvatureEnding: zi, + ZeroFactor: Vd, + ZeroSlopeEnding: ki, + ZeroStencilOp: Jx, + _SRGBAFormat: co, + sRGBEncoding: si }; function getWebGLErrorMessage() { return getErrorMessage(1); @@ -19600,7 +20226,7 @@ function event2scene_pixel(scene, event) { ]; } function Identity4x4() { - return new pe(); + return new Ot(); } function in_scene(scene, mouse_event) { const [x, y] = event2scene_pixel(scene, mouse_event); @@ -19612,9 +20238,9 @@ function attach_3d_camera(canvas, makie_camera, cam3d, scene) { return; } const [w, h] = makie_camera.resolution.value; - const camera = new ut(cam3d.fov, w / h, cam3d.near, cam3d.far); - const center = new M(...cam3d.lookat); - camera.up = new M(...cam3d.upvector); + const camera = new xe(cam3d.fov, w / h, cam3d.near, cam3d.far); + const center = new A(...cam3d.lookat); + camera.up = new A(...cam3d.upvector); camera.position.set(...cam3d.eyeposition); camera.lookAt(center); function update() { @@ -19777,17 +20403,17 @@ function relative_space() { } class MakieCamera { constructor(){ - this.view = new go(Identity4x4()); - this.projection = new go(Identity4x4()); - this.projectionview = new go(Identity4x4()); - this.pixel_space = new go(Identity4x4()); - this.pixel_space_inverse = new go(Identity4x4()); - this.projectionview_inverse = new go(Identity4x4()); - this.relative_space = new go(relative_space()); - this.relative_inverse = new go(relative_space().invert()); - this.clip_space = new go(Identity4x4()); - this.resolution = new go(new X()); - this.eyeposition = new go(new M()); + this.view = new Eu(Identity4x4()); + this.projection = new Eu(Identity4x4()); + this.projectionview = new Eu(Identity4x4()); + this.pixel_space = new Eu(Identity4x4()); + this.pixel_space_inverse = new Eu(Identity4x4()); + this.projectionview_inverse = new Eu(Identity4x4()); + this.relative_space = new Eu(relative_space()); + this.relative_inverse = new Eu(relative_space().invert()); + this.clip_space = new Eu(Identity4x4()); + this.resolution = new Eu(new J()); + this.eyeposition = new Eu(new A()); this.preprojections = {}; } calculate_matrices() { @@ -19852,7 +20478,7 @@ class MakieCamera { return matrix_uniform; } else { const matrix = this.calculate_preprojection_matrix(space, markerspace); - const uniform = new go(matrix); + const uniform = new Eu(matrix); this.preprojections[key] = uniform; return uniform; } @@ -19987,8 +20613,7 @@ function linesegments_vertex_shader(uniforms, attributes) { const attribute_decl = attributes_to_type_declaration(attributes); const uniform_decl = uniforms_to_type_declaration(uniforms); const color = attribute_type(attributes.color_start) || uniform_type(uniforms.color_start); - return `#version 300 es - precision mediump int; + return `precision mediump int; precision highp float; ${attribute_decl} @@ -20040,8 +20665,7 @@ function lines_fragment_shader(uniforms, attributes) { "lowclip" ]); const uniform_decl = uniforms_to_type_declaration(color_uniforms); - return `#version 300 es - #extension GL_OES_standard_derivatives : enable + return `#extension GL_OES_standard_derivatives : enable precision mediump int; precision highp float; @@ -20111,6 +20735,7 @@ function create_line_material(uniforms, attributes) { const uniforms_des = deserialize_uniforms(uniforms); return new THREE.RawShaderMaterial({ uniforms: uniforms_des, + glslVersion: THREE.GLSL3, vertexShader: linesegments_vertex_shader(uniforms_des, attributes), fragmentShader: lines_fragment_shader(uniforms_des, attributes), transparent: true @@ -20390,6 +21015,7 @@ function create_material(program) { fragmentShader: program.fragment_source, side: is_volume ? mod.BackSide : mod.DoubleSide, transparent: true, + glslVersion: mod.GLSL3, depthTest: !program.overdraw.value, depthWrite: !program.transparency.value }); @@ -20641,12 +21267,6 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit var rect = canvas.getBoundingClientRect(); var x = (event.clientX - rect.left) / winscale; var y = (event.clientY - rect.top) / winscale; - console.log("-----------------"); - console.log(event.clientX); - console.log(event.clientY); - console.log(rect); - console.log(x); - console.log(y); notify_mouse_throttled(x, y); return false; } diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index 90562eddc5a..f7272e77ad4 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -1,4 +1,4 @@ -import * as THREE from "https://cdn.esm.sh/v66/three@0.136/es2021/three.js"; +import * as THREE from "./THREE.js"; import { getWebGLErrorMessage } from "./WEBGL.js"; import { delete_scenes, From b05a528af9e5889f3b5bbc89c65e17857a7e941d Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 15 Aug 2023 18:09:05 +0200 Subject: [PATCH 21/28] improvements --- WGLMakie/src/Lines.js | 3 +-- WGLMakie/src/WGLMakie.jl | 1 + WGLMakie/src/display.jl | 12 ++++++++++++ WGLMakie/src/lines.jl | 1 + WGLMakie/src/wglmakie.bundled.js | 3 +-- src/interfaces.jl | 3 ++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index ee49f41eddc..6db0cec3a8e 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -232,8 +232,7 @@ function attach_updates(mesh, buffers, attributes, is_segments) { let buff = buffers[name]; const ndims = new_points.type_length; const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - console.log(old_count); + const old_count = buff.array.length; if (old_count < new_line_points.length) { mesh.geometry.dispose(); geometry = create_line_instance_geometry(); diff --git a/WGLMakie/src/WGLMakie.jl b/WGLMakie/src/WGLMakie.jl index 9af22ed65d5..6c805c576ad 100644 --- a/WGLMakie/src/WGLMakie.jl +++ b/WGLMakie/src/WGLMakie.jl @@ -31,6 +31,7 @@ using Makie: spaces, is_data_space, is_pixel_space, is_relative_space, is_clip_s struct WebGL <: ShaderAbstractions.AbstractContext end const WGL = ES6Module(@path joinpath(@__DIR__, "wglmakie.js")) +# Main.download("https://esm.sh/v130/three@0.155.0/es2022/three.mjs", joinpath(@__DIR__, "THREE.js")) include("display.jl") include("three_plot.jl") diff --git a/WGLMakie/src/display.jl b/WGLMakie/src/display.jl index 1fa066c093b..d6a239bad94 100644 --- a/WGLMakie/src/display.jl +++ b/WGLMakie/src/display.jl @@ -90,6 +90,18 @@ mutable struct Screen <: Makie.MakieScreen end end +function Base.show(io::IO, screen::Screen) + c = screen.config + ppu = c.px_per_unit + sf = c.scalefactor + print(io, """WGLMakie.Screen( + framerate = $(c.framerate), + resize_to_body = $(c.resize_to_body), + px_per_unit = $(isnothing(ppu) ? :automatic : ppu), + scalefactor = $(isnothing(sf) ? :automatic : sf) + )""") +end + # Resizing the scene is enough for WGLMakie Base.resize!(::WGLMakie.Screen, w, h) = nothing diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index b56b79829e7..83467090fb0 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -20,6 +20,7 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) attributes = Dict{Symbol, Any}( :linepoint => lift(serialize_buffer_attribute, plot[1]) ) + for (name, attr) in [:color => color, :linewidth => linewidth] if Makie.is_scalar_attribute(to_value(attr)) uniforms[Symbol("$(name)_start")] = attr diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 1598d73f3fe..83ca936f292 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20794,8 +20794,7 @@ function attach_updates(mesh, buffers, attributes, is_segments) { let buff = buffers[name]; const ndims = new_points.type_length; const new_line_points = new_points.flat; - const old_count = buff.updateRange.count; - console.log(old_count); + const old_count = buff.array.length; if (old_count < new_line_points.length) { mesh.geometry.dispose(); geometry = create_line_instance_geometry(); diff --git a/src/interfaces.jl b/src/interfaces.jl index 5dcc4c0857d..4c70849c6db 100644 --- a/src/interfaces.jl +++ b/src/interfaces.jl @@ -82,7 +82,8 @@ function calculated_attributes!(::Type{T}, plot) where {T<:Union{Lines, LineSegm for attr in [:color, :linewidth] # taken from @edljk in PR #77 if haskey(plot, attr) && isa(plot[attr][], AbstractVector) && (length(pos) ÷ 2) == length(plot[attr][]) - plot[attr] = lift(plot, plot[attr]) do cols + # TODO, this is actually buggy for `plot.color = new_colors`, since we're overwriting the origin color input + attributes(plot.attributes)[attr] = lift(plot, plot[attr]) do cols map(i -> cols[(i + 1) ÷ 2], 1:(length(cols) * 2)) end end From 8fbaa222948cf5dece5a2288c602ef29efac2037 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Aug 2023 14:33:52 +0200 Subject: [PATCH 22/28] fix DataTexture3D deprecation --- WGLMakie/src/Serialization.js | 4 ++-- WGLMakie/src/wglmakie.bundled.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WGLMakie/src/Serialization.js b/WGLMakie/src/Serialization.js index 6c66a0fd50d..23515e55bec 100644 --- a/WGLMakie/src/Serialization.js +++ b/WGLMakie/src/Serialization.js @@ -249,7 +249,7 @@ function connect_uniforms(mesh, updater) { function create_texture(data) { const buffer = data.data; if (data.size.length == 3) { - const tex = new THREE.DataTexture3D( + const tex = new THREE.Data3DTexture( buffer, data.size[0], data.size[1], @@ -274,7 +274,7 @@ function create_texture(data) { function re_create_texture(old_texture, buffer, size) { if (size.length == 3) { - const tex = new THREE.DataTexture3D(buffer, size[0], size[1], size[2]); + const tex = new THREE.Data3DTexture(buffer, size[0], size[1], size[2]); tex.format = old_texture.format; tex.type = old_texture.type; return tex; diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 1598d73f3fe..3cd1db37cd3 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20920,7 +20920,7 @@ function connect_uniforms(mesh, updater) { function create_texture(data) { const buffer = data.data; if (data.size.length == 3) { - const tex = new mod.DataTexture3D(buffer, data.size[0], data.size[1], data.size[2]); + const tex = new mod.Data3DTexture(buffer, data.size[0], data.size[1], data.size[2]); tex.format = mod[data.three_format]; tex.type = mod[data.three_type]; return tex; @@ -20931,7 +20931,7 @@ function create_texture(data) { } function re_create_texture(old_texture, buffer, size) { if (size.length == 3) { - const tex = new mod.DataTexture3D(buffer, size[0], size[1], size[2]); + const tex = new mod.Data3DTexture(buffer, size[0], size[1], size[2]); tex.format = old_texture.format; tex.type = old_texture.type; return tex; From fd93a6d79a3ec908f902cad8e4d5ace108da5bd2 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Aug 2023 14:56:12 +0200 Subject: [PATCH 23/28] run CI, against JSServe#sd/fix-asset-server --- .github/workflows/Docs.yml | 4 ++-- .github/workflows/cairomakie.yaml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/compilation-benchmark.yaml | 2 +- .github/workflows/glmakie.yaml | 4 ++-- .github/workflows/rprmakie.yaml | 4 ++-- .github/workflows/wglmakie.yaml | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Docs.yml b/.github/workflows/Docs.yml index 713a076214e..67f985d1fdb 100644 --- a/.github/workflows/Docs.yml +++ b/.github/workflows/Docs.yml @@ -4,13 +4,13 @@ on: branches: - main - master - - breaking-release + - sd/beta-20 tags: '*' pull_request: branches: - main - master - - breaking-release + - sd/beta-20 concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/cairomakie.yaml b/.github/workflows/cairomakie.yaml index 8f314850197..36ccaa3d495 100644 --- a/.github/workflows/cairomakie.yaml +++ b/.github/workflows/cairomakie.yaml @@ -6,14 +6,14 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 push: paths-ignore: - 'docs/**' - '*.md' branches: - master - - breaking-release + - sd/beta-20 tags: '*' concurrency: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9bd234ebb1..4ed4ba3bdfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,14 +6,14 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 push: paths-ignore: - 'docs/**' - '*.md' branches: - master - - breaking-release + - sd/beta-20 tags: '*' concurrency: diff --git a/.github/workflows/compilation-benchmark.yaml b/.github/workflows/compilation-benchmark.yaml index fabccef141b..a3255a6030b 100644 --- a/.github/workflows/compilation-benchmark.yaml +++ b/.github/workflows/compilation-benchmark.yaml @@ -6,7 +6,7 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 jobs: benchmark: name: ${{ matrix.package }} diff --git a/.github/workflows/glmakie.yaml b/.github/workflows/glmakie.yaml index 0fb1ca3eea9..316ee182c6e 100644 --- a/.github/workflows/glmakie.yaml +++ b/.github/workflows/glmakie.yaml @@ -6,14 +6,14 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 push: paths-ignore: - 'docs/**' - '*.md' branches: - master - - breaking-release + - sd/beta-20 tags: '*' concurrency: diff --git a/.github/workflows/rprmakie.yaml b/.github/workflows/rprmakie.yaml index d6e301ec30b..749950b59ac 100644 --- a/.github/workflows/rprmakie.yaml +++ b/.github/workflows/rprmakie.yaml @@ -6,14 +6,14 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 push: paths-ignore: - 'docs/**' - '*.md' branches: - master - - breaking-release + - sd/beta-20 tags: '*' concurrency: diff --git a/.github/workflows/wglmakie.yaml b/.github/workflows/wglmakie.yaml index 242e8b2056c..aedc6c6bb6a 100644 --- a/.github/workflows/wglmakie.yaml +++ b/.github/workflows/wglmakie.yaml @@ -6,14 +6,14 @@ on: - '*.md' branches: - master - - breaking-release + - sd/beta-20 push: paths-ignore: - 'docs/**' - '*.md' branches: - master - - breaking-release + - sd/beta-20 tags: '*' concurrency: From b8f94e7b5e52e6876d9b5751ced6dd8b515025d1 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Aug 2023 15:15:30 +0200 Subject: [PATCH 24/28] transform lines --- .github/workflows/wglmakie.yaml | 2 +- WGLMakie/src/lines.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wglmakie.yaml b/.github/workflows/wglmakie.yaml index aedc6c6bb6a..765e39042be 100644 --- a/.github/workflows/wglmakie.yaml +++ b/.github/workflows/wglmakie.yaml @@ -48,7 +48,7 @@ jobs: run: | using Pkg; # dev mono repo versions - pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests" + pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests; add JSServe#sd/fix-asset-server" - name: Run the tests continue-on-error: true run: > diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index b56b79829e7..325541ab7fe 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -17,9 +17,9 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) uniforms[name] = RGBAf(0, 0, 0, 0) end end - attributes = Dict{Symbol, Any}( - :linepoint => lift(serialize_buffer_attribute, plot[1]) - ) + points_transformed = apply_transform(transform_func_obs(plot), plot[1], plot.space) + positions = lift(serialize_buffer_attribute, points_transformed) + attributes = Dict{Symbol, Any}(:linepoint => positions) for (name, attr) in [:color => color, :linewidth => linewidth] if Makie.is_scalar_attribute(to_value(attr)) uniforms[Symbol("$(name)_start")] = attr From 68ecd6adf29584d79b6dae344d9f26b115e55bb9 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 17 Aug 2023 17:44:07 +0200 Subject: [PATCH 25/28] remove logs --- WGLMakie/src/wglmakie.bundled.js | 2 -- WGLMakie/src/wglmakie.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index 83ca936f292..a40ab4f388c 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -21351,8 +21351,6 @@ function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height camera.updateProjectionMatrix(); const size = new mod.Vector2(); renderer.getDrawingBufferSize(size); - console.log("----"); - console.log(size); const picking_target = new mod.WebGLRenderTarget(size.x, size.y); const screen = { renderer, diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index f7272e77ad4..50bfcce60b7 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -298,8 +298,6 @@ function create_scene( // 2) Only Area we pick // It's currently not as easy to change the offset + area of the camera // So, we'll need to make that easier first - console.log("----") - console.log(size); const picking_target = new THREE.WebGLRenderTarget(size.x, size.y); const screen = { renderer, From f003b4c34d0c4d390ddf9a14dc19a53e24e12c78 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Thu, 17 Aug 2023 18:10:57 +0200 Subject: [PATCH 26/28] JSServe got tagged --- .github/workflows/wglmakie.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wglmakie.yaml b/.github/workflows/wglmakie.yaml index 765e39042be..aedc6c6bb6a 100644 --- a/.github/workflows/wglmakie.yaml +++ b/.github/workflows/wglmakie.yaml @@ -48,7 +48,7 @@ jobs: run: | using Pkg; # dev mono repo versions - pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests; add JSServe#sd/fix-asset-server" + pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests" - name: Run the tests continue-on-error: true run: > From e51ffeb01befa2a447135286c4f9414ba14ad656 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 22 Aug 2023 17:01:09 +0200 Subject: [PATCH 27/28] fix resizing, picking, Tooltip and Datainspector --- WGLMakie/src/Camera.js | 17 +- WGLMakie/src/events.jl | 2 +- WGLMakie/src/lines.jl | 2 + WGLMakie/src/three_plot.jl | 1 - WGLMakie/src/wglmakie.bundled.js | 208 ++++++++++++++---------- WGLMakie/src/wglmakie.js | 267 ++++++++++++++++++------------- src/display.jl | 8 +- 7 files changed, 293 insertions(+), 212 deletions(-) diff --git a/WGLMakie/src/Camera.js b/WGLMakie/src/Camera.js index 4f912ff15b3..f2624ddeb28 100644 --- a/WGLMakie/src/Camera.js +++ b/WGLMakie/src/Camera.js @@ -1,13 +1,14 @@ import * as THREE from "./THREE.js"; -const pixelRatio = window.devicePixelRatio || 1.0; - -export function event2scene_pixel(scene, event) { - const { canvas } = scene.screen; +// Unitless is the scene pixel unit space +// so scene.px_area, or size(scene) +// Which isn't the same as the framebuffer pixel size due to scalefactor/px_per_unit/devicePixelRatio +export function events2unitless(screen, event) { + const { canvas, winscale, renderer } = screen; const rect = canvas.getBoundingClientRect(); - const x = (event.clientX - rect.left) * pixelRatio; - const y = (rect.height - (event.clientY - rect.top)) * pixelRatio; - return [x, y]; + const x = (event.clientX - rect.left) / winscale; + const y = (event.clientY - rect.top) / winscale; + return [x, renderer._height - y]; } export function to_world(scene, x, y) { @@ -32,7 +33,7 @@ function Identity4x4() { } function in_scene(scene, mouse_event) { - const [x, y] = event2scene_pixel(scene, mouse_event); + const [x, y] = events2unitless(scene.screen, mouse_event); const [sx, sy, sw, sh] = scene.pixelarea.value; return x >= sx && x < sx + sw && y >= sy && y < sy + sh; } diff --git a/WGLMakie/src/events.jl b/WGLMakie/src/events.jl index 6db9ccfa831..bd129e83d53 100644 --- a/WGLMakie/src/events.jl +++ b/WGLMakie/src/events.jl @@ -54,7 +54,7 @@ function connect_scene_events!(scene::Scene, comm::Observable) @async try @handle msg.mouseposition begin x, y = Float64.((mouseposition...,)) - e.mouseposition[] = (x, size(scene)[2] - y) + e.mouseposition[] = (x, y) end @handle msg.mousedown begin # This can probably be done better from the JS side? diff --git a/WGLMakie/src/lines.jl b/WGLMakie/src/lines.jl index 325541ab7fe..0beeb6ffdec 100644 --- a/WGLMakie/src/lines.jl +++ b/WGLMakie/src/lines.jl @@ -2,6 +2,8 @@ function serialize_three(scene::Scene, plot::Union{Lines, LineSegments}) Makie.@converted_attribute plot (linewidth,) uniforms = Dict( :model => plot.model, + :object_id => 1, + :picking => false, ) color = plot.calculated_colors diff --git a/WGLMakie/src/three_plot.jl b/WGLMakie/src/three_plot.jl index 0e57fb4ee5a..ae203401694 100644 --- a/WGLMakie/src/three_plot.jl +++ b/WGLMakie/src/three_plot.jl @@ -41,7 +41,6 @@ end function three_display(screen::Screen, session::Session, scene::Scene) config = screen.config scene_serialized = serialize_scene(scene) - window_open = scene.events.window_open width, height = size(scene) canvas_width = lift(x -> [round.(Int, widths(x))...], pixelarea(scene)) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index f0b0302521b..c08957576e7 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20214,22 +20214,21 @@ function attributes_to_type_declaration(attributes_dict) { } return result; } -const pixelRatio1 = window.devicePixelRatio || 1.0; -function event2scene_pixel(scene, event) { - const { canvas } = scene.screen; +function events2unitless(screen, event) { + const { canvas , winscale , renderer } = screen; const rect = canvas.getBoundingClientRect(); - const x = (event.clientX - rect.left) * pixelRatio1; - const y = (rect.height - (event.clientY - rect.top)) * pixelRatio1; + const x = (event.clientX - rect.left) / winscale; + const y = (event.clientY - rect.top) / winscale; return [ x, - y + renderer._height - y ]; } function Identity4x4() { return new Ot(); } function in_scene(scene, mouse_event) { - const [x, y] = event2scene_pixel(scene, mouse_event); + const [x, y] = events2unitless(scene.screen, mouse_event); const [sx, sy, sw, sh] = scene.pixelarea.value; return x >= sx && x < sx + sw && y >= sy && y < sy + sh; } @@ -21222,51 +21221,31 @@ function throttle_function(func, delay) { } return inner_throttle; } -function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor) { - let context = canvas.getContext("webgl2", { - preserveDrawingBuffer: true - }); - if (!context) { - console.warn("WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)"); - context = canvas.getContext("webgl", { - preserveDrawingBuffer: true - }); - } - if (!context) { - return; - } - const pixel_ratio = window.devicePixelRatio || 1.0; - const winscale = scalefactor / pixel_ratio; - const renderer = new mod.WebGLRenderer({ - antialias: true, - canvas: canvas, - context: context, - powerPreference: "high-performance" - }); - renderer.setClearColor("#ffffff"); - const [swidth, sheight] = [ - winscale * width, - winscale * height +function get_body_size() { + const bodyStyle = window.getComputedStyle(document.body); + const width_padding = parseInt(bodyStyle.paddingLeft, 10) + parseInt(bodyStyle.paddingRight, 10) + parseInt(bodyStyle.marginLeft, 10) + parseInt(bodyStyle.marginRight, 10); + const height_padding = parseInt(bodyStyle.paddingTop, 10) + parseInt(bodyStyle.paddingBottom, 10) + parseInt(bodyStyle.marginTop, 10) + parseInt(bodyStyle.marginBottom, 10); + const width = window.innerWidth - width_padding; + const height = window.innerHeight - height_padding; + return [ + width, + height ]; - renderer._width = width; - renderer._height = height; - canvas.width = Math.floor(width * scalefactor); - canvas.height = Math.floor(height * scalefactor); - canvas.style.width = swidth + "px"; - canvas.style.height = sheight + "px"; - renderer.setViewport(0, 0, swidth, sheight); - const mouse_callback = (x, y)=>comm.notify({ +} +function add_canvas_events(screen, comm, resize_to_body) { + const { canvas , winscale } = screen; + function mouse_callback(event) { + const [x, y] = events2unitless(screen, event); + comm.notify({ mouseposition: [ x, y ] }); + } const notify_mouse_throttled = throttle_function(mouse_callback, 40); function mousemove(event) { - var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) / winscale; - var y = (event.clientY - rect.top) / winscale; - notify_mouse_throttled(x, y); + notify_mouse_throttled(event); return false; } canvas.addEventListener("mousemove", mousemove); @@ -21318,15 +21297,11 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit canvas.addEventListener("contextmenu", (e)=>e.preventDefault()); canvas.addEventListener("focusout", contextmenu); function resize_callback() { - const bodyStyle = window.getComputedStyle(document.body); - const width_padding = parseInt(bodyStyle.paddingLeft, 10) + parseInt(bodyStyle.paddingRight, 10) + parseInt(bodyStyle.marginLeft, 10) + parseInt(bodyStyle.marginRight, 10); - const height_padding = parseInt(bodyStyle.paddingTop, 10) + parseInt(bodyStyle.paddingBottom, 10) + parseInt(bodyStyle.marginTop, 10) + parseInt(bodyStyle.marginBottom, 10); - const width = (window.innerWidth - width_padding) * pixelRatio; - const height = (window.innerHeight - height_padding) * pixelRatio; + const [width, height] = get_body_size(); comm.notify({ resize: [ - width, - height + width / winscale, + height / winscale ] }); } @@ -21335,8 +21310,61 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit window.addEventListener("resize", (event)=>resize_callback_throttled()); resize_callback_throttled(); } +} +function threejs_module(canvas) { + let context = canvas.getContext("webgl2", { + preserveDrawingBuffer: true + }); + if (!context) { + console.warn("WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)"); + context = canvas.getContext("webgl", { + preserveDrawingBuffer: true + }); + } + if (!context) { + return; + } + const renderer = new mod.WebGLRenderer({ + antialias: true, + canvas: canvas, + context: context, + powerPreference: "high-performance" + }); + renderer.setClearColor("#ffffff"); return renderer; } +function set_render_size(screen, width, height) { + const { renderer , canvas , scalefactor , winscale } = screen; + const [swidth, sheight] = [ + winscale * width, + winscale * height + ]; + renderer._width = width; + renderer._height = height; + canvas.width = Math.floor(width * scalefactor); + canvas.height = Math.floor(height * scalefactor); + canvas.style.width = swidth + "px"; + canvas.style.height = sheight + "px"; + renderer.setViewport(0, 0, swidth, sheight); + add_picking_target(screen); + return; +} +function add_picking_target(screen) { + const { picking_target , canvas } = screen; + const [w, h] = [ + canvas.width, + canvas.height + ]; + if (picking_target) { + if (picking_target.width == w && picking_target.height == h) { + return; + } else { + picking_target.dispose(); + } + } + screen.picking_target = new mod.WebGLRenderTarget(w, h); + return; +} function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height, texture_atlas_obs, fps, resize_to_body, px_per_unit, scalefactor) { if (!scalefactor) { scalefactor = window.devicePixelRatio || 1.0; @@ -21344,34 +21372,32 @@ function create_scene(wrapper, canvas, canvas_width, scenes, comm, width, height if (!px_per_unit) { px_per_unit = scalefactor; } - const renderer = threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor); + const renderer = threejs_module(canvas); TEXTURE_ATLAS[0] = texture_atlas_obs; - if (renderer) { - const camera = new mod.PerspectiveCamera(45, 1, 0, 100); - camera.updateProjectionMatrix(); - const size = new mod.Vector2(); - renderer.getDrawingBufferSize(size); - const picking_target = new mod.WebGLRenderTarget(size.x, size.y); - const screen = { - renderer, - picking_target, - camera, - fps, - canvas, - px_per_unit, - scalefactor - }; - const three_scene = deserialize_scene(scenes, screen); - start_renderloop(three_scene); - const pixel_ratio = window.devicePixelRatio || 1.0; - const winscale = scalefactor / pixel_ratio; - canvas_width.on((w_h)=>{ - renderer.setSize(Math.round(winscale * w_h[0]), Math.round(winscale * w_h[1])); - }); - } else { + if (!renderer) { const warning = getWebGLErrorMessage(); wrapper.appendChild(warning); } + const camera = new mod.PerspectiveCamera(45, 1, 0, 100); + camera.updateProjectionMatrix(); + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; + const screen = { + renderer, + camera, + fps, + canvas, + px_per_unit, + scalefactor, + winscale + }; + add_canvas_events(screen, comm, resize_to_body); + set_render_size(screen, width, height); + const three_scene = deserialize_scene(scenes, screen); + start_renderloop(three_scene); + canvas_width.on((w_h)=>{ + set_render_size(screen, ...w_h); + }); } function set_picking_uniforms(scene, last_id, picking, picked_plots, plots, id_to_plot) { scene.children.forEach((plot, index)=>{ @@ -21400,8 +21426,20 @@ function set_picking_uniforms(scene, last_id, picking, picked_plots, plots, id_t }); return next_id; } -function pick_native(scene, x, y, w, h) { - const { renderer , picking_target } = scene.screen; +function pick_native(scene, _x, _y, _w, _h) { + const { renderer , picking_target , px_per_unit } = scene.screen; + [_x, _y, _w, _h] = [ + _x, + _y, + _w, + _h + ].map((x)=>Math.round(x * px_per_unit)); + const [x, y, w, h] = [ + _x, + _y, + _w, + _h + ]; renderer.setRenderTarget(picking_target); set_picking_uniforms(scene, 1, true); render_scene(scene, true); @@ -21542,17 +21580,17 @@ function register_popup(popup, scene, plots_to_pick, callback) { } const { canvas } = scene.screen; canvas.addEventListener("mousedown", (event)=>{ - if (!popup.classList.contains("show")) { - popup.classList.add("show"); - } - popup.style.left = event.pageX + "px"; - popup.style.top = event.pageY + "px"; - const [x, y] = event2scene_pixel(scene, event); + const [x, y] = events2unitless(scene.screen, event); const [_, picks] = pick_native(scene, x, y, 1, 1); if (picks.length == 1) { const [plot, index] = picks[0]; if (plots_to_pick.has(plot.plot_uuid)) { const result = callback(plot, index); + if (!popup.classList.contains("show")) { + popup.classList.add("show"); + } + popup.style.left = event.pageX + "px"; + popup.style.top = event.pageY + "px"; if (typeof result === "string" || result instanceof String) { popup.innerText = result; } else { @@ -21582,12 +21620,12 @@ window.WGL = { plot_cache, delete_scenes, create_scene, - event2scene_pixel, + events2unitless, on_next_insert, register_popup, render_scene }; -export { deserialize_scene as deserialize_scene, threejs_module as threejs_module, start_renderloop as start_renderloop, delete_plots as delete_plots, insert_plot as insert_plot, find_plots as find_plots, delete_scene as delete_scene, find_scene as find_scene, scene_cache as scene_cache, plot_cache as plot_cache, delete_scenes as delete_scenes, create_scene as create_scene, event2scene_pixel as event2scene_pixel, on_next_insert as on_next_insert }; +export { deserialize_scene as deserialize_scene, threejs_module as threejs_module, start_renderloop as start_renderloop, delete_plots as delete_plots, insert_plot as insert_plot, find_plots as find_plots, delete_scene as delete_scene, find_scene as find_scene, scene_cache as scene_cache, plot_cache as plot_cache, delete_scenes as delete_scenes, create_scene as create_scene, events2unitless as events2unitless, on_next_insert as on_next_insert }; export { render_scene as render_scene }; export { pick_native as pick_native }; export { pick_closest as pick_closest }; diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index 50bfcce60b7..2f6786aff23 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -15,7 +15,7 @@ import { find_scene, } from "./Serialization.js"; -import { event2scene_pixel } from "./Camera.js"; +import { events2unitless } from "./Camera.js"; window.THREE = THREE; @@ -110,54 +110,38 @@ function throttle_function(func, delay) { return inner_throttle; } -function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit, scalefactor) { - let context = canvas.getContext("webgl2", { - preserveDrawingBuffer: true, - }); - if (!context) { - console.warn( - "WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)" - ); - context = canvas.getContext("webgl", { - preserveDrawingBuffer: true, - }); - } - if (!context) { - // Sigh, safari or something - // we return nothing which will be handled by caller - return; - } - const pixel_ratio = window.devicePixelRatio || 1.0; - const winscale = scalefactor / pixel_ratio; - const renderer = new THREE.WebGLRenderer({ - antialias: true, - canvas: canvas, - context: context, - powerPreference: "high-performance", - }); - - renderer.setClearColor("#ffffff"); - const [swidth, sheight] = [winscale * width, winscale * height]; +function get_body_size() { + const bodyStyle = window.getComputedStyle(document.body); + // Subtract padding that is added by VSCode + const width_padding = + parseInt(bodyStyle.paddingLeft, 10) + + parseInt(bodyStyle.paddingRight, 10) + + parseInt(bodyStyle.marginLeft, 10) + + parseInt(bodyStyle.marginRight, 10); + const height_padding = + parseInt(bodyStyle.paddingTop, 10) + + parseInt(bodyStyle.paddingBottom, 10) + + parseInt(bodyStyle.marginTop, 10) + + parseInt(bodyStyle.marginBottom, 10); + const width = (window.innerWidth - width_padding); + const height = (window.innerHeight - height_padding); + return [width, height]; +} - renderer._width = width; - renderer._height = height; - canvas.width = Math.floor(width * scalefactor); - canvas.height = Math.floor(height * scalefactor); - canvas.style.width = swidth + "px"; - canvas.style.height = sheight + "px"; - renderer.setViewport(0, 0, swidth, sheight); - const mouse_callback = (x, y) => comm.notify({ mouseposition: [x, y] }); +function add_canvas_events(screen, comm, resize_to_body) { + const { canvas, winscale } = screen; + function mouse_callback(event) { + const [x, y] = events2unitless(screen, event); + comm.notify({ mouseposition: [x, y] }); + } const notify_mouse_throttled = throttle_function(mouse_callback, 40); function mousemove(event) { - var rect = canvas.getBoundingClientRect(); - var x = (event.clientX - rect.left) / winscale; - var y = (event.clientY - rect.top) / winscale; - notify_mouse_throttled(x, y); + notify_mouse_throttled(event); return false; } @@ -223,34 +207,92 @@ function threejs_module(canvas, comm, width, height, resize_to_body, px_per_unit canvas.addEventListener("focusout", contextmenu); function resize_callback() { - const bodyStyle = window.getComputedStyle(document.body); - // Subtract padding that is added by VSCode - const width_padding = - parseInt(bodyStyle.paddingLeft, 10) + - parseInt(bodyStyle.paddingRight, 10) + - parseInt(bodyStyle.marginLeft, 10) + - parseInt(bodyStyle.marginRight, 10); - const height_padding = - parseInt(bodyStyle.paddingTop, 10) + - parseInt(bodyStyle.paddingBottom, 10) + - parseInt(bodyStyle.marginTop, 10) + - parseInt(bodyStyle.marginBottom, 10); - const width = (window.innerWidth - width_padding) * pixelRatio; - const height = (window.innerHeight - height_padding) * pixelRatio; - + const [width, height] = get_body_size(); // Send the resize event to Julia - comm.notify({ resize: [width, height] }); + comm.notify({ resize: [width / winscale, height / winscale] }); } if (resize_to_body) { - const resize_callback_throttled = throttle_function(resize_callback, 100); - window.addEventListener("resize", (event) => resize_callback_throttled()); + const resize_callback_throttled = throttle_function( + resize_callback, + 100 + ); + window.addEventListener("resize", (event) => + resize_callback_throttled() + ); // Fire the resize event once at the start to auto-size our window resize_callback_throttled(); } +} + +function threejs_module(canvas) { + + let context = canvas.getContext("webgl2", { + preserveDrawingBuffer: true, + }); + if (!context) { + console.warn( + "WebGL 2.0 not supported by browser, falling back to WebGL 1.0 (Volume plots will not work)" + ); + context = canvas.getContext("webgl", { + preserveDrawingBuffer: true, + }); + } + if (!context) { + // Sigh, safari or something + // we return nothing which will be handled by caller + return; + } + + const renderer = new THREE.WebGLRenderer({ + antialias: true, + canvas: canvas, + context: context, + powerPreference: "high-performance", + }); + + renderer.setClearColor("#ffffff"); return renderer; } +function set_render_size(screen, width, height) { + const { renderer, canvas, scalefactor, winscale } = screen; + const [swidth, sheight] = [winscale * width, winscale * height]; + renderer._width = width; + renderer._height = height; + canvas.width = Math.floor(width * scalefactor); + canvas.height = Math.floor(height * scalefactor); + canvas.style.width = swidth + "px"; + canvas.style.height = sheight + "px"; + renderer.setViewport(0, 0, swidth, sheight); + add_picking_target(screen); + return; +} + +function add_picking_target(screen) { + const { picking_target, canvas } = screen; + const [w, h] = [canvas.width, canvas.height]; + if (picking_target) { + if (picking_target.width == w && picking_target.height == h) { + return + } else { + picking_target.dispose(); + } + } + // BIG TODO here... + // We should only make the picking target as big as the area we're picking + // e.g. for just the mouse position it should be 1x1 + // Or we should just always bind the target and render to it in one pass + // 1) One Pass: + // Only works on WebGL 2.0, which is still not as widely supported + // Also it's a bit more complicated to setup + // 2) Only Area we pick + // It's currently not as easy to change the offset + area of the camera + // So, we'll need to make that easier first + screen.picking_target = new THREE.WebGLRenderTarget(w, h); + return; +} + function create_scene( wrapper, canvas, @@ -272,57 +314,40 @@ function create_scene( px_per_unit = scalefactor; } - const renderer = threejs_module( - canvas, - comm, - width, - height, - resize_to_body, - px_per_unit, - scalefactor - ); + const renderer = threejs_module(canvas); + TEXTURE_ATLAS[0] = texture_atlas_obs; - if (renderer) { - const camera = new THREE.PerspectiveCamera(45, 1, 0, 100); - camera.updateProjectionMatrix(); - const size = new THREE.Vector2(); - renderer.getDrawingBufferSize(size); - // BIG TODO here... - // We should only make the picking target as big as the area we're picking - // e.g. for just the mouse position it should be 1x1 - // Or we should just always bind the target and render to it in one pass - // 1) One Pass: - // Only works on WebGL 2.0, which is still not as widely supported - // Also it's a bit more complicated to setup - // 2) Only Area we pick - // It's currently not as easy to change the offset + area of the camera - // So, we'll need to make that easier first - const picking_target = new THREE.WebGLRenderTarget(size.x, size.y); - const screen = { - renderer, - picking_target, - camera, - fps, - canvas, - px_per_unit, - scalefactor, - }; - - const three_scene = deserialize_scene(scenes, screen); - - start_renderloop(three_scene); - const pixel_ratio = window.devicePixelRatio || 1.0; - const winscale = scalefactor / pixel_ratio; - canvas_width.on((w_h) => { - // `renderer.setSize` correctly updates `canvas` dimensions - renderer.setSize(Math.round(winscale * w_h[0]), Math.round(winscale * w_h[1])); - }); - } else { + if (!renderer) { const warning = getWebGLErrorMessage(); // wrapper.removeChild(canvas) wrapper.appendChild(warning); } + + const camera = new THREE.PerspectiveCamera(45, 1, 0, 100); + camera.updateProjectionMatrix(); + const pixel_ratio = window.devicePixelRatio || 1.0; + const winscale = scalefactor / pixel_ratio; + const screen = { + renderer, + camera, + fps, + canvas, + px_per_unit, + scalefactor, + winscale, + }; + add_canvas_events(screen, comm, resize_to_body); + set_render_size(screen, width, height); + + const three_scene = deserialize_scene(scenes, screen); + + start_renderloop(three_scene); + + canvas_width.on((w_h) => { + // `renderer.setSize` correctly updates `canvas` dimensions + set_render_size(screen, ...w_h); + }); } function set_picking_uniforms( @@ -366,14 +391,24 @@ function set_picking_uniforms( return next_id; } -export function pick_native(scene, x, y, w, h) { - const { renderer, picking_target } = scene.screen; +/** + * + * @param {*} scene + * @param {*} x in scene unitless pixel space + * @param {*} y in scene unitless pixel space + * @param {*} w in scene unitless pixel space + * @param {*} h in scene unitless pixel space + * @returns + */ +export function pick_native(scene, _x, _y, _w, _h) { + const { renderer, picking_target, px_per_unit } = scene.screen; + [_x, _y, _w, _h] = [_x, _y, _w, _h].map((x) => Math.round(x * px_per_unit)); + const [x, y, w, h] = [_x, _y, _w, _h]; // render the scene renderer.setRenderTarget(picking_target); set_picking_uniforms(scene, 1, true); render_scene(scene, true); renderer.setRenderTarget(null); // reset render target - const nbytes = w * h * 4; const pixel_bytes = new Uint8Array(nbytes); //read the pixel @@ -385,6 +420,8 @@ export function pick_native(scene, x, y, w, h) { h, // height pixel_bytes ); + + const picked_plots = {}; const picked_plots_array = []; @@ -510,17 +547,17 @@ export function register_popup(popup, scene, plots_to_pick, callback) { } const { canvas } = scene.screen; canvas.addEventListener("mousedown", (event) => { - if (!popup.classList.contains("show")) { - popup.classList.add("show"); - } - popup.style.left = event.pageX + "px"; - popup.style.top = event.pageY + "px"; - const [x, y] = event2scene_pixel(scene, event); + const [x, y] = events2unitless(scene.screen, event); const [_, picks] = pick_native(scene, x, y, 1, 1); if (picks.length == 1) { const [plot, index] = picks[0]; if (plots_to_pick.has(plot.plot_uuid)) { const result = callback(plot, index); + if (!popup.classList.contains("show")) { + popup.classList.add("show"); + } + popup.style.left = event.pageX + "px"; + popup.style.top = event.pageY + "px"; if (typeof result === "string" || result instanceof String) { popup.innerText = result; } else { @@ -551,7 +588,7 @@ window.WGL = { plot_cache, delete_scenes, create_scene, - event2scene_pixel, + events2unitless, on_next_insert, register_popup, render_scene, @@ -570,6 +607,6 @@ export { plot_cache, delete_scenes, create_scene, - event2scene_pixel, + events2unitless, on_next_insert, }; diff --git a/src/display.jl b/src/display.jl index d8f35953bee..154fd152692 100644 --- a/src/display.jl +++ b/src/display.jl @@ -141,10 +141,15 @@ function Base.display(figlike::FigureLike; backend=current_backend(), end # We show inline if explicitely requested or if automatic and we can actually show something inline! + scene = get_scene(figlike) if (inline === true || inline === automatic) && can_show_inline(backend) + # We can't forward the screenconfig to show, but show uses the current screen if there is any + # We use that, to create a screen before show and rely on show picking up that screen + screen = getscreen(backend, scene; screen_config...) + push_screen!(scene, screen) Core.invoke(display, Tuple{Any}, figlike) # In WGLMakie, we need to wait for the display being done - screen = getscreen(get_scene(figlike)) + screen = getscreen(scene) wait_for_display(screen) return screen else @@ -156,7 +161,6 @@ function Base.display(figlike::FigureLike; backend=current_backend(), If this wasn't set on purpose, call `Makie.inline!()` to restore the default. """ end - scene = get_scene(figlike) update && update_state_before_display!(figlike) screen = getscreen(backend, scene; screen_config...) display(screen, scene) From 72987d5203f823a2aabef592c62a21b492a9122a Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 29 Aug 2023 17:04:59 +0200 Subject: [PATCH 28/28] fix line updates --- WGLMakie/src/Lines.js | 14 ++++++++------ WGLMakie/src/wglmakie.bundled.js | 14 +++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/WGLMakie/src/Lines.js b/WGLMakie/src/Lines.js index 6db0cec3a8e..d1a454e6bcc 100644 --- a/WGLMakie/src/Lines.js +++ b/WGLMakie/src/Lines.js @@ -171,9 +171,6 @@ function create_line_material(uniforms, attributes) { function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { const skip_elems = is_segments ? 2 * ndim : ndim; const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); - if (!is_segments) { - buffer.count = points.length / ndim - 1; - } geometry.setAttribute( attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0) @@ -233,6 +230,7 @@ function attach_updates(mesh, buffers, attributes, is_segments) { const ndims = new_points.type_length; const new_line_points = new_points.flat; const old_count = buff.array.length; + const new_count = new_line_points.length / ndims; if (old_count < new_line_points.length) { mesh.geometry.dispose(); geometry = create_line_instance_geometry(); @@ -246,10 +244,11 @@ function attach_updates(mesh, buffers, attributes, is_segments) { mesh.geometry = geometry; buffers[name] = buff; } else { - buff.set(new_line_points, 0); + buff.set(new_line_points); } - // buff.updateRange.count = new_line_points.length / ndims; - geometry.instanceCount = new_line_points.length / ndims; + const ls_factor = is_segments ? 2 : 1; + const offset = is_segments ? 0 : 1; + mesh.geometry.instanceCount = (new_count / ls_factor) - offset; buff.needsUpdate = true; mesh.needsUpdate = true; }); @@ -271,6 +270,9 @@ export function _create_line(line_data, is_segments) { ); const mesh = new THREE.Mesh(geometry, material); + const offset = is_segments ? 0 : 1; + const new_count = geometry.attributes.linepoint_start.count; + mesh.geometry.instanceCount = new_count - offset; attach_updates(mesh, buffers, line_data.attributes, is_segments); return mesh; } diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index c08957576e7..53966c7d860 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20743,9 +20743,6 @@ function create_line_material(uniforms, attributes) { function attach_interleaved_line_buffer(attr_name, geometry, points, ndim, is_segments) { const skip_elems = is_segments ? 2 * ndim : ndim; const buffer = new THREE.InstancedInterleavedBuffer(points, skip_elems, 1); - if (!is_segments) { - buffer.count = points.length / ndim - 1; - } geometry.setAttribute(attr_name + "_start", new THREE.InterleavedBufferAttribute(buffer, ndim, 0)); geometry.setAttribute(attr_name + "_end", new THREE.InterleavedBufferAttribute(buffer, ndim, ndim)); return buffer; @@ -20794,6 +20791,7 @@ function attach_updates(mesh, buffers, attributes, is_segments) { const ndims = new_points.type_length; const new_line_points = new_points.flat; const old_count = buff.array.length; + const new_count = new_line_points.length / ndims; if (old_count < new_line_points.length) { mesh.geometry.dispose(); geometry = create_line_instance_geometry(); @@ -20801,9 +20799,11 @@ function attach_updates(mesh, buffers, attributes, is_segments) { mesh.geometry = geometry; buffers[name] = buff; } else { - buff.set(new_line_points, 0); + buff.set(new_line_points); } - geometry.instanceCount = new_line_points.length / ndims; + const ls_factor = is_segments ? 2 : 1; + const offset = is_segments ? 0 : 1; + mesh.geometry.instanceCount = new_count / ls_factor - offset; buff.needsUpdate = true; mesh.needsUpdate = true; }); @@ -20815,6 +20815,10 @@ function _create_line(line_data, is_segments) { create_line_buffers(geometry, buffers, line_data.attributes, is_segments); const material = create_line_material(line_data.uniforms, geometry.attributes); const mesh = new THREE.Mesh(geometry, material); + const offset = is_segments ? 0 : 1; + const new_count = geometry.attributes.linepoint_start.count; + mesh.geometry.instanceCount = new_count - offset; + console.log(mesh.geometry); attach_updates(mesh, buffers, line_data.attributes, is_segments); return mesh; }