Create Animation Configs
Even though you can create position configs by either creating its json or using a PositionConfigGenerator, you have to include it in the Prop Config's frameAnimationConfig.
info
We will only use PropConfigGenerator.addPosition
to demonstrate functionalities later since it uses an underlying PositionConfigGenerator
.
There are 3 ways to create a prop's position:
- Create its json and add it to prop's frameAnimationConfig
- Use a PositionConfigGenerator
new PropConfigGenerator().addPosition((generator)=>generator...)
(this gives you a callback with one instance of PositionConfigGenerator)const generator = new PositionConfigGenerator()
andgenerator.getConfig()
(This gives you an animation config object)
Required properties
If you include a prop in the scene, it has to contain at least 1 animation config at any frame.
For every animation config, the property x and y (which defines where the prop's going to be placed at that frame) are required.
- Global Config Generator
- Prop Config Generator
- Config
new GlobalConfigGenerator()
.addProp((generator) => {
generator.type('TABLE').addPosition((positionGenerator) => {
positionGenerator.x(50).y(50)
})
})
.addProp((generator) => {
generator.type('CAMERA').addPosition((positionGenerator) => {
positionGenerator.x(200).y(200)
})
})
const camera = new PropConfigGenerator()
.type('CAMERA')
.addPosition((positionGenerator) => {
positionGenerator.x(200).y(200)
})
const table = new PropConfigGenerator()
.type('TABLE')
.addPosition((positionGenerator) => {
positionGenerator.x(50).y(50)
})
new GlobalConfigGenerator().withProps([table, camera])
config.props = [
{
"frameAnimationConfig": {
"1": {
"x": 50,
"y": 50,
}
},
"type": "TABLE"
},
{
"frameAnimationConfig": {
"1": {
"x": 200,
"y": 200,
}
},
"type": "CAMERA"
}
]