add drag/move, quaternion rotation, lay flat, work mesh matrix debug

This commit is contained in:
Stewart Allen 2022-01-01 00:04:35 -05:00
commit d42db44009
5 changed files with 78 additions and 8 deletions

View file

@ -57,12 +57,12 @@ mesh.model = class MeshModel extends mesh.object {
vertices: this.mesh.geometry.attributes.position.array,
matrix: this.mesh.matrixWorld.elements
}).then(data => {
console.log({data: data[0]});
// mesh.api.group.new([new mesh.model({
// file: "synth",
// mesh: data[0]
// })]);
this.load(data[0]);
if (data && data.length)
// for debugging matrix ops
return mesh.api.group.new([new mesh.model({
file: "synth",
mesh: data[0]
})]);
});
}
@ -78,9 +78,24 @@ mesh.model = class MeshModel extends mesh.object {
meh.receiveShadow = true;
meh.castShadow = true;
meh.renderOrder = 1;
// this ref allows clicks to be traced to models and groups
meh.model = this;
return meh;
}
reload(vertices, indices) {
let geo = this.mesh.geometry;
geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
geo.setAttribute('normal', undefined);
if (indices) {
geo.setIndex(new THREE.BufferAttribute(indices, 1));
geo.attributes.index.needsUpdate = true;
}
geo.attributes.position.needsUpdate = true;
geo.computeFaceNormals();
geo.computeVertexNormals();
}
get group() {
return this._group;
}