auto-git:
[change] src/app/App.tsx [change] src/assets/starter-environment-assets.ts [change] src/document/migrate-scene-document.ts [change] src/document/scene-document-validation.ts [change] src/document/scene-document.ts [change] src/document/world-settings.ts [change] src/rendering/world-background-renderer.ts [change] src/rendering/world-shader-sky.ts [change] src/runtime-three/runtime-host.ts [change] src/runtime-three/runtime-project-time.ts [change] src/shared-ui/world-background-style.ts [change] src/viewport-three/ViewportCanvas.tsx [change] src/viewport-three/viewport-host.ts [change] tests/domain/runtime-project-time.test.ts [change] tests/domain/scene-document-validation.test.ts [change] tests/domain/world-settings.test.ts [change] tests/serialization/project-document-json.test.ts [change] tests/serialization/scene-document-json.test.ts [change] tests/unit/world-shader-sky.test.ts
This commit is contained in:
@@ -636,18 +636,22 @@ export class WorldBackgroundRenderer {
|
||||
opacity: 0
|
||||
});
|
||||
private readonly celestialGeometry = new PlaneGeometry(1, 1);
|
||||
private readonly sunMaterial = createCelestialBodyMaterial(
|
||||
SUN_FRAGMENT_SHADER
|
||||
);
|
||||
private readonly moonMaterial = createCelestialBodyMaterial(
|
||||
MOON_FRAGMENT_SHADER
|
||||
);
|
||||
private readonly sunMaterial =
|
||||
createCelestialBodyMaterial(SUN_FRAGMENT_SHADER);
|
||||
private readonly moonMaterial =
|
||||
createCelestialBodyMaterial(MOON_FRAGMENT_SHADER);
|
||||
private readonly shaderMesh = new Mesh(this.geometry, this.shaderSkyMaterial);
|
||||
private readonly gradientMesh = new Mesh(this.geometry, this.gradientMaterial);
|
||||
private readonly gradientMesh = new Mesh(
|
||||
this.geometry,
|
||||
this.gradientMaterial
|
||||
);
|
||||
private readonly imageMesh = new Mesh(this.geometry, this.imageMaterial);
|
||||
private readonly overlayMesh = new Mesh(this.geometry, this.overlayMaterial);
|
||||
private readonly sunMesh = new Mesh(this.celestialGeometry, this.sunMaterial);
|
||||
private readonly moonMesh = new Mesh(this.celestialGeometry, this.moonMaterial);
|
||||
private readonly moonMesh = new Mesh(
|
||||
this.celestialGeometry,
|
||||
this.moonMaterial
|
||||
);
|
||||
private readonly celestialBodyPosition = new Vector3();
|
||||
private sunState: WorldCelestialBodyState | null = null;
|
||||
private moonState: WorldCelestialBodyState | null = null;
|
||||
@@ -730,9 +734,12 @@ export class WorldBackgroundRenderer {
|
||||
this.overlayMaterial.opacity = overlayOpacity;
|
||||
this.overlayMesh.visible =
|
||||
!showShaderBackground && overlayOpacity > NIGHT_BACKGROUND_EPSILON;
|
||||
this.sunState = showShaderBackground ? null : celestialBodies?.sun ?? null;
|
||||
this.moonState =
|
||||
showShaderBackground ? null : celestialBodies?.moon ?? null;
|
||||
this.sunState = showShaderBackground
|
||||
? null
|
||||
: (celestialBodies?.sun ?? null);
|
||||
this.moonState = showShaderBackground
|
||||
? null
|
||||
: (celestialBodies?.moon ?? null);
|
||||
this.syncCelestialBodyVisualState(
|
||||
this.sunMesh,
|
||||
this.sunMaterial,
|
||||
@@ -805,7 +812,8 @@ export class WorldBackgroundRenderer {
|
||||
state.celestial.sunIntensity;
|
||||
this.shaderSkyMaterial.uniforms.uSunDiscSizeDegrees.value =
|
||||
state.celestial.sunDiscSizeDegrees;
|
||||
this.shaderSkyMaterial.uniforms.uSunVisible.value = state.celestial.sunVisible
|
||||
this.shaderSkyMaterial.uniforms.uSunVisible.value = state.celestial
|
||||
.sunVisible
|
||||
? 1
|
||||
: 0;
|
||||
this.shaderSkyMaterial.uniforms.uMoonDirection.value.set(
|
||||
@@ -820,7 +828,8 @@ export class WorldBackgroundRenderer {
|
||||
state.celestial.moonIntensity;
|
||||
this.shaderSkyMaterial.uniforms.uMoonDiscSizeDegrees.value =
|
||||
state.celestial.moonDiscSizeDegrees;
|
||||
this.shaderSkyMaterial.uniforms.uMoonVisible.value = state.celestial.moonVisible
|
||||
this.shaderSkyMaterial.uniforms.uMoonVisible.value = state.celestial
|
||||
.moonVisible
|
||||
? 1
|
||||
: 0;
|
||||
this.shaderSkyMaterial.uniforms.uDaylightFactor.value =
|
||||
|
||||
@@ -72,7 +72,9 @@ function parseHexColor(colorHex: string): { r: number; g: number; b: number } {
|
||||
|
||||
function formatHexColor(color: { r: number; g: number; b: number }): string {
|
||||
const toHex = (value: number) =>
|
||||
Math.round(clamp(value, 0, 255)).toString(16).padStart(2, "0");
|
||||
Math.round(clamp(value, 0, 255))
|
||||
.toString(16)
|
||||
.padStart(2, "0");
|
||||
|
||||
return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`;
|
||||
}
|
||||
@@ -86,8 +88,7 @@ function blendHexColorsByWeights(
|
||||
},
|
||||
weights: RuntimeDayNightPhaseWeights
|
||||
): string {
|
||||
const totalWeight =
|
||||
weights.day + weights.dawn + weights.dusk + weights.night;
|
||||
const totalWeight = weights.day + weights.dawn + weights.dusk + weights.night;
|
||||
|
||||
if (totalWeight <= 1e-6) {
|
||||
return colors.day;
|
||||
|
||||
Reference in New Issue
Block a user