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
57 lines (45 loc) · 1.69 KB
/
system.js
File metadata and controls
57 lines (45 loc) · 1.69 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
pc.extend(pc, function () {
var _schema = [ 'enabled' ];
/**
* @name pc.ZoneComponentSystem
* @description Create a new ZoneComponentSystem
* @class Defines zone in world.
* @param {pc.Application} app The application
* @extends pc.ComponentSystem
*/
var ZoneComponentSystem = function ZoneComponentSystem(app) {
this.id = 'zone';
this.app = app;
app.systems.add(this.id, this);
this.ComponentType = pc.ZoneComponent;
this.DataType = pc.ZoneComponentData;
this.schema = _schema;
this.on('beforeremove', this._onBeforeRemove, this);
};
ZoneComponentSystem = pc.inherits(ZoneComponentSystem, pc.ComponentSystem);
pc.Component._buildAccessors(pc.ZoneComponent.prototype, _schema);
pc.extend(ZoneComponentSystem.prototype, {
initializeComponentData: function(component, data, properties) {
component.enabled = data.hasOwnProperty('enabled') ? !!data.enabled : true;
if (data.size) {
if (data.size instanceof pc.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: function(entity, clone) {
var data = {
size: entity.zone.size
};
return this.addComponent(clone, data);
},
_onBeforeRemove: function(entity, component) {
component._onBeforeRemove();
}
});
return {
ZoneComponentSystem: ZoneComponentSystem
};
}());