Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic phycis support for primitives #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add basic phycis support for primitives #178

wants to merge 2 commits into from

Conversation

macrozone
Copy link
Collaborator

@macrozone macrozone commented Mar 31, 2018

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

@baransu
Copy link

baransu commented Jun 19, 2018

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 ❤️

@macrozone
Copy link
Collaborator Author

@baransu hm, weird have to check that out. Thx for your feedback <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants