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

add shadow type (without watcher) #45

This commit is contained in:
Kevin Levron 2021-04-29 19:32:29 +02:00
parent 2e81ed9730
commit 7b66f37c09

View File

@ -1,5 +1,5 @@
/* eslint-disable no-use-before-define */ /* 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 { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'
import { defineComponent, InjectionKey, PropType } from 'vue' import { defineComponent, InjectionKey, PropType } from 'vue'
import { bindProp } from '../tools' import { bindProp } from '../tools'
@ -105,6 +105,7 @@ export default defineComponent({
pointer: { type: [Boolean, Object] as PropType<boolean | PointerPublicConfigInterface>, default: false }, pointer: { type: [Boolean, Object] as PropType<boolean | PointerPublicConfigInterface>, default: false },
resize: { type: [Boolean, String] as PropType<boolean | string>, default: false }, resize: { type: [Boolean, String] as PropType<boolean | string>, default: false },
shadow: Boolean, shadow: Boolean,
shadowType: { type: Number, default: PCFShadowMap },
toneMapping: { type: Number, default: NoToneMapping }, toneMapping: { type: Number, default: NoToneMapping },
width: String, width: String,
height: String, height: String,
@ -192,8 +193,10 @@ export default defineComponent({
this.resizeCallbacks.forEach(e => e({ type: 'resize', renderer: this, size })) this.resizeCallbacks.forEach(e => e({ type: 'resize', renderer: this, size }))
} }
// TODO : improve shadow params if (this.shadow) {
this.renderer.shadowMap.enabled = this.shadow this.renderer.shadowMap.enabled = true
this.renderer.shadowMap.type = this.shadowType
}
this.renderFn = this.three.composer ? this.three.renderC : this.three.render this.renderFn = this.three.composer ? this.three.renderC : this.three.render