Proof of Concept: non affine texturing within Three.js
Un-comment ONE of the imported three.module.js files, to appreciate the difference in texturing quality
by Chrisssie
CSS
body {
background-color: #000;
margin: 0px;
overflow: hidden;
}
JavaScript
// activate this line for non-affine, perspective correct texturing (with vertical lines in texture rendered as STRAIGHT lines)
import * as THREE from "https://vielzutun.ch/wordpress/public/three.module.js";
// activate this line for standard affine texturing (with vertical lines in texture rendered as zig-zag)
//import * as THREE from "https://threejs.org/build/three.module.js";
import { OrbitControls } from "https://threejs.org/examples/jsm/controls/OrbitControls.js";
import { GUI } from "https://threejs.org/examples/jsm/libs/lil-gui.module.min.js";
var renderer, scene, camera, controls;
let testMesh, testMaterial, testGeometry;
const PI_180 = Math.PI / 180.0;
const points = [];
let wireMaterial, flatMaterial, gouraudMaterial, phongMaterial, texturedMaterial, reflectiveMaterial;
let ambientLight, light;
let parameters;
let shading = '';
let latheSegments = 0;
init();
animate();
//render();
function init() {
// camera
camera = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.set(0, 70, 60);
// renderer
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputEncoding = THREE.sRGBEncoding;
document.body.appendChild(renderer.domElement);
// scene
scene = new THREE.Scene();
// controls
controls = new OrbitControls(camera, renderer.domElement);
// light
ambientLight = new THREE.AmbientLight(0x444444);
light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(32, 39, 70);
scene.add( ambientLight );
scene.add( light );
// axes
scene.add(new THREE.AxesHelper(40));
// Textures
const textureEquirec = new THREE.TextureLoader().load( "https://vielzutun.ch/wordpress/public/pano_2k.jpg" );
// const textureEquirec = new THREE.TextureLoader().load( "https://vielzutun.ch/wordpress/public/uv_grid_opengl.jpg" );
textureEquirec.mapping =...