diff --git a/package-lock.json b/package-lock.json
index c586bd6..e0bd8ff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,7 @@
"alea": "^1.0.1",
"autoprefixer": "^10.4.16",
"clsx": "^2.1.1",
+ "gradient-path": "^2.3.0",
"most-visible": "^2.0.0",
"postcss": "^8.4.32",
"postprocessing": "^6.33.4",
@@ -27,6 +28,7 @@
"tailwind-variants": "^0.2.1",
"tailwindcss": "^3.4.0",
"threlte-uikit": "^0.4.2",
+ "tinygradient": "^1.1.5",
"vite-imagetools": "^6.2.9"
},
"devDependencies": {
@@ -1713,6 +1715,11 @@
"meshoptimizer": "~0.18.1"
}
},
+ "node_modules/@types/tinycolor2": {
+ "version": "1.4.6",
+ "resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz",
+ "integrity": "sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw=="
+ },
"node_modules/@types/webxr": {
"version": "0.5.16",
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.16.tgz",
@@ -3169,6 +3176,14 @@
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"dev": true
},
+ "node_modules/gradient-path": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/gradient-path/-/gradient-path-2.3.0.tgz",
+ "integrity": "sha512-vZdF/Z0EpqUztzWXFjFC16lqcialHacYoRonslk/bC6CuujkuIrqx7etlzdYHY4SnUU94LRWESamZKfkGh7yYQ==",
+ "dependencies": {
+ "tinygradient": "^1.0.0"
+ }
+ },
"node_modules/graphemer": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
@@ -5084,6 +5099,20 @@
"globrex": "^0.1.2"
}
},
+ "node_modules/tinycolor2": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
+ "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw=="
+ },
+ "node_modules/tinygradient": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/tinygradient/-/tinygradient-1.1.5.tgz",
+ "integrity": "sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==",
+ "dependencies": {
+ "@types/tinycolor2": "^1.4.0",
+ "tinycolor2": "^1.0.0"
+ }
+ },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
diff --git a/package.json b/package.json
index ef953b4..d22b45d 100644
--- a/package.json
+++ b/package.json
@@ -50,6 +50,7 @@
"alea": "^1.0.1",
"autoprefixer": "^10.4.16",
"clsx": "^2.1.1",
+ "gradient-path": "^2.3.0",
"most-visible": "^2.0.0",
"postcss": "^8.4.32",
"postprocessing": "^6.33.4",
@@ -58,6 +59,7 @@
"tailwind-variants": "^0.2.1",
"tailwindcss": "^3.4.0",
"threlte-uikit": "^0.4.2",
+ "tinygradient": "^1.1.5",
"vite-imagetools": "^6.2.9"
}
}
diff --git a/src/lib/components/Hero.svelte b/src/lib/components/Hero.svelte
index 9122420..f1c3779 100644
--- a/src/lib/components/Hero.svelte
+++ b/src/lib/components/Hero.svelte
@@ -1,9 +1,104 @@
-
+
- hello world
+ hello world!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/routes/test/+page.svelte b/src/routes/test/+page.svelte
index 897496a..62b764c 100644
--- a/src/routes/test/+page.svelte
+++ b/src/routes/test/+page.svelte
@@ -1,11 +1,95 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+ style="--delay: 2.0s"
+ d="M 714.71,395.76 C 714.21 396.26, 713.93 396.81, 713.73 398.19 C 713.54 399.57, 713.51 400.64, 713.75 402.67 C 714.00 404.69, 714.34 406.09, 714.97 408.33 C 715.60 410.56, 716.03 411.90, 716.91 413.84 C 717.78 415.77, 718.36 416.81, 719.36 418.00 C 720.36 419.18, 720.93 419.63, 721.90 419.76 C 722.87 419.90, 723.56 419.60, 724.22 418.67 C 724.89 417.73, 725.10 416.85, 725.21 415.08 C 725.33 413.31, 725.11 411.95, 724.81 409.81 C 724.51 407.67, 724.01 406.34, 723.73 404.39 C 723.45 402.44, 723.28 401.52, 723.43 400.06 C 723.57 398.60, 723.76 398.01, 724.46 397.08 C 725.17 396.15, 725.61 395.95, 726.96 395.41 C 728.31 394.87, 729.21 394.75, 731.21 394.39 C 733.21 394.04, 734.47 393.89, 736.96 393.63 C 739.45 393.37, 740.90 393.26, 743.67 393.09 C 746.43 392.92, 748.16 392.97, 750.81 392.77 "
+ />
+
+
+
+
+
+
+
+
--
knotmirror 0.0.1
From c087e884c8ab1959fe2cbe00c33dd80aae1f3f8a Mon Sep 17 00:00:00 2001
From: Florian <45694132+flo-bit@users.noreply.github.com>
Date: Sun, 15 Sep 2024 18:28:56 +0200
Subject: [PATCH 2/2] procedural planets pt1
---
package-lock.json | 34 +-
package.json | 11 +-
src/lib/3D/Depth3D/Scene3D.svelte | 4 +-
src/lib/3D/PlanetModel.svelte | 65 +--
src/lib/3D/PlanetModelOld.svelte | 55 +++
src/lib/3D/PlanetScene.svelte | 20 +
src/lib/3D/Scene.svelte | 133 ++++--
src/lib/3D/planet/Planet.svelte | 29 --
src/lib/3D/planet/geometry/geometry-helper.ts | 167 --------
.../3D/planet/geometry/geometry-modifier.ts | 265 ------------
src/lib/3D/planet/geometry/vertex-helper.ts | 315 --------------
src/lib/3D/planet/nature/BirchTree.svelte | 136 ------
src/lib/3D/planet/nature/Bush.svelte | 93 -----
src/lib/3D/planet/nature/Cactus.svelte | 78 ----
src/lib/3D/planet/nature/CommonTree.svelte | 139 -------
src/lib/3D/planet/nature/PalmTree.svelte | 105 -----
src/lib/3D/planet/worlds/biome.ts | 93 -----
src/lib/3D/planet/worlds/planet.ts | 111 -----
src/lib/3D/planet/worlds/vegetation.ts | 8 -
src/lib/3D/state-new.json | 206 ++++++++++
src/lib/3D/state.json | 289 +++++++++++++
src/lib/3D/worlds/biome.ts | 125 ++++++
.../helper/colorgradient.ts | 0
src/lib/3D/worlds/helper/octtree.ts | 275 +++++++++++++
.../noise => worlds/helper}/uber-noise.ts | 0
src/lib/3D/worlds/models.ts | 154 +++++++
src/lib/3D/worlds/planet.ts | 216 ++++++++++
src/lib/3D/worlds/presets.ts | 257 ++++++++++++
src/lib/3D/worlds/worker.ts | 241 +++++++++++
src/lib/components/About.svelte | 26 +-
src/lib/components/Hero.svelte | 183 ++++-----
src/lib/components/Loading.svelte | 95 +++++
src/lib/components/Projects.svelte | 8 +-
src/lib/components/nav/Navbar.svelte | 4 +-
src/lib/images/flo-depth.png | Bin 0 -> 45982 bytes
src/lib/images/flo.png | Bin 0 -> 402053 bytes
src/lib/images/flo2-depth.png | Bin 0 -> 288360 bytes
src/lib/images/flo2.png | Bin 0 -> 5303170 bytes
src/lib/projects.ts | 73 ++--
src/routes/+page.svelte | 44 +-
static/lowpoly_nature/BirchTree_1.gltf | 317 ++++++++++++++
static/lowpoly_nature/BirchTree_2.gltf | 319 +++++++++++++++
static/lowpoly_nature/BirchTree_3.gltf | 319 +++++++++++++++
static/lowpoly_nature/BirchTree_4.gltf | 317 ++++++++++++++
static/lowpoly_nature/BirchTree_5.gltf | 319 +++++++++++++++
static/lowpoly_nature/BirchTree_Dead_1.gltf | 183 +++++++++
static/lowpoly_nature/BirchTree_Dead_2.gltf | 185 +++++++++
static/lowpoly_nature/BirchTree_Dead_3.gltf | 185 +++++++++
static/lowpoly_nature/BirchTree_Dead_4.gltf | 183 +++++++++
static/lowpoly_nature/BirchTree_Dead_5.gltf | 185 +++++++++
.../lowpoly_nature/BirchTree_Dead_Snow_1.gltf | 250 ++++++++++++
.../lowpoly_nature/BirchTree_Dead_Snow_2.gltf | 252 ++++++++++++
.../lowpoly_nature/BirchTree_Dead_Snow_3.gltf | 252 ++++++++++++
.../lowpoly_nature/BirchTree_Dead_Snow_4.gltf | 250 ++++++++++++
.../lowpoly_nature/BirchTree_Dead_Snow_5.gltf | 252 ++++++++++++
static/lowpoly_nature/BirchTree_Snow_1.gltf | 384 +++++++++++++++++
static/lowpoly_nature/BirchTree_Snow_2.gltf | 386 ++++++++++++++++++
static/lowpoly_nature/BirchTree_Snow_3.gltf | 386 ++++++++++++++++++
static/lowpoly_nature/BirchTree_Snow_4.gltf | 384 +++++++++++++++++
static/lowpoly_nature/BirchTree_Snow_5.gltf | 386 ++++++++++++++++++
static/lowpoly_nature/BushBerries_1.gltf | 183 +++++++++
static/lowpoly_nature/BushBerries_2.gltf | 185 +++++++++
static/lowpoly_nature/Bush_1.gltf | 118 ++++++
static/lowpoly_nature/Bush_2.gltf | 116 ++++++
static/lowpoly_nature/Bush_Snow_1.gltf | 185 +++++++++
static/lowpoly_nature/Bush_Snow_2.gltf | 183 +++++++++
static/lowpoly_nature/CactusFlowers_1.gltf | 116 ++++++
static/lowpoly_nature/CactusFlowers_2.gltf | 185 +++++++++
static/lowpoly_nature/CactusFlowers_3.gltf | 183 +++++++++
static/lowpoly_nature/CactusFlowers_4.gltf | 185 +++++++++
static/lowpoly_nature/CactusFlowers_5.gltf | 183 +++++++++
static/lowpoly_nature/Cactus_1.gltf | 185 +++++++++
static/lowpoly_nature/Cactus_2.gltf | 118 ++++++
static/lowpoly_nature/Cactus_3.gltf | 116 ++++++
static/lowpoly_nature/Cactus_4.gltf | 118 ++++++
static/lowpoly_nature/Cactus_5.gltf | 118 ++++++
static/lowpoly_nature/CommonTree_1.gltf | 183 +++++++++
static/lowpoly_nature/CommonTree_2.gltf | 183 +++++++++
static/lowpoly_nature/CommonTree_3.gltf | 252 ++++++++++++
static/lowpoly_nature/CommonTree_4.gltf | 250 ++++++++++++
static/lowpoly_nature/CommonTree_5.gltf | 185 +++++++++
static/lowpoly_nature/CommonTree_Dead_1.gltf | 116 ++++++
static/lowpoly_nature/CommonTree_Dead_2.gltf | 116 ++++++
static/lowpoly_nature/CommonTree_Dead_3.gltf | 118 ++++++
static/lowpoly_nature/CommonTree_Dead_4.gltf | 116 ++++++
static/lowpoly_nature/CommonTree_Dead_5.gltf | 118 ++++++
.../CommonTree_Dead_Snow_1.gltf | 183 +++++++++
.../CommonTree_Dead_Snow_2.gltf | 183 +++++++++
.../CommonTree_Dead_Snow_3.gltf | 185 +++++++++
.../CommonTree_Dead_Snow_4.gltf | 183 +++++++++
.../CommonTree_Dead_Snow_5.gltf | 185 +++++++++
static/lowpoly_nature/CommonTree_Snow_1.gltf | 250 ++++++++++++
static/lowpoly_nature/CommonTree_Snow_2.gltf | 250 ++++++++++++
static/lowpoly_nature/CommonTree_Snow_3.gltf | 319 +++++++++++++++
static/lowpoly_nature/CommonTree_Snow_4.gltf | 317 ++++++++++++++
static/lowpoly_nature/CommonTree_Snow_5.gltf | 252 ++++++++++++
static/lowpoly_nature/Corn_1.gltf | 116 ++++++
static/lowpoly_nature/Corn_2.gltf | 183 +++++++++
static/lowpoly_nature/Flowers.gltf | 248 +++++++++++
static/lowpoly_nature/Grass_1.gltf | 118 ++++++
static/lowpoly_nature/Grass_2.gltf | 118 ++++++
static/lowpoly_nature/Grass_3.gltf | 118 ++++++
static/lowpoly_nature/Lilypad.gltf | 187 +++++++++
static/lowpoly_nature/PalmTree_1.gltf | 252 ++++++++++++
static/lowpoly_nature/PalmTree_2.gltf | 250 ++++++++++++
static/lowpoly_nature/PalmTree_3.gltf | 319 +++++++++++++++
static/lowpoly_nature/PalmTree_4.gltf | 317 ++++++++++++++
static/lowpoly_nature/PineTree_1.gltf | 183 +++++++++
static/lowpoly_nature/PineTree_2.gltf | 185 +++++++++
static/lowpoly_nature/PineTree_3.gltf | 183 +++++++++
static/lowpoly_nature/PineTree_4.gltf | 183 +++++++++
static/lowpoly_nature/PineTree_5.gltf | 183 +++++++++
static/lowpoly_nature/PineTree_Snow_1.gltf | 250 ++++++++++++
static/lowpoly_nature/PineTree_Snow_2.gltf | 252 ++++++++++++
static/lowpoly_nature/PineTree_Snow_3.gltf | 250 ++++++++++++
static/lowpoly_nature/PineTree_Snow_4.gltf | 250 ++++++++++++
static/lowpoly_nature/PineTree_Snow_5.gltf | 250 ++++++++++++
static/lowpoly_nature/Plant_1.gltf | 118 ++++++
static/lowpoly_nature/Plant_2.gltf | 185 +++++++++
static/lowpoly_nature/Plant_3.gltf | 118 ++++++
static/lowpoly_nature/Plant_4.gltf | 116 ++++++
static/lowpoly_nature/Plant_5.gltf | 185 +++++++++
static/lowpoly_nature/Rock_1.gltf | 118 ++++++
static/lowpoly_nature/Rock_2.gltf | 116 ++++++
static/lowpoly_nature/Rock_3.gltf | 116 ++++++
static/lowpoly_nature/Rock_4.gltf | 116 ++++++
static/lowpoly_nature/Rock_5.gltf | 118 ++++++
static/lowpoly_nature/Rock_6.gltf | 116 ++++++
static/lowpoly_nature/Rock_7.gltf | 116 ++++++
static/lowpoly_nature/Rock_Moss_1.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_2.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_3.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_4.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_5.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_6.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Moss_7.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_1.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_2.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_3.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_4.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_5.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_6.gltf | 183 +++++++++
static/lowpoly_nature/Rock_Snow_7.gltf | 183 +++++++++
static/lowpoly_nature/TreeStump.gltf | 250 ++++++++++++
static/lowpoly_nature/TreeStump_Moss.gltf | 183 +++++++++
static/lowpoly_nature/TreeStump_Snow.gltf | 183 +++++++++
static/lowpoly_nature/Wheat.gltf | 116 ++++++
static/lowpoly_nature/Willow_1.gltf | 185 +++++++++
static/lowpoly_nature/Willow_2.gltf | 185 +++++++++
static/lowpoly_nature/Willow_3.gltf | 185 +++++++++
static/lowpoly_nature/Willow_4.gltf | 183 +++++++++
static/lowpoly_nature/Willow_5.gltf | 183 +++++++++
static/lowpoly_nature/Willow_Dead_1.gltf | 118 ++++++
static/lowpoly_nature/Willow_Dead_2.gltf | 118 ++++++
static/lowpoly_nature/Willow_Dead_3.gltf | 118 ++++++
static/lowpoly_nature/Willow_Dead_4.gltf | 116 ++++++
static/lowpoly_nature/Willow_Dead_5.gltf | 116 ++++++
static/lowpoly_nature/Willow_Dead_Snow_1.gltf | 185 +++++++++
static/lowpoly_nature/Willow_Dead_Snow_2.gltf | 185 +++++++++
static/lowpoly_nature/Willow_Dead_Snow_3.gltf | 185 +++++++++
static/lowpoly_nature/Willow_Dead_Snow_4.gltf | 183 +++++++++
static/lowpoly_nature/Willow_Dead_Snow_5.gltf | 183 +++++++++
static/lowpoly_nature/Willow_Snow_1.gltf | 252 ++++++++++++
static/lowpoly_nature/Willow_Snow_2.gltf | 252 ++++++++++++
static/lowpoly_nature/Willow_Snow_3.gltf | 252 ++++++++++++
static/lowpoly_nature/Willow_Snow_4.gltf | 250 ++++++++++++
static/lowpoly_nature/Willow_Snow_5.gltf | 250 ++++++++++++
static/lowpoly_nature/WoodLog.gltf | 250 ++++++++++++
static/lowpoly_nature/WoodLog_Moss.gltf | 384 +++++++++++++++++
static/lowpoly_nature/WoodLog_Snow.gltf | 183 +++++++++
vite.config.ts | 2 +-
171 files changed, 28083 insertions(+), 1819 deletions(-)
create mode 100644 src/lib/3D/PlanetModelOld.svelte
create mode 100644 src/lib/3D/PlanetScene.svelte
delete mode 100644 src/lib/3D/planet/Planet.svelte
delete mode 100644 src/lib/3D/planet/geometry/geometry-helper.ts
delete mode 100644 src/lib/3D/planet/geometry/geometry-modifier.ts
delete mode 100644 src/lib/3D/planet/geometry/vertex-helper.ts
delete mode 100644 src/lib/3D/planet/nature/BirchTree.svelte
delete mode 100644 src/lib/3D/planet/nature/Bush.svelte
delete mode 100644 src/lib/3D/planet/nature/Cactus.svelte
delete mode 100644 src/lib/3D/planet/nature/CommonTree.svelte
delete mode 100644 src/lib/3D/planet/nature/PalmTree.svelte
delete mode 100644 src/lib/3D/planet/worlds/biome.ts
delete mode 100644 src/lib/3D/planet/worlds/planet.ts
delete mode 100644 src/lib/3D/planet/worlds/vegetation.ts
create mode 100644 src/lib/3D/state-new.json
create mode 100644 src/lib/3D/state.json
create mode 100644 src/lib/3D/worlds/biome.ts
rename src/lib/3D/{planet => worlds}/helper/colorgradient.ts (100%)
create mode 100644 src/lib/3D/worlds/helper/octtree.ts
rename src/lib/3D/{planet/noise => worlds/helper}/uber-noise.ts (100%)
create mode 100644 src/lib/3D/worlds/models.ts
create mode 100644 src/lib/3D/worlds/planet.ts
create mode 100644 src/lib/3D/worlds/presets.ts
create mode 100644 src/lib/3D/worlds/worker.ts
create mode 100644 src/lib/components/Loading.svelte
create mode 100644 src/lib/images/flo-depth.png
create mode 100644 src/lib/images/flo.png
create mode 100644 src/lib/images/flo2-depth.png
create mode 100644 src/lib/images/flo2.png
create mode 100644 static/lowpoly_nature/BirchTree_1.gltf
create mode 100644 static/lowpoly_nature/BirchTree_2.gltf
create mode 100644 static/lowpoly_nature/BirchTree_3.gltf
create mode 100644 static/lowpoly_nature/BirchTree_4.gltf
create mode 100644 static/lowpoly_nature/BirchTree_5.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_1.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_2.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_3.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_4.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_5.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_Snow_1.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_Snow_2.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_Snow_3.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_Snow_4.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Dead_Snow_5.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Snow_1.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Snow_2.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Snow_3.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Snow_4.gltf
create mode 100644 static/lowpoly_nature/BirchTree_Snow_5.gltf
create mode 100644 static/lowpoly_nature/BushBerries_1.gltf
create mode 100644 static/lowpoly_nature/BushBerries_2.gltf
create mode 100644 static/lowpoly_nature/Bush_1.gltf
create mode 100644 static/lowpoly_nature/Bush_2.gltf
create mode 100644 static/lowpoly_nature/Bush_Snow_1.gltf
create mode 100644 static/lowpoly_nature/Bush_Snow_2.gltf
create mode 100644 static/lowpoly_nature/CactusFlowers_1.gltf
create mode 100644 static/lowpoly_nature/CactusFlowers_2.gltf
create mode 100644 static/lowpoly_nature/CactusFlowers_3.gltf
create mode 100644 static/lowpoly_nature/CactusFlowers_4.gltf
create mode 100644 static/lowpoly_nature/CactusFlowers_5.gltf
create mode 100644 static/lowpoly_nature/Cactus_1.gltf
create mode 100644 static/lowpoly_nature/Cactus_2.gltf
create mode 100644 static/lowpoly_nature/Cactus_3.gltf
create mode 100644 static/lowpoly_nature/Cactus_4.gltf
create mode 100644 static/lowpoly_nature/Cactus_5.gltf
create mode 100644 static/lowpoly_nature/CommonTree_1.gltf
create mode 100644 static/lowpoly_nature/CommonTree_2.gltf
create mode 100644 static/lowpoly_nature/CommonTree_3.gltf
create mode 100644 static/lowpoly_nature/CommonTree_4.gltf
create mode 100644 static/lowpoly_nature/CommonTree_5.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_1.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_2.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_3.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_4.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_5.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_Snow_1.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_Snow_2.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_Snow_3.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_Snow_4.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Dead_Snow_5.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Snow_1.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Snow_2.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Snow_3.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Snow_4.gltf
create mode 100644 static/lowpoly_nature/CommonTree_Snow_5.gltf
create mode 100644 static/lowpoly_nature/Corn_1.gltf
create mode 100644 static/lowpoly_nature/Corn_2.gltf
create mode 100644 static/lowpoly_nature/Flowers.gltf
create mode 100644 static/lowpoly_nature/Grass_1.gltf
create mode 100644 static/lowpoly_nature/Grass_2.gltf
create mode 100644 static/lowpoly_nature/Grass_3.gltf
create mode 100644 static/lowpoly_nature/Lilypad.gltf
create mode 100644 static/lowpoly_nature/PalmTree_1.gltf
create mode 100644 static/lowpoly_nature/PalmTree_2.gltf
create mode 100644 static/lowpoly_nature/PalmTree_3.gltf
create mode 100644 static/lowpoly_nature/PalmTree_4.gltf
create mode 100644 static/lowpoly_nature/PineTree_1.gltf
create mode 100644 static/lowpoly_nature/PineTree_2.gltf
create mode 100644 static/lowpoly_nature/PineTree_3.gltf
create mode 100644 static/lowpoly_nature/PineTree_4.gltf
create mode 100644 static/lowpoly_nature/PineTree_5.gltf
create mode 100644 static/lowpoly_nature/PineTree_Snow_1.gltf
create mode 100644 static/lowpoly_nature/PineTree_Snow_2.gltf
create mode 100644 static/lowpoly_nature/PineTree_Snow_3.gltf
create mode 100644 static/lowpoly_nature/PineTree_Snow_4.gltf
create mode 100644 static/lowpoly_nature/PineTree_Snow_5.gltf
create mode 100644 static/lowpoly_nature/Plant_1.gltf
create mode 100644 static/lowpoly_nature/Plant_2.gltf
create mode 100644 static/lowpoly_nature/Plant_3.gltf
create mode 100644 static/lowpoly_nature/Plant_4.gltf
create mode 100644 static/lowpoly_nature/Plant_5.gltf
create mode 100644 static/lowpoly_nature/Rock_1.gltf
create mode 100644 static/lowpoly_nature/Rock_2.gltf
create mode 100644 static/lowpoly_nature/Rock_3.gltf
create mode 100644 static/lowpoly_nature/Rock_4.gltf
create mode 100644 static/lowpoly_nature/Rock_5.gltf
create mode 100644 static/lowpoly_nature/Rock_6.gltf
create mode 100644 static/lowpoly_nature/Rock_7.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_1.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_2.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_3.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_4.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_5.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_6.gltf
create mode 100644 static/lowpoly_nature/Rock_Moss_7.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_1.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_2.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_3.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_4.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_5.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_6.gltf
create mode 100644 static/lowpoly_nature/Rock_Snow_7.gltf
create mode 100644 static/lowpoly_nature/TreeStump.gltf
create mode 100644 static/lowpoly_nature/TreeStump_Moss.gltf
create mode 100644 static/lowpoly_nature/TreeStump_Snow.gltf
create mode 100644 static/lowpoly_nature/Wheat.gltf
create mode 100644 static/lowpoly_nature/Willow_1.gltf
create mode 100644 static/lowpoly_nature/Willow_2.gltf
create mode 100644 static/lowpoly_nature/Willow_3.gltf
create mode 100644 static/lowpoly_nature/Willow_4.gltf
create mode 100644 static/lowpoly_nature/Willow_5.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_1.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_2.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_3.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_4.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_5.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_Snow_1.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_Snow_2.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_Snow_3.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_Snow_4.gltf
create mode 100644 static/lowpoly_nature/Willow_Dead_Snow_5.gltf
create mode 100644 static/lowpoly_nature/Willow_Snow_1.gltf
create mode 100644 static/lowpoly_nature/Willow_Snow_2.gltf
create mode 100644 static/lowpoly_nature/Willow_Snow_3.gltf
create mode 100644 static/lowpoly_nature/Willow_Snow_4.gltf
create mode 100644 static/lowpoly_nature/Willow_Snow_5.gltf
create mode 100644 static/lowpoly_nature/WoodLog.gltf
create mode 100644 static/lowpoly_nature/WoodLog_Moss.gltf
create mode 100644 static/lowpoly_nature/WoodLog_Snow.gltf
diff --git a/package-lock.json b/package-lock.json
index e0bd8ff..76fbde3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,6 +20,7 @@
"autoprefixer": "^10.4.16",
"clsx": "^2.1.1",
"gradient-path": "^2.3.0",
+ "gsap": "^3.12.5",
"most-visible": "^2.0.0",
"postcss": "^8.4.32",
"postprocessing": "^6.33.4",
@@ -35,11 +36,11 @@
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
- "@theatre/core": "^0.7.0",
- "@theatre/studio": "^0.7.0",
- "@threlte/core": "^7.0.12",
- "@threlte/extras": "^8.1.1",
- "@threlte/theatre": "^2.1.5",
+ "@theatre/core": "^0.7.2",
+ "@theatre/studio": "^0.7.2",
+ "@threlte/core": "^7.3.1",
+ "@threlte/extras": "^8.11.5",
+ "@threlte/theatre": "^2.1.8",
"@types/eslint": "8.56.0",
"@types/three": "^0.159.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
@@ -1599,9 +1600,9 @@
}
},
"node_modules/@threlte/core": {
- "version": "7.3.0",
- "resolved": "https://registry.npmjs.org/@threlte/core/-/core-7.3.0.tgz",
- "integrity": "sha512-yedstu5kcjV1/V1W0xNjkFQmL8A+n57NzjxBK+cPC1fdUtOvBtmOPxvOZ0b/TlhTyZM8XkEv4BiKrGibOrBzyA==",
+ "version": "7.3.1",
+ "resolved": "https://registry.npmjs.org/@threlte/core/-/core-7.3.1.tgz",
+ "integrity": "sha512-qGfpboBL5PWYGqPIpnRmvp0ssW551ULRZsXRpWAwSPWGughiOSL9dBZjiwWQTQHUFMEErgquo6hbFJCuWE0uTg==",
"dependencies": {
"mitt": "^3.0.1"
},
@@ -1611,9 +1612,9 @@
}
},
"node_modules/@threlte/extras": {
- "version": "8.11.2",
- "resolved": "https://registry.npmjs.org/@threlte/extras/-/extras-8.11.2.tgz",
- "integrity": "sha512-4wXIh47EoQbgjOrcbwiXFlQ3s4fPxW5x3OSfXEZgn8GGBdC8ZGdMhALyProe/6VeLhGa50uEn21vX7TcQYgn1w==",
+ "version": "8.11.5",
+ "resolved": "https://registry.npmjs.org/@threlte/extras/-/extras-8.11.5.tgz",
+ "integrity": "sha512-pskCysV52Uul6dKTvNjJdoeoRx1IgTvlv8Z9xYiBPKA5W62vQaRxMAFagwTZuyF7s4m1oDDD2DUSNkWFWohr2Q==",
"dev": true,
"dependencies": {
"@threejs-kit/instanced-sprite-mesh": "^2.4.6",
@@ -1637,9 +1638,9 @@
}
},
"node_modules/@threlte/theatre": {
- "version": "2.1.7",
- "resolved": "https://registry.npmjs.org/@threlte/theatre/-/theatre-2.1.7.tgz",
- "integrity": "sha512-VYNHsuwMKLrPcH0/gOW3FkYzPX/dXWXfedfamIt8C1DlpwfWn4c8sYdTMGyKqYah+a1hVQ1oQNu9pfTcj9c6qw==",
+ "version": "2.1.8",
+ "resolved": "https://registry.npmjs.org/@threlte/theatre/-/theatre-2.1.8.tgz",
+ "integrity": "sha512-Wi0GYmTa2vxJelDt0rvGzL+xUaQozi7RPNZkpvmIA4hnwqewKoMgwQfCI8Gi3yATvUodtVvFigxEO26H6pwySA==",
"dev": true,
"peerDependencies": {
"@theatre/core": ">=0.6",
@@ -3190,6 +3191,11 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true
},
+ "node_modules/gsap": {
+ "version": "3.12.5",
+ "resolved": "https://registry.npmjs.org/gsap/-/gsap-3.12.5.tgz",
+ "integrity": "sha512-srBfnk4n+Oe/ZnMIOXt3gT605BX9x5+rh/prT2F1SsNJsU1XuMiP0E2aptW481OnonOGACZWBqseH5Z7csHxhQ=="
+ },
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
diff --git a/package.json b/package.json
index d22b45d..60e0d82 100644
--- a/package.json
+++ b/package.json
@@ -16,11 +16,11 @@
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
- "@theatre/core": "^0.7.0",
- "@theatre/studio": "^0.7.0",
- "@threlte/core": "^7.0.12",
- "@threlte/extras": "^8.1.1",
- "@threlte/theatre": "^2.1.5",
+ "@theatre/core": "^0.7.2",
+ "@theatre/studio": "^0.7.2",
+ "@threlte/core": "^7.3.1",
+ "@threlte/extras": "^8.11.5",
+ "@threlte/theatre": "^2.1.8",
"@types/eslint": "8.56.0",
"@types/three": "^0.159.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
@@ -51,6 +51,7 @@
"autoprefixer": "^10.4.16",
"clsx": "^2.1.1",
"gradient-path": "^2.3.0",
+ "gsap": "^3.12.5",
"most-visible": "^2.0.0",
"postcss": "^8.4.32",
"postprocessing": "^6.33.4",
diff --git a/src/lib/3D/Depth3D/Scene3D.svelte b/src/lib/3D/Depth3D/Scene3D.svelte
index 5214160..6c43bd1 100644
--- a/src/lib/3D/Depth3D/Scene3D.svelte
+++ b/src/lib/3D/Depth3D/Scene3D.svelte
@@ -20,7 +20,7 @@
export let detail = 200;
- export let depthScale = 1;
+ export let depthScale = 1.5;
const map = useTexture(image.image, {
transform: (texture) => {
@@ -74,7 +74,7 @@ void main() {
vec2 rectSize = vec2(1, 1);
// Calculate distance to the edge of the rounded rectangle
- float d = sdRoundedRect(uv, rectSize, 0.1);
+ float d = sdRoundedRect(uv, rectSize, 0.2);
// Smooth transition for anti-aliasing
float aa = fwidth(d);
diff --git a/src/lib/3D/PlanetModel.svelte b/src/lib/3D/PlanetModel.svelte
index b195dc9..70aee23 100644
--- a/src/lib/3D/PlanetModel.svelte
+++ b/src/lib/3D/PlanetModel.svelte
@@ -1,55 +1,22 @@
-
-
- {#await gltf}
-
- {:then gltf}
-
-
-
- {:catch error}
-
- {/await}
-
-
-
+{#await planetMesh then mesh}
+
+{/await}
\ No newline at end of file
diff --git a/src/lib/3D/PlanetModelOld.svelte b/src/lib/3D/PlanetModelOld.svelte
new file mode 100644
index 0000000..b195dc9
--- /dev/null
+++ b/src/lib/3D/PlanetModelOld.svelte
@@ -0,0 +1,55 @@
+
+
+
+
+ {#await gltf}
+
+ {:then gltf}
+
+
+
+ {:catch error}
+
+ {/await}
+
+
+
diff --git a/src/lib/3D/PlanetScene.svelte b/src/lib/3D/PlanetScene.svelte
new file mode 100644
index 0000000..e6e6d6d
--- /dev/null
+++ b/src/lib/3D/PlanetScene.svelte
@@ -0,0 +1,20 @@
+
+
+
diff --git a/src/lib/3D/Scene.svelte b/src/lib/3D/Scene.svelte
index 613339f..05fedd7 100644
--- a/src/lib/3D/Scene.svelte
+++ b/src/lib/3D/Scene.svelte
@@ -1,6 +1,12 @@
-
{
- ref.lookAt(0, 1, 0);
- }}
- far={100}
+
+
+ {
+ ref.lookAt(0, 1, 0);
+ }}
+ far={100}
+ >
+
+
+
+
+
+
+
-
-
-
-
- {
- onPointerDown(evt.nativeEvent);
- }}
- on:pointerleave={() => {
- sizeSpring.set(2);
- onPointerLeave();
- }}
- on:pointerenter={() => {
- sizeSpring.set(2.1);
- onPointerEnter();
- }}
- on:touchstart={(evt) => {
- onPointerDown(evt.nativeEvent);
- }}
- on:touchend={() => {
- onPointerUp();
- }}
- scale={size}
->
-
-
+
+
+ {
+ onPointerDown(evt.nativeEvent);
+ }}
+ on:pointerleave={() => {
+ sizeSpring.set(1.5);
+ onPointerLeave();
+ }}
+ on:pointerenter={() => {
+ sizeSpring.set(1.6);
+ onPointerEnter();
+ }}
+ on:touchstart={(evt) => {
+ onPointerDown(evt.nativeEvent);
+ }}
+ on:touchend={() => {
+ onPointerUp();
+ }}
+ scale={size}
+ >
+
+
+
+
+
diff --git a/src/lib/3D/planet/Planet.svelte b/src/lib/3D/planet/Planet.svelte
deleted file mode 100644
index c876c05..0000000
--- a/src/lib/3D/planet/Planet.svelte
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
diff --git a/src/lib/3D/planet/geometry/geometry-helper.ts b/src/lib/3D/planet/geometry/geometry-helper.ts
deleted file mode 100644
index 62eb4c8..0000000
--- a/src/lib/3D/planet/geometry/geometry-helper.ts
+++ /dev/null
@@ -1,167 +0,0 @@
-import { BufferGeometry, BufferAttribute, Vector3, Color, Vector2, Object3D, Mesh } from 'three';
-
-import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
-
-import { Vertex } from './vertex-helper';
-
-export class GeometryHelper {
- static fromGeometry(geometry: BufferGeometry): Vertex[] {
- if (geometry.index) geometry = geometry.toNonIndexed();
- const vertices = geometry.getAttribute('position');
- const colors = geometry.getAttribute('color');
- const uvs = geometry.getAttribute('uv');
- const normals = geometry.getAttribute('normal');
-
- console.log(normals ? normals.array.length : 'no normals');
-
- const array: Vertex[] = [];
- for (let i = 0; i < vertices.count; i++) {
- const vertex: Vertex = new Vertex(vertices.getX(i), vertices.getY(i), vertices.getZ(i));
- if (colors != undefined)
- vertex.color = new Color(colors.getX(i), colors.getY(i), colors.getZ(i));
- if (uvs != undefined) vertex.uv = new Vector2(uvs.getX(i), uvs.getY(i));
- if (normals != undefined)
- vertex.normal = new Vector3(normals.getX(i), normals.getY(i), normals.getZ(i));
- array.push(vertex);
- }
- return array;
- }
-
- /**
- * creates a three.js buffer geometry from a list of vertices where each face is made of 3 subsequent vertices
- * vertices can also have an optional color, uv and normal
- *
- * @param {*} vertices - array of vertices with x, y and z coordinates (optional: color {r, g, b}, uv {x, y} and normal {x, y, z})
- * @param {*} computeNormals - if true and no normals given, the normals will be computed from the vertices (per vertex normals)
- * @returns {BufferGeometry}
- */
- static createGeometryFromVertices(
- vertices: Vertex[],
- computeNormals: boolean | undefined = undefined
- ): BufferGeometry {
- if (!vertices?.length) {
- throw new Error('No vertices given');
- }
-
- const bufferedVertices = new Float32Array(vertices.length * 3);
- const bufferedColor: Float32Array | undefined = vertices[0].color
- ? new Float32Array(vertices.length * 3)
- : undefined;
- const bufferedUVs: Float32Array | undefined = vertices[0].uv
- ? new Float32Array(vertices.length * 2)
- : undefined;
- const bufferedNormals: Float32Array | undefined = vertices[0].normal
- ? new Float32Array(vertices.length * 3)
- : undefined;
-
- for (let i = 0; i < vertices.length; i++) {
- if (vertices[i] == undefined) {
- throw new Error('Some vertices are undefined');
- }
- bufferedVertices[i * 3] = vertices[i].x;
- bufferedVertices[i * 3 + 1] = vertices[i].y;
- bufferedVertices[i * 3 + 2] = vertices[i].z;
-
- if (bufferedColor && vertices[i].color) {
- const color = vertices[i].color ?? new Color(0xffffff);
- bufferedColor[i * 3] = color.r;
- bufferedColor[i * 3 + 1] = color.g;
- bufferedColor[i * 3 + 2] = color.b;
- }
- if (bufferedUVs && vertices[i].uv) {
- const uv = vertices[i].uv ?? new Vector2(0, 0);
- bufferedUVs[i * 2] = uv.x;
- bufferedUVs[i * 2 + 1] = uv.y;
- }
-
- if (!bufferedNormals || !vertices[i].normal) continue;
- const normal = vertices[i].normal ?? new Vector3(0, 0, 0);
- bufferedNormals[i * 3] = normal.x;
- bufferedNormals[i * 3 + 1] = normal.y;
- bufferedNormals[i * 3 + 2] = normal.z;
- }
-
- return GeometryHelper.createGeometryFromArrays({
- vertices: bufferedVertices,
- colors: bufferedColor,
- uvs: bufferedUVs,
- normals: bufferedNormals,
- computeNormals
- });
- }
-
- static createGeometryFromArrays({
- vertices,
- colors,
- uvs,
- normals,
- computeNormals
- }: {
- vertices: Float32Array;
- colors?: Float32Array;
- uvs?: Float32Array;
- normals?: Float32Array;
- computeNormals?: boolean;
- }): BufferGeometry {
- const geo = new BufferGeometry();
- geo.setAttribute('position', new BufferAttribute(vertices, 3));
-
- if (colors) geo.setAttribute('color', new BufferAttribute(colors, 3));
- if (uvs) geo.setAttribute('uv', new BufferAttribute(uvs, 2));
-
- if (normals && !computeNormals) geo.setAttribute('normal', new BufferAttribute(normals, 3));
- else if (computeNormals !== false) geo.computeVertexNormals();
-
- return geo;
- }
-}
-
-export class GLTFHelper {
- models: Record;
- toLoad: number;
- loaded: number;
- done: (() => void) | undefined;
-
- gltfLoader: GLTFLoader;
-
- constructor(dict: Record, callback: (() => void) | undefined = undefined) {
- this.models = {};
-
- this.toLoad = 0;
- this.loaded = 0;
-
- this.done = callback;
-
- this.gltfLoader = new GLTFLoader();
-
- const keys = Object.keys(dict);
- for (const k of keys) {
- this.load(dict[k], k);
- }
- }
- load(name: string, file: string) {
- this.toLoad += 1;
-
- this.gltfLoader.load(file, (model) => {
- model.scene.gltf = model;
- this.loaded += 1;
-
- this.models[name] = model.scene;
-
- if (this.done != undefined && this.toLoad == this.loaded) this.done();
- });
- }
- changeMaterials(name: string, changeFunction: (material: any, model: any, name: string) => any) {
- const model = this.models[name];
- model.traverse((a: Object3D) => {
- if (a instanceof Mesh && a.material) {
- a.material = changeFunction(a.material, model, name);
- }
- });
- }
- changeMaterialsAll(changeFunction: (material: any, model: any) => any) {
- for (const k of Object.keys(this.models)) {
- this.changeMaterials(k, changeFunction);
- }
- }
-}
diff --git a/src/lib/3D/planet/geometry/geometry-modifier.ts b/src/lib/3D/planet/geometry/geometry-modifier.ts
deleted file mode 100644
index 0724721..0000000
--- a/src/lib/3D/planet/geometry/geometry-modifier.ts
+++ /dev/null
@@ -1,265 +0,0 @@
-import {
- Vector3,
- Color,
- BufferGeometry,
- IcosahedronGeometry,
- PlaneGeometry,
- Mesh,
- MeshStandardMaterial,
- type MeshStandardMaterialParameters
-} from 'three';
-
-import { Vertex, type Face, VertexHelper } from './vertex-helper';
-
-import { GeometryHelper } from './geometry-helper';
-
-import { mergeVertices, toCreasedNormals } from 'three/addons/utils/BufferGeometryUtils.js';
-import UberNoise from '../noise/uber-noise';
-
-export type ModifiedGeometryOptions = {
- name?: string;
- shape?: string;
-
- shapeOptions?: any;
-
- subdivisions?: number;
-
- length?: number;
-
- color?: Color | string | number;
-
- children?: (ModifiedGeometry | ModifiedGeometryOptions)[];
-
- rotation?: Vector3;
- scale?: Vector3;
- position?: Vector3;
-
- scatter?: number;
- scatterScale?: number;
-
- array?: [number, number, number];
-
- reverse?: boolean;
-
- geometry?: BufferGeometry;
-};
-
-type VertexModifierFunction = (v: Vertex) => Vertex | Vertex[] | null | void;
-
-export type FaceModifierFunction = (f: Face) => Face | Face[] | null | void;
-
-export class ModifiedGeometry {
- isProceduralObject = true;
-
- vertices: Vertex[];
- name: string;
-
- static Icosahedron(
- opts: ModifiedGeometryOptions & { detail?: number; radius?: number } = {
- detail: 0,
- radius: 1
- }
- ) {
- return new ModifiedGeometry({
- ...opts,
- geometry: new IcosahedronGeometry(opts.radius, opts.detail)
- });
- }
-
- static Plane(
- opts: ModifiedGeometryOptions & {
- width?: number;
- height?: number;
- widthSegments?: number;
- heightSegments?: number;
- }
- ) {
- return new ModifiedGeometry({
- ...opts,
- geometry: new PlaneGeometry(opts.width, opts.height, opts.widthSegments, opts.heightSegments)
- });
- }
-
- static fromMesh(mesh: THREE.Mesh) {
- return new ModifiedGeometry({ geometry: mesh.geometry });
- }
- static fromGeometry(geometry: BufferGeometry) {
- return new ModifiedGeometry({ geometry });
- }
-
- createGeometry() {
- return mergeVertices(GeometryHelper.createGeometryFromVertices(this.vertices));
- }
-
- createMesh(opts: MeshStandardMaterialParameters = {}) {
- return new Mesh(
- this.createGeometry(),
- new MeshStandardMaterial({
- vertexColors: true,
- flatShading: true,
- ...opts
- })
- );
- }
-
- setLengthFromNoise(noise: UberNoise) {
- this.modifyVertices((v) => {
- v.setLength(noise.get(v.x, v.y, v.z));
- });
- }
-
- setLengthFromFunction(func: (v: Vertex) => number) {
- this.modifyVertices((v) => {
- v.setLength(func(v));
- });
- }
-
- setFaceColorFromFunction(func: (f: Face) => Color) {
- this.modifyFaces((f) => {
- f.a.faceColor = func(f);
- });
- }
-
- setLengthAndFaceColorFromFunction(
- lengthFunc: (v: Vertex) => number,
- colorFunc: (f: Face) => Color,
- modifyVertex = (v: Vertex, n: number) => {
- v.setLength(n);
- }
- ) {
- this.modifyFaces((f) => {
- modifyVertex(f.a, lengthFunc(f.a));
- modifyVertex(f.b, lengthFunc(f.b));
- modifyVertex(f.c, lengthFunc(f.c));
-
- const color = colorFunc(f);
- f.a.color = color;
- f.b.color = color;
- f.c.color = color;
- });
- }
-
- scatter(amount = 0.1, scale = 100, seed = 0) {
- const noise = new UberNoise({
- min: -amount / 2,
- max: amount / 2,
- scale,
- seed
- });
- this.modifyVertices((v) => {
- v.x += noise.get(v.x, v.y, v.z);
- v.y += noise.get(v.y + scale * 100, v.z + scale * 100, v.x + scale * 100);
- v.z += noise.get(v.z + scale * 200, v.x + scale * 200, v.y + scale * 200);
- });
- }
-
- moveAlongNormalFromFunction(func: (v: Vertex) => number) {
- this.modifyFaces((f) => {
- f.a.addScaledVector(f.normal ?? new Vector3(0, 0, 0), func(f.a));
- f.b.addScaledVector(f.normal ?? new Vector3(0, 0, 0), func(f.b));
- f.c.addScaledVector(f.normal ?? new Vector3(0, 0, 0), func(f.c));
- });
- }
-
- moveAlongNormalAndColorFacesFromFunctions(
- lengthFunc: (v: Vertex) => number,
- colorFunc: (f: Face) => Color
- ) {
- this.modifyFaces((f) => {
- f.a.addScaledVector(f.a.normal ?? new Vector3(0, 0, 0), lengthFunc(f.a));
- f.b.addScaledVector(f.b.normal ?? new Vector3(0, 0, 0), lengthFunc(f.b));
- f.c.addScaledVector(f.c.normal ?? new Vector3(0, 0, 0), lengthFunc(f.c));
-
- const color = colorFunc(f);
- f.a.color = color;
- f.b.color = color;
- f.c.color = color;
- });
- }
-
- calculateVertexNormals(tolerance: number | undefined = undefined) {
- const geometry = toCreasedNormals(
- GeometryHelper.createGeometryFromVertices(this.vertices),
- tolerance
- );
-
- console.log(geometry.getAttribute('position').array.length);
- this.vertices = GeometryHelper.fromGeometry(geometry);
- }
-
- constructor(opts: ModifiedGeometryOptions = {}) {
- this.isProceduralObject = true;
-
- this.vertices = [];
- this.name = opts.name ?? 'ProcObject';
-
- if (opts.geometry) {
- this.vertices = GeometryHelper.fromGeometry(opts.geometry);
- }
-
- if (opts.subdivisions) this.subdivide(opts.subdivisions);
- }
-
- modifyVertices(modifier: VertexModifierFunction) {
- if (!modifier) return;
-
- let newVertices: Vertex[] | null = null;
- for (let i = 0; i < this.vertices.length; i++) {
- this.vertices[i].index = i;
- if (i % 3 === 0) {
- this.vertices[i].connectingVertices = [this.vertices[i + 1], this.vertices[i + 2]];
- } else if (i % 3 === 1) {
- this.vertices[i].connectingVertices = [this.vertices[i - 1], this.vertices[i + 1]];
- } else if (i % 3 === 2) {
- this.vertices[i].connectingVertices = [this.vertices[i - 2], this.vertices[i - 1]];
- }
- const res = modifier(this.vertices[i]);
- if (!res) continue;
-
- newVertices = newVertices ?? [];
- if (Array.isArray(res)) newVertices.push(...res);
- else newVertices.push(res);
- }
- if (newVertices) this.vertices = newVertices;
-
- return this.vertices;
- }
-
- modifyFaces(modifier: FaceModifierFunction, calculateNormals = true) {
- if (!modifier) return;
-
- let newFaces: Face[] | null = null;
- for (let i = 0; i < this.vertices.length; i += 3) {
- const face = {
- a: this.vertices[i],
- b: this.vertices[i + 1],
- c: this.vertices[i + 2],
- index: i / 3,
- mid: VertexHelper.midpoint(this.vertices[i], this.vertices[i + 1], this.vertices[i + 2]),
- normal: calculateNormals
- ? VertexHelper.normalFromFace(
- this.vertices[i],
- this.vertices[i + 1],
- this.vertices[i + 2]
- )
- : undefined
- };
- const res = modifier(face);
- if (!res) continue;
-
- newFaces = newFaces ?? [];
- if (Array.isArray(res)) newFaces.push(...res);
- else newFaces.push(res);
- }
- if (newFaces) this.vertices = newFaces.flatMap((f) => [f.a, f.b, f.c]);
-
- return this.vertices;
- }
-
- subdivide(num = 1) {
- this.modifyFaces((f) => {
- return VertexHelper.subdivideFace(f);
- });
- if (num > 1) this.subdivide(num - 1);
- }
-}
diff --git a/src/lib/3D/planet/geometry/vertex-helper.ts b/src/lib/3D/planet/geometry/vertex-helper.ts
deleted file mode 100644
index b3bf37f..0000000
--- a/src/lib/3D/planet/geometry/vertex-helper.ts
+++ /dev/null
@@ -1,315 +0,0 @@
-import { Vector3, Color, Vector2 } from 'three';
-
-export class Vertex extends Vector3 {
- color?: Color;
- uv?: Vector2;
- normal?: Vector3;
-
- index?: number;
-
- connectingVertices?: Vertex[];
-
- clone(): this {
- const clone = super.clone();
- clone.color = this.color?.clone();
- clone.uv = this.uv?.clone();
- clone.normal = this.normal?.clone();
- clone.index = this.index;
-
- if (this.connectingVertices) clone.connectingVertices = [...this.connectingVertices];
-
- return clone;
- }
-
- get isFirstInFace() {
- return this.index != undefined && this.index % 3 === 0;
- }
-
- set faceColor(color: Color) {
- if (!this.connectingVertices) return;
-
- this.color = color;
- for (const vertex of this.connectingVertices) {
- vertex.color = color;
- }
- }
-
- lerp(v: Vertex, alpha: number): this {
- const lerp = super.lerp(v, alpha);
- if (this.color && v.color) lerp.color = this.color?.lerp(v.color, alpha);
- if (this.uv && v.uv) lerp.uv = this.uv?.lerp(v.uv, alpha);
- if (this.normal && v.normal) lerp.normal = this.normal?.lerp(v.normal, alpha);
-
- return lerp;
- }
-}
-
-export type Face = {
- a: Vertex;
- b: Vertex;
- c: Vertex;
- index?: number;
- mid?: Vector3;
- normal?: Vector3;
-};
-
-export class VertexHelper {
- static subdivideFace(face: Face) {
- const newFaces: Face[] = [];
- const d = VertexHelper.midpoint(face.a, face.b);
- const e = VertexHelper.midpoint(face.b, face.c);
- const f = VertexHelper.midpoint(face.c, face.a);
- newFaces.push({ a: d.clone(), b: e.clone(), c: f.clone() });
- newFaces.push({ a: face.a.clone(), b: d.clone(), c: f.clone() });
- newFaces.push({ a: d.clone(), b: face.b.clone(), c: e.clone() });
- newFaces.push({ a: e.clone(), b: face.c.clone(), c: f.clone() });
- return newFaces;
- }
-
- static midpoint(a: Vertex, ...rest: Vertex[]): Vertex {
- const mid = a.clone();
- for (const v of rest) {
- mid.add(v);
- }
- mid.divideScalar(rest.length + 1);
- return mid;
- }
-
- static normalFromFace(a: Vertex, b: Vertex, c: Vertex): Vector3 {
- const ab = b.clone().sub(a);
- const ac = c.clone().sub(a);
- return ab.cross(ac).normalize();
- }
-}
-
-/*
-export class VertexHelper {
- static splitAlongLongestSide(
- a: Vertex,
- b: Vertex,
- c: Vertex,
- array: Vertex[] | undefined = undefined
- ) {
- array = array ?? [];
- let ab = a.distanceTo(b);
- let bc = b.distanceTo(c);
- let ca = c.distanceTo(a);
- if (ab > bc && ab > ca) {
- let mid = b.clone().add(a).divideScalar(2);
- array.push(
- a.clone(),
- mid.clone(),
- c.clone(),
- mid.clone(),
- b.clone(),
- c.clone()
- );
- } else if (bc > ab && bc > ca) {
- let mid = c.clone().add(b).divideScalar(2);
- array.push(
- a.clone(),
- b.clone(),
- mid.clone(),
- mid.clone(),
- c.clone(),
- a.clone()
- );
- } else {
- let mid = a.clone().add(c).divideScalar(2);
- array.push(
- a.clone(),
- b.clone(),
- mid.clone(),
- b.clone(),
- c.clone(),
- mid.clone()
- );
- }
- return array;
- }
-
- // turns rectangle with sides ab, bc, cd, da into two triangles
- static makeFacesFromRect(
- a: Vertex,
- b: Vertex,
- c: Vertex,
- d: Vertex,
- array: Vertex[] | undefined = undefined
- ) {
- array = array || [];
- array.push(
- a.clone(),
- d.clone(),
- c.clone(),
- a.clone(),
- c.clone(),
- b.clone()
- );
- return array;
- }
-
- static midpoint(a: Vertex, b: Vertex) {
- return a.clone().lerp(b, 0.5);
- }
-
- static createPerFaceVerticesFromIndices(ver, ind) {
- let vertices = [];
- for (let i = 0; i < ind.length; i++) {
- let vi = ind[i] * 3;
- vertices.push(Helper.makeVertex(ver[vi], ver[vi + 1], ver[vi + 2]));
- }
- return vertices;
- }
-
- static subdivideFace(
- a: Vertex,
- b: Vertex,
- c: Vertex,
- noClone: boolean = false
- ) {
- let newFaces = [];
- let d = Helper.midpoint(a, b);
- let e = Helper.midpoint(b, c);
- let f = Helper.midpoint(c, a);
- if (noClone == true) {
- newFaces.push(d, e, f);
- newFaces.push(a, d, f);
- newFaces.push(d, b, e);
- newFaces.push(e, c, f);
- } else {
- newFaces.push(d.clone(), e.clone(), f.clone());
- newFaces.push(a.clone(), d.clone(), f.clone());
- newFaces.push(d.clone(), b.clone(), e.clone());
- newFaces.push(e.clone(), c.clone(), f.clone());
- }
- return newFaces;
- }
-
- static addArrayToArray(toArr, fromArr) {
- for (let i of fromArr) {
- toArr.push(i);
- }
- }
-
- static vertexPosForAngle(a, h, r) {
- return new THREE.Vector3(Math.sin(a) * (r || 1), h, Math.cos(a) * (r || 1));
- }
-
- static addMorphToGeo(geo, morphGeo) {
- if (geo.morphAttributes.position == undefined)
- geo.morphAttributes.position = [];
- if (geo.morphAttributes.normal == undefined)
- geo.morphAttributes.normal = [];
-
- let i = geo.morphAttributes.position.length;
- geo.morphAttributes.position[i] = morphGeo.getAttribute("position").clone();
- geo.morphAttributes.normal[i] = morphGeo.getAttribute("normal").clone();
- }
-
- static makeVertex(x, y, z) {
- return new THREE.Vector3(x, y, z);
- }
- static makeFace(a, b, c, index) {
- let mid = Helper.makeVertex(
- (a.x + b.x + c.x) / 3,
- (a.y + b.y + c.y) / 3,
- (a.z + b.z + c.z) / 3
- );
- return {
- a: a,
- b: b,
- c: c,
- face: index,
- mid: mid,
- };
- }
-
- // barycentric method
- static isPointInFace(face, v) {
- var v0 = face.c.clone().sub(face.a);
- var v1 = face.b.clone().sub(face.a);
- var v2 = v.clone().sub(face.a);
- var dot00 = v0.dot(v0);
- var dot01 = v0.dot(v1);
- var dot02 = v0.dot(v2);
- var dot11 = v1.dot(v1);
- var dot12 = v1.dot(v2);
- var invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
- var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
- return u >= 0 && v >= 0 && u + v < 1;
- }
-
- static randomPointInFace(face, RNG) {
- // Call the corners of the triangle A, B, C, the side vectors AB, BC, AC
- let ab = face.b.clone().sub(face.a);
- let bc = face.c.clone().sub(face.b);
- let ac = face.c.clone().sub(face.a);
- // generate two random numbers in [0,1] called u and v.
- let u = RNG != undefined ? RNG.random() : Math.random();
- let v = RNG != undefined ? RNG.random() : Math.random();
- // Let p = u * AB + v * AC.
- let p = ab.clone().multiplyScalar(u).add(ac.clone().multiplyScalar(v));
-
- // If A+p is inside the triangle, return A+p
- let point = face.a.clone().add(p);
-
- // If A+p is outside the triangle, return A + AB + AC - p
- if (!Helper.isPointInFace(face, point)) {
- point.sub(p.multiplyScalar(2));
- point.add(ab);
- point.add(ac);
- }
- return point;
- }
-
- // load pixel data of image so we can access it with getPixel(data, x, y) where x, y in range [0, 1]
- static loadImageData(image) {
- let canvas = document.createElement("canvas");
- canvas.width = image.width;
- canvas.height = image.height;
-
- let context = canvas.getContext("2d");
- context.drawImage(image, 0, 0);
-
- return context.getImageData(0, 0, image.width, image.height);
- }
- // returns pixel as a THREE.Color() object with an addition alpha (a)
- static getPixel(imageData, x, y) {
- // convert from [0, 1] to [0, width/height in pixel]
- x = Math.min(Math.floor(imageData.width * x), imageData.width - 1);
- y = Math.min(Math.floor(imageData.height * y), imageData.height - 1);
-
- let position = (x + imageData.width * y) * 4,
- data = imageData.data;
-
- let color = new THREE.Color(
- data[position],
- data[position + 1],
- data[position + 2]
- );
- color.a = data[position + 3];
- return color;
- }
-}
-
-function rectToTriangles(
- a: Vector3,
- b: Vector3,
- c: Vector3,
- d: Vector3,
- array: Vector3[] | undefined = undefined
-) {
- array = array ?? [];
- array.push(a.clone(), d.clone(), c.clone(), a.clone(), c.clone(), b.clone());
- return array;
-}
-
-function vertexForAngleHeightRadius(angle = 0, height = 0, radius = 1) {
- return new Vector3(
- Math.sin(angle) * radius,
- height,
- Math.cos(angle) * radius
- );
-}
-*/
diff --git a/src/lib/3D/planet/nature/BirchTree.svelte b/src/lib/3D/planet/nature/BirchTree.svelte
deleted file mode 100644
index 0de81ee..0000000
--- a/src/lib/3D/planet/nature/BirchTree.svelte
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
- {#await gltf}
-
- {:then gltf}
-
-
-
-
- {#if dead && snow}
-
- {:else if !dead}
-
-
-
- {#if snow}
-
- {/if}
- {/if}
-
- {:catch error}
-
- {/await}
-
-
-
diff --git a/src/lib/3D/planet/nature/Bush.svelte b/src/lib/3D/planet/nature/Bush.svelte
deleted file mode 100644
index d533450..0000000
--- a/src/lib/3D/planet/nature/Bush.svelte
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
- {#await gltf}
-
- {:then gltf}
-
-
- {#if snow}
-
- {:else if berries}
-
- {/if}
-
- {:catch error}
-
- {/await}
-
-
-
diff --git a/src/lib/3D/planet/nature/Cactus.svelte b/src/lib/3D/planet/nature/Cactus.svelte
deleted file mode 100644
index d017085..0000000
--- a/src/lib/3D/planet/nature/Cactus.svelte
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- {#await gltf}
-
- {:then gltf}
-
-
- {#if flower}
-
- {/if}
-
- {:catch error}
-
- {/await}
-
-
-
diff --git a/src/lib/3D/planet/nature/CommonTree.svelte b/src/lib/3D/planet/nature/CommonTree.svelte
deleted file mode 100644
index 20d64a5..0000000
--- a/src/lib/3D/planet/nature/CommonTree.svelte
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
- {#await gltf}
-
- {:then gltf}
-
-
- {#if !dead}
-
- {/if}
- {#if snow && dead}
-
- {/if}
- {#if !snow && !dead && gltf.nodes.CommonTree_3}
-
- {/if}
-
- {#if snow}
-
- {/if}
- {#if snow}
-
- {/if}
-
-
- {:catch error}
-
- {/await}
-
-
-
diff --git a/src/lib/3D/planet/nature/PalmTree.svelte b/src/lib/3D/planet/nature/PalmTree.svelte
deleted file mode 100644
index 5a89a01..0000000
--- a/src/lib/3D/planet/nature/PalmTree.svelte
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
-
- {#await gltf}
-
- {:then gltf}
-
-
-
-
- {#if coconuts && (variant === 4 || variant === 3)}
-
- {/if}
-
- {:catch error}
-
- {/await}
-
-
-
diff --git a/src/lib/3D/planet/worlds/biome.ts b/src/lib/3D/planet/worlds/biome.ts
deleted file mode 100644
index 1680e57..0000000
--- a/src/lib/3D/planet/worlds/biome.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-
-a biome has a collection of items that can be found in it
-a height map and a color map
-
-*/
-import { UberNoise, type UberNoiseOptions } from '../noise/uber-noise';
-import { Color, Vector3 } from 'three';
-
-import { ColorGradient, type ColorGradientOptions } from '../helper/colorgradient';
-
-export type BiomeOptions = {
- name?: string;
-
- preset?: string;
-
- noise?: UberNoiseOptions;
- colors?: ColorGradientOptions;
-
- vegetation?: {
- density: number;
- items: {
- name: string;
- chance: number;
- }[];
- };
-};
-
-const biomePresets: Record = {
- test: {
- noise: {
- min: 0,
- max: 0.1,
- octaves: 4,
- lacunarity: 2.0,
- gain: {
- min: 0.01,
- max: 0.8,
- scale: 2
- },
- warp: 0.2,
- scale: 1.5,
- seed: 0
- },
- colors: [
- [0.0, 0xccaa00],
- [0.2, 0xccaa00],
- [0.6, 0x007700],
- [1.0, 0x006622]
- ]
- }
-};
-
-export class Biome {
- noise: UberNoise | undefined;
-
- colors: ColorGradient | undefined;
-
- constructor(opts: BiomeOptions = {}) {
- if (opts.preset) {
- const preset = biomePresets[opts.preset];
- if (preset) {
- opts = {
- ...preset,
- ...opts
- };
- }
- }
-
- if (opts.noise) this.noise = new UberNoise(opts.noise);
-
- if (opts.colors) {
- this.colors = new ColorGradient(opts.colors);
-
- console.log(this.colors);
- }
- }
-
- getHeight(pos: Vector3): number | undefined {
- if (this.noise) return this.noise.get(pos);
-
- return undefined;
- }
-
- getColor(pos: Vector3): Color | undefined {
- if (this.noise && this.colors) {
- const alpha = (this.noise.normalized(pos) + 1) * 0.5;
- return this.colors.get(alpha);
- }
-
- return undefined;
- }
-}
diff --git a/src/lib/3D/planet/worlds/planet.ts b/src/lib/3D/planet/worlds/planet.ts
deleted file mode 100644
index 20a353a..0000000
--- a/src/lib/3D/planet/worlds/planet.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Biome, type BiomeOptions } from './biome';
-import { ModifiedGeometry, type ModifiedGeometryOptions } from '../geometry/geometry-modifier';
-import { Color, Mesh, IcosahedronGeometry, MeshStandardMaterial } from 'three';
-import UberNoise, { type UberNoiseOptions } from '../noise/uber-noise';
-import { ColorGradient, type ColorGradientOptions } from '../helper/colorgradient';
-
-export type PlanetOptions = {
- scatter?: number;
-
- ground?: number;
-
- ocean?: {
- level: number;
-
- colors: [number, number][];
-
- noise: UberNoiseOptions;
- };
-};
-
-export class Planet {
- baseGeometry: ModifiedGeometry;
- modifiedGeometry: ModifiedGeometry;
- oceanGeometry: ModifiedGeometry;
-
- mesh: Mesh | undefined;
-
- biome: Biome;
-
- options: PlanetOptions;
-
- ground: number;
-
- constructor(
- biomeOptions: BiomeOptions,
- planetOptions: PlanetOptions = {},
- shapeOptions: ModifiedGeometryOptions = {
- geometry: new IcosahedronGeometry(1, 30)
- }
- ) {
- this.options = planetOptions;
-
- this.baseGeometry = new ModifiedGeometry(shapeOptions);
- this.modifiedGeometry = new ModifiedGeometry(shapeOptions);
-
- this.oceanGeometry = new ModifiedGeometry(shapeOptions);
-
- this.biome = new Biome(biomeOptions);
-
- this.ground = this.options.ground ?? 1.0;
- }
-
- createMesh(): Mesh {
- if (this.options.scatter) this.modifiedGeometry.scatter(this.options.scatter);
-
- this.modifiedGeometry.setLengthAndFaceColorFromFunction(
- (v) => this.ground + (this.biome.getHeight(v) ?? 0),
- (f) => this.biome.getColor(f.mid ?? f.a) ?? new Color(0xffffff)
- );
-
- this.mesh = this.modifiedGeometry.createMesh();
-
- const ocean = this.createOceanMesh();
- if (ocean.material instanceof MeshStandardMaterial) {
- ocean.material.transparent = true;
- ocean.material.opacity = 0.8;
- ocean.material.metalness = 0.5;
- ocean.material.roughness = 0.5;
- }
- this.mesh.add(ocean);
-
- return this.mesh;
- }
-
- createOceanMesh(): Mesh {
- const ocean: {
- level: number;
- colors: ColorGradientOptions;
- noise: UberNoiseOptions;
- } = this.options.ocean ?? {
- level: 0.05,
- colors: [
- [0, 0x000066],
- [0.35, 0x0000aa],
- [0.8, 0x00ccff]
- ],
- noise: {
- min: -0.01,
- max: 0.01,
- scale: 10
- }
- };
- const oceanNoise = new UberNoise(ocean.noise);
-
- const colorGradient = new ColorGradient(ocean.colors);
-
- this.oceanGeometry.scatter(this.options.scatter);
-
- this.oceanGeometry.setLengthAndFaceColorFromFunction(
- (v) => this.ground + ocean.level + oceanNoise.get(v),
- (f) => {
- const waterDepth =
- (((this.biome.getHeight(f.mid ?? f.a) ?? 0) - ocean.level) / ocean.level + 1) / 2;
-
- return colorGradient.get(waterDepth);
- }
- );
-
- return this.oceanGeometry.createMesh();
- }
-}
diff --git a/src/lib/3D/planet/worlds/vegetation.ts b/src/lib/3D/planet/worlds/vegetation.ts
deleted file mode 100644
index 35bf723..0000000
--- a/src/lib/3D/planet/worlds/vegetation.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// load all the vegetation models
-// models should be either
-
-// color vegetation
-
-// instanced mesh vegetation
-
-// one vegetation item can have multiple models
diff --git a/src/lib/3D/state-new.json b/src/lib/3D/state-new.json
new file mode 100644
index 0000000..1af63ea
--- /dev/null
+++ b/src/lib/3D/state-new.json
@@ -0,0 +1,206 @@
+{
+ "sheetsById": {
+ "default": {
+ "staticOverrides": {
+ "byObject": {
+ "planet": {
+ "position": {
+ "x": 0,
+ "y": -1.54635628247858,
+ "z": 0
+ },
+ "rotation": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ },
+ "camera": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 5
+ },
+ "rotation": {
+ "x": 50,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ }
+ }
+ },
+ "sequence": {
+ "subUnitsPerUnit": 30,
+ "length": 10,
+ "type": "PositionalSequence",
+ "tracksByObject": {
+ "planet": {
+ "trackData": {
+ "dnnWz3pFAE": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"x\"]",
+ "keyframes": []
+ },
+ "voGNNDqzWc": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"y\"]",
+ "keyframes": []
+ },
+ "3POG3W7VuU": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"z\"]",
+ "keyframes": []
+ }
+ },
+ "trackIdByPropPath": {
+ "[\"position\",\"x\"]": "dnnWz3pFAE",
+ "[\"position\",\"y\"]": "voGNNDqzWc",
+ "[\"position\",\"z\"]": "3POG3W7VuU"
+ }
+ },
+ "camera": {
+ "trackData": {
+ "zvhTdyhI_a": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"x\"]",
+ "keyframes": [
+ {
+ "id": "azbx576M9F",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 50
+ },
+ {
+ "id": "7ttM3u2xiz",
+ "position": 2,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ },
+ "onnFYicqIh": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"y\"]",
+ "keyframes": []
+ },
+ "RTGMZwrVXl": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"z\"]",
+ "keyframes": [
+ {
+ "id": "8OvNz5yMka",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ },
+ {
+ "id": "i7PWk_TiFo",
+ "position": 2,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ },
+ "zo10cwF9iF": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"x\"]",
+ "keyframes": []
+ },
+ "5j2_W2p49o": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"y\"]",
+ "keyframes": []
+ },
+ "CCNZpB9sxP": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"z\"]",
+ "keyframes": [
+ {
+ "id": "0pulbv92kF",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.77,
+ 0
+ ],
+ "type": "bezier",
+ "value": 10
+ },
+ {
+ "id": "AYruCOJ6oj",
+ "position": 2,
+ "connectedRight": true,
+ "handles": [
+ 0.175,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ }
+ },
+ "trackIdByPropPath": {
+ "[\"rotation\",\"x\"]": "zvhTdyhI_a",
+ "[\"rotation\",\"y\"]": "onnFYicqIh",
+ "[\"rotation\",\"z\"]": "RTGMZwrVXl",
+ "[\"position\",\"x\"]": "zo10cwF9iF",
+ "[\"position\",\"y\"]": "5j2_W2p49o",
+ "[\"position\",\"z\"]": "CCNZpB9sxP"
+ }
+ }
+ }
+ }
+ }
+ },
+ "definitionVersion": "0.4.0",
+ "revisionHistory": [
+ "bOZ-LeLKY9-GAkh7",
+ "fADzXr5CC7jTQseN",
+ "l30cMOfZ3-bzgBCO",
+ "53Zd3JAcFU6OEATa",
+ "IZpHhIeaW9cKqnVz"
+ ]
+}
\ No newline at end of file
diff --git a/src/lib/3D/state.json b/src/lib/3D/state.json
new file mode 100644
index 0000000..aaab146
--- /dev/null
+++ b/src/lib/3D/state.json
@@ -0,0 +1,289 @@
+{
+ "sheetsById": {
+ "default": {
+ "staticOverrides": {
+ "byObject": {
+ "planet": {
+ "position": {
+ "x": 0,
+ "y": -1.54635628247858,
+ "z": 0
+ },
+ "rotation": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ },
+ "camera": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 5
+ },
+ "rotation": {
+ "x": 50,
+ "y": 0,
+ "z": 0
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ }
+ }
+ },
+ "sequence": {
+ "subUnitsPerUnit": 30,
+ "length": 10,
+ "type": "PositionalSequence",
+ "tracksByObject": {
+ "planet": {
+ "trackData": {
+ "dnnWz3pFAE": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"x\"]",
+ "keyframes": [
+ {
+ "id": "BKosfo3ixV",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ },
+ {
+ "id": "aklR7oQdmG",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": -1.23967105616715
+ }
+ ]
+ },
+ "voGNNDqzWc": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"y\"]",
+ "keyframes": [
+ {
+ "id": "M_gJE9ft4U",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": -1.54635628247858
+ },
+ {
+ "id": "jwcVJX9f3_",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0.7033898619652281
+ }
+ ]
+ },
+ "3POG3W7VuU": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "planet:[\"position\",\"z\"]",
+ "keyframes": [
+ {
+ "id": "V0XdnpsdYU",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ },
+ {
+ "id": "L0_6bpsHc5",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ }
+ },
+ "trackIdByPropPath": {
+ "[\"position\",\"x\"]": "dnnWz3pFAE",
+ "[\"position\",\"y\"]": "voGNNDqzWc",
+ "[\"position\",\"z\"]": "3POG3W7VuU"
+ }
+ },
+ "camera": {
+ "trackData": {
+ "zvhTdyhI_a": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"x\"]",
+ "keyframes": [
+ {
+ "id": "azbx576M9F",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 40
+ },
+ {
+ "id": "7ttM3u2xiz",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ },
+ "onnFYicqIh": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"y\"]",
+ "keyframes": []
+ },
+ "RTGMZwrVXl": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"rotation\",\"z\"]",
+ "keyframes": [
+ {
+ "id": "8OvNz5yMka",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ },
+ {
+ "id": "i7PWk_TiFo",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ },
+ "zo10cwF9iF": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"x\"]",
+ "keyframes": []
+ },
+ "5j2_W2p49o": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"y\"]",
+ "keyframes": []
+ },
+ "CCNZpB9sxP": {
+ "type": "BasicKeyframedTrack",
+ "__debugName": "camera:[\"position\",\"z\"]",
+ "keyframes": [
+ {
+ "id": "0pulbv92kF",
+ "position": 0,
+ "connectedRight": true,
+ "handles": [
+ 0.5,
+ 1,
+ 0.77,
+ 0
+ ],
+ "type": "bezier",
+ "value": 10
+ },
+ {
+ "id": "AYruCOJ6oj",
+ "position": 3,
+ "connectedRight": true,
+ "handles": [
+ 0.175,
+ 1,
+ 0.5,
+ 0
+ ],
+ "type": "bezier",
+ "value": 0
+ }
+ ]
+ }
+ },
+ "trackIdByPropPath": {
+ "[\"rotation\",\"x\"]": "zvhTdyhI_a",
+ "[\"rotation\",\"y\"]": "onnFYicqIh",
+ "[\"rotation\",\"z\"]": "RTGMZwrVXl",
+ "[\"position\",\"x\"]": "zo10cwF9iF",
+ "[\"position\",\"y\"]": "5j2_W2p49o",
+ "[\"position\",\"z\"]": "CCNZpB9sxP"
+ }
+ }
+ }
+ }
+ }
+ },
+ "definitionVersion": "0.4.0",
+ "revisionHistory": [
+ "iPKF_7Liopss0hr6",
+ "tOw22eD1UUuWYf3L",
+ "bOZ-LeLKY9-GAkh7",
+ "fADzXr5CC7jTQseN",
+ "l30cMOfZ3-bzgBCO",
+ "53Zd3JAcFU6OEATa",
+ "IZpHhIeaW9cKqnVz"
+ ]
+}
\ No newline at end of file
diff --git a/src/lib/3D/worlds/biome.ts b/src/lib/3D/worlds/biome.ts
new file mode 100644
index 0000000..f531bc4
--- /dev/null
+++ b/src/lib/3D/worlds/biome.ts
@@ -0,0 +1,125 @@
+import { UberNoise, type UberNoiseOptions } from "./helper/uber-noise";
+import { Color, Vector3 } from "three";
+
+import {
+ ColorGradient,
+ type ColorGradientOptions,
+} from "./helper/colorgradient";
+import { biomePresets } from "./presets";
+
+export type BiomeOptions = {
+ name?: string;
+
+ preset?: string;
+
+ noise?: UberNoiseOptions;
+ colors?: ColorGradientOptions;
+
+ seaNoise?: UberNoiseOptions;
+ seaColors?: ColorGradientOptions;
+
+ tintColor?: number;
+
+ vegetation?: {
+ items: {
+ name: string;
+ density: number;
+
+ minimumHeight?: number;
+ maximumHeight?: number;
+
+ minimumDistance?: number;
+ maximumDistance?: number;
+ colors?: Record;
+ }[];
+ };
+};
+
+export class Biome {
+ noise: UberNoise | undefined;
+ colors: ColorGradient | undefined;
+
+ seaNoise: UberNoise | undefined;
+ seaColors: ColorGradient | undefined;
+
+ options: BiomeOptions;
+
+ constructor(opts: BiomeOptions = {}) {
+ if (opts.preset) {
+ const preset = biomePresets[opts.preset];
+ if (preset) {
+ opts = {
+ ...preset,
+ ...opts,
+ };
+ }
+ }
+
+ this.options = opts;
+
+ if (opts.noise) this.noise = new UberNoise(opts.noise);
+
+ if (opts.colors) {
+ this.colors = new ColorGradient(opts.colors);
+ }
+
+ if (opts.seaNoise) this.seaNoise = new UberNoise(opts.seaNoise);
+
+ if (opts.seaColors) {
+ this.seaColors = new ColorGradient(opts.seaColors);
+ }
+ }
+
+ get min(): number {
+ return this.noise?.min ?? -1;
+ }
+
+ get max(): number {
+ return this.noise?.max ?? 1;
+ }
+
+ getHeight(pos: Vector3): number {
+ if (this.noise) return this.noise.get(pos);
+
+ return 0;
+ }
+
+ getColor(
+ pos: Vector3,
+ height: number | undefined = undefined,
+ steepness: number = 0,
+ ): Color | undefined {
+ if (this.noise && height === undefined) {
+ height = this.noise.normalized(pos);
+ }
+
+ if (this.colors) {
+ const color = this.colors.get(height);
+ if (this.options.tintColor) {
+ return color.lerp(
+ new Color(this.options.tintColor),
+ steepness / Math.PI,
+ );
+ }
+ return color;
+ }
+
+ return undefined;
+ }
+
+ getSeaHeight(pos: Vector3): number {
+ if (this.seaNoise) return this.seaNoise.get(pos);
+
+ return 0;
+ }
+
+ getSeaColor(pos: Vector3, ground: number | undefined): Color | undefined {
+ ground ??= this.noise?.normalized(pos) ?? 0;
+
+ if (this.seaColors) {
+ return this.seaColors.get(ground);
+ }
+
+ return undefined;
+ }
+}
diff --git a/src/lib/3D/planet/helper/colorgradient.ts b/src/lib/3D/worlds/helper/colorgradient.ts
similarity index 100%
rename from src/lib/3D/planet/helper/colorgradient.ts
rename to src/lib/3D/worlds/helper/colorgradient.ts
diff --git a/src/lib/3D/worlds/helper/octtree.ts b/src/lib/3D/worlds/helper/octtree.ts
new file mode 100644
index 0000000..b9da67a
--- /dev/null
+++ b/src/lib/3D/worlds/helper/octtree.ts
@@ -0,0 +1,275 @@
+import * as THREE from 'three';
+
+export type OcttreeOptions = {
+ bounds?: THREE.Box3;
+
+ size?: number;
+
+ min?: THREE.Vector3;
+ max?: THREE.Vector3;
+
+ points?: THREE.Vector3[];
+
+ capacity?: number;
+};
+
+export class Octtree {
+ boundary: THREE.Box3;
+
+ points: THREE.Vector3[];
+
+ capacity: number;
+
+ subdivisions: Octtree[] | undefined = undefined;
+
+ constructor(opts: OcttreeOptions = {}) {
+ opts ??= {};
+
+ this.points = [];
+
+ if (opts.bounds) {
+ this.boundary = opts.bounds.clone();
+ } else if (opts.size) {
+ const s = opts.size;
+ this.boundary = new THREE.Box3(new THREE.Vector3(-s, -s, -s), new THREE.Vector3(s, s, s));
+ } else if (opts.min || opts.max) {
+ const min = opts.min || new THREE.Vector3(-1, -1, -1);
+ const max = opts.max || new THREE.Vector3(1, 1, 1);
+ this.boundary = new THREE.Box3(min, max);
+ } else if (opts.points && opts.points.length > 0) {
+ const min = opts.points[0].clone();
+ const max = opts.points[0].clone();
+ for (const p of opts.points) {
+ min.x = Math.min(min.x, p.x);
+ min.y = Math.min(min.y, p.y);
+ min.z = Math.min(min.z, p.z);
+
+ max.x = Math.max(max.x, p.x);
+ max.y = Math.max(max.y, p.y);
+ max.z = Math.max(max.z, p.z);
+ }
+ this.boundary = new THREE.Box3(min, max);
+ } else {
+ this.boundary = new THREE.Box3(new THREE.Vector3(-1, -1, -1), new THREE.Vector3(1, 1, 1));
+ }
+
+ this.capacity = opts.capacity || 4;
+
+ if (opts.points) {
+ for (const p of opts.points) {
+ this.insertXYZ(p.x, p.y, p.z);
+ }
+ }
+ }
+
+ subdivide() {
+ // if already subdivided exit silently
+ if (this.subdivisions != undefined) return;
+
+ // divide each dimension => 2 * 2 * 2 = 8 subdivisions
+ const size = new THREE.Vector3();
+ const subdivisions: Octtree[] = [];
+ for (let x = 0; x < 2; x++) {
+ for (let y = 0; y < 2; y++) {
+ for (let z = 0; z < 2; z++) {
+ const min = this.boundary.min.clone();
+ const max = this.boundary.max.clone();
+ this.boundary.getSize(size);
+ size.divideScalar(2);
+
+ min.x += x * size.x;
+ min.y += y * size.y;
+ min.z += z * size.z;
+ max.x -= (1 - x) * size.x;
+ max.y -= (1 - y) * size.y;
+ max.z -= (1 - z) * size.z;
+
+ subdivisions.push(
+ new Octtree({
+ min: min,
+ max: max,
+ capacity: this.capacity
+ })
+ );
+ }
+ }
+ }
+ this.subdivisions = subdivisions;
+ }
+
+ // returns array of points where
+ // distance between pos and point is less than dist
+ query(pos: THREE.Vector3, dist = 1) {
+ const points = this.queryXYZ(pos.x, pos.y, pos.z, dist);
+ for (let i = points.length - 1; i >= 0; i--) {
+ if (points[i].distanceTo(pos) > dist) points.splice(i, 1);
+ }
+ return points;
+ }
+
+ // vector3 free version, returns points in box around xyz
+ queryXYZ(x: number, y: number, z: number, s: number) {
+ const min = new THREE.Vector3(x - s, y - s, z - s),
+ max = new THREE.Vector3(x + s, y + s, z + s);
+ const box = new THREE.Box3(min, max);
+
+ return this.queryBox(box);
+ }
+
+ queryBox(box: THREE.Box3, found: THREE.Vector3[] = []) {
+ found ??= [];
+
+ if (!box.intersectsBox(this.boundary)) return found;
+
+ for (const p of this.points) {
+ if (box.containsPoint(p)) found.push(p);
+ }
+ if (this.subdivisions) {
+ for (const sub of this.subdivisions) {
+ sub.queryBox(box, found);
+ }
+ }
+ return found;
+ }
+
+ // returns true if no points are closer than dist to point
+ minDist(pos: THREE.Vector3, dist: number) {
+ return this.query(pos, dist).length < 1;
+ }
+
+ // insert point with optional data (sets vec.data = data)
+ insert(pos: THREE.Vector3, data: unknown = undefined) {
+ return this.insertPoint(pos, data);
+ }
+ // vector3 free version
+ insertXYZ(x: number, y: number, z: number, data: unknown = undefined) {
+ return this.insertPoint(new THREE.Vector3(x, y, z), data);
+ }
+ insertPoint(p: THREE.Vector3, data: unknown = undefined) {
+ p = p.clone();
+
+ // @ts-expect-error - data is not a property of Vector3
+ if (data) p.data = data;
+
+ if (!this.boundary.containsPoint(p)) return false;
+
+ if (this.points.length < this.capacity) {
+ this.points.push(p);
+ return true;
+ } else {
+ this.subdivide();
+ let added = false;
+ for (const sub of this.subdivisions ?? []) {
+ if (sub.insertPoint(p, data)) added = true;
+ }
+ return added;
+ }
+ }
+
+ showBoxes(mat: THREE.Material, parent: THREE.Object3D | undefined = undefined) {
+ const size = new THREE.Vector3();
+ this.boundary.getSize(size);
+
+ const box = new THREE.BoxGeometry(size.x * 2, size.y * 2, size.z * 2);
+ const mesh = new THREE.Mesh(
+ box,
+ mat ||
+ new THREE.MeshStandardMaterial({
+ wireframe: true
+ })
+ );
+ this.boundary.getCenter(mesh.position);
+
+ parent ??= new THREE.Object3D();
+ parent.add(mesh);
+
+ if (this.subdivisions) {
+ for (const sub of this.subdivisions) sub.showBoxes(mat, parent);
+ }
+ return parent;
+ }
+
+ show(
+ opts: {
+ pointsOnly?: boolean;
+ mat?: THREE.Material;
+ size?: number;
+ sizeAttenuation?: boolean;
+ p?: THREE.Vector3;
+ min?: number;
+ } = {}
+ ) {
+ opts ??= {};
+
+ const pointsOnly = opts.pointsOnly;
+ let mat = opts.mat;
+ const points = this.all();
+
+ const pointsGeo = new THREE.BufferGeometry();
+ const positionData = new Float32Array(points.length * 3);
+ const colorData = new Float32Array(points.length * 3);
+
+ let q;
+
+ if (opts.p && opts.min) {
+ for (const point of points) {
+ // @ts-expect-error - close is not a property of Vector3
+ point.close = false;
+ }
+ q = this.query(opts.p, opts.min);
+
+ for (const point of q) {
+ // @ts-expect-error - close is not a property of Vector3
+ point.close = true;
+ }
+ }
+
+ for (let i = 0; i < points.length; i++) {
+ positionData[i * 3] = points[i].x;
+ positionData[i * 3 + 1] = points[i].y;
+ positionData[i * 3 + 2] = points[i].z;
+
+ // @ts-expect-error - close is not a property of Vector3
+ colorData[i * 3] = points[i].close ? 1 : 0.7;
+
+ // @ts-expect-error - close is not a property of Vector3
+ colorData[i * 3 + 1] = points[i].close ? 0 : 0.7;
+
+ // @ts-expect-error - close is not a property of Vector3
+ colorData[i * 3 + 2] = points[i].close ? 0 : 0.7;
+ }
+ pointsGeo.setAttribute('position', new THREE.BufferAttribute(positionData, 3));
+ pointsGeo.setAttribute('color', new THREE.BufferAttribute(colorData, 3));
+ const pointMesh = new THREE.Points(
+ pointsGeo,
+ new THREE.PointsMaterial({
+ size: opts.size || 1,
+ sizeAttenuation: opts.sizeAttenuation || false,
+ vertexColors: true
+ })
+ );
+ if (pointsOnly) return pointMesh;
+
+ mat =
+ mat ||
+ new THREE.MeshStandardMaterial({
+ transparent: true,
+ opacity: 0.01,
+ depthTest: false
+ });
+ const boxes = this.showBoxes(mat);
+ boxes.add(pointMesh);
+ return boxes;
+ }
+
+ all(arr: THREE.Vector3[] = []) {
+ arr ??= [];
+ for (const p of this.points) {
+ arr.push(p);
+ }
+ if (this.subdivisions) {
+ for (const subs of this.subdivisions) subs.all(arr);
+ }
+ return arr;
+ }
+}
diff --git a/src/lib/3D/planet/noise/uber-noise.ts b/src/lib/3D/worlds/helper/uber-noise.ts
similarity index 100%
rename from src/lib/3D/planet/noise/uber-noise.ts
rename to src/lib/3D/worlds/helper/uber-noise.ts
diff --git a/src/lib/3D/worlds/models.ts b/src/lib/3D/worlds/models.ts
new file mode 100644
index 0000000..2fb1265
--- /dev/null
+++ b/src/lib/3D/worlds/models.ts
@@ -0,0 +1,154 @@
+import * as THREE from "three";
+import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
+
+const lowPolyNatureCollectionModels: Record<
+ string,
+ { versions?: number; materials: string[] }
+> = {
+ BirchTree: {
+ versions: 5,
+ materials: ["White", "Black", "DarkGreen", "Green"],
+ },
+ BirchTree_Dead: { versions: 5, materials: ["White", "Black"] },
+ BirchTree_Dead_Snow: { versions: 5, materials: ["White", "Snow", "Black"] },
+ BirchTree_Snow: {
+ versions: 5,
+ materials: ["White", "Black", "DarkGreen", "Green", "Snow"],
+ },
+ Bush: { versions: 2, materials: ["Green"] },
+ Bush_Snow: { versions: 2, materials: ["Snow", "Green"] },
+ BushBerries: { versions: 2, materials: ["Green", "Red"] },
+ Cactus: { versions: 5, materials: ["Green", "LightOrange"] },
+ CactusFlowers: { versions: 5, materials: ["Green", "Pink"] },
+ CommonTree: { versions: 5, materials: ["Brown", "Green", "DarkGreen"] },
+ CommonTree_Dead: { versions: 5, materials: ["Brown"] },
+ CommonTree_Dead_Snow: { versions: 5, materials: ["Brown", "Snow"] },
+ CommonTree_Snow: {
+ versions: 5,
+ materials: ["Brown", "Green", "Snow", "DarkGreen"],
+ },
+ Corn: { versions: 2, materials: ["Green", "Yellow"] },
+ Flowers: { materials: ["Green", "Cyan", "Yellow"] },
+ Grass: { versions: 3, materials: ["Green"] },
+ Lilypad: { materials: ["Green", "Pink"] },
+ PalmTree: { versions: 4, materials: ["Brown", "Green", "DarkGreen"] },
+ PineTree: { versions: 5, materials: ["Brown", "Green"] },
+ PineTree_Snow: { versions: 5, materials: ["Brown", "Green", "Snow"] },
+ Plant: {
+ versions: 5,
+ materials: ["Brown", "Green", "DarkGreen", "Yellow", "Pink"],
+ },
+ Rock: { versions: 7, materials: ["Gray"] },
+ Rock_Moss: { versions: 7, materials: ["Gray", "Green"] },
+ Rock_Snow: { versions: 7, materials: ["Gray", "Snow"] },
+ TreeStump_Moss: { materials: ["Brown", "Green"] },
+ TreeStump_Snow: { materials: ["Brown", "Snow"] },
+ TreeStump: { materials: ["Brown", "LightBrown", "Green"] },
+ Wheat: { materials: ["Yellow"] },
+ Willow: { versions: 5, materials: ["Brown", "DarkGreen"] },
+ Willow_Dead: { versions: 5, materials: ["Brown"] },
+ Willow_Dead_Snow: { versions: 5, materials: ["Brown", "Snow"] },
+ Willow_Snow: { versions: 5, materials: ["Brown", "Snow", "DarkGreen"] },
+ WoodLog_Moss: {
+ materials: [
+ "Brown",
+ "Green",
+ "Mushroom_Top",
+ "Mushroom_Bottom",
+ "DarkGreen",
+ ],
+ },
+ WoodLog_Snow: { materials: ["Brown", "Snow"] },
+ WoodLog: { materials: ["Brown", "Mushroom_Top", "Mushroom_Bottom"] },
+};
+
+type Collection = {
+ models: Record;
+ name: string;
+};
+
+export const lowPolyNatureCollection = {
+ models: lowPolyNatureCollectionModels,
+ name: "lowpoly_nature",
+};
+
+type Collections = "lowpoly_nature";
+
+export const collections: Record = {
+ lowpoly_nature: lowPolyNatureCollection,
+};
+
+export function getModels(
+ collection: Collections = "lowpoly_nature",
+): string[] {
+ return Object.keys(collections[collection].models);
+}
+
+export function getModelPathsAndMaterials(
+ name: string,
+ collection: Collections = "lowpoly_nature",
+): {
+ filePaths: string[];
+ materials: string[];
+} | null {
+ const model = collections[collection].models[name];
+ if (!model) {
+ console.error(`Model ${name} not found.`);
+ return null;
+ }
+
+ // Construct file paths based on the number of versions
+ const filePaths: string[] = [];
+ if (model.versions) {
+ for (let i = 1; i <= model.versions; i++) {
+ filePaths.push(`${collections[collection].name}/${name}_${i}.gltf`);
+ }
+ } else {
+ filePaths.push(`${collections[collection].name}/${name}.gltf`);
+ }
+
+ return {
+ filePaths,
+ materials: model.materials,
+ };
+}
+
+export async function loadModels(
+ name: string,
+ collection: Collections = "lowpoly_nature",
+): Promise {
+ const loader = new GLTFLoader();
+ const modelInfo = getModelPathsAndMaterials(name, collection);
+
+ if (!modelInfo) {
+ return [];
+ }
+
+ const promises = modelInfo.filePaths.map((filePath) => {
+ return new Promise((resolve, reject) => {
+ loader.load(
+ filePath,
+ (gltf) => {
+ gltf.scene.userData = {
+ name,
+ path: filePath,
+ };
+ gltf.scene.traverse((child) => {
+ if (child instanceof THREE.Mesh) {
+ child.castShadow = true;
+ child.receiveShadow = true;
+ }
+ });
+ resolve(gltf.scene);
+ },
+ undefined,
+ (error) => {
+ console.error(`Failed to load model ${filePath}:`, error);
+ reject(error);
+ },
+ );
+ });
+ });
+
+ return Promise.all(promises);
+}
diff --git a/src/lib/3D/worlds/planet.ts b/src/lib/3D/worlds/planet.ts
new file mode 100644
index 0000000..5496277
--- /dev/null
+++ b/src/lib/3D/worlds/planet.ts
@@ -0,0 +1,216 @@
+import {
+ BufferGeometry,
+ Float32BufferAttribute,
+ Mesh,
+ MeshStandardMaterial,
+ Object3D,
+ Quaternion,
+ Vector3,
+} from "three";
+import { Biome, type BiomeOptions } from "./biome";
+import { loadModels } from "./models";
+
+export type PlanetOptions = {
+ scatter?: number;
+
+ ground?: number;
+
+ detail?: number;
+};
+
+export class Planet {
+ worker: Worker;
+
+ callbacks: Record void>;
+ requestId: number;
+
+ biome: Biome;
+
+ biomeOptions: BiomeOptions;
+ options: PlanetOptions;
+
+ vegetationPositions?: Record;
+
+ constructor(biomeOptions: BiomeOptions, planetOptions: PlanetOptions = {}) {
+ this.options = planetOptions;
+
+ this.biome = new Biome(biomeOptions);
+ this.biomeOptions = this.biome.options;
+
+ this.worker = new Worker(new URL("worker.ts", import.meta.url), {
+ type: "module",
+ });
+ this.worker.onmessage = this.handleMessage.bind(this);
+ this.callbacks = {};
+ this.requestId = 0;
+ }
+
+ handleMessage(event: {
+ data: {
+ type: "geometry";
+ data: {
+ positions: number[];
+ colors: number[];
+ normals: number[];
+ oceanPositions: number[];
+ oceanColors: number[];
+ oceanNormals: number[];
+ vegetation: Record;
+ };
+ requestId: number;
+ };
+ }) {
+ const { type, data, requestId } = event.data;
+
+ const callback = this.callbacks[requestId];
+ if (!callback) {
+ console.error("No callback found for requestId:", requestId);
+ return;
+ }
+
+ if (type === "geometry") {
+ const geometry = new BufferGeometry();
+ const oceanGeometry = new BufferGeometry();
+ geometry.setAttribute(
+ "position",
+ new Float32BufferAttribute(new Float32Array(data.positions), 3),
+ );
+ geometry.setAttribute(
+ "color",
+ new Float32BufferAttribute(new Float32Array(data.colors), 3),
+ );
+ geometry.setAttribute(
+ "normal",
+ new Float32BufferAttribute(new Float32Array(data.normals), 3),
+ );
+
+ oceanGeometry.setAttribute(
+ "position",
+ new Float32BufferAttribute(new Float32Array(data.oceanPositions), 3),
+ );
+ oceanGeometry.setAttribute(
+ "color",
+ new Float32BufferAttribute(new Float32Array(data.oceanColors), 3),
+ );
+
+ oceanGeometry.computeVertexNormals();
+
+ this.vegetationPositions = data.vegetation;
+
+ const planetMesh = new Mesh(
+ geometry,
+ new MeshStandardMaterial({
+ vertexColors: true,
+ }),
+ );
+ planetMesh.castShadow = true;
+ planetMesh.receiveShadow = true;
+
+ const oceanMesh = new Mesh(
+ oceanGeometry,
+ new MeshStandardMaterial({
+ vertexColors: true,
+ transparent: true,
+ opacity: 0.7,
+ metalness: 0.5,
+ roughness: 0.5,
+ }),
+ );
+
+ planetMesh.add(oceanMesh);
+ callback(planetMesh);
+ }
+
+ delete this.callbacks[requestId];
+ }
+
+ async create(): Promise {
+ const models = this.biomeOptions.vegetation?.items.map((item) => {
+ return item.name;
+ });
+
+ const loaded: Promise[] = [];
+
+ for (const model of models ?? []) {
+ const loadedModels = loadModels(model);
+ loaded.push(loadedModels);
+ }
+
+ const planetPromise = this.createMesh();
+ loaded.push(planetPromise);
+
+ await Promise.all(loaded);
+
+ const planet = await planetPromise;
+
+ for (let i = 0; i < loaded.length - 1; i++) {
+ const models = await loaded[i];
+ const name = models[0].userData.name;
+
+ const positions = this.vegetationPositions?.[name];
+
+ if (!positions) continue;
+
+ let item = this.biomeOptions.vegetation?.items[i];
+
+ for (const position of positions) {
+ const model = models[Math.floor(Math.random() * models.length)].clone();
+ model.position.set(0, 1, 0);
+ this.updatePosition(
+ model,
+ new Vector3(position.x, position.y, position.z),
+ );
+ model.scale.setScalar(0.04);
+
+ model.traverse((child) => {
+ if (child instanceof Mesh) {
+ let color = item?.colors?.[child.material.name];
+ if (color && color.array) {
+ let randomColor =
+ color.array[Math.floor(Math.random() * color.array.length)];
+ child.material.color.setHex(randomColor);
+ }
+
+ if (child.material.name === "Snow") {
+ child.material.roughness = 0.2;
+ child.material.color.setHex(0xffffff);
+ }
+ }
+ });
+ planet.add(model);
+ }
+ }
+
+ return planetPromise;
+ }
+
+ createMesh(): Promise {
+ return new Promise((resolve) => {
+ const requestId = this.requestId++;
+ this.callbacks[requestId] = resolve;
+
+ this.worker.postMessage({
+ type: "createGeometry",
+ requestId,
+ data: {
+ biomeOptions: this.biome.options,
+ planetOptions: this.options,
+ },
+ });
+ });
+ }
+
+ updatePosition(item: Object3D, pos: Vector3) {
+ item.position.copy(pos);
+
+ const currentRotation = new Quaternion();
+ const a = item.up.clone().normalize();
+ const b = pos.clone().normalize();
+
+ currentRotation.setFromUnitVectors(a, b);
+
+ item.quaternion.copy(currentRotation);
+
+ item.up = b;
+ }
+}
diff --git a/src/lib/3D/worlds/presets.ts b/src/lib/3D/worlds/presets.ts
new file mode 100644
index 0000000..4edc6fa
--- /dev/null
+++ b/src/lib/3D/worlds/presets.ts
@@ -0,0 +1,257 @@
+import { type BiomeOptions } from './biome';
+
+const beach: BiomeOptions = {
+ noise: {
+ min: -0.05,
+ max: 0.05,
+ octaves: 4,
+ lacunarity: 2.0,
+ gain: {
+ min: 0.1,
+ max: 0.8,
+ scale: 2
+ },
+ warp: 0.3,
+ scale: 1,
+ power: 1.5
+ },
+
+ colors: [
+ [-0.5, 0x994400],
+ [-0.0, 0xccaa00],
+ [0.4, 0xcc7700],
+ [1.0, 0x002222]
+ ],
+
+ seaColors: [
+ [-1, 0x000066],
+ [-0.52, 0x0000aa],
+ [-0.1, 0x00f2e5]
+ ],
+ seaNoise: {
+ min: -0.005,
+ max: 0.005,
+ scale: 5
+ },
+
+ vegetation: {
+ items: [
+ {
+ name: 'PalmTree',
+ density: 50,
+ minimumHeight: 0.1,
+ colors: {
+ Brown: { array: [0x8b4513, 0x5b3105] },
+ Green: { array: [0x22851e, 0x22a51e] },
+ DarkGreen: { array: [0x006400] }
+ }
+ },
+ {
+ name: 'Rock',
+ density: 10,
+ minimumHeight: 0.1,
+ colors: {
+ Gray: { array: [0x775544] }
+ }
+ }
+ ]
+ }
+};
+
+const forest: BiomeOptions = {
+ noise: {
+ min: -0.05,
+ max: 0.05,
+ octaves: 4,
+ lacunarity: 2.0,
+ gain: {
+ min: 0.1,
+ max: 0.8,
+ scale: 2
+ },
+ warp: 0.3,
+ scale: 1,
+ power: 0.8
+ },
+
+ tintColor: 0x113322,
+
+ colors: [
+ [-0.5, 0x332200],
+ [-0.0, 0x115512],
+ [0.4, 0x224411],
+ [1.0, 0x006622]
+ ],
+
+ seaColors: [
+ [-1, 0x000066],
+ [-0.52, 0x0000aa],
+ [-0.1, 0x0042a5]
+ ],
+ seaNoise: {
+ min: -0.005,
+ max: 0.005,
+ scale: 5
+ },
+
+ vegetation: {
+ items: [
+ {
+ name: 'Rock',
+ density: 5,
+ minimumHeight: 0.1,
+ colors: {
+ Gray: { array: [0x888888, 0x616161, 0x414141] }
+ }
+ },
+ {
+ name: 'CommonTree',
+ density: 5,
+ minimumHeight: 0.0
+ },
+ {
+ name: 'Bush',
+ density: 5,
+ minimumHeight: 0.0
+ },
+ {
+ name: 'CommonTree_Dead',
+ density: 5
+ },
+ {
+ name: 'PineTree',
+ density: 5
+ },
+ {
+ name: 'TreeStump',
+ density: 1
+ },
+ {
+ name: 'TreeStump_Moss',
+ density: 1
+ },
+ {
+ name: 'Willow',
+ density: 5
+ },
+ {
+ name: 'Willow_Dead',
+ density: 5
+ },
+ {
+ name: 'WoodLog',
+ density: 1
+ },
+ {
+ name: 'BirchTree',
+ density: 5
+ },
+ {
+ name: 'BirchTree_Dead',
+ density: 5
+ }
+ ]
+ }
+};
+
+const snowForest: BiomeOptions = {
+ noise: {
+ min: -0.05,
+ max: 0.05,
+ octaves: 4,
+ lacunarity: 2.0,
+ gain: {
+ min: 0.1,
+ max: 0.8,
+ scale: 2
+ },
+ warp: 0.3,
+ scale: 1,
+ power: 0.8
+ },
+
+ tintColor: 0x119922,
+
+ colors: [
+ [-0.5, 0xff99ff],
+ [-0.0, 0xffffff],
+ [0.4, 0xeeffff],
+ [1.0, 0xffffff]
+ ],
+
+ seaColors: [
+ [-1, 0x8899cc],
+ [-0.52, 0xaaccff],
+ [-0.1, 0xaaccff]
+ ],
+ seaNoise: {
+ min: -0.005,
+ max: 0.005,
+ scale: 5
+ },
+
+ vegetation: {
+ items: [
+ {
+ name: 'Rock_Snow',
+ density: 5,
+ minimumHeight: 0.1,
+ colors: {
+ Gray: { array: [0x888888, 0x616161, 0x414141] }
+ }
+ },
+ {
+ name: 'CommonTree_Snow',
+ density: 5,
+ minimumHeight: 0.0
+ },
+ {
+ name: 'Bush_Snow',
+ density: 5,
+ minimumHeight: 0.0
+ },
+ {
+ name: 'CommonTree_Dead_Snow',
+ density: 5
+ },
+ {
+ name: 'PineTree_Snow',
+ density: 5
+ },
+ {
+ name: 'TreeStump_Snow',
+ density: 1
+ },
+ {
+ name: 'TreeStump_Snow',
+ density: 1
+ },
+ {
+ name: 'Willow_Snow',
+ density: 5
+ },
+ {
+ name: 'Willow_Dead_Snow',
+ density: 5
+ },
+ {
+ name: 'WoodLog_Snow',
+ density: 1
+ },
+ {
+ name: 'BirchTree_Snow',
+ density: 5
+ },
+ {
+ name: 'BirchTree_Dead_Snow',
+ density: 5
+ }
+ ]
+ }
+};
+
+export const biomePresets: Record = {
+ beach,
+ forest,
+ snowForest
+};
diff --git a/src/lib/3D/worlds/worker.ts b/src/lib/3D/worlds/worker.ts
new file mode 100644
index 0000000..6f33f6f
--- /dev/null
+++ b/src/lib/3D/worlds/worker.ts
@@ -0,0 +1,241 @@
+import { IcosahedronGeometry, Vector3, BufferAttribute } from "three";
+
+import { Biome, type BiomeOptions } from "./biome";
+import { type PlanetOptions } from "./planet";
+import UberNoise from "./helper/uber-noise";
+
+onmessage = function (e) {
+ const { type, data, requestId } = e.data;
+
+ if (type === "createGeometry") {
+ const [geometry, oceanGeometry, vegetation] = createGeometry(data);
+
+ const positions = geometry.getAttribute("position").array.buffer;
+ const colors = geometry.getAttribute("color").array.buffer;
+ const normals = geometry.getAttribute("normal").array.buffer;
+
+ const oceanPositions = oceanGeometry.getAttribute("position").array.buffer;
+ const oceanColors = oceanGeometry.getAttribute("color").array.buffer;
+ const oceanNormals = oceanGeometry.getAttribute("normal").array.buffer;
+
+ postMessage(
+ {
+ type: "geometry",
+ data: {
+ positions,
+ colors,
+ normals,
+ oceanPositions,
+ oceanColors,
+ oceanNormals,
+ vegetation,
+ },
+ requestId,
+ },
+ // @ts-expect-error - hmm
+ [positions, colors, normals, oceanPositions, oceanColors, oceanNormals],
+ );
+ } else {
+ console.error("Unknown message type", type);
+ }
+};
+
+function createGeometry({
+ biomeOptions,
+ planetOptions,
+}: {
+ biomeOptions: BiomeOptions;
+ planetOptions: PlanetOptions;
+}): [IcosahedronGeometry, IcosahedronGeometry, Record] {
+ const sphere = new IcosahedronGeometry(1, planetOptions.detail ?? 50);
+ const oceanSphere = new IcosahedronGeometry(1, planetOptions.detail ?? 50);
+
+ const biome = new Biome(biomeOptions);
+
+ const vertices = sphere.getAttribute("position");
+ const oceanVertices = oceanSphere.getAttribute("position");
+ const faceCount = vertices.count / 3;
+ const faceSize = (Math.PI * 4) / faceCount;
+ console.log("faces:", faceCount);
+
+ const calculatedVertices = new Map<
+ string,
+ {
+ height: number;
+ seaHeight: number;
+ scatter: Vector3;
+ }
+ >();
+
+ const colors = new Float32Array(vertices.count * 3);
+ const oceanColors = new Float32Array(oceanVertices.count * 3);
+
+ const normals = sphere.getAttribute("normal");
+ const oceanNormals = oceanSphere.getAttribute("normal");
+
+ const a = new Vector3(),
+ b = new Vector3(),
+ c = new Vector3();
+
+ const mid = new Vector3();
+
+ const placedVegetation: Record = {};
+ a.fromBufferAttribute(vertices, 0);
+ b.fromBufferAttribute(vertices, 1);
+
+ // default to scatter = distance of first edge
+ const scatterAmount = planetOptions.scatter ?? b.distanceTo(a);
+ const scatterScale = 100;
+
+ const scatterNoise = new UberNoise({
+ min: -scatterAmount / 2,
+ max: scatterAmount / 2,
+ scale: scatterScale,
+ seed: 0,
+ });
+
+ for (let i = 0; i < vertices.count; i += 3) {
+ a.fromBufferAttribute(vertices, i);
+ b.fromBufferAttribute(vertices, i + 1);
+ c.fromBufferAttribute(vertices, i + 2);
+
+ mid.set(0, 0, 0);
+ mid.addVectors(a, b).add(c).divideScalar(3);
+
+ let normalizedHeight = 0;
+
+ for (let j = 0; j < 3; j++) {
+ let v = a;
+ if (j === 1) v = b;
+ if (j === 2) v = c;
+ const key = `${v.x.toFixed(5)},${v.y.toFixed(5)},${v.z.toFixed(5)}`;
+
+ let move = calculatedVertices.get(key);
+
+ if (!move) {
+ const height = biome.getHeight(v) + 1;
+ const scatterX = scatterNoise.get(v);
+ const scatterY = scatterNoise.get(
+ v.y + scatterScale * 100,
+ v.z - scatterScale * 100,
+ v.x + scatterScale * 100,
+ );
+ const scatterZ = scatterNoise.get(
+ v.z - scatterScale * 200,
+ v.x + scatterScale * 200,
+ v.y - scatterScale * 200,
+ );
+ const seaHeight = biome.getSeaHeight(v) + 1;
+
+ move = {
+ height,
+ scatter: new Vector3(scatterX, scatterY, scatterZ),
+ seaHeight,
+ };
+ calculatedVertices.set(key, move);
+ }
+
+ normalizedHeight += move.height - 1;
+ v.add(move.scatter).normalize().multiplyScalar(move.height);
+
+ vertices.setXYZ(i + j, v.x, v.y, v.z);
+
+ const oceanV = v.clone().normalize().multiplyScalar(move.seaHeight);
+ oceanVertices.setXYZ(i + j, oceanV.x, oceanV.y, oceanV.z);
+ }
+
+ normalizedHeight /= 3;
+ normalizedHeight = (normalizedHeight - biome.min) / (biome.max - biome.min);
+ normalizedHeight = normalizedHeight * 2 - 1;
+ // now averageHeight is between -1 and 1 (0 is sea level)
+
+ for (
+ let j = 0;
+ biome.options.vegetation && j < biome.options.vegetation.items.length;
+ j++
+ ) {
+ const vegetation = biome.options.vegetation.items[j];
+ if (Math.random() < faceSize * vegetation.density) {
+ if (
+ vegetation.minimumHeight !== undefined &&
+ normalizedHeight < vegetation.minimumHeight
+ ) {
+ continue;
+ }
+
+ if (vegetation.minimumHeight === undefined && normalizedHeight < 0) {
+ continue;
+ }
+
+ if (
+ vegetation.maximumHeight !== undefined &&
+ normalizedHeight > vegetation.maximumHeight
+ ) {
+ continue;
+ }
+ if (!placedVegetation[vegetation.name]) {
+ placedVegetation[vegetation.name] = [];
+ }
+ placedVegetation[vegetation.name].push(a.clone());
+ break;
+ }
+ }
+
+ // calculate new normal
+ const normal = new Vector3();
+ normal.crossVectors(b.clone().sub(a), c.clone().sub(a)).normalize();
+
+ // flat shading, so all normals for the face are the same
+ normals.setXYZ(i, normal.x, normal.y, normal.z);
+ normals.setXYZ(i + 1, normal.x, normal.y, normal.z);
+ normals.setXYZ(i + 2, normal.x, normal.y, normal.z);
+
+ // calculate steepness (acos of dot product of normal and up vector)
+ // (up vector = old mid point on sphere)
+ const steepness = Math.acos(Math.abs(normal.dot(mid)));
+ // steepness is between 0 and PI/2
+
+ const color = biome.getColor(mid, normalizedHeight, steepness);
+
+ // flat shading, so all colors for the face are the same
+ if (color) {
+ colors[i * 3] = color.r;
+ colors[i * 3 + 1] = color.g;
+ colors[i * 3 + 2] = color.b;
+
+ colors[i * 3 + 3] = color.r;
+ colors[i * 3 + 4] = color.g;
+ colors[i * 3 + 5] = color.b;
+
+ colors[i * 3 + 6] = color.r;
+ colors[i * 3 + 7] = color.g;
+ colors[i * 3 + 8] = color.b;
+ }
+
+ // calculate ocean vertices
+ const oceanColor = biome.getSeaColor(mid, normalizedHeight);
+
+ if (oceanColor) {
+ oceanColors[i * 3] = oceanColor.r;
+ oceanColors[i * 3 + 1] = oceanColor.g;
+ oceanColors[i * 3 + 2] = oceanColor.b;
+
+ oceanColors[i * 3 + 3] = oceanColor.r;
+ oceanColors[i * 3 + 4] = oceanColor.g;
+ oceanColors[i * 3 + 5] = oceanColor.b;
+
+ oceanColors[i * 3 + 6] = oceanColor.r;
+ oceanColors[i * 3 + 7] = oceanColor.g;
+ oceanColors[i * 3 + 8] = oceanColor.b;
+ }
+
+ oceanNormals.setXYZ(i, mid.x, mid.y, mid.z);
+ oceanNormals.setXYZ(i + 1, mid.x, mid.y, mid.z);
+ oceanNormals.setXYZ(i + 2, mid.x, mid.y, mid.z);
+ }
+
+ sphere.setAttribute("color", new BufferAttribute(colors, 3));
+ oceanSphere.setAttribute("color", new BufferAttribute(oceanColors, 3));
+
+ return [sphere, oceanSphere, placedVegetation];
+}
diff --git a/src/lib/components/About.svelte b/src/lib/components/About.svelte
index e82f323..8764975 100644
--- a/src/lib/components/About.svelte
+++ b/src/lib/components/About.svelte
@@ -2,9 +2,9 @@
import Depth3D from '$lib/3D/Depth3D/Depth3D.svelte';
// @ts-ignore
- import imageMe from '$lib/images/avatar.png?w=512&format=webp';
+ import imageMe from '$lib/images/flo2.png?w=512&format=webp';
// @ts-ignore
- import depthMe from '$lib/images/avatar-depth.png?w=512&format=webp';
+ import depthMe from '$lib/images/flo2-depth.png?w=512&format=webp';
import Resume from './Resume.svelte';
@@ -23,12 +23,13 @@
class="aspect-square rotate-3 rounded-2xl bg-zinc-100 object-cover dark:bg-zinc-800"
/> -->
-