entangled-worlds-orbiters-shared 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/world/worldNormal.js +46 -0
package/package.json
CHANGED
package/src/world/worldNormal.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { EARTH_RADIUS_UNITS } from './worldTexture.js';
|
|
4
4
|
import { applyFlagsToMaterial } from '../utils/materials.js';
|
|
5
|
+
import { getLightFresnel } from '../core/lightFresnel.js';
|
|
6
|
+
import { createCloudShell } from './cloudShell.js';
|
|
7
|
+
import { resolvePublicUrl } from '../config/env.js';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Create a simple sphere using THREE.MeshNormalMaterial.
|
|
@@ -12,6 +15,18 @@ export async function makeNormalSphere({
|
|
|
12
15
|
sphereWidthSegments,
|
|
13
16
|
sphereHeightSegments,
|
|
14
17
|
flags,
|
|
18
|
+
glow, // halo (glow) enabled
|
|
19
|
+
glowScale = 1.18,
|
|
20
|
+
glowRimHex = 0x66ccff,
|
|
21
|
+
glowFacingHex = 0x000000,
|
|
22
|
+
glowBias = 0.02,
|
|
23
|
+
glowFresnelScale = 1.0,
|
|
24
|
+
glowPower = 3.5,
|
|
25
|
+
cloudsEnabled,
|
|
26
|
+
cloudsTextureUrl = '/assets/texture/2k_earth_clouds.jpg',
|
|
27
|
+
cloudsColor = 0xffffff,
|
|
28
|
+
cloudsOpacity = 0.6,
|
|
29
|
+
cloudsSpeed = 0.015,
|
|
15
30
|
} = {}) {
|
|
16
31
|
const radius = typeof sphereRadius === 'number' ? Math.max(0.0001, sphereRadius) : EARTH_RADIUS_UNITS;
|
|
17
32
|
const widthSegs = Number.isFinite(sphereWidthSegments) ? Math.max(3, Math.floor(sphereWidthSegments)) : 64;
|
|
@@ -21,5 +36,36 @@ export async function makeNormalSphere({
|
|
|
21
36
|
if (flags) applyFlagsToMaterial(material, flags);
|
|
22
37
|
const mesh = new THREE.Mesh(geometry, material);
|
|
23
38
|
mesh.name = 'worldNormalSphere';
|
|
39
|
+
|
|
40
|
+
// Attach halo (glow) effect if enabled
|
|
41
|
+
if (glow) {
|
|
42
|
+
const fresnelMat = getLightFresnel({ rimHex: glowRimHex, facingHex: glowFacingHex });
|
|
43
|
+
fresnelMat.uniforms.fresnelBias.value = glowBias;
|
|
44
|
+
fresnelMat.uniforms.fresnelScale.value = glowFresnelScale;
|
|
45
|
+
fresnelMat.uniforms.fresnelPower.value = glowPower;
|
|
46
|
+
|
|
47
|
+
const glowGeom = geometry.clone();
|
|
48
|
+
const fresnelMesh = new THREE.Mesh(glowGeom, fresnelMat);
|
|
49
|
+
fresnelMesh.scale.set(glowScale, glowScale, glowScale);
|
|
50
|
+
fresnelMesh.renderOrder = 999;
|
|
51
|
+
fresnelMesh.name = 'worldNormalGlow';
|
|
52
|
+
mesh.add(fresnelMesh);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Attach clouds effect if enabled
|
|
56
|
+
if (cloudsEnabled) {
|
|
57
|
+
const cloudMesh = await createCloudShell({
|
|
58
|
+
baseGeometry: geometry,
|
|
59
|
+
baseRadius: radius,
|
|
60
|
+
widthSegments: widthSegs,
|
|
61
|
+
heightSegments: heightSegs,
|
|
62
|
+
textureUrl: resolvePublicUrl(cloudsTextureUrl),
|
|
63
|
+
color: cloudsColor,
|
|
64
|
+
opacity: cloudsOpacity,
|
|
65
|
+
speed: cloudsSpeed,
|
|
66
|
+
});
|
|
67
|
+
mesh.add(cloudMesh);
|
|
68
|
+
}
|
|
69
|
+
|
|
24
70
|
return mesh;
|
|
25
71
|
}
|