export class FenceFactory {
map;
constructor(map) {
this.map = map;
}
createFenceGeometry(fencePositions = [], fenceMaximumHeight = 30) {
return minemap.Geometries.FenceGeometry.fromConstantHeights({
positions: minemap.Math.Vector3.fromDegreesArray(fencePositions),
maximumHeight: fenceMaximumHeight,
});
}
createFenceMaterial(imgUrl, textureOption = {}) {
const textureDefaultOption = {
speed: 10,
direction: 'up',
rotation: 0,
texRepeat: [0, 0],
};
const fenceTexture = new minemap.TextureLoader().load({
map: this.map,
texUrl: imgUrl,
});
const fenceMaterial = minemap.StandardMaterial.fromType('Texture', {
baseColorTexture: fenceTexture,
opacity: 1.0,
lightingModel: minemap.LightingModelType.None,
doubleSided: true,
});
const option = { ...textureDefaultOption, ...textureOption };
fenceMaterial.flowTexture(option);
return fenceMaterial;
}
createPrimitive(id, fenceGeometry, fenceMaterial, allowPick = true) {
const fencePrimitive = new minemap.Primitive({
id: id,
geometry: fenceGeometry,
material: fenceMaterial,
allowPick: allowPick,
});
this.map.addPrimitive(fencePrimitive);
}
removePrimitiveById(id) {
this.map.removePrimitiveById(id);
}
}