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
 | 
			
		||||
    // later pixel transfers.
 | 
			
		||||
    freeDownloaded(arrayBuffer) {
 | 
			
		||||
    freeDownload(arrayBuffer) {
 | 
			
		||||
        this.#downloadBufferPool.push(arrayBuffer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -189,7 +189,7 @@ function readUrl(urlString) {
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
            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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ export class User {
 | 
			
		|||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    simulate(chunkAllocator, wall, interactions) {
 | 
			
		||||
    simulate(chunkAllocator, brushRenderer, wall, interactions) {
 | 
			
		||||
        console.group("simulate", this.nickname);
 | 
			
		||||
        for (let interaction of interactions) {
 | 
			
		||||
            if (interaction.kind == "setBrush") {
 | 
			
		||||
| 
						 | 
				
			
			@ -72,10 +72,16 @@ export class User {
 | 
			
		|||
                if (interaction.kind == "scribble" && this.#expectContKind(ContKind.Scribble)) {
 | 
			
		||||
                    renderToChunksInArea(
 | 
			
		||||
                        chunkAllocator,
 | 
			
		||||
                        brushRenderer,
 | 
			
		||||
                        this.getScratchLayer(wall),
 | 
			
		||||
                        this.simulation.renderArea,
 | 
			
		||||
                        (pixmap, translationX, translationY) => {
 | 
			
		||||
                            return this.haku.contScribble(pixmap, translationX, translationY);
 | 
			
		||||
                        (brushRenderer, canvas, translationX, translationY) => {
 | 
			
		||||
                            return this.haku.contScribble(
 | 
			
		||||
                                brushRenderer,
 | 
			
		||||
                                canvas,
 | 
			
		||||
                                translationX,
 | 
			
		||||
                                translationY,
 | 
			
		||||
                            );
 | 
			
		||||
                        },
 | 
			
		||||
                    );
 | 
			
		||||
                    console.info("ended simulation");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ export class Layer {
 | 
			
		|||
                            downloaded.height,
 | 
			
		||||
                        ),
 | 
			
		||||
                    );
 | 
			
		||||
                    chunkAllocator.freeDownloaded(downloaded.data);
 | 
			
		||||
                    chunkAllocator.freeDownload(downloaded.data);
 | 
			
		||||
                    let canvas = new OffscreenCanvas(downloaded.width, downloaded.height);
 | 
			
		||||
                    let ctx = canvas.getContext("bitmaprenderer");
 | 
			
		||||
                    ctx.transferFromImageBitmap(imageBitmap);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue