-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basic colliders support (#120)
* feat: `BaseCollider` integration ### Description - Move out logics from `RigidBody` component - `InstancedMesh` logic in a new `InstancedRigidBody` component - `Collider` logic in a new `BaseCollider` component - Add a `BaseCollider` Component - Export extended collider components (`BallCollider`, `CuboidCollider`, etc) - Add Physics props type - Can pause the physical world from properties - Fix physical word stepping twice - Export most of the resources Co-Authored-By: Jaime A Torrealba C <[email protected]> * feat: add new examples ### Description - Simplified `RigidBody` example - Add an `InstancedMesh` example - Add a `Colliders` example Co-Authored-By: Jaime A Torrealba C <[email protected]> * fix: add missing `gravity` prop * fix(style): lint errors correction * fix(rc): post merge code resolution * refactor(core): extend props for auto values * refactor(core): correct unwanted collider object update ### Description - Configure `RigidBody`s slot to be rendered once - Implement physics unmounted logics Co-Authored-By: Jaime A Torrealba C <[email protected]> * refactor(demo): improve first balls explosion * refactor(docs): improve collider utils `js-docs` --------- Co-authored-by: Jaime A Torrealba C <[email protected]>
- Loading branch information
1 parent
2f95276
commit 07f1745
Showing
25 changed files
with
6,180 additions
and
4,726 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { BallCollider, CapsuleCollider, ConeCollider, CuboidCollider, CylinderCollider, Physics, RigidBody } from '@tresjs/rapier' | ||
import { ACESFilmicToneMapping, SRGBColorSpace } from 'three' | ||
const gl = { | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: ACESFilmicToneMapping, | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresCanvas v-bind="gl" window-size> | ||
<TresPerspectiveCamera :position="[11, 11, 11]" :look-at="[0, 0, 0]" /> | ||
<OrbitControls /> | ||
|
||
<Suspense> | ||
<Physics debug> | ||
<RigidBody> | ||
<BallCollider :args="[1, 1, 1]" :position="[2, 10, 0]" /> | ||
<CapsuleCollider :args="[1, 1, 1]" :position="[-2, 10, 0]" /> | ||
<ConeCollider :args="[1, 1, 1]" :position="[0, 10, 2]" /> | ||
<CuboidCollider :args="[1, 1, 1]" :position="[0, 10, -2]" /> | ||
<CylinderCollider :args="[1, 1, 1]" :position="[2, 10, 2]" /> | ||
</RigidBody> | ||
|
||
<RigidBody collider="cuboid"> | ||
<BallCollider :args="[1, 1, 1]" :position="[0, 15, 0]" /> | ||
|
||
<TresMesh :position="[0, 15, 0]"> | ||
<TresTorusGeometry /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
</RigidBody> | ||
|
||
<RigidBody type="fixed"> | ||
<TresMesh :position="[0, 0, 0]"> | ||
<TresPlaneGeometry :args="[20, 20, 20]" :rotate-x="-Math.PI / 2" /> | ||
<TresMeshBasicMaterial color="#f4f4f4" /> | ||
</TresMesh> | ||
</RigidBody> | ||
</Physics> | ||
</Suspense> | ||
</TresCanvas> | ||
</template> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<script setup lang="ts"> | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { Physics, RigidBody } from '@tresjs/rapier' | ||
import { ACESFilmicToneMapping, SRGBColorSpace } from 'three' | ||
const gl = { | ||
clearColor: '#82DBC5', | ||
shadows: true, | ||
alpha: false, | ||
outputColorSpace: SRGBColorSpace, | ||
toneMapping: ACESFilmicToneMapping, | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresCanvas v-bind="gl" window-size> | ||
<TresPerspectiveCamera :position="[11, 11, 11]" :look-at="[0, 0, 0]" /> | ||
<OrbitControls /> | ||
|
||
<Suspense> | ||
<Physics debug> | ||
<RigidBody> | ||
<TresMesh :position="[0, 8, 0]"> | ||
<TresTorusGeometry /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
</RigidBody> | ||
|
||
<RigidBody type="fixed"> | ||
<TresMesh :position="[0, 0, 0]"> | ||
<TresPlaneGeometry :args="[20, 20, 20]" :rotate-x="-Math.PI / 2" /> | ||
<TresMeshBasicMaterial color="#f4f4f4" /> | ||
</TresMesh> | ||
</RigidBody> | ||
</Physics> | ||
</Suspense> | ||
</TresCanvas> | ||
</template> |
This file contains 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
Oops, something went wrong.