Skip to content

Commit

Permalink
Added missing entities
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia committed May 14, 2024
1 parent 7b55519 commit 43b5cb6
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { serializeCrdtMessages } from './logger'
import { contentFetchBaseUrl, mainCrdt, sceneId, sdk6FetchComponent, sdk6SceneContent } from '../sceneFetcher'
import { writeFile, mkdir } from 'fs'
import { engine, Entity, PutComponentOperation, Transform, UiCanvasInformation } from '@dcl/ecs/dist-cjs'
import {CameraMode, engine, Entity, PutComponentOperation, Transform, UiCanvasInformation} from '@dcl/ecs/dist-cjs'
import { ReadWriteByteBuffer } from '@dcl/ecs/dist-cjs/serialization/ByteBuffer'
import { FRAMES_TO_RUN, framesCount } from '../../adapters/scene'

Expand Down Expand Up @@ -32,7 +32,7 @@ function addPlayerEntityTransform() {
const transformData = buffer.toCopiedBinary()
buffer.resetBuffer()
PutComponentOperation.write(1 as Entity, 1, Transform.componentId, transformData, buffer)

PutComponentOperation.write(2 as Entity, 1, Transform.componentId, transformData, buffer)
return buffer.toBinary()
}

Expand All @@ -47,6 +47,16 @@ function addUICanvasOnRootEntity() {
return buffer.toBinary()
}

function addCameraMode() {
const buffer = new ReadWriteByteBuffer()
const cameraMode = CameraMode.create(engine.RootEntity)
CameraMode.schema.serialize(cameraMode, buffer)
const cameraModeComponentData = buffer.toCopiedBinary()
buffer.resetBuffer()
PutComponentOperation.write(2 as Entity, 1, CameraMode.componentId, cameraModeComponentData, buffer)
return buffer.toBinary()
}

type LoadableApis = {
EnvironmentApi: typeof EnvironmentApi
UserIdentity: typeof UserIdentity
Expand Down Expand Up @@ -104,7 +114,7 @@ export const LoadableApis: LoadableApis = {
unsubscribe: async () => ({ events: [] }),
crdtGetState: async () => ({
hasEntities: mainCrdt !== undefined,
data: [addPlayerEntityTransform(), addUICanvasOnRootEntity(), mainCrdt]
data: [addPlayerEntityTransform(), addUICanvasOnRootEntity(), addCameraMode() ,mainCrdt]
}),
crdtGetMessageFromRenderer: async () => ({ data: [] }),
crdtSendToRenderer: async ({ data }: { data: Uint8Array }) => {
Expand Down Expand Up @@ -266,3 +276,4 @@ function joinBuffers(...buffers: ArrayBuffer[]) {
}
return tmp
}

0 comments on commit 43b5cb6

Please sign in to comment.