GLB model not rendering at correct position

Im just trying to load this model at 0,0,0 within given parent.
But it just not loading correctly neither with model position nor its rigidbody.

const BlockEnd = () => {
	const position = [4, 0, 0] as Position;
	const obstacleRef = useRef<RapierRigidBody>(null!);
	useSimpleRotation(obstacleRef, 0.5);
	const { scene } = useGLTF("./psyduck.glb");

	return (
		<Block position={position} material={floor0Material}>
			<RigidBody type="fixed">
				<primitive object={scene} scale={0.025} />
			</RigidBody>
		</Block>
	);
};


as a workaround I add manual colliders and fix their rotations. Still would love to know whats causing this wrong axis.


const BlockEnd = () => {
	const position = [0, 0, 12] as Position;
	const obstacleRef = useRef<RapierRigidBody>(null!);
	useSimpleRotation(obstacleRef, 0.5);
	const psyduck = assets.models.psyduck();

	return (
		<Block position={position} material={floor0Material}>
			<RigidBody
				type="fixed"
				position={[0.5, 0, 2]}
				rotation={[0, Math.PI / 1, 0]}
				colliders={false}
				restitution={0.3}
			>
				<primitive object={(psyduck as GLTF).scene} scale={0.025} />
				<CuboidCollider args={[0.5, 0.5, 0.5]} position={[0.5, 0.5, 2]} />
			</RigidBody>
		</Block>
	);
};

Could you share the model file? There’s a chance the displacement is caused by how the GLTF was exported - if you place a mesh off-centre in Blender and export the model, the mesh will have an offset when loaded in three.

To make sure the mesh appears in the centre when loaded, move it to the (0, 0, 0) point in Blender - then select everything, and Apply > All Transforms:

(Unfortunately it gets a bit more complicated if mesh has armature / animations :skull:)

1 Like

sorry i dont know how to use blender, but I can tell you when I imported this glb file into blender it was not visible on screen, where as when I imported another model it looks fine. and as well Im now using this new Duck model which renders fine inside threejs. seems some issue with this GLB pysduck model

as you can see in the screenshot, the middle object at 0,0,0 is that corrupt Psyduck model, which does not render inside Blender