start mesh api. add function wrapper for array arguments unroll

This commit is contained in:
Stewart Allen 2021-12-29 21:52:24 -05:00
commit a1644ed609
6 changed files with 83 additions and 7 deletions

42
src/mesh/api.js Normal file
View file

@ -0,0 +1,42 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
"use strict";
(function() {
// dep: ext.three
// dep: ext.three-bgu
gapp.register("mesh.api", [
"moto.license", // dep: moto.license
"moto.client", // dep: moto.client
"moto.space", // dep: moto.space
"mesh.tool", // dep: mesh.tool
"add.array", // dep: add.array
]);
let mesh = self.mesh = self.mesh || {};
if (mesh.api) return;
let space = moto.Space;
let models = [];
let api = mesh.api = {
models: {
all: models,
add: model => {
if (!models.contains(model)) {
space.model.add(model.mesh);
models.push(model);
}
},
remove: Array.handle(model => {
space.model.remove(model.mesh);
models.remove(model);
})
}
};
})();