1- import { OrthographicCamera , PerspectiveCamera , Scene } from "three"
1+ import { OrthographicCamera , PerspectiveCamera , Scene , Vector3 } from "three"
22
33import { DEFAULT_CAMERA_OPTIONS } from "../../constants/defaultCameraOptions"
44import {
55 ABOVE_FIELD_CAMERA ,
66 BLUE_GOAL_CAMERA ,
77 ORANGE_GOAL_CAMERA ,
8- ORTHOGRAPHIC_CAMERA ,
8+ ORTHOGRAPHIC ,
99} from "../../constants/gameObjectNames"
1010
1111export const addCameras = ( scene : Scene ) => {
@@ -24,24 +24,50 @@ export const addCameras = (scene: Scene) => {
2424 aboveFieldCamera . position . set ( 0 , 2000 , 0 )
2525 scene . add ( aboveFieldCamera )
2626
27- const orthographicCamera = new OrthographicCamera (
28- - 320 ,
29- 320 ,
30- 240 ,
31- - 240 ,
32- 0.1 ,
33- 20000
34- )
35- orthographicCamera . name = ORTHOGRAPHIC_CAMERA
36- orthographicCamera . position . set ( 3500 , 5000 , 5000 )
37- orthographicCamera . lookAt ( - 500 , 0 , - 500 )
38- orthographicCamera . zoom = 0.05
39- scene . add ( orthographicCamera )
27+ const generateOrthographicCamera = ( ) => {
28+ const camera = new OrthographicCamera ( - 320 , 320 , 240 , - 240 , 0.1 , 20000 )
29+ camera . zoom = 0.05
30+ scene . add ( camera )
31+ return camera
32+ }
33+
34+ const ORTHOGRAPHIC_X = 3500
35+ const ORTHOGRAPHIC_Y = 5000
36+ const ORTHOGRAPHIC_Z = 5000
37+
38+ const orthographicCameras = [
39+ {
40+ name : ORTHOGRAPHIC . BLUE_LEFT ,
41+ position : new Vector3 ( ORTHOGRAPHIC_X , ORTHOGRAPHIC_Y , - ORTHOGRAPHIC_Z ) ,
42+ } ,
43+ {
44+ name : ORTHOGRAPHIC . BLUE_RIGHT ,
45+ position : new Vector3 ( - ORTHOGRAPHIC_X , ORTHOGRAPHIC_Y , - ORTHOGRAPHIC_Z ) ,
46+ } ,
47+ {
48+ name : ORTHOGRAPHIC . ORANGE_LEFT ,
49+ position : new Vector3 ( - ORTHOGRAPHIC_X , ORTHOGRAPHIC_Y , ORTHOGRAPHIC_Z ) ,
50+ } ,
51+ {
52+ name : ORTHOGRAPHIC . ORANGE_RIGHT ,
53+ position : new Vector3 ( ORTHOGRAPHIC_X , ORTHOGRAPHIC_Y , ORTHOGRAPHIC_Z ) ,
54+ } ,
55+ {
56+ name : ORTHOGRAPHIC . ABOVE_FIELD ,
57+ position : new Vector3 ( 0 , 8000 , 0 ) ,
58+ } ,
59+ ] . map ( ( { name, position } ) => {
60+ const camera = generateOrthographicCamera ( )
61+ camera . name = name
62+ camera . position . set ( position . x , position . y , position . z )
63+ camera . lookAt ( 0 , 0 , 0 )
64+ return camera
65+ } )
4066
4167 return [
4268 blueGoalCamera ,
4369 orangeGoalCamera ,
4470 aboveFieldCamera ,
45- orthographicCamera ,
71+ ... orthographicCameras ,
4672 ]
4773}
0 commit comments