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 => {
|
2021-04-20 01:57:10 +08:00
|
|
|
// @ts-ignore
|
2021-04-20 02:49:52 +08:00
|
|
|
watch(() => this[p], (value) => { light[p] = value })
|
2021-04-19 04:58:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
this.initLight(light)
|
|
|
|
},
|
|
|
|
__hmrId: 'SpotLight',
|
|
|
|
})
|