2024-07-23 15:57:22 +03:00
|
|
|
import { IsArray } from "class-validator";
|
2024-07-13 18:18:14 +03:00
|
|
|
import { Type } from "class-transformer";
|
|
|
|
import { CameraModel } from "./camera_model";
|
|
|
|
import { SceneModelsTypes } from "./scene_models_type";
|
|
|
|
import { RobotModel } from "./robot_model";
|
|
|
|
import { SolidModel } from "./solid_model";
|
|
|
|
import { PointModel } from "./point_model";
|
|
|
|
import { ZoneModel } from "./zone_model";
|
|
|
|
import { CoreThreeRepository } from "../repository/core_three_repository";
|
|
|
|
import { LightModel } from "./light_model";
|
|
|
|
import { Vector3 } from "three";
|
2024-07-23 13:33:19 +03:00
|
|
|
import { SceneItems } from "../../features/scene_manager/presentation/scene_manager_store";
|
2024-07-13 18:18:14 +03:00
|
|
|
|
|
|
|
export abstract class Instance {
|
2024-07-23 13:33:19 +03:00
|
|
|
type: string;
|
2024-07-13 18:18:14 +03:00
|
|
|
abstract icon: string;
|
|
|
|
@Type(() => Vector3)
|
2024-07-23 15:57:22 +03:00
|
|
|
position: Vector3;
|
|
|
|
orientation: number[];
|
2024-07-13 18:18:14 +03:00
|
|
|
name: string;
|
2024-07-23 15:57:22 +03:00
|
|
|
toWebGl = (_coreThreeRepository: CoreThreeRepository) => {};
|
|
|
|
update = (_coreThreeRepository: CoreThreeRepository) => {};
|
2024-07-13 18:18:14 +03:00
|
|
|
}
|
|
|
|
export class SceneAsset {
|
2024-07-23 13:33:19 +03:00
|
|
|
name: string;
|
2024-07-13 18:18:14 +03:00
|
|
|
@IsArray()
|
|
|
|
@Type(() => Instance, {
|
|
|
|
discriminator: {
|
|
|
|
property: "type",
|
|
|
|
subTypes: [
|
|
|
|
{ value: SolidModel, name: SceneModelsTypes.SOLID },
|
|
|
|
{ value: CameraModel, name: SceneModelsTypes.CAMERA },
|
|
|
|
{ value: RobotModel, name: SceneModelsTypes.ROBOT },
|
|
|
|
{ value: PointModel, name: SceneModelsTypes.POINT },
|
|
|
|
{ value: LightModel, name: SceneModelsTypes.LIGHT },
|
|
|
|
{ value: ZoneModel, name: SceneModelsTypes.ZONE },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
keepDiscriminatorProperty: true,
|
|
|
|
})
|
|
|
|
scene: (Instance | SolidModel | CameraModel | RobotModel | PointModel | ZoneModel)[];
|
2024-07-23 13:33:19 +03:00
|
|
|
toSceneItems = (): SceneItems[] => {
|
|
|
|
return this.scene.map((el) => {
|
|
|
|
return {
|
|
|
|
fn: () => {},
|
|
|
|
name: el.name,
|
|
|
|
icon: el.icon,
|
|
|
|
isSelected: false,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
getElementByName = <T>(name: string) => this.scene.filter((el) => el.name.isEqual(name)).at(0) as T;
|
|
|
|
getAllRobotsTopics = () => this.scene.filter((el) => el.type.isEqual(SceneModelsTypes.ROBOT)).map((el) => el.name);
|
|
|
|
getAllCameraTopics = () => {};
|
|
|
|
getAllPoints = () => this.scene.filter((el) => el.type.isEqual(SceneModelsTypes.POINT)).map((el) => el.name);
|
|
|
|
static newScene = (
|
|
|
|
scene: (Instance | SolidModel | CameraModel | RobotModel | PointModel | ZoneModel)[],
|
|
|
|
name: string
|
|
|
|
) => {
|
|
|
|
const sceneAsset = new SceneAsset();
|
|
|
|
sceneAsset.scene = scene;
|
|
|
|
sceneAsset.name = name;
|
|
|
|
return sceneAsset;
|
|
|
|
};
|
2024-07-13 18:18:14 +03:00
|
|
|
}
|