Skip to content

Commit 7ac7d5c

Browse files
authored
Fix animation error (galacean#2014)
* fix: animation error
1 parent 329e52f commit 7ac7d5c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/loader/src/gltf/parser/GLTFAnimationParser.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ export class GLTFAnimationParser extends GLTFParser {
3636
const { glTF } = context;
3737
const { accessors, bufferViews } = glTF;
3838
const { channels, samplers } = animationInfo;
39-
const sampleDataCollection = new Array<SampleData>();
39+
const len = samplers.length;
40+
const sampleDataCollection = new Array<SampleData>(len);
4041
const entities = context.get<Entity>(GLTFParserType.Entity);
4142

4243
let duration = -1;
4344
let promises = new Array<Promise<void | Entity[]>>();
4445

4546
// parse samplers
46-
for (let j = 0, m = samplers.length; j < m; j++) {
47+
for (let j = 0, m = len; j < m; j++) {
4748
const glTFSampler = samplers[j];
4849
const inputAccessor = accessors[glTFSampler.input];
4950
const outputAccessor = accessors[glTFSampler.output];
@@ -84,13 +85,13 @@ export class GLTFAnimationParser extends GLTFParser {
8485
duration = maxTime;
8586
}
8687

87-
sampleDataCollection.push({
88+
sampleDataCollection[j] = {
8889
type: outputAccessor.type,
8990
interpolation: samplerInterpolation,
9091
input,
9192
output,
9293
outputSize: outputStride
93-
});
94+
};
9495
});
9596
promises.push(promise);
9697
}

0 commit comments

Comments
 (0)