-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4dc164
commit e474400
Showing
7 changed files
with
2,174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script> | ||
import { T } from '@threlte/core' | ||
import * as THREE from 'three' | ||
import { Easing } from 'intween' | ||
import Terrain from '../lib/three.terrain.js' | ||
export let color = 0x000000 | ||
const size = 4 | ||
const xS = 63 * size | ||
const yS = 63 * size | ||
const random = (min, max) => Math.random() * (max - min) + min | ||
const island = function(coords) { | ||
const theta = Math.random() * Math.PI * 2; | ||
coords.x = 0.5 + Math.cos(theta) * coords.x * 0.4; | ||
coords.y = 0.5 + Math.sin(theta) * coords.y * 0.4; | ||
}; | ||
const valley = (coords) => { | ||
const theta = Math.random() * Math.PI * 2; | ||
const r = 0.5 * Easing.quadOut(Math.sqrt(random(0.001, 1))); | ||
coords.x = 0.5 + Math.cos(theta) * r; | ||
coords.y = 0.5 + Math.sin(theta) * r; | ||
} | ||
const material = new THREE.MeshStandardMaterial({color: 0x000000}) | ||
const terrainScene = Terrain({ | ||
easing: Terrain.EaseInOut, | ||
frequency: 15, | ||
heightmap: (g, o, feature) => { | ||
Terrain.Hill(g, o, feature, valley); | ||
}, | ||
material, | ||
maxHeight: 2800, | ||
minHeight: -0.1, | ||
steps: 1, | ||
xSegments: xS, | ||
xSize: 1024 * 32 * size, | ||
ySegments: yS, | ||
ySize: 1024 * 32 * size, | ||
}) | ||
$: material.color.set(color) | ||
</script> | ||
|
||
<T is={terrainScene} /> |
Oops, something went wrong.