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

46 lines
1.5 KiB
JavaScript

"use strict";
const FrameObjectGame = (function(){
const FrameObjectGame = 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.frame)
|| new FrameGeometryGame(hollow_bond);
const mat_fac = material_factory
|| (hollow_bond.dungeon && hollow_bond.dungeon.materials && hollow_bond.dungeon.materials.frame)
|| new FrameMaterialGame(hollow_bond);
const is_horiz = model.axis === "horizontal";
const pass_w = model.width;
const pad_y = hollow_bond.room_padding || 0;
const wall_depth = pad_y * 2;
const h = model.height;
const geometry = geom_fac.get(pass_w, h, wall_depth, is_horiz);
const material = mat_fac.get_material();
this.mesh = new THREE.Mesh(geometry, material);
const floor_h = hollow_bond.room_height || 3;
// Misma cota base de suelo que la habitación
const base_y = (model.y * floor_h) + pad_y;
const center_x = is_horiz ? (model.x + model.width / 2) : model.x;
const center_y = base_y + h / 2;
const center_z = is_horiz ? model.z : (model.z + model.width / 2);
this.mesh.position.set(center_x, center_y, center_z);
this.collider = new FrameCollider(hollow_bond, model);
this.destroy = () => {};
};
return FrameObjectGame;
})();