potree-core
Version:
Potree wrapper for three.js applications
1 lines • 268 kB
JavaScript
import*as e from"three";var t={324:(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});const n="precision highp float;\r\nprecision highp int;\r\n\r\n// Uniforms for screen size, and texture sampler\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform sampler2D map;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\t// Calculate pixel offsets\r\n\tfloat dx = 1.0 / screenWidth;\r\n\tfloat dy = 1.0 / screenHeight;\r\n\r\n\t// Average the color of the 9 surrounding pixels\r\n\tvec3 color = texture2D(map, vUv + vec2(-dx, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, -dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2(-dx, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, 0.0)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2(-dx, dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( 0.0, dy)).rgb;\r\n\tcolor += texture2D(map, vUv + vec2( dx, dy)).rgb;\r\n\r\n\t// Set the output color with alpha = 1.0\r\n\tgl_FragColor = vec4(color / 9.0, 1.0);\r\n}\r\n"},652:(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});const n="// Vertex shader for blur effect.\r\nprecision highp float; // Use high precision for floats.\r\nprecision highp int; // Use high precision for ints.\r\n\r\nattribute vec3 position; // Vertex position.\r\nattribute vec2 uv; // Texture coordinate.\r\n\r\nuniform mat4 modelViewMatrix; // Model-view transformation.\r\nuniform mat4 projectionMatrix; // Projection transformation.\r\n\r\nvarying vec2 vUv; // Pass uv coordinates to fragment shader.\r\n\r\nvoid main() {\r\n\t// Pass the texture coordinate.\r\n\tvUv = uv;\r\n\r\n\t// Compute the vertex position.\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n}"},42:(e,t,i)=>{i.d(t,{A:()=>n});const n="// Adapted from the EDL shader code from Christian Boucheny in Cloud Compare\r\n// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL\r\n\r\nprecision highp float;\r\nprecision highp int;\r\n\r\n// Uniforms\r\nuniform float screenWidth; // The width of the screen (or render target) in pixels.\r\nuniform float screenHeight; // The height of the screen in pixels.\r\nuniform vec2 neighbours[NEIGHBOUR_COUNT]; // Predefined offsets for neighbor sampling.\r\nuniform float edlStrength; // Strength factor for the Eye Dome Lighting (EDL) effect.\r\nuniform float radius; // Radius used to determine neighbor distance.\r\nuniform float opacity; // Global opacity for shaded output.\r\nuniform sampler2D colorMap; // Texture containing both color data and depth (in its alpha channel).\r\n\r\n// Projection matrix used to reconstruct regular depth from log depth.\r\nuniform mat4 uProj;\r\n\r\n// Far plane distance, used to reconstruct logarithmic depth buffer values.\r\nuniform float far;\r\n\r\n// Wether the renderer is using a logarithmic depth buffer.\r\nuniform bool useLogDepth;\r\n\r\n// Orthographic camera flag.\r\nuniform bool useOrthographicCamera;\r\n\r\n// Varying variable passed from the vertex shader:\r\nin vec2 vUv; // Texture coordinates for the current fragment.\r\n\r\nout vec4 fragColor;\r\n\r\n// Function to compute the shading response based on depth differences:\r\nfloat response(const float depth) {\r\n\t// Convert the radius from pixels to texture coordinate space.\r\n\tvec2 uvRadius = vec2(radius / screenWidth, radius / screenHeight);\r\n\tfloat sum = 0.0;\r\n\t\r\n\t// Iterate over all neighbor offsets.\r\n\tfor (int i = 0; i < NEIGHBOUR_COUNT; i++) {\r\n\t\t// Calculate the texture coordinate for the neighbor.\r\n\t\tvec2 uvNeighbor = vUv + uvRadius * neighbours[i];\r\n\t\t// Retrieve the neighbor's depth value from the alpha channel of the texture.\r\n\t\tfloat neighbourDepth = texture(colorMap, uvNeighbor).a;\r\n\t\t\r\n\t\t// Background marker: upstream Potree clears alpha to 1.0 and treats it as background.\r\n\t\t// Alpha stores log2(linearDepth), so alpha==1.0 could theoretically collide with real geometry at linearDepth==2.0.\r\n\t\t// We keep this convention for visual parity with upstream.\r\n\t\tneighbourDepth = (neighbourDepth == 1.0) ? 0.0 : neighbourDepth;\r\n\t\t\r\n\t\t// Check if the neighbor has a valid depth.\r\n\t\tif (neighbourDepth != 0.0) {\r\n\t\t\t// If the current depth is zero, add a high value to emphasize the effect;\r\n\t\t\t// otherwise, add the positive difference between current and neighbor depth.\r\n\t\t\tsum += (depth == 0.0) ? 100.0 : max(0.0, depth - neighbourDepth);\r\n\t\t}\r\n\t}\r\n\t\r\n\t// Compute the average response over all neighbors.\r\n\treturn sum / float(NEIGHBOUR_COUNT);\r\n}\r\n\r\nvoid main() {\r\n\t// Sample the texture at the current fragment's coordinates.\r\n\tvec4 color = texture(colorMap, vUv);\r\n\t\r\n\t// Use the alpha channel as the depth value.\r\n\tfloat depth = color.a;\r\n\t// Treat alpha==1.0 as background (see comment in response()).\r\n\tdepth = (depth == 1.0) ? 0.0 : depth;\r\n\t\r\n\t// Compute the depth difference response using neighbor sampling.\r\n\tfloat res = response(depth);\r\n\t\r\n\t// Determine the shading factor using the EDL strength and a scaling constant.\r\n\tfloat factor = edlStrength * 300.0;\r\n\t// Compute the shading value with an exponential decay function.\r\n\tfloat shade = exp(-res * factor);\r\n\t\r\n\t// Discard fragments with no valid depth.\r\n\t// (Keeps behavior close to upstream: background is cleared and not composited.)\r\n\tif (depth == 0.0) {\r\n\t\tdiscard;\r\n\t}\r\n\t\r\n\t// Output the final color by combining the original color with the shading effect, and applying the set opacity.\r\n\tfragColor = vec4(color.rgb * shade, opacity);\r\n\r\n\t// Reconstruct linear depth from the stored log2(lenearDepth) value.\r\n\tfloat dl = pow(2.0, depth);\r\n\t\r\n\tif(useLogDepth && !useOrthographicCamera) {\r\n\t\t// Logarithmic depth buffer: write depth in the same format as three.js\r\n\t\t// logarithmicDepthBuffer, which uses:\r\n\t\t// vFlagDepth = clipPos.w + 1.0.\r\n\t\t// logDepthBufFC = 2.0 / log(far + 1.0).\r\n\t\t// gl_FragDepth = log2(vFlagDepth) * logDepthBufFC * 0.5;\r\n\t\t// Simplifies to: log2(linearDepth + 1.0) / log2(far + 1.0)\r\n\t\tgl_FragDepth = log2(dl + 1.0) / log2(far + 1.0);\r\n\t} else {\r\n\t\t// Standard hyperbolic depth buffer.\r\n\t\tvec4 dp = uProj * vec4(0.0, 0.0, -dl, 1.0);\r\n\t\tfloat pz = dp.z / dp.w;\r\n\t\tgl_FragDepth = (pz + 1.0) / 2.0;\r\n\t}\r\n}\r\n"},370:(e,t,i)=>{i.d(t,{A:()=>n});const n="precision highp float;\r\n\r\nin vec3 position;\r\nin vec2 uv;\r\n\r\nuniform mat4 projectionMatrix;\r\nuniform mat4 modelViewMatrix;\r\n\r\nout vec2 vUv;\r\n\r\nvoid main() {\r\n\t// Assign the UV coordinates from the vertex data to vUv\r\n\tvUv = uv;\r\n\r\n\t// Compute the model-view position of the vertex\r\n\tvec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\r\n\r\n\t// Project the computed position onto the screen\r\n\tgl_Position = projectionMatrix * mvPosition;\r\n}"},650:(e,t,i)=>{i.d(t,{A:()=>n});const n="// Set precision for floats and ints\r\nprecision highp float;\r\nprecision highp int;\r\n\r\n// Uniforms for camera, projection and point parameters\r\nuniform mat4 viewMatrix;\r\nuniform vec3 cameraPosition;\r\nuniform mat4 projectionMatrix;\r\nuniform float opacity;\r\nuniform bool useOrthographicCamera;\r\nuniform float blendHardness;\r\nuniform float blendDepthSupplement;\r\nuniform float fov;\r\nuniform float spacing;\r\nuniform float pcIndex;\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform float far;\r\nuniform sampler2D depthMap;\r\n\r\nout vec4 fragColor;\r\n\r\n#ifdef highlight_point\r\n\t// Color used to highlight a point\r\n\tuniform vec4 highlightedPointColor;\r\n#endif\r\n\r\n#ifdef new_format\r\n\tin vec4 vColor;\r\n#else\r\n\tin vec3 vColor;\r\n#endif\r\n\r\n#if !defined(color_type_point_index)\r\n\t// Opacity attribute when not using point index color type\r\n\tin float vOpacity;\r\n#endif\r\n\r\n#if defined(weighted_splats)\r\n\t// Linear depth value for weighted splats\r\n\tin float vLinearDepth;\r\n#endif\r\n\r\n\r\n\r\nin vec3 vViewPosition;\r\n#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\t// Radius for point shapes\r\n\tin float vRadius;\r\n#endif\r\n\r\n#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\t// Normal for Phong shading\r\n\tin vec3 vNormal;\r\n#endif\r\n\r\n#ifdef highlight_point\r\n\t// Highlight flag for the point\r\n\tin float vHighlight;\r\n#endif\r\n\r\nconst float specularStrength = 1.0;\r\n\r\nvoid main() {\r\n\t// Choose the proper color format\r\n\t#ifdef new_format\r\n\t\tvec3 actualColor = vColor.xyz;\r\n\t#else\r\n\t\tvec3 actualColor = vColor;\r\n\t#endif\r\n\tvec3 color = actualColor;\r\n\r\n\t// Precompute normalized point coordinate if needed\r\n\t#if defined(circle_point_shape) || defined(paraboloid_point_shape) || defined(weighted_splats)\r\n\t\tvec2 pc = 2.0 * gl_PointCoord - 1.0;\r\n\t#endif\r\n\r\n\t// Discard fragments outside circle for certain shapes\r\n\t#if defined(circle_point_shape) || defined(weighted_splats)\r\n\t\tif(dot(pc, pc) > 1.0) discard;\r\n\t#endif\r\n\r\n\t// Depth comparison for weighted splats\r\n\t#if defined(weighted_splats)\r\n\t\tvec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight);\r\n\t\tif(vLinearDepth > texture(depthMap, uv).r + vRadius + blendDepthSupplement) discard;\r\n\t#endif\r\n\r\n\t// Initialize fragment color and opacity\r\n\t#if defined(weighted_splats)\r\n\t\tfloat wx = 2.0 * length(pc);\r\n\t\tfloat w = exp(-wx * wx * 0.5);\r\n\t\tfragColor = vec4(color * w, w);\r\n\t#elif defined(color_type_point_index)\r\n\t\tfragColor = vec4(color, pcIndex / 255.0);\r\n\t#else\r\n\t\tfragColor = vec4(color, vOpacity);\r\n\t#endif\r\n\r\n\t// Lighting calculations for Phong shading\r\n\t#if defined(color_type_phong)\r\n\t\t#if MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0\r\n\t\t\tvec3 normal = normalize(vNormal);\r\n\t\t\tnormal.z = abs(normal.z);\r\n\t\t\tvec3 viewDir = normalize(vViewPosition);\r\n\t\t#endif\r\n\r\n\t\t#if MAX_POINT_LIGHTS > 0\r\n\t\t\tvec3 pointDiffuse = vec3(0.0);\r\n\t\t\t// Loop through each point light\r\n\t\t\tfor(int i = 0; i < MAX_POINT_LIGHTS; i++) {\r\n\t\t\t\tvec4 lPos = viewMatrix * vec4(pointLightPosition[i], 1.0);\r\n\t\t\t\tvec3 lVector = normalize(lPos.xyz + vViewPosition);\r\n\t\t\t\tfloat lDistance = (pointLightDistance[i] > 0.0)\r\n\t\t\t\t\t? 1.0 - min(length(lVector)/pointLightDistance[i], 1.0)\r\n\t\t\t\t\t: 1.0;\r\n\t\t\t\tfloat dotVal = dot(normal, lVector);\r\n\t\t\t\t#ifdef WRAP_AROUND\r\n\t\t\t\t\t// Use wrap around lighting if enabled\r\n\t\t\t\t\tfloat fullW = max(dotVal, 0.0);\r\n\t\t\t\t\tfloat halfW = max(0.5 * dotVal + 0.5, 0.0);\r\n\t\t\t\t\tfloat diffuseW = mix(fullW, halfW, wrapRGB);\r\n\t\t\t\t#else\r\n\t\t\t\t\tfloat diffuseW = max(dotVal, 0.0);\r\n\t\t\t\t#endif\r\n\t\t\t\tpointDiffuse += diffuse * pointLightColor[i] * diffuseW * lDistance;\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t#if MAX_DIR_LIGHTS > 0\r\n\t\t\tvec3 dirDiffuse = vec3(0.0);\r\n\t\t\tvec3 dirSpecular = vec3(0.0);\r\n\t\t\t// Loop through each directional light\r\n\t\t\tfor(int i = 0; i < MAX_DIR_LIGHTS; i++) {\r\n\t\t\t\tvec4 lDir = viewMatrix * vec4(directionalLightDirection[i], 0.0);\r\n\t\t\t\tvec3 dVector = normalize(lDir.xyz);\r\n\t\t\t\tfloat dotVal = dot(normal, dVector);\r\n\t\t\t\t#ifdef WRAP_AROUND\r\n\t\t\t\t\tfloat fullW = max(dotVal, 0.0);\r\n\t\t\t\t\tfloat halfW = max(0.5 * dotVal + 0.5, 0.0);\r\n\t\t\t\t\tfloat diffuseW = mix(fullW, halfW, wrapRGB);\r\n\t\t\t\t#else\r\n\t\t\t\t\tfloat diffuseW = max(dotVal, 0.0);\r\n\t\t\t\t#endif\r\n\t\t\t\tdirDiffuse += diffuse * directionalLightColor[i] * diffuseW;\r\n\t\t\t\tvec3 halfVec = normalize(dVector + viewDir);\r\n\t\t\t\tfloat specW = specularStrength * max(pow(max(dot(normal, halfVec), 0.0), shininess), 0.0);\r\n\t\t\t\tfloat normFactor = (shininess + 2.0) / 8.0;\r\n\t\t\t\tvec3 schlick = specular + (vec3(1.0)-specular)*pow(max(1.0-dot(dVector, halfVec), 0.0), 5.0);\r\n\t\t\t\tdirSpecular += schlick * directionalLightColor[i] * specW * diffuseW * normFactor;\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t// Combine lighting contributions from both light types\r\n\t\tvec3 totalDiffuse = vec3(0.0);\r\n\t\tvec3 totalSpecular = vec3(0.0);\r\n\t\t#if MAX_POINT_LIGHTS > 0\r\n\t\t\ttotalDiffuse += pointDiffuse;\r\n\t\t#endif\r\n\t\t#if MAX_DIR_LIGHTS > 0\r\n\t\t\ttotalDiffuse += dirDiffuse;\r\n\t\t\ttotalSpecular += dirSpecular;\r\n\t\t#endif\r\n\t\tfragColor.rgb = fragColor.rgb * (emissive + totalDiffuse + ambientLightColor * ambient) + totalSpecular;\r\n\t#endif\r\n\r\n\t// Compute depth from view position\r\n\tvec4 pos = vec4(vViewPosition, 1.0);\r\n\t#if defined(paraboloid_point_shape)\r\n\t\tif(!useOrthographicCamera){\r\n\t\t\t// Adjust depth based on point shape\r\n\t\t\tpos.z += -dot(pc, pc) * vRadius;\r\n\t\t}\r\n\t#endif\r\n\r\n\tfloat linearDepth = -pos.z;\r\n\tvec4 clipPos = projectionMatrix * pos;\r\n\tclipPos /= clipPos.w;\r\n\r\n\t// When using an orthographic camera, paraboloid correction is not applied,\r\n\t// so use the GPU-compluted default depth (gl_FragCoord.z).\r\n\tif(useOrthographicCamera){\r\n\t\t// Orthographic camera: use the GPU-computed default depth.\r\n\t\t// When using an orthographic camera, Three.js does not use `logarithmicDepthBuffer` either.\r\n\t\tgl_FragDepth = gl_FragCoord.z;\r\n\t}else{\r\n\t\t#if defined(use_log_depth)\r\n\t\t\t// Logarithmic depth\r\n\t\t\tgl_FragDepth = log2(linearDepth + 1.0) * log(2.0) / log(far + 1.0);\r\n\t\t#else\r\n\t\t\t// Use the GPU-computed default depth.\r\n\t\t\tgl_FragDepth = gl_FragCoord.z;\r\n\t\t#endif\r\n\t}\r\n\r\n\t#if defined(color_type_depth)\r\n\t\t// Render depth information into color channels\r\n\t\tfragColor.r = linearDepth;\r\n\t\tfragColor.g = clipPos.z;\r\n\t#endif\r\n\r\n\t#if defined(use_edl)\r\n\t\t// For EDL, store log2(linearDepth) in alpha.\r\n\t\t// This is recomputed here (rather than in VS) so it matches per-fragment depth\r\n\t\t// adjustments such as paraboloid point shape.\r\n\t\tfragColor.a = log2(max(linearDepth, 1e-6));\r\n\t#endif\r\n\r\n\t#if defined(highlight_point)\r\n\t\t// Override color for highlighted points\r\n\t\tif(vHighlight > 0.0) {\r\n\t\t\tfragColor = highlightedPointColor;\r\n\t\t}\r\n\t#endif\r\n}\r\n"},26:(e,t,i)=>{i.d(t,{A:()=>n});const n="precision highp float;\r\nprecision highp int;\r\n\r\n#define max_clip_boxes 30 // Maximum number of clipping boxes\r\n#define max_clip_spheres 30 // Maximum number of clipping spheres\r\n#define max_clip_planes 30 // Maximum number of clipping planes\r\n\r\n// Input Attributes\r\nin vec3 position;\r\nin vec3 normal;\r\nin float intensity;\r\nin float classification;\r\nin float returnNumber;\r\nin float numberOfReturns;\r\nin float pointSourceID;\r\nin vec4 indices;\r\n\r\n\r\n// Uniforms\r\nuniform mat4 modelMatrix;\r\nuniform mat4 modelViewMatrix;\r\nuniform mat4 projectionMatrix;\r\nuniform mat4 viewMatrix;\r\nuniform mat3 normalMatrix;\r\n\r\nuniform float pcIndex;\r\n\r\nuniform float screenWidth;\r\nuniform float screenHeight;\r\nuniform float fov;\r\nuniform float spacing;\r\nuniform float viewScale;\r\n\r\nuniform bool useOrthographicCamera;\r\nuniform float orthoWidth;\r\nuniform float orthoHeight;\r\n\r\n#if defined use_clip_box\r\n\tuniform mat4 clipBoxes[max_clip_boxes]; // Clipping box transforms\r\n#endif\r\n\r\n#if defined use_clip_sphere\r\n\tuniform vec4 clipSpheres[max_clip_spheres]; // Clipping spheres: xyz = center, w = radius\r\n\tuniform float clipSphereCount;\r\n#endif\r\n\r\n#if defined use_clip_plane\r\n\tuniform vec4 clipPlanes[max_clip_planes]; // Clipping planes: xyz = normal, w = constant\r\n\tuniform float clipPlaneCount;\r\n#endif\r\n\r\nuniform float heightMin;\r\nuniform float heightMax;\r\nuniform float size; // Base pixel size\r\nuniform float minSize; // Minimum point size\r\nuniform float maxSize; // Maximum point size\r\nuniform float octreeSize;\r\nuniform vec3 bbSize;\r\nuniform vec3 uColor;\r\nuniform float opacity;\r\nuniform float clipBoxCount;\r\nuniform float level;\r\nuniform float vnStart;\r\nuniform bool isLeafNode;\r\n\r\nuniform float filterByNormalThreshold;\r\nuniform vec2 intensityRange;\r\nuniform float opacityAttenuation;\r\nuniform float intensityGamma;\r\nuniform float intensityContrast;\r\nuniform float intensityBrightness;\r\nuniform float rgbGamma;\r\nuniform float rgbContrast;\r\nuniform float rgbBrightness;\r\nuniform float transition;\r\nuniform float wRGB;\r\nuniform float wIntensity;\r\nuniform float wElevation;\r\nuniform float wClassification;\r\nuniform float wReturnNumber;\r\nuniform float wSourceID;\r\n\r\nuniform sampler2D visibleNodes;\r\nuniform sampler2D gradient;\r\nuniform sampler2D classificationLUT;\r\nuniform sampler2D depthMap;\r\n\r\n#ifdef highlight_point\r\n\tuniform vec3 highlightedPointCoordinate;\r\n\tuniform bool enablePointHighlighting;\r\n\tuniform float highlightedPointScale;\r\n#endif\r\n\r\n#ifdef new_format\r\n\tin vec4 rgba;\r\n\tout vec4 vColor;\r\n#else\r\n\tin vec3 color;\r\n\tout vec3 vColor;\r\n#endif\r\n\r\n#if !defined(color_type_point_index)\r\n\tout float vOpacity;\r\n#endif\r\n\r\n#if defined(weighted_splats)\r\n\tout float vLinearDepth;\r\n#endif\r\n\r\n\r\n\r\nout vec3 vViewPosition;\r\n\r\n#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\tout float vRadius;\r\n#endif\r\n\r\n#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\tout vec3 vNormal;\r\n#endif\r\n\r\n#ifdef highlight_point\r\n\tout float vHighlight;\r\n#endif\r\n\r\n\r\n// OCTREE LOD FUNCTIONS\r\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_octree)\r\n\r\n// Returns count of bits set up to a given index\r\nint numberOfOnes(int number, int index) {\r\n\tint numOnes = 0;\r\n\tint tmp = 128;\r\n\tfor (int i = 7; i >= 0; i--) {\r\n\t\tif (number >= tmp) {\r\n\t\t\tnumber -= tmp;\r\n\t\t\tif (i <= index) { numOnes++; }\r\n\t\t}\r\n\t\ttmp /= 2;\r\n\t}\r\n\treturn numOnes;\r\n}\r\n\r\n// Checks if bit at specific index is set\r\nbool isBitSet(int number, int index){\r\n\treturn ((number >> index) & 1) != 0;\r\n}\r\n\r\n// Computes level-of-detail based on octree visibility\r\nfloat getLOD() {\r\n\tvec3 offset = vec3(0.0);\r\n\tint iOffset = int(vnStart);\r\n\tfloat depth = level;\r\n\r\n\tfor (float i = 0.0; i <= 30.0; i++) {\r\n\t\tfloat nodeSizeAtLevel = octreeSize / pow(2.0, i + level);\r\n\t\tvec3 index3d = floor((position - offset) / nodeSizeAtLevel + 0.5);\r\n\t\tint index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));\r\n\t\t\r\n\t\tvec4 value = texture(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));\r\n\t\tint mask = int(round(value.r * 255.0));\r\n\r\n\t\tif (isBitSet(mask, index)) {\r\n\t\t\tint advanceG = int(round(value.g * 255.0)) * 256;\r\n\t\t\tint advanceB = int(round(value.b * 255.0));\r\n\t\t\tint advanceChild = numberOfOnes(mask, index - 1);\r\n\t\t\tint advance = advanceG + advanceB + advanceChild;\r\n\t\t\tiOffset += advance;\r\n\t\t\tdepth++;\r\n\t\t} else {\r\n\t\t\treturn depth;\r\n\t\t}\r\n\t\toffset += (vec3(1.0) * nodeSizeAtLevel * 0.5) * index3d;\r\n\t}\r\n\treturn depth;\r\n}\r\n\r\nfloat getPointSizeAttenuation() {\r\n\treturn 0.5 * pow(2.0, getLOD());\r\n}\r\n\r\n#endif\r\n\r\n\r\n// KD-TREE LOD FUNCTIONS\r\n\r\n#if (defined(adaptive_point_size) || defined(color_type_lod)) && defined(tree_type_kdtree)\r\n\r\nfloat getLOD() {\r\n\tvec3 offset = vec3(0.0);\r\n\tfloat intOffset = 0.0;\r\n\tfloat depth = 0.0;\r\n\tvec3 size_ = bbSize;\r\n\tvec3 pos = position;\r\n\t\t\r\n\tfor (float i = 0.0; i <= 1000.0; i++) {\r\n\t\tvec4 value = texture(visibleNodes, vec2(intOffset / 2048.0, 0.0));\r\n\t\tint children = int(value.r * 255.0);\r\n\t\tfloat next = value.g * 255.0;\r\n\t\tint split = int(value.b * 255.0);\r\n\t\t\r\n\t\tif (next == 0.0) { return depth; }\r\n\t\t\r\n\t\tvec3 splitv = (split == 1) ? vec3(1.0, 0.0, 0.0) :\r\n\t\t\t\t\t (split == 2) ? vec3(0.0, 1.0, 0.0) :\r\n\t\t\t\t\t (split == 4) ? vec3(0.0, 0.0, 1.0) : vec3(0.0);\r\n\t\t\r\n\t\tintOffset += next;\r\n\t\t\r\n\t\tfloat factor = length((pos * splitv) / size_);\r\n\t\tif (factor < 0.5) {\r\n\t\t\tif (children == 0 || children == 2) { return depth; }\r\n\t\t} else {\r\n\t\t\tpos -= size_ * splitv * 0.5;\r\n\t\t\tif (children == 0 || children == 1) { return depth; }\r\n\t\t\tif (children == 3) { intOffset += 1.0; }\r\n\t\t}\r\n\t\tsize_ *= ((1.0 - (splitv + 1.0) / 2.0) + 0.5);\r\n\t\tdepth++;\r\n\t}\r\n\treturn depth;\t\r\n}\r\n\r\nfloat getPointSizeAttenuation() {\r\n\treturn 0.5 * pow(1.3, getLOD());\r\n}\r\n\r\n#endif\r\n\r\n\r\n// COLOR/BRIGHTNESS FUNCTIONS\r\n\r\nfloat getContrastFactor(float contrast) {\r\n\treturn 1.0158730158730156 * (contrast + 1.0) / (1.0158730158730156 - contrast);\r\n}\r\n\r\n#ifndef new_format\r\n// Adjusts RGB values with gamma, contrast and brightness factors\r\nvec3 getRGB() {\r\n\t#if defined(use_rgb_gamma_contrast_brightness)\r\n\t\tvec3 rgb = pow(color, vec3(rgbGamma));\r\n\t\trgb += rgbBrightness;\r\n\t\trgb = (rgb - 0.5) * getContrastFactor(rgbContrast) + 0.5;\r\n\t\treturn clamp(rgb, 0.0, 1.0);\r\n\t#else\r\n\t\treturn color;\r\n\t#endif\r\n}\r\n#endif\r\n\r\n// Adjusts intensity value based on settings\r\nfloat getIntensity() {\r\n\tfloat w = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\r\n\tw = pow(w, intensityGamma) + intensityBrightness;\r\n\tw = (w - 0.5) * getContrastFactor(intensityContrast) + 0.5;\r\n\treturn clamp(w, 0.0, 1.0);\r\n}\r\n\r\n// Maps elevation to a gradient color\r\nvec3 getElevation() {\r\n\tvec4 world = modelMatrix * vec4(position, 1.0);\r\n\tfloat w = (world.z - heightMin) / (heightMax - heightMin);\r\n\treturn texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n}\r\n\r\n// Gets classification color and transparency from texture LUT\r\nvec4 getClassification() {\r\n\tvec2 uv = vec2(classification / 255.0, 0.5);\r\n\treturn texture(classificationLUT, uv);\r\n}\r\n\r\n// Returns color based on number of returns and return number\r\nvec3 getReturnNumber() {\r\n\treturn (numberOfReturns == 1.0) ? vec3(1.0, 1.0, 0.0) :\r\n\t\t (returnNumber == 1.0) ? vec3(1.0, 0.0, 0.0) :\r\n\t\t (returnNumber == numberOfReturns) ? vec3(0.0, 0.0, 1.0) :\r\n\t\t\t\t\t\t\t\t\t\tvec3(0.0, 1.0, 0.0);\r\n}\r\n\r\n// Gets source ID color from gradient\r\nvec3 getSourceID() {\r\n\tfloat w = mod(pointSourceID, 10.0) / 10.0;\r\n\treturn texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n}\r\n\r\n#ifndef new_format\r\n// Combines multiple color sources into one composite color\r\nvec3 getCompositeColor() {\r\n\tvec3 c = wRGB * getRGB();\r\n\tfloat w = wRGB;\r\n\tc += wIntensity * getIntensity() * vec3(1.0);\r\n\tw += wIntensity;\r\n\tc += wElevation * getElevation();\r\n\tw += wElevation;\r\n\tc += wReturnNumber * getReturnNumber();\r\n\tw += wReturnNumber;\r\n\tc += wSourceID * getSourceID();\r\n\tw += wSourceID;\r\n\r\n\tvec4 cl = wClassification * getClassification();\r\n\tc += cl.a * cl.rgb;\r\n\tw += wClassification * cl.a;\r\n\r\n\tc /= w;\r\n\tif (w == 0.0) {\r\n\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0);\r\n\t}\r\n\treturn c;\r\n}\r\n#endif\r\n\r\n#ifdef new_format\r\n// sRGB conversion functions\r\nvec4 fromLinear(vec4 linearRGB) {\r\n\tbvec4 cutoff = lessThan(linearRGB, vec4(0.0031308));\r\n\treturn mix(linearRGB * vec4(12.92), vec4(1.055) * pow(linearRGB, vec4(1.0/2.4)) - vec4(0.055), cutoff);\r\n} \r\nvec4 toLinear(vec4 sRGB) {\r\n\tbvec4 cutoff = lessThan(sRGB, vec4(0.04045));\r\n\treturn mix(sRGB/vec4(12.92), pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4)), cutoff);\r\n}\r\n#else\r\nvec3 fromLinear(vec3 linearRGB) {\r\n\tbvec3 cutoff = lessThan(linearRGB, vec3(0.0031308));\r\n\treturn mix(linearRGB * vec3(12.92), vec3(1.055) * pow(linearRGB, vec3(1.0/2.4)) - vec3(0.055), cutoff);\r\n}\r\nvec3 toLinear(vec3 sRGB) {\r\n\tbvec3 cutoff = lessThan(sRGB, vec3(0.04045));\r\n\treturn mix(sRGB/vec3(12.92), pow((sRGB + vec3(0.055))/vec3(1.055), vec3(2.4)), cutoff);\r\n}\r\n#endif\r\n\r\nvoid main() {\r\n\t// Compute model-view position and projected position\r\n\tvec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\r\n\tgl_Position = projectionMatrix * mvPosition;\r\n\tvViewPosition = mvPosition.xyz;\r\n\r\n\t#if defined weighted_splats\r\n\t\tvLinearDepth = gl_Position.w;\r\n\t#endif\r\n\r\n\t#if defined(color_type_phong) && (MAX_POINT_LIGHTS > 0 || MAX_DIR_LIGHTS > 0)\r\n\t\tvNormal = normalize(normalMatrix * normal);\r\n\t#endif\r\n\r\n\t// EDL alpha (log2(linearDepth)) is written in the fragment shader so it can\r\n\t// account for per-fragment depth adjustments (e.g. paraboloid point shape).\r\n\r\n\r\n\t// POINT SIZE COMPUTATION\r\n\tfloat tanHalfFOV = tan(fov * 0.5);\r\n\tfloat projFactor = -0.5 * screenHeight / (tanHalfFOV * mvPosition.z);\r\n\t// Scale compensation based on transformation difference \r\n\tfloat scale = length(modelViewMatrix * vec4(0, 0, 0, 1) - modelViewMatrix * vec4(spacing, 0, 0, 1)) / spacing;\r\n\tprojFactor *= scale;\r\n\t\r\n\tfloat pointSize = 1.0;\r\n\t#if defined fixed_point_size\r\n\t\tpointSize = size;\r\n\t#elif defined attenuated_point_size\r\n\t\tpointSize = useOrthographicCamera ? size : size * spacing * projFactor;\r\n\t#elif defined adaptive_point_size\r\n\t\tfloat worldSpaceSize = 2.0 * size * spacing / getPointSizeAttenuation();\r\n\t\tpointSize = useOrthographicCamera ? (worldSpaceSize / orthoWidth) * screenWidth : worldSpaceSize * projFactor;\r\n\t#endif\r\n\r\n\tpointSize = clamp(pointSize, minSize, maxSize);\r\n\t#if defined(weighted_splats) || defined(paraboloid_point_shape)\r\n\t\tvRadius = pointSize / projFactor;\r\n\t#endif\r\n\t\r\n\tpointSize *= viewScale;\r\n\tgl_PointSize = pointSize;\r\n\r\n\r\n\t// HIGHLIGHTING\r\n\t#ifdef highlight_point\r\n\t\tvec4 mPosition = modelMatrix * vec4(position, 1.0);\r\n\t\tif (enablePointHighlighting &&\r\n\t\t\tabs(mPosition.x - highlightedPointCoordinate.x) < 0.0001 &&\r\n\t\t\tabs(mPosition.y - highlightedPointCoordinate.y) < 0.0001 &&\r\n\t\t\tabs(mPosition.z - highlightedPointCoordinate.z) < 0.0001) {\r\n\t\t\tvHighlight = 1.0;\r\n\t\t\tgl_PointSize = pointSize * highlightedPointScale;\r\n\t\t} else {\r\n\t\t\tvHighlight = 0.0;\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// OPACITY\r\n\t#ifndef color_type_point_index\r\n\t\t#ifdef attenuated_opacity\r\n\t\t\tvOpacity = opacity * exp(-length(-mvPosition.xyz) / opacityAttenuation);\r\n\t\t#else\r\n\t\t\tvOpacity = opacity;\r\n\t\t#endif\r\n\t#endif\r\n\r\n\r\n\t// NORMAL FILTERING\r\n\t#ifdef use_filter_by_normal\r\n\t\tif(abs((modelViewMatrix * vec4(normal, 0.0)).z) > filterByNormalThreshold) {\r\n\t\t\tgl_Position = vec4(0.0, 0.0, 2.0, 1.0); // Cull point\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// POINT COLOR SELECTION\r\n\t#ifdef new_format\r\n\t\tvColor = rgba;\r\n\t#elif defined color_type_rgb\r\n\t\tvColor = getRGB();\r\n\t#elif defined color_type_height\r\n\t\tvColor = getElevation();\r\n\t#elif defined color_type_rgb_height\r\n\t\tvec3 cHeight = getElevation();\r\n\t\tvColor = mix(getRGB(), cHeight, transition);\r\n\t#elif defined color_type_depth\r\n\t\tfloat linearDepth = -mvPosition.z;\r\n\t\tfloat expDepth = (gl_Position.z / gl_Position.w) * 0.5 + 0.5;\r\n\t\tvColor = vec3(linearDepth, expDepth, 0.0);\r\n\t#elif defined color_type_intensity\r\n\t\tfloat w = getIntensity();\r\n\t\tvColor = vec3(w);\r\n\t#elif defined color_type_intensity_gradient\r\n\t\tfloat w = getIntensity();\r\n\t\tvColor = texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n\t#elif defined color_type_color\r\n\t\tvColor = uColor;\r\n\t#elif defined color_type_lod\r\n\t\tfloat w = getLOD() / 10.0;\r\n\t\tvColor = texture(gradient, vec2(w, 1.0 - w)).rgb;\r\n\t#elif defined color_type_point_index\r\n\t\tvColor = indices.rgb;\r\n\t#elif defined color_type_classification\r\n\t\tvec4 cl = getClassification();\r\n\t\tvColor = cl.rgb;\r\n\t#elif defined color_type_return_number\r\n\t\tvColor = getReturnNumber();\r\n\t#elif defined color_type_source\r\n\t\tvColor = getSourceID();\r\n\t#elif defined color_type_normal\r\n\t\tvColor = (modelMatrix * vec4(normal, 0.0)).xyz;\r\n\t#elif defined color_type_phong\r\n\t\tvColor = color;\r\n\t#elif defined color_type_composite\r\n\t\tvColor = getCompositeColor();\r\n\t#endif\r\n\t\r\n\t#if !defined color_type_composite && defined color_type_classification\r\n\t\tif (getClassification().a == 0.0) {\r\n\t\t\tgl_Position = vec4(100.0, 100.0, 100.0, 0.0); // Cull point if classification alpha is zero\r\n\t\t\treturn;\r\n\t\t}\r\n\t#endif\r\n\r\n\r\n\t// CLIPPING\r\n\t#if defined use_clip_box || defined use_clip_sphere || defined use_clip_plane\r\n\t\tbool insideAny = false;\r\n\t\tbool hasVolumeClip = false;\r\n\r\n\t\t#if defined use_clip_box\r\n\t\t\thasVolumeClip = true;\r\n\t\t\tfor (int i = 0; i < max_clip_boxes; i++) {\r\n\t\t\t\tif (i == int(clipBoxCount)) break;\r\n\t\t\t\tvec4 clipPosition = clipBoxes[i] * modelMatrix * vec4(position, 1.0);\r\n\t\t\t\tbool inside = abs(clipPosition.x) <= 0.5 && abs(clipPosition.y) <= 0.5 && abs(clipPosition.z) <= 0.5;\r\n\t\t\t\tinsideAny = insideAny || inside;\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t#if defined use_clip_sphere\r\n\t\t\thasVolumeClip = true;\r\n\t\t\tvec4 modelPos = modelMatrix * vec4(position, 1.0);\r\n\t\t\tfor (int i = 0; i < max_clip_spheres; i++) {\r\n\t\t\t\tif (i == int(clipSphereCount)) break;\r\n\t\t\t\tfloat dist = distance(modelPos.xyz, clipSpheres[i].xyz);\r\n\t\t\t\tinsideAny = insideAny || (dist <= clipSpheres[i].w);\r\n\t\t\t}\r\n\t\t#endif\r\n\r\n\t\t// When only clip planes are used, start as inside\r\n\t\tif (!hasVolumeClip) insideAny = true;\r\n\r\n\t\t#if defined use_clip_plane\r\n\t\t\t// Point must be on positive side of all planes\r\n\t\t\tvec4 clipWorldPos = modelMatrix * vec4(position, 1.0);\r\n\t\t\tfor (int i = 0; i < max_clip_planes; i++) {\r\n\t\t\t\tif (i == int(clipPlaneCount)) break;\r\n\t\t\t\tfloat d = dot(clipPlanes[i].xyz, clipWorldPos.xyz) + clipPlanes[i].w;\r\n\t\t\t\t// Even if a point was accepted by a volume clip,\r\n\t\t\t\t// it is rejected when it falls on the negative side of a plane.\r\n\t\t\t\tif (d < 0.0) { insideAny = false; break; }\r\n\t\t\t}\r\n\t\t#endif\r\n\t\t\r\n\t\t#if defined clip_outside\r\n\t\t\tif (!insideAny) { gl_Position = vec4(1000.0); } // Cull if outside any clip volume\r\n\t\t#elif defined clip_inside\r\n\t\t\tif (insideAny) { gl_Position = vec4(1000.0); } // Cull if inside any clip volume\r\n\t\t#elif defined clip_highlight_inside && !defined(color_type_depth)\r\n\t\t\tif (!insideAny) { /* additional processing if needed */ }\r\n\t\t#endif\r\n\r\n\t\t#if defined clip_highlight_inside\r\n\t\t\tif (insideAny) { vColor.r += 0.5; }\r\n\t\t#endif\r\n\t#endif\r\n\r\n\r\n\t// COLOR ENCODING ADJUSTMENTS\r\n\t#if defined(output_color_encoding_sRGB) && defined(input_color_encoding_linear) && !defined(color_type_point_index)\r\n\t\tvColor = toLinear(vColor);\r\n\t#endif\r\n\r\n\t#if defined(output_color_encoding_linear) && defined(input_color_encoding_sRGB) && !defined(color_type_point_index)\r\n\t\tvColor = fromLinear(vColor);\r\n\t#endif\r\n}\r\n"},512:e=>{e.exports=function(e,t,i,n){var r=self||window;try{try{var o;try{o=new r.Blob([e])}catch(t){(o=new(r.BlobBuilder||r.WebKitBlobBuilder||r.MozBlobBuilder||r.MSBlobBuilder)).append(e),o=o.getBlob()}var a=r.URL||r.webkitURL,s=a.createObjectURL(o),l=new r[t](s,i);return a.revokeObjectURL(s),l}catch(n){return new r[t]("data:application/javascript,".concat(encodeURIComponent(e)),i)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new r[t](n,i)}}},290:(e,t,i)=>{i.d(t,{A:()=>r});var n=i(512);function r(){return n('const e={DATA_TYPE_DOUBLE:{ordinal:0,name:"double",size:8},DATA_TYPE_FLOAT:{ordinal:1,name:"float",size:4},DATA_TYPE_INT8:{ordinal:2,name:"int8",size:1},DATA_TYPE_UINT8:{ordinal:3,name:"uint8",size:1},DATA_TYPE_INT16:{ordinal:4,name:"int16",size:2},DATA_TYPE_UINT16:{ordinal:5,name:"uint16",size:2},DATA_TYPE_INT32:{ordinal:6,name:"int32",size:4},DATA_TYPE_UINT32:{ordinal:7,name:"uint32",size:4},DATA_TYPE_INT64:{ordinal:8,name:"int64",size:8},DATA_TYPE_UINT64:{ordinal:9,name:"uint64",size:8}};let t=0;for(let n in e)e[t]=e[n],t++;class n{constructor(e,t,n,i=[1/0,-1/0]){this.name=e,this.type=t,this.numElements=n,this.range=i,this.byteSize=this.numElements*this.type.size,this.description=""}}new n("POSITION_CARTESIAN",e.DATA_TYPE_FLOAT,3),new n("COLOR_PACKED",e.DATA_TYPE_INT8,4),new n("COLOR_PACKED",e.DATA_TYPE_INT8,4),new n("COLOR_PACKED",e.DATA_TYPE_INT8,3),new n("NORMAL_FLOATS",e.DATA_TYPE_FLOAT,3),new n("INTENSITY",e.DATA_TYPE_UINT16,1),new n("CLASSIFICATION",e.DATA_TYPE_UINT8,1),new n("NORMAL_SPHEREMAPPED",e.DATA_TYPE_UINT8,2),new n("NORMAL_OCT16",e.DATA_TYPE_UINT8,2),new n("NORMAL",e.DATA_TYPE_FLOAT,3),new n("RETURN_NUMBER",e.DATA_TYPE_UINT8,1),new n("NUMBER_OF_RETURNS",e.DATA_TYPE_UINT8,1),new n("SOURCE_ID",e.DATA_TYPE_UINT16,1),new n("INDICES",e.DATA_TYPE_UINT32,1),new n("SPACING",e.DATA_TYPE_FLOAT,1),new n("GPS_TIME",e.DATA_TYPE_DOUBLE,1);const i=function(){var e=new Int8Array(0);function t(e){this.data=e,this.offset=0}var n=Int32Array.from([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]),i=Int32Array.from([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),a=Int32Array.from([0,3,2,1,0,0,0,0,0,0,3,3,3,3,3,3]),o=Int32Array.from([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),r=Int32Array.from([131072,131076,131075,196610,131072,131076,131075,262145,131072,131076,131075,196610,131072,131076,131075,262149]),s=Int32Array.from([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),l=Int32Array.from([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),c=Int32Array.from([1,5,9,13,17,25,33,41,49,65,81,97,113,145,177,209,241,305,369,497,753,1265,2289,4337,8433,16625]),d=Int32Array.from([2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,7,8,9,10,11,12,13,24]),h=Int16Array.from([0,0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,12,14,24]),f=Int16Array.from([0,0,0,0,0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,24]),u=new Int16Array(2816);function p(e){for(var t=-1,n=16;n>0;)e>>>n!=0&&(t+=n,e>>>=n),n>>=1;return t+e}function m(e,t,n){return 16+t+2*(n<<e)}function g(e,t,n){if(e<n+(2<<t))throw"maxDistance is too small";var i=4+(e-n>>t),a=p(i)-1;return((a-1<<1|i>>a&1)-1<<t)+(1<<t)+n+16}function P(e){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0!=U(e,1)){var t=U(e,3);return 0==t?1:U(e,t)+(1<<t)}return 0}function $(e,t,n){var i=e[t],a=n.accumulator32>>>n.bitOffset,o=e[i+=255&a]>>16,r=65535&e[i];return o<=8?(n.bitOffset+=o,r):(i+=r,i+=(a&(1<<o)-1)>>>8,n.bitOffset+=8+(e[i]>>16),65535&e[i])}function b(e,t,n){n.bitOffset>=16&&(n.accumulator32=n.shortBuffer[n.halfOffset++]<<16|n.accumulator32>>>16,n.bitOffset-=16);var i=$(e,t,n),a=d[i];return n.bitOffset>=16&&(n.accumulator32=n.shortBuffer[n.halfOffset++]<<16|n.accumulator32>>>16,n.bitOffset-=16),c[i]+(a<=16?U(n,a):_(n,a))}function v(e,t){for(var n=e[t];t>0;t--)e[t]=e[t-1];e[0]=n}function y(e,t,n,a,o){o.halfOffset>2030&&N(o),o.bitOffset>=16&&(o.accumulator32=o.shortBuffer[o.halfOffset++]<<16|o.accumulator32>>>16,o.bitOffset-=16);var s=U(o,2);return 1==s?function(e,t,n,i,a){for(var o=new Int32Array(t),r=new Int32Array(4),s=1+p(e-1),l=U(a,2)+1,c=0;c<l;c++){a.bitOffset>=16&&(a.accumulator32=a.shortBuffer[a.halfOffset++]<<16|a.accumulator32>>>16,a.bitOffset-=16);var d=U(a,s);if(d>=t)throw"Can\'t readHuffmanCode";r[c]=d}!function(e,t){for(var n=0;n<t-1;++n)for(var i=n+1;i<t;++i)if(e[n]==e[i])throw"Duplicate simple Huffman code symbol"}(r,l);var h=l;switch(4==l&&(h+=U(a,1)),h){case 1:o[r[0]]=1;break;case 2:o[r[0]]=1,o[r[1]]=1;break;case 3:o[r[0]]=1,o[r[1]]=2,o[r[2]]=2;break;case 4:o[r[0]]=2,o[r[1]]=2,o[r[2]]=2,o[r[3]]=2;break;case 5:o[r[0]]=1,o[r[1]]=2,o[r[2]]=3,o[r[3]]=3}return L(n,i,8,o,t)}(e,t,n,a,o):function(e,t,n,a,o){for(var s=new Int32Array(e),l=new Int32Array(18),c=32,d=0,h=t;h<18&&c>0;h++){var f=i[h];o.bitOffset>=16&&(o.accumulator32=o.shortBuffer[o.halfOffset++]<<16|o.accumulator32>>>16,o.bitOffset-=16);var u=o.accumulator32>>>o.bitOffset&15;o.bitOffset+=r[u]>>16;var p=65535&r[u];l[f]=p,0!=p&&(c-=32>>p,d++)}if(0!=c&&1!=d)throw"Corrupted Huffman code histogram";return function(e,t,n,i){var a=0,o=8,r=0,s=0,l=32768,c=new Int32Array(33);for(L(c,c.length-1,5,e,18);a<t&&l>0;){i.halfOffset>2030&&N(i),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var d=i.accumulator32>>>i.bitOffset&31;i.bitOffset+=c[d]>>16;var h=65535&c[d];if(h<16)r=0,n[a++]=h,0!=h&&(o=h,l-=32768>>h);else{var f=h-14,u=0;16==h&&(u=o),s!=u&&(r=0,s=u);var p=r;r>0&&(r-=2,r<<=f),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var m=(r+=U(i,f)+3)-p;if(a+m>t)throw"symbol + repeatDelta > numSymbols";for(var g=0;g<m;g++)n[a++]=s;0!=s&&(l-=m<<15-s)}}if(0!=l)throw"Unused space";n.fill(0,a,t)}(l,e,s,o),L(n,a,8,s,e)}(t,s,n,a,o)}function X(e,t,i){i.halfOffset>2030&&N(i);var a=P(i)+1;if(1==a)return t.fill(0,0,e),a;i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var o=0;0!=U(i,1)&&(o=U(i,4)+1);var r=a+o,s=n[r+31>>5],l=new Int32Array(s+1),c=l.length-1;y(r,r,l,c,i);for(var d=0;d<e;){i.halfOffset>2030&&N(i),i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);var h=$(l,c,i);if(0==h)t[d]=0,d++;else if(h<=o){i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16);for(var f=(1<<h)+U(i,h);0!=f;){if(d>=e)throw"Corrupted context map";t[d]=0,d++,f--}}else t[d]=h-o,d++}return i.bitOffset>=16&&(i.accumulator32=i.shortBuffer[i.halfOffset++]<<16|i.accumulator32>>>16,i.bitOffset-=16),1==U(i,1)&&function(e,t){for(var n=new Int32Array(256),i=0;i<256;i++)n[i]=i;for(i=0;i<t;i++){var a=255&e[i];e[i]=n[a],0!=a&&v(n,a)}}(t,e),a}function w(e,t,n){var i=e.rings,a=4+2*t;e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16);var o=$(e.blockTrees,2*t,e),r=b(e.blockTrees,2*t+1,e);return 1==o?o=i[a+1]+1:0==o?o=i[a]:o-=2,o>=n&&(o-=n),i[a]=i[a+1],i[a+1]=o,r}function Y(e){e.literalBlockLength=w(e,0,e.numLiteralBlockTypes);var t=e.rings[5];e.contextMapSlice=t<<6,e.literalTreeIdx=255&e.contextMap[e.contextMapSlice];var n=e.contextModes[t];e.contextLookupOffset1=n<<9,e.contextLookupOffset2=e.contextLookupOffset1+256}function Q(e){e.commandBlockLength=w(e,1,e.numCommandBlockTypes),e.commandTreeIdx=e.rings[7]}function x(e){e.distanceBlockLength=w(e,2,e.numDistanceBlockTypes),e.distContextMapSlice=e.rings[9]<<2}function k(e){if(0!=e.inputEnd)return e.nextRunningState=10,void(e.runningState=12);e.literalTreeGroup=new Int32Array(0),e.commandTreeGroup=new Int32Array(0),e.distanceTreeGroup=new Int32Array(0),e.halfOffset>2030&&N(e),function(e){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.inputEnd=U(e,1),e.metaBlockLength=0,e.isUncompressed=0,e.isMetadata=0,0==e.inputEnd||0==U(e,1)){var t=U(e,2)+4;if(7==t){if(e.isMetadata=1,0!=U(e,1))throw"Corrupted reserved bit";var n=U(e,2);if(0==n)return;for(var i=0;i<n;i++){if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==(a=U(e,8))&&i+1==n&&n>1)throw"Exuberant nibble";e.metaBlockLength|=a<<8*i}}else for(i=0;i<t;i++){var a;if(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==(a=U(e,4))&&i+1==t&&t>4)throw"Exuberant nibble";e.metaBlockLength|=a<<4*i}e.metaBlockLength++,0==e.inputEnd&&(e.isUncompressed=U(e,1))}}(e),0==e.metaBlockLength&&0==e.isMetadata||(0!=e.isUncompressed||0!=e.isMetadata?(H(e),e.runningState=0!=e.isMetadata?5:6):e.runningState=3,0==e.isMetadata&&(e.expectedTotalSize+=e.metaBlockLength,e.expectedTotalSize>1<<30&&(e.expectedTotalSize=1<<30),e.ringBufferSize<e.maxRingBufferSize&&function(e){var t=e.maxRingBufferSize;if(t>e.expectedTotalSize){for(var n=e.expectedTotalSize;t>>1>n;)t>>=1;0==e.inputEnd&&t<16384&&e.maxRingBufferSize>=16384&&(t=16384)}if(!(t<=e.ringBufferSize)){var i=new Int8Array(t+37);0!=e.ringBuffer.length&&i.set(e.ringBuffer.subarray(0,0+e.ringBufferSize),0),e.ringBuffer=i,e.ringBufferSize=t}}(e)))}function C(e,t,n){var i=e.blockTrees[2*t];if(n<=1)return e.blockTrees[2*t+1]=i,e.blockTrees[2*t+2]=i,1<<28;var a=n+2;return i+=y(a,a,e.blockTrees,2*t,e),e.blockTrees[2*t+1]=i,i+=y(26,26,e.blockTrees,2*t+1,e),e.blockTrees[2*t+2]=i,b(e.blockTrees,2*t+1,e)}function A(e){e.numLiteralBlockTypes=P(e)+1,e.literalBlockLength=C(e,0,e.numLiteralBlockTypes),e.numCommandBlockTypes=P(e)+1,e.commandBlockLength=C(e,1,e.numCommandBlockTypes),e.numDistanceBlockTypes=P(e)+1,e.distanceBlockLength=C(e,2,e.numDistanceBlockTypes),e.halfOffset>2030&&N(e),e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.distancePostfixBits=U(e,2),e.numDirectDistanceCodes=U(e,4)<<e.distancePostfixBits,e.distancePostfixMask=(1<<e.distancePostfixBits)-1,e.contextModes=new Int8Array(e.numLiteralBlockTypes);for(var t=0;t<e.numLiteralBlockTypes;){for(var n=V(t+96,e.numLiteralBlockTypes);t<n;++t)e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),e.contextModes[t]=U(e,2);e.halfOffset>2030&&N(e)}e.contextMap=new Int8Array(e.numLiteralBlockTypes<<6);var i=X(e.numLiteralBlockTypes<<6,e.contextMap,e);e.trivialLiteralContext=1;for(var a=0;a<e.numLiteralBlockTypes<<6;a++)if(e.contextMap[a]!=a>>6){e.trivialLiteralContext=0;break}e.distContextMap=new Int8Array(e.numDistanceBlockTypes<<2);var o=X(e.numDistanceBlockTypes<<2,e.distContextMap,e);e.literalTreeGroup=I(256,256,i,e),e.commandTreeGroup=I(704,704,e.numCommandBlockTypes,e);var r=m(e.distancePostfixBits,e.numDirectDistanceCodes,24),s=r;1==e.isLargeWindow&&(r=m(e.distancePostfixBits,e.numDirectDistanceCodes,62),s=g(2147483644,e.distancePostfixBits,e.numDirectDistanceCodes)),e.distanceTreeGroup=I(r,s,o,e),function(e,t){for(var n=e.distExtraBits,i=e.distOffset,a=e.distancePostfixBits,o=e.numDirectDistanceCodes,r=1<<a,s=1,l=0,c=16,d=0;d<o;++d)n[c]=0,i[c]=d+1,++c;for(;c<t;){var h=o+((2+l<<s)-4<<a)+1;for(d=0;d<r;++d)n[c]=s,i[c]=h+d,++c;s+=l,l^=1}}(e,s),e.contextMapSlice=0,e.distContextMapSlice=0,e.contextLookupOffset1=512*e.contextModes[0],e.contextLookupOffset2=e.contextLookupOffset1+256,e.literalTreeIdx=0,e.commandTreeIdx=0,e.rings[4]=1,e.rings[5]=0,e.rings[6]=1,e.rings[7]=0,e.rings[8]=1,e.rings[9]=0}function T(e){var t=e.ringBuffer;if(e.metaBlockLength<=0)return F(e),void(e.runningState=2);var n=V(e.ringBufferSize-e.pos,e.metaBlockLength);if(function(e,t,n,i){if(7&e.bitOffset)throw"Unaligned copyBytes";for(;32!=e.bitOffset&&0!=i;)t[n++]=e.accumulator32>>>e.bitOffset,e.bitOffset+=8,i--;if(0!=i){var a=V(W(e),i>>1);if(a>0){var o=e.halfOffset<<1,r=a<<1;t.set(e.byteBuffer.subarray(o,o+r),n),n+=r,i-=r,e.halfOffset+=a}if(0!=i)if(W(e)>0){for(e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16);0!=i;)t[n++]=e.accumulator32>>>e.bitOffset,e.bitOffset+=8,i--;M(e,0)}else for(;i>0;){var s=Z(e.input,t,n,i);if(-1==s)throw"Unexpected end of input";n+=s,i-=s}}}(e,t,e.pos,n),e.metaBlockLength-=n,e.pos+=n,e.pos==e.ringBufferSize)return e.nextRunningState=6,void(e.runningState=12);F(e),e.runningState=2}function B(e){var t=V(e.outputLength-e.outputUsed,e.ringBufferBytesReady-e.ringBufferBytesWritten);return 0!=t&&(e.output.set(e.ringBuffer.subarray(e.ringBufferBytesWritten,e.ringBufferBytesWritten+t),e.outputOffset+e.outputUsed),e.outputUsed+=t,e.ringBufferBytesWritten+=t),e.outputUsed<e.outputLength?1:0}function I(e,t,i,a){for(var o=n[t+31>>5],r=new Int32Array(i+i*o),s=i,l=0;l<i;++l)r[l]=s,s+=y(e,t,r,l,a);return r}function O(e){var t=e.ringBufferSize;return 0!=e.isEager&&(t=V(t,e.ringBufferBytesWritten+e.outputLength-e.outputUsed)),t}function S(t){if(0==t.runningState)throw"Can\'t decompress until initialized";if(11==t.runningState)throw"Can\'t decompress after close";if(1==t.runningState){var n=function(e){var t=e.isLargeWindow;if(e.isLargeWindow=0,e.bitOffset>=16&&(e.accumulator32=e.shortBuffer[e.halfOffset++]<<16|e.accumulator32>>>16,e.bitOffset-=16),0==U(e,1))return 16;var n=U(e,3);return 0!=n?17+n:0!=(n=U(e,3))?1==n?0==t?-1:(e.isLargeWindow=1,1==U(e,1)||(n=U(e,6))<10||n>30?-1:n):8+n:17}(t);if(-1==n)throw"Invalid \'windowBits\' code";t.maxRingBufferSize=1<<n,t.maxBackwardDistance=t.maxRingBufferSize-16,t.runningState=2}for(var i=O(t),r=t.ringBufferSize-1,c=t.ringBuffer;10!=t.runningState;)switch(t.runningState){case 2:if(t.metaBlockLength<0)throw"Invalid metablock length";k(t),i=O(t),r=t.ringBufferSize-1,c=t.ringBuffer;continue;case 3:A(t),t.runningState=4;case 4:if(t.metaBlockLength<=0){t.runningState=2;continue}t.halfOffset>2030&&N(t),0==t.commandBlockLength&&Q(t),t.commandBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var d=$(t.commandTreeGroup,t.commandTreeIdx,t)<<2,h=u[d],f=u[d+1],p=u[d+2];t.distanceCode=u[d+3],t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var m=255&h;t.insertLength=f+(m<=16?U(t,m):_(t,m)),t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),m=h>>8,t.copyLength=p+(m<=16?U(t,m):_(t,m)),t.j=0,t.runningState=7;case 7:if(0!=t.trivialLiteralContext){for(;t.j<t.insertLength;)if(t.halfOffset>2030&&N(t),0==t.literalBlockLength&&Y(t),t.literalBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),c[t.pos]=$(t.literalTreeGroup,t.literalTreeIdx,t),t.pos++,t.j++,t.pos>=i){t.nextRunningState=7,t.runningState=12;break}}else for(var g=255&c[t.pos-1&r],P=255&c[t.pos-2&r];t.j<t.insertLength;){t.halfOffset>2030&&N(t),0==t.literalBlockLength&&Y(t);var b=G[t.contextLookupOffset1+g]|G[t.contextLookupOffset2+P],v=255&t.contextMap[t.contextMapSlice+b];if(t.literalBlockLength--,P=g,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),g=$(t.literalTreeGroup,v,t),c[t.pos]=g,t.pos++,t.j++,t.pos>=i){t.nextRunningState=7,t.runningState=12;break}}if(7!=t.runningState)continue;if(t.metaBlockLength-=t.insertLength,t.metaBlockLength<=0){t.runningState=4;continue}var y=t.distanceCode;if(y<0)t.distance=t.rings[t.distRbIdx];else{t.halfOffset>2030&&N(t),0==t.distanceBlockLength&&x(t),t.distanceBlockLength--,t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16);var X=255&t.distContextMap[t.distContextMapSlice+y];if((y=$(t.distanceTreeGroup,X,t))<16){var w=t.distRbIdx+a[y]&3;if(t.distance=t.rings[w]+o[y],t.distance<0)throw"Negative distance"}else{var C;m=t.distExtraBits[y],t.bitOffset+m<=32?C=U(t,m):(t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),C=m<=16?U(t,m):_(t,m)),t.distance=t.distOffset[y]+(C<<t.distancePostfixBits)}}if(t.maxDistance!=t.maxBackwardDistance&&t.pos<t.maxBackwardDistance?t.maxDistance=t.pos:t.maxDistance=t.maxBackwardDistance,t.distance>t.maxDistance){t.runningState=9;continue}if(y>0&&(t.distRbIdx=t.distRbIdx+1&3,t.rings[t.distRbIdx]=t.distance),t.copyLength>t.metaBlockLength)throw"Invalid backward reference";t.j=0,t.runningState=8;case 8:var I=t.pos-t.distance&r,S=t.pos,q=t.copyLength-t.j,D=I+q,z=S+q;if(D<r&&z<r){if(q<12||D>S&&z>I)for(var L=0;L<q;L+=4)c[S++]=c[I++],c[S++]=c[I++],c[S++]=c[I++],c[S++]=c[I++];else c.copyWithin(S,I,D);t.j+=q,t.metaBlockLength-=q,t.pos+=q}else for(;t.j<t.copyLength;)if(c[t.pos]=c[t.pos-t.distance&r],t.metaBlockLength--,t.pos++,t.j++,t.pos>=i){t.nextRunningState=8,t.runningState=12;break}8==t.runningState&&(t.runningState=4);continue;case 9:if(t.distance>2147483644)throw"Invalid backward reference";if(!(t.copyLength>=4&&t.copyLength<=24))throw"Invalid backward reference";var R=s[t.copyLength],F=t.distance-t.maxDistance-1,W=l[t.copyLength],J=F>>>W;if(R+=(F&(1<<W)-1)*t.copyLength,!(J<121))throw"Invalid backward reference";var K=E(c,t.pos,e,R,t.copyLength,j,J);if(t.pos+=K,t.metaBlockLength-=K,t.pos>=i){t.nextRunningState=4,t.runningState=12;continue}t.runningState=4;continue;case 5:for(;t.metaBlockLength>0;)t.halfOffset>2030&&N(t),t.bitOffset>=16&&(t.accumulator32=t.shortBuffer[t.halfOffset++]<<16|t.accumulator32>>>16,t.bitOffset-=16),U(t,8),t.metaBlockLength--;t.runningState=2;continue;case 6:T(t);continue;case 12:t.ringBufferBytesReady=V(t.pos,t.ringBufferSize),t.runningState=13;case 13:if(0==B(t))return;t.pos>=t.maxBackwardDistance&&(t.maxDistance=t.maxBackwardDistance),t.pos>=t.ringBufferSize&&(t.pos>t.ringBufferSize&&c.copyWithin(0,t.ringBufferSize,t.pos),t.pos&=r,t.ringBufferBytesWritten=0),t.runningState=t.nextRunningState;continue;default:throw"Unexpected state "+t.runningState}if(10==t.runningState){if(t.metaBlockLength<0)throw"Invalid metablock length";H(t),M(t,1)}}!function(e){var t=new Int16Array(24),n=new Int16Array(24);n[0]=2;for(var i=0;i<23;++i)t[i+1]=t[i]+(1<<h[i]),n[i+1]=n[i]+(1<<f[i]);for(var a=0;a<704;++a){var o=a>>>6,r=-4;o>=2&&(o-=2,r=0);var s=(170064>>>2*o&3)<<3|a>>>3&7,l=(156228>>>2*o&3)<<3|7&a,c=n[l],d=r+(c>4?3:c-2),u=4*a;e[u+0]=h[s]|f[l]<<8,e[u+1]=t[s],e[u+2]=n[l],e[u+3]=d}}(u);var j=new function(){this.numTransforms=0,this.triplets=new Int32Array(0),this.prefixSuffixStorage=new Int8Array(0),this.prefixSuffixHeads=new Int32Array(0),this.params=new Int16Array(0),this.numTransforms=121,this.triplets=new Int32Array(363),this.params=new Int16Array(121),this.prefixSuffixStorage=new Int8Array(167),this.prefixSuffixHeads=new Int32Array(51)}(121,167,50);function E(e,t,n,i,a,o,r){var s=t,l=o.triplets,c=o.prefixSuffixStorage,d=o.prefixSuffixHeads,h=3*r,f=l[h],u=l[h+1]