three.js - Control multiple cameras with the same controls -


i have 2 different threejs scenes , each has own camera. can control each camera individually corresponding trackballcontrols instance.

is there reliable way 'lock' or 'bind' these controls together, manipulating 1 causes same camera repositioning in other? current approach add change listeners controls , update both cameras either's change, isn't neat as, one, both controls can changing @ once (due dampening).

i believe should work if set matrices of second camera values of first , disable automatic matrix-updates of both cameras:

camera2.matrix = camera1.matrix; camera2.projectionmatrix = camera1.projectionmatrix; camera1.matrixautoupdate = false; camera2.matrixautoupdate = false; 

but need update matrix manually in renderloop:

camera1.updatematrix(); 

that call take values position, rotation , scale (that have been updated controls) , compose them camera1.matrix, per assignment before used matrix second camera.

however, feels bit hacky , can lead sorts of weird problems. prefer more explicit approach have implemented.

question why using 2 camera- , controls-instances? long camera isn't added scene can render both scenes using same camera.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -