From 42aad2f1d705c335b12faa8b20ee53460b98bbb8 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Mon, 3 Nov 2014 13:04:56 +0100 Subject: [PATCH] custom updateMatrixWorld() for PointCloudOctree --- src/PointCloudOctree.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js index 7cc3d4ad..de87c1c8 100644 --- a/src/PointCloudOctree.js +++ b/src/PointCloudOctree.js @@ -128,7 +128,7 @@ Potree.PointCloudOctree.prototype.update = function(camera){ } } - + object.matrixWorld.multiplyMatrices( object.parent.matrixWorld, object.matrix ); if(object instanceof THREE.PointCloud){ this.numVisibleNodes++; @@ -192,9 +192,29 @@ Potree.PointCloudOctree.prototype.update = function(camera){ } } -//Potree.PointCloudOctree.updateMatrixWorld = function( force ){ -// node.matrixWorld.multiplyMatrices( node.parent.matrixWorld, node.matrix ); -//}; +Potree.PointCloudOctree.prototype.updateMatrixWorld = function( force ){ + //node.matrixWorld.multiplyMatrices( node.parent.matrixWorld, node.matrix ); + + if ( this.matrixAutoUpdate === true ) this.updateMatrix(); + + if ( this.matrixWorldNeedsUpdate === true || force === true ) { + + if ( this.parent === undefined ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + this.matrixWorldNeedsUpdate = false; + + force = true; + + } +}; Potree.PointCloudOctree.prototype.replaceProxy = function(proxy){ @@ -211,6 +231,8 @@ Potree.PointCloudOctree.prototype.replaceProxy = function(proxy){ var parent = proxy.parent; parent.remove(proxy); parent.add(node); + + node.matrixWorld.multiplyMatrices( node.parent.matrixWorld, node.matrix ); for(var i = 0; i < 8; i++){ if(geometryNode.children[i] !== undefined){