add front-end

This commit is contained in:
Evert Prants 2023-06-19 18:19:02 +03:00
parent d25086632f
commit f1509a3a64
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
27 changed files with 6173 additions and 66 deletions

23
app/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# Nuxt dev/build outputs
.output
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example

0
app/.npmrc Normal file
View File

63
app/README.md Normal file
View File

@ -0,0 +1,63 @@
# Nuxt 3 Minimal Starter
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install the dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm run dev
# yarn
yarn dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm run build
# yarn
yarn build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm run preview
# yarn
yarn preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

3
app/app.vue Normal file
View File

@ -0,0 +1,3 @@
<template>
<NuxtPage />
</template>

View File

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

11
app/nuxt.config.ts Normal file
View File

@ -0,0 +1,11 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
css: ['@/assets/styles/index.scss'],
devtools: { enabled: true },
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
});

40
app/package.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "@freeblox/app",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@nuxt/schema": "^3.5.3",
"@types/node": "^18.0.0",
"autoprefixer": "^10.4.14",
"nuxi": "^3.5.3",
"nuxt": "^3.5.2",
"postcss": "^8.4.24",
"sass": "^1.62.1",
"tailwindcss": "^3.3.2",
"typescript": "^5.1.3",
"vue-tsc": "^1.4.2"
},
"dependencies": {
"@freeblox/client": "workspace:^",
"@freeblox/editor": "workspace:^",
"@unhead/vue": "^1.1.27",
"@vue/reactivity": "^3.3.4",
"@vue/runtime-core": "^3.3.4",
"@vue/runtime-dom": "^3.3.4",
"@vue/shared": "^3.3.4",
"defu": "^6.1.2",
"ufo": "^1.1.2",
"unctx": "^2.3.1",
"unstorage": "^1.6.1",
"vue": "^3.2.47",
"vue-router": "^4.2.2",
"vue-types": "^5.0.4"
}
}

13
app/pages/editor.vue Normal file
View File

@ -0,0 +1,13 @@
<template>
<ClientOnly>
<LazyEditorWrapper />
</ClientOnly>
</template>
<script setup lang="ts">
import { EditorWrapper as LazyEditorWrapper } from '@freeblox/editor';
</script>
<style lang="scss">
@import '@freeblox/editor/dist/style.css';
</style>

13
app/pages/index.vue Normal file
View File

@ -0,0 +1,13 @@
<template>
<div>
<h1>Nuxt Routing set up successfully!</h1>
<p class="text-green-500">Current route: {{ route.path }}</p>
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank"
>Learn more about Nuxt Routing</a
>
</div>
</template>
<script setup lang="ts">
const route = useRoute();
</script>

13
app/pages/player.vue Normal file
View File

@ -0,0 +1,13 @@
<template>
<ClientOnly>
<LazyGameWrapper />
</ClientOnly>
</template>
<script setup lang="ts">
import { GameWrapper as LazyGameWrapper } from '@freeblox/client';
</script>
<style lang="scss">
@import '@freeblox/client/dist/style.css';
</style>

BIN
app/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

3
app/server/tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

15
app/tailwind.config.js Normal file
View File

@ -0,0 +1,15 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./components/**/*.{js,vue,ts}',
'./layouts/**/*.vue',
'./pages/**/*.vue',
'./plugins/**/*.{js,ts}',
'./nuxt.config.{js,ts}',
'./app.vue',
],
theme: {
extend: {},
},
plugins: [],
};

4
app/tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}

View File

@ -12,6 +12,10 @@
".": {
"import": "./dist/client.js",
"require": "./dist/client.umd.cjs"
},
"./dist/style.css": {
"import": "./dist/style.css",
"require": "./dist/style.css"
}
},
"author": "Evert Prants <evert@lunasqu.ee>",

View File

@ -1,12 +1,10 @@
import {
EngineComponent,
EventEmitter,
World,
instanceCharacterObject,
getCharacterController,
Humanoid,
} from '@freeblox/engine';
import { GameEvents } from '../types/events';
import { Vector3 } from 'three';
import { ThirdPersonCamera } from './camera';

View File

@ -1 +1 @@
export * as GameWrapper from './components/GameWrapper.vue';
export { default as GameWrapper } from './components/GameWrapper.vue';

View File

@ -12,6 +12,10 @@
".": {
"import": "./dist/editor.js",
"require": "./dist/editor.umd.cjs"
},
"./dist/style.css": {
"import": "./dist/style.css",
"require": "./dist/style.css"
}
},
"author": "Evert Prants <evert@lunasqu.ee>",

View File

@ -19,11 +19,13 @@ 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.viewport.setSizeFromViewport();
const resize = () =>
editorRef.value.getComponent(ViewportComponent).setSizeFromViewport();
onMounted(() => {
editorRef.value.mount(wrapperRef.value);

View File

@ -1 +1 @@
export * as EditorWrapper from './components/EditorWrapper.vue';
export { default as EditorWrapper } from './components/EditorWrapper.vue';

View File

@ -6,7 +6,7 @@ import { EditorProperty, EditorPropertyExclude } from '../decorators/property';
export class Environment extends GameObject {
public objectType = Environment.name;
@EditorPropertyExclude()
public name = Environment.name;
public name = 'Environment';
public virtual = true;
@EditorPropertyExclude()

View File

@ -1,6 +1,6 @@
import { GameObject3D } from '../types/game-object';
export class Group extends GameObject3D {
public objectType = Group.name;
public name = Group.name;
public objectType = 'Group';
public name = 'Group';
}

View File

@ -25,8 +25,8 @@ export type HumanoidBodyPart =
export class Humanoid extends GameObject implements Ticking {
public isTickingObject = true;
public objectType = Humanoid.name;
public name = Humanoid.name;
public objectType = 'Humanoid';
public name = 'Humanoid';
private ready = false;
private skeleton!: Skeleton;
private _health = 100;

View File

@ -13,15 +13,15 @@ import { MeshPart } from './mesh.object';
import { Humanoid } from './humanoid.object';
export const instancableGameObjects: Record<string, Instancable<GameObject>> = {
[Group.name]: Group,
[Brick.name]: Brick,
[Cylinder.name]: Cylinder,
[Sphere.name]: Sphere,
[Torus.name]: Torus,
[Capsule.name]: Capsule,
[Wedge.name]: Wedge,
[WedgeCorner.name]: WedgeCorner,
[WedgeInnerCorner.name]: WedgeInnerCorner,
['Group']: Group,
['Brick']: Brick,
['Cylinder']: Cylinder,
['Sphere']: Sphere,
['Torus']: Torus,
['Capsule']: Capsule,
['Wedge']: Wedge,
['WedgeCorner']: WedgeCorner,
['WedgeInnerCorner']: WedgeInnerCorner,
};
export * from './environment.object';

View File

@ -68,8 +68,11 @@ export const instanceCharacterObject = async (name: string) => {
baseObject.add(bone as Bone);
baseObject.archivable = false;
baseObject.name = name;
convertedBodyParts.forEach((object) => baseObject.add(object));
convertedBodyParts.forEach((object) => (object.archivable = false));
convertedBodyParts.forEach((object) => {
baseObject.add(object);
object.archivable = false;
});
head.texture = base.faceTexture;

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
packages:
- 'apps/**'
- 'app'
- 'packages/**'