Comments (3)
Looking into this, why not eagerly create World
here in state?
react-three-rapier/packages/react-three-rapier/src/Physics.tsx
Lines 152 to 159 in ab28c58
I also see this in other places, although this is initialized immediately in createWorldApi
before passing in context.
from react-three-rapier.
Good call! I'll wrap the Demos in StrictMode from now on.
There is some work to be done on RigidBody
lifecycles.
React 18 Strict Mode has some annoying but necessary behaviors in order to catch potential problems, especially in Development Mode where it runs all components twice, invoking effects and state-setters both times.
The safe way to ensure a single eagerly created instance is to use the refGetter
pattern like above βοΈ @CodyJasonBennett -- I really dislike it, but what can you do.
It would be nice to create the world
in a useState
, but then we'd have a non-symmetrical side-effect where we have to destroy it in an unrelated useEffect
.
I should be passing the refGetter
to the update hooks in the RigidBody
instead of the refs. Strict Mode is causing the component to mount multiple times, breaking the rigid body reference in the "newest" world...
Do you have suggestions on cleaner ways of handling this?
from react-three-rapier.
In this case, you would nullify worldRef.current
on unmount to unsatisfy the null check, but I wanted to understand why internals were designed that way and if they work around existing problems. Do you need access to these bodies at render? Can we remove render-effects entirely?
from react-three-rapier.
Related Issues (20)
- How to update center of origin position? HOT 1
- RigidBody Hull & Trimesh Colliders resulting in errors HOT 1
- RigidBody Colliders are not updated. HOT 2
- Colliders on PathExtrusionGeometry
- Ghost RigidBody after using setNextKinematicRotation HOT 2
- Does react-three-rapier support RN app? HOT 10
- <CuboidCollider /> component doesn't get rerender! HOT 2
- Can i get the complete control of "when Rapier does run"? HOT 1
- Collider Scale and Position to RigidBody having no effect HOT 4
- Website is broken. HOT 2
- Some Demos are laggy in Edge browser. Is it only me? HOT 3
- PrismaticJointParams donβt match up with usePrismaticJoint HOT 3
- How can I apply RigidBody to extrudeGeometry? HOT 1
- Restore world from snapshot HOT 3
- How i can load RigidBody in order HOT 2
- How to apply forces to dynamically created RigidBodies? HOT 1
- Ball Collider Fails to Interact with HeightfieldCollider in React Three Rapier
- CollisionPayload - event and other types not directly available. HOT 5
- is there an option to recompute the world base on fiber's scene change?
- Make Rapier instance available outside React/hooks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-three-rapier.