refactor: removed rigged arm when not needed
This commit is contained in:
parent
0e552f645a
commit
14d3de4ece
|
@ -46,7 +46,7 @@ const ArmReplace: React.FC = () => {
|
|||
modelUrl={armModel}
|
||||
position={positions[i]}
|
||||
rotation={rotations[i]}
|
||||
visibility={activeModule === "simulation" ? false : true}
|
||||
visibility={activeModule === "simulation" ? true : false}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useLoader } from "@react-three/fiber";
|
||||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
||||
|
||||
import { clone } from "three/examples/jsm/utils/SkeletonUtils";
|
||||
interface MultiGLTFInstancesProps {
|
||||
index: number;
|
||||
modelUrl: string;
|
||||
|
@ -15,8 +15,9 @@ export const MultiGLTFInstances: React.FC<MultiGLTFInstancesProps> = ({
|
|||
modelUrl,
|
||||
position,
|
||||
rotation,
|
||||
visibility
|
||||
visibility,
|
||||
}) => {
|
||||
console.log("position: ", position);
|
||||
const originalGltf = useLoader(GLTFLoader, modelUrl, (loader) => {
|
||||
const draco = new DRACOLoader();
|
||||
draco.setDecoderPath(
|
||||
|
@ -25,18 +26,19 @@ export const MultiGLTFInstances: React.FC<MultiGLTFInstancesProps> = ({
|
|||
loader.setDRACOLoader(draco);
|
||||
});
|
||||
const cloned = originalGltf.scene.clone();
|
||||
cloned.name = `rigged_arm_${index}`; // Set the name of the cloned object
|
||||
console.log(index);
|
||||
return (
|
||||
<>
|
||||
<primitive
|
||||
key={index}
|
||||
object={cloned}
|
||||
position={position}
|
||||
scale={[1, 1, 1]}
|
||||
rotation={rotation}
|
||||
visible={visibility}
|
||||
/>
|
||||
{visibility && (
|
||||
<primitive
|
||||
name={`rigged_arm`}
|
||||
key={index}
|
||||
object={cloned}
|
||||
position={position}
|
||||
scale={[1, 1, 1]}
|
||||
rotation={rotation}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -17,9 +17,12 @@ export const findLinkObjects = (
|
|||
const count: string[] = [];
|
||||
let i = 0;
|
||||
|
||||
let name = scene.getObjectByName("rigged_arm");
|
||||
console.log(name);
|
||||
|
||||
scene.traverse((object) => {
|
||||
if (object.name === "link_0") {
|
||||
if (object.parent) {
|
||||
if (object.parent && object.type !== "SkinnedMesh") {
|
||||
// count
|
||||
count[i] = object.uuid;
|
||||
i++;
|
||||
|
@ -40,4 +43,4 @@ export const findLinkObjects = (
|
|||
setPositions(positions);
|
||||
setRotations(rotations);
|
||||
setCount(count);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue