62 lines
1.4 KiB
Vue
62 lines
1.4 KiB
Vue
<template>
|
|
<div class="editor">
|
|
<EditorToolbar :editor="editorRef" />
|
|
<TransformControls :editor="editorRef" />
|
|
<div class="editor-row">
|
|
<div class="viewport">
|
|
<div class="canvas-wrapper" ref="wrapperRef"></div>
|
|
</div>
|
|
<EditorSidebar :editor="editorRef" />
|
|
</div>
|
|
<EditorAssets :editor="editorRef" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onBeforeUnmount, onMounted, ref, shallowRef } from 'vue';
|
|
import { Editor } from '../editor';
|
|
import EditorToolbar from './EditorToolbar.vue';
|
|
import TransformControls from './TransformControls.vue';
|
|
import EditorSidebar from './EditorSidebar.vue';
|
|
import EditorAssets from './assets/EditorAssets.vue';
|
|
import { ViewportComponent } from '@freeblox/engine';
|
|
|
|
const wrapperRef = ref();
|
|
const editorRef = shallowRef<Editor>(new Editor());
|
|
|
|
const resize = () =>
|
|
editorRef.value.getComponent(ViewportComponent).setSizeFromViewport();
|
|
|
|
onMounted(() => {
|
|
editorRef.value.mount(wrapperRef.value);
|
|
window.addEventListener('resize', resize);
|
|
});
|
|
|
|
onBeforeUnmount(() => {
|
|
window.removeEventListener('resize', resize);
|
|
editorRef.value?.stop();
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.editor {
|
|
position: relative;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.viewport {
|
|
overflow: hidden;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.editor-row {
|
|
display: flex;
|
|
flex-direction: row;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|