Browse Source

Read object name from .3dm file

perkma 4 năm trước cách đây
mục cha
commit
77fc77918c
1 tập tin đã thay đổi với 15 bổ sung0 xóa
  1. 15 0
      examples/jsm/loaders/3DMLoader.js

+ 15 - 0
examples/jsm/loaders/3DMLoader.js

@@ -442,6 +442,9 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				var points = new Points( geometry, material );
 				var points = new Points( geometry, material );
 				points.userData[ 'attributes' ] = attributes;
 				points.userData[ 'attributes' ] = attributes;
 				points.userData[ 'objectType' ] = obj.objectType;
 				points.userData[ 'objectType' ] = obj.objectType;
+				if( attributes.name ) {
+					points.name = attributes.name;
+				}
 				return points;
 				return points;
 
 
 			case 'Mesh':
 			case 'Mesh':
@@ -468,6 +471,9 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				mesh.receiveShadow = attributes.receivesShadows;
 				mesh.receiveShadow = attributes.receivesShadows;
 				mesh.userData[ 'attributes' ] = attributes;
 				mesh.userData[ 'attributes' ] = attributes;
 				mesh.userData[ 'objectType' ] = obj.objectType;
 				mesh.userData[ 'objectType' ] = obj.objectType;
+				if( attributes.name ) {
+					mesh.name = attributes.name;
+				}
 
 
 				return mesh;
 				return mesh;
 
 
@@ -488,6 +494,9 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 
 				brepObject.userData[ 'attributes' ] = attributes;
 				brepObject.userData[ 'attributes' ] = attributes;
 				brepObject.userData[ 'objectType' ] = obj.objectType;
 				brepObject.userData[ 'objectType' ] = obj.objectType;
+<				if( attributes.name ) {
+					brepObject.name = attributes.name;
+				}
 
 
 				return brepObject;
 				return brepObject;
 
 
@@ -504,6 +513,9 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				var lines = new Line( geometry, material );
 				var lines = new Line( geometry, material );
 				lines.userData[ 'attributes' ] = attributes;
 				lines.userData[ 'attributes' ] = attributes;
 				lines.userData[ 'objectType' ] = obj.objectType;
 				lines.userData[ 'objectType' ] = obj.objectType;
+				if( attributes.name ) {
+					lines.name = attributes.name;
+				}
 
 
 				return lines;
 				return lines;
 
 
@@ -546,6 +558,9 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 
 				sprite.userData[ 'attributes' ] = attributes;
 				sprite.userData[ 'attributes' ] = attributes;
 				sprite.userData[ 'objectType' ] = obj.objectType;
 				sprite.userData[ 'objectType' ] = obj.objectType;
+				if( attributes.name ) {
+					sprite.name = attributes.name;
+				}
 
 
 				return sprite;
 				return sprite;