fix synchronisation between users
This commit is contained in:
parent
410f82201d
commit
85dce88ec2
4 changed files with 16 additions and 7 deletions
|
@ -300,7 +300,7 @@ export class AtlasAllocator {
|
||||||
|
|
||||||
// Call after download() finishes running to give memory back to the allocator, for reuse in
|
// Call after download() finishes running to give memory back to the allocator, for reuse in
|
||||||
// later pixel transfers.
|
// later pixel transfers.
|
||||||
freeDownloaded(arrayBuffer) {
|
freeDownload(arrayBuffer) {
|
||||||
this.#downloadBufferPool.push(arrayBuffer);
|
this.#downloadBufferPool.push(arrayBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ function readUrl(urlString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wallEvent.kind.event == "interact") {
|
if (wallEvent.kind.event == "interact") {
|
||||||
user.simulate(chunkAllocator, wall, wallEvent.kind.interactions);
|
user.simulate(chunkAllocator, brushRenderer, wall, wallEvent.kind.interactions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -281,7 +281,10 @@ function readUrl(urlString) {
|
||||||
cursor += edit.data.size;
|
cursor += edit.data.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.sendEdit(editRecords, new Blob(dataParts));
|
let data = new Blob(dataParts);
|
||||||
|
|
||||||
|
console.log("sending edit data. record count:", editRecords.length, "data blob:", data);
|
||||||
|
session.sendEdit(editRecords, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
canvasRenderer.addEventListener(".viewportUpdate", () => reticleRenderer.render());
|
canvasRenderer.addEventListener(".viewportUpdate", () => reticleRenderer.render());
|
||||||
|
|
|
@ -42,7 +42,7 @@ export class User {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
simulate(chunkAllocator, wall, interactions) {
|
simulate(chunkAllocator, brushRenderer, wall, interactions) {
|
||||||
console.group("simulate", this.nickname);
|
console.group("simulate", this.nickname);
|
||||||
for (let interaction of interactions) {
|
for (let interaction of interactions) {
|
||||||
if (interaction.kind == "setBrush") {
|
if (interaction.kind == "setBrush") {
|
||||||
|
@ -72,10 +72,16 @@ export class User {
|
||||||
if (interaction.kind == "scribble" && this.#expectContKind(ContKind.Scribble)) {
|
if (interaction.kind == "scribble" && this.#expectContKind(ContKind.Scribble)) {
|
||||||
renderToChunksInArea(
|
renderToChunksInArea(
|
||||||
chunkAllocator,
|
chunkAllocator,
|
||||||
|
brushRenderer,
|
||||||
this.getScratchLayer(wall),
|
this.getScratchLayer(wall),
|
||||||
this.simulation.renderArea,
|
this.simulation.renderArea,
|
||||||
(pixmap, translationX, translationY) => {
|
(brushRenderer, canvas, translationX, translationY) => {
|
||||||
return this.haku.contScribble(pixmap, translationX, translationY);
|
return this.haku.contScribble(
|
||||||
|
brushRenderer,
|
||||||
|
canvas,
|
||||||
|
translationX,
|
||||||
|
translationY,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
console.info("ended simulation");
|
console.info("ended simulation");
|
||||||
|
|
|
@ -82,7 +82,7 @@ export class Layer {
|
||||||
downloaded.height,
|
downloaded.height,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
chunkAllocator.freeDownloaded(downloaded.data);
|
chunkAllocator.freeDownload(downloaded.data);
|
||||||
let canvas = new OffscreenCanvas(downloaded.width, downloaded.height);
|
let canvas = new OffscreenCanvas(downloaded.width, downloaded.height);
|
||||||
let ctx = canvas.getContext("bitmaprenderer");
|
let ctx = canvas.getContext("bitmaprenderer");
|
||||||
ctx.transferFromImageBitmap(imageBitmap);
|
ctx.transferFromImageBitmap(imageBitmap);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue