浏览代码

Support for SubD mesh from controlNet, dot tuneup

Luis Fraguada 4 年之前
父节点
当前提交
497787571b
共有 3 个文件被更改,包括 37 次插入2 次删除
  1. 0 0
      examples/jsm/libs/rhino3dm/rhino3dm.js
  2. 二进制
      examples/jsm/libs/rhino3dm/rhino3dm.wasm
  3. 37 2
      examples/jsm/loaders/3DMLoader.js

文件差异内容过多而无法显示
+ 0 - 0
examples/jsm/libs/rhino3dm/rhino3dm.js


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


+ 37 - 2
examples/jsm/loaders/3DMLoader.js

@@ -446,6 +446,7 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			case 'Mesh':
 			case 'Extrusion':
+			case 'SubD':
 
 				var geometry = loader.parse( obj.geometry );
 
@@ -455,6 +456,13 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
+				if ( mat === null ) {
+
+					mat = this._createMaterial();
+					mat = this._compareMaterials( mat );
+
+				}
+
 				var mesh = new Mesh( geometry, mat );
 				mesh.castShadow = attributes.castsShadows;
 				mesh.receiveShadow = attributes.receivesShadows;
@@ -509,8 +517,21 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				var width = ctx.measureText( geometry.text ).width + 10;
 				var height = geometry.fontHeight + 10;
 
-				ctx.canvas.width = width;
-				ctx.canvas.height = height;
+				// ref https://bl.ocks.org/duhaime/60c7083009bbd49ce50a58c371d8c818
+				var dpr = window.devicePixelRatio || 1;
+        		var bsr = ctx.webkitBackingStorePixelRatio ||
+					ctx.mozBackingStorePixelRatio ||
+					ctx.msBackingStorePixelRatio ||
+					ctx.oBackingStorePixelRatio ||
+					ctx.backingStorePixelRatio || 1;
+
+				var r = dpr / bsr;
+
+				ctx.canvas.width = width * r;
+				ctx.canvas.height = height * r;
+				ctx.canvas.style.width = width + 'px';
+				ctx.canvas.style.height = height + 'px';
+				ctx.setTransform( r, 0, 0, r, 0, 0 );
 
 				ctx.font = font;
 				ctx.textBaseline = 'middle';
@@ -1166,6 +1187,20 @@ Rhino3dmLoader.Rhino3dmWorker = function () {
 
 				break;
 
+			case rhino.ObjectType.SubD:
+
+				// TODO: precalculate resulting vertices and faces and warn on excessive results
+				_geometry.subdivide( 3 );
+				var mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
+				if ( mesh ) {
+
+					geometry = mesh.toThreejsJSON();
+					mesh.delete();
+
+				}
+
+				break;
+
 				/*
 				case rhino.ObjectType.Annotation:
 				case rhino.ObjectType.Hatch:

部分文件因为文件数量过多而无法显示