expose indexVertices in csg

This commit is contained in:
Stewart Allen 2022-11-15 23:45:45 -05:00
commit a2bc54808e
3 changed files with 14 additions and 17 deletions

View file

@ -74,8 +74,9 @@ const CSG = {
const vmin = new THREE.Vector3(min.x, min.y, min.z); const vmin = new THREE.Vector3(min.x, min.y, min.z);
const vmax = new THREE.Vector3(max.x, max.y, max.z); const vmax = new THREE.Vector3(max.x, max.y, max.z);
return new THREE.Box3(vmin, vmax); return new THREE.Box3(vmin, vmax);
} },
indexVertices
}; };
function indexVertices(pos) { function indexVertices(pos) {

View file

@ -85,25 +85,22 @@ function init() {
} }
// restore space layout and view from previous session // restore space layout and view from previous session
function restore_space() { async function restore_space() {
let { api } = mesh; const { api } = mesh;
let count = 0; const space = moto.space;
let space = moto.space; const db_admin = mesh.db.admin;
let mcache = {}; const db_space = mesh.db.space;
mesh.db.admin.get("camera") // let mcache = {};
await db_admin.get("camera")
.then(saved => { .then(saved => {
if (saved) { if (saved) {
space.view.load(saved.place); space.view.load(saved.place);
space.view.setFocus(saved.focus); space.view.setFocus(saved.focus);
} }
}); });
mesh.db.admin.get("matrices") const mcache = await db_admin.get("matrices") || {};
.then(data => { let count = 0;
if (data) { await db_space.iterate({ map: true }).then(cached => {
mcache = data;
}
});
mesh.db.space.iterate({ map: true }).then(cached => {
const keys = []; const keys = [];
const claimed = []; const claimed = [];
for (let [id, data] of Object.entries(cached)) { for (let [id, data] of Object.entries(cached)) {
@ -126,7 +123,7 @@ function restore_space() {
mesh.api.group.new(models, id).applyMatrix(mcache[id]); mesh.api.group.new(models, id).applyMatrix(mcache[id]);
} else { } else {
mesh.api.log.emit(`removed empty group ${id}`); mesh.api.log.emit(`removed empty group ${id}`);
mesh.db.space.remove(id); db_space.remove(id);
} }
} }
} }
@ -138,7 +135,7 @@ function restore_space() {
} }
// clear out meshes left in the space db along with their matrices // clear out meshes left in the space db along with their matrices
for (let id of keys) { for (let id of keys) {
mesh.db.space.remove(id); db_space.remove(id);
delete mcache[id]; delete mcache[id];
} }
// restore global cache only after objects are restored // restore global cache only after objects are restored

View file

@ -63,7 +63,6 @@ let materials = mesh.material = {
opacity: 1 opacity: 1
}), }),
wireframe: new MeshBasicMaterial({ wireframe: new MeshBasicMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
wireframe: true, wireframe: true,
color: 0x0, color: 0x0,