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

28 lines
737 B
TypeScript
Raw Normal View History

2021-04-19 04:58:28 +08:00
import { defineComponent, watch } from 'vue'
import { SpotLight } from 'three'
import Light from './Light'
export default defineComponent({
extends: Light,
props: {
angle: { type: Number, default: Math.PI / 3 },
decay: { type: Number, default: 1 },
distance: { type: Number, default: 0 },
penumbra: { type: Number, default: 0 },
target: Object,
},
created() {
const light = new SpotLight(this.color, this.intensity, this.distance, this.angle, this.penumbra, this.decay)
const watchProps = ['angle', 'decay', 'distance', 'penumbra']
watchProps.forEach(p => {
watch(() => this[p], () => {
light[p] = this[p]
})
})
this.initLight(light)
},
__hmrId: 'SpotLight',
})