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

39 lines
1.0 KiB
Vue
Raw Normal View History

2020-09-14 22:57:11 +08:00
<template>
2021-04-27 01:09:06 +08:00
<Renderer ref="renderer" antialias :pointer="{ resetOnEnd: true }" :orbit-ctrl="{ enableDamping: true }" resize="window">
2021-03-01 04:01:56 +08:00
<Camera :position="{ z: 10 }" />
<Scene>
<PointLight :position="{ y: 50, z: 50 }" />
2021-04-27 01:09:06 +08:00
<Box :size="1" ref="box" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }">
2021-03-13 06:16:34 +08:00
<LambertMaterial />
2021-03-01 04:01:56 +08:00
</Box>
</Scene>
</Renderer>
2020-09-14 22:57:11 +08:00
</template>
2021-04-27 01:09:06 +08:00
<script lang="ts">
import { defineComponent } from 'vue'
2021-05-03 02:56:34 +08:00
import { Box, Camera, LambertMaterial, MeshPublicInterface, PointLight, Renderer, RendererPublicInterface, Scene } from './export'
2021-04-27 01:09:06 +08:00
export default defineComponent({
components: { Box, Camera, LambertMaterial, PointLight, Renderer, Scene },
2021-03-01 04:01:56 +08:00
mounted() {
2021-05-03 02:56:34 +08:00
const renderer = this.$refs.renderer as RendererPublicInterface
const mesh = (this.$refs.box as MeshPublicInterface).mesh
2021-04-27 01:09:06 +08:00
if (renderer && mesh) {
renderer.onBeforeRender(() => {
mesh.rotation.x += 0.01
})
}
2021-03-01 04:01:56 +08:00
},
2021-04-27 01:09:06 +08:00
})
2020-09-14 22:57:11 +08:00
</script>
2020-09-15 16:07:57 +08:00
2021-03-13 06:16:34 +08:00
<style>
body, html {
2021-03-01 04:01:56 +08:00
margin: 0;
}
2021-03-13 06:16:34 +08:00
canvas {
display: block;
2020-09-15 16:07:57 +08:00
}
</style>