소스 검색

3dmLoader: Updates (#21347)

* extract name and value properties from objects

* Extract object userStrings
Luis E. Fraguada 4 년 전
부모
커밋
9522135fda
1개의 변경된 파일21개의 추가작업 그리고 5개의 파일을 삭제
  1. 21 5
      examples/jsm/loaders/3DMLoader.js

+ 21 - 5
examples/jsm/loaders/3DMLoader.js

@@ -1247,11 +1247,16 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
 
 			}
 
+			if ( _geometry.userStringCount > 0 ) {
+
+				attributes.geometry.userStrings = _geometry.getUserStrings();
+
+			}
+
 			attributes.drawColor = _attributes.drawColor( doc );
 
 			objectType = objectType.constructor.name;
 			objectType = objectType.substring( 11, objectType.length );
-			attributes.geometry.objectType = objectType;
 
 			return { geometry, attributes, objectType };
 
@@ -1269,13 +1274,24 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
 
 		for ( var property in object ) {
 
-			if ( typeof object[ property ] !== 'function' ) {
+			var value = object[ property ];
+
+			if ( typeof value !== 'function' ) {
+
+				if ( typeof value === 'object' && value !== null && value.hasOwnProperty( 'constructor' ) ) {
 
-				result[ property ] = object[ property ];
+					result[ property ] = { name: value.constructor.name, value: value.value };
+
+				} else {
+
+					result[ property ] = value;
+
+				}
 
 			} else {
 
-				// console.log( `${property}: ${object[ property ]}` );
+				// these are functions that could be called to extract more data.
+				//console.log( `${property}: ${object[ property ].constructor.name}` );
 
 			}
 
@@ -1368,7 +1384,7 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
 			var tan = curve.tangentAt( t );
 			var prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );
 
-			// Duplicaated from THREE.Vector3
+			// Duplicated from THREE.Vector3
 			// How to pass imports to worker?
 
 			var tS = tan[ 0 ] * tan[ 0 ] + tan[ 1 ] * tan[ 1 ] + tan[ 2 ] * tan[ 2 ];