File tree Expand file tree Collapse file tree 4 files changed +57
-4
lines changed Expand file tree Collapse file tree 4 files changed +57
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"Universe4" : {
3
3
"camera" : {
4
- "FreeCamera4" : []
4
+ "FreeCamera4::new_with_location" : [
5
+ {
6
+ "Point4" : [
7
+ -10 ,
8
+ 0 ,
9
+ 0 ,
10
+ 0
11
+ ]
12
+ }
13
+ ]
5
14
},
6
15
"entities" : [
7
16
{
Original file line number Diff line number Diff line change @@ -1329,22 +1329,34 @@ impl Parser {
1329
1329
}
1330
1330
}
1331
1331
1332
- // TODO: Add optional parameters via `Option<$($item_type:tt)+>`
1333
1332
add_deserializer ! {
1334
1333
"PitchYawCamera3" , "PitchYawCamera3::new" ;
1335
1334
-> Box <Camera3 <F >> {
1336
1335
Box :: new( PitchYawCamera3 :: new( ) )
1337
1336
}
1338
1337
}
1339
1338
1340
- // TODO: Add optional parameters via `Option<$($item_type:tt)+>`
1339
+ add_deserializer ! {
1340
+ "PitchYawCamera3::new_with_location" ;
1341
+ [ location: Point3 <F >] -> Box <Camera3 <F >> {
1342
+ Box :: new( PitchYawCamera3 :: new_with_location( location) )
1343
+ }
1344
+ }
1345
+
1341
1346
add_deserializer ! {
1342
1347
"FreeCamera3" , "FreeCamera3::new" ;
1343
1348
-> Box <Camera3 <F >> {
1344
1349
Box :: new( FreeCamera3 :: new( ) )
1345
1350
}
1346
1351
}
1347
1352
1353
+ add_deserializer ! {
1354
+ "FreeCamera3::new_with_location" ;
1355
+ [ location: Point3 <F >] -> Box <Camera3 <F >> {
1356
+ Box :: new( FreeCamera3 :: new_with_location( location) )
1357
+ }
1358
+ }
1359
+
1348
1360
add_deserializer ! {
1349
1361
"Universe4" , "Universe4::new" ;
1350
1362
[ camera: Box <Camera4 <F >>]
@@ -1360,13 +1372,19 @@ impl Parser {
1360
1372
}
1361
1373
}
1362
1374
1363
- // TODO: Add optional parameters via `Option<$($item_type:tt)+>`
1364
1375
add_deserializer ! {
1365
1376
"FreeCamera4" , "FreeCamera4::new" ;
1366
1377
-> Box <Camera4 <F >> {
1367
1378
Box :: new( FreeCamera4 :: new( ) )
1368
1379
}
1369
1380
}
1381
+
1382
+ add_deserializer ! {
1383
+ "FreeCamera4::new_with_location" ;
1384
+ [ location: Point4 <F >] -> Box <Camera4 <F >> {
1385
+ Box :: new( FreeCamera4 :: new_with_location( location) )
1386
+ }
1387
+ }
1370
1388
}
1371
1389
1372
1390
parser
Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ impl<F: CustomFloat> Camera3Data<F> {
42
42
}
43
43
}
44
44
45
+ pub fn new_with_location ( location : Point3 < F > ) -> Self {
46
+ Camera3Data {
47
+ location : location,
48
+ .. Self :: new ( )
49
+ }
50
+ }
51
+
45
52
fn get_left ( & self ) -> Vector3 < F > {
46
53
na:: cross ( & self . up , & self . forward ) . normalize ( )
47
54
}
@@ -65,6 +72,12 @@ impl<F: CustomFloat> PitchYawCamera3<F> {
65
72
}
66
73
}
67
74
75
+ pub fn new_with_location ( location : Point3 < F > ) -> Self {
76
+ PitchYawCamera3 {
77
+ data : Camera3Data :: new_with_location ( location)
78
+ }
79
+ }
80
+
68
81
fn update_rotation ( & mut self , context : & SimulationContext ) {
69
82
let delta_mouse_float: Vector2 < F > =
70
83
Vector2 :: new ( <F as NumCast >:: from ( context. delta_mouse . x ) . unwrap ( ) ,
@@ -266,6 +279,12 @@ impl<F: CustomFloat> FreeCamera3<F> {
266
279
}
267
280
}
268
281
282
+ pub fn new_with_location ( location : Point3 < F > ) -> Self {
283
+ FreeCamera3 {
284
+ data : Camera3Data :: new_with_location ( location)
285
+ }
286
+ }
287
+
269
288
fn update_rotation ( & mut self , delta_millis : F , context : & SimulationContext ) {
270
289
let delta_mouse_float: Vector2 < F > =
271
290
Vector2 :: new ( <F as NumCast >:: from ( context. delta_mouse . x ) . unwrap ( ) ,
Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ impl<F: CustomFloat> FreeCamera4<F> {
48
48
}
49
49
}
50
50
51
+ pub fn new_with_location ( location : Point4 < F > ) -> Self {
52
+ FreeCamera4 {
53
+ location : location,
54
+ .. Self :: new ( )
55
+ }
56
+ }
57
+
51
58
fn update_rotation ( & mut self , delta_millis : F , context : & SimulationContext ) {
52
59
let pressed_keys: & HashSet < VirtualKeyCode > = context. pressed_keys ( ) ;
53
60
let mut angle: F = <F as Zero >:: zero ( ) ;
You can’t perform that action at this time.
0 commit comments