-
Notifications
You must be signed in to change notification settings - Fork 42
fix(RenderableManager): scale bounding box from center instead of origin #328
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
base: main
Are you sure you want to change the base?
Conversation
|
Do you have a full log of the build error you're getting? I will test the PR on my own, but it would be really cool to see if we could get the example app working for you. It should be "as simple as":
|
|
thanks for the PR btw! |
When a component unmounts and remounts while async resource loading is in progress, race conditions can occur: - useBuffer: stale Promise callbacks would call setBuffer() with outdated data after remount - useDisposableResource: calling release() on stale callbacks could release resources still in use by the new mount, causing "Pointer has already been manually released!" errors This commonly happens with: - Fast navigation (navigating away before loading completes) - Fast Refresh / Hot Reload during development - Conditional rendering with rapid state changes - React StrictMode (which double-mounts components in development) Changes: - Add token-based invalidation to useDisposableResource to ignore stale Promise callbacks from previous mounts - Don't call release() on stale callbacks - let GC handle cleanup via C++ shared_ptr preventing memory leaks - Add releaseOnUnmount option for explicit resource lifecycle control - Refactor useBuffer to use useDisposableResource (removes duplication)
|
@hannojg Thanks! Looks like I forgot to run |
4f36844 to
211c9ea
Compare
Add example screen to verify frustum culling behavior with scaleBoundingBox: - FrustumCulling.tsx: Interactive test with model and scale selection - hiphopgirl_offset.glb: Test model with mesh vertices baked at X=100 (world position X≈1 after Armature scale 0.01) Test behavior with offset model: - 1x, 2x scale: Model displays correctly - 5x+ scale: Model disappears due to bounding box center shift (demonstrates the bug that scaling from center fixes) Features: - Model type selection (Normal / Offset) - Scale factor selection (1x to 1000x) - Back button to return to settings
Previously, scaleBoundingBox multiplied min/max by scaleFactor, which shifted the bounding box center away from the model when the model was not at the origin. Now scales from center by: 1. Computing the bounding box center 2. Scaling the half-extent by scaleFactor 3. Reconstructing min/max from center ± scaledHalfExtent This preserves the bounding box position relative to the model, ensuring frustum culling works correctly for offset models.
211c9ea to
28aab32
Compare
|
Added a few more changes: FrustumCulling Example
StrictMode Race Condition Fix
Should I move the |
|
hey, thanks for taking the time and the awesome fixes! Actually i will leave this up to you 😊 |
|
The example app depends on the |
Summary
Fixes #326
scaleBoundingBoxto scale from the bounding box center instead of the originNote
@hannojg Thanks for the suggestion! I tried to add an example to the example app, but ran into a C++ build error on Android:
Looks like a pre-existing build config issue. Let me know if there's a workaround.