浏览代码

3dmLoader updates (#22860)

* extract name and value properties from objects

* Extract object userStrings

* 3dmLoader: refactor es6

* Remove unnecessary imports.

* adding some error catching related to PBR mats

* fix bug in texturetype checking

* adding taskId in worker

* Fixed eslint errors for examples

* doc strings

* rhino3dm 7.11.1 updates

Includes
- updating the example to 7.11.1 lib
- adding texture wrapping data from 3dm data
Luis E. Fraguada 3 年之前
父节点
当前提交
64b25a15ed
共有 3 个文件被更改,包括 19 次插入13 次删除
  1. 二进制
      examples/jsm/libs/rhino3dm/rhino3dm.wasm
  2. 18 12
      examples/jsm/loaders/3DMLoader.js
  3. 1 1
      examples/webgl_loader_3dm.html

二进制
examples/jsm/libs/rhino3dm/rhino3dm.wasm


+ 18 - 12
examples/jsm/loaders/3DMLoader.js

@@ -288,6 +288,10 @@ class Rhino3dmLoader extends Loader {
 
 
 				}
 				}
 
 
+				map.wrapS = texture.wrapU === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
+				map.wrapT = texture.wrapV === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
+				map.repeat.set( texture.repeat[ 0 ], texture.repeat[ 1 ] );
+
 			}
 			}
 
 
 		}
 		}
@@ -869,6 +873,7 @@ function Rhino3dmWorker() {
 		const views = [];
 		const views = [];
 		const namedViews = [];
 		const namedViews = [];
 		const groups = [];
 		const groups = [];
+		const strings = [];
 
 
 		//Handle objects
 		//Handle objects
 
 
@@ -958,6 +963,12 @@ function Rhino3dmWorker() {
 
 
 					const image = doc.getEmbeddedFileAsBase64( _texture.fileName );
 					const image = doc.getEmbeddedFileAsBase64( _texture.fileName );
 
 
+					texture.wrapU = _texture.wrapU;
+					texture.wrapV = _texture.wrapV;
+					texture.wrapW = _texture.wrapW;
+					const uvw = _texture.uvwTransform.toFloatArray( true );
+					texture.repeat = [ uvw[ 0 ], uvw[ 5 ] ];
+
 					if ( image ) {
 					if ( image ) {
 
 
 						texture.image = 'data:image/png;base64,' + image;
 						texture.image = 'data:image/png;base64,' + image;
@@ -1081,27 +1092,22 @@ function Rhino3dmWorker() {
 		// Handle bitmaps
 		// Handle bitmaps
 		// console.log( `Bitmap Count: ${doc.bitmaps().count()}` );
 		// console.log( `Bitmap Count: ${doc.bitmaps().count()}` );
 
 
-		// Handle strings -- this seems to be broken at the moment in rhino3dm
+		// Handle strings
 		// console.log( `Document Strings Count: ${doc.strings().count()}` );
 		// console.log( `Document Strings Count: ${doc.strings().count()}` );
+		// Note: doc.strings().documentUserTextCount() counts any doc.strings defined in a section
+		//console.log( `Document User Text Count: ${doc.strings().documentUserTextCount()}` );
 
 
-		/*
-		for( var i = 0; i < doc.strings().count(); i++ ){
-
-			var _string= doc.strings().get( i );
-
-			console.log(_string);
-			var string = extractProperties( _group );
+		const strings_count = doc.strings().count();
 
 
-			strings.push( string );
+		for ( let i = 0; i < strings_count; i ++ ) {
 
 
-			_string.delete();
+			strings.push( doc.strings().get( i ) );
 
 
 		}
 		}
-		*/
 
 
 		doc.delete();
 		doc.delete();
 
 
-		return { objects, materials, layers, views, namedViews, groups, settings };
+		return { objects, materials, layers, views, namedViews, groups, strings, settings };
 
 
 	}
 	}
 
 

+ 1 - 1
examples/webgl_loader_3dm.html

@@ -67,7 +67,7 @@
 				scene.add( directionalLight );
 				scene.add( directionalLight );
 
 
 				const loader = new Rhino3dmLoader();
 				const loader = new Rhino3dmLoader();
-				loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/rhino3dm@0.15.0-beta/' );
+				loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/rhino3dm@7.11.1/' );
 				loader.load( 'models/3dm/Rhino_Logo.3dm', function ( object ) {
 				loader.load( 'models/3dm/Rhino_Logo.3dm', function ( object ) {
 
 
 					scene.add( object );
 					scene.add( object );