1
+ import './style.css'
2
+ import * as THREE from 'three' ;
3
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
4
+
5
+ const scene1 = new THREE . Scene ( ) ;
6
+ const canvas1 = document . getElementById ( 'c1' ) ;
7
+
8
+ let sizeWidth1 = canvas1 . clientWidth ;
9
+ let sizeHeight1 = canvas1 . clientHeight ;
10
+
11
+ const camera1 = new THREE . PerspectiveCamera ( 75 , sizeWidth1 / sizeHeight1 , 0.1 , 1000 )
12
+
13
+ const renderer1 = new THREE . WebGLRenderer ( {
14
+ canvas : canvas1 ,
15
+ antialias : true
16
+ } ) ;
17
+ renderer1 . setPixelRatio ( Math . min ( window . devicePixelRatio , 2 ) ) ;
18
+ renderer1 . setSize ( sizeWidth1 , sizeHeight1 ) ;
19
+ renderer1 . setClearColor ( 0x1b1b1b , 1 ) ;
20
+
21
+ camera1 . position . set ( 6 , 4 , 0 ) ;
22
+ scene1 . add ( camera1 ) ;
23
+
24
+ const controls1 = new OrbitControls ( camera1 , canvas1 ) ;
25
+ controls1 . target . set ( 0 , 2.5 , 0 ) ;
26
+ controls1 . maxDistance = 12 ;
27
+ controls1 . minDistance = 5 ;
28
+ controls1 . enablePan = false ;
29
+
30
+ const gridHelper1 = new THREE . GridHelper ( 10 , 10 ) ;
31
+ scene1 . add ( gridHelper1 ) ;
32
+
33
+ const cube1 = new THREE . Mesh (
34
+ new THREE . BoxGeometry ( 1 , 1 , 1 ) ,
35
+ new THREE . MeshBasicMaterial ( { color :0xff00ff } )
36
+ ) ;
37
+ scene1 . add ( cube1 ) ;
38
+
39
+ /**
40
+ *
41
+ *
42
+ *
43
+ *
44
+ *
45
+ */
46
+
47
+ const scene2 = new THREE . Scene ( ) ;
48
+ const canvas2 = document . getElementById ( 'c2' ) ;
49
+
50
+ let sizeWidth2 = canvas2 . clientWidth ;
51
+ let sizeHeight2 = canvas2 . clientHeight ;
52
+
53
+ const camera2 = new THREE . PerspectiveCamera ( 75 , sizeWidth2 / sizeHeight2 , 0.1 , 1000 )
54
+
55
+ const renderer2 = new THREE . WebGLRenderer ( {
56
+ canvas : canvas2 ,
57
+ antialias : true
58
+ } ) ;
59
+ renderer2 . setPixelRatio ( Math . min ( window . devicePixelRatio , 2 ) ) ;
60
+ renderer2 . setSize ( sizeWidth2 , sizeHeight2 ) ;
61
+ renderer2 . setClearColor ( 0x1b1b1b , 1 ) ;
62
+
63
+ camera2 . position . set ( 6 , 4 , 0 ) ;
64
+ scene2 . add ( camera2 ) ;
65
+
66
+ const controls2 = new OrbitControls ( camera2 , canvas2 ) ;
67
+ controls2 . target . set ( 0 , 2.5 , 0 ) ;
68
+ controls2 . maxDistance = 12 ;
69
+ controls2 . minDistance = 5 ;
70
+ controls2 . enablePan = false ;
71
+
72
+ const gridHelper2 = new THREE . GridHelper ( 10 , 10 ) ;
73
+ scene2 . add ( gridHelper2 ) ;
74
+
75
+ const cube2 = new THREE . Mesh (
76
+ new THREE . BoxGeometry ( 1 , 1 , 1 ) ,
77
+ new THREE . MeshBasicMaterial ( { color :0x0000ff } )
78
+ ) ;
79
+ scene2 . add ( cube2 ) ;
80
+
81
+ /**
82
+ *
83
+ *
84
+ *
85
+ *
86
+ *
87
+ */
88
+
89
+ const tick = ( ) => {
90
+ controls1 . update ( ) ;
91
+ renderer1 . render ( scene1 , camera1 ) ;
92
+ controls2 . update ( ) ;
93
+ renderer2 . render ( scene2 , camera2 ) ;
94
+ window . requestAnimationFrame ( tick ) ;
95
+ }
96
+ tick ( ) ;
97
+
98
+
99
+ /**
100
+ * LICENSE CREDIT
101
+ *
102
+ * ASFAN Internatioal Trading Company
103
+ *
104
+ * "MatCaps" (https://github.com/nidorx/matcaps/blob/master/thumbnail/AC171C_FA8593_E84854_D3464E.jpg) Matcaps by nidorx github (https://github.com/nidorx)
105
+ * "MatCaps" (https://github.com/nidorx/matcaps/blob/master/thumbnail/9F1A27_F1AF7F_CD5845_D08441.jpg) Matcaps by nidorx github (https://github.com/nidorx)
106
+ * "MatCaps" (https://github.com/nidorx/matcaps/blob/master/thumbnail/7877EE_D87FC5_75D9C7_1C78C0.jpg) Matcaps by nidorx github (https://github.com/nidorx)
107
+ */
0 commit comments