refactor: standardize position and rotation types to use tuple arrays for consistency
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { useLoader } from "@react-three/fiber";
|
||||
import { Vector3 } from "three";
|
||||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
||||
import { clone } from "three/examples/jsm/utils/SkeletonUtils";
|
||||
@@ -7,9 +6,8 @@ import { clone } from "three/examples/jsm/utils/SkeletonUtils";
|
||||
interface MultiGLTFInstancesProps {
|
||||
index: number;
|
||||
modelUrl: string;
|
||||
position: Vector3;
|
||||
rotation: Vector3;
|
||||
visibility?: boolean;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
}
|
||||
|
||||
export const MultiGLTFInstances: React.FC<MultiGLTFInstancesProps> = ({
|
||||
@@ -17,9 +15,8 @@ export const MultiGLTFInstances: React.FC<MultiGLTFInstancesProps> = ({
|
||||
modelUrl,
|
||||
position,
|
||||
rotation,
|
||||
visibility,
|
||||
}) => {
|
||||
console.log("position: ", position);
|
||||
// Load GLTF model with DRACO loader for compression
|
||||
const originalGltf = useLoader(GLTFLoader, modelUrl, (loader) => {
|
||||
const draco = new DRACOLoader();
|
||||
draco.setDecoderPath(
|
||||
@@ -27,19 +24,20 @@ export const MultiGLTFInstances: React.FC<MultiGLTFInstancesProps> = ({
|
||||
);
|
||||
loader.setDRACOLoader(draco);
|
||||
});
|
||||
|
||||
// Clone the model for independent transformations
|
||||
const cloned = clone(originalGltf.scene);
|
||||
|
||||
// Render the cloned model
|
||||
return (
|
||||
<>
|
||||
{visibility && (
|
||||
<primitive
|
||||
name={`rigged_arm`}
|
||||
key={index}
|
||||
object={cloned}
|
||||
position={position}
|
||||
scale={[1, 1, 1]}
|
||||
rotation={rotation}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
<mesh>
|
||||
<primitive
|
||||
name="rigged_arm"
|
||||
key={index}
|
||||
object={cloned}
|
||||
position={position}
|
||||
rotation={rotation}
|
||||
/>
|
||||
</mesh>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user