@starcried/starlite-vrm 0.1.0-alpha.1 → 0.1.0-alpha.2
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/README.md +1 -1
- package/dist/character.d.ts +1 -1
- package/dist/character.js +16 -5
- package/dist/index.js +24 -24
- package/dist/inspect.cjs +18 -10
- package/dist/inspect.js +29 -13
- package/dist/prepare.cjs +18 -10
- package/package.json +2 -2
package/dist/inspect.cjs
CHANGED
|
@@ -109,17 +109,25 @@ function inspectVrm(bytes) {
|
|
|
109
109
|
if (!Number.isSafeInteger(node) || !json.nodes?.[node] || used.has(node)) throw new Error("invalid required humanoid bone");
|
|
110
110
|
used.add(node);
|
|
111
111
|
}
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
const blinkNames = v0 ? ["blink", "blink_l", "blink_r"] : ["blink", "blinkLeft", "blinkRight"];
|
|
113
|
+
const groups = v0?.blendShapeMaster?.blendShapeGroups;
|
|
114
|
+
if (groups !== void 0 && !Array.isArray(groups)) throw new Error("invalid VRM blink expressions");
|
|
115
|
+
const blinkPresets = v0 ? (groups ?? []).filter((item) => blinkNames.includes(item?.presetName)) : blinkNames.flatMap((name2) => {
|
|
116
|
+
const expression = json.extensions.VRMC_vrm.expressions?.preset?.[name2];
|
|
117
|
+
return expression === void 0 ? [] : [expression];
|
|
118
|
+
});
|
|
119
|
+
for (const expression of blinkPresets) {
|
|
120
|
+
if (!expression || typeof expression !== "object" || Array.isArray(expression)) throw new Error("invalid VRM blink expression");
|
|
121
|
+
const binds = v0 ? expression.binds : expression.morphTargetBinds;
|
|
122
|
+
if (binds === void 0) continue;
|
|
123
|
+
if (!Array.isArray(binds)) throw new Error("invalid VRM blink bindings");
|
|
124
|
+
for (const bind of binds) {
|
|
125
|
+
const mesh = v0 ? bind?.mesh : json.nodes?.[bind?.node]?.mesh;
|
|
117
126
|
const primitives = json.meshes?.[mesh]?.primitives;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
throw new Error("VRM needs usable blink morph bindings, or both left and right blink presets");
|
|
127
|
+
if (!bind || !Number.isSafeInteger(mesh) || mesh < 0 || !v0 && (!Number.isSafeInteger(bind.node) || bind.node < 0) || !Number.isSafeInteger(bind.index) || bind.index < 0 || !Number.isFinite(bind.weight) || bind.weight < 0 || bind.weight > (v0 ? 100 : 1) || !Array.isArray(primitives) || !primitives.some((primitive) => primitive.targets?.[bind.index] !== void 0)) {
|
|
128
|
+
throw new Error("invalid VRM blink morph binding");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
123
131
|
}
|
|
124
132
|
const meta = (v0 ?? json.extensions.VRMC_vrm).meta ?? {};
|
|
125
133
|
const name = v0 ? meta.title : meta.name;
|
package/dist/inspect.js
CHANGED
|
@@ -107,20 +107,36 @@ export function inspectVrm(bytes) {
|
|
|
107
107
|
throw new Error("invalid required humanoid bone");
|
|
108
108
|
used.add(node);
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
// Blink is an optional capability. Declared bindings must still be valid;
|
|
111
|
+
// missing, empty or zero-weight presets simply provide no automatic blink.
|
|
112
|
+
const blinkNames = v0 ? ["blink", "blink_l", "blink_r"] : ["blink", "blinkLeft", "blinkRight"];
|
|
113
|
+
const groups = v0?.blendShapeMaster?.blendShapeGroups;
|
|
114
|
+
if (groups !== undefined && !Array.isArray(groups))
|
|
115
|
+
throw new Error("invalid VRM blink expressions");
|
|
116
|
+
const blinkPresets = v0 ? (groups ?? []).filter((item) => blinkNames.includes(item?.presetName))
|
|
117
|
+
: blinkNames.flatMap(name => {
|
|
118
|
+
const expression = json.extensions.VRMC_vrm.expressions?.preset?.[name];
|
|
119
|
+
return expression === undefined ? [] : [expression];
|
|
120
120
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
for (const expression of blinkPresets) {
|
|
122
|
+
if (!expression || typeof expression !== "object" || Array.isArray(expression))
|
|
123
|
+
throw new Error("invalid VRM blink expression");
|
|
124
|
+
const binds = v0 ? expression.binds : expression.morphTargetBinds;
|
|
125
|
+
if (binds === undefined)
|
|
126
|
+
continue;
|
|
127
|
+
if (!Array.isArray(binds))
|
|
128
|
+
throw new Error("invalid VRM blink bindings");
|
|
129
|
+
for (const bind of binds) {
|
|
130
|
+
const mesh = v0 ? bind?.mesh : json.nodes?.[bind?.node]?.mesh;
|
|
131
|
+
const primitives = json.meshes?.[mesh]?.primitives;
|
|
132
|
+
if (!bind || !Number.isSafeInteger(mesh) || mesh < 0
|
|
133
|
+
|| (!v0 && (!Number.isSafeInteger(bind.node) || bind.node < 0))
|
|
134
|
+
|| !Number.isSafeInteger(bind.index) || bind.index < 0
|
|
135
|
+
|| !Number.isFinite(bind.weight) || bind.weight < 0 || bind.weight > (v0 ? 100 : 1)
|
|
136
|
+
|| !Array.isArray(primitives) || !primitives.some((primitive) => primitive.targets?.[bind.index] !== undefined)) {
|
|
137
|
+
throw new Error("invalid VRM blink morph binding");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
124
140
|
}
|
|
125
141
|
const meta = (v0 ?? json.extensions.VRMC_vrm).meta ?? {};
|
|
126
142
|
const name = v0 ? meta.title : meta.name;
|
package/dist/prepare.cjs
CHANGED
|
@@ -112,17 +112,25 @@ function inspectVrm(bytes) {
|
|
|
112
112
|
if (!Number.isSafeInteger(node) || !json.nodes?.[node] || used.has(node)) throw new Error("invalid required humanoid bone");
|
|
113
113
|
used.add(node);
|
|
114
114
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
const blinkNames = v0 ? ["blink", "blink_l", "blink_r"] : ["blink", "blinkLeft", "blinkRight"];
|
|
116
|
+
const groups = v0?.blendShapeMaster?.blendShapeGroups;
|
|
117
|
+
if (groups !== void 0 && !Array.isArray(groups)) throw new Error("invalid VRM blink expressions");
|
|
118
|
+
const blinkPresets = v0 ? (groups ?? []).filter((item) => blinkNames.includes(item?.presetName)) : blinkNames.flatMap((name2) => {
|
|
119
|
+
const expression = json.extensions.VRMC_vrm.expressions?.preset?.[name2];
|
|
120
|
+
return expression === void 0 ? [] : [expression];
|
|
121
|
+
});
|
|
122
|
+
for (const expression of blinkPresets) {
|
|
123
|
+
if (!expression || typeof expression !== "object" || Array.isArray(expression)) throw new Error("invalid VRM blink expression");
|
|
124
|
+
const binds = v0 ? expression.binds : expression.morphTargetBinds;
|
|
125
|
+
if (binds === void 0) continue;
|
|
126
|
+
if (!Array.isArray(binds)) throw new Error("invalid VRM blink bindings");
|
|
127
|
+
for (const bind of binds) {
|
|
128
|
+
const mesh = v0 ? bind?.mesh : json.nodes?.[bind?.node]?.mesh;
|
|
120
129
|
const primitives = json.meshes?.[mesh]?.primitives;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
throw new Error("VRM needs usable blink morph bindings, or both left and right blink presets");
|
|
130
|
+
if (!bind || !Number.isSafeInteger(mesh) || mesh < 0 || !v0 && (!Number.isSafeInteger(bind.node) || bind.node < 0) || !Number.isSafeInteger(bind.index) || bind.index < 0 || !Number.isFinite(bind.weight) || bind.weight < 0 || bind.weight > (v0 ? 100 : 1) || !Array.isArray(primitives) || !primitives.some((primitive) => primitive.targets?.[bind.index] !== void 0)) {
|
|
131
|
+
throw new Error("invalid VRM blink morph binding");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
126
134
|
}
|
|
127
135
|
const meta = (v0 ?? json.extensions.VRMC_vrm).meta ?? {};
|
|
128
136
|
const name = v0 ? meta.title : meta.name;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starcried/starlite-vrm",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "BSD-2-Clause",
|
|
6
6
|
"files": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@pixiv/three-vrm": "3.5.5",
|
|
42
42
|
"@pixiv/three-vrm-animation": "3.5.5",
|
|
43
|
-
"@starcried/starlite-core": "0.1.0-alpha.
|
|
43
|
+
"@starcried/starlite-core": "0.1.0-alpha.2",
|
|
44
44
|
"three": "0.186.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|