Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
e86d909e07 | |||
|
39ba4856a2 | ||
51a95f9bf1 |
@ -4,10 +4,12 @@ import ip from 'ip';
|
||||
|
||||
import Server from './framework/express/server';
|
||||
import UserModel from './framework/mongo/user';
|
||||
import CardModel from './framework/mongo/card';
|
||||
import { Config } from './config';
|
||||
|
||||
export type Services = {
|
||||
userModel: UserModel;
|
||||
cardModel: CardModel;
|
||||
};
|
||||
|
||||
const configFile = process.env.CONFIGFILE;
|
||||
@ -23,6 +25,7 @@ const db = mongo.db(config.mongo.dbName);
|
||||
|
||||
const services: Services = {
|
||||
userModel: new UserModel(db),
|
||||
cardModel: new CardModel(db),
|
||||
};
|
||||
|
||||
const server = new Server(config.server, config.mongo, services);
|
||||
@ -34,10 +37,10 @@ process.on('SIGINT', async () => {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
server.start(() =>
|
||||
server.start().then(() => {
|
||||
console.log(
|
||||
`Running on http://127.0.0.1:${config.server.port} http://${ip.address()}:${
|
||||
config.server.port
|
||||
}`,
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
|
37
api/src/entities/card.ts
Normal file
37
api/src/entities/card.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { CardCtor, CardInfo, CardRarity, CombatStats } from '@core';
|
||||
import { Entity } from './entity';
|
||||
|
||||
export class Card extends Entity implements CardInfo {
|
||||
name: string;
|
||||
rarity: keyof typeof CardRarity;
|
||||
stats: CombatStats;
|
||||
thumbnail: string;
|
||||
model: string;
|
||||
|
||||
constructor(raw: CardCtor) {
|
||||
super(raw);
|
||||
this.name = raw.name || '';
|
||||
this.rarity = raw.rarity || CardRarity.COMMON;
|
||||
this.stats = raw.stats || {
|
||||
baseAtk: 0,
|
||||
baseCrit: 0,
|
||||
baseDef: 0,
|
||||
multAtk: 0,
|
||||
multCrit: 0,
|
||||
multDef: 0,
|
||||
};
|
||||
this.thumbnail = raw.thumbnail || '';
|
||||
this.model = raw.model || '';
|
||||
}
|
||||
|
||||
Info(): CardInfo {
|
||||
return {
|
||||
uuid: this.uuid,
|
||||
name: this.name,
|
||||
rarity: this.rarity,
|
||||
stats: this.stats,
|
||||
thumbnail: this.thumbnail,
|
||||
model: this.model,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
import { EntityCtor, EntityInfo } from '@core';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { ObjectId } from 'mongodb';
|
||||
|
||||
export class Entity implements EntityInfo {
|
||||
_id: ObjectId;
|
||||
uuid: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
||||
constructor(raw: EntityCtor) {
|
||||
this._id = raw._id || new ObjectId();
|
||||
this.uuid = raw.uuid || randomUUID();
|
||||
this.createdAt = raw.createdAt || new Date();
|
||||
this.updatedAt = raw.updatedAt || new Date();
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {
|
||||
CardInfo,
|
||||
UserCtor,
|
||||
UserInfo,
|
||||
UserInfoWithPassword,
|
||||
@ -6,17 +7,20 @@ import {
|
||||
UserWithPasswordCtor,
|
||||
} from '@core';
|
||||
import { getHashedPassword } from '../functions/password';
|
||||
import { Card } from './card';
|
||||
import { Entity } from './entity';
|
||||
|
||||
export class User extends Entity implements UserInfo {
|
||||
username: string;
|
||||
role: keyof typeof UserRoles;
|
||||
cards: Card[];
|
||||
|
||||
constructor(raw: UserCtor) {
|
||||
super(raw);
|
||||
|
||||
this.username = raw.username || '';
|
||||
this.role = raw.role || UserRoles.USER;
|
||||
this.cards = raw.cards ? raw.cards.map(card => new Card(card)) : [];
|
||||
}
|
||||
|
||||
Info(): UserInfo {
|
||||
@ -24,6 +28,7 @@ export class User extends Entity implements UserInfo {
|
||||
uuid: this.uuid,
|
||||
username: this.username,
|
||||
role: this.role,
|
||||
cards: this.cards.map(card => card.Info()),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -42,6 +47,7 @@ export class UserWithPassword extends User implements UserInfoWithPassword {
|
||||
uuid: this.uuid,
|
||||
username: this.username,
|
||||
role: this.role,
|
||||
cards: this.cards.map(card => card.Info()),
|
||||
password: this.password,
|
||||
};
|
||||
}
|
||||
|
66
api/src/framework/express/card.ts
Normal file
66
api/src/framework/express/card.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { RequestHandler, Router } from 'express';
|
||||
import { CreateCard, ListCards, ReadCard } from '../../functions/card';
|
||||
import { Services } from '../../app';
|
||||
import { CheckPermissions, getRequestId, ValidateSchema } from './middleware';
|
||||
import { CreateCardSchema, ReadCardSchema } from './schema/card';
|
||||
|
||||
function CreateHandler(services: Services): RequestHandler {
|
||||
const createCard = CreateCard(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const card = await createCard(getRequestId(req), req.body);
|
||||
res.status(200).send(card);
|
||||
} catch (error) {
|
||||
next({ status: 409, message: 'Card Already Exists' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function ReadHandler(services: Services): RequestHandler {
|
||||
const readCard = ReadCard(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const card = await readCard(getRequestId(req), req.params.uuid);
|
||||
res.status(200).send(card);
|
||||
} catch (error) {
|
||||
next({ status: 404, message: 'Card Not Found' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function ListHandler(services: Services): RequestHandler {
|
||||
const listCards = ListCards(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const cards = await listCards(getRequestId(req));
|
||||
res.status(200).send(cards);
|
||||
} catch (error) {
|
||||
next({ message: 'Unknown Error' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function Routes(services: Services) {
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
'/create',
|
||||
CheckPermissions(),
|
||||
CreateCardSchema(),
|
||||
ValidateSchema(),
|
||||
CreateHandler(services),
|
||||
);
|
||||
router.get(
|
||||
'/read/:uuid',
|
||||
CheckPermissions(),
|
||||
ReadCardSchema(),
|
||||
ValidateSchema(),
|
||||
ReadHandler(services),
|
||||
);
|
||||
router.get('/list', CheckPermissions(), ListHandler(services));
|
||||
|
||||
return router;
|
||||
}
|
@ -56,8 +56,6 @@ export function CheckPermissions(): RequestHandler {
|
||||
|
||||
export function ValidateSchema(): RequestHandler {
|
||||
return (req, res, next) => {
|
||||
const error = validationResult(req);
|
||||
|
||||
const oldBody = req.body;
|
||||
req.body = matchedData(req, { locations: ['body'] });
|
||||
|
||||
@ -67,6 +65,7 @@ export function ValidateSchema(): RequestHandler {
|
||||
message: 'Unprocessable Entity',
|
||||
});
|
||||
|
||||
const error = validationResult(req);
|
||||
error.isEmpty()
|
||||
? next()
|
||||
: next({
|
||||
@ -76,6 +75,12 @@ export function ValidateSchema(): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
export function NotFoundHandler(): RequestHandler {
|
||||
return (req, res, next) => {
|
||||
next({ status: 404, message: 'Not Found' });
|
||||
};
|
||||
}
|
||||
|
||||
export function ErrorHandler(): ErrorRequestHandler {
|
||||
return (error, req, res, next) => {
|
||||
error.status
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { Router } from 'express';
|
||||
import { Services } from '../../app';
|
||||
import * as user from './user';
|
||||
import * as card from './card';
|
||||
|
||||
export function Routes(services: Services) {
|
||||
const router = Router();
|
||||
|
||||
router.use('/user', user.Routes(services));
|
||||
router.use('/card', card.Routes(services));
|
||||
|
||||
return router;
|
||||
}
|
||||
|
29
api/src/framework/express/schema/card.ts
Normal file
29
api/src/framework/express/schema/card.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { checkSchema } from 'express-validator';
|
||||
import { CardRarity } from '@core';
|
||||
|
||||
export const CreateCardSchema = () =>
|
||||
checkSchema({
|
||||
name: {
|
||||
isString: true,
|
||||
},
|
||||
rarity: {
|
||||
isIn: {
|
||||
options: [Object.values(CardRarity)],
|
||||
},
|
||||
},
|
||||
thumbnail: {
|
||||
isString: true,
|
||||
},
|
||||
model: {
|
||||
isString: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const ReadCardSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
});
|
@ -1,15 +1,6 @@
|
||||
import { checkSchema } from 'express-validator';
|
||||
import { UserRoles } from '@core';
|
||||
|
||||
export const ReadUserSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const LoginUserSchema = () =>
|
||||
checkSchema({
|
||||
username: {
|
||||
@ -37,8 +28,24 @@ export const CreateUserSchema = () =>
|
||||
},
|
||||
});
|
||||
|
||||
export const ReadUserSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const ListUsersSchema = () => checkSchema({});
|
||||
|
||||
export const UpdateUserSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
username: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
@ -54,3 +61,31 @@ export const UpdateUserSchema = () =>
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const AddCardToUserSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
cardUuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const RemoveCardFromUserSchema = () =>
|
||||
checkSchema({
|
||||
uuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
cardUuid: {
|
||||
isUUID: {
|
||||
options: 4,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ import { randomUUID } from 'crypto';
|
||||
import * as http from 'http';
|
||||
|
||||
import { Routes } from './router';
|
||||
import { RequestId, ErrorHandler } from './middleware';
|
||||
import { RequestId, ErrorHandler, NotFoundHandler } from './middleware';
|
||||
import { Services } from '../../app';
|
||||
import { MongoConfig, ServerConfig } from '../../config';
|
||||
|
||||
@ -32,7 +32,6 @@ class Server {
|
||||
origin: this.config.origin,
|
||||
}),
|
||||
);
|
||||
this.app.use(RequestId());
|
||||
this.app.use(
|
||||
session({
|
||||
proxy: process.env.NODE_ENV === 'production',
|
||||
@ -52,12 +51,16 @@ class Server {
|
||||
saveUninitialized: false,
|
||||
}),
|
||||
);
|
||||
this.app.use(RequestId());
|
||||
this.app.use(Routes(services));
|
||||
this.app.use(NotFoundHandler());
|
||||
this.app.use(ErrorHandler());
|
||||
}
|
||||
|
||||
start(func: () => void): void {
|
||||
this.server = this.app.listen(this.config.port, func);
|
||||
async start(): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.server = this.app.listen(this.config.port, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
async close(): Promise<void> {
|
||||
|
@ -5,6 +5,8 @@ import {
|
||||
ReadUser,
|
||||
LoginUser,
|
||||
UpdateUser,
|
||||
ListUsers,
|
||||
AddCardToUser,
|
||||
} from '../../functions/user';
|
||||
import {
|
||||
LoginUserSchema,
|
||||
@ -12,10 +14,13 @@ import {
|
||||
ReadUserSchema,
|
||||
LogoutUserSchema,
|
||||
UpdateUserSchema,
|
||||
ListUsersSchema,
|
||||
AddCardToUserSchema,
|
||||
RemoveCardFromUserSchema,
|
||||
} from './schema/user';
|
||||
import { CheckPermissions, getRequestId, ValidateSchema } from './middleware';
|
||||
|
||||
function LoginHandler(services: Services): RequestHandler {
|
||||
function LoginUserHandler(services: Services): RequestHandler {
|
||||
const login = LoginUser(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
@ -29,7 +34,7 @@ function LoginHandler(services: Services): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
function LogoutHandler(services: Services): RequestHandler {
|
||||
function LogoutUserHandler(services: Services): RequestHandler {
|
||||
return async (req, res, next) => {
|
||||
if (req.session.user) {
|
||||
req.session.user = null;
|
||||
@ -40,7 +45,7 @@ function LogoutHandler(services: Services): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
function CreateHandler(services: Services): RequestHandler {
|
||||
function CreateUserHandler(services: Services): RequestHandler {
|
||||
const createUser = CreateUser(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
@ -53,7 +58,7 @@ function CreateHandler(services: Services): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
function ReadHandler(services: Services): RequestHandler {
|
||||
function ReadUserHandler(services: Services): RequestHandler {
|
||||
const readUser = ReadUser(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
@ -66,7 +71,7 @@ function ReadHandler(services: Services): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
function UpdateHandler(services: Services): RequestHandler {
|
||||
function UpdateUserHandler(services: Services): RequestHandler {
|
||||
const updateUser = UpdateUser(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
@ -83,43 +88,95 @@ function UpdateHandler(services: Services): RequestHandler {
|
||||
};
|
||||
}
|
||||
|
||||
function ListUserHandler(services: Services): RequestHandler {
|
||||
const listUsers = ListUsers(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const users = await listUsers(getRequestId(req));
|
||||
res.status(200).send(users);
|
||||
} catch (error) {
|
||||
next({ message: 'Unknown Error' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function AddCardToUserHandler(services: Services): RequestHandler {
|
||||
const addCardToUser = AddCardToUser(services);
|
||||
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const user = await addCardToUser(
|
||||
getRequestId(req),
|
||||
req.params.uuid,
|
||||
req.body.cardUuid,
|
||||
);
|
||||
res.status(200).send(user);
|
||||
} catch (error) {
|
||||
next({ message: 'Unknown Error' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function Routes(services: Services) {
|
||||
const router = Router();
|
||||
|
||||
//User
|
||||
router.post(
|
||||
'/login',
|
||||
LoginUserSchema(),
|
||||
ValidateSchema(),
|
||||
LoginHandler(services),
|
||||
LoginUserHandler(services),
|
||||
);
|
||||
router.post(
|
||||
'/logout',
|
||||
LogoutUserSchema(),
|
||||
ValidateSchema(),
|
||||
LogoutHandler(services),
|
||||
LogoutUserHandler(services),
|
||||
);
|
||||
router.get(
|
||||
'/read/:uuid',
|
||||
CheckPermissions(),
|
||||
ReadUserSchema(),
|
||||
ValidateSchema(),
|
||||
ReadHandler(services),
|
||||
ReadUserHandler(services),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/create',
|
||||
CheckPermissions(),
|
||||
CreateUserSchema(),
|
||||
ValidateSchema(),
|
||||
CreateHandler(services),
|
||||
CreateUserHandler(services),
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/update/:uuid',
|
||||
CheckPermissions(),
|
||||
UpdateUserSchema(),
|
||||
ValidateSchema(),
|
||||
UpdateHandler(services),
|
||||
UpdateUserHandler(services),
|
||||
);
|
||||
router.get(
|
||||
'/list',
|
||||
CheckPermissions(),
|
||||
ListUsersSchema(),
|
||||
ValidateSchema(),
|
||||
ListUserHandler(services),
|
||||
);
|
||||
|
||||
//Alteration
|
||||
router.post(
|
||||
'/addCard/:uuid',
|
||||
CheckPermissions(),
|
||||
AddCardToUserSchema(),
|
||||
ValidateSchema(),
|
||||
AddCardToUserHandler(services),
|
||||
);
|
||||
router.post(
|
||||
'/removeCard/:uuid',
|
||||
CheckPermissions(),
|
||||
RemoveCardFromUserSchema(),
|
||||
ValidateSchema(),
|
||||
//RemoveCardFromUserHandler(),
|
||||
);
|
||||
|
||||
return router;
|
||||
|
74
api/src/framework/mongo/card.ts
Normal file
74
api/src/framework/mongo/card.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { Collection, Db } from 'mongodb';
|
||||
import { UpdateCardBody } from '@core';
|
||||
import { Card } from '../../entities/card';
|
||||
import { log } from '../../functions/logger';
|
||||
|
||||
class CardModel {
|
||||
private collection: Collection<Card>;
|
||||
|
||||
constructor(db: Db) {
|
||||
this.collection = db.collection<Card>('cards');
|
||||
}
|
||||
|
||||
public async create(tracker: string, cardInfo: Card): Promise<Card> {
|
||||
const checkCard = await this.collection.findOne({
|
||||
uuid: cardInfo.uuid,
|
||||
});
|
||||
if (checkCard) {
|
||||
log(tracker, 'Card Already Exists');
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
await this.collection.insertOne(cardInfo);
|
||||
|
||||
const card = await this.read(tracker, cardInfo.uuid);
|
||||
log(tracker, 'CREATE USER', card);
|
||||
return card;
|
||||
}
|
||||
|
||||
public async read(tracker: string, uuid: string): Promise<Card> {
|
||||
const cardDocument = await this.collection.findOne({ uuid });
|
||||
if (!cardDocument) {
|
||||
log(tracker, 'Card Not Found');
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
const card = new Card(cardDocument);
|
||||
log(tracker, 'READ CARD', card);
|
||||
return card;
|
||||
}
|
||||
|
||||
public async update(
|
||||
tracker: string,
|
||||
uuid: string,
|
||||
cardInfo: UpdateCardBody,
|
||||
): Promise<Card> {
|
||||
const checkCard = await this.collection.findOne({ uuid });
|
||||
if (!checkCard) {
|
||||
log(tracker, 'Card Does Not Exist');
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
await this.collection.updateOne(
|
||||
{ uuid },
|
||||
{
|
||||
$set: {
|
||||
...cardInfo,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const card = await this.read(tracker, uuid);
|
||||
log(tracker, 'UPDATE CARD', card);
|
||||
return card;
|
||||
}
|
||||
|
||||
public async list(tracker: string): Promise<Card[]> {
|
||||
const cardCollection = await this.collection.find().toArray();
|
||||
log(tracker, 'LIST CARDS');
|
||||
return cardCollection.map((cardDocument) => new Card(cardDocument));
|
||||
}
|
||||
}
|
||||
|
||||
export default CardModel;
|
@ -1,5 +1,5 @@
|
||||
import { Collection, Db } from 'mongodb';
|
||||
import { LoginUserBody, UpdateUserBody } from '@core';
|
||||
import { Card, CardInfo, LoginUserBody, UpdateUserBody, UserInfo } from '@core';
|
||||
import { User, UserWithPassword } from '../../entities/user';
|
||||
import { log } from '../../functions/logger';
|
||||
import { getHashedPassword } from '../../functions/password';
|
||||
@ -11,9 +11,9 @@ class UserModel {
|
||||
this.collection = db.collection<User>('users');
|
||||
}
|
||||
|
||||
public async login(tracker: string, data: LoginUserBody): Promise<User> {
|
||||
public async login(tracker: string, userInfo: LoginUserBody): Promise<User> {
|
||||
const checkUser = await this.collection.findOne({
|
||||
username: data.username,
|
||||
username: userInfo.username,
|
||||
});
|
||||
if (!checkUser) {
|
||||
log(tracker, 'User Not Found');
|
||||
@ -22,7 +22,7 @@ class UserModel {
|
||||
|
||||
const userDocument = await this.collection.findOne({
|
||||
uuid: checkUser.uuid,
|
||||
password: getHashedPassword(checkUser.uuid, data.password),
|
||||
password: getHashedPassword(checkUser.uuid, userInfo.password),
|
||||
});
|
||||
if (!userDocument) {
|
||||
log(tracker, 'Wrong Password');
|
||||
@ -54,7 +54,22 @@ class UserModel {
|
||||
}
|
||||
|
||||
public async read(tracker: string, uuid: string): Promise<User> {
|
||||
const userDocument = await this.collection.findOne({ uuid });
|
||||
const [userDocument] = await this.collection.aggregate<UserInfo>([
|
||||
{
|
||||
$match:{
|
||||
uuid
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cards",
|
||||
localField: "cards",
|
||||
foreignField: "_id",
|
||||
as: "cards"
|
||||
}
|
||||
}
|
||||
]).toArray();
|
||||
console.log(JSON.stringify(userDocument));
|
||||
if (!userDocument) {
|
||||
log(tracker, 'User Not Found');
|
||||
throw new Error();
|
||||
@ -93,6 +108,40 @@ class UserModel {
|
||||
log(tracker, 'UPDATE USER', user);
|
||||
return user;
|
||||
}
|
||||
|
||||
public async list(tracker: string): Promise<User[]> {
|
||||
const userCollection = await this.collection.find().toArray();
|
||||
log(tracker, 'LIST USERS');
|
||||
return userCollection.map((userDocument) => new User(userDocument));
|
||||
}
|
||||
|
||||
public async addCard(
|
||||
tracker: string,
|
||||
uuid: string,
|
||||
card: Card,
|
||||
): Promise<User> {
|
||||
const checkUser = await this.collection.findOne({ uuid });
|
||||
if (!checkUser) {
|
||||
log(tracker, 'User Does Not Exist');
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
await this.collection.updateOne(
|
||||
{ uuid },
|
||||
{
|
||||
$set: {
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
$addToSet: {
|
||||
cards: card._id,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const user = await this.read(tracker, uuid);
|
||||
log(tracker, 'ADD CARD TO USER', user, card);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
export default UserModel;
|
||||
|
36
api/src/functions/card.ts
Normal file
36
api/src/functions/card.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { CardInfo, CreateCardBody } from '@core';
|
||||
import { Card } from '../entities/card';
|
||||
import { Services } from '../app';
|
||||
|
||||
export function CreateCard(
|
||||
services: Services,
|
||||
): (tracker: string, raw: CreateCardBody) => Promise<CardInfo> {
|
||||
const { cardModel } = services;
|
||||
|
||||
return async (tracker, raw) => {
|
||||
const card = await cardModel.create(tracker, new Card(raw));
|
||||
return card.Info();
|
||||
};
|
||||
}
|
||||
|
||||
export function ReadCard(
|
||||
services: Services,
|
||||
): (tracker: string, uuid: string) => Promise<CardInfo> {
|
||||
const { cardModel } = services;
|
||||
|
||||
return async (tracker, uuid) => {
|
||||
const card = await cardModel.read(tracker, uuid);
|
||||
return card.Info();
|
||||
};
|
||||
}
|
||||
|
||||
export function ListCards(
|
||||
services: Services,
|
||||
): (tracker: string) => Promise<CardInfo[]> {
|
||||
const { cardModel } = services;
|
||||
|
||||
return async (tracker) => {
|
||||
const cards = await cardModel.list(tracker);
|
||||
return cards.map((card) => card.Info());
|
||||
};
|
||||
}
|
@ -45,3 +45,27 @@ export function UpdateUser(
|
||||
return user.Info();
|
||||
};
|
||||
}
|
||||
|
||||
export function ListUsers(
|
||||
services: Services,
|
||||
): (tracker: string) => Promise<UserInfo[]> {
|
||||
const { userModel } = services;
|
||||
|
||||
return async (tracker) => {
|
||||
const users = await userModel.list(tracker);
|
||||
return users.map((user) => user.Info());
|
||||
};
|
||||
}
|
||||
|
||||
export function AddCardToUser(
|
||||
services: Services,
|
||||
): (tracker: string, uuid: string, cardUuid: string) => Promise<UserInfo> {
|
||||
const { userModel, cardModel } = services;
|
||||
|
||||
return async (tracker, uuid, cardUuid) => {
|
||||
const card = await cardModel.read(tracker, cardUuid);
|
||||
|
||||
const user = await userModel.addCard(tracker, uuid, card);
|
||||
return user.Info();
|
||||
};
|
||||
}
|
||||
|
2568
core/package-lock.json
generated
2568
core/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.8.4",
|
||||
"prettier": "^2.7.1",
|
||||
"mongodb": "^4.10.0",
|
||||
"typescript": "^4.8.3"
|
||||
}
|
||||
}
|
||||
|
12
core/src/alteration.ts
Normal file
12
core/src/alteration.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { EntityInfo } from './entity';
|
||||
import { CardInfo } from './card';
|
||||
|
||||
export type AlerationInfo = {
|
||||
card: CardInfo;
|
||||
level: number;
|
||||
xp: number;
|
||||
};
|
||||
|
||||
export type Ateration = AlerationInfo & EntityInfo;
|
||||
|
||||
export type AlerationCtor = Partial<Ateration>;
|
40
core/src/card.ts
Normal file
40
core/src/card.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { EntityInfo } from './entity';
|
||||
|
||||
export enum CardRarity {
|
||||
COMMON = 'COMMON',
|
||||
RARE = 'RARE',
|
||||
EPIC = 'EPIC',
|
||||
LEGENDARY = 'LEGENDARY',
|
||||
}
|
||||
|
||||
export type CombatStats = {
|
||||
baseAtk: number;
|
||||
baseDef: number;
|
||||
baseCrit: number;
|
||||
multAtk: number;
|
||||
multDef: number;
|
||||
multCrit: number;
|
||||
};
|
||||
|
||||
export type CardInfo = {
|
||||
uuid: string;
|
||||
name: string;
|
||||
rarity: keyof typeof CardRarity;
|
||||
stats: CombatStats;
|
||||
thumbnail: string;
|
||||
model: string;
|
||||
};
|
||||
|
||||
export type CreateCardBody = {
|
||||
name: string;
|
||||
rarity: keyof typeof CardRarity;
|
||||
stats: CombatStats;
|
||||
thumbnail: string;
|
||||
model: string;
|
||||
};
|
||||
|
||||
export type Card = CardInfo & EntityInfo;
|
||||
|
||||
export type CardCtor = Partial<Card>;
|
||||
|
||||
export type UpdateCardBody = Partial<Omit<CardInfo, 'uuid'>>;
|
@ -1,4 +1,7 @@
|
||||
import { ObjectId } from 'mongodb';
|
||||
|
||||
export type EntityInfo = {
|
||||
_id: ObjectId;
|
||||
uuid: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
@ -1,2 +1,4 @@
|
||||
export * from './alteration';
|
||||
export * from './card';
|
||||
export * from './user';
|
||||
export * from './entity';
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { EntityInfo } from './entity';
|
||||
import { CardInfo } from './card';
|
||||
|
||||
export enum UserRoles {
|
||||
ADMIN = 'ADMIN',
|
||||
@ -9,6 +10,7 @@ export type UserInfo = {
|
||||
uuid: string;
|
||||
username: string;
|
||||
role: keyof typeof UserRoles;
|
||||
cards: CardInfo[];
|
||||
};
|
||||
|
||||
export type User = UserInfo & EntityInfo;
|
||||
|
1251
www/package-lock.json
generated
1251
www/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,6 @@
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ar-js-org/ar.js": "^3.4.3",
|
||||
"papercss": "^1.8.3",
|
||||
"sirv-cli": "^2.0.0",
|
||||
"spaper": "^0.9.6",
|
||||
|
Binary file not shown.
@ -1,195 +0,0 @@
|
||||
234 235 240 233 240 234 240 235 240 237 240 238 240 240 240 232
|
||||
229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 228
|
||||
227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 239
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
231 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
225 149 240 240 186 216 225 174 240 240 240 237 238 240 240 240
|
||||
150 107 238 231 75 208 115 147 238 228 223 226 237 180 226 240
|
||||
150 62 181 213 62 187 113 169 197 72 29 237 120 50 53 207
|
||||
149 63 47 78 53 184 113 101 142 5 150 150 45 217 186 83
|
||||
121 84 220 222 58 180 121 92 128 109 237 124 155 232 161 64
|
||||
149 71 240 240 76 210 98 109 122 108 240 129 51 119 161 155
|
||||
149 186 240 240 98 219 135 152 207 191 236 227 152 77 175 209
|
||||
235 235 240 233 240 234 240 235 240 236 240 238 240 240 240 240
|
||||
229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
236 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
225 156 240 240 186 216 225 186 240 240 240 240 240 240 240 240
|
||||
150 117 240 231 72 206 115 162 240 232 223 237 240 180 226 240
|
||||
150 74 187 213 51 184 103 168 197 78 29 237 120 50 53 216
|
||||
144 77 51 74 61 184 106 101 142 5 150 152 52 217 186 85
|
||||
117 89 219 219 65 184 121 92 128 100 236 125 156 240 170 73
|
||||
148 71 240 240 76 210 109 109 121 99 240 137 51 120 166 164
|
||||
140 186 240 240 98 220 150 156 207 192 236 230 152 77 176 212
|
||||
234 235 240 233 240 234 240 235 240 236 240 238 240 240 240 233
|
||||
229 240 240 240 240 240 240 240 240 240 240 240 240 240 240 239
|
||||
227 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
234 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
235 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
232 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
228 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
225 156 240 240 182 212 225 180 240 240 240 240 240 240 240 240
|
||||
150 116 238 228 66 205 115 151 238 236 225 240 240 180 226 240
|
||||
156 84 186 211 47 184 109 170 200 92 30 240 120 50 53 216
|
||||
147 83 51 73 50 184 106 110 148 17 151 150 45 217 186 85
|
||||
127 98 219 219 58 179 109 101 128 107 237 125 155 240 163 72
|
||||
155 86 240 240 76 201 85 108 121 95 232 137 51 118 153 155
|
||||
149 189 240 240 98 220 141 154 206 178 235 230 152 77 175 209
|
||||
|
||||
232 228 239 240 240 240 240 240 240 240 240 207 83 64 155 209
|
||||
240 240 240 240 240 240 240 240 240 240 226 53 186 161 161 175
|
||||
240 240 240 240 240 240 240 240 240 240 180 50 217 232 119 77
|
||||
240 240 240 240 240 240 240 240 240 238 237 120 45 155 51 152
|
||||
238 240 240 240 240 240 240 240 240 237 226 237 150 124 129 227
|
||||
240 240 240 240 240 240 240 240 240 240 223 29 150 237 240 236
|
||||
237 240 240 240 240 240 240 240 240 240 228 72 5 109 108 191
|
||||
240 240 240 240 240 240 240 240 240 240 238 197 142 128 122 207
|
||||
235 240 240 240 240 240 240 240 240 174 147 169 101 92 109 152
|
||||
240 240 240 240 240 240 240 240 240 225 115 113 113 121 98 135
|
||||
234 240 240 240 240 240 240 240 240 216 208 187 184 180 210 219
|
||||
240 240 240 240 240 240 240 240 240 186 75 62 53 58 76 98
|
||||
233 240 240 240 240 240 240 240 240 240 231 213 78 222 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 238 181 47 220 240 240
|
||||
235 240 240 240 240 240 240 240 240 149 107 62 63 84 71 186
|
||||
234 229 227 240 236 234 236 231 229 225 150 150 149 121 149 149
|
||||
240 240 240 240 240 240 240 240 240 240 240 216 85 73 164 212
|
||||
240 240 240 240 240 240 240 240 240 240 226 53 186 170 166 176
|
||||
240 240 240 240 240 240 240 240 240 240 180 50 217 240 120 77
|
||||
240 240 240 240 240 240 240 240 240 240 240 120 52 156 51 152
|
||||
238 240 240 240 240 240 240 240 240 240 237 237 152 125 137 230
|
||||
240 240 240 240 240 240 240 240 240 240 223 29 150 236 240 236
|
||||
236 240 240 240 240 240 240 240 240 240 232 78 5 100 99 192
|
||||
240 240 240 240 240 240 240 240 240 240 240 197 142 128 121 207
|
||||
235 240 240 240 240 240 240 240 240 186 162 168 101 92 109 156
|
||||
240 240 240 240 240 240 240 240 240 225 115 103 106 121 109 150
|
||||
234 240 240 240 240 240 240 240 240 216 206 184 184 184 210 220
|
||||
240 240 240 240 240 240 240 240 240 186 72 51 61 65 76 98
|
||||
233 240 240 240 240 240 240 240 240 240 231 213 74 219 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 240 187 51 219 240 240
|
||||
235 240 240 240 240 240 240 240 240 156 117 74 77 89 71 186
|
||||
235 229 227 240 236 234 236 232 229 225 150 150 144 117 148 140
|
||||
233 239 240 240 240 240 240 240 240 240 240 216 85 72 155 209
|
||||
240 240 240 240 240 240 240 240 240 240 226 53 186 163 153 175
|
||||
240 240 240 240 240 240 240 240 240 240 180 50 217 240 118 77
|
||||
240 240 240 240 240 240 240 240 240 240 240 120 45 155 51 152
|
||||
238 240 240 240 240 240 240 240 240 240 240 240 150 125 137 230
|
||||
240 240 240 240 240 240 240 240 240 240 225 30 151 237 232 235
|
||||
236 240 240 240 240 240 240 240 240 240 236 92 17 107 95 178
|
||||
240 240 240 240 240 240 240 240 240 240 238 200 148 128 121 206
|
||||
235 240 240 240 240 240 240 240 240 180 151 170 110 101 108 154
|
||||
240 240 240 240 240 240 240 240 240 225 115 109 106 109 85 141
|
||||
234 240 240 240 240 240 240 240 240 212 205 184 184 179 201 220
|
||||
240 240 240 240 240 240 240 240 240 182 66 47 50 58 76 98
|
||||
233 240 240 240 240 240 240 240 240 240 228 211 73 219 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 238 186 51 219 240 240
|
||||
235 240 240 240 240 240 240 240 240 156 116 84 83 98 86 189
|
||||
234 229 227 240 234 232 235 232 228 225 150 156 147 127 155 149
|
||||
|
||||
209 175 77 152 227 236 191 207 152 135 219 98 240 240 186 149
|
||||
155 161 119 51 129 240 108 122 109 98 210 76 240 240 71 149
|
||||
64 161 232 155 124 237 109 128 92 121 180 58 222 220 84 121
|
||||
83 186 217 45 150 150 5 142 101 113 184 53 78 47 63 149
|
||||
207 53 50 120 237 29 72 197 169 113 187 62 213 181 62 150
|
||||
240 226 180 237 226 223 228 238 147 115 208 75 231 238 107 150
|
||||
240 240 240 238 237 240 240 240 174 225 216 186 240 240 149 225
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 231
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227
|
||||
228 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229
|
||||
232 240 240 240 238 240 237 240 235 240 234 240 233 240 235 234
|
||||
212 176 77 152 230 236 192 207 156 150 220 98 240 240 186 140
|
||||
164 166 120 51 137 240 99 121 109 109 210 76 240 240 71 148
|
||||
73 170 240 156 125 236 100 128 92 121 184 65 219 219 89 117
|
||||
85 186 217 52 152 150 5 142 101 106 184 61 74 51 77 144
|
||||
216 53 50 120 237 29 78 197 168 103 184 51 213 187 74 150
|
||||
240 226 180 240 237 223 232 240 162 115 206 72 231 240 117 150
|
||||
240 240 240 240 240 240 240 240 186 225 216 186 240 240 156 225
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 236
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229
|
||||
240 240 240 240 238 240 236 240 235 240 234 240 233 240 235 235
|
||||
209 175 77 152 230 235 178 206 154 141 220 98 240 240 189 149
|
||||
155 153 118 51 137 232 95 121 108 85 201 76 240 240 86 155
|
||||
72 163 240 155 125 237 107 128 101 109 179 58 219 219 98 127
|
||||
85 186 217 45 150 151 17 148 110 106 184 50 73 51 83 147
|
||||
216 53 50 120 240 30 92 200 170 109 184 47 211 186 84 156
|
||||
240 226 180 240 240 225 236 238 151 115 205 66 228 238 116 150
|
||||
240 240 240 240 240 240 240 240 180 225 212 182 240 240 156 225
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 228
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 235
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 232
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 234
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 227
|
||||
239 240 240 240 240 240 240 240 240 240 240 240 240 240 240 229
|
||||
233 240 240 240 238 240 236 240 235 240 234 240 233 240 235 234
|
||||
|
||||
149 149 121 149 150 150 225 229 231 236 234 236 240 227 229 234
|
||||
186 71 84 63 62 107 149 240 240 240 240 240 240 240 240 235
|
||||
240 240 220 47 181 238 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 222 78 213 231 240 240 240 240 240 240 240 240 240 233
|
||||
98 76 58 53 62 75 186 240 240 240 240 240 240 240 240 240
|
||||
219 210 180 184 187 208 216 240 240 240 240 240 240 240 240 234
|
||||
135 98 121 113 113 115 225 240 240 240 240 240 240 240 240 240
|
||||
152 109 92 101 169 147 174 240 240 240 240 240 240 240 240 235
|
||||
207 122 128 142 197 238 240 240 240 240 240 240 240 240 240 240
|
||||
191 108 109 5 72 228 240 240 240 240 240 240 240 240 240 237
|
||||
236 240 237 150 29 223 240 240 240 240 240 240 240 240 240 240
|
||||
227 129 124 150 237 226 237 240 240 240 240 240 240 240 240 238
|
||||
152 51 155 45 120 237 238 240 240 240 240 240 240 240 240 240
|
||||
77 119 232 217 50 180 240 240 240 240 240 240 240 240 240 240
|
||||
175 161 161 186 53 226 240 240 240 240 240 240 240 240 240 240
|
||||
209 155 64 83 207 240 240 240 240 240 240 240 240 239 228 232
|
||||
140 148 117 144 150 150 225 229 232 236 234 236 240 227 229 235
|
||||
186 71 89 77 74 117 156 240 240 240 240 240 240 240 240 235
|
||||
240 240 219 51 187 240 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 219 74 213 231 240 240 240 240 240 240 240 240 240 233
|
||||
98 76 65 61 51 72 186 240 240 240 240 240 240 240 240 240
|
||||
220 210 184 184 184 206 216 240 240 240 240 240 240 240 240 234
|
||||
150 109 121 106 103 115 225 240 240 240 240 240 240 240 240 240
|
||||
156 109 92 101 168 162 186 240 240 240 240 240 240 240 240 235
|
||||
207 121 128 142 197 240 240 240 240 240 240 240 240 240 240 240
|
||||
192 99 100 5 78 232 240 240 240 240 240 240 240 240 240 236
|
||||
236 240 236 150 29 223 240 240 240 240 240 240 240 240 240 240
|
||||
230 137 125 152 237 237 240 240 240 240 240 240 240 240 240 238
|
||||
152 51 156 52 120 240 240 240 240 240 240 240 240 240 240 240
|
||||
77 120 240 217 50 180 240 240 240 240 240 240 240 240 240 240
|
||||
176 166 170 186 53 226 240 240 240 240 240 240 240 240 240 240
|
||||
212 164 73 85 216 240 240 240 240 240 240 240 240 240 240 240
|
||||
149 155 127 147 156 150 225 228 232 235 232 234 240 227 229 234
|
||||
189 86 98 83 84 116 156 240 240 240 240 240 240 240 240 235
|
||||
240 240 219 51 186 238 240 240 240 240 240 240 240 240 240 240
|
||||
240 240 219 73 211 228 240 240 240 240 240 240 240 240 240 233
|
||||
98 76 58 50 47 66 182 240 240 240 240 240 240 240 240 240
|
||||
220 201 179 184 184 205 212 240 240 240 240 240 240 240 240 234
|
||||
141 85 109 106 109 115 225 240 240 240 240 240 240 240 240 240
|
||||
154 108 101 110 170 151 180 240 240 240 240 240 240 240 240 235
|
||||
206 121 128 148 200 238 240 240 240 240 240 240 240 240 240 240
|
||||
178 95 107 17 92 236 240 240 240 240 240 240 240 240 240 236
|
||||
235 232 237 151 30 225 240 240 240 240 240 240 240 240 240 240
|
||||
230 137 125 150 240 240 240 240 240 240 240 240 240 240 240 238
|
||||
152 51 155 45 120 240 240 240 240 240 240 240 240 240 240 240
|
||||
77 118 240 217 50 180 240 240 240 240 240 240 240 240 240 240
|
||||
175 153 163 186 53 226 240 240 240 240 240 240 240 240 240 240
|
||||
209 155 72 85 216 240 240 240 240 240 240 240 240 240 239 233
|
@ -15,7 +15,7 @@
|
||||
let focalLength: number = 540 / Math.atan((70 * Math.PI) / 180);
|
||||
let fov = 75;
|
||||
//let baseHorizontalFOV: number = 2.0*Math.atan(baseAspectRation*Math.tan(baseVerticalFOV*0.5));
|
||||
|
||||
|
||||
let scene: Three.Scene = new Three.Scene();
|
||||
let camera: Three.PerspectiveCamera = new Three.PerspectiveCamera(
|
||||
75,
|
||||
|
@ -1,24 +0,0 @@
|
||||
<script context="module">
|
||||
import 'aframe';
|
||||
import '@ar-js-org/ar.js/aframe/build/aframe-ar';
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script>
|
||||
let Angle = 45;
|
||||
setInterval(() => {
|
||||
Angle++;
|
||||
}, 100);
|
||||
</script>
|
||||
-->
|
||||
|
||||
<a-scene embedded arjs>
|
||||
<a-marker preset="hiro">
|
||||
<a-entity
|
||||
position="0 0 0"
|
||||
scale="0.10 0.10 0.10"
|
||||
gltf-model="/models/dingus_the_cat.glb"
|
||||
/>
|
||||
</a-marker>
|
||||
<a-entity camera />
|
||||
</a-scene>
|
@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import ARHandler from '../components/ARHandler.svelte';
|
||||
import View3D from '../components/3DHandler.svelte';
|
||||
import Camera from '../components/CameraHandler.svelte';
|
||||
import NavBar from '../components/NavBar.svelte';
|
||||
|
||||
let containerHeight: number;
|
||||
@ -11,9 +12,8 @@
|
||||
bind:clientHeight={containerHeight}
|
||||
bind:clientWidth={containerWidth}
|
||||
>
|
||||
<ARHandler/>
|
||||
<!-- <Camera height={containerHeight} width={containerWidth} /> -->
|
||||
<!-- <View3D height={containerHeight} width={containerWidth} /> -->
|
||||
<Camera height={containerHeight} width={containerWidth} />
|
||||
<View3D height={containerHeight} width={containerWidth} />
|
||||
</div>
|
||||
<NavBar />
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@core": ["../../core/src"]
|
||||
},
|
||||
"allowJs": true
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "public/*"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user