perf: inline entity from JSON
This commit is contained in:
parent
28b1312f40
commit
a66b6889f2
|
@ -56,7 +56,7 @@ const decorate = compose(
|
|||
|
||||
export class Entity extends decorate(Resource) {
|
||||
|
||||
constructor() {
|
||||
constructor(json) {
|
||||
super();
|
||||
this._hooks = {};
|
||||
this.isDirty = true;
|
||||
|
@ -69,6 +69,9 @@ export class Entity extends decorate(Resource) {
|
|||
this.removeAllTraits();
|
||||
});
|
||||
this.initializeSynchronizedChildren();
|
||||
if ('undefined' !== typeof json) {
|
||||
this.fromJSON(json);
|
||||
}
|
||||
}
|
||||
|
||||
acceptPacket(packet) {
|
||||
|
|
|
@ -94,8 +94,8 @@ export class Layer extends decorate(class {}) {
|
|||
fromJSON(json) {
|
||||
if (json.entities) {
|
||||
json.entities.forEach((entityJSON) => {
|
||||
const entity = new Entity();
|
||||
this.entityList.addEntity(entity.fromJSON(entityJSON));
|
||||
const entity = new Entity(entityJSON);
|
||||
this.entityList.addEntity(entity);
|
||||
});
|
||||
}
|
||||
if (json.tiles) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user