Create Props
Even though you can create prop configs by either creating its json or using a PropConfigGenerator, you have to include it in the Global Config's Prop List.
You can however interact with a scene's PropContext to modify your prop list.
info
We will only use GlobalConfigGenerator.addProp
to demonstrate functionalities later since it uses an underlying PropConfigGenerator
.
There are 3 ways to create a prop. We will cover prop's properties later.
- Create its json and add it to global config's props
- Use a PropConfigGenerator
new GlobalConfigGenerator().addProp((generator)=>generator...)
(this gives you a callback with one instance of PropConfigGenerator)const generator = new PropConfigGenerator()
andgenerator.getConfig()
(This gives you a prop config object)
- 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"
}
]