@navaramap/three 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.ts +91 -26
- package/dist/index.js +261 -213
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +31 -31
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +12 -12
- package/src/core/BaseDesc.ts +25 -1
- package/src/core/MeshDesc.ts +2 -1
- package/src/index.ts +174 -77
- package/src/material/enhancer/model/modelBaseEnhancer/shader.ts +2 -2
- package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.ts +2 -2
- package/src/pick/pickHelper.test.ts +182 -55
- package/src/pick/pickHelper.ts +144 -56
- package/src/plugins/AttributionPlugin/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -21390,6 +21390,7 @@ var vk = {
|
|
|
21390
21390
|
ctx;
|
|
21391
21391
|
_instance;
|
|
21392
21392
|
_visible;
|
|
21393
|
+
_destroyed = !1;
|
|
21393
21394
|
constructor(e, t, n = {}) {
|
|
21394
21395
|
super(), this.id = n.id || T(), this._visible = n.visible ?? !0, this.view = e, this.ctx = t;
|
|
21395
21396
|
}
|
|
@@ -21400,7 +21401,10 @@ var vk = {
|
|
|
21400
21401
|
this.emit("needsUpdate");
|
|
21401
21402
|
}
|
|
21402
21403
|
onDestroy() {
|
|
21403
|
-
this._instance = void 0;
|
|
21404
|
+
this._destroyed = !0, this._instance = void 0;
|
|
21405
|
+
}
|
|
21406
|
+
get destroyed() {
|
|
21407
|
+
return this._destroyed;
|
|
21404
21408
|
}
|
|
21405
21409
|
get visible() {
|
|
21406
21410
|
return !!this._visible;
|
|
@@ -22422,7 +22426,7 @@ in float attrBatchId;
|
|
|
22422
22426
|
in vec4 scaleNormalAndCap;
|
|
22423
22427
|
|
|
22424
22428
|
uniform vec2 uMinMaxHeight;
|
|
22425
|
-
out float nvr_vBatchId;
|
|
22429
|
+
flat out float nvr_vBatchId;
|
|
22426
22430
|
|
|
22427
22431
|
${i ? bN : ""}
|
|
22428
22432
|
${ON}
|
|
@@ -22462,7 +22466,7 @@ uniform float nvr_uPickable;
|
|
|
22462
22466
|
uniform bool uIsTexturized;
|
|
22463
22467
|
${hP.fragment.UNIFORM_END}
|
|
22464
22468
|
|
|
22465
|
-
in float nvr_vBatchId;
|
|
22469
|
+
flat in float nvr_vBatchId;
|
|
22466
22470
|
|
|
22467
22471
|
${DN}
|
|
22468
22472
|
|
|
@@ -22797,7 +22801,7 @@ var HP = {
|
|
|
22797
22801
|
i.useRTE && (t.modelViewMatrixRTE && t.modelViewMatrixRTE.value.copy(e), t.u_cameraPositionHigh && t.u_cameraPositionHigh.value.copy(n), t.u_cameraPositionLow && t.u_cameraPositionLow.value.copy(r));
|
|
22798
22802
|
}
|
|
22799
22803
|
};
|
|
22800
|
-
}, WP = "vec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n\n#include <common>\n#include <color_pars_fragment>\n\nuniform vec3 color;\nuniform float nvr_uPickable;\n\nin float nvr_vBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nin float nvr_vShow;\nin float nvr_vOpacity;\n#endif\n\nvoid main() {\n #ifdef USE_BATCH_COLOR_SHOW\n\nif (nvr_vShow < 0.5) {\n discard;\n}\n\nif (nvr_vOpacity <= 0.0) {\n discard;\n}\n\n#endif\n\n vec4 diffuseColor = vec4(color, 1.0);\n #include <clipping_planes_fragment>\n\n #include <color_fragment>\n\n#ifdef USE_BATCH_COLOR_SHOW\n diffuseColor.a *= nvr_vOpacity;\n#endif\n\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n\n if(nvr_uPickable > 0.0) {\n vec3 pickColor = nvr_batchIdToColor(nvr_vBatchId);\n gl_FragColor = vec4(pickColor.xyz, 1.0);\n }\n}", GP = "in float attrBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nout float nvr_vShow;\nout float nvr_vOpacity;\n#endif\n\nin vec4 right_normal_and_texture_coordinate_normalization_y;\n\n#include <common>\n#include <color_pars_vertex>\n#ifdef USE_BATCH_TEXTURE\nuniform sampler2D batchDataTexture;\nin float _batchid;\n\nfloat decodeRGBAToFloat(vec4 rgba) {\n uvec4 bytes = uvec4(rgba * 255.0);\n\n uint value = bytes.r | (bytes.g << 8) | (bytes.b << 16) | (bytes.a << 24);\n\n return uintBitsToFloat(value);\n}\n\nvec2 getBatchTextureCoord(float batchId, float rowIndex) {\n vec2 texSize = vec2(textureSize(batchDataTexture, 0));\n\n \n \n float col = mod(batchId, texSize.x);\n float batchRow = floor(batchId / texSize.x);\n\n float u = (col + 0.5) / texSize.x;\n float v = (batchRow * BATCHED_TEXTURE_ROW_COUNT + rowIndex + 0.5) / texSize.y;\n\n return vec2(u, v);\n}\n\n#ifdef USE_BATCH_COLOR_SHOW\nvec4 getBatchColorShow(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_COLOR_SHOW);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return data;\n}\n#endif\n\n#ifdef USE_BATCH_HEIGHT\nfloat getBatchHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_EXTRUDED_HEIGHT\nfloat getBatchExtrudedHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_EXTRUDED_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_LINE_WIDTH\nfloat getBatchLineWidth(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_LINE_WIDTH);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n#endif\nuniform float uAddHeight;\n\nuniform vec3 minMaxHeightAndWidth;\n\nout float nvr_vBatchId;\n\nvoid main() {\n #include <begin_vertex>\n #include <color_vertex>\n\n #ifdef USE_BATCH_HEIGHT\n float addHeight = 0.; \n#else\n float addHeight = uAddHeight;\n#endif\n float batchLineWidth = -1.0;\n\n #ifdef USE_BATCH_TEXTURE\n float batchId = _batchid;\n\n #ifdef USE_BATCH_COLOR_SHOW\n vec4 batchColor = getBatchColorShow(batchId);\n #ifdef USE_COLOR\n vColor.rgb = batchColor.rgb;\n #endif\n \n float packedByte = clamp(floor(batchColor.a * 255.0 + 0.5), 0.0, 255.0); \n nvr_vShow = step(128.0, packedByte); \n nvr_vOpacity = mod(packedByte, 128.0) / 127.0; \n #endif\n\n #ifdef USE_BATCH_EXTRUDED_HEIGHT\n float extrudedHeight = getBatchExtrudedHeight(batchId);\n addExtrudedHeight = extrudedHeight;\n #endif\n\n #ifdef USE_BATCH_HEIGHT\n float batchHeight = getBatchHeight(batchId);\n addHeight = batchHeight;\n #endif\n\n #ifdef USE_BATCH_LINE_WIDTH\n batchLineWidth = getBatchLineWidth(batchId);\n #endif\n#endif\n\n nvr_vBatchId = attrBatchId;\n\n \n vec2 miterNormal = right_normal_and_texture_coordinate_normalization_y.xy;\n float miterLength = right_normal_and_texture_coordinate_normalization_y.w; \n\n \n \n \n #ifdef USE_BATCH_LINE_WIDTH\n float baseWidth = batchLineWidth >= 0.0 ? batchLineWidth : minMaxHeightAndWidth.z;\n #else\n float baseWidth = minMaxHeightAndWidth.z;\n #endif\n \n \n float lineWidth = baseWidth * (2.0 / 512.0);\n\n \n \n \n \n lineWidth /= projectionMatrix[0][0];\n\n \n vec3 offsetPos = position + vec3(miterNormal * lineWidth * 0.5 * miterLength, 0.0);\n\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(offsetPos, 1.0);\n}", KP = "vec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n\n#include <lights_pars_begin>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n\nuniform vec3 color;\nuniform float nvr_uPickable;\n\nin float nvr_vBatchId;\nin vec3 vNormal;\n\n#ifdef USE_BATCH_COLOR_SHOW\nin float nvr_vShow;\nin float nvr_vOpacity;\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n\n#ifdef GBUFFER_NORMAL_LOCATION\nlayout(location = GBUFFER_NORMAL_LOCATION) out vec4 normalBuffer;\n\n#ifdef NVR_BLENDED\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) 1.0\n#else\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) (roughnessValue)\n#endif\n\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue) normalBuffer = vec4(packNormalToVec2(n), blue, GBUFFER_NORMAL_ALPHA(roughnessValue));\n#else\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue)\n#endif\n\n#ifdef USE_GBUFFER_SELECTIVE_EFFECT\nlayout(location = GBUFFER_EFFECT_ID_LOCATION) out vec4 effectIdBuffer;\n\n#define GBUFFER_WRITE_EFFECT_ID(mask) effectIdBuffer = vec4(mask, 0.0, 0.0, 1.0);\n\n#define GBUFFER_WRITE_EFFECT_ID_ZERO effectIdBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EFFECT_ID(mask)\n#define GBUFFER_WRITE_EFFECT_ID_ZERO\n#endif\n\n#ifdef USE_GBUFFER_EMISSIVE\nlayout(location = GBUFFER_EMISSIVE_LOCATION) out vec4 emissiveBuffer;\n\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb) emissiveBuffer = vec4(emissiveRgb, 1.0);\n\n#define GBUFFER_WRITE_EMISSIVE_ZERO emissiveBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n#define GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_GBUFFER_SHADOW\nlayout(location = GBUFFER_SHADOW_LOCATION) out vec4 shadowBuffer;\n\nfloat nvr_shadowMask = 1.0;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n#define NVR_GBUFFER_UNLIT_FLAG 1.0\n#else\n#define NVR_GBUFFER_UNLIT_FLAG 0.0\n#endif\n\n#define GBUFFER_WRITE_SHADOW shadowBuffer = vec4(1.0 - nvr_shadowMask, NVR_GBUFFER_UNLIT_FLAG, 0.0, 1.0);\n\n#define GBUFFER_WRITE_SHADOW_ZERO shadowBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_SHADOW\n#define GBUFFER_WRITE_SHADOW_ZERO\n#endif\n\n#define GBUFFER_WRITE_EFFECT(mask, emissiveRgb) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n\n#define GBUFFER_WRITE_EFFECT_ID_ONLY(mask) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE_ZERO\n#define GBUFFER_WRITE_EFFECT_ZERO GBUFFER_WRITE_EFFECT_ID_ZERO GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_SELECTIVE_EFFECT\n uniform float uEffectIdsMask;\n uniform vec3 uEmissiveColor;\n uniform float uEmissiveIntensity;\n#endif\n\nvoid main() {\n #ifdef USE_BATCH_COLOR_SHOW\n\nif (nvr_vShow < 0.5) {\n discard;\n}\n\nif (nvr_vOpacity <= 0.0) {\n discard;\n}\n\n#endif\n \n vec4 diffuseColor = vec4(color, 1.);\n #include <clipping_planes_fragment>\n\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = vec3(0.);\n\n #include <color_fragment>\n\n#ifdef USE_BATCH_COLOR_SHOW\n diffuseColor.a *= nvr_vOpacity;\n#endif\n\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <emissivemap_fragment>\n\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n \n outgoingLight = diffuseColor.rgb;\n#endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n\n if(nvr_uPickable > 0.0) {\n vec3 pickColor = nvr_batchIdToColor(nvr_vBatchId);\n gl_FragColor = vec4(pickColor.xyz, 1.0);\n }\n\n #ifndef USE_SHADOWMAP_DEPTH\n GBUFFER_WRITE_NORMAL(vNormal, 0.0, 1.0)\n #ifdef USE_SELECTIVE_EFFECT\n GBUFFER_WRITE_EFFECT(uEffectIdsMask, (diffuseColor.rgb + uEmissiveColor) * uEmissiveIntensity)\n #else\n GBUFFER_WRITE_EFFECT_ZERO\n #endif\n\n \n GBUFFER_WRITE_SHADOW\n #endif\n}", qP = "float nvr_branchFreeTernary(bool comparison, float a, float b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec2 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec2} a Value to return if the comparison is true.\n * @param {vec2} b Value to return if the comparison is false.\n *\n * @returns {vec2} equivalent of comparison ? a : b\n */\nvec2 nvr_branchFreeTernary(bool comparison, vec2 a, vec2 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec3 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec3 nvr_branchFreeTernary(bool comparison, vec3 a, vec3 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec4 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec4 nvr_branchFreeTernary(bool comparison, vec4 a, vec4 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\nfloat nvr_planeDistance(vec4 plane, vec3 point) {\n return (dot(plane.xyz, point) + plane.w);\n}\n\n/**\n * Computes distance from a point to a plane.\n *\n * @name nvr_planeDistance\n * @glslFunction\n *\n * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js\n * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js\n * param {vec3} point A point in the same space as the plane.\n * returns {float} The distance from the point to the plane.\n */\nfloat nvr_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {\n return (dot(planeNormal, point) + planeDistance);\n}\nfloat nvr_metersPerPixel(vec4 positionEC, vec3 viewportAndPixelRatio, vec2 frustumNearFar, vec4 frustumRatio)\n{\n float width = viewportAndPixelRatio.x * viewportAndPixelRatio.z;\n float height = viewportAndPixelRatio.y * viewportAndPixelRatio.z;\n float pixelWidth;\n float pixelHeight;\n\n float top = frustumRatio.x;\n float bottom = frustumRatio.y;\n float right = frustumRatio.z;\n float left = frustumRatio.w;\n\n \n \n \n \n \n \n \n \n \n \n float distanceToPixel = -positionEC.z;\n float inverseNear = 1.0 / frustumNearFar.x;\n float tanTheta = top * inverseNear;\n pixelHeight = 2.0 * distanceToPixel * tanTheta / height;\n tanTheta = right * inverseNear;\n pixelWidth = 2.0 * distanceToPixel * tanTheta / width;\n \n\n float pixelRatio = viewportAndPixelRatio.z;\n\n return max(pixelWidth, pixelHeight) * pixelRatio;\n}\n#ifndef ELLIPSOID_GLSL\n#define ELLIPSOID_GLSL\n\n#define WGS84_A 6378137.0\n#define WGS84_B 6356752.3142451793\n\nconst vec3 WGS84_RADII = vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII = 1.0 / vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII_SQUARED = 1.0 / vec3(WGS84_A * WGS84_A, WGS84_A * WGS84_A, WGS84_B * WGS84_B);\n\nconst float WGS84_E2 = 0.00669438; \nconst float WGS84_E2_SECOND = 0.00673950; \n\nconst float WGS84_FLATTENING = 0.00335281; \nconst float WGS84_FLATTENING_RECIPROCAL = 298.257223563; \n\n#endif\n\nflat out int vHorizonCulled;\n\nbool nvr_horizon_culled(vec3 targetPosition, vec3 cameraPosition) {\n vec3 cameraPositionScaled = cameraPosition * ONE_OVER_WGS84_RADII;\n vec3 targetPositionScaled = targetPosition * ONE_OVER_WGS84_RADII;\n\n vec3 vt = cameraPositionScaled - targetPositionScaled;\n vec3 vc = cameraPositionScaled;\n float a = dot(vc, vc) - 1.0;\n\n return dot(vt, vc) > a;\n}\n\nin float attrBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nout float nvr_vShow;\nout float nvr_vOpacity;\n#endif\n\n#ifdef USE_RTE\n uniform vec3 u_cameraPositionHigh;\nuniform vec3 u_cameraPositionLow;\n\nuniform float u_rteOne;\n\nuniform mat4 modelViewMatrixRTE;\n\nattribute vec3 position_3d_high;\nattribute vec3 position_3d_low;\n attribute vec3 start_3d_high;\n attribute vec3 start_3d_low;\n attribute vec3 end_3d_high;\n attribute vec3 end_3d_low;\n#else\n in vec3 start;\n in vec3 forward_offset;\n#endif\n\nin vec3 start_normal;\nin vec4 end_normal_and_texture_coordinate_normalization_x;\nin vec4 right_normal_and_texture_coordinate_normalization_y;\n\n#include <common>\n#include <color_pars_vertex>\n#include <shadowmap_pars_vertex>\n#ifdef USE_BATCH_TEXTURE\nuniform sampler2D batchDataTexture;\nin float _batchid;\n\nfloat decodeRGBAToFloat(vec4 rgba) {\n uvec4 bytes = uvec4(rgba * 255.0);\n\n uint value = bytes.r | (bytes.g << 8) | (bytes.b << 16) | (bytes.a << 24);\n\n return uintBitsToFloat(value);\n}\n\nvec2 getBatchTextureCoord(float batchId, float rowIndex) {\n vec2 texSize = vec2(textureSize(batchDataTexture, 0));\n\n \n \n float col = mod(batchId, texSize.x);\n float batchRow = floor(batchId / texSize.x);\n\n float u = (col + 0.5) / texSize.x;\n float v = (batchRow * BATCHED_TEXTURE_ROW_COUNT + rowIndex + 0.5) / texSize.y;\n\n return vec2(u, v);\n}\n\n#ifdef USE_BATCH_COLOR_SHOW\nvec4 getBatchColorShow(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_COLOR_SHOW);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return data;\n}\n#endif\n\n#ifdef USE_BATCH_HEIGHT\nfloat getBatchHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_EXTRUDED_HEIGHT\nfloat getBatchExtrudedHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_EXTRUDED_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_LINE_WIDTH\nfloat getBatchLineWidth(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_LINE_WIDTH);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n#endif\n\nuniform vec3 minMaxHeightAndWidth;\nuniform vec3 viewportAndPixelRatio;\nuniform vec2 frustumNearFar;\nuniform vec4 frustumRatio;\nuniform float maxWidth;\nuniform float uAddHeight;\n\nflat out vec4 v_startPlaneNormalEcAndHalfWidth;\nflat out vec3 v_endPlaneNormalEc;\nflat out vec4 v_rightPlaneEC;\nflat out float v_startPlaneOffsetEc;\nflat out float v_endPlaneOffsetEc;\nout vec4 v_endEcAndStartEcX;\nout vec4 v_texcoordNormalizationAndStartEcYZ;\nout vec3 vViewPosition;\nout float nvr_vBatchId;\nout vec3 vNormal;\n\nvoid main() {\n #ifdef USE_RTE\n \n \n \n \n \n \n vec3 segmentStartAbs = start_3d_high + start_3d_low;\n vec3 segmentEndAbs = end_3d_high + end_3d_low;\n if (nvr_horizon_culled(segmentStartAbs, cameraPosition)\n && nvr_horizon_culled(segmentEndAbs, cameraPosition)) {\n vHorizonCulled = 1;\n gl_Position = vec4(0.0);\n return;\n }\n vHorizonCulled = 0;\n #endif\n\n #ifdef USE_RTE\n vec3 highDiff = (position_3d_high - u_cameraPositionHigh) * u_rteOne;\nvec3 lowDiff = position_3d_low - u_cameraPositionLow;\nvec3 transformed = highDiff + lowDiff;\n\nvec3 absTransformed = position_3d_high + position_3d_low;\n \n #else\n #include <begin_vertex>\n #endif\n\n #include <color_vertex>\n\n #ifdef USE_BATCH_HEIGHT\n float addHeight = 0.; \n#else\n float addHeight = uAddHeight;\n#endif\n float batchLineWidth = -1.0;\n\n #ifdef USE_BATCH_TEXTURE\n float batchId = _batchid;\n\n #ifdef USE_BATCH_COLOR_SHOW\n vec4 batchColor = getBatchColorShow(batchId);\n #ifdef USE_COLOR\n vColor.rgb = batchColor.rgb;\n #endif\n \n float packedByte = clamp(floor(batchColor.a * 255.0 + 0.5), 0.0, 255.0); \n nvr_vShow = step(128.0, packedByte); \n nvr_vOpacity = mod(packedByte, 128.0) / 127.0; \n #endif\n\n #ifdef USE_BATCH_EXTRUDED_HEIGHT\n float extrudedHeight = getBatchExtrudedHeight(batchId);\n addExtrudedHeight = extrudedHeight;\n #endif\n\n #ifdef USE_BATCH_HEIGHT\n float batchHeight = getBatchHeight(batchId);\n addHeight = batchHeight;\n #endif\n\n #ifdef USE_BATCH_LINE_WIDTH\n batchLineWidth = getBatchLineWidth(batchId);\n #endif\n#endif\n\n vec3 ecStart;\n vec3 ecEnd;\n vec3 offset;\n\n #ifdef USE_RTE\n \n vec3 startHighDiff = (start_3d_high - u_cameraPositionHigh) * u_rteOne;\n vec3 startLowDiff = start_3d_low - u_cameraPositionLow;\n vec3 startCameraRelative = startHighDiff + startLowDiff;\n\n vec3 endHighDiff = (end_3d_high - u_cameraPositionHigh) * u_rteOne;\n vec3 endLowDiff = end_3d_low - u_cameraPositionLow;\n vec3 endCameraRelative = endHighDiff + endLowDiff;\n\n ecStart = (modelViewMatrixRTE * vec4(startCameraRelative, 1.0)).xyz;\n ecEnd = (modelViewMatrixRTE * vec4(endCameraRelative, 1.0)).xyz;\n offset = ecEnd - ecStart;\n #else\n ecStart = (modelViewMatrix * vec4(start, 1.0)).xyz;\n offset = normalMatrix * forward_offset;\n ecEnd = ecStart + offset;\n #endif\n\n nvr_vBatchId = attrBatchId;\n\n vec3 forwardDirectionEC = normalize(offset);\n\n \n vec4 startPlaneEC;\n #ifdef USE_RTE\n startPlaneEC.xyz = mat3(modelViewMatrixRTE) * start_normal;\n #else\n startPlaneEC.xyz = normalMatrix * start_normal;\n #endif\n startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\n \n vec4 endPlaneEC;\n #ifdef USE_RTE\n endPlaneEC.xyz = mat3(modelViewMatrixRTE) * end_normal_and_texture_coordinate_normalization_x.xyz;\n #else\n endPlaneEC.xyz = normalMatrix * end_normal_and_texture_coordinate_normalization_x.xyz;\n #endif\n endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\n \n #ifdef USE_RTE\n v_rightPlaneEC.xyz = mat3(modelViewMatrixRTE) * right_normal_and_texture_coordinate_normalization_y.xyz;\n #else\n v_rightPlaneEC.xyz = normalMatrix * right_normal_and_texture_coordinate_normalization_y.xyz;\n #endif\n v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\n v_texcoordNormalizationAndStartEcYZ.x = abs(end_normal_and_texture_coordinate_normalization_x.w);\n v_texcoordNormalizationAndStartEcYZ.y = right_normal_and_texture_coordinate_normalization_y.w;\n\n v_endEcAndStartEcX.xyz = ecEnd;\n v_endEcAndStartEcX.w = ecStart.x;\n v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz;\n\n #ifdef USE_RTE\n vec4 positionEC = modelViewMatrixRTE * vec4(transformed, 1.0);\n #else\n vec4 positionEC = modelViewMatrix * vec4(position, 1.0);\n #endif\n\n float absStartPlaneDistance = abs(nvr_planeDistance(startPlaneEC, positionEC.xyz));\n float absEndPlaneDistance = abs(nvr_planeDistance(endPlaneEC, positionEC.xyz));\n\n vec3 planeDirection = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz);\n vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection)); \n vec3 normalEC = normalize(cross(planeDirection, upOrDown)); \n\n \n vec3 heightNormal = normalize(nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, cross(v_rightPlaneEC.xyz, startPlaneEC.xyz), cross(endPlaneEC.xyz, v_rightPlaneEC.xyz)));\n #ifdef USE_RTE\n \n vec3 ecCurPoint = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, ecStart, ecEnd);\n vec3 distToRef = normalize(positionEC.xyz - ecCurPoint);\n\n \n \n vec3 height = heightNormal * nvr_branchFreeTernary(dot(distToRef, heightNormal) > 0., minMaxHeightAndWidth.y, minMaxHeightAndWidth.x);\n positionEC.xyz += height;\n #else\n vec3 cur_point = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, start, start + forward_offset);\n vec3 diff = normalize(position - cur_point);\n vec3 height = heightNormal * nvr_branchFreeTernary(dot(diff, heightNormal) > 0., minMaxHeightAndWidth.y, minMaxHeightAndWidth.x);\n positionEC.xyz += height;\n #endif\n\n \n positionEC.xyz += heightNormal * addHeight;\n\n vec3 transformedNormal = vec3( heightNormal );\n\n #include <normal_vertex>\n \n v_texcoordNormalizationAndStartEcYZ.y = nvr_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y));\n\n \n \n #ifdef USE_BATCH_LINE_WIDTH\n float lineWidth = batchLineWidth >= 0.0 ? batchLineWidth : minMaxHeightAndWidth.z;\n #else\n float lineWidth = minMaxHeightAndWidth.z;\n #endif\n\n v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz;\n v_startPlaneNormalEcAndHalfWidth.w = lineWidth * 0.5;\n\n v_endPlaneNormalEc.xyz = endPlaneEC.xyz;\n\n \n v_startPlaneOffsetEc = startPlaneEC.w;\n v_endPlaneOffsetEc = endPlaneEC.w;\n\n lineWidth = lineWidth * max(0.0, nvr_metersPerPixel(positionEC, viewportAndPixelRatio, frustumNearFar, frustumRatio)); \n \n lineWidth = min(lineWidth, maxWidth);\n\n \n \n float forwardPush = lineWidth * 0.5;\n float pushDirection = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, -1.0, 1.0);\n positionEC.xyz += pushDirection * forwardPush * forwardDirectionEC;\n\n lineWidth = lineWidth / dot(normalEC, v_rightPlaneEC.xyz); \n\n normalEC *= sign(end_normal_and_texture_coordinate_normalization_x.w);\n\n positionEC.xyz += lineWidth * normalEC;\n gl_Position = projectionMatrix * positionEC;\n vViewPosition = -positionEC.xyz;\n\n \n \n \n vec4 mvPosition = positionEC;\n\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n}", JP = (e) => e ? {
|
|
22804
|
+
}, WP = "vec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n\n#include <common>\n#include <color_pars_fragment>\n\nuniform vec3 color;\nuniform float nvr_uPickable;\n\nflat in float nvr_vBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nin float nvr_vShow;\nin float nvr_vOpacity;\n#endif\n\nvoid main() {\n #ifdef USE_BATCH_COLOR_SHOW\n\nif (nvr_vShow < 0.5) {\n discard;\n}\n\nif (nvr_vOpacity <= 0.0) {\n discard;\n}\n\n#endif\n\n vec4 diffuseColor = vec4(color, 1.0);\n #include <clipping_planes_fragment>\n\n #include <color_fragment>\n\n#ifdef USE_BATCH_COLOR_SHOW\n diffuseColor.a *= nvr_vOpacity;\n#endif\n\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n\n if(nvr_uPickable > 0.0) {\n vec3 pickColor = nvr_batchIdToColor(nvr_vBatchId);\n gl_FragColor = vec4(pickColor.xyz, 1.0);\n }\n}", GP = "in float attrBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nout float nvr_vShow;\nout float nvr_vOpacity;\n#endif\n\nin vec4 right_normal_and_texture_coordinate_normalization_y;\n\n#include <common>\n#include <color_pars_vertex>\n#ifdef USE_BATCH_TEXTURE\nuniform sampler2D batchDataTexture;\nin float _batchid;\n\nfloat decodeRGBAToFloat(vec4 rgba) {\n uvec4 bytes = uvec4(rgba * 255.0);\n\n uint value = bytes.r | (bytes.g << 8) | (bytes.b << 16) | (bytes.a << 24);\n\n return uintBitsToFloat(value);\n}\n\nvec2 getBatchTextureCoord(float batchId, float rowIndex) {\n vec2 texSize = vec2(textureSize(batchDataTexture, 0));\n\n \n \n float col = mod(batchId, texSize.x);\n float batchRow = floor(batchId / texSize.x);\n\n float u = (col + 0.5) / texSize.x;\n float v = (batchRow * BATCHED_TEXTURE_ROW_COUNT + rowIndex + 0.5) / texSize.y;\n\n return vec2(u, v);\n}\n\n#ifdef USE_BATCH_COLOR_SHOW\nvec4 getBatchColorShow(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_COLOR_SHOW);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return data;\n}\n#endif\n\n#ifdef USE_BATCH_HEIGHT\nfloat getBatchHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_EXTRUDED_HEIGHT\nfloat getBatchExtrudedHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_EXTRUDED_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_LINE_WIDTH\nfloat getBatchLineWidth(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_LINE_WIDTH);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n#endif\nuniform float uAddHeight;\n\nuniform vec3 minMaxHeightAndWidth;\n\nflat out float nvr_vBatchId;\n\nvoid main() {\n #include <begin_vertex>\n #include <color_vertex>\n\n #ifdef USE_BATCH_HEIGHT\n float addHeight = 0.; \n#else\n float addHeight = uAddHeight;\n#endif\n float batchLineWidth = -1.0;\n\n #ifdef USE_BATCH_TEXTURE\n float batchId = _batchid;\n\n #ifdef USE_BATCH_COLOR_SHOW\n vec4 batchColor = getBatchColorShow(batchId);\n #ifdef USE_COLOR\n vColor.rgb = batchColor.rgb;\n #endif\n \n float packedByte = clamp(floor(batchColor.a * 255.0 + 0.5), 0.0, 255.0); \n nvr_vShow = step(128.0, packedByte); \n nvr_vOpacity = mod(packedByte, 128.0) / 127.0; \n #endif\n\n #ifdef USE_BATCH_EXTRUDED_HEIGHT\n float extrudedHeight = getBatchExtrudedHeight(batchId);\n addExtrudedHeight = extrudedHeight;\n #endif\n\n #ifdef USE_BATCH_HEIGHT\n float batchHeight = getBatchHeight(batchId);\n addHeight = batchHeight;\n #endif\n\n #ifdef USE_BATCH_LINE_WIDTH\n batchLineWidth = getBatchLineWidth(batchId);\n #endif\n#endif\n\n nvr_vBatchId = attrBatchId;\n\n \n vec2 miterNormal = right_normal_and_texture_coordinate_normalization_y.xy;\n float miterLength = right_normal_and_texture_coordinate_normalization_y.w; \n\n \n \n \n #ifdef USE_BATCH_LINE_WIDTH\n float baseWidth = batchLineWidth >= 0.0 ? batchLineWidth : minMaxHeightAndWidth.z;\n #else\n float baseWidth = minMaxHeightAndWidth.z;\n #endif\n \n \n float lineWidth = baseWidth * (2.0 / 512.0);\n\n \n \n \n \n lineWidth /= projectionMatrix[0][0];\n\n \n vec3 offsetPos = position + vec3(miterNormal * lineWidth * 0.5 * miterLength, 0.0);\n\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(offsetPos, 1.0);\n}", KP = "vec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n\n#include <lights_pars_begin>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n\nuniform vec3 color;\nuniform float nvr_uPickable;\n\nflat in float nvr_vBatchId;\nin vec3 vNormal;\n\n#ifdef USE_BATCH_COLOR_SHOW\nin float nvr_vShow;\nin float nvr_vOpacity;\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n\n#ifdef GBUFFER_NORMAL_LOCATION\nlayout(location = GBUFFER_NORMAL_LOCATION) out vec4 normalBuffer;\n\n#ifdef NVR_BLENDED\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) 1.0\n#else\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) (roughnessValue)\n#endif\n\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue) normalBuffer = vec4(packNormalToVec2(n), blue, GBUFFER_NORMAL_ALPHA(roughnessValue));\n#else\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue)\n#endif\n\n#ifdef USE_GBUFFER_SELECTIVE_EFFECT\nlayout(location = GBUFFER_EFFECT_ID_LOCATION) out vec4 effectIdBuffer;\n\n#define GBUFFER_WRITE_EFFECT_ID(mask) effectIdBuffer = vec4(mask, 0.0, 0.0, 1.0);\n\n#define GBUFFER_WRITE_EFFECT_ID_ZERO effectIdBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EFFECT_ID(mask)\n#define GBUFFER_WRITE_EFFECT_ID_ZERO\n#endif\n\n#ifdef USE_GBUFFER_EMISSIVE\nlayout(location = GBUFFER_EMISSIVE_LOCATION) out vec4 emissiveBuffer;\n\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb) emissiveBuffer = vec4(emissiveRgb, 1.0);\n\n#define GBUFFER_WRITE_EMISSIVE_ZERO emissiveBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n#define GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_GBUFFER_SHADOW\nlayout(location = GBUFFER_SHADOW_LOCATION) out vec4 shadowBuffer;\n\nfloat nvr_shadowMask = 1.0;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n#define NVR_GBUFFER_UNLIT_FLAG 1.0\n#else\n#define NVR_GBUFFER_UNLIT_FLAG 0.0\n#endif\n\n#define GBUFFER_WRITE_SHADOW shadowBuffer = vec4(1.0 - nvr_shadowMask, NVR_GBUFFER_UNLIT_FLAG, 0.0, 1.0);\n\n#define GBUFFER_WRITE_SHADOW_ZERO shadowBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_SHADOW\n#define GBUFFER_WRITE_SHADOW_ZERO\n#endif\n\n#define GBUFFER_WRITE_EFFECT(mask, emissiveRgb) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n\n#define GBUFFER_WRITE_EFFECT_ID_ONLY(mask) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE_ZERO\n#define GBUFFER_WRITE_EFFECT_ZERO GBUFFER_WRITE_EFFECT_ID_ZERO GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_SELECTIVE_EFFECT\n uniform float uEffectIdsMask;\n uniform vec3 uEmissiveColor;\n uniform float uEmissiveIntensity;\n#endif\n\nvoid main() {\n #ifdef USE_BATCH_COLOR_SHOW\n\nif (nvr_vShow < 0.5) {\n discard;\n}\n\nif (nvr_vOpacity <= 0.0) {\n discard;\n}\n\n#endif\n \n vec4 diffuseColor = vec4(color, 1.);\n #include <clipping_planes_fragment>\n\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = vec3(0.);\n\n #include <color_fragment>\n\n#ifdef USE_BATCH_COLOR_SHOW\n diffuseColor.a *= nvr_vOpacity;\n#endif\n\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <emissivemap_fragment>\n\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n \n outgoingLight = diffuseColor.rgb;\n#endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n\n if(nvr_uPickable > 0.0) {\n vec3 pickColor = nvr_batchIdToColor(nvr_vBatchId);\n gl_FragColor = vec4(pickColor.xyz, 1.0);\n }\n\n #ifndef USE_SHADOWMAP_DEPTH\n GBUFFER_WRITE_NORMAL(vNormal, 0.0, 1.0)\n #ifdef USE_SELECTIVE_EFFECT\n GBUFFER_WRITE_EFFECT(uEffectIdsMask, (diffuseColor.rgb + uEmissiveColor) * uEmissiveIntensity)\n #else\n GBUFFER_WRITE_EFFECT_ZERO\n #endif\n\n \n GBUFFER_WRITE_SHADOW\n #endif\n}", qP = "float nvr_branchFreeTernary(bool comparison, float a, float b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec2 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec2} a Value to return if the comparison is true.\n * @param {vec2} b Value to return if the comparison is false.\n *\n * @returns {vec2} equivalent of comparison ? a : b\n */\nvec2 nvr_branchFreeTernary(bool comparison, vec2 a, vec2 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec3 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec3 nvr_branchFreeTernary(bool comparison, vec3 a, vec3 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec4 expression.\n *\n * @name nvr_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec4 nvr_branchFreeTernary(bool comparison, vec4 a, vec4 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\nfloat nvr_planeDistance(vec4 plane, vec3 point) {\n return (dot(plane.xyz, point) + plane.w);\n}\n\n/**\n * Computes distance from a point to a plane.\n *\n * @name nvr_planeDistance\n * @glslFunction\n *\n * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js\n * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js\n * param {vec3} point A point in the same space as the plane.\n * returns {float} The distance from the point to the plane.\n */\nfloat nvr_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {\n return (dot(planeNormal, point) + planeDistance);\n}\nfloat nvr_metersPerPixel(vec4 positionEC, vec3 viewportAndPixelRatio, vec2 frustumNearFar, vec4 frustumRatio)\n{\n float width = viewportAndPixelRatio.x * viewportAndPixelRatio.z;\n float height = viewportAndPixelRatio.y * viewportAndPixelRatio.z;\n float pixelWidth;\n float pixelHeight;\n\n float top = frustumRatio.x;\n float bottom = frustumRatio.y;\n float right = frustumRatio.z;\n float left = frustumRatio.w;\n\n \n \n \n \n \n \n \n \n \n \n float distanceToPixel = -positionEC.z;\n float inverseNear = 1.0 / frustumNearFar.x;\n float tanTheta = top * inverseNear;\n pixelHeight = 2.0 * distanceToPixel * tanTheta / height;\n tanTheta = right * inverseNear;\n pixelWidth = 2.0 * distanceToPixel * tanTheta / width;\n \n\n float pixelRatio = viewportAndPixelRatio.z;\n\n return max(pixelWidth, pixelHeight) * pixelRatio;\n}\n#ifndef ELLIPSOID_GLSL\n#define ELLIPSOID_GLSL\n\n#define WGS84_A 6378137.0\n#define WGS84_B 6356752.3142451793\n\nconst vec3 WGS84_RADII = vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII = 1.0 / vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII_SQUARED = 1.0 / vec3(WGS84_A * WGS84_A, WGS84_A * WGS84_A, WGS84_B * WGS84_B);\n\nconst float WGS84_E2 = 0.00669438; \nconst float WGS84_E2_SECOND = 0.00673950; \n\nconst float WGS84_FLATTENING = 0.00335281; \nconst float WGS84_FLATTENING_RECIPROCAL = 298.257223563; \n\n#endif\n\nflat out int vHorizonCulled;\n\nbool nvr_horizon_culled(vec3 targetPosition, vec3 cameraPosition) {\n vec3 cameraPositionScaled = cameraPosition * ONE_OVER_WGS84_RADII;\n vec3 targetPositionScaled = targetPosition * ONE_OVER_WGS84_RADII;\n\n vec3 vt = cameraPositionScaled - targetPositionScaled;\n vec3 vc = cameraPositionScaled;\n float a = dot(vc, vc) - 1.0;\n\n return dot(vt, vc) > a;\n}\n\nin float attrBatchId;\n\n#ifdef USE_BATCH_COLOR_SHOW\nout float nvr_vShow;\nout float nvr_vOpacity;\n#endif\n\n#ifdef USE_RTE\n uniform vec3 u_cameraPositionHigh;\nuniform vec3 u_cameraPositionLow;\n\nuniform float u_rteOne;\n\nuniform mat4 modelViewMatrixRTE;\n\nattribute vec3 position_3d_high;\nattribute vec3 position_3d_low;\n attribute vec3 start_3d_high;\n attribute vec3 start_3d_low;\n attribute vec3 end_3d_high;\n attribute vec3 end_3d_low;\n#else\n in vec3 start;\n in vec3 forward_offset;\n#endif\n\nin vec3 start_normal;\nin vec4 end_normal_and_texture_coordinate_normalization_x;\nin vec4 right_normal_and_texture_coordinate_normalization_y;\n\n#include <common>\n#include <color_pars_vertex>\n#include <shadowmap_pars_vertex>\n#ifdef USE_BATCH_TEXTURE\nuniform sampler2D batchDataTexture;\nin float _batchid;\n\nfloat decodeRGBAToFloat(vec4 rgba) {\n uvec4 bytes = uvec4(rgba * 255.0);\n\n uint value = bytes.r | (bytes.g << 8) | (bytes.b << 16) | (bytes.a << 24);\n\n return uintBitsToFloat(value);\n}\n\nvec2 getBatchTextureCoord(float batchId, float rowIndex) {\n vec2 texSize = vec2(textureSize(batchDataTexture, 0));\n\n \n \n float col = mod(batchId, texSize.x);\n float batchRow = floor(batchId / texSize.x);\n\n float u = (col + 0.5) / texSize.x;\n float v = (batchRow * BATCHED_TEXTURE_ROW_COUNT + rowIndex + 0.5) / texSize.y;\n\n return vec2(u, v);\n}\n\n#ifdef USE_BATCH_COLOR_SHOW\nvec4 getBatchColorShow(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_COLOR_SHOW);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return data;\n}\n#endif\n\n#ifdef USE_BATCH_HEIGHT\nfloat getBatchHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_EXTRUDED_HEIGHT\nfloat getBatchExtrudedHeight(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_EXTRUDED_HEIGHT);\n \n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n\n#ifdef USE_BATCH_LINE_WIDTH\nfloat getBatchLineWidth(float batchId) {\n vec2 uv = getBatchTextureCoord(batchId, BATCHED_TEXTURE_ROW_LINE_WIDTH);\n\n vec4 data = texture2D(batchDataTexture, uv);\n return decodeRGBAToFloat(data);\n}\n#endif\n#endif\n\nuniform vec3 minMaxHeightAndWidth;\nuniform vec3 viewportAndPixelRatio;\nuniform vec2 frustumNearFar;\nuniform vec4 frustumRatio;\nuniform float maxWidth;\nuniform float uAddHeight;\n\nflat out vec4 v_startPlaneNormalEcAndHalfWidth;\nflat out vec3 v_endPlaneNormalEc;\nflat out vec4 v_rightPlaneEC;\nflat out float v_startPlaneOffsetEc;\nflat out float v_endPlaneOffsetEc;\nout vec4 v_endEcAndStartEcX;\nout vec4 v_texcoordNormalizationAndStartEcYZ;\nout vec3 vViewPosition;\nflat out float nvr_vBatchId;\nout vec3 vNormal;\n\nvoid main() {\n #ifdef USE_RTE\n \n \n \n \n \n \n vec3 segmentStartAbs = start_3d_high + start_3d_low;\n vec3 segmentEndAbs = end_3d_high + end_3d_low;\n if (nvr_horizon_culled(segmentStartAbs, cameraPosition)\n && nvr_horizon_culled(segmentEndAbs, cameraPosition)) {\n vHorizonCulled = 1;\n gl_Position = vec4(0.0);\n return;\n }\n vHorizonCulled = 0;\n #endif\n\n #ifdef USE_RTE\n vec3 highDiff = (position_3d_high - u_cameraPositionHigh) * u_rteOne;\nvec3 lowDiff = position_3d_low - u_cameraPositionLow;\nvec3 transformed = highDiff + lowDiff;\n\nvec3 absTransformed = position_3d_high + position_3d_low;\n \n #else\n #include <begin_vertex>\n #endif\n\n #include <color_vertex>\n\n #ifdef USE_BATCH_HEIGHT\n float addHeight = 0.; \n#else\n float addHeight = uAddHeight;\n#endif\n float batchLineWidth = -1.0;\n\n #ifdef USE_BATCH_TEXTURE\n float batchId = _batchid;\n\n #ifdef USE_BATCH_COLOR_SHOW\n vec4 batchColor = getBatchColorShow(batchId);\n #ifdef USE_COLOR\n vColor.rgb = batchColor.rgb;\n #endif\n \n float packedByte = clamp(floor(batchColor.a * 255.0 + 0.5), 0.0, 255.0); \n nvr_vShow = step(128.0, packedByte); \n nvr_vOpacity = mod(packedByte, 128.0) / 127.0; \n #endif\n\n #ifdef USE_BATCH_EXTRUDED_HEIGHT\n float extrudedHeight = getBatchExtrudedHeight(batchId);\n addExtrudedHeight = extrudedHeight;\n #endif\n\n #ifdef USE_BATCH_HEIGHT\n float batchHeight = getBatchHeight(batchId);\n addHeight = batchHeight;\n #endif\n\n #ifdef USE_BATCH_LINE_WIDTH\n batchLineWidth = getBatchLineWidth(batchId);\n #endif\n#endif\n\n vec3 ecStart;\n vec3 ecEnd;\n vec3 offset;\n\n #ifdef USE_RTE\n \n vec3 startHighDiff = (start_3d_high - u_cameraPositionHigh) * u_rteOne;\n vec3 startLowDiff = start_3d_low - u_cameraPositionLow;\n vec3 startCameraRelative = startHighDiff + startLowDiff;\n\n vec3 endHighDiff = (end_3d_high - u_cameraPositionHigh) * u_rteOne;\n vec3 endLowDiff = end_3d_low - u_cameraPositionLow;\n vec3 endCameraRelative = endHighDiff + endLowDiff;\n\n ecStart = (modelViewMatrixRTE * vec4(startCameraRelative, 1.0)).xyz;\n ecEnd = (modelViewMatrixRTE * vec4(endCameraRelative, 1.0)).xyz;\n offset = ecEnd - ecStart;\n #else\n ecStart = (modelViewMatrix * vec4(start, 1.0)).xyz;\n offset = normalMatrix * forward_offset;\n ecEnd = ecStart + offset;\n #endif\n\n nvr_vBatchId = attrBatchId;\n\n vec3 forwardDirectionEC = normalize(offset);\n\n \n vec4 startPlaneEC;\n #ifdef USE_RTE\n startPlaneEC.xyz = mat3(modelViewMatrixRTE) * start_normal;\n #else\n startPlaneEC.xyz = normalMatrix * start_normal;\n #endif\n startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\n \n vec4 endPlaneEC;\n #ifdef USE_RTE\n endPlaneEC.xyz = mat3(modelViewMatrixRTE) * end_normal_and_texture_coordinate_normalization_x.xyz;\n #else\n endPlaneEC.xyz = normalMatrix * end_normal_and_texture_coordinate_normalization_x.xyz;\n #endif\n endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\n \n #ifdef USE_RTE\n v_rightPlaneEC.xyz = mat3(modelViewMatrixRTE) * right_normal_and_texture_coordinate_normalization_y.xyz;\n #else\n v_rightPlaneEC.xyz = normalMatrix * right_normal_and_texture_coordinate_normalization_y.xyz;\n #endif\n v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\n v_texcoordNormalizationAndStartEcYZ.x = abs(end_normal_and_texture_coordinate_normalization_x.w);\n v_texcoordNormalizationAndStartEcYZ.y = right_normal_and_texture_coordinate_normalization_y.w;\n\n v_endEcAndStartEcX.xyz = ecEnd;\n v_endEcAndStartEcX.w = ecStart.x;\n v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz;\n\n #ifdef USE_RTE\n vec4 positionEC = modelViewMatrixRTE * vec4(transformed, 1.0);\n #else\n vec4 positionEC = modelViewMatrix * vec4(position, 1.0);\n #endif\n\n float absStartPlaneDistance = abs(nvr_planeDistance(startPlaneEC, positionEC.xyz));\n float absEndPlaneDistance = abs(nvr_planeDistance(endPlaneEC, positionEC.xyz));\n\n vec3 planeDirection = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz);\n vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection)); \n vec3 normalEC = normalize(cross(planeDirection, upOrDown)); \n\n \n vec3 heightNormal = normalize(nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, cross(v_rightPlaneEC.xyz, startPlaneEC.xyz), cross(endPlaneEC.xyz, v_rightPlaneEC.xyz)));\n #ifdef USE_RTE\n \n vec3 ecCurPoint = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, ecStart, ecEnd);\n vec3 distToRef = normalize(positionEC.xyz - ecCurPoint);\n\n \n \n vec3 height = heightNormal * nvr_branchFreeTernary(dot(distToRef, heightNormal) > 0., minMaxHeightAndWidth.y, minMaxHeightAndWidth.x);\n positionEC.xyz += height;\n #else\n vec3 cur_point = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, start, start + forward_offset);\n vec3 diff = normalize(position - cur_point);\n vec3 height = heightNormal * nvr_branchFreeTernary(dot(diff, heightNormal) > 0., minMaxHeightAndWidth.y, minMaxHeightAndWidth.x);\n positionEC.xyz += height;\n #endif\n\n \n positionEC.xyz += heightNormal * addHeight;\n\n vec3 transformedNormal = vec3( heightNormal );\n\n #include <normal_vertex>\n \n v_texcoordNormalizationAndStartEcYZ.y = nvr_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y));\n\n \n \n #ifdef USE_BATCH_LINE_WIDTH\n float lineWidth = batchLineWidth >= 0.0 ? batchLineWidth : minMaxHeightAndWidth.z;\n #else\n float lineWidth = minMaxHeightAndWidth.z;\n #endif\n\n v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz;\n v_startPlaneNormalEcAndHalfWidth.w = lineWidth * 0.5;\n\n v_endPlaneNormalEc.xyz = endPlaneEC.xyz;\n\n \n v_startPlaneOffsetEc = startPlaneEC.w;\n v_endPlaneOffsetEc = endPlaneEC.w;\n\n lineWidth = lineWidth * max(0.0, nvr_metersPerPixel(positionEC, viewportAndPixelRatio, frustumNearFar, frustumRatio)); \n \n lineWidth = min(lineWidth, maxWidth);\n\n \n \n float forwardPush = lineWidth * 0.5;\n float pushDirection = nvr_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, -1.0, 1.0);\n positionEC.xyz += pushDirection * forwardPush * forwardDirectionEC;\n\n lineWidth = lineWidth / dot(normalEC, v_rightPlaneEC.xyz); \n\n normalEC *= sign(end_normal_and_texture_coordinate_normalization_x.w);\n\n positionEC.xyz += lineWidth * normalEC;\n gl_Position = projectionMatrix * positionEC;\n vViewPosition = -positionEC.xyz;\n\n \n \n \n vec4 mvPosition = positionEC;\n\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n}", JP = (e) => e ? {
|
|
22801
22805
|
vertexShader: GP,
|
|
22802
22806
|
fragmentShader: WP
|
|
22803
22807
|
} : {
|
|
@@ -22983,7 +22987,7 @@ var iF = (e, t, n) => {
|
|
|
22983
22987
|
r.uTexture && (r.uTexture.value = e.value);
|
|
22984
22988
|
}
|
|
22985
22989
|
};
|
|
22986
|
-
}, aF = "float nvr_circle_alpha(vec2 uv) {\n float border = 0.01;\n float radius = 0.5;\n\n float dist = radius - length(uv);\n\n float t = 0.0;\n if (dist > border)\n t = 1.0;\n else if (dist > 0.0)\n t = dist / border;\n \n return mix(0., 1., t);\n}\nvec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n#ifdef BILLBOARD\n uniform sampler2D uTexture;\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n\n#ifdef GBUFFER_NORMAL_LOCATION\nlayout(location = GBUFFER_NORMAL_LOCATION) out vec4 normalBuffer;\n\n#ifdef NVR_BLENDED\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) 1.0\n#else\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) (roughnessValue)\n#endif\n\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue) normalBuffer = vec4(packNormalToVec2(n), blue, GBUFFER_NORMAL_ALPHA(roughnessValue));\n#else\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue)\n#endif\n\n#ifdef USE_GBUFFER_SELECTIVE_EFFECT\nlayout(location = GBUFFER_EFFECT_ID_LOCATION) out vec4 effectIdBuffer;\n\n#define GBUFFER_WRITE_EFFECT_ID(mask) effectIdBuffer = vec4(mask, 0.0, 0.0, 1.0);\n\n#define GBUFFER_WRITE_EFFECT_ID_ZERO effectIdBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EFFECT_ID(mask)\n#define GBUFFER_WRITE_EFFECT_ID_ZERO\n#endif\n\n#ifdef USE_GBUFFER_EMISSIVE\nlayout(location = GBUFFER_EMISSIVE_LOCATION) out vec4 emissiveBuffer;\n\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb) emissiveBuffer = vec4(emissiveRgb, 1.0);\n\n#define GBUFFER_WRITE_EMISSIVE_ZERO emissiveBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n#define GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_GBUFFER_SHADOW\nlayout(location = GBUFFER_SHADOW_LOCATION) out vec4 shadowBuffer;\n\nfloat nvr_shadowMask = 1.0;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n#define NVR_GBUFFER_UNLIT_FLAG 1.0\n#else\n#define NVR_GBUFFER_UNLIT_FLAG 0.0\n#endif\n\n#define GBUFFER_WRITE_SHADOW shadowBuffer = vec4(1.0 - nvr_shadowMask, NVR_GBUFFER_UNLIT_FLAG, 0.0, 1.0);\n\n#define GBUFFER_WRITE_SHADOW_ZERO shadowBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_SHADOW\n#define GBUFFER_WRITE_SHADOW_ZERO\n#endif\n\n#define GBUFFER_WRITE_EFFECT(mask, emissiveRgb) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n\n#define GBUFFER_WRITE_EFFECT_ID_ONLY(mask) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE_ZERO\n#define GBUFFER_WRITE_EFFECT_ZERO GBUFFER_WRITE_EFFECT_ID_ZERO GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n #ifdef USE_SELECTIVE_EFFECT\n uniform float uEffectIdsMask;\n uniform vec3 uEmissiveColor;\n uniform float uEmissiveIntensity;\n #endif\n\n \n vec2 packNormalToVec2(vec3 normal) {\n return normal.xy * 0.5 + 0.5;\n }\n\n vec3 screenSpaceNormal() {\n vec3 fdx = dFdx(gl_FragCoord.xyz);\n vec3 fdy = dFdy(gl_FragCoord.xyz);\n vec3 normal = normalize(cross(fdx, fdy));\n if (normal.z < 0.0) normal = -normal;\n return normal;\n }\n#endif\n\nvarying vec2 vUv;\nvarying vec3 vColor;\
|
|
22990
|
+
}, aF = "float nvr_circle_alpha(vec2 uv) {\n float border = 0.01;\n float radius = 0.5;\n\n float dist = radius - length(uv);\n\n float t = 0.0;\n if (dist > border)\n t = 1.0;\n else if (dist > 0.0)\n t = dist / border;\n \n return mix(0., 1., t);\n}\nvec3 nvr_batchIdToColor(float batchId) {\n float r = floor(batchId / 65536.0);\n float g = floor(mod(batchId / 256.0, 256.0));\n float b = floor(mod(batchId, 256.0));\n\n return vec3(r/255.0, g/255.0, b/255.0);\n}\n#ifdef BILLBOARD\n uniform sampler2D uTexture;\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n\n#ifdef GBUFFER_NORMAL_LOCATION\nlayout(location = GBUFFER_NORMAL_LOCATION) out vec4 normalBuffer;\n\n#ifdef NVR_BLENDED\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) 1.0\n#else\n#define GBUFFER_NORMAL_ALPHA(roughnessValue) (roughnessValue)\n#endif\n\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue) normalBuffer = vec4(packNormalToVec2(n), blue, GBUFFER_NORMAL_ALPHA(roughnessValue));\n#else\n#define GBUFFER_WRITE_NORMAL(n, blue, roughnessValue)\n#endif\n\n#ifdef USE_GBUFFER_SELECTIVE_EFFECT\nlayout(location = GBUFFER_EFFECT_ID_LOCATION) out vec4 effectIdBuffer;\n\n#define GBUFFER_WRITE_EFFECT_ID(mask) effectIdBuffer = vec4(mask, 0.0, 0.0, 1.0);\n\n#define GBUFFER_WRITE_EFFECT_ID_ZERO effectIdBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EFFECT_ID(mask)\n#define GBUFFER_WRITE_EFFECT_ID_ZERO\n#endif\n\n#ifdef USE_GBUFFER_EMISSIVE\nlayout(location = GBUFFER_EMISSIVE_LOCATION) out vec4 emissiveBuffer;\n\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb) emissiveBuffer = vec4(emissiveRgb, 1.0);\n\n#define GBUFFER_WRITE_EMISSIVE_ZERO emissiveBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n#define GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifdef USE_GBUFFER_SHADOW\nlayout(location = GBUFFER_SHADOW_LOCATION) out vec4 shadowBuffer;\n\nfloat nvr_shadowMask = 1.0;\n\n#if !defined(NVR_LIT) && (defined(NVR_UNLIT) || defined(NVR_UNLIT_SCENE))\n#define NVR_GBUFFER_UNLIT_FLAG 1.0\n#else\n#define NVR_GBUFFER_UNLIT_FLAG 0.0\n#endif\n\n#define GBUFFER_WRITE_SHADOW shadowBuffer = vec4(1.0 - nvr_shadowMask, NVR_GBUFFER_UNLIT_FLAG, 0.0, 1.0);\n\n#define GBUFFER_WRITE_SHADOW_ZERO shadowBuffer = vec4(0.0);\n#else\n#define GBUFFER_WRITE_SHADOW\n#define GBUFFER_WRITE_SHADOW_ZERO\n#endif\n\n#define GBUFFER_WRITE_EFFECT(mask, emissiveRgb) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE(emissiveRgb)\n\n#define GBUFFER_WRITE_EFFECT_ID_ONLY(mask) GBUFFER_WRITE_EFFECT_ID(mask) GBUFFER_WRITE_EMISSIVE_ZERO\n#define GBUFFER_WRITE_EFFECT_ZERO GBUFFER_WRITE_EFFECT_ID_ZERO GBUFFER_WRITE_EMISSIVE_ZERO\n#endif\n\n#ifndef USE_SHADOWMAP_DEPTH\n #ifdef USE_SELECTIVE_EFFECT\n uniform float uEffectIdsMask;\n uniform vec3 uEmissiveColor;\n uniform float uEmissiveIntensity;\n #endif\n\n \n vec2 packNormalToVec2(vec3 normal) {\n return normal.xy * 0.5 + 0.5;\n }\n\n vec3 screenSpaceNormal() {\n vec3 fdx = dFdx(gl_FragCoord.xyz);\n vec3 fdy = dFdy(gl_FragCoord.xyz);\n vec3 normal = normalize(cross(fdx, fdy));\n if (normal.z < 0.0) normal = -normal;\n return normal;\n }\n#endif\n\nvarying vec2 vUv;\nvarying vec3 vColor;\nflat varying float vBatchID;\nvarying float vFragDepth;\nvarying float vOpacity;\n\nuniform bool uOffsetDepth;\nuniform float nvr_uPickable;\nuniform float uAlphaTest;\nuniform float uFarPlane;\n\nvoid main() {\n \n gl_FragDepth = log(vFragDepth) / log(uFarPlane + 1.0);\n\n \n if (uOffsetDepth) { gl_FragDepth -= 0.01; }\n\n float alphaForTest = 1.0;\n float alphaForColor = 1.0;\n #ifdef BILLBOARD\n \n vec4 color = texture(uTexture, vUv);\n \n color.rgb *= vColor;\n alphaForTest = color.a;\n alphaForColor = color.a * vOpacity;\n #else\n alphaForTest = nvr_circle_alpha(vUv - vec2(0.5));\n alphaForColor = vOpacity;\n vec4 color = vec4(vColor, 1.0);\n #endif\n\n if (alphaForTest <= uAlphaTest) { discard; };\n \n if (nvr_uPickable > 0.0 && alphaForTest > 0.0) {\n vec3 pickColor = nvr_batchIdToColor(vBatchID);\n color = vec4(pickColor.xyz, 1.0);\n } else {\n color.a = alphaForColor;\n }\n\n gl_FragColor = color;\n\n #ifndef USE_SHADOWMAP_DEPTH\n \n vec3 normal = screenSpaceNormal();\n GBUFFER_WRITE_NORMAL(normal, 0.0, 1.0)\n\n #ifdef USE_SELECTIVE_EFFECT\n GBUFFER_WRITE_EFFECT(uEffectIdsMask, (color.rgb + uEmissiveColor) * uEmissiveIntensity)\n #else\n GBUFFER_WRITE_EFFECT_ZERO\n #endif\n\n GBUFFER_WRITE_SHADOW_ZERO\n #endif\n}", oF = "#ifndef ELLIPSOID_GLSL\n#define ELLIPSOID_GLSL\n\n#define WGS84_A 6378137.0\n#define WGS84_B 6356752.3142451793\n\nconst vec3 WGS84_RADII = vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII = 1.0 / vec3(WGS84_A, WGS84_A, WGS84_B);\nconst vec3 ONE_OVER_WGS84_RADII_SQUARED = 1.0 / vec3(WGS84_A * WGS84_A, WGS84_A * WGS84_A, WGS84_B * WGS84_B);\n\nconst float WGS84_E2 = 0.00669438; \nconst float WGS84_E2_SECOND = 0.00673950; \n\nconst float WGS84_FLATTENING = 0.00335281; \nconst float WGS84_FLATTENING_RECIPROCAL = 298.257223563; \n\n#endif\n\nflat out int vHorizonCulled;\n\nbool nvr_horizon_culled(vec3 targetPosition, vec3 cameraPosition) {\n vec3 cameraPositionScaled = cameraPosition * ONE_OVER_WGS84_RADII;\n vec3 targetPositionScaled = targetPosition * ONE_OVER_WGS84_RADII;\n\n vec3 vt = cameraPositionScaled - targetPositionScaled;\n vec3 vc = cameraPositionScaled;\n float a = dot(vc, vc) - 1.0;\n\n return dot(vt, vc) > a;\n}\nvec4 mvr_getMvHeightOffset(vec3 worldPos3, float addHight) {\n if (addHight != 0.0) {\n vec3 globeNormal = normalize(worldPos3);\n vec3 heightOffset = globeNormal * addHight;\n vec4 mvHeightOffset = viewMatrix * vec4(heightOffset, 0.0);\n return mvHeightOffset;\n }\n else {\n return vec4(0.0);\n }\n}\nfloat nvr_pxToWorld(float px, float fov, float screenHeight, vec3 worldPosition, vec3 cameraPosition) {\n float distance = length(cameraPosition - worldPosition.xyz);\n float world_screen_height = tan(fov / 2.0) * distance * 2.0;\n float world_per_pixel = world_screen_height / screenHeight;\n\n return px * world_per_pixel;\n}\n\n#ifdef USE_RTE\n attribute vec3 instancePositionLOW; \n attribute vec3 instancePositionHIGH; \n#else\n attribute vec3 instancePosition; \n#endif\n\n#ifdef BILLBOARD\n \n \n \n attribute vec4 instanceUvRect;\n uniform vec2 uAtlasSize;\n#endif\n\nattribute vec4 instanceParams; \nattribute vec3 instanceColor;\nattribute float instanceBatchID;\n\nattribute float instanceDeclutterHide;\n\nuniform vec3 uRTCCenter;\n\nuniform vec3 uRTCCenterView;\nuniform vec3 uEyeRTEHigh;\nuniform vec3 uEyeRTELow;\n\nuniform float u_rteOne;\nuniform float uScale;\nuniform bool uSizeInMeters;\nuniform vec2 uCenter;\nuniform float uFovRad;\nuniform float uScreenHeightPx;\n\nvarying vec2 vUv;\nvarying vec3 vColor;\nflat varying float vBatchID;\nvarying float vFragDepth;\nvarying float vOpacity; \n\nvoid main() {\n float instanceHeight = instanceParams.x;\n float instanceSize = instanceParams.y;\n float instanceShow = instanceParams.z;\n vOpacity = instanceParams.w * (1.0 - instanceDeclutterHide);\n\n#ifdef USE_RTE\n vec3 absTransformed = instancePositionHIGH + instancePositionLOW;\n#else\n vec3 absTransformed = instancePosition + uRTCCenter;\n#endif\n bool horizonCulled = nvr_horizon_culled(absTransformed, cameraPosition);\nif (horizonCulled) {\n vHorizonCulled = 1;\n gl_Position = vec4(0.0);\n return;\n}\nvHorizonCulled = 0;\n\n#ifdef BILLBOARD\n vUv = (instanceUvRect.xy + uv * instanceUvRect.zw) / uAtlasSize;\n#else\n vUv = uv;\n#endif\n vBatchID = instanceBatchID;\n vColor = instanceColor;\n\n \n \n \n \n#ifdef BILLBOARD\n bool nvr_hasImage = instanceUvRect.z > 0.0 && instanceUvRect.w > 0.0;\n#else\n bool nvr_hasImage = true;\n#endif\n\n if (instanceShow <= 0.5 || instanceDeclutterHide >= 0.999 || !nvr_hasImage) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0); \n return;\n }\n\n vec4 mvPosition;\n#ifdef USE_RTE\n \n vec3 highDiff = (instancePositionHIGH - uEyeRTEHigh) * u_rteOne;\n vec3 lowDiff = instancePositionLOW - uEyeRTELow;\n vec3 resolvedPosition = highDiff + lowDiff;\n\n mat4 viewMatrixRTE = viewMatrix;\n viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0); \n mvPosition = viewMatrixRTE * vec4(resolvedPosition, 1.0);\n#else\n \n \n \n mat4 viewMatrixRTC = viewMatrix;\n viewMatrixRTC[3] = vec4(uRTCCenterView, 1.0);\n\n mvPosition = viewMatrixRTC * vec4(instancePosition, 1.0);\n#endif\n\n mvPosition += mvr_getMvHeightOffset(absTransformed, instanceHeight);\n vec2 center = clamp(uCenter, vec2(-0.5), vec2(0.5)); \n\n \n float scale = instanceSize >= 0.0 ? instanceSize : uScale;\n float clampedScale = max(0.0, scale); \n#ifdef BILLBOARD\n \n float aspect = instanceUvRect.w > 0.0 ? instanceUvRect.z / instanceUvRect.w : 1.0;\n#else\n float aspect = 1.0;\n#endif\n \n if (!uSizeInMeters) {\n clampedScale = nvr_pxToWorld(clampedScale, uFovRad, uScreenHeightPx, vec3(0.0, 0.0, mvPosition.z), vec3(0.0, 0.0, 0.0));\n mvPosition.xy += (((position.xy - center)) * vec2(aspect, 1.0) * clampedScale);\n } else {\n mvPosition.xy += (((position.xy - center)) * vec2(aspect, 1.0) * clampedScale);\n }\n\n gl_Position = projectionMatrix * mvPosition;\n vFragDepth = gl_Position.w + 1.0;\n}", sF = (e, t, n, r) => {
|
|
22987
22991
|
e.vertexShader = oF, e.fragmentShader = aF, e.defines ??= {}, t.useRTE && (e.defines.USE_RTE = 1), t.billboard && (e.defines.BILLBOARD = 1), e.defines.USE_SELECTIVE_EFFECT = 1, r.userData?.defines && Object.assign(e.defines, r.userData.defines), n.updateUniforms(e.uniforms, t);
|
|
22988
22992
|
}, cF = {
|
|
22989
22993
|
useRTE: !1,
|
|
@@ -25921,13 +25925,13 @@ var LL = class extends Nk {
|
|
|
25921
25925
|
}
|
|
25922
25926
|
onUpdateConfig(e) {
|
|
25923
25927
|
let t = e.geodetic === void 0 ? this.geodetic : IL(this.geodetic, e.geodetic);
|
|
25924
|
-
FL(t, e.matrix === void 0 ? this.matrix : e.matrix, e.matrixWorld === void 0 ? this.matrixWorld : e.matrixWorld), super.onUpdateConfig(e)
|
|
25928
|
+
FL(t, e.matrix === void 0 ? this.matrix : e.matrix, e.matrixWorld === void 0 ? this.matrixWorld : e.matrixWorld), super.onUpdateConfig(e);
|
|
25925
25929
|
let n = e.matrix !== void 0 || e.matrixWorld !== void 0 || e.geodetic !== void 0 || e.position !== void 0 || e.scale !== void 0 || e.rotation !== void 0;
|
|
25926
25930
|
if (e.geodetic !== void 0) {
|
|
25927
25931
|
let e = this.geodetic;
|
|
25928
25932
|
this.geodetic = t, (t?.lng !== e?.lng || t?.lat !== e?.lat || t?.heightReference !== e?.heightReference) && this.subscribeTerrainHeight();
|
|
25929
25933
|
}
|
|
25930
|
-
e.matrix !== void 0 && (this.matrix = e.matrix), e.matrixWorld !== void 0 && (this.matrixWorld = e.matrixWorld), e.position !== void 0 && (this.position = e.position), e.scale !== void 0 && (this.scale = e.scale), e.rotation !== void 0 && (this.rotation = e.rotation), "lit" in e && (this.lit = e.lit, this.applyLit()), n && (this.geodetic || this.matrixWorld || this.matrix ? this.applyTransform() : (e.position !== void 0 && this.raw.position.copy(e.position), e.scale !== void 0 && this.raw.scale.copy(e.scale), e.rotation !== void 0 && this.raw.rotation.set(e.rotation.x, e.rotation.y, e.rotation.z))), this.onPassKeyChange();
|
|
25934
|
+
e.matrix !== void 0 && (this.matrix = e.matrix), e.matrixWorld !== void 0 && (this.matrixWorld = e.matrixWorld), e.position !== void 0 && (this.position = e.position), e.scale !== void 0 && (this.scale = e.scale), e.rotation !== void 0 && (this.rotation = e.rotation), "lit" in e && (this.lit = e.lit, this.applyLit()), this.raw && (n && (this.geodetic || this.matrixWorld || this.matrix ? this.applyTransform() : (e.position !== void 0 && this.raw.position.copy(e.position), e.scale !== void 0 && this.raw.scale.copy(e.scale), e.rotation !== void 0 && this.raw.rotation.set(e.rotation.x, e.rotation.y, e.rotation.z))), this.onPassKeyChange());
|
|
25931
25935
|
}
|
|
25932
25936
|
onPassKeyChange() {
|
|
25933
25937
|
let e = this.getPassKey();
|
|
@@ -26690,7 +26694,7 @@ var oz = (e, t, n, r) => {
|
|
|
26690
26694
|
#include <packing>
|
|
26691
26695
|
|
|
26692
26696
|
in float batchId;
|
|
26693
|
-
out float nvr_vBatchId;
|
|
26697
|
+
flat out float nvr_vBatchId;
|
|
26694
26698
|
out vec3 vPosition;
|
|
26695
26699
|
|
|
26696
26700
|
${ON}
|
|
@@ -26716,7 +26720,7 @@ uniform float nvr_uPickable;
|
|
|
26716
26720
|
// uEffectIdsMask is declared by overrideMaterialsForMRT (#ifdef USE_SELECTIVE_EFFECT block)
|
|
26717
26721
|
${iz.fragment.UNIFORM_END}
|
|
26718
26722
|
|
|
26719
|
-
in float nvr_vBatchId;
|
|
26723
|
+
flat in float nvr_vBatchId;
|
|
26720
26724
|
|
|
26721
26725
|
${DN}
|
|
26722
26726
|
|
|
@@ -33747,11 +33751,11 @@ var OW = class {
|
|
|
33747
33751
|
dispose() {
|
|
33748
33752
|
this.canvas.remove(), this.canvasForImage.remove();
|
|
33749
33753
|
}
|
|
33750
|
-
}, AW = 5;
|
|
33751
|
-
function
|
|
33752
|
-
return e.distanceTo(t) <
|
|
33754
|
+
}, AW = 5, jW = 30;
|
|
33755
|
+
function MW(e, t, n = 5) {
|
|
33756
|
+
return e.distanceTo(t) < n;
|
|
33753
33757
|
}
|
|
33754
|
-
var
|
|
33758
|
+
var NW = 3, PW = 10, FW = class {
|
|
33755
33759
|
element;
|
|
33756
33760
|
pixelBuffer;
|
|
33757
33761
|
_renderer;
|
|
@@ -33765,15 +33769,16 @@ var MW = class {
|
|
|
33765
33769
|
onHoverCallback;
|
|
33766
33770
|
shouldClickPick;
|
|
33767
33771
|
shouldHoverPick;
|
|
33768
|
-
|
|
33769
|
-
|
|
33770
|
-
|
|
33772
|
+
pointerDownPosition;
|
|
33773
|
+
pointerDownHandler;
|
|
33774
|
+
pointerUpHandler;
|
|
33775
|
+
pointerCancelHandler;
|
|
33771
33776
|
hoverMoveHandler;
|
|
33772
33777
|
hoverLeaveHandler;
|
|
33773
33778
|
hoverPosition;
|
|
33774
33779
|
hoverRafId;
|
|
33775
33780
|
constructor(e, t, n, r, i, a, o, s, c) {
|
|
33776
|
-
this.element = e, this.pixelBuffer = /* @__PURE__ */ new Uint8Array(4), this._renderer = t, this._camera = n, this._meshes = r, this.onPickCallback = i, this.onHoverCallback = a, this.shouldClickPick = o, this.shouldHoverPick = s, this.
|
|
33781
|
+
this.element = e, this.pixelBuffer = /* @__PURE__ */ new Uint8Array(4), this._renderer = t, this._camera = n, this._meshes = r, this.onPickCallback = i, this.onHoverCallback = a, this.shouldClickPick = o, this.shouldHoverPick = s, this.pointerDownHandler = (e) => this.onPointerDown(e), this.pointerUpHandler = (e) => this.onPointerUp(e), this.pointerCancelHandler = () => this.onPointerCancel(), this.hoverMoveHandler = (e) => this.onHoverPointerMove(e), this.hoverLeaveHandler = () => this.onHoverPointerLeave();
|
|
33777
33782
|
let l = this._renderer.getContext().drawingBufferWidth, u = this._renderer.getContext().drawingBufferHeight;
|
|
33778
33783
|
this.pickRenderTarget = new In(l, u, {
|
|
33779
33784
|
format: on,
|
|
@@ -33785,17 +33790,27 @@ var MW = class {
|
|
|
33785
33790
|
stencilBuffer: !1
|
|
33786
33791
|
}));
|
|
33787
33792
|
}
|
|
33788
|
-
|
|
33789
|
-
|
|
33793
|
+
onPointerDown(e) {
|
|
33794
|
+
if (!e.isPrimary) {
|
|
33795
|
+
this.pointerDownPosition = void 0;
|
|
33796
|
+
return;
|
|
33797
|
+
}
|
|
33798
|
+
this.pointerDownPosition = new V(e.clientX, e.clientY);
|
|
33799
|
+
}
|
|
33800
|
+
onPointerUp(e) {
|
|
33801
|
+
if (!e.isPrimary) return;
|
|
33802
|
+
let t = this.pointerDownPosition;
|
|
33803
|
+
if (this.pointerDownPosition = void 0, !t || !this.shouldClickPick()) return;
|
|
33804
|
+
let n = e.pointerType === "touch" ? 30 : 5;
|
|
33805
|
+
MW(t, new V(e.clientX, e.clientY), n) && this.onClickPick(e);
|
|
33790
33806
|
}
|
|
33791
|
-
|
|
33792
|
-
|
|
33793
|
-
this.mouseDownPosition = void 0, t && this.shouldClickPick() && jW(t, new V(e.clientX, e.clientY)) && this.onMouseClick(e);
|
|
33807
|
+
onPointerCancel() {
|
|
33808
|
+
this.pointerDownPosition = void 0;
|
|
33794
33809
|
}
|
|
33795
33810
|
enablePick(e) {
|
|
33796
|
-
e ? (this.element.addEventListener("
|
|
33811
|
+
e ? (this.element.addEventListener("pointerdown", this.pointerDownHandler), this.element.addEventListener("pointerup", this.pointerUpHandler), this.element.addEventListener("pointercancel", this.pointerCancelHandler), this.element.addEventListener("pointermove", this.hoverMoveHandler), this.element.addEventListener("pointerleave", this.hoverLeaveHandler)) : (this.element.removeEventListener("pointerdown", this.pointerDownHandler), this.element.removeEventListener("pointerup", this.pointerUpHandler), this.element.removeEventListener("pointercancel", this.pointerCancelHandler), this.element.removeEventListener("pointermove", this.hoverMoveHandler), this.element.removeEventListener("pointerleave", this.hoverLeaveHandler), this.cancelPendingHoverPick());
|
|
33797
33812
|
}
|
|
33798
|
-
|
|
33813
|
+
onHoverPointerMove(e) {
|
|
33799
33814
|
e.buttons !== 0 || !this.shouldHoverPick() || (this.hoverPosition ||= new V(), this.hoverPosition.set(e.clientX, e.clientY), this.hoverRafId === void 0 && (this.hoverRafId = requestAnimationFrame(() => {
|
|
33800
33815
|
this.hoverRafId = void 0;
|
|
33801
33816
|
let e = this.hoverPosition;
|
|
@@ -33804,7 +33819,7 @@ var MW = class {
|
|
|
33804
33819
|
this.onHoverCallback(t > 0 ? [t] : []);
|
|
33805
33820
|
})));
|
|
33806
33821
|
}
|
|
33807
|
-
|
|
33822
|
+
onHoverPointerLeave() {
|
|
33808
33823
|
this.cancelPendingHoverPick(), this.shouldHoverPick() && this.onHoverCallback([]);
|
|
33809
33824
|
}
|
|
33810
33825
|
cancelPendingHoverPick() {
|
|
@@ -33834,18 +33849,26 @@ var MW = class {
|
|
|
33834
33849
|
renderDebugCanvas() {
|
|
33835
33850
|
!this.debugBufferView || !this.debugRenderTarget || (this.processRender(this.debugRenderTarget), this.debugBufferView.render(this._renderer, this.debugRenderTarget));
|
|
33836
33851
|
}
|
|
33837
|
-
|
|
33838
|
-
let t = this.pickBatchIdAt(e.clientX, e.clientY),
|
|
33839
|
-
this.onPickCallback(
|
|
33852
|
+
onClickPick(e) {
|
|
33853
|
+
let t = e.pointerType === "touch" ? 10 : 3, n = this.pickBatchIdAt(e.clientX, e.clientY, t), r = n > 0 ? [n] : [];
|
|
33854
|
+
this.onPickCallback(r);
|
|
33840
33855
|
}
|
|
33841
|
-
pickBatchIdAt(e, t) {
|
|
33842
|
-
let
|
|
33843
|
-
|
|
33856
|
+
pickBatchIdAt(e, t, n = 3) {
|
|
33857
|
+
let r = this.element.getBoundingClientRect(), i = e - r.left, a = t - r.top, o = this._renderer.getPixelRatio(), s = this._renderer.getContext().drawingBufferWidth, c = this._renderer.getContext().drawingBufferHeight, l = Math.max(0, Math.min(Math.floor(i * o), s - 1)), u = Math.max(0, Math.min(Math.floor(a * o), c - 1)), d = new V(l + .5, c - u - .5), f = c - 1 - u, p = Math.max(0, Math.round(n * o)), m = Math.max(0, l - p), h = Math.min(s - 1, l + p), g = Math.max(0, f - p), _ = Math.min(c - 1, f + p), v = h - m + 1, y = _ - g + 1;
|
|
33858
|
+
this._renderer.setScissor(m, g, v, y), this._renderer.setScissorTest(!0), this.processRender(this.pickRenderTarget, d), this.pixelBuffer.length < v * y * 4 && (this.pixelBuffer = new Uint8Array(v * y * 4)), this._renderer.readRenderTargetPixels(this.pickRenderTarget, m, g, v, y, this.pixelBuffer), this._renderer.setScissorTest(!1);
|
|
33859
|
+
let b = 0, x = Infinity;
|
|
33860
|
+
for (let e = 0; e < y; e++) for (let t = 0; t < v; t++) {
|
|
33861
|
+
let n = (e * v + t) * 4, r = (this.pixelBuffer[n] << 16) + (this.pixelBuffer[n + 1] << 8) + this.pixelBuffer[n + 2];
|
|
33862
|
+
if (r === 0) continue;
|
|
33863
|
+
let i = m + t - l, a = g + e - f, o = i * i + a * a;
|
|
33864
|
+
o < x && (x = o, b = r);
|
|
33865
|
+
}
|
|
33866
|
+
return b;
|
|
33844
33867
|
}
|
|
33845
33868
|
dispose() {
|
|
33846
33869
|
this.enablePick(!1), this.pickRenderTarget.dispose(), this.debugRenderTarget?.dispose(), this.debugBufferView?.dispose();
|
|
33847
33870
|
}
|
|
33848
|
-
},
|
|
33871
|
+
}, IW = class {
|
|
33849
33872
|
quad;
|
|
33850
33873
|
scene;
|
|
33851
33874
|
camera;
|
|
@@ -33874,10 +33897,10 @@ var MW = class {
|
|
|
33874
33897
|
dispose() {
|
|
33875
33898
|
this.quad.geometry.dispose(), this.material.dispose(), this.sampleTarget.dispose();
|
|
33876
33899
|
}
|
|
33877
|
-
},
|
|
33900
|
+
}, LW = class {
|
|
33878
33901
|
depthPickPass;
|
|
33879
33902
|
constructor() {
|
|
33880
|
-
this.depthPickPass = new
|
|
33903
|
+
this.depthPickPass = new IW();
|
|
33881
33904
|
}
|
|
33882
33905
|
pick(e, t, n, r, i) {
|
|
33883
33906
|
let a = this._sampleDepthAt(e, t, n, r);
|
|
@@ -33929,11 +33952,11 @@ var MW = class {
|
|
|
33929
33952
|
};
|
|
33930
33953
|
//#endregion
|
|
33931
33954
|
//#region src/plugins/AttributionPlugin/attribution.ts
|
|
33932
|
-
function
|
|
33955
|
+
function RW(e) {
|
|
33933
33956
|
return "attributionHtml" in e;
|
|
33934
33957
|
}
|
|
33935
|
-
function
|
|
33936
|
-
return
|
|
33958
|
+
function zW(e) {
|
|
33959
|
+
return RW(e) ? JSON.stringify(["html", e.attributionHtml]) : JSON.stringify([
|
|
33937
33960
|
"src",
|
|
33938
33961
|
e.attribution,
|
|
33939
33962
|
e.attributionUrl ?? null,
|
|
@@ -33947,23 +33970,23 @@ function IW(e) {
|
|
|
33947
33970
|
])
|
|
33948
33971
|
]);
|
|
33949
33972
|
}
|
|
33950
|
-
function
|
|
33973
|
+
function BW(e) {
|
|
33951
33974
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
33952
33975
|
for (let r of e) {
|
|
33953
|
-
let e =
|
|
33976
|
+
let e = zW(r);
|
|
33954
33977
|
t.has(e) || (t.add(e), n.push(r));
|
|
33955
33978
|
}
|
|
33956
33979
|
return n;
|
|
33957
33980
|
}
|
|
33958
|
-
function
|
|
33981
|
+
function VW(e) {
|
|
33959
33982
|
let t = /* @__PURE__ */ new Map();
|
|
33960
|
-
for (let n of e) for (let e of
|
|
33983
|
+
for (let n of e) for (let e of UW(n)) t.set(e, (t.get(e) ?? 0) + 1);
|
|
33961
33984
|
return Array.from(t.entries()).sort((e, t) => t[1] - e[1] || (e[0] < t[0] ? -1 : +(e[0] > t[0]))).map(([e]) => e);
|
|
33962
33985
|
}
|
|
33963
|
-
function
|
|
33986
|
+
function HW(e) {
|
|
33964
33987
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
33965
33988
|
}
|
|
33966
|
-
function
|
|
33989
|
+
function UW(e) {
|
|
33967
33990
|
let t = new DOMParser().parseFromString(e, "text/html"), n = [], r = "", i = () => {
|
|
33968
33991
|
let e = r.trim();
|
|
33969
33992
|
e && n.push(e), r = "";
|
|
@@ -33971,7 +33994,7 @@ function BW(e) {
|
|
|
33971
33994
|
e.childNodes.forEach((e) => {
|
|
33972
33995
|
if (e instanceof Text) {
|
|
33973
33996
|
(e.textContent ?? "").split(";").forEach((e, t) => {
|
|
33974
|
-
t > 0 && i(), r +=
|
|
33997
|
+
t > 0 && i(), r += HW(e);
|
|
33975
33998
|
});
|
|
33976
33999
|
return;
|
|
33977
34000
|
}
|
|
@@ -33984,10 +34007,10 @@ function BW(e) {
|
|
|
33984
34007
|
};
|
|
33985
34008
|
return a(t.body), i(), n;
|
|
33986
34009
|
}
|
|
33987
|
-
function
|
|
34010
|
+
function WW(e, t) {
|
|
33988
34011
|
return t === void 0 || !(e.minZoom !== void 0 && t < e.minZoom || e.maxZoom !== void 0 && t > e.maxZoom);
|
|
33989
34012
|
}
|
|
33990
|
-
function
|
|
34013
|
+
function GW(e) {
|
|
33991
34014
|
let t;
|
|
33992
34015
|
try {
|
|
33993
34016
|
t = new URL(e, "http://localhost/");
|
|
@@ -33996,49 +34019,49 @@ function HW(e) {
|
|
|
33996
34019
|
}
|
|
33997
34020
|
if (t.protocol === "http:" || t.protocol === "https:" || t.protocol === "mailto:") return e;
|
|
33998
34021
|
}
|
|
33999
|
-
function
|
|
34022
|
+
function KW(e, t) {
|
|
34000
34023
|
let n = document.createElement("a");
|
|
34001
34024
|
return n.href = e, n.target = "_blank", n.rel = "noopener noreferrer", t !== void 0 && (n.textContent = t), n;
|
|
34002
34025
|
}
|
|
34003
|
-
function
|
|
34004
|
-
|
|
34026
|
+
function qW(e, t) {
|
|
34027
|
+
JW(e, new DOMParser().parseFromString(t, "text/html").body);
|
|
34005
34028
|
}
|
|
34006
|
-
function
|
|
34029
|
+
function JW(e, t, n = !0) {
|
|
34007
34030
|
t.childNodes.forEach((t) => {
|
|
34008
34031
|
if (t instanceof Text) {
|
|
34009
|
-
n ?
|
|
34032
|
+
n ? ZW(e, t.textContent ?? "") : e.appendChild(document.createTextNode(t.textContent ?? ""));
|
|
34010
34033
|
return;
|
|
34011
34034
|
}
|
|
34012
34035
|
if (t instanceof HTMLAnchorElement) {
|
|
34013
|
-
let r = t.getAttribute("href"), i = r ?
|
|
34036
|
+
let r = t.getAttribute("href"), i = r ? GW(r) : void 0;
|
|
34014
34037
|
if (!i) {
|
|
34015
|
-
|
|
34038
|
+
JW(e, t, n);
|
|
34016
34039
|
return;
|
|
34017
34040
|
}
|
|
34018
|
-
let a =
|
|
34019
|
-
|
|
34041
|
+
let a = KW(i);
|
|
34042
|
+
JW(a, t, !1), e.appendChild(a);
|
|
34020
34043
|
return;
|
|
34021
34044
|
}
|
|
34022
|
-
t instanceof Element &&
|
|
34045
|
+
t instanceof Element && JW(e, t, n);
|
|
34023
34046
|
});
|
|
34024
34047
|
}
|
|
34025
|
-
var
|
|
34026
|
-
function
|
|
34048
|
+
var YW = /https?:\/\/[^\s]+/g, XW = /[.,;:!?)\]}'"]+$/;
|
|
34049
|
+
function ZW(e, t) {
|
|
34027
34050
|
let n = 0;
|
|
34028
|
-
for (let r of t.matchAll(
|
|
34029
|
-
let i = r.index ?? 0, a = r[0], o = a.match(
|
|
34051
|
+
for (let r of t.matchAll(YW)) {
|
|
34052
|
+
let i = r.index ?? 0, a = r[0], o = a.match(XW);
|
|
34030
34053
|
o && (a = a.slice(0, a.length - o[0].length)), i > n && e.appendChild(document.createTextNode(t.slice(n, i)));
|
|
34031
|
-
let s =
|
|
34032
|
-
s ? e.appendChild(
|
|
34054
|
+
let s = GW(a);
|
|
34055
|
+
s ? e.appendChild(KW(s, a)) : e.appendChild(document.createTextNode(a)), n = i + a.length;
|
|
34033
34056
|
}
|
|
34034
34057
|
n < t.length && e.appendChild(document.createTextNode(t.slice(n)));
|
|
34035
34058
|
}
|
|
34036
34059
|
//#endregion
|
|
34037
34060
|
//#region src/plugins/AttributionPlugin/attributionStyles.ts
|
|
34038
|
-
var
|
|
34061
|
+
var QW = "navara-attribution-styles", $W = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n <circle cx=\"12\" cy=\"12\" r=\"10.5\" stroke=\"currentColor\" stroke-width=\"2\" />\n <circle cx=\"12\" cy=\"8\" r=\"1\" fill=\"currentColor\" />\n <rect x=\"11\" y=\"11\" width=\"2\" height=\"6\" rx=\"1\" fill=\"currentColor\" />\n</svg>", eG = "\n.navara-attr-dock {\n position: fixed;\n right: 8px;\n bottom: 8px;\n z-index: 1000;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 10px;\n font-family: system-ui, sans-serif;\n}\n.navara-attr-dock--left {\n right: auto;\n left: 8px;\n align-items: flex-start;\n}\n.navara-attr-logoframe {\n position: fixed;\n left: 8px;\n bottom: 8px;\n z-index: 1000;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n/* Bottom-left mode: the ⓘ trigger (24px) occupies the far-left corner, so the\n logo frame starts to its right, keeping the two in a single row. */\n.navara-attr-logoframe--left {\n left: 40px;\n}\n.navara-attr-logo {\n height: 24px;\n width: auto;\n display: block;\n user-select: none;\n}\n.navara-attr-toggle {\n width: 24px;\n height: 24px;\n min-width: 24px;\n padding: 0;\n border-radius: 50%;\n cursor: pointer;\n background: var(--nvr-attr-bg, rgba(252, 253, 254, 0.92));\n border: 1px solid var(--nvr-attr-border, rgba(0, 0, 0, 0.1));\n box-shadow: 0 2px 8px rgba(20, 24, 28, 0.16);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--nvr-attr-link, #3a6595);\n}\n.navara-attr-toggle svg {\n width: 16px;\n height: 16px;\n display: block;\n}\n.navara-attr-card {\n width: 280px;\n max-width: calc(100vw - 16px);\n max-height: 340px;\n overflow-y: auto;\n background: var(--nvr-attr-bg, rgba(252, 253, 254, 0.96));\n border-radius: 14px;\n box-shadow: 0 10px 30px rgba(20, 24, 28, 0.16);\n color: var(--nvr-attr-text, #1b1f24);\n}\n.navara-attr-card[hidden] {\n display: none;\n}\n/* display:flex on these beats the UA [hidden] rule, so hide explicitly. */\n.navara-attr-dock[hidden],\n.navara-attr-logoframe[hidden] {\n display: none;\n}\n.navara-attr-head {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px;\n border-bottom: 1px solid var(--nvr-attr-border, rgba(0, 0, 0, 0.08));\n}\n.navara-attr-head h3 {\n margin: 0;\n font-size: 13.5px;\n font-weight: 600;\n color: var(--nvr-attr-title, inherit);\n}\n.navara-attr-close {\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 15px;\n line-height: 1;\n color: var(--nvr-attr-nested, rgba(27, 31, 36, 0.64));\n padding: 2px 4px;\n}\n.navara-attr-list {\n list-style: none;\n margin: 0;\n padding: 12px;\n}\n.navara-attr-item + .navara-attr-item {\n margin-top: 15px;\n}\n.navara-attr-name {\n display: flex;\n gap: 8px;\n font-size: 13px;\n font-weight: 500;\n overflow-wrap: anywhere;\n word-break: break-word;\n}\n.navara-attr-bullet {\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--nvr-attr-bullet, #3a6595);\n flex: none;\n margin-top: 6px;\n}\n.navara-attr-related {\n list-style: none;\n margin: 5px 0 0 13px;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 5px;\n}\n.navara-attr-related li {\n font-size: 12px;\n color: var(--nvr-attr-nested, rgba(27, 31, 36, 0.64));\n line-height: 1.5;\n overflow-wrap: anywhere;\n word-break: break-word;\n}\n.navara-attr-card a {\n color: var(--nvr-attr-link, #3a6595);\n text-decoration: none;\n}\n.navara-attr-card a:hover {\n text-decoration: underline;\n}\n", tG = 0, nG = {
|
|
34039
34062
|
attribution: "Navara",
|
|
34040
|
-
attributionUrl: "https://navara
|
|
34041
|
-
},
|
|
34063
|
+
attributionUrl: "https://navara.world/"
|
|
34064
|
+
}, rG = class extends Pl {
|
|
34042
34065
|
view;
|
|
34043
34066
|
items = [];
|
|
34044
34067
|
styleEl;
|
|
@@ -34060,17 +34083,17 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34060
34083
|
super(), this.style = e.style ?? {}, this.position = e.position ?? "bottom-right", this.boundKeydown = this.handleKeydown.bind(this), this.boundPreRender = this.handlePreRender.bind(this);
|
|
34061
34084
|
}
|
|
34062
34085
|
displayedItems() {
|
|
34063
|
-
return [
|
|
34086
|
+
return [nG, ...this.items];
|
|
34064
34087
|
}
|
|
34065
34088
|
async init(e, t) {
|
|
34066
34089
|
this.view = e, e.on("preRender", this.boundPreRender), this.apply();
|
|
34067
34090
|
}
|
|
34068
34091
|
add(e) {
|
|
34069
|
-
this.items =
|
|
34092
|
+
this.items = BW([...this.items, ...e]), this.apply();
|
|
34070
34093
|
}
|
|
34071
34094
|
remove(e) {
|
|
34072
|
-
let t = new Set(e.map(
|
|
34073
|
-
this.items = this.items.filter((e) => !t.has(
|
|
34095
|
+
let t = new Set(e.map(zW));
|
|
34096
|
+
this.items = this.items.filter((e) => !t.has(zW(e))), this.apply();
|
|
34074
34097
|
}
|
|
34075
34098
|
clear() {
|
|
34076
34099
|
this.items = [], this.apply();
|
|
@@ -34084,7 +34107,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34084
34107
|
if (!t) return [];
|
|
34085
34108
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
34086
34109
|
for (let i of e) {
|
|
34087
|
-
if (
|
|
34110
|
+
if (RW(i) || !i.creditLayerId || n.has(i.creditLayerId)) continue;
|
|
34088
34111
|
n.add(i.creditLayerId);
|
|
34089
34112
|
let e = t.findLayerById(i.creditLayerId);
|
|
34090
34113
|
e && r.push(e);
|
|
@@ -34118,19 +34141,19 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34118
34141
|
if (!this.view) return;
|
|
34119
34142
|
this.ensureDom();
|
|
34120
34143
|
let e = this.displayedItems();
|
|
34121
|
-
this.hasZoomBands = e.some((e) => !
|
|
34122
|
-
let t = e.some((e) => !
|
|
34144
|
+
this.hasZoomBands = e.some((e) => !RW(e) && (e.children?.some((e) => e.minZoom !== void 0 || e.maxZoom !== void 0) ?? !1)), this.lastZoomLevel = this.currentZoomLevel(), this.populateList(), this.populateLogos(), this.dock && (this.dock.hidden = !1);
|
|
34145
|
+
let t = e.some((e) => !RW(e) && !!e.logo);
|
|
34123
34146
|
this.logosEl && (this.logosEl.hidden = !t);
|
|
34124
34147
|
}
|
|
34125
34148
|
ensureDom() {
|
|
34126
34149
|
if (!this.styleEl) {
|
|
34127
|
-
let e = document.getElementById(
|
|
34150
|
+
let e = document.getElementById(QW);
|
|
34128
34151
|
if (e instanceof HTMLStyleElement) this.styleEl = e;
|
|
34129
34152
|
else {
|
|
34130
34153
|
let e = document.createElement("style");
|
|
34131
|
-
e.id =
|
|
34154
|
+
e.id = QW, e.textContent = eG, document.head.appendChild(e), this.styleEl = e;
|
|
34132
34155
|
}
|
|
34133
|
-
|
|
34156
|
+
tG += 1;
|
|
34134
34157
|
}
|
|
34135
34158
|
if (this.dock) return;
|
|
34136
34159
|
let e = document.createElement("div");
|
|
@@ -34146,7 +34169,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34146
34169
|
let a = document.createElement("ul");
|
|
34147
34170
|
a.className = "navara-attr-list", t.appendChild(n), t.appendChild(a);
|
|
34148
34171
|
let o = document.createElement("button");
|
|
34149
|
-
o.className = "navara-attr-toggle", o.type = "button", o.innerHTML =
|
|
34172
|
+
o.className = "navara-attr-toggle", o.type = "button", o.innerHTML = $W, o.setAttribute("aria-expanded", String(this.isOpen)), o.setAttribute("aria-label", this.isOpen ? "Hide attributions" : "Show attributions"), o.addEventListener("click", () => this.setOpen()), e.appendChild(t), e.appendChild(o), document.body.appendChild(e);
|
|
34150
34173
|
let s = document.createElement("div");
|
|
34151
34174
|
s.className = "navara-attr-logoframe", this.position === "bottom-left" && s.classList.add("navara-attr-logoframe--left"), document.body.appendChild(s), document.addEventListener("keydown", this.boundKeydown), this.dock = e, this.card = t, this.listEl = a, this.logosEl = s, this.toggle = o, this.applyStyle();
|
|
34152
34175
|
}
|
|
@@ -34168,21 +34191,21 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34168
34191
|
this.listEl.replaceChildren();
|
|
34169
34192
|
for (let e of this.displayedItems()) {
|
|
34170
34193
|
let { li: t, text: n } = this.createItemShell();
|
|
34171
|
-
if (
|
|
34172
|
-
|
|
34194
|
+
if (RW(e)) {
|
|
34195
|
+
qW(n, e.attributionHtml), this.listEl.appendChild(t);
|
|
34173
34196
|
continue;
|
|
34174
34197
|
}
|
|
34175
|
-
let r = e.attributionUrl ?
|
|
34176
|
-
r ? n.appendChild(
|
|
34198
|
+
let r = e.attributionUrl ? GW(e.attributionUrl) : void 0;
|
|
34199
|
+
r ? n.appendChild(KW(r, e.attribution)) : n.textContent = e.attribution;
|
|
34177
34200
|
let i = document.createElement("ul");
|
|
34178
34201
|
if (i.className = "navara-attr-related", e.children) for (let t of e.children) {
|
|
34179
|
-
if (!
|
|
34202
|
+
if (!WW(t, this.lastZoomLevel)) continue;
|
|
34180
34203
|
let e = document.createElement("li");
|
|
34181
|
-
|
|
34204
|
+
qW(e, t.attribution), i.appendChild(e);
|
|
34182
34205
|
}
|
|
34183
34206
|
if (e.creditLayerId) for (let t of this.layerCreditStrings(e.creditLayerId)) {
|
|
34184
34207
|
let e = document.createElement("li");
|
|
34185
|
-
|
|
34208
|
+
qW(e, t), i.appendChild(e);
|
|
34186
34209
|
}
|
|
34187
34210
|
i.childElementCount > 0 && t.appendChild(i), this.listEl.appendChild(t);
|
|
34188
34211
|
}
|
|
@@ -34196,7 +34219,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34196
34219
|
let r = t.credits.get(e);
|
|
34197
34220
|
r && n.push(r);
|
|
34198
34221
|
}
|
|
34199
|
-
return
|
|
34222
|
+
return VW(n);
|
|
34200
34223
|
}
|
|
34201
34224
|
requestRender() {
|
|
34202
34225
|
this.dock && this.isOpen && this.populateList();
|
|
@@ -34205,11 +34228,11 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34205
34228
|
if (this.logosEl) {
|
|
34206
34229
|
this.logosEl.replaceChildren();
|
|
34207
34230
|
for (let e of this.displayedItems()) {
|
|
34208
|
-
if (
|
|
34231
|
+
if (RW(e) || !e.logo) continue;
|
|
34209
34232
|
let t = document.createElement("img");
|
|
34210
34233
|
t.src = e.logo, t.alt = e.attribution, t.className = "navara-attr-logo", t.draggable = !1;
|
|
34211
|
-
let n = e.logoUrl ?
|
|
34212
|
-
n && (r =
|
|
34234
|
+
let n = e.logoUrl ? GW(e.logoUrl) : void 0, r = t;
|
|
34235
|
+
n && (r = KW(n), r.appendChild(t)), this.logosEl.appendChild(r);
|
|
34213
34236
|
}
|
|
34214
34237
|
}
|
|
34215
34238
|
}
|
|
@@ -34230,7 +34253,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34230
34253
|
}
|
|
34231
34254
|
teardownDom() {
|
|
34232
34255
|
for (let e of this.layerCleanups) e();
|
|
34233
|
-
this.layerCleanups = [], this.dock && (document.removeEventListener("keydown", this.boundKeydown), this.dock.remove()), this.logosEl?.remove(), this.styleEl && (
|
|
34256
|
+
this.layerCleanups = [], this.dock && (document.removeEventListener("keydown", this.boundKeydown), this.dock.remove()), this.logosEl?.remove(), this.styleEl && (tG = Math.max(0, tG - 1), tG === 0 && this.styleEl.remove()), this.dock = void 0, this.card = void 0, this.listEl = void 0, this.logosEl = void 0, this.toggle = void 0, this.styleEl = void 0, this.isOpen = !1, this.layerCredits.clear();
|
|
34234
34257
|
}
|
|
34235
34258
|
trackLayers(e) {
|
|
34236
34259
|
for (let e of this.layerCleanups) e();
|
|
@@ -34255,7 +34278,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34255
34278
|
}, t.on("featureCreated", n), t.on("featureRemoved", r), t.on("featureVisibilityChanged", i), t.on("deleted", o), this.layerCleanups.push(a);
|
|
34256
34279
|
}
|
|
34257
34280
|
}
|
|
34258
|
-
},
|
|
34281
|
+
}, iG = new L(16777215), aG = class extends Gt {
|
|
34259
34282
|
mainLight;
|
|
34260
34283
|
cascadedLights;
|
|
34261
34284
|
direction = new H(-1, -1, -1);
|
|
@@ -34272,7 +34295,7 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34272
34295
|
let n = this.mainLight;
|
|
34273
34296
|
for (let r = t; r < e; ++r) {
|
|
34274
34297
|
let e = n.clone();
|
|
34275
|
-
e.color.copy(
|
|
34298
|
+
e.color.copy(iG), this.add(e), this.add(e.target), this.cascadedLights[r] = e;
|
|
34276
34299
|
}
|
|
34277
34300
|
} else for (let n = e; n < t; ++n) {
|
|
34278
34301
|
let e = this.cascadedLights[n];
|
|
@@ -34291,11 +34314,11 @@ var YW = "navara-attribution-styles", XW = "<svg xmlns=\"http://www.w3.org/2000/
|
|
|
34291
34314
|
}
|
|
34292
34315
|
return this;
|
|
34293
34316
|
}
|
|
34294
|
-
},
|
|
34295
|
-
function
|
|
34296
|
-
if (!e) throw Error(
|
|
34317
|
+
}, oG = "Invariant failed";
|
|
34318
|
+
function sG(e, t) {
|
|
34319
|
+
if (!e) throw Error(oG);
|
|
34297
34320
|
}
|
|
34298
|
-
var
|
|
34321
|
+
var cG = class e {
|
|
34299
34322
|
near = [
|
|
34300
34323
|
new H(),
|
|
34301
34324
|
new H(),
|
|
@@ -34345,11 +34368,11 @@ var aG = class e {
|
|
|
34345
34368
|
for (let t = 0; t < 4; ++t) this.near[t].applyMatrix4(e), this.far[t].applyMatrix4(e);
|
|
34346
34369
|
return this;
|
|
34347
34370
|
}
|
|
34348
|
-
},
|
|
34349
|
-
function
|
|
34371
|
+
}, lG = "// Based on the following work:\n// https://github.com/StrandedKitty/three-csm/tree/master/src\n// https://github.com/mrdoob/three.js/tree/r169/examples/jsm/csm\n\nvoid cascadedFadedLights() {\n directionalLight = directionalLights[0];\n getDirectionalLightInfo(directionalLight, directLight);\n\n float clipDepth = vViewPosition.z / (csmFar - csmNear);\n bool lastCascade;\n vec2 cascade;\n float cascadeCenter;\n float closestEdge;\n float margin;\n float shadow = 1.0;\n float nextShadow = 1.0;\n\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n #if UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n #if UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n\n lastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADE_COUNT - 1;\n cascade = csmCascades[i];\n cascadeCenter = (cascade.x + cascade.y) * 0.5;\n closestEdge = clipDepth < cascadeCenter ? cascade.x : cascade.y;\n margin = 0.25 * pow(closestEdge, 2.0);\n cascade += margin * vec2(-0.5, 0.5);\n\n if (clipDepth >= cascade.x && (clipDepth < cascade.y || lastCascade)) {\n directionalLightShadow = directionalLightShadows[i];\n float prevShadow = nextShadow;\n nextShadow =\n directLight.visible && receiveShadow\n ? getShadow(\n directionalShadowMap[i],\n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias,\n directionalLightShadow.shadowRadius,\n vDirectionalShadowCoord[i]\n )\n : 1.0;\n\n shadow = mix(\n prevShadow,\n nextShadow,\n saturate(min(clipDepth - cascade.x, cascade.y - clipDepth) / margin)\n );\n }\n #endif // UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n #endif // UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n }\n #pragma unroll_loop_end\n\n // No loop here: all cascaded lights are in fact one light only.\n directLight.color *= shadow;\n #if defined(USE_GBUFFER_SHADOW) && !defined(USE_SHADOWMAP_DEPTH)\n // Feed the G-buffer shadow output (declared by gbuffer_pars_fragment).\n nvr_shadowMask *= shadow;\n #endif\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n\n // The rest of directional lights.\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n #if UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n #if UNROLLED_LOOP_INDEX >= CSM_CASCADE_COUNT\n directionalLight = directionalLights[i];\n getDirectionalLightInfo(directionalLight, directLight);\n\n directionalLightShadow = directionalLightShadows[i];\n {\n float nvrShadowFactor =\n directLight.visible && receiveShadow\n ? getShadow(\n directionalShadowMap[i],\n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias,\n directionalLightShadow.shadowRadius,\n vDirectionalShadowCoord[i]\n )\n : 1.0;\n directLight.color *= nvrShadowFactor;\n #if defined(USE_GBUFFER_SHADOW) && !defined(USE_SHADOWMAP_DEPTH)\n nvr_shadowMask *= nvrShadowFactor;\n #endif\n }\n\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n #endif // UNROLLED_LOOP_INDEX >= CSM_CASCADE_COUNT\n #endif // UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n }\n #pragma unroll_loop_end\n}\n", uG = "// Based on the following work:\n// https://github.com/StrandedKitty/three-csm/tree/master/src\n// https://github.com/mrdoob/three.js/tree/r169/examples/jsm/csm\n\nvoid cascadedLights() {\n directionalLight = directionalLights[0];\n getDirectionalLightInfo(directionalLight, directLight);\n\n float clipDepth = vViewPosition.z / (csmFar - csmNear);\n vec2 cascade;\n\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n #if UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n #if UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n cascade = csmCascades[i];\n directionalLightShadow = directionalLightShadows[i];\n if (clipDepth >= cascade.x && clipDepth < cascade.y) {\n float nvrShadowFactor =\n directLight.visible && receiveShadow\n ? getShadow(\n directionalShadowMap[i],\n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias,\n directionalLightShadow.shadowRadius,\n vDirectionalShadowCoord[i]\n )\n : 1.0;\n directLight.color *= nvrShadowFactor;\n #if defined(USE_GBUFFER_SHADOW) && !defined(USE_SHADOWMAP_DEPTH)\n // Feed the G-buffer shadow output (declared by gbuffer_pars_fragment).\n nvr_shadowMask *= nvrShadowFactor;\n #endif\n }\n #endif // UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n #endif // UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n }\n #pragma unroll_loop_end\n\n // No loop here: all cascaded lights are in fact one light only.\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n\n // The rest of directional lights.\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n #if UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n #if UNROLLED_LOOP_INDEX >= CSM_CASCADE_COUNT\n directionalLight = directionalLights[i];\n getDirectionalLightInfo(directionalLight, directLight);\n\n directionalLightShadow = directionalLightShadows[i];\n {\n float nvrShadowFactor =\n directLight.visible && receiveShadow\n ? getShadow(\n directionalShadowMap[i],\n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias,\n directionalLightShadow.shadowRadius,\n vDirectionalShadowCoord[i]\n )\n : 1.0;\n directLight.color *= nvrShadowFactor;\n #if defined(USE_GBUFFER_SHADOW) && !defined(USE_SHADOWMAP_DEPTH)\n nvr_shadowMask *= nvrShadowFactor;\n #endif\n }\n\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n #endif // UNROLLED_LOOP_INDEX >= CSM_CASCADE_COUNT\n #endif // UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n }\n #pragma unroll_loop_end\n}\n", dG = "// Based on the following work:\n// https://github.com/StrandedKitty/three-csm/tree/master/src\n// https://github.com/mrdoob/three.js/tree/r169/examples/jsm/csm\n\nvoid cascadedLightsWithoutShadows() {\n // No loop here: all cascaded lights are in fact one light only.\n getDirectionalLightInfo(directionalLights[0], directLight);\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n\n // The rest of directional lights.\n #pragma unroll_loop_start\n for (int i = CSM_CASCADE_COUNT; i < NUM_DIR_LIGHTS; i++) {\n directionalLight = directionalLights[i];\n getDirectionalLightInfo(directionalLight, directLight);\n\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n }\n #pragma unroll_loop_end\n}\n", fG = "// Default shader.\n// See: https://github.com/mrdoob/three.js/blob/r169/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js#L136\n\nvoid defaultLights() {\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n directionalLight = directionalLights[i];\n getDirectionalLightInfo(directionalLight, directLight);\n\n #if defined(USE_SHADOWMAP) && UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS\n directionalLightShadow = directionalLightShadows[i];\n {\n float nvrShadowFactor =\n directLight.visible && receiveShadow\n ? getShadow(\n directionalShadowMap[i],\n directionalLightShadow.shadowMapSize,\n directionalLightShadow.shadowIntensity,\n directionalLightShadow.shadowBias,\n directionalLightShadow.shadowRadius,\n vDirectionalShadowCoord[i]\n )\n : 1.0;\n directLight.color *= nvrShadowFactor;\n #if defined(USE_GBUFFER_SHADOW) && !defined(USE_SHADOWMAP_DEPTH)\n // Feed the G-buffer shadow output (declared by gbuffer_pars_fragment).\n nvr_shadowMask *= nvrShadowFactor;\n #endif\n }\n #endif\n\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n }\n #pragma unroll_loop_end\n}\n", pG = "void nonShadowCastingLights() {\n #pragma unroll_loop_start\n for (int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i++) {\n directionalLight = directionalLights[i];\n getDirectionalLightInfo(directionalLight, directLight);\n\n RE_Direct(\n directLight,\n geometryPosition,\n geometryNormal,\n geometryViewDir,\n geometryClearcoatNormal,\n material,\n reflectedLight\n );\n }\n #pragma unroll_loop_end\n}\n", mG = "\n #include <lights_pars_begin>\n\n #ifdef CSM\n uniform vec2 csmCascades[CSM_CASCADE_COUNT];\n uniform float csmNear;\n uniform float csmFar;\n #endif // CSM\n";
|
|
34372
|
+
function hG(e) {
|
|
34350
34373
|
return e.replace(/^\s*void\s+\w+\s*\(\s*\)\s*/m, "");
|
|
34351
34374
|
}
|
|
34352
|
-
var
|
|
34375
|
+
var gG = `
|
|
34353
34376
|
#if NUM_DIR_LIGHTS > 0 && defined(RE_Direct)
|
|
34354
34377
|
DirectionalLight directionalLight;
|
|
34355
34378
|
#if defined(USE_SHADOWMAP) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -34359,52 +34382,52 @@ var pG = `
|
|
|
34359
34382
|
#ifdef CSM
|
|
34360
34383
|
#ifdef USE_SHADOWMAP
|
|
34361
34384
|
#ifdef CSM_FADE
|
|
34362
|
-
${
|
|
34385
|
+
${hG(lG)}
|
|
34363
34386
|
#else
|
|
34364
|
-
${
|
|
34387
|
+
${hG(uG)}
|
|
34365
34388
|
#endif // CSM_FADE
|
|
34366
34389
|
#elif NUM_DIR_LIGHT_SHADOWS > 0
|
|
34367
|
-
${
|
|
34390
|
+
${hG(dG)}
|
|
34368
34391
|
#endif // USE_SHADOWMAP
|
|
34369
34392
|
|
|
34370
34393
|
#if NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS
|
|
34371
|
-
${
|
|
34394
|
+
${hG(pG)}
|
|
34372
34395
|
#endif
|
|
34373
34396
|
#else
|
|
34374
|
-
${fG
|
|
34397
|
+
${hG(fG)}
|
|
34375
34398
|
#endif // CSM
|
|
34376
34399
|
#endif // NUM_DIR_LIGHTS > 0 && defined(RE_Direct)
|
|
34377
34400
|
`;
|
|
34378
|
-
function
|
|
34401
|
+
function _G({ source: e, startLine: t, endLine: n, replacement: r }) {
|
|
34379
34402
|
let i = `\n${t}\n`, a = e.indexOf(i);
|
|
34380
34403
|
if (a < 0) return e;
|
|
34381
34404
|
let o = `\n${n}\n`, s = e.indexOf(o, a + i.length);
|
|
34382
34405
|
return s < 0 ? e : e.slice(0, a + 1) + r + e.slice(s + o.length - 1);
|
|
34383
34406
|
}
|
|
34384
|
-
function
|
|
34385
|
-
return e.replace("#include <lights_pars_begin>",
|
|
34407
|
+
function vG(e) {
|
|
34408
|
+
return e.replace("#include <lights_pars_begin>", mG).replace("#include <lights_fragment_begin>", _G({
|
|
34386
34409
|
source: hn.lights_fragment_begin,
|
|
34387
34410
|
startLine: "#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )",
|
|
34388
34411
|
endLine: "#endif",
|
|
34389
|
-
replacement:
|
|
34412
|
+
replacement: gG
|
|
34390
34413
|
}));
|
|
34391
34414
|
}
|
|
34392
|
-
var
|
|
34393
|
-
function
|
|
34415
|
+
var yG = "\n#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n// Per-cascade shadow matrices composed with the render camera's world matrix\n// on the CPU in f64 (shadow.matrix * camera.matrixWorld). Multiplied with the\n// view-space position instead of the absolute world position to avoid f32\n// cancellation at ECEF magnitudes.\n//\n// Only the CSM cascade lights (the first CSM_CASCADE_COUNT shadow indices,\n// matching the ordering assumption of the CSM fragment shader) get these\n// matrices; additional shadow-casting directional lights keep the stock\n// directionalShadowMatrix path. Outside a CSM material the define is absent —\n// treat every directional shadow as camera-composed then.\n#ifndef CSM_CASCADE_COUNT\n#define CSM_CASCADE_COUNT NUM_DIR_LIGHT_SHADOWS\n#endif\nuniform mat4 nvrCsmShadowMatrixView[ CSM_CASCADE_COUNT ];\n#endif\n";
|
|
34416
|
+
function bG(e, t, n) {
|
|
34394
34417
|
if (!e.includes(t)) throw Error(`Failed to replace "${t}" in shader code. The pattern was not found.`);
|
|
34395
34418
|
return e.replace(t, n);
|
|
34396
34419
|
}
|
|
34397
|
-
function
|
|
34420
|
+
function xG(e, t) {
|
|
34398
34421
|
if (e.defines?.USE_SHADOWMAP_DEPTH || !e.vertexShader.includes("#include <shadowmap_vertex>")) return;
|
|
34399
34422
|
e.uniforms.nvrCsmShadowMatrixView = t;
|
|
34400
|
-
let n =
|
|
34401
|
-
n =
|
|
34423
|
+
let n = bG(hn.shadowmap_vertex, "shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );", "#if UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n shadowWorldPosition = vec4( mvPosition.xyz + ( viewMatrix * vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0.0 ) ).xyz, 1.0 );\n #else\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n #endif");
|
|
34424
|
+
n = bG(n, "vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;", "#if UNROLLED_LOOP_INDEX < CSM_CASCADE_COUNT\n vDirectionalShadowCoord[ i ] = nvrCsmShadowMatrixView[ i ] * shadowWorldPosition;\n #else\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n #endif"), e.vertexShader = bG(bG(e.vertexShader, "#include <shadowmap_pars_vertex>", `#include <shadowmap_pars_vertex>\n${yG}`), "#include <shadowmap_vertex>", n);
|
|
34402
34425
|
}
|
|
34403
|
-
function
|
|
34426
|
+
function SG(e, t, n) {
|
|
34404
34427
|
n.length = e.length;
|
|
34405
34428
|
for (let r = 0; r < e.length; r++) (n[r] ?? (n[r] = new z())).multiplyMatrices(e[r].shadow.matrix, t);
|
|
34406
34429
|
}
|
|
34407
|
-
var
|
|
34430
|
+
var CG = class {
|
|
34408
34431
|
map = /* @__PURE__ */ new Map();
|
|
34409
34432
|
setup(e, t) {
|
|
34410
34433
|
if (this.map.has(e)) return e;
|
|
@@ -34414,7 +34437,7 @@ var bG = class {
|
|
|
34414
34437
|
let r = (e, r) => {
|
|
34415
34438
|
n.parameters = e, t.captureRenderer(r);
|
|
34416
34439
|
let i = t.cascades, a = t.mainCamera.near, o = Math.min(t.mainCamera.far, t.far), s = e.uniforms;
|
|
34417
|
-
s.csmCascades = { value: i }, s.csmNear = { value: a }, s.csmFar = { value: o }, e.fragmentShader =
|
|
34440
|
+
s.csmCascades = { value: i }, s.csmNear = { value: a }, s.csmFar = { value: o }, e.fragmentShader = vG(e.fragmentShader), xG(e, t.shadowMatricesViewUniform);
|
|
34418
34441
|
}, i = e.onBeforeCompile.bind(e), a = e.customProgramCacheKey.bind(e);
|
|
34419
34442
|
Object.prototype.hasOwnProperty.call(e, "hasOwnProperty") && (n.originalHandler = i), e.customProgramCacheKey = () => i.toString() + a(), e.onBeforeCompile = (...t) => {
|
|
34420
34443
|
let [n] = t;
|
|
@@ -34450,10 +34473,10 @@ var bG = class {
|
|
|
34450
34473
|
}
|
|
34451
34474
|
};
|
|
34452
34475
|
Math.PI / 180, 180 / Math.PI;
|
|
34453
|
-
function
|
|
34476
|
+
function wG(e, t, n) {
|
|
34454
34477
|
return (1 - n) * e + n * t;
|
|
34455
34478
|
}
|
|
34456
|
-
var
|
|
34479
|
+
var TG = {
|
|
34457
34480
|
uniform: (e, t, n, r, i = []) => {
|
|
34458
34481
|
for (let r = 0; r < e; ++r) i[r] = (t + (n - t) * (r + 1) / e) / n;
|
|
34459
34482
|
return i.length = e, i;
|
|
@@ -34465,15 +34488,15 @@ var SG = {
|
|
|
34465
34488
|
practical: (e, t, n, r = .5, i = []) => {
|
|
34466
34489
|
for (let a = 0; a < e; ++a) {
|
|
34467
34490
|
let o = (t + (n - t) * (a + 1) / e) / n, s = t * (n / t) ** ((a + 1) / e) / n;
|
|
34468
|
-
i[a] =
|
|
34491
|
+
i[a] = wG(o, s, r);
|
|
34469
34492
|
}
|
|
34470
34493
|
return i.length = e, i;
|
|
34471
34494
|
}
|
|
34472
34495
|
};
|
|
34473
|
-
function
|
|
34474
|
-
return
|
|
34496
|
+
function EG(e, t, n, r, i, a = []) {
|
|
34497
|
+
return TG[e](t, n, r, i, a);
|
|
34475
34498
|
}
|
|
34476
|
-
var
|
|
34499
|
+
var DG = /*#__PURE__*/ new H(), OG = /*#__PURE__*/ new H(), kG = /*#__PURE__*/ new z(), AG = /*#__PURE__*/ new z(), jG = /*#__PURE__*/ new cG(), MG = /*#__PURE__*/ new Fe(), NG = {
|
|
34477
34500
|
cascadeCount: 4,
|
|
34478
34501
|
mapSize: 2048,
|
|
34479
34502
|
far: 5e3,
|
|
@@ -34482,12 +34505,12 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34482
34505
|
margin: 200,
|
|
34483
34506
|
fade: !0,
|
|
34484
34507
|
disableLastCascadeCutoff: !1
|
|
34485
|
-
},
|
|
34508
|
+
}, PG = class {
|
|
34486
34509
|
mainCamera;
|
|
34487
34510
|
needsUpdateFrusta = !0;
|
|
34488
|
-
directionalLights = new
|
|
34489
|
-
materialStates = new
|
|
34490
|
-
mainFrustum = new
|
|
34511
|
+
directionalLights = new aG();
|
|
34512
|
+
materialStates = new CG();
|
|
34513
|
+
mainFrustum = new cG();
|
|
34491
34514
|
cascadedFrusta = [];
|
|
34492
34515
|
splits = [];
|
|
34493
34516
|
cascades = [];
|
|
@@ -34508,7 +34531,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34508
34531
|
return n();
|
|
34509
34532
|
} };
|
|
34510
34533
|
let { cascadeCount: r, mapSize: i, far: a, mode: o, lambda: s, margin: c, fade: l, disableLastCascadeCutoff: u } = {
|
|
34511
|
-
...
|
|
34534
|
+
...NG,
|
|
34512
34535
|
...t
|
|
34513
34536
|
};
|
|
34514
34537
|
this._far = a, this._mode = o, this._lambda = s, this._margin = c, this._fade = l, this._disableLastCascadeCutoff = u, this.cascadeCount = r, this.mapSize = i;
|
|
@@ -34524,7 +34547,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34524
34547
|
}
|
|
34525
34548
|
refreshShadowMatricesView() {
|
|
34526
34549
|
let e = this._renderer?.info.render.frame ?? -1;
|
|
34527
|
-
(e === -1 || e !== this._shadowMatricesViewFrame) && (this._shadowMatricesViewFrame = e,
|
|
34550
|
+
(e === -1 || e !== this._shadowMatricesViewFrame) && (this._shadowMatricesViewFrame = e, SG(this.directionalLights.cascadedLights, this.mainCamera.matrixWorld, this._shadowMatricesView));
|
|
34528
34551
|
}
|
|
34529
34552
|
rollbackMaterial(e) {
|
|
34530
34553
|
return this.materialStates.rollback(e);
|
|
@@ -34537,7 +34560,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34537
34560
|
}
|
|
34538
34561
|
updateCascades() {
|
|
34539
34562
|
let e = this.cascadeCount, t = this.splits;
|
|
34540
|
-
|
|
34563
|
+
EG(this.mode, e, this.mainCamera.near, Math.min(this.mainCamera.far, this.far), this.lambda, t), this.mainFrustum.setFromCamera(this.mainCamera, this.far), this.mainFrustum.split(t, this.cascadedFrusta);
|
|
34541
34564
|
let n = this.cascades;
|
|
34542
34565
|
for (let r = 0; r < e; ++r) (n[r] ?? (n[r] = new V())).set(t[r - 1] ?? 0, t[r] ?? 0);
|
|
34543
34566
|
this.disableLastCascadeCutoff && (n[e - 1].y = Infinity), n.length = e;
|
|
@@ -34552,7 +34575,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34552
34575
|
}
|
|
34553
34576
|
updateShadowBounds() {
|
|
34554
34577
|
let e = this.cascadedFrusta, t = this.directionalLights.cascadedLights;
|
|
34555
|
-
|
|
34578
|
+
sG(e.length === t.length);
|
|
34556
34579
|
for (let n = 0; n < e.length; ++n) {
|
|
34557
34580
|
let e = this.getFrustumRadius(this.cascadedFrusta[n]), r = t[n].shadow.camera;
|
|
34558
34581
|
r.left = -e, r.right = e, r.top = e, r.bottom = -e, r.near = 0, r.far = e * 2 + this.margin, r.updateProjectionMatrix();
|
|
@@ -34563,11 +34586,11 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34563
34586
|
}
|
|
34564
34587
|
update() {
|
|
34565
34588
|
this.needsUpdateFrusta && (this.needsUpdateFrusta = !1, this.updateFrusta());
|
|
34566
|
-
let e = this.directionalLights, t =
|
|
34589
|
+
let e = this.directionalLights, t = DG.copy(e.direction).normalize(), n = kG.lookAt(new H(), t, Gt.DEFAULT_UP), r = AG.multiplyMatrices(AG.copy(n).invert(), this.mainCamera.matrixWorld), i = this.margin, a = this.mapSize, o = this.cascadedFrusta, s = e.cascadedLights;
|
|
34567
34590
|
for (let e = 0; e < o.length; ++e) {
|
|
34568
|
-
let { near: c, far: l } =
|
|
34591
|
+
let { near: c, far: l } = jG.copy(o[e]).applyMatrix4(r), u = MG.makeEmpty();
|
|
34569
34592
|
for (let e = 0; e < 4; e++) u.expandByPoint(c[e]), u.expandByPoint(l[e]);
|
|
34570
|
-
let d = u.getCenter(
|
|
34593
|
+
let d = u.getCenter(OG);
|
|
34571
34594
|
d.z = u.max.z + i;
|
|
34572
34595
|
let f = s[e], { left: p, right: m, top: h, bottom: g } = f.shadow.camera, _ = (m - p) / a, v = (h - g) / a;
|
|
34573
34596
|
d.x = Math.round(d.x / _) * _, d.y = Math.round(d.y / v) * v, d.applyMatrix4(n), f.position.copy(d), f.target.position.copy(d), f.target.position.add(t);
|
|
@@ -34687,7 +34710,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34687
34710
|
for (let n = 0; n < t.length; ++n) t[n].shadow.blurSamples = e;
|
|
34688
34711
|
}
|
|
34689
34712
|
}
|
|
34690
|
-
},
|
|
34713
|
+
}, FG = class extends it {
|
|
34691
34714
|
csm;
|
|
34692
34715
|
displayFrustum = !0;
|
|
34693
34716
|
displayPlanes = !0;
|
|
@@ -34758,7 +34781,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34758
34781
|
let u = r.near, d = r.far;
|
|
34759
34782
|
o.setXYZ(0, d[0].x, d[0].y, d[0].z), o.setXYZ(1, d[3].x, d[3].y, d[3].z), o.setXYZ(2, d[2].x, d[2].y, d[2].z), o.setXYZ(3, d[1].x, d[1].y, d[1].z), o.setXYZ(4, u[0].x, u[0].y, u[0].z), o.setXYZ(5, u[3].x, u[3].y, u[3].z), o.setXYZ(6, u[2].x, u[2].y, u[2].z), o.setXYZ(7, u[1].x, u[1].y, u[1].z), o.needsUpdate = !0;
|
|
34760
34783
|
}
|
|
34761
|
-
},
|
|
34784
|
+
}, IG = class {
|
|
34762
34785
|
viewers = [];
|
|
34763
34786
|
lights;
|
|
34764
34787
|
enabled = !1;
|
|
@@ -34767,7 +34790,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34767
34790
|
}
|
|
34768
34791
|
render(e) {
|
|
34769
34792
|
if (!this.enabled || !e.shadowMap.enabled) return;
|
|
34770
|
-
let t = this.lights.children.find((e) => e instanceof
|
|
34793
|
+
let t = this.lights.children.find((e) => e instanceof aG);
|
|
34771
34794
|
if (this.viewers.length && t?.cascadedLights.length === this.viewers.length) {
|
|
34772
34795
|
this.viewers.forEach((t) => {
|
|
34773
34796
|
t && t.render(e);
|
|
@@ -34781,7 +34804,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34781
34804
|
}
|
|
34782
34805
|
});
|
|
34783
34806
|
}
|
|
34784
|
-
},
|
|
34807
|
+
}, LG = /* @__PURE__ */ Jn((/* @__PURE__ */ Kn(((e, t) => {
|
|
34785
34808
|
(function(n, r) {
|
|
34786
34809
|
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : n.Stats = r();
|
|
34787
34810
|
})(e, function() {
|
|
@@ -34835,7 +34858,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34835
34858
|
};
|
|
34836
34859
|
}, e;
|
|
34837
34860
|
});
|
|
34838
|
-
})))(), 1),
|
|
34861
|
+
})))(), 1), RG = 1e3, zG = class {
|
|
34839
34862
|
stats;
|
|
34840
34863
|
renderer;
|
|
34841
34864
|
drawCalls;
|
|
@@ -34848,7 +34871,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34848
34871
|
maxWasmMB = 1;
|
|
34849
34872
|
maxJsHeapMB = 1;
|
|
34850
34873
|
constructor(e, t) {
|
|
34851
|
-
this.stats = new
|
|
34874
|
+
this.stats = new LG.default(), this.renderer = e, this.memorySampler = t, this.drawCalls = this.stats.addPanel(new LG.default.Panel("Draws", "#0ff", "#002")), this.numTriangles = this.stats.addPanel(new LG.default.Panel("Triangles", "#0fff57", "#013a12")), this.memGeometries = this.stats.addPanel(new LG.default.Panel("Geometries", "#ffa100", "#301e00")), this.wasmMemory = this.stats.addPanel(new LG.default.Panel("WASM MB", "#f08", "#201")), this.jsMemory = this.stats.addPanel(new LG.default.Panel("JS MB", "#f4f", "#210")), this.stats.showPanel(0);
|
|
34852
34875
|
}
|
|
34853
34876
|
begin() {
|
|
34854
34877
|
this.renderer.beginRender(), this.stats.begin();
|
|
@@ -34860,7 +34883,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34860
34883
|
sampleMemory() {
|
|
34861
34884
|
if (!this.memorySampler) return;
|
|
34862
34885
|
let e = performance.now();
|
|
34863
|
-
if (e - this.lastMemorySampleAt <
|
|
34886
|
+
if (e - this.lastMemorySampleAt < RG) return;
|
|
34864
34887
|
this.lastMemorySampleAt = e;
|
|
34865
34888
|
let t = this.memorySampler();
|
|
34866
34889
|
t && (t.wasmMB !== void 0 && (this.maxWasmMB = Math.max(this.maxWasmMB, t.wasmMB), this.wasmMemory.update(t.wasmMB, t.budgetMB ?? this.maxWasmMB)), t.jsHeapMB !== void 0 && (this.maxJsHeapMB = Math.max(this.maxJsHeapMB, t.jsHeapMB), this.jsMemory.update(t.jsHeapMB, this.maxJsHeapMB)));
|
|
@@ -34868,7 +34891,7 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34868
34891
|
get dom() {
|
|
34869
34892
|
return this.stats.dom;
|
|
34870
34893
|
}
|
|
34871
|
-
},
|
|
34894
|
+
}, BG = 20, VG = {
|
|
34872
34895
|
r_scaler: 0,
|
|
34873
34896
|
g_scaler: 0,
|
|
34874
34897
|
b_scaler: 0,
|
|
@@ -34877,12 +34900,12 @@ var wG = /*#__PURE__*/ new H(), TG = /*#__PURE__*/ new H(), EG = /*#__PURE__*/ n
|
|
|
34877
34900
|
min_offset: 0,
|
|
34878
34901
|
boundary: 0,
|
|
34879
34902
|
epsilon: 0
|
|
34880
|
-
},
|
|
34881
|
-
async function
|
|
34903
|
+
}, HG = 6, UG = 3, WG = 2, GG = 200;
|
|
34904
|
+
async function KG(e, t, n) {
|
|
34882
34905
|
if (t.length === 0) return [];
|
|
34883
|
-
let r =
|
|
34884
|
-
|
|
34885
|
-
let a =
|
|
34906
|
+
let r = qG(e), i = n?.signal;
|
|
34907
|
+
eK(i);
|
|
34908
|
+
let a = JG(n?.level ?? r.maxZoom, r), o = n?.level == null ? r.minZoom : a, s = new Float64Array(t.length * 2);
|
|
34886
34909
|
t.forEach((e, t) => {
|
|
34887
34910
|
s[t * 2] = N(e.lng), s[t * 2 + 1] = N(e.lat);
|
|
34888
34911
|
});
|
|
@@ -34900,22 +34923,22 @@ async function UG(e, t, n) {
|
|
|
34900
34923
|
lng: e.lng,
|
|
34901
34924
|
height: void 0,
|
|
34902
34925
|
level: void 0
|
|
34903
|
-
})), d = /* @__PURE__ */ new Map(), f =
|
|
34926
|
+
})), d = /* @__PURE__ */ new Map(), f = $G(HG);
|
|
34904
34927
|
return await Promise.all([...l.values()].map(async (e) => {
|
|
34905
34928
|
let t = new Float64Array(e.indices.length * 2);
|
|
34906
34929
|
e.indices.forEach((e, n) => {
|
|
34907
34930
|
t[n * 2] = s[e * 2], t[n * 2 + 1] = s[e * 2 + 1];
|
|
34908
34931
|
});
|
|
34909
|
-
let n = await
|
|
34932
|
+
let n = await YG(r, e, a, o, d, f, i);
|
|
34910
34933
|
if (!n) return;
|
|
34911
|
-
let c = await
|
|
34934
|
+
let c = await ZG(r, n, t, i);
|
|
34912
34935
|
c && e.indices.forEach((e, t) => {
|
|
34913
34936
|
let r = c[t];
|
|
34914
34937
|
r !== void 0 && Number.isFinite(r) && (u[e].height = r, u[e].level = n.level);
|
|
34915
34938
|
});
|
|
34916
34939
|
})), u;
|
|
34917
34940
|
}
|
|
34918
|
-
function
|
|
34941
|
+
function qG(e) {
|
|
34919
34942
|
let t = e.url;
|
|
34920
34943
|
if (!t) throw TypeError("sampleTerrainMostDetailed: source.url is required");
|
|
34921
34944
|
if (e.type === "quantized-mesh") return {
|
|
@@ -34924,9 +34947,9 @@ function WG(e) {
|
|
|
34924
34947
|
geographic: e.geographic ?? !0,
|
|
34925
34948
|
tms: e.tms ?? !0,
|
|
34926
34949
|
minZoom: e.minZoom ?? 0,
|
|
34927
|
-
maxZoom: e.maxZoom ??
|
|
34950
|
+
maxZoom: e.maxZoom ?? BG,
|
|
34928
34951
|
token: e.token ?? void 0,
|
|
34929
|
-
decoder:
|
|
34952
|
+
decoder: VG
|
|
34930
34953
|
};
|
|
34931
34954
|
let n = e;
|
|
34932
34955
|
return {
|
|
@@ -34935,25 +34958,25 @@ function WG(e) {
|
|
|
34935
34958
|
geographic: !1,
|
|
34936
34959
|
tms: n.tms ?? !1,
|
|
34937
34960
|
minZoom: n.minZoom ?? 0,
|
|
34938
|
-
maxZoom: n.maxZoom ??
|
|
34961
|
+
maxZoom: n.maxZoom ?? BG,
|
|
34939
34962
|
token: void 0,
|
|
34940
34963
|
decoder: {
|
|
34941
|
-
...
|
|
34964
|
+
...VG,
|
|
34942
34965
|
...n.elevationDecoder
|
|
34943
34966
|
}
|
|
34944
34967
|
};
|
|
34945
34968
|
}
|
|
34946
|
-
function
|
|
34969
|
+
function JG(e, t) {
|
|
34947
34970
|
return Math.min(Math.max(Math.floor(e), t.minZoom), t.maxZoom);
|
|
34948
34971
|
}
|
|
34949
|
-
async function
|
|
34972
|
+
async function YG(e, t, n, r, i, a, o) {
|
|
34950
34973
|
let s = n;
|
|
34951
34974
|
for (; s >= r;) {
|
|
34952
|
-
let c = Math.max(s - (s === n ? 1 :
|
|
34975
|
+
let c = Math.max(s - (s === n ? 1 : UG) + 1, r), l = [];
|
|
34953
34976
|
for (let e = s; e >= c; e--) l.push(e);
|
|
34954
34977
|
let u = await Promise.all(l.map((r) => {
|
|
34955
34978
|
let s = n - r, c = t.x >> s, l = t.y >> s, u = F(e.url, e.geographic, e.tms, c, l, r), d = i.get(u);
|
|
34956
|
-
return d || (d = a(() =>
|
|
34979
|
+
return d || (d = a(() => XG(e, u, o)), i.set(u, d)), d.then((e) => ({
|
|
34957
34980
|
level: r,
|
|
34958
34981
|
x: c,
|
|
34959
34982
|
y: l,
|
|
@@ -34973,11 +34996,11 @@ async function KG(e, t, n, r, i, a, o) {
|
|
|
34973
34996
|
}
|
|
34974
34997
|
return null;
|
|
34975
34998
|
}
|
|
34976
|
-
async function
|
|
34999
|
+
async function XG(e, t, n) {
|
|
34977
35000
|
let r = {};
|
|
34978
35001
|
e.kind === "quantized-mesh" && (r.Accept = "application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"), e.token && (r.Authorization = `Bearer ${e.token}`);
|
|
34979
35002
|
for (let e = 0;; e++) {
|
|
34980
|
-
|
|
35003
|
+
eK(n);
|
|
34981
35004
|
let i;
|
|
34982
35005
|
try {
|
|
34983
35006
|
i = await fetch(t, {
|
|
@@ -34986,8 +35009,8 @@ async function qG(e, t, n) {
|
|
|
34986
35009
|
});
|
|
34987
35010
|
} catch (t) {
|
|
34988
35011
|
if (n?.aborted) throw t;
|
|
34989
|
-
if (e <
|
|
34990
|
-
await
|
|
35012
|
+
if (e < WG) {
|
|
35013
|
+
await tK(GG * 2 ** e);
|
|
34991
35014
|
continue;
|
|
34992
35015
|
}
|
|
34993
35016
|
return { kind: "failed" };
|
|
@@ -34998,22 +35021,22 @@ async function qG(e, t, n) {
|
|
|
34998
35021
|
};
|
|
34999
35022
|
if (i.status === 404 || i.status === 410) return { kind: "missing" };
|
|
35000
35023
|
if (i.status === 401 || i.status === 403) throw Error(`sampleTerrainMostDetailed: ${i.status} ${i.statusText} for ${t} — check the source's token`);
|
|
35001
|
-
if (i.status >= 500 && e <
|
|
35002
|
-
await
|
|
35024
|
+
if (i.status >= 500 && e < WG) {
|
|
35025
|
+
await tK(GG * 2 ** e);
|
|
35003
35026
|
continue;
|
|
35004
35027
|
}
|
|
35005
35028
|
return { kind: "failed" };
|
|
35006
35029
|
}
|
|
35007
35030
|
}
|
|
35008
|
-
async function
|
|
35031
|
+
async function ZG(e, t, n, r) {
|
|
35009
35032
|
if (e.kind === "quantized-mesh") {
|
|
35010
35033
|
let i = new Uint8Array(await t.response.arrayBuffer());
|
|
35011
|
-
return
|
|
35034
|
+
return eK(r), Se(i, e.geographic, t.x, t.y, t.level, n) ?? null;
|
|
35012
35035
|
}
|
|
35013
|
-
let i = await
|
|
35014
|
-
return
|
|
35036
|
+
let i = await QG(await t.response.blob());
|
|
35037
|
+
return eK(r), i ? Ce(i, e.decoder, t.x, t.y, t.level, n) ?? null : null;
|
|
35015
35038
|
}
|
|
35016
|
-
async function
|
|
35039
|
+
async function QG(e) {
|
|
35017
35040
|
if (Uv()) try {
|
|
35018
35041
|
let t = await XR(e);
|
|
35019
35042
|
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
@@ -35036,7 +35059,7 @@ async function YG(e) {
|
|
|
35036
35059
|
t.close();
|
|
35037
35060
|
}
|
|
35038
35061
|
}
|
|
35039
|
-
function
|
|
35062
|
+
function $G(e) {
|
|
35040
35063
|
let t = 0, n = [], r = () => {
|
|
35041
35064
|
t--, n.shift()?.();
|
|
35042
35065
|
};
|
|
@@ -35049,26 +35072,26 @@ function XG(e) {
|
|
|
35049
35072
|
}
|
|
35050
35073
|
};
|
|
35051
35074
|
}
|
|
35052
|
-
function
|
|
35075
|
+
function eK(e) {
|
|
35053
35076
|
if (e?.aborted) throw e.reason instanceof Error ? e.reason : new DOMException("The operation was aborted.", "AbortError");
|
|
35054
35077
|
}
|
|
35055
|
-
function
|
|
35078
|
+
function tK(e) {
|
|
35056
35079
|
return new Promise((t) => setTimeout(t, e));
|
|
35057
35080
|
}
|
|
35058
35081
|
//#endregion
|
|
35059
35082
|
//#region src/terrain/terrainHeightEvent.ts
|
|
35060
|
-
function
|
|
35083
|
+
function nK(e, t) {
|
|
35061
35084
|
return e.bits === t && e.height != null;
|
|
35062
35085
|
}
|
|
35063
35086
|
//#endregion
|
|
35064
35087
|
//#region src/worker/index.ts?url&worker
|
|
35065
|
-
var
|
|
35088
|
+
var rK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, iK = {
|
|
35066
35089
|
linear: 0,
|
|
35067
35090
|
quadInOut: 1,
|
|
35068
35091
|
cubicInOut: 2,
|
|
35069
35092
|
cubicOut: 3,
|
|
35070
35093
|
quinticInOut: 4
|
|
35071
|
-
},
|
|
35094
|
+
}, aK = class extends gr {
|
|
35072
35095
|
_camera;
|
|
35073
35096
|
_renderer;
|
|
35074
35097
|
_globe;
|
|
@@ -35311,9 +35334,9 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35311
35334
|
}
|
|
35312
35335
|
if (this._options = e, e.defaultAttribution !== !1 && !NN()) {
|
|
35313
35336
|
let t = typeof e.defaultAttribution == "object" ? e.defaultAttribution : void 0;
|
|
35314
|
-
this._attribution = new
|
|
35337
|
+
this._attribution = new rG(t), this.addPlugin(this._attribution);
|
|
35315
35338
|
}
|
|
35316
|
-
this._terrainPicker = new
|
|
35339
|
+
this._terrainPicker = new LW(), e.canvas?.addEventListener("contextmenu", (e) => {
|
|
35317
35340
|
e.preventDefault();
|
|
35318
35341
|
});
|
|
35319
35342
|
let t = new Ln({
|
|
@@ -35351,7 +35374,7 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35351
35374
|
let i = e.backgroundColor ? e.backgroundColor.toHex() : 0;
|
|
35352
35375
|
if (this._renderer.setClearColor(i), !e.disableAutoResize && !NN() && (window.addEventListener("resize", this._handleResize), this.pixelRatioMatchedMedia = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`), this.pixelRatioMatchedMedia.addEventListener("change", this._handleResize)), e.debug) {
|
|
35353
35376
|
let t = e.container || this._renderer.domElement.parentElement;
|
|
35354
|
-
t && (this._stats = new
|
|
35377
|
+
t && (this._stats = new zG({
|
|
35355
35378
|
beginRender: () => this._renderer.info.reset(),
|
|
35356
35379
|
endRender: () => ({
|
|
35357
35380
|
...this._renderer.info.render,
|
|
@@ -35401,9 +35424,9 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35401
35424
|
this.layersManager.emitById(e, t, ...n);
|
|
35402
35425
|
}), this._renderFlag.animation = !!e.animation, this._camera.on("frustumChanged", () => {
|
|
35403
35426
|
this.renderPassOrchestrator.effectComposer.setMainCamera(this._camera.raw);
|
|
35404
|
-
}), this.shadowMapViewers = new
|
|
35427
|
+
}), this.shadowMapViewers = new IG(this._scenes.light);
|
|
35405
35428
|
}
|
|
35406
|
-
|
|
35429
|
+
convertToMapEvent(e) {
|
|
35407
35430
|
let t = this._renderer.domElement.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top, i = LN(this, n, r);
|
|
35408
35431
|
return i ? Object.assign(e, { map: {
|
|
35409
35432
|
x: i.x,
|
|
@@ -35518,7 +35541,7 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35518
35541
|
isMobile: t,
|
|
35519
35542
|
poolSize: n.total
|
|
35520
35543
|
});
|
|
35521
|
-
zv(
|
|
35544
|
+
zv(rK, n, { maxWorkerHeapBytes: this._options.memoryBudget?.maxWorkerHeapBytes ?? r.maxWorkerHeapBytes }), await Promise.all([e(), bf()]), this._core = new l(oK()), this._core.start();
|
|
35522
35545
|
let i = this._options.cacheBytes ?? r.cacheBytes;
|
|
35523
35546
|
this._options.cacheBytes = i, this._core.setCacheBytes(i), this._core.setMaxPendingRequests(this._options.memoryBudget?.maxPendingRequests ?? r.maxPendingRequests), this._core.setSseMultiplierRange(this._options.memoryBudget?.sseMultiplierMin ?? r.sseMultiplierMin, this._options.memoryBudget?.sseMultiplierMax ?? r.sseMultiplierMax);
|
|
35524
35547
|
let a = NR({ isMobile: t });
|
|
@@ -35568,26 +35591,32 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35568
35591
|
}), this.registerBuiltIns(), NN() || (this._eventDisposer = nW(this._core, this._renderer.domElement, () => {
|
|
35569
35592
|
let e = this._renderer.domElement.getBoundingClientRect(), t = this.pickDepthPosition(e.left + e.width / 2, e.top + e.height / 2);
|
|
35570
35593
|
return t ? this._camera.raw.position.distanceTo(t) : null;
|
|
35571
|
-
}), this._pickHelper = new
|
|
35594
|
+
}), this._pickHelper = new FW(this._renderer.domElement, this._renderer, this._camera.raw, this._meshes, this.onPick.bind(this), this.onHoverPick.bind(this), () => !!this.size("featureClick"), () => !!(this.size("featureHover") || this.size("featureEnter") || this.size("featureLeave"))), this._pickHelper.enablePick(this._options.picking ?? !0)), this.initializeRenderPass(), this.viewContext._setRenderPass(this.renderPass), Vv().catch((e) => console.error("Failed to warm up the worker pool:", e)), await Promise.all(this.plugins.map((e) => e.init(this, this.viewContext))), this._startMainLoop();
|
|
35572
35595
|
let c = new V();
|
|
35573
|
-
this._renderer.getSize(c), this.resize(c.width, c.height, this._renderer.getPixelRatio()), this._camera.core = this._core
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
let t = this.
|
|
35578
|
-
t && this.emit("
|
|
35579
|
-
}), this._renderer.domElement.addEventListener("
|
|
35580
|
-
let t = this.
|
|
35581
|
-
t && this.emit("
|
|
35582
|
-
}), this._renderer.domElement.addEventListener("
|
|
35583
|
-
let t = this.
|
|
35584
|
-
t && this.emit("
|
|
35585
|
-
}), this._renderer.domElement.addEventListener("
|
|
35586
|
-
let t = this.
|
|
35587
|
-
t && this.emit("
|
|
35588
|
-
}), this._renderer.domElement.addEventListener("
|
|
35589
|
-
let t = this.
|
|
35590
|
-
t && this.emit("
|
|
35596
|
+
this._renderer.getSize(c), this.resize(c.width, c.height, this._renderer.getPixelRatio()), this._camera.core = this._core;
|
|
35597
|
+
let u;
|
|
35598
|
+
this._renderer.domElement.addEventListener("pointerdown", (e) => {
|
|
35599
|
+
u = e.isPrimary && e.button === 0 ? new V(e.clientX, e.clientY) : void 0;
|
|
35600
|
+
let t = this.convertToMapEvent(e);
|
|
35601
|
+
t && this.emit("pointerdown", t);
|
|
35602
|
+
}), this._renderer.domElement.addEventListener("pointerenter", (e) => {
|
|
35603
|
+
let t = this.convertToMapEvent(e);
|
|
35604
|
+
t && this.emit("pointerenter", t);
|
|
35605
|
+
}), this._renderer.domElement.addEventListener("pointerleave", (e) => {
|
|
35606
|
+
let t = this.convertToMapEvent(e);
|
|
35607
|
+
t && this.emit("pointerleave", t);
|
|
35608
|
+
}), this._renderer.domElement.addEventListener("pointermove", (e) => {
|
|
35609
|
+
let t = this.convertToMapEvent(e);
|
|
35610
|
+
t && this.emit("pointermove", t);
|
|
35611
|
+
}), this._renderer.domElement.addEventListener("pointerup", (e) => {
|
|
35612
|
+
let t = this.convertToMapEvent(e);
|
|
35613
|
+
if (t && this.emit("pointerup", t), !e.isPrimary || e.button !== 0) return;
|
|
35614
|
+
let n = u;
|
|
35615
|
+
if (u = void 0, !n || !t) return;
|
|
35616
|
+
let r = e.pointerType === "touch" ? 30 : 5;
|
|
35617
|
+
MW(n, new V(e.clientX, e.clientY), r) && this.emit("click", t);
|
|
35618
|
+
}), this._renderer.domElement.addEventListener("pointercancel", (e) => {
|
|
35619
|
+
u = void 0, this.emit("pointercancel", e);
|
|
35591
35620
|
});
|
|
35592
35621
|
}
|
|
35593
35622
|
dispose() {
|
|
@@ -35677,33 +35706,52 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35677
35706
|
addSource(e) {
|
|
35678
35707
|
return W(this._core), W(e.type), new AH(this._core.addSource(e), e.type, this._core);
|
|
35679
35708
|
}
|
|
35709
|
+
_trackAsyncCreate(e, t, n, r) {
|
|
35710
|
+
if (!(n instanceof Promise)) {
|
|
35711
|
+
r();
|
|
35712
|
+
return;
|
|
35713
|
+
}
|
|
35714
|
+
n.then(r, (n) => {
|
|
35715
|
+
console.error(`Failed to create ${e} descriptor:`, n), t.emit("error", n);
|
|
35716
|
+
});
|
|
35717
|
+
}
|
|
35680
35718
|
addMesh(e) {
|
|
35681
35719
|
let t = this.registries.mesh.findMeshType(e);
|
|
35682
35720
|
if (!t) throw new Bk("mesh", e);
|
|
35683
35721
|
let n = this.registries.mesh.create(t, e);
|
|
35684
|
-
|
|
35685
|
-
|
|
35686
|
-
|
|
35687
|
-
|
|
35688
|
-
|
|
35689
|
-
|
|
35722
|
+
this._trackAsyncCreate("mesh", n, n.onCreate(), () => {
|
|
35723
|
+
if (!n.destroyed) {
|
|
35724
|
+
if (n.update && this.on("preRender", n.update.bind(n)), n.onResize) {
|
|
35725
|
+
this.on("resize", n.onResize.bind(n));
|
|
35726
|
+
let e = this._getCanvasSize();
|
|
35727
|
+
e && n.onResize(e.width, e.height);
|
|
35728
|
+
}
|
|
35729
|
+
n.on("needsUpdate", this.forceUpdate), this.forceUpdate();
|
|
35730
|
+
}
|
|
35731
|
+
});
|
|
35690
35732
|
let r = new QL(n);
|
|
35691
|
-
return this.layersManager.add(r), r;
|
|
35733
|
+
return r.on("deleted", this.forceUpdate), this.layersManager.add(r), r;
|
|
35692
35734
|
}
|
|
35693
35735
|
addLight(e) {
|
|
35694
35736
|
let t = this.registries.light.findLightType(e);
|
|
35695
35737
|
if (!t) throw new Bk("light", e);
|
|
35696
35738
|
let n = this.registries.light.create(t, e);
|
|
35697
|
-
|
|
35739
|
+
this._trackAsyncCreate("light", n, n.onCreate(), () => {
|
|
35740
|
+
n.destroyed || (n.update && this.on("preRender", n.update.bind(n)), n.on("needsUpdate", this.forceUpdate), this.forceUpdate());
|
|
35741
|
+
});
|
|
35698
35742
|
let r = new $L(n);
|
|
35699
|
-
return this.layersManager.add(r), r;
|
|
35743
|
+
return r.on("deleted", this.forceUpdate), this.layersManager.add(r), r;
|
|
35700
35744
|
}
|
|
35701
35745
|
addEffect(e) {
|
|
35702
35746
|
let t = this.registries.effect.findEffectType(e);
|
|
35703
35747
|
if (!t) throw new Bk("effect", e);
|
|
35704
35748
|
this._assertGBufferCapacity(t);
|
|
35705
35749
|
let n = this.registries.effect.create(t, e), r = new eR(n);
|
|
35706
|
-
return this.layersManager.add(r), this._syncGBuffers(), r.on("deleted",
|
|
35750
|
+
return this.layersManager.add(r), this._syncGBuffers(), r.on("deleted", () => {
|
|
35751
|
+
this._syncGBuffers(), this.forceUpdate();
|
|
35752
|
+
}), this._trackAsyncCreate("effect", n, n.onCreate(), () => {
|
|
35753
|
+
n.destroyed || (n.update && this.on("preRender", n.update.bind(n)), n.on("needsUpdate", this.forceUpdate), this.forceUpdate());
|
|
35754
|
+
}), r;
|
|
35707
35755
|
}
|
|
35708
35756
|
_syncGBuffers = () => {
|
|
35709
35757
|
let e = [];
|
|
@@ -35821,7 +35869,7 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35821
35869
|
n.lng,
|
|
35822
35870
|
n.lat,
|
|
35823
35871
|
n.height ?? 0
|
|
35824
|
-
]), i = this._core?.flyTo(r, n.pitch, n.heading, n.roll, t.duration, t.maxHeight, n.distance, t.easing === void 0 ? void 0 :
|
|
35872
|
+
]), i = this._core?.flyTo(r, n.pitch, n.heading, n.roll, t.duration, t.maxHeight, n.distance, t.easing === void 0 ? void 0 : iK[t.easing]);
|
|
35825
35873
|
return i === void 0 ? Promise.resolve(!1) : new Promise((e) => {
|
|
35826
35874
|
this._pendingFlights.set(i, e);
|
|
35827
35875
|
});
|
|
@@ -35865,12 +35913,12 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35865
35913
|
W(this._core);
|
|
35866
35914
|
let r = e instanceof AH ? e.id : e, i = this._core.getSourceDescription(r);
|
|
35867
35915
|
if (i?.type !== "quantized-mesh" && i?.type !== "raster-dem") throw Error(`sampleTerrainMostDetailed: source "${r}" is not a registered quantized-mesh or raster-dem source`);
|
|
35868
|
-
return
|
|
35916
|
+
return KG(i, t, n);
|
|
35869
35917
|
}
|
|
35870
35918
|
observeTerrainHeightAt(e, t) {
|
|
35871
35919
|
if (!this._core) return () => {};
|
|
35872
35920
|
let n = new m(Cf(e.lat), Cf(e.lng), 0), r = this._core.registerSampleTerrainHeightEvent(n), i = (e) => {
|
|
35873
|
-
|
|
35921
|
+
nK(e, r) && t(e.height);
|
|
35874
35922
|
};
|
|
35875
35923
|
return this.on("_sample_terrain_height_received", i), () => {
|
|
35876
35924
|
this._core?.unregisterSampleTerrainHeightEvent(r), this.off("_sample_terrain_height_received", i);
|
|
@@ -35964,10 +36012,10 @@ var eK = "" + new URL("assets/index-VfUncKuS.js", import.meta.url).href, tK = {
|
|
|
35964
36012
|
return this._terrainPicker.pick(e, t, this._renderer, this.depthTexture, this._camera.raw);
|
|
35965
36013
|
}
|
|
35966
36014
|
};
|
|
35967
|
-
function
|
|
36015
|
+
function oK() {
|
|
35968
36016
|
return Math.random().toString(36).slice(2);
|
|
35969
36017
|
}
|
|
35970
36018
|
//#endregion
|
|
35971
|
-
export { kE as ATMOSPHERE_HIGHER_ORDER_SCATTERING_URL, OE as ATMOSPHERE_IRRADIANCE_URL, DE as ATMOSPHERE_SCATTERING_URL, AE as ATMOSPHERE_SINGLE_MIE_SCATTERING_URL, RE as ATMOSPHERE_TEXTURE_URLS, EE as ATMOSPHERE_TRANSMITTANCE_URL, cW as AllDepthCopyPass, Sk as Atmosphere,
|
|
36019
|
+
export { kE as ATMOSPHERE_HIGHER_ORDER_SCATTERING_URL, OE as ATMOSPHERE_IRRADIANCE_URL, DE as ATMOSPHERE_SCATTERING_URL, AE as ATMOSPHERE_SINGLE_MIE_SCATTERING_URL, RE as ATMOSPHERE_TEXTURE_URLS, EE as ATMOSPHERE_TRANSMITTANCE_URL, cW as AllDepthCopyPass, Sk as Atmosphere, rG as AttributionPlugin, Mz as BATCHED_ATTRIBUTE_NAMES, jz as BATCH_TEXTURE_ROW, Nk as BaseDesc, ZL as BaseHandle, Qz as BatchedFeatureMesh, SH as BatchedSdfTextMesh, kW as BufferView, AW as CLICK_PIXEL_TOLERANCE, ME as CLOUD_LOCAL_WEATHER_URL, PE as CLOUD_SHAPE_DETAIL_URL, NE as CLOUD_SHAPE_URL, FE as CLOUD_TURBULENCE_URL, FG as CSMHelper, r as CameraDirection, PG as CascadedShadowMaps, Ck as Color, Ml as ColorMap, Vk as ConflictingTransformError, Mk as CopyPass, Ak as CustomEffectPass, mW as CustomRenderPass, Dk as DEFAULT_EFFECT_OPTIONS, oW as DEPTH_PACKING_SHADER, Ek as DescRegistry, EH as DrapedMesh, kk as Effect, Pk as EffectDesc, Fk as EffectDescRegistry, eR as EffectHandle, yf as EllipsoidGeodesic, gr as EventHandler, kH as FeatureEvaluator, fB as FeatureMesh, rW as FinalCopyEffectDesc, GN as GBUFFER_ATTACHMENT_NAMES, rP as GBUFFER_DEFINE_NAMES, QN as GBUFFER_EFFECT_ID_LOCATION_DEFINE, sP as GBUFFER_EFFECT_WRITE_BUILTIN, lP as GBUFFER_EFFECT_WRITE_ID_ONLY, cP as GBUFFER_EFFECT_WRITE_SHADER_MATERIAL, uP as GBUFFER_EFFECT_WRITE_ZERO, eP as GBUFFER_EMISSIVE_LOCATION_DEFINE, XN as GBUFFER_NORMAL_LOCATION_DEFINE, oP as GBUFFER_NORMAL_WRITE_BASIC, aP as GBUFFER_NORMAL_WRITE_PHYSICAL, YN as GBUFFER_PARS_FRAGMENT, nP as GBUFFER_SHADOW_LOCATION_DEFINE, WN as GBUFFER_TEXTURE_INDEX, QR as GEOMETRY_TYPES, HV as GlyphKind, mB as InstancedMesh, YL as InstancedMeshDesc, VV as InstancedSpriteMesh, zE as JAPAN_GSI_ELEVATION_DECODER, jH as Layer, XL as LightDesc, Ik as LightDescRegistry, $L as LightHandle, BE as MAPBOX_ELEVATION_DECODER, Iz as MAX_BATCH_TEXTURE_WIDTH, pR as MB, Kz as MODEL_BATCH_TEXTURE_CONFIG, gW as MRTPassEffectDesc, LL as MeshDesc, Lk as MeshDescRegistry, RL as MeshDescWithSelectiveEffect, QL as MeshHandle, qz as ModelMesh, aW as NORMAL_PACKING_SHADER, EL as NVR_BLENDED_DEFINE, CL as NVR_LIT_DEFINE, wL as NVR_UNLIT_DEFINE, TL as NVR_UNLIT_SCENE_DEFINE, uW as NormalCopyPass, NW as PICK_RADIUS, Xz as POLYGON_BATCH_TEXTURE_ROWS, Zz as POLYLINE_BATCH_TEXTURE_ROWS, Ok as Pass, yV as PickableInstancedMeshWrapper, Jz as PickableMesh, vV as PickableMeshWrapper, bV as PickableMultiInstancedMeshWrapper, Pl as Plugin, oB as PolygonMesh, dB as PolygonOutlineMesh, lB as PolylineMesh, ff as RTE_ONE_UNIFORM, Rk as Registries, jk as RenderPass, fW as RenderTargetCopyPass, DH as SKY_RENDER_ORDER, jE as STARS_ASSETS_URL, OH as STARS_RENDER_ORDER, IE as STBN_URL, vW as SelectiveEffectDesc, nR as SelectiveEffectRegistry, Hk as ShaderLib, yW as SkyEnvMapEffectDesc, hW as SkyEnvMapPass, AH as Source, jW as TAP_PIXEL_TOLERANCE, VE as TERRARIUM_ELEVATION_DECODER, LF as TILE_EMISSIVE_EFFECT_BUFFER_REPLACEMENT, IF as TILE_NORMAL_BUFFER_REPLACEMENT, RF as TILE_PICK_FRAGMENT_OVERRIDE, zF as TILE_VERTEX_INJECTIONS, PW as TOUCH_PICK_RADIUS, fV as TileMesh, bW as TransparentPassEffectDesc, $N as USE_GBUFFER_EMISSIVE_DEFINE, ZN as USE_GBUFFER_SELECTIVE_EFFECT_DEFINE, tP as USE_GBUFFER_SHADOW_DEFINE, Bk as UnknownTypeError, $R as VALID_GEOMETRY_TYPES, rR as ViewContext, jF as WATERMASK_OCEAN_REFLECTIVITY, MF as WATERMASK_OCEAN_ROUGHNESS, LE as WATER_NORMAL_URL, fP as appendOptionalGBufferAttachments, DL as applyLitOption, FL as assertNoTransformConflict, Vz as batchBaseIndex, zN as blendFunction, mH as breakLines, _H as buildLabelLayout, vf as calcCameraPosition, mf as calcModelMatrixRTE, NC as cascadedShadowMaps, hf as composeWorldMatrixForRTE, iP as computeGBufferDefines, JN as computeGBufferTextureIndex, Tf as convertScreenToWorld, Nf as convertWorldToScreen, _W as createFullscreenQuad, dP as createGBufferAttachments, pF as createInstancedSpriteMaterialEnhancer, MP as createPolygonMaterialEnhancer, tF as createPolylineMaterialEnhancer, IN as createReplacer, AF as createSdfTextMaterialEnhancer, zP as createShadowMapDepthEnhancer, aK as default, Cf as degreeToRadian, PC as depth, Df as eastNorthUpToFixedFrame, Nz as encodeFloatToRGBA, pf as encodePositionRTE, zl as fetchFontFamilyFromCss, NF as generateTileCommonInjection, PF as generateTileMapFragment, FF as generateTileNormalFragmentMaps, FC as generators, Ef as geodeticSurfaceNormal, xf as geodeticToVector3, Bz as getBatchDataTexture, TR as getDefaultCacheBytes, HR as getDefaultDynamicSse, BR as getDefaultLodFog, PR as getDefaultMemoryBudgets, df as getHeightFromEllipsoid, lf as getPickRay, cf as getPlaneFromPointNormal, uf as getRayPlaneIntersection, zz as getRowIndex, Rf as getWGS84Eccentricity, If as getWGS84EccentricitySquared, Lf as getWGS84Flattening, Pf as getWGS84SemiMajorAxis, Ff as getWGS84SemiMinorAxis, Mf as headingPitchRollToFixedFrame, Rz as initBatchDataTexture, Lz as initBatchedMaterial, bf as initNavaraApi, IC as interleavedGradientNoise, RW as isAttributionHtml, pB as isFeatureMesh, Yz as isPickableMesh, pH as isRtlText, dH as lineWidthFu, LC as math, IL as mergeGeodetic, Of as northEastDownToFixedFrame, kf as northUpEastToFixedFrame, Af as northWestUpToFixedFrame, jL as overrideMaterialsForMRT, Pz as packShowOpacity, RC as packing, Ll as parseCssUnicodeRange, Rl as parseFontFamilyFromCss, wf as radianToDegree, zC as raySphereIntersection, KN as resolveGBufferOptions, aB as setRTCPosition, iB as setRTEPosition, TH as setupMaterialForDrape, PL as setupMaterialForMRT, rB as setupRTEBeforeRender, nB as setupRTECallback, aR as setupSelectiveEffectUniforms, BC as transform, VC as turbo, qN as unionGBufferRequirements, Fz as unpackShowOpacity, Hz as updateBatchAttribute, Sf as vector3ToGeodetic, HC as vogelDisk, jf as westUpNorthToFixedFrame };
|
|
35972
36020
|
|
|
35973
36021
|
//# sourceMappingURL=index.js.map
|