@@ -15,9 +15,7 @@ import { ReconcilerRoot, extend, createRoot, unmountComponentAtNode, RenderProps
15
15
import { createPointerEvents } from './events'
16
16
import { DomEvent } from '../core/events'
17
17
18
- export interface CanvasProps
19
- extends Omit < RenderProps < HTMLCanvasElement > , 'size' > ,
20
- React . HTMLAttributes < HTMLDivElement > {
18
+ export interface CanvasProps extends RenderProps < HTMLCanvasElement > , React . HTMLAttributes < HTMLDivElement > {
21
19
children ?: React . ReactNode
22
20
ref ?: React . Ref < HTMLCanvasElement >
23
21
/** Canvas fallback content, similar to img's alt prop */
@@ -37,6 +35,7 @@ function CanvasImpl({
37
35
ref,
38
36
children,
39
37
fallback,
38
+ size : manualSize ,
40
39
resize,
41
40
style,
42
41
gl,
@@ -83,7 +82,8 @@ function CanvasImpl({
83
82
84
83
useIsomorphicLayoutEffect ( ( ) => {
85
84
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 ) {
87
87
if ( ! root . current ) root . current = createRoot < HTMLCanvasElement > ( canvas )
88
88
89
89
async function run ( ) {
@@ -101,7 +101,7 @@ function CanvasImpl({
101
101
performance,
102
102
raycaster,
103
103
camera,
104
- size : containerRect ,
104
+ size,
105
105
// Pass mutable reference to onPointerMissed so it's free to update
106
106
onPointerMissed : ( ...args ) => handlePointerMissed . current ?.( ...args ) ,
107
107
onCreated : ( state ) => {
0 commit comments