Bug Fixes and Life Improvement Features #3678
Merged
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.
forceEven Canvas Prop
Added
forceEvenprop to Canvas for Safari compatibility. Safari has issues with odd or fractional HTML canvas dimensions. When enabled, canvas dimensions are rounded up to the nearest even number.Key details:
Math.ceil(n / 2) * 2to ensure odd values round up, not downuseThree((state) => state.internal.forceEven)Files changed:
packages/fiber/types/canvas.d.ts- AddedforceEvenprop typepackages/fiber/types/store.d.ts- AddedforceEvento InternalStatepackages/fiber/src/core/Canvas.tsx- Prop destructuring and effectiveSize rounding logicpackages/fiber/src/core/renderer.tsx- Store forceEven in internal stateCanvas Background Prop
Added a flexible
backgroundprop to Canvas for declarative scene background and environment configuration. Supports colors, URLs, presets, and an expanded object form for separate background/environment maps.Simple string forms:
Expanded object form:
Key features:
backgroundMapand environment files<color attach="background">patternLoader migrations:
RGBELoader→HDRLoader(renamed in Three.js r180)HDRJPGLoader→UltraHDRLoader(Three.js native)New exports:
Environmentcomponent from@react-three/fiberuseEnvironmenthook from@react-three/fiberpresetsObjandPresetsTypefor preset namesFiles changed:
packages/fiber/types/canvas.d.ts- AddedBackgroundProp,BackgroundConfigtypespackages/fiber/src/core/Canvas.tsx- Background prop parsing and Environment renderingpackages/fiber/src/core/components/Environment/Environment.tsx- Enhanced with color/backgroundFiles supportpackages/fiber/src/core/hooks/useEnvironment.tsx- Loader migrationspackages/fiber/src/core/index.tsx- Added Environment exportspackages/fiber/src/core/hooks/index.tsx- Added useEnvironment exportMulti-Canvas Rendering (WebGPU)
Added support for sharing a single WebGPURenderer across multiple Canvas components, enabling HUD overlays, picture-in-picture views, and multi-viewport rendering.
Primary canvas setup:
Secondary canvas sharing the renderer:
Key features:
renderer={{ primaryCanvas: 'id' }}- Share renderer from another canvasscheduler.after- Control render ordering between canvasesscheduler.fps- Limit secondary canvas render rateprimaryStore- Access primary's scene/camera for HUD-style renderingColor Management Props
Added explicit
colorSpaceandtoneMappingprops for direct control over renderer color settings, deprecating the booleanlinearandflatshortcuts.New props:
colorSpace- Setrenderer.outputColorSpacedirectly (default:THREE.SRGBColorSpace)toneMapping- Setrenderer.toneMappingdirectly (default:THREE.ACESFilmicToneMapping)Deprecated props:
linear- UsecolorSpace={THREE.LinearSRGBColorSpace}insteadflat- UsetoneMapping={THREE.NoToneMapping}insteadsizestate being overwritten by parent resize events. Portals now correctly preserve their own size override when the root canvas resizes, matching the existing behavior forevents. This also fixes nested portals ignoring their size configuration.setSizenot triggering a frame in demand mode. Now callsscheduler.invalidate()directly souseFramecallbacks can respond to size changes.