mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
app.vue example
This commit is contained in:
parent
79f1512a1e
commit
8b778a2100
30
src/App.vue
30
src/App.vue
@ -1,25 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<Renderer ref="renderer" antialias orbit-ctrl resize="window">
|
<Renderer ref="renderer" antialias :pointer="{ resetOnEnd: true }" :orbit-ctrl="{ enableDamping: true }" resize="window">
|
||||||
<Camera :position="{ z: 10 }" />
|
<Camera :position="{ z: 10 }" />
|
||||||
<Scene>
|
<Scene>
|
||||||
<PointLight :position="{ y: 50, z: 50 }" />
|
<PointLight :position="{ y: 50, z: 50 }" />
|
||||||
<Box ref="box" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }">
|
<Box :size="1" ref="box" :rotation="{ y: Math.PI / 4, z: Math.PI / 4 }">
|
||||||
<LambertMaterial />
|
<LambertMaterial />
|
||||||
</Box>
|
</Box>
|
||||||
</Scene>
|
</Scene>
|
||||||
</Renderer>
|
</Renderer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { defineComponent } from 'vue'
|
||||||
|
import Box from './meshes/Box'
|
||||||
|
import Camera from './core/PerspectiveCamera'
|
||||||
|
import LambertMaterial from './materials/LambertMaterial'
|
||||||
|
import { MeshInterface } from './meshes/Mesh'
|
||||||
|
import PointLight from './lights/PointLight'
|
||||||
|
import Renderer, { RendererInterface } from './core/Renderer'
|
||||||
|
import Scene from './core/Scene'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
components: { Box, Camera, LambertMaterial, PointLight, Renderer, Scene },
|
||||||
mounted() {
|
mounted() {
|
||||||
const renderer = this.$refs.renderer;
|
const renderer = this.$refs.renderer as RendererInterface
|
||||||
const box = this.$refs.box.mesh;
|
const mesh = (this.$refs.box as MeshInterface).mesh
|
||||||
|
if (renderer && mesh) {
|
||||||
renderer.onBeforeRender(() => {
|
renderer.onBeforeRender(() => {
|
||||||
box.rotation.x += 0.01;
|
mesh.rotation.x += 0.01
|
||||||
});
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user