bug fix human
This commit is contained in:
@@ -8,18 +8,21 @@ interface MaterialPosition {
|
||||
position: THREE.Vector3;
|
||||
}
|
||||
|
||||
type MaterialPositionsMap = Record<string, MaterialPosition[]>;
|
||||
|
||||
type MaterialsStore = {
|
||||
materials: MaterialsSchema;
|
||||
materialHistory: MaterialHistorySchema;
|
||||
materialPositions: MaterialPosition[];
|
||||
materialPositions: MaterialPositionsMap;
|
||||
|
||||
|
||||
addMaterial: (material: MaterialSchema) => MaterialSchema | undefined;
|
||||
removeMaterial: (materialId: string) => MaterialSchema | undefined;
|
||||
clearMaterials: () => void;
|
||||
updateMaterial: (materialId: string, updates: Partial<MaterialSchema>) => MaterialSchema | undefined;
|
||||
|
||||
setMaterialPositions: (materialPosition: MaterialPosition[]) => void;
|
||||
getMaterialPosition: (materialId: string) => THREE.Vector3 | undefined;
|
||||
setMaterialPositions: (modelUuid: string, materialPositions: MaterialPosition[]) => void;
|
||||
getMaterialPosition: (modelUuid: string, materialId: string) => THREE.Vector3 | undefined;
|
||||
|
||||
setPreviousLocation: (
|
||||
materialId: string,
|
||||
@@ -72,7 +75,7 @@ export const createMaterialStore = () => {
|
||||
immer((set, get) => ({
|
||||
materials: [],
|
||||
materialHistory: [],
|
||||
materialPositions: [],
|
||||
materialPositions: {},
|
||||
|
||||
addMaterial: (material) => {
|
||||
let updatedMaterial: MaterialSchema | undefined;
|
||||
@@ -274,21 +277,14 @@ export const createMaterialStore = () => {
|
||||
return updatedMaterial;
|
||||
},
|
||||
|
||||
setMaterialPositions: (materials) => {
|
||||
setMaterialPositions: (modelUuid, positions) => {
|
||||
set((state) => {
|
||||
state.materialPositions = materials;
|
||||
state.materialPositions[modelUuid] = positions;
|
||||
});
|
||||
},
|
||||
|
||||
getMaterialPosition: (materialid) => {
|
||||
let position: THREE.Vector3 | undefined;
|
||||
set((state) => {
|
||||
const material = state.materialPositions.find(m => m.materialId === materialid);
|
||||
if (material) {
|
||||
position = material.position;
|
||||
}
|
||||
});
|
||||
return position;
|
||||
getMaterialPosition: (modelUuid, materialId) => {
|
||||
return get().materialPositions[modelUuid]?.find(p => p.materialId === materialId)?.position;
|
||||
},
|
||||
|
||||
getMaterialById: (materialId) => {
|
||||
|
||||
Reference in New Issue
Block a user