Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Release 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
elfrank committed May 8, 2020
1 parent 4e0c1d0 commit 1e51e88
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
32 changes: 19 additions & 13 deletions build/RayTracingRenderer.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,24 +421,18 @@
var environmentLights = [];
scene.traverse(function (child) {
if (child.isMesh) {
if (!child.geometry || !child.geometry.getAttribute('position')) {
console.warn(child, 'must have a geometry property with a position attribute');
if (!child.geometry) {
console.warn(child, 'must have a geometry property');
} else if (!child.material.isMeshStandardMaterial) {
console.warn(child, 'must use MeshStandardMaterial in order to be rendered.');
} else {
meshes.push(child);
}
}

if (child.isDirectionalLight) {
} else if (child.isDirectionalLight) {
directionalLights.push(child);
}

if (child.isAmbientLight) {
} else if (child.isAmbientLight) {
ambientLights.push(child);
}

if (child.isEnvironmentLight) {
} else if (child.isEnvironmentLight) {
if (environmentLights.length > 1) {
console.warn(environmentLights, 'only one environment light can be used per scene');
} // Valid lights have HDR texture map in RGBEEncoding
Expand Down Expand Up @@ -1267,8 +1261,9 @@
try {
for (var _iterator3 = materials[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var material = _step3.value;
var isTextureLoaded = material[textureName] && material[textureName].image;

if (!material[textureName]) {
if (!isTextureLoaded) {
indices.push(-1);
} else {
var index = textures.length;
Expand Down Expand Up @@ -1574,7 +1569,13 @@
for (var _iterator = meshes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var mesh = _step.value;

var _geometry = cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']);
if (!mesh.visible) {
continue;
}

var _geometry = mesh.geometry.isBufferGeometry ? cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']) : // BufferGeometry object
new THREE$1.BufferGeometry().fromGeometry(mesh.geometry); // Geometry object


var index = _geometry.getIndex();

Expand Down Expand Up @@ -1933,6 +1934,11 @@
}

var dim = maximumExtent(centroidBounds);

if (centroidBounds.max[dim] === centroidBounds.min[dim]) {
return makeLeafNode(primitiveInfo.slice(start, end), bounds);
}

var mid = Math.floor((start + end) / 2); // middle split method
// const dimMid = (centroidBounds.max[dim] + centroidBounds.min[dim]) / 2;
// mid = partition(primitiveInfo, p => p.center[dim] < dimMid, start, end);
Expand Down
26 changes: 19 additions & 7 deletions build/RayTracingRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,22 @@

scene.traverse(child => {
if (child.isMesh) {
if (!child.geometry || !child.geometry.getAttribute('position')) {
console.warn(child, 'must have a geometry property with a position attribute');
if (!child.geometry) {
console.warn(child, 'must have a geometry property');
}
else if (!(child.material.isMeshStandardMaterial)) {
console.warn(child, 'must use MeshStandardMaterial in order to be rendered.');
} else {
meshes.push(child);
}
}
if (child.isDirectionalLight) {
else if (child.isDirectionalLight) {
directionalLights.push(child);
}
if (child.isAmbientLight) {
else if (child.isAmbientLight) {
ambientLights.push(child);
}
if (child.isEnvironmentLight) {
else if (child.isEnvironmentLight) {
if (environmentLights.length > 1) {
console.warn(environmentLights, 'only one environment light can be used per scene');
}
Expand Down Expand Up @@ -1153,7 +1153,9 @@ vec3 getMatNormal(int materialIndex, vec2 uv, vec3 normal, vec3 dp1, vec3 dp2, v
const indices = [];

for (const material of materials) {
if (!material[textureName]) {
const isTextureLoaded = material[textureName] && material[textureName].image;

if (!isTextureLoaded) {
indices.push(-1);
} else {
let index = textures.length;
Expand Down Expand Up @@ -1353,7 +1355,13 @@ vec3 getMatNormal(int materialIndex, vec2 uv, vec3 normal, vec3 dp1, vec3 dp2, v
const materialIndexMap = new Map();

for (const mesh of meshes) {
const geometry = cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']);
if (!mesh.visible) {
continue;
}

const geometry = mesh.geometry.isBufferGeometry ?
cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']) : // BufferGeometry object
new THREE$1.BufferGeometry().fromGeometry(mesh.geometry); // Geometry object

const index = geometry.getIndex();
if (!index) {
Expand Down Expand Up @@ -1664,6 +1672,10 @@ vec3 getMatNormal(int materialIndex, vec2 uv, vec3 normal, vec3 dp1, vec3 dp2, v
}
const dim = maximumExtent(centroidBounds);

if (centroidBounds.max[dim] === centroidBounds.min[dim]) {
return makeLeafNode(primitiveInfo.slice(start, end), bounds);
}

let mid = Math.floor((start + end) / 2);

// middle split method
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ray-tracing-renderer",
"version": "0.9.0",
"version": "0.9.1",
"description": "A [Three.js](https://github.com/mrdoob/three.js/) renderer which utilizes path tracing to render a scene with true photorealism. The renderer supports global illumination, reflections, soft shadows, and realistic environment lighting.",
"main": "build/RayTracingRenderer.js",
"scripts": {
Expand Down

0 comments on commit 1e51e88

Please sign in to comment.