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>
|
||||
<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 }" />
|
||||
<Scene>
|
||||
<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 />
|
||||
</Box>
|
||||
</Scene>
|
||||
</Renderer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
<script lang="ts">
|
||||
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() {
|
||||
const renderer = this.$refs.renderer;
|
||||
const box = this.$refs.box.mesh;
|
||||
const renderer = this.$refs.renderer as RendererInterface
|
||||
const mesh = (this.$refs.box as MeshInterface).mesh
|
||||
if (renderer && mesh) {
|
||||
renderer.onBeforeRender(() => {
|
||||
box.rotation.x += 0.01;
|
||||
});
|
||||
mesh.rotation.x += 0.01
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
Loading…
Reference in New Issue
Block a user