diff --git a/media/viewer.js b/media/viewer.js index afcfc4e..76379ae 100644 --- a/media/viewer.js +++ b/media/viewer.js @@ -176,6 +176,20 @@ function onProgress(xhr) { } function loadModel() { + if(modelLoader instanceof THREE.OBJLoader) { + new THREE.MTLLoader().load(userSettings.fileToLoad.replace('.obj', '.mtl'), materials => { + modelLoader.setMaterials(materials); + + loadModelFile(); + }, _ => { // Assume no .mtl file + loadModelFile(); + }); + }else{ + loadModelFile(); + } +} + +function loadModelFile() { modelLoader.load(userSettings.fileToLoad, file => { const object = file.scene ? file.scene : file.isGeometry || file.isBufferGeometry ? new THREE.Mesh(file) : file; object.mixer = new THREE.AnimationMixer(object); diff --git a/src/MeshViewerProvider.ts b/src/MeshViewerProvider.ts index f1b58f9..702b936 100644 --- a/src/MeshViewerProvider.ts +++ b/src/MeshViewerProvider.ts @@ -121,6 +121,7 @@ export class MeshViewerProvider implements vscode.CustomReadonlyEditorProvider