Skip to content

Commit

Permalink
Merge branch 'main' into 16-include-diffuse-radiation
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianK13 authored Jul 22, 2024
2 parents dcc16b6 + a87fde3 commit f5a6f21
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class ShadingScene {
let shadingGeometry = BufferGeometryUtils.mergeGeometries(this.shadingGeometries);

// TODO: This breaks everything, why?
simulationGeometry = this.refineMesh(simulationGeometry, 0.5); // TODO: make configurable
simulationGeometry = this.refineMesh(simulationGeometry, 1.0); // TODO: make configurable

console.log('Number of simulation triangles:', simulationGeometry.attributes.position.count / 3);
console.log('Number of shading triangles:', shadingGeometry.attributes.position.count / 3);
Expand All @@ -145,27 +145,32 @@ export default class ShadingScene {
const points = simulationGeometry.attributes.position.array;
const normalsArray = simulationGeometry.attributes.normal.array;

let midpointsNan = 0;
let midpoints: number[] = [];
for (let i = 0; i < normalsArray.length; i += 9) {
const midpoint = triangleUtils.midpoint(points, i);
for (let j = 0; j < 3; j++) {
midpoints.push(midpoint[j] + normalsArray[i + j] * 0.05);
if (isNaN(midpoint[j])) {
console.log(`midpoint ${i} is nan`);
}
if (isNaN(normalsArray[i])) {
console.log(`normals ${i} is nan`);
midpointsNan++;
}
}
}
if (midpointsNan > 0) {
console.log(`${midpointsNan}/${midpoints.length} midpoints are nan`);
}

const midpointsArray = new Float32Array(midpoints.slice());

let meshNan = 0;
for (let i = 0; i < meshArray.length; i++) {
if (isNaN(meshArray[i])) {
console.log(`mesh ${i} is nan`);
meshNan++;
}
}
if (meshNan > 0) {
console.log(`${meshNan}/${meshArray.length} mesh coordinates are nan`);
}
// Compute unique intensities
console.log('Calling this.rayTrace');

Expand All @@ -188,9 +193,11 @@ export default class ShadingScene {
progressCallback,
);
}

console.log('directIntensities', directIntensities);
console.log('diffuseIntensities', diffuseIntensities);


const intensities = await sun.calculatePVYield(
directIntensities,
diffuseIntensities,
Expand All @@ -200,6 +207,7 @@ export default class ShadingScene {
);
console.log('finalIntensities', intensities);


return this.createMesh(simulationGeometry, intensities, maxYieldPerSquareMeter);
}
/** @ignore */
Expand All @@ -221,7 +229,7 @@ export default class ShadingScene {
vertexColors: true,
side: THREE.DoubleSide,
// shininess: 0, // TODO: typescript rejects this, do we need it?
roughness: 1,
// roughness: 1,
});
subdividedGeometry.setAttribute('intensities', new THREE.Float32BufferAttribute(intensities, 1));
let mesh = new THREE.Mesh(subdividedGeometry, material);
Expand Down

0 comments on commit f5a6f21

Please sign in to comment.