@starcried/starlite-vrm 0.1.0-alpha.3 → 0.1.0
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/BUNDLED_MOTIONS.json +63 -0
- package/BUNDLED_MOTIONS.md +41 -0
- package/README.en.md +65 -0
- package/README.md +14 -4
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/adjustments.d.ts +9 -0
- package/dist/adjustments.js +95 -0
- package/dist/builtin-motion-catalog.d.ts +16 -0
- package/dist/builtin-motion-catalog.js +10 -0
- package/dist/builtin-motion-data.d.ts +5 -0
- package/dist/builtin-motion-data.js +6 -0
- package/dist/builtin-motions.d.ts +3 -0
- package/dist/builtin-motions.js +10 -0
- package/dist/camera.d.ts +8 -0
- package/dist/camera.js +50 -0
- package/dist/config.cjs +41 -2
- package/dist/config.d.ts +2 -0
- package/dist/config.js +10 -3
- package/dist/environment-lighting.d.ts +12 -0
- package/dist/environment-lighting.js +82 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +220 -220
- package/dist/inspect.cjs +14 -1
- package/dist/inspect.js +3 -2
- package/dist/prepare.cjs +15 -4
- package/dist/prepare.js +4 -3
- package/dist/types.d.ts +3 -1
- package/package.json +6 -3
package/dist/inspect.cjs
CHANGED
|
@@ -28,6 +28,19 @@ __export(inspect_exports, {
|
|
|
28
28
|
parseGlb: () => parseGlb
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(inspect_exports);
|
|
31
|
+
|
|
32
|
+
// src/builtin-motion-catalog.ts
|
|
33
|
+
var BUILTIN_ANIMATIONS = [
|
|
34
|
+
{ name: "StarLiteIdle", durationMs: 6e3 },
|
|
35
|
+
{ name: "StarLiteCuriousPeek", durationMs: 2100 },
|
|
36
|
+
{ name: "StarLiteHappyWave", durationMs: 4600 },
|
|
37
|
+
{ name: "StarLiteSleepyStartle", durationMs: 5500 }
|
|
38
|
+
];
|
|
39
|
+
function isBuiltinAnimation(name) {
|
|
40
|
+
return BUILTIN_ANIMATIONS.some((animation) => animation.name === name);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/inspect.ts
|
|
31
44
|
var VrmInspectionError = class extends Error {
|
|
32
45
|
code;
|
|
33
46
|
details;
|
|
@@ -110,7 +123,7 @@ function embeddedAnimationCatalog(json) {
|
|
|
110
123
|
const names = /* @__PURE__ */ new Set();
|
|
111
124
|
return animations.map((animation, index) => {
|
|
112
125
|
const name = animation.name ?? "Animation_" + (index + 1);
|
|
113
|
-
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || name
|
|
126
|
+
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || isBuiltinAnimation(name) || names.has(name)) throw new VrmInspectionError("INVALID_ANIMATION", "invalid or duplicate embedded animation name; use unique names of at most 128 UTF-8 bytes, excluding reserved StarLite program motion names");
|
|
114
127
|
names.add(name);
|
|
115
128
|
let duration = 0;
|
|
116
129
|
for (const sampler of animation.samplers ?? []) {
|
package/dist/inspect.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isBuiltinAnimation } from "./builtin-motion-catalog.js";
|
|
1
2
|
/** Controlled diagnostic text only: never include input paths, URIs or JSON text. */
|
|
2
3
|
export class VrmInspectionError extends Error {
|
|
3
4
|
code;
|
|
@@ -108,8 +109,8 @@ export function embeddedAnimationCatalog(json) {
|
|
|
108
109
|
const names = new Set();
|
|
109
110
|
return animations.map((animation, index) => {
|
|
110
111
|
const name = animation.name ?? "Animation_" + (index + 1);
|
|
111
|
-
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || name
|
|
112
|
-
throw new VrmInspectionError("INVALID_ANIMATION", "invalid or duplicate embedded animation name; use unique names of at most 128 UTF-8 bytes, excluding
|
|
112
|
+
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || isBuiltinAnimation(name) || names.has(name))
|
|
113
|
+
throw new VrmInspectionError("INVALID_ANIMATION", "invalid or duplicate embedded animation name; use unique names of at most 128 UTF-8 bytes, excluding reserved StarLite program motion names");
|
|
113
114
|
names.add(name);
|
|
114
115
|
let duration = 0;
|
|
115
116
|
for (const sampler of animation.samplers ?? []) {
|
package/dist/prepare.cjs
CHANGED
|
@@ -29,6 +29,17 @@ var import_node_crypto = require("node:crypto");
|
|
|
29
29
|
var import_promises = require("node:fs/promises");
|
|
30
30
|
var import_node_path = require("node:path");
|
|
31
31
|
|
|
32
|
+
// src/builtin-motion-catalog.ts
|
|
33
|
+
var BUILTIN_ANIMATIONS = [
|
|
34
|
+
{ name: "StarLiteIdle", durationMs: 6e3 },
|
|
35
|
+
{ name: "StarLiteCuriousPeek", durationMs: 2100 },
|
|
36
|
+
{ name: "StarLiteHappyWave", durationMs: 4600 },
|
|
37
|
+
{ name: "StarLiteSleepyStartle", durationMs: 5500 }
|
|
38
|
+
];
|
|
39
|
+
function isBuiltinAnimation(name) {
|
|
40
|
+
return BUILTIN_ANIMATIONS.some((animation) => animation.name === name);
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
// src/inspect.ts
|
|
33
44
|
var VrmInspectionError = class extends Error {
|
|
34
45
|
code;
|
|
@@ -112,7 +123,7 @@ function embeddedAnimationCatalog(json) {
|
|
|
112
123
|
const names = /* @__PURE__ */ new Set();
|
|
113
124
|
return animations.map((animation, index) => {
|
|
114
125
|
const name = animation.name ?? "Animation_" + (index + 1);
|
|
115
|
-
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || name
|
|
126
|
+
if (typeof name !== "string" || !name.trim() || new TextEncoder().encode(name).length > 128 || /[\u0000-\u001f\u007f]/.test(name) || isBuiltinAnimation(name) || names.has(name)) throw new VrmInspectionError("INVALID_ANIMATION", "invalid or duplicate embedded animation name; use unique names of at most 128 UTF-8 bytes, excluding reserved StarLite program motion names");
|
|
116
127
|
names.add(name);
|
|
117
128
|
let duration = 0;
|
|
118
129
|
for (const sampler of animation.samplers ?? []) {
|
|
@@ -418,7 +429,7 @@ function animationNames(animations) {
|
|
|
418
429
|
if (!Array.isArray(animations) || animations.length > 64) throw new Error("invalid animation collection");
|
|
419
430
|
const names = /* @__PURE__ */ new Set();
|
|
420
431
|
for (const a of animations) {
|
|
421
|
-
if (!a || typeof a.name !== "string" || !a.name.trim() || a.name.length > 128 || names.has(a.name)) throw new Error("duplicate or invalid animation name");
|
|
432
|
+
if (!a || typeof a.name !== "string" || !a.name.trim() || a.name.length > 128 || names.has(a.name) || a.name !== "StarLiteIdle" && isBuiltinAnimation(a.name)) throw new Error("duplicate or invalid animation name");
|
|
422
433
|
names.add(a.name);
|
|
423
434
|
}
|
|
424
435
|
}
|
|
@@ -447,7 +458,7 @@ async function prepareModel(request) {
|
|
|
447
458
|
const data = await bounded(request.profile, 1024 * 1024);
|
|
448
459
|
const profile = JSON.parse(data.toString("utf8"));
|
|
449
460
|
validateCharacterProfile(profile);
|
|
450
|
-
profileNames(profile, [...animations, ...inspected.animations,
|
|
461
|
+
profileNames(profile, [...animations, ...inspected.animations, ...BUILTIN_ANIMATIONS]);
|
|
451
462
|
files.set("profile.json", data);
|
|
452
463
|
manifest.profile = record("profile.json", data);
|
|
453
464
|
}
|
|
@@ -512,7 +523,7 @@ function readPreparedBundleSync(directory) {
|
|
|
512
523
|
const bytes = load(manifest.profile, 1024 * 1024);
|
|
513
524
|
const profile = JSON.parse(bytes.toString("utf8"));
|
|
514
525
|
validateCharacterProfile(profile);
|
|
515
|
-
profileNames(profile, [...manifest.animations, ...inspected.animations,
|
|
526
|
+
profileNames(profile, [...manifest.animations, ...inspected.animations, ...BUILTIN_ANIMATIONS]);
|
|
516
527
|
}
|
|
517
528
|
return { manifest, files };
|
|
518
529
|
}
|
package/dist/prepare.js
CHANGED
|
@@ -4,6 +4,7 @@ import { lstat, mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/
|
|
|
4
4
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
5
|
import { inspectVrm, inspectVrma, MAX_MODEL_BYTES, MAX_ANIMATION_BYTES } from "./inspect.js";
|
|
6
6
|
import { validateCharacterProfile } from "./config.js";
|
|
7
|
+
import { BUILTIN_ANIMATIONS, isBuiltinAnimation } from "./builtin-motion-catalog.js";
|
|
7
8
|
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
8
9
|
const arrayBuffer = (bytes) => Uint8Array.from(bytes).buffer;
|
|
9
10
|
async function bounded(path, maximum) {
|
|
@@ -20,7 +21,7 @@ function animationNames(animations) {
|
|
|
20
21
|
throw new Error("invalid animation collection");
|
|
21
22
|
const names = new Set();
|
|
22
23
|
for (const a of animations) {
|
|
23
|
-
if (!a || typeof a.name !== "string" || !a.name.trim() || a.name.length > 128 || names.has(a.name))
|
|
24
|
+
if (!a || typeof a.name !== "string" || !a.name.trim() || a.name.length > 128 || names.has(a.name) || (a.name !== "StarLiteIdle" && isBuiltinAnimation(a.name)))
|
|
24
25
|
throw new Error("duplicate or invalid animation name");
|
|
25
26
|
names.add(a.name);
|
|
26
27
|
}
|
|
@@ -53,7 +54,7 @@ export async function prepareModel(request) {
|
|
|
53
54
|
const data = await bounded(request.profile, 1024 * 1024);
|
|
54
55
|
const profile = JSON.parse(data.toString("utf8"));
|
|
55
56
|
validateCharacterProfile(profile);
|
|
56
|
-
profileNames(profile, [...animations, ...inspected.animations,
|
|
57
|
+
profileNames(profile, [...animations, ...inspected.animations, ...BUILTIN_ANIMATIONS]);
|
|
57
58
|
files.set("profile.json", data);
|
|
58
59
|
manifest.profile = record("profile.json", data);
|
|
59
60
|
}
|
|
@@ -128,7 +129,7 @@ export function readPreparedBundleSync(directory) {
|
|
|
128
129
|
const bytes = load(manifest.profile, 1024 * 1024);
|
|
129
130
|
const profile = JSON.parse(bytes.toString("utf8"));
|
|
130
131
|
validateCharacterProfile(profile);
|
|
131
|
-
profileNames(profile, [...manifest.animations, ...inspected.animations,
|
|
132
|
+
profileNames(profile, [...manifest.animations, ...inspected.animations, ...BUILTIN_ANIMATIONS]);
|
|
132
133
|
}
|
|
133
134
|
return { manifest, files };
|
|
134
135
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DialogueSceneConfig, ModelController, PerformanceConfig } from "@starcried/starlite-core";
|
|
1
|
+
import type { EnvironmentLighting, StarLiteLocale, DialogueSceneConfig, ModelController, PerformanceConfig } from "@starcried/starlite-core";
|
|
2
2
|
export type { ModelController, AnimationPlaybackResult, AnimationPlaybackOptions } from "@starcried/starlite-core";
|
|
3
3
|
export interface VrmAnimationSource {
|
|
4
4
|
name: string;
|
|
@@ -49,9 +49,11 @@ export interface CharacterProfile {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
export interface VrmWidgetConfig {
|
|
52
|
+
locale?: StarLiteLocale;
|
|
52
53
|
backend?: "vrm";
|
|
53
54
|
adjustments?: ModelAdjustments;
|
|
54
55
|
performance?: PerformanceConfig;
|
|
56
|
+
environmentLighting?: EnvironmentLighting;
|
|
55
57
|
model: string;
|
|
56
58
|
fallback: string;
|
|
57
59
|
animations?: readonly VrmAnimationSource[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starcried/starlite-vrm",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "BSD-2-Clause",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"README.md",
|
|
10
10
|
"DEFAULT_IDLE.md",
|
|
11
11
|
"THIRD_PARTY_NOTICES.md",
|
|
12
|
-
"THIRD_PARTY_LICENSES.txt"
|
|
12
|
+
"THIRD_PARTY_LICENSES.txt",
|
|
13
|
+
"README.en.md",
|
|
14
|
+
"BUNDLED_MOTIONS.md",
|
|
15
|
+
"BUNDLED_MOTIONS.json"
|
|
13
16
|
],
|
|
14
17
|
"exports": {
|
|
15
18
|
".": {
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
"dependencies": {
|
|
41
44
|
"@pixiv/three-vrm": "3.5.5",
|
|
42
45
|
"@pixiv/three-vrm-animation": "3.5.5",
|
|
43
|
-
"@starcried/starlite-core": "0.1.0
|
|
46
|
+
"@starcried/starlite-core": "0.1.0",
|
|
44
47
|
"three": "0.186.0"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|