|
35 | 35 |
|
36 | 36 | const params = { |
37 | 37 | enableSSR: true, |
38 | | - autoRotate: false, |
| 38 | + autoRotate: true, |
39 | 39 | otherMeshes: true, |
40 | 40 | groundReflector: true, |
41 | 41 | }; |
|
48 | 48 | const otherMeshes = []; |
49 | 49 | let groundReflector; |
50 | 50 | const selects = []; |
51 | | - window.selects = selects; |
52 | 51 | let bunny, cube, sphere, cone; |
53 | 52 | let folder; |
54 | 53 |
|
|
67 | 66 | camera.position.set( 0.13271600513224902, 0.3489546826045913, 0.43921296427927076 ); |
68 | 67 |
|
69 | 68 | scene = new THREE.Scene(); |
70 | | - window.scene = scene; |
71 | | - // scene.fog = new THREE.Fog( 0x443333, 1, 4 ); |
72 | 69 |
|
73 | 70 | // Ground |
74 | 71 | const groundPlane = new THREE.Mesh( |
75 | | - new THREE.PlaneGeometry( 8, 8 ), |
| 72 | + new THREE.PlaneGeometry( 1, 1 ), |
76 | 73 | new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } ) |
77 | 74 | ); |
78 | 75 | groundPlane.rotation.x = - Math.PI / 2; |
|
81 | 78 | scene.add( groundPlane ); |
82 | 79 | if ( ! params.groundReflector ) selects.push( groundPlane ); |
83 | 80 | groundPlane.name = 'groundPlane'; |
84 | | - window.groundPlane = groundPlane; |
85 | 81 |
|
86 | 82 | // Lights |
87 | 83 | const hemiLight = new THREE.HemisphereLight( 0x443333, 0x111122 ); |
|
118 | 114 | } ); |
119 | 115 |
|
120 | 116 | let geometry, material, mesh; |
121 | | - let group = new THREE.Group(); |
122 | | - window.group = group; |
| 117 | + const group = new THREE.Group(); |
123 | 118 | scene.add( group ); |
124 | 119 | otherMeshes.push( group ); |
125 | 120 | selects.push( group ); |
|
134 | 129 | // selects.push( mesh ); |
135 | 130 | cube = mesh; |
136 | 131 | mesh.name = 'cube'; |
137 | | - window.cube = cube; |
138 | 132 |
|
139 | 133 | geometry = new THREE.IcosahedronBufferGeometry( .025, 4 ); |
140 | 134 | material = new THREE.MeshPhysicalMaterial( { metalness: .5, roughness: .5, color: 'cyan' } ); |
|
145 | 139 | // selects.push( mesh ); |
146 | 140 | sphere = mesh; |
147 | 141 | mesh.name = 'sphere'; |
148 | | - window.sphere = sphere; |
149 | 142 |
|
150 | 143 | geometry = new THREE.ConeBufferGeometry( .025, .05, 64 ); |
151 | 144 | material = new THREE.MeshStandardMaterial( { metalness: .5, roughness: .5, color: 'yellow' } ); |
|
158 | 151 | mesh.position.sub( cube.position ); |
159 | 152 | cone = mesh; |
160 | 153 | mesh.name = 'cone'; |
161 | | - window.cone = cone; |
162 | 154 |
|
163 | 155 | geometry = new THREE.PlaneBufferGeometry( 1, 1 ); |
164 | 156 | groundReflector = new ReflectorForSSRPass( geometry, { |
|
179 | 171 | renderer.setSize( window.innerWidth, window.innerHeight ); |
180 | 172 | renderer.outputEncoding = THREE.sRGBEncoding; |
181 | 173 | container.appendChild( renderer.domElement ); |
182 | | - // scene.background = new THREE.Color( 0x443333 ); |
183 | | - // new THREE.TextureLoader().load('textures/equirectangular/venice_sunset_1k.hdr', envMap=>{ |
184 | | - // scene.background=envMap |
185 | | - // }) |
186 | | - |
187 | 174 |
|
188 | 175 | const pmremGenerator = new THREE.PMREMGenerator( renderer ); |
189 | 176 | pmremGenerator.compileEquirectangularShader(); |
|
192 | 179 | .setPath( 'textures/equirectangular/' ) |
193 | 180 | .load( 'venice_sunset_1k.hdr', function ( texture ) { |
194 | 181 |
|
195 | | - let envMap = pmremGenerator.fromEquirectangular( texture ).texture; |
| 182 | + const envMap = pmremGenerator.fromEquirectangular( texture ).texture; |
196 | 183 | pmremGenerator.dispose(); |
197 | 184 |
|
198 | 185 | scene.background = envMap; |
|
226 | 213 | height: innerHeight, |
227 | 214 | encoding: THREE.sRGBEncoding, |
228 | 215 | groundReflector: params.groundReflector ? groundReflector : null, |
229 | | - selects: params.groundReflector ? selects : null |
| 216 | + selects, |
230 | 217 | } ); |
231 | | - window.ssrPass = ssrPass; |
232 | 218 |
|
233 | 219 | composer.addPass( ssrPass ); |
234 | 220 |
|
|
0 commit comments