DreamsCoder.com

We Code your Dreams


home > Drawing Prism using Three.js




Drawing Prism using Three.js







Click here for Live demo

Files

Three.js | Source code

var scene = new THREE.Scene();
 
var camera = new THREE.PerspectiveCamera
(75, window.innerWidth/window.innerHeight, 0.2, 1000);

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth,
window.innerHeight);
            document.body.appendChild(renderer.domElement);
 
            camera.position.z = 3.9;
 
            //1st top planar polygon
            //2nd is bottom planar polygon
            //3rd is  Height
            //4th is dimension 4 for 4d

var pyramidgeometry = new THREE.CylinderGeometry(0.1, bp, h, d, false);

var pyramidmaterial = new THREE.MeshBasicMaterial
({wireframe: true, color: 0x0fff00});
var pyramid = new THREE.Mesh(pyramidgeometry, pyramidmaterial);
    
pyramid.position.set(0.3,0.4,1.6);
scene.add(pyramid);
 
 
            var render = function () {
                requestAnimationFrame(render);
                
                pyramid.rotation.y += 0.01;
                pyramid.rotation.z += 0.01;
                pyramid.rotation.x += 0.01;
                
 
                renderer.render(scene, camera);
            };
 
 
            render();

Label - javascript





by - Chinmay Mahajan





Are you looking for something else?


Suggested Programs




How to Detect Ad Blocker on your website using Javascript


Canvas Rotate Scale Translate Skew using JavaScript


Change button color using javascript and keep it same on refresh


Get current Date and Time automatically using JavaSrcipt


Searching Strings with indexOf and lastIndexOf using JavaScript