add client/worker sync test

This commit is contained in:
Stewart Allen 2021-12-31 22:11:20 -05:00
commit 650a9b4d68
2 changed files with 31 additions and 0 deletions

View file

@ -14,6 +14,23 @@ gapp.finalize("mesh.work", [
"moto.client", // dep: moto.client
"moto.worker", // dep: moto.worker
"mesh.tool", // dep: mesh.tool
"add.three", // dep: add.three
]);
// compensation for space/world/platform rotation
let space_rotation = new THREE.Matrix4().makeRotationX(Math.PI / 2);
moto.worker.bind("model_sync", (data, send) => {
let { vertices, matrix } = data;
console.log('model_sync', {vertices, matrix, send});
let geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
geo.setAttribute('normal', undefined);
geo.computeFaceNormals();
geo.computeVertexNormals();
let m4 = space_rotation.clone().multiply( new THREE.Matrix4().fromArray(matrix) );
geo.applyMatrix4(m4);
send.done(geo.attributes.position.array);
});
})();