From b06eea894379c6327680a3da4aedd3d19cb6ece1 Mon Sep 17 00:00:00 2001 From: Nathan Mande Date: Wed, 4 Sep 2024 15:44:24 +0200 Subject: [PATCH] feat: rigid body continued (#18) * Add `` and `` components * feat: world and rigid boxy * chore: add prettier for coding harmony * chore(config): correct `vite` configuration ### Desccription - Add missing `name` & `description` from package.json - Format vite config file * feat: add `trimesh` supporrt ### Description - Uncomment & implement `trimesh` support - Add `heightfield` todo comment Co-Authored-By: Alvaro Saburido * chore(config): add bracket & endline prettier support * refactor: better access to rapier context ### Description - Correct `world` step usage - Correctly update the `timestep` - Use correct type for `useRapierContext` - Improve methods documentation Co-Authored-By: Alvaro Saburido * chore(deps): install packages with `pnpm` * refactor(architecture): better structure separation ### Description - Move `vue` components at `./src/components/` - Move all types/interfaces at `./src/types` - Add `RigidBodyType` type (containing the supported rigidBodyDesc types) - Add `RigidBodyProps` interface - Add `InjectableRapierContext` interface - Add `PhysicsProps` interface - Add `ColliderShape` type - Move helper/utils at `./src/utils/` - Rename `createColliderDesc` to `createColliderDesc`, and return a `ColliderDesc` - Rename `createRigidBody` to `createRigidBodyDesc` and return a `RigidBodyDesc` - Add a `./src/constants/` sub folder Co-Authored-By: Alvaro Saburido * feat: delegate responsibilities to sub-utils ### Description - Add `createRigiBody` util - Add `CreateRigidBodyProps` type - `createRigidBodyDesc` need an object now - Add `CreateRigidBodyDescProps` type - `createColliderDesc ` need an object now - Add `CreateColliderDescProps ` type - Add `createCollider` util - Add `CreateColliderProps` type - Add `createColliderFromChildren` util - Add `CreateColliderFromChildrenProps` type - Map received children colliders and update their states * feat: add `hull` collider ### Description - Add `convexHull` colliderDesc support * feat: base of instanced `mesh` support * feat: rigid-body instance Matrix compose support ### Description - Add `instancedMesh` rigid-body position support - Add `instancedMesh` rigid-body rotation support - Make `createRigidBody` export the received `object` - Add `CreateRigidBodyReturnType` - Make `createCollider` export the received `object` - Add `CreateColliderReturnType` * refactor(style): request changes improvements ### description - Remove redundant suffixes - Add missing types to callbacks params Co-Authored-By: Alvaro Saburido --------- Co-authored-by: Francesco Michelini Co-authored-by: alvarosabu --- package.json | 2 + playground/src/pages/basics/RigidBodyDemo.vue | 64 +- pnpm-lock.yaml | 2232 +++++++++++------ src/{core => components}/Debug.vue | 15 +- src/{core => components}/Physics.vue | 8 +- src/components/RigidBody.vue | 137 + src/composables/useRapier.ts | 79 +- src/constants/object.ts | 6 + src/constants/physics.ts | 1 + src/core/RigidBody.vue | 102 - src/core/index.ts | 10 +- src/core/injectionKeys.ts | 8 +- src/types/collider.ts | 55 + src/types/physics.ts | 1 + src/types/rapier.ts | 42 + src/types/rigid-body.ts | 56 + src/utils/collider.ts | 120 + src/utils/rigid-body.ts | 71 + vite.config.ts | 14 +- 19 files changed, 2106 insertions(+), 917 deletions(-) rename src/{core => components}/Debug.vue (82%) rename src/{core => components}/Physics.vue (71%) create mode 100644 src/components/RigidBody.vue create mode 100644 src/constants/object.ts create mode 100644 src/constants/physics.ts delete mode 100644 src/core/RigidBody.vue create mode 100644 src/types/collider.ts create mode 100644 src/types/physics.ts create mode 100644 src/types/rapier.ts create mode 100644 src/types/rigid-body.ts create mode 100644 src/utils/collider.ts create mode 100644 src/utils/rigid-body.ts diff --git a/package.json b/package.json index 95d9651..c346970 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "version": "0.0.0", "private": true, "packageManager": "pnpm@9.7.1", + "description": "TresJs physics support, powered by rapier", + "author": "Alvaro Saburido (https://github.com/alvarosabu/)", "license": "MIT", "keywords": [ "vue", diff --git a/playground/src/pages/basics/RigidBodyDemo.vue b/playground/src/pages/basics/RigidBodyDemo.vue index ca5e921..7778aa7 100644 --- a/playground/src/pages/basics/RigidBodyDemo.vue +++ b/playground/src/pages/basics/RigidBodyDemo.vue @@ -1,8 +1,10 @@