@@ -15,9 +15,7 @@ import { ReconcilerRoot, extend, createRoot, unmountComponentAtNode, RenderProps
1515import { createPointerEvents } from './events'
1616import { DomEvent } from '../core/events'
1717
18- export interface CanvasProps
19- extends Omit < RenderProps < HTMLCanvasElement > , 'size' > ,
20- React . HTMLAttributes < HTMLDivElement > {
18+ export interface CanvasProps extends RenderProps < HTMLCanvasElement > , React . HTMLAttributes < HTMLDivElement > {
2119 children ?: React . ReactNode
2220 ref ?: React . Ref < HTMLCanvasElement >
2321 /** Canvas fallback content, similar to img's alt prop */
@@ -37,6 +35,7 @@ function CanvasImpl({
3735 ref,
3836 children,
3937 fallback,
38+ size : manualSize ,
4039 resize,
4140 style,
4241 gl,
@@ -83,7 +82,8 @@ function CanvasImpl({
8382
8483 useIsomorphicLayoutEffect ( ( ) => {
8584 const canvas = canvasRef . current
86- if ( containerRect . width > 0 && containerRect . height > 0 && canvas ) {
85+ const size = manualSize ?? containerRect
86+ if ( size . width > 0 && size . height > 0 && canvas ) {
8787 if ( ! root . current ) root . current = createRoot < HTMLCanvasElement > ( canvas )
8888
8989 async function run ( ) {
@@ -101,7 +101,7 @@ function CanvasImpl({
101101 performance,
102102 raycaster,
103103 camera,
104- size : containerRect ,
104+ size,
105105 // Pass mutable reference to onPointerMissed so it's free to update
106106 onPointerMissed : ( ...args ) => handlePointerMissed . current ?.( ...args ) ,
107107 onCreated : ( state ) => {
0 commit comments