technology logo
technology logo

Porting 3D Rose using Javascript

share link

by vsasikalabe dot icon Updated: Mar 2, 2023

Guide Kit Guide Kit  

The three.js is a JavaScript-based WebGL engine. It can run games and other graphic apps directly from the browser. This library has many functions for drawing 3D scenes in our browser. Orbit controls the camera around a target. Scenes allow displaying of the rendered picture by three.js. The scene is displayed on an HTML Canvas Element. It uses WebGL by default.  


You’ll need to import the Three.js library at the top of your JavaScript program before you start. We can retrieve the library using multiple CDN (content delivery network) services. First, we must establish a scene, a camera, and a renderer to display any 2D or 3D objects. We must declare a constant global variable for all of these. To use its scene (), PerspectiveCamera(), and WebGLRenderer() functions, a new element is assigned to each variable by calling the THREE libraries. 

In three.js, the scene variable is assigned to a new object. Using the scene.add() function, which allows you to add elements, like 3D models and lights, to the scene later in our program. This function adjusts elements in the scene, such as the background color. You’re also passing some arguments by using the PerspectiveCamera() function. This can specify the camera’s field of view (75) and aspect ratio (window.innerWidth / window.innerHeight). 

The renderer variable is used to assign a new WebGL renderer system. The Three.js rendering system is called multiple times by using this variable so that we can perform animations and movement in the scene. 


Here is an example of how to Porting 3D Rose using Javascript: