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

defineComponent for core components (#10)

This commit is contained in:
Kevin Levron 2021-04-03 22:19:57 +02:00
parent f6ecd087fb
commit 885268fede
8 changed files with 24 additions and 21 deletions

View File

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

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { Group } from 'three'; import { Group } from 'three';
import Object3D from './Object3D.js'; import Object3D from './Object3D.js';
export default { export default defineComponent({
name: 'Group', name: 'Group',
extends: Object3D, extends: Object3D,
created() { created() {
@ -9,4 +10,4 @@ export default {
this.initObject3D(this.group); this.initObject3D(this.group);
}, },
__hmrId: 'Group', __hmrId: 'Group',
}; });

View File

@ -1,7 +1,7 @@
import { watch } from 'vue'; import { defineComponent, watch } from 'vue';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
export default { export default defineComponent({
name: 'Object3D', name: 'Object3D',
inject: ['three', 'scene', 'rendererComponent'], inject: ['three', 'scene', 'rendererComponent'],
emits: ['created', 'ready'], emits: ['created', 'ready'],
@ -65,4 +65,4 @@ export default {
return this.$slots.default ? this.$slots.default() : []; return this.$slots.default ? this.$slots.default() : [];
}, },
__hmrId: 'Object3D', __hmrId: 'Object3D',
}; });

View File

@ -1,9 +1,9 @@
import { defineComponent, watch } from 'vue';
import { OrthographicCamera } from 'three'; import { OrthographicCamera } from 'three';
import { watch } from 'vue';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
import Camera from './Camera.js'; import Camera from './Camera.js';
export default { export default defineComponent({
extends: Camera, extends: Camera,
name: 'OrthographicCamera', name: 'OrthographicCamera',
inject: ['three'], inject: ['three'],
@ -31,4 +31,4 @@ export default {
this.three.camera = this.camera; this.three.camera = this.camera;
}, },
__hmrId: 'OrthographicCamera', __hmrId: 'OrthographicCamera',
}; });

View File

@ -1,9 +1,9 @@
import { defineComponent, watch } from 'vue';
import { PerspectiveCamera } from 'three'; import { PerspectiveCamera } from 'three';
import { watch } from 'vue';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
import Camera from './Camera.js'; import Camera from './Camera.js';
export default { export default defineComponent({
extends: Camera, extends: Camera,
name: 'PerspectiveCamera', name: 'PerspectiveCamera',
inject: ['three'], inject: ['three'],
@ -32,4 +32,4 @@ export default {
this.three.camera = this.camera; this.three.camera = this.camera;
}, },
__hmrId: 'PerspectiveCamera', __hmrId: 'PerspectiveCamera',
}; });

View File

@ -1,6 +1,7 @@
import { defineComponent } from 'vue';
import usePointer from './usePointer'; import usePointer from './usePointer';
export default { export default defineComponent({
name: 'Raycaster', name: 'Raycaster',
inject: ['three', 'rendererComponent'], inject: ['three', 'rendererComponent'],
props: { props: {
@ -45,4 +46,4 @@ export default {
return []; return [];
}, },
__hmrId: 'Raycaster', __hmrId: 'Raycaster',
}; });

View File

@ -1,7 +1,7 @@
import { h } from 'vue'; import { defineComponent, h } from 'vue';
import useThree from './useThree'; import useThree from './useThree';
export default { export default defineComponent({
name: 'Renderer', name: 'Renderer',
props: { props: {
antialias: Boolean, antialias: Boolean,
@ -77,4 +77,4 @@ export default {
return h('canvas', {}, this.$slots.default()); return h('canvas', {}, this.$slots.default());
}, },
__hmrId: 'Renderer', __hmrId: 'Renderer',
}; });

View File

@ -1,7 +1,7 @@
import { defineComponent, watch } from 'vue';
import { Scene, Color } from 'three'; import { Scene, Color } from 'three';
import { watch } from 'vue';
export default { export default defineComponent({
name: 'Scene', name: 'Scene',
inject: ['three'], inject: ['three'],
props: { props: {
@ -32,4 +32,4 @@ export default {
return this.$slots.default ? this.$slots.default() : []; return this.$slots.default ? this.$slots.default() : [];
}, },
__hmrId: 'Scene', __hmrId: 'Scene',
}; });