File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 63
63
}
64
64
65
65
//传递obj文件数据给渲染器
66
- function transferObj ( txtObj , txtMtl ) {
66
+ function transferObj ( txtObj , needFetchMtl ) {
67
67
const scene = txtObj ? ObjParser ( txtObj ) : '' ;
68
68
scene . materialLibraries = scene . materialLibraries || [ ] ;
69
69
$ ( "selFile" ) . disabled = false ;
70
70
const mtlPath = scene . materialLibraries [ 0 ] ;
71
- if ( mtlPath ) { //若存在引用mtl文件,则请求mtl文件
71
+ if ( needFetchMtl && mtlPath ) { //若存在引用mtl文件,则请求mtl文件
72
72
lastRequestPath = lastRequestPath . replace ( REG_OBJ , mtlPath ) ;
73
73
fetch ( lastRequestPath ) . then ( r => r . text ( ) ) . catch ( ex => alert ( ex ) ) . then ( txtMtl => {
74
74
let mtl = null ;
88
88
mtl . forEach ( m => {
89
89
const imagePath = m . map_Kd . file ;
90
90
if ( ! imagePath ) return ;
91
+ debugger
91
92
if ( mtl . __imageData [ imagePath ] ) return ; //若图片数据已经存在,说明之前请求过了,则忽略
92
93
93
94
fetch ( lastRequestPath . replace ( REG_MTL , imagePath ) ) . then ( r => r . blob ( ) ) . catch ( ex => alert ( ex ) ) . then ( blob => {
126
127
lastRequestPath = ABS_PATH + path ;
127
128
$ ( "selFile" ) . disabled = true ;
128
129
fetch ( lastRequestPath ) . then ( r => r . text ( ) ) . catch ( ex => alert ( ex ) ) . then ( txt => {
129
- transferObj ( txt ) ;
130
+ transferObj ( txt , true ) ;
130
131
} ) ;
131
132
}
132
133
function uploadFile ( evt ) {
139
140
let reader = new FileReader ( ) ;
140
141
reader . onload = function ( e ) {
141
142
const txt = e . target . result ;
142
- transferObj ( txt ) ;
143
+ transferObj ( txt , false ) ;
143
144
} ;
144
145
reader . readAsText ( f ) ;
145
146
}
You can’t perform that action at this time.
0 commit comments