minor perf improvements

This commit is contained in:
m-schuetz 2017-10-14 15:17:29 +02:00
parent 7932491dd9
commit bbf973f6ca
2 changed files with 31 additions and 26 deletions

View File

@ -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;
}

View File

@ -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;