remove unused indexed option for mesh loading
This commit is contained in:
parent
b5ed7b1a4a
commit
cad64d52f8
5 changed files with 16 additions and 27 deletions
|
|
@ -18,8 +18,8 @@
|
||||||
gapp.main("main.mesh", [], (root) => {
|
gapp.main("main.mesh", [], (root) => {
|
||||||
|
|
||||||
const { Quaternion } = THREE;
|
const { Quaternion } = THREE;
|
||||||
const { broker } = gapp;
|
|
||||||
const { mesh, moto } = root;
|
const { mesh, moto } = root;
|
||||||
|
const { broker } = gapp;
|
||||||
const { space } = moto;
|
const { space } = moto;
|
||||||
|
|
||||||
const version = mesh.version = '1.4.9';
|
const version = mesh.version = '1.4.9';
|
||||||
|
|
|
||||||
|
|
@ -1179,20 +1179,12 @@ const tool = {
|
||||||
let p = worker.model_heal({
|
let p = worker.model_heal({
|
||||||
id: m.id, opt
|
id: m.id, opt
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
if (data) {
|
data?.length && m.reload(data.vertices);
|
||||||
m.reload(
|
|
||||||
data.vertices,
|
|
||||||
data.indices,
|
|
||||||
data.normals
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
promises.push(p);
|
promises.push(p);
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(resolve).catch(error => reject);
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ let materials = mesh.material = {
|
||||||
mesh.model = class MeshModel extends mesh.object {
|
mesh.model = class MeshModel extends mesh.object {
|
||||||
constructor(data, id) {
|
constructor(data, id) {
|
||||||
super(id);
|
super(id);
|
||||||
let { file, mesh, vertices, indices } = data;
|
let { file, mesh, vertices } = data;
|
||||||
|
|
||||||
if (!mesh) {
|
if (!mesh) {
|
||||||
dbug.error(`'${file}' missing mesh data`);
|
dbug.error(`'${file}' missing mesh data`);
|
||||||
|
|
@ -111,7 +111,7 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.file = file || 'unnamed';
|
this.file = file || 'unnamed';
|
||||||
this.load(mesh || vertices, indices);
|
this.load(mesh || vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
|
|
@ -250,14 +250,9 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
load(vertices, indices) {
|
load(vertices) {
|
||||||
let geo = new BufferGeometry();
|
let geo = new BufferGeometry();
|
||||||
geo.setAttribute('position', new BufferAttribute(vertices, 3));
|
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, [
|
let meh = this.mesh = new Mesh(geo, [
|
||||||
this.mats.normal,
|
this.mats.normal,
|
||||||
this.mats.face
|
this.mats.face
|
||||||
|
|
@ -276,13 +271,10 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
worker.model_load({id: this.id, name: this.file, vertices});
|
worker.model_load({id: this.id, name: this.file, vertices});
|
||||||
}
|
}
|
||||||
|
|
||||||
reload(vertices, indices) {
|
reload(vertices) {
|
||||||
let was = this.wireframe(false);
|
let was = this.wireframe(false);
|
||||||
let geo = this.mesh.geometry;
|
let geo = this.mesh.geometry;
|
||||||
geo.setAttribute('position', new BufferAttribute(vertices, 3));
|
geo.setAttribute('position', new BufferAttribute(vertices, 3));
|
||||||
if (indices) {
|
|
||||||
geo.setIndex(new BufferAttribute(indices, 1));
|
|
||||||
}
|
|
||||||
// signal util.box3expand that geometry changed
|
// signal util.box3expand that geometry changed
|
||||||
geo._model_invalid = true;
|
geo._model_invalid = true;
|
||||||
geo.computeVertexNormals();
|
geo.computeVertexNormals();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ mesh.object = class MeshObject {
|
||||||
|
|
||||||
applyMatrix(elements) {
|
applyMatrix(elements) {
|
||||||
if (elements) {
|
if (elements) {
|
||||||
|
console.log('matrix', this.type, this.id);
|
||||||
this.object.applyMatrix4(new Matrix4().fromArray(elements));
|
this.object.applyMatrix4(new Matrix4().fromArray(elements));
|
||||||
return this.matrixChanged();
|
return this.matrixChanged();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,13 @@ let model = {
|
||||||
let { vertices, name, id } = data;
|
let { vertices, name, id } = data;
|
||||||
let geo = new BufferGeometry();
|
let geo = new BufferGeometry();
|
||||||
geo.setAttribute('position', new BufferAttribute(vertices, 3));
|
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
|
// return new vertices in world coordinates
|
||||||
|
|
@ -294,9 +300,7 @@ let model = {
|
||||||
let tool = analyze(id, opt);
|
let tool = analyze(id, opt);
|
||||||
log(`${id} | unrolling...`);
|
log(`${id} | unrolling...`);
|
||||||
let unrolled = tool.unrolled();
|
let unrolled = tool.unrolled();
|
||||||
return {
|
return { vertices: unrolled.toFloat32() };
|
||||||
vertices: unrolled.toFloat32(),
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
indexFaces(data) {
|
indexFaces(data) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue