Visualization Part 2d and floating API Completed. Template Save and Get API completed
This commit is contained in:
@@ -1,44 +1,41 @@
|
||||
import mongoose, { Document, Schema } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
interface IAction {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
material: string;
|
||||
delay: string;
|
||||
spawnInterval: string;
|
||||
isUsed: boolean;
|
||||
}
|
||||
|
||||
// Interface for TypeScript with PascalCase
|
||||
export interface assetData extends Document {
|
||||
modeluuid: string;
|
||||
modelfileID: string;
|
||||
modelname: string;
|
||||
isLocked: boolean;
|
||||
type: string;
|
||||
isVisible: boolean;
|
||||
position: [];
|
||||
rotation: {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
};
|
||||
points: [
|
||||
{
|
||||
uuid: string;
|
||||
position: [];
|
||||
rotation: [];
|
||||
actions: [mongoose.Types.ObjectId];
|
||||
triggers: [mongoose.Types.ObjectId];
|
||||
// connections:{
|
||||
// source:{
|
||||
// pathuuid:string,pointuuid:string
|
||||
// },
|
||||
// target:[]
|
||||
// }
|
||||
}
|
||||
];
|
||||
// position: [];
|
||||
// rotation: {
|
||||
// x: number;
|
||||
// y: number;
|
||||
// z: number;
|
||||
// };
|
||||
points: {
|
||||
uuid: string;
|
||||
position: [];
|
||||
rotation: [];
|
||||
actions: [mongoose.Types.ObjectId];
|
||||
triggers: [mongoose.Types.ObjectId];
|
||||
connections: {
|
||||
source: {
|
||||
pathUUID: string;
|
||||
pointUUID: string;
|
||||
};
|
||||
targets: [
|
||||
{
|
||||
pathUUID: string;
|
||||
pointUUID: string;
|
||||
}
|
||||
];
|
||||
}[];
|
||||
}[];
|
||||
assetPosition: number[];
|
||||
assetRotation: number[];
|
||||
speed: number;
|
||||
}
|
||||
|
||||
// Define the Mongoose Schema
|
||||
@@ -46,7 +43,8 @@ const assetDataSchema: Schema = new Schema({
|
||||
modeluuid: { type: String },
|
||||
modelfileID: { type: String },
|
||||
modelname: { type: String },
|
||||
position: { type: Array },
|
||||
type: { type: String },
|
||||
// assetPosition: { type: Array },
|
||||
points: [
|
||||
{
|
||||
uuid: { type: String },
|
||||
@@ -54,15 +52,30 @@ const assetDataSchema: Schema = new Schema({
|
||||
rotation: { type: Array },
|
||||
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
|
||||
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
|
||||
connections: {
|
||||
source: {
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
assetPosition: { type: [Number] },
|
||||
assetRotation: { type: [Number] },
|
||||
speed: { type: Number },
|
||||
isLocked: { type: Boolean },
|
||||
isVisible: { type: Boolean },
|
||||
rotation: {
|
||||
x: { type: Number },
|
||||
y: { type: Number },
|
||||
z: { type: Number },
|
||||
},
|
||||
// rotation: {
|
||||
// x: { type: Number },
|
||||
// y: { type: Number },
|
||||
// z: { type: Number },
|
||||
// },
|
||||
});
|
||||
|
||||
// export default floorItemsModel;
|
||||
|
||||
@@ -9,53 +9,81 @@ interface IAction {
|
||||
delay: string;
|
||||
spawnInterval: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
buffer: number;
|
||||
}
|
||||
|
||||
// interface IConnection {
|
||||
// source: { pathUUID: string; pointUUID: string };
|
||||
// targets: string[];
|
||||
// }
|
||||
interface ITriggers {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPoint {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
rotation: number[];
|
||||
actions: IAction[];
|
||||
triggers: string[];
|
||||
// connections: IConnection;
|
||||
triggers: ITriggers[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IBaseModel extends Document {
|
||||
modelfileID: string;
|
||||
type: "Conveyor" | "Vehicle";
|
||||
points: IPoint[] | IPoint;
|
||||
speed: number;
|
||||
}
|
||||
|
||||
// Base Schema
|
||||
const PointSchema = new Schema<IPoint>({
|
||||
uuid: { type: String, required: true },
|
||||
position: { type: [Number], required: true },
|
||||
rotation: { type: [Number], required: true },
|
||||
position: { type: [Number] },
|
||||
rotation: { type: [Number] },
|
||||
actions: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String, required: true },
|
||||
type: { type: String, required: true },
|
||||
material: { type: String, required: true },
|
||||
delay: { type: String, required: true },
|
||||
spawnInterval: { type: String, required: true },
|
||||
isUsed: { type: Boolean, required: true },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
material: { type: String },
|
||||
delay: { type: String },
|
||||
spawnInterval: { type: String },
|
||||
isUsed: { type: Boolean },
|
||||
hitCount: { type: String },
|
||||
start: { type: String },
|
||||
end: { type: String },
|
||||
buffer: { type: String },
|
||||
},
|
||||
],
|
||||
triggers: { type: [String], default: [] },
|
||||
// connections: {
|
||||
// source: {
|
||||
// pathUUID: { type: String, required: true },
|
||||
// pointUUID: { type: String, required: true },
|
||||
// },
|
||||
// targets: { type: [String], default: [] },
|
||||
// },
|
||||
triggers: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
bufferTime: { type: Number },
|
||||
isUsed: { type: Boolean },
|
||||
},
|
||||
],
|
||||
connections: {
|
||||
source: {
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const BaseSchema = new Schema<IBaseModel>(
|
||||
@@ -66,7 +94,6 @@ const BaseSchema = new Schema<IBaseModel>(
|
||||
type: Schema.Types.Mixed,
|
||||
required: true,
|
||||
},
|
||||
speed: { type: Number },
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user