JavaScript backend code for downloading transaction PDFs as a ZIP file

const buttonAction = async (base64Values) => {     //let base64Values be the array of object contain transaction number and base64 value of transaction PDFs     const filenameSet = new Set();     base64Values.forEach((data, index) => {         const byteCharacters = atob(data.base64Value);         const byteNumbers = new Array(byteCharacters.length);… Continue reading JavaScript backend code for downloading transaction PDFs as a ZIP file

Baking

Baking  When you do a render in a 3D software like Blender, it usually looks better than the model you import into Three.js, no matter how hard you try to get the exact same lighting and colors. This is because of the technique used while making the render. Ray Tracing consists of casting multiple rays… Continue reading Baking

Displacement pass

Displacement pass Create a new shader named DisplacementShader, then a new pass named displacementPass from the ShaderPass and add it to effectComposer: const DisplacementShader = { uniforms: { tDiffuse: { value: null } }, vertexShader: ` varying vec2 vUv; void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); vUv = uv; } `, fragmentShader: ` uniform sampler2D tDiffuse; varying… Continue reading Displacement pass

Fixing the antialias

Fixing the antialias  There’s another feature that seems to stop working.if you are using a screen with a pixel ratio above 1, you probably can’t see the problem. Be careful; if you only have the renderPass available, you won’t see the problem because the render is done in the canvas with antialias support. Enable at least one pass… Continue reading Fixing the antialias

Change orientation of the camera is based on the device’s orientation.

async function startCamera() {     try {         // Stop the previous stream if it exists         if (videoStream) {             const tracks = videoStream.getTracks();             tracks.forEach(track => track.stop());         }        … Continue reading Change orientation of the camera is based on the device’s orientation.

Generating a single smoke cloud using ThreeJS

Overview of SingleCloud.js SingleCloud.js uses Three.js’s PointsMaterial and BufferGeometry to render a single smoke cloud as a set of particles with variations in position, size, and color. The goal is to create a standalone, soft-looking smoke cloud with an organic, billowing effect. 1. Initializing the Smoke Cloud The SingleCloud class initializes by loading a texture… Continue reading Generating a single smoke cloud using ThreeJS

StructureClone for Deep Copy

structuredClone is a browser API that deep clones complex data structures, including circular references. const original = { name: “Bruce”, meta: { age: 32 } }; const copy = structuredClone(original);

JavaScript code for delayed operations

You can use setTimeout with a delay for the delayed operation console.log(‘First’); setTimeout(() => console.log(‘Second’), 1000); The “Second’ will be logged after a delay provided as the above code

JavaScript API for formatting dates, numbers, and currencies

The Intl object is a powerful API for formatting dates, numbers, and currencies in a way that is localized. const currencyFormatter = new Intl.NumberFormat(‘en-US’, {   style: ‘currency’,   currency: ‘USD’ }); console.log(currencyFormatter.format(1234.56)); // “$1,234.56”

Positional Audio

Positional Audio Create a positional audio object. This uses the Web Audio API. Code Example // create an AudioListener and add it to the camera const listener = new THREE.AudioListener(); camera.add( listener ); // create the PositionalAudio object (passing in the listener) const sound = new THREE.PositionalAudio( listener ); // load a sound and set it… Continue reading Positional Audio