{"version":3,"sources":["jsdelivr-header.js","/npm/@antv/g-plugin-device-renderer@2.5.1/src/components/Renderable3D.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/LightPool.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/Mesh.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/MeshUpdater.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/PickingIdGenerator.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/DeviceProgram.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/DynamicUniformBuffer.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/HashMap.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderCache.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/interfaces.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/interfaces.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderGraphPass.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderTarget.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/SingleSampledTexture.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderGraph.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/utils/layer.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/utils/projection.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/utils/matrix.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderInst.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderInstList.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderInstPool.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderInstManager.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderHelper.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderTargetDescription.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/RenderGraphHelpers.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/TextureHolder.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/render/TemporalTexture.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/lights/Light.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/lights/Fog.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/geometries/BufferGeometry.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/passes/FXAA.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/RenderGraphPlugin.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/PickingPlugin.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Batch.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/materials/Material.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/materials/ShaderMaterial.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/utils/enum.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/utils/compression.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/Instanced.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/SDF.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/utils/sample.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/utils/tiny-sdf.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/InstancedPath.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/InstancedFill.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/InstancedLine.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/Image.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/symbol/AlphaImage.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/symbol/GlyphAtlas.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/symbol/GlyphManager.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/symbol/SymbolQuad.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/Text.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/drawcalls/Mesh.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Circle.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Path.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Image.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Text.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Line.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Mesh.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/Rect.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/renderer/BatchManager.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/TexturePool.ts","/npm/@antv/g-plugin-device-renderer@2.5.1/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;4vCCJa,aAAY,cAAA,SAAA,IAAA,gBAAA,KAAA,GAAA,KAOvB,UAAyB,EAAE,IAPhB,aACJ,IAAM,kBCDf,IAAa,UAAS,WAIQ,OAAA,cAJR,SAAA,IAAA,gBAAA,KAAA,GACpB,KAGQ,OAAkB,EAAE,KAAA,IAAA,WAAA,MAO5B,SAAS,GACP,KAAK,OAAO,KAAK,GACjB,KAAK,YACP,GAAC,CAAA,IAAA,cAAA,MAED,SAAY,GACV,IAAM,EAAI,KAAK,OAAO,QAAQ,GAC9B,KAAK,OAAO,OAAO,EAAG,GACtB,KAAK,YACP,GAAC,CAAA,IAAA,SAAA,MAED,SAAO,GACL,KAAK,IAAM,CACb,GAAC,CAAA,IAAA,YAAA,MAED,SAAU,GACR,KAAK,IAAM,IACb,GAAC,CAAA,IAAA,SAAA,MAED,WACE,OAAO,KAAK,GACd,GAAC,CAAA,IAAA,eAAA,MAED,WACE,OAAO,KAAK,MACd,GAEA,CAAA,I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BAAuB,YAAM,MAAQ,IAAI,YAEjD,IAAM,EAAe,IAAI,aAAa,KAAK,YACrC,EAAY,IAAI,UAChB,EAAc,IAAI,YAAY,KAAK,QAAS,GAC5C,EAAqB,IAAI,mBAEzB,EAAiB,IAAI,eACrB,EAAe,IAAI,aACnB,GAAqC,gKAAA,EAAA,GACxC,YAAM,OAAS,GACf,YAAM,QAAU,GAChB,YAAM,SAAW,GACjB,YAAM,KAAO,GACb,YAAM,QAAU,GAChB,YAAM,KAAO,IAAI,cACjB,YAAM,MAAQ,IAAI,eAClB,YAAM,KAAO,IAAI,cACjB,YAAM,KAAO,IAAI,cACjB,YAAM,KAAO,IAAI,cAAc,gCAAA,EAC/B,YAAM,WAAQ,GACd,YAAM,UAAO,IAGV,EAAe,IAAI,aACvB,EACA,EACA,EACA,GAGI,EAAoB,IAAI,kBAC5B,EACA,EACA,EACA,EACA,KAAK,SAEP,KAAK,mBAAmB,GACxB,KAAK,mBACH,IAAI,cACF,EACA,EACA,EACA,GAGN,GAAC,CAAA,IAAA,UAAA,MACD,SAAQ,UACC,EAAQ,uBAAuB,YAAM,KAC9C,GAAC,CAAA,IAAA,uBAAA,MAED,WACE,OAAO,KAAK,QAAQ,EACtB,GAAC,CAAA,IAAA,YAAA,MAED,WACE,OAAO,KAAK,uBAAuB,WACrC,GAAC,CAAA,IAAA,eAAA,MAED,WACE,OAAO,KAAK,uBAAuB,cACrC,GAAC,CAAA,IAAA,cAAA,MAED,SACE,EACA,EACA,GAEA,OAAO,KAAK,uBAAuB,YACjC,EACA,EACA,EAEJ,GAAC,CAAA,IAAA,YAAA,MAED,SAAU,GACR,OAAO,KAAK,uBAAuB,UAAU,EAC/C,GAAC,CAAA,IAAA,gBAAA,MAED,SAAc,GACZ,KAAK,WAAU,4BACV,GAAA,KAAK,YACL,EAEP,IAAC,CAtGgB,CAAS,8B","file":"/npm/@antv/g-plugin-device-renderer@2.5.1/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@antv/g-plugin-device-renderer@2.5.1/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import type { Instanced } from '../drawcalls';\n\nexport class Renderable3D {\n  static tag = 'c-renderable-3d';\n\n  pickingId: number;\n\n  encodedPickingColor: [number, number, number];\n\n  drawcalls: Instanced[] = [];\n}\n","import type { Fog, Light } from './lights';\n\nexport class LightPool {\n  /**\n   * lights\n   */\n  private lights: Light[] = [];\n\n  /**\n   * support only 1 fog\n   */\n  private fog: Fog;\n\n  addLight(light: Light) {\n    this.lights.push(light);\n    this.sortLights();\n  }\n\n  removeLight(light: Light) {\n    const i = this.lights.indexOf(light);\n    this.lights.splice(i, 1);\n    this.sortLights();\n  }\n\n  addFog(fog: Fog) {\n    this.fog = fog;\n  }\n\n  removeFog(fog: Fog) {\n    this.fog = null;\n  }\n\n  getFog() {\n    return this.fog;\n  }\n\n  getAllLights() {\n    return this.lights;\n  }\n\n  /**\n   * USE_LIGHT\n   * NUM_AMBIENT_LIGHTS\n   * NUM_DIR_LIGHTS\n   */\n  getDefines(): Record<string, number | boolean> {\n    const defines = {\n      USE_LIGHT: !!this.lights.length,\n    };\n    this.lights.forEach((light) => {\n      if (!defines[light.define]) {\n        defines[light.define] = 0;\n      }\n\n      defines[light.define]++;\n    });\n\n    return defines;\n  }\n\n  private sortLights() {\n    this.lights.sort((a, b) => a.order - b.order);\n  }\n}\n","import type {\n  BaseStyleProps,\n  DisplayObjectConfig,\n  ParsedBaseStyleProps,\n} from '@antv/g-lite';\nimport { DisplayObject, Shape } from '@antv/g-lite';\nimport type { BufferGeometry } from './geometries';\nimport type { Material } from './materials';\n\nexport interface MeshStyleProps extends BaseStyleProps {\n  x?: number | string;\n  y?: number | string;\n  z?: number | string;\n  geometry: BufferGeometry;\n  material: Material;\n}\n\nexport interface ParsedMeshStyleProps extends ParsedBaseStyleProps {\n  x: number;\n  y: number;\n  z: number;\n  geometry: BufferGeometry;\n  material: Material;\n}\n\nexport class Mesh<GeometryProps = any> extends DisplayObject<\n  GeometryProps & MeshStyleProps\n> {\n  static PARSED_STYLE_LIST = new Set([\n    ...DisplayObject.PARSED_STYLE_LIST,\n    'x',\n    'y',\n    'z',\n    'geometry',\n    'material',\n  ]);\n\n  constructor({\n    style,\n    ...rest\n  }: DisplayObjectConfig<GeometryProps & MeshStyleProps>) {\n    super({\n      type: Shape.MESH,\n      style: {\n        x: '',\n        y: '',\n        z: '',\n        lineWidth: 0,\n        ...style,\n      },\n      ...rest,\n    });\n\n    this.cullable.enable = false;\n\n    this.style.geometry.meshes.push(this);\n    this.style.material.meshes.push(this);\n  }\n\n  // getVertexBufferData(bufferIndex: number) {\n  //   return this.style.geometry.vertexBuffers[bufferIndex];\n  // }\n\n  // setVertexBufferData(descriptor: {\n  //   bufferIndex: number;\n  //   byteOffset: number;\n  //   data: ArrayBufferView;\n  // }) {}\n\n  destroy() {\n    super.destroy();\n\n    // detach from geometry\n    let { meshes } = this.style.geometry;\n    let index = meshes.indexOf(this);\n    meshes.splice(index, 1);\n\n    // detach from material\n    meshes = this.style.material.meshes;\n    index = meshes.indexOf(this);\n    meshes.splice(index, 1);\n  }\n}\n","import type { GeometryAABBUpdater } from '@antv/g-lite';\nimport type { ParsedMeshStyleProps } from './Mesh';\n\nexport class MeshUpdater implements GeometryAABBUpdater<ParsedMeshStyleProps> {\n  update(parsedStyle: ParsedMeshStyleProps) {\n    const { x = 0, y = 0, z = 0, geometry } = parsedStyle;\n\n    const aabb = geometry.computeBoundingBox();\n\n    return {\n      cx: x,\n      cy: y,\n      cz: z,\n      hwidth: aabb.halfExtents[0],\n      hheight: aabb.halfExtents[1],\n      hdepth: aabb.halfExtents[2],\n    };\n  }\n}\n","import type { DisplayObject } from '@antv/g-lite';\n\nexport class PickingIdGenerator {\n  private counter = 0;\n\n  private id2DisplayObjectMap: Record<number, DisplayObject> = {};\n\n  getId(displayObject: DisplayObject) {\n    const id = this.counter++;\n    this.id2DisplayObjectMap[id] = displayObject;\n    return id;\n  }\n\n  getById(id: number): DisplayObject {\n    return this.id2DisplayObjectMap[id];\n  }\n\n  deleteById(id: number) {\n    delete this.id2DisplayObjectMap[id];\n  }\n\n  reset() {\n    this.counter = 0;\n    this.id2DisplayObjectMap = {};\n  }\n\n  decodePickingColor(color: Uint8Array): number {\n    const [i1, i2, i3] = color;\n    const index = i1 + i2 * 256 + i3 * 65536 - 1;\n    return index;\n  }\n\n  encodePickingColor(featureIdx: number): [number, number, number] {\n    return [\n      (featureIdx + 1) & 255,\n      ((featureIdx + 1) >> 8) & 255,\n      (((featureIdx + 1) >> 8) >> 8) & 255,\n    ];\n  }\n}\n","import { isNil } from '@antv/util';\nimport { assert, nullify } from '@antv/g-device-api';\n\nexport class DeviceProgram {\n  name = '(unnamed)';\n\n  // Compiled program.\n  preprocessedVert = '';\n  preprocessedFrag = '';\n\n  // Inputs.\n  both = '';\n  vert = '';\n  frag = '';\n  defines: Record<string, string> = {};\n\n  definesChanged(): void {\n    this.preprocessedVert = '';\n    this.preprocessedFrag = '';\n  }\n\n  setDefineString(name: string, v: string | null): boolean {\n    if (v !== null) {\n      if (this.defines[name] === v) return false;\n      this.defines[name] = v;\n    } else {\n      if (isNil(this.defines[name])) return false;\n      delete this.defines[name];\n    }\n    this.definesChanged();\n    return true;\n  }\n\n  setDefineBool(name: string, v: boolean): boolean {\n    return this.setDefineString(name, v ? '1' : null);\n  }\n\n  getDefineString(name: string): string | null {\n    return nullify(this.defines[name]);\n  }\n\n  getDefineBool(name: string): boolean {\n    const str = this.getDefineString(name);\n    if (str !== null) assert(str === '1');\n    return str !== null;\n  }\n}\n","import type { Device, Buffer } from '@antv/g-device-api';\nimport {\n  BufferUsage,\n  BufferFrequencyHint,\n  alignNonPowerOfTwo,\n  assert,\n  assertExists,\n} from '@antv/g-device-api';\n\n// This is a very basic linear allocator. We allocate offsets in-order.\nexport class DynamicUniformBuffer {\n  private device: Device;\n  private uniformBufferWordAlignment: number;\n  private uniformBufferMaxPageWordSize: number;\n\n  /**\n   * Word count, 4 bytes per word\n   */\n  private currentBufferWordSize = -1;\n  private currentWordOffset = 0;\n  buffer: Buffer | null = null;\n\n  private shadowBufferF32: Float32Array | null = null;\n  private shadowBufferU8: Uint8Array | null = null;\n\n  constructor(device: Device) {\n    this.device = device;\n    const limits = device.queryLimits();\n    this.uniformBufferWordAlignment = limits.uniformBufferWordAlignment;\n    this.uniformBufferMaxPageWordSize = limits.uniformBufferMaxPageWordSize;\n  }\n\n  isSupportedUBO() {\n    // UBO not supported in WebGL1\n    return this.device.queryVendorInfo().platformString !== 'WebGL1';\n  }\n\n  private findPageIndex(wordOffset: number): number {\n    return (wordOffset / this.uniformBufferMaxPageWordSize) | 0;\n  }\n\n  allocateChunk(wordCount: number): number {\n    wordCount = alignNonPowerOfTwo(wordCount, this.uniformBufferWordAlignment);\n    assert(wordCount < this.uniformBufferMaxPageWordSize);\n\n    let wordOffset = this.currentWordOffset;\n\n    // If we straddle the page, then put it at the start of the next one.\n    if (\n      this.findPageIndex(wordOffset) !==\n      this.findPageIndex(wordOffset + wordCount - 1)\n    )\n      wordOffset = alignNonPowerOfTwo(\n        wordOffset,\n        this.uniformBufferMaxPageWordSize,\n      );\n\n    this.currentWordOffset = wordOffset + wordCount;\n    this.ensureShadowBuffer(wordOffset, wordCount);\n\n    return wordOffset;\n  }\n\n  private ensureShadowBuffer(wordOffset: number, wordCount: number): void {\n    if (this.shadowBufferU8 === null || this.shadowBufferF32 === null) {\n      const newWordCount = alignNonPowerOfTwo(\n        this.currentWordOffset,\n        this.uniformBufferMaxPageWordSize,\n      );\n      this.shadowBufferU8 = new Uint8Array(newWordCount * 4);\n      this.shadowBufferF32 = new Float32Array(this.shadowBufferU8.buffer);\n    } else if (wordOffset + wordCount >= this.shadowBufferF32.length) {\n      assert(\n        wordOffset < this.currentWordOffset &&\n          wordOffset + wordCount <= this.currentWordOffset,\n      );\n\n      // Grow logarithmically, aligned to page size.\n      const newWordCount = alignNonPowerOfTwo(\n        Math.max(this.currentWordOffset, this.shadowBufferF32.length * 2),\n        this.uniformBufferMaxPageWordSize,\n      );\n      const newBuffer = new Uint8Array(newWordCount * 4);\n\n      newBuffer.set(this.shadowBufferU8, 0);\n      this.shadowBufferU8 = newBuffer;\n      this.shadowBufferF32 = new Float32Array(this.shadowBufferU8.buffer);\n\n      if (!(this.currentWordOffset <= newWordCount))\n        throw new Error(\n          `Assert fail: this.currentWordOffset [${this.currentWordOffset}] <= newWordCount [${newWordCount}]`,\n        );\n    }\n  }\n\n  /**\n   * Return the CPU data buffer used internally. Fill this in to submit data to the CPU. Write to\n   * it with the offset that was returned from {@see allocateChunk}.\n   */\n  mapBufferF32(): Float32Array {\n    return assertExists(this.shadowBufferF32);\n  }\n\n  prepareToRender(): void {\n    if (this.shadowBufferF32 === null) {\n      return;\n    }\n\n    const shadowBufferF32 = assertExists(this.shadowBufferF32);\n\n    if (shadowBufferF32.length !== this.currentBufferWordSize) {\n      this.currentBufferWordSize = shadowBufferF32.length;\n\n      if (this.buffer !== null) {\n        this.buffer.destroy();\n      }\n\n      this.buffer = this.device.createBuffer({\n        // in bytes length\n        viewOrSize: this.currentBufferWordSize * 4,\n        usage: BufferUsage.UNIFORM,\n        hint: BufferFrequencyHint.DYNAMIC,\n      });\n    }\n\n    const wordCount = alignNonPowerOfTwo(\n      this.currentWordOffset,\n      this.uniformBufferMaxPageWordSize,\n    );\n    if (!(wordCount <= this.currentBufferWordSize))\n      throw new Error(\n        `Assert fail: wordCount [${wordCount}] (${this.currentWordOffset} aligned ${this.uniformBufferMaxPageWordSize}) <= this.currentBufferWordSize [${this.currentBufferWordSize}]`,\n      );\n\n    if (this.isSupportedUBO()) {\n      const buffer = assertExists(this.buffer);\n      buffer.setSubData(0, this.shadowBufferU8, 0, wordCount * 4);\n    }\n\n    // Reset the offset for next frame.\n    this.currentWordOffset = 0;\n  }\n\n  destroy(): void {\n    if (this.buffer !== null) this.buffer.destroy();\n\n    this.shadowBufferF32 = null;\n    this.shadowBufferU8 = null;\n  }\n}\n","/* eslint-disable max-classes-per-file */\n// Jenkins One-at-a-Time hash from http://www.burtleburtle.net/bob/hash/doobs.html\nexport function hashCodeNumberUpdate(hash: number, v: number): number {\n  hash += v;\n  hash += hash << 10;\n  hash += hash >>> 6;\n  return hash >>> 0;\n}\n\nexport function hashCodeNumberFinish(hash: number): number {\n  hash += hash << 3;\n  hash ^= hash >>> 11;\n  hash += hash << 15;\n  return hash >>> 0;\n}\n\n// Pass this as a hash function to use a one-bucket HashMap (equivalent to linear search in an array),\n// which can be efficient for small numbers of items.\nexport function nullHashFunc<T>(k: T): number {\n  return 0;\n}\n\nexport type EqualFunc<K> = (a: K, b: K) => boolean;\nexport type HashFunc<K> = (a: K) => number;\n\nclass HashBucket<K, V> {\n  keys: K[] = [];\n  values: V[] = [];\n}\n\nexport class HashMap<K, V> {\n  buckets = new Map<number, HashBucket<K, V>>();\n\n  constructor(\n    private keyEqualFunc: EqualFunc<K>,\n    private keyHashFunc: HashFunc<K>,\n  ) {}\n\n  private findBucketIndex(bucket: HashBucket<K, V>, k: K): number {\n    for (let i = 0; i < bucket.keys.length; i++)\n      if (this.keyEqualFunc(k, bucket.keys[i])) return i;\n    return -1;\n  }\n\n  private findBucket(k: K): HashBucket<K, V> | undefined {\n    const bw = this.keyHashFunc(k);\n    return this.buckets.get(bw);\n  }\n\n  get(k: K): V | null {\n    const bucket = this.findBucket(k);\n    if (bucket === undefined) return null;\n    const bi = this.findBucketIndex(bucket, k);\n    if (bi < 0) return null;\n    return bucket.values[bi];\n  }\n\n  add(k: K, v: V): void {\n    const bw = this.keyHashFunc(k);\n    if (this.buckets.get(bw) === undefined)\n      this.buckets.set(bw, new HashBucket<K, V>());\n    const bucket = this.buckets.get(bw);\n    bucket.keys.push(k);\n    bucket.values.push(v);\n  }\n\n  delete(k: K): void {\n    const bucket = this.findBucket(k);\n    if (bucket === undefined) return;\n    const bi = this.findBucketIndex(bucket, k);\n    if (bi === -1) return;\n    bucket.keys.splice(bi, 1);\n    bucket.values.splice(bi, 1);\n  }\n\n  clear(): void {\n    this.buckets.clear();\n  }\n\n  size(): number {\n    let acc = 0;\n    for (const bucket of this.buckets.values()) acc += bucket.values.length;\n    return acc;\n  }\n\n  *values(): IterableIterator<V> {\n    for (const bucket of this.buckets.values())\n      for (let j = bucket.values.length - 1; j >= 0; j--)\n        yield bucket.values[j];\n  }\n}\n","import type {\n  AttachmentState,\n  Bindings,\n  BindingsDescriptor,\n  ChannelBlendState,\n  Color,\n  Device,\n  InputLayout,\n  InputLayoutDescriptor,\n  MegaStateDescriptor,\n  Program,\n  ProgramDescriptorSimple,\n  RenderPipeline,\n  RenderPipelineDescriptor,\n  Sampler,\n  SamplerDescriptor,\n} from '@antv/g-device-api';\nimport {\n  assert,\n  bindingsDescriptorCopy,\n  bindingsDescriptorEquals,\n  inputLayoutDescriptorCopy,\n  inputLayoutDescriptorEquals,\n  renderPipelineDescriptorCopy,\n  renderPipelineDescriptorEquals,\n  samplerDescriptorEquals,\n  preprocessProgram_GLSL,\n  ProgramDescriptorSimpleWithOrig,\n} from '@antv/g-device-api';\nimport { DeviceProgram } from './DeviceProgram';\nimport {\n  hashCodeNumberFinish,\n  hashCodeNumberUpdate,\n  HashMap,\n  nullHashFunc,\n} from './HashMap';\n\nfunction preprocessProgramObj_GLSL(\n  device: Device,\n  obj: DeviceProgram,\n): ProgramDescriptorSimpleWithOrig {\n  const defines = obj.defines !== undefined ? obj.defines : null;\n  const vert = obj.both !== undefined ? obj.both + obj.vert : obj.vert;\n  const frag = obj.both !== undefined ? obj.both + obj.frag : obj.frag;\n  return preprocessProgram_GLSL(device.queryVendorInfo(), vert, frag, defines);\n}\n\nfunction programDescriptorSimpleEquals(\n  a: ProgramDescriptorSimple,\n  b: ProgramDescriptorSimple,\n): boolean {\n  assert(a.preprocessedVert !== '' && b.preprocessedVert !== '');\n  assert(a.preprocessedFrag !== '' && b.preprocessedFrag !== '');\n  return (\n    a.preprocessedVert === b.preprocessedVert &&\n    a.preprocessedFrag === b.preprocessedFrag\n  );\n}\n\nfunction programDescriptorSimpleCopy(\n  a: ProgramDescriptorSimple,\n): ProgramDescriptorSimple {\n  const { preprocessedVert } = a;\n  const { preprocessedFrag } = a;\n  const { vert } = a;\n  const { frag } = a;\n  return { preprocessedVert, preprocessedFrag, vert, frag };\n}\n\nfunction blendStateHash(hash: number, a: ChannelBlendState): number {\n  hash = hashCodeNumberUpdate(hash, a.blendMode);\n  hash = hashCodeNumberUpdate(hash, a.blendSrcFactor);\n  hash = hashCodeNumberUpdate(hash, a.blendDstFactor);\n  return hash;\n}\n\nfunction attachmentStateHash(hash: number, a: AttachmentState): number {\n  hash = blendStateHash(hash, a.rgbBlendState);\n  hash = blendStateHash(hash, a.alphaBlendState);\n  hash = hashCodeNumberUpdate(hash, a.channelWriteMask);\n  return hash;\n}\n\nfunction colorHash(hash: number, a: Color): number {\n  hash = hashCodeNumberUpdate(\n    hash,\n    (a.r << 24) | (a.g << 16) | (a.b << 8) | a.a,\n  );\n  return hash;\n}\n\nfunction megaStateDescriptorHash(hash: number, a: MegaStateDescriptor): number {\n  for (let i = 0; i < a.attachmentsState.length; i++)\n    hash = attachmentStateHash(hash, a.attachmentsState[i]);\n  hash = colorHash(hash, a.blendConstant);\n  hash = hashCodeNumberUpdate(hash, a.depthCompare);\n  hash = hashCodeNumberUpdate(hash, a.depthWrite ? 1 : 0);\n  hash = hashCodeNumberUpdate(hash, a.stencilFront?.compare);\n  hash = hashCodeNumberUpdate(hash, a.stencilFront?.passOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilFront?.failOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilFront?.depthFailOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilBack?.compare);\n  hash = hashCodeNumberUpdate(hash, a.stencilBack?.passOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilBack?.failOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilBack?.depthFailOp);\n  hash = hashCodeNumberUpdate(hash, a.stencilWrite ? 1 : 0);\n  hash = hashCodeNumberUpdate(hash, a.cullMode);\n  hash = hashCodeNumberUpdate(hash, a.frontFace ? 1 : 0);\n  hash = hashCodeNumberUpdate(hash, a.polygonOffset ? 1 : 0);\n  return hash;\n}\n\nfunction renderPipelineDescriptorHash(a: RenderPipelineDescriptor): number {\n  let hash = 0;\n  hash = hashCodeNumberUpdate(hash, a.program.id);\n  if (a.inputLayout !== null)\n    hash = hashCodeNumberUpdate(hash, a.inputLayout.id);\n  hash = megaStateDescriptorHash(hash, a.megaStateDescriptor);\n  for (let i = 0; i < a.colorAttachmentFormats.length; i++)\n    hash = hashCodeNumberUpdate(hash, a.colorAttachmentFormats[i] || 0);\n  hash = hashCodeNumberUpdate(hash, a.depthStencilAttachmentFormat || 0);\n  return hashCodeNumberFinish(hash);\n}\n\nfunction bindingsDescriptorHash(a: BindingsDescriptor): number {\n  let hash = 0;\n  for (let i = 0; i < a.samplerBindings.length; i++) {\n    const binding = a.samplerBindings[i];\n    if (binding !== null && binding.texture !== null)\n      hash = hashCodeNumberUpdate(hash, binding.texture.id);\n  }\n  for (let i = 0; i < a.uniformBufferBindings.length; i++) {\n    const binding = a.uniformBufferBindings[i];\n    if (binding !== null && binding.buffer !== null) {\n      hash = hashCodeNumberUpdate(hash, binding.buffer.id);\n      hash = hashCodeNumberUpdate(hash, binding.binding);\n      hash = hashCodeNumberUpdate(hash, binding.offset);\n      hash = hashCodeNumberUpdate(hash, binding.size);\n    }\n  }\n  return hashCodeNumberFinish(hash);\n}\n\nexport class RenderCache {\n  device: Device;\n\n  private bindingsCache = new HashMap<BindingsDescriptor, Bindings>(\n    bindingsDescriptorEquals,\n    bindingsDescriptorHash,\n  );\n  private renderPipelinesCache = new HashMap<\n    RenderPipelineDescriptor,\n    RenderPipeline\n  >(renderPipelineDescriptorEquals, renderPipelineDescriptorHash);\n  private inputLayoutsCache = new HashMap<InputLayoutDescriptor, InputLayout>(\n    inputLayoutDescriptorEquals,\n    nullHashFunc,\n  );\n  private programCache = new HashMap<ProgramDescriptorSimple, Program>(\n    programDescriptorSimpleEquals,\n    nullHashFunc,\n  );\n  private samplerCache = new HashMap<SamplerDescriptor, Sampler>(\n    samplerDescriptorEquals,\n    nullHashFunc,\n  );\n\n  constructor(device: Device) {\n    this.device = device;\n  }\n\n  createBindings(descriptor: BindingsDescriptor): Bindings {\n    let bindings = this.bindingsCache.get(descriptor);\n    if (bindings === null) {\n      const descriptorCopy = bindingsDescriptorCopy(descriptor);\n\n      descriptorCopy.uniformBufferBindings =\n        descriptorCopy.uniformBufferBindings.filter(({ size }) => size > 0);\n\n      bindings = this.device.createBindings(descriptorCopy);\n      this.bindingsCache.add(descriptorCopy, bindings);\n    }\n    return bindings;\n  }\n\n  createRenderPipeline(descriptor: RenderPipelineDescriptor): RenderPipeline {\n    let renderPipeline = this.renderPipelinesCache.get(descriptor);\n    if (renderPipeline === null) {\n      const descriptorCopy = renderPipelineDescriptorCopy(descriptor);\n      renderPipeline = this.device.createRenderPipeline({\n        ...descriptorCopy,\n        colorAttachmentFormats: descriptor.colorAttachmentFormats.filter(\n          (f) => f,\n        ),\n      });\n      this.renderPipelinesCache.add(descriptorCopy, renderPipeline);\n    }\n    return renderPipeline;\n  }\n\n  createInputLayout(descriptor: InputLayoutDescriptor): InputLayout {\n    // remove hollows\n    descriptor.vertexBufferDescriptors =\n      descriptor.vertexBufferDescriptors.filter((d) => !!d);\n    let inputLayout = this.inputLayoutsCache.get(descriptor);\n    if (inputLayout === null) {\n      const descriptorCopy = inputLayoutDescriptorCopy(descriptor);\n      inputLayout = this.device.createInputLayout(descriptorCopy);\n      this.inputLayoutsCache.add(descriptorCopy, inputLayout);\n    }\n    return inputLayout;\n  }\n\n  createProgramSimple(deviceProgram: DeviceProgram): Program {\n    const { vert, frag, preprocessedFrag, preprocessedVert } = deviceProgram;\n\n    let program: Program = null;\n    if (preprocessedVert && preprocessedFrag) {\n      program = this.programCache.get({\n        vert,\n        frag,\n        preprocessedFrag,\n        preprocessedVert,\n      });\n    }\n\n    if (program === null) {\n      const { preprocessedVert, preprocessedFrag } = preprocessProgramObj_GLSL(\n        this.device,\n        deviceProgram,\n      );\n      deviceProgram.preprocessedVert = preprocessedVert;\n      deviceProgram.preprocessedFrag = preprocessedFrag;\n\n      const descriptorCopy = programDescriptorSimpleCopy(deviceProgram);\n\n      program = this.device.createProgramSimple(\n        {\n          vertex: {\n            glsl: preprocessedVert,\n          },\n          fragment: {\n            glsl: preprocessedFrag,\n          },\n        },\n        vert,\n      );\n      this.programCache.add(descriptorCopy, program);\n    }\n\n    return program;\n  }\n\n  createSampler(descriptor: SamplerDescriptor): Sampler {\n    let sampler = this.samplerCache.get(descriptor);\n    if (sampler === null) {\n      sampler = this.device.createSampler(descriptor);\n      this.samplerCache.add(descriptor, sampler);\n    }\n    return sampler;\n  }\n\n  destroy(): void {\n    for (const bindings of this.bindingsCache.values()) bindings.destroy();\n    for (const renderPipeline of this.renderPipelinesCache.values())\n      renderPipeline.destroy();\n    for (const inputLayout of this.inputLayoutsCache.values())\n      inputLayout.destroy();\n    for (const program of this.programCache.values()) program.destroy();\n    for (const sampler of this.samplerCache.values()) sampler.destroy();\n    this.bindingsCache.clear();\n    this.renderPipelinesCache.clear();\n    this.inputLayoutsCache.clear();\n    this.programCache.clear();\n    this.samplerCache.clear();\n  }\n}\n","import type { SwapChain } from '@antv/g-device-api';\n\nexport interface DeviceContribution {\n  createSwapChain: ($canvas: HTMLCanvasElement) => Promise<SwapChain>;\n}\n\nexport enum ToneMapping {\n  NONE = 'none',\n  LINEAR = 'LinearToneMapping',\n  REINHARD = 'ReinhardToneMapping',\n  CINEON = 'OptimizedCineonToneMapping',\n  ACES_FILMIC = 'ACESFilmicToneMapping',\n  CUSTOM = 'CustomToneMapping',\n}\n\nexport interface RendererParameters {\n  toneMapping: ToneMapping;\n  toneMappingExposure: number;\n}\n\nexport interface DeviceRendererPluginOptions {\n  enableFXAA: boolean;\n}\n","import type {\n  QueryPool,\n  RenderPass,\n  RenderTarget,\n  Texture,\n} from '@antv/g-device-api';\nimport type { RGRenderTargetDescription } from './RenderTargetDescription';\n\nexport enum RGAttachmentSlot {\n  Color0 = 0,\n  Color1 = 1,\n  Color2 = 2,\n  Color3 = 3,\n  ColorMax = Color3,\n  DepthStencil,\n}\n\nexport interface RGPassScope {\n  getResolveTextureForID: (id: number) => Texture;\n  getRenderTargetAttachment: (slot: RGAttachmentSlot) => RenderTarget | null;\n  getRenderTargetTexture: (slot: RGAttachmentSlot) => Texture | null;\n}\n\nexport type PassSetupFunc = (renderPass: IRenderGraphPass) => void;\nexport type PassExecFunc = (\n  passRenderer: RenderPass,\n  scope: RGPassScope,\n) => void;\nexport type PassPostFunc = (scope: RGPassScope) => void;\n\nexport interface IRenderGraphPass {\n  /**\n   * Set the debug name of a given pass.\n   */\n  setDebugName: (debugName: string) => void;\n\n  /**\n   * Set whether to output a debug thumbnail. false by default.\n   */\n  pushDebugThumbnail: (attachmentSlot: RGAttachmentSlot) => void;\n\n  /**\n   * Attach the given renderTargetID to the given attachmentSlot.\n   * This determines which render targets this pass will render to.\n   */\n  attachRenderTargetID: (\n    attachmentSlot: RGAttachmentSlot,\n    renderTargetID: number,\n  ) => void;\n\n  /**\n   * Attach the occlusion query pool used by this rendering pass.\n   */\n  attachOcclusionQueryPool: (queryPool: QueryPool) => void;\n\n  /**\n   * Set the viewport for the given render pass in *normalized* coordinates (0..1).\n   * Not required; defaults to full viewport.\n   */\n  setViewport(x: number, y: number, w: number, h: number): void;\n\n  /**\n   * Attach the resolve texture ID to the given pass. All resolve textures used within the pass\n   * must be attached before-hand in order for the scheduler to properly allocate our resolve texture.\n   */\n  attachResolveTexture: (resolveTextureID: number) => void;\n\n  /**\n   * Set the pass's execution callback.\n   */\n  exec: (func: PassExecFunc) => void;\n\n  /**\n   * Set the pass's post callback\n   */\n  post: (func: PassPostFunc) => void;\n\n  addExtraRef: (renderTargetID: RGAttachmentSlot) => void;\n}\n\nexport interface RGGraphBuilder {\n  /**\n   * Add a new pass. {@param setupFunc} will be called *immediately* to set up the\n   * pass. This is wrapped in a function simply to limit the scope of a pass. It\n   * is possible I might change this in the future to limit the allocations caused\n   * by closures.\n   */\n  pushPass: (setupFunc: PassSetupFunc) => void;\n\n  /**\n   * Tell the system about a render target with the given descriptions. Render targets\n   * are \"virtual\", and is only backed by an actual device resource when inside of a pass.\n   * This allows render targets to be reused without the user having to track any of this\n   * logic.\n   *\n   * When a pass has a render target ID attached, the created {@see GfxRenderPass} will have\n   * the render targets already bound. To use a render target as an input to a rendering\n   * algorithm, it must first be \"resolved\" to a texture. Use {@see resolveRenderTarget} to\n   * get a resolved texture ID corresponding to a given render target.\n   *\n   * To retrieve actual backing resource for a given render target ID inside of a pass,\n   * use the {@see GfxrPassScope} given to the pass's execution or post callbacks, however\n   * this usage should be rarer than the resolve case.\n   */\n  createRenderTargetID: (\n    desc: Readonly<RGRenderTargetDescription>,\n    debugName: string,\n  ) => number;\n\n  /**\n   * Resolve the render target in slot {@param attachmentSlot} of pass {@param pass}, and return\n   * the resolve texture ID.\n   *\n   * To bind the image of a render target in a rendering pass, it first must be \"resolved\" to\n   * a texture. Please remember to attach the resolve texture to a pass where it is used with\n   * {@see GfxrPassScope::attachResolveTexture}. When in the pass's execution or post callbacks,\n   * you can retrieve a proper {@param GfxTexture} for a resolve texture ID with\n   * {@see GfxrPassScope::getResolveTextureForID}}.\n   */\n  resolveRenderTargetPassAttachmentSlot: (\n    pass: IRenderGraphPass,\n    attachmentSlot: RGAttachmentSlot,\n  ) => number;\n\n  /**\n   * Resolve the render target ID {@param renderTargetID}, and return the resolve texture ID.\n   *\n   * To bind the image of a render target in a rendering pass, it first must be \"resolved\" to\n   * a texture. Please remember to attach the resolve texture to a pass where it is used with\n   * {@see GfxrPassScope::attachResolveTexture}. When in the pass's execution or post callbacks,\n   * you can retrieve a proper {@param GfxTexture} for a resolve texture ID with\n   * {@see GfxrPassScope::getResolveTextureForID}}.\n   *\n   * This just looks up the last pass that drew to the render target {@param renderTargetID},\n   * and then calls {@see resolveRenderTargetPassAttachmentSlot} using the information it found.\n   */\n  resolveRenderTarget: (renderTargetID: number) => number;\n\n  /**\n   * Specify that the render target ID {@param renderTargetID} should be resolved to an\n   * externally-provided texture. The texture must have been allocated by the user, and it must\n   * match the dimensions of the render target.\n   *\n   * Warning: This API might change in the near future.\n   */\n  resolveRenderTargetToExternalTexture: (\n    renderTargetID: number,\n    texture: Texture,\n  ) => void;\n\n  /**\n   * Return the description that a render target was created with. This allows the creator to\n   * not have to pass information to any dependent modules to derive from it.\n   */\n  getRenderTargetDescription: (\n    renderTargetID: number,\n  ) => Readonly<RGRenderTargetDescription>;\n\n  /**\n   * Internal API.\n   */\n  getDebug: () => RGGraphBuilderDebug;\n}\n\nexport interface RGGraphBuilderDebug {\n  getPasses: () => IRenderGraphPass[];\n  getPassDebugThumbnails: (pass: IRenderGraphPass) => boolean[];\n  getPassRenderTargetID: (\n    pass: IRenderGraphPass,\n    slot: RGAttachmentSlot,\n  ) => number;\n  getRenderTargetIDDebugName: (renderTargetID: number) => string;\n}\n","import type {\n  QueryPool,\n  RenderPassDescriptor,\n  Texture,\n} from '@antv/g-device-api';\nimport { assert } from '@antv/g-device-api';\nimport type {\n  IRenderGraphPass,\n  PassExecFunc,\n  PassPostFunc,\n  RGAttachmentSlot,\n} from './interfaces';\nimport type { RGRenderTarget } from './RenderTarget';\n\nexport class RenderGraphPass implements IRenderGraphPass {\n  // RenderTargetAttachmentSlot => renderTargetID\n  renderTargetIDs: number[] = [];\n  renderTargetLevels: number[] = [];\n  // RenderTargetAttachmentSlot => resolveTextureID\n  resolveTextureOutputIDs: number[] = [];\n  // RenderTargetAttachmentSlot => Texture\n  resolveTextureOutputExternalTextures: Texture[] = [];\n  resolveTextureOutputExternalTextureLevel: number[] = [];\n  // List of resolveTextureIDs that we have a reference to.\n  resolveTextureInputIDs: number[] = [];\n  // RGAttachmentSlot => refcount.\n  renderTargetExtraRefs: boolean[] = [];\n\n  resolveTextureInputTextures: Texture[] = [];\n\n  renderTargets: (RGRenderTarget | null)[] = [];\n\n  // Execution state computed by scheduling.\n  descriptor: RenderPassDescriptor = {\n    colorAttachment: [],\n    colorAttachmentLevel: [],\n    colorResolveTo: [],\n    colorResolveToLevel: [],\n    colorStore: [],\n    depthStencilAttachment: null,\n    depthStencilResolveTo: null,\n    depthStencilStore: true,\n    colorClearColor: ['load'],\n    depthClearValue: 'load',\n    stencilClearValue: 'load',\n    occlusionQueryPool: null,\n  };\n\n  viewportX = 0;\n  viewportY = 0;\n  viewportW = 1;\n  viewportH = 1;\n\n  // Execution callback from user.\n  execFunc: PassExecFunc | null = null;\n  postFunc: PassPostFunc | null = null;\n\n  // Misc. state.\n  debugName: string;\n  debugThumbnails: boolean[] = [];\n\n  setDebugName(debugName: string): void {\n    this.debugName = debugName;\n  }\n\n  pushDebugThumbnail(attachmentSlot: RGAttachmentSlot): void {\n    this.debugThumbnails[attachmentSlot] = true;\n  }\n\n  setViewport(x: number, y: number, w: number, h: number): void {\n    this.viewportX = x;\n    this.viewportY = y;\n    this.viewportW = w;\n    this.viewportH = h;\n  }\n\n  attachRenderTargetID(\n    attachmentSlot: RGAttachmentSlot,\n    renderTargetID: number,\n    level = 0,\n  ): void {\n    assert(this.renderTargetIDs[attachmentSlot] === undefined);\n    this.renderTargetIDs[attachmentSlot] = renderTargetID;\n    this.renderTargetLevels[attachmentSlot] = level;\n  }\n\n  attachResolveTexture(resolveTextureID: number): void {\n    this.resolveTextureInputIDs.push(resolveTextureID);\n  }\n\n  attachOcclusionQueryPool(queryPool: QueryPool): void {\n    this.descriptor.occlusionQueryPool = queryPool;\n  }\n\n  exec(func: PassExecFunc): void {\n    assert(this.execFunc === null);\n    this.execFunc = func;\n  }\n\n  post(func: PassPostFunc): void {\n    assert(this.postFunc === null);\n    this.postFunc = func;\n  }\n\n  addExtraRef(slot: RGAttachmentSlot): void {\n    this.renderTargetExtraRefs[slot] = true;\n  }\n}\n","import type { Device, Format, RenderTarget, Texture } from '@antv/g-device-api';\nimport { assert, TextureDimension, TextureUsage } from '@antv/g-device-api';\nimport type { RGRenderTargetDescription } from './RenderTargetDescription';\n\nexport class RGRenderTarget {\n  debugName: string;\n\n  readonly dimension = TextureDimension.TEXTURE_2D;\n  readonly depthOrArrayLayers = 1;\n  readonly mipLevelCount = 1;\n\n  format: Format;\n  width = 0;\n  height = 0;\n  sampleCount = 0;\n  usage: TextureUsage = TextureUsage.RENDER_TARGET;\n\n  needsClear = true;\n  texture: Texture | null = null;\n  attachment: RenderTarget;\n  age = 0;\n\n  constructor(device: Device, desc: Readonly<RGRenderTargetDescription>) {\n    this.format = desc.format;\n    this.width = desc.width;\n    this.height = desc.height;\n    this.sampleCount = desc.sampleCount;\n\n    assert(this.sampleCount >= 1);\n\n    if (this.sampleCount > 1) {\n      // MSAA render targets must be backed by attachments.\n      this.attachment = device.createRenderTarget(this);\n    } else {\n      // Single-sampled textures can be backed by regular textures.\n      this.texture = device.createTexture(this);\n      this.attachment = device.createRenderTargetFromTexture(this.texture);\n    }\n  }\n\n  setDebugName(device: Device, debugName: string): void {\n    this.debugName = debugName;\n    if (this.texture !== null) {\n      device.setResourceName(this.texture, this.debugName);\n    }\n    device.setResourceName(this.attachment, this.debugName);\n  }\n\n  matchesDescription(desc: Readonly<RGRenderTargetDescription>): boolean {\n    return (\n      this.format === desc.format &&\n      this.width === desc.width &&\n      this.height === desc.height &&\n      this.sampleCount === desc.sampleCount\n    );\n  }\n\n  reset(desc: Readonly<RGRenderTargetDescription>): void {\n    assert(this.matchesDescription(desc));\n    this.age = 0;\n  }\n\n  destroy(): void {\n    this.attachment.destroy();\n  }\n}\n","import type { Device, Format, Texture } from '@antv/g-device-api';\nimport { assert, TextureDimension, TextureUsage } from '@antv/g-device-api';\nimport type { RGRenderTargetDescription } from './RenderTargetDescription';\n\n// Whenever we need to resolve a multi-sampled render target to a single-sampled texture,\n// we record an extra single-sampled texture here.\nexport class SingleSampledTexture {\n  readonly dimension = TextureDimension.TEXTURE_2D;\n  readonly depthOrArrayLayers = 1;\n  readonly mipLevelCount = 1;\n\n  readonly usage = TextureUsage.RENDER_TARGET;\n\n  format: Format;\n  width = 0;\n  height = 0;\n\n  texture: Texture;\n  age = 0;\n\n  constructor(device: Device, desc: Readonly<RGRenderTargetDescription>) {\n    this.format = desc.format;\n    this.width = desc.width;\n    this.height = desc.height;\n\n    this.texture = device.createTexture(this);\n  }\n\n  matchesDescription(desc: Readonly<RGRenderTargetDescription>): boolean {\n    return (\n      this.format === desc.format &&\n      this.width === desc.width &&\n      this.height === desc.height\n    );\n  }\n\n  reset(desc: Readonly<RGRenderTargetDescription>): void {\n    assert(this.matchesDescription(desc));\n    this.age = 0;\n  }\n\n  destroy(): void {\n    this.texture.destroy();\n  }\n}\n","/* eslint-disable max-classes-per-file */\nimport type { Device, RenderTarget, Texture } from '@antv/g-device-api';\nimport { assert, assertExists, fillArray } from '@antv/g-device-api';\nimport type {\n  PassSetupFunc,\n  RGGraphBuilder,\n  RGGraphBuilderDebug,\n} from './interfaces';\nimport { RGAttachmentSlot } from './interfaces';\nimport { RenderGraphPass } from './RenderGraphPass';\nimport { RGRenderTarget } from './RenderTarget';\nimport type { RGRenderTargetDescription } from './RenderTargetDescription';\nimport { SingleSampledTexture } from './SingleSampledTexture';\n\ninterface ResolveParam {\n  resolveTo: Texture | null;\n  store: boolean;\n  level: number;\n}\n\nclass GraphImpl {\n  // [Symbol.species]?: 'RGGraph';\n\n  // Used for determining scheduling.\n  renderTargetDescriptions: Readonly<RGRenderTargetDescription>[] = [];\n  resolveTextureRenderTargetIDs: number[] = [];\n\n  passes: RenderGraphPass[] = [];\n\n  // Debugging.\n  renderTargetDebugNames: string[] = [];\n}\n\nexport class RenderGraph implements RGGraphBuilder {\n  private device: Device;\n  // For scope callbacks.\n  private currentPass: RenderGraphPass | null = null;\n\n  // #region Resource Creation & Caching\n  renderTargetDeadPool: RGRenderTarget[] = [];\n  private singleSampledTextureDeadPool: SingleSampledTexture[] = [];\n\n  constructor(device: Device) {\n    this.device = device;\n  }\n\n  private acquireRenderTargetForDescription(\n    desc: Readonly<RGRenderTargetDescription>,\n  ): RGRenderTarget {\n    for (let i = 0; i < this.renderTargetDeadPool.length; i++) {\n      const freeRenderTarget = this.renderTargetDeadPool[i];\n      if (freeRenderTarget.matchesDescription(desc)) {\n        // Pop it off the list.\n        freeRenderTarget.reset(desc);\n        this.renderTargetDeadPool.splice(i--, 1);\n        return freeRenderTarget;\n      }\n    }\n\n    // Allocate a new render target.\n    return new RGRenderTarget(this.device, desc);\n  }\n\n  private acquireSingleSampledTextureForDescription(\n    desc: Readonly<RGRenderTargetDescription>,\n  ): SingleSampledTexture {\n    for (let i = 0; i < this.singleSampledTextureDeadPool.length; i++) {\n      const freeSingleSampledTexture = this.singleSampledTextureDeadPool[i];\n      if (freeSingleSampledTexture.matchesDescription(desc)) {\n        // Pop it off the list.\n        freeSingleSampledTexture.reset(desc);\n        this.singleSampledTextureDeadPool.splice(i--, 1);\n        return freeSingleSampledTexture;\n      }\n    }\n\n    // Allocate a new resolve texture.\n    return new SingleSampledTexture(this.device, desc);\n  }\n  // #endregion\n\n  // #region Graph Builder\n  private currentGraph: GraphImpl | null = null;\n\n  beginGraphBuilder() {\n    assert(this.currentGraph === null);\n    this.currentGraph = new GraphImpl();\n  }\n\n  pushPass(setupFunc: PassSetupFunc): void {\n    const pass = new RenderGraphPass();\n    setupFunc(pass);\n    this.currentGraph.passes.push(pass);\n  }\n\n  createRenderTargetID(\n    desc: Readonly<RGRenderTargetDescription>,\n    debugName: string,\n  ): number {\n    this.currentGraph.renderTargetDebugNames.push(debugName);\n    return this.currentGraph.renderTargetDescriptions.push(desc) - 1;\n  }\n\n  private createResolveTextureID(renderTargetID: number): number {\n    return (\n      this.currentGraph.resolveTextureRenderTargetIDs.push(renderTargetID) - 1\n    );\n  }\n\n  /**\n   * 查找最靠近输出的一个关联目标 RT 的 RGPass\n   */\n  private findMostRecentPassThatAttachedRenderTarget(\n    renderTargetID: number,\n  ): RenderGraphPass | null {\n    for (let i = this.currentGraph.passes.length - 1; i >= 0; i--) {\n      const pass = this.currentGraph.passes[i];\n      if (pass.renderTargetIDs.includes(renderTargetID)) return pass;\n    }\n\n    return null;\n  }\n\n  resolveRenderTargetPassAttachmentSlot(\n    pass: RenderGraphPass,\n    attachmentSlot: RGAttachmentSlot,\n  ): number {\n    const renderPass = pass;\n\n    if (renderPass.resolveTextureOutputIDs[attachmentSlot] === undefined) {\n      const renderTargetID = renderPass.renderTargetIDs[attachmentSlot];\n      const resolveTextureID = this.createResolveTextureID(renderTargetID);\n      renderPass.resolveTextureOutputIDs[attachmentSlot] = resolveTextureID;\n    }\n\n    return renderPass.resolveTextureOutputIDs[attachmentSlot];\n  }\n\n  private findPassForResolveRenderTarget(\n    renderTargetID: number,\n  ): RenderGraphPass {\n    // Find the last pass that rendered to this render target, and resolve it now.\n\n    // If you wanted a previous snapshot copy of it, you should have created a separate,\n    // intermediate pass to copy that out. Perhaps we should have a helper for that use case?\n\n    // If there was no pass that wrote to this RT, well there's no point in resolving it, is there?\n    const renderPass = assertExists(\n      this.findMostRecentPassThatAttachedRenderTarget(renderTargetID),\n    );\n\n    // Check which attachment we're in. This could possibly be explicit from the user, but it's\n    // easy enough to find...\n    const attachmentSlot: RGAttachmentSlot =\n      renderPass.renderTargetIDs.indexOf(renderTargetID);\n\n    // Check that the pass isn't resolving its attachment to another texture. Can't do both!\n    assert(\n      renderPass.resolveTextureOutputExternalTextures[attachmentSlot] ===\n        undefined,\n    );\n\n    return renderPass;\n  }\n\n  resolveRenderTarget(renderTargetID: number): number {\n    const renderPass = this.findPassForResolveRenderTarget(renderTargetID);\n    const attachmentSlot: RGAttachmentSlot =\n      renderPass.renderTargetIDs.indexOf(renderTargetID);\n    return this.resolveRenderTargetPassAttachmentSlot(\n      renderPass,\n      attachmentSlot,\n    );\n  }\n\n  resolveRenderTargetToExternalTexture(\n    renderTargetID: number,\n    texture: Texture,\n    level = 0,\n  ): void {\n    const renderPass = this.findPassForResolveRenderTarget(renderTargetID);\n    const attachmentSlot: RGAttachmentSlot =\n      renderPass.renderTargetIDs.indexOf(renderTargetID);\n    // We shouldn't be resolving to a resolve texture ID in this case.\n    assert(renderPass.resolveTextureOutputIDs[attachmentSlot] === undefined);\n    renderPass.resolveTextureOutputExternalTextures[attachmentSlot] = texture;\n    renderPass.resolveTextureOutputExternalTextureLevel[attachmentSlot] = level;\n  }\n\n  getRenderTargetDescription(\n    renderTargetID: number,\n  ): Readonly<RGRenderTargetDescription> {\n    return assertExists(\n      this.currentGraph.renderTargetDescriptions[renderTargetID],\n    );\n  }\n  // #endregion\n\n  // #region Scheduling\n  private renderTargetOutputCount: number[] = [];\n  private renderTargetResolveCount: number[] = [];\n  private resolveTextureUseCount: number[] = [];\n\n  private renderTargetAliveForID: RGRenderTarget[] = [];\n  private singleSampledTextureForResolveTextureID: SingleSampledTexture[] = [];\n\n  private scheduleAddUseCount(graph: GraphImpl, pass: RenderGraphPass): void {\n    for (let slot = 0; slot < pass.renderTargetIDs.length; slot++) {\n      const renderTargetID = pass.renderTargetIDs[slot];\n      if (renderTargetID === undefined) continue;\n\n      this.renderTargetOutputCount[renderTargetID]++;\n\n      if (pass.renderTargetExtraRefs[slot])\n        this.renderTargetOutputCount[renderTargetID]++;\n    }\n\n    for (let i = 0; i < pass.resolveTextureInputIDs.length; i++) {\n      const resolveTextureID = pass.resolveTextureInputIDs[i];\n      if (resolveTextureID === undefined) continue;\n\n      this.resolveTextureUseCount[resolveTextureID]++;\n\n      const renderTargetID =\n        graph.resolveTextureRenderTargetIDs[resolveTextureID];\n      this.renderTargetResolveCount[renderTargetID]++;\n    }\n  }\n\n  private acquireRenderTargetForID(\n    graph: GraphImpl,\n    renderTargetID: number | undefined,\n  ): RGRenderTarget | null {\n    if (renderTargetID === undefined) return null;\n\n    assert(this.renderTargetOutputCount[renderTargetID] > 0);\n\n    if (!this.renderTargetAliveForID[renderTargetID]) {\n      const desc = graph.renderTargetDescriptions[renderTargetID];\n      const newRenderTarget = this.acquireRenderTargetForDescription(desc);\n      newRenderTarget.setDebugName(\n        this.device,\n        graph.renderTargetDebugNames[renderTargetID],\n      );\n      this.renderTargetAliveForID[renderTargetID] = newRenderTarget;\n    }\n\n    return this.renderTargetAliveForID[renderTargetID];\n  }\n\n  private releaseRenderTargetForID(\n    renderTargetID: number | undefined,\n    forOutput: boolean,\n  ): RGRenderTarget | null {\n    if (renderTargetID === undefined) return null;\n\n    const renderTarget = assertExists(\n      this.renderTargetAliveForID[renderTargetID],\n    );\n\n    if (forOutput) {\n      assert(this.renderTargetOutputCount[renderTargetID] > 0);\n      this.renderTargetOutputCount[renderTargetID]--;\n    } else {\n      assert(this.renderTargetResolveCount[renderTargetID] > 0);\n      this.renderTargetResolveCount[renderTargetID]--;\n    }\n\n    if (\n      this.renderTargetOutputCount[renderTargetID] === 0 &&\n      this.renderTargetResolveCount[renderTargetID] === 0\n    ) {\n      // This was the last reference to this RT -- steal it from the alive list, and put it back into the pool.\n      renderTarget.needsClear = true;\n\n      this.renderTargetAliveForID[renderTargetID] = undefined;\n      this.renderTargetDeadPool.push(renderTarget);\n    }\n\n    return renderTarget;\n  }\n\n  private acquireResolveTextureInputTextureForID(\n    graph: GraphImpl,\n    resolveTextureID: number,\n  ): Texture {\n    const renderTargetID =\n      graph.resolveTextureRenderTargetIDs[resolveTextureID];\n\n    assert(this.resolveTextureUseCount[resolveTextureID] > 0);\n    this.resolveTextureUseCount[resolveTextureID]--;\n\n    const renderTarget = assertExists(\n      this.releaseRenderTargetForID(renderTargetID, false),\n    );\n\n    if (\n      this.singleSampledTextureForResolveTextureID[resolveTextureID] !==\n      undefined\n    ) {\n      // The resolved texture belonging to this RT is backed by our own single-sampled texture.\n\n      const singleSampledTexture =\n        this.singleSampledTextureForResolveTextureID[resolveTextureID];\n\n      if (this.resolveTextureUseCount[resolveTextureID] === 0) {\n        // Release this single-sampled texture back to the pool, if this is the last use of it.\n        this.singleSampledTextureDeadPool.push(singleSampledTexture);\n      }\n\n      return singleSampledTexture.texture;\n    }\n    // The resolved texture belonging to this RT is backed by our render target.\n    return assertExists(renderTarget.texture);\n  }\n\n  private determineResolveParam(\n    graph: GraphImpl,\n    pass: RenderGraphPass,\n    slot: RGAttachmentSlot,\n  ): ResolveParam {\n    const renderTargetID = pass.renderTargetIDs[slot];\n    const resolveTextureOutputID = pass.resolveTextureOutputIDs[slot];\n    const externalTexture = pass.resolveTextureOutputExternalTextures[slot];\n\n    // We should have either an output ID or an external texture, not both.\n    const hasResolveTextureOutputID = resolveTextureOutputID !== undefined;\n    const hasExternalTexture = externalTexture !== undefined;\n    assert(!(hasResolveTextureOutputID && hasExternalTexture));\n\n    let resolveTo: Texture | null = null;\n    let store = false;\n    let level = 0;\n\n    if (this.renderTargetOutputCount[renderTargetID] > 1) {\n      // A future pass is going to render to this RT, we need to store the results.\n      store = true;\n    }\n\n    if (hasResolveTextureOutputID) {\n      assert(\n        graph.resolveTextureRenderTargetIDs[resolveTextureOutputID] ===\n          renderTargetID,\n      );\n      assert(this.resolveTextureUseCount[resolveTextureOutputID] > 0);\n      assert(this.renderTargetOutputCount[renderTargetID] > 0);\n\n      const renderTarget = assertExists(\n        this.renderTargetAliveForID[renderTargetID],\n      );\n\n      // If we're the last user of this RT, then we don't need to resolve -- the texture itself will be enough.\n      // Note that this isn't exactly an exactly correct algorithm. If we have pass A writing to RenderTargetA,\n      // pass B resolving RenderTargetA to ResolveTextureA, and pass C writing to RenderTargetA, then we don't\n      // strictly need to copy, but in order to determine that at the time of pass A, we'd need a much fancier\n      // schedule than just tracking refcounts...\n      if (\n        renderTarget.texture !== null &&\n        this.renderTargetOutputCount[renderTargetID] === 1\n      ) {\n        resolveTo = null;\n        store = true;\n      } else {\n        if (\n          !this.singleSampledTextureForResolveTextureID[resolveTextureOutputID]\n        ) {\n          const desc = assertExists(\n            graph.renderTargetDescriptions[renderTargetID],\n          );\n          this.singleSampledTextureForResolveTextureID[resolveTextureOutputID] =\n            this.acquireSingleSampledTextureForDescription(desc);\n          this.device.setResourceName(\n            this.singleSampledTextureForResolveTextureID[resolveTextureOutputID]\n              .texture,\n            `${renderTarget.debugName} (Resolve ${resolveTextureOutputID})`,\n          );\n        }\n\n        resolveTo =\n          this.singleSampledTextureForResolveTextureID[resolveTextureOutputID]\n            .texture;\n      }\n    } else if (hasExternalTexture) {\n      resolveTo = externalTexture;\n      level = pass.resolveTextureOutputExternalTextureLevel[slot];\n    } else {\n      resolveTo = null;\n    }\n\n    return { resolveTo, store, level };\n  }\n\n  private schedulePass(graph: GraphImpl, pass: RenderGraphPass) {\n    const depthStencilRenderTargetID =\n      pass.renderTargetIDs[RGAttachmentSlot.DepthStencil];\n\n    for (\n      let slot = RGAttachmentSlot.Color0;\n      slot <= RGAttachmentSlot.ColorMax;\n      slot++\n    ) {\n      const colorRenderTargetID = pass.renderTargetIDs[slot];\n      const colorRenderTarget = this.acquireRenderTargetForID(\n        graph,\n        colorRenderTargetID,\n      );\n      pass.renderTargets[slot] = colorRenderTarget;\n      pass.descriptor.colorAttachment[slot] =\n        colorRenderTarget !== null ? colorRenderTarget.attachment : null;\n      pass.descriptor.colorAttachmentLevel[slot] =\n        pass.renderTargetLevels[slot];\n      const { resolveTo, store, level } = this.determineResolveParam(\n        graph,\n        pass,\n        slot,\n      );\n      pass.descriptor.colorResolveTo[slot] = resolveTo;\n      pass.descriptor.colorResolveToLevel[slot] = level;\n      pass.descriptor.colorStore[slot] = store;\n      pass.descriptor.colorClearColor[slot] =\n        colorRenderTarget !== null && colorRenderTarget.needsClear\n          ? graph.renderTargetDescriptions[colorRenderTargetID].colorClearColor\n          : 'load';\n    }\n\n    const depthStencilRenderTarget = this.acquireRenderTargetForID(\n      graph,\n      depthStencilRenderTargetID,\n    );\n    pass.renderTargets[RGAttachmentSlot.DepthStencil] =\n      depthStencilRenderTarget;\n    pass.descriptor.depthStencilAttachment =\n      depthStencilRenderTarget !== null\n        ? depthStencilRenderTarget.attachment\n        : null;\n    const { resolveTo, store } = this.determineResolveParam(\n      graph,\n      pass,\n      RGAttachmentSlot.DepthStencil,\n    );\n    pass.descriptor.depthStencilResolveTo = resolveTo;\n    pass.descriptor.depthStencilStore = store;\n    pass.descriptor.depthClearValue =\n      depthStencilRenderTarget !== null && depthStencilRenderTarget.needsClear\n        ? graph.renderTargetDescriptions[depthStencilRenderTargetID]\n            .depthClearValue\n        : 'load';\n    pass.descriptor.stencilClearValue =\n      depthStencilRenderTarget !== null && depthStencilRenderTarget.needsClear\n        ? graph.renderTargetDescriptions[depthStencilRenderTargetID]\n            .stencilClearValue\n        : 'load';\n\n    let rtWidth = 0;\n    let rtHeight = 0;\n    let rtSampleCount = 0;\n    for (let i = 0; i < pass.renderTargets.length; i++) {\n      const renderTarget = pass.renderTargets[i];\n      if (!renderTarget) continue;\n\n      const width = renderTarget.width >>> pass.renderTargetLevels[i];\n      const height = renderTarget.height >>> pass.renderTargetLevels[i];\n\n      if (rtWidth === 0) {\n        rtWidth = width;\n        rtHeight = height;\n        rtSampleCount = renderTarget.sampleCount;\n      }\n\n      assert(width === rtWidth);\n      assert(height === rtHeight);\n      assert(renderTarget.sampleCount === rtSampleCount);\n      renderTarget.needsClear = false;\n    }\n\n    if (rtWidth > 0 && rtHeight > 0) {\n      pass.viewportX *= rtWidth;\n      pass.viewportY *= rtHeight;\n      pass.viewportW *= rtWidth;\n      pass.viewportH *= rtHeight;\n    }\n\n    for (let i = 0; i < pass.resolveTextureInputIDs.length; i++) {\n      const resolveTextureID = pass.resolveTextureInputIDs[i];\n      pass.resolveTextureInputTextures[i] =\n        this.acquireResolveTextureInputTextureForID(graph, resolveTextureID);\n    }\n\n    for (let i = 0; i < pass.renderTargetIDs.length; i++)\n      this.releaseRenderTargetForID(pass.renderTargetIDs[i], true);\n\n    for (let slot = 0; slot < pass.renderTargetExtraRefs.length; slot++)\n      if (pass.renderTargetExtraRefs[slot])\n        this.releaseRenderTargetForID(pass.renderTargetIDs[slot], true);\n  }\n\n  private scheduleGraph(graph: GraphImpl): void {\n    assert(this.renderTargetOutputCount.length === 0);\n    assert(this.renderTargetResolveCount.length === 0);\n    assert(this.resolveTextureUseCount.length === 0);\n\n    // Go through and increment the age of everything in our dead pools to mark that it's old.\n    for (let i = 0; i < this.renderTargetDeadPool.length; i++)\n      this.renderTargetDeadPool[i].age++;\n    for (let i = 0; i < this.singleSampledTextureDeadPool.length; i++)\n      this.singleSampledTextureDeadPool[i].age++;\n\n    // Schedule our resources -- first, count up all uses of resources, then hand them out.\n\n    // Initialize our accumulators.\n    fillArray(\n      this.renderTargetOutputCount,\n      graph.renderTargetDescriptions.length,\n      0,\n    );\n    fillArray(\n      this.renderTargetResolveCount,\n      graph.renderTargetDescriptions.length,\n      0,\n    );\n    fillArray(\n      this.resolveTextureUseCount,\n      graph.resolveTextureRenderTargetIDs.length,\n      0,\n    );\n\n    // Count.\n    for (let i = 0; i < graph.passes.length; i++)\n      this.scheduleAddUseCount(graph, graph.passes[i]);\n\n    // Now hand out resources.\n    for (let i = 0; i < graph.passes.length; i++)\n      this.schedulePass(graph, graph.passes[i]);\n\n    // Double-check that all resources were handed out.\n    for (let i = 0; i < this.renderTargetOutputCount.length; i++)\n      assert(this.renderTargetOutputCount[i] === 0);\n    for (let i = 0; i < this.renderTargetResolveCount.length; i++)\n      assert(this.renderTargetResolveCount[i] === 0);\n    for (let i = 0; i < this.resolveTextureUseCount.length; i++)\n      assert(this.resolveTextureUseCount[i] === 0);\n    for (let i = 0; i < this.renderTargetAliveForID.length; i++)\n      assert(this.renderTargetAliveForID[i] === undefined);\n\n    // Now go through and kill anything that's over our age threshold (hasn't been used in a bit)\n    const ageThreshold = 1;\n\n    for (let i = 0; i < this.renderTargetDeadPool.length; i++) {\n      if (this.renderTargetDeadPool[i].age >= ageThreshold) {\n        this.renderTargetDeadPool[i].destroy();\n        this.renderTargetDeadPool.splice(i--, 1);\n      }\n    }\n\n    for (let i = 0; i < this.singleSampledTextureDeadPool.length; i++) {\n      if (this.singleSampledTextureDeadPool[i].age >= ageThreshold) {\n        this.singleSampledTextureDeadPool[i].destroy();\n        this.singleSampledTextureDeadPool.splice(i--, 1);\n      }\n    }\n\n    // Clear out our transient scheduling state.\n    this.renderTargetResolveCount.length = 0;\n    this.renderTargetOutputCount.length = 0;\n    this.resolveTextureUseCount.length = 0;\n  }\n  // #endregion\n\n  // #region Execution\n  private execPass(pass: RenderGraphPass): void {\n    assert(this.currentPass === null);\n    this.currentPass = pass;\n\n    const renderPass = this.device.createRenderPass(pass.descriptor);\n    renderPass.pushDebugGroup(pass.debugName);\n\n    renderPass.setViewport(\n      pass.viewportX,\n      pass.viewportY,\n      pass.viewportW,\n      pass.viewportH,\n    );\n\n    if (pass.execFunc !== null) pass.execFunc(renderPass, this);\n\n    renderPass.popDebugGroup();\n    this.device.submitPass(renderPass);\n\n    if (pass.postFunc !== null) pass.postFunc(this);\n\n    this.currentPass = null;\n  }\n\n  private execGraph(graph: GraphImpl) {\n    this.scheduleGraph(graph);\n\n    this.device.beginFrame();\n    graph.passes.forEach((pass) => {\n      this.execPass(pass);\n    });\n    this.device.endFrame();\n    // Clear our transient scope state.\n    this.singleSampledTextureForResolveTextureID.length = 0;\n  }\n\n  execute() {\n    const graph = assertExists(this.currentGraph);\n    this.execGraph(graph);\n    this.currentGraph = null;\n  }\n\n  getDebug(): RGGraphBuilderDebug {\n    return this;\n  }\n  // #endregion\n\n  // #region GfxrGraphBuilderDebug\n  getPasses(): RenderGraphPass[] {\n    return this.currentGraph.passes;\n  }\n\n  getPassDebugThumbnails(pass: RenderGraphPass): boolean[] {\n    return pass.debugThumbnails;\n  }\n\n  getPassRenderTargetID(pass: RenderGraphPass, slot: RGAttachmentSlot): number {\n    return pass.renderTargetIDs[slot];\n  }\n\n  getRenderTargetIDDebugName(renderTargetID: number): string {\n    return this.currentGraph.renderTargetDebugNames[renderTargetID];\n  }\n  // #endregion\n\n  // #region GfxrPassScope\n  getResolveTextureForID(resolveTextureID: number): Texture {\n    const currentGraphPass = this.currentPass;\n    const i = currentGraphPass.resolveTextureInputIDs.indexOf(resolveTextureID);\n    assert(i >= 0);\n    return assertExists(currentGraphPass.resolveTextureInputTextures[i]);\n  }\n\n  getRenderTargetAttachment(slot: RGAttachmentSlot): RenderTarget | null {\n    const currentGraphPass = this.currentPass;\n    const renderTarget = currentGraphPass.renderTargets[slot];\n    if (!renderTarget) return null;\n    return renderTarget.attachment;\n  }\n\n  getRenderTargetTexture(slot: RGAttachmentSlot): Texture | null {\n    const currentGraphPass = this.currentPass;\n    const renderTarget = currentGraphPass.renderTargets[slot];\n    if (!renderTarget) return null;\n    return renderTarget.texture;\n  }\n  // #endregion\n\n  newGraphBuilder(): RGGraphBuilder {\n    this.beginGraphBuilder();\n    return this;\n  }\n\n  destroy(): void {\n    // At the time this is called, we shouldn't have anything alive.\n    for (let i = 0; i < this.renderTargetAliveForID.length; i++)\n      assert(this.renderTargetAliveForID[i] === undefined);\n    for (\n      let i = 0;\n      i < this.singleSampledTextureForResolveTextureID.length;\n      i++\n    )\n      assert(this.singleSampledTextureForResolveTextureID[i] === undefined);\n\n    for (let i = 0; i < this.renderTargetDeadPool.length; i++)\n      this.renderTargetDeadPool[i].destroy();\n    for (let i = 0; i < this.singleSampledTextureDeadPool.length; i++)\n      this.singleSampledTextureDeadPool[i].destroy();\n  }\n}\n","import { clamp } from '@antv/util';\nimport { assert } from '@antv/g-device-api';\n\n// Suggested values for the \"layer\" of makeSortKey. These are rough groups, and you can define your own\n// ordering within the rough groups (e.g. you might use BACKGROUND + 1, or BACKGROUND + 2).\n// TRANSLUCENT is meant to be used as a bitflag. It's special as it changes the behavior of the generic sort key\n\n// functions like makeSortKey and setSortKeyDepth.\nexport enum RendererLayer {\n  BACKGROUND = 0x00,\n  ALPHA_TEST = 0x10,\n  OPAQUE = 0x20,\n  TRANSLUCENT = 0x80,\n}\n\nconst MAX_DEPTH = 0x10000;\n\nconst DEPTH_BITS = 16;\n\nexport function makeDepthKey(\n  depth: number,\n  flipDepth: boolean,\n  maxDepth: number = MAX_DEPTH,\n) {\n  // Input depth here is: 0 is the closest to the camera, positive values are further away. Negative values (behind camera) are clamped to 0.\n  // normalizedDepth: 0.0 is closest to camera, 1.0 is farthest from camera.\n  // These values are flipped if flipDepth is set.\n  let normalizedDepth = clamp(depth, 0, maxDepth) / maxDepth;\n  if (flipDepth) normalizedDepth = 1.0 - normalizedDepth;\n  const depthKey = normalizedDepth * ((1 << DEPTH_BITS) - 1);\n  return depthKey & 0xffff;\n}\n\n// Common sort key kinds.\n// Indexed:     TLLLLLLL IIIIIIII IIIIIIII IIIIIIII\n// Opaque:      0LLLLLLL PPPPPPPP PPPPPPPP DDDDDDDD\n// Translucent: 1LLLLLLL DDDDDDDD DDDDDDDD BBBBBBBB\n\nexport function getSortKeyLayer(sortKey: number): number {\n  return (sortKey >>> 24) & 0xff;\n}\n\nexport function setSortKeyLayer(sortKey: number, layer: number): number {\n  return ((sortKey & 0x00ffffff) | ((layer & 0xff) << 24)) >>> 0;\n}\n\nexport function setSortKeyProgramKey(\n  sortKey: number,\n  programKey: number,\n): number {\n  const isTransparent = !!((sortKey >>> 31) & 1);\n  if (isTransparent) return sortKey;\n  return ((sortKey & 0xff0000ff) | ((programKey & 0xffff) << 8)) >>> 0;\n}\n\nexport function setSortKeyBias(sortKey: number, bias: number): number {\n  const isTransparent = !!((sortKey >>> 31) & 1);\n  if (isTransparent) return ((sortKey & 0xffffff00) | (bias & 0xff)) >>> 0;\n  return sortKey;\n}\n\nexport function makeSortKeyOpaque(layer: number, programKey: number): number {\n  return setSortKeyLayer(setSortKeyProgramKey(0, programKey), layer);\n}\n\nexport function setSortKeyOpaqueDepth(\n  sortKey: number,\n  depthKey: number,\n): number {\n  assert(depthKey >= 0);\n  return ((sortKey & 0xffffff00) | ((depthKey >>> 8) & 0xff)) >>> 0;\n}\n\nexport function makeSortKeyTranslucent(layer: number): number {\n  return setSortKeyLayer(0, layer);\n}\n\nexport function setSortKeyTranslucentDepth(\n  sortKey: number,\n  depthKey: number,\n): number {\n  assert(depthKey >= 0);\n  return ((sortKey & 0xff0000ff) | (depthKey << 8)) >>> 0;\n}\n\nexport function makeSortKey(layer: RendererLayer, programKey = 0): number {\n  if (layer & RendererLayer.TRANSLUCENT) return makeSortKeyTranslucent(layer);\n  return makeSortKeyOpaque(layer, programKey);\n}\n\nexport function setSortKeyDepthKey(sortKey: number, depthKey: number): number {\n  const isTranslucent = !!((sortKey >>> 31) & 1);\n  return isTranslucent\n    ? setSortKeyTranslucentDepth(sortKey, depthKey)\n    : setSortKeyOpaqueDepth(sortKey, depthKey);\n}\n\nexport function setSortKeyDepth(\n  sortKey: number,\n  depth: number,\n  maxDepth: number = MAX_DEPTH,\n): number {\n  const isTranslucent = !!((sortKey >>> 31) & 1);\n  const depthKey = makeDepthKey(depth, isTranslucent, maxDepth);\n  return isTranslucent\n    ? setSortKeyTranslucentDepth(sortKey, depthKey)\n    : setSortKeyOpaqueDepth(sortKey, depthKey);\n}\n\nexport function getSortKeyDepth(sortKey: number): number {\n  const isTranslucent = !!((sortKey >>> 31) & 1);\n  if (isTranslucent) return (sortKey >>> 8) & 0xffff;\n\n  return ((sortKey >>> 8) & 0xfffc) | (sortKey & 0x03);\n}\n","import { mat4 } from 'gl-matrix';\nimport { ClipSpaceNearZ } from '@antv/g-device-api';\n\nconst mtxOpenGLFromD3D = mat4.fromValues(\n  1,\n  0,\n  0,\n  0,\n  0,\n  1,\n  0,\n  0,\n  0,\n  0,\n  2,\n  0,\n  0,\n  0,\n  -1,\n  1,\n);\n\n// Converts a projection matrix from D3D-style Z range [0, 1] to OpenGL-style Z range [-1, 1]\nfunction projectionMatrixOpenGLFromD3D(m: mat4): void {\n  mat4.mul(m, mtxOpenGLFromD3D, m);\n}\n\nconst mtxD3DFromOpenGL = mat4.fromValues(\n  1,\n  0,\n  0,\n  0,\n  0,\n  1,\n  0,\n  0,\n  0,\n  0,\n  0.5,\n  0,\n  0,\n  0,\n  0.5,\n  1,\n);\n\n// Converts a projection matrix from OpenGL-style Z range [-1, 1] to D3D-style Z range [0, 1]\nfunction projectionMatrixD3DFromOpenGL(m: mat4): void {\n  mat4.mul(m, mtxD3DFromOpenGL, m);\n}\n\n/**\n * Convert a projection matrix {@param m} between differing clip spaces.\n *\n * There are two kinds of clip-space conventions in active use in graphics APIs, differing in the\n * range of the Z axis: OpenGL (and thus GL ES and WebGL) use a Z range of [-1, 1] which matches\n * the X and Y axis ranges. Direct3D, Vulkan, Metal, and WebGPU all use a Z range of [0, 1], which\n * differs from the X and Y axis ranges, but makes sense from the perspective of a camera: a camera\n * can see to the left and right of it, above and below it, but only in front and not behind it.\n *\n * The [0, 1] convention for Z range also has better characteristics for \"reversed depth\". Since\n * floating point numbers have higher precision around 0 than around 1. We then get to choose where\n * to put the extra precise bits: close to the near plane, or close to the far plane.\n *\n * With OpenGL's [-1, 1] convention, both -1 and 1 have similar amounts of precision, so we don't\n * get to make the same choice, and our higher precision around 0 is stuck in the middle of the\n * scene, which doesn't particularly help.\n *\n * The gl-matrix library has two different kinds of entry points: {@method mat4.perpsective} will\n * generate a matrix with a [-1, 1] clip space, corresponding to {@see ClipSpaceNearZ.NegativeOne},\n * but {@method mat4.perspectiveZO} will generate a matrix with a [0, 1] clip space, corresponding\n * to {@see ClipSpaceNearZ.Zero}.\n *\n * This function does nothing if {@param dst} and {@param src} are the same.\n */\nexport function projectionMatrixConvertClipSpaceNearZ(\n  m: mat4,\n  dst: ClipSpaceNearZ,\n  src: ClipSpaceNearZ,\n): void {\n  if (dst === src) return;\n\n  if (dst === ClipSpaceNearZ.NEGATIVE_ONE) projectionMatrixOpenGLFromD3D(m);\n  else if (dst === ClipSpaceNearZ.ZERO) projectionMatrixD3DFromOpenGL(m);\n}\n","// Helpers to fill vertex buffers.\nimport type { ReadonlyVec3, ReadonlyVec4, ReadonlyMat4 } from 'gl-matrix';\n// import { ReadonlyMat2d } from 'gl-matrix';\nimport type { Color } from '@antv/g-device-api';\n\nexport function fillVec3v(\n  d: Float32Array,\n  offs: number,\n  v: ReadonlyVec3,\n  v3 = 0,\n): number {\n  d[offs + 0] = v[0];\n  d[offs + 1] = v[1];\n  d[offs + 2] = v[2];\n  d[offs + 3] = v3;\n  return 4;\n}\n\nexport function fillVec4(\n  d: Float32Array,\n  offs: number,\n  v0: number,\n  v1 = 0,\n  v2 = 0,\n  v3 = 0,\n): number {\n  d[offs + 0] = v0;\n  d[offs + 1] = v1;\n  d[offs + 2] = v2;\n  d[offs + 3] = v3;\n  return 4;\n}\n\nexport function fillVec4v(\n  d: Float32Array,\n  offs: number,\n  v: ReadonlyVec4,\n): number {\n  d[offs + 0] = v[0];\n  d[offs + 1] = v[1];\n  d[offs + 2] = v[2];\n  d[offs + 3] = v[3];\n  return 4;\n}\n\nexport function fillColor(\n  d: Float32Array,\n  offs: number,\n  c: Readonly<Color>,\n  a: number = c.a,\n): number {\n  d[offs + 0] = c.r;\n  d[offs + 1] = c.g;\n  d[offs + 2] = c.b;\n  d[offs + 3] = a;\n  return 4;\n}\n\n// All of our matrices are row-major.\nexport function fillMatrix4x4(\n  d: Float32Array,\n  offs: number,\n  m: ReadonlyMat4,\n): number {\n  // d[offs + 0] = m[0];\n  // d[offs + 1] = m[4];\n  // d[offs + 2] = m[8];\n  // d[offs + 3] = m[12];\n  // d[offs + 4] = m[1];\n  // d[offs + 5] = m[5];\n  // d[offs + 6] = m[9];\n  // d[offs + 7] = m[13];\n  // d[offs + 8] = m[2];\n  // d[offs + 9] = m[6];\n  // d[offs + 10] = m[10];\n  // d[offs + 11] = m[14];\n  // d[offs + 12] = m[3];\n  // d[offs + 13] = m[7];\n  // d[offs + 14] = m[11];\n  // d[offs + 15] = m[15];\n  d[offs + 0] = m[0];\n  d[offs + 1] = m[1];\n  d[offs + 2] = m[2];\n  d[offs + 3] = m[3];\n  d[offs + 4] = m[4];\n  d[offs + 5] = m[5];\n  d[offs + 6] = m[6];\n  d[offs + 7] = m[7];\n  d[offs + 8] = m[8];\n  d[offs + 9] = m[9];\n  d[offs + 10] = m[10];\n  d[offs + 11] = m[11];\n  d[offs + 12] = m[12];\n  d[offs + 13] = m[13];\n  d[offs + 14] = m[14];\n  d[offs + 15] = m[15];\n  return 4 * 4;\n}\n\n// export function fillMatrix4x3(d: Float32Array, offs: number, m: ReadonlyMat4): number {\n//   d[offs + 0] = m[0];\n//   d[offs + 1] = m[4];\n//   d[offs + 2] = m[8];\n//   d[offs + 3] = m[12];\n//   d[offs + 4] = m[1];\n//   d[offs + 5] = m[5];\n//   d[offs + 6] = m[9];\n//   d[offs + 7] = m[13];\n//   d[offs + 8] = m[2];\n//   d[offs + 9] = m[6];\n//   d[offs + 10] = m[10];\n//   d[offs + 11] = m[14];\n//   return 4 * 3;\n// }\n\n// export function fillMatrix3x2(d: Float32Array, offs: number, m: ReadonlyMat2d): number {\n//   // 3x2 matrices are actually sent across as 4x2.\n//   const ma = m[0],\n//     mb = m[1];\n//   const mc = m[2],\n//     md = m[3];\n//   const mx = m[4],\n//     my = m[5];\n//   d[offs + 0] = ma;\n//   d[offs + 1] = mc;\n//   d[offs + 2] = mx;\n//   d[offs + 3] = 0;\n//   d[offs + 4] = mb;\n//   d[offs + 5] = md;\n//   d[offs + 6] = my;\n//   d[offs + 7] = 0;\n//   return 4 * 2;\n// }\n\n// export function fillMatrix4x2(d: Float32Array, offs: number, m: ReadonlyMat4): number {\n//   // The bottom two rows are basically just ignored in a 4x2.\n//   d[offs + 0] = m[0];\n//   d[offs + 1] = m[4];\n//   d[offs + 2] = m[8];\n//   d[offs + 3] = m[12];\n//   d[offs + 4] = m[1];\n//   d[offs + 5] = m[5];\n//   d[offs + 6] = m[9];\n//   d[offs + 7] = m[13];\n//   return 4 * 2;\n// }\n","import { isNumber } from '@antv/util';\nimport type {\n  BindingsDescriptor,\n  Device,\n  IndexBufferDescriptor,\n  InputLayout,\n  MegaStateDescriptor,\n  Program,\n  RenderPass,\n  RenderPipelineDescriptor,\n  SamplerBinding,\n  VertexBufferDescriptor,\n} from '@antv/g-device-api';\nimport {\n  assert,\n  assertExists,\n  copyMegaState,\n  defaultMegaState,\n  nArray,\n  setBitFlagEnabled,\n  setMegaStateFlags,\n  PrimitiveTopology,\n} from '@antv/g-device-api';\nimport type { DynamicUniformBuffer } from './DynamicUniformBuffer';\nimport type { RenderCache } from './RenderCache';\nimport { fillVec4 } from './utils';\n\nexport enum RenderInstFlags {\n  None = 0,\n  Indexed = 1 << 0,\n  AllowSkippingIfPipelineNotReady = 1 << 1,\n\n  // Mostly for error checking.\n  Template = 1 << 2,\n  Draw = 1 << 3,\n\n  // Which flags are inherited from templates...\n  InheritedFlags = Indexed | AllowSkippingIfPipelineNotReady,\n}\n\nexport interface RenderInstUniform {\n  name: string;\n  value: number | number[] | Float32Array;\n}\n\nexport class RenderInst {\n  sortKey = 0;\n\n  // Debugging pointer for whomever wants it...\n  debug: any = null;\n\n  // Pipeline building.\n  renderPipelineDescriptor: RenderPipelineDescriptor;\n\n  // Bindings building.\n  private uniformBuffer: DynamicUniformBuffer;\n\n  uniforms: RenderInstUniform[][] = [];\n\n  private bindingDescriptors: BindingsDescriptor[] = nArray(1, () => ({\n    bindingLayout: null,\n    samplerBindings: [],\n    uniformBufferBindings: [],\n  }));\n  private dynamicUniformBufferByteOffsets: number[] = nArray(4, () => 0);\n\n  flags: RenderInstFlags = 0;\n  private vertexBuffers: (VertexBufferDescriptor | null)[] | null = null;\n  private indexBuffer: IndexBufferDescriptor | null = null;\n  private drawStart = 0;\n  private drawCount = 0;\n  private drawInstanceCount = 0;\n\n  constructor() {\n    this.renderPipelineDescriptor = {\n      inputLayout: null,\n      megaStateDescriptor: copyMegaState(defaultMegaState),\n      program: null!,\n      topology: PrimitiveTopology.TRIANGLES,\n      colorAttachmentFormats: [],\n      depthStencilAttachmentFormat: null,\n      sampleCount: 1,\n    };\n\n    this.reset();\n  }\n\n  /**\n   * Resets a render inst to be boring, so it can re-enter the pool.\n   * Normally, you should not need to call this.\n   */\n  reset(): void {\n    this.sortKey = 0;\n    this.flags = RenderInstFlags.AllowSkippingIfPipelineNotReady;\n    this.vertexBuffers = null;\n    this.indexBuffer = null;\n    this.renderPipelineDescriptor.inputLayout = null;\n  }\n\n  /**\n   * Copies the fields from another render inst {@param o} to this render inst.\n   * Normally, you should not need to call this.\n   */\n  setFromTemplate(o: RenderInst): void {\n    setMegaStateFlags(\n      this.renderPipelineDescriptor.megaStateDescriptor,\n      o.renderPipelineDescriptor.megaStateDescriptor,\n    );\n    this.renderPipelineDescriptor.program = o.renderPipelineDescriptor.program;\n    this.renderPipelineDescriptor.inputLayout =\n      o.renderPipelineDescriptor.inputLayout;\n    this.renderPipelineDescriptor.topology =\n      o.renderPipelineDescriptor.topology;\n    this.renderPipelineDescriptor.colorAttachmentFormats.length = Math.max(\n      this.renderPipelineDescriptor.colorAttachmentFormats.length,\n      o.renderPipelineDescriptor.colorAttachmentFormats.length,\n    );\n    for (\n      let i = 0;\n      i < o.renderPipelineDescriptor.colorAttachmentFormats.length;\n      i++\n    )\n      this.renderPipelineDescriptor.colorAttachmentFormats[i] =\n        o.renderPipelineDescriptor.colorAttachmentFormats[i];\n    this.renderPipelineDescriptor.depthStencilAttachmentFormat =\n      o.renderPipelineDescriptor.depthStencilAttachmentFormat;\n    this.renderPipelineDescriptor.sampleCount =\n      o.renderPipelineDescriptor.sampleCount;\n    this.uniformBuffer = o.uniformBuffer;\n    this.uniforms = [...o.uniforms];\n    this.drawCount = o.drawCount;\n    this.drawStart = o.drawStart;\n    this.drawInstanceCount = o.drawInstanceCount;\n    this.vertexBuffers = o.vertexBuffers;\n    this.indexBuffer = o.indexBuffer;\n    this.flags =\n      (this.flags & ~RenderInstFlags.InheritedFlags) |\n      (o.flags & RenderInstFlags.InheritedFlags);\n    this.sortKey = o.sortKey;\n    const tbd = this.bindingDescriptors[0];\n    const obd = o.bindingDescriptors[0];\n    this.setBindingLayout({\n      numSamplers: obd.samplerBindings?.length,\n      numUniformBuffers: obd.uniformBufferBindings?.length,\n    });\n\n    for (\n      let i = 0;\n      i <\n      Math.min(\n        tbd.uniformBufferBindings.length,\n        obd.uniformBufferBindings.length,\n      );\n      i++\n    )\n      tbd.uniformBufferBindings[i].size =\n        o.bindingDescriptors[0].uniformBufferBindings[i].size;\n    this.setSamplerBindingsFromTextureMappings(obd.samplerBindings);\n    for (let i = 0; i < o.dynamicUniformBufferByteOffsets.length; i++)\n      this.dynamicUniformBufferByteOffsets[i] =\n        o.dynamicUniformBufferByteOffsets[i];\n  }\n\n  validate(): void {\n    // Validate uniform buffer bindings.\n    for (let i = 0; i < this.bindingDescriptors.length; i++) {\n      const bd = this.bindingDescriptors[i];\n      for (let j = 0; j < bd.uniformBufferBindings?.length; j++)\n        assert(bd.uniformBufferBindings[j].size > 0);\n    }\n\n    assert(this.drawCount > 0);\n  }\n\n  /**\n   * Set the {@see Program} that this render inst will render with. This is part of the automatic\n   * pipeline building facilities. At render time, a pipeline will be automatically and constructed from\n   * the pipeline parameters.\n   */\n  setProgram(program: Program): void {\n    this.renderPipelineDescriptor.program = program;\n  }\n\n  /**\n   * Set the {@see MegaStateDescriptor} that this render inst will render with. This is part of the automatic\n   * pipeline building facilities. At render time, a pipeline will be automatically and constructed from\n   * the pipeline parameters.\n   */\n  setMegaStateFlags(r: Partial<MegaStateDescriptor>): MegaStateDescriptor {\n    setMegaStateFlags(this.renderPipelineDescriptor.megaStateDescriptor, r);\n    return this.renderPipelineDescriptor.megaStateDescriptor;\n  }\n\n  /**\n   * Retrieve the {@see MegaStateDescriptor} property bag that this will render with. This is similar to\n   * {@see setMegaStateFlags} but allows you to set fields directly on the internal property bag, rather than\n   * merge them. This can be slightly more efficient.\n   */\n  getMegaStateFlags(): MegaStateDescriptor {\n    return this.renderPipelineDescriptor.megaStateDescriptor;\n  }\n\n  /**\n   * Sets the vertex input configuration to be used by this render instance.\n   * The {@see InputLayout} is used to construct the pipeline as part of the automatic pipeline building\n   * facilities, while the {@see VertexBufferDescriptor} and {@see IndexBufferDescriptor} is used for the render.\n   */\n  setVertexInput(\n    inputLayout: InputLayout | null,\n    vertexBuffers: (VertexBufferDescriptor | null)[] | null,\n    indexBuffer: IndexBufferDescriptor | null,\n  ): void {\n    this.vertexBuffers = vertexBuffers;\n    this.indexBuffer = indexBuffer;\n    this.renderPipelineDescriptor.inputLayout = inputLayout;\n  }\n\n  setBindingLayout(bindingLayout: {\n    numUniformBuffers: number;\n    numSamplers: number;\n  }): void {\n    assert(\n      bindingLayout.numUniformBuffers <\n        this.dynamicUniformBufferByteOffsets.length,\n    );\n\n    for (\n      let i = this.bindingDescriptors[0].uniformBufferBindings.length;\n      i < bindingLayout.numUniformBuffers;\n      i++\n    )\n      this.bindingDescriptors[0].uniformBufferBindings.push({\n        binding: i,\n        buffer: null,\n        size: 0,\n      });\n    for (\n      let i = this.bindingDescriptors[0].samplerBindings.length;\n      i < bindingLayout.numSamplers;\n      i++\n    )\n      this.bindingDescriptors[0].samplerBindings.push({\n        sampler: null,\n        texture: null,\n      });\n  }\n\n  drawIndexes(indexCount: number, indexStart = 0): void {\n    this.flags = setBitFlagEnabled(this.flags, RenderInstFlags.Indexed, true);\n    this.drawCount = indexCount;\n    this.drawStart = indexStart;\n    this.drawInstanceCount = 1;\n  }\n\n  drawIndexesInstanced(\n    indexCount: number,\n    instanceCount: number,\n    indexStart = 0,\n  ): void {\n    this.flags = setBitFlagEnabled(this.flags, RenderInstFlags.Indexed, true);\n    this.drawCount = indexCount;\n    this.drawStart = indexStart;\n    this.drawInstanceCount = instanceCount;\n  }\n\n  drawPrimitives(primitiveCount: number, primitiveStart = 0): void {\n    this.flags = setBitFlagEnabled(this.flags, RenderInstFlags.Indexed, false);\n    this.drawCount = primitiveCount;\n    this.drawStart = primitiveStart;\n    this.drawInstanceCount = 1;\n  }\n\n  /**\n   * account for WebGL1\n   */\n  setUniforms(bufferIndex: number, uniforms: RenderInstUniform[]) {\n    if (uniforms.length === 0) {\n      return;\n    }\n\n    // use later in WebGL1\n    this.uniforms[bufferIndex] = uniforms;\n\n    // calc buffer size\n    let offset = 0;\n    const uboBuffer = [];\n    uniforms.forEach((uniform) => {\n      const { value } = uniform;\n\n      // number | number[] | Float32Array\n      if (\n        isNumber(value) ||\n        Array.isArray(value) ||\n        value instanceof Float32Array\n      ) {\n        const array = isNumber(value) ? [value] : value;\n        const formatByteSize = array.length > 4 ? 4 : array.length;\n\n        // std140 UBO layout\n        const emptySpace = 4 - (offset % 4);\n        if (emptySpace !== 4) {\n          if (emptySpace >= formatByteSize) {\n          } else {\n            offset += emptySpace;\n            for (let j = 0; j < emptySpace; j++) {\n              uboBuffer.push(0); // padding\n            }\n          }\n        }\n\n        offset += array.length;\n\n        uboBuffer.push(...array);\n      }\n    });\n\n    // padding\n    const emptySpace = 4 - (uboBuffer.length % 4);\n    if (emptySpace !== 4) {\n      for (let j = 0; j < emptySpace; j++) {\n        uboBuffer.push(0);\n      }\n    }\n\n    // upload UBO\n    let offs = this.allocateUniformBuffer(bufferIndex, uboBuffer.length);\n    const d = this.mapUniformBufferF32(bufferIndex);\n    for (let i = 0; i < uboBuffer.length; i += 4) {\n      offs += fillVec4(\n        d,\n        offs,\n        uboBuffer[i],\n        uboBuffer[i + 1],\n        uboBuffer[i + 2],\n        uboBuffer[i + 3],\n      );\n    }\n  }\n\n  setUniformBuffer(uniformBuffer: DynamicUniformBuffer): void {\n    this.uniformBuffer = uniformBuffer;\n  }\n\n  /**\n   * Allocates {@param wordCount} words from the uniform buffer and assigns it to the buffer\n   * slot at index {@param bufferIndex}. As a convenience, this also directly returns the same\n   * offset into the uniform buffer, in words, that would be returned by a subsequent call to\n   * {@see getUniformBufferOffset}.\n   */\n  allocateUniformBuffer(bufferIndex: number, wordCount: number): number {\n    assert(\n      this.bindingDescriptors[0].uniformBufferBindings?.length <\n        this.dynamicUniformBufferByteOffsets.length,\n    );\n    this.dynamicUniformBufferByteOffsets[bufferIndex] =\n      this.uniformBuffer.allocateChunk(wordCount) << 2;\n\n    const dst = this.bindingDescriptors[0].uniformBufferBindings[bufferIndex];\n    dst.size = wordCount << 2;\n    return this.getUniformBufferOffset(bufferIndex);\n  }\n\n  /**\n   * Returns the offset into the uniform buffer, in words, that is assigned to the buffer slot\n   * at index {@param bufferIndex}, to be used with e.g. {@see mapUniformBufferF32}.\n   */\n  getUniformBufferOffset(bufferIndex: number) {\n    const wordOffset = this.dynamicUniformBufferByteOffsets[bufferIndex] >>> 2;\n    return wordOffset;\n  }\n\n  /**\n   * This is a convenience wrapper for {@see RenderDynamicUniformBuffer.mapBufferF32}, but uses\n   * the values previously assigned for the uniform buffer slot at index {@param bufferIndex}.\n   * Like {@see RenderDynamicUniformBuffer.mapBufferF32}, this does not return a slice for the\n   * buffer; you need to write to it with the correct uniform buffer offset; this will usually be\n   * returned by {@see allocateUniformBuffer}.\n   */\n  mapUniformBufferF32(bufferIndex: number): Float32Array {\n    return this.uniformBuffer.mapBufferF32();\n  }\n\n  /**\n   * Retrieve the {@see RenderDynamicUniformBuffer} that this render inst will use to allocate.\n   */\n  getUniformBuffer(): DynamicUniformBuffer {\n    return this.uniformBuffer;\n  }\n\n  /**\n   * Sets the {@param SamplerBinding}s in use by this render instance.\n   *\n   * Note that {@see RenderInst} has a method of doing late binding, intended to solve cases where live render\n   * targets are used, which can have difficult control flow consequences for users. Pass a string instead of a\n   * SamplerBinding to record that it can be resolved later, and use {@see RenderInst.resolveLateSamplerBinding}\n   * or equivalent to fill it in later.\n   */\n  setSamplerBindingsFromTextureMappings(\n    mappings: (SamplerBinding | null)[],\n  ): void {\n    mappings = mappings.filter((m) => m);\n    for (\n      let i = 0;\n      i < this.bindingDescriptors[0].samplerBindings.length;\n      i++\n    ) {\n      const dst = this.bindingDescriptors[0].samplerBindings[i];\n      const binding = mappings[i];\n\n      if (binding === undefined || binding === null) {\n        dst.texture = null;\n        dst.sampler = null;\n        continue;\n      }\n\n      dst.texture = binding.texture;\n      dst.sampler = binding.sampler;\n    }\n  }\n\n  /**\n   * Sets whether this render inst should be skipped if the render pipeline isn't ready.\n   *\n   * Some draws of objects can be skipped if the pipelines aren't ready. Others are more\n   * crucial to draw, and so this can be set to force for the pipeline to become available.\n   *\n   * By default, this is true.\n   */\n  setAllowSkippingIfPipelineNotReady(v: boolean): void {\n    this.flags = setBitFlagEnabled(\n      this.flags,\n      RenderInstFlags.AllowSkippingIfPipelineNotReady,\n      v,\n    );\n  }\n\n  private setAttachmentFormatsFromRenderPass(\n    device: Device,\n    passRenderer: RenderPass,\n  ): void {\n    const passDescriptor = device.queryRenderPass(passRenderer);\n\n    let sampleCount = -1;\n    for (let i = 0; i < passDescriptor.colorAttachment.length; i++) {\n      const colorAttachmentDescriptor =\n        passDescriptor.colorAttachment[i] !== null\n          ? device.queryRenderTarget(passDescriptor.colorAttachment[i])\n          : null;\n      this.renderPipelineDescriptor.colorAttachmentFormats[i] =\n        colorAttachmentDescriptor !== null\n          ? colorAttachmentDescriptor.format\n          : null;\n      if (colorAttachmentDescriptor !== null) {\n        if (sampleCount === -1)\n          sampleCount = colorAttachmentDescriptor.sampleCount;\n        else assert(sampleCount === colorAttachmentDescriptor.sampleCount);\n      }\n    }\n\n    const depthStencilAttachmentDescriptor =\n      passDescriptor.depthStencilAttachment !== null\n        ? device.queryRenderTarget(passDescriptor.depthStencilAttachment)\n        : null;\n    this.renderPipelineDescriptor.depthStencilAttachmentFormat =\n      depthStencilAttachmentDescriptor !== null\n        ? depthStencilAttachmentDescriptor.format\n        : null;\n    if (depthStencilAttachmentDescriptor !== null) {\n      if (sampleCount === -1)\n        sampleCount = depthStencilAttachmentDescriptor.sampleCount;\n      else assert(sampleCount === depthStencilAttachmentDescriptor.sampleCount);\n    }\n\n    assert(sampleCount > 0);\n    this.renderPipelineDescriptor.sampleCount = sampleCount;\n  }\n\n  drawOnPass(cache: RenderCache, passRenderer: RenderPass): boolean {\n    const { device } = cache;\n    this.setAttachmentFormatsFromRenderPass(device, passRenderer);\n\n    const gfxPipeline = cache.createRenderPipeline(\n      this.renderPipelineDescriptor,\n    );\n\n    const pipelineReady = device.pipelineQueryReady(gfxPipeline);\n    if (!pipelineReady) {\n      if (this.flags & RenderInstFlags.AllowSkippingIfPipelineNotReady) {\n        return false;\n      }\n      device.pipelineForceReady(gfxPipeline);\n    }\n\n    passRenderer.setPipeline(gfxPipeline);\n\n    passRenderer.setVertexInput(\n      this.renderPipelineDescriptor.inputLayout,\n      this.vertexBuffers,\n      this.indexBuffer,\n    );\n\n    // upload uniforms\n    for (\n      let i = 0;\n      i < this.bindingDescriptors[0].uniformBufferBindings.length;\n      i++\n    ) {\n      this.bindingDescriptors[0].uniformBufferBindings[i].buffer = assertExists(\n        this.uniformBuffer.buffer,\n      );\n      this.bindingDescriptors[0].uniformBufferBindings[i].offset =\n        this.dynamicUniformBufferByteOffsets[i];\n    }\n\n    if ((this.renderPipelineDescriptor.program as any).gl_program) {\n      this.uniforms.forEach((uniforms) => {\n        const uniformsMap = {};\n        uniforms.forEach(({ name, value }) => {\n          uniformsMap[name] = value;\n        });\n        this.renderPipelineDescriptor.program.setUniformsLegacy(uniformsMap);\n      });\n    }\n\n    // TODO: Support multiple binding descriptors.\n    const gfxBindings = cache.createBindings({\n      ...this.bindingDescriptors[0],\n      pipeline: gfxPipeline,\n    });\n\n    passRenderer.setBindings(gfxBindings);\n\n    if (this.flags & RenderInstFlags.Indexed) {\n      passRenderer.drawIndexed(\n        this.drawCount,\n        this.drawInstanceCount,\n        this.drawStart,\n        0,\n        0,\n      );\n    } else {\n      passRenderer.draw(\n        this.drawCount,\n        this.drawInstanceCount,\n        this.drawStart,\n        0,\n      );\n    }\n\n    return true;\n  }\n}\n","import type { RenderPass } from '@antv/g-device-api';\nimport { spliceBisectRight } from '@antv/g-device-api';\nimport type { RenderCache } from './RenderCache';\nimport type { RenderInst } from './RenderInst';\nimport { RenderInstFlags } from './RenderInst';\n\nexport const renderInstCompareNone = null;\n\nexport function renderInstCompareSortKey(a: RenderInst, b: RenderInst): number {\n  return a.sortKey - b.sortKey;\n}\n\nexport enum RenderInstExecutionOrder {\n  Forwards,\n  Backwards,\n}\n\nexport type RenderInstCompareFunc = (a: RenderInst, b: RenderInst) => number;\n\nexport class RenderInstList {\n  renderInsts: RenderInst[] = [];\n  compareFunction: RenderInstCompareFunc | null;\n  executionOrder: RenderInstExecutionOrder;\n  private usePostSort = false;\n\n  constructor(\n    compareFunction: RenderInstCompareFunc | null = renderInstCompareSortKey,\n    executionOrder = RenderInstExecutionOrder.Forwards,\n  ) {\n    this.compareFunction = compareFunction;\n    this.executionOrder = executionOrder;\n  }\n\n  /**\n   * Determine whether to use post-sorting, based on some heuristics.\n   */\n  checkUsePostSort(): void {\n    // Over a certain threshold, it's faster to push and then sort than insort directly...\n    this.usePostSort =\n      this.compareFunction !== null && this.renderInsts.length >= 500;\n  }\n\n  /**\n   * Insert a render inst to the list. This directly inserts the render inst to\n   * the position specified by the compare function, so the render inst must be\n   * fully constructed at this point.\n   */\n  private insertSorted(renderInst: RenderInst): void {\n    if (this.compareFunction === null) {\n      this.renderInsts.push(renderInst);\n    } else if (this.usePostSort) {\n      this.renderInsts.push(renderInst);\n    } else {\n      spliceBisectRight(this.renderInsts, renderInst, this.compareFunction);\n    }\n\n    this.checkUsePostSort();\n  }\n\n  submitRenderInst(renderInst: RenderInst): void {\n    // TODO: drawCount = 0\n    // renderInst.validate();\n    renderInst.flags |= RenderInstFlags.Draw;\n    this.insertSorted(renderInst);\n  }\n\n  ensureSorted(): void {\n    if (this.usePostSort) {\n      if (this.renderInsts.length !== 0)\n        this.renderInsts.sort(this.compareFunction);\n      this.usePostSort = false;\n    }\n  }\n\n  drawOnPassRendererNoReset(\n    cache: RenderCache,\n    passRenderer: RenderPass,\n  ): void {\n    this.ensureSorted();\n\n    if (this.executionOrder === RenderInstExecutionOrder.Forwards) {\n      for (let i = 0; i < this.renderInsts.length; i++)\n        this.renderInsts[i].drawOnPass(cache, passRenderer);\n    } else {\n      for (let i = this.renderInsts.length - 1; i >= 0; i--)\n        this.renderInsts[i].drawOnPass(cache, passRenderer);\n    }\n  }\n\n  reset(): void {\n    this.renderInsts.length = 0;\n  }\n\n  drawOnPassRenderer(cache: RenderCache, passRenderer: RenderPass) {\n    this.drawOnPassRendererNoReset(cache, passRenderer);\n    this.reset();\n  }\n}\n","import { RenderInst } from './RenderInst';\n\nexport class RenderInstPool {\n  // The pool contains all render insts that we've ever created.\n  pool: RenderInst[] = [];\n  // The number of render insts currently allocated out to the user.\n  allocCount = 0;\n\n  allocRenderInstIndex(): number {\n    this.allocCount++;\n\n    if (this.allocCount > this.pool.length) {\n      this.pool.push(new RenderInst());\n    }\n\n    return this.allocCount - 1;\n  }\n\n  popRenderInst(): void {\n    this.allocCount--;\n  }\n\n  reset(): void {\n    for (let i = 0; i < this.pool.length; i++) {\n      this.pool[i].reset();\n    }\n    this.allocCount = 0;\n  }\n\n  destroy(): void {\n    this.pool.length = 0;\n    this.allocCount = 0;\n  }\n}\n","import type { RenderPass } from '@antv/g-device-api';\nimport { assert, assertExists } from '@antv/g-device-api';\nimport type { RenderCache } from './RenderCache';\nimport type { RenderInst } from './RenderInst';\nimport { RenderInstFlags } from './RenderInst';\nimport { RenderInstList } from './RenderInstList';\nimport { RenderInstPool } from './RenderInstPool';\n\nexport class RenderInstManager {\n  instPool = new RenderInstPool();\n  templatePool = new RenderInstPool();\n  simpleRenderInstList: RenderInstList | null = new RenderInstList();\n  currentRenderInstList: RenderInstList = this.simpleRenderInstList;\n\n  constructor(public renderCache: RenderCache) {}\n\n  /**\n   * Creates a new RenderInst object and returns it. If there is a template\n   * pushed onto the template stack, then its values will be used as a base for this\n   * render inst.\n   */\n  newRenderInst(): RenderInst {\n    const templateIndex = this.templatePool.allocCount - 1;\n    const renderInstIndex = this.instPool.allocRenderInstIndex();\n    const renderInst = this.instPool.pool[renderInstIndex];\n    renderInst.debug = null;\n    if (templateIndex >= 0)\n      renderInst.setFromTemplate(this.templatePool.pool[templateIndex]);\n    return renderInst;\n  }\n\n  /**\n   * Submits RenderInst to the current render inst list. Note that\n   * this assumes the render inst was fully filled in, so do not modify it\n   * after submitting it.\n   */\n  submitRenderInst(\n    renderInst: RenderInst,\n    list: RenderInstList = this.currentRenderInstList,\n  ): void {\n    list.submitRenderInst(renderInst);\n  }\n\n  /**\n   * Sets the currently active render inst list. This is the list that will\n   * be used by @param submitRenderInst}. If you use this function, please\n   * make sure to call {@see disableSimpleMode} when the RenderInstManager\n   * is created, to ensure that nobody uses the \"legacy\" APIs. Failure to do\n   * so might cause memory leaks or other problems.\n   */\n  setCurrentRenderInstList(list: RenderInstList): void {\n    assert(this.simpleRenderInstList === null);\n    this.currentRenderInstList = list;\n  }\n\n  /**\n   * Pushes a new template render inst to the template stack. All properties set\n   * on the topmost template on the template stack will be the defaults for both\n   * for any future render insts created. Once done with a template, call\n   * {@param popTemplateRenderInst} to pop it off the template stack.\n   */\n  pushTemplateRenderInst(): RenderInst {\n    const templateIndex = this.templatePool.allocCount - 1;\n    const newTemplateIndex = this.templatePool.allocRenderInstIndex();\n    const newTemplate = this.templatePool.pool[newTemplateIndex];\n    if (templateIndex >= 0)\n      newTemplate.setFromTemplate(this.templatePool.pool[templateIndex]);\n    newTemplate.flags |= RenderInstFlags.Template;\n    return newTemplate;\n  }\n\n  popTemplateRenderInst(): void {\n    this.templatePool.popRenderInst();\n  }\n\n  /**\n   * Retrieves the current template render inst on the top of the template stack.\n   */\n  getTemplateRenderInst(): RenderInst {\n    const templateIndex = this.templatePool.allocCount - 1;\n    return this.templatePool.pool[templateIndex];\n  }\n\n  /**\n   * Reset all allocated render insts. This should be called at the end of the frame,\n   * once done with all of the allocated render insts and render inst lists.\n   */\n  resetRenderInsts(): void {\n    // Retire the existing render insts.\n    this.instPool.reset();\n    if (this.simpleRenderInstList !== null) this.simpleRenderInstList.reset();\n    // Ensure we aren't leaking templates.\n    assert(this.templatePool.allocCount === 0);\n  }\n\n  destroy(): void {\n    this.instPool.destroy();\n    this.renderCache.destroy();\n  }\n\n  /**\n   * Disables the \"simple\" render inst list management API.\n   */\n  disableSimpleMode(): void {\n    // This is a one-way street!\n    this.simpleRenderInstList = null;\n  }\n\n  // /**\n  //  * Execute all scheduled render insts in {@param list} onto the {@param RenderPass},\n  //  * using {@param device} and {@param cache} to create any device-specific resources\n  //  * necessary to complete the draws.\n  //  */\n  // drawListOnPassRenderer(list: RenderInstList, passRenderer: RenderPass): void {\n  //   list.drawOnPassRenderer(this.renderCache, passRenderer);\n  // }\n\n  drawOnPassRenderer(passRenderer: RenderPass): void {\n    const list = assertExists(this.simpleRenderInstList);\n    list.drawOnPassRenderer(this.renderCache, passRenderer);\n  }\n\n  drawOnPassRendererNoReset(passRenderer: RenderPass): void {\n    const list = assertExists(this.simpleRenderInstList);\n    list.drawOnPassRendererNoReset(this.renderCache, passRenderer);\n  }\n}\n","import type { Device } from '@antv/g-device-api';\nimport { RendererParameters, ToneMapping } from '../interfaces';\nimport { DynamicUniformBuffer } from './DynamicUniformBuffer';\nimport { RenderCache } from './RenderCache';\nimport { RenderGraph } from './RenderGraph';\nimport type { RenderInst } from './RenderInst';\nimport { RenderInstManager } from './RenderInstManager';\n\nexport class RenderHelper {\n  renderCache: RenderCache;\n  renderGraph: RenderGraph;\n  renderInstManager: RenderInstManager;\n  uniformBuffer: DynamicUniformBuffer;\n  // debugThumbnails: DebugThumbnailDrawer;\n\n  private device: Device;\n\n  constructor(private parameters: RendererParameters) {}\n\n  getDevice(): Device {\n    return this.device;\n  }\n\n  setDevice(device: Device) {\n    this.device = device;\n\n    this.renderCache = new RenderCache(device);\n    this.renderGraph = new RenderGraph(this.device);\n    this.renderInstManager = new RenderInstManager(this.renderCache);\n    this.uniformBuffer = new DynamicUniformBuffer(this.device);\n    // this.debugThumbnails = new DebugThumbnailDrawer(this);\n  }\n\n  pushTemplateRenderInst(): RenderInst {\n    const template = this.renderInstManager.pushTemplateRenderInst();\n    template.setUniformBuffer(this.uniformBuffer);\n    return template;\n  }\n\n  prepareToRender(): void {\n    this.uniformBuffer.prepareToRender();\n  }\n\n  destroy(): void {\n    if (this.uniformBuffer) {\n      this.uniformBuffer.destroy();\n    }\n    if (this.renderInstManager) {\n      this.renderInstManager.destroy();\n    }\n    if (this.renderCache) {\n      this.renderCache.destroy();\n    }\n    if (this.renderGraph) {\n      this.renderGraph.destroy();\n    }\n  }\n\n  // getDebugTextDrawer(): TextDrawer | null {\n  //   return null;\n  // }\n\n  getCache(): RenderCache {\n    return this.renderCache;\n  }\n\n  getDefines() {\n    return {\n      USE_TONEMAPPING:\n        this.parameters?.toneMapping &&\n        this.parameters?.toneMapping !== ToneMapping.NONE,\n      toneMapping: this.parameters?.toneMapping,\n    };\n  }\n}\n","import type { Color, Format } from '@antv/g-device-api';\n\nexport class RGRenderTargetDescription {\n  width = 0;\n  height = 0;\n  sampleCount = 0;\n\n  colorClearColor: Readonly<Color> | 'load' = 'load';\n  depthClearValue: number | 'load' = 'load';\n  stencilClearValue: number | 'load' = 'load';\n\n  constructor(public format: Format) {}\n\n  /**\n   * Set the dimensions of a render target description.\n   */\n  setDimensions(width: number, height: number, sampleCount: number): void {\n    this.width = width;\n    this.height = height;\n    this.sampleCount = sampleCount;\n  }\n\n  copyDimensions(desc: Readonly<RGRenderTargetDescription>): void {\n    this.width = desc.width;\n    this.height = desc.height;\n    this.sampleCount = desc.sampleCount;\n  }\n}\n","import type { Color } from '@antv/g-device-api';\nimport {\n  Format,\n  colorNewFromRGBA,\n  OpaqueBlack,\n  OpaqueWhite,\n} from '@antv/g-device-api';\n// import { reverseDepthForClearValue } from '../platform/utils';\nimport { RGAttachmentSlot } from './interfaces';\nimport { RGRenderTargetDescription } from './RenderTargetDescription';\n\nexport function makeAttachmentClearDescriptor(\n  clearColor: Readonly<Color> | 'load',\n): GfxrAttachmentClearDescriptor {\n  return {\n    colorClearColor: clearColor,\n    // depthClearValue: reverseDepthForClearValue(1.0),\n    depthClearValue: 1,\n    stencilClearValue: 0.0,\n  };\n}\n\nexport const standardFullClearRenderPassDescriptor =\n  makeAttachmentClearDescriptor(colorNewFromRGBA(0.88, 0.88, 0.88, 1.0));\nexport const opaqueBlackFullClearRenderPassDescriptor =\n  makeAttachmentClearDescriptor(OpaqueBlack);\nexport const opaqueWhiteFullClearRenderPassDescriptor =\n  makeAttachmentClearDescriptor(OpaqueWhite);\n\nexport enum AntialiasingMode {\n  None,\n  FXAA,\n  MSAAx4,\n}\n\nexport interface RenderInput {\n  backbufferWidth: number;\n  backbufferHeight: number;\n  antialiasingMode: AntialiasingMode;\n}\n\nfunction selectFormatSimple(slot: RGAttachmentSlot): Format {\n  if (slot === RGAttachmentSlot.Color0) {\n    return Format.U8_RGBA_RT;\n  }\n  if (slot === RGAttachmentSlot.DepthStencil) {\n    return Format.D24_S8;\n  }\n  throw new Error('whoops');\n}\n\nfunction selectSampleCount(renderInput: RenderInput): number {\n  if (renderInput.antialiasingMode === AntialiasingMode.MSAAx4) {\n    return 4;\n  }\n  return 1;\n}\n\nexport function setBackbufferDescSimple(\n  desc: RGRenderTargetDescription,\n  renderInput: RenderInput,\n): void {\n  const sampleCount = selectSampleCount(renderInput);\n  desc.setDimensions(\n    renderInput.backbufferWidth,\n    renderInput.backbufferHeight,\n    sampleCount,\n  );\n}\n\nexport interface GfxrAttachmentClearDescriptor {\n  colorClearColor: Readonly<Color> | 'load';\n  depthClearValue: number;\n  stencilClearValue: number;\n}\n\nexport function makeBackbufferDescSimple(\n  slot: RGAttachmentSlot,\n  renderInput: RenderInput,\n  clearDescriptor: GfxrAttachmentClearDescriptor,\n): RGRenderTargetDescription {\n  const pixelFormat = selectFormatSimple(slot);\n  const desc = new RGRenderTargetDescription(pixelFormat);\n\n  setBackbufferDescSimple(desc, renderInput);\n\n  if (clearDescriptor !== null) {\n    desc.colorClearColor = clearDescriptor.colorClearColor;\n    desc.depthClearValue = clearDescriptor.depthClearValue;\n    desc.stencilClearValue = clearDescriptor.stencilClearValue;\n  }\n\n  return desc;\n}\n","import type { Sampler, Texture } from '@antv/g-device-api';\n\nexport interface ViewerTexture {\n  name: string;\n  surfaces: HTMLCanvasElement[];\n  extraInfo?: Map<string, string> | null;\n  activate?: () => Promise<void>;\n}\n\nexport interface TextureOverride {\n  texture: Texture | null;\n  sampler?: Sampler;\n  width: number;\n  height: number;\n}\n\nexport interface TextureBase {\n  name: string;\n  width: number;\n  height: number;\n}\n\nexport class TextureMapping {\n  name: string;\n  texture: Texture | null = null;\n  sampler: Sampler | null = null;\n  width = 0;\n  height = 0;\n  lodBias = 0;\n  // GL sucks. This is a convenience when building texture matrices.\n  // The core renderer does not use this code at all.\n  // flipY: boolean = false;\n\n  reset(): void {\n    this.texture = null;\n    this.sampler = null;\n    this.width = 0;\n    this.height = 0;\n    this.lodBias = 0;\n    // this.flipY = false;\n  }\n\n  copy(other: TextureMapping): void {\n    this.texture = other.texture;\n    this.sampler = other.sampler;\n    this.width = other.width;\n    this.height = other.height;\n    this.lodBias = other.lodBias;\n    // this.flipY = other.flipY;\n  }\n}\n\nexport interface LoadedTexture {\n  texture: Texture;\n  viewerTexture: ViewerTexture;\n}\n","import type { Device, Texture } from '@antv/g-device-api';\nimport { assert } from '@antv/g-device-api';\nimport type { RGRenderTargetDescription } from './RenderTargetDescription';\nimport { SingleSampledTexture } from './SingleSampledTexture';\n\n// Public API for saving off copies of images for temporal-style effects.\nexport class TemporalTexture {\n  // These names might be a bit confusing, but they're named relative to the graph.\n  // outputTexture is the target of a resolve, inputTexture is the source for sampling.\n\n  private inputTexture: SingleSampledTexture | null = null;\n  private outputTexture: SingleSampledTexture | null = null;\n\n  setDescription(\n    device: Device,\n    desc: Readonly<RGRenderTargetDescription>,\n  ): void {\n    // Updating the description will happen at the start of the frame,\n    // so we need to keep the inputTexture alive (the previous frame's texture),\n    // and create a new outputTexture.\n\n    if (this.inputTexture !== this.outputTexture) {\n      if (this.inputTexture !== null) this.inputTexture.destroy();\n\n      // Set the input texture to our old output texture.\n      this.inputTexture = this.outputTexture;\n    }\n\n    assert(this.inputTexture === this.outputTexture);\n\n    if (\n      this.outputTexture !== null &&\n      this.outputTexture.matchesDescription(desc)\n    )\n      return;\n\n    this.outputTexture = new SingleSampledTexture(device, desc);\n    if (this.inputTexture === null) this.inputTexture = this.outputTexture;\n  }\n\n  getTextureForSampling(): Texture | null {\n    return this.inputTexture !== null ? this.inputTexture.texture : null;\n  }\n\n  getTextureForResolving(): Texture {\n    return this.outputTexture?.texture;\n  }\n\n  destroy(): void {\n    if (\n      this.outputTexture !== null &&\n      this.outputTexture !== this.inputTexture\n    ) {\n      this.outputTexture.destroy();\n      this.outputTexture = null;\n    }\n    if (this.inputTexture !== null) {\n      this.inputTexture.destroy();\n      this.inputTexture = null;\n    }\n  }\n}\n","import type { BaseStyleProps, DisplayObjectConfig } from '@antv/g-lite';\nimport { DisplayObject } from '@antv/g-lite';\nimport type { RenderInstUniform } from '../render';\n\nexport interface LightProps extends BaseStyleProps {\n  intensity?: number;\n}\nexport abstract class Light extends DisplayObject<LightProps> {\n  static PARSED_STYLE_LIST = new Set([\n    ...DisplayObject.PARSED_STYLE_LIST,\n    'intensity',\n  ]);\n\n  static tag = 'light';\n\n  abstract define: string;\n  abstract order: number;\n\n  constructor({ style, ...rest }: DisplayObjectConfig<LightProps> = {}) {\n    super({\n      type: Light.tag,\n      style: {\n        intensity: Math.PI,\n        ...style,\n      },\n      ...rest,\n    });\n  }\n\n  abstract uploadUBO(uniforms: RenderInstUniform[], index: number): void;\n}\n","import type { BaseStyleProps, DisplayObjectConfig } from '@antv/g-lite';\nimport { DisplayObject } from '@antv/g-lite';\n\nexport enum FogType {\n  NONE = 0,\n  EXP = 1,\n  EXP2 = 2,\n  LINEAR = 3,\n}\n\nexport interface FogProps extends BaseStyleProps {\n  // @see https://doc.babylonjs.com/advanced_topics/shaders/Fog+ShaderMat\n  // @see https://developer.playcanvas.com/en/api/pc.Scene.html#fog\n  type: FogType;\n  density: number;\n  start: number;\n  end: number;\n}\nexport class Fog extends DisplayObject<FogProps> {\n  static PARSED_STYLE_LIST = new Set([\n    ...DisplayObject.PARSED_STYLE_LIST,\n    'type',\n    'density',\n    'start',\n    'end',\n  ]);\n\n  static tag = 'fog';\n\n  constructor({ style, ...rest }: DisplayObjectConfig<FogProps> = {}) {\n    super({\n      type: Fog.tag,\n      style: {\n        type: FogType.NONE,\n        fill: 'black',\n        start: 1,\n        end: 1000,\n        density: 0,\n        ...style,\n      },\n      ...rest,\n    });\n  }\n\n  // abstract getUniformWordCount(): number;\n}\n","import { AABB } from '@antv/g-lite';\nimport EventEmitter from 'eventemitter3';\nimport type {\n  Buffer,\n  Device,\n  InputLayoutDescriptor,\n  VertexStepMode,\n} from '@antv/g-device-api';\nimport {\n  BufferFrequencyHint,\n  BufferUsage,\n  Format,\n  PrimitiveTopology,\n} from '@antv/g-device-api';\nimport type { Mesh } from '../Mesh';\n\nexport function makeDataBuffer(\n  device: Device,\n  usage: BufferUsage,\n  data: ArrayBufferLike,\n  hint = BufferFrequencyHint.STATIC,\n): Buffer {\n  const buffer = device.createBuffer({\n    viewOrSize: data.byteLength,\n    usage,\n    hint,\n  });\n  buffer.setSubData(0, new Uint8Array(data));\n  return buffer;\n}\n\nexport type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;\n\nexport interface GeometryVertexBufferDescriptor {\n  bufferIndex: number;\n  byteStride: number;\n  stepMode: VertexStepMode;\n  attributes: {\n    format: Format;\n    bufferByteOffset: number;\n    byteStride?: number;\n    location: number;\n    divisor?: number;\n  }[];\n  data: ArrayBufferView;\n}\n\nexport interface GeometryPatch {\n  bufferIndex: number;\n  location: number;\n  data: ArrayBufferView;\n}\n\nexport interface VertexBufferToUpdateDescriptor {\n  bufferIndex: number;\n  bufferByteOffset?: number;\n  data: ArrayBufferView;\n}\n\nexport enum GeometryEvent {\n  CHANGED = 'changed',\n}\n\n/**\n * just hold descriptors of buffers & indices, won't use underlying GPU resources\n */\nexport class BufferGeometry<GeometryProps = any> extends EventEmitter {\n  drawMode: PrimitiveTopology = PrimitiveTopology.TRIANGLES;\n\n  vertexBuffers: Buffer[] = [];\n\n  vertices: ArrayBufferView[] = [];\n\n  indexBuffer: Buffer;\n\n  indices: IndicesArray;\n\n  inputLayoutDescriptor: InputLayoutDescriptor = {\n    vertexBufferDescriptors: [],\n    indexBufferFormat: null,\n    program: null,\n  };\n\n  vertexCount = 0;\n\n  instancedCount = 0;\n\n  indexStart = 0;\n\n  primitiveStart = 0;\n\n  dirty = true;\n\n  meshes: Mesh[] = [];\n\n  constructor(\n    public device: Device,\n    public props: Partial<GeometryProps> = {},\n  ) {\n    super();\n  }\n\n  validate(mesh: Mesh) {\n    return true;\n  }\n\n  build(meshes: Mesh<GeometryProps>[]) {}\n\n  computeBoundingBox(): AABB {\n    return new AABB();\n  }\n\n  setIndexBuffer(indices: IndicesArray) {\n    if (this.indexBuffer) {\n      this.indexBuffer.destroy();\n    }\n\n    this.indexBuffer = makeDataBuffer(\n      this.device,\n      BufferUsage.INDEX,\n      new Uint32Array(ArrayBuffer.isView(indices) ? indices.buffer : indices)\n        .buffer,\n    );\n\n    this.indices = indices;\n\n    this.inputLayoutDescriptor.indexBufferFormat = Format.U32_R;\n\n    return this;\n  }\n\n  setVertexBuffer(descriptor: GeometryVertexBufferDescriptor) {\n    const { bufferIndex, byteStride, stepMode, attributes, data } = descriptor;\n\n    this.inputLayoutDescriptor.vertexBufferDescriptors[bufferIndex] = {\n      arrayStride: byteStride,\n      stepMode,\n      attributes: [],\n    };\n\n    this.vertices[bufferIndex] = data;\n\n    attributes.forEach(\n      ({ format, bufferByteOffset, location, divisor, byteStride }) => {\n        const existed = this.inputLayoutDescriptor.vertexBufferDescriptors[\n          bufferIndex\n        ].attributes.find((e) => e.shaderLocation === location);\n        if (existed) {\n          existed.format = format;\n          existed.offset = bufferByteOffset;\n          existed.divisor = divisor;\n        } else {\n          this.inputLayoutDescriptor.vertexBufferDescriptors[\n            bufferIndex\n          ].attributes.push({\n            format,\n            offset: bufferByteOffset,\n            shaderLocation: location,\n            divisor,\n          });\n        }\n      },\n    );\n\n    // create GPUBuffer\n    if (this.vertexBuffers[bufferIndex]) {\n      this.vertexBuffers[bufferIndex].destroy();\n    }\n\n    const buffer = makeDataBuffer(\n      this.device,\n      BufferUsage.VERTEX,\n      data.buffer,\n      BufferFrequencyHint.DYNAMIC,\n    );\n    this.vertexBuffers[bufferIndex] = buffer;\n\n    return this;\n  }\n\n  getVertexBuffer(bufferIndex: number) {\n    return this.vertexBuffers[bufferIndex];\n  }\n\n  updateVertexBuffer(\n    bufferIndex: number,\n    location: number,\n    index: number,\n    data: Uint8Array,\n  ) {\n    const bufferDescriptor =\n      this.inputLayoutDescriptor.vertexBufferDescriptors[bufferIndex];\n    if (!bufferDescriptor) {\n      return;\n    }\n    const { arrayStride } = bufferDescriptor;\n\n    const descriptor = this.inputLayoutDescriptor.vertexBufferDescriptors[\n      bufferIndex\n    ].attributes.find((d) => d.shaderLocation === location);\n\n    if (descriptor) {\n      const vertexBuffer = this.getVertexBuffer(bufferIndex);\n      const offset = index * arrayStride;\n      vertexBuffer.setSubData(descriptor.offset + offset, data);\n\n      // TODO: update vertices\n      // this.vertices[bufferIndex] = data;\n    }\n\n    this.emit(GeometryEvent.CHANGED);\n  }\n\n  updateIndices(indices: IndicesArray, offset = 0) {\n    if (this.indexBuffer) {\n      this.indexBuffer.setSubData(\n        offset,\n        new Uint8Array(\n          ArrayBuffer.isView(indices) ? indices : new Uint32Array(indices),\n        ),\n      );\n    }\n    return this;\n  }\n\n  destroy() {\n    this.vertexBuffers.forEach((buffer) => {\n      if (buffer) {\n        buffer.destroy();\n      }\n    });\n\n    if (this.indexBuffer) {\n      this.indexBuffer.destroy();\n    }\n\n    this.inputLayoutDescriptor.vertexBufferDescriptors = [];\n\n    this.indexBuffer = undefined;\n    this.vertexBuffers = [];\n    this.indices = undefined;\n    this.vertices = [];\n    this.vertexCount = 0;\n    this.instancedCount = 0;\n  }\n}\n","import type { InputLayout } from '@antv/g-device-api';\nimport {\n  Format,\n  VertexStepMode,\n  fullscreenMegaState,\n  nArray,\n} from '@antv/g-device-api';\nimport { BufferGeometry } from '../geometries';\nimport { DeviceProgram } from '../render/DeviceProgram';\nimport type { RGGraphBuilder } from '../render/interfaces';\nimport { RGAttachmentSlot } from '../render/interfaces';\nimport type { RenderHelper } from '../render/RenderHelper';\nimport { TextureMapping } from '../render/TextureHolder';\nimport { fillVec4 } from '../render/utils';\nimport vert from '../shader/passes/fullscreen.vert';\nimport frag from '../shader/passes/fxaa.frag';\n\nclass FXAAProgram extends DeviceProgram {\n  features = {};\n\n  both = `\nlayout(std140) uniform ub_Params {\n    vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n`;\n\n  vert = vert;\n  frag = frag;\n}\n\ninterface RenderInput {\n  backbufferWidth: number;\n  backbufferHeight: number;\n}\n\nconst textureMapping = nArray(1, () => new TextureMapping());\nlet geometry: BufferGeometry;\nlet inputLayout: InputLayout;\n\nexport function pushFXAAPass(\n  builder: RGGraphBuilder,\n  renderHelper: RenderHelper,\n  renderInput: RenderInput,\n  mainColorTargetID: number,\n): void {\n  builder.pushPass((pass) => {\n    pass.setDebugName('FXAA');\n    pass.attachRenderTargetID(RGAttachmentSlot.Color0, mainColorTargetID);\n\n    const mainColorResolveTextureID =\n      builder.resolveRenderTarget(mainColorTargetID);\n    pass.attachResolveTexture(mainColorResolveTextureID);\n\n    const renderInst = renderHelper.renderInstManager.newRenderInst();\n    renderInst.setUniformBuffer(renderHelper.uniformBuffer);\n    renderInst.setAllowSkippingIfPipelineNotReady(false);\n\n    renderInst.setMegaStateFlags(fullscreenMegaState);\n    renderInst.setBindingLayout({ numUniformBuffers: 1, numSamplers: 1 });\n    renderInst.drawPrimitives(3);\n\n    // since gl_VertexID is not available in GLSL 100, we need to use a geometry\n    const offs = renderInst.allocateUniformBuffer(0, 4);\n    const d = renderInst.mapUniformBufferF32(0);\n    fillVec4(\n      d,\n      offs,\n      1.0 / renderInput.backbufferWidth,\n      1.0 / renderInput.backbufferHeight,\n    );\n\n    const fxaaProgram = new FXAAProgram();\n    const program = renderHelper.renderCache.createProgramSimple(fxaaProgram);\n\n    renderInst.setProgram(program);\n\n    if (!geometry) {\n      geometry = new BufferGeometry(renderHelper.getDevice());\n      geometry.setVertexBuffer({\n        bufferIndex: 0,\n        byteStride: 4 * 2,\n        stepMode: VertexStepMode.VERTEX,\n        attributes: [\n          {\n            format: Format.F32_RG,\n            bufferByteOffset: 4 * 0,\n            location: 0,\n          },\n        ],\n        // rendering a fullscreen triangle instead of quad\n        // @see https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/\n        data: new Float32Array([1, 3, -3, -1, 1, -1]),\n      });\n      geometry.vertexCount = 3;\n\n      inputLayout = renderHelper\n        .getCache()\n        .createInputLayout(geometry.inputLayoutDescriptor);\n    }\n\n    pass.exec((passRenderer, scope) => {\n      textureMapping[0].texture = scope.getResolveTextureForID(\n        mainColorResolveTextureID,\n      );\n      renderInst.setSamplerBindingsFromTextureMappings(textureMapping);\n      renderInst.setVertexInput(\n        inputLayout,\n        geometry.vertexBuffers.map((buffer) => ({\n          buffer,\n          byteOffset: 0,\n        })),\n        null,\n      );\n      renderInst.drawOnPass(renderHelper.renderCache, passRenderer);\n    });\n  });\n}\n","/// <reference types=\"webxr\" />\n\nimport type {\n  CSSRGB,\n  DataURLOptions,\n  DisplayObject,\n  FederatedEvent,\n  CustomEvent,\n  MutationEvent,\n  MutationRecord,\n  RenderingPlugin,\n  RenderingPluginContext,\n} from '@antv/g-lite';\nimport { CanvasEvent, ElementEvent, Shape, parseColor } from '@antv/g-lite';\nimport type {\n  Color,\n  Device,\n  SwapChain,\n  Texture,\n  TextureDescriptor,\n} from '@antv/g-device-api';\nimport {\n  BlendFactor,\n  BlendMode,\n  colorNewFromRGBA,\n  setAttachmentStateSimple,\n  TransparentBlack,\n  TransparentWhite,\n} from '@antv/g-device-api';\nimport { mat4, vec3 } from 'gl-matrix';\nimport { Renderable3D } from './components/Renderable3D';\nimport type { LightPool } from './LightPool';\nimport { Fog, Light } from './lights';\nimport { pushFXAAPass } from './passes/FXAA';\nimport type { RGGraphBuilder, RenderHelper } from './render';\nimport {\n  AntialiasingMode,\n  makeAttachmentClearDescriptor,\n  makeBackbufferDescSimple,\n  opaqueWhiteFullClearRenderPassDescriptor,\n  RenderInstList,\n  RGAttachmentSlot,\n} from './render';\nimport type { BatchManager } from './renderer';\nimport type { TexturePool } from './TexturePool';\nimport { DeviceRendererPluginOptions } from './interfaces';\n\n// scene uniform block index\nexport const SceneUniformBufferIndex = 0;\n\n// uniforms in scene level\nexport enum SceneUniform {\n  PROJECTION_MATRIX = 'u_ProjectionMatrix',\n  VIEW_MATRIX = 'u_ViewMatrix',\n  CAMERA_POSITION = 'u_CameraPosition',\n  DEVICE_PIXEL_RATIO = 'u_DevicePixelRatio',\n  VIEWPORT = 'u_Viewport',\n  IS_ORTHO = 'u_IsOrtho',\n  IS_PICKING = 'u_IsPicking',\n}\n\nexport class RenderGraphPlugin implements RenderingPlugin {\n  static tag = 'RenderGraph';\n\n  private context: RenderingPluginContext;\n\n  constructor(\n    private renderHelper: RenderHelper,\n    private lightPool: LightPool,\n    private texturePool: TexturePool,\n    private batchManager: BatchManager,\n    private options: Partial<DeviceRendererPluginOptions>,\n  ) {}\n\n  private device: Device;\n\n  private swapChain: SwapChain;\n\n  private renderLists = {\n    /**\n     * used in main forward rendering pass\n     */\n    leftEye: new RenderInstList(),\n    /**\n     * right eye in VR session.\n     */\n    rightEye: new RenderInstList(),\n    /**\n     * used in picking pass, should disable blending\n     */\n    picking: new RenderInstList(),\n  };\n\n  /**\n   * Render Graph builder at each frame\n   */\n  private builder: RGGraphBuilder;\n\n  private enableCapture: boolean;\n  private captureOptions: Partial<DataURLOptions>;\n  private capturePromise: Promise<string> | undefined;\n  private resolveCapturePromise: (dataURL: string) => void;\n\n  /**\n   * An array of sub cameras used in VR scenes.\n   * @see https://threejs.org/docs/#api/en/cameras/ArrayCamera\n   */\n  private cameras: {\n    viewport: XRViewport;\n    projectionMatrix: mat4;\n    viewMatrix: mat4;\n    cameraPosition: vec3;\n    isOrtho: boolean;\n  }[] = [];\n\n  getDevice(): Device {\n    return this.device;\n  }\n\n  getSwapChain(): SwapChain {\n    return this.swapChain;\n  }\n\n  getRenderLists() {\n    return this.renderLists;\n  }\n\n  apply(context: RenderingPluginContext) {\n    this.context = context;\n    const { renderingService, renderingContext, config } = context;\n    const canvas = renderingContext.root.ownerDocument.defaultView;\n    config.disableRenderHooks = true;\n\n    const handleMounted = (e: FederatedEvent) => {\n      const object = e.target as DisplayObject;\n\n      // collect lights\n      if (object.nodeName === Light.tag) {\n        this.lightPool.addLight(object as unknown as Light);\n        return;\n      }\n      if (object.nodeName === Fog.tag) {\n        this.lightPool.addFog(object as Fog);\n        return;\n      }\n\n      // @ts-ignore\n      if (!object.renderable3D) {\n        // @ts-ignore\n        object.renderable3D = new Renderable3D();\n      }\n\n      this.batchManager.add(object);\n    };\n\n    const handleUnmounted = (e: FederatedEvent) => {\n      const object = e.target as DisplayObject;\n\n      if (object.nodeName === Light.tag) {\n        this.lightPool.removeLight(object as unknown as Light);\n        return;\n      }\n      if (object.nodeName === Fog.tag) {\n        this.lightPool.removeFog(object as Fog);\n        return;\n      }\n      if (object.nodeName === Shape.MESH) {\n        if (object.style.geometry?.meshes) {\n          const index = object.style.geometry.meshes.indexOf(object);\n          if (index > -1) {\n            object.style.geometry.meshes.splice(index, 1);\n          }\n        }\n        if (object.style.material?.meshes) {\n          const index = object.style.material.meshes.indexOf(object);\n          if (index > -1) {\n            object.style.material.meshes.splice(index, 1);\n          }\n        }\n      }\n\n      if (this.swapChain) {\n        this.batchManager.remove(object);\n      }\n\n      // @ts-ignore\n      delete object.renderable3D;\n\n      // entity.removeComponent(Geometry3D, true);\n      // entity.removeComponent(Material3D, true);\n      // entity.removeComponent(Renderable3D, true);\n    };\n\n    const handleAttributeChanged = (e: MutationEvent) => {\n      if (this.swapChain) {\n        const object = e.target as DisplayObject;\n        const { attrName, newValue } = e;\n\n        if (attrName === 'zIndex') {\n          object.parentNode.forEach((child: DisplayObject) => {\n            this.batchManager.changeRenderOrder(\n              child,\n              child.sortable.renderOrder,\n            );\n          });\n        } else {\n          this.batchManager.updateAttribute(object, attrName, newValue);\n        }\n      }\n    };\n\n    const handleBoundsChanged = (\n      e: CustomEvent<{ detail: MutationRecord[] }>,\n    ) => {\n      if (this.swapChain) {\n        const records = e.detail;\n        for (let i = 0; i < records.length; i++) {\n          const record = records[i];\n          const object = record.target as DisplayObject;\n          const nodes =\n            object.nodeName === Shape.FRAGMENT ? object.childNodes : [object];\n\n          nodes.forEach((node: DisplayObject) => {\n            this.batchManager.updateAttribute(node, 'modelMatrix', null);\n          });\n        }\n      }\n    };\n\n    renderingService.hooks.initAsync.tapPromise(\n      RenderGraphPlugin.tag,\n      async () => {\n        canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);\n        canvas.addEventListener(ElementEvent.UNMOUNTED, handleUnmounted);\n        canvas.addEventListener(\n          ElementEvent.ATTR_MODIFIED,\n          handleAttributeChanged,\n        );\n        canvas.addEventListener(\n          ElementEvent.BOUNDS_CHANGED,\n          handleBoundsChanged,\n        );\n        this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;\n\n        const $canvas =\n          this.context.contextService.getDomElement() as HTMLCanvasElement;\n\n        const { width, height } = this.context.config;\n        this.context.contextService.resize(width, height);\n\n        // create swap chain and get device\n        // @ts-ignore\n        this.swapChain =\n          await this.context.deviceContribution.createSwapChain($canvas);\n        this.device = this.swapChain.getDevice();\n        this.renderHelper.setDevice(this.device);\n        this.renderHelper.renderInstManager.disableSimpleMode();\n        this.swapChain.configureSwapChain($canvas.width, $canvas.height);\n\n        canvas.addEventListener(CanvasEvent.RESIZE, () => {\n          this.swapChain.configureSwapChain($canvas.width, $canvas.height);\n        });\n\n        this.batchManager.attach({\n          device: this.device,\n          ...context,\n        });\n      },\n    );\n\n    renderingService.hooks.destroy.tap(RenderGraphPlugin.tag, () => {\n      this.renderHelper.destroy();\n      this.batchManager.destroy();\n      this.texturePool.destroy();\n\n      canvas.removeEventListener(ElementEvent.MOUNTED, handleMounted);\n      canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);\n      canvas.removeEventListener(\n        ElementEvent.ATTR_MODIFIED,\n        handleAttributeChanged,\n      );\n      canvas.removeEventListener(\n        ElementEvent.BOUNDS_CHANGED,\n        handleBoundsChanged,\n      );\n\n      this.device.destroy();\n      this.device.checkForLeaks();\n\n      config.disableRenderHooks = false;\n    });\n\n    /**\n     * build frame graph at the beginning of each frame\n     */\n    renderingService.hooks.beginFrame.tap(\n      RenderGraphPlugin.tag,\n      (frame: XRFrame) => {\n        const session = frame?.session;\n        const { width, height } = this.context.config;\n        if (session) {\n          // Assumed to be a XRWebGLLayer for now.\n          let layer = session.renderState.baseLayer;\n          if (!layer) {\n            layer = session.renderState.layers[0] as XRWebGLLayer;\n          } else {\n            // Bind the graphics framebuffer to the baseLayer's framebuffer.\n            // Only baseLayer has framebuffer and we need to bind it, even if it is null (for inline sessions).\n            // gl.bindFramebuffer(gl.FRAMEBUFFER, layer.framebuffer);\n          }\n\n          this.swapChain.configureSwapChain(\n            layer.framebufferWidth,\n            layer.framebufferHeight,\n            layer.framebuffer,\n          );\n\n          // @ts-ignore\n          const referenceSpace = session.referenceSpace as XRReferenceSpace;\n          // Retrieve the pose of the device.\n          // XRFrame.getViewerPose can return null while the session attempts to establish tracking.\n          const pose = frame.getViewerPose(referenceSpace);\n          if (pose) {\n            // In mobile AR, we only have one view.\n            pose.views.forEach((view, i) => {\n              const viewport = session.renderState.baseLayer.getViewport(view);\n\n              // @ts-ignore\n              const cameraMatrix = mat4.fromValues(...view.transform.matrix);\n              cameraMatrix[12] *= width;\n              cameraMatrix[13] *= height;\n              cameraMatrix[14] *= 500;\n\n              cameraMatrix[12] += width / 2;\n              cameraMatrix[13] -= height / 2;\n              cameraMatrix[14] += 500 / 2;\n\n              // Use this matrix without modification or decomposition\n              // @see https://immersive-web.github.io/webxr/#dom-xrview-projectionmatrix\n              const projectionMatrix = mat4.fromValues(\n                // @ts-ignore\n                ...view.projectionMatrix,\n              );\n\n              const viewMatrix = mat4.invert(mat4.create(), cameraMatrix);\n              mat4.scale(viewMatrix, viewMatrix, vec3.fromValues(1, -1, 1));\n\n              // @see https://github.com/immersive-web/webxr-samples/blob/main/js/render/core/renderer.js#L651\n              const { x, y, z } = view.transform.position;\n              this.cameras[i] = {\n                viewport: {\n                  x: viewport.x / layer.framebufferWidth,\n                  y: viewport.y / layer.framebufferHeight,\n                  width: viewport.width / layer.framebufferWidth,\n                  height: viewport.height / layer.framebufferHeight,\n                },\n                projectionMatrix,\n                viewMatrix,\n                cameraPosition: [x, y, z],\n                isOrtho: false,\n              };\n            });\n          }\n        } else {\n          const { camera } = this.context;\n          this.cameras = [\n            {\n              viewport: {\n                x: 0,\n                y: 0,\n                width: 1,\n                height: 1,\n              },\n              projectionMatrix: camera.getPerspective(),\n              viewMatrix: camera.getViewTransform(),\n              cameraPosition: camera.getPosition(),\n              isOrtho: camera.isOrtho(),\n            },\n          ];\n        }\n\n        const canvas = this.swapChain.getCanvas() as HTMLCanvasElement;\n        const { renderInstManager } = this.renderHelper;\n        this.builder = this.renderHelper.renderGraph.newGraphBuilder();\n\n        let clearColor: Color;\n        if (this.context.config.background === 'transparent') {\n          clearColor = TransparentBlack;\n        } else {\n          // use canvas.background\n          const backgroundColor = parseColor(\n            this.context.config.background,\n          ) as CSSRGB;\n\n          clearColor = this.context.config.background\n            ? // use premultipliedAlpha\n              // @see https://canvatechblog.com/alpha-blending-and-webgl-99feb392779e\n              colorNewFromRGBA(\n                (Number(backgroundColor.r) / 255) *\n                  Number(backgroundColor.alpha),\n                (Number(backgroundColor.g) / 255) *\n                  Number(backgroundColor.alpha),\n                (Number(backgroundColor.b) / 255) *\n                  Number(backgroundColor.alpha),\n                Number(backgroundColor.alpha),\n              )\n            : TransparentWhite;\n        }\n\n        // retrieve at each frame since canvas may resize\n        const renderInput = {\n          backbufferWidth: canvas.width,\n          backbufferHeight: canvas.height,\n          antialiasingMode: AntialiasingMode.None,\n        };\n        // create main Color RT\n        const mainRenderDesc = makeBackbufferDescSimple(\n          RGAttachmentSlot.Color0,\n          renderInput,\n          makeAttachmentClearDescriptor(clearColor),\n        );\n        // create main Depth RT\n        const mainDepthDesc = makeBackbufferDescSimple(\n          RGAttachmentSlot.DepthStencil,\n          renderInput,\n          opaqueWhiteFullClearRenderPassDescriptor,\n        );\n        const mainColorTargetID = this.builder.createRenderTargetID(\n          mainRenderDesc,\n          'Main Color',\n        );\n        const mainDepthTargetID = this.builder.createRenderTargetID(\n          mainDepthDesc,\n          'Main Depth',\n        );\n\n        // main render pass\n        this.builder.pushPass((pass) => {\n          pass.setDebugName('Main Render Pass');\n          pass.attachRenderTargetID(RGAttachmentSlot.Color0, mainColorTargetID);\n          pass.attachRenderTargetID(\n            RGAttachmentSlot.DepthStencil,\n            mainDepthTargetID,\n          );\n\n          pass.exec((passRenderer, scope) => {\n            this.cameras.forEach(({ viewport }, i) => {\n              const { x, y, width, height } = viewport;\n\n              const { viewportW, viewportH } = scope.currentPass;\n\n              // @see https://github.com/immersive-web/webxr-samples/blob/main/js/render/core/renderer.js#L757\n              passRenderer.setViewport(\n                x * viewportW,\n                y * viewportH,\n                width * viewportW,\n                height * viewportH,\n              );\n\n              (i === 0\n                ? this.renderLists.leftEye\n                : this.renderLists.rightEye\n              ).drawOnPassRenderer(renderInstManager.renderCache, passRenderer);\n            });\n          });\n        });\n\n        // TODO: other post-processing passes\n        if (this.options?.enableFXAA) {\n          // FXAA\n          pushFXAAPass(\n            this.builder,\n            this.renderHelper,\n            renderInput,\n            mainColorTargetID,\n          );\n        }\n\n        // output to screen\n        this.builder.resolveRenderTargetToExternalTexture(\n          mainColorTargetID,\n          this.swapChain.getOnscreenTexture(),\n        );\n      },\n    );\n\n    renderingService.hooks.endFrame.tap(\n      RenderGraphPlugin.tag,\n      (frame: XRFrame) => {\n        const { renderInstManager } = this.renderHelper;\n        const { width, height } = this.context.config;\n        this.cameras.forEach(\n          (\n            { viewport, cameraPosition, viewMatrix, projectionMatrix, isOrtho },\n            i,\n          ) => {\n            const { width: normalizedW, height: normalizedH } = viewport;\n\n            // Push our outer template, which contains the dynamic UBO bindings...\n            const template = this.renderHelper.pushTemplateRenderInst();\n            // SceneParams: binding = 0, ObjectParams: binding = 1\n            template.setBindingLayout({ numUniformBuffers: 2, numSamplers: 0 });\n            template.setMegaStateFlags(\n              setAttachmentStateSimple(\n                {\n                  depthWrite: true,\n                  blendConstant: TransparentBlack,\n                },\n                {\n                  rgbBlendMode: BlendMode.ADD,\n                  alphaBlendMode: BlendMode.ADD,\n                  rgbBlendSrcFactor: BlendFactor.SRC_ALPHA,\n                  alphaBlendSrcFactor: BlendFactor.ONE,\n                  rgbBlendDstFactor: BlendFactor.ONE_MINUS_SRC_ALPHA,\n                  alphaBlendDstFactor: BlendFactor.ONE_MINUS_SRC_ALPHA,\n                },\n              ),\n            );\n\n            template.setUniforms(SceneUniformBufferIndex, [\n              {\n                name: SceneUniform.PROJECTION_MATRIX,\n                value: projectionMatrix,\n              },\n              {\n                name: SceneUniform.VIEW_MATRIX,\n                value: viewMatrix,\n              },\n              {\n                name: SceneUniform.CAMERA_POSITION,\n                value: cameraPosition,\n              },\n              {\n                name: SceneUniform.DEVICE_PIXEL_RATIO,\n                value: this.context.contextService.getDPR(),\n              },\n              {\n                name: SceneUniform.VIEWPORT,\n                value: [width * normalizedW, height * normalizedH],\n              },\n              {\n                name: SceneUniform.IS_ORTHO,\n                value: isOrtho ? 1 : 0,\n              },\n              {\n                name: SceneUniform.IS_PICKING,\n                value: 0,\n              },\n            ]);\n\n            this.batchManager.render(\n              i === 0 ? this.renderLists.leftEye : this.renderLists.rightEye,\n            );\n\n            renderInstManager.popTemplateRenderInst();\n          },\n        );\n\n        this.renderHelper.prepareToRender();\n        this.renderHelper.renderGraph.execute();\n\n        renderInstManager.resetRenderInsts();\n\n        // capture here since we don't preserve drawing buffer\n        if (this.enableCapture && this.resolveCapturePromise) {\n          const { type, encoderOptions } = this.captureOptions;\n          const dataURL = (\n            this.context.contextService.getDomElement() as HTMLCanvasElement\n          ).toDataURL(type, encoderOptions);\n          this.resolveCapturePromise(dataURL);\n          this.enableCapture = false;\n          this.captureOptions = undefined;\n          this.resolveCapturePromise = undefined;\n        }\n      },\n    );\n  }\n\n  /**\n   * load texture in an async way and render when loaded\n   */\n  loadTexture(\n    src: string | TexImageSource,\n    descriptor?: TextureDescriptor,\n    successCallback?: (t: Texture) => void,\n  ) {\n    return this.texturePool.getOrCreateTexture(\n      this.device,\n      src,\n      descriptor,\n      (t) => {\n        if (successCallback) {\n          successCallback(t);\n        }\n      },\n    );\n  }\n\n  async toDataURL(options: Partial<DataURLOptions>) {\n    // trigger re-render\n    this.enableCapture = true;\n    this.captureOptions = options;\n    this.capturePromise = new Promise((resolve) => {\n      this.resolveCapturePromise = (dataURL: string) => {\n        resolve(dataURL);\n      };\n    });\n    return this.capturePromise;\n  }\n}\n","import type {\n  DisplayObject,\n  FederatedEvent,\n  PickingResult,\n  RenderingPlugin,\n  RenderingPluginContext,\n} from '@antv/g-lite';\nimport { ElementEvent, Rectangle } from '@antv/g-lite';\nimport { clamp } from '@antv/util';\nimport {\n  BlendFactor,\n  BlendMode,\n  setAttachmentStateSimple,\n  TransparentBlack,\n} from '@antv/g-device-api';\nimport type { PickingIdGenerator } from './PickingIdGenerator';\nimport type { RenderHelper } from './render';\nimport {\n  AntialiasingMode,\n  makeAttachmentClearDescriptor,\n  makeBackbufferDescSimple,\n  opaqueWhiteFullClearRenderPassDescriptor,\n  RGAttachmentSlot,\n} from './render';\nimport type { BatchManager } from './renderer';\nimport type { RenderGraphPlugin } from './RenderGraphPlugin';\nimport { SceneUniform, SceneUniformBufferIndex } from './RenderGraphPlugin';\nimport { Renderable3D } from './components/Renderable3D';\n\n/**\n * max depth when doing multi-layer picking\n */\nconst MAX_PICKING_DEPTH = 100;\n\n/**\n * Use color-based picking in GPU\n */\nexport class PickingPlugin implements RenderingPlugin {\n  static tag = 'WebGLPicker';\n\n  private context: RenderingPluginContext;\n\n  constructor(\n    private renderHelper: RenderHelper,\n    private renderGraphPlugin: RenderGraphPlugin,\n    private pickingIdGenerator: PickingIdGenerator,\n    private batchManager: BatchManager,\n  ) {}\n\n  apply(context: RenderingPluginContext) {\n    this.context = context;\n    const { renderingService, renderingContext } = context;\n    const canvas = renderingContext.root.ownerDocument.defaultView;\n\n    const handleMounted = (e: FederatedEvent) => {\n      const object = e.target as DisplayObject;\n\n      // @ts-ignore\n      if (!object.renderable3D) {\n        // @ts-ignore\n        object.renderable3D = new Renderable3D();\n      }\n\n      // @ts-ignore\n      const { renderable3D } = object;\n      // generate picking id for later use\n      const pickingId = this.pickingIdGenerator.getId(object);\n      renderable3D.pickingId = pickingId;\n      renderable3D.encodedPickingColor =\n        this.pickingIdGenerator.encodePickingColor(pickingId);\n    };\n\n    const handleUnmounted = (e: FederatedEvent) => {\n      const object = e.target as DisplayObject;\n\n      // @ts-ignore\n      const { renderable3D } = object;\n      if (renderable3D) {\n        this.pickingIdGenerator.deleteById(renderable3D.pickingId);\n      }\n    };\n\n    renderingService.hooks.init.tap(PickingPlugin.tag, () => {\n      canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);\n      canvas.addEventListener(ElementEvent.UNMOUNTED, handleUnmounted);\n    });\n\n    renderingService.hooks.destroy.tap(PickingPlugin.tag, () => {\n      canvas.removeEventListener(ElementEvent.MOUNTED, handleMounted);\n      canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);\n      this.pickingIdGenerator.reset();\n    });\n\n    /**\n     * Sync version is not implemented.\n     */\n    renderingService.hooks.pickSync.tap(\n      PickingPlugin.tag,\n      (result: PickingResult) => {\n        return this.pick(result);\n      },\n    );\n\n    renderingService.hooks.pick.tapPromise(\n      PickingPlugin.tag,\n      async (result: PickingResult) => {\n        return this.pick(result);\n      },\n    );\n  }\n\n  private pick(result: PickingResult) {\n    const { topmost, position } = result;\n\n    // use viewportX/Y\n    const { viewportX: x, viewportY: y } = position;\n    const dpr = this.context.contextService.getDPR();\n    const width = this.context.config.width * dpr;\n    const height = this.context.config.height * dpr;\n\n    const xInDevicePixel = x * dpr;\n    const yInDevicePixel = y * dpr;\n\n    if (\n      !this.renderHelper.renderGraph ||\n      xInDevicePixel > width ||\n      xInDevicePixel < 0 ||\n      yInDevicePixel > height ||\n      yInDevicePixel < 0\n    ) {\n      result.picked = [];\n      return result;\n    }\n\n    // implements multi-layer picking\n    // @see https://github.com/antvis/g/issues/948\n    const pickedDisplayObjects = this.pickByRectangleInDepth(\n      new Rectangle(\n        clamp(Math.round(xInDevicePixel), 0, width - 1),\n        clamp(Math.round(yInDevicePixel), 0, height - 1),\n        1,\n        1,\n      ),\n      topmost ? 1 : MAX_PICKING_DEPTH,\n    );\n\n    result.picked = pickedDisplayObjects;\n    return result;\n  }\n\n  private pickByRectangleInDepth(\n    rect: Rectangle,\n    depth = MAX_PICKING_DEPTH,\n  ): DisplayObject[] {\n    let picked = null;\n    let counter = 1;\n    const targets = [];\n\n    do {\n      picked = this.pickByRectangle(rect, picked);\n\n      if (picked) {\n        counter++;\n        targets.push(picked);\n      } else {\n        break;\n      }\n    } while (picked && counter <= depth);\n\n    if (depth > 1) {\n      // restore encoded picking color\n      this.restorePickingColor(targets);\n    }\n\n    return targets;\n  }\n\n  private restorePickingColor(displayObjects: DisplayObject[]) {\n    displayObjects.forEach((picked) => {\n      this.batchManager.updateAttribute(picked, 'pointerEvents', true, true);\n    });\n  }\n\n  /**\n   * return displayobjects in target rectangle\n   */\n  private pickByRectangle(\n    rect: Rectangle,\n    picked: DisplayObject,\n  ): DisplayObject | null {\n    const device = this.renderGraphPlugin.getDevice();\n    const renderLists = this.renderGraphPlugin.getRenderLists();\n\n    const { renderInstManager } = this.renderHelper;\n    const builder = this.renderHelper.renderGraph.newGraphBuilder();\n    const clearColor = TransparentBlack;\n    const { camera } = this.context;\n\n    // retrieve at each frame since canvas may resize\n    const { x, y, width, height } = rect;\n\n    // use a small picking area(like 1x1) instead of a fullscreen rt\n    const renderInput = {\n      backbufferWidth: width,\n      backbufferHeight: height,\n      antialiasingMode: AntialiasingMode.None,\n    };\n    const mainPickingDesc = makeBackbufferDescSimple(\n      RGAttachmentSlot.Color0,\n      renderInput,\n      makeAttachmentClearDescriptor(clearColor),\n    );\n    const pickingColorTargetID = builder.createRenderTargetID(\n      mainPickingDesc,\n      'Picking Color',\n    );\n    // create main Depth RT\n    const mainDepthDesc = makeBackbufferDescSimple(\n      RGAttachmentSlot.DepthStencil,\n      renderInput,\n      opaqueWhiteFullClearRenderPassDescriptor,\n    );\n    const mainDepthTargetID = builder.createRenderTargetID(\n      mainDepthDesc,\n      'Picking Depth',\n    );\n\n    // account for current view offset\n    const currentView = { ...camera.getView() };\n\n    // prevent unused RTs like main color being destroyed\n    this.renderHelper.renderGraph.renderTargetDeadPool.forEach((rt) => {\n      rt.age = -1;\n    });\n\n    // picking pass\n    let target: DisplayObject;\n    builder.pushPass((pass) => {\n      pass.setDebugName('Picking Pass');\n      pass.attachRenderTargetID(RGAttachmentSlot.Color0, pickingColorTargetID);\n      pass.attachRenderTargetID(\n        RGAttachmentSlot.DepthStencil,\n        mainDepthTargetID,\n      );\n      pass.exec((passRenderer) => {\n        renderLists.picking.drawOnPassRenderer(\n          renderInstManager.renderCache,\n          passRenderer,\n        );\n      });\n      pass.post((scope) => {\n        const texture = scope.getRenderTargetTexture(RGAttachmentSlot.Color0);\n\n        const readback = device.createReadback();\n\n        // restore previous view\n        if (currentView && currentView.enabled) {\n          camera.setViewOffset(\n            currentView.fullWidth,\n            currentView.fullHeight,\n            currentView.offsetX,\n            currentView.offsetY,\n            currentView.width,\n            currentView.height,\n          );\n        } else {\n          camera.clearViewOffset();\n        }\n\n        camera.setEnableUpdate(true);\n\n        let pickedColors: Uint8Array;\n        try {\n          pickedColors = readback.readTextureSync(\n            texture,\n            0,\n            0,\n            width,\n            height,\n            new Uint8Array(width * height * 4),\n          ) as Uint8Array;\n        } catch {}\n\n        let pickedFeatureIdx = -1;\n\n        if (\n          pickedColors &&\n          (pickedColors[0] !== 0 ||\n            pickedColors[1] !== 0 ||\n            pickedColors[2] !== 0)\n        ) {\n          pickedFeatureIdx =\n            this.pickingIdGenerator.decodePickingColor(pickedColors);\n        }\n\n        if (pickedFeatureIdx > -1) {\n          const pickedDisplayObject =\n            this.pickingIdGenerator.getById(pickedFeatureIdx);\n\n          if (\n            pickedDisplayObject &&\n            pickedDisplayObject.isVisible() &&\n            pickedDisplayObject.isInteractive()\n          ) {\n            target = pickedDisplayObject;\n          }\n        }\n        readback.destroy();\n      });\n    });\n\n    // Push our outer template, which contains the dynamic UBO bindings...\n    const template = this.renderHelper.pushTemplateRenderInst();\n    // SceneParams: binding = 0, ObjectParams: binding = 1\n    template.setBindingLayout({ numUniformBuffers: 2, numSamplers: 0 });\n    template.setMegaStateFlags(\n      setAttachmentStateSimple(\n        {\n          depthWrite: true,\n        },\n        {\n          rgbBlendMode: BlendMode.ADD,\n          rgbBlendSrcFactor: BlendFactor.ONE,\n          rgbBlendDstFactor: BlendFactor.ZERO,\n          alphaBlendMode: BlendMode.ADD,\n          alphaBlendSrcFactor: BlendFactor.ONE,\n          alphaBlendDstFactor: BlendFactor.ZERO,\n        },\n      ),\n    );\n\n    // Update Scene Params\n    const { width: canvasWidth, height: canvasHeight } = this.context.config;\n    const dpr = this.context.contextService.getDPR();\n\n    camera.setEnableUpdate(false);\n    camera.setViewOffset(\n      canvasWidth * dpr,\n      canvasHeight * dpr,\n      x,\n      // fix https://github.com/antvis/G/issues/1747\n      canvasHeight * dpr - y,\n      width,\n      height,\n    );\n\n    template.setUniforms(SceneUniformBufferIndex, [\n      {\n        name: SceneUniform.PROJECTION_MATRIX,\n        value: camera.getPerspective(),\n      },\n      {\n        name: SceneUniform.VIEW_MATRIX,\n        value: camera.getViewTransform(),\n      },\n      {\n        name: SceneUniform.CAMERA_POSITION,\n        value: camera.getPosition(),\n      },\n      {\n        name: SceneUniform.DEVICE_PIXEL_RATIO,\n        value: this.context.contextService.getDPR(),\n      },\n      {\n        name: SceneUniform.VIEWPORT,\n        value: [width, height],\n      },\n      {\n        name: SceneUniform.IS_ORTHO,\n        value: camera.isOrtho() ? 1 : 0,\n      },\n      {\n        name: SceneUniform.IS_PICKING,\n        value: 1,\n      },\n    ]);\n\n    if (picked) {\n      this.batchManager.updateAttribute(picked, 'pointerEvents', false, true);\n    }\n    this.batchManager.render(renderLists.picking, true);\n\n    renderInstManager.popTemplateRenderInst();\n\n    this.renderHelper.prepareToRender();\n    this.renderHelper.renderGraph.execute();\n\n    renderInstManager.resetRenderInsts();\n\n    return target;\n  }\n}\n","import type { DisplayObject } from '@antv/g-lite';\nimport type { Instanced } from '../drawcalls/Instanced';\nimport type { RenderInst } from '../render/RenderInst';\n\n/**\n * render order start from 0, our default camera's Z is 500\n */\nexport const RENDER_ORDER_SCALE = 500 / 1000000;\n\n/**\n * A container for multiple display objects with the same `style`,\n * eg. 1000 Circles with the same stroke color, but their position, radius can be different\n */\nexport abstract class Batch {\n  /**\n   * describe render insts used in this draw call\n   * eg. a Polygon with stroke will use 2 renderInsts\n   */\n  abstract getDrawcallCtors(object: DisplayObject): (typeof Instanced)[];\n\n  private clipPathMeshCreated = false;\n\n  beforeUploadUBO(renderInst: RenderInst, mesh: Instanced) {}\n\n  beforeInitMesh(mesh: Instanced) {}\n  afterInitMesh(mesh: Instanced) {}\n\n  // private findClipPath(): DisplayObject | null {\n  //   let node = this.instance;\n  //   while (node && node.style) {\n  //     if (node.style.clipPath) {\n  //       return node.style.clipPath;\n  //     }\n  //     node = node.parentNode as DisplayObject;\n  //   }\n  //   return null;\n  // }\n\n  // private applyClipPath() {\n  //   // find clipPath\n  //   const clipPathShape = this.findClipPath();\n  //   if (clipPathShape && !this.clipPathMeshCreated) {\n  //     if (this.batchMeshList.length === 0) {\n  //       return;\n  //     }\n\n  //     const clipPathMesh = this.meshFactory(clipPathShape.nodeName);\n  //     clipPathMesh.clipPathTarget = this.instance;\n\n  //     // draw clipPath first\n  //     this.batchMeshList.unshift(clipPathMesh);\n  //     this.clipPathMeshCreated = true;\n\n  //     this.batchMeshList.forEach((mesh, i) => {\n  //       mesh.clipPath = clipPathShape;\n\n  //       if (!mesh.material) {\n  //         mesh.material = new ShaderMaterial(this.device);\n  //       }\n  //       mesh.material.stencilRef = this.batchManager.getStencilRef(clipPathShape);\n  //     });\n  //   }\n\n  //   // remove clipPath from render queue\n  //   if (!clipPathShape) {\n  //     if (this.batchMeshList.length && this.batchMeshList[0].clipPathTarget) {\n  //       this.batchMeshList.shift();\n  //     }\n  //   }\n  // }\n}\n","import type { Tuple4Number } from '@antv/g-lite';\nimport { isNil } from '@antv/util';\nimport EventEmitter from 'eventemitter3';\nimport type {\n  BlendFactor,\n  BlendMode,\n  Color,\n  CompareFunction,\n  CullMode,\n  Device,\n  Format,\n  FrontFace,\n  StencilFaceState,\n  Texture,\n} from '@antv/g-device-api';\nimport {\n  TextureEvent,\n  copyMegaState,\n  defaultMegaState,\n  getUniforms,\n} from '@antv/g-device-api';\nimport type { Mesh } from '../Mesh';\n\nexport interface IMaterial {\n  cullMode: CullMode;\n\n  blendConstant: Color;\n  blendEquation: BlendMode;\n  blendEquationAlpha: BlendMode;\n  blendSrc: BlendFactor;\n  blendDst: BlendFactor;\n  blendSrcAlpha: BlendFactor;\n  blendDstAlpha: BlendFactor;\n\n  depthCompare: CompareFunction;\n  depthTest: boolean;\n  depthWrite: boolean;\n\n  stencilFront: Partial<StencilFaceState>;\n  stencilBack: Partial<StencilFaceState>;\n\n  stencilWrite: boolean;\n  stencilRef: number;\n\n  frontFace: FrontFace;\n\n  // @see https://developer.mozilla.org/zh-CN/docs/Web/API/WebGLRenderingContext/polygonOffset\n  polygonOffset: boolean;\n\n  // gl.DITHER\n  dithering: boolean;\n\n  // @see https://doc.babylonjs.com/divingDeeper/materials/using/materials_introduction#wireframe\n  wireframe: boolean;\n  wireframeColor: string;\n  wireframeLineWidth: number;\n\n  vertexShader: string;\n  fragmentShader: string;\n}\n\ntype MaterialUniformData =\n  | number\n  | [number]\n  | [number, number]\n  | [number, number, number]\n  | Tuple4Number\n  | [\n      // mat2\n      [number, number],\n      [number, number],\n    ]\n  | [\n      // mat3\n      [number, number, number],\n      [number, number, number],\n      [number, number, number],\n    ]\n  | [\n      // mat4\n      [number, number, number, number],\n      [number, number, number, number],\n      [number, number, number, number],\n      [number, number, number, number],\n    ];\n\nexport interface MaterialUniform {\n  name: string;\n  format: Format;\n  data: MaterialUniformData;\n  offset?: number;\n  size?: number;\n}\n\nfunction isTexture(t: any): t is Texture {\n  return !!(t && t.type);\n}\n\nexport enum MaterialEvent {\n  CHANGED = 'changed',\n}\n\n/**\n * an encapsulation on top of shaders\n * @see https://doc.babylonjs.com/divingDeeper/materials/using/materials_introduction\n */\nexport abstract class Material<T extends IMaterial = any> extends EventEmitter {\n  protected device: Device;\n  protected props: T = {} as T;\n\n  /**\n   * relative meshes\n   */\n  meshes: Mesh[] = [];\n\n  /**\n   * cullFace\n   */\n  get cullMode() {\n    return this.props.cullMode;\n  }\n  set cullMode(value) {\n    this.props.cullMode = value;\n  }\n\n  get frontFace() {\n    return this.props.frontFace;\n  }\n  set frontFace(value) {\n    this.props.frontFace = value;\n  }\n\n  /**\n   * Blending state\n   */\n  get blendConstant() {\n    return this.props.blendConstant;\n  }\n  set blendConstant(value) {\n    this.props.blendConstant = value;\n  }\n  get blendEquation() {\n    return this.props.blendEquation;\n  }\n  set blendEquation(value) {\n    this.props.blendEquation = value;\n  }\n  get blendEquationAlpha() {\n    return this.props.blendEquationAlpha;\n  }\n  set blendEquationAlpha(value) {\n    this.props.blendEquationAlpha = value;\n  }\n  get blendSrc() {\n    return this.props.blendSrc;\n  }\n  set blendSrc(value) {\n    this.props.blendSrc = value;\n  }\n  get blendDst() {\n    return this.props.blendDst;\n  }\n  set blendDst(value) {\n    this.props.blendDst = value;\n  }\n  get blendSrcAlpha() {\n    return this.props.blendSrcAlpha;\n  }\n  set blendSrcAlpha(value) {\n    this.props.blendSrcAlpha = value;\n  }\n  get blendDstAlpha() {\n    return this.props.blendDstAlpha;\n  }\n  set blendDstAlpha(value) {\n    this.props.blendDstAlpha = value;\n  }\n\n  get depthCompare() {\n    return this.props.depthCompare;\n  }\n  set depthCompare(value) {\n    this.props.depthCompare = value;\n  }\n  get depthTest() {\n    return this.props.depthTest;\n  }\n  set depthTest(value) {\n    this.props.depthTest = value;\n  }\n  get depthWrite() {\n    return this.props.depthWrite;\n  }\n  set depthWrite(value) {\n    this.props.depthWrite = value;\n  }\n\n  get stencilFront() {\n    return this.props.stencilFront;\n  }\n  set stencilFront(value) {\n    this.props.stencilFront = value;\n  }\n  get stencilBack() {\n    return this.props.stencilBack;\n  }\n  set stencilBack(value) {\n    this.props.stencilBack = value;\n  }\n  get stencilWrite() {\n    return this.props.stencilWrite;\n  }\n  set stencilWrite(value) {\n    this.props.stencilWrite = value;\n  }\n  get stencilRef() {\n    return this.props.stencilRef;\n  }\n  set stencilRef(value) {\n    this.props.stencilRef = value;\n  }\n\n  // @see https://developer.mozilla.org/zh-CN/docs/Web/API/WebGLRenderingContext/polygonOffset\n  get polygonOffset() {\n    return this.props.polygonOffset;\n  }\n  set polygonOffset(value) {\n    this.props.polygonOffset = value;\n  }\n\n  // gl.DITHER\n  get dithering() {\n    return this.props.dithering;\n  }\n  set dithering(value) {\n    this.props.dithering = value;\n  }\n\n  // @see https://doc.babylonjs.com/divingDeeper/materials/using/materials_introduction#wireframe\n  get wireframe() {\n    return this.props.wireframe;\n  }\n  set wireframe(value) {\n    if (this.props.wireframe !== value) {\n      // need re-generate geometry\n      this.geometryDirty = true;\n      this.programDirty = true;\n      this.props.wireframe = value;\n\n      this.dispatchMutationEvent();\n    }\n\n    this.defines.USE_WIREFRAME = !!value;\n  }\n\n  get wireframeColor() {\n    return this.props.wireframeColor;\n  }\n  set wireframeColor(value) {\n    this.props.wireframeColor = value;\n  }\n  get wireframeLineWidth() {\n    return this.props.wireframeLineWidth;\n  }\n  set wireframeLineWidth(value) {\n    this.props.wireframeLineWidth = value;\n  }\n\n  // shader pairs\n  get vertexShader() {\n    return this.props.vertexShader;\n  }\n  set vertexShader(value) {\n    if (this.props.vertexShader !== value) {\n      this.programDirty = true;\n      this.props.vertexShader = value;\n      this.compile();\n    }\n  }\n  get fragmentShader() {\n    return this.props.fragmentShader;\n  }\n  set fragmentShader(value) {\n    if (this.props.fragmentShader !== value) {\n      this.programDirty = true;\n      this.props.fragmentShader = value;\n      this.compile();\n    }\n  }\n\n  // USE_XXX\n  defines: Record<string, number | boolean | string> = {};\n\n  uniforms: Record<string, number | number[] | Float32Array> = {};\n  // used when sorting before inserted into WebGL2's UBO\n  uniformNames: string[];\n  uboBuffer: number[] = [];\n\n  textures: Record<string, Texture> = {};\n  samplers: string[] = [];\n\n  /**\n   * need re-compiling like vs/fs changed\n   */\n  programDirty = true;\n\n  /**\n   * need re-upload textures\n   */\n  textureDirty = true;\n\n  /**\n   * inform geometry to rebuild, eg. wireframe\n   */\n  geometryDirty = true;\n\n  constructor(device: Device, props: Partial<IMaterial>) {\n    super();\n    const {\n      cullMode,\n      depthCompare,\n      depthWrite,\n      stencilFront,\n      stencilBack,\n      stencilWrite,\n      frontFace,\n      polygonOffset,\n      attachmentsState,\n    } = copyMegaState(defaultMegaState);\n\n    this.device = device;\n\n    // @ts-ignore\n    this.props = {\n      cullMode,\n      depthTest: true,\n      depthCompare,\n      depthWrite,\n      stencilFront,\n      stencilBack,\n      stencilWrite,\n      frontFace,\n      polygonOffset,\n      attachmentsState,\n      dithering: false,\n      wireframe: false,\n      wireframeColor: 'black',\n      wireframeLineWidth: 1,\n      vertexShader: '',\n      fragmentShader: '',\n      ...props,\n    };\n\n    this.compile();\n  }\n\n  private compile() {\n    // uniform sampler2D u_Texture0;\n    this.props.fragmentShader.replace(\n      /^\\s*uniform\\s*sampler2D\\s*(.*)\\s*;$/gm,\n      (_, name) => {\n        this.samplers.push(name);\n        return '';\n      },\n    );\n\n    /**\n     * extract from uniform buffer object, should account for struct & pre-defines, eg.\n     * layout(std140) uniform ub_ObjectParams {\n     *   mat4 u_ModelMatrix;\n     *   vec4 u_Color;\n     *   vec4 u_StrokeColor;\n     *   #ifdef NUM_DIR_LIGHTS\n     *     DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n     *   #endif\n     * }\n     */\n    this.uniformNames = getUniforms(this.props.fragmentShader);\n  }\n\n  /**\n   * @example\n   * material.setUniforms({\n   *   u_ModelMatrix: [1, 2, 3, 4],\n   *   u_Time: 1,\n   *   u_Map: texture,\n   * })\n   */\n  setUniforms(\n    uniforms: Record<string, null | number | number[] | Float32Array | Texture>,\n  ) {\n    let shoudDispatchMutationEvent = false;\n    Object.keys(uniforms).forEach((key) => {\n      const value = uniforms[key];\n      const existedTexture = this.textures[key];\n      if (existedTexture && existedTexture !== value) {\n        // existedTexture.destroy();\n        this.textureDirty = true;\n      }\n\n      if (isTexture(value)) {\n        this.textures[key] = value;\n        this.textureDirty = true;\n        value.on(TextureEvent.LOADED, () => {\n          this.dispatchMutationEvent();\n        });\n      } else {\n        this.uniforms[key] = value;\n        shoudDispatchMutationEvent = true;\n      }\n\n      if (isNil(uniforms[key])) {\n        delete this.textures[key];\n        delete this.uniforms[key];\n      }\n    });\n\n    if (shoudDispatchMutationEvent) {\n      this.dispatchMutationEvent();\n    }\n  }\n\n  private dispatchMutationEvent() {\n    this.emit(MaterialEvent.CHANGED);\n  }\n}\n","import type { Device } from '@antv/g-device-api';\nimport type { IMaterial } from './Material';\nimport { Material } from './Material';\n\nexport class ShaderMaterial extends Material {\n  constructor(device: Device, props?: Partial<IMaterial>) {\n    super(device, {\n      ...props,\n    });\n\n    this.defines = {\n      ...this.defines,\n      USE_UV: false,\n      USE_MAP: false,\n      USE_WIREFRAME: false,\n      USE_FOG: false,\n      USE_LIGHT: false,\n    };\n  }\n}\n","export function enumToObject(enumObject: any): Record<string, number> {\n  const result = {};\n  Object.keys(enumObject).forEach((key) => {\n    if (typeof enumObject[key as any] === 'number') {\n      result[key] = enumObject[key as any];\n    }\n  });\n  return result;\n}\n\nexport function compareDefines(\n  d1: Record<string, any>,\n  d2: Record<string, any>,\n) {\n  const d1Keys = Object.keys(d1);\n  const d2Keys = Object.keys(d2);\n  if (d1Keys.length !== d2Keys.length) {\n    return false;\n  }\n\n  return d1Keys.every((key) => d1[key] === d2[key]);\n}\n\nexport const definedProps = (obj: Record<string, unknown>) =>\n  Object.fromEntries(Object.entries(obj).filter(([k, v]) => v !== undefined));\n","import { clamp } from '@antv/util';\n\nexport function packUint8ToFloat(a: number, b: number) {\n  a = clamp(Math.floor(a), 0, 255);\n  b = clamp(Math.floor(b), 0, 255);\n  return 256 * a + b;\n}\n","import type { DisplayObject, Tuple4Number } from '@antv/g-lite';\nimport { CSSRGB, isPattern, isCSSRGB, parseColor, Shape } from '@antv/g-lite';\nimport { mat4, vec3 } from 'gl-matrix';\nimport {\n  ChannelWriteMask,\n  CompareFunction,\n  Format,\n  makeTextureDescriptor2D,\n  MipmapFilterMode,\n  StencilOp,\n  FilterMode,\n  VertexStepMode,\n  AddressMode,\n} from '@antv/g-device-api';\nimport { BufferGeometry, GeometryEvent } from '../geometries';\nimport type { LightPool } from '../LightPool';\nimport type { Fog } from '../lights';\nimport type { Material } from '../materials';\nimport { MaterialEvent, ShaderMaterial } from '../materials';\nimport type { RenderInst, RenderInstUniform, RenderHelper } from '../render';\nimport {\n  DeviceProgram,\n  makeSortKeyOpaque,\n  RendererLayer,\n  TextureMapping,\n} from '../render';\nimport type { BatchContext } from '../renderer';\nimport type { Batch } from '../renderer/Batch';\nimport { RENDER_ORDER_SCALE } from '../renderer/Batch';\nimport type { TexturePool } from '../TexturePool';\nimport { compareDefines, definedProps, enumToObject } from '../utils/enum';\nimport { packUint8ToFloat } from '../utils/compression';\nimport { ParsedMeshStyleProps } from '../Mesh';\n\nlet counter = 1;\nexport const FILL_TEXTURE_MAPPING = 'FillTextureMapping';\n\n/**\n * WebGPU has max vertex attribute num(8)\n */\nexport enum VertexAttributeBufferIndex {\n  MODEL_MATRIX = 0,\n  PACKED_COLOR,\n  PACKED_STYLE,\n  PICKING_COLOR, // built-in\n  POSITION,\n  NORMAL,\n  UV,\n  BARYCENTRIC,\n  MAX,\n}\n\n/**\n * GL.MAX_VERTEX_ATTRIBS\n */\nexport enum VertexAttributeLocation {\n  // TODO: bind mat4 in WebGL2 instead of decomposed 4 * vec4?\n  // @see https://stackoverflow.com/questions/38853096/webgl-how-to-bind-values-to-a-mat4-attribute/38853623#38853623\n  MODEL_MATRIX0,\n  MODEL_MATRIX1,\n  MODEL_MATRIX2,\n  MODEL_MATRIX3,\n  PACKED_COLOR, // fill & stroke\n  PACKED_STYLE1, // opacity fillOpacity strokeOpacity lineWidth\n  PACKED_STYLE2, // visibility anchorX anchorY increasedLineWidthForHitTesting\n  PICKING_COLOR,\n  POSITION,\n  NORMAL,\n  UV,\n  BARYCENTRIC,\n  MAX,\n}\n\n/**\n * Draw call.\n */\nexport abstract class Instanced {\n  /**\n   * unique ID\n   */\n  id = counter++;\n  renderer: Batch;\n\n  /**\n   * assigned by user which help BatchManager deciding whether to merge,\n   * e.g. `will-change` property in CSS\n   */\n  key: string;\n\n  /**\n   * attribute name used for gradient or pattern\n   */\n  gradientAttributeName: 'stroke' | 'fill' = 'fill';\n\n  constructor(\n    protected renderHelper: RenderHelper,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n    object: DisplayObject,\n    /**\n     * All drawcall constructors.\n     */\n    protected drawcallCtors: (new (..._: any) => Instanced)[],\n    /**\n     * index in renderer.meshes\n     */\n    public index = -1,\n    public context: BatchContext,\n  ) {}\n\n  /**\n   * instances\n   */\n  objects: DisplayObject[] = [];\n\n  material: Material;\n  geometry: BufferGeometry;\n\n  clipPath: DisplayObject;\n  clipPathTarget: DisplayObject;\n\n  private program: DeviceProgram = new DeviceProgram();\n  geometryDirty = true;\n  /**\n   * the same material maybe shared between different canvases\n   */\n  materialDirty = true;\n  /**\n   * texture mappings\n   */\n  protected textureMappings: TextureMapping[] = [];\n\n  /**\n   * Divisor of instanced array.\n   */\n  protected divisor = 1;\n\n  /**\n   * Account for anchor and merge it into modelMatrix.\n   */\n  protected mergeXYZIntoModelMatrix = false;\n\n  protected checkNodeName = true;\n\n  /**\n   * Create a new batch if the number of instances exceeds.\n   */\n  maxInstances = Infinity;\n\n  protected abstract createMaterial(objects: DisplayObject[]): void;\n\n  get instance() {\n    return this.objects[0];\n  }\n\n  inited = false;\n  init() {\n    if (this.inited) {\n      return;\n    }\n\n    this.renderer.beforeInitMesh(this);\n    this.material = new ShaderMaterial(this.context.device);\n    this.material.defines = {\n      ...enumToObject(VertexAttributeLocation),\n      ...this.material.defines,\n    };\n    this.geometry = new BufferGeometry(this.context.device);\n\n    // make refs so that we can trigger MutationEvent on every object\n    this.geometry.meshes = this.objects;\n    this.material.meshes = this.objects;\n\n    this.observeGeometryChanged();\n    this.observeMaterialChanged();\n\n    this.inited = true;\n    this.renderer.afterInitMesh(this);\n  }\n\n  observeGeometryChanged() {\n    this.geometry.on(GeometryEvent.CHANGED, () => {\n      this.geometry.meshes.forEach((mesh) => {\n        mesh.renderable.dirty = true;\n      });\n      this.context.renderingService.dirty();\n    });\n  }\n\n  observeMaterialChanged() {\n    this.material.on(MaterialEvent.CHANGED, () => {\n      this.material.meshes.forEach((mesh) => {\n        mesh.renderable.dirty = true;\n      });\n      this.context.renderingService.dirty();\n    });\n  }\n\n  private shouldMergeColor(o1: DisplayObject, o2: DisplayObject, name: string) {\n    // c1: CSSRGB | CSSGradientValue[] | Pattern, c2: CSSRGB | CSSGradientValue[] | Pattern\n    // can't be merged if gradients & pattern used\n    const source = o1.parsedStyle[name];\n    const target = o2.parsedStyle[name];\n\n    if (!source && !target) {\n      return true;\n    }\n\n    // constant color value\n    if (isCSSRGB(source) && isCSSRGB(target)) {\n      return true;\n    }\n\n    // pattern\n    if (\n      isPattern(source) &&\n      isPattern(target) &&\n      source.image === target.image\n    ) {\n      return true;\n    }\n\n    // gradients\n    if (\n      Array.isArray(source) &&\n      Array.isArray(target) &&\n      o1.style[name] === o2.style[name]\n    ) {\n      return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * should be merged into current InstancedMesh\n   */\n  shouldMerge(object: DisplayObject, index: number): boolean {\n    if (!this.instance) {\n      return true;\n    }\n\n    // Path / Polyline could be rendered as Line\n    if (this.checkNodeName && this.instance.nodeName !== object.nodeName) {\n      return false;\n    }\n\n    // can't be merged when using clipPath\n    if (object.parsedStyle.clipPath) {\n      return false;\n    }\n\n    if (\n      !this.shouldMergeColor(this.instance, object, 'fill') ||\n      !this.shouldMergeColor(this.instance, object, 'stroke')\n    ) {\n      return false;\n    }\n\n    return true;\n  }\n\n  protected createGeometry(objects: DisplayObject[]) {\n    const modelMatrix = mat4.create();\n    const modelViewMatrix = mat4.create();\n    // const normalMatrix = mat3.create();\n    const packedModelMatrix: number[] = [];\n    const packedFillStroke: number[] = [];\n    const packedStyle: number[] = [];\n    const packedPicking: number[] = [];\n    const { divisor } = this;\n    const anchorOffset =\n      objects[0]?.nodeName === Shape.CIRCLE ||\n      objects[0]?.nodeName === Shape.ELLIPSE\n        ? 0.5\n        : 0;\n\n    // const useNormal = this.material.defines.NORMAL;\n\n    objects.forEach((object) => {\n      const {\n        fill,\n        stroke,\n        opacity = 1,\n        fillOpacity = 1,\n        strokeOpacity = 1,\n        lineWidth = 1,\n        visibility,\n        increasedLineWidthForHitTesting = 0,\n      } = object.parsedStyle;\n      let fillColor: Tuple4Number = [0, 0, 0, 0];\n      if (isCSSRGB(fill)) {\n        fillColor = [\n          Number(fill.r),\n          Number(fill.g),\n          Number(fill.b),\n          Number(fill.alpha) * 255,\n        ];\n      }\n      let strokeColor: Tuple4Number = [0, 0, 0, 0];\n      if (isCSSRGB(stroke)) {\n        strokeColor = [\n          Number(stroke.r),\n          Number(stroke.g),\n          Number(stroke.b),\n          Number(stroke.alpha) * 255,\n        ];\n      }\n\n      // if (this.clipPathTarget) {\n      //   // account for target's rts\n      //   mat4.copy(modelMatrix, object.getLocalTransform());\n      //   fillColor = [255, 255, 255, 255];\n      //   mat4.mul(\n      //     modelMatrix,\n      //     this.clipPathTarget.getWorldTransform(),\n      //     modelMatrix,\n      //   );\n      // } else {\n      //   mat4.copy(modelMatrix, object.getWorldTransform());\n      // }\n      mat4.mul(\n        modelViewMatrix,\n        this.context.camera.getViewTransform(),\n        modelMatrix,\n      );\n\n      const encodedPickingColor = (object.isInteractive() &&\n        // @ts-ignore\n        object.renderable3D?.encodedPickingColor) || [0, 0, 0];\n\n      if (this.mergeXYZIntoModelMatrix) {\n        const { x, y, z } = object.parsedStyle as ParsedMeshStyleProps;\n        mat4.mul(\n          modelMatrix,\n          object.getWorldTransform(), // apply anchor\n          mat4.fromTranslation(modelMatrix, vec3.fromValues(x, y, z)),\n        );\n      } else {\n        mat4.copy(modelMatrix, object.getWorldTransform());\n      }\n      packedModelMatrix.push(...modelMatrix);\n      packedFillStroke.push(\n        packUint8ToFloat(fillColor[0], fillColor[1]),\n        packUint8ToFloat(fillColor[2], fillColor[3]),\n        packUint8ToFloat(strokeColor[0], strokeColor[1]),\n        packUint8ToFloat(strokeColor[2], strokeColor[3]),\n      );\n      packedStyle.push(\n        opacity,\n        fillOpacity,\n        strokeOpacity,\n        lineWidth,\n        visibility !== 'hidden' ? 1 : 0,\n        anchorOffset,\n        anchorOffset,\n        increasedLineWidthForHitTesting,\n      );\n      packedPicking.push(\n        ...encodedPickingColor,\n        object.sortable.renderOrder * RENDER_ORDER_SCALE,\n      );\n\n      // if (useNormal) {\n      //   // should not calc normal matrix in shader, mat3.invert is not cheap\n      //   // @see https://stackoverflow.com/a/21079741\n      //   mat3.fromMat4(normalMatrix, modelViewMatrix);\n      //   mat3.invert(normalMatrix, normalMatrix);\n      //   mat3.transpose(normalMatrix, normalMatrix);\n\n      //   const { NORMAL_MATRIX0, NORMAL_MATRIX1, NORMAL_MATRIX2 } = this.material.defines;\n      //   this.bufferGeometry.setVertexBuffer({\n      //     bufferIndex: 4,\n      //     byteStride: 4 * (3 * 3),\n      //     stepMode: VertexStepMode.INSTANCE,\n      //     attributes: [\n      //       {\n      //         format: Format.F32_RGB,\n      //         bufferByteOffset: 4 * 0,\n      //         location: Number(NORMAL_MATRIX0),\n      //         divisor\n      //       },\n      //       {\n      //         format: Format.F32_RGB,\n      //         bufferByteOffset: 4 * 3,\n      //         location: Number(NORMAL_MATRIX1),\n      //         divisor\n      //       },\n      //       {\n      //         format: Format.F32_RGB,\n      //         bufferByteOffset: 4 * 6,\n      //         location: Number(NORMAL_MATRIX2),\n      //         divisor\n      //       },\n      //     ],\n      //     data: new Float32Array(normalMatrix),\n      //   });\n      // }\n    });\n\n    this.geometry.instancedCount = objects.length;\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.MODEL_MATRIX,\n      byteStride: 4 * (4 * 4),\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.MODEL_MATRIX0,\n          divisor,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 4,\n          location: VertexAttributeLocation.MODEL_MATRIX1,\n          divisor,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 8,\n          location: VertexAttributeLocation.MODEL_MATRIX2,\n          divisor,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 12,\n          location: VertexAttributeLocation.MODEL_MATRIX3,\n          divisor,\n        },\n      ],\n      data: new Float32Array(packedModelMatrix),\n    });\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.PACKED_COLOR,\n      byteStride: 4 * 4,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.PACKED_COLOR,\n          divisor,\n        },\n      ],\n      data: new Float32Array(packedFillStroke),\n    });\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.PACKED_STYLE,\n      byteStride: 4 * 8,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.PACKED_STYLE1,\n          divisor,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 4,\n          location: VertexAttributeLocation.PACKED_STYLE2,\n          divisor,\n        },\n      ],\n      data: new Float32Array(packedStyle),\n    });\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.PICKING_COLOR,\n      byteStride: 4 * 4,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.PICKING_COLOR,\n          divisor,\n        },\n      ],\n      data: new Float32Array(packedPicking),\n    });\n  }\n\n  destroy() {\n    if (this.geometry) {\n      this.geometry.destroy();\n    }\n    // if (this.textureMappings) {\n    //   this.textureMappings.forEach((mapping) => {\n    //     mapping.texture.destroy();\n    //   });\n    //   this.textureMappings = [];\n    // }\n  }\n\n  applyRenderInst(renderInst: RenderInst, objects: DisplayObject[]) {\n    // detect if scene changed, eg. lights & fog\n    const fog = this.lightPool.getFog();\n    const useFog = !!fog;\n\n    if (this.clipPathTarget || this.clipPath) {\n      if (this.clipPathTarget) {\n        this.material.stencilWrite = true;\n        // @see https://open.gl/depthstencils\n        this.material.depthWrite = false;\n        this.material.stencilFront = {\n          compare: CompareFunction.ALWAYS,\n          passOp: StencilOp.REPLACE,\n        };\n        this.material.stencilBack = {\n          compare: CompareFunction.ALWAYS,\n          passOp: StencilOp.REPLACE,\n        };\n      } else {\n        this.material.stencilWrite = false;\n        this.material.depthWrite = true;\n        this.material.stencilFront = {\n          compare: CompareFunction.EQUAL,\n          passOp: StencilOp.KEEP,\n        };\n        this.material.stencilBack = {\n          compare: CompareFunction.EQUAL,\n          passOp: StencilOp.KEEP,\n        };\n      }\n    } else {\n      this.material.stencilWrite = false;\n    }\n\n    if (this.materialDirty || this.material.programDirty) {\n      this.createMaterial(objects);\n    }\n\n    const oldDefines = { ...this.material.defines };\n\n    this.material.defines.USE_FOG = useFog;\n    this.material.defines = {\n      ...this.lightPool.getDefines(),\n      ...this.material.defines,\n      ...this.renderHelper.getDefines(),\n    };\n\n    // re-upload textures\n    if (this.material.textureDirty) {\n      this.textureMappings = [];\n\n      // set texture mappings\n      const fillTextureMapping = this.createFillGradientTextureMapping(objects);\n      if (fillTextureMapping) {\n        this.textureMappings.push(fillTextureMapping);\n      }\n\n      Object.keys(this.material.textures)\n        .sort(\n          (a, b) =>\n            this.material.samplers.indexOf(a) -\n            this.material.samplers.indexOf(b),\n        )\n        .forEach((key) => {\n          const mapping = new TextureMapping();\n          mapping.name = key;\n          mapping.texture = this.material.textures[key];\n          this.context.device.setResourceName(\n            mapping.texture,\n            `Material Texture ${key}`,\n          );\n          mapping.sampler = this.renderHelper.getCache().createSampler({\n            addressModeU: AddressMode.CLAMP_TO_EDGE,\n            addressModeV: AddressMode.CLAMP_TO_EDGE,\n            minFilter: FilterMode.POINT,\n            magFilter: FilterMode.BILINEAR,\n            mipmapFilter: MipmapFilterMode.LINEAR,\n            lodMinClamp: 0,\n            lodMaxClamp: 0,\n          });\n\n          this.textureMappings.push(mapping);\n        });\n\n      if (this.textureMappings.length) {\n        this.material.defines.USE_UV = true;\n        this.material.defines.USE_MAP = true;\n      } else {\n        this.material.defines.USE_UV = false;\n        this.material.defines.USE_MAP = false;\n      }\n\n      this.material.textureDirty = false;\n    }\n\n    const needRecompileProgram = !compareDefines(\n      oldDefines,\n      this.material.defines,\n    );\n\n    // re-compile program, eg. DEFINE changed\n    if (\n      needRecompileProgram ||\n      this.material.programDirty ||\n      this.materialDirty\n    ) {\n      // set defines\n      this.material.defines = {\n        ...this.material.defines,\n        ...enumToObject(VertexAttributeLocation),\n      };\n\n      Object.keys(this.material.defines).forEach((key) => {\n        const value = this.material.defines[key];\n        if (typeof value === 'boolean') {\n          this.program.setDefineBool(key, value);\n        } else {\n          this.program.setDefineString(key, `${value}`);\n        }\n      });\n\n      // build shaders\n      this.program.vert = this.material.vertexShader;\n      this.program.frag = this.material.fragmentShader;\n      this.material.programDirty = false;\n      this.materialDirty = false;\n    }\n\n    if (this.material.geometryDirty) {\n      // wireframe 需要额外生成 geometry 重心坐标\n      this.geometryDirty = true;\n      this.material.geometryDirty = false;\n    }\n\n    if (this.geometryDirty || this.geometry.dirty) {\n      // destroy first\n      if (this.geometry) {\n        this.geometry.destroy();\n      }\n      // re-create buffer geometry\n      this.createGeometry(objects);\n\n      // generate wireframe\n      if (this.material.wireframe) {\n        this.generateWireframe(this.geometry);\n      }\n\n      // sync to internal Geometry\n      this.geometryDirty = false;\n      this.geometry.dirty = false;\n    }\n\n    // cached input layout\n    const program = this.renderHelper\n      .getCache()\n      .createProgramSimple(this.program);\n    const inputLayout = this.renderHelper.getCache().createInputLayout({\n      ...this.geometry.inputLayoutDescriptor,\n      program,\n    });\n\n    const useIndexes = !!this.geometry.indexBuffer;\n    renderInst.renderPipelineDescriptor.topology = this.geometry.drawMode;\n    renderInst.setProgram(program);\n    renderInst.setVertexInput(\n      inputLayout,\n      this.geometry.vertexBuffers\n        .filter((b) => !!b)\n        .map((buffer) => ({\n          buffer,\n          byteOffset: 0,\n        })),\n      useIndexes ? { buffer: this.geometry.indexBuffer, offset: 0 } : null,\n    );\n\n    this.renderer.beforeUploadUBO(renderInst, this);\n    // upload uniform buffer object\n    this.uploadUBO(renderInst);\n\n    if (useIndexes) {\n      // drawElements\n      renderInst.drawIndexesInstanced(\n        this.geometry.vertexCount,\n        this.geometry.instancedCount,\n        this.geometry.indexStart,\n      );\n    } else {\n      // drawArrays\n      renderInst.drawPrimitives(\n        this.geometry.vertexCount,\n        this.geometry.primitiveStart,\n      );\n    }\n    // FIXME: 暂时都当作非透明物体，按照创建顺序排序\n    renderInst.sortKey = makeSortKeyOpaque(\n      RendererLayer.OPAQUE,\n      objects[0].sortable.renderOrder,\n    );\n  }\n\n  /**\n   * update a continuous GPU buffer\n   */\n  protected updateBatchedAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ) {\n    if (objects.length === 0) {\n      return;\n    }\n\n    const stylePacked = [\n      'opacity',\n      'fillOpacity',\n      'strokeOpacity',\n      'lineWidth',\n      'visibility',\n      'anchor',\n      'increasedLineWidthForHitTesting',\n    ];\n\n    if (name === 'fill' || name === 'stroke') {\n      const packedFillStroke: number[] = [];\n\n      objects.forEach((object) => {\n        const { fill, stroke } = object.parsedStyle;\n\n        let fillColor: Tuple4Number = [0, 0, 0, 0];\n        if (isCSSRGB(fill)) {\n          fillColor = [\n            Number(fill.r),\n            Number(fill.g),\n            Number(fill.b),\n            Number(fill.alpha) * 255,\n          ];\n        }\n        let strokeColor: Tuple4Number = [0, 0, 0, 0];\n        if (isCSSRGB(stroke)) {\n          strokeColor = [\n            Number(stroke.r),\n            Number(stroke.g),\n            Number(stroke.b),\n            Number(stroke.alpha) * 255,\n          ];\n        }\n\n        packedFillStroke.push(\n          packUint8ToFloat(fillColor[0], fillColor[1]),\n          packUint8ToFloat(fillColor[2], fillColor[3]),\n          packUint8ToFloat(strokeColor[0], strokeColor[1]),\n          packUint8ToFloat(strokeColor[2], strokeColor[3]),\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.PACKED_COLOR,\n        VertexAttributeLocation.PACKED_COLOR,\n        startIndex,\n        new Uint8Array(new Float32Array(packedFillStroke).buffer),\n      );\n\n      const { fill } = this.instance.parsedStyle;\n      const i = this.textureMappings.findIndex(\n        (m) => m.name === FILL_TEXTURE_MAPPING,\n      );\n      if (isCSSRGB(fill)) {\n        if (i >= 0) {\n          // remove original fill texture mapping\n          this.textureMappings.splice(i, -1);\n          this.material.textureDirty = true;\n        }\n      } else {\n        const fillTextureMapping = this.createFillGradientTextureMapping([\n          this.instance,\n        ]);\n        if (i >= 0) {\n          this.textureMappings.splice(i, 1, fillTextureMapping);\n        }\n        this.material.textureDirty = true;\n      }\n    } else if (stylePacked.indexOf(name) > -1) {\n      const packed: number[] = [];\n      const anchorOffset =\n        objects[0]?.nodeName === Shape.CIRCLE ||\n        objects[0]?.nodeName === Shape.ELLIPSE\n          ? 0.5\n          : 0;\n      objects.forEach((object) => {\n        const {\n          opacity = 1,\n          fillOpacity = 1,\n          strokeOpacity = 1,\n          lineWidth = 1,\n          visibility,\n          increasedLineWidthForHitTesting = 0,\n        } = object.parsedStyle;\n        packed.push(\n          opacity,\n          fillOpacity,\n          strokeOpacity,\n          lineWidth,\n          visibility !== 'hidden' ? 1 : 0,\n          anchorOffset,\n          anchorOffset,\n          increasedLineWidthForHitTesting,\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.PACKED_STYLE,\n        VertexAttributeLocation.PACKED_STYLE1,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (\n      name === 'modelMatrix' ||\n      (this.mergeXYZIntoModelMatrix &&\n        (name === 'x' || name === 'y' || name === 'z'))\n    ) {\n      const packed: number[] = [];\n      const modelMatrix = mat4.create();\n      objects.forEach((object) => {\n        if (this.mergeXYZIntoModelMatrix) {\n          const { x, y, z } = object.parsedStyle as ParsedMeshStyleProps;\n          mat4.mul(\n            modelMatrix,\n            object.getWorldTransform(), // apply anchor\n            mat4.fromTranslation(modelMatrix, vec3.fromValues(x, y, z)),\n          );\n        } else {\n          mat4.copy(modelMatrix, object.getWorldTransform());\n        }\n        packed.push(...modelMatrix);\n      });\n\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.MODEL_MATRIX,\n        VertexAttributeLocation.MODEL_MATRIX0,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (name === 'pointerEvents') {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const encodedPickingColor = (value &&\n          object.isInteractive() &&\n          // @ts-ignore\n          object.renderable3D?.encodedPickingColor) || [0, 0, 0];\n        packed.push(\n          ...encodedPickingColor,\n          object.sortable.renderOrder * RENDER_ORDER_SCALE,\n        );\n      });\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.PICKING_COLOR,\n        VertexAttributeLocation.PICKING_COLOR,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    }\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ): void {\n    if (name === 'clipPath') {\n      if (this.clipPath) {\n        this.geometryDirty = true;\n      }\n    }\n\n    // fix https://github.com/antvis/G/issues/1768\n    if (this.geometryDirty === true && this.objects.length !== 0) {\n      if (this.geometry) {\n        this.geometry.destroy();\n      }\n      this.createGeometry(this.objects);\n\n      this.geometryDirty = false;\n    }\n  }\n\n  changeRenderOrder(object: DisplayObject, renderOrder: number) {\n    const index = this.objects.indexOf(object);\n\n    const encodedPickingColor = (object.isInteractive() &&\n      // @ts-ignore\n      object.renderable3D?.encodedPickingColor) || [0, 0, 0];\n    this.geometry.updateVertexBuffer(\n      VertexAttributeBufferIndex.PICKING_COLOR,\n      VertexAttributeLocation.PICKING_COLOR,\n      index,\n      new Uint8Array(\n        new Float32Array([\n          ...encodedPickingColor,\n          renderOrder * RENDER_ORDER_SCALE,\n        ]).buffer,\n      ),\n    );\n  }\n\n  private generateWireframe(geometry: BufferGeometry) {\n    // need generate barycentric coordinates\n    const { indices } = geometry;\n    const indiceNum = geometry.indices.length;\n    const originalVertexBuffers = geometry.vertices.map((buffer) => {\n      // @ts-ignore\n      return buffer.slice();\n    }) as ArrayBufferView[];\n    for (\n      let i = VertexAttributeBufferIndex.PICKING_COLOR;\n      i < geometry.vertexBuffers.length;\n      i++\n    ) {\n      const { arrayStride } =\n        geometry.inputLayoutDescriptor.vertexBufferDescriptors[i];\n      geometry.vertices[i] = new Float32Array((arrayStride / 4) * indiceNum);\n    }\n    // reallocate attribute data\n    let cursor = 0;\n    const uniqueIndices = new Uint32Array(indiceNum);\n    for (let i = 0; i < indiceNum; i++) {\n      const ii = indices[i];\n      for (let j = 1; j < geometry.vertices.length; j++) {\n        const { arrayStride } =\n          geometry.inputLayoutDescriptor.vertexBufferDescriptors[j];\n        const size = arrayStride / 4;\n        for (let k = 0; k < size; k++) {\n          geometry.vertices[j][cursor * size + k] =\n            originalVertexBuffers[j][ii * size + k];\n        }\n      }\n      uniqueIndices[i] = cursor;\n      cursor++;\n    }\n    for (\n      let i = VertexAttributeBufferIndex.PICKING_COLOR + 1;\n      i < geometry.vertexBuffers.length;\n      i++\n    ) {\n      // if (i === 3) {\n      //   continue;\n      // }\n      const { stepMode, arrayStride } =\n        geometry.inputLayoutDescriptor.vertexBufferDescriptors[i];\n      const descriptor =\n        geometry.inputLayoutDescriptor.vertexBufferDescriptors[i].attributes[0];\n      if (descriptor) {\n        const {\n          shaderLocation: location,\n          offset: bufferByteOffset,\n          format,\n          divisor,\n        } = descriptor;\n        geometry.setVertexBuffer({\n          bufferIndex: i,\n          byteStride: arrayStride,\n          stepMode,\n          attributes: [\n            {\n              format,\n              bufferByteOffset,\n              location,\n              divisor,\n            },\n          ],\n          data: geometry.vertices[i],\n        });\n      }\n    }\n    // create barycentric attributes\n    const barycentricBuffer = new Float32Array(indiceNum * 3);\n    for (let i = 0; i < indiceNum; ) {\n      for (let j = 0; j < 3; j++) {\n        const ii = uniqueIndices[i++];\n        barycentricBuffer[ii * 3 + j] = 1;\n      }\n    }\n\n    geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.BARYCENTRIC,\n      byteStride: 4 * 3,\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: Number(VertexAttributeLocation.BARYCENTRIC),\n        },\n      ],\n      data: barycentricBuffer,\n    });\n\n    geometry.setIndexBuffer(uniqueIndices);\n  }\n\n  protected beforeUploadUBO(\n    renderInst: RenderInst,\n    objects: DisplayObject[],\n  ): void {}\n  private uploadUBO(renderInst: RenderInst): void {\n    const numUniformBuffers = 1; // Scene UBO\n    const { material } = this;\n    const lights = this.lightPool.getAllLights();\n    const fog = this.lightPool.getFog();\n    const useFog = !!fog;\n    const useLight = material.defines.USE_LIGHT ?? !!lights.length;\n\n    const useWireframe = material.defines.USE_WIREFRAME;\n\n    // collect uniforms\n    const uniforms = [];\n    if (useWireframe) {\n      const wireframeColor = parseColor(material.wireframeColor) as CSSRGB;\n      uniforms.push({\n        name: 'u_WireframeLineColor',\n        value: [\n          Number(wireframeColor.r) / 255,\n          Number(wireframeColor.g) / 255,\n          Number(wireframeColor.b) / 255,\n        ],\n      });\n      uniforms.push({\n        name: 'u_WireframeLineWidth',\n        value: material.wireframeLineWidth,\n      });\n    }\n\n    if (useFog) {\n      this.uploadFog(uniforms, fog);\n    }\n    this.uploadMaterial(uniforms, material);\n\n    if (useLight) {\n      const counter: Record<string, number> = {};\n\n      lights.forEach((light) => {\n        if (!counter[light.define]) {\n          counter[light.define] = -1;\n        }\n\n        counter[light.define]++;\n\n        light.uploadUBO(uniforms, counter[light.define]);\n      });\n    }\n\n    uniforms.sort(\n      (a, b) =>\n        this.material.uniformNames.indexOf(a.name) -\n        this.material.uniformNames.indexOf(b.name),\n    );\n\n    // TODO: should not upload all uniforms if no change\n    renderInst.setUniforms(numUniformBuffers, uniforms);\n\n    const {\n      depthCompare,\n      depthWrite,\n      stencilFront,\n      stencilBack,\n      stencilWrite,\n      stencilRef,\n      cullMode,\n      frontFace,\n      polygonOffset,\n      blendConstant,\n      blendEquation,\n      blendEquationAlpha,\n      blendSrc,\n      blendDst,\n      blendSrcAlpha,\n      blendDstAlpha,\n    } = material;\n\n    const materialMegaState = definedProps({\n      blendConstant,\n      depthCompare,\n      depthWrite,\n      stencilFront,\n      stencilBack,\n      stencilWrite,\n      stencilRef,\n      cullMode,\n      frontFace,\n      polygonOffset,\n    });\n\n    const currentAttachmentsState =\n      renderInst.getMegaStateFlags().attachmentsState[0];\n\n    renderInst.setMegaStateFlags({\n      attachmentsState: [\n        {\n          // should not affect color buffer when drawing stencil\n          channelWriteMask: this.material.stencilWrite\n            ? ChannelWriteMask.NONE\n            : ChannelWriteMask.ALL,\n          // channelWriteMask: ChannelWriteMask.AllChannels,\n          rgbBlendState: {\n            ...currentAttachmentsState.rgbBlendState,\n            ...definedProps({\n              blendMode: blendEquation,\n              blendSrcFactor: blendSrc,\n              blendDstFactor: blendDst,\n            }),\n          },\n          alphaBlendState: {\n            ...currentAttachmentsState.alphaBlendState,\n            ...definedProps({\n              blendMode: blendEquationAlpha,\n              blendSrcFactor: blendSrcAlpha,\n              blendDstFactor: blendDstAlpha,\n            }),\n          },\n        },\n      ],\n      ...materialMegaState,\n    });\n\n    renderInst.setBindingLayout({\n      numUniformBuffers,\n      numSamplers: this.textureMappings.length,\n    });\n\n    renderInst.setSamplerBindingsFromTextureMappings(this.textureMappings);\n  }\n\n  private uploadFog(uniforms: RenderInstUniform[], fog: Fog) {\n    const { type, fill, start, end, density } = fog.parsedStyle;\n\n    if (isCSSRGB(fill)) {\n      const fillColor = [\n        Number(fill.r) / 255,\n        Number(fill.g) / 255,\n        Number(fill.b) / 255,\n        Number(fill.alpha),\n      ];\n      uniforms.push({\n        name: 'u_FogInfos',\n        value: [type, start, end, density],\n      });\n      uniforms.push({\n        name: 'u_FogColor',\n        value: fillColor,\n      });\n    }\n  }\n\n  private uploadMaterial(uniforms: RenderInstUniform[], material: Material) {\n    // sort\n    const materialUniforms = Object.keys(material.uniforms).map((name) => ({\n      name,\n      value: material.uniforms[name],\n    }));\n    uniforms.push(...materialUniforms);\n  }\n\n  protected createFillGradientTextureMapping(\n    objects: DisplayObject[],\n  ): TextureMapping | null {\n    const instance = objects[0];\n\n    // should account for Line, Path, Polyline and Polyline\n    const fill = instance.parsedStyle[this.gradientAttributeName];\n\n    let texImageSource: string | TexImageSource;\n\n    // use pattern & gradient\n    if (fill && (isPattern(fill) || Array.isArray(fill))) {\n      if (Array.isArray(fill)) {\n        this.program.setDefineBool('USE_PATTERN', false);\n        this.texturePool.getOrCreateGradient({\n          gradients: fill,\n          width: 128,\n          height: 128,\n          instance,\n        });\n      } else if (isPattern(fill)) {\n        this.program.setDefineBool('USE_PATTERN', true);\n        this.texturePool.getOrCreatePattern(fill, instance, () => {\n          // need re-render\n          objects.forEach((object) => {\n            object.renderable.dirty = true;\n          });\n          this.material.textureDirty = true;\n        });\n      }\n\n      texImageSource = this.texturePool.getOrCreateCanvas() as TexImageSource;\n      const texture = this.texturePool.getOrCreateTexture(\n        this.context.device,\n        texImageSource,\n        makeTextureDescriptor2D(Format.U8_RGBA_NORM, 1, 1, 1),\n      );\n\n      if (texture) {\n        const fillMapping = new TextureMapping();\n        fillMapping.name = FILL_TEXTURE_MAPPING;\n        fillMapping.texture = texture;\n        fillMapping.texture.on('loaded', () => {\n          // need re-render\n          objects.forEach((object) => {\n            object.renderable.dirty = true;\n          });\n          this.material.textureDirty = true;\n        });\n        this.context.device.setResourceName(\n          fillMapping.texture,\n          `Fill Texture${this.id}`,\n        );\n        fillMapping.sampler = this.renderHelper.getCache().createSampler({\n          addressModeU: AddressMode.CLAMP_TO_EDGE,\n          addressModeV: AddressMode.CLAMP_TO_EDGE,\n          minFilter: FilterMode.POINT,\n          magFilter: FilterMode.BILINEAR,\n          mipmapFilter: MipmapFilterMode.LINEAR,\n          lodMinClamp: 0,\n          lodMaxClamp: 0,\n        });\n\n        return fillMapping;\n      }\n    }\n\n    return null;\n  }\n}\n","import type {\n  Circle,\n  CSSRGB,\n  DisplayObject,\n  ParsedBaseStyleProps,\n  ParsedCircleStyleProps,\n  ParsedEllipseStyleProps,\n  ParsedRectStyleProps,\n} from '@antv/g-lite';\nimport { Shape } from '@antv/g-lite';\nimport { Format, VertexStepMode } from '@antv/g-device-api';\nimport frag from '../shader/sdf.frag';\nimport vert from '../shader/sdf.vert';\nimport { enumToObject } from '../utils/enum';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\n\nenum SDFVertexAttributeBufferIndex {\n  PACKED_STYLE = VertexAttributeBufferIndex.POSITION + 1,\n}\n\nenum SDFVertexAttributeLocation {\n  PACKED_STYLE3 = VertexAttributeLocation.MAX,\n  EXTRUDE,\n  SIZE,\n}\n\nconst SDF_Shape: string[] = [Shape.CIRCLE, Shape.ELLIPSE, Shape.RECT];\n\n/**\n * Use SDF to render 2D shapes, eg. circle, ellipse.\n * Use less triangles(2) and vertices compared with normal triangulation.\n */\nexport class SDFDrawcall extends Instanced {\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n\n    if (!shouldMerge) {\n      return false;\n    }\n\n    // if (\n    //   this.needDrawStrokeSeparately(object.parsedStyle) ||\n    //   this.needDrawStrokeSeparately(this.instance.parsedStyle)\n    // ) {\n    //   return false;\n    // }\n\n    // const { fill: instanceFill } = this.instance\n    //   .parsedStyle as ParsedBaseStyleProps;\n    // const { fill } = object.parsedStyle as ParsedBaseStyleProps;\n    // if ((instanceFill as CSSRGB).isNone !== (fill as CSSRGB).isNone) {\n    //   return false;\n    // }\n\n    return true;\n  }\n\n  createMaterial(objects: DisplayObject[]) {\n    this.material.vertexShader = vert;\n    this.material.fragmentShader = frag;\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(SDFVertexAttributeLocation),\n    };\n  }\n\n  createGeometry(objects: DisplayObject[]) {\n    // use default common attributes\n    super.createGeometry(objects);\n\n    const instanced = [];\n    const positions = [];\n    objects.forEach((object, i) => {\n      const circle = object as Circle;\n      // @ts-ignore\n      const { radius } = circle.parsedStyle;\n      const omitStroke = this.shouldOmitStroke(circle.parsedStyle);\n      const size = this.getSize(object.parsedStyle, circle.nodeName);\n      const position = this.getPosition(object.parsedStyle, circle.nodeName);\n      instanced.push(\n        ...size,\n        circle.parsedStyle.isBillboard ? 1 : 0,\n        circle.parsedStyle.isSizeAttenuation ? 1 : 0,\n        SDF_Shape.indexOf(circle.nodeName),\n        (radius && radius[0]) || 0,\n        omitStroke ? 1 : 0,\n      );\n      positions.push(...position);\n    });\n\n    this.geometry.setIndexBuffer(new Uint32Array([0, 2, 1, 0, 3, 2]));\n    this.geometry.vertexCount = 6;\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.UV,\n      byteStride: 4 * 4,\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 0,\n          location: SDFVertexAttributeLocation.EXTRUDE,\n        },\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 2,\n          location: VertexAttributeLocation.UV,\n        },\n      ],\n      data: new Float32Array([\n        -1, -1, 0, 0, 1, -1, 1, 0, 1, 1, 1, 1, -1, 1, 0, 1,\n      ]),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.POSITION,\n      byteStride: 4 * 3,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.POSITION,\n        },\n      ],\n      data: new Float32Array(positions),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: SDFVertexAttributeBufferIndex.PACKED_STYLE,\n      byteStride: 4 * 7,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: SDFVertexAttributeLocation.SIZE,\n          divisor: 1,\n        },\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 4,\n          location: SDFVertexAttributeLocation.PACKED_STYLE3,\n          divisor: 1,\n        },\n      ],\n      data: new Float32Array(instanced),\n    });\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ) {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n\n    if (\n      name === 'r' ||\n      name === 'rx' ||\n      name === 'ry' ||\n      name === 'width' ||\n      name === 'height' ||\n      name === 'lineWidth' ||\n      name === 'stroke' ||\n      name === 'lineDash' ||\n      name === 'strokeOpacity' ||\n      name === 'radius' ||\n      name === 'isBillboard' ||\n      name === 'isSizeAttenuation'\n    ) {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const circle = object as Circle;\n        const omitStroke = this.shouldOmitStroke(circle.parsedStyle);\n\n        const [halfWidth, halfHeight] = this.getSize(\n          object.parsedStyle,\n          object.nodeName,\n        );\n        const size = [halfWidth, halfHeight];\n        packed.push(\n          ...size,\n          circle.parsedStyle.isBillboard ? 1 : 0,\n          circle.parsedStyle.isSizeAttenuation ? 1 : 0,\n          SDF_Shape.indexOf(object.nodeName),\n          (object.parsedStyle.radius && object.parsedStyle.radius[0]) || 0,\n          omitStroke ? 1 : 0,\n        );\n      });\n      this.geometry.updateVertexBuffer(\n        SDFVertexAttributeBufferIndex.PACKED_STYLE,\n        SDFVertexAttributeLocation.SIZE,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (name === 'cx' || name === 'cy' || name === 'x' || name === 'y') {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const [x, y] = this.getPosition(object.parsedStyle, object.nodeName);\n        packed.push(x, y);\n      });\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.POSITION,\n        VertexAttributeLocation.POSITION,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    }\n  }\n\n  private getPosition(\n    parsed:\n      | ParsedCircleStyleProps\n      | ParsedEllipseStyleProps\n      | ParsedRectStyleProps,\n    tagName: string,\n  ) {\n    let size: [number, number, number] = [0, 0, 0];\n    if (tagName === Shape.CIRCLE || tagName === Shape.ELLIPSE) {\n      const { cx = 0, cy = 0, cz = 0 } = parsed as ParsedCircleStyleProps;\n      size = [cx, cy, cz];\n    } else if (tagName === Shape.RECT) {\n      const { x = 0, y = 0, z = 0 } = parsed as ParsedRectStyleProps;\n      size = [x, y, z];\n    }\n    return size;\n  }\n\n  private getSize(\n    parsed:\n      | ParsedCircleStyleProps\n      | ParsedEllipseStyleProps\n      | ParsedRectStyleProps,\n    tagName: string,\n  ) {\n    let size: [number, number] = [0, 0];\n    if (tagName === Shape.CIRCLE) {\n      const { r } = parsed as ParsedCircleStyleProps;\n      size = [r, r];\n    } else if (tagName === Shape.ELLIPSE) {\n      const { rx, ry } = parsed as ParsedEllipseStyleProps;\n      size = [rx, ry];\n    } else if (tagName === Shape.RECT) {\n      const { width, height } = parsed as ParsedRectStyleProps;\n      size = [width / 2, height / 2];\n    }\n\n    return size;\n  }\n\n  private shouldOmitStroke(parsedStyle: ParsedBaseStyleProps) {\n    const { lineDash, stroke, strokeOpacity } = parsedStyle;\n    const hasStroke = stroke && !(stroke as CSSRGB).isNone;\n    const hasLineDash =\n      lineDash &&\n      lineDash.length &&\n      lineDash.every((item: number) => item !== 0);\n    const hasStrokeOpacity = strokeOpacity < 1;\n    return !hasStroke || (hasStroke && (hasLineDash || hasStrokeOpacity));\n  }\n}\n","import { cubicLength, quadLength } from '@antv/g-math';\nimport { clamp } from '@antv/util';\n\nconst SEGMENT_LENGTH = 10;\nconst MIN_SEGMENT_NUM = 8;\nconst MAX_SEGMENT_NUM = 100;\n\nexport function quadCurveTo(\n  cpX: number,\n  cpY: number,\n  toX: number,\n  toY: number,\n  points: number[],\n  segmentNum?: number,\n) {\n  const fromX = points[points.length - 3];\n  const fromY = points[points.length - 2];\n\n  const n =\n    segmentNum ??\n    clamp(\n      quadLength(fromX, fromY, cpX, cpY, toX, toY) / SEGMENT_LENGTH,\n      MIN_SEGMENT_NUM,\n      MAX_SEGMENT_NUM,\n    );\n\n  let xa = 0;\n  let ya = 0;\n\n  for (let i = 1; i <= n; ++i) {\n    const j = i / n;\n\n    xa = fromX + (cpX - fromX) * j;\n    ya = fromY + (cpY - fromY) * j;\n\n    points.push(\n      xa + (cpX + (toX - cpX) * j - xa) * j,\n      ya + (cpY + (toY - cpY) * j - ya) * j,\n      0,\n    );\n  }\n}\n\nexport function bezierCurveTo(\n  cpX: number,\n  cpY: number,\n  cpX2: number,\n  cpY2: number,\n  toX: number,\n  toY: number,\n  points: number[],\n  segmentNum?: number,\n): void {\n  const fromX = points[points.length - 3];\n  const fromY = points[points.length - 2];\n\n  points.length -= 3;\n\n  const n =\n    segmentNum ??\n    clamp(\n      cubicLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) /\n        SEGMENT_LENGTH,\n      MIN_SEGMENT_NUM,\n      MAX_SEGMENT_NUM,\n    );\n\n  let dt = 0;\n  let dt2 = 0;\n  let dt3 = 0;\n  let t2 = 0;\n  let t3 = 0;\n\n  points.push(fromX, fromY, 0);\n\n  for (let i = 1, j = 0; i <= n; ++i) {\n    j = i / n;\n\n    dt = 1 - j;\n    dt2 = dt * dt;\n    dt3 = dt2 * dt;\n\n    t2 = j * j;\n    t3 = t2 * j;\n\n    points.push(\n      dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX,\n      dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY,\n      0,\n    );\n  }\n}\n","/**\n * Borrow from https://github.com/mapbox/tiny-sdf\n */\n\nimport { CanvasLike, GlobalRuntime } from '@antv/g-lite';\n\nconst INF = 1e20;\n\ntype TinySDFOptions = {\n  canvas: CanvasLike;\n  fontSize?: number;\n  buffer?: number;\n  radius?: number;\n  cutoff?: number;\n  fontFamily?: string;\n  fontWeight?: string;\n  fontStyle?: string;\n};\n\nexport class TinySDF {\n  private buffer: number;\n  private radius: number;\n  private cutoff: number;\n  private size: number;\n  private f: Float64Array;\n  private z: Float64Array;\n  private v: Uint16Array;\n  private gridOuter: Float64Array;\n  private gridInner: Float64Array;\n  private ctx: CanvasRenderingContext2D;\n\n  constructor(options: TinySDFOptions, runtime: GlobalRuntime) {\n    const {\n      fontSize = 24,\n      buffer = 3,\n      radius = 8,\n      cutoff = 0.25,\n      fontFamily = 'sans-serif',\n      fontWeight = 'normal',\n      fontStyle = 'normal',\n      canvas,\n    } = options;\n    this.buffer = buffer;\n    this.cutoff = cutoff;\n    this.radius = radius;\n\n    // make the canvas size big enough to both have the specified buffer around the glyph\n    // for \"halo\", and account for some glyphs possibly being larger than their font size\n    const size = (this.size = fontSize + buffer * 4);\n\n    const $offscreenCanvas = runtime.offscreenCanvasCreator.getOrCreateCanvas(\n      canvas,\n    ) as HTMLCanvasElement;\n\n    // canvas.width = canvas.height = size;\n    // $offscreenCanvas.width = width * dpr;\n    // $offscreenCanvas.height = height * dpr;\n    $offscreenCanvas.width = size;\n    $offscreenCanvas.height = size;\n\n    const ctx = runtime.offscreenCanvasCreator.getOrCreateContext(canvas, {\n      willReadFrequently: true,\n    }) as CanvasRenderingContext2D;\n    this.ctx = ctx;\n\n    // const ctx = (this.ctx = canvas.getContext('2d', {\n    //   willReadFrequently: true,\n    // }));\n    ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;\n\n    ctx.textBaseline = 'alphabetic';\n    ctx.textAlign = 'left'; // Necessary so that RTL text doesn't have different alignment\n    ctx.fillStyle = 'black';\n\n    // temporary arrays for the distance transform\n    this.gridOuter = new Float64Array(size * size);\n    this.gridInner = new Float64Array(size * size);\n    this.f = new Float64Array(size);\n    this.z = new Float64Array(size + 1);\n    this.v = new Uint16Array(size);\n  }\n\n  // _createCanvas(size) {\n  //   const canvas = document.createElement('canvas');\n  //   canvas.width = canvas.height = size;\n  //   return canvas;\n  // }\n\n  draw(char: string) {\n    const {\n      width: glyphAdvance,\n      actualBoundingBoxAscent,\n      actualBoundingBoxDescent,\n      actualBoundingBoxLeft,\n      actualBoundingBoxRight,\n    } = this.ctx.measureText(char);\n\n    // The integer/pixel part of the top alignment is encoded in metrics.glyphTop\n    // The remainder is implicitly encoded in the rasterization\n    const glyphTop = Math.ceil(actualBoundingBoxAscent);\n    const glyphLeft = 0;\n\n    // If the glyph overflows the canvas size, it will be clipped at the bottom/right\n    const glyphWidth = Math.max(\n      0,\n      Math.min(\n        this.size - this.buffer,\n        Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft),\n      ),\n    );\n    const glyphHeight = Math.min(\n      this.size - this.buffer,\n      glyphTop + Math.ceil(actualBoundingBoxDescent),\n    );\n\n    const width = glyphWidth + 2 * this.buffer;\n    const height = glyphHeight + 2 * this.buffer;\n\n    const len = Math.max(width * height, 0);\n    const data = new Uint8ClampedArray(len);\n    const glyph = {\n      data,\n      width,\n      height,\n      glyphWidth,\n      glyphHeight,\n      glyphTop,\n      glyphLeft,\n      glyphAdvance,\n    };\n    if (glyphWidth === 0 || glyphHeight === 0) return glyph;\n\n    const { ctx, buffer, gridInner, gridOuter } = this;\n    ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight);\n    ctx.fillText(char, buffer, buffer + glyphTop);\n    const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight);\n\n    // Initialize grids outside the glyph range to alpha 0\n    gridOuter.fill(INF, 0, len);\n    gridInner.fill(0, 0, len);\n\n    for (let y = 0; y < glyphHeight; y++) {\n      for (let x = 0; x < glyphWidth; x++) {\n        const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 255; // alpha value\n        if (a === 0) continue; // empty pixels\n\n        const j = (y + buffer) * width + x + buffer;\n\n        if (a === 1) {\n          // fully drawn pixels\n          gridOuter[j] = 0;\n          gridInner[j] = INF;\n        } else {\n          // aliased pixels\n          const d = 0.5 - a;\n          gridOuter[j] = d > 0 ? d * d : 0;\n          gridInner[j] = d < 0 ? d * d : 0;\n        }\n      }\n    }\n\n    edt(gridOuter, 0, 0, width, height, width, this.f, this.v, this.z);\n    edt(\n      gridInner,\n      buffer,\n      buffer,\n      glyphWidth,\n      glyphHeight,\n      width,\n      this.f,\n      this.v,\n      this.z,\n    );\n\n    for (let i = 0; i < len; i++) {\n      const d = Math.sqrt(gridOuter[i]) - Math.sqrt(gridInner[i]);\n      data[i] = Math.round(255 - 255 * (d / this.radius + this.cutoff));\n    }\n\n    return glyph;\n  }\n}\n\n// 2D Euclidean squared distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nfunction edt(\n  data: Float64Array,\n  x0: number,\n  y0: number,\n  width: number,\n  height: number,\n  gridSize: number,\n  f: Float64Array,\n  v: Uint16Array,\n  z: Float64Array,\n) {\n  for (let x = x0; x < x0 + width; x++)\n    edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z);\n  for (let y = y0; y < y0 + height; y++)\n    edt1d(data, y * gridSize + x0, 1, width, f, v, z);\n}\n\n// 1D squared distance transform\nfunction edt1d(\n  grid: Float64Array,\n  offset: number,\n  stride: number,\n  length: number,\n  f: Float64Array,\n  v: Uint16Array,\n  z: Float64Array,\n) {\n  v[0] = 0;\n  z[0] = -INF;\n  z[1] = INF;\n  f[0] = grid[offset];\n\n  for (let q = 1, k = 0, s = 0; q < length; q++) {\n    f[q] = grid[offset + q * stride];\n    const q2 = q * q;\n    do {\n      const r = v[k];\n      s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2;\n    } while (s <= z[k] && --k > -1);\n\n    k++;\n    v[k] = q;\n    z[k] = s;\n    z[k + 1] = INF;\n  }\n\n  for (let q = 0, k = 0; q < length; q++) {\n    while (z[k + 1] < q) k++;\n    const r = v[k];\n    const qr = q - r;\n    grid[offset + q * stride] = f[r] + qr * qr;\n  }\n}\n","/**\n * Instanced line which has a  better performance.\n * @see https://www.yuque.com/antv/ou292n/gg1gh5\n */\nimport {\n  DisplayObject,\n  ParsedPathStyleProps,\n  Path,\n  Shape,\n  ParsedLineStyleProps,\n  Polyline,\n  isDisplayObject,\n  parsePath,\n  convertToPath,\n} from '@antv/g-lite';\nimport { mat4 } from 'gl-matrix';\nimport { arcToCubic, isNil } from '@antv/util';\nimport earcut from 'earcut';\nimport { Format, VertexStepMode } from '@antv/g-device-api';\nimport frag from '../shader/line.frag';\nimport vert from '../shader/line.vert';\nimport { enumToObject } from '../utils/enum';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\nimport { RenderHelper } from '../render';\nimport { TexturePool } from '../TexturePool';\nimport { LightPool } from '../LightPool';\nimport { bezierCurveTo, quadCurveTo } from '../utils';\nimport { InstancedFillDrawcall } from './InstancedFill';\nimport { BatchContext } from '../renderer';\nimport { RENDER_ORDER_SCALE } from '../renderer/Batch';\n\nenum LineVertexAttributeBufferIndex {\n  PACKED = VertexAttributeBufferIndex.POSITION + 1,\n  VERTEX_NUM,\n  TRAVEL,\n  DASH,\n}\n\nenum LineVertexAttributeLocation {\n  PREV = VertexAttributeLocation.POSITION,\n  POINT1,\n  POINT2,\n  NEXT,\n  VERTEX_JOINT,\n  VERTEX_NUM,\n  TRAVEL,\n  DASH,\n}\n\nconst SEGMENT_NUM = 12;\n\nfunction packBoolean(a: boolean, b: boolean, c: boolean) {\n  return (a ? 1 : 0) * 4 + (b ? 1 : 0) * 2 + (c ? 1 : 0);\n}\n\nfunction is3DPolyline(object: DisplayObject) {\n  const isPolyline = object.nodeName === Shape.POLYLINE;\n  if (!isPolyline) {\n    return false;\n  }\n  // Polyline supports 3 dimensions so that each point is shaped like [x, y, z].\n  const polylineControlPoints = (object as Polyline).parsedStyle.points.points;\n  const { length } = polylineControlPoints;\n\n  return length && !isNil(polylineControlPoints[0][2]);\n}\n\n/**\n * Used for Curve only contains 2 commands, e.g. [[M], [C | Q | A]]\n */\nexport class InstancedPathDrawcall extends Instanced {\n  static calcSubpathNum(object: DisplayObject) {\n    if (object.nodeName === Shape.PATH) {\n      const {\n        d: { absolutePath },\n      } = object.parsedStyle as ParsedPathStyleProps;\n      return absolutePath.filter((d) => d[0] === 'M').length;\n    }\n\n    return 1;\n  }\n\n  constructor(\n    protected renderHelper: RenderHelper,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n    object: DisplayObject,\n    drawcallCtors: (new (..._: any) => Instanced)[],\n    index: number,\n    context: BatchContext,\n  ) {\n    super(\n      renderHelper,\n      texturePool,\n      lightPool,\n      object,\n      drawcallCtors,\n      index,\n      context,\n    );\n    this.segmentNum = this.calcSegmentNum(object);\n    this.gradientAttributeName = 'stroke';\n  }\n\n  // protected mergeAnchorIntoModelMatrix = true;\n\n  private segmentNum = -1;\n\n  private calcSegmentNum(object: DisplayObject) {\n    // FIXME: only need to collect instanced count\n    const { instancedCount } = updateBuffer(\n      object,\n      false,\n      SEGMENT_NUM,\n      this.calcSubpathIndex(object),\n    );\n    return instancedCount;\n  }\n\n  private calcSubpathIndex(object: DisplayObject) {\n    if (object.nodeName === Shape.PATH) {\n      const fillDrawcallCount = this.drawcallCtors.filter(\n        (ctor) => ctor === InstancedFillDrawcall,\n      ).length;\n      return this.index - fillDrawcallCount;\n    }\n    return 0;\n  }\n\n  /**\n   * Paths with the same number of vertices should be merged.\n   */\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n    if (!shouldMerge) {\n      return false;\n    }\n\n    if (this.index !== index) {\n      return false;\n    }\n\n    const segmentNum = this.calcSegmentNum(object);\n\n    return this.segmentNum === segmentNum;\n  }\n\n  createMaterial(objects: DisplayObject[]): void {\n    this.material.vertexShader = vert;\n    this.material.fragmentShader = frag;\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(LineVertexAttributeLocation),\n    };\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    const indices: number[] = [];\n    const pointsBuffer: number[] = [];\n    const travelBuffer: number[] = [];\n    const packedDash: number[] = [];\n    let instancedCount = 0;\n    let offset = 0;\n    objects.forEach((object) => {\n      const {\n        pointsBuffer: pBuffer,\n        travelBuffer: tBuffer,\n        instancedCount: count,\n      } = updateBuffer(\n        object,\n        false,\n        SEGMENT_NUM,\n        this.calcSubpathIndex(object),\n      );\n\n      const { lineDash, lineDashOffset, isBillboard, isSizeAttenuation } = (\n        object as Path\n      ).parsedStyle;\n\n      packedDash.push(\n        (lineDash && lineDash[0]) || 0, // DASH\n        (lineDash && lineDash[1]) || 0, // GAP\n        lineDashOffset || 0,\n        packBoolean(isBillboard, isSizeAttenuation, is3DPolyline(object)),\n      );\n\n      instancedCount += count;\n\n      // Can't use interleaved buffer here, we should spread them like:\n      // | prev - pointA - pointB - next |. This will allocate ~4x buffer memory space.\n      for (let i = 0; i < pBuffer.length - 3 * 4; i += 4) {\n        pointsBuffer.push(\n          pBuffer[i],\n          pBuffer[i + 1],\n          pBuffer[i + 2],\n          pBuffer[i + 3],\n          pBuffer[i + 4],\n          pBuffer[i + 5],\n          pBuffer[i + 6],\n          pBuffer[i + 7],\n          pBuffer[i + 8],\n          pBuffer[i + 9],\n          pBuffer[i + 10],\n          pBuffer[i + 11],\n          pBuffer[i + 12],\n          pBuffer[i + 13],\n          pBuffer[i + 14],\n          pBuffer[i + 15],\n        );\n      }\n\n      travelBuffer.push(...tBuffer);\n\n      indices.push(\n        0 + offset,\n        2 + offset,\n        1 + offset,\n        0 + offset,\n        3 + offset,\n        2 + offset,\n        4 + offset,\n        6 + offset,\n        5 + offset,\n        4 + offset,\n        7 + offset,\n        6 + offset,\n        4 + offset,\n        7 + offset,\n        8 + offset,\n      );\n      offset += 9;\n    });\n\n    if (pointsBuffer.length) {\n      this.geometry.setVertexBuffer({\n        bufferIndex: LineVertexAttributeBufferIndex.PACKED,\n        byteStride: 4 * (4 + 4 + 4 + 4),\n        stepMode: VertexStepMode.INSTANCE,\n        attributes: [\n          {\n            format: Format.F32_RGB,\n            bufferByteOffset: 4 * 0,\n            location: LineVertexAttributeLocation.PREV,\n            divisor: 1,\n          },\n          {\n            format: Format.F32_RGB,\n            bufferByteOffset: 4 * 4,\n            location: LineVertexAttributeLocation.POINT1,\n            divisor: 1,\n          },\n          {\n            format: Format.F32_R,\n            bufferByteOffset: 4 * 7,\n            location: LineVertexAttributeLocation.VERTEX_JOINT,\n            divisor: 1,\n          },\n          {\n            format: Format.F32_RGB,\n            bufferByteOffset: 4 * 8,\n            location: LineVertexAttributeLocation.POINT2,\n            divisor: 1,\n          },\n          {\n            format: Format.F32_RGB,\n            bufferByteOffset: 4 * 12,\n            location: LineVertexAttributeLocation.NEXT,\n            divisor: 1,\n          },\n        ],\n        data: new Float32Array(pointsBuffer),\n      });\n      this.geometry.setVertexBuffer({\n        bufferIndex: LineVertexAttributeBufferIndex.VERTEX_NUM,\n        byteStride: 4 * 1,\n        stepMode: VertexStepMode.INSTANCE,\n        attributes: [\n          {\n            format: Format.F32_R,\n            bufferByteOffset: 4 * 0,\n            byteStride: 4 * 1,\n            location: LineVertexAttributeLocation.VERTEX_NUM,\n            divisor: 0,\n          },\n        ],\n        data: new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\n      });\n      this.geometry.setVertexBuffer({\n        bufferIndex: LineVertexAttributeBufferIndex.TRAVEL,\n        byteStride: 4 * 1,\n        stepMode: VertexStepMode.INSTANCE,\n        attributes: [\n          {\n            format: Format.F32_R,\n            bufferByteOffset: 4 * 0,\n            byteStride: 4 * 1,\n            location: LineVertexAttributeLocation.TRAVEL,\n            divisor: 1,\n          },\n        ],\n        data: new Float32Array(travelBuffer),\n      });\n\n      // this attribute only changes for each n instance\n      this.divisor = instancedCount / objects.length;\n      this.geometry.setVertexBuffer({\n        bufferIndex: LineVertexAttributeBufferIndex.DASH,\n        byteStride: 4 * 4,\n        stepMode: VertexStepMode.INSTANCE,\n        attributes: [\n          {\n            format: Format.F32_RGBA,\n            bufferByteOffset: 4 * 0,\n            location: LineVertexAttributeLocation.DASH,\n            divisor: this.divisor,\n          },\n        ],\n        data: new Float32Array(packedDash),\n      });\n\n      // use default common attributes\n      super.createGeometry(objects);\n\n      this.geometry.vertexCount = 15;\n      this.geometry.instancedCount = instancedCount;\n      this.geometry.setIndexBuffer(new Uint32Array(indices));\n    }\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ) {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n\n    if (\n      name === 'r' ||\n      name === 'rx' ||\n      name === 'ry' ||\n      name === 'width' ||\n      name === 'height' ||\n      name === 'radius' ||\n      name === 'x1' ||\n      name === 'y1' ||\n      name === 'x2' ||\n      name === 'y2' ||\n      name === 'points' ||\n      name === 'path' ||\n      name === 'd' ||\n      name === 'lineJoin' ||\n      name === 'lineCap' ||\n      name === 'markerStartOffset' ||\n      name === 'markerEndOffset' ||\n      name === 'markerStart' ||\n      name === 'markerEnd'\n    ) {\n      const pointsBuffer: number[] = [];\n      const travelBuffer: number[] = [];\n      let instancedCount = 0;\n      objects.forEach((object) => {\n        const {\n          pointsBuffer: pBuffer,\n          travelBuffer: tBuffer,\n          instancedCount: iCount,\n        } = updateBuffer(\n          object,\n          false,\n          SEGMENT_NUM,\n          this.calcSubpathIndex(object),\n        );\n        instancedCount = iCount;\n\n        // Can't use interleaved buffer here, we should spread them like:\n        // | prev - pointA - pointB - next |. This will allocate ~4x buffer memory space.\n        for (let i = 0; i < pBuffer.length - 3 * 4; i += 4) {\n          pointsBuffer.push(\n            pBuffer[i],\n            pBuffer[i + 1],\n            pBuffer[i + 2],\n            pBuffer[i + 3],\n            pBuffer[i + 4],\n            pBuffer[i + 5],\n            pBuffer[i + 6],\n            pBuffer[i + 7],\n            pBuffer[i + 8],\n            pBuffer[i + 9],\n            pBuffer[i + 10],\n            pBuffer[i + 11],\n            pBuffer[i + 12],\n            pBuffer[i + 13],\n            pBuffer[i + 14],\n            pBuffer[i + 15],\n          );\n        }\n\n        travelBuffer.push(...tBuffer);\n      });\n\n      this.geometry.updateVertexBuffer(\n        LineVertexAttributeBufferIndex.PACKED,\n        LineVertexAttributeLocation.PREV,\n        startIndex * instancedCount,\n        new Uint8Array(new Float32Array(pointsBuffer).buffer),\n      );\n      this.geometry.updateVertexBuffer(\n        LineVertexAttributeBufferIndex.TRAVEL,\n        LineVertexAttributeLocation.TRAVEL,\n        startIndex,\n        new Uint8Array(new Float32Array(travelBuffer).buffer),\n      );\n    } else if (\n      name === 'lineDashOffset' ||\n      name === 'lineDash' ||\n      name === 'isBillboard' ||\n      name === 'isSizeAttenuation'\n    ) {\n      const packedDash: number[] = [];\n      objects.forEach((object) => {\n        const { lineDash, lineDashOffset, isBillboard, isSizeAttenuation } = (\n          object as Path\n        ).parsedStyle;\n\n        packedDash.push(\n          (lineDash && lineDash[0]) || 0, // DASH\n          (lineDash && lineDash[1]) || 0, // GAP\n          lineDashOffset || 0,\n          packBoolean(isBillboard, isSizeAttenuation, is3DPolyline(object)),\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        LineVertexAttributeBufferIndex.DASH,\n        LineVertexAttributeLocation.DASH,\n        startIndex,\n        new Uint8Array(new Float32Array(packedDash).buffer),\n      );\n    }\n  }\n}\n\nexport enum JOINT_TYPE {\n  NONE = 0,\n  FILL = 1,\n  JOINT_BEVEL = 4,\n  JOINT_MITER = 8,\n  JOINT_ROUND = 12,\n  JOINT_CAP_BUTT = 16,\n  JOINT_CAP_SQUARE = 18,\n  JOINT_CAP_ROUND = 20,\n  FILL_EXPAND = 24,\n  CAP_BUTT = 1 << 5,\n  CAP_SQUARE = 2 << 5,\n  CAP_ROUND = 3 << 5,\n  CAP_BUTT2 = 4 << 5,\n}\n\nconst stridePoints = 3;\nconst strideFloats = 4;\n\nexport function updateBuffer(\n  object: DisplayObject,\n  needEarcut = false,\n  segmentNum?: number,\n  subPathIndex = 0,\n) {\n  const { lineCap, lineJoin } = object.parsedStyle;\n  const zIndex = object.sortable.renderOrder * RENDER_ORDER_SCALE;\n  let defX = 0;\n  let defY = 0;\n  const { markerStart, markerEnd, markerStartOffset, markerEndOffset } =\n    object.parsedStyle as ParsedLineStyleProps;\n\n  const points: number[][] = [];\n  let triangles: number[] = [];\n\n  if (object.nodeName === Shape.POLYLINE || object.nodeName === Shape.POLYGON) {\n    const polylineControlPoints = (object as Polyline).parsedStyle.points\n      .points;\n    const { length } = polylineControlPoints;\n    let startOffsetX = 0;\n    let startOffsetY = 0;\n    let endOffsetX = 0;\n    let endOffsetY = 0;\n\n    let rad = 0;\n    let x: number;\n    let y: number;\n\n    if (markerStart && isDisplayObject(markerStart) && markerStartOffset) {\n      x = polylineControlPoints[1][0] - polylineControlPoints[0][0];\n      y = polylineControlPoints[1][1] - polylineControlPoints[0][1];\n      rad = Math.atan2(y, x);\n      startOffsetX = Math.cos(rad) * (markerStartOffset || 0);\n      startOffsetY = Math.sin(rad) * (markerStartOffset || 0);\n    }\n\n    if (markerEnd && isDisplayObject(markerEnd) && markerEndOffset) {\n      x =\n        polylineControlPoints[length - 2][0] -\n        polylineControlPoints[length - 1][0];\n      y =\n        polylineControlPoints[length - 2][1] -\n        polylineControlPoints[length - 1][1];\n      rad = Math.atan2(y, x);\n      endOffsetX = Math.cos(rad) * (markerEndOffset || 0);\n      endOffsetY = Math.sin(rad) * (markerEndOffset || 0);\n    }\n\n    const isPolyline = object.nodeName === Shape.POLYLINE;\n    points[0] = polylineControlPoints.reduce((prev, cur, i) => {\n      let offsetX = 0;\n      let offsetY = 0;\n      if (i === 0) {\n        offsetX = startOffsetX;\n        offsetY = startOffsetY;\n      } else if (i === length - 1) {\n        offsetX = endOffsetX;\n        offsetY = endOffsetY;\n      }\n\n      prev.push(\n        cur[0] + offsetX,\n        cur[1] + offsetY,\n        isPolyline ? cur[2] || 0 : zIndex,\n      );\n      return prev;\n    }, [] as number[]);\n\n    // close polygon, dealing with extra joint\n    if (object.nodeName === Shape.POLYGON) {\n      if (needEarcut) {\n        // use earcut for triangulation\n        triangles = earcut(points[0], [], 3);\n        return {\n          pointsBuffer: points[0],\n          travelBuffer: [],\n          triangles,\n          instancedCount: Math.round(points[0].length / stridePoints),\n        };\n      }\n      points[0].push(points[0][0], points[0][1], points[0][2] || zIndex);\n      points[0].push(\n        ...addTailSegment(\n          points[0][0],\n          points[0][1],\n          points[0][2] || zIndex,\n          points[0][3],\n          points[0][4],\n          points[0][5] || zIndex,\n        ),\n      );\n    }\n  } else if (\n    object.nodeName === Shape.PATH ||\n    object.nodeName === Shape.CIRCLE ||\n    object.nodeName === Shape.ELLIPSE ||\n    object.nodeName === Shape.RECT\n  ) {\n    let path: ParsedPathStyleProps['d'];\n    if (object.nodeName !== Shape.PATH) {\n      path = parsePath(convertToPath(object, mat4.identity(mat4.create())));\n\n      // support negative width/height of Rect\n      if (object.nodeName === Shape.RECT) {\n        const { width, height } = object.parsedStyle;\n        if (width < 0) {\n          defX += path.rect.width;\n        }\n        if (height < 0) {\n          defY += path.rect.height;\n        }\n      }\n    } else {\n      path = object.parsedStyle.d;\n    }\n    const { absolutePath, segments } = path;\n\n    let startOffsetX = 0;\n    let startOffsetY = 0;\n    let endOffsetX = 0;\n    let endOffsetY = 0;\n\n    let rad = 0;\n    let x: number;\n    let y: number;\n\n    if (\n      markerStart &&\n      markerStart.parentNode &&\n      isDisplayObject(markerStart) &&\n      markerStartOffset\n    ) {\n      const [p1, p2] = (markerStart.parentNode as Path).getStartTangent();\n      x = p1[0] - p2[0];\n      y = p1[1] - p2[1];\n\n      rad = Math.atan2(y, x);\n      startOffsetX = Math.cos(rad) * (markerStartOffset || 0);\n      startOffsetY = Math.sin(rad) * (markerStartOffset || 0);\n    }\n\n    if (\n      markerEnd &&\n      markerEnd.parentNode &&\n      isDisplayObject(markerEnd) &&\n      markerEndOffset\n    ) {\n      const [p1, p2] = (markerEnd.parentNode as Path).getEndTangent();\n      x = p1[0] - p2[0];\n      y = p1[1] - p2[1];\n      rad = Math.atan2(y, x);\n      endOffsetX = Math.cos(rad) * (markerEndOffset || 0);\n      endOffsetY = Math.sin(rad) * (markerEndOffset || 0);\n    }\n\n    let startPointIndex = -1;\n    let mCommandsNum = -1;\n    absolutePath.forEach(([command, ...params], i) => {\n      const nextSegment = absolutePath[i + 1];\n      const useStartOffset =\n        i === 0 && (startOffsetX !== 0 || startOffsetY !== 0);\n      const useEndOffset =\n        (i === absolutePath.length - 1 ||\n          (nextSegment &&\n            (nextSegment[0] === 'M' || nextSegment[0] === 'Z'))) &&\n        endOffsetX !== 0 &&\n        endOffsetY !== 0;\n\n      if (command === 'M') {\n        mCommandsNum++;\n        points[mCommandsNum] = [];\n        startPointIndex = points[mCommandsNum].length;\n\n        if (useStartOffset) {\n          points[mCommandsNum].push(\n            params[0] - defX + startOffsetX,\n            params[1] - defY + startOffsetY,\n            zIndex,\n            params[0] - defX,\n            params[1] - defY,\n            zIndex,\n          );\n        } else {\n          points[mCommandsNum].push(params[0] - defX, params[1] - defY, zIndex);\n        }\n      } else if (command === 'L') {\n        if (useEndOffset) {\n          points[mCommandsNum].push(\n            params[0] - defX + endOffsetX,\n            params[1] - defY + endOffsetY,\n            zIndex,\n          );\n        } else {\n          points[mCommandsNum].push(params[0] - defX, params[1] - defY, zIndex);\n        }\n      } else if (command === 'Q') {\n        quadCurveTo(\n          params[0] - defX,\n          params[1] - defY,\n          params[2] - defX,\n          params[3] - defY,\n          points[mCommandsNum],\n          segmentNum,\n        );\n        if (useEndOffset) {\n          points[mCommandsNum].push(\n            params[2] - defX + endOffsetX,\n            params[3] - defY + endOffsetY,\n            zIndex,\n          );\n        }\n      } else if (command === 'A') {\n        // convert Arc to Cubic\n\n        const [px1, py1] = segments[i].prePoint;\n        const args = arcToCubic(\n          px1,\n          py1,\n          params[0],\n          params[1],\n          params[2],\n          params[3],\n          params[4],\n          params[5],\n          params[6],\n          undefined,\n        );\n\n        // fixArc\n        for (let i = 0; i < args.length; i += 6) {\n          bezierCurveTo(\n            args[i] - defX,\n            args[i + 1] - defY,\n            args[i + 2] - defX,\n            args[i + 3] - defY,\n            args[i + 4] - defX,\n            args[i + 5] - defY,\n            points[mCommandsNum],\n            segmentNum,\n          );\n        }\n        if (useEndOffset) {\n          points[mCommandsNum].push(\n            params[5] - defX + endOffsetX,\n            params[6] - defY + endOffsetY,\n            zIndex,\n          );\n        }\n      } else if (command === 'C') {\n        bezierCurveTo(\n          params[0] - defX,\n          params[1] - defY,\n          params[2] - defX,\n          params[3] - defY,\n          params[4] - defX,\n          params[5] - defY,\n          points[mCommandsNum],\n          segmentNum,\n        );\n        if (useEndOffset) {\n          points[mCommandsNum].push(\n            params[4] - defX + endOffsetX,\n            params[5] - defY + endOffsetY,\n            zIndex,\n          );\n        }\n      } else if (\n        command === 'Z' &&\n        (object.nodeName === Shape.PATH || object.nodeName === Shape.RECT)\n      ) {\n        const epsilon = 0.0001;\n        // skip if already closed\n        if (\n          Math.abs(\n            points[mCommandsNum][points[mCommandsNum].length - 2] -\n              points[mCommandsNum][startPointIndex],\n          ) > epsilon ||\n          Math.abs(\n            points[mCommandsNum][points[mCommandsNum].length - 1] -\n              points[mCommandsNum][startPointIndex + 1],\n          ) > epsilon\n        ) {\n          points[mCommandsNum].push(\n            points[mCommandsNum][startPointIndex],\n            points[mCommandsNum][startPointIndex + 1],\n            zIndex,\n          );\n        }\n\n        points[mCommandsNum].push(\n          ...addTailSegment(\n            points[mCommandsNum][startPointIndex],\n            points[mCommandsNum][startPointIndex + 1],\n            points[mCommandsNum][startPointIndex + 2],\n            points[mCommandsNum][startPointIndex + 3],\n            points[mCommandsNum][startPointIndex + 4],\n            points[mCommandsNum][startPointIndex + 5],\n          ),\n        );\n      }\n    });\n\n    if (needEarcut) {\n      const pointsBuffer = points[subPathIndex];\n      // use earcut for triangulation\n      triangles = earcut(pointsBuffer, [], 3);\n      return {\n        pointsBuffer,\n        travelBuffer: [],\n        triangles,\n        instancedCount: Math.round(pointsBuffer.length / stridePoints),\n      };\n    }\n  }\n\n  const jointType = getJointType(lineJoin);\n  const capType = getCapType(lineCap);\n  let endJoint = capType;\n  if (capType === JOINT_TYPE.CAP_ROUND) {\n    endJoint = JOINT_TYPE.JOINT_CAP_ROUND;\n  }\n  if (capType === JOINT_TYPE.CAP_BUTT) {\n    endJoint = JOINT_TYPE.JOINT_CAP_BUTT;\n  }\n  if (capType === JOINT_TYPE.CAP_SQUARE) {\n    endJoint = JOINT_TYPE.JOINT_CAP_SQUARE;\n  }\n\n  const subPath = points[subPathIndex];\n  {\n    const points = subPath;\n    let j = (Math.round(0 / stridePoints) + 2) * strideFloats;\n    // const needDash = !isNil(lineDash);\n    let dist = 0;\n    const pointsBuffer: number[] = [];\n    const travelBuffer: number[] = [];\n    for (let i = 0; i < points.length; i += stridePoints) {\n      // calc travel\n      // if (needDash) {\n      if (i > 1) {\n        dist += Math.sqrt(\n          (points[i] - points[i - stridePoints]) ** 2 +\n            (points[i + 1] - points[i + 1 - stridePoints]) ** 2 +\n            (points[i + 2] - points[i + 2 - stridePoints]) ** 2,\n        );\n      }\n      travelBuffer.push(dist);\n      // } else {\n      //   travelBuffer.push(0);\n      // }\n\n      pointsBuffer[j++] = points[i];\n      pointsBuffer[j++] = points[i + 1];\n      pointsBuffer[j++] = points[i + 2] || 0;\n      pointsBuffer[j] = jointType;\n      if (i === 0 && capType !== JOINT_TYPE.CAP_ROUND) {\n        pointsBuffer[j] += capType;\n      }\n      if (i + stridePoints * 2 >= points.length) {\n        pointsBuffer[j] += endJoint - jointType;\n      } else if (i + stridePoints >= points.length) {\n        pointsBuffer[j] = 0;\n      }\n      j++;\n    }\n    pointsBuffer[j++] = points[points.length - 6];\n    pointsBuffer[j++] = points[points.length - 5];\n    pointsBuffer[j++] = points[points.length - 4] || zIndex;\n    pointsBuffer[j++] = 0;\n    pointsBuffer[0] = points[0];\n    pointsBuffer[1] = points[1];\n    pointsBuffer[2] = points[2] || zIndex;\n    pointsBuffer[3] = 0;\n    pointsBuffer[4] = points[3];\n    pointsBuffer[5] = points[4];\n    pointsBuffer[6] = points[5] || zIndex;\n    pointsBuffer[7] = capType === JOINT_TYPE.CAP_ROUND ? capType : 0;\n\n    const instancedCount = Math.round(points.length / stridePoints);\n\n    return {\n      pointsBuffer,\n      travelBuffer,\n      triangles,\n      instancedCount,\n    };\n  }\n}\n\nfunction getJointType(lineJoin: CanvasLineJoin) {\n  let joint: number;\n\n  switch (lineJoin) {\n    case 'bevel':\n      joint = JOINT_TYPE.JOINT_BEVEL;\n      break;\n    case 'round':\n      joint = JOINT_TYPE.JOINT_ROUND;\n      break;\n    default:\n      joint = JOINT_TYPE.JOINT_MITER;\n      break;\n  }\n\n  return joint;\n}\n\nfunction getCapType(lineCap: CanvasLineCap) {\n  let cap: number;\n\n  switch (lineCap) {\n    case 'square':\n      cap = JOINT_TYPE.CAP_SQUARE;\n      break;\n    case 'round':\n      cap = JOINT_TYPE.CAP_ROUND;\n      break;\n    default:\n      cap = JOINT_TYPE.CAP_BUTT;\n      break;\n  }\n\n  return cap;\n}\n\nfunction addTailSegment(\n  x1: number,\n  y1: number,\n  z1: number,\n  x2: number = x1,\n  y2: number = y1,\n  z2: number = z1,\n) {\n  const vec = [x2 - x1, y2 - y1, z2 - z1];\n  const length = 0.01;\n  return [x1 + vec[0] * length, y1 + vec[1] * length, z1 + vec[2] * length];\n}\n","import { DisplayObject, Shape } from '@antv/g-lite';\nimport { Format, VertexStepMode } from '@antv/g-device-api';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\nimport meshFrag from '../shader/mesh.frag';\nimport meshVert from '../shader/mesh.vert';\nimport { updateBuffer } from './InstancedPath';\nimport { RenderHelper } from '../render';\nimport { TexturePool } from '../TexturePool';\nimport { LightPool } from '../LightPool';\nimport { BatchContext } from '../renderer';\nimport { enumToObject } from '../utils';\n\nconst SEGMENT_NUM = 12;\n\nenum FillVertexAttributeBufferIndex {\n  PACKED_STYLE = VertexAttributeBufferIndex.POSITION + 1,\n}\n\nenum FillVertexAttributeLocation {\n  PACKED_STYLE3 = VertexAttributeLocation.MAX,\n}\n\nexport class InstancedFillDrawcall extends Instanced {\n  // protected mergeAnchorIntoModelMatrix = true;\n\n  constructor(\n    protected renderHelper: RenderHelper,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n    object: DisplayObject,\n    drawcallCtors: (new (..._: any) => Instanced)[],\n    index: number,\n    context: BatchContext,\n  ) {\n    super(\n      renderHelper,\n      texturePool,\n      lightPool,\n      object,\n      drawcallCtors,\n      index,\n      context,\n    );\n    this.trianglesHash = this.calcSegmentNum(object);\n  }\n\n  private trianglesHash: [number[], number[]] = [[], []];\n  private calcSegmentNum(object: DisplayObject): [number[], number[]] {\n    const { triangles, pointsBuffer } = updateBuffer(\n      object,\n      true,\n      SEGMENT_NUM,\n      this.calcSubpathIndex(object),\n    );\n    return [triangles, pointsBuffer];\n  }\n\n  private calcSubpathIndex(object: DisplayObject) {\n    if (object.nodeName === Shape.PATH) {\n      return this.index;\n    }\n    return 0;\n  }\n\n  private compareTrianglesHash(hash: [number[], number[]]) {\n    const [triangles, points] = this.trianglesHash;\n    const [t, p] = hash;\n    if (triangles.length !== t.length || points.length !== p.length) {\n      return false;\n    }\n\n    if (\n      triangles.some((n, i) => n !== t[i]) ||\n      points.some((n, i) => n !== p[i])\n    ) {\n      return false;\n    }\n\n    return true;\n  }\n\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n    if (!shouldMerge) {\n      return false;\n    }\n\n    if (this.index !== index) {\n      return false;\n    }\n\n    const trianglesHash = this.calcSegmentNum(object);\n    return this.compareTrianglesHash(trianglesHash);\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    const indices: number[] = [];\n    const pointsBuffer: number[] = [];\n    const uvsBuffer: number[] = [];\n    let offset = 0;\n    objects.forEach((object, i) => {\n      // use triangles for Polygon\n      const { triangles, pointsBuffer: pBuffer } = updateBuffer(\n        object,\n        true,\n        SEGMENT_NUM,\n        this.calcSubpathIndex(object),\n      );\n\n      if (triangles.length) {\n        const { halfExtents } = object.getGeometryBounds();\n        // pointsBuffer use 3D\n        const uvBuffer = [];\n        pBuffer.forEach((x, i) => {\n          if (i % 3 !== 2) {\n            uvBuffer.push(x / halfExtents[i % 3] / 2);\n          }\n        });\n\n        offset += pointsBuffer.length / 3;\n\n        pointsBuffer.push(...pBuffer);\n        uvsBuffer.push(...uvBuffer);\n        indices.push(...triangles.map((n) => n + offset));\n      }\n    });\n\n    if (pointsBuffer.length) {\n      // use default common attributes\n      super.createGeometry(objects);\n\n      const packedStyle: number[] = [];\n      objects.forEach((object) => {\n        const { isBillboard, billboardRotation, isSizeAttenuation } =\n          object.parsedStyle;\n        packedStyle.push(\n          isBillboard ? 1 : 0,\n          billboardRotation ?? 0,\n          isSizeAttenuation ? 1 : 0,\n          0,\n        );\n      });\n\n      this.geometry.setVertexBuffer({\n        bufferIndex: VertexAttributeBufferIndex.POSITION,\n        byteStride: 4 * 3,\n        stepMode: VertexStepMode.VERTEX,\n        attributes: [\n          {\n            format: Format.F32_RGB,\n            bufferByteOffset: 4 * 0,\n            location: VertexAttributeLocation.POSITION,\n          },\n        ],\n        data: new Float32Array(pointsBuffer),\n      });\n      this.geometry.setVertexBuffer({\n        bufferIndex: FillVertexAttributeBufferIndex.PACKED_STYLE,\n        byteStride: 4 * 4,\n        stepMode: VertexStepMode.INSTANCE,\n        attributes: [\n          {\n            format: Format.F32_RGBA,\n            bufferByteOffset: 4 * 0,\n            location: FillVertexAttributeLocation.PACKED_STYLE3,\n            divisor: 1,\n          },\n        ],\n        data: new Float32Array(packedStyle),\n      });\n      this.geometry.setVertexBuffer({\n        bufferIndex: VertexAttributeBufferIndex.UV,\n        byteStride: 4 * 2,\n        stepMode: VertexStepMode.VERTEX,\n        attributes: [\n          {\n            format: Format.F32_RG,\n            bufferByteOffset: 4 * 0,\n            location: VertexAttributeLocation.UV,\n          },\n        ],\n        data: new Float32Array(uvsBuffer),\n      });\n      this.geometry.vertexCount = indices.length / objects.length;\n      this.geometry.setIndexBuffer(new Uint32Array(indices));\n    }\n  }\n\n  createMaterial(objects: DisplayObject[]): void {\n    this.material.vertexShader = meshVert;\n    this.material.fragmentShader = meshFrag;\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(FillVertexAttributeLocation),\n      INSTANCED: true,\n    };\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ): void {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n\n    if (\n      name === 'isBillboard' ||\n      name === 'billboardRotation' ||\n      name === 'isSizeAttenuation'\n    ) {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const { isBillboard, billboardRotation, isSizeAttenuation } =\n          object.parsedStyle;\n        packed.push(\n          isBillboard ? 1 : 0,\n          billboardRotation ?? 0,\n          isSizeAttenuation ? 1 : 0,\n          0,\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        FillVertexAttributeBufferIndex.PACKED_STYLE,\n        FillVertexAttributeLocation.PACKED_STYLE3,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    }\n  }\n}\n","/**\n * Instanced line which has a  better performance.\n * @see https://www.yuque.com/antv/ou292n/gg1gh5\n */\nimport type {\n  Line,\n  ParsedLineStyleProps,\n  Path,\n  Polyline,\n  ParsedPathStyleProps,\n  ParsedPolylineStyleProps,\n} from '@antv/g-lite';\nimport { DisplayObject, Shape, isDisplayObject } from '@antv/g-lite';\nimport { Format, VertexStepMode } from '@antv/g-device-api';\nimport frag from '../shader/instanced-line.frag';\nimport vert from '../shader/instanced-line.vert';\nimport { enumToObject } from '../utils/enum';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\nimport { InstancedFillDrawcall } from './InstancedFill';\nimport { RenderHelper } from '../render';\nimport { TexturePool } from '../TexturePool';\nimport { LightPool } from '../LightPool';\nimport { BatchContext } from '../renderer';\n\nexport const segmentInstanceGeometry = [\n  0, -0.5, 0, 0, 0, 1, -0.5, 1, 1, 0, 1, 0.5, 1, 1, 1, 0, 0.5, 0, 0, 1,\n];\n\nenum InstancedLineVertexAttributeBufferIndex {\n  POINT = VertexAttributeBufferIndex.POSITION + 1,\n  CAP,\n  DASH,\n}\n\nenum InstancedLineVertexAttributeLocation {\n  POSITION = VertexAttributeLocation.POSITION,\n  UV = VertexAttributeLocation.UV,\n  POINTA = VertexAttributeLocation.NORMAL,\n  POINTB = VertexAttributeLocation.BARYCENTRIC,\n  CAP = VertexAttributeLocation.MAX,\n  DASH = VertexAttributeLocation.MAX + 1,\n}\n\nconst LineCap_MAP = {\n  butt: 1,\n  round: 2,\n  square: 3,\n};\n\nexport class InstancedLineDrawcall extends Instanced {\n  static isLine(object: DisplayObject, subpathIndex: number) {\n    if (object.nodeName === Shape.PATH) {\n      const {\n        d: { absolutePath },\n      } = object.parsedStyle as ParsedPathStyleProps;\n\n      let mSegmentCount = 0;\n      let mCommandIndex = 0;\n      for (let i = 0; i < absolutePath.length; i++) {\n        const segment = absolutePath[i];\n        if (segment[0] === 'M') {\n          if (mSegmentCount === subpathIndex) {\n            mCommandIndex = i;\n            break;\n          }\n          mSegmentCount++;\n        }\n      }\n\n      // only contains M & L commands\n      if (\n        absolutePath[mCommandIndex][0] === 'M' &&\n        absolutePath[mCommandIndex + 1][0] === 'L' &&\n        (absolutePath[mCommandIndex + 2] === undefined ||\n          absolutePath[mCommandIndex + 2][0] === 'M')\n      ) {\n        return true;\n      }\n    } else if (object.nodeName === Shape.POLYLINE) {\n      const {\n        points: { points },\n      } = object.parsedStyle as ParsedPolylineStyleProps;\n      const tangent =\n        (points[1][0] - points[1][1]) / (points[0][0] - points[0][1]);\n      for (let i = 1; i < points.length - 1; i++) {\n        if (\n          (points[i + 1][0] - points[i + 1][1]) /\n            (points[i][0] - points[i][1]) !==\n          tangent\n        ) {\n          return false;\n        }\n      }\n\n      return true;\n    }\n\n    return false;\n  }\n\n  constructor(\n    protected renderHelper: RenderHelper,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n    object: DisplayObject,\n    drawcallCtors: (new (..._: any) => Instanced)[],\n    index: number,\n    context: BatchContext,\n  ) {\n    super(\n      renderHelper,\n      texturePool,\n      lightPool,\n      object,\n      drawcallCtors,\n      index,\n      context,\n    );\n    this.gradientAttributeName = 'stroke';\n  }\n\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n    if (!shouldMerge) {\n      return false;\n    }\n\n    return true;\n  }\n\n  createMaterial(objects: DisplayObject[]): void {\n    this.material.vertexShader = vert;\n    this.material.fragmentShader = frag;\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(InstancedLineVertexAttributeLocation),\n    };\n  }\n\n  private calcSubpathIndex(object: DisplayObject) {\n    if (object.nodeName === Shape.PATH) {\n      const fillDrawcallCount = this.drawcallCtors.filter(\n        (ctor) => ctor === InstancedFillDrawcall,\n      ).length;\n      return this.index - fillDrawcallCount;\n    }\n    return 0;\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    // use default common attributes\n    super.createGeometry(objects);\n\n    const interleaved: number[] = [];\n    const packedCap: number[] = [];\n    const packedDash: number[] = [];\n    const indices: number[] = [];\n    let offset = 0;\n    objects.forEach((object) => {\n      let parsedLineStyleProps: Partial<ParsedLineStyleProps>;\n      let totalLength: number;\n      if (object.nodeName === Shape.LINE) {\n        parsedLineStyleProps = (object as Line).parsedStyle;\n        totalLength = (object as Line).getTotalLength();\n      } else if (object.nodeName === Shape.POLYLINE) {\n        const {\n          points: { points },\n          lineCap,\n          lineDash,\n          lineDashOffset,\n          markerStart,\n          markerEnd,\n          markerStartOffset,\n          markerEndOffset,\n          isBillboard,\n          // @ts-ignore\n          isSizeAttenuation,\n        } = (object as Polyline).parsedStyle;\n        parsedLineStyleProps = {\n          x1: points[0][0],\n          y1: points[0][1],\n          x2: points[points.length - 1][0],\n          y2: points[points.length - 1][1],\n          z1: 0,\n          z2: 0,\n          lineCap,\n          lineDash,\n          lineDashOffset,\n          isBillboard,\n          isSizeAttenuation,\n          markerStart,\n          markerEnd,\n          markerStartOffset,\n          markerEndOffset,\n        };\n        totalLength = (object as Polyline).getTotalLength();\n      } else if (object.nodeName === Shape.PATH) {\n        const {\n          d: { absolutePath },\n          lineCap,\n          lineDash,\n          lineDashOffset,\n          markerStart,\n          markerEnd,\n          markerStartOffset,\n          markerEndOffset,\n          isBillboard,\n          isSizeAttenuation,\n        } = (object as Path).parsedStyle;\n        let mSegmentCount = 0;\n        let mCommandIndex = 0;\n        const index = this.calcSubpathIndex(object);\n        for (let i = 0; i < absolutePath.length; i++) {\n          const segment = absolutePath[i];\n          if (segment[0] === 'M') {\n            if (mSegmentCount === index) {\n              mCommandIndex = i;\n              break;\n            }\n            mSegmentCount++;\n          }\n        }\n        parsedLineStyleProps = {\n          x1: absolutePath[mCommandIndex][1],\n          y1: absolutePath[mCommandIndex][2],\n          x2: absolutePath[mCommandIndex + 1][1],\n          y2: absolutePath[mCommandIndex + 1][2],\n          z1: 0,\n          z2: 0,\n          lineCap,\n          lineDash,\n          lineDashOffset,\n          isBillboard,\n          isSizeAttenuation,\n          markerStart,\n          markerEnd,\n          markerStartOffset,\n          markerEndOffset,\n        };\n        totalLength = (object as Path).getTotalLength();\n      }\n\n      const {\n        x1,\n        y1,\n        x2,\n        y2,\n        z1,\n        z2,\n        lineCap,\n        isBillboard,\n        isSizeAttenuation,\n      } = parsedLineStyleProps;\n\n      const { startOffsetX, startOffsetY, endOffsetX, endOffsetY } =\n        this.calcOffset(parsedLineStyleProps);\n      const { dashOffset, dashSegmentPercent, dashRatioInEachSegment } =\n        this.calcDash(parsedLineStyleProps, totalLength);\n\n      packedCap.push(\n        // caps\n        LineCap_MAP[lineCap],\n      );\n      packedDash.push(\n        dashOffset,\n        dashSegmentPercent,\n        dashRatioInEachSegment,\n        // isSizeAttenuation\n        isBillboard || isSizeAttenuation ? 1 : 0,\n      );\n\n      interleaved.push(\n        x1 + startOffsetX,\n        y1 + startOffsetY,\n        z1,\n        x2 + endOffsetX,\n        y2 + endOffsetY,\n        z2,\n      );\n      indices.push(\n        0 + offset,\n        2 + offset,\n        1 + offset,\n        0 + offset,\n        3 + offset,\n        2 + offset,\n      );\n      offset += 4;\n    });\n\n    this.geometry.setIndexBuffer(new Uint32Array(indices));\n    this.geometry.vertexCount = 6;\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.POSITION,\n      byteStride: 4 * 5,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: InstancedLineVertexAttributeLocation.POSITION,\n          divisor: 0,\n        },\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 3,\n          location: InstancedLineVertexAttributeLocation.UV,\n          divisor: 0,\n        },\n      ],\n      data: new Float32Array(segmentInstanceGeometry),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: InstancedLineVertexAttributeBufferIndex.POINT,\n      byteStride: 4 * (3 + 3),\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: InstancedLineVertexAttributeLocation.POINTA,\n          divisor: 1,\n        },\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 3,\n          location: InstancedLineVertexAttributeLocation.POINTB,\n          divisor: 1,\n        },\n      ],\n      data: new Float32Array(interleaved),\n    });\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: InstancedLineVertexAttributeBufferIndex.CAP,\n      byteStride: 4 * 1,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_R,\n          bufferByteOffset: 4 * 0,\n          location: InstancedLineVertexAttributeLocation.CAP,\n          divisor: 1,\n        },\n      ],\n      data: new Float32Array(packedCap),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: InstancedLineVertexAttributeBufferIndex.DASH,\n      byteStride: 4 * 4,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: InstancedLineVertexAttributeLocation.DASH,\n          divisor: 1,\n        },\n      ],\n      data: new Float32Array(packedDash),\n    });\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ) {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n\n    if (\n      name === 'x1' ||\n      name === 'y1' ||\n      name === 'x2' ||\n      name === 'y2' ||\n      name === 'z1' ||\n      name === 'z2' ||\n      name === 'markerStartOffset' ||\n      name === 'markerEndOffset' ||\n      name === 'markerStart' ||\n      name === 'markerEnd' ||\n      name === 'points' ||\n      name === 'd'\n    ) {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        let parsedLineStyleProps: Partial<ParsedLineStyleProps>;\n        if (object.nodeName === Shape.LINE) {\n          parsedLineStyleProps = (object as Line).parsedStyle;\n        } else if (object.nodeName === Shape.POLYLINE) {\n          const {\n            points: { points },\n            lineCap,\n            markerStart,\n            markerEnd,\n            markerStartOffset,\n            markerEndOffset,\n            isBillboard,\n            // @ts-ignore\n            isSizeAttenuation,\n          } = (object as Polyline).parsedStyle;\n          parsedLineStyleProps = {\n            x1: points[0][0],\n            y1: points[0][1],\n            x2: points[points.length - 1][0],\n            y2: points[points.length - 1][1],\n            z1: 0,\n            z2: 0,\n            lineCap,\n            isSizeAttenuation,\n            isBillboard,\n            markerStart,\n            markerEnd,\n            markerStartOffset,\n            markerEndOffset,\n          };\n        } else if (object.nodeName === Shape.PATH) {\n          const {\n            d: { absolutePath },\n            lineCap,\n            markerStart,\n            markerEnd,\n            markerStartOffset,\n            markerEndOffset,\n            isBillboard,\n            isSizeAttenuation,\n          } = (object as Path).parsedStyle;\n          parsedLineStyleProps = {\n            x1: absolutePath[0][1],\n            y1: absolutePath[0][2],\n            x2: absolutePath[1][1],\n            y2: absolutePath[1][2],\n            z1: 0,\n            z2: 0,\n            lineCap,\n            isBillboard,\n            isSizeAttenuation,\n            markerStart,\n            markerEnd,\n            markerStartOffset,\n            markerEndOffset,\n          };\n        }\n\n        const { x1, y1, x2, y2, z1, z2 } = parsedLineStyleProps;\n        const { startOffsetX, startOffsetY, endOffsetX, endOffsetY } =\n          this.calcOffset(parsedLineStyleProps);\n        packed.push(\n          x1 + startOffsetX,\n          y1 + startOffsetY,\n          z1,\n          x2 + endOffsetX,\n          y2 + endOffsetY,\n          z2,\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        InstancedLineVertexAttributeBufferIndex.POINT,\n        InstancedLineVertexAttributeLocation.POINTA,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (\n      name === 'lineDashOffset' ||\n      name === 'lineDash' ||\n      name === 'isSizeAttenuation' ||\n      name === 'isBillboard'\n    ) {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const totalLength = (object as Line).getTotalLength();\n\n        const { dashOffset, dashSegmentPercent, dashRatioInEachSegment } =\n          this.calcDash(object.parsedStyle, totalLength);\n        packed.push(\n          dashOffset,\n          dashSegmentPercent,\n          dashRatioInEachSegment,\n          object.parsedStyle.isBillboard || object.parsedStyle.isSizeAttenuation\n            ? 1\n            : 0, // isSizeAttenuation\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        InstancedLineVertexAttributeBufferIndex.DASH,\n        InstancedLineVertexAttributeLocation.DASH,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (name === 'lineCap') {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const { lineCap } = object.parsedStyle;\n        packed.push(LineCap_MAP[lineCap]);\n      });\n      this.geometry.updateVertexBuffer(\n        InstancedLineVertexAttributeBufferIndex.CAP,\n        InstancedLineVertexAttributeLocation.CAP,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    }\n  }\n\n  private calcOffset(parsedStyle: Partial<ParsedLineStyleProps>) {\n    const {\n      x1,\n      y1,\n      x2,\n      y2,\n      markerStart,\n      markerEnd,\n      markerStartOffset,\n      markerEndOffset,\n    } = parsedStyle;\n\n    let startOffsetX = 0;\n    let startOffsetY = 0;\n    let endOffsetX = 0;\n    let endOffsetY = 0;\n\n    let rad = 0;\n    let x: number;\n    let y: number;\n\n    if (markerStart && isDisplayObject(markerStart) && markerStartOffset) {\n      x = x2 - x1;\n      y = y2 - y1;\n      rad = Math.atan2(y, x);\n      startOffsetX = Math.cos(rad) * (markerStartOffset || 0);\n      startOffsetY = Math.sin(rad) * (markerStartOffset || 0);\n    }\n\n    if (markerEnd && isDisplayObject(markerEnd) && markerEndOffset) {\n      x = x1 - x2;\n      y = y1 - y2;\n      rad = Math.atan2(y, x);\n      endOffsetX = Math.cos(rad) * (markerEndOffset || 0);\n      endOffsetY = Math.sin(rad) * (markerEndOffset || 0);\n    }\n\n    return {\n      startOffsetX,\n      startOffsetY,\n      endOffsetX,\n      endOffsetY,\n    };\n  }\n\n  private calcDash(\n    parsedLineStyle: Partial<ParsedLineStyleProps>,\n    totalLength: number,\n  ) {\n    const { lineDash, lineDashOffset } = parsedLineStyle;\n    let dashOffset = 0;\n    let dashSegmentPercent = 1;\n    let dashRatioInEachSegment = 0;\n    if (lineDash && lineDash.length) {\n      dashOffset = (lineDashOffset || 0) / totalLength;\n      const segmentsLength = lineDash.reduce((cur, prev) => cur + prev, 0);\n\n      if (segmentsLength === 0) {\n        dashSegmentPercent = 1;\n        dashRatioInEachSegment = 0;\n      } else {\n        dashSegmentPercent = segmentsLength / totalLength;\n        dashRatioInEachSegment = lineDash[1] / segmentsLength;\n      }\n    }\n    return {\n      dashOffset,\n      dashSegmentPercent,\n      dashRatioInEachSegment,\n    };\n  }\n}\n","import type { DisplayObject, Image as ImageShape } from '@antv/g-lite';\nimport { Format, VertexStepMode } from '@antv/g-device-api';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\nimport frag from '../shader/image.frag';\nimport vert from '../shader/image.vert';\nimport { enumToObject } from '../utils';\n\nenum ImageVertexAttributeBufferIndex {\n  PACKED_STYLE = VertexAttributeBufferIndex.POSITION + 1,\n  SIZE = VertexAttributeBufferIndex.MAX,\n}\n\nenum ImageVertexAttributeLocation {\n  PACKED_STYLE3 = VertexAttributeLocation.MAX,\n  SIZE,\n}\n\nexport class ImageDrawcall extends Instanced {\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n\n    if (!shouldMerge) {\n      return false;\n    }\n\n    if (this.instance.parsedStyle.src !== object.parsedStyle.src) {\n      return false;\n    }\n\n    return true;\n  }\n\n  // private calculateWithAspectRatio(\n  //   object: Image,\n  //   imageWidth: number,\n  //   imageHeight: number,\n  // ) {\n  //   const { width, height } = object.parsedStyle;\n  //   // if (width && !height) {\n  //   //   object.setAttribute('height', (imageHeight / imageWidth) * width);\n  //   // } else if (!width && height) {\n  //   //   object.setAttribute('width', (imageWidth / imageHeight) * height);\n  //   // }\n  // }\n\n  createMaterial(objects: DisplayObject[]): void {\n    const instance = objects[0];\n    const { src } = instance.parsedStyle;\n\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(ImageVertexAttributeLocation),\n    };\n\n    this.material.vertexShader = vert;\n    this.material.fragmentShader = frag;\n\n    const map = this.texturePool.getOrCreateTexture(\n      this.context.device,\n      src,\n      undefined,\n      // (texture, image) => {\n      //   const { width, height } = image;\n      //   objects.forEach((object) => {\n      //     const image = object as ImageShape;\n      //     const { keepAspectRatio } = image.parsedStyle;\n      //     if (keepAspectRatio) {\n      //       this.calculateWithAspectRatio(object, width, height);\n      //       // set dirty rectangle flag\n      //       object.renderable.dirty = true;\n      //       this.context.renderingService.dirty();\n      //     }\n      //   });\n      // },\n    );\n    this.material.setUniforms({\n      u_Map: map,\n    });\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    // use default common attributes\n    super.createGeometry(objects);\n\n    const positions: number[] = [];\n    const sizes: number[] = [];\n    const packedStyle: number[] = [];\n    objects.forEach((object, i) => {\n      const image = object as ImageShape;\n      const {\n        x = 0,\n        y = 0,\n        z = 0,\n        width,\n        height,\n        isBillboard,\n        billboardRotation,\n        isSizeAttenuation,\n      } = image.parsedStyle;\n      positions.push(x, y, z);\n      sizes.push(width, height);\n      packedStyle.push(\n        isBillboard ? 1 : 0,\n        billboardRotation ?? 0,\n        isSizeAttenuation ? 1 : 0,\n        0,\n      );\n    });\n\n    this.geometry.setIndexBuffer(new Uint32Array([0, 2, 1, 0, 3, 2]));\n    this.geometry.vertexCount = 6;\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.POSITION,\n      byteStride: 4 * 3,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.POSITION,\n        },\n      ],\n      data: new Float32Array(positions),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: ImageVertexAttributeBufferIndex.SIZE,\n      byteStride: 4 * 2,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 0,\n          location: ImageVertexAttributeLocation.SIZE,\n        },\n      ],\n      data: new Float32Array(sizes),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: ImageVertexAttributeBufferIndex.PACKED_STYLE,\n      byteStride: 4 * 4,\n      stepMode: VertexStepMode.INSTANCE,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: ImageVertexAttributeLocation.PACKED_STYLE3,\n          divisor: 1,\n        },\n      ],\n      data: new Float32Array(packedStyle),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.UV,\n      byteStride: 4 * 2,\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.UV,\n        },\n      ],\n      data: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n    });\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ) {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n\n    if (name === 'x' || name === 'y' || name === 'z') {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const image = object as ImageShape;\n        const { x = 0, y = 0, z = 0 } = image.parsedStyle;\n        packed.push(x, y, z);\n      });\n\n      this.geometry.updateVertexBuffer(\n        VertexAttributeBufferIndex.POSITION,\n        VertexAttributeLocation.POSITION,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (name === 'width' || name === 'height') {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const image = object as ImageShape;\n        const { width, height } = image.parsedStyle;\n        packed.push(width, height);\n      });\n\n      this.geometry.updateVertexBuffer(\n        ImageVertexAttributeBufferIndex.SIZE,\n        ImageVertexAttributeLocation.SIZE,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (\n      name === 'isBillboard' ||\n      name === 'billboardRotation' ||\n      name === 'isSizeAttenuation'\n    ) {\n      const packed: number[] = [];\n      objects.forEach((object) => {\n        const image = object as ImageShape;\n        const { isBillboard, billboardRotation, isSizeAttenuation } =\n          image.parsedStyle;\n        packed.push(\n          isBillboard ? 1 : 0,\n          billboardRotation ?? 0,\n          isSizeAttenuation ? 1 : 0,\n          0,\n        );\n      });\n\n      this.geometry.updateVertexBuffer(\n        ImageVertexAttributeBufferIndex.PACKED_STYLE,\n        ImageVertexAttributeLocation.PACKED_STYLE3,\n        startIndex,\n        new Uint8Array(new Float32Array(packed).buffer),\n      );\n    } else if (name === 'src') {\n      const map = this.texturePool.getOrCreateTexture(\n        this.context.device,\n        value,\n      );\n      this.material.setUniforms({\n        u_Map: map,\n      });\n    }\n  }\n}\n","// borrow from mapbox/src/symbol\n\nexport type GlyphMetrics = {\n  width: number;\n  height: number;\n  left: number;\n  top: number;\n  advance: number;\n};\n\nexport type StyleGlyph = {\n  id: number;\n  bitmap: AlphaImage;\n  metrics: GlyphMetrics;\n};\n\nexport type Size = {\n  width: number;\n  height: number;\n};\n\nexport type Point = {\n  x: number;\n  y: number;\n};\n\nfunction createImage(\n  image: any,\n  { width, height }: Size,\n  channels: number,\n  data?: Uint8Array | Uint8ClampedArray,\n) {\n  if (!data) {\n    data = new Uint8Array(width * height * channels);\n  } else if (data.length !== width * height * channels) {\n    throw new RangeError('mismatched image size');\n  }\n  image.width = width;\n  image.height = height;\n  image.data = data;\n  return image;\n}\n\nfunction resizeImage(image: any, { width, height }: Size, channels: number) {\n  if (width === image.width && height === image.height) {\n    return;\n  }\n\n  const newImage = createImage({}, { width, height }, channels);\n\n  copyImage(\n    image,\n    newImage,\n    { x: 0, y: 0 },\n    { x: 0, y: 0 },\n    {\n      width: Math.min(image.width, width),\n      height: Math.min(image.height, height),\n    },\n    channels,\n  );\n\n  image.width = width;\n  image.height = height;\n  image.data = newImage.data;\n}\n\nfunction copyImage(\n  srcImg: any,\n  dstImg: any,\n  srcPt: Point,\n  dstPt: Point,\n  size: Size,\n  channels: number,\n) {\n  if (size.width === 0 || size.height === 0) {\n    return dstImg;\n  }\n\n  if (\n    size.width > srcImg.width ||\n    size.height > srcImg.height ||\n    srcPt.x > srcImg.width - size.width ||\n    srcPt.y > srcImg.height - size.height\n  ) {\n    throw new RangeError('out of range source coordinates for image copy');\n  }\n\n  if (\n    size.width > dstImg.width ||\n    size.height > dstImg.height ||\n    dstPt.x > dstImg.width - size.width ||\n    dstPt.y > dstImg.height - size.height\n  ) {\n    throw new RangeError('out of range destination coordinates for image copy');\n  }\n\n  const srcData = srcImg.data;\n  const dstData = dstImg.data;\n\n  for (let y = 0; y < size.height; y++) {\n    const srcOffset = ((srcPt.y + y) * srcImg.width + srcPt.x) * channels;\n    const dstOffset = ((dstPt.y + y) * dstImg.width + dstPt.x) * channels;\n    for (let i = 0; i < size.width * channels; i++) {\n      dstData[dstOffset + i] = srcData[srcOffset + i];\n    }\n  }\n\n  return dstImg;\n}\n\nexport class AlphaImage {\n  width: number;\n  height: number;\n  data: Uint8Array | Uint8ClampedArray;\n\n  constructor(size: Size, data?: Uint8Array | Uint8ClampedArray) {\n    createImage(this, size, 1, data);\n  }\n\n  resize(size: Size) {\n    resizeImage(this, size, 1);\n  }\n\n  clone() {\n    return new AlphaImage(\n      { width: this.width, height: this.height },\n      new Uint8Array(this.data),\n    );\n  }\n\n  static copy(\n    srcImg: AlphaImage,\n    dstImg: AlphaImage,\n    srcPt: Point,\n    dstPt: Point,\n    size: Size,\n  ) {\n    copyImage(srcImg, dstImg, srcPt, dstPt, size, 1);\n  }\n}\n","import type { GlyphMetrics, StyleGlyph } from './AlphaImage';\nimport { AlphaImage } from './AlphaImage';\n\n// borrow from https://github.com/mapbox/potpack/blob/master/index.mjs\n// @see https://github.com/antvis/g/issues/836\nfunction potpack(\n  boxes: {\n    x: number;\n    y: number;\n    w: number;\n    h: number;\n  }[],\n) {\n  // calculate total box area and maximum box width\n  let area = 0;\n  let maxWidth = 0;\n\n  for (const box of boxes) {\n    area += box.w * box.h;\n    maxWidth = Math.max(maxWidth, box.w);\n  }\n\n  // sort the boxes for insertion by height, descending\n  boxes.sort((a, b) => b.h - a.h);\n\n  // aim for a squarish resulting container,\n  // slightly adjusted for sub-100% space utilization\n  const startWidth = Math.max(Math.ceil(Math.sqrt(area / 0.95)), maxWidth);\n\n  // start with a single empty space, unbounded at the bottom\n  const spaces = [{ x: 0, y: 0, w: startWidth, h: Infinity }];\n\n  let width = 0;\n  let height = 0;\n\n  for (const box of boxes) {\n    // look through spaces backwards so that we check smaller spaces first\n    for (let i = spaces.length - 1; i >= 0; i--) {\n      const space = spaces[i];\n\n      // look for empty spaces that can accommodate the current box\n      if (box.w > space.w || box.h > space.h) continue;\n\n      // found the space; add the box to its top-left corner\n      // |-------|-------|\n      // |  box  |       |\n      // |_______|       |\n      // |         space |\n      // |_______________|\n      box.x = space.x;\n      box.y = space.y;\n\n      height = Math.max(height, box.y + box.h);\n      width = Math.max(width, box.x + box.w);\n\n      if (box.w === space.w && box.h === space.h) {\n        // space matches the box exactly; remove it\n        const last = spaces.pop();\n        if (i < spaces.length) spaces[i] = last;\n      } else if (box.h === space.h) {\n        // space matches the box height; update it accordingly\n        // |-------|---------------|\n        // |  box  | updated space |\n        // |_______|_______________|\n        space.x += box.w;\n        space.w -= box.w;\n      } else if (box.w === space.w) {\n        // space matches the box width; update it accordingly\n        // |---------------|\n        // |      box      |\n        // |_______________|\n        // | updated space |\n        // |_______________|\n        space.y += box.h;\n        space.h -= box.h;\n      } else {\n        // otherwise the box splits the space into two spaces\n        // |-------|-----------|\n        // |  box  | new space |\n        // |_______|___________|\n        // | updated space     |\n        // |___________________|\n        spaces.push({\n          x: space.x + box.w,\n          y: space.y,\n          w: space.w - box.w,\n          h: box.h,\n        });\n        space.y += box.h;\n        space.h -= box.h;\n      }\n      break;\n    }\n  }\n\n  return {\n    w: width, // container width\n    h: height, // container height\n    fill: area / (width * height) || 0, // space utilization\n  };\n}\n\nconst padding = 1;\n\ntype Rect = {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n};\n\nexport type GlyphPosition = {\n  rect: Rect;\n  metrics: GlyphMetrics;\n};\n\nexport type GlyphPositions = Record<string, Record<number, GlyphPosition>>;\n\n/**\n * Merge SDFs into a large squared atlas with `potpack`,\n * because on WebGL1 context, all textures are resized to a power of two to produce the best quality.\n *\n * @see https://doc.babylonjs.com/advanced_topics/webGL2#power-of-two-textures\n */\nexport default class GlyphAtlas {\n  image: AlphaImage;\n  positions: GlyphPositions;\n\n  constructor(stacks: Record<string, Record<number, StyleGlyph>>) {\n    const positions = {};\n    const bins: {\n      x: number;\n      y: number;\n      w: number;\n      h: number;\n    }[] = [];\n\n    for (const stack in stacks) {\n      const glyphs = stacks[stack];\n      // @ts-ignore\n      const stackPositions = (positions[stack] = {});\n\n      for (const id in glyphs) {\n        const src = glyphs[+id];\n        if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n        const bin = {\n          x: 0,\n          y: 0,\n          w: src.bitmap.width + 2 * padding,\n          h: src.bitmap.height + 2 * padding,\n        };\n        bins.push(bin);\n        // @ts-ignore\n        stackPositions[id] = { rect: bin, metrics: src.metrics };\n      }\n    }\n\n    const { w, h } = potpack(bins);\n    const image = new AlphaImage({ width: w || 1, height: h || 1 });\n\n    for (const stack in stacks) {\n      const glyphs = stacks[stack];\n\n      for (const id in glyphs) {\n        const src = glyphs[+id];\n        if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n        // @ts-ignore\n        const bin = positions[stack][id].rect;\n        AlphaImage.copy(\n          src.bitmap,\n          image,\n          { x: 0, y: 0 },\n          { x: bin.x + padding, y: bin.y + padding },\n          src.bitmap,\n        );\n      }\n    }\n\n    this.image = image;\n    this.positions = positions;\n  }\n}\n","import { CanvasLike, GlobalRuntime } from '@antv/g-lite';\nimport type { Device, Texture } from '@antv/g-device-api';\nimport { Format, makeTextureDescriptor2D } from '@antv/g-device-api';\nimport { TinySDF } from '../../utils';\nimport type { StyleGlyph } from './AlphaImage';\nimport { AlphaImage } from './AlphaImage';\nimport GlyphAtlas from './GlyphAtlas';\n\nexport type PositionedGlyph = {\n  glyph: number; // charCode\n  x: number;\n  y: number;\n  scale: number; // 根据缩放等级计算的缩放比例\n  fontStack: string;\n};\n\nexport const BASE_FONT_WIDTH = 24;\nexport const BASE_FONT_BUFFER = 3;\n\nconst fontSize = BASE_FONT_WIDTH; // Font size in pixels\nconst buffer = BASE_FONT_BUFFER; // Whitespace buffer around a glyph in pixels\nconst radius = 8; // How many pixels around the glyph shape to use for encoding distance\nconst cutoff = 0.25; // How much of the radius (relative) is used for the inside part the glyph\n\nexport function isCJK(char: number): boolean {\n  return char >= 0x4e00 && char <= 0x9fff;\n}\n\nexport function getDefaultCharacterSet(): string[] {\n  const charSet = [];\n  for (let i = 32; i < 128; i++) {\n    charSet.push(String.fromCharCode(i));\n  }\n  return charSet;\n}\n\n/**\n * TODO: use one atlas for all fontstacks, each fontstack has one texture now\n */\nexport class GlyphManager {\n  private sdfGeneratorCache: Record<string, TinySDF> = {};\n\n  private textMetricsCache: Record<string, Record<string, number>> = {};\n\n  private glyphAtlas: GlyphAtlas;\n  private glyphMap: Record<string, Record<number, StyleGlyph>> = {};\n  private glyphAtlasTexture: Texture;\n\n  constructor(private runtime: GlobalRuntime) {}\n\n  destroy() {\n    if (this.glyphAtlasTexture) {\n      this.glyphAtlasTexture.destroy();\n    }\n  }\n\n  getMap() {\n    return this.glyphMap;\n  }\n\n  getAtlas() {\n    return this.glyphAtlas;\n  }\n\n  getAtlasTexture() {\n    return this.glyphAtlasTexture;\n  }\n\n  layout(\n    lines: string[],\n    fontStack: string,\n    lineHeight: number,\n    textAlign: CanvasTextAlign | 'middle',\n    letterSpacing: number,\n    offsetX: number,\n    offsetY: number,\n  ): PositionedGlyph[] {\n    const positionedGlyphs: PositionedGlyph[] = [];\n\n    let x = offsetX;\n    let y = offsetY;\n\n    const justify =\n      // eslint-disable-next-line no-nested-ternary\n      textAlign === 'right' || textAlign === 'end'\n        ? 1\n        : textAlign === 'left' || textAlign === 'start'\n          ? 0\n          : 0.5;\n\n    lines.forEach((line) => {\n      const lineStartIndex = positionedGlyphs.length;\n      Array.from(line).forEach((char) => {\n        // fontStack\n        const positions = this.glyphMap[fontStack];\n        const charCode = char.charCodeAt(0);\n        const glyph = positions && positions[charCode];\n\n        if (glyph) {\n          positionedGlyphs.push({\n            glyph: charCode,\n            x,\n            y,\n            scale: 1,\n            fontStack,\n          });\n          x += glyph.metrics.advance + letterSpacing;\n        }\n      });\n\n      const lineWidth = x - letterSpacing;\n      for (let i = lineStartIndex; i < positionedGlyphs.length; i++) {\n        positionedGlyphs[i].x -= justify * lineWidth;\n      }\n\n      x = 0;\n      y += lineHeight;\n    });\n\n    return positionedGlyphs;\n  }\n\n  generateAtlas(\n    canvas: CanvasLike,\n    fontStack = '',\n    fontFamily: string,\n    fontWeight: string,\n    fontStyle = '',\n    text: string,\n    device: Device,\n  ) {\n    let newChars: string[] = [];\n    if (!this.glyphMap[fontStack]) {\n      newChars = getDefaultCharacterSet();\n    }\n\n    const existedChars = Object.keys(this.glyphMap[fontStack] || {});\n    Array.from(new Set(text.split(''))).forEach((char) => {\n      if (existedChars.indexOf(char.charCodeAt(0).toString()) === -1) {\n        newChars.push(char);\n      }\n    });\n\n    if (newChars.length) {\n      const glyphMap = newChars\n        .map((char) => {\n          return this.generateSDF(\n            canvas,\n            fontStack,\n            fontFamily,\n            fontWeight,\n            fontStyle,\n            char,\n          );\n        })\n        .reduce((prev, cur) => {\n          // @ts-ignore\n          prev[cur.id] = cur;\n          return prev;\n        }, {}) as StyleGlyph;\n\n      this.glyphMap[fontStack] = {\n        ...this.glyphMap[fontStack],\n        ...glyphMap,\n      };\n      this.glyphAtlas = new GlyphAtlas(this.glyphMap);\n      const {\n        width: atlasWidth,\n        height: atlasHeight,\n        data,\n      } = this.glyphAtlas.image;\n\n      if (this.glyphAtlasTexture) {\n        this.glyphAtlasTexture.destroy();\n      }\n\n      this.glyphAtlasTexture = device.createTexture({\n        ...makeTextureDescriptor2D(Format.ALPHA, atlasWidth, atlasHeight, 1),\n        pixelStore: {\n          unpackFlipY: false,\n          unpackAlignment: 1,\n        },\n      });\n      this.glyphAtlasTexture.setImageData([data]);\n    }\n  }\n\n  private generateSDF(\n    canvas: CanvasLike,\n    fontStack = '',\n    fontFamily: string,\n    fontWeight: string,\n    fontStyle: string,\n    char: string,\n  ): StyleGlyph {\n    const charCode = char.charCodeAt(0);\n    let sdfGenerator = this.sdfGeneratorCache[fontStack];\n    if (!sdfGenerator) {\n      // 创建 SDF\n      sdfGenerator = this.sdfGeneratorCache[fontStack] =\n        // TODO: use OffscreenCanvas in TextService\n        new TinySDF(\n          {\n            canvas,\n            fontSize,\n            fontFamily,\n            fontWeight,\n            fontStyle,\n            buffer,\n            radius,\n            cutoff,\n          },\n          this.runtime,\n        );\n    }\n\n    if (!this.textMetricsCache[fontStack]) {\n      this.textMetricsCache[fontStack] = {};\n    }\n\n    if (!this.textMetricsCache[fontStack][char]) {\n      // 使用 mapbox/tiny-sdf 中的 context\n      // @see https://stackoverflow.com/questions/46126565/how-to-get-font-glyphs-metrics-details-in-javascript\n      this.textMetricsCache[fontStack][char] =\n        // @ts-ignore\n        sdfGenerator.ctx.measureText(char).width;\n    }\n\n    // use sdf 2.x @see https://github.com/mapbox/tiny-sdf\n    const {\n      data,\n      width,\n      height,\n      glyphWidth,\n      glyphHeight,\n      glyphLeft,\n      glyphTop,\n      glyphAdvance,\n    } = sdfGenerator.draw(char);\n\n    return {\n      id: charCode,\n      // 在 canvas 中绘制字符，使用 Uint8Array 存储 30*30 sdf 数据\n      bitmap: new AlphaImage(\n        {\n          width,\n          height,\n        },\n        data,\n      ),\n      metrics: {\n        width: glyphWidth,\n        height: glyphHeight,\n        left: glyphLeft,\n        top: glyphTop - BASE_FONT_WIDTH + BASE_FONT_BUFFER,\n        advance: glyphAdvance,\n      },\n    };\n  }\n}\n","import type { GlyphPosition } from './GlyphAtlas';\nimport type { Point } from './AlphaImage';\nimport type { PositionedGlyph } from './GlyphManager';\nimport { BASE_FONT_BUFFER } from './GlyphManager';\n\nexport type SymbolQuad = {\n  tl: Point;\n  tr: Point;\n  bl: Point;\n  br: Point;\n  tex: {\n    x: number;\n    y: number;\n    w: number;\n    h: number;\n  };\n  glyphOffset: [number, number];\n};\n\n/**\n * Create the quads used for rendering a text label.\n */\nexport function getGlyphQuads(\n  positionedGlyphs: PositionedGlyph[],\n  positions: Record<string, Record<number, GlyphPosition>>,\n): SymbolQuad[] {\n  const quads: SymbolQuad[] = [];\n\n  for (let k = 0; k < positionedGlyphs.length; k++) {\n    const positionedGlyph = positionedGlyphs[k];\n    const glyphPositions = positions[positionedGlyph.fontStack];\n    const glyph = glyphPositions && glyphPositions[positionedGlyph.glyph];\n    if (!glyph) continue;\n\n    const { rect } = glyph;\n    if (!rect) continue;\n\n    // The rects have an addditional buffer that is not included in their size.\n    const glyphPadding = 1.0;\n    // const glyphPadding = 0.0;\n    const rectBuffer = BASE_FONT_BUFFER + glyphPadding;\n\n    const halfAdvance = (glyph.metrics.advance * positionedGlyph.scale) / 2;\n\n    const glyphOffset: [number, number] = [0, 0];\n\n    const builtInOffset = [positionedGlyph.x + halfAdvance, positionedGlyph.y];\n\n    const x1 =\n      (glyph.metrics.left - rectBuffer) * positionedGlyph.scale -\n      halfAdvance +\n      builtInOffset[0];\n    const y1 =\n      (-glyph.metrics.top - rectBuffer) * positionedGlyph.scale +\n      builtInOffset[1];\n    const x2 = x1 + rect.w * positionedGlyph.scale;\n    const y2 = y1 + rect.h * positionedGlyph.scale;\n\n    const tl = { x: x1, y: y1 };\n    const tr = { x: x2, y: y1 };\n    const bl = { x: x1, y: y2 };\n    const br = { x: x2, y: y2 };\n\n    quads.push({ tl, tr, bl, br, tex: rect, glyphOffset });\n  }\n\n  return quads;\n}\n","import type {\n  DisplayObject,\n  ParsedTextStyleProps,\n  Text as TextShape,\n  Tuple4Number,\n} from '@antv/g-lite';\nimport { isCSSRGB } from '@antv/g-lite';\nimport { mat4 } from 'gl-matrix';\nimport { CullMode, Format, VertexStepMode } from '@antv/g-device-api';\nimport { RENDER_ORDER_SCALE } from '../renderer/Batch';\nimport frag from '../shader/text.frag';\nimport vert from '../shader/text.vert';\nimport { enumToObject } from '../utils/enum';\nimport {\n  Instanced,\n  VertexAttributeBufferIndex,\n  VertexAttributeLocation,\n} from './Instanced';\nimport type GlyphAtlas from './symbol/GlyphAtlas';\nimport { BASE_FONT_WIDTH, GlyphManager } from './symbol/GlyphManager';\nimport { getGlyphQuads } from './symbol/SymbolQuad';\nimport { packUint8ToFloat } from '../utils/compression';\nimport { LightPool } from '../LightPool';\nimport { TexturePool } from '../TexturePool';\nimport { RenderHelper } from '../render';\nimport { BatchContext } from '../renderer';\n\nenum TextVertexAttributeBufferIndex {\n  INSTANCED = VertexAttributeBufferIndex.POSITION + 1,\n  TEX,\n}\n\nenum TextVertexAttributeLocation {\n  TEX = VertexAttributeLocation.MAX,\n  OFFSET,\n}\n\nexport enum TextUniform {\n  SDF_MAP = 'u_SDFMap',\n  SDF_MAP_SIZE = 'u_SDFMapSize',\n  FONT_SIZE = 'u_FontSize',\n  GAMMA_SCALE = 'u_GammaScale',\n  STROKE_BLUR = 'u_StrokeBlur',\n  HAS_STROKE = 'u_HasStroke',\n}\n\nexport class TextDrawcall extends Instanced {\n  private glyphManager: GlyphManager;\n\n  private packedBufferObjectMap = new WeakMap<\n    DisplayObject,\n    [number, number]\n  >();\n\n  private tmpMat4 = mat4.create();\n\n  private fontHash: string;\n\n  constructor(\n    protected renderHelper: RenderHelper,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n    object: DisplayObject,\n    drawcallCtors: (new (..._: any) => Instanced)[],\n    index: number,\n    context: BatchContext,\n  ) {\n    super(\n      renderHelper,\n      texturePool,\n      lightPool,\n      object,\n      drawcallCtors,\n      index,\n      context,\n    );\n    this.fontHash = this.calcFontHash(object);\n    this.glyphManager = new GlyphManager(this.context);\n  }\n\n  private calcFontHash(object: DisplayObject) {\n    // Trigger text geometry calculation.\n    object.getBounds();\n\n    const instancedAttributes = [\n      'fontSize',\n      'fontFamily',\n      'fontWeight',\n      'textBaseline',\n      'letterSpacing',\n    ];\n    return (\n      object.parsedStyle.metrics.font +\n      instancedAttributes.reduce((prev, cur) => {\n        return prev + object.parsedStyle[cur];\n      }, '')\n    );\n  }\n\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n\n    if (!shouldMerge) {\n      return false;\n    }\n\n    if (this.index !== index) {\n      return false;\n    }\n\n    return this.fontHash === this.calcFontHash(object);\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    const object = this.instance as TextShape;\n    const { fontSize = 16, letterSpacing = 0 } = object.parsedStyle;\n    let { textBaseline = 'alphabetic' } = object.parsedStyle;\n\n    // scale current font size to base(24)\n    const fontScale = BASE_FONT_WIDTH / fontSize;\n\n    const indices = [];\n    const positions = [];\n    const uvOffsets = [];\n    const packed = [];\n    let indicesOff = 0;\n    objects.forEach((object) => {\n      const {\n        metrics,\n        dx = 0,\n        dy = 0,\n      } = object.parsedStyle as ParsedTextStyleProps;\n      const { font, lines, height, lineHeight } = metrics;\n\n      // account for dx & dy\n      const offsetX = dx;\n      const offsetY = dy;\n\n      if (textBaseline === 'alphabetic') {\n        textBaseline = 'bottom';\n      }\n\n      let linePositionY = 0;\n      // handle vertical text baseline\n      if (textBaseline === 'middle') {\n        linePositionY += -height / 2;\n      } else if (textBaseline === 'bottom') {\n        linePositionY += -height;\n      } else if (textBaseline === 'top' || textBaseline === 'hanging') {\n        linePositionY += 0;\n      } else if (textBaseline === 'ideographic') {\n        linePositionY += -height;\n      }\n\n      const glyphAtlas = this.glyphManager.getAtlas();\n      const {\n        indicesOffset,\n        indexBuffer,\n        charUVOffsetBuffer,\n        charPositionsBuffer,\n        charPackedBuffer,\n      } = this.buildTextBuffers({\n        object,\n        lines,\n        fontStack: font,\n        lineHeight: fontScale * lineHeight,\n        offsetX: fontScale * offsetX,\n        offsetY: fontScale * (linePositionY + offsetY),\n        letterSpacing: fontScale * letterSpacing,\n        glyphAtlas,\n        indicesOffset: indicesOff,\n      });\n      indicesOff = indicesOffset;\n\n      const start = packed.length;\n      packed.push(...charPackedBuffer);\n      const end = packed.length;\n      this.packedBufferObjectMap.set(object, [start, end]);\n\n      uvOffsets.push(...charUVOffsetBuffer);\n      positions.push(...charPositionsBuffer);\n      indices.push(...indexBuffer);\n    });\n\n    this.geometry.vertexCount = indices.length;\n    this.geometry.setIndexBuffer(new Uint32Array(indices));\n    this.geometry.setVertexBuffer({\n      bufferIndex: TextVertexAttributeBufferIndex.INSTANCED,\n      byteStride: 4 * (4 * 4 + 4 + 4 + 4 + 4), // 32\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.MODEL_MATRIX0,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 4,\n          location: VertexAttributeLocation.MODEL_MATRIX1,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 8,\n          location: VertexAttributeLocation.MODEL_MATRIX2,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 12,\n          location: VertexAttributeLocation.MODEL_MATRIX3,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 16,\n          location: VertexAttributeLocation.PACKED_COLOR,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 20,\n          location: VertexAttributeLocation.PACKED_STYLE1,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 24,\n          location: VertexAttributeLocation.PACKED_STYLE2,\n        },\n        {\n          format: Format.F32_RGBA,\n          bufferByteOffset: 4 * 28,\n          location: VertexAttributeLocation.PICKING_COLOR,\n        },\n      ],\n      data: new Float32Array(packed),\n    });\n\n    this.geometry.setVertexBuffer({\n      bufferIndex: VertexAttributeBufferIndex.POSITION,\n      byteStride: 4 * 3,\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RGB,\n          bufferByteOffset: 4 * 0,\n          location: VertexAttributeLocation.POSITION,\n        },\n      ],\n      data: new Float32Array(positions),\n    });\n    this.geometry.setVertexBuffer({\n      bufferIndex: TextVertexAttributeBufferIndex.TEX,\n      byteStride: 4 * (2 + 2),\n      stepMode: VertexStepMode.VERTEX,\n      attributes: [\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 0,\n          location: TextVertexAttributeLocation.TEX,\n        },\n        {\n          format: Format.F32_RG,\n          bufferByteOffset: 4 * 2,\n          location: TextVertexAttributeLocation.OFFSET,\n        },\n      ],\n      data: new Float32Array(uvOffsets),\n    });\n  }\n\n  protected createMaterial(objects: DisplayObject[]): void {\n    this.material.vertexShader = vert;\n    this.material.fragmentShader = frag;\n    this.material.cullMode = CullMode.BACK;\n    this.material.defines = {\n      ...this.material.defines,\n      ...enumToObject(TextVertexAttributeLocation),\n    };\n\n    const object = this.instance as TextShape;\n    const {\n      fontSize = 16,\n      fontFamily = 'sans-serif',\n      fontWeight = 'normal',\n      fontStyle = 'normal',\n      metrics,\n    } = object.parsedStyle;\n    const { font } = metrics;\n    const allText = objects.map((object) => object.parsedStyle.text).join('');\n\n    this.glyphManager.generateAtlas(\n      this.texturePool.context.config.offscreenCanvas,\n      font,\n      fontFamily,\n      fontWeight.toString(),\n      fontStyle,\n      allText,\n      this.context.device,\n    );\n    const glyphAtlasTexture = this.glyphManager.getAtlasTexture();\n    const glyphAtlas = this.glyphManager.getAtlas();\n\n    this.context.device.setResourceName(glyphAtlasTexture, 'TextSDF Texture');\n\n    const { width: atlasWidth, height: atlasHeight } = glyphAtlas.image;\n\n    this.material.setUniforms({\n      [TextUniform.SDF_MAP]: glyphAtlasTexture,\n      [TextUniform.SDF_MAP_SIZE]: [atlasWidth, atlasHeight],\n      [TextUniform.FONT_SIZE]: fontSize,\n      [TextUniform.GAMMA_SCALE]: 1,\n      [TextUniform.STROKE_BLUR]: 0.2,\n      [TextUniform.HAS_STROKE]: this.index,\n    });\n  }\n\n  changeRenderOrder(object: DisplayObject, renderOrder: number) {\n    const vertice = this.geometry.vertices[\n      TextVertexAttributeBufferIndex.INSTANCED\n    ] as Float32Array;\n    const { arrayStride } =\n      this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[\n        TextVertexAttributeBufferIndex.INSTANCED\n      ];\n    const bytes = arrayStride / 4;\n    const [start, end] = this.packedBufferObjectMap.get(object);\n    const sliced = vertice.slice(start, end);\n    for (let i = 0; i < end - start; i += bytes) {\n      sliced[i + bytes - 1] = renderOrder * RENDER_ORDER_SCALE;\n    }\n    this.geometry.updateVertexBuffer(\n      TextVertexAttributeBufferIndex.INSTANCED,\n      VertexAttributeLocation.MODEL_MATRIX0,\n      start / bytes,\n      new Uint8Array(sliced.buffer),\n    );\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ): void {\n    // fix https://github.com/antvis/G/issues/1755\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n\n    if (\n      name === 'text' ||\n      name === 'fontFamily' ||\n      name === 'fontSize' ||\n      name === 'fontWeight' ||\n      name === 'fontStyle' ||\n      name === 'fontVariant' ||\n      name === 'textBaseline' ||\n      name === 'letterSpacing' ||\n      name === 'wordWrapWidth' ||\n      name === 'lineHeight' ||\n      name === 'wordWrap' ||\n      name === 'textAlign' ||\n      name === 'x' ||\n      name === 'y' ||\n      name === 'dx' ||\n      name === 'dy'\n    ) {\n      this.material.programDirty = true;\n      this.material.geometryDirty = true;\n      // need re-upload SDF texture\n      this.material.textureDirty = true;\n    } else if (\n      name === 'modelMatrix' ||\n      name === 'fill' ||\n      name === 'fillOpacity' ||\n      name === 'stroke' ||\n      name === 'strokeOpacity' ||\n      name === 'opacity' ||\n      name === 'lineWidth' ||\n      name === 'visibility' ||\n      name === 'pointerEvents' ||\n      name === 'isBillboard' ||\n      name === 'billboardRotation' ||\n      name === 'isSizeAttenuation'\n    ) {\n      const vertice = this.geometry.vertices[\n        TextVertexAttributeBufferIndex.INSTANCED\n      ] as Float32Array;\n      const { arrayStride } =\n        this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[\n          TextVertexAttributeBufferIndex.INSTANCED\n        ];\n      const bytes = arrayStride / 4;\n\n      objects.forEach((object) => {\n        const {\n          fill,\n          stroke,\n          opacity = 1,\n          fillOpacity = 1,\n          strokeOpacity = 1,\n          lineWidth = 1,\n          visibility,\n          isBillboard,\n          billboardRotation,\n          isSizeAttenuation,\n        } = object.parsedStyle as ParsedTextStyleProps;\n        let fillColor: Tuple4Number = [0, 0, 0, 0];\n        if (isCSSRGB(fill)) {\n          fillColor = [\n            Number(fill.r),\n            Number(fill.g),\n            Number(fill.b),\n            Number(fill.alpha) * 255,\n          ];\n        }\n\n        let strokeColor: Tuple4Number = [0, 0, 0, 0];\n        if (isCSSRGB(stroke)) {\n          strokeColor = [\n            Number(stroke.r),\n            Number(stroke.g),\n            Number(stroke.b),\n            Number(stroke.alpha) * 255,\n          ];\n        }\n\n        const encodedPickingColor = (object.isInteractive() &&\n          // @ts-ignore\n          object.renderable3D?.encodedPickingColor) || [0, 0, 0];\n\n        const modelMatrix = mat4.copy(this.tmpMat4, object.getWorldTransform());\n\n        const [start, end] = this.packedBufferObjectMap.get(object);\n        const sliced = vertice.slice(start, end);\n        for (let i = 0; i < end - start; i += bytes) {\n          // if (name === 'modelMatrix') {\n          sliced[i + 0] = modelMatrix[0];\n          sliced[i + 1] = modelMatrix[1];\n          sliced[i + 2] = modelMatrix[2];\n          sliced[i + 3] = modelMatrix[3];\n          sliced[i + 4] = modelMatrix[4];\n          sliced[i + 5] = modelMatrix[5];\n          sliced[i + 6] = modelMatrix[6];\n          sliced[i + 7] = modelMatrix[7];\n          sliced[i + 8] = modelMatrix[8];\n          sliced[i + 9] = modelMatrix[9];\n          sliced[i + 10] = modelMatrix[10];\n          sliced[i + 11] = modelMatrix[11];\n          sliced[i + 12] = modelMatrix[12];\n          sliced[i + 13] = modelMatrix[13];\n          sliced[i + 14] = modelMatrix[14];\n          sliced[i + 15] = modelMatrix[15];\n          // } else if (name === 'fill') {\n          sliced[i + 16] = packUint8ToFloat(fillColor[0], fillColor[1]);\n          sliced[i + 17] = packUint8ToFloat(fillColor[2], fillColor[3]);\n          // } else if (name === 'stroke') {\n          sliced[i + 18] = packUint8ToFloat(strokeColor[0], strokeColor[1]);\n          sliced[i + 19] = packUint8ToFloat(strokeColor[2], strokeColor[3]);\n          // }\n          sliced[i + 20] = opacity;\n          sliced[i + 21] = fillOpacity;\n          sliced[i + 22] = strokeOpacity;\n          sliced[i + 23] = lineWidth;\n          sliced[i + 24] = visibility !== 'hidden' ? 1 : 0;\n          sliced[i + 25] = isBillboard ? 1 : 0;\n          sliced[i + 26] = isSizeAttenuation ? 1 : 0;\n          sliced[i + 27] = billboardRotation ?? 0;\n          sliced[i + 28] = encodedPickingColor[0];\n          sliced[i + 29] = encodedPickingColor[1];\n          sliced[i + 30] = encodedPickingColor[2];\n          // sliced[i + 31] = object.sortable.renderOrder * RENDER_ORDER_SCALE;\n        }\n\n        this.geometry.updateVertexBuffer(\n          TextVertexAttributeBufferIndex.INSTANCED,\n          VertexAttributeLocation.MODEL_MATRIX0,\n          start / bytes,\n          new Uint8Array(sliced.buffer),\n        );\n      });\n    }\n  }\n\n  private buildTextBuffers({\n    object,\n    lines,\n    fontStack,\n    lineHeight,\n    letterSpacing,\n    offsetX,\n    offsetY,\n    glyphAtlas,\n    indicesOffset,\n  }: {\n    object: DisplayObject;\n    lines: string[];\n    fontStack: string;\n    lineHeight: number;\n    letterSpacing: number;\n    offsetX: number;\n    offsetY: number;\n    glyphAtlas: GlyphAtlas;\n    indicesOffset: number;\n  }) {\n    const {\n      textAlign = 'start',\n      fill,\n      stroke,\n      opacity = 1,\n      fillOpacity = 1,\n      strokeOpacity = 1,\n      lineWidth = 1,\n      visibility,\n      isBillboard,\n      billboardRotation,\n      isSizeAttenuation,\n      x = 0,\n      y = 0,\n      z = 0,\n    } = object.parsedStyle as ParsedTextStyleProps;\n    let fillColor: Tuple4Number = [0, 0, 0, 0];\n    if (isCSSRGB(fill)) {\n      fillColor = [\n        Number(fill.r),\n        Number(fill.g),\n        Number(fill.b),\n        Number(fill.alpha) * 255,\n      ];\n    }\n\n    let strokeColor: Tuple4Number = [0, 0, 0, 0];\n    if (isCSSRGB(stroke)) {\n      strokeColor = [\n        Number(stroke.r),\n        Number(stroke.g),\n        Number(stroke.b),\n        Number(stroke.alpha) * 255,\n      ];\n    }\n\n    const encodedPickingColor = (object.isInteractive() &&\n      // @ts-ignore\n      object.renderable3D?.encodedPickingColor) || [0, 0, 0];\n\n    const modelMatrix = mat4.copy(this.tmpMat4, object.getWorldTransform());\n\n    const charPackedBuffer: number[] = [];\n    const charUVOffsetBuffer: number[] = [];\n    const charPositionsBuffer: number[] = [];\n    const indexBuffer: number[] = [];\n\n    let i = indicesOffset;\n    const positionedGlyphs = this.glyphManager.layout(\n      lines,\n      fontStack,\n      lineHeight,\n      textAlign,\n      letterSpacing,\n      offsetX,\n      offsetY,\n    );\n\n    // 计算每个独立字符相对于锚点的位置信息\n    const glyphQuads = getGlyphQuads(positionedGlyphs, glyphAtlas.positions);\n\n    glyphQuads.forEach((quad) => {\n      // rollup will use `concat`\n      const temp = [];\n      temp.push(...modelMatrix);\n      const packed: number[] = [\n        ...temp,\n        packUint8ToFloat(fillColor[0], fillColor[1]),\n        packUint8ToFloat(fillColor[2], fillColor[3]),\n        packUint8ToFloat(strokeColor[0], strokeColor[1]),\n        packUint8ToFloat(strokeColor[2], strokeColor[3]),\n        opacity,\n        fillOpacity,\n        strokeOpacity,\n        lineWidth,\n        visibility !== 'hidden' ? 1 : 0,\n        isBillboard ? 1 : 0,\n        isSizeAttenuation ? 1 : 0,\n        billboardRotation ?? 0,\n        ...encodedPickingColor,\n        object.sortable.renderOrder * RENDER_ORDER_SCALE,\n      ];\n      // Can't use instanced here since the total number of each Text can be different.\n      charPackedBuffer.push(...packed, ...packed, ...packed, ...packed);\n\n      // interleaved uv & offsets\n      charUVOffsetBuffer.push(quad.tex.x, quad.tex.y, quad.tl.x, quad.tl.y);\n      charUVOffsetBuffer.push(\n        quad.tex.x + quad.tex.w,\n        quad.tex.y,\n        quad.tr.x,\n        quad.tr.y,\n      );\n      charUVOffsetBuffer.push(\n        quad.tex.x + quad.tex.w,\n        quad.tex.y + quad.tex.h,\n        quad.br.x,\n        quad.br.y,\n      );\n      charUVOffsetBuffer.push(\n        quad.tex.x,\n        quad.tex.y + quad.tex.h,\n        quad.bl.x,\n        quad.bl.y,\n      );\n      charPositionsBuffer.push(x, y, z, x, y, z, x, y, z, x, y, z);\n\n      indexBuffer.push(0 + i, 2 + i, 1 + i);\n      indexBuffer.push(2 + i, 0 + i, 3 + i);\n      i += 4;\n    });\n\n    return {\n      indexBuffer,\n      charUVOffsetBuffer,\n      charPositionsBuffer,\n      charPackedBuffer,\n      indicesOffset: i,\n    };\n  }\n\n  destroy() {\n    super.destroy();\n    this.glyphManager.destroy();\n  }\n}\n","import type { DisplayObject } from '@antv/g-lite';\nimport { Shape } from '@antv/g-lite';\nimport type { Mesh } from '../Mesh';\nimport { Instanced } from './Instanced';\n\nexport class MeshDrawcall extends Instanced {\n  protected mergeXYZIntoModelMatrix = false;\n\n  shouldMerge(object: DisplayObject, index: number) {\n    const shouldMerge = super.shouldMerge(object, index);\n\n    if (!shouldMerge) {\n      return false;\n    }\n\n    if (this.instance.nodeName === Shape.MESH) {\n      if (\n        this.instance.parsedStyle.material !== object.parsedStyle.material ||\n        this.instance.parsedStyle.geometry !== object.parsedStyle.geometry\n      ) {\n        return false;\n      }\n    }\n\n    return true;\n  }\n\n  updateAttribute(\n    objects: DisplayObject[],\n    startIndex: number,\n    name: string,\n    value: any,\n  ): void {\n    if (objects.length === 0) {\n      return;\n    }\n\n    super.updateAttribute(objects, startIndex, name, value);\n    this.updateBatchedAttribute(objects, startIndex, name, value);\n  }\n\n  createMaterial(objects: DisplayObject[]): void {\n    const { material } = (this.instance as Mesh).parsedStyle;\n    this.material = material;\n    this.observeMaterialChanged();\n  }\n\n  createGeometry(objects: DisplayObject[]): void {\n    const { geometry } = (this.instance as Mesh).parsedStyle;\n    this.geometry = geometry;\n\n    // use default common attributes\n    super.createGeometry(objects);\n\n    this.geometry.build(objects as Mesh[]);\n\n    // TODO: clear dirty listener\n    this.observeGeometryChanged();\n  }\n}\n","import type {\n  CSSRGB,\n  DisplayObject,\n  ParsedCircleStyleProps,\n} from '@antv/g-lite';\nimport { Instanced, InstancedPathDrawcall, SDFDrawcall } from '../drawcalls';\nimport { Batch } from './Batch';\n\n/**\n * Use 2 meshes:\n * * SDF to draw fill & simple stroke if needed.\n * * InstancedPathDrawcall to draw stroke separately.\n */\nexport class CircleRenderer extends Batch {\n  getDrawcallCtors(object: DisplayObject) {\n    const drawcalls: (typeof Instanced)[] = [];\n    const { fill } = object.parsedStyle as ParsedCircleStyleProps;\n    if (fill && !(fill as CSSRGB).isNone) {\n      drawcalls.push(SDFDrawcall);\n    }\n    if (this.needDrawStrokeSeparately(object)) {\n      drawcalls.push(InstancedPathDrawcall);\n    }\n\n    return drawcalls;\n  }\n\n  /**\n   * need an additional mesh to draw stroke:\n   * 1. strokeOpacity < 1\n   * 2. lineDash used\n   * 3. stroke is not 'none'\n   */\n  private needDrawStrokeSeparately(object: DisplayObject) {\n    const { fill, stroke, lineDash, lineWidth, strokeOpacity } =\n      object.parsedStyle as ParsedCircleStyleProps;\n\n    const hasFill = fill && !(fill as CSSRGB).isNone;\n    const hasStroke = stroke && !(stroke as CSSRGB).isNone;\n    const hasDash =\n      lineDash &&\n      lineDash.length &&\n      lineDash.every((item: number) => item !== 0);\n\n    return (\n      !hasFill || (hasStroke && lineWidth > 0 && (strokeOpacity < 1 || hasDash))\n    );\n  }\n}\n","/**\n * @see https://www.khronos.org/assets/uploads/developers/presentations/Crazy_Panda_How_to_draw_lines_in_WebGL.pdf\n */\nimport type { CSSRGB, DisplayObject, ParsedPathStyleProps } from '@antv/g-lite';\nimport { Shape } from '@antv/g-lite';\nimport {\n  Instanced,\n  InstancedFillDrawcall,\n  InstancedLineDrawcall,\n  InstancedPathDrawcall,\n} from '../drawcalls';\nimport { Batch } from './Batch';\n\n/**\n * Use the following perf enhancements:\n * * Downgrading the \"simple\" Path / Polyline to {@link InstancedLineDrawcall}, e.g. 'M 0 0 L 100 0'\n * * Merge the Path into {@link InstancedPathDrawcall} which contains only one curve command, e.g 'M 0 0 Q 10 10 100 100'\n * @see https://github.com/antvis/G/issues/1113\n */\nexport class PathRenderer extends Batch {\n  // meshes = [\n  //   InstancedFillDrawcall ?,\n  //   (InstancedLineDrawcall | InstancedPathDrawcall) *, // sub paths\n  // ];\n\n  getDrawcallCtors(object: DisplayObject) {\n    const { fill, stroke, opacity, strokeOpacity, lineWidth } =\n      object.parsedStyle as ParsedPathStyleProps;\n    const hasStroke = stroke && !(stroke as CSSRGB).isNone;\n    const subpathNum = InstancedPathDrawcall.calcSubpathNum(object);\n\n    const drawcalls: (typeof Instanced)[] = [];\n\n    // Polyline don't need fill\n    if (!(object.nodeName === Shape.POLYLINE || (fill as CSSRGB)?.isNone)) {\n      for (let i = 0; i < subpathNum; i++) {\n        drawcalls.push(InstancedFillDrawcall);\n      }\n    }\n\n    for (let i = 0; i < subpathNum; i++) {\n      if (\n        !(strokeOpacity === 0 || opacity === 0 || lineWidth === 0 || !hasStroke)\n      ) {\n        const isLine = InstancedLineDrawcall.isLine(object, i);\n        if (isLine) {\n          drawcalls.push(InstancedLineDrawcall);\n        } else {\n          drawcalls.push(InstancedPathDrawcall);\n        }\n      }\n    }\n\n    return drawcalls;\n  }\n}\n","import { ImageDrawcall } from '../drawcalls';\nimport { Batch } from './Batch';\n\nexport class ImageRenderer extends Batch {\n  getDrawcallCtors() {\n    return [ImageDrawcall];\n  }\n}\n","import type { CSSRGB, DisplayObject, ParsedTextStyleProps } from '@antv/g-lite';\nimport type { Instanced } from '../drawcalls';\nimport { TextDrawcall, TextUniform } from '../drawcalls';\nimport type { RenderInst } from '../render/RenderInst';\nimport { Batch } from './Batch';\nimport { Renderable3D } from '../components/Renderable3D';\n\nexport class TextRenderer extends Batch {\n  /**\n   * one for fill, one for stroke\n   */\n  getDrawcallCtors(object: DisplayObject) {\n    const drawcalls: (typeof Instanced)[] = [];\n\n    const { stroke, lineWidth = 1 } =\n      object.parsedStyle as ParsedTextStyleProps;\n    const hasStroke = !!(stroke && !(stroke as CSSRGB).isNone && lineWidth);\n\n    if (hasStroke) {\n      drawcalls.push(TextDrawcall);\n    }\n\n    drawcalls.push(TextDrawcall);\n    return drawcalls;\n  }\n\n  beforeUploadUBO(renderInst: RenderInst, mesh: Instanced) {\n    const drawcallNum = ((mesh.instance as any).renderable3D as Renderable3D)\n      .drawcalls.length;\n\n    mesh.material.setUniforms({\n      [TextUniform.HAS_STROKE]: drawcallNum === 1 ? 0 : 1 - mesh.index,\n    });\n  }\n}\n","import { InstancedLineDrawcall } from '../drawcalls';\nimport { Batch } from './Batch';\n\n/**\n * use instanced for each segment\n * @see https://blog.scottlogic.com/2019/11/18/drawing-lines-with-webgl.html\n *\n * support dash array\n * TODO: joint & cap\n */\nexport class LineRenderer extends Batch {\n  getDrawcallCtors() {\n    return [InstancedLineDrawcall];\n  }\n}\n","import { MeshDrawcall } from '../drawcalls';\nimport { Batch } from './Batch';\n\nexport class MeshRenderer extends Batch {\n  getDrawcallCtors() {\n    return [MeshDrawcall];\n  }\n}\n","import type { CSSRGB, DisplayObject, ParsedRectStyleProps } from '@antv/g-lite';\nimport {\n  Instanced,\n  InstancedFillDrawcall,\n  InstancedPathDrawcall,\n  SDFDrawcall,\n} from '../drawcalls';\nimport { Batch } from './Batch';\n\n/**\n * Use 2 meshes:\n * * For simple Rect with fill & simple stroke, we use SDFDrawcall to draw which has a better performance.\n * * FillMesh & LineMesh to draw rounded rect with different radius.\n */\nexport class RectRenderer extends Batch {\n  getDrawcallCtors(object: DisplayObject) {\n    const drawcalls: (typeof Instanced)[] = [];\n\n    const { fill, radius } = object.parsedStyle as ParsedRectStyleProps;\n    const hasDifferentRadius =\n      radius && radius.length && radius.some((r) => r !== radius[0]);\n\n    if (!((fill as CSSRGB)?.isNone || hasDifferentRadius)) {\n      drawcalls.push(SDFDrawcall);\n    }\n\n    if (hasDifferentRadius) {\n      drawcalls.push(InstancedFillDrawcall);\n    }\n\n    if (hasDifferentRadius || this.needDrawStrokeSeparately(object)) {\n      drawcalls.push(InstancedPathDrawcall);\n    }\n\n    return drawcalls;\n  }\n\n  /**\n   * need an additional mesh to draw stroke:\n   * 1. strokeOpacity < 1\n   * 2. lineDash used\n   * 3. stroke is not 'none'\n   */\n  private needDrawStrokeSeparately(object: DisplayObject) {\n    const { fill, stroke, lineDash, lineWidth, strokeOpacity } =\n      object.parsedStyle as ParsedRectStyleProps;\n\n    const hasFill = fill && !(fill as CSSRGB).isNone;\n    const hasStroke = stroke && !(stroke as CSSRGB).isNone;\n    const hasDash =\n      lineDash && lineDash.length && lineDash.every((item) => item !== 0);\n\n    return (\n      !hasFill || (hasStroke && lineWidth > 0 && (strokeOpacity < 1 || hasDash))\n    );\n  }\n}\n","import type {\n  DisplayObject,\n  RenderingPluginContext,\n  Shape,\n} from '@antv/g-lite';\nimport type { Device } from '@antv/g-device-api';\nimport type { Renderable3D } from '../components/Renderable3D';\nimport type { LightPool } from '../LightPool';\nimport type { Instanced } from '../drawcalls/Instanced';\nimport type { RenderInstList, RenderHelper } from '../render';\nimport type { TexturePool } from '../TexturePool';\nimport type { Batch } from './Batch';\n\nlet stencilRefCounter = 1;\n\nexport type BatchContext = { device: Device } & RenderingPluginContext;\n\nexport class BatchManager {\n  constructor(\n    protected renderHelper: RenderHelper,\n    private rendererFactory: Record<Shape, Batch>,\n    protected texturePool: TexturePool,\n    protected lightPool: LightPool,\n  ) {}\n\n  /**\n   * attached when Device created\n   */\n  private context: BatchContext;\n\n  /**\n   * draw calls\n   */\n  private drawcalls: Instanced[] = [];\n\n  /**\n   * update patches which can be merged before rendering\n   */\n  private pendingUpdatePatches: Record<\n    string,\n    {\n      instance: Instanced;\n      objectIndices: number[];\n      name: string;\n      value: any;\n      // names: string[];\n    }\n  > = {};\n\n  private stencilRefCache: Record<number, number> = {};\n\n  destroy() {\n    this.drawcalls.forEach((drawcall) => {\n      drawcall.destroy();\n    });\n    this.drawcalls = [];\n    this.pendingUpdatePatches = {};\n  }\n\n  render(list: RenderInstList, isPicking = false) {\n    if (!isPicking) {\n      this.updatePendingPatches();\n    }\n\n    this.drawcalls.forEach((mesh) => {\n      // init rendering service, create geometry & material\n      mesh.init();\n\n      let { objects } = mesh;\n      if (mesh.clipPathTarget) {\n        objects = [mesh.clipPath];\n      }\n\n      // new render instance\n      const renderInst = this.renderHelper.renderInstManager.newRenderInst();\n      renderInst.setAllowSkippingIfPipelineNotReady(false);\n      mesh.applyRenderInst(renderInst, objects);\n\n      this.renderHelper.renderInstManager.submitRenderInst(renderInst, list);\n\n      // console.log('submit: ', mesh);\n\n      if (!isPicking) {\n        // finish rendering...\n        mesh.objects.forEach((object) => {\n          object.renderable.dirty = false;\n        });\n      }\n    });\n  }\n\n  /**\n   * get called in RenderGraphPlugin\n   */\n  attach(context: BatchContext) {\n    this.context = context;\n  }\n\n  add(object: DisplayObject) {\n    const renderable3D = (object as any).renderable3D as Renderable3D;\n    if (renderable3D && !renderable3D.drawcalls.length) {\n      const renderer = this.rendererFactory[object.nodeName] as Batch;\n      if (renderer) {\n        // A complex Path can be splitted into multple sub paths.\n        renderer\n          .getDrawcallCtors(object)\n          .forEach(\n            (\n              DrawCallCtor: new (..._: any) => Instanced,\n              i: number,\n              drawcallCtors: (new (..._: any) => Instanced)[],\n            ) => {\n              let existedDrawcall = this.drawcalls.find(\n                (mesh) =>\n                  DrawCallCtor === mesh.constructor &&\n                  mesh.index === i &&\n                  mesh.objects.length < mesh.maxInstances &&\n                  mesh.shouldMerge(object, i),\n              );\n              if (\n                !existedDrawcall ||\n                existedDrawcall.key !== object.parsedStyle.batchKey\n              ) {\n                existedDrawcall = new DrawCallCtor(\n                  this.renderHelper,\n                  this.texturePool,\n                  this.lightPool,\n                  object,\n                  drawcallCtors,\n                  i,\n                  this.context,\n                );\n                existedDrawcall.renderer = renderer;\n                this.drawcalls.push(existedDrawcall);\n\n                if (object.parsedStyle.batchKey) {\n                  existedDrawcall.key = object.parsedStyle.batchKey;\n                }\n              }\n\n              if (existedDrawcall) {\n                existedDrawcall.objects.push(object);\n                renderable3D.drawcalls[i] = existedDrawcall;\n                existedDrawcall.geometryDirty = true;\n              }\n            },\n          );\n      }\n    }\n  }\n\n  remove(object: DisplayObject) {\n    // @ts-ignore\n    const renderable3D = object.renderable3D as Renderable3D;\n    if (renderable3D) {\n      renderable3D.drawcalls.forEach((mesh) => {\n        if (mesh) {\n          // remove from mesh\n          const index = mesh.objects.indexOf(object);\n          if (index > -1) {\n            mesh.objects.splice(index, 1);\n            mesh.geometryDirty = true;\n          }\n\n          if (mesh.objects.length === 0) {\n            const deletedDrawcalls = this.drawcalls.splice(\n              this.drawcalls.indexOf(mesh),\n              1,\n            );\n            deletedDrawcalls.forEach((deletedDrawcall) => {\n              deletedDrawcall.destroy();\n            });\n          }\n        }\n      });\n      renderable3D.drawcalls = [];\n    }\n  }\n\n  updateAttribute(\n    object: DisplayObject,\n    attributeName: string,\n    newValue: any,\n    immediately = false,\n  ) {\n    const renderable3D = (object as any).renderable3D as Renderable3D;\n    const renderer = this.rendererFactory[object.nodeName] as Batch;\n    if (renderer) {\n      const drawcallCtors = renderer.getDrawcallCtors(object);\n      drawcallCtors.forEach((DrawCallCtor, i, drawcallCtors) => {\n        let existedDrawcall = renderable3D.drawcalls.find(\n          (mesh) =>\n            mesh && mesh.index === i && mesh.constructor === DrawCallCtor,\n        );\n\n        if (!existedDrawcall) {\n          // Clear invalid drawcall.\n          existedDrawcall = renderable3D.drawcalls[i];\n\n          if (existedDrawcall) {\n            // remove from mesh\n            existedDrawcall.objects.splice(\n              existedDrawcall.objects.indexOf(object),\n              1,\n            );\n            existedDrawcall.geometryDirty = true;\n\n            if (existedDrawcall.objects.length === 0) {\n              this.drawcalls.splice(this.drawcalls.indexOf(existedDrawcall), 1);\n            }\n            renderable3D.drawcalls[\n              renderable3D.drawcalls.indexOf(existedDrawcall)\n            ] = undefined;\n          }\n\n          // We should create a new drawcall from scratch.\n          existedDrawcall = this.drawcalls.find(\n            (mesh) =>\n              DrawCallCtor === mesh.constructor &&\n              mesh.index === i &&\n              mesh.objects.length < mesh.maxInstances &&\n              mesh.shouldMerge(object, i),\n          );\n\n          if (!existedDrawcall) {\n            // @ts-ignore\n            existedDrawcall = new DrawCallCtor(\n              this.renderHelper,\n              this.texturePool,\n              this.lightPool,\n              object,\n              drawcallCtors,\n              i,\n              this.context,\n            );\n            existedDrawcall.renderer = renderer;\n            existedDrawcall.init();\n            this.drawcalls.push(existedDrawcall);\n          } else {\n            existedDrawcall.geometryDirty = true;\n          }\n\n          existedDrawcall.objects.push(object);\n          renderable3D.drawcalls[i] = existedDrawcall;\n        }\n\n        if (existedDrawcall.inited && !existedDrawcall.geometryDirty) {\n          const shouldMerge = existedDrawcall.shouldMerge(object, i);\n          if (shouldMerge) {\n            const objectIdx = existedDrawcall.objects.indexOf(object);\n            if (immediately) {\n              object.parsedStyle[attributeName] = newValue;\n              existedDrawcall.updateAttribute(\n                [object],\n                objectIdx,\n                attributeName,\n                newValue,\n              );\n            } else {\n              const patchKey = existedDrawcall.id + attributeName;\n              if (!this.pendingUpdatePatches[patchKey]) {\n                this.pendingUpdatePatches[patchKey] = {\n                  instance: existedDrawcall,\n                  objectIndices: [],\n                  name: attributeName,\n                  value: newValue,\n                };\n              }\n              if (\n                this.pendingUpdatePatches[patchKey].objectIndices.indexOf(\n                  objectIdx,\n                ) === -1\n              ) {\n                this.pendingUpdatePatches[patchKey].objectIndices.push(\n                  objectIdx,\n                );\n              }\n            }\n          } else {\n            this.remove(object);\n            this.add(object);\n          }\n        } else {\n          this.remove(object);\n          this.add(object);\n        }\n      });\n\n      // Clear redundant drawcalls.\n      if (renderable3D.drawcalls.length > drawcallCtors.length) {\n        const drawcallNum = renderable3D.drawcalls.length;\n        for (let i = drawcallNum - 1; i >= drawcallCtors.length; i--) {\n          const existedDrawcall = renderable3D.drawcalls[i];\n\n          // remove from mesh\n          existedDrawcall.objects.splice(\n            existedDrawcall.objects.indexOf(object),\n            1,\n          );\n          existedDrawcall.geometryDirty = true;\n\n          if (existedDrawcall.objects.length === 0) {\n            this.drawcalls.splice(this.drawcalls.indexOf(existedDrawcall), 1);\n          }\n          renderable3D.drawcalls.pop();\n        }\n      }\n    }\n  }\n\n  changeRenderOrder(object: DisplayObject, renderOrder: number) {\n    // @ts-ignore\n    const renderable3D = object.renderable3D as Renderable3D;\n    if (renderable3D && renderable3D.drawcalls.length) {\n      renderable3D.drawcalls.forEach((mesh) => {\n        if (mesh && mesh.inited && !mesh.geometryDirty) {\n          if (mesh.inited) {\n            mesh.changeRenderOrder(object, renderOrder);\n          }\n        }\n      });\n    }\n  }\n\n  getStencilRef(object: DisplayObject) {\n    if (!this.stencilRefCache[object.entity]) {\n      this.stencilRefCache[object.entity] = stencilRefCounter++;\n    }\n    return this.stencilRefCache[object.entity];\n  }\n\n  private updatePendingPatches() {\n    // merge update patches to reduce `setSubData` calls\n    Object.keys(this.pendingUpdatePatches).forEach((patchKey) => {\n      const { instance, objectIndices, name, value } =\n        this.pendingUpdatePatches[patchKey];\n      objectIndices.sort((a, b) => a - b);\n\n      const updatePatches: number[][] = [];\n      objectIndices.forEach((i) => {\n        const lastUpdateBatch = updatePatches[updatePatches.length - 1];\n\n        if (\n          !lastUpdateBatch ||\n          i !== lastUpdateBatch[lastUpdateBatch.length - 1] + 1\n        ) {\n          updatePatches.push([i]);\n        } else {\n          lastUpdateBatch.push(i);\n        }\n      });\n\n      updatePatches.forEach((indices) => {\n        instance.updateAttribute(\n          instance.objects.slice(indices[0], indices[0] + indices.length),\n          indices[0],\n          name,\n          value,\n        );\n      });\n    });\n    this.pendingUpdatePatches = {};\n  }\n\n  // private findClipPath(): DisplayObject | null {\n  //   let node = this.instance;\n  //   while (node && node.style) {\n  //     if (node.style.clipPath) {\n  //       return node.style.clipPath;\n  //     }\n  //     node = node.parentNode as DisplayObject;\n  //   }\n  //   return null;\n  // }\n\n  // private applyClipPath() {\n  //   // find clipPath\n  //   const clipPathShape = this.findClipPath();\n  //   if (clipPathShape && !this.clipPathMeshCreated) {\n  //     if (this.batchMeshList.length === 0) {\n  //       return;\n  //     }\n\n  //     const clipPathMesh = this.meshFactory(clipPathShape.nodeName);\n  //     clipPathMesh.clipPathTarget = this.instance;\n\n  //     // draw clipPath first\n  //     this.batchMeshList.unshift(clipPathMesh);\n  //     this.clipPathMeshCreated = true;\n\n  //     this.batchMeshList.forEach((mesh, i) => {\n  //       mesh.clipPath = clipPathShape;\n\n  //       // if (!mesh.material) {\n  //       //   mesh.material = new ShaderMaterial(this.device);\n  //       // }\n  //       mesh.material.stencilRef = this.batchManager.getStencilRef(clipPathShape);\n  //     });\n  //   }\n\n  //   // remove clipPath from render queue\n  //   if (!clipPathShape) {\n  //     if (this.batchMeshList.length && this.batchMeshList[0].clipPathTarget) {\n  //       this.batchMeshList.shift();\n  //     }\n  //   }\n  // }\n}\n","import {\n  CanvasContext,\n  CSSGradientValue,\n  DisplayObject,\n  GlobalRuntime,\n  LinearGradient,\n  parsedTransformToMat4,\n  parseTransform,\n  Pattern,\n  RadialGradient,\n} from '@antv/g-lite';\nimport type { ImagePool } from '@antv/g-plugin-image-loader';\nimport { isString } from '@antv/util';\nimport type { Device, Texture, TextureDescriptor } from '@antv/g-device-api';\nimport {\n  Format,\n  TextureDimension,\n  TextureEvent,\n  TextureUsage,\n} from '@antv/g-device-api';\n\nexport interface GradientParams {\n  width: number;\n  height: number;\n  gradients: CSSGradientValue[];\n  instance: DisplayObject;\n}\n\nexport class TexturePool {\n  constructor(\n    public context: CanvasContext,\n    private runtime: GlobalRuntime,\n  ) {}\n\n  private textureCache: Record<string, Texture> = {};\n\n  getOrCreateTexture(\n    device: Device,\n    src: string | TexImageSource,\n    descriptor?: TextureDescriptor,\n    successCallback?: (\n      t: Texture,\n      image: ImageBitmap | HTMLImageElement,\n    ) => void,\n  ): Texture {\n    // use Image URL or src as cache key\n    // @ts-ignore\n    const id = typeof src === 'string' ? src : src.src || '';\n    let texture: Texture;\n\n    if (!id || !this.textureCache[id]) {\n      texture = device.createTexture({\n        format: Format.U8_RGBA_NORM,\n        width: 1,\n        height: 1,\n        depthOrArrayLayers: 1,\n        mipLevelCount: 1,\n        dimension: TextureDimension.TEXTURE_2D,\n        usage: TextureUsage.SAMPLED,\n        pixelStore: {\n          unpackFlipY: false,\n        },\n        ...descriptor,\n      });\n\n      if (id) {\n        this.textureCache[id] = texture;\n      }\n\n      if (!isString(src)) {\n        texture.setImageData([src]);\n        texture.emit(TextureEvent.LOADED);\n        this.context.renderingService.dirty();\n      } else {\n        // @see https://github.com/antvis/g/issues/938\n        const image = this.context.config.createImage();\n\n        if (image) {\n          image.onload = () => {\n            const onSuccess = (bitmap: ImageBitmap | HTMLImageElement) => {\n              this.textureCache[id].setImageData([bitmap]);\n              this.textureCache[id].emit(TextureEvent.LOADED);\n              this.context.renderingService.dirty();\n              if (successCallback) {\n                successCallback(this.textureCache[id], bitmap);\n              }\n            };\n\n            if (this.runtime.globalThis.createImageBitmap) {\n              this.runtime.globalThis\n                .createImageBitmap(image)\n                .then((bitmap: ImageBitmap) => onSuccess(bitmap))\n                .catch(() => {\n                  // Unhandled Rejection (InvalidStateError):\n                  // Failed to execute 'createImageBitmap' on 'Window':\n                  // The image element contains an SVG image without intrinsic dimensions,\n                  // and no resize options or crop region are specified.\n                  onSuccess(image);\n                });\n            } else {\n              onSuccess(image);\n            }\n          };\n          image.onerror = () => {};\n          image.crossOrigin = 'Anonymous';\n          image.src = src;\n        }\n      }\n    } else {\n      texture = this.textureCache[id];\n      texture.emit(TextureEvent.LOADED);\n    }\n    return texture;\n  }\n\n  getOrCreateCanvas() {\n    return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(\n      this.context.config.offscreenCanvas,\n    );\n  }\n\n  getOrCreateGradient(params: GradientParams) {\n    const { instance, gradients } = params;\n    const { halfExtents } = instance.getGeometryBounds();\n    const width = halfExtents[0] * 2 || 1;\n    const height = halfExtents[1] * 2 || 1;\n\n    const { offscreenCanvas } = this.context.config;\n    const canvas =\n      this.runtime.offscreenCanvasCreator.getOrCreateCanvas(offscreenCanvas);\n    const context = this.runtime.offscreenCanvasCreator.getOrCreateContext(\n      offscreenCanvas,\n    ) as CanvasRenderingContext2D;\n\n    canvas.width = width;\n    canvas.height = height;\n\n    // @ts-ignore\n    const imagePool = this.context.imagePool as ImagePool;\n\n    gradients.forEach((g) => {\n      const gradient = imagePool.getOrCreateGradient(\n        {\n          type: g.type,\n          ...(g.value as LinearGradient & RadialGradient),\n          width,\n          height,\n          min: [0, 0],\n        },\n        context,\n      );\n\n      // used as canvas' ID\n      // @ts-ignore\n      // canvas.src = key;\n\n      context.fillStyle = gradient;\n      context.fillRect(0, 0, width, height);\n    });\n  }\n\n  getOrCreatePattern(\n    pattern: Pattern,\n    instance: DisplayObject,\n    callback: () => void,\n  ) {\n    const { image, repetition, transform } = pattern;\n    const { halfExtents } = instance.getGeometryBounds();\n    const width = halfExtents[0] * 2 || 1;\n    const height = halfExtents[1] * 2 || 1;\n    const { offscreenCanvas } = this.context.config;\n\n    const canvas =\n      this.runtime.offscreenCanvasCreator.getOrCreateCanvas(offscreenCanvas);\n    const context =\n      this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);\n\n    canvas.width = width;\n    canvas.height = height;\n\n    let src: CanvasImageSource;\n    // Image URL\n    if (isString(image)) {\n      const imageCache = (this.context.imagePool as ImagePool).getImageSync(\n        image,\n        instance,\n        callback,\n      );\n      src = imageCache?.img;\n    } else {\n      src = image as CanvasImageSource;\n    }\n\n    const canvasPattern = src && context.createPattern(src, repetition);\n\n    // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform\n    if (transform) {\n      const mat = parsedTransformToMat4(\n        parseTransform(transform),\n        new DisplayObject({}),\n      );\n      canvasPattern.setTransform({\n        a: mat[0],\n        b: mat[1],\n        c: mat[4],\n        d: mat[5],\n        e: mat[12],\n        f: mat[13],\n      });\n    }\n\n    context.fillStyle = canvasPattern;\n    context.fillRect(0, 0, width, height);\n  }\n\n  destroy() {\n    for (const key in this.textureCache) {\n      this.textureCache[key].destroy();\n    }\n    this.textureCache = {};\n  }\n}\n","import type { DataURLOptions, GlobalRuntime } from '@antv/g-lite';\nimport { Shape, AbstractRendererPlugin } from '@antv/g-lite';\nimport type { Texture, TextureDescriptor } from '@antv/g-device-api';\nimport { Renderable3D } from './components/Renderable3D';\nimport { LightPool } from './LightPool';\nimport { Mesh } from './Mesh';\nimport { MeshUpdater } from './MeshUpdater';\nimport { PickingIdGenerator } from './PickingIdGenerator';\nimport { PickingPlugin } from './PickingPlugin';\nimport { RenderHelper } from './render/RenderHelper';\nimport {\n  Batch,\n  BatchManager,\n  CircleRenderer,\n  ImageRenderer,\n  LineRenderer,\n  MeshRenderer,\n  PathRenderer,\n  RectRenderer,\n  TextRenderer,\n} from './renderer';\nimport { RenderGraphPlugin } from './RenderGraphPlugin';\nimport { TexturePool } from './TexturePool';\nimport {\n  DeviceRendererPluginOptions,\n  RendererParameters,\n  ToneMapping,\n} from './interfaces';\n\nexport * from './geometries';\nexport * from './interfaces';\nexport * from './lights';\nexport * from './materials';\nexport * from './drawcalls';\nexport * from './passes';\nexport * from './render';\nexport * from './utils';\nexport { Renderable3D, Batch, TexturePool, RenderGraphPlugin, Mesh };\n\nexport class Plugin extends AbstractRendererPlugin {\n  name = 'device-renderer';\n\n  parameters: RendererParameters = {\n    /**\n     * ToneMapping is a renderer-level parameter, it will affect all materials.\n     * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.toneMapping\n     */\n    toneMapping: ToneMapping.NONE,\n    toneMappingExposure: 1,\n  };\n\n  constructor(private options: Partial<DeviceRendererPluginOptions> = {}) {\n    super();\n  }\n\n  init(runtime: GlobalRuntime): void {\n    runtime.geometryUpdaterFactory[Shape.MESH] = new MeshUpdater();\n\n    const renderHelper = new RenderHelper(this.parameters);\n    const lightPool = new LightPool();\n    const texturePool = new TexturePool(this.context, runtime);\n    const pickingIdGenerator = new PickingIdGenerator();\n\n    const circleRenderer = new CircleRenderer();\n    const pathRenderer = new PathRenderer();\n    const rendererFactory: Record<Shape, Batch> = {\n      [Shape.CIRCLE]: circleRenderer,\n      [Shape.ELLIPSE]: circleRenderer,\n      [Shape.POLYLINE]: pathRenderer,\n      [Shape.PATH]: pathRenderer,\n      [Shape.POLYGON]: pathRenderer,\n      [Shape.RECT]: new RectRenderer(),\n      [Shape.IMAGE]: new ImageRenderer(),\n      [Shape.LINE]: new LineRenderer(),\n      [Shape.TEXT]: new TextRenderer(),\n      [Shape.MESH]: new MeshRenderer(),\n      [Shape.GROUP]: undefined,\n      [Shape.HTML]: undefined,\n    };\n\n    const batchManager = new BatchManager(\n      renderHelper,\n      rendererFactory,\n      texturePool,\n      lightPool,\n    );\n\n    const renderGraphPlugin = new RenderGraphPlugin(\n      renderHelper,\n      lightPool,\n      texturePool,\n      batchManager,\n      this.options,\n    );\n    this.addRenderingPlugin(renderGraphPlugin);\n    this.addRenderingPlugin(\n      new PickingPlugin(\n        renderHelper,\n        renderGraphPlugin,\n        pickingIdGenerator,\n        batchManager,\n      ),\n    );\n  }\n  destroy(runtime: GlobalRuntime): void {\n    delete runtime.geometryUpdaterFactory[Shape.MESH];\n  }\n\n  private getRenderGraphPlugin() {\n    return this.plugins[0] as RenderGraphPlugin;\n  }\n\n  getDevice() {\n    return this.getRenderGraphPlugin().getDevice();\n  }\n\n  getSwapChain() {\n    return this.getRenderGraphPlugin().getSwapChain();\n  }\n\n  loadTexture(\n    src: string | TexImageSource,\n    descriptor?: TextureDescriptor,\n    successCallback?: (t: Texture) => void,\n  ) {\n    return this.getRenderGraphPlugin().loadTexture(\n      src,\n      descriptor,\n      successCallback,\n    );\n  }\n\n  toDataURL(options: Partial<DataURLOptions>) {\n    return this.getRenderGraphPlugin().toDataURL(options);\n  }\n\n  setParameters(parameters: Partial<RendererParameters>) {\n    this.parameters = {\n      ...this.parameters,\n      ...parameters,\n    };\n  }\n}\n"]}