refactor: reorganize asset management functions and remove unused components

This commit is contained in:
2025-05-27 09:16:33 +05:30
parent b086ee8f75
commit f6f0478e9a
5 changed files with 414 additions and 414 deletions

View File

@@ -11,7 +11,7 @@ import Models from "./models/models";
import useModuleStore from "../../../store/useModuleStore"; import useModuleStore from "../../../store/useModuleStore";
import { useThree } from "@react-three/fiber"; import { useThree } from "@react-three/fiber";
import { CameraControls } from "@react-three/drei"; import { CameraControls } from "@react-three/drei";
import addAssetModel from "../geomentries/assets/addAssetModel"; import addAssetModel from "./functions/addAssetModel";
const gltfLoaderWorker = new Worker( const gltfLoaderWorker = new Worker(
new URL( new URL(

View File

@@ -1,6 +1,6 @@
import { Box3, BoxGeometry, EdgesGeometry, Vector3 } from "three"; import { Box3, BoxGeometry, EdgesGeometry, Vector3 } from "three";
export const AssetBoundingBox = ({ asset, boundingBox }: { asset: Asset, boundingBox: Box3 | null }) => { export const AssetBoundingBox = ({ boundingBox }: { boundingBox: Box3 | null }) => {
if (!boundingBox) return null; if (!boundingBox) return null;
const size = boundingBox.getSize(new Vector3()); const size = boundingBox.getSize(new Vector3());
@@ -13,7 +13,7 @@ export const AssetBoundingBox = ({ asset, boundingBox }: { asset: Asset, boundin
<group name='Asset FallBack'> <group name='Asset FallBack'>
<lineSegments position={center}> <lineSegments position={center}>
<bufferGeometry attach="geometry" {...edges} /> <bufferGeometry attach="geometry" {...edges} />
<lineBasicMaterial attach="material" color="gray" linewidth={1} /> <lineBasicMaterial depthWrite={false} attach="material" color="gray" linewidth={1} />
</lineSegments> </lineSegments>
</group> </group>
); );

View File

@@ -5,8 +5,8 @@ import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
import { useFrame, useThree } from '@react-three/fiber'; import { useFrame, useThree } from '@react-three/fiber';
import { useActiveTool, useDeletableFloorItem, useRenderDistance, useSelectedFloorItem } from '../../../../../store/builder/store'; import { useActiveTool, useDeletableFloorItem, useRenderDistance, useSelectedFloorItem } from '../../../../../store/builder/store';
import { AssetBoundingBox } from './assetBoundingBox'; import { AssetBoundingBox } from '../../functions/assetBoundingBox';
import { CameraControls } from '@react-three/drei'; import { CameraControls, Detailed } from '@react-three/drei';
import { useAssetsStore } from '../../../../../store/builder/useAssetStore'; import { useAssetsStore } from '../../../../../store/builder/useAssetStore';
import { useEventsStore } from "../../../../../store/simulation/useEventsStore"; import { useEventsStore } from "../../../../../store/simulation/useEventsStore";
import { useProductStore } from "../../../../../store/simulation/useProductStore"; import { useProductStore } from "../../../../../store/simulation/useProductStore";
@@ -216,7 +216,7 @@ function Model({ asset }: { asset: Asset }) {
isRendered ? ( isRendered ? (
<primitive object={gltfScene.scene.clone()} /> <primitive object={gltfScene.scene.clone()} />
) : ( ) : (
<AssetBoundingBox asset={asset} boundingBox={boundingBox} /> <AssetBoundingBox boundingBox={boundingBox} />
) )
)} )}
</group> </group>

View File

@@ -50,7 +50,7 @@ const BoundingBox = ({ boundingBoxRef }: any) => {
<> <>
{points.length > 0 && ( {points.length > 0 && (
<> <>
<Line points={points} color={savedTheme === "dark" ? "#c4abf1" : "#6f42c1"} lineWidth={2.7} segments /> <Line depthWrite={false} points={points} color={savedTheme === "dark" ? "#c4abf1" : "#6f42c1"} lineWidth={2.7} segments />
<mesh ref={boundingBoxRef} visible={false} position={boxProps.position}> <mesh ref={boundingBoxRef} visible={false} position={boxProps.position}>
<boxGeometry args={boxProps.args} /> <boxGeometry args={boxProps.args} />
<meshBasicMaterial /> <meshBasicMaterial />