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

Commit 1e51e88

Browse files
committed
Release 0.9.1
1 parent 4e0c1d0 commit 1e51e88

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
lines changed

build/RayTracingRenderer.es5.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -421,24 +421,18 @@
421421
var environmentLights = [];
422422
scene.traverse(function (child) {
423423
if (child.isMesh) {
424-
if (!child.geometry || !child.geometry.getAttribute('position')) {
425-
console.warn(child, 'must have a geometry property with a position attribute');
424+
if (!child.geometry) {
425+
console.warn(child, 'must have a geometry property');
426426
} else if (!child.material.isMeshStandardMaterial) {
427427
console.warn(child, 'must use MeshStandardMaterial in order to be rendered.');
428428
} else {
429429
meshes.push(child);
430430
}
431-
}
432-
433-
if (child.isDirectionalLight) {
431+
} else if (child.isDirectionalLight) {
434432
directionalLights.push(child);
435-
}
436-
437-
if (child.isAmbientLight) {
433+
} else if (child.isAmbientLight) {
438434
ambientLights.push(child);
439-
}
440-
441-
if (child.isEnvironmentLight) {
435+
} else if (child.isEnvironmentLight) {
442436
if (environmentLights.length > 1) {
443437
console.warn(environmentLights, 'only one environment light can be used per scene');
444438
} // Valid lights have HDR texture map in RGBEEncoding
@@ -1267,8 +1261,9 @@
12671261
try {
12681262
for (var _iterator3 = materials[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
12691263
var material = _step3.value;
1264+
var isTextureLoaded = material[textureName] && material[textureName].image;
12701265

1271-
if (!material[textureName]) {
1266+
if (!isTextureLoaded) {
12721267
indices.push(-1);
12731268
} else {
12741269
var index = textures.length;
@@ -1574,7 +1569,13 @@
15741569
for (var _iterator = meshes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
15751570
var mesh = _step.value;
15761571

1577-
var _geometry = cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']);
1572+
if (!mesh.visible) {
1573+
continue;
1574+
}
1575+
1576+
var _geometry = mesh.geometry.isBufferGeometry ? cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']) : // BufferGeometry object
1577+
new THREE$1.BufferGeometry().fromGeometry(mesh.geometry); // Geometry object
1578+
15781579

15791580
var index = _geometry.getIndex();
15801581

@@ -1933,6 +1934,11 @@
19331934
}
19341935

19351936
var dim = maximumExtent(centroidBounds);
1937+
1938+
if (centroidBounds.max[dim] === centroidBounds.min[dim]) {
1939+
return makeLeafNode(primitiveInfo.slice(start, end), bounds);
1940+
}
1941+
19361942
var mid = Math.floor((start + end) / 2); // middle split method
19371943
// const dimMid = (centroidBounds.max[dim] + centroidBounds.min[dim]) / 2;
19381944
// mid = partition(primitiveInfo, p => p.center[dim] < dimMid, start, end);

build/RayTracingRenderer.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,22 @@
151151

152152
scene.traverse(child => {
153153
if (child.isMesh) {
154-
if (!child.geometry || !child.geometry.getAttribute('position')) {
155-
console.warn(child, 'must have a geometry property with a position attribute');
154+
if (!child.geometry) {
155+
console.warn(child, 'must have a geometry property');
156156
}
157157
else if (!(child.material.isMeshStandardMaterial)) {
158158
console.warn(child, 'must use MeshStandardMaterial in order to be rendered.');
159159
} else {
160160
meshes.push(child);
161161
}
162162
}
163-
if (child.isDirectionalLight) {
163+
else if (child.isDirectionalLight) {
164164
directionalLights.push(child);
165165
}
166-
if (child.isAmbientLight) {
166+
else if (child.isAmbientLight) {
167167
ambientLights.push(child);
168168
}
169-
if (child.isEnvironmentLight) {
169+
else if (child.isEnvironmentLight) {
170170
if (environmentLights.length > 1) {
171171
console.warn(environmentLights, 'only one environment light can be used per scene');
172172
}
@@ -1153,7 +1153,9 @@ vec3 getMatNormal(int materialIndex, vec2 uv, vec3 normal, vec3 dp1, vec3 dp2, v
11531153
const indices = [];
11541154

11551155
for (const material of materials) {
1156-
if (!material[textureName]) {
1156+
const isTextureLoaded = material[textureName] && material[textureName].image;
1157+
1158+
if (!isTextureLoaded) {
11571159
indices.push(-1);
11581160
} else {
11591161
let index = textures.length;
@@ -1353,7 +1355,13 @@ vec3 getMatNormal(int materialIndex, vec2 uv, vec3 normal, vec3 dp1, vec3 dp2, v
13531355
const materialIndexMap = new Map();
13541356

13551357
for (const mesh of meshes) {
1356-
const geometry = cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']);
1358+
if (!mesh.visible) {
1359+
continue;
1360+
}
1361+
1362+
const geometry = mesh.geometry.isBufferGeometry ?
1363+
cloneBufferGeometry(mesh.geometry, ['position', 'normal', 'uv']) : // BufferGeometry object
1364+
new THREE$1.BufferGeometry().fromGeometry(mesh.geometry); // Geometry object
13571365

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

1675+
if (centroidBounds.max[dim] === centroidBounds.min[dim]) {
1676+
return makeLeafNode(primitiveInfo.slice(start, end), bounds);
1677+
}
1678+
16671679
let mid = Math.floor((start + end) / 2);
16681680

16691681
// middle split method

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ray-tracing-renderer",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"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.",
55
"main": "build/RayTracingRenderer.js",
66
"scripts": {

0 commit comments

Comments
 (0)