react-native-arkit
react-native-arkit copied to clipboard
add basic phycis support for primitives
you can now add phycisbody to your 3d objects:
<ARKit.Sphere
transition={{ duration: 0.1 }}
position={{ x: 1, y: 2, z: 1 }}
shape={{ radius: 0.1 }}
physicsBody={{
type: ARKit.PhysicsBodyType.Dynamic,
mass: 1
}}
/>
<ARKit.Plane
eulerAngles={{ x: Math.PI / 2 }}
position={{ x: 0, y: 0, z: 0 }}
physicsBody={{
type: ARKit.PhysicsBodyType.Kinematic
}}
shape={{
width: 100,
height: 100
}}
/>
This works for primitives. It will use the same shape for the physicsBody.
For models, Groups or if you want to customize physicsShape, you can specify the shape:
<ARKit.Sphere
transition={{ duration: 0.1 }}
position={{ x: 1, y: 2, z: 1 }}
shape={{ radius: 0.1 }}
physicsBody={{
type: ARKit.PhysicsBodyType.Dynamic,
shape: {
type: 'sphere', // any of "sphere", "box", "cylinder", "plane", etc.
radius: 0.2 // this makes the sphere bigger than it visual representation is
}
}}
/>
for a Group:
<ARKit.Group
position={{ x: 1, y: 2, z: 0 }}
shape={{ radius: 0.1 }}
physicsBody={{
type: ARKit.PhysicsBodyType.Dynamic,
shape: {
type: 'cylinder',
radius: 0.1,
height: 0.4
}
}}
>
<ARKit.Sphere
position={{ x: 0, y: -0.1, z: 0 }}
shape={{ radius: 0.1 }}
/>
<ARKit.Sphere position={{ x: 0, y: 0.1, z: 0 }} shape={{ radius: 0.1 }} />
</ARKit.Group>
If you want to debug the physics shape, set debug to arView:
<ARView debug .../>
i need to figure out, how to get updates to the position, rotation, etc, which will be needed, if you need to sync back your nodes to state / redux
Amazing work with the whole library. I was trying to test this PR and encountered the problem with no input file. It turned out to be problem in ios/RCTARKit.xcodeproj/project.pbxproj.
- B12E5F302070241D00D423F4 /* Switcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Switcher.m; path = "../../../../../../panter/archilogic/react-native-arkit/ios/Switcher.m"; sourceTree = "<group>"; };
+ B12E5F302070241D00D423F4 /* Switcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Switcher.m; sourceTree = "<group>"; };
Besides that everything worked like a charm ❤️
@Baransu hm, weird have to check that out. Thx for your feedback <3