mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
28 lines
737 B
TypeScript
28 lines
737 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 => {
|
||
|
watch(() => this[p], () => {
|
||
|
light[p] = this[p]
|
||
|
})
|
||
|
})
|
||
|
|
||
|
this.initLight(light)
|
||
|
},
|
||
|
__hmrId: 'SpotLight',
|
||
|
})
|