From c9bd7ad6ef3ba86855c887886a9032fe0a324dd2 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Mon, 19 Dec 2022 12:56:21 +0100 Subject: [PATCH 1/2] fix(cientos): draco encoding and decoderPath --- packages/cientos/src/core/useGLTF/component.ts | 3 ++- packages/cientos/src/core/useGLTF/index.ts | 12 ++++++++---- packages/tres/src/components/TheExperience.vue | 11 ++++------- packages/tres/src/core/useLoader/index.ts | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/cientos/src/core/useGLTF/component.ts b/packages/cientos/src/core/useGLTF/component.ts index d794fd12e..6ae3e9bb7 100644 --- a/packages/cientos/src/core/useGLTF/component.ts +++ b/packages/cientos/src/core/useGLTF/component.ts @@ -7,12 +7,13 @@ export const GLTFModel = defineComponent({ props: { path: String, draco: Boolean, + decoderPath: String, }, async setup(props) { const scene = inject>('local-scene') - const { scene: model } = await useGLTF(props.path as string, { draco: props.draco }) + const { scene: model } = await useGLTF(props.path as string, { draco: props.draco, decoderPath: props.decoderPath }) if (scene?.value) { scene.value.add(model) } diff --git a/packages/cientos/src/core/useGLTF/index.ts b/packages/cientos/src/core/useGLTF/index.ts index 67913dc21..9cf99a01d 100644 --- a/packages/cientos/src/core/useGLTF/index.ts +++ b/packages/cientos/src/core/useGLTF/index.ts @@ -1,5 +1,6 @@ import { GLTFLoader, DRACOLoader } from 'three-stdlib' -import { useLoader } from '@tresjs/core' +import { useLoader } from '../../../../tres/src/core' +/* import { useLoader } from '@tresjs/core' */ import { Object3D } from 'three' export interface GLTFLoaderOptions { @@ -24,10 +25,13 @@ function setExtensions(options: GLTFLoaderOptions, extendLoader?: (loader: GLTFL if (extendLoader) { extendLoader(loader as GLTFLoader) } - if (!dracoLoader) { - dracoLoader = new DRACOLoader() + if (options.draco) { + if (!dracoLoader) { + dracoLoader = new DRACOLoader() + } + dracoLoader.setDecoderPath(options.decoderPath || 'https://www.gstatic.com/draco/versioned/decoders/1.4.3/') + loader.setDRACOLoader(dracoLoader) } - dracoLoader.setDecoderPath(options.decoderPath || 'https://www.gstatic.com/draco/versioned/decoders/1.4.3/') } } export async function useGLTF( diff --git a/packages/tres/src/components/TheExperience.vue b/packages/tres/src/components/TheExperience.vue index 5cc4d0e5e..12303e308 100644 --- a/packages/tres/src/components/TheExperience.vue +++ b/packages/tres/src/components/TheExperience.vue @@ -1,5 +1,6 @@