diff --git a/js/MazeMesh.js b/js/MazeMesh.js deleted file mode 100644 index df1ad5c..0000000 --- a/js/MazeMesh.js +++ /dev/null @@ -1,74 +0,0 @@ -import * as THREE from 'three'; - -export default class MazeMesh extends THREE.InstancedMesh { - constructor( width, length, height, material ) { - super( - new THREE.BoxGeometry( 1, height, 1 ), - material, - width*length - 2 - ); - this.length = length - this.width = width - this.map = new Array(length).fill().map(() => new Array(width).fill(1)) - this.start = new THREE.Vector3(width/2, .1, length/2) - this.exit = new THREE.Vector3(Math.floor(width/2), 0, 1) - - this.dig(this.exit) - this.dig(new THREE.Vector3(Math.floor(width/2), 0, 0)) - this.build ( this.exit ) - let matrix = new THREE.Matrix4() - this.count = 0 - this.map.forEach((row, z) => { - row.forEach((isWall, x) => { - if (isWall) { - matrix.setPosition( x + .5 - width/2, 0.5, z + .5 - length/2) - this.setMatrixAt( this.count, matrix ); - this.count++ - } - }) - }) - } - -dig(position) { - this.map[position.z][position.x] = 0 - } - - static DIRECTIONS = [ - new THREE.Vector3( 0, 0, -1), - new THREE.Vector3( 0, 0, 1), - new THREE.Vector3(-1, 0, 0), - new THREE.Vector3( 1, 0, 0), - ] - build(position) { - for (var direction of Array.from(this.constructor.DIRECTIONS).sort(x => .5 - Math.random())) { - var step1 = position.clone().add(direction) - var step2 = step1.clone().add(direction) - if (this.isWall(step2) == 1) { - this.dig(step1) - this.dig(step2) - this.count -= 2 - this.build(step2) - } - } - } - - isWall(position) { - if (0 <= position.x && position.x < this.width && - 0 <= position.y && - 0 <= position.z && position.z < this.length) { - return this.map[Math.floor(position.z)][Math.floor(position.x)] - } else { - return -1 - } - } - - collision(position) { - return this.isWall(this.worldToLocal(position)) - } - - toString() { - return this.map.map(row => - row.map(isWall => isWall? "██":" ").join("") - ).join("\n") - } -} \ No newline at end of file diff --git a/main.js b/main.js index 8bf3ba6..ba44f71 100644 --- a/main.js +++ b/main.js @@ -5,7 +5,6 @@ import { Water } from 'three/addons/objects/Water.js' import { PointerLockControls } from 'three/addons/controls/PointerLockControls.js' import { GUI } from 'three/addons/libs/lil-gui.module.min.js' import { OctreeHelper } from 'three/addons/helpers/OctreeHelper.js' -import { CSM } from 'three/addons/csm/CSM.js'; import Stats from 'three/addons/libs/stats.module.js' import MazeMesh from './MazeMesh.js' @@ -184,26 +183,27 @@ const sideGroundMaterial = new THREE.MeshStandardMaterial({ roughness : wallMaterial.roughness, metalness : wallMaterial.metalness, }) -loader.load('Poly-cobblestone-wall/ao_map.jpg', (texture) => { - wallMaterial.aoMap = texture - wallMaterial.metalnessMap = texture - wallMaterial.needsUpdate = true +sideGroundMaterial.map.wrapS = sideGroundMaterial.map.wrapT = THREE.RepeatWrapping +sideGroundMaterial.map.repeat.set(mazeWidth, 20) +sideGroundMaterial.map.rotation = Math.PI +sideGroundMaterial.normalMap.wrapS = sideGroundMaterial.normalMap.wrapT = THREE.RepeatWrapping +sideGroundMaterial.normalMap.repeat.set(mazeWidth, 20) +sideGroundMaterial.normalMap.rotation = Math.PI +sideGroundMaterial.roughnessMap.wrapS = sideGroundMaterial.roughnessMap.wrapT = THREE.RepeatWrapping +sideGroundMaterial.roughnessMap.repeat.set(mazeWidth, 20) +sideGroundMaterial.roughnessMap.rotation = Math.PI - const sidegroundTexture = texture.clone() +loader.load('Poly-cobblestone-wall/ao_map.jpg', (texture) => { + wallMaterial.aoMap = texture + wallMaterial.metalnessMap = texture + wallMaterial.needsUpdate = true + + const sidegroundTexture = texture.clone() sidegroundTexture.wrapS = sidegroundTexture.wrapT = THREE.RepeatWrapping sidegroundTexture.repeat.set(mazeWidth, 20) sidegroundTexture.rotation = Math.PI - sideGroundMaterial.map.wrapS = sideGroundMaterial.map.wrapT = THREE.RepeatWrapping - sideGroundMaterial.map.repeat.set(mazeWidth, 20) - sideGroundMaterial.map.rotation = Math.PI - sideGroundMaterial.normalMap.wrapS = sideGroundMaterial.normalMap.wrapT = THREE.RepeatWrapping - sideGroundMaterial.normalMap.repeat.set(mazeWidth, 20) - sideGroundMaterial.normalMap.rotation = Math.PI - sideGroundMaterial.aoMap = sidegroundTexture - sideGroundMaterial.roughnessMap.wrapS = sideGroundMaterial.roughnessMap.wrapT = THREE.RepeatWrapping - sideGroundMaterial.roughnessMap.repeat.set(mazeWidth, 20) - sideGroundMaterial.roughnessMap.rotation = Math.PI + sideGroundMaterial.aoMap = sidegroundTexture sideGroundMaterial.metalnessMap = sidegroundTexture sideGroundMaterial.needsUpdate = true @@ -246,13 +246,7 @@ const groundMaterial = new THREE.MeshStandardMaterial({ aoMap : loader.load('angled-blocks-vegetation/ao.webp', repeatGroundMaterial), metalnessMap: loader.load('angled-blocks-vegetation/ao-roughness-metalness.webp', repeatGroundMaterial), normalMap : loader.load('angled-blocks-vegetation/normal-dx.webp', repeatGroundMaterial), - roughnessMap: loader.load('angled-blocks-vegetation/ao-roughness-metalness.webp', repeatGroundMaterial), - /*hexTiling : { - patchScale: 1, - useContrastCorrectedBlending: true, - lookupSkipThreshold: 0.01, - textureSampleCoefficientExponent: 32, - }*/ + roughnessMap: loader.load('angled-blocks-vegetation/ao-roughness-metalness.webp', repeatGroundMaterial) }) const ground = new THREE.Mesh( @@ -296,7 +290,7 @@ const ocean = new Water(waterGeometry, { waterColor : 0x001e0f, distortionScale: 3.7, fog : scene.fog !== undefined, - alpha : 0.7 + alpha : 0.9 }) ocean.rotation.x = - Math.PI / 2 ocean.position.y = -0.2 @@ -526,27 +520,9 @@ if (dev) { wallMaterialFolder.add(wallMaterial, "roughness").min(0).max(1) wallMaterialFolder.add(wallMaterial, "metalness").min(0).max(1) wallMaterialFolder.add(wallMaterial, "aoMapIntensity").min(-10).max(10) - wallMaterialFolder.add(wallMaterial, "bumpScale").min(-10).max(10).onChange(() => wallMaterial.needsUpdate = true) + wallMaterialFolder.add(wallMaterial.normalScale, "x") + wallMaterialFolder.add(wallMaterial.normalScale, "y") wallMaterialFolder.close() - - if (wallMaterial?.hexTiling) { - const hexTilingFolder = gui.addFolder('Hex Tiling') - if (wallMaterial?.hexTiling?.patchScale) { - const wallMaterialFolder = hexTilingFolder.addFolder("wall") - wallMaterialFolder.add(wallMaterial.hexTiling, "patchScale", 0, 10) - wallMaterialFolder.add(wallMaterial.hexTiling, "useContrastCorrectedBlending") - wallMaterialFolder.add(wallMaterial.hexTiling, "lookupSkipThreshold", 0, 1) - wallMaterialFolder.add(wallMaterial.hexTiling, "textureSampleCoefficientExponent", 0, 64).name("SampleCoefExp") - } - if (groundMaterial?.hexTiling?.patchScale) { - const groundMaterialFolder = hexTilingFolder.addFolder("ground") - groundMaterialFolder.add(groundMaterial.hexTiling, "patchScale", 0, 10) - groundMaterialFolder.add(groundMaterial.hexTiling, "useContrastCorrectedBlending") - groundMaterialFolder.add(groundMaterial.hexTiling, "lookupSkipThreshold", 0, 1) - groundMaterialFolder.add(groundMaterial.hexTiling, "textureSampleCoefficientExponent", 0, 64).name("SampleCoefExp") - } - hexTilingFolder.close() - } } // diff --git a/textures/Poly-wood/ao_map.jpg b/textures/Poly-wood/ao_map.jpg deleted file mode 100644 index dc64283..0000000 Binary files a/textures/Poly-wood/ao_map.jpg and /dev/null differ diff --git a/textures/Poly-wood/color_map.jpg b/textures/Poly-wood/color_map.jpg deleted file mode 100644 index 3529486..0000000 Binary files a/textures/Poly-wood/color_map.jpg and /dev/null differ diff --git a/textures/Poly-wood/displacement_map.jpg b/textures/Poly-wood/displacement_map.jpg deleted file mode 100644 index 14cd50c..0000000 Binary files a/textures/Poly-wood/displacement_map.jpg and /dev/null differ diff --git a/textures/Poly-wood/normal_map_opengl.jpg b/textures/Poly-wood/normal_map_opengl.jpg deleted file mode 100644 index 79efc2b..0000000 Binary files a/textures/Poly-wood/normal_map_opengl.jpg and /dev/null differ diff --git a/textures/Poly-wood/render_map.jpg b/textures/Poly-wood/render_map.jpg deleted file mode 100644 index d0aef52..0000000 Binary files a/textures/Poly-wood/render_map.jpg and /dev/null differ diff --git a/textures/Poly-wood/roughness_map.jpg b/textures/Poly-wood/roughness_map.jpg deleted file mode 100644 index bba3258..0000000 Binary files a/textures/Poly-wood/roughness_map.jpg and /dev/null differ diff --git a/textures/angled-blocks-vegetation/albedo.png b/textures/angled-blocks-vegetation/albedo.png deleted file mode 100644 index f93fded..0000000 Binary files a/textures/angled-blocks-vegetation/albedo.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/ao-roughness-metalness.png b/textures/angled-blocks-vegetation/ao-roughness-metalness.png deleted file mode 100644 index dae1d26..0000000 Binary files a/textures/angled-blocks-vegetation/ao-roughness-metalness.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/ao.png b/textures/angled-blocks-vegetation/ao.png deleted file mode 100644 index b5aed3d..0000000 Binary files a/textures/angled-blocks-vegetation/ao.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/height.png b/textures/angled-blocks-vegetation/height.png deleted file mode 100644 index 589a6a3..0000000 Binary files a/textures/angled-blocks-vegetation/height.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/metallic.png b/textures/angled-blocks-vegetation/metallic.png deleted file mode 100644 index e7d94d6..0000000 Binary files a/textures/angled-blocks-vegetation/metallic.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/normal-dx.png b/textures/angled-blocks-vegetation/normal-dx.png deleted file mode 100644 index 73b3b2a..0000000 Binary files a/textures/angled-blocks-vegetation/normal-dx.png and /dev/null differ diff --git a/textures/angled-blocks-vegetation/roughness.png b/textures/angled-blocks-vegetation/roughness.png deleted file mode 100644 index 0342105..0000000 Binary files a/textures/angled-blocks-vegetation/roughness.png and /dev/null differ diff --git a/textures/calm-sea-skybox/bk.jpg b/textures/calm-sea-skybox/bk.jpg deleted file mode 100644 index 0152290..0000000 Binary files a/textures/calm-sea-skybox/bk.jpg and /dev/null differ diff --git a/textures/calm-sea-skybox/dn.jpg b/textures/calm-sea-skybox/dn.jpg deleted file mode 100644 index 5270feb..0000000 Binary files a/textures/calm-sea-skybox/dn.jpg and /dev/null differ diff --git a/textures/calm-sea-skybox/ft.jpg b/textures/calm-sea-skybox/ft.jpg deleted file mode 100644 index e19097c..0000000 Binary files a/textures/calm-sea-skybox/ft.jpg and /dev/null differ diff --git a/textures/calm-sea-skybox/lf.jpg b/textures/calm-sea-skybox/lf.jpg deleted file mode 100644 index c4bc05d..0000000 Binary files a/textures/calm-sea-skybox/lf.jpg and /dev/null differ diff --git a/textures/calm-sea-skybox/rt.jpg b/textures/calm-sea-skybox/rt.jpg deleted file mode 100644 index 1891a91..0000000 Binary files a/textures/calm-sea-skybox/rt.jpg and /dev/null differ diff --git a/textures/calm-sea-skybox/up.jpg b/textures/calm-sea-skybox/up.jpg deleted file mode 100644 index 3c8db46..0000000 Binary files a/textures/calm-sea-skybox/up.jpg and /dev/null differ diff --git a/textures/waternormals.jpg b/textures/waternormals.jpg deleted file mode 100644 index 9dfe03c..0000000 Binary files a/textures/waternormals.jpg and /dev/null differ