remove hex tiling
This commit is contained in:
parent
96d485aabb
commit
4722783018
111
main.js
111
main.js
@ -7,7 +7,7 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
|
|||||||
import { OctreeHelper } from 'three/addons/helpers/OctreeHelper.js';
|
import { OctreeHelper } from 'three/addons/helpers/OctreeHelper.js';
|
||||||
import Stats from 'three/addons/libs/stats.module.js';
|
import Stats from 'three/addons/libs/stats.module.js';
|
||||||
|
|
||||||
import 'three-hex-tiling';
|
//import 'three-hex-tiling';
|
||||||
|
|
||||||
import MazeMesh from './MazeMesh.js';
|
import MazeMesh from './MazeMesh.js';
|
||||||
|
|
||||||
@ -118,7 +118,6 @@ scene.add(maze)
|
|||||||
console.log(String(maze))
|
console.log(String(maze))
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
|
||||||
const invisibleWall = new THREE.Mesh(new THREE.BoxGeometry( .9, 1.8, .9 ));
|
const invisibleWall = new THREE.Mesh(new THREE.BoxGeometry( .9, 1.8, .9 ));
|
||||||
invisibleWall.material.visible = false;
|
invisibleWall.material.visible = false;
|
||||||
let matrix = new THREE.Matrix4()
|
let matrix = new THREE.Matrix4()
|
||||||
@ -130,54 +129,27 @@ if (!dev) {
|
|||||||
clone.position.y = 1;
|
clone.position.y = 1;
|
||||||
mazeCollisionner.add(clone);
|
mazeCollisionner.add(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ground
|
// Ground
|
||||||
|
|
||||||
const groundGeometry = new THREE.BoxGeometry(mazeWidth, mazeWidth, 20)
|
const groundGeometry = new THREE.BoxGeometry(mazeWidth, mazeWidth, 20)
|
||||||
|
function repeatGroundMaterial (texture) {
|
||||||
|
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
||||||
|
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
|
||||||
|
}
|
||||||
const groundMaterial = new THREE.MeshStandardMaterial({
|
const groundMaterial = new THREE.MeshStandardMaterial({
|
||||||
map: loader.load(
|
map : loader.load('textures/angled-blocks-vegetation/albedo.png', repeatGroundMaterial),
|
||||||
'textures/angled-blocks-vegetation/albedo.png',
|
aoMap : loader.load('textures/angled-blocks-vegetation/ao-roughness-metalness.png', repeatGroundMaterial),
|
||||||
texture => {
|
metalnessMap: loader.load('textures/angled-blocks-vegetation/ao-roughness-metalness.png', repeatGroundMaterial),
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
normalMap : loader.load('textures/angled-blocks-vegetation/normal-dx.png', repeatGroundMaterial),
|
||||||
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
|
roughnessMap: loader.load('textures/angled-blocks-vegetation/ao-roughness-metalness.png', repeatGroundMaterial),
|
||||||
}
|
/*hexTiling : {
|
||||||
),
|
|
||||||
aoMap: loader.load(
|
|
||||||
'textures/angled-blocks-vegetation/ao-roughness-metalness.png',
|
|
||||||
texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
metalnessMap: loader.load(
|
|
||||||
'textures/angled-blocks-vegetation/ao-roughness-metalness.png',
|
|
||||||
texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
normalMap: loader.load(
|
|
||||||
'textures/angled-blocks-vegetation/normal-dx.png',
|
|
||||||
texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
roughnessMap: loader.load(
|
|
||||||
'textures/angled-blocks-vegetation/ao-roughness-metalness.png',
|
|
||||||
texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
hexTiling: {
|
|
||||||
patchScale: 1,
|
patchScale: 1,
|
||||||
useContrastCorrectedBlending: true,
|
useContrastCorrectedBlending: true,
|
||||||
lookupSkipThreshold: 0.01,
|
lookupSkipThreshold: 0.01,
|
||||||
textureSampleCoefficientExponent: 32,
|
textureSampleCoefficientExponent: 32,
|
||||||
}
|
}*/
|
||||||
})
|
})
|
||||||
|
|
||||||
const sideGroundMaterial = new THREE.MeshStandardMaterial({
|
const sideGroundMaterial = new THREE.MeshStandardMaterial({
|
||||||
@ -189,16 +161,16 @@ const sideGroundMaterial = new THREE.MeshStandardMaterial({
|
|||||||
roughness : 1,
|
roughness : 1,
|
||||||
})
|
})
|
||||||
sideGroundMaterial.map.wrapS = sideGroundMaterial.map.wrapT = THREE.RepeatWrapping
|
sideGroundMaterial.map.wrapS = sideGroundMaterial.map.wrapT = THREE.RepeatWrapping
|
||||||
sideGroundMaterial.normalMap.wrapS = sideGroundMaterial.normalMap.wrapT = THREE.RepeatWrapping
|
|
||||||
sideGroundMaterial.aoMap.wrapS = sideGroundMaterial.aoMap.wrapT = THREE.RepeatWrapping
|
|
||||||
sideGroundMaterial.roughnessMap.wrapS = sideGroundMaterial.roughnessMap.wrapT = THREE.RepeatWrapping
|
|
||||||
sideGroundMaterial.map.repeat.set(mazeWidth, 20)
|
sideGroundMaterial.map.repeat.set(mazeWidth, 20)
|
||||||
sideGroundMaterial.normalMap.repeat.set(mazeWidth, 20)
|
|
||||||
sideGroundMaterial.aoMap.repeat.set(mazeWidth, 20)
|
|
||||||
sideGroundMaterial.roughnessMap.repeat.set(mazeWidth, 20)
|
|
||||||
sideGroundMaterial.map.rotation = Math.PI
|
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.normalMap.rotation = Math.PI
|
||||||
|
sideGroundMaterial.aoMap.wrapS = sideGroundMaterial.aoMap.wrapT = THREE.RepeatWrapping
|
||||||
|
sideGroundMaterial.aoMap.repeat.set(mazeWidth, 20)
|
||||||
sideGroundMaterial.aoMap.rotation = Math.PI
|
sideGroundMaterial.aoMap.rotation = Math.PI
|
||||||
|
sideGroundMaterial.roughnessMap.wrapS = sideGroundMaterial.roughnessMap.wrapT = THREE.RepeatWrapping
|
||||||
|
sideGroundMaterial.roughnessMap.repeat.set(mazeWidth, 20)
|
||||||
sideGroundMaterial.roughnessMap.rotation = Math.PI
|
sideGroundMaterial.roughnessMap.rotation = Math.PI
|
||||||
|
|
||||||
const ground = new THREE.Mesh(
|
const ground = new THREE.Mesh(
|
||||||
@ -288,7 +260,7 @@ const oceanOctree = new Octree().fromGraphNode(ocean);
|
|||||||
|
|
||||||
const sun = new THREE.Vector3();
|
const sun = new THREE.Vector3();
|
||||||
|
|
||||||
const ambientLight = new THREE.AmbientLight(0x404040, 7);
|
const ambientLight = new THREE.AmbientLight(0x404040, 5);
|
||||||
scene.add(ambientLight);
|
scene.add(ambientLight);
|
||||||
|
|
||||||
const sunLight = new THREE.DirectionalLight(0xffffff, 1);
|
const sunLight = new THREE.DirectionalLight(0xffffff, 1);
|
||||||
@ -325,31 +297,20 @@ function updateSun() {
|
|||||||
// Raft
|
// Raft
|
||||||
|
|
||||||
const raftGeometry = new THREE.BoxGeometry(1.8, .1, 1.1, 1, 1, 16)
|
const raftGeometry = new THREE.BoxGeometry(1.8, .1, 1.1, 1, 1, 16)
|
||||||
|
function repeatRaftMaterial(texture) {
|
||||||
|
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
||||||
|
texture.repeat.set(2, 1)
|
||||||
|
}
|
||||||
const raftMaterial = new THREE.MeshStandardMaterial({
|
const raftMaterial = new THREE.MeshStandardMaterial({
|
||||||
map: loader.load("textures/Poly-wood/color_map.jpg", texture => {
|
map: loader.load("textures/Poly-wood/color_map.jpg", repeatRaftMaterial),
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
aoMap: loader.load("textures/Poly-wood/ao_map.jpg", repeatRaftMaterial),
|
||||||
texture.repeat.set(2, 1)
|
normalMap: loader.load("textures/Poly-wood/normal_map_opengl.jpg", repeatRaftMaterial),
|
||||||
}),
|
|
||||||
aoMap: loader.load("textures/Poly-wood/ao_map.jpg", texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(2, 1)
|
|
||||||
}),
|
|
||||||
normalMap: loader.load("textures/Poly-wood/normal_map_opengl.jpg", texture => {
|
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(2, 1)
|
|
||||||
}),
|
|
||||||
normalScale : new THREE.Vector2(2, 2),
|
normalScale : new THREE.Vector2(2, 2),
|
||||||
roughnessMap: loader.load("textures/Poly-wood/roughness_map.jpg", texture => {
|
roughnessMap: loader.load("textures/Poly-wood/roughness_map.jpg", repeatRaftMaterial),
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(2, 1)
|
|
||||||
}),
|
|
||||||
depthFunc: 3,
|
depthFunc: 3,
|
||||||
depthTest: true,
|
depthTest: true,
|
||||||
depthWrite: true,
|
depthWrite: true,
|
||||||
displacementMap: loader.load("textures/Poly-wood/displacement_map.jpg", texture => {
|
displacementMap: loader.load("textures/Poly-wood/displacement_map.jpg", repeatRaftMaterial),
|
||||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
|
|
||||||
texture.repeat.set(2, 1)
|
|
||||||
}),
|
|
||||||
displacementScale: -0.3,
|
displacementScale: -0.3,
|
||||||
displacementBias: 0.15,
|
displacementBias: 0.15,
|
||||||
})
|
})
|
||||||
@ -480,14 +441,22 @@ if (dev) {
|
|||||||
});
|
});
|
||||||
waveCFolder.open();
|
waveCFolder.open();
|
||||||
|
|
||||||
const HexTilingFolder = gui.addFolder('Hex Tiling')
|
const hexTilingFolder = gui.addFolder('Hex Tiling')
|
||||||
const groundMaterialFolder = HexTilingFolder.addFolder("ground")
|
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, "patchScale", 0, 10)
|
||||||
groundMaterialFolder.add(groundMaterial.hexTiling, "useContrastCorrectedBlending")
|
groundMaterialFolder.add(groundMaterial.hexTiling, "useContrastCorrectedBlending")
|
||||||
groundMaterialFolder.add(groundMaterial.hexTiling, "lookupSkipThreshold", 0, 1)
|
groundMaterialFolder.add(groundMaterial.hexTiling, "lookupSkipThreshold", 0, 1)
|
||||||
groundMaterialFolder.add(groundMaterial.hexTiling, "textureSampleCoefficientExponent", 0, 64).name("SampleCoefExp")
|
groundMaterialFolder.add(groundMaterial.hexTiling, "textureSampleCoefficientExponent", 0, 64).name("SampleCoefExp")
|
||||||
HexTilingFolder.close()
|
}
|
||||||
|
hexTilingFolder.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user