commit 31a0a5c456602f148d834fcb649b4aeb62b60a13
parent ae79a2f3ad9d97f58630406fa73eeb59e41a908e
Author: Martin Klöckner <mjkloeckner@gmail.com>
Date: Tue, 25 Jun 2024 18:29:59 -0300
code cleanup and draw `railsPath` curve as line
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tp/src/rails.js b/tp/src/rails.js
@@ -1,10 +1,10 @@
import * as THREE from 'three';
import * as dat from 'dat.gui';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
-import { vertexShader, fragmentShader } from '/assets/treesShaders.js';
import { ParametricGeometry } from 'three/addons/geometries/ParametricGeometry.js';
import { ParametricGeometries } from 'three/examples/jsm/geometries/ParametricGeometries.js';
+import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';
let scene, camera, renderer, container, terrainMaterial, instancedTrees;
let spherePath;
@@ -239,6 +239,10 @@ function buildRails() {
const rails = new THREE.Mesh(railsGeometry, railsMaterial);
scene.add(rails);
}
+
+function mainLoop() {
+ requestAnimationFrame(mainLoop);
+ renderer.render(scene, camera);
}
function main() {
@@ -250,6 +254,12 @@ function main() {
new THREE.Vector3(-10, 0, -10),
], true);
+ const railsPathPoints = railsPath.getPoints(50);
+ const railsPathGeometry = new THREE.BufferGeometry().setFromPoints(railsPathPoints);
+ const railsPathMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 });
+ const railsPathMesh = new THREE.Line(railsPathGeometry, railsPathMaterial);
+ scene.add(railsPathMesh);
+
buildRailsFoundation();
buildRails();
mainLoop();