It only took 3 days - to draw a friggin circle

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@rxhector·
0.000 HBD
It only took 3 days - to draw a friggin circle
so i been playin with babylon js - i have some interesting ideas for a game and didnt want to go full unity yet

babylon playground is awesome place to experiment and learn 3d math

so i was able to draw all the cool shapes and platonic solids - but there didnt seem to be any 2d functions - like just draw me a friggin circle OUTLINE - hollow

i could draw a 'disc' just fine but i didnt want my objects 'sliced' - i just wanted an outline

so i came up with a super easy 'outline mesh'

/*
	create2Dpoly
	uses same options as BABYLON.MeshBuilder.CreateDisc / BABYLON.VertexData.CreateDisc
	returns the outline for disc (only lines)
	tessellation 3 = triangle,4 square, 5 pentagon etc,etc
	
*/
function create2Dpoly(options, scene) {
	var pos , points = [];
	var disc = BABYLON.VertexData.CreateDisc(options);
	pos = disc.positions;
	//skip the center point
	for (var i = 1; i < disc.positions.length/3; i++){
		points.push(new BABYLON.Vector3(pos[i*3] , pos[i*3+1] , pos[i*3+2]));
	}
	var poly = BABYLON.MeshBuilder.CreateLines("circle", {points:points}, scene);
	return poly;	
}//end function

![babyloncircle79229.png](https://www.steemimg.com/images/2016/10/09/babyloncircle79229.png)
http://www.babylonjs-playground.com/#QDM1B#0


go figure - it was easy enough to just draw lines LOL
👍 , , , , , , , , , , , , , , , , , , ,