@babylonjs/loaders 9.26.0 → 9.26.1
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/FBX/fbxConstraintBehavior.d.ts +188 -0
- package/FBX/fbxConstraintBehavior.js +532 -0
- package/FBX/fbxConstraintBehavior.js.map +1 -0
- package/FBX/fbxFileLoader.pure.d.ts +175 -6
- package/FBX/fbxFileLoader.pure.js +1521 -286
- package/FBX/fbxFileLoader.pure.js.map +1 -1
- package/FBX/index.d.ts +4 -1
- package/FBX/index.js +1 -0
- package/FBX/index.js.map +1 -1
- package/FBX/interpreter/animation.d.ts +73 -33
- package/FBX/interpreter/animation.js +620 -223
- package/FBX/interpreter/animation.js.map +1 -1
- package/FBX/interpreter/animationCurve.d.ts +91 -0
- package/FBX/interpreter/animationCurve.js +623 -0
- package/FBX/interpreter/animationCurve.js.map +1 -0
- package/FBX/interpreter/blendShapes.js +9 -18
- package/FBX/interpreter/blendShapes.js.map +1 -1
- package/FBX/interpreter/connections.d.ts +1 -1
- package/FBX/interpreter/connections.js +173 -34
- package/FBX/interpreter/connections.js.map +1 -1
- package/FBX/interpreter/constraints.d.ts +68 -0
- package/FBX/interpreter/constraints.js +143 -0
- package/FBX/interpreter/constraints.js.map +1 -0
- package/FBX/interpreter/fbxInterpreter.d.ts +89 -4
- package/FBX/interpreter/fbxInterpreter.js +474 -122
- package/FBX/interpreter/fbxInterpreter.js.map +1 -1
- package/FBX/interpreter/geometry.d.ts +1 -1
- package/FBX/interpreter/geometry.js +150 -92
- package/FBX/interpreter/geometry.js.map +1 -1
- package/FBX/interpreter/legacyDocument.d.ts +11 -0
- package/FBX/interpreter/legacyDocument.js +425 -0
- package/FBX/interpreter/legacyDocument.js.map +1 -0
- package/FBX/interpreter/materialModel.d.ts +71 -0
- package/FBX/interpreter/materialModel.js +622 -0
- package/FBX/interpreter/materialModel.js.map +1 -0
- package/FBX/interpreter/materials.d.ts +13 -1
- package/FBX/interpreter/materials.js +88 -5
- package/FBX/interpreter/materials.js.map +1 -1
- package/FBX/interpreter/nodeTransform.d.ts +32 -0
- package/FBX/interpreter/nodeTransform.js +54 -0
- package/FBX/interpreter/nodeTransform.js.map +1 -0
- package/FBX/interpreter/nurbs.d.ts +99 -0
- package/FBX/interpreter/nurbs.js +627 -0
- package/FBX/interpreter/nurbs.js.map +1 -0
- package/FBX/interpreter/propertyTemplates.d.ts +23 -0
- package/FBX/interpreter/propertyTemplates.js +109 -2
- package/FBX/interpreter/propertyTemplates.js.map +1 -1
- package/FBX/interpreter/rig.js +16 -0
- package/FBX/interpreter/rig.js.map +1 -1
- package/FBX/interpreter/sceneDiagnostics.js +28 -3
- package/FBX/interpreter/sceneDiagnostics.js.map +1 -1
- package/FBX/interpreter/skeleton.d.ts +4 -18
- package/FBX/interpreter/skeleton.js +16 -94
- package/FBX/interpreter/skeleton.js.map +1 -1
- package/FBX/parsers/fbxAsciiParser.js +119 -9
- package/FBX/parsers/fbxAsciiParser.js.map +1 -1
- package/FBX/parsers/fbxBinaryParser.js +74 -22
- package/FBX/parsers/fbxBinaryParser.js.map +1 -1
- package/FBX/pure.d.ts +1 -0
- package/FBX/pure.js +1 -0
- package/FBX/pure.js.map +1 -1
- package/FBX/types/fbxTypes.d.ts +18 -2
- package/FBX/types/fbxTypes.js +40 -12
- package/FBX/types/fbxTypes.js.map +1 -1
- package/USD/usdCommandProtocol.d.ts +20 -4
- package/USD/usdCommandProtocol.js +25 -3
- package/USD/usdCommandProtocol.js.map +1 -1
- package/USD/usdFileLoader.pure.js +2 -0
- package/USD/usdFileLoader.pure.js.map +1 -1
- package/USD/usdSceneMaterializer.js +430 -92
- package/USD/usdSceneMaterializer.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime evaluation of FBX constraints. An `FBXConstraintBehavior` is attached to each constrained node; all
|
|
3
|
+
* behaviors of a scene register with one `FBXConstraintSolver`, which solves them in dependency order (a constraint
|
|
4
|
+
* whose target or parent is driven by another constraint is solved after it) and reuses scratch objects, so solving
|
|
5
|
+
* allocates nothing per frame.
|
|
6
|
+
*
|
|
7
|
+
* The solver brackets the scene's animation phase: before animations run it writes each node's unconstrained
|
|
8
|
+
* transform back, after they ran it captures the result as the new unconstrained transform and solves. A partial
|
|
9
|
+
* weight therefore always blends from what animation (or nothing) produced this frame, never from the previous
|
|
10
|
+
* solve's output, so a 50% weight stays a 50% blend instead of converging on the target.
|
|
11
|
+
*
|
|
12
|
+
* All maths happen in FBX space, i.e. relative to the loader's root node, so the handedness conversion applied
|
|
13
|
+
* at the root never enters the solve.
|
|
14
|
+
*/
|
|
15
|
+
import { type Behavior } from "@babylonjs/core/Behaviors/behavior.js";
|
|
16
|
+
import { type Nullable } from "@babylonjs/core/types.js";
|
|
17
|
+
import { type Node } from "@babylonjs/core/node.js";
|
|
18
|
+
import { type Scene } from "@babylonjs/core/scene.js";
|
|
19
|
+
import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.pure.js";
|
|
20
|
+
import { type TransformNode } from "@babylonjs/core/Meshes/transformNode.pure.js";
|
|
21
|
+
import { type FBXConstraintData } from "./interpreter/constraints.js";
|
|
22
|
+
/** Resolved target of a constraint. */
|
|
23
|
+
export interface FBXConstraintBehaviorTarget {
|
|
24
|
+
/** Target node */
|
|
25
|
+
node: TransformNode;
|
|
26
|
+
/** Normalized target weight (0..1) */
|
|
27
|
+
weight: number;
|
|
28
|
+
/** Offset matrix for parent constraints (in the target's space) */
|
|
29
|
+
offset: Matrix;
|
|
30
|
+
}
|
|
31
|
+
/** Options resolved by the loader when creating the behavior. */
|
|
32
|
+
export interface FBXConstraintBehaviorOptions {
|
|
33
|
+
/** Root of the loaded asset; world matrices are made relative to it */
|
|
34
|
+
root: TransformNode;
|
|
35
|
+
/** Resolved targets of the constraint, in file order */
|
|
36
|
+
targets: FBXConstraintBehaviorTarget[];
|
|
37
|
+
/** World up object of an aim constraint, when it has one */
|
|
38
|
+
upNode: Nullable<TransformNode>;
|
|
39
|
+
/** Scene up axis in FBX space */
|
|
40
|
+
sceneUp: Vector3;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Solves every FBX constraint of a scene once per frame, in dependency order, from the scene's animation phase
|
|
44
|
+
* observers (`beginFrame` before animations, `solve` after them). Created on demand by the first
|
|
45
|
+
* `FBXConstraintBehavior` attached in the scene and removed with the last one.
|
|
46
|
+
*/
|
|
47
|
+
export declare class FBXConstraintSolver {
|
|
48
|
+
private readonly _scene;
|
|
49
|
+
private readonly _behaviors;
|
|
50
|
+
private _ordered;
|
|
51
|
+
private _cyclic;
|
|
52
|
+
private _dirty;
|
|
53
|
+
private _beforeAnimations;
|
|
54
|
+
private _afterAnimations;
|
|
55
|
+
private constructor();
|
|
56
|
+
/**
|
|
57
|
+
* Solver of a scene, if any constraint behavior is attached in it.
|
|
58
|
+
* @param scene - Scene to look up
|
|
59
|
+
* @returns The solver, or undefined
|
|
60
|
+
*/
|
|
61
|
+
static Get(scene: Scene): FBXConstraintSolver | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Solver of a scene, created when missing.
|
|
64
|
+
* @param scene - Scene to look up
|
|
65
|
+
* @returns The solver
|
|
66
|
+
*/
|
|
67
|
+
static GetOrCreate(scene: Scene): FBXConstraintSolver;
|
|
68
|
+
/** Registered behaviors in solve order (a target's constraint before the constraints that read it). */
|
|
69
|
+
get constraints(): readonly FBXConstraintBehavior[];
|
|
70
|
+
/**
|
|
71
|
+
* Behaviors that take part in a dependency cycle (A targets B while B targets A). They are solved after all
|
|
72
|
+
* acyclic constraints, in registration order, so each sees the other's result from the previous solve.
|
|
73
|
+
*/
|
|
74
|
+
get cyclicConstraints(): readonly FBXConstraintBehavior[];
|
|
75
|
+
/**
|
|
76
|
+
* Adds a behavior to the solve set.
|
|
77
|
+
* @param behavior - Behavior to add
|
|
78
|
+
*/
|
|
79
|
+
register(behavior: FBXConstraintBehavior): void;
|
|
80
|
+
/**
|
|
81
|
+
* Removes a behavior from the solve set; the solver disposes itself with the last one.
|
|
82
|
+
* @param behavior - Behavior to remove
|
|
83
|
+
*/
|
|
84
|
+
unregister(behavior: FBXConstraintBehavior): void;
|
|
85
|
+
/** Marks the solve order stale, e.g. after re-parenting a constrained node. */
|
|
86
|
+
invalidateOrder(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Start of a frame, before animations run: every constrained node gets its unconstrained transform back, so
|
|
89
|
+
* that animation either overwrites it or leaves it untouched.
|
|
90
|
+
*/
|
|
91
|
+
beginFrame(): void;
|
|
92
|
+
/**
|
|
93
|
+
* End of the animation phase: takes every constrained node's current transform as its unconstrained value,
|
|
94
|
+
* then solves every registered constraint once, in dependency order.
|
|
95
|
+
*/
|
|
96
|
+
solve(): void;
|
|
97
|
+
private _ensureOrder;
|
|
98
|
+
private static _IsAncestorOrSelf;
|
|
99
|
+
}
|
|
100
|
+
/** Babylon behavior evaluating an FBX aim, parent, position, rotation or scale constraint. */
|
|
101
|
+
export declare class FBXConstraintBehavior implements Behavior<TransformNode> {
|
|
102
|
+
/** Constraint data extracted from the file */
|
|
103
|
+
readonly constraint: FBXConstraintData;
|
|
104
|
+
private readonly _options;
|
|
105
|
+
/** Behavior name (`fbxConstraint:` followed by the constraint name) */
|
|
106
|
+
readonly name: string;
|
|
107
|
+
/** Node the behavior is attached to */
|
|
108
|
+
attachedNode: Nullable<TransformNode>;
|
|
109
|
+
/** Set to false to pause the constraint without detaching it */
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
private readonly _offsetTranslation;
|
|
112
|
+
private readonly _offsetRotation;
|
|
113
|
+
private readonly _offsetScale;
|
|
114
|
+
private readonly _localBasisTransposed;
|
|
115
|
+
/** Unconstrained transform of the current frame (what animation produced), blended towards the constraint's result. */
|
|
116
|
+
private readonly _base;
|
|
117
|
+
private _hasBase;
|
|
118
|
+
/**
|
|
119
|
+
* Creates the behavior.
|
|
120
|
+
* @param constraint - Constraint data extracted from the file
|
|
121
|
+
* @param _options - Resolved targets and scene information
|
|
122
|
+
*/
|
|
123
|
+
constructor(
|
|
124
|
+
/** Constraint data extracted from the file */
|
|
125
|
+
constraint: FBXConstraintData, _options: FBXConstraintBehaviorOptions);
|
|
126
|
+
/** Nothing to initialize */
|
|
127
|
+
init(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Registers the behavior with the scene's solver, takes the node's current transform as the unconstrained
|
|
130
|
+
* value and solves the constraint once.
|
|
131
|
+
* @param target - Node to constrain
|
|
132
|
+
*/
|
|
133
|
+
attach(target: TransformNode): void;
|
|
134
|
+
/** Unregisters the behavior; the node keeps its last solved transform. */
|
|
135
|
+
detach(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Takes the node's current transform as the unconstrained value the next solve blends from. The solver calls
|
|
138
|
+
* this after the scene's animations ran; call it yourself after writing a transform by hand.
|
|
139
|
+
*/
|
|
140
|
+
captureBase(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Writes the unconstrained transform back to the node. The solver calls this before the scene's animations
|
|
143
|
+
* run, so a node nothing animates keeps its unconstrained value between frames instead of the solved one.
|
|
144
|
+
*/
|
|
145
|
+
restoreBase(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Nodes whose world transform the solve reads: the targets, the up node and the constrained node's parent.
|
|
148
|
+
* @returns The nodes, used by the solver to order constraints
|
|
149
|
+
*/
|
|
150
|
+
dependencyNodes(): Nullable<Node>[];
|
|
151
|
+
/**
|
|
152
|
+
* Solves the constraint from the captured unconstrained transform and writes the node's local transform.
|
|
153
|
+
* Blends are relative to the value captured by `captureBase`, not to whatever the node holds now.
|
|
154
|
+
*/
|
|
155
|
+
evaluate(): void;
|
|
156
|
+
/**
|
|
157
|
+
* World matrix of a node relative to the asset root (FBX space).
|
|
158
|
+
* @param node - node to evaluate
|
|
159
|
+
* @param out - matrix receiving the result
|
|
160
|
+
* @returns `out`
|
|
161
|
+
*/
|
|
162
|
+
private _fbxWorld;
|
|
163
|
+
/**
|
|
164
|
+
* Weighted blend of the targets' world transforms (relative to the root).
|
|
165
|
+
* @param position - Receives the blended translation
|
|
166
|
+
* @param rotation - Receives the blended rotation
|
|
167
|
+
* @param scale - Receives the blended scale
|
|
168
|
+
* @returns The total target weight, 0 when no target contributes
|
|
169
|
+
*/
|
|
170
|
+
private _blendTargets;
|
|
171
|
+
private _applyWeighted;
|
|
172
|
+
private _applyRotation;
|
|
173
|
+
private _writePosition;
|
|
174
|
+
private _writeScaling;
|
|
175
|
+
private _solvePosition;
|
|
176
|
+
private _solveRotation;
|
|
177
|
+
private _solveScale;
|
|
178
|
+
private _solveParent;
|
|
179
|
+
private _solveAim;
|
|
180
|
+
/**
|
|
181
|
+
* Builds a rotation matrix whose rows are `first`, `second` made orthogonal to it, and their cross product.
|
|
182
|
+
* @param first - primary axis
|
|
183
|
+
* @param second - secondary axis
|
|
184
|
+
* @param out - matrix receiving the basis
|
|
185
|
+
* @returns false when the axes are parallel or degenerate (`out` is then unchanged)
|
|
186
|
+
*/
|
|
187
|
+
private static _OrthonormalBasisToRef;
|
|
188
|
+
}
|