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

add RectAreaLight

This commit is contained in:
Kevin Levron 2021-03-07 00:48:06 +01:00
parent c477a8cfb3
commit 42386a572d
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { RectAreaLight } from 'three';
import { RectAreaLightUniformsLib } from 'three/examples/jsm/lights/RectAreaLightUniformsLib.js';
import { RectAreaLightHelper } from 'three/examples/jsm/helpers/RectAreaLightHelper.js';
import { watch } from 'vue';
import Light from './Light.js';
export default {
extends: Light,
props: {
width: { type: Number, default: 10 },
height: { type: Number, default: 10 },
},
created() {
RectAreaLightUniformsLib.init();
this.light = new RectAreaLight(this.color, this.intensity, this.width, this.height);
['width', 'height'].forEach(p => {
watch(() => this[p], () => {
this.light[p] = this[p];
});
});
this.$parent.add(new RectAreaLightHelper(this.light));
this.initLight();
},
__hmrId: 'RectAreaLight',
};

View File

@ -1,4 +1,5 @@
export { default as AmbientLight } from './AmbientLight.js';
export { default as DirectionalLight } from './DirectionalLight.js';
export { default as PointLight } from './PointLight.js';
export { default as RectAreaLight } from './RectAreaLight.js';
export { default as SpotLight } from './SpotLight.js';

View File

@ -30,6 +30,7 @@ export const TroisJSVuePlugin = {
'AmbientLight',
'DirectionalLight',
'PointLight',
'RectAreaLight',
'SpotLight',
'BasicMaterial',