From bbf973f6cae7da843b1852921bd054bfcc9f8321 Mon Sep 17 00:00:00 2001 From: m-schuetz Date: Sat, 14 Oct 2017 15:17:29 +0200 Subject: [PATCH] minor perf improvements --- src/PointCloudOctree.js | 19 ++++++++++++------- src/viewer/viewer.js | 38 +++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js index efeffa86..956b01ae 100644 --- a/src/PointCloudOctree.js +++ b/src/PointCloudOctree.js @@ -250,15 +250,19 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree { let children = []; for (let j = 0; j < 8; j++) { let child = node.children[j]; - if (child instanceof Potree.PointCloudOctreeNode && nodes.includes(child)) { + + //if (child instanceof Potree.PointCloudOctreeNode && nodes.includes(child)) { + // "child.constructor" version is slightly faster than the "child instanceof" version in chrome 61, + // especially if the profiler is running + if( child && child.constructor === Potree.PointCloudOctreeNode && nodes.includes(child, i)){ children.push(child); } } - children.sort(function (a, b) { - if (a.geometryNode.name < b.geometryNode.name) return -1; - if (a.geometryNode.name > b.geometryNode.name) return 1; - return 0; - }); + //children.sort(function (a, b) { + // if (a.geometryNode.name < b.geometryNode.name) return -1; + // if (a.geometryNode.name > b.geometryNode.name) return 1; + // return 0; + //}); data[i * 3 + 0] = 0; data[i * 3 + 1] = 0; @@ -269,7 +273,8 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree { data[i * 3 + 0] += Math.pow(2, index); if (j === 0) { - let vArrayIndex = nodes.indexOf(child); + let vArrayIndex = nodes.indexOf(child, i); + //let vArrayIndex = child._index; data[i * 3 + 1] = (vArrayIndex - i) >> 8; data[i * 3 + 2] = (vArrayIndex - i) % 256; } diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 45595c04..d7436cc8 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -1942,24 +1942,24 @@ class EDLRenderer { this.rtColor.depthTexture.type = THREE.UnsignedIntType; - //this.rtShadow = new THREE.WebGLRenderTarget(1024, 1024, { - // minFilter: THREE.NearestFilter, - // magFilter: THREE.NearestFilter, - // format: THREE.RGBAFormat, - // type: THREE.FloatType - //}); - //this.rtShadow.depthTexture = new THREE.DepthTexture(); - //this.rtShadow.depthTexture.type = THREE.UnsignedIntType; - - - //{ - // let geometry = new THREE.PlaneBufferGeometry( 10, 7, 32 ); - // let material = new THREE.MeshBasicMaterial( {side: THREE.DoubleSide, map: this.rtShadow.texture} ); - // let plane = new THREE.Mesh( geometry, material ); - // plane.position.z = 0.2; - // plane.position.y = -1; - // this.viewer.scene.scene.add( plane ); - //} + this.rtShadow = new THREE.WebGLRenderTarget(1024, 1024, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat, + type: THREE.FloatType + }); + this.rtShadow.depthTexture = new THREE.DepthTexture(); + this.rtShadow.depthTexture.type = THREE.UnsignedIntType; + + + { + let geometry = new THREE.PlaneBufferGeometry( 10, 7, 32 ); + let material = new THREE.MeshBasicMaterial( {side: THREE.DoubleSide, map: this.rtShadow.texture} ); + let plane = new THREE.Mesh( geometry, material ); + plane.position.z = 0.2; + plane.position.y = -1; + this.viewer.scene.scene.add( plane ); + } }; resize () { @@ -2028,7 +2028,7 @@ class EDLRenderer { viewer.renderer.render(viewer.scene.scene, camera); - //viewer.renderer.clearTarget( this.rtShadow, true, true, true ); + viewer.renderer.clearTarget( this.rtShadow, true, true, true ); viewer.renderer.clearTarget( this.rtColor, true, true, true ); let width = viewer.renderArea.clientWidth;