/
CameraPrototypes.json
2159 lines (2159 loc) · 89.7 KB
/
CameraPrototypes.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ "X3D": {
"encoding":"UTF-8",
"@profile":"Immersive",
"@version":"3.2",
"@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.2.xsd",
"JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
"head": {
"meta": [
{
"@name":"title",
"@content":"CameraPrototypes.x3d"
},
{
"@name":"description",
"@content":"Camera, CameraShot and CameraMovement prototypes that demonstrate storyboard capabilities and precise camera operation. This is a developmental effort for potential X3D Specification improvement."
},
{
"@name":"creator",
"@content":"Don Brutzman and Jeff Weekley"
},
{
"@name":"created",
"@content":"16 March 2009"
},
{
"@name":"modified",
"@content":"25 October 2016"
},
{
"@name":"TODO",
"@content":"Schematron rules, backed up by initialize() checks"
},
{
"@name":"reference",
"@content":"BeyondViewpointCameraNodesWeb3D2009.pdf"
},
{
"@name":"reference",
"@content":"https://www.web3d.org/x3d/specifications/ISO-IEC-FDIS-19775-1.2-X3D-AbstractSpecification/Part01/components/navigation.html"
},
{
"@name":"subject",
"@content":"Camera nodes for Viewpoint navigation control"
},
{
"@name":"reference",
"@content":"CameraExamples.x3d"
},
{
"@name":"identifier",
"@content":"https://www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypes.x3d"
},
{
"@name":"reference",
"@content":"http://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/CameraPrototypes.x3d"
},
{
"@name":"generator",
"@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
},
{
"@name":"license",
"@content":"../license.html"
},
{
"@name":"translated",
"@content":"01 March 2024"
},
{
"@name":"generator",
"@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
},
{
"@name":"reference",
"@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
}
]
},
"Scene": {
"-children":[
{
"#comment":"=============== Camera =============="
},
{ "ProtoDeclare":
{
"@name":"Camera",
"@appinfo":"Camera node provides direct control of scene view to enable cinematic camera animation shot by shot and move by move along with still digital-photography settings for offline rendering of camera images.",
"ProtoInterface": {
"-children":[
{
"#comment":"Viewpoint-related fields, NavigationInfo-related fields and Camera-unique fields"
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"Text description to be displayed for this Camera",
"@type":"SFString"
},
{
"@name":"position",
"@accessType":"inputOutput",
"@appinfo":"Camera position in local transformation frame, which is default prior to first CameraShot initialPosition getting activated",
"@type":"SFVec3f",
"@value":[0,0,10]
},
{
"@name":"orientation",
"@accessType":"inputOutput",
"@appinfo":"Camera rotation in local transformation frame, which is default prior to first CameraShot initialPosition getting activated",
"@type":"SFRotation",
"@value":[0,0,1,0]
},
{
"@name":"fieldOfView",
"@accessType":"inputOutput",
"@appinfo":"pi/4",
"@type":"SFFloat",
"@value":0.7854
},
{
"@name":"set_fraction",
"@accessType":"inputOnly",
"@appinfo":"input fraction drives interpolators",
"@type":"SFFloat"
},
{
"@name":"set_bind",
"@accessType":"inputOnly",
"@appinfo":"input event binds or unbinds this Camera",
"@type":"SFBool"
},
{
"@name":"bindTime",
"@accessType":"outputOnly",
"@appinfo":"output event indicates when this Camera is bound",
"@type":"SFTime"
},
{
"@name":"isBound",
"@accessType":"outputOnly",
"@appinfo":"output event indicates whether this Camera is bound or unbound",
"@type":"SFBool"
},
{
"@name":"nearClipPlane",
"@accessType":"inputOutput",
"@appinfo":"Vector distance to near clipping plane corresponds to NavigationInfo.avatarSize[0]",
"@type":"SFFloat",
"@value":0.25
},
{
"@name":"farClipPlane",
"@accessType":"inputOutput",
"@appinfo":"Vector distance to far clipping plane corresponds to NavigationInfo.visibilityLimit",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shots",
"@accessType":"inputOutput",
"@appinfo":"Array of CameraShot nodes which in turn contain CameraMovement nodes",
"@type":"MFNode",
"-children":[
{
"#comment":"initialization nodes (if any) go here"
}
]
},
{
"@name":"headlight",
"@accessType":"inputOutput",
"@appinfo":"Whether camera headlight is on or off",
"@type":"SFBool",
"@value":true
},
{
"@name":"headlightColor",
"@accessType":"inputOutput",
"@appinfo":"Camera headlight color",
"@type":"SFColor",
"@value":[1,1,1]
},
{
"@name":"headlightIntensity",
"@accessType":"inputOutput",
"@appinfo":"Camera headlight intensity",
"@type":"SFFloat",
"@value":1
},
{
"@name":"filterColor",
"@accessType":"inputOutput",
"@appinfo":"Camera filter color that modifies virtual lens capture",
"@type":"SFColor",
"@value":[1,1,1]
},
{
"@name":"filterTransparency",
"@accessType":"inputOutput",
"@appinfo":"Camera filter transparency that modifies virtual lens capture",
"@type":"SFFloat",
"@value":1
},
{
"@name":"upVector",
"@accessType":"inputOutput",
"@appinfo":"upVector changes modify camera orientation (and possibly vice versa)",
"@type":"SFVec3f",
"@value":[0,1,0]
},
{
"@name":"fStop",
"@accessType":"inputOutput",
"@appinfo":"Focal length divided effective aperture diameter indicating width of focal plane",
"@type":"SFFloat",
"@value":5.6
},
{
"@name":"focusDistance",
"@accessType":"inputOutput",
"@appinfo":"Distance to focal plane of sharpest focus",
"@type":"SFFloat",
"@value":10
},
{
"@name":"isActive",
"@accessType":"outputOnly",
"@appinfo":"Mark start/stop with true/false output respectively useful to trigger external animations",
"@type":"SFBool"
},
{
"@name":"totalDuration",
"@accessType":"outputOnly",
"@appinfo":"Total duration of contained enabled CameraShot (and thus CameraMovement) move durations",
"@type":"SFTime"
},
{
"@name":"offlineRender",
"@accessType":"inputOutput",
"@appinfo":"OfflineRender node",
"@type":"SFNode",
"-children":[
{
"#comment":"initialization node (if any) goes here"
}
]
},
{
"@name":"traceEnabled",
"@accessType":"initializeOnly",
"@appinfo":"enable console output to trace script computations and prototype progress",
"@type":"SFBool",
"@value":false
}
]
},
"ProtoBody": {
"-children":[
{ "Viewpoint":
{
"@DEF":"CameraViewpoint",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"position",
"@protoField":"position"
},
{
"@nodeField":"orientation",
"@protoField":"orientation"
},
{
"@nodeField":"fieldOfView",
"@protoField":"fieldOfView"
},
{
"@nodeField":"set_bind",
"@protoField":"set_bind"
},
{
"@nodeField":"bindTime",
"@protoField":"bindTime"
},
{
"@nodeField":"isBound",
"@protoField":"isBound"
}
]
}
}
},
{
"#comment":"NavInfo EXAMINE used since some browsers (InstantReality) try to lock view to vertical when flying to avoid disorientation"
},
{ "NavigationInfo":
{
"@DEF":"CameraNavInfo",
"@type":"\"EXAMINE\" \"FLY\" \"ANY\"",
"IS": {
"connect": [
{
"@nodeField":"set_bind",
"@protoField":"set_bind"
},
{
"@nodeField":"headlight",
"@protoField":"headlight"
},
{
"@nodeField":"visibilityLimit",
"@protoField":"farClipPlane"
}
],
"-children":[
{
"#comment":"No need to bind outputs bindTime, isBound from NavigationInfo since Viewpoint outputs will suffice. TODO inform BitManagement that bindTime field is missing."
}
]
}
}
},
{
"#comment":"this DirectionalLight replaces NavigationInfo headlight in order to add color capability"
},
{ "DirectionalLight":
{
"@DEF":"CameraDirectionalLight",
"@global":true,
"-children":[
{
"#comment":"TODO confirm other default field values match NavigationInfo spec"
}
],
"IS": {
"connect": [
{
"@nodeField":"on",
"@protoField":"headlight"
},
{
"@nodeField":"color",
"@protoField":"headlightColor"
},
{
"@nodeField":"intensity",
"@protoField":"headlightIntensity"
}
]
}
}
},
{ "PositionInterpolator":
{
"@DEF":"CameraPositionInterpolator",
"@key":[0,1],
"@keyValue":[0,0,0,0,0,0],
"IS": {
"connect": [
{
"@nodeField":"set_fraction",
"@protoField":"set_fraction"
}
]
}
}
},
{ "OrientationInterpolator":
{
"@DEF":"CameraOrientationInterpolator",
"@key":[0,1],
"@keyValue":[0,1,0,0,0,1,0,0],
"IS": {
"connect": [
{
"@nodeField":"set_fraction",
"@protoField":"set_fraction"
}
]
}
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"CameraPositionInterpolator",
"@toField":"position",
"@toNode":"CameraViewpoint"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"CameraOrientationInterpolator",
"@toField":"orientation",
"@toNode":"CameraViewpoint"
}
},
{ "Script":
{
"@DEF":"CameraScript",
"@directOutput":true,
"@mustEvaluate":true,
"-children":[
{
"#comment":"binding is controlled externally, all camera operations proceed the same regardless of whether bound or not"
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"Text description to be displayed for this Camera",
"@type":"SFString"
},
{
"@name":"position",
"@accessType":"inputOutput",
"@appinfo":"Camera position in local transformation frame",
"@type":"SFVec3f"
},
{
"@name":"orientation",
"@accessType":"inputOutput",
"@appinfo":"Camera rotation in local transformation frame",
"@type":"SFRotation"
},
{
"@name":"set_fraction",
"@accessType":"inputOnly",
"@appinfo":"input fraction drives interpolators",
"@type":"SFFloat"
},
{
"@name":"set_bind",
"@accessType":"inputOnly",
"@appinfo":"input event binds or unbinds this Camera",
"@type":"SFBool"
},
{
"@name":"fieldOfView",
"@accessType":"inputOutput",
"@appinfo":"pi/4",
"@type":"SFFloat"
},
{
"@name":"nearClipPlane",
"@accessType":"inputOutput",
"@appinfo":"Vector distance to near clipping plane",
"@type":"SFFloat"
},
{
"@name":"farClipPlane",
"@accessType":"inputOutput",
"@appinfo":"Vector distance to far clipping plane",
"@type":"SFFloat"
},
{
"@name":"shots",
"@accessType":"inputOutput",
"@appinfo":"Array of CameraShot nodes which in turn contain CameraMovement nodes",
"@type":"MFNode",
"-children":[
{
"#comment":"initialization nodes (if any) go here"
}
]
},
{
"@name":"filterColor",
"@accessType":"inputOutput",
"@appinfo":"Camera filter color that modifies virtual lens capture",
"@type":"SFColor"
},
{
"@name":"filterTransparency",
"@accessType":"inputOutput",
"@appinfo":"Camera filter transparency that modifies virtual lens capture",
"@type":"SFFloat"
},
{
"@name":"upVector",
"@accessType":"inputOutput",
"@appinfo":"upVector changes modify camera orientation (and possibly vice versa)",
"@type":"SFVec3f"
},
{
"@name":"fStop",
"@accessType":"inputOutput",
"@appinfo":"Focal length divided effective aperture diameter indicating width of focal plane",
"@type":"SFFloat"
},
{
"@name":"focusDistance",
"@accessType":"inputOutput",
"@appinfo":"Distance to focal plane of sharpest focus",
"@type":"SFFloat"
},
{
"@name":"isActive",
"@accessType":"outputOnly",
"@appinfo":"Mark start/stop with true/false output respectively useful to trigger external animations",
"@type":"SFBool"
},
{
"@name":"totalDuration",
"@accessType":"outputOnly",
"@appinfo":"Total duration of contained enabled CameraShot (and thus CameraMovement) move durations",
"@type":"SFTime"
},
{
"@name":"offlineRender",
"@accessType":"inputOutput",
"@appinfo":"OfflineRender node",
"@type":"SFNode",
"-children":[
{
"#comment":"initialization node (if any) goes here"
}
]
},
{
"@name":"ViewpointNode",
"@accessType":"initializeOnly",
"@appinfo":"node reference to permit getting setting fields from within Script",
"@type":"SFNode",
"-children":[
{ "Viewpoint":
{
"@USE":"CameraViewpoint"
}
}
]
},
{
"@name":"NavInfoNode",
"@accessType":"initializeOnly",
"@appinfo":"node reference to permit getting setting fields from within Script",
"@type":"SFNode",
"-children":[
{ "NavigationInfo":
{
"@USE":"CameraNavInfo"
}
}
]
},
{
"@name":"CameraPI",
"@accessType":"initializeOnly",
"@appinfo":"node reference to permit getting setting fields from within Script",
"@type":"SFNode",
"-children":[
{ "PositionInterpolator":
{
"@USE":"CameraPositionInterpolator"
}
}
]
},
{
"@name":"CameraOI",
"@accessType":"initializeOnly",
"@appinfo":"node reference to permit getting setting fields from within Script",
"@type":"SFNode",
"-children":[
{ "OrientationInterpolator":
{
"@USE":"CameraOrientationInterpolator"
}
}
]
},
{
"@name":"key",
"@accessType":"inputOutput",
"@appinfo":"key array for interpolators",
"@type":"MFFloat"
},
{
"@name":"keyValuePosition",
"@accessType":"inputOutput",
"@appinfo":"keyValue array for PositionInterpolator",
"@type":"MFVec3f"
},
{
"@name":"keyValueOrientation",
"@accessType":"inputOutput",
"@appinfo":"keyValue array for OrientationInterpolator",
"@type":"MFRotation"
},
{
"@name":"animated",
"@accessType":"inputOutput",
"@appinfo":"whether internal CameraShot and CameraMove nodes are tracking or changed via ROUTE events",
"@type":"SFBool",
"@value":false
},
{
"@name":"initialized",
"@accessType":"initializeOnly",
"@appinfo":"perform checkShots() function once immediately after initialization",
"@type":"SFBool",
"@value":false
},
{
"@name":"shotCount",
"@accessType":"initializeOnly",
"@appinfo":"how many CameraShot nodes are contained in shots array",
"@type":"SFInt32",
"@value":0
},
{
"@name":"movesCount",
"@accessType":"initializeOnly",
"@appinfo":"how many CameraMove nodes are contained in moves array",
"@type":"SFInt32",
"@value":0
},
{
"@name":"frameCount",
"@accessType":"initializeOnly",
"@appinfo":"how many frames were created in current loop",
"@type":"SFFloat",
"@value":0
},
{
"@name":"startTime",
"@accessType":"initializeOnly",
"@appinfo":"holding variable",
"@type":"SFTime",
"@value":0
},
{
"@name":"priorTraceTime",
"@accessType":"initializeOnly",
"@appinfo":"holding variable",
"@type":"SFTime",
"@value":0
},
{
"@name":"traceEnabled",
"@accessType":"initializeOnly",
"@appinfo":"enable console output to trace script computations and prototype progress",
"@type":"SFBool"
}
],
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"position",
"@protoField":"position"
},
{
"@nodeField":"orientation",
"@protoField":"orientation"
},
{
"@nodeField":"set_fraction",
"@protoField":"set_fraction"
},
{
"@nodeField":"set_bind",
"@protoField":"set_bind"
},
{
"@nodeField":"fieldOfView",
"@protoField":"fieldOfView"
},
{
"@nodeField":"nearClipPlane",
"@protoField":"nearClipPlane"
},
{
"@nodeField":"farClipPlane",
"@protoField":"farClipPlane"
},
{
"@nodeField":"shots",
"@protoField":"shots"
},
{
"@nodeField":"filterColor",
"@protoField":"filterColor"
},
{
"@nodeField":"filterTransparency",
"@protoField":"filterTransparency"
},
{
"@nodeField":"upVector",
"@protoField":"upVector"
},
{
"@nodeField":"fStop",
"@protoField":"fStop"
},
{
"@nodeField":"focusDistance",
"@protoField":"focusDistance"
},
{
"@nodeField":"isActive",
"@protoField":"isActive"
},
{
"@nodeField":"totalDuration",
"@protoField":"totalDuration"
},
{
"@nodeField":"offlineRender",
"@protoField":"offlineRender"
},
{
"@nodeField":"traceEnabled",
"@protoField":"traceEnabled"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize () // CameraScript",
"{",
"// tracePrint ('initialize start...');",
"",
" NavInfoNode.avatarSize[0] = nearClipPlane;",
"",
" // remaining setups deferred to invocation of checkShots() method",
" // thanks to Yvonne Jung Fraunhofer for diagnosing better approach to function initialization",
" alwaysPrint ('initialize complete');",
"}",
"",
"function checkShots (eventValue)",
"{",
" tracePrint ('checkShots() method should only occur after initialize() methods in all other Scripts are complete');",
"",
" // compute totalDuration by summing durations from contained CameraShot and CameraMovement nodes",
" totalDuration= 0;",
" shotCount = shots.length;",
" movesCount = 0;",
" for (i = 0; i < shotCount; i++) // shots index",
" {",
" tracePrint ('shots[' + i + '].moves.length=' + shots[i].moves.length);",
" movesCount += shots[i].moves.length;",
" totalDuration = totalDuration + shots[i].shotDuration;",
" if (shots[i].moves.length == 0)",
" {",
" alwaysPrint ('warning: CameraShot[' + i + '][' + shots[i].description + '] has no contained CameraMove nodes');",
" }",
" }",
" // size checks before proceeding",
" if (shotCount == 0)",
" {",
" alwaysPrint ('warning: no CameraShot nodes found for the shots, nothing to do!');",
" return;",
" }",
" else if (movesCount == 0)",
" {",
" alwaysPrint ('warning: no CameraMove nodes found for the shots, nothing to do!');",
" return;",
" }",
" else if (totalDuration == 0)",
" {",
" alwaysPrint ('warning: totalDuration = 0 seconds, nothing to do!');",
" return;",
" }",
" tracePrint ('number of contained CameraShot nodes=' + shotCount);",
" tracePrint ('number of contained CameraMove nodes=' + movesCount);",
" tracePrint ('totalDuration=' + totalDuration + ' seconds for all shots and moves');",
"",
" // compute interpolators",
" var k = 0; // index for latest key, keyValuePosition, keyValueOrientation",
" for (i = 0; i < shotCount; i++) // shots index",
" {",
" if (i==0) // initial entries",
" {",
" key[0] = 0.0; // no previous move",
" keyValuePosition[0] = shots[i].initialPosition;",
" keyValueOrientation[0] = shots[i].initialOrientation;",
" }",
" else // new shot repositions, reorients camera as clean break from preceding shot/move",
" {",
" key[k+1] = key[k]; // start from end from previous move",
" keyValuePosition[k+1] = shots[i].initialPosition;",
" keyValueOrientation[k+1] = shots[i].initialOrientation;",
" k++;",
" }",
" tracePrint (shots[i].description);",
" tracePrint ('shots[i].moves.length=' + shots[i].moves.length);",
"",
" for (j = 0; j < shots[i].moves.length; j++) // moves index",
" {",
" var durationFloat = shots[i].moves[j].duration; // implicit type conversion from SFTime",
" // durationFloat = new SFFloat (shots[i].moves[j].duration); // explicit type conversion from SFTime",
" // tracePrint ('durationFloat=' + durationFloat);",
" key[k+1] = key[k] + (durationFloat / totalDuration);",
" keyValuePosition[k+1] = shots[i].moves[j].goalPosition;",
" if (!animated)",
" {",
" keyValueOrientation[k+1] = shots[i].moves[j].goalOrientation;",
" }",
" else",
" {",
" // using constructor SFRotation (SFVec3f fromVector, SFVec3f toVector)",
" // see X3D ECMAScript binding Table 7.18 — SFRotation instance creation functions",
"",
" // test if difference vector is zero, if so maintain previous rotation",
" var shotVector = ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).normalize();",
" if (shotVector.length() >= 0)",
" {",
" // default view direction is along -Z axis",
" shots[i].moves[j].goalOrientation = new SFRotation (new SFVec3f (0, 0, 1), shotVector);",
" keyValueOrientation[k+1] = shots[i].moves[j].goalOrientation;",
" }",
" else // note (k > 0)",
" {",
" keyValueOrientation[k+1] = keyValueOrientation[k]; // no change",
" }",
"",
" tracePrint ('shots[' + i + '].moves[' + j + '].goalAimPoint=' + shots[i].moves[j].goalAimPoint.toString());",
" tracePrint (' ViewpointNode.position=' + ViewpointNode.position.toString());",
" tracePrint (' shotVector delta=' + ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).toString());",
" tracePrint (' shotVector normalize=' + ViewpointNode.position.subtract(shots[i].moves[j].goalAimPoint).normalize().toString());",
" tracePrint (' goalOrientation=' + shots[i].moves[j].goalOrientation.toString());",
" tracePrint (' keyValueOrientation[k+1]=' + keyValueOrientation[k+1].toString() + '\n');",
" }",
" k++; // update index to match latest key, keyValuePosition, keyValueOrientation",
"",
" // check animated parameter: set true if any of moves are tracking moves",
" if (!animated) animated = shots[i].moves[j].tracking; // once true, remains true",
" // tracePrint ('shots[' + i + '].moves[' + j + '].tracking=' + shots[i].moves[j].tracking + ', animated=' + animated);",
"",
" // intermediate trace",
" tracePrint (' key=' + key);",
" tracePrint (' keyValuePosition=' + keyValuePosition);",
" tracePrint ('keyValueOrientation=' + keyValueOrientation);",
" tracePrint ('- ' + shots[i].moves[j].description);",
" }",
" }",
" tracePrint (' key=' + key);",
" tracePrint (' keyValuePosition=' + keyValuePosition);",
" tracePrint ('keyValueOrientation=' + keyValueOrientation);",
" if (key.length != keyValuePosition.length)",
" {",
" alwaysPrint ('warning: internal error during array construction, ' +",
" 'key.length=' + key.length + ' must equal ' +",
" 'keyValuePosition.length=' + keyValuePosition.length);",
" }",
" if (key.length != keyValueOrientation.length)",
" {",
" alwaysPrint ('warning: internal error during array construction, ' +",
" 'key.length=' + key.length + ' must equal ' +",
" 'keyValueOrientation.length=' + keyValueOrientation.length);",
" }",
" if (key.length != (shotCount + movesCount))",
" {",
" alwaysPrint ('warning: internal error during array construction, ' +",
" 'key.length=' + key.length + ' must equal ' +",
" '(shotCount + movesCount)=' + (shotCount + movesCount));",
" }",
" tracePrint (' animated=' + animated);",
" // set node values",
" CameraPI.key = key;",
" CameraOI.key = key;",
" CameraPI.keyValue = keyValuePosition;",
" CameraOI.keyValue = keyValueOrientation;",
"",
" if (!animated) // output results",
" {",
" tracePrint ('<PositionInterpolator DEF=\\'CameraPositionInterpolator\\' key=\\'' + stripBrackets(CameraPI.key) + '\\' keyValue=\\'' + stripBrackets(CameraPI.keyValue) + '\\'/>');",
" tracePrint ('<OrientationInterpolator DEF=\\'CameraOrientationInterpolator\\' key=\\'' + stripBrackets(CameraOI.key) + '\\' keyValue=\\'' + stripBrackets(CameraOI.keyValue) + '\\'/>');",
" }",
" tracePrint ('checkShots() complete');",
"}",
"",
"function stripBrackets (fieldArray)",
"{",
" // some browsers add brackets to array output strings, this function strips them",
" outputString = '';",
" for (i = 0; i < fieldArray.length; i++)",
" {",
" outputString += fieldArray[i].toString();",
" if (i < fieldArray.length - 1) outputString += ' ';",
" }",
" return outputString;",
"}",
"",
"function set_fraction (eventValue, timestamp) // input event received for inputOnly field",
"{",
" // traceEnabled = false; // for testing purposes",
"",
" // if Camera is being animated, immediately recompute interpolator settings",
" if (animated) checkShots (true);",
"",
" // trace progress on console with reduced output frequency",
" if (frameCount == 0)",
" {",
" alwaysPrint ('Animation loop commencing, timestamp=' + timestamp);",
" startTime = timestamp;",
" priorTraceTime = timestamp;",
" alwaysPrint ('shotClock=' + (timestamp - startTime) + ' seconds, frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());",
"",
" if (animated) // output results",
" {",
" // TODO how to report or speed up response? alwaysPrint (' aimPoint=' + aimPoint.toString());",
" tracePrint (' <PositionInterpolator DEF=\\'CameraPositionInterpolator\\' key=\\'' + stripBrackets(CameraPI.key) + '\\' keyValue=\\'' + stripBrackets(CameraPI.keyValue) + '\\'/>');",
" tracePrint (' <OrientationInterpolator DEF=\\'CameraOrientationInterpolator\\' key=\\'' + stripBrackets(CameraOI.key) + '\\' keyValue=\\'' + stripBrackets(CameraOI.keyValue) + '\\'/>');",
" }",
" }",
" else if ((timestamp - priorTraceTime) >= 1.0) // 1 second trace interval",
" {",
" alwaysPrint ('shotClock=' + (timestamp - startTime) + ' seconds, frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());",
" priorTraceTime = timestamp;",
"",
" if (animated) // output results",
" {",
" // TODO how to report or speed up response? alwaysPrint (' aimPoint=' + aimPoint.toString());",
" tracePrint (' <PositionInterpolator DEF=\\'CameraPositionInterpolator\\' key=\\'' + stripBrackets(CameraPI.key) + '\\' keyValue=\\'' + stripBrackets(CameraPI.keyValue) + '\\'/>');",
" alwaysPrint (' <OrientationInterpolator DEF=\\'CameraOrientationInterpolator\\' key=\\'' + stripBrackets(CameraOI.key) + '\\' keyValue=\\'' + stripBrackets(CameraOI.keyValue) + '\\'/>');",
" }",
" }",
" if (eventValue == 0)",
" {",
" // note that zero value is not necessarily sent first by TimeSensor, so otherwise ignored",
" frameCount++;",
" }",
" else if (eventValue == 1)",
" {",
" alwaysPrint ('shotClock=' + (timestamp - startTime) + ', frameCount=' + frameCount + ', fraction=' + eventValue + ', position=' + ViewpointNode.position.toString() + ', orientation=' + ViewpointNode.orientation.toString());",
" if (animated) // output results",
" {",
" // TODO how to report or speed up response? alwaysPrint (' aimPoint=' + aimPoint.toString());",
" }",
" alwaysPrint ('Animation loop complete.');",
" // do not unbind the Viewpoint and NavigationInfo nodes, let that be controlled externally",
" }",
" else",
" {",
" frameCount++;",
" }",
"}",
"",
"function set_bind (eventValue) // input event received for inputOnly field",
"{",
" // need to ensure CameraShot nodes are properly initialized",
" if (initialized == false)",
" {",
" checkShots (true);",
" initialized = true;",
" }",
" if (eventValue)",
" {",
" tracePrint ('Camera has been bound');",
" }",
" else",
" {",
" tracePrint ('Camera has been unbound');",
" }",
"}",
"",
"function set_description (eventValue) // input event received for inputOutput field",
"{",
" description = eventValue;",
"}",
"",
"function set_position (eventValue) // input event received for inputOutput field",
"{",
" position = eventValue;",
"}",
"",
"function set_orientation (eventValue) // input event received for inputOutput field",
"{",
" orientation = eventValue;",
"}",
"",
"function set_fieldOfView (eventValue) // input event received for inputOutput field",
"{",
" fieldOfView = eventValue;",
"}",
"",
"function set_nearClipPlane (eventValue) // input event received for inputOutput field",
"{",
" nearClipPlane = eventValue;",
"}",
"",
"function set_farClipPlane (eventValue) // input event received for inputOutput field",
"{",
" farClipPlane = eventValue;",
"}",