HollowBond/Public/ecma/Objects/Game/HoleObjectGame.ecma.js

40 lines
1.3 KiB
JavaScript

"use strict";
const HoleObjectGame = (function(){
const HoleObjectGame = function(hollow_bond, model, geometry_factory, material_factory){
const self = this;
this.model = model;
const geom_fac = geometry_factory
|| (hollow_bond.dungeon && hollow_bond.dungeon.geometries && hollow_bond.dungeon.geometries.hole)
|| new HoleGeometryGame(hollow_bond);
const mat_fac = material_factory
|| (hollow_bond.dungeon && hollow_bond.dungeon.materials && hollow_bond.dungeon.materials.hole)
|| new HoleMaterialGame(hollow_bond);
const width = model.xt - model.xf;
const depth = model.zt - model.zf;
const floor_h = hollow_bond.room_height || 3;
const pad_y = hollow_bond.room_padding || 0;
const geometry = geom_fac.get(width, depth, model.yf, model.yt, floor_h, pad_y);
const material = mat_fac.get_material();
this.mesh = new THREE.Mesh(geometry, material);
// Posicionado en el centro del pozo en X y Z; el eje Y ya viene calculado de forma absoluta
this.mesh.position.set(
model.xf + width / 2,
0,
model.zf + depth / 2
);
this.destroy = () => {};
};
return HoleObjectGame;
})();