File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,6 @@ export class CameraControls {
272
272
this . domElement . addEventListener ( 'wheel' , this . onMouseWheel )
273
273
this . initTouchControls ( this . enableTouchControls )
274
274
275
- window . addEventListener ( 'resize' , this . onWindowResize )
276
275
this . onWindowResize ( )
277
276
278
277
this . update ( )
@@ -396,12 +395,10 @@ export class CameraControls {
396
395
onWindowResize = ( ) => {
397
396
if ( this . camera instanceof PerspectiveCamera ) {
398
397
this . camera . aspect =
399
- this . engineCommandManager . streamDimensions . width /
400
- this . engineCommandManager . streamDimensions . height
398
+ this . domElement . clientWidth / this . domElement . clientHeight
401
399
} else if ( this . camera instanceof OrthographicCamera ) {
402
- const aspect =
403
- this . engineCommandManager . streamDimensions . width /
404
- this . engineCommandManager . streamDimensions . height
400
+ const aspect = this . domElement . clientWidth / this . domElement . clientHeight
401
+
405
402
this . camera . left = - ORTHOGRAPHIC_CAMERA_SIZE * aspect
406
403
this . camera . right = ORTHOGRAPHIC_CAMERA_SIZE * aspect
407
404
this . camera . top = ORTHOGRAPHIC_CAMERA_SIZE
Original file line number Diff line number Diff line change @@ -131,6 +131,19 @@ export const ClientSideScene = ({
131
131
}
132
132
} , [ ] )
133
133
134
+ useEffect ( ( ) => {
135
+ const canvas = canvasRef . current
136
+ if ( ! canvas ) return
137
+ const observer = new ResizeObserver ( ( ) => {
138
+ sceneInfra . onWindowResize ( )
139
+ sceneInfra . camControls . onWindowResize ( )
140
+ } )
141
+ observer . observe ( canvas )
142
+ return ( ) => {
143
+ observer . disconnect ( )
144
+ }
145
+ } , [ ] )
146
+
134
147
let cursor = 'default'
135
148
if ( state . matches ( 'Sketch' ) ) {
136
149
if (
You can’t perform that action at this time.
0 commit comments