瀏覽代碼

3dmLoader: Updating to 8.4.0 (#27833)

* Fixed eslint errors for examples

* first RDK additions to 3dmLoader

* updated PBR material properties conversion

* compromises for glass

* extractProperties now recursive

* update table count to properties

* update 3dmLoader

* update 3dmLoader

* Added material conversion

* add renderSettings, remove test _initLibrary

* added missing semis

* cleanup 3dmLoader update

* fixes issue with default material getting overwritten with vertex color flag

* cleanup

* updating rhino3dm to 8.4 (much smaller!)

* remove log
Luis E. Fraguada 1 年之前
父節點
當前提交
c66f9d6f3e

+ 6 - 6
docs/examples/en/loaders/3DMLoader.html

@@ -14,7 +14,7 @@
 			A loader for Rhinoceros 3d files and objects. <br /><br />
 			Rhinoceros is a 3D modeler used to create, edit, analyze, document, render, animate, and translate NURBS curves, surfaces, breps, extrusions, point clouds, as well as polygon meshes and SubD objects.
 			[link:https://github.com/mcneel/rhino3dm rhino3dm.js] is compiled to WebAssembly from the open source geometry library [link:https://github.com/mcneel/opennurbs openNURBS].
-			The loader currently uses [link:https://www.npmjs.com/package/rhino3dm/v/8.0.1 rhino3dm.js 8.0.1.]
+			The loader currently uses [link:https://www.npmjs.com/package/rhino3dm/v/8.4.0 rhino3dm.js 8.4.0.]
 		</p>
 
 		<h2>Import</h2>
@@ -166,7 +166,7 @@
 			// Specify path to a folder containing WASM/JS libraries or a CDN.
 			// For example, /jsm/libs/rhino3dm/ is the location of the library inside the three.js repository
 			// loader.setLibraryPath( '/path_to_library/rhino3dm/' );
-			loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.0.1/' );
+			loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.4.0/' );
 	
 			// Load a 3DM file
 			loader.load(
@@ -201,17 +201,17 @@
 		</p>
 		<p>
 		Parse a File3dm ArrayBuffer and call the `onLoad` function with the resulting Object3d.
-		See [link:https://github.com/mcneel/rhino-developer-samples/tree/7/rhino3dm/js/SampleParse3dmObjects this example] for further reference.
+		See [link:https://github.com/mcneel/rhino-developer-samples/tree/8/rhino3dm/js/SampleParse3dmObjects this example] for further reference.
 		</p>
 
 		<code>
-		import rhino3dm from 'https://unpkg.com/rhino3dm@8.0.1'
+		import rhino3dm from 'https://unpkg.com/rhino3dm@8.4.0'
 
 		// Instantiate a loader
 		const loader = new Rhino3dmLoader();
 
 		// Specify path to a folder containing WASM/JS libraries or a CDN.
-		loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.0.1' );
+		loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.4.0' );
 
 		const rhino = await rhino3dm();
 		console.log('Loaded rhino3dm.');
@@ -244,7 +244,7 @@
 		// Specify path to a folder containing the WASM/JS library:
 		loader.setLibraryPath( '/path_to_library/rhino3dm/' );
 		// or from a CDN:
-		loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.0.1' );
+		loader.setLibraryPath( 'https://unpkg.com/rhino3dm@8.4.0' );
 		</code>
 
 		<h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>

File diff suppressed because it is too large
+ 0 - 2044
examples/jsm/libs/rhino3dm/rhino3dm.js


File diff suppressed because it is too large
+ 0 - 2055
examples/jsm/libs/rhino3dm/rhino3dm.module.js


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


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

@@ -192,6 +192,7 @@ class Rhino3dmLoader extends Loader {
 		mat.color.g = material.color.g;
 		mat.color.b = material.color.b;
 		mat.type = material.type;
+		mat.vertexColors = material.vertexColors;
 
 		const json = JSON.stringify( mat );
 
@@ -205,6 +206,7 @@ class Rhino3dmLoader extends Loader {
 			_mat.color.g = m.color.g;
 			_mat.color.b = m.color.b;
 			_mat.type = m.type;
+			_mat.vertexColors = m.vertexColors;
 
 			if ( JSON.stringify( _mat ) === json ) {
 
@@ -488,7 +490,7 @@ class Rhino3dmLoader extends Loader {
 
 				default:
 
-					let matId;
+					let matId = null;
 
 					switch ( attributes.materialSource.name ) {
 
@@ -498,10 +500,6 @@ class Rhino3dmLoader extends Loader {
 
 								matId = data.layers[ attributes.layerIndex ].renderMaterialIndex;
 
-							} else {
-
-								matId = null;
-
 							}
 
 							break;
@@ -512,17 +510,13 @@ class Rhino3dmLoader extends Loader {
 
 								matId = attributes.materialIndex;
 
-							} else {
-
-								matId = null;
-
 							}
 
 							break;
 
 					}
 
-					let material;
+					let material = null;
 
 					if ( matId >= 0 ) {
 
@@ -530,13 +524,8 @@ class Rhino3dmLoader extends Loader {
 						material = this._createMaterial( rMaterial, data.renderEnvironment );
 
 
-					} else {
-
-						material = this._createMaterial();
-
 					}
 
-					material = this._compareMaterials( material );
 					const _object = this._createObject( obj, material );
 
 					if ( _object === undefined ) {
@@ -675,19 +664,22 @@ class Rhino3dmLoader extends Loader {
 
 				geometry = loader.parse( obj.geometry );
 
-				if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
 
-					mat.vertexColors = true;
+				if ( mat === null ) {
+
+					mat = this._createMaterial();
 
 				}
 
-				if ( mat === null ) {
 
-					mat = this._createMaterial();
-					mat = this._compareMaterials( mat );
+				if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
+
+					mat.vertexColors = true;
 
 				}
 
+				mat = this._compareMaterials( mat );
+
 				const mesh = new Mesh( geometry, mat );
 				mesh.castShadow = attributes.castsShadows;
 				mesh.receiveShadow = attributes.receivesShadows;
@@ -1529,7 +1521,7 @@ function Rhino3dmWorker() {
 
 				// TODO: precalculate resulting vertices and faces and warn on excessive results
 				_geometry.subdivide( 3 );
-				mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
+				mesh = rhino.Mesh.createFromSubDControlNet( _geometry, false );
 				if ( mesh ) {
 
 					geometry = mesh.toThreejsJSON();

+ 8 - 0
examples/webgl_loader_3dm.html

@@ -85,6 +85,14 @@
 					// hide spinner
 					document.getElementById( 'loader' ).style.display = 'none';
 
+				}, function ( progress ) {
+
+					console.log ( ( progress.loaded / progress.total * 100 ) + '%' );
+
+				}, function ( error ) {
+
+					console.log ( error );
+
 				} );
 
 				controls = new OrbitControls( camera, renderer.domElement );

Some files were not shown because too many files changed in this diff