/
ArmatureSystem.js
35 lines (28 loc) · 947 Bytes
/
ArmatureSystem.js
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
import Fungi from "../../fungi/Fungi.js";
import { System } from "../../fungi/Ecs.js";
import Armature from "./Armature.js";
import ArmaturePreview from "./ArmaturePreview.js";
const QUERY_COM = ["Armature"];
class ArmatureSystem extends System{
static init( priority = 91 ){ Fungi.ecs.addSystem(new ArmatureSystem, priority); }
constructor(){ super(); }
update(ecs){
let e, ary = ecs.queryEntities( QUERY_COM );
for( e of ary ){
if(!e.com.Armature.isModified) continue;
//...........................................
//If Armature is active, Update the offsets.
if(e.com.Armature.isActive){
console.log("x",e.name);
Armature.updateOffsets( e ).flattenData( e );
}
//...........................................
//If Preview Exists
if(e.com.ArmaturePreview){
ArmaturePreview.flattenData( e ).updateBuffer( e );
}
e.com.Armature.isModified = false;
}
}
}
export default ArmatureSystem;