1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/core/Scene.js
Kevin Levron 44e290f475 wip
2020-10-03 15:57:32 +02:00

41 lines
805 B
JavaScript

import { Scene, Color } from 'three';
import { watch } from 'vue';
export default {
inject: ['three'],
props: {
id: String,
background: [String, Number],
},
setup(props) {
const scene = new Scene();
if (props.background) scene.background = new Color(props.background);
watch(() => props.background, (value) => { scene.background = new Color(value); });
return { scene };
},
provide() {
return {
scene: this.scene,
};
},
mounted() {
if (!this.three.scene) {
this.three.scene = this.scene;
}
},
methods: {
// add(o) {
// this.scene.add(o);
// },
// remove(o) {
// this.scene.remove(o);
// },
},
render() {
if (this.$slots.default) {
return this.$slots.default();
}
return [];
},
};