☀️ Adds sun elevation calculator

This commit is contained in:
Rune Harlyk
2024-07-17 23:58:21 +02:00
committed by Rune Harlyk
parent b61223ea81
commit 5017e20871
2 changed files with 86 additions and 8 deletions
+2 -8
View File
@@ -25,6 +25,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
import { type URDFJoint, type URDFMimicJoint, type URDFRobot } from 'urdf-loader';
import { PointerURDFDragControls } from 'urdf-loader/src/URDFDragControls';
import { sunCalculator } from './utilities/position-utilities';
export const addScene = () => new Scene();
@@ -55,13 +56,6 @@ type directionalLight = position & light;
type gridHelperOptions = gridOptions & position;
function calculateCurrentSunElevation() {
let now = new Date();
let decimalTime = now.getHours() + now.getMinutes() / 60;
let normalizedTime = (decimalTime % 12) / 6 - 1;
return 10 * Math.sin(normalizedTime * Math.PI);
}
export default class SceneBuilder {
public scene: Scene;
public camera!: PerspectiveCamera;
@@ -107,7 +101,7 @@ export default class SceneBuilder {
rayleigh: 3,
mieCoefficient: 0.005,
mieDirectionalG: 0.7,
elevation: calculateCurrentSunElevation(),
elevation: sunCalculator.calculateSunElevation(),
azimuth: 180,
exposure: this.renderer.toneMappingExposure
};