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

27 lines
746 B
TypeScript

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 => {
// @ts-ignore
watch(() => this[p], (value) => { light[p] = value })
})
this.initLight(light)
},
__hmrId: 'SpotLight',
})