pixiv/three-vrm

Fallback logic for `VRMLookAtQuaternionProxy.name` doesn't execute

Opened this issue · 1 comments

I got tripped up when I tried adding a VRMLookAtQuaternionProxy to my VRM scene without manually setting its .name. I didn't see a warning message indicating what went wrong.

} else if (proxy.name == null) {
// if found but name is not set, set the name automatically
console.warn(
'createVRMAnimationClip: VRMLookAtQuaternionProxy is found but its name is not set. Setting the name automatically. To suppress this warning, set the name manually',
);
proxy.name = 'VRMLookAtQuaternionProxy';
}

The above logic attempts to set a default name if one is not manually set and warn the user to set it themselves.

However the logic here checks for a null name, when an unset name actually contains an empty string ''. This is reflected in the type of proxy.name which is string. This means the fallback logic and helpful warning message don't execute.

I suggest changing this to check for empty string instead of null.

That's true! Object3D constructor is already putting '' to its .name.
https://github.com/mrdoob/three.js/blob/beab9e845f9e5ae11d648f55b24a0e910b56a85a/src/core/Object3D.js#L43

Would else if (proxy.name === '') be appropriate? I'm 99% sure but want to make sure.