From a5d066c5475b85a2b81bbcd3ef551f29e3bf205a Mon Sep 17 00:00:00 2001 From: SweetSophia Date: Fri, 4 Sep 2026 21:14:02 +0200 Subject: [PATCH 1/2] fix: skip invalid partIndex in clipping child walk getOffscreenChildDrawableIndexList forwards ownerIndices which may be NoParentIndex (-1). Indexing getPartsHierarchy()[-1] is undefined in JS and throws when reading childDrawObjects. Return without walking when partIndex is out of range. Valid indexes keep the existing child-drawable collection path. --- src/rendering/cubismclippingmanager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rendering/cubismclippingmanager.ts b/src/rendering/cubismclippingmanager.ts index b3f6f7f..1941e83 100644 --- a/src/rendering/cubismclippingmanager.ts +++ b/src/rendering/cubismclippingmanager.ts @@ -580,8 +580,12 @@ export abstract class CubismClippingManager< partIndex: number, childDrawableIndexList: Array ): void { - const childDrawObjects = - model.getPartsHierarchy()[partIndex].childDrawObjects; + const partsHierarchy = model.getPartsHierarchy(); + // NoParentIndex is -1; out-of-range indexes must not index the hierarchy. + if (partIndex < 0 || partIndex >= partsHierarchy.length) { + return; + } + const childDrawObjects = partsHierarchy[partIndex].childDrawObjects; childDrawableIndexList.push(...childDrawObjects.drawableIndices); for (let i = 0; i < childDrawObjects.offscreenIndices.length; ++i) { From e858cb5beb0cdd5b5d5c64de900b29158497143d Mon Sep 17 00:00:00 2001 From: SweetSophia Date: Fri, 4 Sep 2026 21:57:47 +0200 Subject: [PATCH 2/2] fix: reject non-integer partIndex in clipping child walk Sourcery: Number.isInteger so NaN/fractional indexes fail closed. Copilot: keep the new comment in Japanese to match this file. --- src/rendering/cubismclippingmanager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rendering/cubismclippingmanager.ts b/src/rendering/cubismclippingmanager.ts index 1941e83..8d05a11 100644 --- a/src/rendering/cubismclippingmanager.ts +++ b/src/rendering/cubismclippingmanager.ts @@ -581,8 +581,12 @@ export abstract class CubismClippingManager< childDrawableIndexList: Array ): void { const partsHierarchy = model.getPartsHierarchy(); - // NoParentIndex is -1; out-of-range indexes must not index the hierarchy. - if (partIndex < 0 || partIndex >= partsHierarchy.length) { + // NoParentIndex は -1。非整数や範囲外のインデックスでは階層を参照しない。 + if ( + !Number.isInteger(partIndex) || + partIndex < 0 || + partIndex >= partsHierarchy.length + ) { return; } const childDrawObjects = partsHierarchy[partIndex].childDrawObjects;