Browse Source

Add userData to Geometry

Takahiro 7 years ago
parent
commit
2928e097a2
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/core/Geometry.js

+ 7 - 0
src/core/Geometry.js

@@ -46,6 +46,8 @@ function Geometry() {
 	this.boundingBox = null;
 	this.boundingSphere = null;
 
+	this.userData = {};
+
 	// update flags
 
 	this.elementsNeedUpdate = false;
@@ -987,6 +989,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		data.uuid = this.uuid;
 		data.type = this.type;
 		if ( this.name !== '' ) data.name = this.name;
+		if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
 
 		if ( this.parameters !== undefined ) {
 
@@ -1415,6 +1418,10 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		}
 
+		// user data
+
+		this.userData = source.userData;
+
 		// update flags
 
 		this.elementsNeedUpdate = source.elementsNeedUpdate;