import { ALLOWED_COMPONENTS } from './consts';
const ALLOWED_COMPONENT_NAMES = new Set(ALLOWED_COMPONENTS.map((entry) => entry.componentName));
/**
 * Leaves only necessary components to display actor in scene viewer
 */
export const omit = (entity) => {
    var _a, _b;
    return (Object.assign(Object.assign({}, entity), { children: (_a = entity.children) === null || _a === void 0 ? void 0 : _a.map(omit), components: (_b = entity.components) === null || _b === void 0 ? void 0 : _b.filter((component) => ALLOWED_COMPONENT_NAMES.has(component.name)) }));
};
export const removeAllChildren = (scene, mainActorId) => {
    let index = 0;
    while (index < scene.children.length) {
        if (scene.children[index].id !== mainActorId) {
            scene.children[index].remove();
        }
        else {
            index += 1;
        }
    }
};
