export class Scene { constructor() { this.map = {} this.entities = {} this.materials = {} } add(material, entity) { var arr = this.map[material.id] if (arr == undefined) { arr = [] this.materials[material.id] = material } if (!arr.includes(entity.id)) { arr.push(entity.id) this.entities[entity.id] = entity } this.map[material.id] = arr } remove(material, entity) { var arr = this.objects[material.id] if (arr == undefined) { return } const i = arr.indexOf(entity.id) if(i > -1) { arr = arr.splice(i, 1) delete this.entities[entity.id] if(arr.length < 1) { delete this.map[material.id] delete this.materials[material.id] } } } }