commit 5caf653dcb7ef3bbd338d78c80869b015eb3f3bb
parent 118d0ddfa774298ff22720aed664e5e51fcac967
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Thu, 27 Jun 2024 17:38:17 -0300
fix trees position in the `y` axis
previously the trees where rendered with a gap between the terrain an
the tree log in one side of the terrain, in the other of the terrain
it was the opposite: trees were rendered buried down
this was because the trees were rendered with an offset on the `x` and
`y` axes
Diffstat:
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tp/src/track-map.js b/tp/src/track-map.js
@@ -168,18 +168,21 @@ function createInstancedTrees(count) {
continue;
}
- position.x -= widthSegments/2;
- position.y += amplitudeBottom;
- position.z -= heightSegments/2;
+ const treeOffset = 0.25;
+ // 1.50 numbero magico para posicionar correctamente los arboles con
+ // respecto al terreno
+ position.x -= (widthSegments+treesBorderPadding+1.50)/2;
+ position.y += amplitudeBottom - treeOffset;
+ position.z -= (heightSegments+treesBorderPadding)/2;
translationMatrix.makeTranslation(position);
treeLogMatrix.identity();
treeLeavesMatrix.identity();
- let scale = 0.5 + (Math.random()*(logHeight/3));
+ let scale = 0.6 + (Math.random()*(logHeight/3));
treeLogMatrix.makeScale(1, scale, 1);
treeLogMatrix.premultiply(translationMatrix);
- position.y += scale * logHeight;
+ position.y += scale*logHeight;
translationMatrix.makeTranslation(position);
treeLeavesMatrix.premultiply(translationMatrix);