three.js dev template - module
HTML
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three/build/three.webgpu.js",
"three/webgpu": "https://unpkg.com/three/build/three.webgpu.js",
"three/tsl": "https://unpkg.com/three/build/three.tsl.js",
"three/addons/": "https://unpkg.com/three/examples/jsm/"
}
}
</script>
CSS
body {
margin: 0px;
}
JavaScript
import * as THREE from "three/webgpu"
import {
mx_noise_float,
color,
cross,
dot,
float,
bufferAttribute,
transformNormalToView,
positionLocal,
sign,
step,
Fn,
uniform,
varying,
vec2,
vec3,
Loop,
uniformArray,
sin,
} from "three/tsl"
import { GUI } from "three/addons/libs/lil-gui.module.min.js"
import { OrbitControls } from "three/addons/controls/OrbitControls.js"
import { RGBELoader } from "three/addons/loaders/RGBELoader.js"
import { VertexNormalsHelper } from "three/addons/helpers/VertexNormalsHelper.js"
import {
getHeightArray,
get_z_splines,
do_lights,
handleCurves,
getRndIntegerArray,
getRandomInt,
addCurvesToScene,
get_x_splines,
getTerrainMatrix,
varyInt,
} from "@jsfiddle/su2jhcq0.js"
import { hmap_x } from "@jsfiddle/go3svy75.js"
let camera, scene, renderer, controls, drag
init()
//******* HELPERS ********//
function init() {
camera = new THREE.PerspectiveCamera(
100,
window.innerWidth / window.innerHeight,
0.1,
100,
)
camera.position.set(0, 1, 5)
scene = new THREE.Scene()
scene.background = new THREE.Color(0x201919)
const gui = new GUI()
// environment
//const rgbeLoader = new RGBELoader();
//rgbeLoader.load( './textures/equirectangular/pedestrian_overpass_1k.hdr', ( environmentMap ) => {
// environmentMap.mapping = THREE.EquirectangularReflectionMapping;
// scene.background = environmentMap;
// scene.backgroundBlurriness = 0.5;
// scene.environment = environmentMap;
//} );
do_lights(scene)
// MATERIALS
const material = new THREE.MeshStandardNodeMaterial({
metalness: 0.1,
roughness: 0.8,
color: "#ff0000",
side: THREE.DoubleSide,
})
const material_w = new THREE.MeshStandardNodeMaterial({
metalness: 0,
roughness: 0.5,
color: "#ff0000",
wireframe: true,
})
const materialx = new THREE.LineBasicMaterial({
color: 0xff0000,
wireframe: true,
})
const materialy = new THREE.LineBasicMaterial({...