feat: PhysicsNode + physics-demo sample (roadmap 3.2.0)#673
Merged
ThomasGorisse merged 1 commit intomainfrom Mar 20, 2026
Merged
feat: PhysicsNode + physics-demo sample (roadmap 3.2.0)#673ThomasGorisse merged 1 commit intomainfrom
ThomasGorisse merged 1 commit intomainfrom
Conversation
Adds a pure-Kotlin rigid-body physics prototype with no external library: - `sceneview/…/node/PhysicsNode.kt`: `PhysicsBody` class (Euler integration, 9.8 m/s² gravity, floor collision, restitution, sleep detection) and `PhysicsNode` composable that hooks into `Node.onFrame` to drive position each frame. - `samples/physics-demo`: standalone sample — tap to spawn bouncing spheres that fall and bounce off a floor slab; up to 10 simultaneous balls. - `settings.gradle`: register `:samples:physics-demo` module. Build verified: `:samples:physics-demo:assembleDebug` passes clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54d3c72 to
cc2ae31
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
PhysicsNode— a pure-Kotlin rigid-body composable — plus asamples/physics-demoapp that lets you tap to throw bouncing balls.PhysicsNode.kt(sceneview/src/main/java/io/github/sceneview/node/)Two public types:
PhysicsBody— simulation state for one rigid body:Node.onFrameeach frame−9.8 m/s²on Y,dtclamped to 50 ms (absorbs GC spikes)restitution0.05 m/sPhysicsNodecomposable — DSL entry point:samples/physics-demoCubeNode)SphereNodethat falls and bouncesScene {}(non-AR)Design decisions
PhysicsBodyis decoupled from Compose — can be stepped from ViewModel or imperative codefloorY: Floatfor floor detection — avoids full AABB implementation for this prototypemassdeclared for API completeness / future impulse/force extensionsTest plan
./gradlew :samples:physics-demo:assembleDebug🤖 Generated with Claude Code