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);
})
}
};
})();

View file

@ -4,14 +4,15 @@
(function() {
gapp.register("mesh.object", [
gapp.register("mesh.model", [
"add.three", // dep: add.three
"moto.license", // dep: moto.license
]);
let mesh = self.mesh = self.mesh || {};
if (mesh.object) return;
if (mesh.model) return;
/** default materials **/
mesh.material = {
solid: new THREE.MeshPhongMaterial({
transparent: true,
@ -22,7 +23,8 @@ mesh.material = {
})
};
mesh.object = class MeshObject {
/** 3D model rendered on plaform **/
mesh.model = class MeshModel {
constructor(data) {
let { file, mesh } = data;

View file

@ -8,8 +8,9 @@
gapp.register("mesh.tool");
let mesh = self.mesh = self.mesh || {};
if (mesh.object) return;
if (mesh.tool) return;
/** tool for identiying defects and healing them **/
mesh.tool = class MeshTool {
constructor(params = {}) {
this.precision = Math.pow(10, params.precision || 6);