three.js

Enhance shader lighting

3D three.js render

Enhance shader lighting

  • 3d
  • code
  • light
  • real time
  • realistic
  • three.js
  • webgl
import { EquirectangularReflectionMapping, HalfFloatType, Texture } from "three"
import { UltraHDRLoader } from "three/examples/jsm/Addons.js"

const loader = new UltraHDRLoader()

// Fix iPhone 15, iOS 18.3: THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.
loader.setDataType(HalfFloatType)

const envMap = await new Promise((resolve: (texture: Texture) => void) => {
  loader.load("/assets/envmap.jpg", function (texture) {
    texture.mapping = EquirectangularReflectionMapping
    texture.needsUpdate = true
    resolve(texture)
  })
})

scene.environment = envMap

Ultra HDR

  • envmap
  • hdr
  • online
  • three.js
  • tool
  • webgl
Infinite procedural cyberpunk world

synthcity

Infinite procedural cyberpunk world

  • 3d
  • building
  • city
  • cyber punk
  • experiment
  • glow
  • night
  • real time
  • three.js
  • webgl
Real time puddle in rain

Puddle in rain

Real time puddle in rain

  • puddle
  • rain
  • react-three-fiber
  • real time
  • reflection
  • three.js
  • webgl
const hFOV = 2 * Math.atan( Math.tan( camera.fov * Math.PI / 180 / 2 ) * camera.aspect ) * 180 / Math.PI; // degrees

horizontal field-of-view

  • camera
  • code
  • fov
  • javascript
  • three.js
function fovHorizontalToVertical(fovHorizontal, aspect) {
  const fovHorizontalRad = (fovHorizontal * Math.PI) / 180;
  const fovVerticalRad = 2 * Math.atan(Math.tan(fovHorizontalRad / 2) / aspect);
  const fovVertical = (fovVerticalRad * 180) / Math.PI;
  return fovVertical;
}

const fovHorizontal = 50;
const aspect = window.innerWidth / window.innerHeight;

const fovVertical = fovHorizontalToVertical(fovHorizontal, aspect);

camera.fov = fovVertical;
camera.updateProjectionMatrix();

horizontal field-of-view

  • camera
  • code
  • fov
  • javascript
  • three.js