Refactor API imports and restructure services

- Updated import paths for `upsertProductOrEventApi`, `deleteEventDataApi`, `deleteProductApi`, `getProductApi`, `getAllProductsApi`, and `renameProductApi` to point to the new `products` directory.
- Removed old API files for `UpsertProductOrEventApi`, `deleteEventDataApi`, `deleteProductApi`, `getProductApi`, `getAllProductsApi`, and `renameProductApi`.
- Introduced new implementations for the above APIs in the `products` directory.
- Added `MaterialCollisionDetector` component to handle material collision detection using a web worker.
- Updated various components to utilize the new API structure and ensure proper functionality.
This commit is contained in:
2025-05-21 15:36:34 +05:30
parent 60a277f7f0
commit 8e01c24844
32 changed files with 191 additions and 24 deletions

View File

@@ -0,0 +1,40 @@
onmessage = function (e) {
const { materials, positions, sizes } = e.data;
const collisions = [];
const allPairs = [];
for (let i = 0; i < materials.length; i++) {
for (let j = i + 1; j < materials.length; j++) {
const mat1 = materials[i];
const mat2 = materials[j];
const pos1 = positions[mat1.materialId];
const pos2 = positions[mat2.materialId];
if (!pos1 || !pos2) continue;
const size1 = sizes[mat1.materialId] || 0.2;
const size2 = sizes[mat2.materialId] || 0.2;
const distance = Math.sqrt(
Math.pow(pos1.x - pos2.x, 2) +
Math.pow(pos1.y - pos2.y, 2) +
Math.pow(pos1.z - pos2.z, 2)
);
allPairs.push({
materialId1: mat1.materialId,
materialId2: mat2.materialId
});
if (distance < (size1 + size2)) {
collisions.push({
materialId1: mat1.materialId,
materialId2: mat2.materialId,
distance: distance
});
}
}
}
postMessage({ collisions, allPairs });
};