@itwin/core-frontend 5.3.0-dev.7 → 5.3.0-dev.9
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/CHANGELOG.md +18 -1
- package/lib/cjs/ElementLocateManager.d.ts.map +1 -1
- package/lib/cjs/ElementLocateManager.js +2 -5
- package/lib/cjs/ElementLocateManager.js.map +1 -1
- package/lib/cjs/HitDetail.d.ts +1 -24
- package/lib/cjs/HitDetail.d.ts.map +1 -1
- package/lib/cjs/HitDetail.js +0 -5
- package/lib/cjs/HitDetail.js.map +1 -1
- package/lib/cjs/IModeljs-css.js +1 -1
- package/lib/cjs/IModeljs-css.js.map +1 -1
- package/lib/cjs/internal/render/webgl/FrustumUniforms.d.ts +0 -2
- package/lib/cjs/internal/render/webgl/FrustumUniforms.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/FrustumUniforms.js +0 -7
- package/lib/cjs/internal/render/webgl/FrustumUniforms.js.map +1 -1
- package/lib/cjs/internal/render/webgl/SceneCompositor.d.ts +0 -9
- package/lib/cjs/internal/render/webgl/SceneCompositor.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/SceneCompositor.js +4 -67
- package/lib/cjs/internal/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/cjs/internal/render/webgl/ShaderBuilder.d.ts +3 -4
- package/lib/cjs/internal/render/webgl/ShaderBuilder.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/ShaderBuilder.js +3 -3
- package/lib/cjs/internal/render/webgl/ShaderBuilder.js.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Atmosphere.js +1 -1
- package/lib/cjs/internal/render/webgl/glsl/ClearPickAndColor.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/ClearPickAndColor.js +1 -2
- package/lib/cjs/internal/render/webgl/glsl/ClearPickAndColor.js.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Contours.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Contours.js +1 -30
- package/lib/cjs/internal/render/webgl/glsl/Contours.js.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Fragment.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Fragment.js +2 -7
- package/lib/cjs/internal/render/webgl/glsl/Fragment.js.map +1 -1
- package/lib/cjs/internal/render/webgl/glsl/RealityMesh.js +1 -1
- package/lib/cjs/internal/render/webgl/glsl/Surface.js +1 -1
- package/lib/cjs/render/Pixel.d.ts +2 -13
- package/lib/cjs/render/Pixel.d.ts.map +1 -1
- package/lib/cjs/render/Pixel.js +1 -9
- package/lib/cjs/render/Pixel.js.map +1 -1
- package/lib/esm/ElementLocateManager.d.ts.map +1 -1
- package/lib/esm/ElementLocateManager.js +2 -5
- package/lib/esm/ElementLocateManager.js.map +1 -1
- package/lib/esm/HitDetail.d.ts +1 -24
- package/lib/esm/HitDetail.d.ts.map +1 -1
- package/lib/esm/HitDetail.js +0 -5
- package/lib/esm/HitDetail.js.map +1 -1
- package/lib/esm/IModeljs-css.js +1 -1
- package/lib/esm/IModeljs-css.js.map +1 -1
- package/lib/esm/internal/render/webgl/FrustumUniforms.d.ts +0 -2
- package/lib/esm/internal/render/webgl/FrustumUniforms.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/FrustumUniforms.js +1 -8
- package/lib/esm/internal/render/webgl/FrustumUniforms.js.map +1 -1
- package/lib/esm/internal/render/webgl/SceneCompositor.d.ts +0 -9
- package/lib/esm/internal/render/webgl/SceneCompositor.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/SceneCompositor.js +4 -67
- package/lib/esm/internal/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/esm/internal/render/webgl/ShaderBuilder.d.ts +3 -4
- package/lib/esm/internal/render/webgl/ShaderBuilder.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/ShaderBuilder.js +3 -3
- package/lib/esm/internal/render/webgl/ShaderBuilder.js.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/Atmosphere.js +1 -1
- package/lib/esm/internal/render/webgl/glsl/ClearPickAndColor.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/ClearPickAndColor.js +1 -2
- package/lib/esm/internal/render/webgl/glsl/ClearPickAndColor.js.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/Contours.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/Contours.js +1 -30
- package/lib/esm/internal/render/webgl/glsl/Contours.js.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/Fragment.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/Fragment.js +2 -7
- package/lib/esm/internal/render/webgl/glsl/Fragment.js.map +1 -1
- package/lib/esm/internal/render/webgl/glsl/RealityMesh.js +1 -1
- package/lib/esm/internal/render/webgl/glsl/Surface.js +1 -1
- package/lib/esm/render/Pixel.d.ts +2 -13
- package/lib/esm/render/Pixel.d.ts.map +1 -1
- package/lib/esm/render/Pixel.js +1 -9
- package/lib/esm/render/Pixel.js.map +1 -1
- package/package.json +21 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contours.js","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Contours.ts"],"names":[],"mappings":";;AA0HA,4CA4DC;AAtLD;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAoD;AACpD,gDAA6C;AAI7C,yDAAqD;AACrD,qCAAiD;AACjD,qCAA0C;AAE1C,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;CAazB,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;;CAOxB,CAAC;AAEF,MAAM,4BAA4B,GAAG;;;;CAIpC,CAAC;AAEF,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;CAc7B,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;wBAKE,4BAAc,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDtD,CAAC;AAEF,gBA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I,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,GAAG,iDAAwC,aAAa,CAAC,CAAC;IACvE,OAAO,CAAC,IAAI,CAAC,GAAG,0DAAiD,2BAA2B,CAAC,CAAC;AAChG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module WebGL\n */\nimport { ContourDisplay } from \"@itwin/core-common\";\nimport { TextureUnit } from \"../RenderFlags\";\nimport {\n FragmentShaderComponent, ProgramBuilder, VariableType,\n} from \"../ShaderBuilder\";\nimport { addFeatureIndex } from \"./FeatureSymbology\";\nimport { addInstancedRtcMatrix } from \"./Vertex\";\nimport { encodeDepthRgb } from \"./Decode\";\n\nconst computeContourNdx = `\n if (u_contourLUTWidth == 0u)\n return 15.0;\n uint lutIndex = uint(getFeatureIndex());\n bool odd = bool(lutIndex & 1u);\n lutIndex /= 2u;\n uint byteSel = lutIndex & 0x3u;\n lutIndex /= 4u;\n ivec2 coords = ivec2(lutIndex % u_contourLUTWidth, lutIndex / u_contourLUTWidth);\n uvec4 contourNdx4 = uvec4(texelFetch(u_contourLUT, coords, 0) * 255.0 + 0.5);\n uvec2 contourNdx2 = bool(byteSel & 2u) ? contourNdx4.ba : contourNdx4.rg;\n uint contourNdx = bool(byteSel & 1u) ? contourNdx2.g : contourNdx2.r;\n return float(odd ? contourNdx >> 4u : contourNdx & 0xFu);\n`;\n\nconst unpack2BytesVec4 = `\nvec4 unpack2BytesVec4(vec4 f, bool upper) {\n f = floor(f + 0.5);\n vec4 outUpper = floor(f / 256.0);\n vec4 outLower = floor(f - outUpper * 256.0);\n return upper ? outUpper : outLower;\n}\n`;\n\nconst unpackAndNormalize2BytesVec4 = `\nvec4 unpackAndNormalize2BytesVec4(vec4 f, bool upper) {\n return unpack2BytesVec4(f, upper) / 255.0;\n}\n`;\n\nconst encodeContourLineInfo = `\n void encodeContourLineInfo(int groupIndex, bool isMajor, float interval) {\n // ContourDisplay.maxContourGroups is currently 5. Must change this code if that changes.\n float groupIndexAndType = float(groupIndex + (isMajor ? 16 : 8));\n\n // Find nearest multiple of interval to pixel world height.\n float elevation = (v_height >= 0.0 ? floor((v_height + interval / 2.0) / interval) : ceil((v_height - interval / 2.0) / interval)) * interval;\n\n // Convert elevation to a fraction of the frustum's world Z extents\n elevation = clamp((elevation - u_worldFrustumZRange.x) / (u_worldFrustumZRange.y - u_worldFrustumZRange.x), 0.0, 1.0);\n\n // Encode elevation in RGB and the rest of the info in A\n g_contourLineInfo = vec4(groupIndexAndType * 0.03125, encodeDepthRgb(elevation));\n }\n`;\n\nconst applyContours = `\n int contourNdx = int(v_contourNdx + 0.5);\n if (contourNdx > 14) // 15 => no contours\n return baseColor;\n\n const int maxDefs = ${ContourDisplay.maxContourGroups}; // max number of contour definitions allowed, have to change index arrays if this changes\n int contourNdxC = clamp(contourNdx, 0, maxDefs - 1);\n\n bool even = (contourNdxC & 1) == 0;\n vec4 rgbfp = u_contourDefs[even ? contourNdxC * 3 / 2 : (contourNdxC - 1) * 3 / 2 + 2];\n vec4 intervalsPair = u_contourDefs[(contourNdxC / 2) * 3 + 1];\n // intervals.r => minor interval distance, intervals.g => major index count\n vec2 intervals = even ? intervalsPair.rg : intervalsPair.ba;\n\n float coord = v_height / intervals.r;\n // determine if this is in the vicinity of a major contour line (1/2 an interval either way, which is one limit of drawing width)\n bool maj = (fract((abs(coord) + 0.5) / intervals.g) < (1.0 / intervals.g));\n vec4 rgbf = unpackAndNormalize2BytesVec4(rgbfp, maj);\n // rgbf.a => (4-bit linecode / 4-bit weight) maj/min, where the 4-bit weight is a 3-bit weight value with one fraction bit and a 1.5 offset.\n // This gives a weight range of 1.5 to 9 in 0.5 increments.\n // NB: the showGeometry bit flag is stuck in at bit 16 of this, so the major line code has an extra bit in it that needs to be masked out\n int lineCodeWt = int((rgbf.a * 255.0) + 0.5);\n // first * 0.5 is for fractional part of width, then have to add 1.0 for offset, then another 1.0 for actual width bias\n float lineRadius = (float(lineCodeWt & 0xf) * 0.5 + 2.0) * 0.5;\n\n // abs(fract(coord - 0.5) - 0.5) will produce 0.0 at the contour line, and 0.5 at the mid-point between contour lines\n // fwidth(coord) is sum of absolute diffs in coord in adjacent pixels\n float line = abs(fract(coord - 0.5) - 0.5) / fwidth(coord);\n // If line is 0 (like at contour line), contourAlpha = lineRadius, so will use draw in contour color\n\t// If line >= lineRadius, contourAlpha = 0, so won't show contour\n float contourAlpha = lineRadius - min(line, lineRadius);\n\n // figure out which direction line is going, to know which screen pattern offset to use\n float dx = dFdx(contourAlpha);\n float dy = dFdy(contourAlpha);\n\n const float patLength = 32.0;\n uint patterns[10] = uint[](0xffffffffu, 0x80808080u, 0xf8f8f8f8u, 0xffe0ffe0u, 0xfe10fe10u, 0xe0e0e0e0u, 0xf888f888u, 0xff18ff18u, 0xccccccccu, 0x00000001u);\n\n float offset = trunc((abs(dx) > abs(dy)) ? gl_FragCoord.y : gl_FragCoord.x);\n offset = mod(offset, patLength);\n uint msk = 1u << uint(offset);\n contourAlpha *= (patterns[(lineCodeWt / 16) & 0xf] & msk) > 0u ? 1.0 : 0.0;\n contourAlpha = min(contourAlpha, 1.0);\n\n bool isContourLine = contourAlpha >= 0.5;\n if (isContourLine)\n encodeContourLineInfo(contourNdxC, maj, intervals.r);\n\n if (rgbfp.a / 65536.0 < 0.5) { // showGeometry == 0\n if (!isContourLine)\n discard;\n return vec4(rgbf.rgb, 1.0);\n }\n // set contour opaque even if base color is transparent\n float alpha = contourAlpha >= 0.5 ? 1.0 : baseColor.a;\n return vec4(mix(baseColor.rgb, rgbf.rgb, contourAlpha), alpha);\n`;\n\n/** @internal */\nexport function addApplyContours(builder: ProgramBuilder) {\n const modelPos = builder.vert.usesInstancedGeometry ? \"(g_instancedRtcMatrix * rawPosition)\" : \"rawPosition\";\n\n const computeWorldHeight = `\nfloat computeWorldHeight(vec4 rawPosition) {\n float height = (u_modelToWorldC * ${modelPos}).z;\n // TODO: apply ECEF correction to height\n return height;\n}\n`;\n\n addFeatureIndex(builder.vert);\n\n builder.addFunctionComputedVarying(\"v_contourNdx\", VariableType.Float, \"computeContourNdx\", computeContourNdx);\n builder.addFunctionComputedVaryingWithArgs(\"v_height\", VariableType.Float, \"computeWorldHeight(rawPosition)\", computeWorldHeight);\n\n if (builder.vert.usesInstancedGeometry)\n addInstancedRtcMatrix(builder.vert);\n\n builder.vert.addUniform(\"u_contourLUT\", VariableType.Sampler2D, (prog) => {\n prog.addGraphicUniform(\"u_contourLUT\", (uniform, params) => {\n // set this uniform here so that it won't cause problems (e.g.: loopback) if it does not end up being set by bindContourLUT call\n uniform.setUniform1i(TextureUnit.Contours - TextureUnit.Zero);\n params.target.uniforms.batch.bindContourLUT(uniform);\n });\n });\n\n builder.vert.addUniform(\"u_contourLUTWidth\", VariableType.Uint, (prog) => {\n prog.addGraphicUniform(\"u_contourLUTWidth\", (uniform, params) => {\n params.target.uniforms.batch.bindContourLUTWidth(uniform);\n });\n });\n\n builder.vert.addUniform(\"u_modelToWorldC\", VariableType.Mat4, (prog) => {\n prog.addGraphicUniform(\"u_modelToWorldC\", (uniform, params) => {\n params.target.uniforms.branch.bindModelToWorldTransform(uniform, params.geometry, false);\n });\n });\n\n builder.frag.addUniform(\"u_worldFrustumZRange\", VariableType.Vec2, (prog) => {\n prog.addProgramUniform(\"u_worldFrustumZRange\", (uniform, params) => {\n uniform.setUniform2fv(params.target.uniforms.frustum.worldFrustumZRange);\n });\n });\n\n const contourDefsSize = 8;\n builder.frag.addUniformArray(\"u_contourDefs\", VariableType.Vec4, contourDefsSize, (prog) => {\n prog.addGraphicUniform(\"u_contourDefs\", (uniform, params) => {\n params.target.uniforms.contours.bindcontourDefs(uniform);\n });\n });\n\n builder.frag.addGlobal(\"g_contourLineInfo\", VariableType.Vec4, \"vec4(0.0)\");\n builder.frag.addFunction(encodeDepthRgb);\n builder.frag.addFunction(encodeContourLineInfo);\n \n builder.frag.addFunction(unpack2BytesVec4);\n builder.frag.addFunction(unpackAndNormalize2BytesVec4);\n builder.frag.set(FragmentShaderComponent.ApplyContours, applyContours);\n builder.frag.set(FragmentShaderComponent.ComputeContourLineInfo, \"return g_contourLineInfo;\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Contours.js","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Contours.ts"],"names":[],"mappings":";;AAqGA,4CAiDC;AAtJD;;;+FAG+F;AAC/F;;GAEG;AACH,oDAAoD;AACpD,gDAA6C;AAI7C,yDAAqD;AACrD,qCAAiD;AAEjD,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;CAazB,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;;CAOxB,CAAC;AAEF,MAAM,4BAA4B,GAAG;;;;CAIpC,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;wBAKE,4BAAc,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDtD,CAAC;AAEF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,OAAuB;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,aAAa,CAAC;IAE7G,MAAM,kBAAkB,GAAG;;sCAES,QAAQ;;;;CAI7C,CAAC;IAEA,IAAA,kCAAe,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,OAAO,CAAC,0BAA0B,CAAC,cAAc,8BAAsB,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;IAC/G,OAAO,CAAC,kCAAkC,CAAC,UAAU,8BAAsB,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;IAElI,IAAI,OAAO,CAAC,IAAI,CAAC,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AAE;QACzF,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,GAAG,iDAAwC,aAAa,CAAC,CAAC;AACzE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module WebGL\n */\nimport { ContourDisplay } from \"@itwin/core-common\";\nimport { TextureUnit } from \"../RenderFlags\";\nimport {\n FragmentShaderComponent, ProgramBuilder, VariableType,\n} from \"../ShaderBuilder\";\nimport { addFeatureIndex } from \"./FeatureSymbology\";\nimport { addInstancedRtcMatrix } from \"./Vertex\";\n\nconst computeContourNdx = `\n if (u_contourLUTWidth == 0u)\n return 15.0;\n uint lutIndex = uint(getFeatureIndex());\n bool odd = bool(lutIndex & 1u);\n lutIndex /= 2u;\n uint byteSel = lutIndex & 0x3u;\n lutIndex /= 4u;\n ivec2 coords = ivec2(lutIndex % u_contourLUTWidth, lutIndex / u_contourLUTWidth);\n uvec4 contourNdx4 = uvec4(texelFetch(u_contourLUT, coords, 0) * 255.0 + 0.5);\n uvec2 contourNdx2 = bool(byteSel & 2u) ? contourNdx4.ba : contourNdx4.rg;\n uint contourNdx = bool(byteSel & 1u) ? contourNdx2.g : contourNdx2.r;\n return float(odd ? contourNdx >> 4u : contourNdx & 0xFu);\n`;\n\nconst unpack2BytesVec4 = `\nvec4 unpack2BytesVec4(vec4 f, bool upper) {\n f = floor(f + 0.5);\n vec4 outUpper = floor(f / 256.0);\n vec4 outLower = floor(f - outUpper * 256.0);\n return upper ? outUpper : outLower;\n}\n`;\n\nconst unpackAndNormalize2BytesVec4 = `\nvec4 unpackAndNormalize2BytesVec4(vec4 f, bool upper) {\n return unpack2BytesVec4(f, upper) / 255.0;\n}\n`;\n\nconst applyContours = `\n int contourNdx = int(v_contourNdx + 0.5);\n if (contourNdx > 14) // 15 => no contours\n return baseColor;\n\n const int maxDefs = ${ContourDisplay.maxContourGroups}; // max number of contour definitions allowed, have to change index arrays if this changes\n int contourNdxC = clamp(contourNdx, 0, maxDefs - 1);\n\n bool even = (contourNdxC & 1) == 0;\n vec4 rgbfp = u_contourDefs[even ? contourNdxC * 3 / 2 : (contourNdxC - 1) * 3 / 2 + 2];\n vec4 intervalsPair = u_contourDefs[(contourNdxC / 2) * 3 + 1];\n // intervals.r => minor interval distance, intervals.g => major index count\n vec2 intervals = even ? intervalsPair.rg : intervalsPair.ba;\n\n float coord = v_height / intervals.r;\n // determine if this is in the vicinity of a major contour line (1/2 an interval either way, which is one limit of drawing width)\n bool maj = (fract((abs(coord) + 0.5) / intervals.g) < (1.0 / intervals.g));\n vec4 rgbf = unpackAndNormalize2BytesVec4(rgbfp, maj);\n // rgbf.a => (4-bit linecode / 4-bit weight) maj/min, where the 4-bit weight is a 3-bit weight value with one fraction bit and a 1.5 offset.\n // This gives a weight range of 1.5 to 9 in 0.5 increments.\n // NB: the showGeometry bit flag is stuck in at bit 16 of this, so the major line code has an extra bit in it that needs to be masked out\n int lineCodeWt = int((rgbf.a * 255.0) + 0.5);\n // first * 0.5 is for fractional part of width, then have to add 1.0 for offset, then another 1.0 for actual width bias\n float lineRadius = (float(lineCodeWt & 0xf) * 0.5 + 2.0) * 0.5;\n\n // abs(fract(coord - 0.5) - 0.5) will produce 0.0 at the contour line, and 0.5 at the mid-point between contour lines\n // fwidth(coord) is sum of absolute diffs in coord in adjacent pixels\n float line = abs(fract(coord - 0.5) - 0.5) / fwidth(coord);\n // If line is 0 (like at contour line), contourAlpha = lineRadius, so will use draw in contour color\n\t// If line >= lineRadius, contourAlpha = 0, so won't show contour\n float contourAlpha = lineRadius - min(line, lineRadius);\n\n // figure out which direction line is going, to know which screen pattern offset to use\n float dx = dFdx(contourAlpha);\n float dy = dFdy(contourAlpha);\n\n const float patLength = 32.0;\n uint patterns[10] = uint[](0xffffffffu, 0x80808080u, 0xf8f8f8f8u, 0xffe0ffe0u, 0xfe10fe10u, 0xe0e0e0e0u, 0xf888f888u, 0xff18ff18u, 0xccccccccu, 0x00000001u);\n\n float offset = trunc((abs(dx) > abs(dy)) ? gl_FragCoord.y : gl_FragCoord.x);\n offset = mod(offset, patLength);\n uint msk = 1u << uint(offset);\n contourAlpha *= (patterns[(lineCodeWt / 16) & 0xf] & msk) > 0u ? 1.0 : 0.0;\n contourAlpha = min(contourAlpha, 1.0);\n\n if (rgbfp.a / 65536.0 < 0.5) { // showGeometry == 0\n if (contourAlpha < 0.5) // not a contour line\n discard;\n return vec4(rgbf.rgb, 1.0);\n }\n // set contour opaque even if base color is transparent\n float alpha = contourAlpha >= 0.5 ? 1.0 : baseColor.a;\n return vec4(mix(baseColor.rgb, rgbf.rgb, contourAlpha), alpha);\n`;\n\n/** @internal */\nexport function addApplyContours(builder: ProgramBuilder) {\n const modelPos = builder.vert.usesInstancedGeometry ? \"(g_instancedRtcMatrix * rawPosition)\" : \"rawPosition\";\n\n const computeWorldHeight = `\nfloat computeWorldHeight(vec4 rawPosition) {\n float height = (u_modelToWorldC * ${modelPos}).z;\n // TODO: apply ECEF correction to height\n return height;\n}\n`;\n\n addFeatureIndex(builder.vert);\n\n builder.addFunctionComputedVarying(\"v_contourNdx\", VariableType.Float, \"computeContourNdx\", computeContourNdx);\n builder.addFunctionComputedVaryingWithArgs(\"v_height\", VariableType.Float, \"computeWorldHeight(rawPosition)\", computeWorldHeight);\n\n if (builder.vert.usesInstancedGeometry)\n addInstancedRtcMatrix(builder.vert);\n\n builder.vert.addUniform(\"u_contourLUT\", VariableType.Sampler2D, (prog) => {\n prog.addGraphicUniform(\"u_contourLUT\", (uniform, params) => {\n // set this uniform here so that it won't cause problems (e.g.: loopback) if it does not end up being set by bindContourLUT call\n uniform.setUniform1i(TextureUnit.Contours - TextureUnit.Zero);\n params.target.uniforms.batch.bindContourLUT(uniform);\n });\n });\n\n builder.vert.addUniform(\"u_contourLUTWidth\", VariableType.Uint, (prog) => {\n prog.addGraphicUniform(\"u_contourLUTWidth\", (uniform, params) => {\n params.target.uniforms.batch.bindContourLUTWidth(uniform);\n });\n });\n\n builder.vert.addUniform(\"u_modelToWorldC\", VariableType.Mat4, (prog) => {\n prog.addGraphicUniform(\"u_modelToWorldC\", (uniform, params) => {\n params.target.uniforms.branch.bindModelToWorldTransform(uniform, params.geometry, false);\n });\n });\n\n const contourDefsSize = 8;\n builder.frag.addUniformArray(\"u_contourDefs\", VariableType.Vec4, contourDefsSize, (prog) => {\n prog.addGraphicUniform(\"u_contourDefs\", (uniform, params) => {\n params.target.uniforms.contours.bindcontourDefs(uniform);\n });\n });\n\n builder.frag.addFunction(unpack2BytesVec4);\n builder.frag.addFunction(unpackAndNormalize2BytesVec4);\n builder.frag.set(FragmentShaderComponent.ApplyContours, applyContours);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fragment.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Fragment.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAwD,MAAM,kBAAkB,CAAC;AAI/G,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,QAQ/D;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,QASlE;
|
|
1
|
+
{"version":3,"file":"Fragment.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Fragment.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAwD,MAAM,kBAAkB,CAAC;AAI/G,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,QAQ/D;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,QASlE;AA0CD,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CA8BtE;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAazE;AAED,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CASpF;AAED,gBAAgB;AAChB,eAAO,MAAM,eAAe,2BAA2B,CAAC;AAWxD,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,qPAQ9B,CAAC"}
|
|
@@ -64,13 +64,11 @@ const computeAltPickBufferOutputs = `${multiplyAlpha}
|
|
|
64
64
|
vec4 output0 = baseColor;
|
|
65
65
|
vec4 output1 = vec4(0.0);
|
|
66
66
|
vec4 output2 = vec4(0.0);
|
|
67
|
-
vec4 output3 = vec4(0.0);
|
|
68
67
|
`;
|
|
69
68
|
const assignPickBufferOutputsMRT = `
|
|
70
69
|
FragColor0 = output0;
|
|
71
70
|
FragColor1 = output1;
|
|
72
71
|
FragColor2 = output2;
|
|
73
|
-
FragColor3 = output3;
|
|
74
72
|
`;
|
|
75
73
|
const reassignFeatureId = " output1 = overrideFeatureId(output1);";
|
|
76
74
|
/** @internal */
|
|
@@ -87,9 +85,6 @@ function addPickBufferOutputs(frag) {
|
|
|
87
85
|
prelude.addline(" float renderOrder = u_renderOrder;");
|
|
88
86
|
}
|
|
89
87
|
prelude.add(computePickBufferOutputs);
|
|
90
|
-
const computeContourLineInfo = frag.get(23 /* FragmentShaderComponent.ComputeContourLineInfo */) ?? "return vec4(0.0);";
|
|
91
|
-
frag.addFunction("vec4 computeContourLineInfo()", computeContourLineInfo);
|
|
92
|
-
prelude.addline(" vec4 output3 = computeContourLineInfo();");
|
|
93
88
|
const overrideColor = frag.get(21 /* FragmentShaderComponent.OverrideColor */);
|
|
94
89
|
if (undefined !== overrideColor) {
|
|
95
90
|
frag.addFunction("vec4 overrideColor(vec4 currentColor)", overrideColor);
|
|
@@ -101,7 +96,7 @@ function addPickBufferOutputs(frag) {
|
|
|
101
96
|
prelude.addline(reassignFeatureId);
|
|
102
97
|
}
|
|
103
98
|
(0, RenderPass_1.addRenderPass)(frag);
|
|
104
|
-
frag.addDrawBuffersExtension(
|
|
99
|
+
frag.addDrawBuffersExtension(3);
|
|
105
100
|
frag.set(18 /* FragmentShaderComponent.AssignFragData */, prelude.source + assignPickBufferOutputsMRT);
|
|
106
101
|
}
|
|
107
102
|
/** @internal */
|
|
@@ -114,7 +109,7 @@ function addAltPickBufferOutputs(frag) {
|
|
|
114
109
|
prelude.addline(" output0 = overrideColor(output0);");
|
|
115
110
|
}
|
|
116
111
|
(0, RenderPass_1.addRenderPass)(frag);
|
|
117
|
-
frag.addDrawBuffersExtension(
|
|
112
|
+
frag.addDrawBuffersExtension(3);
|
|
118
113
|
frag.set(18 /* FragmentShaderComponent.AssignFragData */, prelude.source + assignPickBufferOutputsMRT);
|
|
119
114
|
}
|
|
120
115
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fragment.js","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Fragment.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAOH,oDAQC;AAGD,0DASC;AA6CD,oDAkCC;AAGD,0DAaC;AAGD,gFASC;AApID,oDAA+G;AAC/G,qCAA0C;AAC1C,6CAA6C;AAE7C,gBAAgB;AAChB,SAAgB,oBAAoB,CAAC,IAA2B;IAC9D,MAAM,uBAAuB,GAAG,4EAA4E,CAAC;IAC7G,IAAI,CAAC,WAAW,CA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AG,aAAa;;;CAGxE,CAAC;AAEF,gBAAgB;AACH,QAAA,kBAAkB,GAAG;;;;;;;;CAQjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module WebGL\n */\n\nimport { FragmentShaderBuilder, FragmentShaderComponent, SourceBuilder, VariableType } from \"../ShaderBuilder\";\nimport { encodeDepthRgb } from \"./Decode\";\nimport { addRenderPass } from \"./RenderPass\";\n\n/** @internal */\nexport function addWindowToTexCoords(frag: FragmentShaderBuilder) {\n const windowCoordsToTexCoords = `\\nvec2 windowCoordsToTexCoords(vec2 wc) { return wc * u_invScreenSize; }\\n`;\n frag.addFunction(windowCoordsToTexCoords);\n frag.addUniform(\"u_invScreenSize\", VariableType.Vec2, (prog) => {\n prog.addProgramUniform(\"u_invScreenSize\", (uniform, params) => {\n params.target.uniforms.viewRect.bindInverseDimensions(uniform);\n });\n });\n}\n\n/** @internal */\nexport function addWhiteOnWhiteReversal(frag: FragmentShaderBuilder) {\n frag.addUniform(\"u_reverseWhiteOnWhite\", VariableType.Boolean, (prog) => {\n prog.addGraphicUniform(\"u_reverseWhiteOnWhite\", (uniform, params) => {\n const wantWoW = params.target.uniforms.style.wantWoWReversal;\n const doReversal = (wantWoW && params.geometry.wantWoWReversal(params.programParams)) ? 1 : 0;\n uniform.setUniform1i(doReversal);\n });\n });\n frag.set(FragmentShaderComponent.ReverseWhiteOnWhite, reverseWhiteOnWhite);\n}\n\nconst reverseWhiteOnWhite = `\n const vec3 white = vec3(1.0);\n const vec3 epsilon = vec3(0.0001);\n vec3 color = baseColor.rgb;\n vec3 delta = (color + epsilon) - white;\n vec4 wowColor = vec4(baseColor.rgb * vec3(float(delta.x <= 0.0 || delta.y <= 0.0 || delta.z <= 0.0)), baseColor.a); // set to black if almost white\n return u_reverseWhiteOnWhite ? wowColor : baseColor;\n`;\n\nconst multiplyAlpha = `\n if (u_renderPass >= kRenderPass_OpaqueLinear && u_renderPass <= kRenderPass_OpaqueGeneral)\n baseColor.a = 1.0;\n else\n baseColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n`;\n\nconst computePickBufferOutputs = `${multiplyAlpha}\n vec4 output0 = baseColor;\n\n // Fix interpolation errors despite all vertices sending exact same feature_id...\n ivec4 feature_id_i = ivec4(feature_id * 255.0 + 0.5);\n vec4 output1 = vec4(feature_id_i) / 255.0;\n float linearDepth = computeLinearDepth(v_eyeSpace.z);\n vec4 output2 = vec4(renderOrder * 0.0625, encodeDepthRgb(linearDepth)); // near=1, far=0\n`;\n\nconst computeAltPickBufferOutputs = `${multiplyAlpha}\n vec4 output0 = baseColor;\n vec4 output1 = vec4(0.0);\n vec4 output2 = vec4(0.0);\n vec4 output3 = vec4(0.0);\n`;\n\nconst assignPickBufferOutputsMRT = `\n FragColor0 = output0;\n FragColor1 = output1;\n FragColor2 = output2;\n FragColor3 = output3;\n`;\n\nconst reassignFeatureId = \" output1 = overrideFeatureId(output1);\";\n\n/** @internal */\nexport function addPickBufferOutputs(frag: FragmentShaderBuilder): void {\n frag.addFunction(encodeDepthRgb);\n frag.addFunction(computeLinearDepth);\n\n const prelude = new SourceBuilder();\n const overrideOrder = frag.get(FragmentShaderComponent.OverrideRenderOrder);\n if (overrideOrder) {\n frag.addFunction(\"float overrideRenderOrder(float currentOrder)\", overrideOrder);\n prelude.addline(\" float renderOrder = overrideRenderOrder(u_renderOrder);\");\n } else {\n prelude.addline(\" float renderOrder = u_renderOrder;\");\n }\n\n prelude.add(computePickBufferOutputs);\n\n const computeContourLineInfo = frag.get(FragmentShaderComponent.ComputeContourLineInfo) ?? \"return vec4(0.0);\";\n frag.addFunction(\"vec4 computeContourLineInfo()\", computeContourLineInfo);\n prelude.addline(\" vec4 output3 = computeContourLineInfo();\");\n\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined !== overrideColor) {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n prelude.addline(\" output0 = overrideColor(output0);\");\n }\n\n const overrideFeatureId = frag.get(FragmentShaderComponent.OverrideFeatureId);\n if (undefined !== overrideFeatureId) {\n frag.addFunction(\"vec4 overrideFeatureId(vec4 currentId)\", overrideFeatureId);\n prelude.addline(reassignFeatureId);\n }\n\n addRenderPass(frag);\n frag.addDrawBuffersExtension(4);\n frag.set(FragmentShaderComponent.AssignFragData, prelude.source + assignPickBufferOutputsMRT);\n}\n\n/** @internal */\nexport function addAltPickBufferOutputs(frag: FragmentShaderBuilder): void {\n const prelude = new SourceBuilder();\n prelude.add(computeAltPickBufferOutputs);\n\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined !== overrideColor) {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n prelude.addline(\" output0 = overrideColor(output0);\");\n }\n\n addRenderPass(frag);\n frag.addDrawBuffersExtension(4);\n frag.set(FragmentShaderComponent.AssignFragData, prelude.source + assignPickBufferOutputsMRT);\n}\n\n/** @internal */\nexport function addFragColorWithPreMultipliedAlpha(frag: FragmentShaderBuilder): void {\n addRenderPass(frag);\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined === overrideColor) {\n frag.set(FragmentShaderComponent.AssignFragData, assignFragColorWithPreMultipliedAlpha);\n } else {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n frag.set(FragmentShaderComponent.AssignFragData, overrideAndAssignFragColorWithPreMultipliedAlpha);\n }\n}\n\n/** @internal */\nexport const assignFragColor = \"FragColor = baseColor;\";\n\nconst assignFragColorWithPreMultipliedAlpha = `${multiplyAlpha}\n FragColor = baseColor;\n`;\n\nconst overrideAndAssignFragColorWithPreMultipliedAlpha = `${multiplyAlpha}\n vec4 fragColor = overrideColor(baseColor);\n FragColor = fragColor;\n`;\n\n/** @internal */\nexport const computeLinearDepth = `\nfloat computeLinearDepth(float eyeSpaceZ) {\n float eyeZ = -eyeSpaceZ;\n float near = u_frustum.x, far = u_frustum.y;\n float depthRange = far - near;\n float linearDepth = (eyeZ - near) / depthRange;\n return 1.0 - linearDepth;\n}\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"Fragment.js","sourceRoot":"","sources":["../../../../../../src/internal/render/webgl/glsl/Fragment.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAOH,oDAQC;AAGD,0DASC;AA2CD,oDA8BC;AAGD,0DAaC;AAGD,gFASC;AA9HD,oDAA+G;AAC/G,qCAA0C;AAC1C,6CAA6C;AAE7C,gBAAgB;AAChB,SAAgB,oBAAoB,CAAC,IAA2B;IAC9D,MAAM,uBAAuB,GAAG,4EAA4E,CAAC;IAC7G,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,iBAAiB,6BAAqB,CAAC,IAAI,EAAE,EAAE;QAC7D,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,SAAgB,uBAAuB,CAAC,IAA2B;IACjE,IAAI,CAAC,UAAU,CAAC,uBAAuB,gCAAwB,CAAC,IAAI,EAAE,EAAE;QACtE,IAAI,CAAC,iBAAiB,CAAC,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC;YAC7D,MAAM,UAAU,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC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qC,CAAC,CAAC;IAC1F,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,WAAW,CAAC,uCAAuC,EAAE,aAAa,CAAC,CAAC;QACzE,IAAI,CAAC,GAAG,kDAAyC,gDAAgD,CAAC,CAAC;IACrG,CAAC;AACH,CAAC;AAED,gBAAgB;AACH,QAAA,eAAe,GAAG,wBAAwB,CAAC;AAExD,MAAM,qCAAqC,GAAG,GAAG,aAAa;;CAE7D,CAAC;AAEF,MAAM,gDAAgD,GAAG,GAAG,aAAa;;;CAGxE,CAAC;AAEF,gBAAgB;AACH,QAAA,kBAAkB,GAAG;;;;;;;;CAQjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module WebGL\n */\n\nimport { FragmentShaderBuilder, FragmentShaderComponent, SourceBuilder, VariableType } from \"../ShaderBuilder\";\nimport { encodeDepthRgb } from \"./Decode\";\nimport { addRenderPass } from \"./RenderPass\";\n\n/** @internal */\nexport function addWindowToTexCoords(frag: FragmentShaderBuilder) {\n const windowCoordsToTexCoords = `\\nvec2 windowCoordsToTexCoords(vec2 wc) { return wc * u_invScreenSize; }\\n`;\n frag.addFunction(windowCoordsToTexCoords);\n frag.addUniform(\"u_invScreenSize\", VariableType.Vec2, (prog) => {\n prog.addProgramUniform(\"u_invScreenSize\", (uniform, params) => {\n params.target.uniforms.viewRect.bindInverseDimensions(uniform);\n });\n });\n}\n\n/** @internal */\nexport function addWhiteOnWhiteReversal(frag: FragmentShaderBuilder) {\n frag.addUniform(\"u_reverseWhiteOnWhite\", VariableType.Boolean, (prog) => {\n prog.addGraphicUniform(\"u_reverseWhiteOnWhite\", (uniform, params) => {\n const wantWoW = params.target.uniforms.style.wantWoWReversal;\n const doReversal = (wantWoW && params.geometry.wantWoWReversal(params.programParams)) ? 1 : 0;\n uniform.setUniform1i(doReversal);\n });\n });\n frag.set(FragmentShaderComponent.ReverseWhiteOnWhite, reverseWhiteOnWhite);\n}\n\nconst reverseWhiteOnWhite = `\n const vec3 white = vec3(1.0);\n const vec3 epsilon = vec3(0.0001);\n vec3 color = baseColor.rgb;\n vec3 delta = (color + epsilon) - white;\n vec4 wowColor = vec4(baseColor.rgb * vec3(float(delta.x <= 0.0 || delta.y <= 0.0 || delta.z <= 0.0)), baseColor.a); // set to black if almost white\n return u_reverseWhiteOnWhite ? wowColor : baseColor;\n`;\n\nconst multiplyAlpha = `\n if (u_renderPass >= kRenderPass_OpaqueLinear && u_renderPass <= kRenderPass_OpaqueGeneral)\n baseColor.a = 1.0;\n else\n baseColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n`;\n\nconst computePickBufferOutputs = `${multiplyAlpha}\n vec4 output0 = baseColor;\n\n // Fix interpolation errors despite all vertices sending exact same feature_id...\n ivec4 feature_id_i = ivec4(feature_id * 255.0 + 0.5);\n vec4 output1 = vec4(feature_id_i) / 255.0;\n float linearDepth = computeLinearDepth(v_eyeSpace.z);\n vec4 output2 = vec4(renderOrder * 0.0625, encodeDepthRgb(linearDepth)); // near=1, far=0\n`;\n\nconst computeAltPickBufferOutputs = `${multiplyAlpha}\n vec4 output0 = baseColor;\n vec4 output1 = vec4(0.0);\n vec4 output2 = vec4(0.0);\n`;\n\nconst assignPickBufferOutputsMRT = `\n FragColor0 = output0;\n FragColor1 = output1;\n FragColor2 = output2;\n`;\n\nconst reassignFeatureId = \" output1 = overrideFeatureId(output1);\";\n\n/** @internal */\nexport function addPickBufferOutputs(frag: FragmentShaderBuilder): void {\n frag.addFunction(encodeDepthRgb);\n frag.addFunction(computeLinearDepth);\n\n const prelude = new SourceBuilder();\n const overrideOrder = frag.get(FragmentShaderComponent.OverrideRenderOrder);\n if (overrideOrder) {\n frag.addFunction(\"float overrideRenderOrder(float currentOrder)\", overrideOrder);\n prelude.addline(\" float renderOrder = overrideRenderOrder(u_renderOrder);\");\n } else {\n prelude.addline(\" float renderOrder = u_renderOrder;\");\n }\n\n prelude.add(computePickBufferOutputs);\n\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined !== overrideColor) {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n prelude.addline(\" output0 = overrideColor(output0);\");\n }\n\n const overrideFeatureId = frag.get(FragmentShaderComponent.OverrideFeatureId);\n if (undefined !== overrideFeatureId) {\n frag.addFunction(\"vec4 overrideFeatureId(vec4 currentId)\", overrideFeatureId);\n prelude.addline(reassignFeatureId);\n }\n\n addRenderPass(frag);\n frag.addDrawBuffersExtension(3);\n frag.set(FragmentShaderComponent.AssignFragData, prelude.source + assignPickBufferOutputsMRT);\n}\n\n/** @internal */\nexport function addAltPickBufferOutputs(frag: FragmentShaderBuilder): void {\n const prelude = new SourceBuilder();\n prelude.add(computeAltPickBufferOutputs);\n\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined !== overrideColor) {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n prelude.addline(\" output0 = overrideColor(output0);\");\n }\n\n addRenderPass(frag);\n frag.addDrawBuffersExtension(3);\n frag.set(FragmentShaderComponent.AssignFragData, prelude.source + assignPickBufferOutputsMRT);\n}\n\n/** @internal */\nexport function addFragColorWithPreMultipliedAlpha(frag: FragmentShaderBuilder): void {\n addRenderPass(frag);\n const overrideColor = frag.get(FragmentShaderComponent.OverrideColor);\n if (undefined === overrideColor) {\n frag.set(FragmentShaderComponent.AssignFragData, assignFragColorWithPreMultipliedAlpha);\n } else {\n frag.addFunction(\"vec4 overrideColor(vec4 currentColor)\", overrideColor);\n frag.set(FragmentShaderComponent.AssignFragData, overrideAndAssignFragColorWithPreMultipliedAlpha);\n }\n}\n\n/** @internal */\nexport const assignFragColor = \"FragColor = baseColor;\";\n\nconst assignFragColorWithPreMultipliedAlpha = `${multiplyAlpha}\n FragColor = baseColor;\n`;\n\nconst overrideAndAssignFragColorWithPreMultipliedAlpha = `${multiplyAlpha}\n vec4 fragColor = overrideColor(baseColor);\n FragColor = fragColor;\n`;\n\n/** @internal */\nexport const computeLinearDepth = `\nfloat computeLinearDepth(float eyeSpaceZ) {\n float eyeZ = -eyeSpaceZ;\n float near = u_frustum.x, far = u_frustum.y;\n float depthRange = far - near;\n float linearDepth = (eyeZ - near) / depthRange;\n return 1.0 - linearDepth;\n}\n`;\n"]}
|
|
@@ -142,7 +142,7 @@ function addThematicToRealityMesh(builder, gradientTextureUnit) {
|
|
|
142
142
|
builder.vert.addGlobal("g_hillshadeIndex", 2 /* VariableType.Float */);
|
|
143
143
|
builder.addFunctionComputedVarying("v_n", 4 /* VariableType.Vec3 */, "computeLightingNormal", computeNormal);
|
|
144
144
|
builder.frag.addGlobal("g_normal", 4 /* VariableType.Vec3 */);
|
|
145
|
-
builder.frag.set(
|
|
145
|
+
builder.frag.set(24 /* FragmentShaderComponent.FinalizeNormal */, exports.finalizeNormal);
|
|
146
146
|
(0, Thematic_1.addThematicDisplay)(builder, false, true);
|
|
147
147
|
builder.addInlineComputedVarying("v_thematicIndex", 2 /* VariableType.Float */, (0, Thematic_1.getComputeThematicIndex)(builder.vert.usesInstancedGeometry, false, false));
|
|
148
148
|
builder.vert.addUniform("u_worldToViewN", 6 /* VariableType.Mat3 */, (prog) => {
|
|
@@ -489,7 +489,7 @@ function addNormal(builder, animated) {
|
|
|
489
489
|
});
|
|
490
490
|
});
|
|
491
491
|
finalizeNormal += finalizeNormalPostlude;
|
|
492
|
-
builder.frag.set(
|
|
492
|
+
builder.frag.set(24 /* FragmentShaderComponent.FinalizeNormal */, finalizeNormal);
|
|
493
493
|
// Set to true to colorize surfaces based on normals (in world space).
|
|
494
494
|
// You must also set checkMaxVarying to false in ProgramBuilder.buildProgram to avoid assertions, if using a non-optimized build.
|
|
495
495
|
const debugNormals = false;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Id64String } from "@itwin/core-bentley";
|
|
5
5
|
import { BatchType, Feature, GeometryClass, ModelFeature } from "@itwin/core-common";
|
|
6
|
-
import {
|
|
6
|
+
import { HitPath, HitPriority } from "../HitDetail";
|
|
7
7
|
import { IModelConnection } from "../IModelConnection";
|
|
8
8
|
import type { Viewport } from "../Viewport";
|
|
9
9
|
import { Transform } from "@itwin/core-geometry";
|
|
@@ -28,10 +28,6 @@ export declare namespace Pixel {
|
|
|
28
28
|
readonly batchType?: BatchType;
|
|
29
29
|
/** The iModel from which the geometry producing the pixel originated. */
|
|
30
30
|
readonly iModel?: IModelConnection;
|
|
31
|
-
/** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, that generated this pixel.
|
|
32
|
-
* @beta
|
|
33
|
-
*/
|
|
34
|
-
readonly contour?: ContourHit;
|
|
35
31
|
/** @internal */
|
|
36
32
|
readonly transformFromIModel?: Transform;
|
|
37
33
|
/** @internal */
|
|
@@ -58,7 +54,6 @@ export declare namespace Pixel {
|
|
|
58
54
|
viewAttachmentId?: string;
|
|
59
55
|
inSectionDrawingAttachment?: boolean;
|
|
60
56
|
transformFromIModel?: Transform;
|
|
61
|
-
contour?: ContourHit;
|
|
62
57
|
});
|
|
63
58
|
/** The Id of the element that produced the pixel. */
|
|
64
59
|
get elementId(): Id64String | undefined;
|
|
@@ -117,10 +112,6 @@ export declare namespace Pixel {
|
|
|
117
112
|
* @beta
|
|
118
113
|
*/
|
|
119
114
|
path?: HitPath;
|
|
120
|
-
/** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, from which the hit originated.
|
|
121
|
-
* @beta
|
|
122
|
-
*/
|
|
123
|
-
contour?: ContourHit;
|
|
124
115
|
}
|
|
125
116
|
/** Describes the type of geometry that produced the [[Pixel.Data]]. */
|
|
126
117
|
enum GeometryType {
|
|
@@ -158,10 +149,8 @@ export declare namespace Pixel {
|
|
|
158
149
|
Feature = 1,// eslint-disable-line @typescript-eslint/no-shadow
|
|
159
150
|
/** Select the type and planarity of geometry which produced each pixel as well as the fraction of its distance between the near and far planes. */
|
|
160
151
|
GeometryAndDistance = 4,
|
|
161
|
-
/** Select the [[ContourHit]]s describing which if any contour line produced each pixel. */
|
|
162
|
-
Contours = 8,
|
|
163
152
|
/** Select all aspects of each pixel. */
|
|
164
|
-
All =
|
|
153
|
+
All = 5
|
|
165
154
|
}
|
|
166
155
|
/** A rectangular array of pixels as read from a [[Viewport]]'s frame buffer. Each pixel is represented as a [[Pixel.Data]] object.
|
|
167
156
|
* The contents of the pixel buffer will be specified using device pixels, not CSS pixels. See [[Viewport.devicePixelRatio]] and [[Viewport.cssPixelsToDevicePixels]].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pixel.d.ts","sourceRoot":"","sources":["../../../src/render/Pixel.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Pixel.d.ts","sourceRoot":"","sources":["../../../src/render/Pixel.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;;;GAIG;AACH,yBAAiB,KAAK,CAAC;IACrB,0DAA0D;IAC1D,MAAa,IAAI;QACf,2CAA2C;QAC3C,SAAgB,OAAO,CAAC,EAAE,OAAO,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,mBAAmB,IAAS;QAC5B,wCAAwC;QACxC,GAAG,IAAgC;KACpC;IAED;;;OAGG;IACH,UAAiB,MAAM;QACrB,gFAAgF;QAChF,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtC;IAED;;OAEG;IACH,KAAY,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC7D"}
|
package/lib/cjs/render/Pixel.js
CHANGED
|
@@ -33,10 +33,6 @@ var Pixel;
|
|
|
33
33
|
batchType;
|
|
34
34
|
/** The iModel from which the geometry producing the pixel originated. */
|
|
35
35
|
iModel;
|
|
36
|
-
/** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, that generated this pixel.
|
|
37
|
-
* @beta
|
|
38
|
-
*/
|
|
39
|
-
contour;
|
|
40
36
|
/** @internal */
|
|
41
37
|
transformFromIModel;
|
|
42
38
|
/** @internal */
|
|
@@ -70,7 +66,6 @@ var Pixel;
|
|
|
70
66
|
this.tileId = args.tileId;
|
|
71
67
|
this.viewAttachmentId = args.viewAttachmentId;
|
|
72
68
|
this.transformFromIModel = args.transformFromIModel;
|
|
73
|
-
this.contour = args.contour;
|
|
74
69
|
}
|
|
75
70
|
/** The Id of the element that produced the pixel. */
|
|
76
71
|
get elementId() {
|
|
@@ -135,7 +130,6 @@ var Pixel;
|
|
|
135
130
|
sourceIModel: this.iModel,
|
|
136
131
|
transformFromSourceIModel: this.transformFromIModel,
|
|
137
132
|
path,
|
|
138
|
-
contour: this.contour,
|
|
139
133
|
};
|
|
140
134
|
}
|
|
141
135
|
}
|
|
@@ -179,10 +173,8 @@ var Pixel;
|
|
|
179
173
|
Selector[Selector["Feature"] = 1] = "Feature";
|
|
180
174
|
/** Select the type and planarity of geometry which produced each pixel as well as the fraction of its distance between the near and far planes. */
|
|
181
175
|
Selector[Selector["GeometryAndDistance"] = 4] = "GeometryAndDistance";
|
|
182
|
-
/** Select the [[ContourHit]]s describing which if any contour line produced each pixel. */
|
|
183
|
-
Selector[Selector["Contours"] = 8] = "Contours";
|
|
184
176
|
/** Select all aspects of each pixel. */
|
|
185
|
-
Selector[Selector["All"] =
|
|
177
|
+
Selector[Selector["All"] = 5] = "All";
|
|
186
178
|
})(Selector = Pixel.Selector || (Pixel.Selector = {}));
|
|
187
179
|
})(Pixel || (exports.Pixel = Pixel = {}));
|
|
188
180
|
//# sourceMappingURL=Pixel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pixel.js","sourceRoot":"","sources":["../../../src/render/Pixel.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAAqF;AACrF,4CAAgE;AAKhE;;;;GAIG;AACH,IAAiB,KAAK,CA6PrB;AA7PD,WAAiB,KAAK;IACpB,0DAA0D;IAC1D,MAAa,IAAI;QACf,2CAA2C;QAC3B,OAAO,CAAW;QAClB,OAAO,CAAc;QACrC,sHAAsH;QACtG,gBAAgB,CAAS;QACzC,oDAAoD;QACpC,IAAI,CAAe;QACnC,6DAA6D;QAC7C,SAAS,CAAY;QACrC,gBAAgB;QACA,SAAS,CAAa;QACtC,yEAAyE;QACzD,MAAM,CAAoB;QAC5C;;aAEK;QACa,OAAO,CAAc;QACrC,gBAAgB;QACA,mBAAmB,CAAa;QAChD,gBAAgB;QACA,MAAM,CAAU;QAChC;;WAEG;QACa,gBAAgB,CAAc;QAC9C;;WAEG;QACa,0BAA0B,CAAU;QACpD,gBAAgB;QAChB,IAAW,YAAY;YACrB,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,IAAI,uBAAS,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC;QAC9E,CAAC;QAED,gBAAgB;QAChB,YAAmB,IAYlB;YACC,IAAI,CAAC,gBAAgB,GAAG,IAAI,EAAE,gBAAgB,IAAI,CAAC,CAAC,CAAC;YACrD,IAAI,CAAC,IAAI,GAA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KAAT,eAAS,QASpB;IAED;;;OAGG;IACH,IAAY,QAUX;IAVD,WAAY,QAAQ;QAClB,uCAAQ,CAAA;QACR,wDAAwD;QACxD,6CAAgB,CAAA;QAChB,mJAAmJ;QACnJ,qEAA4B,CAAA;QAC5B,2FAA2F;QAC3F,+CAAiB,CAAA;QACjB,wCAAwC;QACxC,sCAA8C,CAAA;IAChD,CAAC,EAVW,QAAQ,GAAR,cAAQ,KAAR,cAAQ,QAUnB;AAeH,CAAC,EA7PgB,KAAK,qBAAL,KAAK,QA6PrB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Rendering\n */\n\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { BatchType, Feature, GeometryClass, ModelFeature } from \"@itwin/core-common\";\nimport { ContourHit, HitPath, HitPriority } from \"../HitDetail\";\nimport { IModelConnection } from \"../IModelConnection\";\nimport type { Viewport } from \"../Viewport\";\nimport { Transform } from \"@itwin/core-geometry\";\n\n/** Describes aspects of a pixel as read from a [[Viewport]].\n * @see [[Viewport.readPixels]].\n * @public\n * @extensions\n */\nexport namespace Pixel {\n /** Describes a single pixel within a [[Pixel.Buffer]]. */\n export class Data {\n /** The feature that produced the pixel. */\n public readonly feature?: Feature;\n public readonly modelId?: Id64String;\n /** The pixel's depth in [[CoordSystem.Npc]] coordinates (0 to 1), or -1 if depth was not written or not requested. */\n public readonly distanceFraction: number;\n /** The type of geometry that produced the pixel. */\n public readonly type: GeometryType;\n /** The planarity of the geometry that produced the pixel. */\n public readonly planarity: Planarity;\n /** @internal */\n public readonly batchType?: BatchType;\n /** The iModel from which the geometry producing the pixel originated. */\n public readonly iModel?: IModelConnection;\n /** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, that generated this pixel.\n * @beta\n */\n public readonly contour?: ContourHit;\n /** @internal */\n public readonly transformFromIModel?: Transform;\n /** @internal */\n public readonly tileId?: string;\n /** The Id of the [ViewAttachment]($backend), if any, from which the pixel originated.\n * @beta\n */\n public readonly viewAttachmentId?: Id64String;\n /** True if the pixel originated from a [[SpatialViewState]] attached via a [SectionDrawing]($backend).\n * @beta\n */\n public readonly inSectionDrawingAttachment: boolean;\n /** @internal */\n public get isClassifier(): boolean {\n return undefined !== this.batchType && BatchType.Primary !== this.batchType;\n }\n\n /** @internal */\n public constructor(args?: {\n feature?: ModelFeature;\n distanceFraction?: number;\n type?: GeometryType;\n planarity?: Planarity;\n batchType?: BatchType;\n iModel?: IModelConnection;\n tileId?: string;\n viewAttachmentId?: string;\n inSectionDrawingAttachment?: boolean;\n transformFromIModel?: Transform;\n contour?: ContourHit;\n }) {\n this.distanceFraction = args?.distanceFraction ?? -1;\n this.type = args?.type ?? GeometryType.Unknown;\n this.planarity = args?.planarity ?? Planarity.Unknown;\n this.inSectionDrawingAttachment = true === args?.inSectionDrawingAttachment;\n\n if (!args) {\n return;\n }\n\n if (args.feature) {\n this.feature = new Feature(args.feature.elementId, args.feature.subCategoryId, args.feature.geometryClass);\n }\n\n this.modelId = args.feature?.modelId;\n this.iModel = args.iModel;\n this.tileId = args.tileId;\n this.viewAttachmentId = args.viewAttachmentId;\n this.transformFromIModel = args.transformFromIModel;\n this.contour = args.contour;\n }\n\n /** The Id of the element that produced the pixel. */\n public get elementId(): Id64String | undefined {\n return this.feature?.elementId;\n }\n\n /** The Id of the [SubCategory]($backend) that produced the pixel. */\n public get subCategoryId(): Id64String | undefined {\n return this.feature?.subCategoryId;\n }\n\n /** The class of geometry that produced the pixel. */\n public get geometryClass(): GeometryClass | undefined {\n return this.feature?.geometryClass;\n }\n\n /** Computes the [[HitPriority]] of this pixel based on its [[type]] and [[planarity]]. */\n public computeHitPriority(): HitPriority {\n switch (this.type) {\n case Pixel.GeometryType.Surface:\n return Pixel.Planarity.Planar === this.planarity ? HitPriority.PlanarSurface : HitPriority.NonPlanarSurface;\n case Pixel.GeometryType.Linear:\n return HitPriority.WireEdge;\n case Pixel.GeometryType.Edge:\n return Pixel.Planarity.Planar === this.planarity ? HitPriority.PlanarEdge : HitPriority.NonPlanarEdge;\n case Pixel.GeometryType.Silhouette:\n return HitPriority.SilhouetteEdge;\n default:\n return HitPriority.Unknown;\n }\n }\n\n /** Convert this pixel to a [[Pixel.HitProps]] suitable for constructing a [[HitDetail]].\n * @param viewport The viewport in which the hit originated.\n */\n public toHitProps(viewport: Viewport): Pixel.HitProps {\n let path: HitPath | undefined;\n if (this.viewAttachmentId) {\n const attachmentViewport = viewport.view.getAttachmentViewport({ viewAttachmentId: this.viewAttachmentId });\n if (attachmentViewport) {\n path = {\n viewAttachment: {\n viewport: attachmentViewport,\n id: this.viewAttachmentId,\n },\n };\n }\n }\n\n if (this.inSectionDrawingAttachment) {\n const checkVp = path?.viewAttachment?.viewport ?? viewport;\n const attachVp = checkVp.view.getAttachmentViewport({ inSectionDrawingAttachment: true });\n if (attachVp) {\n path = path ?? { };\n path.sectionDrawingAttachment = { viewport: attachVp };\n }\n }\n\n return {\n sourceId: this.elementId ?? Id64.invalid,\n priority: this.computeHitPriority(),\n distFraction: this.distanceFraction,\n subCategoryId: this.subCategoryId,\n geometryClass: this.geometryClass,\n modelId: this.modelId,\n tileId: this.tileId,\n isClassifier: this.isClassifier,\n sourceIModel: this.iModel,\n transformFromSourceIModel: this.transformFromIModel,\n path,\n contour: this.contour,\n };\n }\n }\n\n /** Describes a subset of [[HitDetailProps]] computed from a [[Pixel.Data]], suitable for constructing a [[HitDetail]].\n * For example, the following function creates a `HitDetail` from a `Pixel.Data` and other hit information:\n * ```ts\n * function makeHitDetail(pixel: Pixel.Data, viewport: ScreenViewport, testPoint: Point3d, hitSource: HitSource, hitPoint: Point3d, distXY: number): HitDetail {\n * return new HitDetail({\n * ...pixel.toHitProps(viewport),\n * viewport, testPoint, hitSource, hitPoint, distXY,\n * };\n * }\n * ```\n * @see [[Data.toHitProps]] to convert a [[Pixel.Data]] to a `HitProps`.\n * @public\n */\n export interface HitProps {\n /** The source of the geometry. This may be a persistent element Id, or a transient Id used for, e.g., pickable decorations. */\n sourceId: Id64String;\n /** The hit geometry priority/classification. */\n priority: HitPriority;\n /** The distance in view coordinates between the hit and the near plane. */\n distFraction: number;\n /** The [SubCategory]($backend) to which the hit geometry belongs. */\n subCategoryId?: Id64String;\n /** The class of the hit geometry. */\n geometryClass?: GeometryClass;\n /** The Id of the [[ModelState]] from which the hit originated. */\n modelId?: Id64String;\n /** The IModelConnection from which the hit originated.\n * This should almost always be left undefined, unless the hit is known to have originated from an iModel\n * other than the one associated with the viewport.\n * @internal\n */\n sourceIModel?: IModelConnection;\n /** @internal */\n transformFromSourceIModel?: Transform;\n /** @internal chiefly for debugging */\n tileId?: string;\n /** True if the hit originated from a reality model classifier.\n * @alpha\n */\n isClassifier?: boolean;\n /** Path through which the hit was located.\n * @beta\n */\n path?: HitPath;\n /** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, from which the hit originated.\n * @beta\n */\n contour?: ContourHit;\n }\n\n /** Describes the type of geometry that produced the [[Pixel.Data]]. */\n export enum GeometryType {\n /** [[Pixel.Selector.GeometryAndDistance]] was not specified, or the type could not be determined. */\n Unknown, // Geometry was not selected, or type could not be determined\n /** No geometry was rendered to this pixel. */\n None,\n /** A surface produced this pixel. */\n Surface,\n /** A point primitive or polyline produced this pixel. */\n Linear,\n /** This pixel was produced by an edge of a surface. */\n Edge,\n /** This pixel was produced by a silhouette edge of a curved surface. */\n Silhouette,\n }\n\n /** Describes the planarity of the foremost geometry which produced the pixel. */\n export enum Planarity {\n /** [[Pixel.Selector.GeometryAndDistance]] was not specified, or the planarity could not be determined. */\n Unknown,\n /** No geometry was rendered to this pixel. */\n None,\n /** Planar geometry produced this pixel. */\n Planar,\n /** Non-planar geometry produced this pixel. */\n NonPlanar,\n }\n\n /**\n * Bit-mask by which callers of [[Viewport.readPixels]] specify which aspects are of interest.\n * Aspects not specified will be omitted from the returned data.\n */\n export enum Selector {\n None = 0,\n /** Select the [[Feature]] which produced each pixel. */\n Feature = 1 << 0, // eslint-disable-line @typescript-eslint/no-shadow\n /** Select the type and planarity of geometry which produced each pixel as well as the fraction of its distance between the near and far planes. */\n GeometryAndDistance = 1 << 2,\n /** Select the [[ContourHit]]s describing which if any contour line produced each pixel. */\n Contours = 1 << 3,\n /** Select all aspects of each pixel. */\n All = GeometryAndDistance | Feature | Contours,\n }\n\n /** A rectangular array of pixels as read from a [[Viewport]]'s frame buffer. Each pixel is represented as a [[Pixel.Data]] object.\n * The contents of the pixel buffer will be specified using device pixels, not CSS pixels. See [[Viewport.devicePixelRatio]] and [[Viewport.cssPixelsToDevicePixels]].\n * @see [[Viewport.readPixels]].\n */\n export interface Buffer {\n /** Retrieve the data associated with the pixel at (x,y) in view coordinates. */\n getPixel(x: number, y: number): Data;\n }\n\n /** A function which receives the results of a call to [[Viewport.readPixels]].\n * @note The contents of the buffer become invalid once the Receiver function returns. Do not store a reference to it.\n */\n export type Receiver = (pixels: Buffer | undefined) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Pixel.js","sourceRoot":"","sources":["../../../src/render/Pixel.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAAqF;AACrF,4CAAoD;AAKpD;;;;GAIG;AACH,IAAiB,KAAK,CAgPrB;AAhPD,WAAiB,KAAK;IACpB,0DAA0D;IAC1D,MAAa,IAAI;QACf,2CAA2C;QAC3B,OAAO,CAAW;QAClB,OAAO,CAAc;QACrC,sHAAsH;QACtG,gBAAgB,CAAS;QACzC,oDAAoD;QACpC,IAAI,CAAe;QACnC,6DAA6D;QAC7C,SAAS,CAAY;QACrC,gBAAgB;QACA,SAAS,CAAa;QACtC,yEAAyE;QACzD,MAAM,CAAoB;QAC1C,gBAAgB;QACA,mBAAmB,CAAa;QAChD,gBAAgB;QACA,MAAM,CAAU;QAChC;;WAEG;QACa,gBAAgB,CA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QAavB;IAED,iFAAiF;IACjF,IAAY,SASX;IATD,WAAY,SAAS;QACnB,0GAA0G;QAC1G,+CAAO,CAAA;QACP,8CAA8C;QAC9C,yCAAI,CAAA;QACJ,2CAA2C;QAC3C,6CAAM,CAAA;QACN,+CAA+C;QAC/C,mDAAS,CAAA;IACX,CAAC,EATW,SAAS,GAAT,eAAS,KAAT,eAAS,QASpB;IAED;;;OAGG;IACH,IAAY,QAQX;IARD,WAAY,QAAQ;QAClB,uCAAQ,CAAA;QACR,wDAAwD;QACxD,6CAAgB,CAAA;QAChB,mJAAmJ;QACnJ,qEAA4B,CAAA;QAC5B,wCAAwC;QACxC,qCAAmC,CAAA;IACrC,CAAC,EARW,QAAQ,GAAR,cAAQ,KAAR,cAAQ,QAQnB;AAeH,CAAC,EAhPgB,KAAK,qBAAL,KAAK,QAgPrB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Rendering\n */\n\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { BatchType, Feature, GeometryClass, ModelFeature } from \"@itwin/core-common\";\nimport { HitPath, HitPriority } from \"../HitDetail\";\nimport { IModelConnection } from \"../IModelConnection\";\nimport type { Viewport } from \"../Viewport\";\nimport { Transform } from \"@itwin/core-geometry\";\n\n/** Describes aspects of a pixel as read from a [[Viewport]].\n * @see [[Viewport.readPixels]].\n * @public\n * @extensions\n */\nexport namespace Pixel {\n /** Describes a single pixel within a [[Pixel.Buffer]]. */\n export class Data {\n /** The feature that produced the pixel. */\n public readonly feature?: Feature;\n public readonly modelId?: Id64String;\n /** The pixel's depth in [[CoordSystem.Npc]] coordinates (0 to 1), or -1 if depth was not written or not requested. */\n public readonly distanceFraction: number;\n /** The type of geometry that produced the pixel. */\n public readonly type: GeometryType;\n /** The planarity of the geometry that produced the pixel. */\n public readonly planarity: Planarity;\n /** @internal */\n public readonly batchType?: BatchType;\n /** The iModel from which the geometry producing the pixel originated. */\n public readonly iModel?: IModelConnection;\n /** @internal */\n public readonly transformFromIModel?: Transform;\n /** @internal */\n public readonly tileId?: string;\n /** The Id of the [ViewAttachment]($backend), if any, from which the pixel originated.\n * @beta\n */\n public readonly viewAttachmentId?: Id64String;\n /** True if the pixel originated from a [[SpatialViewState]] attached via a [SectionDrawing]($backend).\n * @beta\n */\n public readonly inSectionDrawingAttachment: boolean;\n /** @internal */\n public get isClassifier(): boolean {\n return undefined !== this.batchType && BatchType.Primary !== this.batchType;\n }\n\n /** @internal */\n public constructor(args?: {\n feature?: ModelFeature;\n distanceFraction?: number;\n type?: GeometryType;\n planarity?: Planarity;\n batchType?: BatchType;\n iModel?: IModelConnection;\n tileId?: string;\n viewAttachmentId?: string;\n inSectionDrawingAttachment?: boolean;\n transformFromIModel?: Transform;\n }) {\n this.distanceFraction = args?.distanceFraction ?? -1;\n this.type = args?.type ?? GeometryType.Unknown;\n this.planarity = args?.planarity ?? Planarity.Unknown;\n this.inSectionDrawingAttachment = true === args?.inSectionDrawingAttachment;\n\n if (!args) {\n return;\n }\n\n if (args.feature) {\n this.feature = new Feature(args.feature.elementId, args.feature.subCategoryId, args.feature.geometryClass);\n }\n\n this.modelId = args.feature?.modelId;\n this.iModel = args.iModel;\n this.tileId = args.tileId;\n this.viewAttachmentId = args.viewAttachmentId;\n this.transformFromIModel = args.transformFromIModel;\n }\n\n /** The Id of the element that produced the pixel. */\n public get elementId(): Id64String | undefined {\n return this.feature?.elementId;\n }\n\n /** The Id of the [SubCategory]($backend) that produced the pixel. */\n public get subCategoryId(): Id64String | undefined {\n return this.feature?.subCategoryId;\n }\n\n /** The class of geometry that produced the pixel. */\n public get geometryClass(): GeometryClass | undefined {\n return this.feature?.geometryClass;\n }\n\n /** Computes the [[HitPriority]] of this pixel based on its [[type]] and [[planarity]]. */\n public computeHitPriority(): HitPriority {\n switch (this.type) {\n case Pixel.GeometryType.Surface:\n return Pixel.Planarity.Planar === this.planarity ? HitPriority.PlanarSurface : HitPriority.NonPlanarSurface;\n case Pixel.GeometryType.Linear:\n return HitPriority.WireEdge;\n case Pixel.GeometryType.Edge:\n return Pixel.Planarity.Planar === this.planarity ? HitPriority.PlanarEdge : HitPriority.NonPlanarEdge;\n case Pixel.GeometryType.Silhouette:\n return HitPriority.SilhouetteEdge;\n default:\n return HitPriority.Unknown;\n }\n }\n\n /** Convert this pixel to a [[Pixel.HitProps]] suitable for constructing a [[HitDetail]].\n * @param viewport The viewport in which the hit originated.\n */\n public toHitProps(viewport: Viewport): Pixel.HitProps {\n let path: HitPath | undefined;\n if (this.viewAttachmentId) {\n const attachmentViewport = viewport.view.getAttachmentViewport({ viewAttachmentId: this.viewAttachmentId });\n if (attachmentViewport) {\n path = {\n viewAttachment: {\n viewport: attachmentViewport,\n id: this.viewAttachmentId,\n },\n };\n }\n }\n\n if (this.inSectionDrawingAttachment) {\n const checkVp = path?.viewAttachment?.viewport ?? viewport;\n const attachVp = checkVp.view.getAttachmentViewport({ inSectionDrawingAttachment: true });\n if (attachVp) {\n path = path ?? { };\n path.sectionDrawingAttachment = { viewport: attachVp };\n }\n }\n\n return {\n sourceId: this.elementId ?? Id64.invalid,\n priority: this.computeHitPriority(),\n distFraction: this.distanceFraction,\n subCategoryId: this.subCategoryId,\n geometryClass: this.geometryClass,\n modelId: this.modelId,\n tileId: this.tileId,\n isClassifier: this.isClassifier,\n sourceIModel: this.iModel,\n transformFromSourceIModel: this.transformFromIModel,\n path,\n };\n }\n }\n\n /** Describes a subset of [[HitDetailProps]] computed from a [[Pixel.Data]], suitable for constructing a [[HitDetail]].\n * For example, the following function creates a `HitDetail` from a `Pixel.Data` and other hit information:\n * ```ts\n * function makeHitDetail(pixel: Pixel.Data, viewport: ScreenViewport, testPoint: Point3d, hitSource: HitSource, hitPoint: Point3d, distXY: number): HitDetail {\n * return new HitDetail({\n * ...pixel.toHitProps(viewport),\n * viewport, testPoint, hitSource, hitPoint, distXY,\n * };\n * }\n * ```\n * @see [[Data.toHitProps]] to convert a [[Pixel.Data]] to a `HitProps`.\n * @public\n */\n export interface HitProps {\n /** The source of the geometry. This may be a persistent element Id, or a transient Id used for, e.g., pickable decorations. */\n sourceId: Id64String;\n /** The hit geometry priority/classification. */\n priority: HitPriority;\n /** The distance in view coordinates between the hit and the near plane. */\n distFraction: number;\n /** The [SubCategory]($backend) to which the hit geometry belongs. */\n subCategoryId?: Id64String;\n /** The class of the hit geometry. */\n geometryClass?: GeometryClass;\n /** The Id of the [[ModelState]] from which the hit originated. */\n modelId?: Id64String;\n /** The IModelConnection from which the hit originated.\n * This should almost always be left undefined, unless the hit is known to have originated from an iModel\n * other than the one associated with the viewport.\n * @internal\n */\n sourceIModel?: IModelConnection;\n /** @internal */\n transformFromSourceIModel?: Transform;\n /** @internal chiefly for debugging */\n tileId?: string;\n /** True if the hit originated from a reality model classifier.\n * @alpha\n */\n isClassifier?: boolean;\n /** Path through which the hit was located.\n * @beta\n */\n path?: HitPath;\n }\n\n /** Describes the type of geometry that produced the [[Pixel.Data]]. */\n export enum GeometryType {\n /** [[Pixel.Selector.GeometryAndDistance]] was not specified, or the type could not be determined. */\n Unknown, // Geometry was not selected, or type could not be determined\n /** No geometry was rendered to this pixel. */\n None,\n /** A surface produced this pixel. */\n Surface,\n /** A point primitive or polyline produced this pixel. */\n Linear,\n /** This pixel was produced by an edge of a surface. */\n Edge,\n /** This pixel was produced by a silhouette edge of a curved surface. */\n Silhouette,\n }\n\n /** Describes the planarity of the foremost geometry which produced the pixel. */\n export enum Planarity {\n /** [[Pixel.Selector.GeometryAndDistance]] was not specified, or the planarity could not be determined. */\n Unknown,\n /** No geometry was rendered to this pixel. */\n None,\n /** Planar geometry produced this pixel. */\n Planar,\n /** Non-planar geometry produced this pixel. */\n NonPlanar,\n }\n\n /**\n * Bit-mask by which callers of [[Viewport.readPixels]] specify which aspects are of interest.\n * Aspects not specified will be omitted from the returned data.\n */\n export enum Selector {\n None = 0,\n /** Select the [[Feature]] which produced each pixel. */\n Feature = 1 << 0, // eslint-disable-line @typescript-eslint/no-shadow\n /** Select the type and planarity of geometry which produced each pixel as well as the fraction of its distance between the near and far planes. */\n GeometryAndDistance = 1 << 2,\n /** Select all aspects of each pixel. */\n All = GeometryAndDistance | Feature,\n }\n\n /** A rectangular array of pixels as read from a [[Viewport]]'s frame buffer. Each pixel is represented as a [[Pixel.Data]] object.\n * The contents of the pixel buffer will be specified using device pixels, not CSS pixels. See [[Viewport.devicePixelRatio]] and [[Viewport.cssPixelsToDevicePixels]].\n * @see [[Viewport.readPixels]].\n */\n export interface Buffer {\n /** Retrieve the data associated with the pixel at (x,y) in view coordinates. */\n getPixel(x: number, y: number): Data;\n }\n\n /** A function which receives the results of a call to [[Viewport.readPixels]].\n * @note The contents of the buffer become invalid once the Receiver function returns. Do not store a reference to it.\n */\n export type Receiver = (pixels: Buffer | undefined) => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementLocateManager.d.ts","sourceRoot":"","sources":["../../src/ElementLocateManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAW,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtD;;;GAGG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAI;IACZ,UAAU,IAAI;CACf;AAED;;;;GAIG;AACH,oBAAY,kBAAkB;IAC5B,MAAM,IAAI;IACV,MAAM,IAAI;CACX;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,UAAU,IAAI;I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,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IACpC,UAAU,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI;IACjC,UAAU,IAAI,SAAS,GAAG,SAAS;IAE1C,0FAA0F;IACnF,gBAAgB,IAAI,SAAS,GAAG,SAAS;IA+BnC,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqCxG,iBAAiB;IACjB,cAAc;YAOP,SAAS;IAiCV,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,UAAO,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CAYlM"}
|
|
@@ -147,11 +147,8 @@ export class ElementPicker {
|
|
|
147
147
|
this.hitList.resetCurrentHit();
|
|
148
148
|
}
|
|
149
149
|
comparePixel(pixel1, pixel2, distXY1, distXY2) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// If two hits have the same priority, prefer a contour over a non-contour.
|
|
153
|
-
priority1 -= pixel1.contour ? 0.5 : 0;
|
|
154
|
-
priority2 -= pixel2.contour ? 0.5 : 0;
|
|
150
|
+
const priority1 = pixel1.computeHitPriority();
|
|
151
|
+
const priority2 = pixel2.computeHitPriority();
|
|
155
152
|
if (priority1 < priority2)
|
|
156
153
|
return -1;
|
|
157
154
|
if (priority1 > priority2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementLocateManager.js","sourceRoot":"","sources":["../../src/ElementLocateManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,OAAO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AM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAC3F,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAErB,8FAA8F;QAC9F,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO;YACrB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module LocatingElements\n */\n\nimport { expectDefined, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { HitDetail, HitList, HitSource } from \"./HitDetail\";\nimport { IModelApp } from \"./IModelApp\";\nimport { Pixel } from \"./render/Pixel\";\nimport { InputSource, InteractiveTool } from \"./tools/Tool\";\nimport { ScreenViewport, Viewport } from \"./Viewport\";\nimport { ViewRect } from \"./common/ViewRect\";\n\n/** The possible actions for which a locate filter can be called.\n * @public\n * @extensions\n */\nexport enum LocateAction {\n Identify = 0,\n AutoLocate = 1,\n}\n\n/** Values to return from a locate filter.\n * Return `Reject` to indicate the element is unacceptable.\n * @public\n * @extensions\n */\nexport enum LocateFilterStatus {\n Accept = 0,\n Reject = 1,\n}\n\n/**\n * @public\n * @extensions\n */\nexport enum SnapStatus {\n Success = 0,\n Aborted = 1,\n NoElements = 2,\n Disabled = 100,\n NoSnapPossible = 200,\n NotSnappable = 300,\n FilteredByApp = 600,\n FilteredByAppQuietly = 700,\n}\n\n/** Options that customize the way element location (i.e. *picking*) works.\n * @public\n * @extensions\n */\nexport class LocateOptions {\n /** If true, also test graphics from view decorations. */\n public allowDecorations = false;\n /** If true, also test graphics with non-locatable flag set. */\n public allowNonLocatable = false;\n /** Maximum number of hits to return. */\n public maxHits = 20;\n /** The [[HitSource]] identifying the caller. */\n public hitSource = HitSource.DataPoint;\n /** If true, also test graphics from an IModelConnection other than the one associated with the Viewport. This can occur if, e.g., a\n * [[TiledGraphicsProvider]] is used to display graphics from a different iModel into the [[Viewport]].\n * @note If you override this, you must be prepared to properly handle [[HitDetail]]s originating from other IModelConnections.\n * @see [[HitDetail.iModel]] and [[HitDetail.isExternalIModelHit]]\n */\n public allowExternalIModels = false;\n /** If true, then the world point of a hit on a model will preserve any transforms applied to the model at display time,\n * such as those supplied by a [[ModelDisplayTransformProvider]] or [PlanProjectionSettings.elevation]($common).\n * Otherwise, the world point will be multiplied by the inverse of any such transforms to correlate it with the model's true coordinate space.\n */\n public preserveModelDisplayTransforms = false;\n\n /** Make a copy of this LocateOptions. */\n public clone(): LocateOptions {\n const other = new LocateOptions();\n other.allowDecorations = this.allowDecorations;\n other.allowNonLocatable = this.allowNonLocatable;\n other.maxHits = this.maxHits;\n other.hitSource = this.hitSource;\n other.allowExternalIModels = this.allowExternalIModels;\n return other;\n }\n public setFrom(other: LocateOptions): void {\n this.allowDecorations = other.allowDecorations;\n this.allowNonLocatable = other.allowNonLocatable;\n this.maxHits = other.maxHits;\n this.hitSource = other.hitSource;\n this.allowExternalIModels = other.allowExternalIModels;\n }\n public init() {\n this.allowDecorations = this.allowNonLocatable = this.allowExternalIModels = false;\n this.maxHits = 20;\n this.hitSource = HitSource.DataPoint;\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport class LocateResponse {\n public snapStatus = SnapStatus.Success;\n public reason?: string;\n public explanation = \"\";\n\n /** @internal */\n public clone(): LocateResponse {\n const other = new LocateResponse();\n other.snapStatus = this.snapStatus;\n other.reason = this.reason;\n other.explanation = this.explanation;\n return other;\n }\n\n /** @internal */\n public setFrom(other: LocateResponse): void {\n this.snapStatus = other.snapStatus;\n this.reason = other.reason;\n this.explanation = other.explanation;\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport interface HitListHolder {\n setHitList(list: HitList<HitDetail> | undefined): void;\n}\n\n/**\n * @public\n * @extensions\n */\nexport class ElementPicker {\n public viewport?: Viewport;\n public readonly pickPointWorld = new Point3d();\n public hitList?: HitList<HitDetail>;\n\n public empty() {\n this.pickPointWorld.setZero();\n this.viewport = undefined;\n if (this.hitList)\n this.hitList.empty();\n else\n this.hitList = new HitList<HitDetail>();\n }\n\n /** return the HitList for the last Pick performed. Optionally allows the caller to take ownership of the list. */\n public getHitList(takeOwnership: boolean): HitList<HitDetail> {\n const list = expectDefined(this.hitList);\n if (takeOwnership)\n this.hitList = undefined;\n return list;\n }\n\n public getNextHit(): HitDetail | undefined { return this.hitList ? this.hitList.getNextHit() : undefined; }\n\n /** Return a hit from the list of hits created the last time pickElements was called. */\n public getHit(i: number): HitDetail | undefined { return this.hitList ? this.hitList.getHit(i) : undefined; }\n\n public resetCurrentHit(): void {\n if (this.hitList)\n this.hitList.resetCurrentHit();\n }\n\n private comparePixel(pixel1: Pixel.Data, pixel2: Pixel.Data, distXY1: number, distXY2: number) {\n let priority1 = pixel1.computeHitPriority();\n let priority2 = pixel2.computeHitPriority();\n\n // If two hits have the same priority, prefer a contour over a non-contour.\n priority1 -= pixel1.contour ? 0.5 : 0;\n priority2 -= pixel2.contour ? 0.5 : 0;\n\n if (priority1 < priority2)\n return -1;\n if (priority1 > priority2)\n return 1;\n if (distXY1 < distXY2)\n return -1;\n if (distXY1 > distXY2)\n return 1;\n if (pixel1.distanceFraction > pixel2.distanceFraction)\n return -1;\n if (pixel1.distanceFraction < pixel2.distanceFraction)\n return 1;\n\n return 0;\n }\n\n /** Generate a list of elements that are close to a given point.\n * @param vp Viewport to use for pick\n * @param pickPointWorld Pick location in world coordinates\n * @param pickRadiusView Pick radius in pixels\n * @param options Pick options to use\n * @param excludedElements Optional ids to not draw during pick. Allows hits for geometry obscured by these ids to be returned.\n * @returns The number of hits in the hitList of this object.\n */\n public doPick(vp: ScreenViewport, pickPointWorld: Point3d, pickRadiusView: number, options: LocateOptions, excludedElements?: Iterable<Id64String>): number {\n if (this.hitList && this.hitList.length > 0 && vp === this.viewport && pickPointWorld.isAlmostEqual(this.pickPointWorld)) {\n this.hitList.resetCurrentHit();\n return this.hitList.length;\n }\n\n this.empty(); // empty the hit list\n this.viewport = vp;\n this.pickPointWorld.setFrom(pickPointWorld);\n\n const pickPointView = vp.worldToView(pickPointWorld);\n const testPointView = new Point2d(Math.floor(pickPointView.x + 0.5), Math.floor(pickPointView.y + 0.5));\n let pixelRadius = Math.floor(pickRadiusView + 0.5);\n const rect = new ViewRect(testPointView.x - pixelRadius, testPointView.y - pixelRadius, testPointView.x + pixelRadius, testPointView.y + pixelRadius);\n if (rect.isNull)\n return 0;\n const receiver = (pixels: Pixel.Buffer | undefined) => {\n if (undefined === pixels)\n return;\n\n testPointView.x = vp.cssPixelsToDevicePixels(testPointView.x);\n testPointView.y = vp.cssPixelsToDevicePixels(testPointView.y);\n pixelRadius = vp.cssPixelsToDevicePixels(pixelRadius);\n\n const elmHits = new Map<string, Point2d>();\n const testPoint = Point2d.createZero();\n for (testPoint.x = testPointView.x - pixelRadius; testPoint.x <= testPointView.x + pixelRadius; ++testPoint.x) {\n for (testPoint.y = testPointView.y - pixelRadius; testPoint.y <= testPointView.y + pixelRadius; ++testPoint.y) {\n const pixel = pixels.getPixel(testPoint.x, testPoint.y);\n if (undefined === pixel || undefined === pixel.elementId || Id64.isInvalid(pixel.elementId))\n continue; // no geometry at this location...\n\n const distXY = testPointView.distance(testPoint);\n if (distXY > pixelRadius)\n continue; // ignore corners. it's a locate circle not square...\n\n const oldPoint = elmHits.get(pixel.elementId);\n if (undefined !== oldPoint) {\n if (this.comparePixel(pixel, pixels.getPixel(oldPoint.x, oldPoint.y), distXY, testPointView.distance(oldPoint)) < 0)\n oldPoint.setFrom(testPoint); // new hit is better, update location...\n } else {\n elmHits.set(pixel.elementId, testPoint.clone());\n }\n }\n }\n if (0 === elmHits.size)\n return;\n\n for (const elmPoint of elmHits.values()) {\n const pixel = pixels.getPixel(elmPoint.x, elmPoint.y);\n if (undefined === pixel || undefined === pixel.elementId)\n continue;\n\n const hitPointWorld = vp.getPixelDataWorldPoint({\n pixels,\n x: elmPoint.x,\n y: elmPoint.y,\n preserveModelDisplayTransforms: options.preserveModelDisplayTransforms,\n });\n\n if (!hitPointWorld)\n continue;\n\n const hit = new HitDetail({\n ...pixel.toHitProps(vp),\n testPoint: pickPointWorld,\n viewport: vp,\n hitSource: options.hitSource,\n hitPoint: hitPointWorld,\n distXY: testPointView.distance(elmPoint),\n });\n\n const hitList = expectDefined(this.hitList);\n hitList.addHit(hit);\n if (hitList.hits.length > options.maxHits)\n hitList.hits.length = options.maxHits; // truncate array...\n }\n\n result = expectDefined(this.hitList).length;\n };\n\n const args = {\n receiver,\n rect,\n selector: Pixel.Selector.All,\n excludeNonLocatable: !options.allowNonLocatable,\n excludedElements,\n };\n let result: number = 0;\n vp.readPixels(args);\n\n return result;\n }\n\n public testHit(hit: HitDetail, vp: ScreenViewport, pickPointWorld: Point3d, pickRadiusView: number, options: LocateOptions): boolean {\n if (0 === this.doPick(vp, pickPointWorld, pickRadiusView, options))\n return false;\n\n return expectDefined(this.hitList).hits.some((thisHit) => hit.isSameHit(thisHit));\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport class ElementLocateManager {\n public hitList?: HitList<HitDetail>;\n public currHit?: HitDetail;\n public readonly options = new LocateOptions();\n public readonly picker = new ElementPicker();\n\n /** get the full message key for a locate failure */\n public static getFailureMessageKey(key: string) { return `LocateFailure.${key}`; }\n public onInitialized() { }\n public get apertureInches() { return 0.11; }\n public get touchApertureInches() { return 0.22; }\n\n public clear(): void { this.setCurrHit(undefined); }\n public setHitList(list?: HitList<HitDetail>) { this.hitList = list; }\n public setCurrHit(hit?: HitDetail): void { this.currHit = hit; }\n public getNextHit(): HitDetail | undefined { return this.hitList ? this.hitList.getNextHit() : undefined; }\n\n /** return the current path from either the snapping logic or the pre-locating systems. */\n public getPreLocatedHit(): HitDetail | undefined {\n // NOTE: Check AccuSnap first as Tentative is used to build intersect snap. For normal snaps when a Tentative is active there should be no AccuSnap.\n const fromAccuSnap = IModelApp.accuSnap.getHitAndList(this);\n const preLocated = fromAccuSnap ?? IModelApp.tentativePoint.getHitAndList(this);\n\n if (preLocated) {\n const excludedElements = (preLocated.isElementHit ? new Set<string>([preLocated.sourceId]) : undefined);\n\n if (excludedElements || !fromAccuSnap) {\n // NOTE: For tentative snap, get new hit list at snap point; want reset to cycle hits using adjusted point location...\n const point = (fromAccuSnap ? preLocated.hitPoint : preLocated.getPoint());\n const vp = preLocated.viewport;\n\n this.picker.empty();\n this.picker.doPick(vp, point, (vp.pixelsFromInches(this.apertureInches) / 2.0) + 1.5, this.options, excludedElements);\n this.setHitList(this.picker.getHitList(true));\n\n if (excludedElements) {\n if (undefined === this.hitList)\n this.hitList = new HitList<HitDetail>();\n this.hitList.insertHit(0, preLocated);\n }\n }\n }\n\n if (this.hitList)\n this.hitList.resetCurrentHit();\n\n return preLocated;\n }\n\n public async filterHit(hit: HitDetail, _action: LocateAction, out: LocateResponse): Promise<LocateFilterStatus> {\n // Tools must opt-in to locate of transient geometry as it requires special treatment.\n if (!this.options.allowDecorations && !hit.isElementHit) {\n if (hit.isModelHit)\n out.reason = ElementLocateManager.getFailureMessageKey(\"RealityModel\");\n else if (hit.isMapHit)\n out.reason = ElementLocateManager.getFailureMessageKey(\"Map\");\n else\n out.reason = ElementLocateManager.getFailureMessageKey(\"Transient\");\n return LocateFilterStatus.Reject;\n }\n\n // Tools must opt-in to locate geometry from external iModels.\n if (!this.options.allowExternalIModels && hit.isExternalIModelHit) {\n out.reason = ElementLocateManager.getFailureMessageKey(\"ExternalIModel\");\n return LocateFilterStatus.Reject;\n }\n\n if (undefined !== hit.subCategoryId && !hit.isExternalIModelHit) {\n const appearance = hit.viewport.getSubCategoryAppearance(hit.subCategoryId);\n if (appearance.dontLocate) {\n out.reason = ElementLocateManager.getFailureMessageKey(\"NotLocatableSubCategory\");\n return LocateFilterStatus.Reject;\n }\n }\n\n const tool = IModelApp.toolAdmin.activeTool;\n if (!(tool && tool instanceof InteractiveTool))\n return LocateFilterStatus.Accept;\n\n const status = await tool.filterHit(hit, out);\n if (LocateFilterStatus.Reject === status)\n out.reason = ElementLocateManager.getFailureMessageKey(\"ByApp\");\n\n return status;\n }\n\n public initLocateOptions() { this.options.init(); }\n public initToolLocate() {\n this.initLocateOptions();\n this.clear();\n this.picker.empty();\n IModelApp.tentativePoint.clear(true);\n }\n\n private async _doLocate(response: LocateResponse, newSearch: boolean, testPoint: Point3d, vp: ScreenViewport | undefined, source: InputSource, filterHits: boolean): Promise<HitDetail | undefined> {\n if (!vp)\n return;\n\n // the \"newSearch\" flag indicates whether the caller wants us to conduct a new search at the testPoint, or just continue returning paths from the previous search.\n if (newSearch) {\n const hit = this.getPreLocatedHit();\n\n // if we're snapped to something, that path has the highest priority and becomes the active hit.\n if (hit) {\n if (!filterHits || LocateFilterStatus.Accept === await this.filterHit(hit, LocateAction.Identify, response))\n return hit;\n\n response = new LocateResponse(); // we have the reason and explanation we want.\n }\n\n this.picker.empty();\n this.picker.doPick(vp, testPoint, (vp.pixelsFromInches(InputSource.Touch === source ? this.touchApertureInches : this.apertureInches) / 2.0) + 1.5, this.options);\n\n const hitList = this.picker.getHitList(true);\n this.setHitList(hitList);\n }\n\n let newHit: HitDetail | undefined;\n while (undefined !== (newHit = this.getNextHit())) {\n if (!filterHits || LocateFilterStatus.Accept === await this.filterHit(newHit, LocateAction.Identify, response))\n return newHit;\n response = new LocateResponse(); // we have the reason and explanation we want.\n }\n\n return undefined;\n }\n\n public async doLocate(response: LocateResponse, newSearch: boolean, testPoint: Point3d, view: ScreenViewport | undefined, source: InputSource, filterHits = true): Promise<HitDetail | undefined> {\n response.reason = ElementLocateManager.getFailureMessageKey(\"NoElements\");\n response.explanation = \"\";\n\n const hit = await this._doLocate(response, newSearch, testPoint, view, source, filterHits);\n this.setCurrHit(hit);\n\n // if we found a hit, remove it from the list of remaining hits near the current search point.\n if (hit && this.hitList)\n this.hitList.removeHitsFrom(hit.sourceId);\n return hit;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementLocateManager.js","sourceRoot":"","sources":["../../src/ElementLocateManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,2DAAc,CAAA;AAChB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+DAAU,CAAA;IACV,+DAAU,CAAA;AACZ,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iDAAW,CAAA;IACX,iDAAW,CAAA;IACX,uDAAc,CAAA;IACd,qDAAc,CAAA;IACd,iEAAoB,CAAA;IACpB,6DAAkB,CAAA;IAClB,+DAAmB,CAAA;IACnB,6EAA0B,CAAA;AAC5B,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED;;;GAGG;AACH,M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AAU,GAAG,IAAI;QAC9J,QAAQ,CAAC,MAAM,GAAG,oBAAoB,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;QAC1E,QAAQ,CAAC,WAAW,GAAG,EAAE,CAAC;QAE1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAC3F,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAErB,8FAA8F;QAC9F,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO;YACrB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module LocatingElements\n */\n\nimport { expectDefined, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { HitDetail, HitList, HitSource } from \"./HitDetail\";\nimport { IModelApp } from \"./IModelApp\";\nimport { Pixel } from \"./render/Pixel\";\nimport { InputSource, InteractiveTool } from \"./tools/Tool\";\nimport { ScreenViewport, Viewport } from \"./Viewport\";\nimport { ViewRect } from \"./common/ViewRect\";\n\n/** The possible actions for which a locate filter can be called.\n * @public\n * @extensions\n */\nexport enum LocateAction {\n Identify = 0,\n AutoLocate = 1,\n}\n\n/** Values to return from a locate filter.\n * Return `Reject` to indicate the element is unacceptable.\n * @public\n * @extensions\n */\nexport enum LocateFilterStatus {\n Accept = 0,\n Reject = 1,\n}\n\n/**\n * @public\n * @extensions\n */\nexport enum SnapStatus {\n Success = 0,\n Aborted = 1,\n NoElements = 2,\n Disabled = 100,\n NoSnapPossible = 200,\n NotSnappable = 300,\n FilteredByApp = 600,\n FilteredByAppQuietly = 700,\n}\n\n/** Options that customize the way element location (i.e. *picking*) works.\n * @public\n * @extensions\n */\nexport class LocateOptions {\n /** If true, also test graphics from view decorations. */\n public allowDecorations = false;\n /** If true, also test graphics with non-locatable flag set. */\n public allowNonLocatable = false;\n /** Maximum number of hits to return. */\n public maxHits = 20;\n /** The [[HitSource]] identifying the caller. */\n public hitSource = HitSource.DataPoint;\n /** If true, also test graphics from an IModelConnection other than the one associated with the Viewport. This can occur if, e.g., a\n * [[TiledGraphicsProvider]] is used to display graphics from a different iModel into the [[Viewport]].\n * @note If you override this, you must be prepared to properly handle [[HitDetail]]s originating from other IModelConnections.\n * @see [[HitDetail.iModel]] and [[HitDetail.isExternalIModelHit]]\n */\n public allowExternalIModels = false;\n /** If true, then the world point of a hit on a model will preserve any transforms applied to the model at display time,\n * such as those supplied by a [[ModelDisplayTransformProvider]] or [PlanProjectionSettings.elevation]($common).\n * Otherwise, the world point will be multiplied by the inverse of any such transforms to correlate it with the model's true coordinate space.\n */\n public preserveModelDisplayTransforms = false;\n\n /** Make a copy of this LocateOptions. */\n public clone(): LocateOptions {\n const other = new LocateOptions();\n other.allowDecorations = this.allowDecorations;\n other.allowNonLocatable = this.allowNonLocatable;\n other.maxHits = this.maxHits;\n other.hitSource = this.hitSource;\n other.allowExternalIModels = this.allowExternalIModels;\n return other;\n }\n public setFrom(other: LocateOptions): void {\n this.allowDecorations = other.allowDecorations;\n this.allowNonLocatable = other.allowNonLocatable;\n this.maxHits = other.maxHits;\n this.hitSource = other.hitSource;\n this.allowExternalIModels = other.allowExternalIModels;\n }\n public init() {\n this.allowDecorations = this.allowNonLocatable = this.allowExternalIModels = false;\n this.maxHits = 20;\n this.hitSource = HitSource.DataPoint;\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport class LocateResponse {\n public snapStatus = SnapStatus.Success;\n public reason?: string;\n public explanation = \"\";\n\n /** @internal */\n public clone(): LocateResponse {\n const other = new LocateResponse();\n other.snapStatus = this.snapStatus;\n other.reason = this.reason;\n other.explanation = this.explanation;\n return other;\n }\n\n /** @internal */\n public setFrom(other: LocateResponse): void {\n this.snapStatus = other.snapStatus;\n this.reason = other.reason;\n this.explanation = other.explanation;\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport interface HitListHolder {\n setHitList(list: HitList<HitDetail> | undefined): void;\n}\n\n/**\n * @public\n * @extensions\n */\nexport class ElementPicker {\n public viewport?: Viewport;\n public readonly pickPointWorld = new Point3d();\n public hitList?: HitList<HitDetail>;\n\n public empty() {\n this.pickPointWorld.setZero();\n this.viewport = undefined;\n if (this.hitList)\n this.hitList.empty();\n else\n this.hitList = new HitList<HitDetail>();\n }\n\n /** return the HitList for the last Pick performed. Optionally allows the caller to take ownership of the list. */\n public getHitList(takeOwnership: boolean): HitList<HitDetail> {\n const list = expectDefined(this.hitList);\n if (takeOwnership)\n this.hitList = undefined;\n return list;\n }\n\n public getNextHit(): HitDetail | undefined { return this.hitList ? this.hitList.getNextHit() : undefined; }\n\n /** Return a hit from the list of hits created the last time pickElements was called. */\n public getHit(i: number): HitDetail | undefined { return this.hitList ? this.hitList.getHit(i) : undefined; }\n\n public resetCurrentHit(): void {\n if (this.hitList)\n this.hitList.resetCurrentHit();\n }\n\n private comparePixel(pixel1: Pixel.Data, pixel2: Pixel.Data, distXY1: number, distXY2: number) {\n const priority1 = pixel1.computeHitPriority();\n const priority2 = pixel2.computeHitPriority();\n\n if (priority1 < priority2)\n return -1;\n if (priority1 > priority2)\n return 1;\n if (distXY1 < distXY2)\n return -1;\n if (distXY1 > distXY2)\n return 1;\n if (pixel1.distanceFraction > pixel2.distanceFraction)\n return -1;\n if (pixel1.distanceFraction < pixel2.distanceFraction)\n return 1;\n\n return 0;\n }\n\n /** Generate a list of elements that are close to a given point.\n * @param vp Viewport to use for pick\n * @param pickPointWorld Pick location in world coordinates\n * @param pickRadiusView Pick radius in pixels\n * @param options Pick options to use\n * @param excludedElements Optional ids to not draw during pick. Allows hits for geometry obscured by these ids to be returned.\n * @returns The number of hits in the hitList of this object.\n */\n public doPick(vp: ScreenViewport, pickPointWorld: Point3d, pickRadiusView: number, options: LocateOptions, excludedElements?: Iterable<Id64String>): number {\n if (this.hitList && this.hitList.length > 0 && vp === this.viewport && pickPointWorld.isAlmostEqual(this.pickPointWorld)) {\n this.hitList.resetCurrentHit();\n return this.hitList.length;\n }\n\n this.empty(); // empty the hit list\n this.viewport = vp;\n this.pickPointWorld.setFrom(pickPointWorld);\n\n const pickPointView = vp.worldToView(pickPointWorld);\n const testPointView = new Point2d(Math.floor(pickPointView.x + 0.5), Math.floor(pickPointView.y + 0.5));\n let pixelRadius = Math.floor(pickRadiusView + 0.5);\n const rect = new ViewRect(testPointView.x - pixelRadius, testPointView.y - pixelRadius, testPointView.x + pixelRadius, testPointView.y + pixelRadius);\n if (rect.isNull)\n return 0;\n const receiver = (pixels: Pixel.Buffer | undefined) => {\n if (undefined === pixels)\n return;\n\n testPointView.x = vp.cssPixelsToDevicePixels(testPointView.x);\n testPointView.y = vp.cssPixelsToDevicePixels(testPointView.y);\n pixelRadius = vp.cssPixelsToDevicePixels(pixelRadius);\n\n const elmHits = new Map<string, Point2d>();\n const testPoint = Point2d.createZero();\n for (testPoint.x = testPointView.x - pixelRadius; testPoint.x <= testPointView.x + pixelRadius; ++testPoint.x) {\n for (testPoint.y = testPointView.y - pixelRadius; testPoint.y <= testPointView.y + pixelRadius; ++testPoint.y) {\n const pixel = pixels.getPixel(testPoint.x, testPoint.y);\n if (undefined === pixel || undefined === pixel.elementId || Id64.isInvalid(pixel.elementId))\n continue; // no geometry at this location...\n\n const distXY = testPointView.distance(testPoint);\n if (distXY > pixelRadius)\n continue; // ignore corners. it's a locate circle not square...\n\n const oldPoint = elmHits.get(pixel.elementId);\n if (undefined !== oldPoint) {\n if (this.comparePixel(pixel, pixels.getPixel(oldPoint.x, oldPoint.y), distXY, testPointView.distance(oldPoint)) < 0)\n oldPoint.setFrom(testPoint); // new hit is better, update location...\n } else {\n elmHits.set(pixel.elementId, testPoint.clone());\n }\n }\n }\n if (0 === elmHits.size)\n return;\n\n for (const elmPoint of elmHits.values()) {\n const pixel = pixels.getPixel(elmPoint.x, elmPoint.y);\n if (undefined === pixel || undefined === pixel.elementId)\n continue;\n\n const hitPointWorld = vp.getPixelDataWorldPoint({\n pixels,\n x: elmPoint.x,\n y: elmPoint.y,\n preserveModelDisplayTransforms: options.preserveModelDisplayTransforms,\n });\n\n if (!hitPointWorld)\n continue;\n\n const hit = new HitDetail({\n ...pixel.toHitProps(vp),\n testPoint: pickPointWorld,\n viewport: vp,\n hitSource: options.hitSource,\n hitPoint: hitPointWorld,\n distXY: testPointView.distance(elmPoint),\n });\n\n const hitList = expectDefined(this.hitList);\n hitList.addHit(hit);\n if (hitList.hits.length > options.maxHits)\n hitList.hits.length = options.maxHits; // truncate array...\n }\n\n result = expectDefined(this.hitList).length;\n };\n\n const args = {\n receiver,\n rect,\n selector: Pixel.Selector.All,\n excludeNonLocatable: !options.allowNonLocatable,\n excludedElements,\n };\n let result: number = 0;\n vp.readPixels(args);\n\n return result;\n }\n\n public testHit(hit: HitDetail, vp: ScreenViewport, pickPointWorld: Point3d, pickRadiusView: number, options: LocateOptions): boolean {\n if (0 === this.doPick(vp, pickPointWorld, pickRadiusView, options))\n return false;\n\n return expectDefined(this.hitList).hits.some((thisHit) => hit.isSameHit(thisHit));\n }\n}\n\n/**\n * @public\n * @extensions\n */\nexport class ElementLocateManager {\n public hitList?: HitList<HitDetail>;\n public currHit?: HitDetail;\n public readonly options = new LocateOptions();\n public readonly picker = new ElementPicker();\n\n /** get the full message key for a locate failure */\n public static getFailureMessageKey(key: string) { return `LocateFailure.${key}`; }\n public onInitialized() { }\n public get apertureInches() { return 0.11; }\n public get touchApertureInches() { return 0.22; }\n\n public clear(): void { this.setCurrHit(undefined); }\n public setHitList(list?: HitList<HitDetail>) { this.hitList = list; }\n public setCurrHit(hit?: HitDetail): void { this.currHit = hit; }\n public getNextHit(): HitDetail | undefined { return this.hitList ? this.hitList.getNextHit() : undefined; }\n\n /** return the current path from either the snapping logic or the pre-locating systems. */\n public getPreLocatedHit(): HitDetail | undefined {\n // NOTE: Check AccuSnap first as Tentative is used to build intersect snap. For normal snaps when a Tentative is active there should be no AccuSnap.\n const fromAccuSnap = IModelApp.accuSnap.getHitAndList(this);\n const preLocated = fromAccuSnap ?? IModelApp.tentativePoint.getHitAndList(this);\n\n if (preLocated) {\n const excludedElements = (preLocated.isElementHit ? new Set<string>([preLocated.sourceId]) : undefined);\n\n if (excludedElements || !fromAccuSnap) {\n // NOTE: For tentative snap, get new hit list at snap point; want reset to cycle hits using adjusted point location...\n const point = (fromAccuSnap ? preLocated.hitPoint : preLocated.getPoint());\n const vp = preLocated.viewport;\n\n this.picker.empty();\n this.picker.doPick(vp, point, (vp.pixelsFromInches(this.apertureInches) / 2.0) + 1.5, this.options, excludedElements);\n this.setHitList(this.picker.getHitList(true));\n\n if (excludedElements) {\n if (undefined === this.hitList)\n this.hitList = new HitList<HitDetail>();\n this.hitList.insertHit(0, preLocated);\n }\n }\n }\n\n if (this.hitList)\n this.hitList.resetCurrentHit();\n\n return preLocated;\n }\n\n public async filterHit(hit: HitDetail, _action: LocateAction, out: LocateResponse): Promise<LocateFilterStatus> {\n // Tools must opt-in to locate of transient geometry as it requires special treatment.\n if (!this.options.allowDecorations && !hit.isElementHit) {\n if (hit.isModelHit)\n out.reason = ElementLocateManager.getFailureMessageKey(\"RealityModel\");\n else if (hit.isMapHit)\n out.reason = ElementLocateManager.getFailureMessageKey(\"Map\");\n else\n out.reason = ElementLocateManager.getFailureMessageKey(\"Transient\");\n return LocateFilterStatus.Reject;\n }\n\n // Tools must opt-in to locate geometry from external iModels.\n if (!this.options.allowExternalIModels && hit.isExternalIModelHit) {\n out.reason = ElementLocateManager.getFailureMessageKey(\"ExternalIModel\");\n return LocateFilterStatus.Reject;\n }\n\n if (undefined !== hit.subCategoryId && !hit.isExternalIModelHit) {\n const appearance = hit.viewport.getSubCategoryAppearance(hit.subCategoryId);\n if (appearance.dontLocate) {\n out.reason = ElementLocateManager.getFailureMessageKey(\"NotLocatableSubCategory\");\n return LocateFilterStatus.Reject;\n }\n }\n\n const tool = IModelApp.toolAdmin.activeTool;\n if (!(tool && tool instanceof InteractiveTool))\n return LocateFilterStatus.Accept;\n\n const status = await tool.filterHit(hit, out);\n if (LocateFilterStatus.Reject === status)\n out.reason = ElementLocateManager.getFailureMessageKey(\"ByApp\");\n\n return status;\n }\n\n public initLocateOptions() { this.options.init(); }\n public initToolLocate() {\n this.initLocateOptions();\n this.clear();\n this.picker.empty();\n IModelApp.tentativePoint.clear(true);\n }\n\n private async _doLocate(response: LocateResponse, newSearch: boolean, testPoint: Point3d, vp: ScreenViewport | undefined, source: InputSource, filterHits: boolean): Promise<HitDetail | undefined> {\n if (!vp)\n return;\n\n // the \"newSearch\" flag indicates whether the caller wants us to conduct a new search at the testPoint, or just continue returning paths from the previous search.\n if (newSearch) {\n const hit = this.getPreLocatedHit();\n\n // if we're snapped to something, that path has the highest priority and becomes the active hit.\n if (hit) {\n if (!filterHits || LocateFilterStatus.Accept === await this.filterHit(hit, LocateAction.Identify, response))\n return hit;\n\n response = new LocateResponse(); // we have the reason and explanation we want.\n }\n\n this.picker.empty();\n this.picker.doPick(vp, testPoint, (vp.pixelsFromInches(InputSource.Touch === source ? this.touchApertureInches : this.apertureInches) / 2.0) + 1.5, this.options);\n\n const hitList = this.picker.getHitList(true);\n this.setHitList(hitList);\n }\n\n let newHit: HitDetail | undefined;\n while (undefined !== (newHit = this.getNextHit())) {\n if (!filterHits || LocateFilterStatus.Accept === await this.filterHit(newHit, LocateAction.Identify, response))\n return newHit;\n response = new LocateResponse(); // we have the reason and explanation we want.\n }\n\n return undefined;\n }\n\n public async doLocate(response: LocateResponse, newSearch: boolean, testPoint: Point3d, view: ScreenViewport | undefined, source: InputSource, filterHits = true): Promise<HitDetail | undefined> {\n response.reason = ElementLocateManager.getFailureMessageKey(\"NoElements\");\n response.explanation = \"\";\n\n const hit = await this._doLocate(response, newSearch, testPoint, view, source, filterHits);\n this.setCurrHit(hit);\n\n // if we found a hit, remove it from the list of remaining hits near the current search point.\n if (hit && this.hitList)\n this.hitList.removeHitsFrom(hit.sourceId);\n return hit;\n }\n}\n"]}
|
package/lib/esm/HitDetail.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Id64String } from "@itwin/core-bentley";
|
|
5
5
|
import { CurvePrimitive, Point3d, Transform, Vector3d, XYZProps } from "@itwin/core-geometry";
|
|
6
|
-
import {
|
|
6
|
+
import { GeometryClass } from "@itwin/core-common";
|
|
7
7
|
import { IModelConnection } from "./IModelConnection";
|
|
8
8
|
import { Sprite } from "./Sprites";
|
|
9
9
|
import { DecorateContext } from "./ViewContext";
|
|
@@ -131,21 +131,6 @@ export interface HitPath {
|
|
|
131
131
|
/** Details about the [SectionDrawing]($backend) attachment through which the hit was obtained. */
|
|
132
132
|
sectionDrawingAttachment?: SectionDrawingAttachmentHitInfo;
|
|
133
133
|
}
|
|
134
|
-
/** Information about a [contour line]($docs/learning/display/ContourDisplay.md) that generated a [[HitDetail]] or [[Pixel]].
|
|
135
|
-
* @see [[HitDetail.contour]]
|
|
136
|
-
* @see [[Pixel.Data.contour]]
|
|
137
|
-
* @beta
|
|
138
|
-
*/
|
|
139
|
-
export interface ContourHit {
|
|
140
|
-
/** The contour group that generated the contour line, as specified by [[ContourDisplay.groups]]. */
|
|
141
|
-
readonly group: ContourGroup;
|
|
142
|
-
/** True if the contour is a major contour line as specified by the [[group]] from which it originated, false if it is a minor contour line. */
|
|
143
|
-
readonly isMajor: boolean;
|
|
144
|
-
/** The height in world coordinates of the contour line. This is always a multiple of the [Contour.minorInterval]($common) defined for the [[group]].
|
|
145
|
-
* @note The multiple may be approximate due to the limitations of floating-point precision.
|
|
146
|
-
*/
|
|
147
|
-
readonly elevation: number;
|
|
148
|
-
}
|
|
149
134
|
/** Arguments supplied to the [[HitDetail]] constructor.
|
|
150
135
|
* @public
|
|
151
136
|
*/
|
|
@@ -190,10 +175,6 @@ export interface HitDetailProps {
|
|
|
190
175
|
* @beta
|
|
191
176
|
*/
|
|
192
177
|
readonly path?: HitPath;
|
|
193
|
-
/** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, from which this hit originated.
|
|
194
|
-
* @beta
|
|
195
|
-
*/
|
|
196
|
-
readonly contour?: ContourHit;
|
|
197
178
|
}
|
|
198
179
|
/** A HitDetail stores the result when locating geometry displayed in a view.
|
|
199
180
|
* It holds an approximate location on an element (or decoration) from a *pick*.
|
|
@@ -247,10 +228,6 @@ export declare class HitDetail {
|
|
|
247
228
|
* @beta
|
|
248
229
|
*/
|
|
249
230
|
get path(): HitPath | undefined;
|
|
250
|
-
/** Information about the [contour line]($docs/learning/display/ContourDisplay.md), if any, from which this hit originated.
|
|
251
|
-
* @beta
|
|
252
|
-
*/
|
|
253
|
-
get contour(): ContourHit | undefined;
|
|
254
231
|
/** Create a new HitDetail from the inputs to and results of a locate operation. */
|
|
255
232
|
constructor(props: HitDetailProps);
|
|
256
233
|
/** @deprecated in 4.1 - will not be removed until after 2026-06-13. Use the overload that takes a [[HitDetailProps]]. */
|