Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

fix: make camera report position from start #1928

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions kernel/packages/decentraland-ecs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions kernel/packages/shared/world/SceneSystemWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> | null = null
Expand Down Expand Up @@ -82,7 +82,7 @@ export class SceneSystemWorker extends SceneWorker {

private sendUserViewMatrix(positionReport: Readonly<PositionReport>) {
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,
Expand Down