From 7b66f37c09bebba073dbc882788cf3fd87a50a00 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Thu, 29 Apr 2021 19:32:29 +0200 Subject: [PATCH] add shadow type (without watcher) #45 --- src/core/Renderer.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/Renderer.ts b/src/core/Renderer.ts index f55394a..b67007b 100644 --- a/src/core/Renderer.ts +++ b/src/core/Renderer.ts @@ -1,5 +1,5 @@ /* eslint-disable no-use-before-define */ -import { Camera, NoToneMapping, Scene, WebGLRenderer } from 'three' +import { Camera, NoToneMapping, PCFShadowMap, Scene, WebGLRenderer } from 'three' import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer' import { defineComponent, InjectionKey, PropType } from 'vue' import { bindProp } from '../tools' @@ -105,6 +105,7 @@ export default defineComponent({ pointer: { type: [Boolean, Object] as PropType, default: false }, resize: { type: [Boolean, String] as PropType, default: false }, shadow: Boolean, + shadowType: { type: Number, default: PCFShadowMap }, toneMapping: { type: Number, default: NoToneMapping }, width: String, height: String, @@ -192,8 +193,10 @@ export default defineComponent({ this.resizeCallbacks.forEach(e => e({ type: 'resize', renderer: this, size })) } - // TODO : improve shadow params - this.renderer.shadowMap.enabled = this.shadow + if (this.shadow) { + this.renderer.shadowMap.enabled = true + this.renderer.shadowMap.type = this.shadowType + } this.renderFn = this.three.composer ? this.three.renderC : this.three.render