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

29 lines
520 B
JavaScript
Raw Normal View History

2020-09-16 01:50:51 +08:00
import { Scene, Color } from 'three';
2020-09-14 22:57:11 +08:00
export default {
2020-09-16 01:50:51 +08:00
inject: ['three'],
2020-09-15 04:53:30 +08:00
props: {
id: String,
2020-09-16 01:50:51 +08:00
background: [String, Number],
2020-09-15 04:53:30 +08:00
},
2020-09-16 01:50:51 +08:00
setup (props) {
2020-09-14 22:57:11 +08:00
const scene = new Scene();
2020-09-16 01:50:51 +08:00
if (props.background) scene.background = new Color(props.background);
2020-09-14 22:57:11 +08:00
return { scene };
},
provide() {
return {
scene: this.scene,
};
},
mounted() {
this.three.scene = this.scene;
},
render() {
2020-09-15 20:59:34 +08:00
if (this.$slots.default) {
return this.$slots.default();
}
return [];
2020-09-14 22:57:11 +08:00
},
};