@@ -9,6 +9,8 @@ import { Dummy, loadModel } from './props/Dummy.js';
9
9
import { Node } from './sensors/Node.js' ;
10
10
import { Lidar } from './sensors/Lidar.js' ;
11
11
12
+ import { getCamerasTypes } from '/js/data.js' ;
13
+
12
14
class SceneObjects {
13
15
static loadFont ( isBuilder , callback )
14
16
{
@@ -185,6 +187,8 @@ class SceneObjects{
185
187
document . getElementById ( "display-frustums-button" ) . classList . remove ( "hidden" ) ;
186
188
187
189
this . populateStorage ( ) ;
190
+
191
+ return newCamera ;
188
192
}
189
193
190
194
this . displayFrustums = function ( )
@@ -220,6 +224,33 @@ class SceneObjects{
220
224
this . populateStorage ( ) ;
221
225
}
222
226
227
+ this . duplicateNode = function ( node )
228
+ {
229
+ const newCameraTypeData = getCamerasTypes ( ) . find ( type => type . name === node . cameraType . name ) ;
230
+ const newCamera = this . addNode ( false , sceneManager . trackingMode , Node . DEFAULT_CAMERA_TYPE_ID , 0 , 0 , node . zPos , node . xRot , node . yRot , node . zRot ) ;
231
+
232
+ newCamera . setType ( newCameraTypeData , sceneManager ) ;
233
+
234
+ // Update UI
235
+ const selectElement = document . getElementById ( `cam-type-${ newCamera . id } ` ) ;
236
+
237
+ if ( selectElement ) {
238
+ selectElement . value = newCamera . cameraType . name ;
239
+
240
+ // Here we send a fake "change" message on the selectElement to activate chageCameraType function in nodeUI.js
241
+ const changeEvent = new Event ( 'change' , {
242
+ bubbles : true ,
243
+ cancelable : true
244
+ } ) ;
245
+ selectElement . dispatchEvent ( changeEvent ) ;
246
+
247
+ } else {
248
+ console . error ( `L'élément select 'cam-type-${ newCamera . id } ' n'a pas été trouvé pour la duplication.` ) ;
249
+ }
250
+
251
+ this . populateStorage ( ) ;
252
+ }
253
+
223
254
this . addLidar = function ( autoConstruct = false , typeID = Lidar . DEFAULT_LIDAR_TYPE_ID , x = 0 , z = Lidar . DEFAULT_LIDAR_HEIGHT , r = 0 )
224
255
{
225
256
if ( ! SceneObjects . font )
0 commit comments