BabylonJS - DashedLines Mesh



In this section, we will learn how to create DashedLines Mesh.

Syntax

Following is the syntax to create DashedLines Mesh −

var dashedlines = BABYLON.Mesh.CreateDashedLines("dashedLines", [v1, v2, ... vn], dashSize, gapSize, dashNb, scene);

Parameters

Consider the following parameters to create a DashedLines Mesh −

  • Name − The name of the mesh.

  • Array − The array of vectors3.

  • DashSize − The size of the dashes.

  • GapSize − The size of the gaps.

  • DashNumber − The intended number of dashes.

  • Scene − The scene to which the dashlines need to be attached.

Demo – DashedLine mesh

<!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);
            
            var camera = new 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 lines = BABYLON.Mesh.CreateDashedLines("lines", [
               new BABYLON.Vector3(-5, 0, 0),
               new BABYLON.Vector3(5, 0, 0),
               new BABYLON.Vector3(0, 0, -5),
               new BABYLON.Vector3(0, 5, 0)
            ], 5, 5, 5, scene);
            scene.activeCamera.attachControl(canvas);
            return scene;
         };
         var scene = createScene();
         engine.runRenderLoop(function() {
            scene.render();
         });
      </script>
   </body>
</html> 

Output

Basic Elements DashedLine Mesh
babylonjs_basic_elements.htm
Advertisements