prendy
Version:
Make games with prerendered backdrops using babylonjs and repond
37 lines (36 loc) • 1.13 kB
JavaScript
import { forEach } from "chootils/dist/loops";
export default function models(prendyAssets) {
const modelNames = prendyAssets.modelNames;
const getDefaultState = (_modelName) => {
return {
wantToLoad: false,
isLoading: false,
isLoaded: false,
};
};
const getDefaultRefs = (_modelName) => ({
// originalMeshRef: null,
container: null,
materialRef: null,
materialRefs: null,
});
class FuncTypeWrapper {
// wrapped has no explicit return type so we can infer it
wrapped(modelName) {
return getDefaultState(modelName);
}
}
function makeAutmaticModelStartStates() {
const partialModelStates = {};
forEach(modelNames, (modelName) => {
partialModelStates[modelName] = getDefaultState(modelName);
});
return partialModelStates;
}
const startStates = makeAutmaticModelStartStates();
// {
// walker: state("walker"),
// bucket: state("bucket"),
// };
return { startStates, getDefaultState, getDefaultRefs };
}