UNPKG

babylon-testing-library

Version:

Simple utilities that encourage good testing practices for Babylon.js

32 lines 1.19 kB
import { Scene } from '@babylonjs/core'; import { AdvancedDynamicTexture } from '@babylonjs/gui'; const findAllMatchingInControl = (container, matcher) => { const controls = []; if (matcher(container)) { controls.push(container); } return [ ...controls, ...container.getDescendants().filter((control) => matcher(control)), ]; }; const findAllMatchingInTexture = (container, matcher) => { return container.rootContainer.children.flatMap((control) => findAllMatchingInControl(control, matcher)); }; const findAllMatchingInScene = (container, matcher) => { return container.textures .filter((texture) => texture instanceof AdvancedDynamicTexture) .flatMap((control) => findAllMatchingInTexture(control, matcher)); }; export const findAllMatchingDescendants = (container, matcher) => { if (container instanceof Scene) { return findAllMatchingInScene(container, matcher); } else if (container instanceof AdvancedDynamicTexture) { return findAllMatchingInTexture(container, matcher); } else { return findAllMatchingInControl(container, matcher); } }; //# sourceMappingURL=utils.js.map