Gltf object collision error

I found three communities to solve the problem.

It may be difficult to convey the problem due to poor English, but I registered the question because I wanted to solve it so badly.

An error occurs when a gltf object collides with another box.

What is the problem that can be inferred here?

I want to get an answer.

const Model2 = () => {
  //const gltf = useGLTF('/tree_of_life/scene.gltf', true);
  //const gltf = useGLTF('/tree_of_life/scene.gltf')
  const { nodes, materials, scene } = useGLTF('/tree_of_life/scene.gltf')
  const [ref] = useConvexPolyhedron(() => ({
    mass: 1,
    rotation:[-Math.PI / 1, 0, 0],
    position:[0, 20, 0],
    // args:[3,3,3],
    type: 'Dynamic',
  // gltf.scene.position.set(0,20,10)
  // console.log(gltf.scene)
  return (
      {/* <primitive ref={ref} object={gltf.scene} dispose={null}> */}
      <group ref={ref} position={[0, 0, 0]} rotation={[0, 0, 0]} scale={[0.14, 0.14, 0.14]}>
        <mesh geometry={nodes.Object_2.geometry} material={nodes.Object_2.material} />
        <mesh geometry={nodes.Object_3.geometry} material={nodes.Object_3.material} />
        <mesh geometry={nodes.Object_4.geometry} material={nodes.Object_4.material} />
        <mesh geometry={nodes.Object_5.geometry} material={nodes.Object_5.material} />
        <mesh geometry={nodes.Object_6.geometry} material={nodes.Object_6.material} />
        <mesh geometry={nodes.Object_7.geometry} material={nodes.Object_7.material} />
        <mesh geometry={nodes.Object_8.geometry} material={nodes.Object_8.material} />
        <mesh geometry={nodes.Object_9.geometry} material={nodes.Object_9.material} />
        <mesh geometry={nodes.Object_10.geometry} material={nodes.Object_10.material} />
        <mesh geometry={nodes.Object_11.geometry} material={nodes.Object_11.material} />
        <mesh geometry={nodes.Object_12.geometry} material={nodes.Object_12.material} />
        <mesh geometry={nodes.Object_13.geometry} material={nodes.Object_13.material} />
        <mesh geometry={nodes.Object_14.geometry} material={nodes.Object_14.material} />
        <mesh geometry={nodes.Object_15.geometry} material={nodes.Object_15.material} />
      {/* </primitive> */}

(The code with Gltf.)
The code is messed up because of the traces of various attempts. I really want help.

Thank you for reading my poor English.

convexpolyhedron needs some kind of definition, a hull which wraps the object which should be the args props, see Physics with convex-polyhedrons - CodeSandbox

but generally i would not recommend convexpoly’s in cannon, they are too slow. use a shape that more or less fits, a few boxes as a compound shape. the debugger makes it easier to set shapes with visual feedback.

I’ve already seen the example.
I didn’t fully understand because I was a beginner yet.

But thank you so much for answering.^^

Can the 3D shape be completely made from a normal figure?

Without using ConvexPolyhedron?

compound shapes basically allow you to make one collider using multiple simple shapes.

here is an example of this with the debugger on so you see how the physics engine perceives the shapes: Simple physics demo with debug bounds - CodeSandbox

const [ref] = useCompoundBody(() => ({
  shapes: [
    { type: 'Box', position: [0, 0, 0], rotation: [0, 0, 0], args: [1, 1, 1] },
    { type: 'Sphere', position: [1, 0, 0], rotation: [0, 0, 0], args: [0.65] }

this creates a shape consisting of a box and a sphere. it doesn’t have to be super accurate for complex objects, just pick something that more or less fits. your for instance, i’d use two boxes and that’s that.

Thank you for letting me know the new way.

When I become a threeJS expert, I want to help beginners.

Thank you so much.

1 Like