mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 12:22:03 +08:00
39 lines
825 B
JavaScript
39 lines
825 B
JavaScript
|
import { Group } from 'three';
|
||
|
import { inject } from 'vue';
|
||
|
import useBindProp from '../use/useBindProp.js';
|
||
|
|
||
|
export default {
|
||
|
inject: ['three', 'scene'],
|
||
|
props: {
|
||
|
position: Object,
|
||
|
rotation: Object,
|
||
|
scale: Object,
|
||
|
},
|
||
|
setup(props) {
|
||
|
const parent = inject('group', inject('scene'));
|
||
|
const group = new Group();
|
||
|
useBindProp(props, 'position', group.position);
|
||
|
useBindProp(props, 'rotation', group.rotation);
|
||
|
useBindProp(props, 'scale', group.scale);
|
||
|
return { parent, group };
|
||
|
},
|
||
|
provide() {
|
||
|
return {
|
||
|
group: this.group,
|
||
|
};
|
||
|
},
|
||
|
created() {
|
||
|
this.parent.add(this.group);
|
||
|
},
|
||
|
unmounted() {
|
||
|
this.parent.remove(this.group);
|
||
|
},
|
||
|
render() {
|
||
|
if (this.$slots.default) {
|
||
|
return this.$slots.default();
|
||
|
}
|
||
|
return [];
|
||
|
},
|
||
|
__hmrId: 'Group',
|
||
|
};
|