forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.js
More file actions
61 lines (46 loc) · 1.55 KB
/
system.js
File metadata and controls
61 lines (46 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { Vec3 } from '../../../math/vec3.js';
import { Component } from '../component.js';
import { ComponentSystem } from '../system.js';
import { ZoneComponent } from './component.js';
import { ZoneComponentData } from './data.js';
const _schema = ['enabled'];
/**
* @private
* @class
* @name ZoneComponentSystem
* @classdesc Defines zone in world.
* @description Create a new ZoneComponentSystem.
* @param {Application} app - The application.
* @augments ComponentSystem
*/
class ZoneComponentSystem extends ComponentSystem {
constructor(app) {
super(app);
this.id = 'zone';
this.ComponentType = ZoneComponent;
this.DataType = ZoneComponentData;
this.schema = _schema;
this.on('beforeremove', this._onBeforeRemove, this);
}
initializeComponentData(component, data, properties) {
component.enabled = data.hasOwnProperty('enabled') ? !!data.enabled : true;
if (data.size) {
if (data.size instanceof Vec3) {
component.size.copy(data.size);
} else if (data.size instanceof Array && data.size.length >= 3) {
component.size.set(data.size[0], data.size[1], data.size[2]);
}
}
}
cloneComponent(entity, clone) {
var data = {
size: entity.zone.size
};
return this.addComponent(clone, data);
}
_onBeforeRemove(entity, component) {
component._onBeforeRemove();
}
}
Component._buildAccessors(ZoneComponent.prototype, _schema);
export { ZoneComponentSystem };