pages/site/.vitepress/theme/Camera.vue
thepaperpilot 411b2ac293
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 58s
Separated out Background.vue
That'll make using it in the homepage easier
2024-06-20 08:33:48 -05:00

21 lines
573 B
Vue

<template>
<TresOrthographicCamera :position="[0, 0, 10]" />
</template>
<script setup lang="ts">
import { useTresContext } from '@tresjs/core';
import { OrthographicCamera } from 'three';
import { watch } from "vue";
const context = useTresContext();
watch([context.sizes.width, context.sizes.height, context.camera], ([width, height, camera]) => {
const cam = camera as OrthographicCamera;
if (cam) {
cam.left = 0;
cam.bottom = 0
cam.right = width;
cam.top = height;
cam.updateProjectionMatrix();
}
});
</script>