Skip to content

Commit

Permalink
chore: fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Apr 3, 2023
1 parent 46cdd00 commit d661bda
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/TresScene.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, defineComponent, h, onMounted, onUnmounted, onUpdated, provide, ref, watch, watchEffect } from 'vue'
import { App, defineComponent, h, onMounted, onUnmounted, ref, watchEffect } from 'vue'
import * as THREE from 'three'
import { PerspectiveCamera, ShadowMapType, TextureEncoding, ToneMapping } from 'three'
import { createTres } from '/@/core/renderer'
Expand Down Expand Up @@ -54,7 +54,7 @@ export const TresScene = defineComponent<TresSceneProps>({
const container = ref<HTMLElement>()
const canvas = ref<HTMLElement>()
const scene = new THREE.Scene()
const { state, setState } = useTres()
const { setState } = useTres()

setState('scene', scene)
setState('canvas', canvas)
Expand Down
1 change: 0 additions & 1 deletion src/composables/useRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { watch, ref, shallowRef, computed, toRefs } from 'vue'
import {
MaybeComputedRef,
MaybeElementRef,
resolveUnref,
unrefElement,
useDevicePixelRatio,
Expand Down
11 changes: 8 additions & 3 deletions src/composables/useTres/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export interface TresState {
[key: string]: any
}

export type UseTresReturn = {
state: TresState
getState: (key: string) => void
setState: (key: string, value: any) => void
aspectRatio: ComputedRef<number>
}

const TRES_CONTEXT_KEY = Symbol()
const { logError } = useLogger()
/**
Expand Down Expand Up @@ -146,9 +153,7 @@ export function useTresProvider() {
export const useTres = () => {
const context = inject(TRES_CONTEXT_KEY)

if (!context) return

if (!context) logError('UseTres together with useTresProvider')

return context
return context as UseTresReturn
}
4 changes: 2 additions & 2 deletions src/utils/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vector3, Color } from 'three'
import { Vector3, Color, ColorRepresentation } from 'three'

export type SizeFlexibleParams =
| number[]
Expand Down Expand Up @@ -37,5 +37,5 @@ export function normalizeColor(value: Color | Array<number> | string | number) {
if (Array.isArray(value)) {
return new Color(...value)
}
return new Color(value)
return new Color(value as ColorRepresentation)
}

0 comments on commit d661bda

Please sign in to comment.