diff --git a/package-lock.json b/package-lock.json index 86ca9025f..38eae1e44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,7 @@ "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "8.8.0", - "eslint-config-turbo": "*", + "eslint-config-turbo": "latest", "eslint-plugin-formatjs": "4.10.3", "eslint-plugin-import": "2.28.1", "eslint-plugin-jest": "^27.2.3", @@ -120713,7 +120713,7 @@ "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "8.8.0", - "eslint-config-turbo": "*", + "eslint-config-turbo": "latest", "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-formatjs": "4.10.3", "eslint-plugin-import": "2.28.1", diff --git a/packages/scene-composer/src/components/three-fiber/ModelRefComponent/__tests__/GLTFLoader.spec.ts b/packages/scene-composer/src/components/three-fiber/ModelRefComponent/__tests__/GLTFLoader.spec.ts index dae88d527..e780b5f27 100644 --- a/packages/scene-composer/src/components/three-fiber/ModelRefComponent/__tests__/GLTFLoader.spec.ts +++ b/packages/scene-composer/src/components/three-fiber/ModelRefComponent/__tests__/GLTFLoader.spec.ts @@ -94,8 +94,7 @@ describe('GLTFLoader', () => { it('should execute without draco decoder enabled', async () => { const getGlobalSettingsMock = getGlobalSettings as jest.Mock; const dracoDecoder: DracoDecoderConfig = { - enable: true, - path: 'draco/path', + enable: false, }; const basisuDecoder: BasisuDecoderConfig = { enable: false, @@ -109,8 +108,7 @@ describe('GLTFLoader', () => { extensionsCb(mockLoader); expect(extendLoader).toBeCalledTimes(1); - expect(setDecoderPathSpy).toBeCalledWith('draco/path'); - expect(mockLoader.setDRACOLoader).toBeCalledTimes(1); + expect(mockLoader.setDRACOLoader).toBeCalledTimes(0); }); }); diff --git a/packages/scene-composer/src/three/loaderUtilsHelpers.spec.ts b/packages/scene-composer/src/three/loaderUtilsHelpers.spec.ts index 9b1e8f533..f8de0cde9 100644 --- a/packages/scene-composer/src/three/loaderUtilsHelpers.spec.ts +++ b/packages/scene-composer/src/three/loaderUtilsHelpers.spec.ts @@ -18,6 +18,7 @@ describe('dracoSupport', () => { getGlobalSettingsMock.mockReturnValue({ dracoDecoder, + getSceneObjectFunction: jest.fn(), }); const loader = { @@ -41,6 +42,7 @@ describe('dracoSupport', () => { getGlobalSettingsMock.mockReturnValue({ dracoDecoder, + getSceneObjectFunction: jest.fn(), }); const loader = { @@ -73,6 +75,7 @@ describe('setupBasisu', () => { }; getGlobalSettingsMock.mockReturnValue({ basisuDecoder, + getSceneObjectFunction: jest.fn(), }); const loader = { @@ -94,6 +97,7 @@ describe('setupBasisu', () => { }; getGlobalSettingsMock.mockReturnValue({ basisuDecoder, + getSceneObjectFunction: jest.fn(), }); const loader = { setKTX2Loader: jest.fn(), diff --git a/packages/scene-composer/src/three/loaderUtilsHelpers.ts b/packages/scene-composer/src/three/loaderUtilsHelpers.ts index 50fd7f72e..0846e26ac 100644 --- a/packages/scene-composer/src/three/loaderUtilsHelpers.ts +++ b/packages/scene-composer/src/three/loaderUtilsHelpers.ts @@ -10,8 +10,9 @@ import { TwinMakerTextureLoader } from './TwinMakerTextureLoader'; import { GLTFLoader, GLTFLoader as TwinMakerGLTFLoader } from './GLTFLoader'; export const setupDracoSupport = (loader: GLTFLoader, dracoLoader: DRACOLoader = new DRACOLoader()): void => { - const { dracoDecoder } = getGlobalSettings(); - if (dracoDecoder.enable) { + const { dracoDecoder, getSceneObjectFunction } = getGlobalSettings(); + // getSceneObjectFunction is needed for the check to ensure that globalSettings are ready to be evaluated against + if (dracoDecoder.enable && getSceneObjectFunction) { const dracoDecoderPath = dracoDecoder.path ?? `${THREE_PATH}/examples/jsm/libs/draco/gltf/`; // TODO: with CSP issues, Chrome/Edge and some other unknown browsers may fail to load WASM, so we enforce to // only JS DRACO decoder for now. Please fix once we found a better solution @@ -26,10 +27,10 @@ export const setupBasisuSupport = ( renderer: WebGLRenderer, ktx2Loader: KTX2Loader = new KTX2Loader(), ): void => { - const { basisuDecoder } = getGlobalSettings(); - if (basisuDecoder.enable) { + const { basisuDecoder, getSceneObjectFunction } = getGlobalSettings(); + // getSceneObjectFunction is needed for the check to ensure that globalSettings are ready to be evaluated against + if (basisuDecoder.enable && getSceneObjectFunction) { const ktx2DecoderPath = basisuDecoder.path ?? `${THREE_PATH}/examples/jsm/libs/basis/`; - ktx2Loader.setTranscoderPath(ktx2DecoderPath).detectSupport(renderer); (loader as TwinMakerGLTFLoader).setKTX2Loader(ktx2Loader);