mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
added loading models for 3D printing: 3MF and STL
This commit is contained in:
parent
a1b1239809
commit
1831c11536
@ -15,6 +15,8 @@ const external = [
|
|||||||
'three/examples/jsm/loaders/FontLoader.js',
|
'three/examples/jsm/loaders/FontLoader.js',
|
||||||
'three/examples/jsm/loaders/FBXLoader.js',
|
'three/examples/jsm/loaders/FBXLoader.js',
|
||||||
'three/examples/jsm/loaders/GLTFLoader.js',
|
'three/examples/jsm/loaders/GLTFLoader.js',
|
||||||
|
'three/examples/jsm/loaders/3MFLoader.js',
|
||||||
|
'three/examples/jsm/loaders/STLLoader.js',
|
||||||
'three/examples/jsm/postprocessing/BokehPass.js',
|
'three/examples/jsm/postprocessing/BokehPass.js',
|
||||||
'three/examples/jsm/postprocessing/EffectComposer.js',
|
'three/examples/jsm/postprocessing/EffectComposer.js',
|
||||||
'three/examples/jsm/postprocessing/FilmPass.js',
|
'three/examples/jsm/postprocessing/FilmPass.js',
|
||||||
|
15
src/models/3MF.ts
Normal file
15
src/models/3MF.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { defineComponent } from "vue"
|
||||||
|
import Model from "./Model"
|
||||||
|
import { ThreeMFLoader } from "three/examples/jsm/loaders/3MFLoader"
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
extends: Model,
|
||||||
|
created() {
|
||||||
|
const loader: ThreeMFLoader = new ThreeMFLoader()
|
||||||
|
this.$emit('before-load', loader)
|
||||||
|
loader.load(this.src, (threeMF) => {
|
||||||
|
this.onLoad(threeMF)
|
||||||
|
this.initObject3D(threeMF)
|
||||||
|
}, this.onProgress, this.onError)
|
||||||
|
},
|
||||||
|
})
|
20
src/models/STL.ts
Normal file
20
src/models/STL.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { defineComponent } from "vue"
|
||||||
|
import Model from "./Model"
|
||||||
|
import { STLLoader } from "three/examples/jsm/loaders/STLLoader"
|
||||||
|
import { Mesh, MeshLambertMaterial } from "three"
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
extends: Model,
|
||||||
|
created() {
|
||||||
|
const loader: STLLoader = new STLLoader()
|
||||||
|
this.$emit('before-load', loader)
|
||||||
|
loader.load(this.src, (geometry) => {
|
||||||
|
const object3D = new Mesh(geometry, new MeshLambertMaterial())
|
||||||
|
object3D.userData.component = this
|
||||||
|
object3D.geometry = geometry
|
||||||
|
|
||||||
|
this.onLoad(object3D)
|
||||||
|
this.initObject3D(object3D)
|
||||||
|
}, this.onProgress, this.onError)
|
||||||
|
},
|
||||||
|
})
|
@ -1,2 +1,4 @@
|
|||||||
export { default as GltfModel } from './GLTF'
|
export { default as GltfModel } from './GLTF'
|
||||||
export { default as FbxModel } from './FBX'
|
export { default as FbxModel } from './FBX'
|
||||||
|
export { default as ThreeMFModel } from './3MF'
|
||||||
|
export { default as StlModel } from './STL'
|
||||||
|
@ -64,6 +64,8 @@ export const TroisJSVuePlugin = {
|
|||||||
|
|
||||||
'FbxModel',
|
'FbxModel',
|
||||||
'GltfModel',
|
'GltfModel',
|
||||||
|
'ThreeMFModel',
|
||||||
|
'StlModel',
|
||||||
|
|
||||||
'BokehPass',
|
'BokehPass',
|
||||||
'EffectComposer',
|
'EffectComposer',
|
||||||
|
Loading…
Reference in New Issue
Block a user