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

Troika Physics #15

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Conversation

RichardTrott
Copy link
Contributor

@RichardTrott RichardTrott commented Oct 3, 2019

New troika-physics module, powered by ammo.js.

Example Usage

class MyFacade extends InstanceableObject3DFacade {...}

const MyFacadePhysical = extendAsPhysical(MyFacade)

<Canvas3D
  continuousRender={true}
  objects={[
    {
      key: 'physicsManager',
      facade: PhysicsManager,
      simulationEnabled: true,
      children: [
        {
          key: 'ground',
          facade: MyGroundFacade,
          physics: {
            isStatic: true,
            restitution: 0.2
          }
        },
        {
          key: 'foo',
          facade: MyFacadePhysical,
          physics: {
            mass: 20,
            friction: 0.2,
            restitution: 0.8
          }
        }
      ]
    }
  ]}
/>
  • Physics World running in a dedicated worker using the WASM build of Ammo.js
  • WIP Soft body support. Reads vertices from the Facade's BufferGeometry and creates the soft volume automatically.
  • WIP Rigid body support. Attempts to infer an appropriate CollisionShape from the Facade's ThreeJS Geometry

}
}

// FIXME should this attempt to force the parent world into continuousRender mode?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you add a this.notifyWorld('needsRender') call in the worker response handler, that should give a similar result as continousRender.

Alternatively, you could consider having the physics manager set up its own timing loop rather than hooking in to onBeforeRender.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions, that definitely sounds cleaner. I'll investigate those options next.

Richard Trott added 14 commits October 14, 2019 16:23
… code portability and remove unused components.
…rent physics engines. Default package `main` files to ammo.js implementation. Update all worker code to use WorkerModules
…ule-ified Ammo.js output file. Add TODO for finishing ASM.js fallback
…, refactor worker messages to use transferable, start new MouseInteractionExample, integrate adapted AmmoDebugDrawer
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.

None yet

2 participants