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

update cameras to extend base component and render slot

This commit is contained in:
Sander Moolin 2021-03-22 09:30:25 -04:00
parent eb1ca16b8a
commit e66c347e69
3 changed files with 15 additions and 2 deletions

11
src/core/Camera.js Normal file
View File

@ -0,0 +1,11 @@
// import Object3D from '../core/Object3D.js';
export default {
// TODO: eventually extend Object3D, for now: error 'injection "scene" not found'
// because camera is a sibling of scene in Trois
// extends: Object3D,
inject: ['three'],
render() {
return this.$slots.default ? this.$slots.default() : [];
},
}

View File

@ -1,8 +1,10 @@
import { OrthographicCamera } from 'three'; import { OrthographicCamera } from 'three';
import { watch } from 'vue'; import { watch } from 'vue';
import { bindProp } from '../tools.js'; import { bindProp } from '../tools.js';
import Camera from './Camera.js';
export default { export default {
extends: Camera,
name: 'OrthographicCamera', name: 'OrthographicCamera',
inject: ['three'], inject: ['three'],
props: { props: {
@ -28,6 +30,5 @@ export default {
this.three.camera = this.camera; this.three.camera = this.camera;
}, },
render() { return []; },
__hmrId: 'OrthographicCamera', __hmrId: 'OrthographicCamera',
}; };

View File

@ -1,8 +1,10 @@
import { PerspectiveCamera } from 'three'; import { PerspectiveCamera } from 'three';
import { watch } from 'vue'; import { watch } from 'vue';
import { bindProp } from '../tools.js'; import { bindProp } from '../tools.js';
import Camera from './Camera.js';
export default { export default {
extends: Camera,
name: 'PerspectiveCamera', name: 'PerspectiveCamera',
inject: ['three'], inject: ['three'],
props: { props: {
@ -29,6 +31,5 @@ export default {
this.three.camera = this.camera; this.three.camera = this.camera;
}, },
render() { return []; },
__hmrId: 'PerspectiveCamera', __hmrId: 'PerspectiveCamera',
}; };