@doki-land/live2d-renderer 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -511,10 +511,56 @@ declare function calcClippedDrawableBounds(clippedIndices: readonly number[], by
511
511
  * drawable AABB into the atlas cell (higher mask texel density).
512
512
  */
513
513
  declare function fitClippingContexts(contexts: readonly LaidOutClippingContext[], byIndex: ReadonlyMap<number, MaskBoundsMeshRef>, margin?: number): LaidOutClippingContext[];
514
- /** Flatten layout to `[x, y, w, h]` for GPU uniforms. */
515
- declare function maskLayoutVec4(layout: MaskLayoutRect): Float32Array;
516
- /** Flatten channel flag to `[r, g, b, a]` for GPU uniforms. */
517
- declare function maskChannelVec4(flag: MaskChannelFlag): Float32Array;
514
+ /** Flatten layout to `[x, y, w, h]` for GPU uniforms. Reuses `into` when provided. */
515
+ declare function maskLayoutVec4(layout: MaskLayoutRect, into?: Float32Array): Float32Array;
516
+ /** Flatten channel flag to `[r, g, b, a]` for GPU uniforms. Reuses `into` when provided. */
517
+ declare function maskChannelVec4(flag: MaskChannelFlag, into?: Float32Array): Float32Array;
518
+
519
+ /**
520
+ * Resident clipping / mask atlas plan.
521
+ *
522
+ * Topology (maskIndices / invert / packing options) is compiled once; per frame
523
+ * only `modelBounds` is refreshed from current vertex positions.
524
+ */
525
+
526
+ /** Stable key for mask topology (ignores vertex positions / opacity). */
527
+ declare function clippingTopologyKey(drawables: readonly ClippingDrawableRef[]): string;
528
+ type ResidentContext = {
529
+ -readonly [K in keyof LaidOutClippingContext]: LaidOutClippingContext[K];
530
+ } & {
531
+ modelBounds: MaskLayoutRect;
532
+ };
533
+ /**
534
+ * Update `modelBounds` on resident contexts without reallocating the plan.
535
+ */
536
+ declare function fitClippingContextsInPlace(contexts: readonly ResidentContext[], byIndex: ReadonlyMap<number, MaskBoundsMeshRef>, margin?: number): void;
537
+ /**
538
+ * Caches atlas layout + mask/clipped sets while drawable mask topology is
539
+ * unchanged. Call {@link resolve} each frame; call {@link clear} on destroy.
540
+ */
541
+ declare class ResidentClippingPlan {
542
+ #private;
543
+ /**
544
+ * Returns a partition whose `contexts` array identity is stable across
545
+ * frames with the same topology. `modelBounds` are refreshed in place.
546
+ */
547
+ resolve(drawables: readonly ClippingDrawableRef[], options?: MaskAtlasOptions): ClippingPartition;
548
+ /** Convenience for full drawable meshes (GPU backends). */
549
+ resolveMeshes(drawables: readonly DrawableMesh[], options?: MaskAtlasOptions): ClippingPartition;
550
+ /** True when the last {@link resolve} reused the cached atlas layout. */
551
+ get hasPlan(): boolean;
552
+ /** Exposed for tests — context array identity while topology holds. */
553
+ get residentContexts(): readonly LaidOutClippingContext[];
554
+ clear(): void;
555
+ }
556
+
557
+ /**
558
+ * Pos/UV interleave with optional resident output buffer (GPU upload scratch).
559
+ */
560
+ /** Interleave `[x,y]` + `[u,v]` into `[x,y,u,v,…]`. Reuses `into` when large enough. */
561
+ declare function interleavePosUv(positions: Float32Array, uvs: Float32Array, into?: Float32Array): Float32Array;
562
+ /** Byte length of the live interleaved prefix (vertexCount * 16). */
563
+ declare function interleaveByteLength(positions: Float32Array): number;
518
564
 
519
565
  /** Shared untextured preview colors (Canvas2D / WebGL2 / WebGPU parity). */
520
566
  declare const PREVIEW_FILL: {
@@ -566,4 +612,4 @@ declare function compileSharedModelCompile(settings: ModelSettings, mocBytes: Ar
566
612
 
567
613
  declare const LIVE2D_RENDERER_VERSION: "0.0.0";
568
614
 
569
- export { BlendMode, CPU_PROGRAM_KIND, Canvas2DRendererImpl, type Canvas2DRendererOptions, type ClippingContext, type ClippingDrawableRef, type ClippingPartition, type CpuProgramFile, type CreateRendererOptions, type DecodedMoc2, type DecodedMoc3, type DrawableMesh, FULL_NDC_BOUNDS, LIVE2D_RENDERER_VERSION, type LaidOutClippingContext, MASK_CHANNEL_FLAGS, type MaskAtlasMode, type MaskAtlasOptions, type MaskChannelFlag, type MaskLayoutRect, Moc2Backend, Moc3Backend, Moc3DrawableFlag, type Moc3GlueDef, type Moc3GluePair, type ModelBackend, type ModelBackendOptions, type ModelDrawPass, PREVIEW_FILL, PREVIEW_STROKE, type ParameterBinding, type Renderer, type RendererKind, type SharedModelCompile, type TextureData, type WebGl2Renderer, WebGl2RendererImpl, type WebGl2RendererOptions, type WebGpuRenderer, WebGpuRendererImpl, type WebGpuRendererOptions, applyMoc3Glues, applyWebGl2BlendMode, buildClippingContexts, calcClippedDrawableBounds, calcVertexBounds, canvasCompositeForBlendMode, compileSharedModelCompile, createCanvas2DRenderer, createMoc2Backend, createMoc3Backend, createModelInstance, createQuadProgram, createRenderer, createWebGl2Renderer, createWebGpuRenderer, decodeMoc2, decodeMoc2ColorComposition, decodeMoc3, decodeMoc3DrawableFlags, detectMocBinaryFormat, evaluateFrame, expandBounds, fingerprintSnapshot, fitClippingContexts, isCanvas2DAvailable, isCpuProgramBytes, isWebGl2Available, isWebGpuAvailable, layoutMaskAtlas, layoutMaskAtlasRgba, layoutMaskAtlasUvGrid, loadMoc3Glues, maskChannelVec4, maskLayoutVec4, meanGlueSeamDistance, parseCpuProgram, partitionForClipping, selectModelBackend, serializeCpuProgram, setParameterValue, triangleEdgesToLineList, webGpuBlendState };
615
+ export { BlendMode, CPU_PROGRAM_KIND, Canvas2DRendererImpl, type Canvas2DRendererOptions, type ClippingContext, type ClippingDrawableRef, type ClippingPartition, type CpuProgramFile, type CreateRendererOptions, type DecodedMoc2, type DecodedMoc3, type DrawableMesh, FULL_NDC_BOUNDS, LIVE2D_RENDERER_VERSION, type LaidOutClippingContext, MASK_CHANNEL_FLAGS, type MaskAtlasMode, type MaskAtlasOptions, type MaskChannelFlag, type MaskLayoutRect, Moc2Backend, Moc3Backend, Moc3DrawableFlag, type Moc3GlueDef, type Moc3GluePair, type ModelBackend, type ModelBackendOptions, type ModelDrawPass, PREVIEW_FILL, PREVIEW_STROKE, type ParameterBinding, type Renderer, type RendererKind, ResidentClippingPlan, type SharedModelCompile, type TextureData, type WebGl2Renderer, WebGl2RendererImpl, type WebGl2RendererOptions, type WebGpuRenderer, WebGpuRendererImpl, type WebGpuRendererOptions, applyMoc3Glues, applyWebGl2BlendMode, buildClippingContexts, calcClippedDrawableBounds, calcVertexBounds, canvasCompositeForBlendMode, clippingTopologyKey, compileSharedModelCompile, createCanvas2DRenderer, createMoc2Backend, createMoc3Backend, createModelInstance, createQuadProgram, createRenderer, createWebGl2Renderer, createWebGpuRenderer, decodeMoc2, decodeMoc2ColorComposition, decodeMoc3, decodeMoc3DrawableFlags, detectMocBinaryFormat, evaluateFrame, expandBounds, fingerprintSnapshot, fitClippingContexts, fitClippingContextsInPlace, interleaveByteLength, interleavePosUv, isCanvas2DAvailable, isCpuProgramBytes, isWebGl2Available, isWebGpuAvailable, layoutMaskAtlas, layoutMaskAtlasRgba, layoutMaskAtlasUvGrid, loadMoc3Glues, maskChannelVec4, maskLayoutVec4, meanGlueSeamDistance, parseCpuProgram, partitionForClipping, selectModelBackend, serializeCpuProgram, setParameterValue, triangleEdgesToLineList, webGpuBlendState };