mirror of
https://github.com/robonen/canvas-3d.git
synced 2026-03-20 02:44:40 +00:00
9
.gitignore
vendored
9
.gitignore
vendored
@@ -10,10 +10,11 @@ tmp
|
||||
|
||||
# Build
|
||||
src/.nuxt
|
||||
src/.nitro
|
||||
src/.cache
|
||||
src/.output
|
||||
src/dist
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
.output
|
||||
dist
|
||||
|
||||
# Environment
|
||||
.env
|
||||
|
||||
4
.husky/pre-commit
Normal file
4
.husky/pre-commit
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run typecheck
|
||||
@@ -1,12 +1,14 @@
|
||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||
import {defineNuxtConfig} from 'nuxt/config';
|
||||
import {resolve} from 'path';
|
||||
|
||||
const SRC = resolve(__dirname, 'src');
|
||||
|
||||
export default defineNuxtConfig({
|
||||
rootDir: SRC,
|
||||
srcDir: SRC,
|
||||
app: {
|
||||
head: {
|
||||
title: 'Canvas 3D',
|
||||
link: [{rel: 'icon', href: '/favicon.svg'}],
|
||||
},
|
||||
},
|
||||
|
||||
1905
package-lock.json
generated
1905
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,13 +3,18 @@
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
"typecheck": "nuxt typecheck",
|
||||
"info": "nuxt info",
|
||||
"analyze": "nuxt analyze",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
"postinstall": "nuxt prepare",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vueuse/core": "^9.3.1",
|
||||
"@vueuse/nuxt": "^9.3.1",
|
||||
"husky": "^8.0.2",
|
||||
"nuxt": "3.0.0-rc.11",
|
||||
"sass": "^1.55.0"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<template>
|
||||
<NuxtLayout>
|
||||
<NuxtPage/>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
BIN
src/assets/fonts/computer-modern/cmunrm.eot
Normal file
BIN
src/assets/fonts/computer-modern/cmunrm.eot
Normal file
Binary file not shown.
BIN
src/assets/fonts/computer-modern/cmunrm.ttf
Normal file
BIN
src/assets/fonts/computer-modern/cmunrm.ttf
Normal file
Binary file not shown.
BIN
src/assets/fonts/computer-modern/cmunrm.woff
Normal file
BIN
src/assets/fonts/computer-modern/cmunrm.woff
Normal file
Binary file not shown.
12
src/assets/styles/_animations.scss
Normal file
12
src/assets/styles/_animations.scss
Normal file
@@ -0,0 +1,12 @@
|
||||
.slide-leave-active,
|
||||
.slide-enter-active {
|
||||
transition: 1s;
|
||||
}
|
||||
|
||||
.slide-enter {
|
||||
transform: translate(100%, 0);
|
||||
}
|
||||
|
||||
.slide-leave-to {
|
||||
transform: translate(-100%, 0);
|
||||
}
|
||||
@@ -39,3 +39,13 @@ $fonts: (
|
||||
);
|
||||
|
||||
@include MakeFont('Formular', $fonts, '@/assets/fonts/formular');
|
||||
|
||||
@font-face {
|
||||
font-family: 'Computer Modern Serif';
|
||||
src: url('@/assets/fonts/computer-modern/cmunrm.eot');
|
||||
src: url('@/assets/fonts/computer-modern/cmunrm.eot?#iefix') format('embedded-opentype'),
|
||||
url('@/assets/fonts/computer-modern/cmunrm.woff') format('woff'),
|
||||
url('@/assets/fonts/computer-modern/cmunrm.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
body {
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
12
src/assets/styles/_scroll.scss
Normal file
12
src/assets/styles/_scroll.scss
Normal file
@@ -0,0 +1,12 @@
|
||||
::-webkit-scrollbar {
|
||||
width: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: var(--scroll-color);
|
||||
transition: background-color 0.1s;
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
:root {
|
||||
--background-color-primary: #f3f3f3;
|
||||
--font-color-primary: #3d3d3d;
|
||||
--border-color: #e4e1e1;
|
||||
--icon-color: #5e5f60;
|
||||
--seconary-color: #8d8d8d;
|
||||
--scroll-color: #d4d3d4;
|
||||
--shadow-color: rgba(163, 167, 174, 0.2);
|
||||
--border: 1px solid var(--border-color);
|
||||
--shadow: 0 0 9px 0 var(--shadow-color);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@import 'reset';
|
||||
@import 'variables';
|
||||
@import 'fonts';
|
||||
@import 'scroll';
|
||||
@import 'animations';
|
||||
|
||||
html, body, #__nuxt {
|
||||
width: 100%;
|
||||
@@ -12,3 +14,18 @@ body {
|
||||
color: var(--font-color-primary);
|
||||
font-family: Formular, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
48
src/components/accordion.vue
Normal file
48
src/components/accordion.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
const {title} = defineProps<{ title: string }>();
|
||||
const showForm = ref<boolean>(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="block">
|
||||
<div class="header" @click="showForm = !showForm">
|
||||
<h2>{{ title }}</h2>
|
||||
<button class="button">
|
||||
<IconClose v-if="showForm"/>
|
||||
<IconOpen v-else/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="content" v-if="showForm">
|
||||
<slot/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 12px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
column-gap: 12px;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
color: var(--icon-color);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 16px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
</style>
|
||||
105
src/components/form/range.vue
Normal file
105
src/components/form/range.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<script setup lang="ts">
|
||||
const {
|
||||
label,
|
||||
min,
|
||||
max,
|
||||
defaultValue,
|
||||
step = 0.1
|
||||
} = defineProps<{ label: string, min: number, max: number, defaultValue: number, step?: number }>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: number): void
|
||||
}>();
|
||||
|
||||
const value = ref<number>(defaultValue);
|
||||
|
||||
const onChange = (event: Event) => {
|
||||
value.value = (event.target as HTMLInputElement).valueAsNumber;
|
||||
emit('change', value.value);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="block">
|
||||
<label class="label">
|
||||
{{ label }}
|
||||
<input :max="max" :min="min" :value="value" class="input" type="number" @input="onChange"/>
|
||||
</label>
|
||||
<div class="range">
|
||||
<div class="range__border">{{ min }}</div>
|
||||
<input :max="max" :min="min" :step="step" :value="value" class="range__input" type="range" @input="onChange"
|
||||
@dblclick="value = defaultValue"/>
|
||||
<div class="range__border">{{ max }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.block {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
column-gap: 12px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
column-gap: 4px;
|
||||
font-size: 18px;
|
||||
font-family: 'Computer Modern Serif', serif;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
font-family: 'Computer Modern Serif', serif;
|
||||
font-size: inherit;
|
||||
|
||||
&::-webkit-outer-spin-button,
|
||||
&::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
}
|
||||
|
||||
.range {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
column-gap: 14px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.range__border {
|
||||
font-size: 12px;
|
||||
color: var(--seconary-color);
|
||||
}
|
||||
|
||||
.range__input {
|
||||
-webkit-appearance: none;
|
||||
flex: 1;
|
||||
height: 6px;
|
||||
border-radius: 4px;
|
||||
margin: 10px 0;
|
||||
background: #e2e4e6;
|
||||
transition: opacity .2s;
|
||||
|
||||
&:hover, &:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background-color: #ff5c8e;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
14
src/components/grid/container.vue
Normal file
14
src/components/grid/container.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<template>
|
||||
<div class="grid">
|
||||
<slot/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-column-gap: 16px;
|
||||
grid-row-gap: 16px;
|
||||
}
|
||||
</style>
|
||||
61
src/components/grid/element.vue
Normal file
61
src/components/grid/element.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
const {title, isActive = false} = defineProps<{ title?: string, isActive?: boolean }>();
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button class="block" :class="{'block_active': isActive}">
|
||||
<div class="picture"></div>
|
||||
<div v-if="title" class="title">{{ title }}</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.block {
|
||||
font-family: 'Formular', sans-serif;
|
||||
font-weight: 400;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
row-gap: 8px;
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
box-sizing: border-box;
|
||||
border-radius: 8px;
|
||||
background-color: #fae9ef;
|
||||
color: #67122c;
|
||||
padding: 16px;
|
||||
font-size: 17px;
|
||||
transition: background-color 0.2s, transform 0.2s;
|
||||
|
||||
&_active {
|
||||
background-color: #fdd2e2;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: #fdd2e2;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.picture {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin: 8px;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 8px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
6
src/components/icon/close.vue
Normal file
6
src/components/icon/close.vue
Normal file
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5"/>
|
||||
</svg>
|
||||
</template>
|
||||
6
src/components/icon/hide.vue
Normal file
6
src/components/icon/hide.vue
Normal file
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M18.75 19.5l-7.5-7.5 7.5-7.5m-6 15L5.25 12l7.5-7.5"/>
|
||||
</svg>
|
||||
</template>
|
||||
7
src/components/icon/menu.vue
Normal file
7
src/components/icon/menu.vue
Normal file
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
6
src/components/icon/open.vue
Normal file
6
src/components/icon/open.vue
Normal file
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5"/>
|
||||
</svg>
|
||||
</template>
|
||||
71
src/layouts/default.vue
Normal file
71
src/layouts/default.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<script setup lang="ts">
|
||||
const showMenu = ref<boolean>(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<div class="content">
|
||||
<button v-if="!showMenu" class="button" @click="showMenu = true">
|
||||
<IconMenu/>
|
||||
</button>
|
||||
<template v-else>
|
||||
<div class="controls">
|
||||
<slot/>
|
||||
</div>
|
||||
<button class="button" @click="showMenu = false">
|
||||
<IconHide/>
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
<canvas class="canvas"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
height: max-content;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
column-gap: 16px;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.controls {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
padding: 28px 24px;
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
width: 480px;
|
||||
max-height: calc(100% - 40px);
|
||||
overflow: auto;
|
||||
border: var(--border);
|
||||
box-shadow: var(--shadow);
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 24px;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-top: 8px;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.canvas {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
</style>
|
||||
42
src/pages/figure.vue
Normal file
42
src/pages/figure.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
const axes = ['x', 'y', 'z'];
|
||||
const projections = [
|
||||
'Без проекции',
|
||||
'Изометрическая',
|
||||
'Диметрическая',
|
||||
'Триметрическая',
|
||||
'Одноточечная перспективная',
|
||||
'Двухточечная перспективная',
|
||||
];
|
||||
|
||||
const activeProjection = ref<number>(0);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container">
|
||||
<Accordion title="Перемещение">
|
||||
<FormRange v-for="axis in axes" :label="`${axis} =`" :min="-10" :max="10" :step="0.1" :defaultValue="0"/>
|
||||
</Accordion>
|
||||
<Accordion title="Вращение">
|
||||
<FormRange v-for="axis in axes" :label="`${axis} =`" :min="0" :max="359" :step="1" :defaultValue="0"/>
|
||||
</Accordion>
|
||||
<Accordion title="Масштабирование">
|
||||
<FormRange v-for="axis in axes" :key="axis" :label="`${axis} =`" :min="0.1" :max="5" :step="0.1"
|
||||
:defaultValue="1"/>
|
||||
</Accordion>
|
||||
<Accordion title="Проекции">
|
||||
<GridContainer>
|
||||
<GridElement v-for="(projection, i) in projections" :is-active="activeProjection === i" :key="projection"
|
||||
:title="projection" @click="activeProjection = i"/>
|
||||
</GridContainer>
|
||||
</Accordion>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,17 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
const figures = ['Тетраэдр', 'Гексаэдр', 'Октаэдр', 'Додекаэдр', 'Икосаэдр'];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Head>
|
||||
<Title>Главная</Title>
|
||||
</Head>
|
||||
<h1>Hello, Nuxt ✌</h1>
|
||||
</div>
|
||||
<h1>Выберете фигуру</h1>
|
||||
<GridContainer>
|
||||
<GridElement v-for="figure in figures" :key="figure" :title="figure"/>
|
||||
</GridContainer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user