Skip to content

Conversation

@donmccurdy
Copy link
Collaborator

@donmccurdy donmccurdy commented Mar 15, 2019

Also moves TypedArrayUtils into the utils folder.

Diff below:

diff --git a/examples/js/utils/TypedArrayUtils.js b/examples/jsm/utils/TypedArrayUtils.js
index 22024ce72..2817eb46a 100644
--- a/examples/js/utils/TypedArrayUtils.js
+++ b/examples/jsm/utils/TypedArrayUtils.js
@@ -1,5 +1,5 @@
 
-THREE.TypedArrayUtils = {};
+var TypedArrayUtils = {};
 
 /**
  * In-place quicksort for typed arrays (e.g. for Float32Array)
@@ -18,7 +18,7 @@ THREE.TypedArrayUtils = {};
  * orderElement: 0 //order according to x
  */
 
-THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
+TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 
 	var stack = [];
 	var sp = - 1;
@@ -179,10 +179,10 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
  * http://en.wikipedia.org/wiki/Binary_tree
  * http://en.wikipedia.org/wiki/K-d_tree
  *
- * If you want to further minimize memory usage, remove Node.depth and replace in search algorithm with a traversal to root node (see comments at THREE.TypedArrayUtils.Kdtree.prototype.Node)
+ * If you want to further minimize memory usage, remove Node.depth and replace in search algorithm with a traversal to root node (see comments at TypedArrayUtils.Kdtree.prototype.Node)
  */
 
- THREE.TypedArrayUtils.Kdtree = function ( points, metric, eleSize ) {
+ TypedArrayUtils.Kdtree = function ( points, metric, eleSize ) {
 
 	var self = this;
 	
@@ -210,7 +210,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 
 		}
 
-		THREE.TypedArrayUtils.quicksortIP( points, eleSize, dim );
+		TypedArrayUtils.quicksortIP( points, eleSize, dim );
 		
 		median = Math.floor( plength / 2 );
 		
@@ -242,7 +242,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
 			result,
 			bestNodes;
 
-		bestNodes = new THREE.TypedArrayUtils.Kdtree.BinaryHeap(
+		bestNodes = new TypedArrayUtils.Kdtree.BinaryHeap(
 
 			function ( e ) {
 
@@ -405,7 +405,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
  *
  * I experienced that for 200'000 nodes you can get rid of 4 MB memory each, leading to 8 MB memory saved.
  */
-THREE.TypedArrayUtils.Kdtree.prototype.Node = function ( obj, depth, parent, pos ) {
+TypedArrayUtils.Kdtree.prototype.Node = function ( obj, depth, parent, pos ) {
 
 	this.obj = obj;
 	this.left = null;
@@ -421,14 +421,14 @@ THREE.TypedArrayUtils.Kdtree.prototype.Node = function ( obj, depth, parent, pos
  * @author http://eloquentjavascript.net/appendix2.htm
  */
 
-THREE.TypedArrayUtils.Kdtree.BinaryHeap = function ( scoreFunction ) {
+TypedArrayUtils.Kdtree.BinaryHeap = function ( scoreFunction ) {
 
 	this.content = [];
 	this.scoreFunction = scoreFunction;
 
 };
 
-THREE.TypedArrayUtils.Kdtree.BinaryHeap.prototype = {
+TypedArrayUtils.Kdtree.BinaryHeap.prototype = {
 
 	push: function ( element ) {
 
@@ -600,3 +600,5 @@ THREE.TypedArrayUtils.Kdtree.BinaryHeap.prototype = {
 	}
 
 };
+
+export { TypedArrayUtils };

@mrdoob mrdoob added this to the r103 milestone Mar 15, 2019
@mrdoob mrdoob merged commit f7bbe43 into mrdoob:dev Mar 15, 2019
@mrdoob
Copy link
Owner

mrdoob commented Mar 15, 2019

Thanks!

@donmccurdy donmccurdy deleted the jsm-typedarrayutils branch March 15, 2019 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants