mwpowellhtx Posted March 24, 2016 Share Posted March 24, 2016 Hello, I've got the following "simple" code. This will be the most complex my model gets, probably, but currently it is not working. I receive the following error when I call BABYLON.Mesh.CreateTube, Quote Uncaught TypeError: Cannot read property 'subtract' of undefined //... var tp = createArchPoints(10, 32); var tube = BABYLON.Mesh.CreateTube('my tube', tp, 2, 12, null, BABYLON.Mesh.CAP_ALL, scene); //... Which my arch points are created using the very helpful Quadratic Bezier calculation. var createArchPoints = function(dim, count) { var po = new BABYLON.Vector3(0,0,0); // origin var pc = new BABYLON.Vector3(0,0,dim); // control var pd = new BABYLON.Vector3(dim,0,dim); // destination var points = BABYLON.Curve3.CreateQuadraticBezier(po, pc, pd, count); return points; } I know the radius, will be constant; so I do not want a radius function. The points themselves, as far as I can tell, appear to be realistic, as expected. Is there something I need to do to dress the CreateQuadraticBezier result before passing them to CreateTube? My assumption is that one returned a Vector3[], which the other expects as a parameter, but I could be wrong, it's hard to tell sometimes with JavaScript being weakly typed. Any other calculations I need will be along the lines of rectangles in 3D space, even with a couple of transformations and translations, but these are more straightforward in my mind. To help with response, my level of js confidence is growing probably 4 out of 10; 3D about the same, my frame of reference are libraries like Helix Toolkit for WPF (C#) in which I've already done a similar model, just wanting to do something like that with Babylon; also loosely familiar with THREE, so probably same, 4 out of 10. That to say, I'm learning, but I can discuss halfway intelligently. Thank you... Regards, Michael Powell Quote Link to comment Share on other sites More sharing options...
mwpowellhtx Posted March 24, 2016 Author Share Posted March 24, 2016 I got it to work. Since Curve3 is returned from Bezier, it is necessary to access the points. // better name for it var createArchCurve = function(dim, count) { var po = new BABYLON.Vector3(0,0,0); // origin var pc = new BABYLON.Vector3(0,0,dim); // control var pd = new BABYLON.Vector3(dim,0,dim); // destination var points = BABYLON.Curve3.CreateQuadraticBezier(po, pc, pd, count); return points; } Following which, var archCurve = createArchCurve(10, 32); var tube = BABYLON.Mesh.CreateTube('my tube', archCurve.getPoints(), 0.25, 12, null, BABYLON.Mesh.CAP_ALL, scene); After that can have fun with material, color, etc. 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.