File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ function main ( ) {
2+ //scene camera render
3+ const canvas = document . querySelector ( '#c' )
4+
5+ const fov = 50
6+ //const aspect = 2
7+ const aspect = canvas . clientWidth / canvas . clientHeight
8+ const near = 0.1
9+ const far = 2000 //default
10+
11+ const camera = new THREE . PerspectiveCamera ( fov , aspect , near , far )
12+ camera . position . z = 1
13+
14+ const renderer = new THREE . WebGLRenderer ( {
15+ canvas
16+ } )
17+ new THREE . OrbitControls ( camera , canvas )
18+
19+ const scene = new THREE . Scene ( )
20+ const loader = new THREE . TextureLoader ( )
21+ const texture = loader . load ( 'https://threejs.org/manual/examples/resources/images/equirectangularmaps/tears_of_steel_bridge_2k.jpg' , ( ) => {
22+ const rt = new THREE . WebGLCubeRenderTarget ( texture . image . height )
23+ rt . fromEquirectangularTexture ( renderer , texture )
24+ scene . background = rt . texture
25+ } )
26+
27+ function render ( ) {
28+ const width = canvas . clientWidth
29+ const height = canvas . clientHeight
30+ camera . aspect = width / height
31+ camera . updateProjectionMatrix ( )
32+ renderer . setSize ( width , height )
33+ renderer . render ( scene , camera )
34+ requestAnimationFrame ( render )
35+ }
36+ requestAnimationFrame ( render )
37+
38+ }
39+
40+ main ( )
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < link rel ="stylesheet " href ="style.css ">
8+ < title > Document</ title >
9+ </ head >
10+ < body >
11+ < canvas id ="c "> </ canvas >
12+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js "> </ script >
13+ < script src ="https://threejs.org/examples/js/controls/OrbitControls.js "> </ script >
14+ < script src ="app.js "> </ script >
15+ </ body >
16+ </ html >
Original file line number Diff line number Diff line change 1+ html ,
2+ body {
3+ height : 100% ;
4+ margin : 0 ;
5+ }
6+
7+ # c {
8+ width : 100% ;
9+ height : 100% ;
10+ display : block;
11+ }
You can’t perform that action at this time.
0 commit comments