ThreeJs SKY

Sky Sky creates a ready to go sky environment for your scenes. Import Sky is an add-on, and therefore must be imported explicitly. See Installation / Addons. import { Sky } from ‘three/addons/objects/Sky.js’; Code Example const sky = new Sky(); sky.scale.setScalar( 450000 ); const phi = MathUtils.degToRad( 90 ); const theta = MathUtils.degToRad( 180 ); const… Continue reading ThreeJs SKY

MISC Timer

Timer This class is an alternative to Clock with a different API design and behavior. The goal is to avoid the conceptual flaws that became apparent in Clock over time. Timer has an .update() method that updates its internal state. That makes it possible to call .getDelta() and .getElapsed() multiple times per simulation step without getting different values. The class uses the… Continue reading MISC Timer

Troika Text for Three.js

Troika Text The troika-three-text package provides high quality text rendering in Three.js scenes, using signed distance fields (SDF) and antialiasing using standard derivatives. Rather than relying on pre-generated SDF textures, this parses font files (.ttf, .otf, .woff) directly using Typr, and generates the SDF atlas for glyphs on-the-fly as they are used. It also handles proper kerning, ligature glyph substitution,… Continue reading Troika Text for Three.js

Audio

In Three.js, audio functionality allows you to integrate sound effects and music into your 3D scenes. This can enhance the immersive experience of your application or game. The Three.js library provides several classes to handle different aspects of audio, including loading audio files, creating audio sources, and controlling audio playback. Code Example // create an… Continue reading Audio

TextureLoader in ThreeJs

Class for loading a texture. This uses the ImageLoader internally for loading files. Code Example const texture = new THREE.TextureLoader().load(‘textures/land_ocean_ice_cloud_2048.jpg’ ); // immediately use the texture for material creation const material = new THREE.MeshBasicMaterial( { map:texture } ); Code Example with Callbacks // instantiate a loader const loader = new THREE.TextureLoader(); // load a resource loader.load( // resource… Continue reading TextureLoader in ThreeJs

CameraHelper in ThreeJs

This helps with visualizing what a camera contains in its frustum. It visualizes the frustum of a camera using a LineSegments. CameraHelper must be a child of the scene. Code Example const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); const helper = new THREE.CameraHelper( camera ); scene.add( helper ); Constructor CameraHelper( camera… Continue reading CameraHelper in ThreeJs

Raycaster in ThreeJs

This class is designed to assist with raycasting. Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst other things. Code Example const raycaster = new THREE.Raycaster(); const pointer = new THREE.Vector2(); function onPointerMove( event ) { // calculate pointer position in normalized device coordinates // (-1… Continue reading Raycaster in ThreeJs

PerspectiveCamera in Three.js

Camera that uses perspective projection. This projection mode is designed to mimic the way the human eye sees. It is the most common projection mode used for rendering a 3D scene. Code Example const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); scene.add( camera ); Constructor PerspectiveCamera( fov : Number, aspect : Number, near : Number,… Continue reading PerspectiveCamera in Three.js

Introduction to Sorting Algorithms in JavaScript

1. Introduction Sorting algorithms are fundamental to computer science and programming. They are essential tools for organizing data in a meaningful order, whether it’s numerical, alphabetical, or based on any other criteria. For JavaScript developers, understanding these algorithms is crucial, as they often need to manipulate and sort data efficiently within their applications. This blog… Continue reading Introduction to Sorting Algorithms in JavaScript

How to Use WeakMap and WeakSet in JavaScript

JavaScript offers a number of tools for organizing and managing data. And while developers often use widely recognized tools like Maps and Sets, they may often overlook certain other valuable resources. For example, are you familiar with WeakMap and WeakSet? They’re special tools in JavaScript that help store and manage data in unique ways. This… Continue reading How to Use WeakMap and WeakSet in JavaScript