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

41 lines
816 B
JavaScript
Raw Normal View History

2021-02-22 04:39:35 +08:00
import { Group } from 'three';
import useBindProp from '../use/useBindProp.js';
export default {
2021-03-04 06:21:53 +08:00
inject: {
three: 'three',
scene: 'scene',
group: { default: null },
},
2021-02-22 04:39:35 +08:00
props: {
position: Object,
rotation: Object,
scale: Object,
},
provide() {
return {
group: this.group,
};
},
created() {
2021-03-04 06:21:53 +08:00
this.parent = this.group ? this.group : this.scene;
this.group = new Group();
useBindProp(this, 'position', this.group.position);
useBindProp(this, 'rotation', this.group.rotation);
useBindProp(this, 'scale', this.group.scale);
2021-02-22 04:39:35 +08:00
this.parent.add(this.group);
},
unmounted() {
this.parent.remove(this.group);
},
render() {
if (this.$slots.default) {
return this.$slots.default();
}
return [];
},
__hmrId: 'Group',
};