Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/ModelChoose/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</div>
<el-upload
action=""
accept=".glb,.obj,.gltf,.fbx,.stl"
:accept="fileAccept"
class="file-box"
:show-file-list="false"
:auto-upload="false"
Expand All @@ -155,7 +155,7 @@
<el-icon :size="44">
<Plus />
</el-icon>
<div><span>请选择(目前仅支持.glb, .obj, .gltf, .fbx, .stl格式)</span></div>
<div><span>请选择(目前仅支持{{fileAccept}}格式)</span></div>
</div>
</div>
</el-upload>
Expand Down Expand Up @@ -195,6 +195,10 @@ const modelEditMap = {
const store = useMeshEditStore();
const { $bus } = getCurrentInstance().proxy;

// 支持文件类型
const fileAccept = computed(() => {
return Object.keys(store.modelApi.fileLoaderMap || {}).map(key => `.${key}`).join(",");
});
//普通模型
const ordinaryModelList = computed(() => {
return modelList.filter(v => !v.animation);
Expand Down
9 changes: 8 additions & 1 deletion src/utils/renderModel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as THREE from "three"; //导入整个 three.js核心库
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; //导入控制器模块,轨道控制器
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"; //导入GLTF模块,模型解析器,根据文件格式来定
import { TIFFLoader } from "three/examples/jsm/loaders/TIFFLoader"; //导入GLTF模块,模型解析器,根据文件格式来定
import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js";
import { RenderPass } from "three/addons/postprocessing/RenderPass.js";
import { OutlinePass } from "three/addons/postprocessing/OutlinePass.js";
Expand Down Expand Up @@ -47,7 +48,9 @@ class renderModel {
fbx: new FBXLoader(this.loadingManager),
gltf: new GLTFLoader(),
obj: new OBJLoader(this.loadingManager),
stl: new STLLoader()
stl: new STLLoader(),
tif: new TIFFLoader(this.loadingManager),
tiff: new TIFFLoader(this.loadingManager)
};
//模型动画列表
this.modelAnimation;
Expand Down Expand Up @@ -280,6 +283,10 @@ class renderModel {
this.model = mesh;
break;
default:
const tiffGeometry = new THREE.PlaneGeometry();
const tiffMaterial = new THREE.MeshStandardMaterial( { map: result } );
const tiffMesh = new THREE.Mesh(tiffGeometry, tiffMaterial);
this.model = tiffMesh;
break;
}
this.model.decomposeName = decomposeName;
Expand Down