@flighthq/skeleton3d 0.5.1-next.3302.76ece6b → 0.5.1-next.4304.322dc96
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
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/skeleton3d`. The `@f
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/skeleton3d@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/skeleton3d@0.5.1-next.4304.322dc96](https://github.com/flighthq/flight/tree/322dc963fc5a404a31bc0cc612e906de504ea024/packages/skeleton3d)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/322dc963fc5a404a31bc0cc612e906de504ea024/LICENSE.md)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
1
2
|
export declare function areSkeleton3DGuardsEnabled(): boolean;
|
|
2
3
|
export declare function disableSkeleton3DGuards(): void;
|
|
3
|
-
export declare function enableSkeleton3DGuards(): void;
|
|
4
|
+
export declare function enableSkeleton3DGuards(logState: LogState, clock: () => number): void;
|
|
4
5
|
//# sourceMappingURL=enableSkeleton3DGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableSkeleton3DGuards.d.ts","sourceRoot":"","sources":["../src/enableSkeleton3DGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableSkeleton3DGuards.d.ts","sourceRoot":"","sources":["../src/enableSkeleton3DGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvD,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAKD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,MAAM,GAAG,IAAI,CAKpF"}
|
|
@@ -11,15 +11,15 @@ export function disableSkeleton3DGuards() {
|
|
|
11
11
|
// Installs opt-in diagnostics for skeleton operations that substitute a value rather than compute one.
|
|
12
12
|
// The core modules stay message-free, so an application that omits this one sheds both the text and
|
|
13
13
|
// @flighthq/log.
|
|
14
|
-
export function enableSkeleton3DGuards() {
|
|
15
|
-
setSkeleton3DBindPoseGuard(warnOnDegenerateSkeleton3DBindPose);
|
|
14
|
+
export function enableSkeleton3DGuards(logState, clock) {
|
|
15
|
+
setSkeleton3DBindPoseGuard((skeleton, jointIndex) => warnOnDegenerateSkeleton3DBindPose(logState, clock(), skeleton, jointIndex));
|
|
16
16
|
skeleton3DGuardsEnabled = true;
|
|
17
17
|
}
|
|
18
18
|
// The substituted identity is a deliberate recovery, not a computed result: that one joint captures no
|
|
19
19
|
// bind pose and renders undeformed while the rest of the rig works. Nothing else reports it, and the
|
|
20
20
|
// symptom — one limb that will not deform — points at the mesh rather than at the joint's scale.
|
|
21
|
-
function warnOnDegenerateSkeleton3DBindPose(skeleton, jointIndex) {
|
|
22
|
-
logOnce(`skeleton3d:degenerate-bind-pose:${jointIndex}`, LogLevel.Warn, {
|
|
21
|
+
function warnOnDegenerateSkeleton3DBindPose(logState, nowMs, skeleton, jointIndex) {
|
|
22
|
+
logOnce(logState, nowMs, `skeleton3d:degenerate-bind-pose:${jointIndex}`, LogLevel.Warn, {
|
|
23
23
|
joint: skeleton.joints[jointIndex]?.name ?? '<unnamed>',
|
|
24
24
|
jointIndex,
|
|
25
25
|
message: 'setSkeleton3DBindPose: a joint has no invertible world matrix, so its inverse-bind entry was set to identity and that joint will not deform — a zero scale on the joint or an ancestor is the usual cause, and an imported rig can carry one.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableSkeleton3DGuards.js","sourceRoot":"","sources":["../src/enableSkeleton3DGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableSkeleton3DGuards.js","sourceRoot":"","sources":["../src/enableSkeleton3DGuards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,UAAU,0BAA0B;IACxC,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACjC,uBAAuB,GAAG,KAAK,CAAC;AAClC,CAAC;AAED,uGAAuG;AACvG,oGAAoG;AACpG,iBAAiB;AACjB,MAAM,UAAU,sBAAsB,CAAC,QAAkB,EAAE,KAAmB;IAC5E,0BAA0B,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,CAClD,kCAAkC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAC5E,CAAC;IACF,uBAAuB,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,uGAAuG;AACvG,qGAAqG;AACrG,iGAAiG;AACjG,SAAS,kCAAkC,CACzC,QAAkB,EAClB,KAAa,EACb,QAA8B,EAC9B,UAAkB;IAElB,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,mCAAmC,UAAU,EAAE,EAAE,QAAQ,CAAC,IAAI,EAAE;QACvF,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,IAAI,WAAW;QACvD,UAAU;QACV,OAAO,EACL,+OAA+O;KAClP,CAAC,CAAC;AACL,CAAC;AAED,IAAI,uBAAuB,GAAG,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/skeleton3d",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.4304.322dc96",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
43
|
-
"@flighthq/log": "0.5.1-next.
|
|
44
|
-
"@flighthq/meshgeometry": "0.5.1-next.
|
|
45
|
-
"@flighthq/node": "0.5.1-next.
|
|
46
|
-
"@flighthq/scene3d": "0.5.1-next.
|
|
47
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.4304.322dc96",
|
|
42
|
+
"@flighthq/geometry": "0.5.1-next.4304.322dc96",
|
|
43
|
+
"@flighthq/log": "0.5.1-next.4304.322dc96",
|
|
44
|
+
"@flighthq/meshgeometry": "0.5.1-next.4304.322dc96",
|
|
45
|
+
"@flighthq/node": "0.5.1-next.4304.322dc96",
|
|
46
|
+
"@flighthq/scene3d": "0.5.1-next.4304.322dc96",
|
|
47
|
+
"@flighthq/types": "0.5.1-next.4304.322dc96"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"typescript": "^5.3.0"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { setVector3 } from '@flighthq/geometry/contract';
|
|
2
|
-
import {
|
|
2
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
3
|
+
import { createLogState, setLogSink } from '@flighthq/log/contract';
|
|
3
4
|
import { invalidateNodeLocalTransform } from '@flighthq/node/contract';
|
|
4
5
|
import { createNode3D } from '@flighthq/scene3d/contract';
|
|
5
6
|
import type { LogEntry } from '@flighthq/types/contract';
|
|
@@ -12,12 +13,16 @@ import {
|
|
|
12
13
|
} from './enableSkeleton3DGuards.ts';
|
|
13
14
|
import { createSkeleton3D, setSkeleton3DBindPose } from './skeleton3d.ts';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
let logState: LogState;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
logState = createLogState();
|
|
20
|
+
});
|
|
16
21
|
|
|
17
22
|
describe('areSkeleton3DGuardsEnabled', () => {
|
|
18
23
|
test('reports whether the guards are installed', () => {
|
|
19
24
|
expect(areSkeleton3DGuardsEnabled()).toBe(false);
|
|
20
|
-
enableSkeleton3DGuards();
|
|
25
|
+
enableSkeleton3DGuards(logState, () => 0);
|
|
21
26
|
expect(areSkeleton3DGuardsEnabled()).toBe(true);
|
|
22
27
|
disableSkeleton3DGuards();
|
|
23
28
|
expect(areSkeleton3DGuardsEnabled()).toBe(false);
|
|
@@ -26,17 +31,17 @@ describe('areSkeleton3DGuardsEnabled', () => {
|
|
|
26
31
|
|
|
27
32
|
describe('disableSkeleton3DGuards', () => {
|
|
28
33
|
test('leaves the core silent again once removed', () => {
|
|
29
|
-
enableSkeleton3DGuards();
|
|
34
|
+
enableSkeleton3DGuards(logState, () => 0);
|
|
30
35
|
disableSkeleton3DGuards();
|
|
31
36
|
expect(captureLog(() => setSkeleton3DBindPose(collapsedSkeleton()))).toHaveLength(0);
|
|
32
37
|
});
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
describe('enableSkeleton3DGuards', () => {
|
|
36
|
-
// `logOnce` keys on the joint index
|
|
37
|
-
//
|
|
41
|
+
// `logOnce` keys on the joint index for the LogState's lifetime; beforeEach hands every test a fresh
|
|
42
|
+
// state, so no test is deduplicated away by another.
|
|
38
43
|
test('warns, naming the joint, when a bind pose cannot be captured', () => {
|
|
39
|
-
enableSkeleton3DGuards();
|
|
44
|
+
enableSkeleton3DGuards(logState, () => 0);
|
|
40
45
|
const entries = captureLog(() => setSkeleton3DBindPose(collapsedSkeleton()));
|
|
41
46
|
expect(entries).toHaveLength(1);
|
|
42
47
|
expect(entries[0].data).toMatchObject({ jointIndex: 0 });
|
|
@@ -44,7 +49,7 @@ describe('enableSkeleton3DGuards', () => {
|
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
test('stays silent for a rig whose joints all invert', () => {
|
|
47
|
-
enableSkeleton3DGuards();
|
|
52
|
+
enableSkeleton3DGuards(logState, () => 0);
|
|
48
53
|
expect(captureLog(() => setSkeleton3DBindPose(createSkeleton3D([createNode3D()])))).toHaveLength(0);
|
|
49
54
|
});
|
|
50
55
|
});
|
|
@@ -55,11 +60,11 @@ afterEach(() => {
|
|
|
55
60
|
|
|
56
61
|
function captureLog(run: () => void): LogEntry[] {
|
|
57
62
|
const entries: LogEntry[] = [];
|
|
58
|
-
setLogSink((entry) => entries.push(entry));
|
|
63
|
+
setLogSink(logState, (entry) => entries.push(entry));
|
|
59
64
|
try {
|
|
60
65
|
run();
|
|
61
66
|
} finally {
|
|
62
|
-
setLogSink(null);
|
|
67
|
+
setLogSink(logState, null);
|
|
63
68
|
}
|
|
64
69
|
return entries;
|
|
65
70
|
}
|