commit 9f346a5d41cf607acaa984e2a6267db52739f27f
parent dafc276475d0c70d5f3f34e1ec5e9c19e4c98b71
Author: mjkloeckner <martin.cachari@gmail.com>
Date: Sun, 2 Jun 2024 01:43:57 -0300
leave only the base to render a plane
Diffstat:
1 file changed, 1 insertion(+), 38 deletions(-)
diff --git a/tp/src/trees.js b/tp/src/trees.js
@@ -1,17 +1,9 @@
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/shaders.js';
let scene, camera, renderer, container, material;
-const textures = {
- tierra: { url: '/assets/tierra.jpg', object: null },
- roca: { url: '/assets/roca.jpg', object: null },
- pasto: { url: '/assets/pasto.jpg', object: null },
- elevationMap: { url: '/assets/elevation_map2.png', object: null },
-};
-
function onResize() {
camera.aspect = container.offsetWidth / container.offsetHeight;
camera.updateProjectionMatrix();
@@ -55,7 +47,7 @@ function setupThreeJs() {
function buildScene() {
console.log('Building scene');
- console.log('Generating water');
+ console.log('Generating terrain');
const terrainGeometry = new THREE.PlaneGeometry(50, 50);
const terrainMaterial = new THREE.MeshPhongMaterial( {color: 0x365829, side: THREE.DoubleSide} );
const terrain = new THREE.Mesh(terrainGeometry, terrainMaterial);
@@ -64,35 +56,6 @@ function buildScene() {
scene.add(terrain);
}
-function onTextureLoaded(key, texture) {
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
- textures[key].object = texture;
- console.log('Texture `' + key + '` loaded');
-}
-
-function loadTextures(callback) {
- const loadingManager = new THREE.LoadingManager();
-
- loadingManager.onLoad = () => {
- console.log('All textures loaded');
- callback();
- };
-
- for (const key in textures) {
- console.log("Loading textures");
- const loader = new THREE.TextureLoader(loadingManager);
- const texture = textures[key];
- texture.object = loader.load(
- texture.url,
- onTextureLoaded.bind(this, key),
- null,
- (error) => {
- console.error(error);
- }
- );
- }
-}
-
function createMenu() {
const gui = new dat.GUI({ width: 400 });
}