I’m working on a 2d canvas app and am having trouble with blowing up my document size when trying to translate sets of objects.
I’ve been looking at this post: Handling slow mergeUpdates on server - #3 by dmonad but I’m not sure how to solve this issue when operating on groups of objects. Is there a way to ask Yjs to discard or merge transactions? I know the UndoManager can do this, but can the Yjs document do this as well?
Here’s a rough outline of my setup:
type sceneNode = Y.Map<{
slug: string,
material: Y.Map<Material>,
transform: number[]
}>
...
const sceneNodes = Y.Doc.getArray("sceneNodes")
...
window.onMouseMove(( event ) => {
const selectedNodes = getSelectedSceneNodes();
if (!selectedNodes.length) return;
const doc = this.app.yDoc;
doc.transact(() => {
selectedNodes.forEach((sceneNode) => {
const original = sceneNode.get("transform");
const newTransform = getTransform( original, event );
sceneNode.set("transform", transform);
});
});
})
Thanks in advance!