File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed
Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,14 @@ THREE.BufferGeometryUtils = {
9696 ( s1 * z2 - s2 * z1 ) * r
9797 ) ;
9898
99+ // silently ignore degenerate uvs/triangles that yield NaN/Infinite intermediary values
100+ if ( ! ( isFinite ( sdir . x ) && isFinite ( sdir . y ) && isFinite ( sdir . z ) &&
101+ isFinite ( tdir . x ) && isFinite ( tdir . y ) && isFinite ( tdir . z ) ) ) {
102+
103+ return ;
104+
105+ }
106+
99107 tan1 [ a ] . add ( sdir ) ;
100108 tan1 [ b ] . add ( sdir ) ;
101109 tan1 [ c ] . add ( sdir ) ;
Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ var BufferGeometryUtils = {
108108 ( s1 * z2 - s2 * z1 ) * r
109109 ) ;
110110
111+ // silently ignore degenerate uvs/triangles that yield NaN/Infinite intermediary values
112+ if ( ! ( isFinite ( sdir . x ) && isFinite ( sdir . y ) && isFinite ( sdir . z ) &&
113+ isFinite ( tdir . x ) && isFinite ( tdir . y ) && isFinite ( tdir . z ) ) ) {
114+
115+ return ;
116+
117+ }
118+
111119 tan1 [ a ] . add ( sdir ) ;
112120 tan1 [ b ] . add ( sdir ) ;
113121 tan1 [ c ] . add ( sdir ) ;
Original file line number Diff line number Diff line change 1717
1818 import { GLTFLoader } from './jsm/loaders/GLTFLoader.js' ;
1919
20- // import { BufferGeometryUtils } from './jsm/utils/BufferGeometryUtils.js';
20+ import { BufferGeometryUtils } from './jsm/utils/BufferGeometryUtils.js' ;
2121
2222 var scene , renderer ;
2323 var camera , light ;
2424 var vnh ;
25- // var vth;
25+ var vth ;
2626
2727 init ( ) ;
2828 animate ( ) ;
6262
6363 var mesh = gltf . scene . children [ 0 ] ;
6464
65- // BufferGeometryUtils.computeTangents( mesh.geometry ); // generates bad data due to degenerate UVs
65+ BufferGeometryUtils . computeTangents ( mesh . geometry ) ; // generates bad data due to degenerate UVs
6666
6767 var group = new THREE . Group ( ) ;
6868 group . scale . multiplyScalar ( 50 ) ;
7676 vnh = new THREE . VertexNormalsHelper ( mesh , 5 ) ;
7777 scene . add ( vnh ) ;
7878
79- // vth = new THREE.VertexTangentsHelper( mesh, 5 );
80- // scene.add( vth );
79+ vth = new THREE . VertexTangentsHelper ( mesh , 5 ) ;
80+ scene . add ( vth ) ;
8181
8282 scene . add ( new THREE . BoxHelper ( mesh ) ) ;
8383
135135 light . position . z = Math . cos ( time * 1.3 ) * 300 ;
136136
137137 if ( vnh ) vnh . update ( ) ;
138- // if ( vth ) vth.update();
138+ if ( vth ) vth . update ( ) ;
139139
140140 renderer . render ( scene , camera ) ;
141141
You can’t perform that action at this time.
0 commit comments