UV-based triangle clipping utilities for 2D rendering

用于2D渲染的UV三角形裁剪工具类

构造函数

方法

  • 参数

    • vertices: Float32Array

      Vertex position array (x, y pairs)

    • indices: Uint16Array

      Index array (groups of 3 for each triangle)

    • uvs: Float32Array

      UV coordinate array (u, v pairs)

    • uvRange: ArrayLike<number>

      Clipping range [minU, minV, width, height]

    • colors: Float32Array

      Vertex color array (r, g, b, a groups of 4)

    • reuseBuffer: boolean = true

      Whether to reuse internal buffers (default: true). When true, returns views of reusable buffers for better performance. When false, returns newly created arrays.

    返回 {
        colors: Float32Array;
        indices: Uint16Array;
        uvs: Float32Array;
        vertices: Float32Array;
    }

    Clipped data {vertices, indices, uvs, colors}

    • colors: Float32Array
    • indices: Uint16Array
    • uvs: Float32Array
    • vertices: Float32Array

    CPU-side UV vertex clipping. Clips triangles based on UV range and outputs clipped vertices, indices, UVs, and color data.

    CPU端UV顶点裁剪。根据UV范围裁剪三角形,输出裁剪后的顶点、索引、UV和颜色数据。

    When reuseBuffer=true (default): The returned TypedArrays are views of reusable internal buffers. The data is only valid until the next call to this method. If you need to persist the data, either set reuseBuffer=false or copy it yourself (e.g., new Float32Array(result.vertices)). Using reuseBuffer=true reduces GC pressure in high-frequency rendering loops.

    当reuseBuffer=true(默认)时:返回的TypedArray是可复用内部缓冲区的视图。 数据仅在下次调用此方法前有效。如果需要持久化数据, 可以设置reuseBuffer=false或自行复制(例如:new Float32Array(result.vertices))。 使用reuseBuffer=true可减少高频渲染循环中的GC压力。