BabylonJS - 网格边缘渲染器
EdgesRendering 用于绘制网格周围的边缘,如上面的输出所示。
执行以下代码行以在网格上调用以下方法并给出颜色、要绘制的边缘的宽度等。
var box = BABYLON.Mesh.CreateBox("box1", 2, scene); box.enableEdgesRendering(); box.edgesWidth = 4.0; box.edgesColor = new BABYLON.Color4(0, 0, 1, 1);
演示
<!doctype html> <html> <head> <meta charset = "utf-8"> <title>BabylonJs - Basic Element-Creating Scene</title> <script src = "babylon.js"></script> <style> canvas {width: 100%; height: 100%;} </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); var camera = new BABYLON.ArcRotateCamera("camera1", 0,Math.PI / 3,10.0,new BABYLON.Vector3(0, 0,0), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, true); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); var box = BABYLON.Mesh.CreateBox("box1", 2, scene); box.enableEdgesRendering(); box.edgesWidth = 4.0; box.edgesColor = new BABYLON.Color4(0, 0, 1, 1); box.position.y = 1.2; return scene }; var scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); </script> </body> </html>
输出
