1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 12:22:03 +08:00
trois/src/core/Group.js

39 lines
825 B
JavaScript
Raw Normal View History

2021-02-22 04:39:35 +08:00
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',
};