|
@@ -0,0 +1,125 @@
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
+<html lang="en">
|
|
|
|
+ <head>
|
|
|
|
+ <title>three.js webgl - materials - TIFF texture</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> - TIFF texture loader</a>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- Import maps polyfill -->
|
|
|
|
+ <!-- Remove this when import maps will be widely supported -->
|
|
|
|
+ <script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
|
|
|
|
+
|
|
|
|
+ <script type="importmap">
|
|
|
|
+ {
|
|
|
|
+ "imports": {
|
|
|
|
+ "three": "../build/three.module.js"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ </script>
|
|
|
|
+
|
|
|
|
+ <script type="module">
|
|
|
|
+
|
|
|
|
+ import * as THREE from 'three';
|
|
|
|
+
|
|
|
|
+ import { TIFFLoader } from './jsm/loaders/TIFFLoader.js';
|
|
|
|
+
|
|
|
|
+ let renderer, scene, camera;
|
|
|
|
+
|
|
|
|
+ init();
|
|
|
|
+
|
|
|
|
+ function init() {
|
|
|
|
+
|
|
|
|
+ camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.01, 10 );
|
|
|
|
+ camera.position.set( 0, 0, 4 );
|
|
|
|
+
|
|
|
|
+ renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
|
+ renderer.setPixelRatio( window.devicePixelRatio );
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+ document.body.appendChild( renderer.domElement );
|
|
|
|
+
|
|
|
|
+ scene = new THREE.Scene();
|
|
|
|
+
|
|
|
|
+ const loader = new TIFFLoader();
|
|
|
|
+
|
|
|
|
+ const geometry = new THREE.PlaneGeometry();
|
|
|
|
+
|
|
|
|
+ // uncompressed
|
|
|
|
+
|
|
|
|
+ loader.load( 'textures/tiff/crate_uncompressed.tif', function ( texture ) {
|
|
|
|
+
|
|
|
|
+ const material = new THREE.MeshBasicMaterial( { map: texture } );
|
|
|
|
+
|
|
|
|
+ const mesh = new THREE.Mesh( geometry, material );
|
|
|
|
+ mesh.position.set( - 1.5, 0, 0 );
|
|
|
|
+
|
|
|
|
+ scene.add( mesh );
|
|
|
|
+
|
|
|
|
+ render();
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ // LZW
|
|
|
|
+
|
|
|
|
+ loader.load( 'textures/tiff/crate_lzw.tif', function ( texture ) {
|
|
|
|
+
|
|
|
|
+ const material = new THREE.MeshBasicMaterial( { map: texture } );
|
|
|
|
+
|
|
|
|
+ const mesh = new THREE.Mesh( geometry, material );
|
|
|
|
+ mesh.position.set( 0, 0, 0 );
|
|
|
|
+
|
|
|
|
+ scene.add( mesh );
|
|
|
|
+
|
|
|
|
+ render();
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ // JPEG
|
|
|
|
+
|
|
|
|
+ loader.load( 'textures/tiff/crate_jpeg.tif', function ( texture ) {
|
|
|
|
+
|
|
|
|
+ const material = new THREE.MeshBasicMaterial( { map: texture } );
|
|
|
|
+
|
|
|
|
+ const mesh = new THREE.Mesh( geometry, material );
|
|
|
|
+ mesh.position.set( 1.5, 0, 0 );
|
|
|
|
+
|
|
|
|
+ scene.add( mesh );
|
|
|
|
+
|
|
|
|
+ render();
|
|
|
|
+
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ window.addEventListener( 'resize', onWindowResize );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function onWindowResize() {
|
|
|
|
+
|
|
|
|
+ camera.aspect = window.innerWidth / window.innerHeight;
|
|
|
|
+ camera.updateProjectionMatrix();
|
|
|
|
+
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+
|
|
|
|
+ render();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ function render() {
|
|
|
|
+
|
|
|
|
+ renderer.render( scene, camera );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ </script>
|
|
|
|
+ </body>
|
|
|
|
+</html>
|