diff --git a/src/mesh/model.js b/src/mesh/model.js index a8babaf2..ec46f0e0 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -53,6 +53,36 @@ mesh.model = class MeshModel extends mesh.object { return this.mesh; } + move(x = 0, y = 0, z = 0) { + // doesn't fix bounds issue for some rotations. inspired by this threejs forum post: + // https://discourse.threejs.org/t/bounding-box-bigger-than-concave-object-extrudegeometry/26073/2 + // this.mesh.applyMatrix4(new THREE.Matrix4().makeTranslation(x,y,z)); + let pos = this.position(); + pos.set(pos.x + x, pos.y + y, pos.z + z); + this.updateBoundsBox(); + moto.Space.update(); + return this; + } + + rotate() { + throw "model rotate() not allowed"; + } + + rotation() { + throw "model rotation() not allowed"; + } + + qrotation() { + throw "model qrotation() not allowed"; + } + + position() { + if (arguments.length) { + throw "model position(...) not allowed"; + } + return super.position(...arguments); + } + sync() { moto.client.fn.model_sync({ vertices: this.mesh.geometry.attributes.position.array, diff --git a/src/mesh/work.js b/src/mesh/work.js index e510ea1a..86ed010e 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -30,7 +30,6 @@ moto.worker.bind("model_sync", (data, send) => { geo.computeVertexNormals(); let m4 = space_rotation.clone().multiply( new THREE.Matrix4().fromArray(matrix) ); geo.applyMatrix4(m4); - return send.done(); // for debugging matrix ops send.done(geo.attributes.position.array); });