From f31ae49d282fe950f6d58e6dc05488faf3e5b073 Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Wed, 15 Feb 2023 10:28:18 +0100 Subject: [PATCH 01/11] fix(core): solved annoying warning messages about inject [Vue warn]: injection "local-scene" not found. #107 --- packages/tres/src/core/useCamera/index.ts | 2 +- packages/tres/src/core/useInstanceCreator/index.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/tres/src/core/useCamera/index.ts b/packages/tres/src/core/useCamera/index.ts index 0ee345edd..3bda4fb88 100644 --- a/packages/tres/src/core/useCamera/index.ts +++ b/packages/tres/src/core/useCamera/index.ts @@ -44,7 +44,7 @@ const VERTICAL_FIELD_OF_VIEW = 45 let camera: Camera export function useCamera(): UseCameraReturn { - const aspectRatio = inject>('aspect-ratio') + const aspectRatio = inject('aspect-ratio', () => 1) const { setState } = useTres() diff --git a/packages/tres/src/core/useInstanceCreator/index.ts b/packages/tres/src/core/useInstanceCreator/index.ts index 50863e9cc..a8ab35c37 100644 --- a/packages/tres/src/core/useInstanceCreator/index.ts +++ b/packages/tres/src/core/useInstanceCreator/index.ts @@ -9,6 +9,7 @@ import { normalizeVectorFlexibleParam } from '/@/utils/normalize' import { useCamera, useCatalogue, useRenderLoop, useScene } from '/@/core/' import { useLogger } from '/@/composables' import { TresAttributes, TresCatalogue, TresInstance, TresVNode, TresVNodeType, TresEvent } from '/@/types' +import { useRaycaster } from '../useRaycaster' const VECTOR3_PROPS = ['rotation', 'scale', 'position'] @@ -161,9 +162,9 @@ export function useInstanceCreator(prefix: string) { setup(_props, { slots, attrs, ...ctx }) { const { scene: fallback } = useScene() const { onLoop } = useRenderLoop() - const scene = inject>('local-scene') || fallback - /* const { raycaster } = useRaycaster() */ - const raycaster = inject>('raycaster') /* + const scene = inject('local-scene', fallback) + const { raycaster: raycasterFallback } = useRaycaster() + const raycaster = inject('raycaster', raycasterFallback) /* const currentInstance = inject('currentInstance') */ const { pushCamera } = useCamera() From 6e70676480a7cf1c53049a436154b5c847bab5fe Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Wed, 15 Feb 2023 10:33:55 +0100 Subject: [PATCH 02/11] fix(core): remove glsl plugin from core vite config --- packages/tres/vite.config.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/tres/vite.config.ts b/packages/tres/vite.config.ts index 06043c024..043155c44 100644 --- a/packages/tres/vite.config.ts +++ b/packages/tres/vite.config.ts @@ -7,7 +7,6 @@ import banner from 'vite-plugin-banner' import dts from 'vite-plugin-dts' import analyze from 'rollup-plugin-analyzer' /* import { visualizer } from 'rollup-plugin-visualizer' */ -import glsl from 'vite-plugin-glsl' import { resolve } from 'pathe' import { lightGreen, yellow, gray, bold } from 'kolorist' @@ -32,7 +31,6 @@ export default defineConfig({ dts({ insertTypesEntry: true, }), - glsl(), banner({ content: `/**\n * name: ${pkg.name}\n * version: v${ pkg.version From e08c19ab8e53bb47b9afa32f6a01dc37d281bbfb Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Wed, 15 Feb 2023 14:36:28 +0100 Subject: [PATCH 03/11] feat(cientos): access core state via provide inject api --- packages/cientos/src/core/OrbitControls.vue | 14 ++++++-------- packages/cientos/src/core/useCientos.ts | 5 +++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/cientos/src/core/OrbitControls.vue b/packages/cientos/src/core/OrbitControls.vue index 4a47a0feb..5f1573c46 100644 --- a/packages/cientos/src/core/OrbitControls.vue +++ b/packages/cientos/src/core/OrbitControls.vue @@ -1,8 +1,7 @@