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