- BabylonJS - Home
- BabylonJS - Introduction
- BabylonJS - Environment Setup
- BabylonJS - Overview
- BabylonJS - Basic Elements
- BabylonJS - Materials
- BabylonJS - Animations
- BabylonJS - Cameras
- BabylonJS - Lights
- BabylonJS - Parametric Shapes
- BabylonJS - Mesh
- VectorPosition and Rotation
- BabylonJS - Decals
- BabylonJS - Curve3
- BabylonJS - Dynamic Texture
- BabylonJS - Parallax Mapping
- BabylonJS - Lens Flares
- BabylonJS - Create ScreenShot
- BabylonJS - Reflection Probes
- Standard Rendering Pipeline
- BabylonJS - ShaderMaterial
- BabylonJS - Bones and Skeletons
- BabylonJS - Physics Engine
- BabylonJS - Playing Sounds & Music
BabylonJS - Disc
In this section, we will learn how to create a Disc.
Syntax
var disc = BABYLON.Mesh.CreateDisc("disc", 5, 30, scene, false, BABYLON.Mesh.DEFAULTSIDE);
Parameters
Name − This is the name of the disc.
Radius − This is the radius of the disc.
Tessellation − This refers to the tiling of a plane using one or more geometric shapes.
- 3 gives a triangle
- 4 gives a square
- 5 gives a pentagon
- 6 gives a hexagon
- 7 gives a heptagon
- 8 gives an octagon, and so on
Scene − This is the scene to attach the mesh.
Boolean − This is updatable; by default, it is false.
Defaultside − This is the optional side orientation.
With the tessellation value, you can get a regular polygon −
The last 2 parameters can be omitted.
Demo - Disc
<!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title>MDN Games: Babylon.js demo - shapes</title>
<script src = "babylon.js"></script>
<style>
html,body,canvas { margin: 0; padding: 0; width: 100%; height: 100%; font-size: 0; }
</style>
</head>
<body>
<canvas id = "renderCanvas"></canvas>
<script type = "text/javascript">
var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
var createScene = function() {
var scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color3(0, 1, 0);
BABYLON.ArcRotateCamera("Camera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene);
var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);
var disc = BABYLON.Mesh.CreateDisc("disc",2,8, scene);
disc.position = new BABYLON.Vector3(0, 0, 0);
var disc1 = BABYLON.Mesh.CreateDisc("triangle",2,3, scene);
disc1.position = new BABYLON.Vector3(-10, 0, 0);
var disc2 = BABYLON.Mesh.CreateDisc("pentagon",2, 5, scene);
disc2.position = new BABYLON.Vector3(0,0, 5);
scene.activeCamera.attachControl(canvas);
return scene;
};
var scene = createScene();
engine.runRenderLoop(function() {
scene.render();
});
</script>
</body>
</html>
Output
babylonjs_basic_elements.htm
Advertisements