remove unused indexed option for mesh loading

This commit is contained in:
Stewart Allen 2024-08-02 15:35:11 -04:00
commit cad64d52f8
5 changed files with 16 additions and 27 deletions

View file

@ -18,8 +18,8 @@
gapp.main("main.mesh", [], (root) => {
const { Quaternion } = THREE;
const { broker } = gapp;
const { mesh, moto } = root;
const { broker } = gapp;
const { space } = moto;
const version = mesh.version = '1.4.9';

View file

@ -1179,20 +1179,12 @@ const tool = {
let p = worker.model_heal({
id: m.id, opt
}).then(data => {
if (data) {
m.reload(
data.vertices,
data.indices,
data.normals
);
}
data?.length && m.reload(data.vertices);
});
promises.push(p);
}
return new Promise((resolve, reject) => {
Promise.all(promises).then(() => {
resolve();
});
Promise.all(promises).then(resolve).catch(error => reject);
});
},

View file

@ -82,7 +82,7 @@ let materials = mesh.material = {
mesh.model = class MeshModel extends mesh.object {
constructor(data, id) {
super(id);
let { file, mesh, vertices, indices } = data;
let { file, mesh, vertices } = data;
if (!mesh) {
dbug.error(`'${file}' missing mesh data`);
@ -111,7 +111,7 @@ mesh.model = class MeshModel extends mesh.object {
};
this.file = file || 'unnamed';
this.load(mesh || vertices, indices);
this.load(mesh || vertices);
}
get type() {
@ -250,14 +250,9 @@ mesh.model = class MeshModel extends mesh.object {
});
}
load(vertices, indices) {
load(vertices) {
let geo = new BufferGeometry();
geo.setAttribute('position', new BufferAttribute(vertices, 3));
if (indices) {
// unroll indexed geometries
geo.setIndex(new BufferAttribute(indices, 1));
geo = geo.toNonIndexed();
}
let meh = this.mesh = new Mesh(geo, [
this.mats.normal,
this.mats.face
@ -276,13 +271,10 @@ mesh.model = class MeshModel extends mesh.object {
worker.model_load({id: this.id, name: this.file, vertices});
}
reload(vertices, indices) {
reload(vertices) {
let was = this.wireframe(false);
let geo = this.mesh.geometry;
geo.setAttribute('position', new BufferAttribute(vertices, 3));
if (indices) {
geo.setIndex(new BufferAttribute(indices, 1));
}
// signal util.box3expand that geometry changed
geo._model_invalid = true;
geo.computeVertexNormals();

View file

@ -55,6 +55,7 @@ mesh.object = class MeshObject {
applyMatrix(elements) {
if (elements) {
console.log('matrix', this.type, this.id);
this.object.applyMatrix4(new Matrix4().fromArray(elements));
return this.matrixChanged();
} else {

View file

@ -101,7 +101,13 @@ let model = {
let { vertices, name, id } = data;
let geo = new BufferGeometry();
geo.setAttribute('position', new BufferAttribute(vertices, 3));
cacheUpdate(id, { name, geo, xmatrix: core_matrix.clone(), trans: undefined, tool: undefined });
cacheUpdate(id, {
name,
geo,
xmatrix: core_matrix.clone(),
trans: undefined,
tool: undefined
});
},
// return new vertices in world coordinates
@ -294,9 +300,7 @@ let model = {
let tool = analyze(id, opt);
log(`${id} | unrolling...`);
let unrolled = tool.unrolled();
return {
vertices: unrolled.toFloat32(),
};
return { vertices: unrolled.toFloat32() };
},
indexFaces(data) {