You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks in advance for this module, it's very performant and fairly straightforward to implement!
I am using this library to calculate physics for toruses (rings) which I'm achieving by creating a ring of spheres and passing the shapes array to a CompoundBody. This is working as expected, however I'd like to the ability to turn down the amount of segments on each sphere. I've tried using the second two args which I'd assume behave the same as they would if one was implementing the sphereBody outside of a compoundBody. However, when I enable the Debug view (which I assume is displaying the real geometries cannon is using to calculate collisions) I don't see any change in the amount of segments. I've also tried putting negative numbers and even strings in place and the library doesn't even throw an error so I'm guessing anything other than the first parameter (radius) is ignored.
Here is my relevant code which is a component within a ReactJS app:
import React, { useRef } from 'react';
import { useCompoundBody } from '@react-three/cannon';
import { MeshTransmissionMaterial } from '@react-three/drei';
function Ring(props) {
const { position } = props;
const shapes = [];
const radius = 1;
const segments = 8;
for (let i = 0; i < 1; i += (1 / segments)) {
const angle = i * 2 * Math.PI;
shapes.push({
args: [0.4, 1, 1], // <- second two properties are ignored
position: [radius * Math.cos(angle), radius * Math.sin(angle), 0],
type: 'Sphere',
});
}
const [ref, api] = useCompoundBody(
() => ({
mass: 1,
position,
shapes,
}),
useRef(),
);
return (
<group>
<mesh ref={ref}>
<torusGeometry />
<MeshTransmissionMaterial
transmission={0.9}
roughness={0.1}
thickness={0.5}
ior={1.5}
reflectivity={0.1}
color={0xee6688}
backsideThickness={0.1}
/>
</mesh>
</group>
);
}
export default Ring;
The text was updated successfully, but these errors were encountered:
DaveSeidman
changed the title
Add ability to controls amount of segments for shapes within compoundBody
Can't set amount of segments for shapes within compoundBody
Nov 15, 2023
Thanks in advance for this module, it's very performant and fairly straightforward to implement!
I am using this library to calculate physics for toruses (rings) which I'm achieving by creating a ring of spheres and passing the shapes array to a CompoundBody. This is working as expected, however I'd like to the ability to turn down the amount of segments on each sphere. I've tried using the second two args which I'd assume behave the same as they would if one was implementing the sphereBody outside of a compoundBody. However, when I enable the Debug view (which I assume is displaying the real geometries cannon is using to calculate collisions) I don't see any change in the amount of segments. I've also tried putting negative numbers and even strings in place and the library doesn't even throw an error so I'm guessing anything other than the first parameter (radius) is ignored.
Here is my relevant code which is a component within a ReactJS app:
The text was updated successfully, but these errors were encountered: