Gamelab: SerializedAnimationProps does not need source size#9535
Merged
Conversation
Make the sourceSize animation property ephemeral, not part of the SerializedAnimationProps type, because we can always infer it once the asset is loaded. Instead we add a step to our loadfromsource process to determine the dimensions of the asset right before we are done loading.
6b24bf6 to
4df67d6
Compare
Contributor
Author
|
Note: After this is deployed to levelbuilder, I will go update existing gamelab levels to remove sourceSize from their JSON. This is non-urgent though; the sourceSize field in that JSON will just be ignored after this change. |
| import {createStore} from '@cdo/apps/redux'; | ||
| import {expect} from '../../util/configuredChai'; | ||
|
|
||
| // var testUtils = require('../../util/testUtils'); |
Contributor
There was a problem hiding this comment.
do we need these if they are commented out? or are they related to the todos?
Contributor
Author
There was a problem hiding this comment.
Oh, nope, just forgot to remove them. Nice catch.
Contributor
|
👍 thank you for the explanations! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's no need to specify the
sourceSizeproperty in the level's animation data (or to serialize it out, for that matter) so this PR moves sourceSize from theSerializedAnimationPropstype to its ephemeral superset theAnimationPropstype, and extends theloadAnimationFromSourceprocess to read the spritesheet dimensions and populatesourceSizeat that time.A brief overview of how animations are loaded:
SerializedAnimationList(a collection ofSerializedAnimationPropsobjects) from either the level definition or from the student's saved project. This contains the animation properties (name, frame size, framerate, etc) but not the spritesheet images themselves.AnimationListofAnimationProps(which are likeSerializedAnimationPropsbut they have more fields), and in the process we callloadAnimationFromSourcefor every animation.loadAnimationFromSourcemakes an asynchronous request for the animation's spritesheet image. When it's done downloading as a Blob we convert it to a data URI and (as of this change) get its dimensions, add aloadedFromSourceflag, and put all of those on theAnimationPropsin Redux.And how they're used:
AnimationPropsin Redux - this saves us from making a web request for the spritesheet image again. That includes loading the animation into p5.play and sending the image to Piskel to load for editing.AnimationListback into aSerializedAnimationListand save that with the project.