1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

DRACO loader support

This commit is contained in:
Simon 2023-02-21 20:59:29 +01:00
parent 8c5dd149b9
commit 6aba3fa81d

View File

@ -1,11 +1,20 @@
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js' import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js'
import Model from './Model' import Model from './Model'
export default defineComponent({ export default defineComponent({
extends: Model, extends: Model,
props: {
dracoPath: { type: String, required: true },
},
created() { created() {
const loader = new GLTFLoader() const loader = new GLTFLoader()
if (this.dracoPath) {
const dracoLoader = new DRACOLoader()
dracoLoader.setDecoderPath(this.dracoPath)
loader.setDRACOLoader(dracoLoader)
}
this.$emit('before-load', loader) this.$emit('before-load', loader)
loader.load(this.src, (gltf) => { loader.load(this.src, (gltf) => {
this.onLoad(gltf) this.onLoad(gltf)