mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
fix #9
This commit is contained in:
parent
a620b7cd32
commit
a6c77ceafb
@ -4,7 +4,13 @@ import { setFromProp } from '../tools.js';
|
|||||||
import useBindProp from '../use/useBindProp.js';
|
import useBindProp from '../use/useBindProp.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['scene'],
|
inject: {
|
||||||
|
scene: 'scene',
|
||||||
|
parent: {
|
||||||
|
from: 'group',
|
||||||
|
default: () => inject('scene'),
|
||||||
|
},
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -23,9 +29,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// can't use setup because it will not be used in sub components
|
// can't use setup because it will not be used in sub components
|
||||||
// setup() {},
|
// setup() {},
|
||||||
created() {
|
|
||||||
this.parent = inject('group', this.scene);
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
useBindProp(this, 'position', this.light.position);
|
useBindProp(this, 'position', this.light.position);
|
||||||
|
|
||||||
|
@ -11,8 +11,9 @@ export default {
|
|||||||
castShadow: Boolean,
|
castShadow: Boolean,
|
||||||
receiveShadow: Boolean,
|
receiveShadow: Boolean,
|
||||||
},
|
},
|
||||||
created() {
|
setup() {
|
||||||
this.parent = inject('group', this.scene);
|
const parent = inject('group', inject('scene'));
|
||||||
|
return { parent };
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
|
@ -3,7 +3,15 @@ import { inject, watch } from 'vue';
|
|||||||
import useBindProp from '../use/useBindProp.js';
|
import useBindProp from '../use/useBindProp.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['three', 'scene', 'rendererComponent'],
|
inject: {
|
||||||
|
three: 'three',
|
||||||
|
scene: 'scene',
|
||||||
|
rendererComponent: 'rendererComponent',
|
||||||
|
parent: {
|
||||||
|
from: 'group',
|
||||||
|
default: () => inject('scene'),
|
||||||
|
},
|
||||||
|
},
|
||||||
emits: ['ready'],
|
emits: ['ready'],
|
||||||
props: {
|
props: {
|
||||||
materialId: String,
|
materialId: String,
|
||||||
@ -17,9 +25,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// can't use setup because it will not be used in sub components
|
// can't use setup because it will not be used in sub components
|
||||||
// setup() {},
|
// setup() {},
|
||||||
created() {
|
|
||||||
this.parent = inject('group', this.scene);
|
|
||||||
},
|
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
mesh: this,
|
mesh: this,
|
||||||
@ -55,6 +60,8 @@ export default {
|
|||||||
this.three.addIntersectObject(this.mesh);
|
this.three.addIntersectObject(this.mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(this.parent);
|
||||||
|
|
||||||
this.bindProps();
|
this.bindProps();
|
||||||
this.parent.add(this.mesh);
|
this.parent.add(this.mesh);
|
||||||
this.$emit('ready');
|
this.$emit('ready');
|
||||||
|
@ -10,8 +10,9 @@ export default {
|
|||||||
position: Object,
|
position: Object,
|
||||||
scale: Object,
|
scale: Object,
|
||||||
},
|
},
|
||||||
created() {
|
setup() {
|
||||||
this.parent = inject('group', this.scene);
|
const parent = inject('group', inject('scene'));
|
||||||
|
return { parent };
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.texture = new TextureLoader().load(this.src, this.onLoaded);
|
this.texture = new TextureLoader().load(this.src, this.onLoaded);
|
||||||
|
Loading…
Reference in New Issue
Block a user