@mapvx/web-kit 1.2.0-develop.13 → 1.2.0-develop.14
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/dist/cjs/chunks/{DRACOLoader-gEI4jG0V.cjs → DRACOLoader-B1Y7vbrj.cjs} +2 -2
- package/dist/cjs/chunks/{GLTFLoader-Cd9ix-wY.cjs → GLTFLoader-DrrfQ0_F.cjs} +2 -2
- package/dist/cjs/chunks/{KTX2Loader-Dk2GlCFI.cjs → KTX2Loader-BoLi8knA.cjs} +2 -2
- package/dist/cjs/chunks/{accessibility-C9U1mv_p.cjs → accessibility-Djzp33ox.cjs} +2 -2
- package/dist/cjs/chunks/{back_arrow-tpfWrGJ9.cjs → back_arrow-BPoJQerl.cjs} +2 -2
- package/dist/cjs/chunks/{debug-hooks-xLx1YP8n.cjs → debug-hooks-CMF1BR-2.cjs} +2 -2
- package/dist/cjs/chunks/{dist-ENDZf7Zh.cjs → dist-B06OgE5W.cjs} +2 -2
- package/dist/cjs/chunks/{dist-1oZjernx.cjs → dist-DII2Jcfe.cjs} +2 -2
- package/dist/cjs/chunks/{dist-CYGLkXos.cjs → dist-_3MDeFq6.cjs} +2 -2
- package/dist/cjs/chunks/{expression-q70ZQCYv.cjs → expression-Dq2zVyIz.cjs} +2 -2
- package/dist/cjs/chunks/{globe-viewport-CIe_h8dV.cjs → globe-viewport-s9VMxxMl.cjs} +2 -2
- package/dist/cjs/chunks/{icon-origin-point-D_DBb1gM.cjs → icon-origin-point-B07J_RrC.cjs} +2 -2
- package/dist/cjs/chunks/{meshopt_decoder.module-B5j8Tze_.cjs → meshopt_decoder.module-CedN2Fs4.cjs} +2 -2
- package/dist/cjs/chunks/{repeat_icon-F6Q7hnPl.cjs → repeat_icon-BwwtBUqw.cjs} +2 -2
- package/dist/cjs/chunks/{rolldown-runtime-BOxlEPsq.cjs → rolldown-runtime-S4XI6pHy.cjs} +2 -2
- package/dist/cjs/chunks/{shader-type-decoder-B16cQ7H3.cjs → shader-type-decoder-CplMa6Zn.cjs} +2 -2
- package/dist/cjs/chunks/{styles-zP5lXn9p.cjs → styles-eVk3as0O.cjs} +2 -2
- package/dist/cjs/chunks/{three.module-BHURJnCD.cjs → three.module-TyjyfRuV.cjs} +2 -2
- package/dist/cjs/chunks/{walking-CMpmZTw3.cjs → walking-BXmnNjav.cjs} +2 -2
- package/dist/cjs/chunks/{webgl-CJbVWdD9.cjs → webgl-C3A9O7UB.cjs} +2 -2
- package/dist/cjs/chunks/{webgl-device-D7wKHxQy.cjs → webgl-device-CR_IOS1K.cjs} +2 -2
- package/dist/cjs/web-kit.cjs +5 -5
- package/dist/es/chunks/{DRACOLoader-r8VXQ8hj.js → DRACOLoader-D0vU8-Oo.js} +2 -2
- package/dist/es/chunks/{GLTFLoader-IbJ3eCNr.js → GLTFLoader-DQ80Aq6X.js} +2 -2
- package/dist/es/chunks/{KTX2Loader-DZlQyAGv.js → KTX2Loader-Dh9k32r5.js} +2 -2
- package/dist/es/chunks/{accessibility-BldDqm74.js → accessibility-BG8JCwcH.js} +2 -2
- package/dist/es/chunks/{back_arrow-BeeCYF4P.js → back_arrow-CF2VEGV0.js} +2 -2
- package/dist/es/chunks/{debug-hooks-NzJ2oy3C.js → debug-hooks-D_XQuFlb.js} +2 -2
- package/dist/es/chunks/{dist-B3-nPsaF.js → dist-B7VX6I_c.js} +2 -2
- package/dist/es/chunks/{dist-DOcsJa1u.js → dist-CQzG76mh.js} +2 -2
- package/dist/es/chunks/{dist-DNNWa2bQ.js → dist-CcWEArpE.js} +2 -2
- package/dist/es/chunks/{expression-Dpos4VqC.js → expression-C7yC7-03.js} +2 -2
- package/dist/es/chunks/{globe-viewport-BmqhgdhG.js → globe-viewport-D0Ev9_5m.js} +2 -2
- package/dist/es/chunks/{icon-origin-point-CkHTMtFu.js → icon-origin-point-C23InZ8B.js} +2 -2
- package/dist/es/chunks/{meshopt_decoder.module-YGVnWwV0.js → meshopt_decoder.module-CrrPmGGq.js} +2 -2
- package/dist/es/chunks/{repeat_icon-B_t3ecTa.js → repeat_icon-BIa50JSA.js} +2 -2
- package/dist/es/chunks/{rolldown-runtime-BSTMnvUK.js → rolldown-runtime-CDBfnOLQ.js} +2 -2
- package/dist/es/chunks/{shader-type-decoder-CFX5sij5.js → shader-type-decoder-CmsRL_mF.js} +2 -2
- package/dist/es/chunks/{styles-DTTMB3rI.js → styles-CU6-Ggto.js} +2 -2
- package/dist/es/chunks/{three.module-Cj5xe6gn.js → three.module-Df6wkceO.js} +2 -2
- package/dist/es/chunks/{walking--SMEsH_B.js → walking-BY9QNI9o.js} +2 -2
- package/dist/es/chunks/{webgl-device-KnEQ5CNv.js → webgl-device-CjfmtXLr.js} +2 -2
- package/dist/es/chunks/{webgl-ZcaUll7k.js → webgl-y_Wz0lFW.js} +2 -2
- package/dist/es/web-kit.mjs +5 -5
- package/dist/iife/web-kit.iife.js +3 -3
- package/dist/sw/mvx-tiles-sw.js +4 -19
- package/dist/types/index.d.ts +19 -19
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Web-kit v1.2.0-develop.
|
|
2
|
-
!function(){try{var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=(new n.Error).stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="7cfa57dd-dd6b-4e3d-a7ad-2e9982c18d5f",n._sentryDebugIdIdentifier="sentry-dbid-7cfa57dd-dd6b-4e3d-a7ad-2e9982c18d5f")}catch(n){}}();import{Rt as n,U as e,Ut as t}from"./debug-hooks-NzJ2oy3C.js";import{a as i,n as r,r as s,t as u}from"./expression-Dpos4VqC.js";import{h as o,m as a}from"./dist-B3-nPsaF.js";function l(n,e,t=!1){if(t)return 1===e?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return 1===e?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return 1===e?"int":`ivec${e}`;default:return 1===e?"float":`vec${e}`}}function f(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return 1===e?i:3!==e||i.startsWith("float32")||i.endsWith("32")?`${i}x${e}`:`${i}x3-webgl`}function d(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function c(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}var p=new n;function m({module:n,elementWise:e=!1,expression:t,inputs:r,output:u,operationType:o=u.type,outputBuffer:f}){const c=f.device,m=h("result",u.type,u.size,u.normalized),v=[n,m],x=[],y={},E=l(u.type,1,u.normalized),$=l(o,1,u.normalized);let b="",T=null;const w={TYPE:$,RESULT_LEN:u.size.toString()},S=function(n){return Array.isArray(n)?n.map((n,e)=>[`x${e}`,n]):Object.entries(n)}(r);for(const[a,l]of S)v.push(g(a,l.type,l.size,l.normalized,o)),x.push(_(a,l)),l instanceof s?y[a]=l.buffer:(T=T||i.createOrReuse(c,f.byteLength),y[a]=T),b+=`TYPE ${a}[${l.size}]; get_${a}(${a});\n`,w[`${a.toUpperCase()}_LEN`]=l.size.toString();let L="";if(t)for(let i=0;i<u.size;i++)L+=`result[${i}]=${t(i)};\n`;else if(e)for(let i=0;i<u.size;i++){const e=d($),t=S.map(([n,t])=>i<t.size?`${n}[${i}]`:e);L+=`result[${i}]=${n.name}(${t.join(", ")});\n`}else L=`${n.name}(${S.map(([n])=>n).join(", ")}, result);`;const z=`#version 300 es\n\nvoid main() {\n${b}\n${E} result[${u.size}];\n${L}\nset_result(result);\n}\n `,P=new a(c,{vs:z,shaderAssembler:p,defines:w,modules:v,bufferLayout:x,vertexCount:1,instanceCount:u.length,attributes:y,feedbackBufferMode:"interleaved",outputs:m.varyings});c.statsManager.getStats("GPGPU Operation Counts").get("Transform Runs").incrementCount(),P.run({inputBuffers:y,outputBuffers:{[m.varyings[0]]:0===u.offset?f:{buffer:f,byteOffset:u.offset,byteLength:u.byteLength}}}),T&&i.recycle(T)}function g(n,e,t,i=!1,r=e){let s="",u="";for(let o=0;o<t;o+=4){const a=Math.min(t-o,4);s+=`in ${l(e,a,i)} a${n}_${o};\n`;for(let t=0;t<a;t++){let s=`a${n}_${o}`;a>1&&(s=`${s}[${t}]`),(i||e!==r)&&(s=`TYPE(${s})`),u+=`v[${o+t}]=${s};\n`}}return{name:n,vs:`\n${s}\nvoid get_${n}(out TYPE v[${t}]) {\n ${u}\n}\n`}}function _(n,e){const t={name:n,stepMode:e.isConstant?"vertex":"instance",byteStride:e.stride,attributes:[]};for(let i=0;i<e.size;i+=4){const r=Math.min(e.size-i,4);t.attributes.push({attribute:`a${n}_${i}`,format:f(e.type,r,e.normalized),byteOffset:e.offset+e.ValueType.BYTES_PER_ELEMENT*i})}return t}function h(n,e,t,i=!1){const r=[],s=l(e,1,i);let u="",o="";for(let a=0;a<t;a+=4){const s=Math.min(t-a,4),f=l(e,s,i);r.push(`${n}_${a}`),u+=`flat out ${f} ${n}_${a};\n`;const d=Array.from({length:s},(n,e)=>a+e);o+=`${n}_${a} = ${f}(${d.map(n=>`v[${n}]`).join(",")});\n`}return{name:n,varyings:r,vs:`\n${u}\nvoid set_${n}(in ${s} v[${t}]) {\n ${o}\n}\n`}}var v=({inputs:n,output:t,target:i})=>{const s=t.type,o=l(s,1,t.normalized),a=d(o),f=n.namedInputs;return m({module:{name:"arithmetic",dependencies:[e],vs:"TYPE arithmetic_add(TYPE x, TYPE y) {\n return x + y;\n}\n\nTYPE arithmetic_subtract(TYPE x, TYPE y) {\n return x - y;\n}\n\nTYPE arithmetic_multiply(TYPE x, TYPE y) {\n return x * y;\n}\n\nTYPE arithmetic_divide(TYPE x, TYPE y) {\n return x / y;\n}\n\nfloat arithmetic_tan(float x) {\n return tan_fp32(x);\n}\n"},inputs:f,output:t,operationType:s,outputBuffer:i,expression:e=>u(n.expression,{operations:r,inputs:f,laneIndex:e,formatInput:n=>`${n}[${e}]`,formatOutOfBoundsInput:n=>1===f[n].size?`${n}[0]`:a,formatLiteral:n=>{const t=Array.isArray(n)?n[e]??0:n;return`${o}(${function(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}(s,t)})`},formatCall:(n,e)=>`${n}(${e.join(", ")})`})}),{success:!0}},x=({inputs:n,output:e,target:r})=>{const{sourceValues:u}=n,a=r.device;if(0===u.length){const n=new e.ValueType(e.length*e.size);return r.write(n),{success:!0,value:n}}if(u.isConstant){const n=u.value,t=new e.ValueType(e.length*e.size);for(let i=0;i<e.length;i++){const e=n[i];t[2*i]=e,t[2*i+1]=e}return r.write(t),{success:!0,value:t}}const l=a.createTexture({width:1,height:e.length,format:"rg32float",usage:t.RENDER|t.COPY_SRC|t.COPY_DST}),f=a.createFramebuffer({colorAttachments:[l]}),d=new o(a,{vs:"#version 300 es\n\nflat out float extent_value;\n\nvoid main() {\n float sourceValues[SOURCE_VALUES_LEN];\n get_sourceValues(sourceValues);\n extent_value = sourceValues[gl_VertexID];\n\n float y = (float(gl_VertexID) + 0.5) / float(CHANNEL_COUNT) * 2.0 - 1.0;\n gl_Position = vec4(0.0, y, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n ",fs:"#version 300 es\n\nprecision highp float;\n\nflat in float extent_value;\nout vec2 fragColor;\n\nvoid main() {\n fragColor = vec2(-extent_value, extent_value);\n}\n ",topology:"point-list",parameters:{depthCompare:"always",blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},modules:[g("sourceValues",u.type,u.size,u.normalized)],defines:{TYPE:"float",SOURCE_VALUES_LEN:u.size.toString(),CHANNEL_COUNT:e.length.toString()},attributes:{sourceValues:u.buffer},bufferLayout:[_("sourceValues",u)],instanceCount:u.length,vertexCount:e.length,disableWarnings:!0}),c=i.createOrReuse(a,e.byteLength);try{const n=a.beginRenderPass({framebuffer:f,parameters:{viewport:[0,0,1,e.length]},clearColor:[-y,-y,0,0],clearDepth:!1,clearStencil:!1});a.statsManager.getStats("GPGPU Operation Counts").get("Transform Runs").incrementCount(),d.draw(n),n.end();const t=a.createCommandEncoder();return t.copyTextureToBuffer({sourceTexture:l,width:1,height:e.length,destinationBuffer:c,byteOffset:0,bytesPerRow:8}),a.submit(t.finish()),v({device:a,inputs:{expression:{kind:"call",op:"multiply",args:[{kind:"input",name:"x"},{kind:"literal",value:[-1,1]}]},namedInputs:{x:new s({buffer:c,size:2,type:"float32",length:e.length})}},output:e,target:r})}finally{d.destroy(),i.recycle(c),f.destroy(),l.destroy()}},y=3e38,E=({inputs:n,output:e,target:t})=>{const i=n.map((n,e)=>[`x${e}`,n]);!function(n,e){const t=e.reduce((n,[,e])=>n+Math.ceil(e.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}(t.device.limits.maxVertexAttributes,i),function(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}(t.device.limits.maxInterStageShaderVariables,e);const r=i.map(([n,e])=>`in TYPE ${n}[${e.size}]`).join(", ");let s=0;return m({module:{name:"interleave",vs:`void interleave(${r}, out TYPE result[RESULT_LEN]) {\n${i.map(([n,e])=>{const t=Array.from({length:e.size},(e,t)=>` result[${s+t}] = ${n}[${t}];`).join("\n");return s+=e.size,t}).join("\n")}\n}\n`},inputs:n,output:e,outputBuffer:t}),{success:!0}};var $=`#define LE ${function(){const n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}()?1:0}\nconst uint F32_NAN = 0xffffffffu;\nconst uint F32_INF = 0x7f800000u;\n\n// Find first set bit using binary search\n// https://en.wikipedia.org/wiki/Find_first_set#CLZ\nint countLeadingZeros(uint a) {\n if (a == 0u) return 32;\n int n = 0;\n if ((a & 0xffff0000u) == 0u) { n += 16; a = a << 16; }\n if ((a & 0xff000000u) == 0u) { n += 8; a = a << 8; }\n if ((a & 0xf0000000u) == 0u) { n += 4; a = a << 4; }\n if ((a & 0xc0000000u) == 0u) { n += 2; a = a << 2; }\n if ((a & 0x80000000u) == 0u) return n + 1;\n return n;\n}\n\nuint roundShiftRight(uint value, int shift) {\n if (shift <= 0) {\n return value << (-shift);\n }\n\n if (shift >= 32) {\n if (shift == 32 && value > 0x80000000u) {\n return 1u;\n }\n return 0u;\n }\n\n uint truncated = value >> shift;\n uint halfShift = 1u << (shift - 1);\n uint remainder = value & ((1u << shift) - 1u);\n if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) {\n return truncated + 1u;\n }\n return truncated;\n}\n\nuint makeFloat_(uint sign, int exponent, uint mantissa) {\n return (sign << 31) | (uint(exponent + 127) << 23) | (mantissa & 0x7fffffu);\n}\n\n/**\n * Assemble a float32 in bit representation according to IEEE 754\n * https://en.wikipedia.org/wiki/Single-precision_floating-point_format\n */\nuint makeFloat(uint sign, int exponent, uint significand) {\n if (significand == 0u) {\n return sign << 31;\n }\n\n // Remove any extra leading zeros for better precision\n int lead_zeros = countLeadingZeros(significand);\n // Significand is encoded as 1.fraction\n int normalizedExponent = exponent + 31 - lead_zeros;\n\n if (normalizedExponent > 127) {\n return (sign << 31) | F32_INF;\n }\n\n uint mantissa;\n if (normalizedExponent >= -126) {\n mantissa = roundShiftRight(significand, 8 - lead_zeros);\n if (mantissa >= 0x1000000u) {\n mantissa >>= 1;\n normalizedExponent++;\n if (normalizedExponent > 127) {\n return (sign << 31) | F32_INF;\n }\n }\n return makeFloat_(sign, normalizedExponent, mantissa);\n }\n\n int subnormalShift = -149 - exponent;\n mantissa = roundShiftRight(significand, subnormalShift);\n if (mantissa >= 0x800000u) {\n return (sign << 31) | (1u << 23);\n }\n return (sign << 31) | mantissa;\n}\n\n/**\n * Parse 8-byte memory as a float64 number according to IEEE 754\n * https://en.wikipedia.org/wiki/Double-precision_floating-point_format\n * Returns 8-byte memory as 2 float32 numbers, consisting of\n * high part: fround(d)\n * low part: d - fround(d)\n */\nuvec2 parseAsDouble(uvec2 d) {\n #if LE\n d = d.yx; // to big endian\n #endif\n\n uint sign = (d[0] >> 31) & 1u; // first bit\n uint exponentBits = (d[0] >> 20) & 0x7ffu;\n int exponent = int(exponentBits) - 1023; // next 11 bits\n uint fractionHigh = d[0] & 0xfffffu;\n uint fractionLow = d[1];\n\n if (exponentBits == 0x7ffu) {\n if (fractionHigh == 0u && fractionLow == 0u) {\n return uvec2((sign << 31) | F32_INF, F32_NAN);\n }\n return uvec2(F32_NAN);\n }\n \n if (exponentBits == 0u) {\n // All float64 subnormals are too small to survive a float32 split.\n return uvec2(sign << 31);\n }\n\n if (exponent > 127) {\n return uvec2((sign << 31) | F32_INF, ((1u - sign) << 31) | F32_INF);\n }\n\n uint hi_part;\n uint low_part;\n\n // float64 significand has 52 bits\n // float32 significand has 23 bits\n // The significand of the high part is the significand of the double, trimmed\n uint f_hi = 0x800000u | (fractionHigh << 3) | (fractionLow >> 29);\n uint f_low = fractionLow & 0x1fffffffu;\n\n if (exponent < -126) {\n // For tiny normals, the top 24 significand bits still contribute to the float32\n // high part, but they land in the float32 subnormal range.\n hi_part = makeFloat(sign, exponent - 23, f_hi);\n\n // The residual keeps the remaining 29 significand bits at the original double scale.\n low_part = makeFloat(sign, exponent - 52, f_low);\n return uvec2(hi_part, low_part);\n }\n\n bool roundUp = f_low > 0x10000000u || (f_low == 0x10000000u && (f_hi & 1u) == 1u);\n\n uint f_rounded = f_hi + (roundUp ? 1u : 0u);\n int exponent_hi = exponent;\n if (f_rounded == 0x1000000u) {\n f_rounded = 0x800000u;\n exponent_hi++;\n }\n\n if (exponent_hi > 127) {\n // Overflows float32 limit\n hi_part = (sign << 31) | F32_INF;\n low_part = ((1u - sign) << 31) | F32_INF;\n return uvec2(hi_part, low_part);\n }\n \n hi_part = makeFloat_(sign, exponent_hi, f_rounded);\n\n int remainder = int(f_low);\n uint sign_low = sign;\n if (roundUp) {\n remainder -= 0x20000000;\n }\n if (remainder < 0) {\n sign_low = 1u - sign;\n remainder = -remainder;\n }\n low_part = makeFloat(sign_low, exponent - 52, uint(remainder));\n\n return uvec2(hi_part, low_part);\n}\n\nvoid fround(in uint x[X_LEN], out float result[X_LEN]) {\n int n = X_LEN / 2;\n for (int i = 0; i < n; i++) {\n uvec2 f = parseAsDouble(uvec2(x[i * 2], x[i * 2 + 1]));\n result[i] = uintBitsToFloat(f.x);\n result[i + n] = uintBitsToFloat(f.y);\n }\n}\n`,b=({inputs:n,output:e,target:t})=>(m({module:{name:"fround",vs:$},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0});function T(n,e,t){const i=function(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}(t),r=l(e,1),s=Array.from({length:n.size},(n,e)=>` v[${e}] = ${r}(texelFetch(source_values_texture, ivec2(${e}, rowIndex), 0).r);`).join("\n");return{name:"source_values_texture",vs:`\nuniform highp ${i} source_values_texture;\nvoid read_source_values(int rowIndex, out TYPE v[${n.size}]) {\n${s}\n}\n`}}function w(n,e,i){const r=i.createTexture({width:Math.max(n.size,1),height:n.length,format:c(e),usage:t.SAMPLE|t.COPY_DST});if(0===n.length)return r;const s=i.createCommandEncoder();return s.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:r,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),i.submit(s.finish()),r}var S=async({inputs:n,output:e,target:t})=>{const{ids:i,sourceValues:r}=n,s=t.device,u=h("result",e.type,e.size),o=l(i.type,1),c=l(e.type,1),p=e.type,m=w(r,p,s),g=`#version 300 es\n\nvoid main() {\n INDEX_TYPE ids[1];\n get_ids(ids);\n TYPE result[${e.size}];\n gather(ids, result);\n set_result(result);\n}\n `,_=new a(s,{vs:g,defines:{INDEX_TYPE:o,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[L(i,o),T(r,e.type,p),(x=e.type,{name:"gather",vs:`\nvoid zero_result(out TYPE result[RESULT_LEN]) {\n for (int i = 0; i < RESULT_LEN; i++) {\n result[i] = ${d(x)};\n }\n}\n\nvoid gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) {\n int sourceIndex = int(ids[0]);\n if (sourceIndex < 0 || sourceIndex >= SOURCE_VALUES_ROWS) {\n zero_result(result);\n return;\n }\n read_source_values(sourceIndex, result);\n}\n`}),u],bindings:{source_values_texture:m},bufferLayout:[(v=i,{name:"ids",stepMode:v.isConstant?"vertex":"instance",byteStride:v.stride,attributes:[{attribute:"aids_0",format:f(v.type,1,v.normalized),byteOffset:v.offset}]})],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:u.varyings});var v,x;try{return _.run({inputBuffers:{ids:i.buffer},outputBuffers:{[u.varyings[0]]:t}}),{success:!0}}finally{_.destroy(),m.destroy()}};function L(n,e){const t=l(n.type,1);let i="aids_0";return n.type!==function(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}(e)&&(i=`${e}(${i})`),{name:"ids",vs:`\nin ${t} aids_0;\nvoid get_ids(out INDEX_TYPE v[1]) {\n v[0] = ${i};\n}\n`}}var z=({inputs:n,output:e,target:t})=>(m({module:{name:"row_dot",vs:"void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) {\n float sum = 0.0;\n for (int i = 0; i < X_LEN; i++) {\n sum += float(x[i]) * float(y[i]);\n }\n result[0] = sum;\n}\n"},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0}),P=({inputs:n,output:e,target:t})=>(m({module:{name:"equalAll",vs:"void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) {\n uint allEqual = uint(1);\n for (int i = 0; i < X_LEN; i++) {\n if (x[i] != y[i]) {\n allEqual = uint(0);\n break;\n }\n }\n result[0] = allEqual;\n}\n"},inputs:n,output:e,operationType:"uint32"===e.type?n.x.type:e.type,outputBuffer:t}),{success:!0}),N=({inputs:n,output:e,target:t})=>(m({module:{name:"row_length",vs:"void row_length(in TYPE x[X_LEN], out float result[1]) {\n float sum = 0.0;\n for (int i = 0; i < X_LEN; i++) {\n sum += float(x[i]) * float(x[i]);\n }\n result[0] = sqrt(sum);\n}\n"},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0}),I=async({inputs:n,output:e,target:t})=>{const{segments:i}=n,r=t.device,s=h("result",e.type,e.size),u=i.type,o=w(i,u,r),l=new a(r,{vs:"#version 300 es\n\nvoid main() {\n TYPE result[RESULT_LEN];\n segmentedMap(result);\n set_result(result);\n}\n",defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[T(i,e.type,u),{name:"segmentedMap",vs:"\nuint read_segment_start(int segmentIndex) {\n TYPE value[1];\n read_source_values(segmentIndex, value);\n return uint(value[0]);\n}\n\nvoid segmentedMap(out TYPE result[RESULT_LEN]) {\n uint vertexIndex = uint(gl_InstanceID);\n int low = 0;\n int high = SEGMENTS_LENGTH;\n\n while (low < high) {\n int mid = low + (high - low) / 2;\n uint midStart = read_segment_start(mid);\n if (midStart <= vertexIndex) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n uint segmentIndex = uint(max(low - 1, 0));\n uint segmentStart = read_segment_start(int(segmentIndex));\n result[0] = segmentIndex;\n result[1] = vertexIndex - segmentStart;\n}\n"},s],bindings:{source_values_texture:o},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return l.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{l.destroy(),o.destroy()}};var Y=async({inputs:n,output:e,target:t})=>{const i=d(l(e.type,1,e.normalized));return m({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:e=>{const t=C("condition",n.condition,e,i),r=C("whenTrue",n.whenTrue,e,i),s=C("whenFalse",n.whenFalse,e,i);return`(${t} != ${i} ? ${r} : ${s})`}}),{success:!0}};function C(n,e,t,i){return t<e.size?`${n}[${t}]`:1===e.size?`${n}[0]`:i}var F=({inputs:n,output:e,target:t})=>{const i=h("result",e.type,e.size),r=new a(t.device,{vs:"#version 300 es\n\nvoid main() {\n int result[1];\n result[0] = START + gl_InstanceID * STEP;\n set_result(result);\n}\n",defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}},R=({inputs:n,output:e,target:t})=>{const{columns:i}=n;return m({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:n=>`x[${i[n]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}};export{v as arithmetic,z as dot,P as equalAll,x as extent,b as fround,S as gather,E as interleave,N as length,I as segmentedMap,Y as select,F as sequence,R as swizzle};
|
|
1
|
+
/*! Web-kit v1.2.0-develop.14 | (c) 2026 MapVX */
|
|
2
|
+
!function(){try{var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=(new n.Error).stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="78110cc3-87cc-42e8-926f-545405ca5e2f",n._sentryDebugIdIdentifier="sentry-dbid-78110cc3-87cc-42e8-926f-545405ca5e2f")}catch(n){}}();import{Rt as n,U as e,Ut as t}from"./debug-hooks-D_XQuFlb.js";import{a as i,n as r,r as s,t as u}from"./expression-C7yC7-03.js";import{h as o,m as a}from"./dist-B7VX6I_c.js";function l(n,e,t=!1){if(t)return 1===e?"float":`vec${e}`;switch(n){case"uint8":case"uint16":case"uint32":return 1===e?"uint":`uvec${e}`;case"sint8":case"sint16":case"sint32":return 1===e?"int":`ivec${e}`;default:return 1===e?"float":`vec${e}`}}function f(n,e,t=!1){let i;if(t)switch(n){case"uint8":i="unorm8";break;case"sint8":i="snorm8";break;case"uint16":i="unorm16";break;case"sint16":i="snorm16";break;case"float32":i="float32";break;default:throw new Error(`Unsupported normalized vertex format for ${n}`)}else i=n;return 1===e?i:3!==e||i.startsWith("float32")||i.endsWith("32")?`${i}x${e}`:`${i}x3-webgl`}function d(n){switch(n[0]){case"u":return"0u";case"s":return"0";default:return"0."}}function c(n){switch(n){case"uint8":return"r8uint";case"sint8":return"r8sint";case"uint16":return"r16uint";case"sint16":return"r16sint";case"uint32":return"r32uint";case"sint32":return"r32sint";case"float32":return"r32float";default:throw new Error(`Unsupported WebGL gather texture format for ${n}`)}}var p=new n;function m({module:n,elementWise:e=!1,expression:t,inputs:r,output:u,operationType:o=u.type,outputBuffer:f}){const c=f.device,m=h("result",u.type,u.size,u.normalized),v=[n,m],x=[],y={},E=l(u.type,1,u.normalized),$=l(o,1,u.normalized);let b="",T=null;const w={TYPE:$,RESULT_LEN:u.size.toString()},S=function(n){return Array.isArray(n)?n.map((n,e)=>[`x${e}`,n]):Object.entries(n)}(r);for(const[a,l]of S)v.push(g(a,l.type,l.size,l.normalized,o)),x.push(_(a,l)),l instanceof s?y[a]=l.buffer:(T=T||i.createOrReuse(c,f.byteLength),y[a]=T),b+=`TYPE ${a}[${l.size}]; get_${a}(${a});\n`,w[`${a.toUpperCase()}_LEN`]=l.size.toString();let L="";if(t)for(let i=0;i<u.size;i++)L+=`result[${i}]=${t(i)};\n`;else if(e)for(let i=0;i<u.size;i++){const e=d($),t=S.map(([n,t])=>i<t.size?`${n}[${i}]`:e);L+=`result[${i}]=${n.name}(${t.join(", ")});\n`}else L=`${n.name}(${S.map(([n])=>n).join(", ")}, result);`;const z=`#version 300 es\n\nvoid main() {\n${b}\n${E} result[${u.size}];\n${L}\nset_result(result);\n}\n `,P=new a(c,{vs:z,shaderAssembler:p,defines:w,modules:v,bufferLayout:x,vertexCount:1,instanceCount:u.length,attributes:y,feedbackBufferMode:"interleaved",outputs:m.varyings});c.statsManager.getStats("GPGPU Operation Counts").get("Transform Runs").incrementCount(),P.run({inputBuffers:y,outputBuffers:{[m.varyings[0]]:0===u.offset?f:{buffer:f,byteOffset:u.offset,byteLength:u.byteLength}}}),T&&i.recycle(T)}function g(n,e,t,i=!1,r=e){let s="",u="";for(let o=0;o<t;o+=4){const a=Math.min(t-o,4);s+=`in ${l(e,a,i)} a${n}_${o};\n`;for(let t=0;t<a;t++){let s=`a${n}_${o}`;a>1&&(s=`${s}[${t}]`),(i||e!==r)&&(s=`TYPE(${s})`),u+=`v[${o+t}]=${s};\n`}}return{name:n,vs:`\n${s}\nvoid get_${n}(out TYPE v[${t}]) {\n ${u}\n}\n`}}function _(n,e){const t={name:n,stepMode:e.isConstant?"vertex":"instance",byteStride:e.stride,attributes:[]};for(let i=0;i<e.size;i+=4){const r=Math.min(e.size-i,4);t.attributes.push({attribute:`a${n}_${i}`,format:f(e.type,r,e.normalized),byteOffset:e.offset+e.ValueType.BYTES_PER_ELEMENT*i})}return t}function h(n,e,t,i=!1){const r=[],s=l(e,1,i);let u="",o="";for(let a=0;a<t;a+=4){const s=Math.min(t-a,4),f=l(e,s,i);r.push(`${n}_${a}`),u+=`flat out ${f} ${n}_${a};\n`;const d=Array.from({length:s},(n,e)=>a+e);o+=`${n}_${a} = ${f}(${d.map(n=>`v[${n}]`).join(",")});\n`}return{name:n,varyings:r,vs:`\n${u}\nvoid set_${n}(in ${s} v[${t}]) {\n ${o}\n}\n`}}var v=({inputs:n,output:t,target:i})=>{const s=t.type,o=l(s,1,t.normalized),a=d(o),f=n.namedInputs;return m({module:{name:"arithmetic",dependencies:[e],vs:"TYPE arithmetic_add(TYPE x, TYPE y) {\n return x + y;\n}\n\nTYPE arithmetic_subtract(TYPE x, TYPE y) {\n return x - y;\n}\n\nTYPE arithmetic_multiply(TYPE x, TYPE y) {\n return x * y;\n}\n\nTYPE arithmetic_divide(TYPE x, TYPE y) {\n return x / y;\n}\n\nfloat arithmetic_tan(float x) {\n return tan_fp32(x);\n}\n"},inputs:f,output:t,operationType:s,outputBuffer:i,expression:e=>u(n.expression,{operations:r,inputs:f,laneIndex:e,formatInput:n=>`${n}[${e}]`,formatOutOfBoundsInput:n=>1===f[n].size?`${n}[0]`:a,formatLiteral:n=>{const t=Array.isArray(n)?n[e]??0:n;return`${o}(${function(n,e){switch(n){case"uint8":case"uint16":case"uint32":return`${Math.trunc(e)}u`;case"sint8":case"sint16":case"sint32":return`${Math.trunc(e)}`;default:return Number.isInteger(e)?`${e}.0`:`${e}`}}(s,t)})`},formatCall:(n,e)=>`${n}(${e.join(", ")})`})}),{success:!0}},x=({inputs:n,output:e,target:r})=>{const{sourceValues:u}=n,a=r.device;if(0===u.length){const n=new e.ValueType(e.length*e.size);return r.write(n),{success:!0,value:n}}if(u.isConstant){const n=u.value,t=new e.ValueType(e.length*e.size);for(let i=0;i<e.length;i++){const e=n[i];t[2*i]=e,t[2*i+1]=e}return r.write(t),{success:!0,value:t}}const l=a.createTexture({width:1,height:e.length,format:"rg32float",usage:t.RENDER|t.COPY_SRC|t.COPY_DST}),f=a.createFramebuffer({colorAttachments:[l]}),d=new o(a,{vs:"#version 300 es\n\nflat out float extent_value;\n\nvoid main() {\n float sourceValues[SOURCE_VALUES_LEN];\n get_sourceValues(sourceValues);\n extent_value = sourceValues[gl_VertexID];\n\n float y = (float(gl_VertexID) + 0.5) / float(CHANNEL_COUNT) * 2.0 - 1.0;\n gl_Position = vec4(0.0, y, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n ",fs:"#version 300 es\n\nprecision highp float;\n\nflat in float extent_value;\nout vec2 fragColor;\n\nvoid main() {\n fragColor = vec2(-extent_value, extent_value);\n}\n ",topology:"point-list",parameters:{depthCompare:"always",blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},modules:[g("sourceValues",u.type,u.size,u.normalized)],defines:{TYPE:"float",SOURCE_VALUES_LEN:u.size.toString(),CHANNEL_COUNT:e.length.toString()},attributes:{sourceValues:u.buffer},bufferLayout:[_("sourceValues",u)],instanceCount:u.length,vertexCount:e.length,disableWarnings:!0}),c=i.createOrReuse(a,e.byteLength);try{const n=a.beginRenderPass({framebuffer:f,parameters:{viewport:[0,0,1,e.length]},clearColor:[-y,-y,0,0],clearDepth:!1,clearStencil:!1});a.statsManager.getStats("GPGPU Operation Counts").get("Transform Runs").incrementCount(),d.draw(n),n.end();const t=a.createCommandEncoder();return t.copyTextureToBuffer({sourceTexture:l,width:1,height:e.length,destinationBuffer:c,byteOffset:0,bytesPerRow:8}),a.submit(t.finish()),v({device:a,inputs:{expression:{kind:"call",op:"multiply",args:[{kind:"input",name:"x"},{kind:"literal",value:[-1,1]}]},namedInputs:{x:new s({buffer:c,size:2,type:"float32",length:e.length})}},output:e,target:r})}finally{d.destroy(),i.recycle(c),f.destroy(),l.destroy()}},y=3e38,E=({inputs:n,output:e,target:t})=>{const i=n.map((n,e)=>[`x${e}`,n]);!function(n,e){const t=e.reduce((n,[,e])=>n+Math.ceil(e.size/4),0);if(t>n)throw new Error(`interleave() requires ${t} vertex attributes, exceeding device limit ${n}`)}(t.device.limits.maxVertexAttributes,i),function(n,e){if(e.size>n)throw new Error(`interleave() output size ${e.size} exceeds device inter-stage component limit ${n}`)}(t.device.limits.maxInterStageShaderVariables,e);const r=i.map(([n,e])=>`in TYPE ${n}[${e.size}]`).join(", ");let s=0;return m({module:{name:"interleave",vs:`void interleave(${r}, out TYPE result[RESULT_LEN]) {\n${i.map(([n,e])=>{const t=Array.from({length:e.size},(e,t)=>` result[${s+t}] = ${n}[${t}];`).join("\n");return s+=e.size,t}).join("\n")}\n}\n`},inputs:n,output:e,outputBuffer:t}),{success:!0}};var $=`#define LE ${function(){const n=new Uint16Array([255]);return new Uint8Array(n.buffer)[0]>0}()?1:0}\nconst uint F32_NAN = 0xffffffffu;\nconst uint F32_INF = 0x7f800000u;\n\n// Find first set bit using binary search\n// https://en.wikipedia.org/wiki/Find_first_set#CLZ\nint countLeadingZeros(uint a) {\n if (a == 0u) return 32;\n int n = 0;\n if ((a & 0xffff0000u) == 0u) { n += 16; a = a << 16; }\n if ((a & 0xff000000u) == 0u) { n += 8; a = a << 8; }\n if ((a & 0xf0000000u) == 0u) { n += 4; a = a << 4; }\n if ((a & 0xc0000000u) == 0u) { n += 2; a = a << 2; }\n if ((a & 0x80000000u) == 0u) return n + 1;\n return n;\n}\n\nuint roundShiftRight(uint value, int shift) {\n if (shift <= 0) {\n return value << (-shift);\n }\n\n if (shift >= 32) {\n if (shift == 32 && value > 0x80000000u) {\n return 1u;\n }\n return 0u;\n }\n\n uint truncated = value >> shift;\n uint halfShift = 1u << (shift - 1);\n uint remainder = value & ((1u << shift) - 1u);\n if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) {\n return truncated + 1u;\n }\n return truncated;\n}\n\nuint makeFloat_(uint sign, int exponent, uint mantissa) {\n return (sign << 31) | (uint(exponent + 127) << 23) | (mantissa & 0x7fffffu);\n}\n\n/**\n * Assemble a float32 in bit representation according to IEEE 754\n * https://en.wikipedia.org/wiki/Single-precision_floating-point_format\n */\nuint makeFloat(uint sign, int exponent, uint significand) {\n if (significand == 0u) {\n return sign << 31;\n }\n\n // Remove any extra leading zeros for better precision\n int lead_zeros = countLeadingZeros(significand);\n // Significand is encoded as 1.fraction\n int normalizedExponent = exponent + 31 - lead_zeros;\n\n if (normalizedExponent > 127) {\n return (sign << 31) | F32_INF;\n }\n\n uint mantissa;\n if (normalizedExponent >= -126) {\n mantissa = roundShiftRight(significand, 8 - lead_zeros);\n if (mantissa >= 0x1000000u) {\n mantissa >>= 1;\n normalizedExponent++;\n if (normalizedExponent > 127) {\n return (sign << 31) | F32_INF;\n }\n }\n return makeFloat_(sign, normalizedExponent, mantissa);\n }\n\n int subnormalShift = -149 - exponent;\n mantissa = roundShiftRight(significand, subnormalShift);\n if (mantissa >= 0x800000u) {\n return (sign << 31) | (1u << 23);\n }\n return (sign << 31) | mantissa;\n}\n\n/**\n * Parse 8-byte memory as a float64 number according to IEEE 754\n * https://en.wikipedia.org/wiki/Double-precision_floating-point_format\n * Returns 8-byte memory as 2 float32 numbers, consisting of\n * high part: fround(d)\n * low part: d - fround(d)\n */\nuvec2 parseAsDouble(uvec2 d) {\n #if LE\n d = d.yx; // to big endian\n #endif\n\n uint sign = (d[0] >> 31) & 1u; // first bit\n uint exponentBits = (d[0] >> 20) & 0x7ffu;\n int exponent = int(exponentBits) - 1023; // next 11 bits\n uint fractionHigh = d[0] & 0xfffffu;\n uint fractionLow = d[1];\n\n if (exponentBits == 0x7ffu) {\n if (fractionHigh == 0u && fractionLow == 0u) {\n return uvec2((sign << 31) | F32_INF, F32_NAN);\n }\n return uvec2(F32_NAN);\n }\n \n if (exponentBits == 0u) {\n // All float64 subnormals are too small to survive a float32 split.\n return uvec2(sign << 31);\n }\n\n if (exponent > 127) {\n return uvec2((sign << 31) | F32_INF, ((1u - sign) << 31) | F32_INF);\n }\n\n uint hi_part;\n uint low_part;\n\n // float64 significand has 52 bits\n // float32 significand has 23 bits\n // The significand of the high part is the significand of the double, trimmed\n uint f_hi = 0x800000u | (fractionHigh << 3) | (fractionLow >> 29);\n uint f_low = fractionLow & 0x1fffffffu;\n\n if (exponent < -126) {\n // For tiny normals, the top 24 significand bits still contribute to the float32\n // high part, but they land in the float32 subnormal range.\n hi_part = makeFloat(sign, exponent - 23, f_hi);\n\n // The residual keeps the remaining 29 significand bits at the original double scale.\n low_part = makeFloat(sign, exponent - 52, f_low);\n return uvec2(hi_part, low_part);\n }\n\n bool roundUp = f_low > 0x10000000u || (f_low == 0x10000000u && (f_hi & 1u) == 1u);\n\n uint f_rounded = f_hi + (roundUp ? 1u : 0u);\n int exponent_hi = exponent;\n if (f_rounded == 0x1000000u) {\n f_rounded = 0x800000u;\n exponent_hi++;\n }\n\n if (exponent_hi > 127) {\n // Overflows float32 limit\n hi_part = (sign << 31) | F32_INF;\n low_part = ((1u - sign) << 31) | F32_INF;\n return uvec2(hi_part, low_part);\n }\n \n hi_part = makeFloat_(sign, exponent_hi, f_rounded);\n\n int remainder = int(f_low);\n uint sign_low = sign;\n if (roundUp) {\n remainder -= 0x20000000;\n }\n if (remainder < 0) {\n sign_low = 1u - sign;\n remainder = -remainder;\n }\n low_part = makeFloat(sign_low, exponent - 52, uint(remainder));\n\n return uvec2(hi_part, low_part);\n}\n\nvoid fround(in uint x[X_LEN], out float result[X_LEN]) {\n int n = X_LEN / 2;\n for (int i = 0; i < n; i++) {\n uvec2 f = parseAsDouble(uvec2(x[i * 2], x[i * 2 + 1]));\n result[i] = uintBitsToFloat(f.x);\n result[i + n] = uintBitsToFloat(f.y);\n }\n}\n`,b=({inputs:n,output:e,target:t})=>(m({module:{name:"fround",vs:$},inputs:n,output:e,operationType:"uint32",outputBuffer:t}),{success:!0});function T(n,e,t){const i=function(n){switch(n){case"uint32":return"usampler2D";case"sint32":return"isampler2D";case"float32":return"sampler2D";default:throw new Error(`Unsupported WebGL gather sampler type for ${n}`)}}(t),r=l(e,1),s=Array.from({length:n.size},(n,e)=>` v[${e}] = ${r}(texelFetch(source_values_texture, ivec2(${e}, rowIndex), 0).r);`).join("\n");return{name:"source_values_texture",vs:`\nuniform highp ${i} source_values_texture;\nvoid read_source_values(int rowIndex, out TYPE v[${n.size}]) {\n${s}\n}\n`}}function w(n,e,i){const r=i.createTexture({width:Math.max(n.size,1),height:n.length,format:c(e),usage:t.SAMPLE|t.COPY_DST});if(0===n.length)return r;const s=i.createCommandEncoder();return s.copyBufferToTexture({sourceBuffer:n.buffer,destinationTexture:r,byteOffset:n.offset,bytesPerRow:n.stride,rowsPerImage:n.length,size:[n.size,n.length,1]}),i.submit(s.finish()),r}var S=async({inputs:n,output:e,target:t})=>{const{ids:i,sourceValues:r}=n,s=t.device,u=h("result",e.type,e.size),o=l(i.type,1),c=l(e.type,1),p=e.type,m=w(r,p,s),g=`#version 300 es\n\nvoid main() {\n INDEX_TYPE ids[1];\n get_ids(ids);\n TYPE result[${e.size}];\n gather(ids, result);\n set_result(result);\n}\n `,_=new a(s,{vs:g,defines:{INDEX_TYPE:o,TYPE:c,RESULT_LEN:e.size.toString(),SOURCE_VALUES_ROWS:r.length.toString()},modules:[L(i,o),T(r,e.type,p),(x=e.type,{name:"gather",vs:`\nvoid zero_result(out TYPE result[RESULT_LEN]) {\n for (int i = 0; i < RESULT_LEN; i++) {\n result[i] = ${d(x)};\n }\n}\n\nvoid gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) {\n int sourceIndex = int(ids[0]);\n if (sourceIndex < 0 || sourceIndex >= SOURCE_VALUES_ROWS) {\n zero_result(result);\n return;\n }\n read_source_values(sourceIndex, result);\n}\n`}),u],bindings:{source_values_texture:m},bufferLayout:[(v=i,{name:"ids",stepMode:v.isConstant?"vertex":"instance",byteStride:v.stride,attributes:[{attribute:"aids_0",format:f(v.type,1,v.normalized),byteOffset:v.offset}]})],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:u.varyings});var v,x;try{return _.run({inputBuffers:{ids:i.buffer},outputBuffers:{[u.varyings[0]]:t}}),{success:!0}}finally{_.destroy(),m.destroy()}};function L(n,e){const t=l(n.type,1);let i="aids_0";return n.type!==function(n){switch(n){case"uint":return"uint32";case"int":return"sint32";default:return"float32"}}(e)&&(i=`${e}(${i})`),{name:"ids",vs:`\nin ${t} aids_0;\nvoid get_ids(out INDEX_TYPE v[1]) {\n v[0] = ${i};\n}\n`}}var z=({inputs:n,output:e,target:t})=>(m({module:{name:"row_dot",vs:"void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) {\n float sum = 0.0;\n for (int i = 0; i < X_LEN; i++) {\n sum += float(x[i]) * float(y[i]);\n }\n result[0] = sum;\n}\n"},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0}),P=({inputs:n,output:e,target:t})=>(m({module:{name:"equalAll",vs:"void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) {\n uint allEqual = uint(1);\n for (int i = 0; i < X_LEN; i++) {\n if (x[i] != y[i]) {\n allEqual = uint(0);\n break;\n }\n }\n result[0] = allEqual;\n}\n"},inputs:n,output:e,operationType:"uint32"===e.type?n.x.type:e.type,outputBuffer:t}),{success:!0}),N=({inputs:n,output:e,target:t})=>(m({module:{name:"row_length",vs:"void row_length(in TYPE x[X_LEN], out float result[1]) {\n float sum = 0.0;\n for (int i = 0; i < X_LEN; i++) {\n sum += float(x[i]) * float(x[i]);\n }\n result[0] = sqrt(sum);\n}\n"},inputs:n,output:e,operationType:"float32",outputBuffer:t}),{success:!0}),I=async({inputs:n,output:e,target:t})=>{const{segments:i}=n,r=t.device,s=h("result",e.type,e.size),u=i.type,o=w(i,u,r),l=new a(r,{vs:"#version 300 es\n\nvoid main() {\n TYPE result[RESULT_LEN];\n segmentedMap(result);\n set_result(result);\n}\n",defines:{TYPE:"uint",RESULT_LEN:e.size.toString(),SEGMENTS_LENGTH:i.length.toString()},modules:[T(i,e.type,u),{name:"segmentedMap",vs:"\nuint read_segment_start(int segmentIndex) {\n TYPE value[1];\n read_source_values(segmentIndex, value);\n return uint(value[0]);\n}\n\nvoid segmentedMap(out TYPE result[RESULT_LEN]) {\n uint vertexIndex = uint(gl_InstanceID);\n int low = 0;\n int high = SEGMENTS_LENGTH;\n\n while (low < high) {\n int mid = low + (high - low) / 2;\n uint midStart = read_segment_start(mid);\n if (midStart <= vertexIndex) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n uint segmentIndex = uint(max(low - 1, 0));\n uint segmentStart = read_segment_start(int(segmentIndex));\n result[0] = segmentIndex;\n result[1] = vertexIndex - segmentStart;\n}\n"},s],bindings:{source_values_texture:o},vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:s.varyings});try{return l.run({outputBuffers:{[s.varyings[0]]:t}}),{success:!0}}finally{l.destroy(),o.destroy()}};var Y=async({inputs:n,output:e,target:t})=>{const i=d(l(e.type,1,e.normalized));return m({module:{name:"select",vs:""},inputs:n,output:e,operationType:e.type,outputBuffer:t,expression:e=>{const t=C("condition",n.condition,e,i),r=C("whenTrue",n.whenTrue,e,i),s=C("whenFalse",n.whenFalse,e,i);return`(${t} != ${i} ? ${r} : ${s})`}}),{success:!0}};function C(n,e,t,i){return t<e.size?`${n}[${t}]`:1===e.size?`${n}[0]`:i}var F=({inputs:n,output:e,target:t})=>{const i=h("result",e.type,e.size),r=new a(t.device,{vs:"#version 300 es\n\nvoid main() {\n int result[1];\n result[0] = START + gl_InstanceID * STEP;\n set_result(result);\n}\n",defines:{START:n.start.toString(),STEP:n.step.toString()},modules:[i],vertexCount:1,instanceCount:e.length,feedbackBufferMode:"interleaved",outputs:i.varyings});try{return r.run({outputBuffers:{[i.varyings[0]]:t}}),{success:!0}}finally{r.destroy()}},R=({inputs:n,output:e,target:t})=>{const{columns:i}=n;return m({module:{name:"swizzle",vs:"// swizzle expression handled inline"},expression:n=>`x[${i[n]}]`,inputs:{x:n.x},output:e,outputBuffer:t}),{success:!0}};export{v as arithmetic,z as dot,P as equalAll,x as extent,b as fround,S as gather,E as interleave,N as length,I as segmentedMap,Y as select,F as sequence,R as swizzle};
|