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

defineComponent for lights (#10)

This commit is contained in:
Kevin Levron 2021-04-04 20:41:11 +02:00
parent 8eff7c1728
commit 09290f9d88
7 changed files with 21 additions and 18 deletions

View File

@ -1,11 +1,12 @@
import { defineComponent } from 'vue';
import { AmbientLight } from 'three'; import { AmbientLight } from 'three';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
created() { created() {
this.light = new AmbientLight(this.color, this.intensity); this.light = new AmbientLight(this.color, this.intensity);
this.initLight(); this.initLight();
}, },
__hmrId: 'AmbientLight', __hmrId: 'AmbientLight',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { DirectionalLight } from 'three'; import { DirectionalLight } from 'three';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
props: { props: {
target: Object, target: Object,
@ -11,4 +12,4 @@ export default {
this.initLight(); this.initLight();
}, },
__hmrId: 'DirectionalLight', __hmrId: 'DirectionalLight',
}; });

View File

@ -1,8 +1,8 @@
import { defineComponent, watch } from 'vue';
import { HemisphereLight } from 'three'; import { HemisphereLight } from 'three';
import { watch } from 'vue';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
props: { props: {
groundColor: { type: String, default: '#444444' }, groundColor: { type: String, default: '#444444' },
@ -13,4 +13,4 @@ export default {
this.initLight(); this.initLight();
}, },
__hmrId: 'HemisphereLight', __hmrId: 'HemisphereLight',
}; });

View File

@ -1,8 +1,8 @@
import { watch } from 'vue'; import { defineComponent, watch } from 'vue';
import Object3D from '../core/Object3D.js'; import Object3D from '../core/Object3D.js';
import { bindProp, setFromProp } from '../tools'; import { bindProp, setFromProp } from '../tools';
export default { export default defineComponent({
extends: Object3D, extends: Object3D,
name: 'Light', name: 'Light',
props: { props: {
@ -44,4 +44,4 @@ export default {
}, },
}, },
__hmrId: 'Light', __hmrId: 'Light',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { PointLight } from 'three'; import { PointLight } from 'three';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
props: { props: {
distance: { distance: {
@ -18,4 +19,4 @@ export default {
this.initLight(); this.initLight();
}, },
__hmrId: 'PointLight', __hmrId: 'PointLight',
}; });

View File

@ -1,10 +1,10 @@
import { defineComponent, watch } from 'vue';
import { RectAreaLight } from 'three'; import { RectAreaLight } from 'three';
import { RectAreaLightUniformsLib } from 'three/examples/jsm/lights/RectAreaLightUniformsLib.js'; import { RectAreaLightUniformsLib } from 'three/examples/jsm/lights/RectAreaLightUniformsLib.js';
import { RectAreaLightHelper } from 'three/examples/jsm/helpers/RectAreaLightHelper.js'; import { RectAreaLightHelper } from 'three/examples/jsm/helpers/RectAreaLightHelper.js';
import { watch } from 'vue';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
props: { props: {
width: { type: Number, default: 10 }, width: { type: Number, default: 10 },
@ -32,4 +32,4 @@ export default {
if (this.lightHelper) this.removeFromParent(this.lightHelper); if (this.lightHelper) this.removeFromParent(this.lightHelper);
}, },
__hmrId: 'RectAreaLight', __hmrId: 'RectAreaLight',
}; });

View File

@ -1,8 +1,8 @@
import { defineComponent, watch } from 'vue';
import { SpotLight } from 'three'; import { SpotLight } from 'three';
import { watch } from 'vue';
import Light from './Light.js'; import Light from './Light.js';
export default { export default defineComponent({
extends: Light, extends: Light,
props: { props: {
angle: { type: Number, default: Math.PI / 3 }, angle: { type: Number, default: Math.PI / 3 },
@ -21,4 +21,4 @@ export default {
this.initLight(); this.initLight();
}, },
__hmrId: 'SpotLight', __hmrId: 'SpotLight',
}; });