123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>three.js webgl - materials - RGBM texture loader</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <link type="text/css" rel="stylesheet" href="main.css">
- </head>
- <body>
- <div id="info">
- <a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl RGBM texture loader example
- </div>
- <script type="module">
- import * as THREE from '../build/three.module.js';
- import { GUI } from './jsm/libs/dat.gui.module.js';
- var params = {
- exposure: 2.0
- };
- var renderer, scene, camera;
- init();
- function init() {
- renderer = new THREE.WebGLRenderer();
- renderer.setPixelRatio( window.devicePixelRatio );
- renderer.setSize( window.innerWidth, window.innerHeight );
- document.body.appendChild( renderer.domElement );
- renderer.toneMapping = THREE.ReinhardToneMapping;
- renderer.toneMappingExposure = params.exposure;
- renderer.outputEncoding = THREE.sRGBEncoding;
- scene = new THREE.Scene();
- var aspect = window.innerWidth / window.innerHeight;
- camera = new THREE.OrthographicCamera( - aspect, aspect, 1, - 1, 0, 1 );
- new THREE.TextureLoader().load( 'textures/memorial.png', function ( texture ) {
- texture.encoding = THREE.RGBM16Encoding;
- texture.minFilter = THREE.LinearFilter;
- texture.magFilter = THREE.LinearFilter;
- texture.flipY = true;
- var material = new THREE.MeshBasicMaterial( { map: texture } );
- var quad = new THREE.PlaneBufferGeometry( 1.5 * texture.width / texture.height, 1.5 );
- var mesh = new THREE.Mesh( quad, material );
- scene.add( mesh );
- render();
- } );
- //
- var gui = new GUI();
- gui.add( params, 'exposure', 0, 4, 0.01 ).onChange( render );
- gui.open();
- //
- window.addEventListener( 'resize', onWindowResize, false );
- }
- function onWindowResize() {
- var aspect = window.innerWidth / window.innerHeight;
- var frustumHeight = camera.top - camera.bottom;
- camera.left = - frustumHeight * aspect / 2;
- camera.right = frustumHeight * aspect / 2;
- camera.updateProjectionMatrix();
- renderer.setSize( window.innerWidth, window.innerHeight );
- render();
- }
- //
- function render() {
- renderer.toneMappingExposure = params.exposure;
- renderer.render( scene, camera );
- }
- </script>
- </body>
- </html>
|