Butterwell Posted May 18, 2018 Share Posted May 18, 2018 I've got some code in THREE.js that uses the Shape abstraction. I haven't been able to figure out how to do a similar thing in Babylon.js at this level of abstraction. My code does thus to create a fat arc (a 2D geometry/mesh): function fatArcGeometry(bandWidth, radius, radians) { const outerRadius = radius + (bandWidth/2) const innerRadius = radius - (bandWidth/2) var arcShape = new THREE.Shape(); arcShape.moveTo( outerRadius, 0 ); arcShape.absarc( 0, 0, outerRadius, 0, radians, false ); arcShape.lineTo( Math.cos(radians)*innerRadius, Math.sin(radians)*innerRadius ); arcShape.absarc( 0, 0, innerRadius, radians, 0, true ); var geometry = new THREE.ShapeBufferGeometry( arcShape ); return geometry } Is there a similar abstraction or... what are the Babylon building blocks to build a 2D fat arc? Quote Link to comment Share on other sites More sharing options...
Butterwell Posted May 18, 2018 Author Share Posted May 18, 2018 The "obvious" answer (now) is "use a ribbon". Working on it. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 18, 2018 Share Posted May 18, 2018 Correct (And welcome btw) Quote Link to comment Share on other sites More sharing options...
Butterwell Posted May 19, 2018 Author Share Posted May 19, 2018 Got it to work. http://www.babylonjs-playground.com/#9BWQ4C The meat of the solution: var r1 = 3; // inner radius var r2 = 5; // outer radius var segments = 4; var points = segments + 1; var arc1 = []; var arc2 = []; var radians = Math.PI for (var i = 0; i < points; i++) { arc1.push(new BABYLON.Vector3(r1*Math.cos(radians*i/segments), r1*Math.sin(radians*i/segments), 0)); arc2.push(new BABYLON.Vector3(r2*Math.cos(radians*i/segments), r2*Math.sin(radians*i/segments), 0)); } jerome 1 Quote Link to comment Share on other sites More sharing options...
Butterwell Posted May 19, 2018 Author Share Posted May 19, 2018 15 hours ago, Deltakosh said: Correct (And welcome btw) Thank you. Good to be here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.