Skip to content

Commit

Permalink
fix: tres-canvas window-size now support 'true' string
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Apr 6, 2023
1 parent 63a340f commit a63e33f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion playground/src/components/TheFirstScene.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ watchEffect(() => {
</script>

<template>
<TresCanvas ref="context" clear-color="#82DBC5" window-size="true">
<TresCanvas ref="context" clear-color="#82DBC5" window-size>
<TresPerspectiveCamera />
<TresMesh>
<TresTorusGeometry :args="[1, 0.5, 16, 32]" />
Expand Down
3 changes: 1 addition & 2 deletions playground/src/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* html,
html,
body {
margin: 0;
padding: 0;
Expand All @@ -9,4 +9,3 @@ body {
height: 100%;
width: 100%;
}
*/
7 changes: 5 additions & 2 deletions src/composables/useRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface UseRendererOptions extends WebGLRendererParameters {
* @default 0x000000
*/
clearColor?: MaybeComputedRef<TresColor>
windowSize?: MaybeComputedRef<boolean>
windowSize?: MaybeComputedRef<boolean | string>
preset?: RendererPresetsType
}

Expand Down Expand Up @@ -148,7 +148,10 @@ export function useRenderer(options: UseRendererOptions) {

const { state, setState } = useTres()

const { width, height } = resolveUnref(windowSize) ? useWindowSize() : useElementSize(state.container)
const { width, height } =
resolveUnref(windowSize) == true || resolveUnref(windowSize) === '' || resolveUnref(windowSize) === 'true'
? useWindowSize()
: useElementSize(state.container)
const { logError, logWarning } = useLogger()
const { pixelRatio } = useDevicePixelRatio()
const { pause, resume } = useRenderLoop()
Expand Down
2 changes: 1 addition & 1 deletion src/core/nodeOps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BufferAttribute } from 'three'
import { useCamera, useLogger } from '/@/composables'
import { useCamera } from '/@/composables'
import { RendererOptions } from 'vue'
import { catalogue } from './catalogue'
import { isFunction } from '@vueuse/core'
Expand Down

0 comments on commit a63e33f

Please sign in to comment.