Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/headless/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function main(argv: string[]) {
)
.option('--chrome-args <arg...>', 'Additional Chrome launch argument(s).')
.option(
'--max-old-space-size',
'--max-old-space-size <number>',
"Sets the max memory size of V8's old memory section in the browser (in MiB) (default: 16384).",
'16384',
)
Expand Down
2 changes: 1 addition & 1 deletion src/headless/headlessBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function runShadingSceneHeadlessChrome(
'--enable-webgl2',
'--no-sandbox',
'--disable-dev-shm-usage', // Overcome limited resource problems
`--max_old_space_size=${options.maxOldSpaceSize}`, // Increase V8 heap size
`--js-flags=--max_old_space_size=${options.maxOldSpaceSize}`, // Increase V8 heap size
...launchArgs,
],
protocolTimeout: 24 * 60 * 60 * 1_000,
Expand Down
26 changes: 26 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,24 @@ export class ShadingScene {
const minSunAngle = this.minSunAngle ?? getMinSunAngleFromIrradiance(this.solarIrradiance);
this.shadingGeometry = filterShadingBufferGeometry(this.simulationGeometry, this.shadingGeometry, minSunAngle);

// Move geometry coordinates to the coordinate system origin
const simPoints = this.simulationGeometry.attributes.position.array;
const xShift = simPoints[0];
const yShift = simPoints[1];
const zShift = simPoints[2];

for (let i = 0; i < simPoints.length; i += 3) {
simPoints[i] -= xShift;
simPoints[i + 1] -= yShift;
simPoints[i + 2] -= zShift;
}
const shadingPoints = this.shadingGeometry.attributes.position.array;
for (let i = 0; i < shadingPoints.length; i += 3) {
shadingPoints[i] -= xShift;
shadingPoints[i + 1] -= yShift;
shadingPoints[i + 2] -= zShift;
}

// Merge geometries
this.simulationGeometry = this.refineMesh(this.simulationGeometry, 1.0);

Expand Down Expand Up @@ -279,6 +297,14 @@ export class ShadingScene {
this.solarIrradiance[0].metadata.valid_timesteps_for_aggregation,
);

// Restore original coordinates before creating the output mesh
const simResultPoints = this.simulationGeometry.attributes.position.array;
for (let i = 0; i < simResultPoints.length; i += 3) {
simResultPoints[i] += xShift;
simResultPoints[i + 1] += yShift;
simResultPoints[i + 2] += zShift;
}

return this.createMesh(this.simulationGeometry, pvYield, maxYieldPerSquareMeter);
}

Expand Down
3 changes: 2 additions & 1 deletion src/rayTracingWebGL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export async function rayTracingWebGL(
const vertexShaderSource = `#version 300 es
#define INFINITY 1000000.0
precision highp float;

precision highp int;
precision highp sampler2D;

uniform sampler2D u_triangles;
uniform vec3 u_sun_direction;
Expand Down