details preview
This commit is contained in:
parent
81238c5182
commit
0a4eea19c5
39 changed files with 242 additions and 286 deletions
|
@ -6,7 +6,6 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].equals === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.equals = function (array, strict = true) {
|
||||
if (!array) return false;
|
||||
|
||||
|
@ -27,7 +26,6 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].lastElement === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.lastElement = function () {
|
||||
const instanceCheck = this;
|
||||
if (instanceCheck === undefined) {
|
||||
|
@ -39,7 +37,6 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
export const StringExtensions = () => {
|
||||
if ("".isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
|
@ -11,7 +10,6 @@ export const StringExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ("".isNotEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.isNotEmpty = function () {
|
||||
return this.length !== 0;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ export interface Parts {
|
|||
name: string;
|
||||
part_path: string;
|
||||
material_path: string;
|
||||
httpUrl?: string;
|
||||
stlUrl?: string;
|
||||
}
|
||||
export class RobossemblerAssetsNetworkMapperScenario extends CallbackStrategyWithEmpty {
|
||||
call = async (): ResponseBase => (await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, 'is dont active projects')).map((projectModel) => {
|
||||
|
@ -22,8 +22,7 @@ export class RobossemblerAssetsNetworkMapperScenario extends CallbackStrategyWit
|
|||
).map((model) => {
|
||||
|
||||
model.map((el) => {
|
||||
el.httpUrl = address + '/' + rootDir.match(new RegExp(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gm))[0] + '/assets/libs/objects/' + el.name + '.glb'
|
||||
// server/build/public/0ddbb777-8002-4424-a3b0-d869783cca97/assets/libs/objects/planet_gear.glb
|
||||
el.stlUrl = address + '/' + rootDir.match(new RegExp(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gm))[0] + '/assets/' + el.part_path
|
||||
return el
|
||||
})
|
||||
return Result.ok(model);
|
||||
|
|
34
ui/package-lock.json
generated
34
ui/package-lock.json
generated
|
@ -50,6 +50,7 @@
|
|||
"sass": "^1.66.1",
|
||||
"serve": "^14.2.1",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"source-map-loader": "^5.0.0",
|
||||
"styled-components": "^6.1.8",
|
||||
"three": "^0.165.0",
|
||||
"three-stdlib": "^2.28.9",
|
||||
|
@ -14874,6 +14875,26 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-scripts/node_modules/source-map-loader": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-3.0.2.tgz",
|
||||
"integrity": "sha512-BokxPoLjyl3iOrgkWaakaxqnelAJSS+0V+De0kKIq6lyWrXuiPgYTGp6z3iHmqljKAaLXwZa+ctD8GccRJeVvg==",
|
||||
"dependencies": {
|
||||
"abab": "^2.0.5",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"source-map-js": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/webpack"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"webpack": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read-cache": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||
|
@ -15994,23 +16015,22 @@
|
|||
}
|
||||
},
|
||||
"node_modules/source-map-loader": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-3.0.2.tgz",
|
||||
"integrity": "sha512-BokxPoLjyl3iOrgkWaakaxqnelAJSS+0V+De0kKIq6lyWrXuiPgYTGp6z3iHmqljKAaLXwZa+ctD8GccRJeVvg==",
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-5.0.0.tgz",
|
||||
"integrity": "sha512-k2Dur7CbSLcAH73sBcIkV5xjPV4SzqO1NJ7+XaQl8if3VODDUj3FNchNGpqgJSKbvUfJuhVdv8K2Eu8/TNl2eA==",
|
||||
"dependencies": {
|
||||
"abab": "^2.0.5",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"source-map-js": "^1.0.1"
|
||||
"source-map-js": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.13.0"
|
||||
"node": ">= 18.12.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/webpack"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"webpack": "^5.0.0"
|
||||
"webpack": "^5.72.1"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-support": {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"sass": "^1.66.1",
|
||||
"serve": "^14.2.1",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"source-map-loader": "^5.0.0",
|
||||
"styled-components": "^6.1.8",
|
||||
"three": "^0.165.0",
|
||||
"three-stdlib": "^2.28.9",
|
||||
|
@ -59,7 +60,7 @@
|
|||
"xml-formatter": "^3.6.2"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "GENERATE_SOURCEMAP=false && react-scripts start",
|
||||
"dev": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
|
@ -67,9 +68,7 @@
|
|||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
"react-app" ]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
|
|
@ -3,7 +3,6 @@ import { Result } from "../helper/result";
|
|||
/* eslint-disable @typescript-eslint/no-this-alias */
|
||||
export const ArrayExtensions = () => {
|
||||
if ([].equals === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.equals = function (array, strict = true) {
|
||||
if (!array) return false;
|
||||
|
||||
|
@ -24,7 +23,6 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].lastElement === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.lastElement = function () {
|
||||
const instanceCheck = this;
|
||||
if (instanceCheck === undefined) {
|
||||
|
@ -36,31 +34,26 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
}
|
||||
if ([].isNotEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.isNotEmpty = function () {
|
||||
return this.length !== 0;
|
||||
};
|
||||
}
|
||||
if ([].hasIncludeElement === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.hasIncludeElement = function (element) {
|
||||
return this.indexOf(element) !== -1;
|
||||
};
|
||||
}
|
||||
if ([].repeat === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.repeat = function (quantity) {
|
||||
return Array(quantity).fill(this).flat(1);
|
||||
};
|
||||
}
|
||||
if ([].rFind === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.rFind = function (predicate) {
|
||||
const result = this.find(predicate as any);
|
||||
if (result === undefined) {
|
||||
|
@ -70,7 +63,6 @@ export const ArrayExtensions = () => {
|
|||
};
|
||||
}
|
||||
if ([].maxLength === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.maxLength = function (length) {
|
||||
if (this.length > length) {
|
||||
return this;
|
||||
|
|
|
@ -42,6 +42,7 @@ declare global {
|
|||
isEqualMany(str: string[]): boolean;
|
||||
hasPattern(pattern: string): boolean;
|
||||
hasNoPattern(pattern: string): boolean;
|
||||
divideByIndex(index: number): string[]
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
export const MapExtensions = () => {
|
||||
if (Map.prototype.addValueOrMakeCallback === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.addValueOrMakeCallback = function (key, value, fn) {
|
||||
if (this.has(key)) {
|
||||
this.set(key, value);
|
||||
|
@ -12,7 +11,6 @@ export const MapExtensions = () => {
|
|||
};
|
||||
}
|
||||
if (Map.prototype.getKeyFromValueIsExists === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.getKeyFromValueIsExists = function (value) {
|
||||
let result;
|
||||
this.forEach((el, key) => {
|
||||
|
@ -24,7 +22,6 @@ export const MapExtensions = () => {
|
|||
};
|
||||
}
|
||||
if (Map.prototype.overrideValue === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.overrideValue = function (key, value) {
|
||||
const result = this.get(key);
|
||||
|
||||
|
@ -32,7 +29,6 @@ export const MapExtensions = () => {
|
|||
};
|
||||
}
|
||||
if (Map.prototype.keysToJson === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.keysToJson = function () {
|
||||
const result: any[] = [];
|
||||
this.forEach((el) => result.push(el));
|
||||
|
@ -40,13 +36,11 @@ export const MapExtensions = () => {
|
|||
};
|
||||
}
|
||||
if (Map.prototype.toArray === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.toArray = function () {
|
||||
return Array.from(this.values());
|
||||
};
|
||||
}
|
||||
if (Map.prototype.getPredicateValue === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.getPredicateValue = function (callBack) {
|
||||
const result: any[] = [];
|
||||
this.forEach((el, key) => {
|
||||
|
@ -59,7 +53,6 @@ export const MapExtensions = () => {
|
|||
};
|
||||
}
|
||||
if (Map.prototype.incrementValue === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Map.prototype.incrementValue = function (key) {
|
||||
if (this.get(key)) {
|
||||
this.set(key, this.get(key) + 1);
|
||||
|
|
|
@ -1,45 +1,39 @@
|
|||
export const NumberExtensions = () => {
|
||||
if (Number().fromArray === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.fromArray = function () {
|
||||
return Array.from(this.toString()).map((el) => Number(el));
|
||||
};
|
||||
}
|
||||
if (Number().toPx === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.toPx = function () {
|
||||
return String(this) + "px";
|
||||
};
|
||||
}
|
||||
if (Number().unixFromDate === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.unixFromDate = function () {
|
||||
const date = new Date(Number(this) * 1000);
|
||||
return `${date.getUTCFullYear()}.${date.getMonth()}.${date.getDay()} ${date.getHours()}:${date.getMinutes()}`;
|
||||
};
|
||||
}
|
||||
if (Number().isValid === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.isValid = function (str: string) {
|
||||
return !isNaN(Number(str));
|
||||
};
|
||||
}
|
||||
if (Number().randRange === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.randRange = function (min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
};
|
||||
}
|
||||
if (Number().isPositive === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.isPositive = function () {
|
||||
return Math.sign(Number(this)) === 1;
|
||||
};
|
||||
}
|
||||
if(Number().isNegative === undefined){
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Number.prototype.isNegative = function (){
|
||||
return !this.isPositive()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
/* eslint-disable no-extend-native */
|
||||
export const StringExtensions = () => {
|
||||
if ("".isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
}
|
||||
if ("".isNotEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.isNotEmpty = function () {
|
||||
return this.length !== 0;
|
||||
};
|
||||
|
@ -46,4 +44,13 @@ export const StringExtensions = () => {
|
|||
return !this.hasPattern(pattern);
|
||||
};
|
||||
}
|
||||
if (''.divideByIndex === undefined) {
|
||||
String.prototype.divideByIndex = function (index) {
|
||||
if (this.at(index) === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [this.slice(0, index), this.slice(index+1, this.length)]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -40,3 +40,5 @@ export class TypedEvent<T> {
|
|||
return this.on((e) => te.emit(e));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,37 +1,36 @@
|
|||
import { Scene, Engine, MeshBuilder, FreeCamera, HemisphericLight, Vector3, SceneLoader } from 'babylonjs';
|
||||
import { GLTFFileLoader, STLFileLoader } from 'babylonjs-loaders';
|
||||
import { GLTFFileLoader } from 'babylonjs-loaders';
|
||||
|
||||
|
||||
export class BabylonRepository {
|
||||
engine: Engine;
|
||||
canvas: HTMLCanvasElement;
|
||||
scene: Scene;
|
||||
sceneLoader: SceneLoader
|
||||
constructor(canvas: HTMLCanvasElement) {
|
||||
this.sceneLoader = new SceneLoader();
|
||||
this.engine = new Engine(canvas, true);
|
||||
this.scene = this.CreateScene();
|
||||
this.scene = new Scene(this.engine);
|
||||
this.engine.runRenderLoop(() => {
|
||||
this.scene.render();
|
||||
});
|
||||
const Camera = new FreeCamera("camera", new Vector3(0, 1, -5), this.scene);
|
||||
Camera.attachControl();
|
||||
const light = new HemisphericLight("light", new Vector3(0, 1, 0), this.scene);
|
||||
light.intensity = 0.5;
|
||||
//3D Object
|
||||
// const ground = MeshBuilder.CreateGround("ground", { width: 10, height: 10 }, this.scene);
|
||||
// const sphereball = MeshBuilder.CreateSphere("sphereball", { diameter: 1 }, this.scene);
|
||||
// sphereball.position = new Vector3(0, 1, 0)
|
||||
|
||||
this.scene.createDefaultCameraOrLight(true, true, true);
|
||||
new HemisphericLight("hemiLight", new Vector3(0, 1, 0));
|
||||
SceneLoader.RegisterPlugin(new GLTFFileLoader())
|
||||
SceneLoader.RegisterPlugin(new STLFileLoader());
|
||||
SceneLoader.ImportMeshAsync("",
|
||||
"http://localhost:4001/1dfc4e1a-9c1a-4fa2-96b2-19c86acb6ea4/assets/libs/objects/",
|
||||
"sol_gear.glb", this.scene)
|
||||
|
||||
}
|
||||
CreateScene(): Scene {
|
||||
const scene = new Scene(this.engine);
|
||||
return scene;
|
||||
}
|
||||
load = (url: string) => {
|
||||
deleteAllObjectsScene = () => this.scene.meshes.forEach((el) => this.scene.removeMesh(el, true))
|
||||
|
||||
SceneLoader.LoadAssetContainer(url)
|
||||
loadHttp = (url: string) => {
|
||||
const divide = url.divideByIndex(url.lastIndexOf('/'))
|
||||
|
||||
SceneLoader.ImportMeshAsync("",
|
||||
`${divide.at(0)}/`,
|
||||
`${divide.at(1)}`, this.scene).then((frame) => {
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -20,9 +20,7 @@ import {
|
|||
CameraHelper,
|
||||
Quaternion,
|
||||
MeshBasicMaterial,
|
||||
PlaneGeometry,
|
||||
BoxGeometry,
|
||||
AxesHelper,
|
||||
MeshStandardMaterial
|
||||
} from "three";
|
||||
import { TypedEvent } from "../helper/typed_event";
|
||||
|
@ -37,8 +35,9 @@ import { SceneMode } from "../../features/scene_manager/model/scene_view";
|
|||
import { throttle } from "../helper/throttle";
|
||||
import { Asset, InstanceRgbCamera, RobossemblerAssets, SceneSimpleObject } from "../model/robossembler_assets";
|
||||
import { LoadingManager } from 'three';
|
||||
import URDFLoader, { URDFLink } from 'urdf-loader';
|
||||
import { UrdfTransforms, coordsToQuaternion } from "../../features/simulations/tranforms_model";
|
||||
import URDFLoader, { URDFLink } from 'urdf-loader';
|
||||
|
||||
|
||||
Object3D.DEFAULT_UP = new Vector3(0, 0, 1);
|
||||
|
||||
|
@ -46,6 +45,7 @@ export enum UserData {
|
|||
selectedObject = "selected_object",
|
||||
cameraInitialization = "camera_initialization",
|
||||
objectForMagnetism = "object_for_magnetism",
|
||||
loadObject = 'load_object'
|
||||
}
|
||||
|
||||
interface IEventDraggingChange {
|
||||
|
@ -104,16 +104,26 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
|
||||
this.scene.add(this.transformControls);
|
||||
this.orbitControls = new OrbitControls(this.camera, this.htmlCanvasRef);
|
||||
this.scene.background = new Color("black");
|
||||
this.scene.background = new Color("white");
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
deleteAllObjectsScene = () => {
|
||||
|
||||
|
||||
this.getAllSceneNameModels().forEach((el) => this.scene.remove(this.scene.getObjectByName(el) as Object3D<Object3DEventMap>))
|
||||
}
|
||||
|
||||
drawPoint(point: Vector3): Mesh<BoxGeometry, MeshBasicMaterial, Object3DEventMap> {
|
||||
var cube = new Mesh(new BoxGeometry(0.5, 0.5, 0.5), new MeshBasicMaterial({ color: 0x0095dd }));
|
||||
cube.position.add(point);
|
||||
this.scene.add(cube);
|
||||
return cube;
|
||||
}
|
||||
getCenterPoint = (object: Object3D<Object3DEventMap>) => object.getWorldPosition(new Box3().setFromObject(object).getCenter(object.position));
|
||||
|
||||
|
||||
makeCube(inc: number, vector?: Vector3, color?: string, size?: number) {
|
||||
const cube = new Mesh(
|
||||
new BoxGeometry(size ?? 10, size ?? 10, size ?? 10),
|
||||
|
@ -128,6 +138,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
}
|
||||
this.scene.add(cube);
|
||||
}
|
||||
|
||||
makePoint(vector?: Vector3, color?: string, size?: number) {
|
||||
const cube = new Mesh(
|
||||
new BoxGeometry(size ?? 10, size ?? 10, size ?? 10),
|
||||
|
@ -152,7 +163,6 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
robot => {
|
||||
|
||||
this.scene.add(robot)
|
||||
console.log(robot)
|
||||
// @ts-expect-error
|
||||
this.sceneFrame = robot.frames
|
||||
|
||||
|
@ -188,14 +198,18 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
new Quaternion(0, 0, 0, 0)
|
||||
);
|
||||
}
|
||||
load(path: string, name: string, loadCallback?: Function) {
|
||||
loadHttpAndPreview(path: string, name: string, loadCallback?: Function) {
|
||||
|
||||
this.loader(
|
||||
'http://localhost:4001/1dfc4e1a-9c1a-4fa2-96b2-19c86acb6ea4/assets/libs/objects/untitled.glb',
|
||||
loadCallback ? loadCallback : () => { },
|
||||
path,
|
||||
() => {
|
||||
// this.fitCameraToCenteredObject([name])
|
||||
// this.scene.getObjectByName(name)
|
||||
},
|
||||
name,
|
||||
|
||||
new Vector3(0, 0, 0)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
setTransformMode(mode?: SceneMode) {
|
||||
|
@ -324,6 +338,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
floor.userData = {};
|
||||
floor.userData[UserData.cameraInitialization] = true;
|
||||
floor.up.copy(new Vector3(0, 0, 1))
|
||||
|
||||
this.scene.add(floor);
|
||||
}
|
||||
|
||||
|
@ -351,7 +366,6 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
|
||||
loader(url: string, callBack: Function, name: string, position?: Vector3, quaternion?: Quaternion) {
|
||||
const ext = url.split(/\./g).pop()!.toLowerCase();
|
||||
|
||||
switch (ext) {
|
||||
case "gltf":
|
||||
case "glb":
|
||||
|
@ -359,7 +373,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
url,
|
||||
(result) => {
|
||||
this.scene.add(result.scene)
|
||||
|
||||
callBack()
|
||||
},
|
||||
(err) => { }
|
||||
);
|
||||
|
@ -378,6 +392,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
|
||||
this.emit(new StaticAssetItemModel(el.name, el.position, el.quaternion));
|
||||
this.scene.add(el);
|
||||
callBack()
|
||||
});
|
||||
},
|
||||
(err) => { }
|
||||
|
@ -396,6 +411,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
this.stlLoader.load(
|
||||
url,
|
||||
(result) => {
|
||||
|
||||
const material = new MeshStandardMaterial({
|
||||
color: 'red',
|
||||
metalness: 0.35,
|
||||
|
@ -404,9 +420,20 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
transparent: false,
|
||||
});
|
||||
|
||||
const mesh = new Mesh(result, material);
|
||||
this.scene.add(mesh);
|
||||
|
||||
const mesh = new Mesh(result, material);
|
||||
mesh.name = name;
|
||||
|
||||
|
||||
|
||||
|
||||
// var geometry = mesh.geometry;
|
||||
// geometry.computeBoundingBox(); // Вычисляем ограничивающий параллелепипед для геометрии
|
||||
|
||||
if (position) mesh.position.copy(position)
|
||||
|
||||
this.scene.add(mesh);
|
||||
callBack()
|
||||
},
|
||||
|
||||
(err) => { }
|
||||
|
@ -500,8 +527,7 @@ export class CoreThreeRepository extends TypedEvent<BaseSceneItemModel> {
|
|||
urdfTransforms.transforms.forEach((transform) => {
|
||||
if (this.sceneFrame) {
|
||||
const currentLink = this.sceneFrame[transform?.child_frame_id ?? ""]
|
||||
const currentLinkParrent = this.sceneFrame[transform?.header.frame_id ?? ""]
|
||||
// currentLink.position.copy(coordsToVector(transform.transform.translation))
|
||||
|
||||
currentLink.quaternion.copy(coordsToQuaternion(transform.transform.rotation))
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { ClassConstructor, plainToInstance } from "class-transformer";
|
||||
import { Result } from "../helper/result";
|
||||
import { Parts } from "../../features/details/details_http_repository";
|
||||
import { UUID } from "../../features/all_projects/data/project_repository";
|
||||
|
||||
export enum HttpMethod {
|
||||
GET = "GET",
|
||||
|
@ -16,7 +18,6 @@ export class HttpError extends Error {
|
|||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
export class HttpRepository {
|
||||
private server = "http://localhost:4001";
|
||||
public async _formDataRequest<T>(method: HttpMethod, url: string, data?: any): Promise<Result<HttpError, T>> {
|
||||
|
@ -96,5 +97,13 @@ export class HttpRepository {
|
|||
return Result.error(new HttpError(error, 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class CoreHttpRepository extends HttpRepository {
|
||||
getAssetsActiveProject = async (): Promise<Result<HttpError, Parts[]>> => {
|
||||
return this._jsonRequest<Parts[]>(HttpMethod.GET, "/projects/assets");
|
||||
};
|
||||
async getActiveProjectId() {
|
||||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -35,7 +35,9 @@ const Block = (props: IBlockProps) => {
|
|||
alignContent: "center",
|
||||
borderRadius: 12,
|
||||
}
|
||||
: { textAlignLast: "center", alignContent: "center" }
|
||||
: {
|
||||
textAlignLast: "center", alignContent: "center", height: 32,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Icon type={props.icon ?? ""} />
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
import { HttpMethod, HttpRepository } from "../../../core/repository/http_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../../core/repository/http_repository";
|
||||
import { IProjectModel } from "../model/project_model";
|
||||
|
||||
export interface UUID {
|
||||
id: string;
|
||||
}
|
||||
export class ProjectRepository extends HttpRepository {
|
||||
export class ProjectRepository extends CoreHttpRepository {
|
||||
async getAllProject() {
|
||||
return this._jsonRequest<IProjectModel[]>(HttpMethod.GET, "/projects");
|
||||
}
|
||||
|
||||
async getActivePipeline() {
|
||||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
|
||||
async setActivePipeline(id: string) {
|
||||
return this._jsonRequest(HttpMethod.POST, `/projects/set/active/project?id=${id}`);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ export class AllProjectStore extends SimpleErrorState {
|
|||
await this.mapOk<IProjectModel[]>("projectsModels", this.repository.getAllProject());
|
||||
}
|
||||
async getActiveProjectId(): Promise<void> {
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActivePipeline());
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActiveProjectId());
|
||||
}
|
||||
setActiveProject = async (id: string) => {
|
||||
await this.messageHttp(this.repository.setActivePipeline(id), { successMessage: "проект активирован", errorMessage: 'ошибка активации' })
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActivePipeline());
|
||||
await this.mapOk<UUID>("activeProjectId", this.repository.getActiveProjectId());
|
||||
await this.mapOk<IProjectModel[]>("projectsModels", this.repository.getAllProject());
|
||||
}
|
||||
async init() {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Result } from "../../../core/helper/result";
|
||||
import { Skills } from "../../../core/model/skill_model";
|
||||
import { HttpError, HttpMethod, HttpRepository } from "../../../core/repository/http_repository";
|
||||
import { HttpError, HttpMethod, CoreHttpRepository } from "../../../core/repository/http_repository";
|
||||
import { UUID } from "../../all_projects/data/project_repository";
|
||||
import { BehaviorTreeModel } from "../model/behavior_tree_model";
|
||||
import { BehaviorTreeViewModel } from "../model/behavior_tree_view_model";
|
||||
|
||||
export class BehaviorTreeBuilderHttpRepository extends HttpRepository {
|
||||
export class BehaviorTreeBuilderHttpRepository extends CoreHttpRepository {
|
||||
getAllBtInstances = async () => this._jsonRequest<BehaviorTreeModel[]>(HttpMethod.GET, "/behavior/trees");
|
||||
getBtSkills = async (): Promise<Result<HttpError, Skills>> => {
|
||||
return (await this._jsonToClassInstanceRequest<Skills>(
|
||||
|
@ -21,9 +21,7 @@ export class BehaviorTreeBuilderHttpRepository extends HttpRepository {
|
|||
`/behavior/trees/by_id?id=${id}`,
|
||||
BehaviorTreeModel
|
||||
) as unknown as Promise<Result<HttpError, BehaviorTreeModel>>;
|
||||
getActiveProjectId(): Promise<Result<HttpError, UUID>> {
|
||||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
|
||||
editBt = async (model: BehaviorTreeModel) => {
|
||||
await this._jsonRequest(HttpMethod.POST, "/behavior/trees/fill/tree", model);
|
||||
return await this._jsonRequest(HttpMethod.PUT, "/behavior/trees", model);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Cameras } from "../../../../../../core/model/cameras";
|
||||
import { HttpMethod, HttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
|
||||
export class CameraDeviceHttpRepository extends HttpRepository {
|
||||
export class CameraDeviceHttpRepository extends CoreHttpRepository {
|
||||
getAllCameras = () => this._jsonRequest<Cameras>(HttpMethod.GET, '/behavior/trees/cameras');
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { HttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
import { CoreHttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
|
||||
export class RobotDeviceFormHttpRepository extends HttpRepository {
|
||||
export class RobotDeviceFormHttpRepository extends CoreHttpRepository {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Topics } from "../../../../../../core/model/topics";
|
||||
import { HttpMethod, HttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../../../../../core/repository/http_repository";
|
||||
|
||||
export class TopicsFormHttpRepository extends HttpRepository {
|
||||
export class TopicsFormHttpRepository extends CoreHttpRepository {
|
||||
getAllTopics = () => this._jsonRequest<Topics>(HttpMethod.GET, '/behavior/trees/topics');
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export const WeightsForm = observer((props: IWeightsFormProps) => {
|
|||
}
|
||||
style={{ width: "100%" }}
|
||||
options={
|
||||
store.assets?.assets.map((el) => {
|
||||
store.parts?.map((el) => {
|
||||
return { label: el.name, value: el.name };
|
||||
}) ?? []
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import { FormState, CoreError } from "../../../../../../core/store/base_store";
|
||||
import { DataSetHttpRepository } from "../../../../../dataset/dataset_http_repository";
|
||||
import { Assets } from "../../../../../dataset/dataset_model";
|
||||
import { ISkils, SkillsHttpRepository } from "../../../../../skils/skills_http_repository";
|
||||
import { WeightsViewModel } from "./weights_view_model";
|
||||
import { Parts } from "../../../../../details/details_http_repository";
|
||||
|
||||
export class WeightsFormStore extends FormState<WeightsViewModel, CoreError> {
|
||||
weights?: ISkils[];
|
||||
assets?: Assets;
|
||||
parts?: Parts[];
|
||||
suitableWeights: string[] = [];
|
||||
viewModel: WeightsViewModel = WeightsViewModel.empty();
|
||||
skillsHttpRepository: SkillsHttpRepository = new SkillsHttpRepository();
|
||||
|
@ -18,7 +18,7 @@ export class WeightsFormStore extends FormState<WeightsViewModel, CoreError> {
|
|||
}
|
||||
init = async () => {
|
||||
await this.mapOk("weights", this.skillsHttpRepository.getAllSkills());
|
||||
await this.mapOk("assets", this.datasetHttpRepository.getAssetsActiveProject());
|
||||
await this.mapOk("parts", this.datasetHttpRepository.getAssetsActiveProject());
|
||||
};
|
||||
changeDimensions = (index: number, value: number) => {
|
||||
this.viewModel.dimensions[index] = value;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Result } from "../../core/helper/result";
|
||||
import { DatabaseModel } from "../../core/model/database_model";
|
||||
import { ITriggerModel } from "../../core/model/trigger_model";
|
||||
import { HttpMethod, HttpRepository } from "../../core/repository/http_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../core/repository/http_repository";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { ICreateProjectViewModel } from "./project_model";
|
||||
|
||||
|
@ -10,7 +10,7 @@ export interface PipelineModel extends DatabaseModel {
|
|||
trigger: ITriggerModel;
|
||||
}
|
||||
|
||||
export class CreateProjectRepository extends HttpRepository {
|
||||
export class CreateProjectRepository extends CoreHttpRepository {
|
||||
async saveProject(model: ICreateProjectViewModel): Promise<Result<Error, UUID>> {
|
||||
return await this._jsonRequest<UUID>(HttpMethod.POST, "/projects", model);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { Result } from "../../core/helper/result";
|
||||
import { HttpError, HttpMethod, HttpRepository } from "../../core/repository/http_repository";
|
||||
import { HttpError, HttpMethod, CoreHttpRepository } from "../../core/repository/http_repository";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { Assets, DataSetModel, Dataset, IDatasetModel, ProcessStatus } from "./dataset_model";
|
||||
import { Parts } from "../details/details_http_repository";
|
||||
import { DataSetModel, Dataset, IDatasetModel, ProcessStatus } from "./dataset_model";
|
||||
|
||||
export class DataSetHttpRepository extends HttpRepository {
|
||||
export class DataSetHttpRepository extends CoreHttpRepository {
|
||||
editDataset(dataSetModel: DataSetModel) {
|
||||
dataSetModel.processStatus = ProcessStatus.NEW;
|
||||
return this._jsonRequest<void>(HttpMethod.PUT, `/datasets`, dataSetModel);
|
||||
|
@ -11,12 +12,6 @@ export class DataSetHttpRepository extends HttpRepository {
|
|||
deleteDataset(id: string) {
|
||||
return this._jsonRequest<void>(HttpMethod.DELETE, `/datasets/dataset?id=${id}`);
|
||||
}
|
||||
getActiveProjectId(): Promise<Result<HttpError, UUID>> {
|
||||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
getAssetsActiveProject = async (): Promise<Result<HttpError, Assets>> => {
|
||||
return this._jsonRequest<Assets>(HttpMethod.GET, "/projects/assets");
|
||||
};
|
||||
saveDataSet = async (model: DataSetModel) => {
|
||||
return this._jsonRequest<Dataset>(HttpMethod.POST, "/datasets", model);
|
||||
};
|
||||
|
|
|
@ -31,9 +31,6 @@ export interface Dataset {
|
|||
formBuilder: FormBuilderValidationModel;
|
||||
}
|
||||
|
||||
export interface Assets {
|
||||
assets: Asset[];
|
||||
}
|
||||
|
||||
export interface Asset {
|
||||
name: string;
|
||||
|
|
|
@ -101,7 +101,7 @@ export const DataSetScreen: React.FunctionComponent = observer(() => {
|
|||
filled={true}
|
||||
/>
|
||||
</div>
|
||||
{store.assets?.assets?.map((el) => {
|
||||
{store.parts?.map((el) => {
|
||||
return (
|
||||
<ListItem
|
||||
status={store.assetStatus(el.name)}
|
||||
|
|
|
@ -2,10 +2,11 @@ import makeAutoObservable from "mobx-store-inheritance";
|
|||
import { DataSetHttpRepository } from "./dataset_http_repository";
|
||||
import { Drawer, UiErrorState } from "../../core/store/base_store";
|
||||
import { HttpError } from "../../core/repository/http_repository";
|
||||
import { Asset, Assets, DataSetModel, IDatasetModel, ProcessStatus } from "./dataset_model";
|
||||
import { DataSetModel, IDatasetModel, ProcessStatus } from "./dataset_model";
|
||||
import { message } from "antd";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { SocketRepository, socketRepository } from "../../core/repository/socket_repository";
|
||||
import { Parts } from "../details/details_http_repository";
|
||||
|
||||
export enum DrawersDataset {
|
||||
NewDataset = "Новый датасет",
|
||||
|
@ -14,7 +15,7 @@ export enum DrawersDataset {
|
|||
|
||||
export class DataSetStore extends UiErrorState<HttpError> {
|
||||
dataSetRepository: DataSetHttpRepository;
|
||||
assets?: Assets;
|
||||
parts?: Parts[];
|
||||
datasets?: IDatasetModel[];
|
||||
activeProject: UUID;
|
||||
dataSetModel = DataSetModel.empty();
|
||||
|
@ -74,11 +75,11 @@ export class DataSetStore extends UiErrorState<HttpError> {
|
|||
return this.dataSetModel.dataSetObjects.includes(name);
|
||||
}
|
||||
|
||||
datasetCheckBox(asset: Asset): void {
|
||||
if (this.assetStatus(asset.name)) {
|
||||
this.dataSetModel.dataSetObjects = this.dataSetModel.dataSetObjects.filter((el) => !el.isEqual(asset.name));
|
||||
datasetCheckBox(part: Parts): void {
|
||||
if (this.assetStatus(part.name)) {
|
||||
this.dataSetModel.dataSetObjects = this.dataSetModel.dataSetObjects.filter((el) => !el.isEqual(part.name));
|
||||
} else {
|
||||
this.dataSetModel.dataSetObjects.push(asset.name);
|
||||
this.dataSetModel.dataSetObjects.push(part.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +155,7 @@ export class DataSetStore extends UiErrorState<HttpError> {
|
|||
}
|
||||
|
||||
init = async () => {
|
||||
await this.mapOk("assets", this.dataSetRepository.getAssetsActiveProject());
|
||||
await this.mapOk("parts", this.dataSetRepository.getAssetsActiveProject());
|
||||
await this.getDatasets();
|
||||
await this.mapOk("activeProject", this.dataSetRepository.getActiveProjectId());
|
||||
};
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { HttpMethod, HttpRepository } from "../../core/repository/http_repository";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../core/repository/http_repository";
|
||||
export interface Parts {
|
||||
name: string;
|
||||
part_path: string;
|
||||
material_path: string;
|
||||
httpUrl: string;
|
||||
stlUrl: string;
|
||||
image: string;
|
||||
}
|
||||
|
||||
|
||||
export class DetailsHttpRepository extends HttpRepository {
|
||||
getAllDetails = async () => this._jsonRequest<Parts[]>(HttpMethod.GET, '/projects/assets/')
|
||||
}
|
||||
export class DetailsHttpRepository extends CoreHttpRepository {
|
||||
}
|
|
@ -11,7 +11,7 @@ export const DetailsScreen = observer(() => {
|
|||
React.useEffect(() => {
|
||||
store.loadScene(canvasRef.current!);
|
||||
|
||||
})
|
||||
}, [])
|
||||
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
||||
|
||||
return (
|
||||
|
@ -39,87 +39,3 @@ export const DetailsScreen = observer(() => {
|
|||
/>
|
||||
);
|
||||
});
|
||||
|
||||
// /* state-layer */
|
||||
|
||||
// /* Auto layout */
|
||||
// display: flex;
|
||||
// flex-direction: row;
|
||||
// align-items: center;
|
||||
// padding: 16px 24px 16px 16px;
|
||||
// gap: 12px;
|
||||
|
||||
// width: 256px;
|
||||
// height: 56px;
|
||||
|
||||
// /* Inside auto layout */
|
||||
// flex: none;
|
||||
// order: 0;
|
||||
// align-self: stretch;
|
||||
// flex-grow: 1;
|
||||
|
||||
// /* Icon */
|
||||
|
||||
// width: 24px;
|
||||
// height: 24px;
|
||||
|
||||
// /* Inside auto layout */
|
||||
// flex: none;
|
||||
// order: 0;
|
||||
// flex-grow: 0;
|
||||
|
||||
// /* icon */
|
||||
|
||||
// position: absolute;
|
||||
// left: 25%;
|
||||
// right: 25%;
|
||||
// top: 25%;
|
||||
// bottom: 25%;
|
||||
|
||||
// /* M3/sys/light/on-secondary-container */
|
||||
// background: #1D192B;
|
||||
|
||||
// /* Label */
|
||||
|
||||
// width: 160px;
|
||||
// height: 20px;
|
||||
|
||||
// /* M3/label/large - prominent */
|
||||
// font-family: 'Roboto';
|
||||
// font-style: normal;
|
||||
// font-weight: 600;
|
||||
// font-size: 14px;
|
||||
// line-height: 20px;
|
||||
// /* identical to box height, or 143% */
|
||||
// letter-spacing: 0.1px;
|
||||
|
||||
// /* M3/sys/light/on-secondary-container */
|
||||
// color: #1D192B;
|
||||
|
||||
// /* Inside auto layout */
|
||||
// flex: none;
|
||||
// order: 1;
|
||||
// flex-grow: 1;
|
||||
|
||||
// /* Badge label text */
|
||||
|
||||
// width: 8px;
|
||||
// height: 20px;
|
||||
|
||||
// /* M3/label/large - prominent */
|
||||
// font-family: 'Roboto';
|
||||
// font-style: normal;
|
||||
// font-weight: 600;
|
||||
// font-size: 14px;
|
||||
// line-height: 20px;
|
||||
// /* identical to box height, or 143% */
|
||||
// text-align: right;
|
||||
// letter-spacing: 0.1px;
|
||||
|
||||
// /* M3/sys/light/on-secondary-container */
|
||||
// color: #1D192B;
|
||||
|
||||
// /* Inside auto layout */
|
||||
// flex: none;
|
||||
// order: 2;
|
||||
// flex-grow: 0;
|
||||
|
|
|
@ -2,9 +2,7 @@ import makeAutoObservable from "mobx-store-inheritance";
|
|||
import { CoreError, UiErrorState } from "../../core/store/base_store";
|
||||
import { NavigateFunction } from "react-router-dom";
|
||||
import { DetailsHttpRepository, Parts } from "./details_http_repository";
|
||||
import { CoreThreeRepository } from "../../core/repository/core_three_repository";
|
||||
import { Color } from "three";
|
||||
import { BabylonRepository } from "../../core/repository/babylon_repository";
|
||||
import { DetailsThreeRepository } from "./details_three_repository";
|
||||
|
||||
interface IDetailViewModel {
|
||||
label: string;
|
||||
|
@ -12,12 +10,12 @@ interface IDetailViewModel {
|
|||
httpUrl: string;
|
||||
}
|
||||
|
||||
|
||||
export class DetailsStore extends UiErrorState<CoreError> {
|
||||
detailsViewModel: IDetailViewModel[] = [];
|
||||
parts: Parts[] = [];
|
||||
detailsHttpRepository: DetailsHttpRepository = new DetailsHttpRepository();
|
||||
coreThereRepository?: CoreThreeRepository;
|
||||
babylonRepository?: BabylonRepository;
|
||||
detailsThreeRepository?: DetailsThreeRepository;
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
|
@ -25,12 +23,12 @@ export class DetailsStore extends UiErrorState<CoreError> {
|
|||
}
|
||||
errorHandingStrategy = (error: CoreError) => { };
|
||||
init = async (navigate?: NavigateFunction | undefined): Promise<void> => {
|
||||
await this.mapOk("parts", this.detailsHttpRepository.getAllDetails());
|
||||
await this.mapOk("parts", this.detailsHttpRepository.getAssetsActiveProject());
|
||||
this.detailsViewModel = this.parts.map((el) => {
|
||||
return {
|
||||
label: el.name,
|
||||
selected: false,
|
||||
httpUrl: el.httpUrl,
|
||||
httpUrl: el.stlUrl,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -43,15 +41,16 @@ export class DetailsStore extends UiErrorState<CoreError> {
|
|||
this.detailsViewModel.map((el) => {
|
||||
if (el.label.match(label)) {
|
||||
el.selected = true;
|
||||
|
||||
this.babylonRepository?.load(el.httpUrl)
|
||||
this.detailsThreeRepository?.deleteAllObjectsScene()
|
||||
this.detailsThreeRepository?.loadHttpAndPreview(el.httpUrl, el.label, () => { })
|
||||
return el;
|
||||
}
|
||||
return el
|
||||
});
|
||||
};
|
||||
loadScene = async (ref: HTMLCanvasElement) => {
|
||||
this.babylonRepository = new BabylonRepository(ref);
|
||||
|
||||
this.detailsThreeRepository = new DetailsThreeRepository(ref, () => { });
|
||||
this.detailsThreeRepository.render();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
26
ui/src/features/details/details_three_repository.ts
Normal file
26
ui/src/features/details/details_three_repository.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { Box3, GridHelper, Mesh, Object3D, Vector3 } from "three";
|
||||
import { CoreThreeRepository } from "../../core/repository/core_three_repository";
|
||||
|
||||
export class DetailsThreeRepository extends CoreThreeRepository {
|
||||
raiseAnObjectAboveZeroVector = (name: string) => {
|
||||
const mesh = this.scene.getObjectByName(name) as Object3D;
|
||||
mesh.position.sub(new Box3().setFromObject(mesh).min)
|
||||
}
|
||||
matchTwoPlacesInTheCenter = () => {
|
||||
|
||||
}
|
||||
loadHttpAndPreview = (path: string, name: string, loadCallback?: Function) => {
|
||||
|
||||
this.loader(
|
||||
path,
|
||||
() => {
|
||||
this.raiseAnObjectAboveZeroVector(name)
|
||||
console.log(this.getCenterPoint(this.scene.children.filter((el) => el instanceof GridHelper).at(0) as Object3D))
|
||||
},
|
||||
name,
|
||||
new Vector3(0, 0, 0)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import { Result } from "../../core/helper/result";
|
||||
|
||||
export class NumberTriviaModel {
|
||||
constructor() {}
|
||||
isValid(): Result<string, void> {
|
||||
return Result.ok();
|
||||
}
|
||||
static empty() {
|
||||
return new NumberTriviaModel();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
import { Result } from "../../../core/helper/result";
|
||||
import { HttpMethod, HttpRepository } from "../../../core/repository/http_repository";
|
||||
import { HttpMethod, CoreHttpRepository } from "../../../core/repository/http_repository";
|
||||
import { CoreError } from "../../../core/store/base_store";
|
||||
import { RobossemblerAssets } from "../../../core/model/robossembler_assets";
|
||||
|
||||
export class SceneHttpRepository extends HttpRepository {
|
||||
export class SceneHttpRepository extends CoreHttpRepository {
|
||||
async getRobossemblerAssets() {
|
||||
return this._jsonToClassInstanceRequest<RobossemblerAssets>(
|
||||
HttpMethod.GET,
|
||||
|
|
|
@ -14,7 +14,7 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
sceneMode: SceneMode;
|
||||
sceneMenu: SceneMenu;
|
||||
isVisibleSaveButton: boolean = false;
|
||||
coreThereRepository: null | CoreThreeRepository = null;
|
||||
coreThreeRepository: null | CoreThreeRepository = null;
|
||||
sceneHttpRepository: SceneHttpRepository;
|
||||
sceneModels: BaseSceneItemModel[] = [];
|
||||
isSceneMenuShow = false;
|
||||
|
@ -39,7 +39,7 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
|
||||
deleteSceneItem(item: BaseSceneItemModel) {
|
||||
const itm = this.sceneModels.filter((el) => el.id === item.id);
|
||||
this.coreThereRepository!.deleteSceneItem(itm[0]);
|
||||
this.coreThreeRepository!.deleteSceneItem(itm[0]);
|
||||
this.sceneModels = this.sceneModels.filter((el) => el.name !== item.name);
|
||||
this.visibleSaveButton();
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
}
|
||||
|
||||
addNewCamera(model: CameraViewModel) {
|
||||
model.position = this.coreThereRepository!.camera.position;
|
||||
model.quaternion = this.coreThereRepository!.camera.quaternion;
|
||||
model.position = this.coreThreeRepository!.camera.position;
|
||||
model.quaternion = this.coreThreeRepository!.camera.quaternion;
|
||||
this.sceneModels.push(model);
|
||||
this.coreThereRepository?.addSceneCamera(model);
|
||||
this.coreThreeRepository?.addSceneCamera(model);
|
||||
this.visibleSaveButton();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
try {
|
||||
const assetPath = this.robossemblerAssets?.getAssetPath(name) as string;
|
||||
|
||||
this.coreThereRepository?.loader(assetPath, this.loaderWatcher, name);
|
||||
this.coreThreeRepository?.loader(assetPath, this.loaderWatcher, name);
|
||||
this.visibleSaveButton();
|
||||
} catch (error) {
|
||||
message.error(String(error));
|
||||
|
@ -99,7 +99,7 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
} else if (this.sceneMode === mode) {
|
||||
this.sceneMode = SceneMode.EMPTY;
|
||||
}
|
||||
this.coreThereRepository?.setTransformMode(this.sceneMode);
|
||||
this.coreThreeRepository?.setTransformMode(this.sceneMode);
|
||||
this.sceneModeWatcher();
|
||||
};
|
||||
|
||||
|
@ -117,15 +117,15 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
this.loadWebGl(canvasRef);
|
||||
await this.mapOk<RobossemblerAssets>("robossemblerAssets", this.sceneHttpRepository.getRobossemblerAssets());
|
||||
if (this.robossemblerAssets) {
|
||||
this.coreThereRepository?.loadInstances(this.robossemblerAssets);
|
||||
this.coreThreeRepository?.loadInstances(this.robossemblerAssets);
|
||||
}
|
||||
}
|
||||
|
||||
loadWebGl(canvasRef: HTMLCanvasElement): void {
|
||||
this.coreThereRepository = new CoreThreeRepository(canvasRef as HTMLCanvasElement, this.watcherSceneEditorObject);
|
||||
this.coreThereRepository.on(this.watcherThereObjects);
|
||||
this.coreThereRepository.render();
|
||||
this.sceneModels = this.coreThereRepository.getAllSceneModels();
|
||||
this.coreThreeRepository = new CoreThreeRepository(canvasRef as HTMLCanvasElement, this.watcherSceneEditorObject);
|
||||
this.coreThreeRepository.on(this.watcherThereObjects);
|
||||
this.coreThreeRepository.render();
|
||||
this.sceneModels = this.coreThreeRepository.getAllSceneModels();
|
||||
|
||||
window.addEventListener("click", (event) => this.clickLister(event));
|
||||
window.addEventListener("mousedown", (e) => this.sceneContextMenu(e));
|
||||
|
@ -169,9 +169,9 @@ export class SceneMangerStore extends UiErrorState<HttpError> {
|
|||
};
|
||||
|
||||
transformContollsCall = (vector: Vector2) => {
|
||||
this.coreThereRepository?.setRayCastAndGetFirstObject(vector).fold(
|
||||
(success) => this.coreThereRepository?.setTransformControlsAttach(success),
|
||||
(_error) => this.coreThereRepository?.disposeTransformControlsMode()
|
||||
this.coreThreeRepository?.setRayCastAndGetFirstObject(vector).fold(
|
||||
(success) => this.coreThreeRepository?.setTransformControlsAttach(success),
|
||||
(_error) => this.coreThreeRepository?.disposeTransformControlsMode()
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { UrdfTransforms } from "./tranforms_model";
|
|||
|
||||
export class SimulationStore {
|
||||
rosWsUrdfTransfomsListner: RosWsBridgeRepository<UrdfTransforms> = new RosWsBridgeRepository();
|
||||
coreThereRepository?: CoreThreeRepository;
|
||||
coreThreeRepository?: CoreThreeRepository;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
|
@ -15,15 +15,15 @@ export class SimulationStore {
|
|||
}
|
||||
async loadScene(canvasRef: HTMLCanvasElement) {
|
||||
await this.loadWebGl(canvasRef);
|
||||
this.coreThereRepository?.loadUrdf('http://localhost:4001/robot.xml');
|
||||
if (this.coreThereRepository?.urdfTransforms) {
|
||||
this.rosWsUrdfTransfomsListner.on(this.coreThereRepository.urdfTransforms)
|
||||
this.coreThreeRepository?.loadUrdf('http://localhost:4001/robot.xml');
|
||||
if (this.coreThreeRepository?.urdfTransforms) {
|
||||
this.rosWsUrdfTransfomsListner.on(this.coreThreeRepository.urdfTransforms)
|
||||
|
||||
}
|
||||
}
|
||||
loadWebGl = async (canvasRef: HTMLCanvasElement) => {
|
||||
this.coreThereRepository = new CoreThreeRepository(canvasRef as HTMLCanvasElement, () => { });
|
||||
this.coreThereRepository.on(() => { });
|
||||
this.coreThereRepository.render();
|
||||
this.coreThreeRepository = new CoreThreeRepository(canvasRef as HTMLCanvasElement, () => { });
|
||||
this.coreThreeRepository.on(() => { });
|
||||
this.coreThreeRepository.render();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
import { Result } from "../../core/helper/result";
|
||||
import { HttpError, HttpMethod, HttpRepository } from "../../core/repository/http_repository";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { HttpError, HttpMethod, CoreHttpRepository } from "../../core/repository/http_repository";
|
||||
import { IDatasetModel } from "../dataset/dataset_model";
|
||||
import { SkillModel } from "./skill_model";
|
||||
|
||||
|
@ -8,15 +7,15 @@ export interface ISkils {
|
|||
_id: string;
|
||||
name: string;
|
||||
processStatus: string;
|
||||
epoch:number;
|
||||
epoch: number;
|
||||
isFinished: boolean;
|
||||
datasetId: any;
|
||||
project: any;
|
||||
numberOfTrainedEpochs:number;
|
||||
numberOfTrainedEpochs: number;
|
||||
__v: number;
|
||||
}
|
||||
|
||||
export class SkillsHttpRepository extends HttpRepository {
|
||||
export class SkillsHttpRepository extends CoreHttpRepository {
|
||||
execSkill(id: string) {
|
||||
return this._jsonRequest(HttpMethod.GET, `/weights/exec?id=${id}`);
|
||||
}
|
||||
|
@ -36,7 +35,5 @@ export class SkillsHttpRepository extends HttpRepository {
|
|||
getDatasetsActiveProject = async (): Promise<Result<HttpError, IDatasetModel[]>> => {
|
||||
return this._jsonRequest<IDatasetModel[]>(HttpMethod.GET, "/datasets");
|
||||
};
|
||||
getActiveProjectId(): Promise<Result<HttpError, UUID>> {
|
||||
return this._jsonRequest<UUID>(HttpMethod.GET, "/projects/get/active/project/id");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
"eslintConfig": {
|
||||
"extends": ["react-app", "shared-config"],
|
||||
"rules": {
|
||||
"additional-rule": "warn"
|
||||
"additional-rule": "warn",
|
||||
"no-extend-native":"off",
|
||||
"react-hooks/exhaustive-deps":"off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
|
@ -10,7 +12,8 @@
|
|||
"rules": {
|
||||
"additional-typescript-only-rule": "warn",
|
||||
"array-callback-return": "off",
|
||||
"react-hooks/exhaustive-deps": "off"
|
||||
"react-hooks/exhaustive-deps": "off",
|
||||
"no-extend-native":"off"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue