batch mesh updates to ui
This commit is contained in:
parent
f28902e3a2
commit
56c78ff002
1 changed files with 10 additions and 14 deletions
|
|
@ -269,7 +269,7 @@ class Stock {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMesh(send) {
|
updateMesh(updates) {
|
||||||
if (this.sends > 0 && this.subtracts === 0) {
|
if (this.sends > 0 && this.subtracts === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -282,12 +282,10 @@ class Stock {
|
||||||
vertex: this.sharedVertexBuffer.bind(this)
|
vertex: this.sharedVertexBuffer.bind(this)
|
||||||
});
|
});
|
||||||
let sub = Date.now();
|
let sub = Date.now();
|
||||||
this.send(send);
|
updates.push(this);
|
||||||
let snd = Date.now();
|
|
||||||
console.log({
|
console.log({
|
||||||
update: this.id,
|
update: this.id,
|
||||||
time: sub - start,
|
time: sub - start,
|
||||||
send: snd - sub,
|
|
||||||
subs,
|
subs,
|
||||||
subms: (subs / (sub - start)).round(3)
|
subms: (subs / (sub - start)).round(3)
|
||||||
});
|
});
|
||||||
|
|
@ -387,7 +385,7 @@ kiri.load(() => {
|
||||||
|
|
||||||
stockSlices = [];
|
stockSlices = [];
|
||||||
const { x, y, z } = stock;
|
const { x, y, z } = stock;
|
||||||
const sliceCount = 20;
|
const sliceCount = 1;
|
||||||
const sliceWidth = stock.x / sliceCount;
|
const sliceWidth = stock.x / sliceCount;
|
||||||
for (let i=0; i<sliceCount; i++) {
|
for (let i=0; i<sliceCount; i++) {
|
||||||
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth/2;
|
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth/2;
|
||||||
|
|
@ -395,13 +393,11 @@ kiri.load(() => {
|
||||||
let slice = new Stock(sliceWidth, y, z).translate(xmin, 0, z/2);
|
let slice = new Stock(sliceWidth, y, z).translate(xmin, 0, z/2);
|
||||||
slice.dim = { xmin: xmin - sliceWidth / 2, xmax: xmin + sliceWidth / 2 };
|
slice.dim = { xmin: xmin - sliceWidth / 2, xmax: xmin + sliceWidth / 2 };
|
||||||
stockSlices.push(slice);
|
stockSlices.push(slice);
|
||||||
slice.updateMesh(send);
|
slice.updateMesh([]);
|
||||||
|
slice.send(send);
|
||||||
send.data({ mesh_move: { id: slice.id, pos: center } });
|
send.data({ mesh_move: { id: slice.id, pos: center } });
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared array buffers are not transferrable
|
|
||||||
// send.data({ mesh_add: { id: 0, ind: stockMesh.index, pos: stockMesh.vertex } }, [ ]);
|
|
||||||
// send.data({ mesh_move: { id: 0, pos: center } });
|
|
||||||
send.done();
|
send.done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -547,17 +543,17 @@ kiri.load(() => {
|
||||||
|
|
||||||
// send latest tool position and progress bar
|
// send latest tool position and progress bar
|
||||||
function renderUpdate(send) {
|
function renderUpdate(send) {
|
||||||
// console.time('renderUpdate');
|
|
||||||
if (toolUpdateMsg) {
|
if (toolUpdateMsg) {
|
||||||
send.data(toolUpdateMsg);
|
send.data(toolUpdateMsg);
|
||||||
}
|
}
|
||||||
// console.time('updateMeshes');
|
const updated = []
|
||||||
for (let slice of stockSlices) {
|
for (let slice of stockSlices) {
|
||||||
slice.updateMesh(send);
|
slice.updateMesh(updated);
|
||||||
|
}
|
||||||
|
for (let slice of updated) {
|
||||||
|
slice.send(send);
|
||||||
}
|
}
|
||||||
// console.timeEnd('updateMeshes');
|
|
||||||
updates++;
|
updates++;
|
||||||
// console.timeEnd('renderUpdate');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// move tool mesh animation space, update client
|
// move tool mesh animation space, update client
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue