@@ -23,7 +23,7 @@ function cameraParamsToUINode(camera: CameraParams | null): UINode {
2323 const params : Record < string , unknown > = camera
2424 ? { position : camera . position , target : camera . target , ...( camera . up ? { up : camera . up } : { } ) }
2525 : { } ;
26- return { id : '__camera__' , kind : 'camera' , params, children : [ ] } ;
26+ return { id : '__camera__' , kind : 'camera' , params, children : [ ] , ref : camera ?. ref } ;
2727}
2828
2929export function CameraSection ( { camera, onCameraChange } : CameraSectionProps ) {
@@ -37,15 +37,17 @@ export function CameraSection({ camera, onCameraChange }: CameraSectionProps) {
3737
3838 const cameraNode = cameraParamsToUINode ( camera ) ;
3939 const handleUpdate = ( updates : Partial < UINode > ) => {
40- if ( updates . params ) {
41- const p = updates . params ;
42- if ( p . position && p . target ) {
43- onCameraChange ( {
44- position : p . position as [ number , number , number ] ,
45- target : p . target as [ number , number , number ] ,
46- ...( p . up ? { up : p . up as [ number , number , number ] } : { } ) ,
47- } ) ;
48- }
40+ const p = updates . params ;
41+ const newRef = updates . ref !== undefined ? updates . ref : camera ?. ref ;
42+ if ( p && p . position && p . target ) {
43+ onCameraChange ( {
44+ position : p . position as [ number , number , number ] ,
45+ target : p . target as [ number , number , number ] ,
46+ ...( p . up ? { up : p . up as [ number , number , number ] } : { } ) ,
47+ ref : newRef ,
48+ } ) ;
49+ } else if ( updates . ref !== undefined && camera ) {
50+ onCameraChange ( { ...camera , ref : newRef } ) ;
4951 }
5052 } ;
5153
0 commit comments