From bb6358716d8d0cd167c99c47f2690118cf286654 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Mon, 24 Jan 2022 20:55:36 +0100 Subject: [PATCH] WebGLRenderer constructor params #117 --- src/core/Renderer.ts | 4 +++- src/core/useThree.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/Renderer.ts b/src/core/Renderer.ts index 0597bbc..b0dfd87 100644 --- a/src/core/Renderer.ts +++ b/src/core/Renderer.ts @@ -1,5 +1,5 @@ /* eslint-disable no-use-before-define */ -import { Camera, Scene, WebGLRenderer } from 'three' +import { Camera, Scene, WebGLRenderer, WebGLRendererParameters } from 'three' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer' import { ComponentPublicInstance, defineComponent, InjectionKey, PropType } from 'vue' import { bindObjectProp } from '../tools' @@ -98,6 +98,7 @@ export const RendererInjectionKey: InjectionKey = Symbo export default defineComponent({ name: 'Renderer', props: { + params: { type: Object as PropType, default: () => ({}) }, antialias: Boolean, alpha: Boolean, autoClear: { type: Boolean, default: true }, @@ -131,6 +132,7 @@ export default defineComponent({ const config: ThreeConfigInterface = { canvas, + params: props.params, antialias: props.antialias, alpha: props.alpha, autoClear: props.autoClear, diff --git a/src/core/useThree.ts b/src/core/useThree.ts index b8fa5b4..61761f6 100644 --- a/src/core/useThree.ts +++ b/src/core/useThree.ts @@ -1,4 +1,4 @@ -import { Camera, Object3D, OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderer } from 'three' +import { Camera, Object3D, OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderer, WebGLRendererParameters } from 'three' import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js' import usePointer, { PointerConfigInterface, PointerPublicConfigInterface, PointerInterface } from './usePointer' @@ -12,6 +12,7 @@ export interface SizeInterface { } export interface ThreeConfigInterface { + params?: WebGLRendererParameters canvas?: HTMLCanvasElement antialias: boolean alpha: boolean @@ -97,7 +98,7 @@ export default function useThree(params: ThreeConfigInterface): ThreeInterface { * create WebGLRenderer */ function createRenderer(): WebGLRenderer { - const renderer = new WebGLRenderer({ canvas: config.canvas, antialias: config.antialias, alpha: config.alpha }) + const renderer = new WebGLRenderer({ canvas: config.canvas, antialias: config.antialias, alpha: config.alpha, ...config.params }) renderer.autoClear = config.autoClear return renderer }