Skip to content

Commit

Permalink
Correct the little offset in the cadastre generation
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinGaut committed Nov 27, 2024
1 parent 749fa50 commit 74ea421
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions packages/widget_legonizer/src/LegoMockupVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,29 @@ export class LegoMockupVisualizer {
const xplates = heightMap[0].length / 32;
const yplates = heightMap.length / 32;

const frustumSize = 30;
const frustumSize = 32;

const rtCamera = new OrthographicCamera(
-frustumSize * xplates,
frustumSize * xplates,
frustumSize * yplates,
-frustumSize * yplates,
-(frustumSize * xplates) / 2,
(frustumSize * xplates) / 2,
(frustumSize * yplates) / 2,
-(frustumSize * yplates) / 2,
1,
1000
);

rtScene.background = new Color('white');

rtCamera.position.set(heightMap[0].length / 2, 11, -heightMap.length / 2);
rtCamera.lookAt(heightMap[0].length / 2, 0, -heightMap.length / 2);
rtCamera.position.set(
(heightMap[0].length - 1) / 2,
11,
-(heightMap.length - 1) / 2
);
rtCamera.lookAt(
(heightMap[0].length - 1) / 2,
0,
-(heightMap.length - 1) / 2
);

const light = new DirectionalLight(0xffffff, 1);
light.position.set(-20, 20, 20);
Expand All @@ -222,11 +230,11 @@ export class LegoMockupVisualizer {
rtScene.add(line);
});

let scale = 1080;
let scale = 1920;
const renderer = new WebGLRenderer({ antialias: true });
if (heightMap[0].length > heightMap.length)
scale = 1920 / (heightMap[0].length / 32);
else scale = 1920 / (heightMap.length / 32);
scale /= heightMap[0].length / 32;
else scale /= heightMap.length / 32;

renderer.setSize(xplates * scale, yplates * scale, false);
renderer.render(rtScene, rtCamera);
Expand All @@ -237,7 +245,7 @@ export class LegoMockupVisualizer {

const link = document.createElement('a');
document.body.appendChild(link);
link.download = 'calques.jpg';
link.download = 'calqueTemplate.jpg';
link.href = imgData;
link.click();
}
Expand Down

0 comments on commit 74ea421

Please sign in to comment.