Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prop types on TresCanvas #326

Merged
merged 7 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion playground/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module 'vue' {
declare module '@vue/runtime-core' {
export interface GlobalComponents {
AnimatedModel: typeof import('./src/components/AnimatedModel.vue')['default']
Cameras: typeof import('./src/components/Cameras.vue')['default']
Expand Down
20 changes: 11 additions & 9 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import TresScene from './TresScene.vue'
import { CameraType, useTresProvider } from '../composables'
import { ColorSpace, ShadowMapType, ToneMapping } from 'three'
import { RendererPresetsType } from '../composables/useRenderer/const'
import { useTresProvider } from '../composables'

export type TresCanvasProps = {
import type { TresCamera } from '../types/'
import type { RendererPresetsType } from '../composables/useRenderer/const'
import type { ColorSpace, ShadowMapType, ToneMapping } from 'three'

export interface TresCanvasProps {
shadows?: boolean
shadowMapType?: ShadowMapType
physicallyCorrectLights?: boolean
Expand All @@ -19,17 +21,17 @@ export type TresCanvasProps = {
windowSize?: boolean
preset?: RendererPresetsType
disableRender?: boolean
camera?: CameraType
camera?: TresCamera
}

defineProps<TresCanvasProps>()
const props = defineProps<TresCanvasProps>()

const tres = useTresProvider()

defineExpose(tres)
</script>
<template>
<TresScene v-bind="$props">
<slot />
</TresScene>
<TresScene v-bind="props">
<slot />
</TresScene>
</template>
10 changes: 5 additions & 5 deletions src/components/TresScene.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script setup lang="ts">
import { App, onMounted, onUnmounted, ref, watch } from 'vue'
import { PerspectiveCamera, Scene } from 'three'
import { ColorSpace, ShadowMapType, ToneMapping } from 'three'

import { createTres } from '../core/renderer'
import { TresCamera } from '../types/'
import {
CameraType,
TRES_CONTEXT_KEY,
useLogger,
useCamera,
Expand All @@ -15,11 +13,13 @@ import {
usePointerEventHandler,
} from '../composables'
import { extend } from '../core/catalogue'
import { type RendererPresetsType } from '../composables/useRenderer/const'
import { OBJECT_3D_USER_DATA_KEYS } from '../keys'

import type { TresCamera } from '../types/'
import type { RendererPresetsType } from '../composables/useRenderer/const'
import type { ColorSpace, ShadowMapType, ToneMapping } from 'three'

export type TresSceneProps = {
export interface TresSceneProps {
shadows?: boolean
shadowMapType?: ShadowMapType
physicallyCorrectLights?: boolean
Expand Down