From 68e9f7a65989330c2b829b66e9b4db53733d7a49 Mon Sep 17 00:00:00 2001 From: Nicolas Chamo Date: Tue, 12 Jan 2021 14:59:21 -0300 Subject: [PATCH] First commit --- kernel/packages/decentraland-ecs/src/index.ts | 10 ++++++++-- kernel/packages/shared/world/SceneSystemWorker.ts | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kernel/packages/decentraland-ecs/src/index.ts b/kernel/packages/decentraland-ecs/src/index.ts index 6b317badd7..09ba02a372 100644 --- a/kernel/packages/decentraland-ecs/src/index.ts +++ b/kernel/packages/decentraland-ecs/src/index.ts @@ -17,8 +17,8 @@ import { DecentralandSynchronizationSystem } from './decentraland/Implementation import { Engine } from './ecs/Engine' import { Entity } from './ecs/Entity' -const entity = new Entity('scene'); -(entity as any).uuid = '0' +const entity = new Entity('scene') +;(entity as any).uuid = '0' // Initialize engine /** @public */ @@ -37,6 +37,12 @@ if (typeof dcl !== 'undefined') { engine.addSystem(new DecentralandSynchronizationSystem(dcl), Infinity) } +// We instantiate the camera, so that it starts listening to events +import { Camera } from './decentraland/Camera' +if (typeof dcl !== 'undefined') { + dcl.onStart(() => Camera.instance) +} + import { uuidEventSystem, pointerEventSystem, raycastEventSystem } from './decentraland/Systems' // Initialize UUID Events system diff --git a/kernel/packages/shared/world/SceneSystemWorker.ts b/kernel/packages/shared/world/SceneSystemWorker.ts index c126a16c99..efdca708a1 100644 --- a/kernel/packages/shared/world/SceneSystemWorker.ts +++ b/kernel/packages/shared/world/SceneSystemWorker.ts @@ -21,7 +21,7 @@ export const hudWorkerUrl = URL.createObjectURL(hudWorkerBLOB) export class SceneSystemWorker extends SceneWorker { private sceneStarted: boolean = false - private position!: Vector3 + private position: Vector3 | undefined private readonly lastSentPosition = new Vector3(0, 0, 0) private readonly lastSentRotation = new Quaternion(0, 0, 0, 1) private positionObserver: Observer | null = null @@ -82,7 +82,7 @@ export class SceneSystemWorker extends SceneWorker { private sendUserViewMatrix(positionReport: Readonly) { if (this.engineAPI && 'positionChanged' in this.engineAPI.subscribedEvents) { - if (!this.lastSentPosition.equals(positionReport.position)) { + if (this.position && !this.lastSentPosition.equals(positionReport.position)) { this.engineAPI.sendSubscriptionEvent('positionChanged', { position: { x: positionReport.position.x - this.position.x,