23 lines
778 B
JavaScript
23 lines
778 B
JavaScript
|
console.log("loading environment system");
|
||
|
|
||
|
const initEnvironmentSystem = (engine) => {
|
||
|
document.querySelectorAll(".environment")
|
||
|
.forEach(entity => {
|
||
|
console.log(entity);
|
||
|
if (!entity.id) {
|
||
|
entity.id = Date.now().toString(16);
|
||
|
}
|
||
|
engine("registerEntity", entity);
|
||
|
console.log(entity.dataset);
|
||
|
let collider = engine("getComponentConstructor", "collision")(
|
||
|
entity, {
|
||
|
layers: new Set(entity.dataset.collisionLayers.split(",")),
|
||
|
mask: new Set(entity.dataset.collisionMask.split(",")),
|
||
|
collsionShape: {}
|
||
|
});
|
||
|
engine("addComponent", entity, "collision", collider);
|
||
|
});
|
||
|
|
||
|
|
||
|
}
|