1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00
This commit is contained in:
Kevin Levron 2021-02-26 19:33:46 +01:00
parent a620b7cd32
commit a6c77ceafb
4 changed files with 24 additions and 12 deletions

View File

@ -4,7 +4,13 @@ import { setFromProp } from '../tools.js';
import useBindProp from '../use/useBindProp.js';
export default {
inject: ['scene'],
inject: {
scene: 'scene',
parent: {
from: 'group',
default: () => inject('scene'),
},
},
props: {
color: {
type: String,
@ -23,9 +29,6 @@ export default {
},
// can't use setup because it will not be used in sub components
// setup() {},
created() {
this.parent = inject('group', this.scene);
},
mounted() {
useBindProp(this, 'position', this.light.position);

View File

@ -11,8 +11,9 @@ export default {
castShadow: Boolean,
receiveShadow: Boolean,
},
created() {
this.parent = inject('group', this.scene);
setup() {
const parent = inject('group', inject('scene'));
return { parent };
},
provide() {
return {

View File

@ -3,7 +3,15 @@ import { inject, watch } from 'vue';
import useBindProp from '../use/useBindProp.js';
export default {
inject: ['three', 'scene', 'rendererComponent'],
inject: {
three: 'three',
scene: 'scene',
rendererComponent: 'rendererComponent',
parent: {
from: 'group',
default: () => inject('scene'),
},
},
emits: ['ready'],
props: {
materialId: String,
@ -17,9 +25,6 @@ export default {
},
// can't use setup because it will not be used in sub components
// setup() {},
created() {
this.parent = inject('group', this.scene);
},
provide() {
return {
mesh: this,
@ -55,6 +60,8 @@ export default {
this.three.addIntersectObject(this.mesh);
}
console.log(this.parent);
this.bindProps();
this.parent.add(this.mesh);
this.$emit('ready');

View File

@ -10,8 +10,9 @@ export default {
position: Object,
scale: Object,
},
created() {
this.parent = inject('group', this.scene);
setup() {
const parent = inject('group', inject('scene'));
return { parent };
},
mounted() {
this.texture = new TextureLoader().load(this.src, this.onLoaded);