Skip to content

Commit

Permalink
Merge pull request #1462 from pixiv/fix/change-VRMSpringBoneManager-c…
Browse files Browse the repository at this point in the history
…ircular-dependency-error-to-warning

fix: change VRMSpringBoneManager circular dependency error to warning
  • Loading branch information
yue4u authored Aug 9, 2024
2 parents 2286485 + a2eda39 commit f7f0b85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/three-vrm-springbone/src/VRMSpringBoneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { traverseChildrenUntilConditionMet } from './utils/traverseChildrenUntil

export class VRMSpringBoneManager {
private _joints = new Set<VRMSpringBoneJoint>();
private _hasWarnedCircularDependency = false;

public get joints(): Set<VRMSpringBoneJoint> {
return this._joints;
}
Expand Down Expand Up @@ -132,7 +134,7 @@ export class VRMSpringBoneManager {
* Update a spring bone.
* If there are other spring bone that are dependant, it will try to update them recursively.
* It updates matrixWorld of all ancestors and myself.
* It might throw an error if there are circular dependencies.
* It might log an warning message if there are any circular dependencies.
*
* Intended to be used in {@link update} and {@link _processSpringBone} itself recursively.
*
Expand All @@ -153,7 +155,11 @@ export class VRMSpringBoneManager {
}

if (springBonesTried.has(springBone)) {
throw new Error('VRMSpringBoneManager: Circular dependency detected while updating springbones');
if (!this._hasWarnedCircularDependency) {
console.warn('VRMSpringBoneManager: Circular dependency detected while updating springbones');
this._hasWarnedCircularDependency = true;
}
return;
}
springBonesTried.add(springBone);

Expand Down

0 comments on commit f7f0b85

Please sign in to comment.