1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00
trois/src/App.vue
2021-05-02 20:56:34 +02:00

39 lines
1.0 KiB
Vue

<template>
<Renderer ref="renderer" antialias :pointer="{ resetOnEnd: true }" :orbit-ctrl="{ enableDamping: true }" resize="window">
<Camera :position="{ z: 10 }" />
<Scene>
<PointLight :position="{ y: 50, z: 50 }" />
<Box :size="1" ref="box" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }">
<LambertMaterial />
</Box>
</Scene>
</Renderer>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { Box, Camera, LambertMaterial, MeshPublicInterface, PointLight, Renderer, RendererPublicInterface, Scene } from './export'
export default defineComponent({
components: { Box, Camera, LambertMaterial, PointLight, Renderer, Scene },
mounted() {
const renderer = this.$refs.renderer as RendererPublicInterface
const mesh = (this.$refs.box as MeshPublicInterface).mesh
if (renderer && mesh) {
renderer.onBeforeRender(() => {
mesh.rotation.x += 0.01
})
}
},
})
</script>
<style>
body, html {
margin: 0;
}
canvas {
display: block;
}
</style>