Basic Threejs Scene
How do I make an basic threejs scene?
A simple set up to follow along with the Tutsplus guide on graphics shaders. What is a basic threejs scene? How do you make a basic threejs scene? This script and codes were developed by Omar Shehata on 13 August 2022, Saturday.
Basic Threejs Scene - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Basic Threejs Scene</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Basic Threejs Scene - Script Codes CSS Codes
/* We want our scene to span the entire window */
body { margin: 0; }
Basic Threejs Scene - 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/ var scene; var camera; var renderer; function scene_setup(){ //This is all code needed to set up a basic ThreeJS scene //First we initialize the scene and our camera scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); //We create the WebGL renderer and add it to the document renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); } scene_setup(); //Add your code here! var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00} );//We make it green var cube = new THREE.Mesh( geometry, material ); //Add it to the screen scene.add( cube ); cube.position.z = -3;//Shift the cube back so we can see it //Render everything! function render() { cube.rotation.y += 0.05; requestAnimationFrame( render ); renderer.render( scene, camera ); } render();
Developer | Omar Shehata |
Username | omarshe7ta |
Uploaded | August 13, 2022 |
Rating | 3 |
Size | 2,188 Kb |
Views | 26,312 |
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 |
Simple Lighting Model | 3,365 Kb |
Framebuffer - Final | 2,491 Kb |
Cube Sides | 2,390 Kb |
Framebuffer - Basic Scene | 2,217 Kb |
ACM Drawing Practice | 1,802 Kb |
Ball Demo | 2,055 Kb |
Pixijs.v3 Sending Data to Shader | 2,599 Kb |
Buggy Smoke | 3,213 Kb |
Framebuffer - Texture Render | 2,402 Kb |
Rotating Cube | 2,151 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 |
HTM5 picture dropzone | Jaysalvat | 2,576 Kb |
Add This API | ThatGuySam | 2,848 Kb |
Prototype Responsive Homepage | Heyitsolivia | 7,677 Kb |
Spinners using Font Icons | Keyamoon | 3,007 Kb |
CSS Hover Effects | Alen | 3,613 Kb |
Animated Donut Chart | Jplhomer | 3,808 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Barber Shop | Bhlaird | 6,270 Kb |
CSS 3D Radio buttons | Andreasnylin | 1,650 Kb |
CSS Link Zoom On Click | Bryce | 1,960 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!