2025-03-25 12:04:20 +00:00
|
|
|
import { useFloorItems } from '../../../store/store';
|
|
|
|
import * as THREE from 'three';
|
|
|
|
import * as Types from '../../../types/world/worldTypes';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
|
|
|
interface Path {
|
|
|
|
modeluuid: string;
|
|
|
|
modelName: string;
|
|
|
|
points: {
|
|
|
|
uuid: string;
|
|
|
|
position: [number, number, number];
|
|
|
|
rotation: [number, number, number];
|
2025-03-26 13:03:51 +00:00
|
|
|
actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | [];
|
|
|
|
triggers: { uuid: string; name: string; type: string; isUsed: boolean }[] | [];
|
2025-03-27 09:04:36 +00:00
|
|
|
connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
|
2025-03-25 12:04:20 +00:00
|
|
|
}[];
|
|
|
|
pathPosition: [number, number, number];
|
|
|
|
pathRotation: [number, number, number];
|
|
|
|
speed: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Behaviour({ setSimulationPaths }: { setSimulationPaths: any }) {
|
|
|
|
const { floorItems } = useFloorItems();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const newPaths: Path[] = [];
|
|
|
|
|
|
|
|
floorItems.forEach((item: Types.FloorItemType) => {
|
|
|
|
if (item.modelfileID === "6633215057b31fe671145959") {
|
|
|
|
const point1Position = new THREE.Vector3(0, 1.25, 3.3);
|
|
|
|
const middlePointPosition = new THREE.Vector3(0, 1.25, 0);
|
|
|
|
const point2Position = new THREE.Vector3(0, 1.25, -3.3);
|
|
|
|
|
|
|
|
const point1UUID = THREE.MathUtils.generateUUID();
|
|
|
|
const middlePointUUID = THREE.MathUtils.generateUUID();
|
2025-03-27 06:54:15 +00:00
|
|
|
const point2UUID = THREE.MathUtils.generateUUID();
|
2025-03-25 12:04:20 +00:00
|
|
|
|
|
|
|
const newPath: Path = {
|
|
|
|
modeluuid: item.modeluuid,
|
|
|
|
modelName: item.modelname,
|
|
|
|
points: [
|
|
|
|
{
|
|
|
|
uuid: point1UUID,
|
|
|
|
position: [point1Position.x, point1Position.y, point1Position.z],
|
|
|
|
rotation: [0, 0, 0],
|
2025-03-26 13:03:51 +00:00
|
|
|
actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: false }],
|
2025-03-25 12:04:20 +00:00
|
|
|
triggers: [],
|
2025-03-27 09:04:36 +00:00
|
|
|
connections: { source: { pathUUID: item.modeluuid, pointUUID: point1UUID }, targets: [] },
|
2025-03-25 12:04:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
uuid: middlePointUUID,
|
|
|
|
position: [middlePointPosition.x, middlePointPosition.y, middlePointPosition.z],
|
|
|
|
rotation: [0, 0, 0],
|
2025-03-26 13:03:51 +00:00
|
|
|
actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: false }],
|
2025-03-25 12:04:20 +00:00
|
|
|
triggers: [],
|
2025-03-27 09:04:36 +00:00
|
|
|
connections: { source: { pathUUID: item.modeluuid, pointUUID: middlePointUUID }, targets: [] },
|
2025-03-25 12:04:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
uuid: point2UUID,
|
|
|
|
position: [point2Position.x, point2Position.y, point2Position.z],
|
|
|
|
rotation: [0, 0, 0],
|
2025-03-26 13:03:51 +00:00
|
|
|
actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: false }],
|
2025-03-25 12:04:20 +00:00
|
|
|
triggers: [],
|
2025-03-27 09:04:36 +00:00
|
|
|
connections: { source: { pathUUID: item.modeluuid, pointUUID: point2UUID }, targets: [] },
|
2025-03-25 12:04:20 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
pathPosition: [...item.position],
|
|
|
|
pathRotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
|
|
|
speed: 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
newPaths.push(newPath);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setSimulationPaths(newPaths);
|
|
|
|
}, [floorItems]);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2025-03-27 06:54:15 +00:00
|
|
|
export default Behaviour;
|