Framebuffer - Final
How do I make an framebuffer - final?
This is an example for the Tuts+ tutorial on rendering to a texture in Three.js. What is a framebuffer - final? How do you make a framebuffer - final? This script and codes were developed by Omar Shehata on 13 August 2022, Saturday.
Framebuffer - Final - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Framebuffer - Final</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='http://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Framebuffer - Final - Script Codes CSS Codes
/* We want our scene to span the entire window */
body { margin: 0; }
Framebuffer - Final - Script Codes JS Codes
//@author Omar Shehata. 2015.
//We are loading the Three.js library from the cdn here: http://cdnjs.com/libraries/three.js/
///////////////////This is the basic scene setup
var scene = new THREE.Scene();
var width = window.innerWidth;
var height = window.innerHeight;
var camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
///////////////////This is where we create our off-screen render target
//Create a different scene to hold our buffer objects
var bufferScene = new THREE.Scene();
//Create the texture that will store our result
var bufferTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter});
//Let's create a red box
var redMaterial = new THREE.MeshBasicMaterial({color:0xF06565});
var boxGeometry = new THREE.BoxGeometry( 5, 5, 5 );
var boxObject = new THREE.Mesh( boxGeometry, redMaterial );
boxObject.position.z = -10;
bufferScene.add(boxObject);//We add it to the bufferScene instead of the normal scene!
///And a blue plane behind it
var blueMaterial = new THREE.MeshBasicMaterial({color:0x7074FF})
var plane = new THREE.PlaneBufferGeometry( window.innerWidth, window.innerHeight );
var planeObject = new THREE.Mesh(plane,blueMaterial);
planeObject.position.z = -15;
bufferScene.add(planeObject);//We add it to the bufferScene instead of the normal scene!
////////////////////////////Now we use our bufferTexture as a material to render it onto our main scene
var boxMaterial = new THREE.MeshBasicMaterial({map:bufferTexture});
var boxGeometry2 = new THREE.BoxGeometry( 5, 5, 5 );
var mainBoxObject = new THREE.Mesh(boxGeometry2,boxMaterial);
mainBoxObject.position.z = -10;
scene.add(mainBoxObject);
//Render everything!
function render() { requestAnimationFrame( render ); //Make the box rotate on box axises boxObject.rotation.y += 0.01; boxObject.rotation.x += 0.01; //Rotate the main box too mainBoxObject.rotation.y += 0.01; mainBoxObject.rotation.x += 0.01; //Render onto our off screen texture renderer.render(bufferScene,camera,bufferTexture); //Finally, draw to the screen renderer.render( scene, camera );
}
render();
Developer | Omar Shehata |
Username | omarshe7ta |
Uploaded | August 13, 2022 |
Rating | 3 |
Size | 2,491 Kb |
Views | 44,528 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Featherlight Zoom Test | 1,695 Kb |
Pixijs.v3 Shader Example | 3,213 Kb |
Basic Threejs Scene | 2,188 Kb |
Pixijs.v3 Rendering Texture | 2,632 Kb |
Smoke Shader - Diffuse | 3,283 Kb |
Cube Sides | 2,390 Kb |
Initial Scene | 2,545 Kb |
Rotating Cube | 2,151 Kb |
Pixijs.v3 Sending Data to Shader | 2,599 Kb |
Smoke Shader - Frame Buffer | 2,672 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Transitioning application screens with semantically named classes | Djgrant | 3,697 Kb |
A Pen by utcwebdev | Utcwebdev | 2,856 Kb |
HTML5 Video Autoplay | Zivcos | 1,352 Kb |
Svg penguin | _massimo | 2,990 Kb |
Bezier Animation with straight paths | Rhernando | 2,087 Kb |
Pictos font library from CodePen | Jstam | 3,790 Kb |
Project MMetro beta | Atomicsong | 5,157 Kb |
APortfolio | Skybutterfly | 5,174 Kb |
Fixed with using Calc | Tomleo | 2,542 Kb |
JQuery exercise | Brian-baum | 3,780 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!