Skip to content

Commit 156cb35

Browse files
committed
Examples: Simplified webgl_loader_texture_hdrjpg example.
1 parent 66f7aa8 commit 156cb35

File tree

6 files changed

+10
-66
lines changed

6 files changed

+10
-66
lines changed
-24.1 KB
Binary file not shown.

examples/textures/gainmap/spruit_sunrise_4k.json

Lines changed: 0 additions & 29 deletions
This file was deleted.
-1.46 MB
Binary file not shown.

examples/webgl_loader_texture_hdrjpg.html

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
5555
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
5656

57-
import { GainMapLoader, HDRJPGLoader } from '@monogrid/gainmap-js';
57+
import { HDRJPGLoader } from '@monogrid/gainmap-js';
5858

5959
const params = {
6060
envMap: 'HDR JPG',
@@ -68,10 +68,9 @@
6868
let camera, scene, renderer, controls;
6969
let torusMesh, planeMesh;
7070
let hdrJpg, hdrJpgPMREMRenderTarget, hdrJpgEquirectangularMap;
71-
let gainMap, gainMapPMREMRenderTarget, gainMapBackground;
7271
let hdrPMREMRenderTarget, hdrEquirectangularMap;
7372

74-
73+
7574
const fileSizes = {};
7675
const resolutions = {};
7776

@@ -127,14 +126,15 @@
127126

128127

129128
hdrJpg = new HDRJPGLoader( renderer )
130-
.load( 'textures/gainmap/spruit_sunrise_4k.jpg', function ( ) {
129+
.load( 'textures/equirectangular/spruit_sunrise_4k.hdr.jpg', function ( ) {
131130

132131
resolutions[ 'HDR JPG' ] = hdrJpg.width + 'x' + hdrJpg.height;
132+
133133
displayStats( 'HDR JPG' );
134-
134+
135135
hdrJpgEquirectangularMap = hdrJpg.renderTarget.texture;
136136
hdrJpgPMREMRenderTarget = pmremGenerator.fromEquirectangular( hdrJpgEquirectangularMap );
137-
137+
138138
hdrJpgEquirectangularMap.mapping = THREE.EquirectangularReflectionMapping;
139139
hdrJpgEquirectangularMap.needsUpdate = true;
140140

@@ -143,37 +143,14 @@
143143
}, function ( progress ) {
144144

145145
fileSizes[ 'HDR JPG' ] = humanFileSize( progress.total );
146-
147-
} );
148-
149-
gainMap = new GainMapLoader( renderer )
150-
.load( [
151-
'textures/gainmap/spruit_sunrise_4k.webp',
152-
'textures/gainmap/spruit_sunrise_4k-gainmap.webp',
153-
'textures/gainmap/spruit_sunrise_4k.json'
154-
], function ( ) {
155-
156-
resolutions[ 'Webp Gain map (separate)' ] = gainMap.width + 'x' + gainMap.height;
157-
158-
gainMapBackground = gainMap.renderTarget.texture;
159-
gainMapPMREMRenderTarget = pmremGenerator.fromEquirectangular( gainMapBackground );
160-
161-
gainMapBackground.mapping = THREE.EquirectangularReflectionMapping;
162-
gainMapBackground.needsUpdate = true;
163-
164-
gainMap.dispose();
165-
166-
}, function ( progress ) {
167-
168-
fileSizes[ 'Webp Gain map (separate)' ] = humanFileSize( progress.total );
169146

170147
} );
171148

172149
hdrEquirectangularMap = new RGBELoader()
173-
.load( 'textures/gainmap/spruit_sunrise_1k.hdr', function ( ) {
150+
.load( 'textures/equirectangular/spruit_sunrise_1k.hdr', function ( ) {
174151

175152
resolutions[ 'HDR' ] = hdrEquirectangularMap.image.width + 'x' + hdrEquirectangularMap.image.height;
176-
153+
177154
hdrPMREMRenderTarget = pmremGenerator.fromEquirectangular( hdrEquirectangularMap );
178155

179156
hdrEquirectangularMap.mapping = THREE.EquirectangularReflectionMapping;
@@ -202,13 +179,13 @@
202179

203180
const gui = new GUI();
204181

205-
gui.add( params, 'envMap', [ 'HDR JPG', 'Webp Gain map (separate)', 'HDR' ] ).onChange( displayStats );
182+
gui.add( params, 'envMap', [ 'HDR JPG', 'HDR' ] ).onChange( displayStats );
206183
gui.add( params, 'roughness', 0, 1, 0.01 );
207184
gui.add( params, 'metalness', 0, 1, 0.01 );
208185
gui.add( params, 'exposure', 0, 2, 0.01 );
209186
gui.add( params, 'debug' );
210187
gui.open();
211-
188+
212189
function displayStats( value ) {
213190

214191
lbl.innerHTML = value + ' size : ' + fileSizes[ value ] + ', Resolution: ' + resolutions[ value ];
@@ -281,10 +258,6 @@
281258
pmremRenderTarget = hdrJpgPMREMRenderTarget;
282259
equirectangularMap = hdrJpgEquirectangularMap;
283260
break;
284-
case 'Webp Gain map (separate)':
285-
pmremRenderTarget = gainMapPMREMRenderTarget;
286-
equirectangularMap = gainMapBackground;
287-
break;
288261
case 'HDR':
289262
pmremRenderTarget = hdrPMREMRenderTarget;
290263
equirectangularMap = hdrEquirectangularMap;

0 commit comments

Comments
 (0)