refactor: removed rigged arm when not needed
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user