@deck.gl/extensions 9.0.0-alpha.3 → 9.0.0-alpha.5

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.
Files changed (52) hide show
  1. package/dist/dist.dev.js +2064 -2061
  2. package/dist/es5/collision-filter/collision-filter-effect.js +6 -9
  3. package/dist/es5/collision-filter/collision-filter-effect.js.map +1 -1
  4. package/dist/es5/collision-filter/collision-filter-pass.js +2 -1
  5. package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
  6. package/dist/es5/collision-filter/shader-module.js +1 -1
  7. package/dist/es5/collision-filter/shader-module.js.map +1 -1
  8. package/dist/es5/mask/mask-pass.js +2 -1
  9. package/dist/es5/mask/mask-pass.js.map +1 -1
  10. package/dist/esm/collision-filter/collision-filter-effect.js +6 -8
  11. package/dist/esm/collision-filter/collision-filter-effect.js.map +1 -1
  12. package/dist/esm/collision-filter/collision-filter-pass.js +2 -1
  13. package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -1
  14. package/dist/esm/collision-filter/shader-module.js +1 -1
  15. package/dist/esm/collision-filter/shader-module.js.map +1 -1
  16. package/dist/esm/mask/mask-pass.js +2 -1
  17. package/dist/esm/mask/mask-pass.js.map +1 -1
  18. package/dist.min.js +108 -108
  19. package/package.json +4 -3
  20. package/src/collision-filter/collision-filter-effect.ts +4 -7
  21. package/src/collision-filter/collision-filter-pass.ts +2 -2
  22. package/src/collision-filter/shader-module.ts +4 -3
  23. package/src/mask/mask-pass.ts +2 -2
  24. package/typed/brushing/brushing-extension.d.ts +2 -2
  25. package/typed/brushing/shader-module.d.ts +1 -1
  26. package/typed/clip/clip-extension.d.ts +2 -2
  27. package/typed/collision-filter/collision-filter-effect.d.ts +1 -1
  28. package/typed/collision-filter/collision-filter-effect.d.ts.map +1 -1
  29. package/typed/collision-filter/collision-filter-extension.d.ts +1 -1
  30. package/typed/collision-filter/collision-filter-pass.d.ts +1 -1
  31. package/typed/collision-filter/shader-module.d.ts +8 -2
  32. package/typed/collision-filter/shader-module.d.ts.map +1 -1
  33. package/typed/data-filter/data-filter-extension.d.ts +2 -2
  34. package/typed/data-filter/shader-module.d.ts +1 -1
  35. package/typed/fill-style/fill-style-extension.d.ts +2 -2
  36. package/typed/fill-style/shaders.glsl.d.ts +1 -1
  37. package/typed/fp64/fp64-extension.d.ts +2 -2
  38. package/typed/fp64/project64.d.ts +1 -1
  39. package/typed/mask/mask-effect.d.ts +1 -1
  40. package/typed/mask/mask-extension.d.ts +1 -1
  41. package/typed/mask/mask-pass.d.ts +1 -1
  42. package/typed/mask/shader-module.d.ts +1 -1
  43. package/typed/path-style/path-style-extension.d.ts +2 -2
  44. package/typed/terrain/height-map-builder.d.ts +1 -1
  45. package/typed/terrain/shader-module.d.ts +1 -1
  46. package/typed/terrain/terrain-cover.d.ts +1 -1
  47. package/typed/terrain/terrain-effect.d.ts +1 -1
  48. package/typed/terrain/terrain-extension.d.ts +2 -2
  49. package/typed/terrain/terrain-pass.d.ts +1 -1
  50. package/typed/terrain/terrain-picking-pass.d.ts +1 -1
  51. package/typed/utils/projection-utils.d.ts +1 -1
  52. package/typed/package.json +0 -6
package/dist/dist.dev.js CHANGED
@@ -7628,21 +7628,21 @@ varying float dataFilter_value;
7628
7628
  getUniforms: getUniforms64
7629
7629
  };
7630
7630
 
7631
- // ../../node_modules/@luma.gl/engine/dist/model/model.js
7631
+ // ../../../luma.gl/modules/engine/dist/model/model.js
7632
7632
  var import_core36 = __toESM(require_core2(), 1);
7633
7633
  var import_core37 = __toESM(require_core2(), 1);
7634
7634
 
7635
- // ../../node_modules/@luma.gl/shadertools/dist/lib/glsl-utils/highlight.js
7635
+ // ../../../luma.gl/modules/shadertools/dist/lib/glsl-utils/highlight.js
7636
7636
  var glsl = (x) => `${x}`;
7637
7637
 
7638
- // ../../node_modules/@luma.gl/shadertools/dist/lib/utils/assert.js
7638
+ // ../../../luma.gl/modules/shadertools/dist/lib/utils/assert.js
7639
7639
  function assert17(condition, message2) {
7640
7640
  if (!condition) {
7641
7641
  throw new Error(message2 || "shadertools: assertion failed.");
7642
7642
  }
7643
7643
  }
7644
7644
 
7645
- // ../../node_modules/@luma.gl/shadertools/dist/lib/filters/prop-types.js
7645
+ // ../../../luma.gl/modules/shadertools/dist/lib/filters/prop-types.js
7646
7646
  var DEFAULT_PROP_VALIDATORS = {
7647
7647
  number: {
7648
7648
  type: "number",
@@ -7723,7 +7723,7 @@ varying float dataFilter_value;
7723
7723
  return typeof value;
7724
7724
  }
7725
7725
 
7726
- // ../../node_modules/@luma.gl/shadertools/dist/module-injectors.js
7726
+ // ../../../luma.gl/modules/shadertools/dist/module-injectors.js
7727
7727
  var MODULE_INJECTORS_VS = glsl`\
7728
7728
  #ifdef MODULE_LOGDEPTH
7729
7729
  logdepth_adjustPosition(gl_Position);
@@ -7752,7 +7752,7 @@ varying float dataFilter_value;
7752
7752
  #endif
7753
7753
  `;
7754
7754
 
7755
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/shader-injections.js
7755
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/shader-injections.js
7756
7756
  var MODULE_INJECTORS = {
7757
7757
  vertex: MODULE_INJECTORS_VS,
7758
7758
  fragment: MODULE_INJECTORS_FS
@@ -7844,7 +7844,7 @@ varying float dataFilter_value;
7844
7844
  return source;
7845
7845
  }
7846
7846
 
7847
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-module/shader-module-instance.js
7847
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-module/shader-module-instance.js
7848
7848
  var ShaderModuleInstance = class {
7849
7849
  static instantiateModules(modules) {
7850
7850
  return modules.map((module) => {
@@ -7874,7 +7874,7 @@ varying float dataFilter_value;
7874
7874
  vs: vs5,
7875
7875
  fs: fs4,
7876
7876
  dependencies = [],
7877
- uniforms = {},
7877
+ uniformPropTypes = {},
7878
7878
  getUniforms: getUniforms4,
7879
7879
  deprecations = [],
7880
7880
  defines = {},
@@ -7889,8 +7889,8 @@ varying float dataFilter_value;
7889
7889
  this.deprecations = this._parseDeprecationDefinitions(deprecations);
7890
7890
  this.defines = defines;
7891
7891
  this.injections = normalizeInjections(inject6);
7892
- if (uniforms) {
7893
- this.uniforms = makePropValidators(uniforms);
7892
+ if (uniformPropTypes) {
7893
+ this.uniforms = makePropValidators(uniformPropTypes);
7894
7894
  }
7895
7895
  }
7896
7896
  getModuleSource(stage) {
@@ -7962,7 +7962,7 @@ ${moduleSource}// END MODULE_${this.name}
7962
7962
  }
7963
7963
  };
7964
7964
 
7965
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/resolve-modules.js
7965
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/resolve-modules.js
7966
7966
  function resolveModules(modules) {
7967
7967
  const instances = ShaderModuleInstance.instantiateModules(modules);
7968
7968
  return getShaderDependencies(instances);
@@ -8006,7 +8006,7 @@ ${moduleSource}// END MODULE_${this.name}
8006
8006
  }
8007
8007
  }
8008
8008
 
8009
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/platform-defines.js
8009
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/platform-defines.js
8010
8010
  function getPlatformShaderDefines(platformInfo) {
8011
8011
  switch (platformInfo === null || platformInfo === void 0 ? void 0 : platformInfo.gpu.toLowerCase()) {
8012
8012
  case "apple":
@@ -8106,7 +8106,7 @@ ${moduleSource}// END MODULE_${this.name}
8106
8106
  return versionDefines;
8107
8107
  }
8108
8108
 
8109
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-transpiler/transpile-glsl-shader.js
8109
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-transpiler/transpile-glsl-shader.js
8110
8110
  function transpileGLSLShader(source, targetGLSLVersion, stage) {
8111
8111
  switch (targetGLSLVersion) {
8112
8112
  case 300:
@@ -8172,7 +8172,7 @@ ${match}`).replace(new RegExp(`\\b${ES100_FRAGMENT_OUTPUT_NAME}\\b`, "g"), outpu
8172
8172
  return new RegExp(`\\b${qualifier}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`, "g");
8173
8173
  }
8174
8174
 
8175
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/shader-hooks.js
8175
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/shader-hooks.js
8176
8176
  function getShaderHooks(hookFunctions, hookInjections) {
8177
8177
  let result = "";
8178
8178
  for (const hookName in hookFunctions) {
@@ -8232,7 +8232,7 @@ ${match}`).replace(new RegExp(`\\b${ES100_FRAGMENT_OUTPUT_NAME}\\b`, "g"), outpu
8232
8232
  return result;
8233
8233
  }
8234
8234
 
8235
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/assemble-shaders.js
8235
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/assemble-shaders.js
8236
8236
  var INJECT_SHADER_DECLARATIONS = `
8237
8237
 
8238
8238
  ${DECLARATION_INJECT_MARKER}
@@ -8504,7 +8504,7 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
8504
8504
  return sourceText;
8505
8505
  }
8506
8506
 
8507
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/select-shaders.js
8507
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembly/select-shaders.js
8508
8508
  function selectShaders(platformInfo, props) {
8509
8509
  if (!props.vs) {
8510
8510
  throw new Error("no vertex shader");
@@ -8538,7 +8538,7 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
8538
8538
  }
8539
8539
  }
8540
8540
 
8541
- // ../../node_modules/@luma.gl/shadertools/dist/lib/shader-assembler.js
8541
+ // ../../../luma.gl/modules/shadertools/dist/lib/shader-assembler.js
8542
8542
  var ShaderAssembler = class {
8543
8543
  constructor() {
8544
8544
  this._hookFunctions = [];
@@ -8601,2125 +8601,2128 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
8601
8601
  };
8602
8602
  ShaderAssembler.defaultShaderAssembler = void 0;
8603
8603
 
8604
- // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-utils.js
8605
- function fp64ify(a) {
8606
- let out = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
8607
- let startIndex = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
8608
- const hiPart = Math.fround(a);
8609
- const loPart = a - hiPart;
8610
- out[startIndex] = hiPart;
8611
- out[startIndex + 1] = loPart;
8612
- return out;
8604
+ // ../../../luma.gl/modules/engine/dist/geometry/gpu-geometry.js
8605
+ var import_core34 = __toESM(require_core2(), 1);
8606
+ var GPUGeometry = class {
8607
+ constructor(props) {
8608
+ this.id = void 0;
8609
+ this.userData = {};
8610
+ this.topology = void 0;
8611
+ this.bufferLayout = [];
8612
+ this.vertexCount = void 0;
8613
+ this.indices = void 0;
8614
+ this.attributes = void 0;
8615
+ this.id = props.id || (0, import_core34.uid)("geometry");
8616
+ this.topology = props.topology;
8617
+ this.indices = props.indices || null;
8618
+ this.attributes = props.attributes;
8619
+ this.vertexCount = props.vertexCount;
8620
+ this.bufferLayout = props.bufferLayout || [];
8621
+ if (this.indices) {
8622
+ (0, import_core34.assert)(this.indices.usage === import_core34.Buffer.INDEX);
8623
+ }
8624
+ }
8625
+ destroy() {
8626
+ var _this$attributes$colo;
8627
+ this.indices.destroy();
8628
+ this.attributes.positions.destroy();
8629
+ this.attributes.normals.destroy();
8630
+ this.attributes.texCoords.destroy();
8631
+ (_this$attributes$colo = this.attributes.colors) === null || _this$attributes$colo === void 0 ? void 0 : _this$attributes$colo.destroy();
8632
+ }
8633
+ getVertexCount() {
8634
+ return this.vertexCount;
8635
+ }
8636
+ getAttributes() {
8637
+ return this.attributes;
8638
+ }
8639
+ getIndexes() {
8640
+ return this.indices;
8641
+ }
8642
+ _calculateVertexCount(positions) {
8643
+ const vertexCount = positions.byteLength / 12;
8644
+ return vertexCount;
8645
+ }
8646
+ };
8647
+ function makeGPUGeometry(device, geometry) {
8648
+ if (geometry instanceof GPUGeometry) {
8649
+ return geometry;
8650
+ }
8651
+ const indices = getIndexBufferFromGeometry(device, geometry);
8652
+ const {
8653
+ attributes,
8654
+ bufferLayout
8655
+ } = getAttributeBuffersFromGeometry(device, geometry);
8656
+ return new GPUGeometry({
8657
+ topology: geometry.topology || "triangle-list",
8658
+ bufferLayout,
8659
+ vertexCount: geometry.vertexCount,
8660
+ indices,
8661
+ attributes
8662
+ });
8613
8663
  }
8614
- function fp64LowPart(a) {
8615
- return a - Math.fround(a);
8664
+ function getIndexBufferFromGeometry(device, geometry) {
8665
+ if (!geometry.indices) {
8666
+ return void 0;
8667
+ }
8668
+ const data = geometry.indices.value;
8669
+ return device.createBuffer({
8670
+ usage: import_core34.Buffer.INDEX,
8671
+ data
8672
+ });
8616
8673
  }
8617
- function fp64ifyMatrix4(matrix) {
8618
- const matrixFP64 = new Float32Array(32);
8619
- for (let i = 0; i < 4; ++i) {
8620
- for (let j = 0; j < 4; ++j) {
8621
- const index = i * 4 + j;
8622
- fp64ify(matrix[j * 4 + i], matrixFP64, index * 2);
8674
+ function getAttributeBuffersFromGeometry(device, geometry) {
8675
+ const bufferLayout = [];
8676
+ const attributes = {};
8677
+ for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
8678
+ let name = attributeName;
8679
+ switch (attributeName) {
8680
+ case "POSITION":
8681
+ name = "positions";
8682
+ break;
8683
+ case "NORMAL":
8684
+ name = "normals";
8685
+ break;
8686
+ case "TEXCOORD_0":
8687
+ name = "texCoords";
8688
+ break;
8623
8689
  }
8690
+ attributes[name] = device.createBuffer({
8691
+ data: attribute.value,
8692
+ id: `${attributeName}-buffer`
8693
+ });
8694
+ bufferLayout.push({
8695
+ name,
8696
+ format: `float32x${attribute.size}`
8697
+ });
8624
8698
  }
8625
- return matrixFP64;
8699
+ const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices);
8700
+ return {
8701
+ attributes,
8702
+ bufferLayout,
8703
+ vertexCount
8704
+ };
8626
8705
  }
8627
8706
 
8628
- // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js
8629
- var fp64arithmeticShader = glsl`\
8630
- uniform float ONE;
8631
-
8632
- /*
8633
- About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
8634
-
8635
- The purpose of this workaround is to prevent shader compilers from
8636
- optimizing away necessary arithmetic operations by swapping their sequences
8637
- or transform the equation to some 'equivalent' from.
8638
-
8639
- The method is to multiply an artifical variable, ONE, which will be known to
8640
- the compiler to be 1 only at runtime. The whole expression is then represented
8641
- as a polynomial with respective to ONE. In the coefficients of all terms, only one a
8642
- and one b should appear
8643
-
8644
- err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
8645
- */
8646
-
8647
- // Divide float number to high and low floats to extend fraction bits
8648
- vec2 split(float a) {
8649
- const float SPLIT = 4097.0;
8650
- float t = a * SPLIT;
8651
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8652
- float a_hi = t * ONE - (t - a);
8653
- float a_lo = a * ONE - a_hi;
8654
- #else
8655
- float a_hi = t - (t - a);
8656
- float a_lo = a - a_hi;
8657
- #endif
8658
- return vec2(a_hi, a_lo);
8659
- }
8660
-
8661
- // Divide float number again when high float uses too many fraction bits
8662
- vec2 split2(vec2 a) {
8663
- vec2 b = split(a.x);
8664
- b.y += a.y;
8665
- return b;
8666
- }
8707
+ // ../../../luma.gl/modules/engine/dist/lib/pipeline-factory.js
8708
+ var import_core35 = __toESM(require_core2(), 1);
8709
+ var PipelineFactory = class {
8710
+ static getDefaultPipelineFactory(device) {
8711
+ device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
8712
+ return device._lumaData.defaultPipelineFactory;
8713
+ }
8714
+ constructor(device) {
8715
+ this.device = void 0;
8716
+ this._hashCounter = 0;
8717
+ this._hashes = {};
8718
+ this._useCounts = {};
8719
+ this._pipelineCache = {};
8720
+ this.device = device;
8721
+ }
8722
+ createRenderPipeline(options) {
8723
+ const props = {
8724
+ ...PipelineFactory.defaultProps,
8725
+ ...options
8726
+ };
8727
+ const hash = this._hashRenderPipeline({
8728
+ ...props
8729
+ });
8730
+ if (!this._pipelineCache[hash]) {
8731
+ const pipeline = this.device.createRenderPipeline({
8732
+ ...props,
8733
+ vs: this.device.createShader({
8734
+ stage: "vertex",
8735
+ source: props.vs
8736
+ }),
8737
+ fs: props.fs ? this.device.createShader({
8738
+ stage: "fragment",
8739
+ source: props.fs
8740
+ }) : null
8741
+ });
8742
+ pipeline.hash = hash;
8743
+ this._pipelineCache[hash] = pipeline;
8744
+ this._useCounts[hash] = 0;
8745
+ }
8746
+ this._useCounts[hash]++;
8747
+ return this._pipelineCache[hash];
8748
+ }
8749
+ release(pipeline) {
8750
+ const hash = pipeline.hash;
8751
+ this._useCounts[hash]--;
8752
+ if (this._useCounts[hash] === 0) {
8753
+ this._pipelineCache[hash].destroy();
8754
+ delete this._pipelineCache[hash];
8755
+ delete this._useCounts[hash];
8756
+ }
8757
+ }
8758
+ _createRenderPipeline(props) {
8759
+ if (!props.fs) {
8760
+ throw new Error("fs");
8761
+ }
8762
+ const pipeline = this.device.createRenderPipeline({
8763
+ ...props,
8764
+ vs: this.device.createShader({
8765
+ stage: "vertex",
8766
+ source: props.vs
8767
+ }),
8768
+ fs: props.fs ? this.device.createShader({
8769
+ stage: "fragment",
8770
+ source: props.fs
8771
+ }) : null
8772
+ });
8773
+ return pipeline;
8774
+ }
8775
+ _hashRenderPipeline(props) {
8776
+ const vsHash = this._getHash(props.vs);
8777
+ const fsHash = props.fs ? this._getHash(props.fs) : 0;
8778
+ const varyingHash = "-";
8779
+ switch (this.device.info.type) {
8780
+ case "webgpu":
8781
+ const parameterHash = this._getHash(JSON.stringify(props.parameters));
8782
+ const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
8783
+ return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
8784
+ default:
8785
+ return `${vsHash}/${fsHash}V${varyingHash}`;
8786
+ }
8787
+ }
8788
+ _getHash(key) {
8789
+ if (this._hashes[key] === void 0) {
8790
+ this._hashes[key] = this._hashCounter++;
8791
+ }
8792
+ return this._hashes[key];
8793
+ }
8794
+ };
8795
+ PipelineFactory.defaultProps = {
8796
+ ...import_core35.RenderPipeline.defaultProps,
8797
+ vs: void 0,
8798
+ fs: void 0
8799
+ };
8667
8800
 
8668
- // Special sum operation when a > b
8669
- vec2 quickTwoSum(float a, float b) {
8670
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8671
- float sum = (a + b) * ONE;
8672
- float err = b - (sum - a) * ONE;
8673
- #else
8674
- float sum = a + b;
8675
- float err = b - (sum - a);
8676
- #endif
8677
- return vec2(sum, err);
8678
- }
8679
-
8680
- // General sum operation
8681
- vec2 twoSum(float a, float b) {
8682
- float s = (a + b);
8683
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8684
- float v = (s * ONE - a) * ONE;
8685
- float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);
8686
- #else
8687
- float v = s - a;
8688
- float err = (a - (s - v)) + (b - v);
8689
- #endif
8690
- return vec2(s, err);
8691
- }
8692
-
8693
- vec2 twoSub(float a, float b) {
8694
- float s = (a - b);
8695
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8696
- float v = (s * ONE - a) * ONE;
8697
- float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);
8698
- #else
8699
- float v = s - a;
8700
- float err = (a - (s - v)) - (b + v);
8701
- #endif
8702
- return vec2(s, err);
8703
- }
8704
-
8705
- vec2 twoSqr(float a) {
8706
- float prod = a * a;
8707
- vec2 a_fp64 = split(a);
8708
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8709
- float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *
8710
- a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;
8711
- #else
8712
- float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
8713
- #endif
8714
- return vec2(prod, err);
8715
- }
8716
-
8717
- vec2 twoProd(float a, float b) {
8718
- float prod = a * b;
8719
- vec2 a_fp64 = split(a);
8720
- vec2 b_fp64 = split(b);
8721
- float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
8722
- a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
8723
- return vec2(prod, err);
8724
- }
8725
-
8726
- vec2 sum_fp64(vec2 a, vec2 b) {
8727
- vec2 s, t;
8728
- s = twoSum(a.x, b.x);
8729
- t = twoSum(a.y, b.y);
8730
- s.y += t.x;
8731
- s = quickTwoSum(s.x, s.y);
8732
- s.y += t.y;
8733
- s = quickTwoSum(s.x, s.y);
8734
- return s;
8735
- }
8736
-
8737
- vec2 sub_fp64(vec2 a, vec2 b) {
8738
- vec2 s, t;
8739
- s = twoSub(a.x, b.x);
8740
- t = twoSub(a.y, b.y);
8741
- s.y += t.x;
8742
- s = quickTwoSum(s.x, s.y);
8743
- s.y += t.y;
8744
- s = quickTwoSum(s.x, s.y);
8745
- return s;
8746
- }
8747
-
8748
- vec2 mul_fp64(vec2 a, vec2 b) {
8749
- vec2 prod = twoProd(a.x, b.x);
8750
- // y component is for the error
8751
- prod.y += a.x * b.y;
8752
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
8753
- prod = split2(prod);
8754
- #endif
8755
- prod = quickTwoSum(prod.x, prod.y);
8756
- prod.y += a.y * b.x;
8757
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
8758
- prod = split2(prod);
8759
- #endif
8760
- prod = quickTwoSum(prod.x, prod.y);
8761
- return prod;
8762
- }
8763
-
8764
- vec2 div_fp64(vec2 a, vec2 b) {
8765
- float xn = 1.0 / b.x;
8766
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
8767
- vec2 yn = mul_fp64(a, vec2(xn, 0));
8768
- #else
8769
- vec2 yn = a * xn;
8770
- #endif
8771
- float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
8772
- vec2 prod = twoProd(xn, diff);
8773
- return sum_fp64(yn, prod);
8774
- }
8775
-
8776
- vec2 sqrt_fp64(vec2 a) {
8777
- if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
8778
- if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
8779
-
8780
- float x = 1.0 / sqrt(a.x);
8781
- float yn = a.x * x;
8782
- #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
8783
- vec2 yn_sqr = twoSqr(yn) * ONE;
8784
- #else
8785
- vec2 yn_sqr = twoSqr(yn);
8786
- #endif
8787
- float diff = sub_fp64(a, yn_sqr).x;
8788
- vec2 prod = twoProd(x * 0.5, diff);
8789
- #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
8790
- return sum_fp64(split(yn), prod);
8791
- #else
8792
- return sum_fp64(vec2(yn, 0.0), prod);
8793
- #endif
8794
- }
8795
- `;
8796
-
8797
- // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js
8798
- var fp64functionShader = glsl`\
8799
- const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
8800
- const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
8801
- const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
8802
- const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
8803
- const vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8);
8804
- const vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8);
8805
- const vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9);
8806
- const vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8);
8807
- const vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9);
8808
- const vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10);
8809
-
8810
- const vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9);
8811
- const vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9);
8812
- const vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8);
8813
- const vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8);
8814
-
8815
- const vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8);
8816
- const vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8);
8817
- const vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8);
8818
- const vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8);
8819
-
8820
- const vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09); // 1/3!
8821
- const vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09); // 1/4!
8822
- const vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10); // 1/5!
8823
- const vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11); // 1/6!
8824
- const vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12); // 1/7!
8825
- const vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13); // 1/8!
8826
- const vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14); // 1/9!
8827
- const vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15); // 1/10!
8828
-
8829
- float nint(float d) {
8830
- if (d == floor(d)) return d;
8831
- return floor(d + 0.5);
8832
- }
8833
-
8834
- vec2 nint_fp64(vec2 a) {
8835
- float hi = nint(a.x);
8836
- float lo;
8837
- vec2 tmp;
8838
- if (hi == a.x) {
8839
- lo = nint(a.y);
8840
- tmp = quickTwoSum(hi, lo);
8841
- } else {
8842
- lo = 0.0;
8843
- if (abs(hi - a.x) == 0.5 && a.y < 0.0) {
8844
- hi -= 1.0;
8845
- }
8846
- tmp = vec2(hi, lo);
8847
- }
8848
- return tmp;
8849
- }
8850
-
8851
- /* k_power controls how much range reduction we would like to have
8852
- Range reduction uses the following method:
8853
- assume a = k_power * r + m * log(2), k and m being integers.
8854
- Set k_power = 4 (we can choose other k to trade accuracy with performance.
8855
- we only need to calculate exp(r) and using exp(a) = 2^m * exp(r)^k_power;
8856
- */
8857
-
8858
- vec2 exp_fp64(vec2 a) {
8859
- // We need to make sure these two numbers match
8860
- // as bit-wise shift is not available in GLSL 1.0
8861
- const int k_power = 4;
8862
- const float k = 16.0;
8863
-
8864
- const float inv_k = 1.0 / k;
8865
-
8866
- if (a.x <= -88.0) return vec2(0.0, 0.0);
8867
- if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0);
8868
- if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0);
8869
- if (a.x == 1.0 && a.y == 0.0) return E_FP64;
8870
-
8871
- float m = floor(a.x / LOG2_FP64.x + 0.5);
8872
- vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k;
8873
- vec2 s, t, p;
8874
-
8875
- p = mul_fp64(r, r);
8876
- s = sum_fp64(r, p * 0.5);
8877
- p = mul_fp64(p, r);
8878
- t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64);
8879
-
8880
- s = sum_fp64(s, t);
8881
- p = mul_fp64(p, r);
8882
- t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64);
8883
-
8884
- s = sum_fp64(s, t);
8885
- p = mul_fp64(p, r);
8886
- t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64);
8887
-
8888
- // s = sum_fp64(s, t);
8889
- // p = mul_fp64(p, r);
8890
- // t = mul_fp64(p, INVERSE_FACTORIAL_6_FP64);
8891
-
8892
- // s = sum_fp64(s, t);
8893
- // p = mul_fp64(p, r);
8894
- // t = mul_fp64(p, INVERSE_FACTORIAL_7_FP64);
8895
-
8896
- s = sum_fp64(s, t);
8897
-
8898
-
8899
- // At this point, s = exp(r) - 1; but after following 4 recursions, we will get exp(r) ^ 512 - 1.
8900
- for (int i = 0; i < k_power; i++) {
8901
- s = sum_fp64(s * 2.0, mul_fp64(s, s));
8902
- }
8903
-
8904
- #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
8905
- s = sum_fp64(s, vec2(ONE, 0.0));
8906
- #else
8907
- s = sum_fp64(s, vec2(1.0, 0.0));
8908
- #endif
8909
-
8910
- return s * pow(2.0, m);
8911
- // return r;
8912
- }
8913
-
8914
- vec2 log_fp64(vec2 a)
8915
- {
8916
- if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0);
8917
- if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
8918
- vec2 x = vec2(log(a.x), 0.0);
8919
- vec2 s;
8920
- #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
8921
- s = vec2(ONE, 0.0);
8922
- #else
8923
- s = vec2(1.0, 0.0);
8924
- #endif
8925
-
8926
- x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s);
8927
- return x;
8928
- }
8929
-
8930
- vec2 sin_taylor_fp64(vec2 a) {
8931
- vec2 r, s, t, x;
8932
-
8933
- if (a.x == 0.0 && a.y == 0.0) {
8934
- return vec2(0.0, 0.0);
8935
- }
8936
-
8937
- x = -mul_fp64(a, a);
8938
- s = a;
8939
- r = a;
8940
-
8941
- r = mul_fp64(r, x);
8942
- t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64);
8943
- s = sum_fp64(s, t);
8944
-
8945
- r = mul_fp64(r, x);
8946
- t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64);
8947
- s = sum_fp64(s, t);
8948
-
8949
- /* keep the following commented code in case we need them
8950
- for extra accuracy from the Taylor expansion*/
8951
-
8952
- // r = mul_fp64(r, x);
8953
- // t = mul_fp64(r, INVERSE_FACTORIAL_7_FP64);
8954
- // s = sum_fp64(s, t);
8955
-
8956
- // r = mul_fp64(r, x);
8957
- // t = mul_fp64(r, INVERSE_FACTORIAL_9_FP64);
8958
- // s = sum_fp64(s, t);
8959
-
8960
- return s;
8961
- }
8962
-
8963
- vec2 cos_taylor_fp64(vec2 a) {
8964
- vec2 r, s, t, x;
8965
-
8966
- if (a.x == 0.0 && a.y == 0.0) {
8967
- return vec2(1.0, 0.0);
8968
- }
8969
-
8970
- x = -mul_fp64(a, a);
8971
- r = x;
8972
- s = sum_fp64(vec2(1.0, 0.0), r * 0.5);
8973
-
8974
- r = mul_fp64(r, x);
8975
- t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64);
8976
- s = sum_fp64(s, t);
8977
-
8978
- r = mul_fp64(r, x);
8979
- t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64);
8980
- s = sum_fp64(s, t);
8981
-
8982
- /* keep the following commented code in case we need them
8983
- for extra accuracy from the Taylor expansion*/
8984
-
8985
- // r = mul_fp64(r, x);
8986
- // t = mul_fp64(r, INVERSE_FACTORIAL_8_FP64);
8987
- // s = sum_fp64(s, t);
8988
-
8989
- // r = mul_fp64(r, x);
8990
- // t = mul_fp64(r, INVERSE_FACTORIAL_10_FP64);
8991
- // s = sum_fp64(s, t);
8992
-
8993
- return s;
8994
- }
8995
-
8996
- void sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) {
8997
- if (a.x == 0.0 && a.y == 0.0) {
8998
- sin_t = vec2(0.0, 0.0);
8999
- cos_t = vec2(1.0, 0.0);
9000
- }
9001
-
9002
- sin_t = sin_taylor_fp64(a);
9003
- cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t)));
9004
- }
9005
-
9006
- vec2 sin_fp64(vec2 a) {
9007
- if (a.x == 0.0 && a.y == 0.0) {
9008
- return vec2(0.0, 0.0);
9009
- }
9010
-
9011
- // 2pi range reduction
9012
- vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9013
- vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9014
-
9015
- vec2 t;
9016
- float q = floor(r.x / PI_2_FP64.x + 0.5);
9017
- int j = int(q);
9018
-
9019
- if (j < -2 || j > 2) {
9020
- return vec2(0.0 / 0.0, 0.0 / 0.0);
9021
- }
9022
-
9023
- t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9024
-
9025
- q = floor(t.x / PI_16_FP64.x + 0.5);
9026
- int k = int(q);
9027
-
9028
- if (k == 0) {
9029
- if (j == 0) {
9030
- return sin_taylor_fp64(t);
9031
- } else if (j == 1) {
9032
- return cos_taylor_fp64(t);
9033
- } else if (j == -1) {
9034
- return -cos_taylor_fp64(t);
9035
- } else {
9036
- return -sin_taylor_fp64(t);
9037
- }
9038
- }
9039
-
9040
- int abs_k = int(abs(float(k)));
9041
-
9042
- if (abs_k > 4) {
9043
- return vec2(0.0 / 0.0, 0.0 / 0.0);
9044
- } else {
9045
- t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
9046
- }
9047
-
9048
- vec2 u = vec2(0.0, 0.0);
9049
- vec2 v = vec2(0.0, 0.0);
9050
-
9051
- #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9052
- if (abs(float(abs_k) - 1.0) < 0.5) {
9053
- u = COS_TABLE_0_FP64;
9054
- v = SIN_TABLE_0_FP64;
9055
- } else if (abs(float(abs_k) - 2.0) < 0.5) {
9056
- u = COS_TABLE_1_FP64;
9057
- v = SIN_TABLE_1_FP64;
9058
- } else if (abs(float(abs_k) - 3.0) < 0.5) {
9059
- u = COS_TABLE_2_FP64;
9060
- v = SIN_TABLE_2_FP64;
9061
- } else if (abs(float(abs_k) - 4.0) < 0.5) {
9062
- u = COS_TABLE_3_FP64;
9063
- v = SIN_TABLE_3_FP64;
9064
- }
9065
- #else
9066
- if (abs_k == 1) {
9067
- u = COS_TABLE_0_FP64;
9068
- v = SIN_TABLE_0_FP64;
9069
- } else if (abs_k == 2) {
9070
- u = COS_TABLE_1_FP64;
9071
- v = SIN_TABLE_1_FP64;
9072
- } else if (abs_k == 3) {
9073
- u = COS_TABLE_2_FP64;
9074
- v = SIN_TABLE_2_FP64;
9075
- } else if (abs_k == 4) {
9076
- u = COS_TABLE_3_FP64;
9077
- v = SIN_TABLE_3_FP64;
9078
- }
9079
- #endif
9080
-
9081
- vec2 sin_t, cos_t;
9082
- sincos_taylor_fp64(t, sin_t, cos_t);
9083
-
9084
-
9085
-
9086
- vec2 result = vec2(0.0, 0.0);
9087
- if (j == 0) {
9088
- if (k > 0) {
9089
- result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9090
- } else {
9091
- result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9092
- }
9093
- } else if (j == 1) {
9094
- if (k > 0) {
9095
- result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9096
- } else {
9097
- result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9098
- }
9099
- } else if (j == -1) {
9100
- if (k > 0) {
9101
- result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9102
- } else {
9103
- result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9104
- }
9105
- } else {
9106
- if (k > 0) {
9107
- result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9108
- } else {
9109
- result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
9110
- }
9111
- }
9112
-
9113
- return result;
9114
- }
9115
-
9116
- vec2 cos_fp64(vec2 a) {
9117
- if (a.x == 0.0 && a.y == 0.0) {
9118
- return vec2(1.0, 0.0);
8801
+ // ../../../luma.gl/modules/engine/dist/model/model.js
8802
+ var Model = class {
8803
+ constructor(device, props) {
8804
+ this.device = void 0;
8805
+ this.id = void 0;
8806
+ this.vs = void 0;
8807
+ this.fs = void 0;
8808
+ this.pipelineFactory = void 0;
8809
+ this.userData = {};
8810
+ this.parameters = void 0;
8811
+ this.topology = void 0;
8812
+ this.bufferLayout = void 0;
8813
+ this.vertexCount = void 0;
8814
+ this.instanceCount = 0;
8815
+ this.indexBuffer = null;
8816
+ this.bufferAttributes = {};
8817
+ this.constantAttributes = {};
8818
+ this.bindings = {};
8819
+ this.uniforms = {};
8820
+ this.pipeline = void 0;
8821
+ this.vertexArray = void 0;
8822
+ this._pipelineNeedsUpdate = "newly created";
8823
+ this._attributeInfos = {};
8824
+ this._gpuGeometry = null;
8825
+ this._getModuleUniforms = void 0;
8826
+ this.props = void 0;
8827
+ this.props = {
8828
+ ...Model.defaultProps,
8829
+ ...props
8830
+ };
8831
+ props = this.props;
8832
+ this.id = props.id || (0, import_core36.uid)("model");
8833
+ this.device = device;
8834
+ Object.assign(this.userData, props.userData);
8835
+ const platformInfo = {
8836
+ type: device.info.type,
8837
+ shaderLanguage: device.info.shadingLanguages[0],
8838
+ gpu: device.info.gpu,
8839
+ features: device.features
8840
+ };
8841
+ const {
8842
+ vs: vs5,
8843
+ fs: fs4,
8844
+ getUniforms: getUniforms4
8845
+ } = this.props.shaderAssembler.assembleShaders(platformInfo, this.props);
8846
+ this.vs = vs5;
8847
+ this.fs = fs4;
8848
+ this._getModuleUniforms = getUniforms4;
8849
+ this.vertexCount = this.props.vertexCount;
8850
+ this.instanceCount = this.props.instanceCount;
8851
+ this.topology = this.props.topology;
8852
+ this.bufferLayout = this.props.bufferLayout;
8853
+ this.parameters = this.props.parameters;
8854
+ if (props.geometry) {
8855
+ this._gpuGeometry = this.setGeometry(props.geometry);
8856
+ }
8857
+ this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
8858
+ this.pipeline = this._updatePipeline();
8859
+ this.vertexArray = device.createVertexArray({
8860
+ renderPipeline: this.pipeline
8861
+ });
8862
+ if (this._gpuGeometry) {
8863
+ this._setGeometryAttributes(this._gpuGeometry);
8864
+ }
8865
+ if (props.vertexCount) {
8866
+ this.setVertexCount(props.vertexCount);
8867
+ }
8868
+ if (props.instanceCount) {
8869
+ this.setInstanceCount(props.instanceCount);
8870
+ }
8871
+ if (props.indices) {
8872
+ throw new Error("Model.props.indices removed. Use props.indexBuffer");
8873
+ }
8874
+ if (props.indexBuffer) {
8875
+ this.setIndexBuffer(props.indexBuffer);
8876
+ }
8877
+ if (props.attributes) {
8878
+ this.setAttributes(props.attributes);
8879
+ }
8880
+ if (props.constantAttributes) {
8881
+ this.setConstantAttributes(props.constantAttributes);
8882
+ }
8883
+ if (props.bindings) {
8884
+ this.setBindings(props.bindings);
8885
+ }
8886
+ if (props.uniforms) {
8887
+ this.setUniforms(props.uniforms);
8888
+ }
8889
+ if (props.moduleSettings) {
8890
+ this.updateModuleSettings(props.moduleSettings);
8891
+ }
8892
+ this.setUniforms(this._getModuleUniforms());
8893
+ Object.seal(this);
9119
8894
  }
9120
-
9121
- // 2pi range reduction
9122
- vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9123
- vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9124
-
9125
- vec2 t;
9126
- float q = floor(r.x / PI_2_FP64.x + 0.5);
9127
- int j = int(q);
9128
-
9129
- if (j < -2 || j > 2) {
9130
- return vec2(0.0 / 0.0, 0.0 / 0.0);
8895
+ destroy() {
8896
+ this.pipelineFactory.release(this.pipeline);
9131
8897
  }
9132
-
9133
- t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9134
-
9135
- q = floor(t.x / PI_16_FP64.x + 0.5);
9136
- int k = int(q);
9137
-
9138
- if (k == 0) {
9139
- if (j == 0) {
9140
- return cos_taylor_fp64(t);
9141
- } else if (j == 1) {
9142
- return -sin_taylor_fp64(t);
9143
- } else if (j == -1) {
9144
- return sin_taylor_fp64(t);
9145
- } else {
9146
- return -cos_taylor_fp64(t);
9147
- }
8898
+ draw(renderPass) {
8899
+ this.pipeline = this._updatePipeline();
8900
+ this.pipeline.setBindings(this.bindings);
8901
+ this.pipeline.setUniforms(this.uniforms);
8902
+ this.pipeline.draw({
8903
+ renderPass,
8904
+ vertexArray: this.vertexArray,
8905
+ vertexCount: this.vertexCount,
8906
+ instanceCount: this.instanceCount
8907
+ });
9148
8908
  }
9149
-
9150
- int abs_k = int(abs(float(k)));
9151
-
9152
- if (abs_k > 4) {
9153
- return vec2(0.0 / 0.0, 0.0 / 0.0);
9154
- } else {
9155
- t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
8909
+ setGeometry(geometry) {
8910
+ const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
8911
+ this.setTopology(gpuGeometry.topology || "triangle-list");
8912
+ this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
8913
+ if (this.vertexArray) {
8914
+ this._setGeometryAttributes(gpuGeometry);
8915
+ }
8916
+ return gpuGeometry;
9156
8917
  }
9157
-
9158
- vec2 u = vec2(0.0, 0.0);
9159
- vec2 v = vec2(0.0, 0.0);
9160
-
9161
- #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9162
- if (abs(float(abs_k) - 1.0) < 0.5) {
9163
- u = COS_TABLE_0_FP64;
9164
- v = SIN_TABLE_0_FP64;
9165
- } else if (abs(float(abs_k) - 2.0) < 0.5) {
9166
- u = COS_TABLE_1_FP64;
9167
- v = SIN_TABLE_1_FP64;
9168
- } else if (abs(float(abs_k) - 3.0) < 0.5) {
9169
- u = COS_TABLE_2_FP64;
9170
- v = SIN_TABLE_2_FP64;
9171
- } else if (abs(float(abs_k) - 4.0) < 0.5) {
9172
- u = COS_TABLE_3_FP64;
9173
- v = SIN_TABLE_3_FP64;
8918
+ _setGeometryAttributes(gpuGeometry) {
8919
+ this.vertexCount = gpuGeometry.vertexCount;
8920
+ this.setAttributes(gpuGeometry.attributes);
8921
+ this.setIndexBuffer(gpuGeometry.indices);
9174
8922
  }
9175
- #else
9176
- if (abs_k == 1) {
9177
- u = COS_TABLE_0_FP64;
9178
- v = SIN_TABLE_0_FP64;
9179
- } else if (abs_k == 2) {
9180
- u = COS_TABLE_1_FP64;
9181
- v = SIN_TABLE_1_FP64;
9182
- } else if (abs_k == 3) {
9183
- u = COS_TABLE_2_FP64;
9184
- v = SIN_TABLE_2_FP64;
9185
- } else if (abs_k == 4) {
9186
- u = COS_TABLE_3_FP64;
9187
- v = SIN_TABLE_3_FP64;
8923
+ setTopology(topology) {
8924
+ if (topology !== this.topology) {
8925
+ this.topology = topology;
8926
+ this._setPipelineNeedsUpdate("topology");
8927
+ }
9188
8928
  }
9189
- #endif
9190
-
9191
- vec2 sin_t, cos_t;
9192
- sincos_taylor_fp64(t, sin_t, cos_t);
9193
-
9194
- vec2 result = vec2(0.0, 0.0);
9195
- if (j == 0) {
9196
- if (k > 0) {
9197
- result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9198
- } else {
9199
- result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9200
- }
9201
- } else if (j == 1) {
9202
- if (k > 0) {
9203
- result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9204
- } else {
9205
- result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
9206
- }
9207
- } else if (j == -1) {
9208
- if (k > 0) {
9209
- result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9210
- } else {
9211
- result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9212
- }
9213
- } else {
9214
- if (k > 0) {
9215
- result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9216
- } else {
9217
- result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9218
- }
8929
+ setBufferLayout(bufferLayout) {
8930
+ this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
8931
+ this._setPipelineNeedsUpdate("bufferLayout");
8932
+ this.pipeline = this._updatePipeline();
8933
+ this.vertexArray = this.device.createVertexArray({
8934
+ renderPipeline: this.pipeline
8935
+ });
8936
+ if (this._gpuGeometry) {
8937
+ this._setGeometryAttributes(this._gpuGeometry);
8938
+ }
9219
8939
  }
9220
-
9221
- return result;
9222
- }
9223
-
9224
- vec2 tan_fp64(vec2 a) {
9225
- vec2 sin_a;
9226
- vec2 cos_a;
9227
-
9228
- if (a.x == 0.0 && a.y == 0.0) {
9229
- return vec2(0.0, 0.0);
8940
+ setParameters(parameters2) {
8941
+ if (!(0, import_core36.deepEqual)(parameters2, this.parameters, 2)) {
8942
+ this.parameters = parameters2;
8943
+ this._setPipelineNeedsUpdate("parameters");
8944
+ }
9230
8945
  }
9231
-
9232
- // 2pi range reduction
9233
- vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9234
- vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9235
-
9236
- vec2 t;
9237
- float q = floor(r.x / PI_2_FP64.x + 0.5);
9238
- int j = int(q);
9239
-
9240
-
9241
- if (j < -2 || j > 2) {
9242
- return vec2(0.0 / 0.0, 0.0 / 0.0);
8946
+ setVertexCount(vertexCount) {
8947
+ this.vertexCount = vertexCount;
9243
8948
  }
9244
-
9245
- t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9246
-
9247
- q = floor(t.x / PI_16_FP64.x + 0.5);
9248
- int k = int(q);
9249
- int abs_k = int(abs(float(k)));
9250
-
9251
- // We just can't get PI/16 * 3.0 very accurately.
9252
- // so let's just store it
9253
- if (abs_k > 4) {
9254
- return vec2(0.0 / 0.0, 0.0 / 0.0);
9255
- } else {
9256
- t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
8949
+ setInstanceCount(instanceCount) {
8950
+ this.instanceCount = instanceCount;
9257
8951
  }
9258
-
9259
-
9260
- vec2 u = vec2(0.0, 0.0);
9261
- vec2 v = vec2(0.0, 0.0);
9262
-
9263
- vec2 sin_t, cos_t;
9264
- vec2 s, c;
9265
- sincos_taylor_fp64(t, sin_t, cos_t);
9266
-
9267
- if (k == 0) {
9268
- s = sin_t;
9269
- c = cos_t;
9270
- } else {
9271
- #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9272
- if (abs(float(abs_k) - 1.0) < 0.5) {
9273
- u = COS_TABLE_0_FP64;
9274
- v = SIN_TABLE_0_FP64;
9275
- } else if (abs(float(abs_k) - 2.0) < 0.5) {
9276
- u = COS_TABLE_1_FP64;
9277
- v = SIN_TABLE_1_FP64;
9278
- } else if (abs(float(abs_k) - 3.0) < 0.5) {
9279
- u = COS_TABLE_2_FP64;
9280
- v = SIN_TABLE_2_FP64;
9281
- } else if (abs(float(abs_k) - 4.0) < 0.5) {
9282
- u = COS_TABLE_3_FP64;
9283
- v = SIN_TABLE_3_FP64;
8952
+ setShaderModuleProps(props) {
8953
+ const uniforms = this._getModuleUniforms(props);
8954
+ const keys = Object.keys(uniforms).filter((k) => {
8955
+ const uniform = uniforms[k];
8956
+ return !(0, import_core36.isNumberArray)(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
8957
+ });
8958
+ const bindings = {};
8959
+ for (const k of keys) {
8960
+ bindings[k] = uniforms[k];
8961
+ delete uniforms[k];
8962
+ }
8963
+ Object.assign(this.uniforms, uniforms);
8964
+ Object.assign(this.bindings, bindings);
8965
+ }
8966
+ updateModuleSettings(props) {
8967
+ this.setShaderModuleProps(props);
8968
+ }
8969
+ setBindings(bindings) {
8970
+ Object.assign(this.bindings, bindings);
8971
+ }
8972
+ setUniforms(uniforms) {
8973
+ this.pipeline.setUniforms(uniforms);
8974
+ Object.assign(this.uniforms, uniforms);
8975
+ }
8976
+ setIndexBuffer(indexBuffer) {
8977
+ this.vertexArray.setIndexBuffer(indexBuffer);
8978
+ }
8979
+ setAttributes(buffers) {
8980
+ if (buffers.indices) {
8981
+ import_core36.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
8982
+ }
8983
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
8984
+ var _bufferLayout$attribu;
8985
+ const bufferLayout = this.bufferLayout.find((layout) => layout.name === bufferName);
8986
+ if (!bufferLayout) {
8987
+ continue;
9284
8988
  }
9285
- #else
9286
- if (abs_k == 1) {
9287
- u = COS_TABLE_0_FP64;
9288
- v = SIN_TABLE_0_FP64;
9289
- } else if (abs_k == 2) {
9290
- u = COS_TABLE_1_FP64;
9291
- v = SIN_TABLE_1_FP64;
9292
- } else if (abs_k == 3) {
9293
- u = COS_TABLE_2_FP64;
9294
- v = SIN_TABLE_2_FP64;
9295
- } else if (abs_k == 4) {
9296
- u = COS_TABLE_3_FP64;
9297
- v = SIN_TABLE_3_FP64;
8989
+ const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map((layout) => layout.attribute) : [bufferLayout.name];
8990
+ let set2 = false;
8991
+ for (const attributeName of attributeNames) {
8992
+ const attributeInfo = this._attributeInfos[attributeName];
8993
+ if (attributeInfo) {
8994
+ this.vertexArray.setBuffer(attributeInfo.location, buffer);
8995
+ set2 = true;
8996
+ }
9298
8997
  }
9299
- #endif
9300
- if (k > 0) {
9301
- s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9302
- c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
8998
+ if (!set2) {
8999
+ import_core36.log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
9000
+ }
9001
+ }
9002
+ }
9003
+ setConstantAttributes(attributes) {
9004
+ for (const [attributeName, value] of Object.entries(attributes)) {
9005
+ const attributeInfo = this._attributeInfos[attributeName];
9006
+ if (attributeInfo) {
9007
+ this.vertexArray.setConstant(attributeInfo.location, value);
9303
9008
  } else {
9304
- s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9305
- c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9009
+ import_core36.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
9306
9010
  }
9011
+ }
9307
9012
  }
9308
-
9309
- if (j == 0) {
9310
- sin_a = s;
9311
- cos_a = c;
9312
- } else if (j == 1) {
9313
- sin_a = c;
9314
- cos_a = -s;
9315
- } else if (j == -1) {
9316
- sin_a = -c;
9317
- cos_a = s;
9318
- } else {
9319
- sin_a = -s;
9320
- cos_a = -c;
9013
+ _setPipelineNeedsUpdate(reason) {
9014
+ this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
9321
9015
  }
9322
- return div_fp64(sin_a, cos_a);
9323
- }
9324
-
9325
- vec2 radians_fp64(vec2 degree) {
9326
- return mul_fp64(degree, PI_180_FP64);
9327
- }
9328
-
9329
- vec2 mix_fp64(vec2 a, vec2 b, float x) {
9330
- vec2 range = sub_fp64(b, a);
9331
- return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));
9332
- }
9333
-
9334
- // Vector functions
9335
- // vec2 functions
9336
- void vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
9337
- out_val[0] = sum_fp64(a[0], b[0]);
9338
- out_val[1] = sum_fp64(a[1], b[1]);
9339
- }
9340
-
9341
- void vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
9342
- out_val[0] = sub_fp64(a[0], b[0]);
9343
- out_val[1] = sub_fp64(a[1], b[1]);
9344
- }
9345
-
9346
- void vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
9347
- out_val[0] = mul_fp64(a[0], b[0]);
9348
- out_val[1] = mul_fp64(a[1], b[1]);
9349
- }
9350
-
9351
- void vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
9352
- out_val[0] = div_fp64(a[0], b[0]);
9353
- out_val[1] = div_fp64(a[1], b[1]);
9354
- }
9355
-
9356
- void vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) {
9357
- vec2 range[2];
9358
- vec2_sub_fp64(y, x, range);
9359
- vec2 portion[2];
9360
- portion[0] = range[0] * a;
9361
- portion[1] = range[1] * a;
9362
- vec2_sum_fp64(x, portion, out_val);
9363
- }
9364
-
9365
- vec2 vec2_length_fp64(vec2 x[2]) {
9366
- return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])));
9367
- }
9368
-
9369
- void vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) {
9370
- vec2 length = vec2_length_fp64(x);
9371
- vec2 length_vec2[2];
9372
- length_vec2[0] = length;
9373
- length_vec2[1] = length;
9374
-
9375
- vec2_div_fp64(x, length_vec2, out_val);
9376
- }
9377
-
9378
- vec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) {
9379
- vec2 diff[2];
9380
- vec2_sub_fp64(x, y, diff);
9381
- return vec2_length_fp64(diff);
9382
- }
9383
-
9384
- vec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) {
9385
- vec2 v[2];
9386
-
9387
- v[0] = mul_fp64(a[0], b[0]);
9388
- v[1] = mul_fp64(a[1], b[1]);
9389
-
9390
- return sum_fp64(v[0], v[1]);
9391
- }
9392
-
9393
- // vec3 functions
9394
- void vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
9395
- for (int i = 0; i < 3; i++) {
9396
- out_val[i] = sum_fp64(a[i], b[i]);
9397
- }
9398
- }
9399
-
9400
- void vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
9401
- for (int i = 0; i < 3; i++) {
9402
- out_val[i] = sum_fp64(a[i], b[i]);
9403
- }
9404
- }
9405
-
9406
- vec2 vec3_length_fp64(vec2 x[3]) {
9407
- return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])),
9408
- mul_fp64(x[2], x[2])));
9409
- }
9410
-
9411
- vec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) {
9412
- vec2 diff[3];
9413
- vec3_sub_fp64(x, y, diff);
9414
- return vec3_length_fp64(diff);
9415
- }
9416
-
9417
- // vec4 functions
9418
- void vec4_fp64(vec4 a, out vec2 out_val[4]) {
9419
- out_val[0].x = a[0];
9420
- out_val[0].y = 0.0;
9421
-
9422
- out_val[1].x = a[1];
9423
- out_val[1].y = 0.0;
9424
-
9425
- out_val[2].x = a[2];
9426
- out_val[2].y = 0.0;
9427
-
9428
- out_val[3].x = a[3];
9429
- out_val[3].y = 0.0;
9430
- }
9431
-
9432
- void vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) {
9433
- out_val[0] = mul_fp64(a[0], b);
9434
- out_val[1] = mul_fp64(a[1], b);
9435
- out_val[2] = mul_fp64(a[2], b);
9436
- out_val[3] = mul_fp64(a[3], b);
9437
- }
9438
-
9439
- void vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) {
9440
- for (int i = 0; i < 4; i++) {
9441
- out_val[i] = sum_fp64(a[i], b[i]);
9016
+ _updatePipeline() {
9017
+ if (this._pipelineNeedsUpdate) {
9018
+ if (this.pipeline) {
9019
+ import_core36.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
9020
+ }
9021
+ this._pipelineNeedsUpdate = false;
9022
+ this.pipeline = this.device.createRenderPipeline({
9023
+ ...this.props,
9024
+ bufferLayout: this.bufferLayout,
9025
+ topology: this.topology,
9026
+ parameters: this.parameters,
9027
+ vs: this.device.createShader({
9028
+ id: "{$this.id}-vertex",
9029
+ stage: "vertex",
9030
+ source: this.vs
9031
+ }),
9032
+ fs: this.fs ? this.device.createShader({
9033
+ id: "{$this.id}-fragment",
9034
+ stage: "fragment",
9035
+ source: this.fs
9036
+ }) : null
9037
+ });
9038
+ this._attributeInfos = (0, import_core37.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout, this.bufferLayout);
9039
+ }
9040
+ return this.pipeline;
9041
+ }
9042
+ };
9043
+ Model.defaultProps = {
9044
+ ...import_core36.RenderPipeline.defaultProps,
9045
+ vs: null,
9046
+ fs: null,
9047
+ id: "unnamed",
9048
+ handle: void 0,
9049
+ userData: {},
9050
+ defines: {},
9051
+ modules: [],
9052
+ moduleSettings: {},
9053
+ geometry: null,
9054
+ indexBuffer: null,
9055
+ attributes: {},
9056
+ constantAttributes: {},
9057
+ pipelineFactory: void 0,
9058
+ shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
9059
+ };
9060
+ function mergeBufferLayouts(layouts1, layouts2) {
9061
+ const layouts = [...layouts1];
9062
+ for (const attribute of layouts2) {
9063
+ const index = layouts.findIndex((attribute2) => attribute2.name === attribute.name);
9064
+ if (index < 0) {
9065
+ layouts.push(attribute);
9066
+ } else {
9067
+ layouts[index] = attribute;
9068
+ }
9069
+ }
9070
+ return layouts;
9442
9071
  }
9443
- }
9444
9072
 
