keyframe data from esp32 now loads correctly
parent
951e140129
commit
bc2eb3125d
27
script.js
27
script.js
|
|
@ -14,7 +14,7 @@ window.onload = () => {
|
||||||
const frameDisplay = document.getElementById('frameDisplay');
|
const frameDisplay = document.getElementById('frameDisplay');
|
||||||
const canvas = document.getElementById('timelineCanvas');
|
const canvas = document.getElementById('timelineCanvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
const totalFrames = 400;
|
const totalFrames = 500;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -142,16 +142,31 @@ window.onload = () => {
|
||||||
frames.push(positions);
|
frames.push(positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(frames);
|
// Move offset to end of reserved 10 seconds of animation, to keyframe data
|
||||||
|
offset = 5016;
|
||||||
|
|
||||||
|
const keyFrameCount = view.getUint16(offset, true); offset += 2;
|
||||||
|
let keyframes = [];
|
||||||
|
for (var i = 0; i < keyFrameCount; i++) {
|
||||||
|
let motorID = view.getUint8(offset); offset += 1;
|
||||||
|
let frame = view.getUint16(offset, true); offset += 2;
|
||||||
|
let position = view.getUint16(offset, true); offset += 2;
|
||||||
|
keyframes.push({ motorID, frame, position });
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(keyFrameCount);
|
||||||
|
console.log(keyframes);
|
||||||
|
|
||||||
// Populate from parsed animation frames
|
// Populate from parsed animation frames
|
||||||
frames.forEach((positions, frameIndex) => {
|
keyframes.forEach(({ motorID, frame, position }) => {
|
||||||
positions.forEach((val, motorId) => {
|
if (!dialKeyframes[motorID]) {
|
||||||
dialKeyframes[motorId][frameIndex] = val;
|
dialKeyframes[motorID] = []; // Initialize if missing
|
||||||
});
|
}
|
||||||
|
dialKeyframes[motorID][frame] = position;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
header: { magic, version, frameCount, frameRate },
|
header: { magic, version, frameCount, frameRate },
|
||||||
frames
|
frames
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue