TA159

Notas, resueltos y trabajos practicos de la materia Sistemas Gráficos
Index Commits Files Refs Submodules README LICENSE
commit ae79a2f3ad9d97f58630406fa73eeb59e41a908e
parent 00b14881e1a2c7e14a49495f4afd4e70dca08689
Author: Martin Klöckner <mjkloeckner@gmail.com>
Date:   Tue, 25 Jun 2024 18:29:24 -0300

move content of `railsFoundation()` into `buildRailsFoundation()`

Diffstat:
Mtp/src/rails.js | 52++++++++++++++++++----------------------------------
1 file changed, 18 insertions(+), 34 deletions(-)
diff --git a/tp/src/rails.js b/tp/src/rails.js
@@ -67,7 +67,7 @@ function parametricRailsFoundation(u, v, target) {
     const levelMatrix = new THREE.Matrix4();
 
     let railsPathPos = railsPath.getPointAt(u);
-    let railsFoundationShapePos = railsFoundationShape.getPointAt(v);
+    let railsFoundationShapePos = railsFoundationShape.getPointAt(v).multiplyScalar(0.5);
 
     let tangente = new THREE.Vector3();
     let binormal = new THREE.Vector3();
@@ -95,24 +95,6 @@ function parametricRailsFoundation(u, v, target) {
     target.set(x, y, z);
 }
 
-function railsFoundation() {
-    railsFoundationShape = new THREE.CatmullRomCurve3([
-        new THREE.Vector3( -2, 0, 0),
-        new THREE.Vector3( -1, 0, 1),
-        new THREE.Vector3(  1, 0, 1),
-        new THREE.Vector3(  2, 0, 0),
-    ], false);
-
-    // const points = railsFoundationShape.getPoints(50);
-    // const geometry = new THREE.BufferGeometry().setFromPoints(points);
-    // const lineMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 });
-    // const curveObject = new THREE.Line(geometry, lineMaterial);
-    // scene.add(curveObject);
-
-    const pGeometry = new ParametricGeometry(parametricRailsFoundation, 100, 10);
-    return pGeometry;
-}
-
 function onResize() {
     camera.aspect = container.offsetWidth / container.offsetHeight;
     camera.updateProjectionMatrix();
@@ -186,20 +168,24 @@ function loadTextures(callback) {
     }
 }
 
-function mainLoop() {
-    requestAnimationFrame(mainLoop);
-    renderer.render(scene, camera);
-}
-
 function buildRailsFoundation() {
-    railsPath = new THREE.CatmullRomCurve3([
-        new THREE.Vector3(-10, 0,  10),
-        new THREE.Vector3( 10, 0,  10),
-        new THREE.Vector3( 10, 0, -10),
-        new THREE.Vector3(-10, 0, -10),
-    ], true);
+    railsFoundationShape = new THREE.CatmullRomCurve3([
+        new THREE.Vector3( -2, 0, 0),
+        new THREE.Vector3( -1, 0, 1),
+        new THREE.Vector3(  1, 0, 1),
+        new THREE.Vector3(  2, 0, 0),
+    ], false);
 
-    const pGeometry = railsFoundation();
+    /*
+    // show rails foundation shape
+    const points = railsFoundationShape.getPoints(50);
+    const geometry = new THREE.BufferGeometry().setFromPoints(points);
+    const lineMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 });
+    const curveObject = new THREE.Line(geometry, lineMaterial);
+    scene.add(curveObject);
+    */
+
+    const pGeometry = new ParametricGeometry(parametricRailsFoundation, 100, 10);
 
     textures.tierra.object.wrapS = THREE.MirroredRepeatWrapping;
     textures.tierra.object.wrapT = THREE.MirroredRepeatWrapping;
@@ -207,6 +193,7 @@ function buildRailsFoundation() {
     textures.tierra.object.anisotropy = 16;
 
     /*
+    // load into `map` the examples texture
     const map = new THREE.TextureLoader().load('https://threejs.org/examples/textures/uv_grid_opengl.jpg');
     map.wrapS = map.wrapT = THREE.RepeatWrapping;
     map.repeat.set(25, 1);
@@ -269,7 +256,4 @@ function main() {
 }
 
 setupThreeJs();
-// buildRailsPath();
-// createPath();
-// main();
 loadTextures(main);