AssetPoints based on type fixed, Asset Get,Create, 3d widget type updated in socket

This commit is contained in:
2025-04-03 19:51:51 +05:30
parent bc97dfa1ed
commit 7b8636c43b
14 changed files with 1648 additions and 460 deletions

View File

@@ -8,35 +8,10 @@ export interface assetData extends Document {
isLocked: boolean;
type: string;
isVisible: boolean;
isArchive:false
// 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;
}
];
}[];
}[];
isArchive: false;
points: [] | {};
position: [];
// rotation: [];
rotation: {
rotation: {
x: number;
y: number;
z: number;
@@ -44,37 +19,14 @@ export interface assetData extends Document {
speed: number | string;
}
// Define the Mongoose Schema
const assetDataSchema: Schema = new Schema({
isArchive:{type:Boolean,default:false},
isArchive: { type: Boolean, default: false },
modeluuid: { type: String },
modelfileID: { type: String },
modelname: { type: String },
type: { type: String },
// assetPosition: { type: Array },
points: [
{
uuid: { type: String },
position: { type: Array },
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 },
},
],
},
},
],
position: { type: Array},
// rotation: { type: Array},
points: { type: Schema.Types.Mixed },
position: { type: Array },
rotation: {
x: { type: Number },
y: { type: Number },
@@ -90,3 +42,96 @@ const assetModel = (db: string) => {
return MainModel(db, "Assets", assetDataSchema, "Assets");
};
export default assetModel;
// import mongoose, { Document, Schema } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// export interface assetData extends Document {
// modeluuid: string;
// modelfileID: string;
// modelname: string;
// isLocked: boolean;
// type: string;
// isVisible: boolean;
// isArchive: false;
// // 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;
// }
// ];
// }[];
// }[];
// position: [];
// // rotation: [];
// rotation: {
// x: number;
// y: number;
// z: number;
// };
// speed: number | string;
// }
// // Define the Mongoose Schema
// const assetDataSchema: Schema = new Schema({
// isArchive: { type: Boolean, default: false },
// modeluuid: { type: String },
// modelfileID: { type: String },
// modelname: { type: String },
// type: { type: String },
// // assetPosition: { type: Array },
// points: [
// {
// uuid: { type: String },
// position: { type: Array },
// 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 },
// },
// ],
// },
// },
// ],
// position: { type: Array },
// // rotation: { type: Array},
// rotation: {
// x: { type: Number },
// y: { type: Number },
// z: { type: Number },
// },
// speed: { type: Schema.Types.Mixed },
// isLocked: { type: Boolean },
// isVisible: { type: Boolean },
// });
// // export default floorItemsModel;
// const assetModel = (db: string) => {
// return MainModel(db, "Assets", assetDataSchema, "Assets");
// };
// export default assetModel;

View File

@@ -1,107 +1,410 @@
import mongoose, { Schema, Document } from "mongoose";
import MainModel from "../../../connect/mongoose.ts";
interface IAction {
uuid: string;
name: string;
type: string;
material: string;
delay: string;
spawnInterval: string;
isUsed: boolean;
hitCount: number;
start: string;
end: string;
buffer: number;
}
interface ITriggers {
// Common Interfaces
interface ITriggerConveyor {
uuid: string;
name: string;
type: string;
isUsed: boolean;
bufferTime: number;
}
interface ITriggerVehicle {
uuid: string;
name: string;
type: string;
isUsed: boolean;
}
interface IConnection {
source: { pathUUID: string; pointUUID: string };
targets: { pathUUID: string; pointUUID: string }[];
}
interface IPoint {
// Point Types
interface IPointBase {
uuid: string;
position: number[];
rotation: number[];
actions: IAction[];
triggers: ITriggers[];
connections: IConnection;
}
interface IBaseModel extends Document {
modelfileID: string;
type: "Conveyor" | "Vehicle";
points: IPoint[] | IPoint;
interface IPointConveyor extends IPointBase {
rotation: number[];
actions: Array<{
uuid: string;
name: string;
type: string;
material: string;
delay: number | string;
spawnInterval: number | string;
isUsed: boolean;
}>;
triggers: Array<{
uuid: string;
name: string;
type: string;
isUsed: boolean;
bufferTime: number;
}>;
}
// Base Schema
const PointSchema = new Schema<IPoint>({
uuid: { type: String, required: true },
position: { type: [Number] },
rotation: { type: [Number] },
actions: [
{
uuid: { type: String, default: "" },
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: [
{
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 },
},
],
},
});
interface IPointVehicle extends IPointBase {
actions: Array<{
uuid: string;
name: string;
type: string;
isUsed: boolean;
hitCount: number;
start: string;
end: string;
buffer: number;
}>;
triggers: Array<{
uuid: string;
name: string;
type: string;
isUsed: boolean;
}>;
}
const BaseSchema = new Schema<IBaseModel>(
// Main Document Interface
interface IPointModel extends Document {
modelfileID: string;
type: "Conveyor" | "Vehicle";
points: IPointConveyor[] | IPointVehicle;
isArchive: boolean;
}
// Single Schema for both types
const PointSchema = new Schema<IPointModel>(
{
modelfileID: { type: String },
type: { type: String, enum: ["Conveyor", "Vehicle"] },
type: { type: String, enum: ["Conveyor", "Vehicle"], required: true },
isArchive: { type: Boolean, default: false },
points: {
type: Schema.Types.Mixed,
type: Schema.Types.Mixed, // Flexible structure based on type
required: true,
},
},
{ discriminatorKey: "type", timestamps: true }
{ timestamps: true }
);
// Model Creation
const pointModel = (db: string) => {
return MainModel(db, "Points", BaseSchema, "Points");
return MainModel(db, "Points", PointSchema, "Points"); // Single collection
};
export default pointModel;
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// import mongoose, { Schema, Document } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// interface IActionConveyor {
// uuid: string;
// name: string;
// type: string;
// material: string;
// delay: number | string;
// spawnInterval: number | string;
// spawnMaterial: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// 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 IActionVehicle {
// uuid: string;
// name: string;
// type: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// interface IPointConveyor {
// uuid: string;
// position: number[];
// rotation: number[];
// actions: IActionConveyor[];
// triggers: ITriggers[];
// connections: IConnection;
// }
// interface IPointVehicle {
// uuid: string;
// position: number[];
// actions: IActionVehicle[];
// triggers: ITriggers[];
// connections: IConnection;
// }
// interface IBaseModel extends Document {
// modelfileID: string;
// type: "Conveyor" | "Vehicle";
// points: IPointConveyor[] | IPointVehicle;
// }
// const PointconveyorSchema = new Schema<IPointConveyor>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// rotation: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// material: { type: String },
// delay: { type: Schema.Types.Mixed },
// spawnInterval: { type: Schema.Types.Mixed },
// spawnMaterial: { type: String },
// isUsed: { type: Boolean },
// },
// ],
// 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 PointvehicleSchema = new Schema<IPointVehicle>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// isUsed: { type: Boolean },
// hitCount: { type: String },
// start: { type: String },
// end: { type: String },
// buffer: { type: String },
// },
// ],
// 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>(
// {
// modelfileID: { type: String },
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
// points: {
// type: Schema.Types.Mixed,
// required: true,
// },
// },
// { discriminatorKey: "type", timestamps: true }
// );
// const pointModel = (db: string) => {
// const BasePointModel = MainModel(db, "Points", BaseSchema, "Points");
// const ConveyorModel = BasePointModel.discriminator(
// "Conveyor",
// new Schema({
// points: [PointconveyorSchema],
// })
// );
// const VehicleModel = BasePointModel.discriminator(
// "Vehicle",
// new Schema({
// points: PointvehicleSchema,
// })
// );
// return { ConveyorModel, VehicleModel };
// };
// export default pointModel;
// ===
// const pointModel = (db: string) => {
// const BasePointModel =
// mongoose.models.Points || MainModel(db, "Points", BaseSchema, "Points");
// if (!BasePointModel.discriminators?.Conveyor) {
// BasePointModel.discriminator(
// "Conveyor",
// new Schema({
// points: [PointconveyorSchema],
// })
// );
// }
// if (!BasePointModel.discriminators?.Vehicle) {
// BasePointModel.discriminator(
// "Vehicle",
// new Schema({
// points: PointvehicleSchema,
// })
// );
// }
// const ConveyorModel =
// mongoose.models.Conveyor || BasePointModel.discriminators?.Conveyor;
// const VehicleModel =
// mongoose.models.Vehicle || BasePointModel.discriminators?.Vehicle;
// return { ConveyorModel, VehicleModel, BasePointModel };
// };
// export default pointModel;
// ===========================================
// ===
// import mongoose, { Schema, Document } from "mongoose";
// import MainModel from "../../../connect/mongoose.ts";
// interface IAction {
// uuid: string;
// name: string;
// type: string;
// material: string;
// delay: number | string;
// spawnInterval: number | string;
// spawnMaterial: string;
// isUsed: boolean;
// hitCount: number;
// start: string;
// end: string;
// buffer: number;
// }
// 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: ITriggers[];
// connections: IConnection;
// }
// interface IBaseModel extends Document {
// modelfileID: string;
// type: "Conveyor" | "Vehicle";
// points: IPoint[] | IPoint;
// }
// const PointSchema = new Schema<IPoint>({
// uuid: { type: String, required: true },
// position: { type: [Number] },
// rotation: { type: [Number] },
// actions: [
// {
// uuid: { type: String, default: "" },
// name: { type: String },
// type: { type: String },
// material: { type: String },
// delay: { type: String },
// spawnInterval: { type: String },
// spawnMaterial: { type: String },
// isUsed: { type: Boolean },
// hitCount: { type: String },
// start: { type: String },
// end: { type: String },
// buffer: { type: String },
// },
// ],
// 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 },
// },
// ],
// },
// });
// // Base Schema
// const BaseSchema = new Schema<IBaseModel>(
// {
// modelfileID: { type: String },
// type: { type: String, enum: ["Conveyor", "Vehicle"] },
// points: {
// type: Schema.Types.Mixed,
// required: true,
// },
// },
// { discriminatorKey: "type", timestamps: true }
// );
// const pointModel = (db: string) => {
// return MainModel(db, "Points", BaseSchema, "Points");
// };
// export default pointModel;

View File

@@ -16,7 +16,7 @@ const environmentSchema: Schema = new Schema({
roofVisibility: { type: Boolean, default: false },
wallVisibility: { type: Boolean, default: false },
shadowVisibility: { type: Boolean, default: false },
renderDistance: { type: Number, default: false },
renderDistance: { type: Number, default: 40 },
limitDistance: { type: Boolean, default: true },
});

View File

@@ -13,6 +13,7 @@ export interface Action extends Document {
material: string;
delay: string;
spawnInterval: string;
spawnMaterial: string;
isUsed: boolean;
hitCount: number;
start: string;
@@ -31,6 +32,7 @@ const actionSchema: Schema = new Schema(
material: { type: String },
delay: { type: String },
spawnInterval: { type: String },
spawnMaterial: { type: String },
isUsed: { type: Boolean },
hitCount: { type: String },
start: { type: String },

View File

@@ -0,0 +1,97 @@
// import mongoose, { Schema, Document, model } from "mongoose";
// import MainModel from "../../connect/mongoose.ts";
// export interface ProductFlow extends Document {
// productName: string;
// ProductData: [
// {
// AssetName: string;
// Assetuuid: string;
// paths: {
// Points: [
// {
// pointuuid: string;
// actions: [mongoose.Types.ObjectId];
// triggers: [mongoose.Types.ObjectId];
// position: [];
// rotation: [number];
// connections: {
// source: {
// // pathUUID: { type: String };
// pointUUID: string;
// };
// targets: [
// {
// // pathUUID: { type: String };
// pointUUID: string;
// }
// ];
// };
// }
// ];
// // endPoint: {
// // pointuuid: string;
// // actions: [mongoose.Types.ObjectId];
// // triggers: [mongoose.Types.ObjectId];
// // position: [];
// // rotation: [];
// // };
// };
// isArchive: false;
// }
// ];
// isArchive: false;
// }
// const productFlowSchema: Schema = new Schema(
// {
// productName: { type: String },
// ProductData: [
// {
// AssetName: { type: String },
// Assetuuid: { type: String },
// paths: {
// Points: [
// {
// pointuuid: { type: String },
// 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 },
// },
// ],
// },
// position: { type: Array },
// rotation: {
// type: [Number],
// validate: {
// validator: function (value: number[]) {
// return value && value.length > 0; // Ensures it's only stored if it has values
// },
// message: "Rotation array should not be empty",
// },
// },
// },
// ],
// },
// isArchive: { type: Boolean, default: false },
// },
// ],
// },
// { timestamps: true }
// );
// const productFlowModel = (db: any) => {
// return MainModel(db, "ProductFlow", productFlowSchema, "ProductFlow");
// };
// export default productFlowModel;