Skip to content

Commit

Permalink
fix tween sync entity
Browse files Browse the repository at this point in the history
  • Loading branch information
gonpombo8 committed Sep 16, 2024
1 parent 008bb68 commit 7d7e096
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/@dcl/ecs/src/serialization/crdt/network/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,25 @@ export function localMessageToNetwork(
destinationBuffer.writeBuffer(buffer.buffer().subarray(offset, buffer.currentWriteOffset()), false)
}

const buffer = new ReadWriteByteBuffer()
/* istanbul ignore next */
export function fixTransformParent(
message: ReceiveMessage,
transformValue?: TransformType,
parent?: Entity
): Uint8Array {
buffer.resetBuffer()
let transform = transformValue
const buffer = new ReadWriteByteBuffer()

if (!transform && 'data' in message) {
buffer.writeBuffer(message.data)
transform = TransformSchema.deserialize(buffer)
buffer.resetBuffer()
transform = TransformSchema.deserialize(new ReadWriteByteBuffer(message.data))
}

if (!transform) throw new Error('Invalid parent transform')

// Generate new transform raw data with the parent
const newTransform = { ...transform, parent }
buffer.resetBuffer()

TransformSchema.serialize(newTransform, buffer)
return buffer.toBinary()
}

0 comments on commit 7d7e096

Please sign in to comment.