9445
- void vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) {
9446
- vec2 v[4];
9073
+ // src/data-filter/aggregator.ts
9074
+ var AGGREGATE_VS = `#define SHADER_NAME data-filter-vertex-shader
9447
9075
 
9448
- v[0] = mul_fp64(a[0], b[0]);
9449
- v[1] = mul_fp64(a[1], b[1]);
9450
- v[2] = mul_fp64(a[2], b[2]);
9451
- v[3] = mul_fp64(a[3], b[3]);
9076
+ #ifdef FLOAT_TARGET
9077
+ attribute float filterIndices;
9078
+ attribute float filterPrevIndices;
9079
+ #else
9080
+ attribute vec2 filterIndices;
9081
+ attribute vec2 filterPrevIndices;
9082
+ #endif
9452
9083
 
9453
- out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3]));
9084
+ varying vec4 vColor;
9085
+ const float component = 1.0 / 255.0;
9086
+
9087
+ void main() {
9088
+ #ifdef FLOAT_TARGET
9089
+ dataFilter_value *= float(filterIndices != filterPrevIndices);
9090
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
9091
+ vColor = vec4(0.0, 0.0, 0.0, 1.0);
9092
+ #else
9093
+ // Float texture is not supported: pack result into 4 channels x 256 px x 64px
9094
+ dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
9095
+ float col = filterIndices.x;
9096
+ float row = filterIndices.y * 4.0;
9097
+ float channel = floor(row);
9098
+ row = fract(row);
9099
+ vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
9100
+ gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
9101
+ #endif
9102
+ gl_PointSize = 1.0;
9454
9103
  }
9104
+ `;
9105
+ var AGGREGATE_FS = `#define SHADER_NAME data-filter-fragment-shader
9106
+ precision highp float;
9455
9107
 
9456
- void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
9457
- vec2 tmp[4];
9108
+ varying vec4 vColor;
9458
9109
 
9459
- for (int i = 0; i < 4; i++)
9460
- {
9461
- for (int j = 0; j < 4; j++)
9462
- {
9463
- tmp[j] = b[j + i * 4];
9464
- }
9465
- vec4_dot_fp64(a, tmp, out_val[i]);
9110
+ void main() {
9111
+ if (dataFilter_value < 0.5) {
9112
+ discard;
9466
9113
  }
9114
+ gl_FragColor = vColor;
9467
9115
  }
9468
9116
  `;
9469
-
9470
- // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64.js
9471
- var CONST_UNIFORMS = {
9472
- ONE: 1
9473
- };
9474
- function getUniforms2() {
9475
- return CONST_UNIFORMS;
9117
+ function supportsFloatTarget(device) {
9118
+ const gl = device.gl;
9119
+ return Boolean(gl.getExtension("EXT_float_blend") && (gl.getExtension("EXT_color_buffer_float") || gl.getExtension("WEBGL_color_buffer_float")));
9476
9120
  }
9477
- var fp64arithmetic = {
9478
- name: "fp64-arithmetic",
9479
- vs: fp64arithmeticShader,
9480
- getUniforms: getUniforms2,
9481
- fp64ify,
9482
- fp64LowPart,
9483
- fp64ifyMatrix4
9484
- };
9485
- var fp64 = {
9486
- name: "fp64",
9487
- vs: fp64functionShader,
9488
- dependencies: [fp64arithmetic],
9489
- fp64ify,
9490
- fp64LowPart,
9491
- fp64ifyMatrix4
9121
+ function getFramebuffer3(device, useFloatTarget) {
9122
+ if (useFloatTarget) {
9123
+ return device.createFramebuffer({
9124
+ width: 1,
9125
+ height: 1,
9126
+ colorAttachments: [device.createTexture({
9127
+ format: device.info.type === "webgl2" ? "rgba32float" : "rgba8unorm",
9128
+ type: 5126,
9129
+ mipmaps: false
9130
+ })]
9131
+ });
9132
+ }
9133
+ return device.createFramebuffer({
9134
+ width: 256,
9135
+ height: 64,
9136
+ colorAttachments: [device.createTexture({
9137
+ format: "rgba8unorm",
9138
+ type: 5126,
9139
+ mipmaps: false
9140
+ })]
9141
+ });
9142
+ }
9143
+ function getModel(device, shaderOptions, useFloatTarget) {
9144
+ shaderOptions.defines.NON_INSTANCED_MODEL = 1;
9145
+ if (useFloatTarget) {
9146
+ shaderOptions.defines.FLOAT_TARGET = 1;
9147
+ }
9148
+ return new Model(device, {
9149
+ id: "data-filter-aggregation-model",
9150
+ vertexCount: 1,
9151
+ isInstanced: false,
9152
+ drawMode: 0,
9153
+ vs: AGGREGATE_VS,
9154
+ fs: AGGREGATE_FS,
9155
+ ...shaderOptions
9156
+ });
9157
+ }
9158
+ var parameters = {
9159
+ blend: true,
9160
+ blendFunc: [1, 1, 1, 1],
9161
+ blendEquation: [32774, 32774],
9162
+ depthTest: false
9492
9163
  };
9493
9164
 
9494
- // ../../node_modules/@math.gl/core/dist/lib/common.js
9495
- var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
9496
- var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
9497
- var DEFAULT_CONFIG = {
9498
- EPSILON: 1e-12,
9499
- debug: false,
9500
- precision: 4,
9501
- printTypes: false,
9502
- printDegrees: false,
9503
- printRowMajor: true,
9504
- _cartographicRadians: false
9165
+ // src/data-filter/data-filter-extension.ts
9166
+ var defaultProps2 = {
9167
+ getFilterValue: {
9168
+ type: "accessor",
9169
+ value: 0
9170
+ },
9171
+ onFilteredItemsChange: {
9172
+ type: "function",
9173
+ value: null,
9174
+ optional: true
9175
+ },
9176
+ filterEnabled: true,
9177
+ filterRange: [-1, 1],
9178
+ filterSoftRange: null,
9179
+ filterTransformSize: true,
9180
+ filterTransformColor: true
9505
9181
  };
9506
- globalThis.mathgl = globalThis.mathgl || {
9507
- config: {
9508
- ...DEFAULT_CONFIG
9509
- }
9182
+ var DATA_TYPE_FROM_SIZE = {
9183
+ 1: "float",
9184
+ 2: "vec2",
9185
+ 3: "vec3",
9186
+ 4: "vec4"
9510
9187
  };
9511
- var config = globalThis.mathgl.config;
9512
- function isArray2(value) {
9513
- return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
9514
- }
9515
- function equals(a, b, epsilon) {
9516
- const oldEpsilon = config.EPSILON;
9517
- if (epsilon) {
9518
- config.EPSILON = epsilon;
9188
+ var DataFilterExtension = class extends import_core38.LayerExtension {
9189
+ constructor({
9190
+ filterSize = 1,
9191
+ fp64: fp642 = false,
9192
+ countItems = false
9193
+ } = {}) {
9194
+ if (!DATA_TYPE_FROM_SIZE[filterSize]) {
9195
+ throw new Error("filterSize out of range");
9196
+ }
9197
+ super({
9198
+ filterSize,
9199
+ fp64: fp642,
9200
+ countItems
9201
+ });
9519
9202
  }
9520
- try {
9521
- if (a === b) {
9522
- return true;
9203
+ getShaders(extension) {
9204
+ const {
9205
+ filterSize,
9206
+ fp64: fp642
9207
+ } = extension.opts;
9208
+ return {
9209
+ modules: [fp642 ? shaderModule64 : shaderModule],
9210
+ defines: {
9211
+ DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
9212
+ DATAFILTER_DOUBLE: Boolean(fp642)
9213
+ }
9214
+ };
9215
+ }
9216
+ initializeState(context, extension) {
9217
+ const attributeManager = this.getAttributeManager();
9218
+ if (attributeManager) {
9219
+ attributeManager.add({
9220
+ filterValues: {
9221
+ size: extension.opts.filterSize,
9222
+ type: extension.opts.fp64 ? 5130 : 5126,
9223
+ accessor: "getFilterValue",
9224
+ shaderAttributes: {
9225
+ filterValues: {
9226
+ divisor: 0
9227
+ },
9228
+ instanceFilterValues: {
9229
+ divisor: 1
9230
+ }
9231
+ }
9232
+ }
9233
+ });
9523
9234
  }
9524
- if (isArray2(a) && isArray2(b)) {
9525
- if (a.length !== b.length) {
9526
- return false;
9235
+ const {
9236
+ device
9237
+ } = this.context;
9238
+ if (attributeManager && extension.opts.countItems) {
9239
+ const useFloatTarget = supportsFloatTarget(device);
9240
+ attributeManager.add({
9241
+ filterIndices: {
9242
+ size: useFloatTarget ? 1 : 2,
9243
+ vertexOffset: 1,
9244
+ type: 5121,
9245
+ normalized: true,
9246
+ accessor: (object, {
9247
+ index
9248
+ }) => {
9249
+ const i = object && object.__source ? object.__source.index : index;
9250
+ return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
9251
+ },
9252
+ shaderAttributes: {
9253
+ filterPrevIndices: {
9254
+ vertexOffset: 0
9255
+ },
9256
+ filterIndices: {
9257
+ vertexOffset: 1
9258
+ }
9259
+ }
9260
+ }
9261
+ });
9262
+ const filterFBO = getFramebuffer3(device, useFloatTarget);
9263
+ const filterModel = getModel(device, extension.getShaders.call(this, extension), useFloatTarget);
9264
+ this.setState({
9265
+ filterFBO,
9266
+ filterModel
9267
+ });
9268
+ }
9269
+ }
9270
+ updateState({
9271
+ props,
9272
+ oldProps
9273
+ }) {
9274
+ if (this.state.filterModel) {
9275
+ const attributeManager = this.getAttributeManager();
9276
+ const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() || props.filterEnabled !== oldProps.filterEnabled || props.filterRange !== oldProps.filterRange || props.filterSoftRange !== oldProps.filterSoftRange;
9277
+ if (filterNeedsUpdate) {
9278
+ this.setState({
9279
+ filterNeedsUpdate
9280
+ });
9527
9281
  }
9528
- for (let i = 0; i < a.length; ++i) {
9529
- if (!equals(a[i], b[i])) {
9530
- return false;
9282
+ }
9283
+ }
9284
+ draw(params, extension) {
9285
+ const filterFBO = this.state.filterFBO;
9286
+ const filterModel = this.state.filterModel;
9287
+ const filterNeedsUpdate = this.state.filterNeedsUpdate;
9288
+ const {
9289
+ onFilteredItemsChange
9290
+ } = this.props;
9291
+ if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
9292
+ const {
9293
+ attributes: {
9294
+ filterValues,
9295
+ filterIndices
9531
9296
  }
9297
+ } = this.getAttributeManager();
9298
+ filterModel.setVertexCount(this.getNumInstances());
9299
+ clear(this.context.device, {
9300
+ framebuffer: filterFBO,
9301
+ color: [0, 0, 0, 0]
9302
+ });
9303
+ filterModel.updateModuleSettings(params.moduleParameters);
9304
+ filterModel.setAttributes({
9305
+ ...filterValues.getValue(),
9306
+ ...filterIndices?.getValue()
9307
+ });
9308
+ withGLParameters(filterModel.device, {
9309
+ framebuffer: filterFBO,
9310
+ ...parameters,
9311
+ viewport: [0, 0, filterFBO.width, filterFBO.height]
9312
+ }, () => {
9313
+ filterModel.draw(this.context.renderPass);
9314
+ });
9315
+ const color = readPixelsToArray(filterFBO);
9316
+ let count = 0;
9317
+ for (let i = 0; i < color.length; i++) {
9318
+ count += color[i];
9532
9319
  }
9533
- return true;
9534
- }
9535
- if (a && a.equals) {
9536
- return a.equals(b);
9537
- }
9538
- if (b && b.equals) {
9539
- return b.equals(a);
9540
- }
9541
- if (typeof a === "number" && typeof b === "number") {
9542
- return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
9320
+ onFilteredItemsChange({
9321
+ id: this.id,
9322
+ count
9323
+ });
9324
+ this.state.filterNeedsUpdate = false;
9543
9325
  }
9544
- return false;
9545
- } finally {
9546
- config.EPSILON = oldEpsilon;
9547
9326
  }
9548
- }
9327
+ finalizeState() {
9328
+ const filterFBO = this.state.filterFBO;
9329
+ const filterModel = this.state.filterModel;
9330
+ filterFBO?.destroy();
9331
+ filterModel?.destroy();
9332
+ }
9333
+ };
9334
+ __publicField(DataFilterExtension, "defaultProps", defaultProps2);
9335
+ __publicField(DataFilterExtension, "extensionName", "DataFilterExtension");
9549
9336
 
9550
- // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
9551
- var EPSILON = 1e-6;
9552
- var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
9553
- var RANDOM = Math.random;
9554
- function round(a) {
9555
- if (a >= 0)
9556
- return Math.round(a);
9557
- return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
9558
- }
9559
- var degree = Math.PI / 180;
9337
+ // src/fp64/fp64-extension.ts
9338
+ var import_core40 = __toESM(require_core());
9560
9339
 
9561
- // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
9562
- var vec3_exports = {};
9563
- __export(vec3_exports, {
9564
- add: () => add,
9565
- angle: () => angle,
9566
- bezier: () => bezier,
9567
- ceil: () => ceil,
9568
- clone: () => clone,
9569
- copy: () => copy,
9570
- create: () => create,
9571
- cross: () => cross,
9572
- dist: () => dist,
9573
- distance: () => distance,
9574
- div: () => div,
9575
- divide: () => divide,
9576
- dot: () => dot,
9577
- equals: () => equals2,
9578
- exactEquals: () => exactEquals,
9579
- floor: () => floor,
9580
- forEach: () => forEach,
9581
- fromValues: () => fromValues,
9582
- hermite: () => hermite,
9583
- inverse: () => inverse,
9584
- len: () => len,
9585
- length: () => length,
9586
- lerp: () => lerp,
9587
- max: () => max,
9588
- min: () => min,
9589
- mul: () => mul,
9590
- multiply: () => multiply,
9591
- negate: () => negate,
9592
- normalize: () => normalize,
9593
- random: () => random,
9594
- rotateX: () => rotateX,
9595
- rotateY: () => rotateY,
9596
- rotateZ: () => rotateZ,
9597
- round: () => round2,
9598
- scale: () => scale,
9599
- scaleAndAdd: () => scaleAndAdd,
9600
- set: () => set,
9601
- slerp: () => slerp,
9602
- sqrDist: () => sqrDist,
9603
- sqrLen: () => sqrLen,
9604
- squaredDistance: () => squaredDistance,
9605
- squaredLength: () => squaredLength,
9606
- str: () => str,
9607
- sub: () => sub,
9608
- subtract: () => subtract,
9609
- transformMat3: () => transformMat3,
9610
- transformMat4: () => transformMat4,
9611
- transformQuat: () => transformQuat,
9612
- zero: () => zero
9613
- });
9614
- function create() {
9615
- const out = new ARRAY_TYPE(3);
9616
- if (ARRAY_TYPE != Float32Array) {
9617
- out[0] = 0;
9618
- out[1] = 0;
9619
- out[2] = 0;
9620
- }
9621
- return out;
9622
- }
9623
- function clone(a) {
9624
- const out = new ARRAY_TYPE(3);
9625
- out[0] = a[0];
9626
- out[1] = a[1];
9627
- out[2] = a[2];
9628
- return out;
9629
- }
9630
- function length(a) {
9631
- const x = a[0];
9632
- const y = a[1];
9633
- const z = a[2];
9634
- return Math.sqrt(x * x + y * y + z * z);
9635
- }
9636
- function fromValues(x, y, z) {
9637
- const out = new ARRAY_TYPE(3);
9638
- out[0] = x;
9639
- out[1] = y;
9640
- out[2] = z;
9641
- return out;
9642
- }
9643
- function copy(out, a) {
9644
- out[0] = a[0];
9645
- out[1] = a[1];
9646
- out[2] = a[2];
9647
- return out;
9648
- }
9649
- function set(out, x, y, z) {
9650
- out[0] = x;
9651
- out[1] = y;
9652
- out[2] = z;
9653
- return out;
9654
- }
9655
- function add(out, a, b) {
9656
- out[0] = a[0] + b[0];
9657
- out[1] = a[1] + b[1];
9658
- out[2] = a[2] + b[2];
9659
- return out;
9660
- }
9661
- function subtract(out, a, b) {
9662
- out[0] = a[0] - b[0];
9663
- out[1] = a[1] - b[1];
9664
- out[2] = a[2] - b[2];
9665
- return out;
9666
- }
9667
- function multiply(out, a, b) {
9668
- out[0] = a[0] * b[0];
9669
- out[1] = a[1] * b[1];
9670
- out[2] = a[2] * b[2];
9671
- return out;
9672
- }
9673
- function divide(out, a, b) {
9674
- out[0] = a[0] / b[0];
9675
- out[1] = a[1] / b[1];
9676
- out[2] = a[2] / b[2];
9677
- return out;
9678
- }
9679
- function ceil(out, a) {
9680
- out[0] = Math.ceil(a[0]);
9681
- out[1] = Math.ceil(a[1]);
9682
- out[2] = Math.ceil(a[2]);
9683
- return out;
9684
- }
9685
- function floor(out, a) {
9686
- out[0] = Math.floor(a[0]);
9687
- out[1] = Math.floor(a[1]);
9688
- out[2] = Math.floor(a[2]);
9689
- return out;
9690
- }
9691
- function min(out, a, b) {
9692
- out[0] = Math.min(a[0], b[0]);
9693
- out[1] = Math.min(a[1], b[1]);
9694
- out[2] = Math.min(a[2], b[2]);
9695
- return out;
9696
- }
9697
- function max(out, a, b) {
9698
- out[0] = Math.max(a[0], b[0]);
9699
- out[1] = Math.max(a[1], b[1]);
9700
- out[2] = Math.max(a[2], b[2]);
9701
- return out;
9702
- }
9703
- function round2(out, a) {
9704
- out[0] = round(a[0]);
9705
- out[1] = round(a[1]);
9706
- out[2] = round(a[2]);
9707
- return out;
9708
- }
9709
- function scale(out, a, b) {
9710
- out[0] = a[0] * b;
9711
- out[1] = a[1] * b;
9712
- out[2] = a[2] * b;
9713
- return out;
9714
- }
9715
- function scaleAndAdd(out, a, b, scale2) {
9716
- out[0] = a[0] + b[0] * scale2;
9717
- out[1] = a[1] + b[1] * scale2;
9718
- out[2] = a[2] + b[2] * scale2;
9340
+ // ../../node_modules/@luma.gl/shadertools/dist/lib/glsl-utils/highlight.js
9341
+ var glsl2 = (x) => `${x}`;
9342
+
9343
+ // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-utils.js
9344
+ function fp64ify(a) {
9345
+ let out = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
9346
+ let startIndex = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
9347
+ const hiPart = Math.fround(a);
9348
+ const loPart = a - hiPart;
9349
+ out[startIndex] = hiPart;
9350
+ out[startIndex + 1] = loPart;
9719
9351
  return out;
9720
9352
  }
9721
- function distance(a, b) {
9722
- const x = b[0] - a[0];
9723
- const y = b[1] - a[1];
9724
- const z = b[2] - a[2];
9725
- return Math.sqrt(x * x + y * y + z * z);
9726
- }
9727
- function squaredDistance(a, b) {
9728
- const x = b[0] - a[0];
9729
- const y = b[1] - a[1];
9730
- const z = b[2] - a[2];
9731
- return x * x + y * y + z * z;
9732
- }
9733
- function squaredLength(a) {
9734
- const x = a[0];
9735
- const y = a[1];
9736
- const z = a[2];
9737
- return x * x + y * y + z * z;
9738
- }
9739
- function negate(out, a) {
9740
- out[0] = -a[0];
9741
- out[1] = -a[1];
9742
- out[2] = -a[2];
9743
- return out;
9353
+ function fp64LowPart(a) {
9354
+ return a - Math.fround(a);
9744
9355
  }
9745
- function inverse(out, a) {
9746
- out[0] = 1 / a[0];
9747
- out[1] = 1 / a[1];
9748
- out[2] = 1 / a[2];
9749
- return out;
9356
+ function fp64ifyMatrix4(matrix) {
9357
+ const matrixFP64 = new Float32Array(32);
9358
+ for (let i = 0; i < 4; ++i) {
9359
+ for (let j = 0; j < 4; ++j) {
9360
+ const index = i * 4 + j;
9361
+ fp64ify(matrix[j * 4 + i], matrixFP64, index * 2);
9362
+ }
9363
+ }
9364
+ return matrixFP64;
9750
9365
  }
9751
- function normalize(out, a) {
9752
- const x = a[0];
9753
- const y = a[1];
9754
- const z = a[2];
9755
- let len2 = x * x + y * y + z * z;
9756
- if (len2 > 0) {
9757
- len2 = 1 / Math.sqrt(len2);
9366
+
9367
+ // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js
9368
+ var fp64arithmeticShader = glsl2`\
9369
+ uniform float ONE;
9370
+
9371
+ /*
9372
+ About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
9373
+
9374
+ The purpose of this workaround is to prevent shader compilers from
9375
+ optimizing away necessary arithmetic operations by swapping their sequences
9376
+ or transform the equation to some 'equivalent' from.
9377
+
9378
+ The method is to multiply an artifical variable, ONE, which will be known to
9379
+ the compiler to be 1 only at runtime. The whole expression is then represented
9380
+ as a polynomial with respective to ONE. In the coefficients of all terms, only one a
9381
+ and one b should appear
9382
+
9383
+ err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
9384
+ */
9385
+
9386
+ // Divide float number to high and low floats to extend fraction bits
9387
+ vec2 split(float a) {
9388
+ const float SPLIT = 4097.0;
9389
+ float t = a * SPLIT;
9390
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9391
+ float a_hi = t * ONE - (t - a);
9392
+ float a_lo = a * ONE - a_hi;
9393
+ #else
9394
+ float a_hi = t - (t - a);
9395
+ float a_lo = a - a_hi;
9396
+ #endif
9397
+ return vec2(a_hi, a_lo);
9398
+ }
9399
+
9400
+ // Divide float number again when high float uses too many fraction bits
9401
+ vec2 split2(vec2 a) {
9402
+ vec2 b = split(a.x);
9403
+ b.y += a.y;
9404
+ return b;
9405
+ }
9406
+
9407
+ // Special sum operation when a > b
9408
+ vec2 quickTwoSum(float a, float b) {
9409
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9410
+ float sum = (a + b) * ONE;
9411
+ float err = b - (sum - a) * ONE;
9412
+ #else
9413
+ float sum = a + b;
9414
+ float err = b - (sum - a);
9415
+ #endif
9416
+ return vec2(sum, err);
9417
+ }
9418
+
9419
+ // General sum operation
9420
+ vec2 twoSum(float a, float b) {
9421
+ float s = (a + b);
9422
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9423
+ float v = (s * ONE - a) * ONE;
9424
+ float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);
9425
+ #else
9426
+ float v = s - a;
9427
+ float err = (a - (s - v)) + (b - v);
9428
+ #endif
9429
+ return vec2(s, err);
9430
+ }
9431
+
9432
+ vec2 twoSub(float a, float b) {
9433
+ float s = (a - b);
9434
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9435
+ float v = (s * ONE - a) * ONE;
9436
+ float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);
9437
+ #else
9438
+ float v = s - a;
9439
+ float err = (a - (s - v)) - (b + v);
9440
+ #endif
9441
+ return vec2(s, err);
9442
+ }
9443
+
9444
+ vec2 twoSqr(float a) {
9445
+ float prod = a * a;
9446
+ vec2 a_fp64 = split(a);
9447
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9448
+ float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *
9449
+ a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;
9450
+ #else
9451
+ float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
9452
+ #endif
9453
+ return vec2(prod, err);
9454
+ }
9455
+
9456
+ vec2 twoProd(float a, float b) {
9457
+ float prod = a * b;
9458
+ vec2 a_fp64 = split(a);
9459
+ vec2 b_fp64 = split(b);
9460
+ float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
9461
+ a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
9462
+ return vec2(prod, err);
9463
+ }
9464
+
9465
+ vec2 sum_fp64(vec2 a, vec2 b) {
9466
+ vec2 s, t;
9467
+ s = twoSum(a.x, b.x);
9468
+ t = twoSum(a.y, b.y);
9469
+ s.y += t.x;
9470
+ s = quickTwoSum(s.x, s.y);
9471
+ s.y += t.y;
9472
+ s = quickTwoSum(s.x, s.y);
9473
+ return s;
9474
+ }
9475
+
9476
+ vec2 sub_fp64(vec2 a, vec2 b) {
9477
+ vec2 s, t;
9478
+ s = twoSub(a.x, b.x);
9479
+ t = twoSub(a.y, b.y);
9480
+ s.y += t.x;
9481
+ s = quickTwoSum(s.x, s.y);
9482
+ s.y += t.y;
9483
+ s = quickTwoSum(s.x, s.y);
9484
+ return s;
9485
+ }
9486
+
9487
+ vec2 mul_fp64(vec2 a, vec2 b) {
9488
+ vec2 prod = twoProd(a.x, b.x);
9489
+ // y component is for the error
9490
+ prod.y += a.x * b.y;
9491
+ #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
9492
+ prod = split2(prod);
9493
+ #endif
9494
+ prod = quickTwoSum(prod.x, prod.y);
9495
+ prod.y += a.y * b.x;
9496
+ #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
9497
+ prod = split2(prod);
9498
+ #endif
9499
+ prod = quickTwoSum(prod.x, prod.y);
9500
+ return prod;
9501
+ }
9502
+
9503
+ vec2 div_fp64(vec2 a, vec2 b) {
9504
+ float xn = 1.0 / b.x;
9505
+ #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
9506
+ vec2 yn = mul_fp64(a, vec2(xn, 0));
9507
+ #else
9508
+ vec2 yn = a * xn;
9509
+ #endif
9510
+ float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
9511
+ vec2 prod = twoProd(xn, diff);
9512
+ return sum_fp64(yn, prod);
9513
+ }
9514
+
9515
+ vec2 sqrt_fp64(vec2 a) {
9516
+ if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
9517
+ if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
9518
+
9519
+ float x = 1.0 / sqrt(a.x);
9520
+ float yn = a.x * x;
9521
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
9522
+ vec2 yn_sqr = twoSqr(yn) * ONE;
9523
+ #else
9524
+ vec2 yn_sqr = twoSqr(yn);
9525
+ #endif
9526
+ float diff = sub_fp64(a, yn_sqr).x;
9527
+ vec2 prod = twoProd(x * 0.5, diff);
9528
+ #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
9529
+ return sum_fp64(split(yn), prod);
9530
+ #else
9531
+ return sum_fp64(vec2(yn, 0.0), prod);
9532
+ #endif
9533
+ }
9534
+ `;
9535
+
9536
+ // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js
9537
+ var fp64functionShader = glsl2`\
9538
+ const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
9539
+ const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
9540
+ const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
9541
+ const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
9542
+ const vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8);
9543
+ const vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8);
9544
+ const vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9);
9545
+ const vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8);
9546
+ const vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9);
9547
+ const vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10);
9548
+
9549
+ const vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9);
9550
+ const vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9);
9551
+ const vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8);
9552
+ const vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8);
9553
+
9554
+ const vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8);
9555
+ const vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8);
9556
+ const vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8);
9557
+ const vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8);
9558
+
9559
+ const vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09); // 1/3!
9560
+ const vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09); // 1/4!
9561
+ const vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10); // 1/5!
9562
+ const vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11); // 1/6!
9563
+ const vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12); // 1/7!
9564
+ const vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13); // 1/8!
9565
+ const vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14); // 1/9!
9566
+ const vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15); // 1/10!
9567
+
9568
+ float nint(float d) {
9569
+ if (d == floor(d)) return d;
9570
+ return floor(d + 0.5);
9571
+ }
9572
+
9573
+ vec2 nint_fp64(vec2 a) {
9574
+ float hi = nint(a.x);
9575
+ float lo;
9576
+ vec2 tmp;
9577
+ if (hi == a.x) {
9578
+ lo = nint(a.y);
9579
+ tmp = quickTwoSum(hi, lo);
9580
+ } else {
9581
+ lo = 0.0;
9582
+ if (abs(hi - a.x) == 0.5 && a.y < 0.0) {
9583
+ hi -= 1.0;
9584
+ }
9585
+ tmp = vec2(hi, lo);
9758
9586
  }
9759
- out[0] = a[0] * len2;
9760
- out[1] = a[1] * len2;
9761
- out[2] = a[2] * len2;
9762
- return out;
9763
- }
9764
- function dot(a, b) {
9765
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
9766
- }
9767
- function cross(out, a, b) {
9768
- const ax = a[0];
9769
- const ay = a[1];
9770
- const az = a[2];
9771
- const bx = b[0];
9772
- const by = b[1];
9773
- const bz = b[2];
9774
- out[0] = ay * bz - az * by;
9775
- out[1] = az * bx - ax * bz;
9776
- out[2] = ax * by - ay * bx;
9777
- return out;
9778
- }
9779
- function lerp(out, a, b, t) {
9780
- const ax = a[0];
9781
- const ay = a[1];
9782
- const az = a[2];
9783
- out[0] = ax + t * (b[0] - ax);
9784
- out[1] = ay + t * (b[1] - ay);
9785
- out[2] = az + t * (b[2] - az);
9786
- return out;
9787
- }
9788
- function slerp(out, a, b, t) {
9789
- const angle2 = Math.acos(Math.min(Math.max(dot(a, b), -1), 1));
9790
- const sinTotal = Math.sin(angle2);
9791
- const ratioA = Math.sin((1 - t) * angle2) / sinTotal;
9792
- const ratioB = Math.sin(t * angle2) / sinTotal;
9793
- out[0] = ratioA * a[0] + ratioB * b[0];
9794
- out[1] = ratioA * a[1] + ratioB * b[1];
9795
- out[2] = ratioA * a[2] + ratioB * b[2];
9796
- return out;
9797
- }
9798
- function hermite(out, a, b, c, d, t) {
9799
- const factorTimes2 = t * t;
9800
- const factor1 = factorTimes2 * (2 * t - 3) + 1;
9801
- const factor2 = factorTimes2 * (t - 2) + t;
9802
- const factor3 = factorTimes2 * (t - 1);
9803
- const factor4 = factorTimes2 * (3 - 2 * t);
9804
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
9805
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
9806
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
9807
- return out;
9808
- }
9809
- function bezier(out, a, b, c, d, t) {
9810
- const inverseFactor = 1 - t;
9811
- const inverseFactorTimesTwo = inverseFactor * inverseFactor;
9812
- const factorTimes2 = t * t;
9813
- const factor1 = inverseFactorTimesTwo * inverseFactor;
9814
- const factor2 = 3 * t * inverseFactorTimesTwo;
9815
- const factor3 = 3 * factorTimes2 * inverseFactor;
9816
- const factor4 = factorTimes2 * t;
9817
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
9818
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
9819
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
9820
- return out;
9821
- }
9822
- function random(out, scale2) {
9823
- scale2 = scale2 === void 0 ? 1 : scale2;
9824
- const r = RANDOM() * 2 * Math.PI;
9825
- const z = RANDOM() * 2 - 1;
9826
- const zScale = Math.sqrt(1 - z * z) * scale2;
9827
- out[0] = Math.cos(r) * zScale;
9828
- out[1] = Math.sin(r) * zScale;
9829
- out[2] = z * scale2;
9830
- return out;
9831
- }
9832
- function transformMat4(out, a, m) {
9833
- const x = a[0];
9834
- const y = a[1];
9835
- const z = a[2];
9836
- let w = m[3] * x + m[7] * y + m[11] * z + m[15];
9837
- w = w || 1;
9838
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
9839
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
9840
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
9841
- return out;
9842
- }
9843
- function transformMat3(out, a, m) {
9844
- const x = a[0];
9845
- const y = a[1];
9846
- const z = a[2];
9847
- out[0] = x * m[0] + y * m[3] + z * m[6];
9848
- out[1] = x * m[1] + y * m[4] + z * m[7];
9849
- out[2] = x * m[2] + y * m[5] + z * m[8];
9850
- return out;
9851
- }
9852
- function transformQuat(out, a, q) {
9853
- const qx = q[0];
9854
- const qy = q[1];
9855
- const qz = q[2];
9856
- const qw = q[3];
9857
- const x = a[0];
9858
- const y = a[1];
9859
- const z = a[2];
9860
- let uvx = qy * z - qz * y;
9861
- let uvy = qz * x - qx * z;
9862
- let uvz = qx * y - qy * x;
9863
- let uuvx = qy * uvz - qz * uvy;
9864
- let uuvy = qz * uvx - qx * uvz;
9865
- let uuvz = qx * uvy - qy * uvx;
9866
- const w2 = qw * 2;
9867
- uvx *= w2;
9868
- uvy *= w2;
9869
- uvz *= w2;
9870
- uuvx *= 2;
9871
- uuvy *= 2;
9872
- uuvz *= 2;
9873
- out[0] = x + uvx + uuvx;
9874
- out[1] = y + uvy + uuvy;
9875
- out[2] = z + uvz + uuvz;
9876
- return out;
9877
- }
9878
- function rotateX(out, a, b, rad) {
9879
- const p = [];
9880
- const r = [];
9881
- p[0] = a[0] - b[0];
9882
- p[1] = a[1] - b[1];
9883
- p[2] = a[2] - b[2];
9884
- r[0] = p[0];
9885
- r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);
9886
- r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);
9887
- out[0] = r[0] + b[0];
9888
- out[1] = r[1] + b[1];
9889
- out[2] = r[2] + b[2];
9890
- return out;
9891
- }
9892
- function rotateY(out, a, b, rad) {
9893
- const p = [];
9894
- const r = [];
9895
- p[0] = a[0] - b[0];
9896
- p[1] = a[1] - b[1];
9897
- p[2] = a[2] - b[2];
9898
- r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);
9899
- r[1] = p[1];
9900
- r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);
9901
- out[0] = r[0] + b[0];
9902
- out[1] = r[1] + b[1];
9903
- out[2] = r[2] + b[2];
9904
- return out;
9905
- }
9906
- function rotateZ(out, a, b, rad) {
9907
- const p = [];
9908
- const r = [];
9909
- p[0] = a[0] - b[0];
9910
- p[1] = a[1] - b[1];
9911
- p[2] = a[2] - b[2];
9912
- r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);
9913
- r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);
9914
- r[2] = p[2];
9915
- out[0] = r[0] + b[0];
9916
- out[1] = r[1] + b[1];
9917
- out[2] = r[2] + b[2];
9918
- return out;
9919
- }
9920
- function angle(a, b) {
9921
- const ax = a[0];
9922
- const ay = a[1];
9923
- const az = a[2];
9924
- const bx = b[0];
9925
- const by = b[1];
9926
- const bz = b[2];
9927
- const mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz));
9928
- const cosine = mag && dot(a, b) / mag;
9929
- return Math.acos(Math.min(Math.max(cosine, -1), 1));
9930
- }
9931
- function zero(out) {
9932
- out[0] = 0;
9933
- out[1] = 0;
9934
- out[2] = 0;
9935
- return out;
9587
+ return tmp;
9588
+ }
9589
+
9590
+ /* k_power controls how much range reduction we would like to have
9591
+ Range reduction uses the following method:
9592
+ assume a = k_power * r + m * log(2), k and m being integers.
9593
+ Set k_power = 4 (we can choose other k to trade accuracy with performance.
9594
+ we only need to calculate exp(r) and using exp(a) = 2^m * exp(r)^k_power;
9595
+ */
9596
+
9597
+ vec2 exp_fp64(vec2 a) {
9598
+ // We need to make sure these two numbers match
9599
+ // as bit-wise shift is not available in GLSL 1.0
9600
+ const int k_power = 4;
9601
+ const float k = 16.0;
9602
+
9603
+ const float inv_k = 1.0 / k;
9604
+
9605
+ if (a.x <= -88.0) return vec2(0.0, 0.0);
9606
+ if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0);
9607
+ if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0);
9608
+ if (a.x == 1.0 && a.y == 0.0) return E_FP64;
9609
+
9610
+ float m = floor(a.x / LOG2_FP64.x + 0.5);
9611
+ vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k;
9612
+ vec2 s, t, p;
9613
+
9614
+ p = mul_fp64(r, r);
9615
+ s = sum_fp64(r, p * 0.5);
9616
+ p = mul_fp64(p, r);
9617
+ t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64);
9618
+
9619
+ s = sum_fp64(s, t);
9620
+ p = mul_fp64(p, r);
9621
+ t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64);
9622
+
9623
+ s = sum_fp64(s, t);
9624
+ p = mul_fp64(p, r);
9625
+ t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64);
9626
+
9627
+ // s = sum_fp64(s, t);
9628
+ // p = mul_fp64(p, r);
9629
+ // t = mul_fp64(p, INVERSE_FACTORIAL_6_FP64);
9630
+
9631
+ // s = sum_fp64(s, t);
9632
+ // p = mul_fp64(p, r);
9633
+ // t = mul_fp64(p, INVERSE_FACTORIAL_7_FP64);
9634
+
9635
+ s = sum_fp64(s, t);
9636
+
9637
+
9638
+ // At this point, s = exp(r) - 1; but after following 4 recursions, we will get exp(r) ^ 512 - 1.
9639
+ for (int i = 0; i < k_power; i++) {
9640
+ s = sum_fp64(s * 2.0, mul_fp64(s, s));
9936
9641
  }
9937
- function str(a) {
9938
- return "vec3(".concat(a[0], ", ").concat(a[1], ", ").concat(a[2], ")");
9642
+
9643
+ #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9644
+ s = sum_fp64(s, vec2(ONE, 0.0));
9645
+ #else
9646
+ s = sum_fp64(s, vec2(1.0, 0.0));
9647
+ #endif
9648
+
9649
+ return s * pow(2.0, m);
9650
+ // return r;
9651
+ }
9652
+
9653
+ vec2 log_fp64(vec2 a)
9654
+ {
9655
+ if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0);
9656
+ if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
9657
+ vec2 x = vec2(log(a.x), 0.0);
9658
+ vec2 s;
9659
+ #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9660
+ s = vec2(ONE, 0.0);
9661
+ #else
9662
+ s = vec2(1.0, 0.0);
9663
+ #endif
9664
+
9665
+ x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s);
9666
+ return x;
9667
+ }
9668
+
9669
+ vec2 sin_taylor_fp64(vec2 a) {
9670
+ vec2 r, s, t, x;
9671
+
9672
+ if (a.x == 0.0 && a.y == 0.0) {
9673
+ return vec2(0.0, 0.0);
9939
9674
  }
9940
- function exactEquals(a, b) {
9941
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
9675
+
9676
+ x = -mul_fp64(a, a);
9677
+ s = a;
9678
+ r = a;
9679
+
9680
+ r = mul_fp64(r, x);
9681
+ t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64);
9682
+ s = sum_fp64(s, t);
9683
+
9684
+ r = mul_fp64(r, x);
9685
+ t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64);
9686
+ s = sum_fp64(s, t);
9687
+
9688
+ /* keep the following commented code in case we need them
9689
+ for extra accuracy from the Taylor expansion*/
9690
+
9691
+ // r = mul_fp64(r, x);
9692
+ // t = mul_fp64(r, INVERSE_FACTORIAL_7_FP64);
9693
+ // s = sum_fp64(s, t);
9694
+
9695
+ // r = mul_fp64(r, x);
9696
+ // t = mul_fp64(r, INVERSE_FACTORIAL_9_FP64);
9697
+ // s = sum_fp64(s, t);
9698
+
9699
+ return s;
9700
+ }
9701
+
9702
+ vec2 cos_taylor_fp64(vec2 a) {
9703
+ vec2 r, s, t, x;
9704
+
9705
+ if (a.x == 0.0 && a.y == 0.0) {
9706
+ return vec2(1.0, 0.0);
9942
9707
  }
9943
- function equals2(a, b) {
9944
- const a0 = a[0];
9945
- const a1 = a[1];
9946
- const a2 = a[2];
9947
- const b0 = b[0];
9948
- const b1 = b[1];
9949
- const b2 = b[2];
9950
- return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2));
9708
+
9709
+ x = -mul_fp64(a, a);
9710
+ r = x;
9711
+ s = sum_fp64(vec2(1.0, 0.0), r * 0.5);
9712
+
9713
+ r = mul_fp64(r, x);
9714
+ t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64);
9715
+ s = sum_fp64(s, t);
9716
+
9717
+ r = mul_fp64(r, x);
9718
+ t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64);
9719
+ s = sum_fp64(s, t);
9720
+
9721
+ /* keep the following commented code in case we need them
9722
+ for extra accuracy from the Taylor expansion*/
9723
+
9724
+ // r = mul_fp64(r, x);
9725
+ // t = mul_fp64(r, INVERSE_FACTORIAL_8_FP64);
9726
+ // s = sum_fp64(s, t);
9727
+
9728
+ // r = mul_fp64(r, x);
9729
+ // t = mul_fp64(r, INVERSE_FACTORIAL_10_FP64);
9730
+ // s = sum_fp64(s, t);
9731
+
9732
+ return s;
9733
+ }
9734
+
9735
+ void sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) {
9736
+ if (a.x == 0.0 && a.y == 0.0) {
9737
+ sin_t = vec2(0.0, 0.0);
9738
+ cos_t = vec2(1.0, 0.0);
9951
9739
  }
9952
- var sub = subtract;
9953
- var mul = multiply;
9954
- var div = divide;
9955
- var dist = distance;
9956
- var sqrDist = squaredDistance;
9957
- var len = length;
9958
- var sqrLen = squaredLength;
9959
- var forEach = function() {
9960
- const vec = create();
9961
- return function(a, stride, offset, count, fn, arg) {
9962
- let i;
9963
- let l;
9964
- if (!stride) {
9965
- stride = 3;
9966
- }
9967
- if (!offset) {
9968
- offset = 0;
9969
- }
9970
- if (count) {
9971
- l = Math.min(count * stride + offset, a.length);
9972
- } else {
9973
- l = a.length;
9974
- }
9975
- for (i = offset; i < l; i += stride) {
9976
- vec[0] = a[i];
9977
- vec[1] = a[i + 1];
9978
- vec[2] = a[i + 2];
9979
- fn(vec, vec, arg);
9980
- a[i] = vec[0];
9981
- a[i + 1] = vec[1];
9982
- a[i + 2] = vec[2];
9983
- }
9984
- return a;
9985
- };
9986
- }();
9987
9740
 
9988
- // ../../node_modules/@luma.gl/engine/dist/geometry/gpu-geometry.js
9989
- var import_core34 = __toESM(require_core2(), 1);
9990
- var GPUGeometry = class {
9991
- constructor(props) {
9992
- this.id = void 0;
9993
- this.userData = {};
9994
- this.topology = void 0;
9995
- this.bufferLayout = [];
9996
- this.vertexCount = void 0;
9997
- this.indices = void 0;
9998
- this.attributes = void 0;
9999
- this.id = props.id || (0, import_core34.uid)("geometry");
10000
- this.topology = props.topology;
10001
- this.indices = props.indices || null;
10002
- this.attributes = props.attributes;
10003
- this.vertexCount = props.vertexCount;
10004
- this.bufferLayout = props.bufferLayout || [];
10005
- if (this.indices) {
10006
- (0, import_core34.assert)(this.indices.usage === import_core34.Buffer.INDEX);
10007
- }
10008
- }
10009
- destroy() {
10010
- var _this$attributes$colo;
10011
- this.indices.destroy();
10012
- this.attributes.positions.destroy();
10013
- this.attributes.normals.destroy();
10014
- this.attributes.texCoords.destroy();
10015
- (_this$attributes$colo = this.attributes.colors) === null || _this$attributes$colo === void 0 ? void 0 : _this$attributes$colo.destroy();
10016
- }
10017
- getVertexCount() {
10018
- return this.vertexCount;
10019
- }
10020
- getAttributes() {
10021
- return this.attributes;
10022
- }
10023
- getIndexes() {
10024
- return this.indices;
10025
- }
10026
- _calculateVertexCount(positions) {
10027
- const vertexCount = positions.byteLength / 12;
10028
- return vertexCount;
10029
- }
10030
- };
10031
- function makeGPUGeometry(device, geometry) {
10032
- if (geometry instanceof GPUGeometry) {
10033
- return geometry;
10034
- }
10035
- const indices = getIndexBufferFromGeometry(device, geometry);
10036
- const {
10037
- attributes,
10038
- bufferLayout
10039
- } = getAttributeBuffersFromGeometry(device, geometry);
10040
- return new GPUGeometry({
10041
- topology: geometry.topology || "triangle-list",
10042
- bufferLayout,
10043
- vertexCount: geometry.vertexCount,
10044
- indices,
10045
- attributes
10046
- });
9741
+ sin_t = sin_taylor_fp64(a);
9742
+ cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t)));
9743
+ }
9744
+
9745
+ vec2 sin_fp64(vec2 a) {
9746
+ if (a.x == 0.0 && a.y == 0.0) {
9747
+ return vec2(0.0, 0.0);
9748
+ }
9749
+
9750
+ // 2pi range reduction
9751
+ vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9752
+ vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9753
+
9754
+ vec2 t;
9755
+ float q = floor(r.x / PI_2_FP64.x + 0.5);
9756
+ int j = int(q);
9757
+
9758
+ if (j < -2 || j > 2) {
9759
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9760
+ }
9761
+
9762
+ t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9763
+
9764
+ q = floor(t.x / PI_16_FP64.x + 0.5);
9765
+ int k = int(q);
9766
+
9767
+ if (k == 0) {
9768
+ if (j == 0) {
9769
+ return sin_taylor_fp64(t);
9770
+ } else if (j == 1) {
9771
+ return cos_taylor_fp64(t);
9772
+ } else if (j == -1) {
9773
+ return -cos_taylor_fp64(t);
9774
+ } else {
9775
+ return -sin_taylor_fp64(t);
9776
+ }
9777
+ }
9778
+
9779
+ int abs_k = int(abs(float(k)));
9780
+
9781
+ if (abs_k > 4) {
9782
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9783
+ } else {
9784
+ t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
9785
+ }
9786
+
9787
+ vec2 u = vec2(0.0, 0.0);
9788
+ vec2 v = vec2(0.0, 0.0);
9789
+
9790
+ #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9791
+ if (abs(float(abs_k) - 1.0) < 0.5) {
9792
+ u = COS_TABLE_0_FP64;
9793
+ v = SIN_TABLE_0_FP64;
9794
+ } else if (abs(float(abs_k) - 2.0) < 0.5) {
9795
+ u = COS_TABLE_1_FP64;
9796
+ v = SIN_TABLE_1_FP64;
9797
+ } else if (abs(float(abs_k) - 3.0) < 0.5) {
9798
+ u = COS_TABLE_2_FP64;
9799
+ v = SIN_TABLE_2_FP64;
9800
+ } else if (abs(float(abs_k) - 4.0) < 0.5) {
9801
+ u = COS_TABLE_3_FP64;
9802
+ v = SIN_TABLE_3_FP64;
9803
+ }
9804
+ #else
9805
+ if (abs_k == 1) {
9806
+ u = COS_TABLE_0_FP64;
9807
+ v = SIN_TABLE_0_FP64;
9808
+ } else if (abs_k == 2) {
9809
+ u = COS_TABLE_1_FP64;
9810
+ v = SIN_TABLE_1_FP64;
9811
+ } else if (abs_k == 3) {
9812
+ u = COS_TABLE_2_FP64;
9813
+ v = SIN_TABLE_2_FP64;
9814
+ } else if (abs_k == 4) {
9815
+ u = COS_TABLE_3_FP64;
9816
+ v = SIN_TABLE_3_FP64;
9817
+ }
9818
+ #endif
9819
+
9820
+ vec2 sin_t, cos_t;
9821
+ sincos_taylor_fp64(t, sin_t, cos_t);
9822
+
9823
+
9824
+
9825
+ vec2 result = vec2(0.0, 0.0);
9826
+ if (j == 0) {
9827
+ if (k > 0) {
9828
+ result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9829
+ } else {
9830
+ result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9831
+ }
9832
+ } else if (j == 1) {
9833
+ if (k > 0) {
9834
+ result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9835
+ } else {
9836
+ result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9837
+ }
9838
+ } else if (j == -1) {
9839
+ if (k > 0) {
9840
+ result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9841
+ } else {
9842
+ result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9843
+ }
9844
+ } else {
9845
+ if (k > 0) {
9846
+ result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9847
+ } else {
9848
+ result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
9849
+ }
9850
+ }
9851
+
9852
+ return result;
9853
+ }
9854
+
9855
+ vec2 cos_fp64(vec2 a) {
9856
+ if (a.x == 0.0 && a.y == 0.0) {
9857
+ return vec2(1.0, 0.0);
9858
+ }
9859
+
9860
+ // 2pi range reduction
9861
+ vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9862
+ vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9863
+
9864
+ vec2 t;
9865
+ float q = floor(r.x / PI_2_FP64.x + 0.5);
9866
+ int j = int(q);
9867
+
9868
+ if (j < -2 || j > 2) {
9869
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9870
+ }
9871
+
9872
+ t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9873
+
9874
+ q = floor(t.x / PI_16_FP64.x + 0.5);
9875
+ int k = int(q);
9876
+
9877
+ if (k == 0) {
9878
+ if (j == 0) {
9879
+ return cos_taylor_fp64(t);
9880
+ } else if (j == 1) {
9881
+ return -sin_taylor_fp64(t);
9882
+ } else if (j == -1) {
9883
+ return sin_taylor_fp64(t);
9884
+ } else {
9885
+ return -cos_taylor_fp64(t);
9886
+ }
9887
+ }
9888
+
9889
+ int abs_k = int(abs(float(k)));
9890
+
9891
+ if (abs_k > 4) {
9892
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9893
+ } else {
9894
+ t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
9895
+ }
9896
+
9897
+ vec2 u = vec2(0.0, 0.0);
9898
+ vec2 v = vec2(0.0, 0.0);
9899
+
9900
+ #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
9901
+ if (abs(float(abs_k) - 1.0) < 0.5) {
9902
+ u = COS_TABLE_0_FP64;
9903
+ v = SIN_TABLE_0_FP64;
9904
+ } else if (abs(float(abs_k) - 2.0) < 0.5) {
9905
+ u = COS_TABLE_1_FP64;
9906
+ v = SIN_TABLE_1_FP64;
9907
+ } else if (abs(float(abs_k) - 3.0) < 0.5) {
9908
+ u = COS_TABLE_2_FP64;
9909
+ v = SIN_TABLE_2_FP64;
9910
+ } else if (abs(float(abs_k) - 4.0) < 0.5) {
9911
+ u = COS_TABLE_3_FP64;
9912
+ v = SIN_TABLE_3_FP64;
9913
+ }
9914
+ #else
9915
+ if (abs_k == 1) {
9916
+ u = COS_TABLE_0_FP64;
9917
+ v = SIN_TABLE_0_FP64;
9918
+ } else if (abs_k == 2) {
9919
+ u = COS_TABLE_1_FP64;
9920
+ v = SIN_TABLE_1_FP64;
9921
+ } else if (abs_k == 3) {
9922
+ u = COS_TABLE_2_FP64;
9923
+ v = SIN_TABLE_2_FP64;
9924
+ } else if (abs_k == 4) {
9925
+ u = COS_TABLE_3_FP64;
9926
+ v = SIN_TABLE_3_FP64;
9927
+ }
9928
+ #endif
9929
+
9930
+ vec2 sin_t, cos_t;
9931
+ sincos_taylor_fp64(t, sin_t, cos_t);
9932
+
9933
+ vec2 result = vec2(0.0, 0.0);
9934
+ if (j == 0) {
9935
+ if (k > 0) {
9936
+ result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9937
+ } else {
9938
+ result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9939
+ }
9940
+ } else if (j == 1) {
9941
+ if (k > 0) {
9942
+ result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9943
+ } else {
9944
+ result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
9945
+ }
9946
+ } else if (j == -1) {
9947
+ if (k > 0) {
9948
+ result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9949
+ } else {
9950
+ result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
9951
+ }
9952
+ } else {
9953
+ if (k > 0) {
9954
+ result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
9955
+ } else {
9956
+ result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
9957
+ }
9958
+ }
9959
+
9960
+ return result;
9961
+ }
9962
+
9963
+ vec2 tan_fp64(vec2 a) {
9964
+ vec2 sin_a;
9965
+ vec2 cos_a;
9966
+
9967
+ if (a.x == 0.0 && a.y == 0.0) {
9968
+ return vec2(0.0, 0.0);
9969
+ }
9970
+
9971
+ // 2pi range reduction
9972
+ vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
9973
+ vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
9974
+
9975
+ vec2 t;
9976
+ float q = floor(r.x / PI_2_FP64.x + 0.5);
9977
+ int j = int(q);
9978
+
9979
+
9980
+ if (j < -2 || j > 2) {
9981
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9982
+ }
9983
+
9984
+ t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
9985
+
9986
+ q = floor(t.x / PI_16_FP64.x + 0.5);
9987
+ int k = int(q);
9988
+ int abs_k = int(abs(float(k)));
9989
+
9990
+ // We just can't get PI/16 * 3.0 very accurately.
9991
+ // so let's just store it
9992
+ if (abs_k > 4) {
9993
+ return vec2(0.0 / 0.0, 0.0 / 0.0);
9994
+ } else {
9995
+ t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
9996
+ }
9997
+
9998
+
9999
+ vec2 u = vec2(0.0, 0.0);
10000
+ vec2 v = vec2(0.0, 0.0);
10001
+
10002
+ vec2 sin_t, cos_t;
10003
+ vec2 s, c;
10004
+ sincos_taylor_fp64(t, sin_t, cos_t);
10005
+
10006
+ if (k == 0) {
10007
+ s = sin_t;
10008
+ c = cos_t;
10009
+ } else {
10010
+ #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
10011
+ if (abs(float(abs_k) - 1.0) < 0.5) {
10012
+ u = COS_TABLE_0_FP64;
10013
+ v = SIN_TABLE_0_FP64;
10014
+ } else if (abs(float(abs_k) - 2.0) < 0.5) {
10015
+ u = COS_TABLE_1_FP64;
10016
+ v = SIN_TABLE_1_FP64;
10017
+ } else if (abs(float(abs_k) - 3.0) < 0.5) {
10018
+ u = COS_TABLE_2_FP64;
10019
+ v = SIN_TABLE_2_FP64;
10020
+ } else if (abs(float(abs_k) - 4.0) < 0.5) {
10021
+ u = COS_TABLE_3_FP64;
10022
+ v = SIN_TABLE_3_FP64;
10023
+ }
10024
+ #else
10025
+ if (abs_k == 1) {
10026
+ u = COS_TABLE_0_FP64;
10027
+ v = SIN_TABLE_0_FP64;
10028
+ } else if (abs_k == 2) {
10029
+ u = COS_TABLE_1_FP64;
10030
+ v = SIN_TABLE_1_FP64;
10031
+ } else if (abs_k == 3) {
10032
+ u = COS_TABLE_2_FP64;
10033
+ v = SIN_TABLE_2_FP64;
10034
+ } else if (abs_k == 4) {
10035
+ u = COS_TABLE_3_FP64;
10036
+ v = SIN_TABLE_3_FP64;
10037
+ }
10038
+ #endif
10039
+ if (k > 0) {
10040
+ s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
10041
+ c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
10042
+ } else {
10043
+ s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
10044
+ c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
10045
+ }
10046
+ }
10047
+
10048
+ if (j == 0) {
10049
+ sin_a = s;
10050
+ cos_a = c;
10051
+ } else if (j == 1) {
10052
+ sin_a = c;
10053
+ cos_a = -s;
10054
+ } else if (j == -1) {
10055
+ sin_a = -c;
10056
+ cos_a = s;
10057
+ } else {
10058
+ sin_a = -s;
10059
+ cos_a = -c;
10060
+ }
10061
+ return div_fp64(sin_a, cos_a);
10062
+ }
10063
+
10064
+ vec2 radians_fp64(vec2 degree) {
10065
+ return mul_fp64(degree, PI_180_FP64);
10066
+ }
10067
+
10068
+ vec2 mix_fp64(vec2 a, vec2 b, float x) {
10069
+ vec2 range = sub_fp64(b, a);
10070
+ return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));
10071
+ }
10072
+
10073
+ // Vector functions
10074
+ // vec2 functions
10075
+ void vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
10076
+ out_val[0] = sum_fp64(a[0], b[0]);
10077
+ out_val[1] = sum_fp64(a[1], b[1]);
10078
+ }
10079
+
10080
+ void vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
10081
+ out_val[0] = sub_fp64(a[0], b[0]);
10082
+ out_val[1] = sub_fp64(a[1], b[1]);
10083
+ }
10084
+
10085
+ void vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
10086
+ out_val[0] = mul_fp64(a[0], b[0]);
10087
+ out_val[1] = mul_fp64(a[1], b[1]);
10088
+ }
10089
+
10090
+ void vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
10091
+ out_val[0] = div_fp64(a[0], b[0]);
10092
+ out_val[1] = div_fp64(a[1], b[1]);
10093
+ }
10094
+
10095
+ void vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) {
10096
+ vec2 range[2];
10097
+ vec2_sub_fp64(y, x, range);
10098
+ vec2 portion[2];
10099
+ portion[0] = range[0] * a;
10100
+ portion[1] = range[1] * a;
10101
+ vec2_sum_fp64(x, portion, out_val);
10102
+ }
10103
+
10104
+ vec2 vec2_length_fp64(vec2 x[2]) {
10105
+ return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])));
10106
+ }
10107
+
10108
+ void vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) {
10109
+ vec2 length = vec2_length_fp64(x);
10110
+ vec2 length_vec2[2];
10111
+ length_vec2[0] = length;
10112
+ length_vec2[1] = length;
10113
+
10114
+ vec2_div_fp64(x, length_vec2, out_val);
10115
+ }
10116
+
10117
+ vec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) {
10118
+ vec2 diff[2];
10119
+ vec2_sub_fp64(x, y, diff);
10120
+ return vec2_length_fp64(diff);
10121
+ }
10122
+
10123
+ vec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) {
10124
+ vec2 v[2];
10125
+
10126
+ v[0] = mul_fp64(a[0], b[0]);
10127
+ v[1] = mul_fp64(a[1], b[1]);
10128
+
10129
+ return sum_fp64(v[0], v[1]);
10130
+ }
10131
+
10132
+ // vec3 functions
10133
+ void vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
10134
+ for (int i = 0; i < 3; i++) {
10135
+ out_val[i] = sum_fp64(a[i], b[i]);
10047
10136
  }
10048
- function getIndexBufferFromGeometry(device, geometry) {
10049
- if (!geometry.indices) {
10050
- return void 0;
10051
- }
10052
- const data = geometry.indices.value;
10053
- return device.createBuffer({
10054
- usage: import_core34.Buffer.INDEX,
10055
- data
10056
- });
10137
+ }
10138
+
10139
+ void vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
10140
+ for (int i = 0; i < 3; i++) {
10141
+ out_val[i] = sum_fp64(a[i], b[i]);
10057
10142
  }
10058
- function getAttributeBuffersFromGeometry(device, geometry) {
10059
- const bufferLayout = [];
10060
- const attributes = {};
10061
- for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
10062
- let name = attributeName;
10063
- switch (attributeName) {
10064
- case "POSITION":
10065
- name = "positions";
10066
- break;
10067
- case "NORMAL":
10068
- name = "normals";
10069
- break;
10070
- case "TEXCOORD_0":
10071
- name = "texCoords";
10072
- break;
10073
- }
10074
- attributes[name] = device.createBuffer({
10075
- data: attribute.value,
10076
- id: `${attributeName}-buffer`
10077
- });
10078
- bufferLayout.push({
10079
- name,
10080
- format: `float32x${attribute.size}`
10081
- });
10082
- }
10083
- const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices);
10084
- return {
10085
- attributes,
10086
- bufferLayout,
10087
- vertexCount
10088
- };
10143
+ }
10144
+
10145
+ vec2 vec3_length_fp64(vec2 x[3]) {
10146
+ return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])),
10147
+ mul_fp64(x[2], x[2])));
10148
+ }
10149
+
10150
+ vec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) {
10151
+ vec2 diff[3];
10152
+ vec3_sub_fp64(x, y, diff);
10153
+ return vec3_length_fp64(diff);
10154
+ }
10155
+
10156
+ // vec4 functions
10157
+ void vec4_fp64(vec4 a, out vec2 out_val[4]) {
10158
+ out_val[0].x = a[0];
10159
+ out_val[0].y = 0.0;
10160
+
10161
+ out_val[1].x = a[1];
10162
+ out_val[1].y = 0.0;
10163
+
10164
+ out_val[2].x = a[2];
10165
+ out_val[2].y = 0.0;
10166
+
10167
+ out_val[3].x = a[3];
10168
+ out_val[3].y = 0.0;
10169
+ }
10170
+
10171
+ void vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) {
10172
+ out_val[0] = mul_fp64(a[0], b);
10173
+ out_val[1] = mul_fp64(a[1], b);
10174
+ out_val[2] = mul_fp64(a[2], b);
10175
+ out_val[3] = mul_fp64(a[3], b);
10176
+ }
10177
+
10178
+ void vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) {
10179
+ for (int i = 0; i < 4; i++) {
10180
+ out_val[i] = sum_fp64(a[i], b[i]);
10089
10181
  }
10182
+ }
10090
10183
 
10091
- // ../../node_modules/@luma.gl/engine/dist/lib/pipeline-factory.js
10092
- var import_core35 = __toESM(require_core2(), 1);
10093
- var PipelineFactory = class {
10094
- static getDefaultPipelineFactory(device) {
10095
- device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
10096
- return device._lumaData.defaultPipelineFactory;
10097
- }
10098
- constructor(device) {
10099
- this.device = void 0;
10100
- this._hashCounter = 0;
10101
- this._hashes = {};
10102
- this._useCounts = {};
10103
- this._pipelineCache = {};
10104
- this.device = device;
10105
- }
10106
- createRenderPipeline(options) {
10107
- const props = {
10108
- ...PipelineFactory.defaultProps,
10109
- ...options
10110
- };
10111
- const hash = this._hashRenderPipeline({
10112
- ...props
10113
- });
10114
- if (!this._pipelineCache[hash]) {
10115
- const pipeline = this.device.createRenderPipeline({
10116
- ...props,
10117
- vs: this.device.createShader({
10118
- stage: "vertex",
10119
- source: props.vs
10120
- }),
10121
- fs: props.fs ? this.device.createShader({
10122
- stage: "fragment",
10123
- source: props.fs
10124
- }) : null
10125
- });
10126
- pipeline.hash = hash;
10127
- this._pipelineCache[hash] = pipeline;
10128
- this._useCounts[hash] = 0;
10129
- }
10130
- this._useCounts[hash]++;
10131
- return this._pipelineCache[hash];
10132
- }
10133
- release(pipeline) {
10134
- const hash = pipeline.hash;
10135
- this._useCounts[hash]--;
10136
- if (this._useCounts[hash] === 0) {
10137
- this._pipelineCache[hash].destroy();
10138
- delete this._pipelineCache[hash];
10139
- delete this._useCounts[hash];
10140
- }
10141
- }
10142
- _createRenderPipeline(props) {
10143
- if (!props.fs) {
10144
- throw new Error("fs");
10145
- }
10146
- const pipeline = this.device.createRenderPipeline({
10147
- ...props,
10148
- vs: this.device.createShader({
10149
- stage: "vertex",
10150
- source: props.vs
10151
- }),
10152
- fs: props.fs ? this.device.createShader({
10153
- stage: "fragment",
10154
- source: props.fs
10155
- }) : null
10156
- });
10157
- return pipeline;
10158
- }
10159
- _hashRenderPipeline(props) {
10160
- const vsHash = this._getHash(props.vs);
10161
- const fsHash = props.fs ? this._getHash(props.fs) : 0;
10162
- const varyingHash = "-";
10163
- switch (this.device.info.type) {
10164
- case "webgpu":
10165
- const parameterHash = this._getHash(JSON.stringify(props.parameters));
10166
- const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
10167
- return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
10168
- default:
10169
- return `${vsHash}/${fsHash}V${varyingHash}`;
10170
- }
10171
- }
10172
- _getHash(key) {
10173
- if (this._hashes[key] === void 0) {
10174
- this._hashes[key] = this._hashCounter++;
10175
- }
10176
- return this._hashes[key];
10184
+ void vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) {
10185
+ vec2 v[4];
10186
+
10187
+ v[0] = mul_fp64(a[0], b[0]);
10188
+ v[1] = mul_fp64(a[1], b[1]);
10189
+ v[2] = mul_fp64(a[2], b[2]);
10190
+ v[3] = mul_fp64(a[3], b[3]);
10191
+
10192
+ out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3]));
10193
+ }
10194
+
10195
+ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
10196
+ vec2 tmp[4];
10197
+
10198
+ for (int i = 0; i < 4; i++)
10199
+ {
10200
+ for (int j = 0; j < 4; j++)
10201
+ {
10202
+ tmp[j] = b[j + i * 4];
10177
10203
  }
10204
+ vec4_dot_fp64(a, tmp, out_val[i]);
10205
+ }
10206
+ }
10207
+ `;
10208
+
10209
+ // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64.js
10210
+ var CONST_UNIFORMS = {
10211
+ ONE: 1
10178
10212
  };
10179
- PipelineFactory.defaultProps = {
10180
- ...import_core35.RenderPipeline.defaultProps,
10181
- vs: void 0,
10182
- fs: void 0
10213
+ function getUniforms2() {
10214
+ return CONST_UNIFORMS;
10215
+ }
10216
+ var fp64arithmetic = {
10217
+ name: "fp64-arithmetic",
10218
+ vs: fp64arithmeticShader,
10219
+ getUniforms: getUniforms2,
10220
+ fp64ify,
10221
+ fp64LowPart,
10222
+ fp64ifyMatrix4
10223
+ };
10224
+ var fp64 = {
10225
+ name: "fp64",
10226
+ vs: fp64functionShader,
10227
+ dependencies: [fp64arithmetic],
10228
+ fp64ify,
10229
+ fp64LowPart,
10230
+ fp64ifyMatrix4
10183
10231
  };
10184
10232
 
10185
- // ../../node_modules/@luma.gl/engine/dist/model/model.js
10186
- var Model = class {
10187
- constructor(device, props) {
10188
- this.device = void 0;
10189
- this.id = void 0;
10190
- this.vs = void 0;
10191
- this.fs = void 0;
10192
- this.pipelineFactory = void 0;
10193
- this.userData = {};
10194
- this.parameters = void 0;
10195
- this.topology = void 0;
10196
- this.bufferLayout = void 0;
10197
- this.vertexCount = void 0;
10198
- this.instanceCount = 0;
10199
- this.indexBuffer = null;
10200
- this.bufferAttributes = {};
10201
- this.constantAttributes = {};
10202
- this.bindings = {};
10203
- this.uniforms = {};
10204
- this.pipeline = void 0;
10205
- this.vertexArray = void 0;
10206
- this._pipelineNeedsUpdate = "newly created";
10207
- this._attributeInfos = {};
10208
- this._gpuGeometry = null;
10209
- this._getModuleUniforms = void 0;
10210
- this.props = void 0;
10211
- this.props = {
10212
- ...Model.defaultProps,
10213
- ...props
10214
- };
10215
- props = this.props;
10216
- this.id = props.id || (0, import_core36.uid)("model");
10217
- this.device = device;
10218
- Object.assign(this.userData, props.userData);
10219
- const platformInfo = {
10220
- type: device.info.type,
10221
- shaderLanguage: device.info.shadingLanguages[0],
10222
- gpu: device.info.gpu,
10223
- features: device.features
10224
- };
10225
- const {
10226
- vs: vs5,
10227
- fs: fs4,
10228
- getUniforms: getUniforms4
10229
- } = this.props.shaderAssembler.assembleShaders(platformInfo, this.props);
10230
- this.vs = vs5;
10231
- this.fs = fs4;
10232
- this._getModuleUniforms = getUniforms4;
10233
- this.vertexCount = this.props.vertexCount;
10234
- this.instanceCount = this.props.instanceCount;
10235
- this.topology = this.props.topology;
10236
- this.bufferLayout = this.props.bufferLayout;
10237
- this.parameters = this.props.parameters;
10238
- if (props.geometry) {
10239
- this._gpuGeometry = this.setGeometry(props.geometry);
10240
- }
10241
- this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
10242
- this.pipeline = this._updatePipeline();
10243
- this.vertexArray = device.createVertexArray({
10244
- renderPipeline: this.pipeline
10245
- });
10246
- if (this._gpuGeometry) {
10247
- this._setGeometryAttributes(this._gpuGeometry);
10248
- }
10249
- if (props.vertexCount) {
10250
- this.setVertexCount(props.vertexCount);
10251
- }
10252
- if (props.instanceCount) {
10253
- this.setInstanceCount(props.instanceCount);
10254
- }
10255
- if (props.indices) {
10256
- throw new Error("Model.props.indices removed. Use props.indexBuffer");
10257
- }
10258
- if (props.indexBuffer) {
10259
- this.setIndexBuffer(props.indexBuffer);
10260
- }
10261
- if (props.attributes) {
10262
- this.setAttributes(props.attributes);
10263
- }
10264
- if (props.constantAttributes) {
10265
- this.setConstantAttributes(props.constantAttributes);
10266
- }
10267
- if (props.bindings) {
10268
- this.setBindings(props.bindings);
10269
- }
10270
- if (props.uniforms) {
10271
- this.setUniforms(props.uniforms);
10272
- }
10273
- if (props.moduleSettings) {
10274
- this.updateModuleSettings(props.moduleSettings);
10275
- }
10276
- this.setUniforms(this._getModuleUniforms());
10277
- Object.seal(this);
10278
- }
10279
- destroy() {
10280
- this.pipelineFactory.release(this.pipeline);
10281
- }
10282
- draw(renderPass) {
10283
- this.pipeline = this._updatePipeline();
10284
- this.pipeline.setBindings(this.bindings);
10285
- this.pipeline.setUniforms(this.uniforms);
10286
- this.pipeline.draw({
10287
- renderPass,
10288
- vertexArray: this.vertexArray,
10289
- vertexCount: this.vertexCount,
10290
- instanceCount: this.instanceCount
10291
- });
10292
- }
10293
- setGeometry(geometry) {
10294
- const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
10295
- this.setTopology(gpuGeometry.topology || "triangle-list");
10296
- this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
10297
- if (this.vertexArray) {
10298
- this._setGeometryAttributes(gpuGeometry);
10299
- }
10300
- return gpuGeometry;
10301
- }
10302
- _setGeometryAttributes(gpuGeometry) {
10303
- this.vertexCount = gpuGeometry.vertexCount;
10304
- this.setAttributes(gpuGeometry.attributes);
10305
- this.setIndexBuffer(gpuGeometry.indices);
10306
- }
10307
- setTopology(topology) {
10308
- if (topology !== this.topology) {
10309
- this.topology = topology;
10310
- this._setPipelineNeedsUpdate("topology");
10311
- }
10312
- }
10313
- setBufferLayout(bufferLayout) {
10314
- this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
10315
- this._setPipelineNeedsUpdate("bufferLayout");
10316
- this.pipeline = this._updatePipeline();
10317
- this.vertexArray = this.device.createVertexArray({
10318
- renderPipeline: this.pipeline
10319
- });
10320
- if (this._gpuGeometry) {
10321
- this._setGeometryAttributes(this._gpuGeometry);
10322
- }
10323
- }
10324
- setParameters(parameters2) {
10325
- if (!(0, import_core36.deepEqual)(parameters2, this.parameters, 2)) {
10326
- this.parameters = parameters2;
10327
- this._setPipelineNeedsUpdate("parameters");
10328
- }
10329
- }
10330
- setVertexCount(vertexCount) {
10331
- this.vertexCount = vertexCount;
10332
- }
10333
- setInstanceCount(instanceCount) {
10334
- this.instanceCount = instanceCount;
10335
- }
10336
- setShaderModuleProps(props) {
10337
- const uniforms = this._getModuleUniforms(props);
10338
- const keys = Object.keys(uniforms).filter((k) => {
10339
- const uniform = uniforms[k];
10340
- return !(0, import_core36.isNumberArray)(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
10341
- });
10342
- const bindings = {};
10343
- for (const k of keys) {
10344
- bindings[k] = uniforms[k];
10345
- delete uniforms[k];
10346
- }
10347
- Object.assign(this.uniforms, uniforms);
10348
- Object.assign(this.bindings, bindings);
10349
- }
10350
- updateModuleSettings(props) {
10351
- this.setShaderModuleProps(props);
10352
- }
10353
- setBindings(bindings) {
10354
- Object.assign(this.bindings, bindings);
10355
- }
10356
- setUniforms(uniforms) {
10357
- this.pipeline.setUniforms(uniforms);
10358
- Object.assign(this.uniforms, uniforms);
10233
+ // ../../node_modules/@math.gl/core/dist/lib/common.js
10234
+ var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
10235
+ var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
10236
+ var DEFAULT_CONFIG = {
10237
+ EPSILON: 1e-12,
10238
+ debug: false,
10239
+ precision: 4,
10240
+ printTypes: false,
10241
+ printDegrees: false,
10242
+ printRowMajor: true,
10243
+ _cartographicRadians: false
10244
+ };
10245
+ globalThis.mathgl = globalThis.mathgl || {
10246
+ config: {
10247
+ ...DEFAULT_CONFIG
10359
10248
  }
10360
- setIndexBuffer(indexBuffer) {
10361
- this.vertexArray.setIndexBuffer(indexBuffer);
10249
+ };
10250
+ var config = globalThis.mathgl.config;
10251
+ function isArray2(value) {
10252
+ return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
10253
+ }
10254
+ function equals(a, b, epsilon) {
10255
+ const oldEpsilon = config.EPSILON;
10256
+ if (epsilon) {
10257
+ config.EPSILON = epsilon;
10362
10258
  }
10363
- setAttributes(buffers) {
10364
- if (buffers.indices) {
10365
- import_core36.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
10259
+ try {
10260
+ if (a === b) {
10261
+ return true;
10366
10262
  }
10367
- for (const [bufferName, buffer] of Object.entries(buffers)) {
10368
- var _bufferLayout$attribu;
10369
- const bufferLayout = this.bufferLayout.find((layout) => layout.name === bufferName);
10370
- if (!bufferLayout) {
10371
- continue;
10372
- }
10373
- const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map((layout) => layout.attribute) : [bufferLayout.name];
10374
- let set2 = false;
10375
- for (const attributeName of attributeNames) {
10376
- const attributeInfo = this._attributeInfos[attributeName];
10377
- if (attributeInfo) {
10378
- this.vertexArray.setBuffer(attributeInfo.location, buffer);
10379
- set2 = true;
10380
- }
10263
+ if (isArray2(a) && isArray2(b)) {
10264
+ if (a.length !== b.length) {
10265
+ return false;
10381
10266
  }
10382
- if (!set2) {
10383
- import_core36.log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
10267
+ for (let i = 0; i < a.length; ++i) {
10268
+ if (!equals(a[i], b[i])) {
10269
+ return false;
10270
+ }
10384
10271
  }
10272
+ return true;
10385
10273
  }
10386
- }
10387
- setConstantAttributes(attributes) {
10388
- for (const [attributeName, value] of Object.entries(attributes)) {
10389
- const attributeInfo = this._attributeInfos[attributeName];
10390
- if (attributeInfo) {
10391
- this.vertexArray.setConstant(attributeInfo.location, value);
10392
- } else {
10393
- import_core36.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
10394
- }
10274
+ if (a && a.equals) {
10275
+ return a.equals(b);
10395
10276
  }
10396
- }
10397
- _setPipelineNeedsUpdate(reason) {
10398
- this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
10399
- }
10400
- _updatePipeline() {
10401
- if (this._pipelineNeedsUpdate) {
10402
- if (this.pipeline) {
10403
- import_core36.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
10404
- }
10405
- this._pipelineNeedsUpdate = false;
10406
- this.pipeline = this.device.createRenderPipeline({
10407
- ...this.props,
10408
- bufferLayout: this.bufferLayout,
10409
- topology: this.topology,
10410
- parameters: this.parameters,
10411
- vs: this.device.createShader({
10412
- id: "{$this.id}-vertex",
10413
- stage: "vertex",
10414
- source: this.vs
10415
- }),
10416
- fs: this.fs ? this.device.createShader({
10417
- id: "{$this.id}-fragment",
10418
- stage: "fragment",
10419
- source: this.fs
10420
- }) : null
10421
- });
10422
- this._attributeInfos = (0, import_core37.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout, this.bufferLayout);
10277
+ if (b && b.equals) {
10278
+ return b.equals(a);
10423
10279
  }
10424
- return this.pipeline;
10425
- }
10426
- };
10427
- Model.defaultProps = {
10428
- ...import_core36.RenderPipeline.defaultProps,
10429
- vs: null,
10430
- fs: null,
10431
- id: "unnamed",
10432
- handle: void 0,
10433
- userData: {},
10434
- defines: {},
10435
- modules: [],
10436
- moduleSettings: {},
10437
- geometry: null,
10438
- indexBuffer: null,
10439
- attributes: {},
10440
- constantAttributes: {},
10441
- pipelineFactory: void 0,
10442
- shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
10443
- };
10444
- function mergeBufferLayouts(layouts1, layouts2) {
10445
- const layouts = [...layouts1];
10446
- for (const attribute of layouts2) {
10447
- const index = layouts.findIndex((attribute2) => attribute2.name === attribute.name);
10448
- if (index < 0) {
10449
- layouts.push(attribute);
10450
- } else {
10451
- layouts[index] = attribute;
10280
+ if (typeof a === "number" && typeof b === "number") {
10281
+ return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
10452
10282
  }
10283
+ return false;
10284
+ } finally {
10285
+ config.EPSILON = oldEpsilon;
10286
+ }
10287
+ }
10288
+
10289
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
10290
+ var EPSILON = 1e-6;
10291
+ var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
10292
+ var RANDOM = Math.random;
10293
+ function round(a) {
10294
+ if (a >= 0)
10295
+ return Math.round(a);
10296
+ return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
10297
+ }
10298
+ var degree = Math.PI / 180;
10299
+
10300
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
10301
+ var vec3_exports = {};
10302
+ __export(vec3_exports, {
10303
+ add: () => add,
10304
+ angle: () => angle,
10305
+ bezier: () => bezier,
10306
+ ceil: () => ceil,
10307
+ clone: () => clone,
10308
+ copy: () => copy,
10309
+ create: () => create,
10310
+ cross: () => cross,
10311
+ dist: () => dist,
10312
+ distance: () => distance,
10313
+ div: () => div,
10314
+ divide: () => divide,
10315
+ dot: () => dot,
10316
+ equals: () => equals2,
10317
+ exactEquals: () => exactEquals,
10318
+ floor: () => floor,
10319
+ forEach: () => forEach,
10320
+ fromValues: () => fromValues,
10321
+ hermite: () => hermite,
10322
+ inverse: () => inverse,
10323
+ len: () => len,
10324
+ length: () => length,
10325
+ lerp: () => lerp,
10326
+ max: () => max,
10327
+ min: () => min,
10328
+ mul: () => mul,
10329
+ multiply: () => multiply,
10330
+ negate: () => negate,
10331
+ normalize: () => normalize,
10332
+ random: () => random,
10333
+ rotateX: () => rotateX,
10334
+ rotateY: () => rotateY,
10335
+ rotateZ: () => rotateZ,
10336
+ round: () => round2,
10337
+ scale: () => scale,
10338
+ scaleAndAdd: () => scaleAndAdd,
10339
+ set: () => set,
10340
+ slerp: () => slerp,
10341
+ sqrDist: () => sqrDist,
10342
+ sqrLen: () => sqrLen,
10343
+ squaredDistance: () => squaredDistance,
10344
+ squaredLength: () => squaredLength,
10345
+ str: () => str,
10346
+ sub: () => sub,
10347
+ subtract: () => subtract,
10348
+ transformMat3: () => transformMat3,
10349
+ transformMat4: () => transformMat4,
10350
+ transformQuat: () => transformQuat,
10351
+ zero: () => zero
10352
+ });
10353
+ function create() {
10354
+ const out = new ARRAY_TYPE(3);
10355
+ if (ARRAY_TYPE != Float32Array) {
10356
+ out[0] = 0;
10357
+ out[1] = 0;
10358
+ out[2] = 0;
10359
+ }
10360
+ return out;
10361
+ }
10362
+ function clone(a) {
10363
+ const out = new ARRAY_TYPE(3);
10364
+ out[0] = a[0];
10365
+ out[1] = a[1];
10366
+ out[2] = a[2];
10367
+ return out;
10368
+ }
10369
+ function length(a) {
10370
+ const x = a[0];
10371
+ const y = a[1];
10372
+ const z = a[2];
10373
+ return Math.sqrt(x * x + y * y + z * z);
10374
+ }
10375
+ function fromValues(x, y, z) {
10376
+ const out = new ARRAY_TYPE(3);
10377
+ out[0] = x;
10378
+ out[1] = y;
10379
+ out[2] = z;
10380
+ return out;
10381
+ }
10382
+ function copy(out, a) {
10383
+ out[0] = a[0];
10384
+ out[1] = a[1];
10385
+ out[2] = a[2];
10386
+ return out;
10387
+ }
10388
+ function set(out, x, y, z) {
10389
+ out[0] = x;
10390
+ out[1] = y;
10391
+ out[2] = z;
10392
+ return out;
10393
+ }
10394
+ function add(out, a, b) {
10395
+ out[0] = a[0] + b[0];
10396
+ out[1] = a[1] + b[1];
10397
+ out[2] = a[2] + b[2];
10398
+ return out;
10399
+ }
10400
+ function subtract(out, a, b) {
10401
+ out[0] = a[0] - b[0];
10402
+ out[1] = a[1] - b[1];
10403
+ out[2] = a[2] - b[2];
10404
+ return out;
10405
+ }
10406
+ function multiply(out, a, b) {
10407
+ out[0] = a[0] * b[0];
10408
+ out[1] = a[1] * b[1];
10409
+ out[2] = a[2] * b[2];
10410
+ return out;
10411
+ }
10412
+ function divide(out, a, b) {
10413
+ out[0] = a[0] / b[0];
10414
+ out[1] = a[1] / b[1];
10415
+ out[2] = a[2] / b[2];
10416
+ return out;
10417
+ }
10418
+ function ceil(out, a) {
10419
+ out[0] = Math.ceil(a[0]);
10420
+ out[1] = Math.ceil(a[1]);
10421
+ out[2] = Math.ceil(a[2]);
10422
+ return out;
10423
+ }
10424
+ function floor(out, a) {
10425
+ out[0] = Math.floor(a[0]);
10426
+ out[1] = Math.floor(a[1]);
10427
+ out[2] = Math.floor(a[2]);
10428
+ return out;
10429
+ }
10430
+ function min(out, a, b) {
10431
+ out[0] = Math.min(a[0], b[0]);
10432
+ out[1] = Math.min(a[1], b[1]);
10433
+ out[2] = Math.min(a[2], b[2]);
10434
+ return out;
10435
+ }
10436
+ function max(out, a, b) {
10437
+ out[0] = Math.max(a[0], b[0]);
10438
+ out[1] = Math.max(a[1], b[1]);
10439
+ out[2] = Math.max(a[2], b[2]);
10440
+ return out;
10441
+ }
10442
+ function round2(out, a) {
10443
+ out[0] = round(a[0]);
10444
+ out[1] = round(a[1]);
10445
+ out[2] = round(a[2]);
10446
+ return out;
10447
+ }
10448
+ function scale(out, a, b) {
10449
+ out[0] = a[0] * b;
10450
+ out[1] = a[1] * b;
10451
+ out[2] = a[2] * b;
10452
+ return out;
10453
+ }
10454
+ function scaleAndAdd(out, a, b, scale2) {
10455
+ out[0] = a[0] + b[0] * scale2;
10456
+ out[1] = a[1] + b[1] * scale2;
10457
+ out[2] = a[2] + b[2] * scale2;
10458
+ return out;
10459
+ }
10460
+ function distance(a, b) {
10461
+ const x = b[0] - a[0];
10462
+ const y = b[1] - a[1];
10463
+ const z = b[2] - a[2];
10464
+ return Math.sqrt(x * x + y * y + z * z);
10465
+ }
10466
+ function squaredDistance(a, b) {
10467
+ const x = b[0] - a[0];
10468
+ const y = b[1] - a[1];
10469
+ const z = b[2] - a[2];
10470
+ return x * x + y * y + z * z;
10471
+ }
10472
+ function squaredLength(a) {
10473
+ const x = a[0];
10474
+ const y = a[1];
10475
+ const z = a[2];
10476
+ return x * x + y * y + z * z;
10477
+ }
10478
+ function negate(out, a) {
10479
+ out[0] = -a[0];
10480
+ out[1] = -a[1];
10481
+ out[2] = -a[2];
10482
+ return out;
10483
+ }
10484
+ function inverse(out, a) {
10485
+ out[0] = 1 / a[0];
10486
+ out[1] = 1 / a[1];
10487
+ out[2] = 1 / a[2];
10488
+ return out;
10489
+ }
10490
+ function normalize(out, a) {
10491
+ const x = a[0];
10492
+ const y = a[1];
10493
+ const z = a[2];
10494
+ let len2 = x * x + y * y + z * z;
10495
+ if (len2 > 0) {
10496
+ len2 = 1 / Math.sqrt(len2);
10453
10497
  }
10454
- return layouts;
10498
+ out[0] = a[0] * len2;
10499
+ out[1] = a[1] * len2;
10500
+ out[2] = a[2] * len2;
10501
+ return out;
10455
10502
  }
10456
-
10457
- // src/data-filter/aggregator.ts
10458
- var AGGREGATE_VS = `#define SHADER_NAME data-filter-vertex-shader
10459
-
10460
- #ifdef FLOAT_TARGET
10461
- attribute float filterIndices;
10462
- attribute float filterPrevIndices;
10463
- #else
10464
- attribute vec2 filterIndices;
10465
- attribute vec2 filterPrevIndices;
10466
- #endif
10467
-
10468
- varying vec4 vColor;
10469
- const float component = 1.0 / 255.0;
10470
-
10471
- void main() {
10472
- #ifdef FLOAT_TARGET
10473
- dataFilter_value *= float(filterIndices != filterPrevIndices);
10474
- gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
10475
- vColor = vec4(0.0, 0.0, 0.0, 1.0);
10476
- #else
10477
- // Float texture is not supported: pack result into 4 channels x 256 px x 64px
10478
- dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
10479
- float col = filterIndices.x;
10480
- float row = filterIndices.y * 4.0;
10481
- float channel = floor(row);
10482
- row = fract(row);
10483
- vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
10484
- gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
10485
- #endif
10486
- gl_PointSize = 1.0;
10487
- }
10488
- `;
10489
- var AGGREGATE_FS = `#define SHADER_NAME data-filter-fragment-shader
10490
- precision highp float;
10491
-
10492
- varying vec4 vColor;
10493
-
10494
- void main() {
10495
- if (dataFilter_value < 0.5) {
10496
- discard;
10503
+ function dot(a, b) {
10504
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
10497
10505
  }
10498
- gl_FragColor = vColor;
10499
- }
10500
- `;
10501
- function supportsFloatTarget(device) {
10502
- const gl = device.gl;
10503
- return Boolean(gl.getExtension("EXT_float_blend") && (gl.getExtension("EXT_color_buffer_float") || gl.getExtension("WEBGL_color_buffer_float")));
10506
+ function cross(out, a, b) {
10507
+ const ax = a[0];
10508
+ const ay = a[1];
10509
+ const az = a[2];
10510
+ const bx = b[0];
10511
+ const by = b[1];
10512
+ const bz = b[2];
10513
+ out[0] = ay * bz - az * by;
10514
+ out[1] = az * bx - ax * bz;
10515
+ out[2] = ax * by - ay * bx;
10516
+ return out;
10517
+ }
10518
+ function lerp(out, a, b, t) {
10519
+ const ax = a[0];
10520
+ const ay = a[1];
10521
+ const az = a[2];
10522
+ out[0] = ax + t * (b[0] - ax);
10523
+ out[1] = ay + t * (b[1] - ay);
10524
+ out[2] = az + t * (b[2] - az);
10525
+ return out;
10526
+ }
10527
+ function slerp(out, a, b, t) {
10528
+ const angle2 = Math.acos(Math.min(Math.max(dot(a, b), -1), 1));
10529
+ const sinTotal = Math.sin(angle2);
10530
+ const ratioA = Math.sin((1 - t) * angle2) / sinTotal;
10531
+ const ratioB = Math.sin(t * angle2) / sinTotal;
10532
+ out[0] = ratioA * a[0] + ratioB * b[0];
10533
+ out[1] = ratioA * a[1] + ratioB * b[1];
10534
+ out[2] = ratioA * a[2] + ratioB * b[2];
10535
+ return out;
10536
+ }
10537
+ function hermite(out, a, b, c, d, t) {
10538
+ const factorTimes2 = t * t;
10539
+ const factor1 = factorTimes2 * (2 * t - 3) + 1;
10540
+ const factor2 = factorTimes2 * (t - 2) + t;
10541
+ const factor3 = factorTimes2 * (t - 1);
10542
+ const factor4 = factorTimes2 * (3 - 2 * t);
10543
+ out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
10544
+ out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
10545
+ out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
10546
+ return out;
10547
+ }
10548
+ function bezier(out, a, b, c, d, t) {
10549
+ const inverseFactor = 1 - t;
10550
+ const inverseFactorTimesTwo = inverseFactor * inverseFactor;
10551
+ const factorTimes2 = t * t;
10552
+ const factor1 = inverseFactorTimesTwo * inverseFactor;
10553
+ const factor2 = 3 * t * inverseFactorTimesTwo;
10554
+ const factor3 = 3 * factorTimes2 * inverseFactor;
10555
+ const factor4 = factorTimes2 * t;
10556
+ out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
10557
+ out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
10558
+ out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
10559
+ return out;
10560
+ }
10561
+ function random(out, scale2) {
10562
+ scale2 = scale2 === void 0 ? 1 : scale2;
10563
+ const r = RANDOM() * 2 * Math.PI;
10564
+ const z = RANDOM() * 2 - 1;
10565
+ const zScale = Math.sqrt(1 - z * z) * scale2;
10566
+ out[0] = Math.cos(r) * zScale;
10567
+ out[1] = Math.sin(r) * zScale;
10568
+ out[2] = z * scale2;
10569
+ return out;
10570
+ }
10571
+ function transformMat4(out, a, m) {
10572
+ const x = a[0];
10573
+ const y = a[1];
10574
+ const z = a[2];
10575
+ let w = m[3] * x + m[7] * y + m[11] * z + m[15];
10576
+ w = w || 1;
10577
+ out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
10578
+ out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
10579
+ out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
10580
+ return out;
10581
+ }
10582
+ function transformMat3(out, a, m) {
10583
+ const x = a[0];
10584
+ const y = a[1];
10585
+ const z = a[2];
10586
+ out[0] = x * m[0] + y * m[3] + z * m[6];
10587
+ out[1] = x * m[1] + y * m[4] + z * m[7];
10588
+ out[2] = x * m[2] + y * m[5] + z * m[8];
10589
+ return out;
10590
+ }
10591
+ function transformQuat(out, a, q) {
10592
+ const qx = q[0];
10593
+ const qy = q[1];
10594
+ const qz = q[2];
10595
+ const qw = q[3];
10596
+ const x = a[0];
10597
+ const y = a[1];
10598
+ const z = a[2];
10599
+ let uvx = qy * z - qz * y;
10600
+ let uvy = qz * x - qx * z;
10601
+ let uvz = qx * y - qy * x;
10602
+ let uuvx = qy * uvz - qz * uvy;
10603
+ let uuvy = qz * uvx - qx * uvz;
10604
+ let uuvz = qx * uvy - qy * uvx;
10605
+ const w2 = qw * 2;
10606
+ uvx *= w2;
10607
+ uvy *= w2;
10608
+ uvz *= w2;
10609
+ uuvx *= 2;
10610
+ uuvy *= 2;
10611
+ uuvz *= 2;
10612
+ out[0] = x + uvx + uuvx;
10613
+ out[1] = y + uvy + uuvy;
10614
+ out[2] = z + uvz + uuvz;
10615
+ return out;
10616
+ }
10617
+ function rotateX(out, a, b, rad) {
10618
+ const p = [];
10619
+ const r = [];
10620
+ p[0] = a[0] - b[0];
10621
+ p[1] = a[1] - b[1];
10622
+ p[2] = a[2] - b[2];
10623
+ r[0] = p[0];
10624
+ r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);
10625
+ r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);
10626
+ out[0] = r[0] + b[0];
10627
+ out[1] = r[1] + b[1];
10628
+ out[2] = r[2] + b[2];
10629
+ return out;
10630
+ }
10631
+ function rotateY(out, a, b, rad) {
10632
+ const p = [];
10633
+ const r = [];
10634
+ p[0] = a[0] - b[0];
10635
+ p[1] = a[1] - b[1];
10636
+ p[2] = a[2] - b[2];
10637
+ r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);
10638
+ r[1] = p[1];
10639
+ r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);
10640
+ out[0] = r[0] + b[0];
10641
+ out[1] = r[1] + b[1];
10642
+ out[2] = r[2] + b[2];
10643
+ return out;
10644
+ }
10645
+ function rotateZ(out, a, b, rad) {
10646
+ const p = [];
10647
+ const r = [];
10648
+ p[0] = a[0] - b[0];
10649
+ p[1] = a[1] - b[1];
10650
+ p[2] = a[2] - b[2];
10651
+ r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);
10652
+ r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);
10653
+ r[2] = p[2];
10654
+ out[0] = r[0] + b[0];
10655
+ out[1] = r[1] + b[1];
10656
+ out[2] = r[2] + b[2];
10657
+ return out;
10658
+ }
10659
+ function angle(a, b) {
10660
+ const ax = a[0];
10661
+ const ay = a[1];
10662
+ const az = a[2];
10663
+ const bx = b[0];
10664
+ const by = b[1];
10665
+ const bz = b[2];
10666
+ const mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz));
10667
+ const cosine = mag && dot(a, b) / mag;
10668
+ return Math.acos(Math.min(Math.max(cosine, -1), 1));
10669
+ }
10670
+ function zero(out) {
10671
+ out[0] = 0;
10672
+ out[1] = 0;
10673
+ out[2] = 0;
10674
+ return out;
10675
+ }
10676
+ function str(a) {
10677
+ return "vec3(".concat(a[0], ", ").concat(a[1], ", ").concat(a[2], ")");
10504
10678
  }
10505
- function getFramebuffer3(device, useFloatTarget) {
10506
- if (useFloatTarget) {
10507
- return device.createFramebuffer({
10508
- width: 1,
10509
- height: 1,
10510
- colorAttachments: [device.createTexture({
10511
- format: device.info.type === "webgl2" ? "rgba32float" : "rgba8unorm",
10512
- type: 5126,
10513
- mipmaps: false
10514
- })]
10515
- });
10516
- }
10517
- return device.createFramebuffer({
10518
- width: 256,
10519
- height: 64,
10520
- colorAttachments: [device.createTexture({
10521
- format: "rgba8unorm",
10522
- type: 5126,
10523
- mipmaps: false
10524
- })]
10525
- });
10679
+ function exactEquals(a, b) {
10680
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
10526
10681
  }
10527
- function getModel(device, shaderOptions, useFloatTarget) {
10528
- shaderOptions.defines.NON_INSTANCED_MODEL = 1;
10529
- if (useFloatTarget) {
10530
- shaderOptions.defines.FLOAT_TARGET = 1;
10531
- }
10532
- return new Model(device, {
10533
- id: "data-filter-aggregation-model",
10534
- vertexCount: 1,
10535
- isInstanced: false,
10536
- drawMode: 0,
10537
- vs: AGGREGATE_VS,
10538
- fs: AGGREGATE_FS,
10539
- ...shaderOptions
10540
- });
10682
+ function equals2(a, b) {
10683
+ const a0 = a[0];
10684
+ const a1 = a[1];
10685
+ const a2 = a[2];
10686
+ const b0 = b[0];
10687
+ const b1 = b[1];
10688
+ const b2 = b[2];
10689
+ return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2));
10541
10690
  }
10542
- var parameters = {
10543
- blend: true,
10544
- blendFunc: [1, 1, 1, 1],
10545
- blendEquation: [32774, 32774],
10546
- depthTest: false
10547
- };
10548
-
10549
- // src/data-filter/data-filter-extension.ts
10550
- var defaultProps2 = {
10551
- getFilterValue: {
10552
- type: "accessor",
10553
- value: 0
10554
- },
10555
- onFilteredItemsChange: {
10556
- type: "function",
10557
- value: null,
10558
- optional: true
10559
- },
10560
- filterEnabled: true,
10561
- filterRange: [-1, 1],
10562
- filterSoftRange: null,
10563
- filterTransformSize: true,
10564
- filterTransformColor: true
10565
- };
10566
- var DATA_TYPE_FROM_SIZE = {
10567
- 1: "float",
10568
- 2: "vec2",
10569
- 3: "vec3",
10570
- 4: "vec4"
10571
- };
10572
- var DataFilterExtension = class extends import_core38.LayerExtension {
10573
- constructor({
10574
- filterSize = 1,
10575
- fp64: fp642 = false,
10576
- countItems = false
10577
- } = {}) {
10578
- if (!DATA_TYPE_FROM_SIZE[filterSize]) {
10579
- throw new Error("filterSize out of range");
10580
- }
10581
- super({
10582
- filterSize,
10583
- fp64: fp642,
10584
- countItems
10585
- });
10586
- }
10587
- getShaders(extension) {
10588
- const {
10589
- filterSize,
10590
- fp64: fp642
10591
- } = extension.opts;
10592
- return {
10593
- modules: [fp642 ? shaderModule64 : shaderModule],
10594
- defines: {
10595
- DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
10596
- DATAFILTER_DOUBLE: Boolean(fp642)
10597
- }
10598
- };
10599
- }
10600
- initializeState(context, extension) {
10601
- const attributeManager = this.getAttributeManager();
10602
- if (attributeManager) {
10603
- attributeManager.add({
10604
- filterValues: {
10605
- size: extension.opts.filterSize,
10606
- type: extension.opts.fp64 ? 5130 : 5126,
10607
- accessor: "getFilterValue",
10608
- shaderAttributes: {
10609
- filterValues: {
10610
- divisor: 0
10611
- },
10612
- instanceFilterValues: {
10613
- divisor: 1
10614
- }
10615
- }
10616
- }
10617
- });
10691
+ var sub = subtract;
10692
+ var mul = multiply;
10693
+ var div = divide;
10694
+ var dist = distance;
10695
+ var sqrDist = squaredDistance;
10696
+ var len = length;
10697
+ var sqrLen = squaredLength;
10698
+ var forEach = function() {
10699
+ const vec = create();
10700
+ return function(a, stride, offset, count, fn, arg) {
10701
+ let i;
10702
+ let l;
10703
+ if (!stride) {
10704
+ stride = 3;
10618
10705
  }
10619
- const {
10620
- device
10621
- } = this.context;
10622
- if (attributeManager && extension.opts.countItems) {
10623
- const useFloatTarget = supportsFloatTarget(device);
10624
- attributeManager.add({
10625
- filterIndices: {
10626
- size: useFloatTarget ? 1 : 2,
10627
- vertexOffset: 1,
10628
- type: 5121,
10629
- normalized: true,
10630
- accessor: (object, {
10631
- index
10632
- }) => {
10633
- const i = object && object.__source ? object.__source.index : index;
10634
- return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
10635
- },
10636
- shaderAttributes: {
10637
- filterPrevIndices: {
10638
- vertexOffset: 0
10639
- },
10640
- filterIndices: {
10641
- vertexOffset: 1
10642
- }
10643
- }
10644
- }
10645
- });
10646
- const filterFBO = getFramebuffer3(device, useFloatTarget);
10647
- const filterModel = getModel(device, extension.getShaders.call(this, extension), useFloatTarget);
10648
- this.setState({
10649
- filterFBO,
10650
- filterModel
10651
- });
10706
+ if (!offset) {
10707
+ offset = 0;
10652
10708
  }
10653
- }
10654
- updateState({
10655
- props,
10656
- oldProps
10657
- }) {
10658
- if (this.state.filterModel) {
10659
- const attributeManager = this.getAttributeManager();
10660
- const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() || props.filterEnabled !== oldProps.filterEnabled || props.filterRange !== oldProps.filterRange || props.filterSoftRange !== oldProps.filterSoftRange;
10661
- if (filterNeedsUpdate) {
10662
- this.setState({
10663
- filterNeedsUpdate
10664
- });
10665
- }
10709
+ if (count) {
10710
+ l = Math.min(count * stride + offset, a.length);
10711
+ } else {
10712
+ l = a.length;
10666
10713
  }
10667
- }
10668
- draw(params, extension) {
10669
- const filterFBO = this.state.filterFBO;
10670
- const filterModel = this.state.filterModel;
10671
- const filterNeedsUpdate = this.state.filterNeedsUpdate;
10672
- const {
10673
- onFilteredItemsChange
10674
- } = this.props;
10675
- if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
10676
- const {
10677
- attributes: {
10678
- filterValues,
10679
- filterIndices
10680
- }
10681
- } = this.getAttributeManager();
10682
- filterModel.setVertexCount(this.getNumInstances());
10683
- clear(this.context.device, {
10684
- framebuffer: filterFBO,
10685
- color: [0, 0, 0, 0]
10686
- });
10687
- filterModel.updateModuleSettings(params.moduleParameters);
10688
- filterModel.setAttributes({
10689
- ...filterValues.getValue(),
10690
- ...filterIndices?.getValue()
10691
- });
10692
- withGLParameters(filterModel.device, {
10693
- framebuffer: filterFBO,
10694
- ...parameters,
10695
- viewport: [0, 0, filterFBO.width, filterFBO.height]
10696
- }, () => {
10697
- filterModel.draw(this.context.renderPass);
10698
- });
10699
- const color = readPixelsToArray(filterFBO);
10700
- let count = 0;
10701
- for (let i = 0; i < color.length; i++) {
10702
- count += color[i];
10703
- }
10704
- onFilteredItemsChange({
10705
- id: this.id,
10706
- count
10707
- });
10708
- this.state.filterNeedsUpdate = false;
10714
+ for (i = offset; i < l; i += stride) {
10715
+ vec[0] = a[i];
10716
+ vec[1] = a[i + 1];
10717
+ vec[2] = a[i + 2];
10718
+ fn(vec, vec, arg);
10719
+ a[i] = vec[0];
10720
+ a[i + 1] = vec[1];
10721
+ a[i + 2] = vec[2];
10709
10722
  }
10710
- }
10711
- finalizeState() {
10712
- const filterFBO = this.state.filterFBO;
10713
- const filterModel = this.state.filterModel;
10714
- filterFBO?.destroy();
10715
- filterModel?.destroy();
10716
- }
10717
- };
10718
- __publicField(DataFilterExtension, "defaultProps", defaultProps2);
10719
- __publicField(DataFilterExtension, "extensionName", "DataFilterExtension");
10720
-
10721
- // src/fp64/fp64-extension.ts
10722
- var import_core40 = __toESM(require_core());
10723
+ return a;
10724
+ };
10725
+ }();
10723
10726
 
10724
10727
  // src/fp64/project64.ts
10725
10728
  var import_core39 = __toESM(require_core());
@@ -11482,7 +11485,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
11482
11485
  } = opts;
11483
11486
  return {
11484
11487
  collision_sort: Boolean(drawToCollisionMap),
11485
- collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap
11488
+ collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap
11486
11489
  };
11487
11490
  };
11488
11491
  var shader_module_default2 = {
@@ -11501,15 +11504,16 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
11501
11504
  var CollisionFilterPass = class extends import_core47._LayersPass {
11502
11505
  renderCollisionMap(target, options) {
11503
11506
  const padding = 1;
11507
+ const clearColor = [0, 0, 0, 0];
11504
11508
  return withGLParameters(this.device, {
11505
11509
  scissorTest: true,
11506
11510
  scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],
11507
- clearColor: [0, 0, 0, 0],
11508
11511
  blend: false,
11509
11512
  depthTest: true,
11510
11513
  depthRange: [0, 1]
11511
11514
  }, () => this.render({
11512
11515
  ...options,
11516
+ clearColor,
11513
11517
  target,
11514
11518
  pass: "collision"
11515
11519
  }));
@@ -11556,8 +11560,8 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
11556
11560
  render(options) {
11557
11561
  const colorMask = [false, false, false, false];
11558
11562
  colorMask[options.channel] = true;
11563
+ const clearColor = [255, 255, 255, 255];
11559
11564
  return withGLParameters(this.device, {
11560
- clearColor: [255, 255, 255, 255],
11561
11565
  blend: true,
11562
11566
  blendFunc: [0, 1],
11563
11567
  blendEquation: 32778,
@@ -11565,6 +11569,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
11565
11569
  depthTest: false
11566
11570
  }, () => super.render({
11567
11571
  ...options,
11572
+ clearColor,
11568
11573
  target: this.fbo,
11569
11574
  pass: "mask"
11570
11575
  }));
@@ -12064,7 +12069,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
12064
12069
  }
12065
12070
  });
12066
12071
  const depthBuffer = new WEBGLRenderbuffer(device, {
12067
- format: "depth16",
12072
+ format: "depth16unorm",
12068
12073
  width,
12069
12074
  height
12070
12075
  });
@@ -12078,11 +12083,9 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
12078
12083
  }
12079
12084
  destroyFBO(collisionGroup) {
12080
12085
  const fbo = this.collisionFBOs[collisionGroup];
12081
- const attachments = fbo.attachments;
12082
- for (const attachment of Object.values(attachments)) {
12083
- attachment.delete();
12084
- }
12085
- fbo.delete();
12086
+ fbo.colorAttachments[0]?.destroy();
12087
+ fbo.depthStencilAttachment?.destroy();
12088
+ fbo.destroy();
12086
12089
  delete this.collisionFBOs[collisionGroup];
12087
12090
  }
12088
12091
  };