1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

pixel ratio #88

This commit is contained in:
Kevin Levron 2022-02-16 17:10:36 +01:00
parent 1c5a1942f8
commit 60eee1a544

View File

@ -1,7 +1,7 @@
/* eslint-disable no-use-before-define */ /* eslint-disable no-use-before-define */
import { Camera, Scene, WebGLRenderer, WebGLRendererParameters } from 'three' import { Camera, Scene, WebGLRenderer, WebGLRendererParameters } from 'three'
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'
import { ComponentPublicInstance, defineComponent, InjectionKey, PropType } from 'vue' import { ComponentPublicInstance, defineComponent, InjectionKey, PropType, watchEffect } from 'vue'
import { bindObjectProp } from '../tools' import { bindObjectProp } from '../tools'
import { PointerInterface, PointerPublicConfigInterface } from './usePointer' import { PointerInterface, PointerPublicConfigInterface } from './usePointer'
import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree' import useThree, { SizeInterface, ThreeConfigInterface, ThreeInterface } from './useThree'
@ -108,6 +108,7 @@ export default defineComponent({
shadow: Boolean, shadow: Boolean,
width: String, width: String,
height: String, height: String,
pixelRatio: Number,
xr: Boolean, xr: Boolean,
props: { type: Object, default: () => ({}) }, props: { type: Object, default: () => ({}) },
onReady: Function as PropType<(r: RendererInterface) => void>, onReady: Function as PropType<(r: RendererInterface) => void>,
@ -147,6 +148,10 @@ export default defineComponent({
const three = useThree(config) const three = useThree(config)
bindObjectProp(props, 'props', three.renderer) bindObjectProp(props, 'props', three.renderer)
watchEffect(() => {
if (props.pixelRatio) three.renderer.setPixelRatio(props.pixelRatio)
})
const renderFn: {(): void} = () => {} const renderFn: {(): void} = () => {}
return { return {