Bladetrick

Members
  • Content Count

    40
  • Joined

  • Last visited

About Bladetrick

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I ran through the documentation on facet data and used it to construct a function that seems to work for me. function GetNearestPoint(currentSphere) { var nearestMesh, nearestFacet, facetPos; var projected; var distance = 0; var shortestDistance = 9999999; meshes.forEach(function (mesh) { // meshes is an array containing the mesh and its "sub meshes" var facets = mesh.getFacetLocalPositions() if (facets.length > 0) { facets.forEach(function (facet) { distance = BABYLON.Vector3.Distance(currentSphere.position, facet); if (distance < shortestDistance) { nearestFacet = facet; shortestDistance = distance; nearestMesh = mesh; } }); } }); projected = BABYLON.Vector3.Zero(); var index = nearestMesh.getClosestFacetAtCoordinates(nearestFacet.x, nearestFacet.y, nearestFacet.z, projected); return projected; // use this set of coordinates to construct the newer/closer sphere } Thanks for the help, everyone!
  2. Bladetrick

    multiple mesh models

    hello! I have inherited a model that has several layers. Its a vehicle that is broken down into engine, body, exhaust, and break systems. Each component is a new mesh layer. As I was using babylon js to iterate through the layers of the model, I noticed that every mesh in the entire model has a position of (0, 0 , 0). Is this normal?
  3. Thanks John, I'll take a looksee. I found the original example I grabbed from three js. this is basically what I want to do: https://codepen.io/maurizzzio/pen/pERqxV?editors=0010
  4. Hello! My scenario: - An OBJ file containing several meshes (cube, cones, monkey head, etc) all touching each other - A sphere (or more than one) created off to the side of the imported mesh. My objectives are: - Determine the closest point on the imported mesh from the sphere. - Create another Sphere at that point. The end result is a sphere on the surface of the imported mesh. Before I started playing with Babylon JS, I had tried Three JS. I found a small routine that would do this. Now I'd like to do the same thing in Babylon. Here's the Three JS. // This function is called first. it accepts datapoint as a parameter. datapoint is the sphere that is off to the side of the imported model. function updateClosestPointPosition(datapoint) { var p = datapoint.position; var geom = partmodel.geometry; // cone.geometry var closestDistance = 1e9; // Don't understand 1e9 to be honest var closestFace = geom.faces.forEach(function (face) { var normal = face.normal; var va = geom.vertices[face.a]; var vb = geom.vertices[face.b]; var vc = geom.vertices[face.c]; var pd = normal.dot(p.clone().sub(va)); // move p -(pd - td) units in the direction of the normal var proj = p.clone().sub(normal.clone().multiplyScalar(pd)); // closest point of proj and the triangle var cp = closestPointToTriangle(proj, va, vb, vc); if (cp.distanceTo(p) < closestDistance) { closestDistance = cp.distanceTo(p); closestPoint.position.copy(cp); closestPoint.position.y.toString() + ',' + closestPoint.position.z.toString() + ','; } }) function sameSide(p1, p2, a, b) { var ab = b.clone().sub(a) var ap1 = p1.clone().sub(a) var ap2 = p2.clone().sub(a) var cp1 = new THREE.Vector3().crossVectors(ab, ap1) var cp2 = new THREE.Vector3().crossVectors(ab, ap2) return cp1.dot(cp2) >= 0 } function pointInTriangle(p, a, b, c) { return sameSide(p, a, b, c) && sameSide(p, b, a, c) && sameSide(p, c, a, b) } function closestToSegment(p, a, b) { var ab = b.clone().sub(a) var nab = ab.clone().normalize() var n = nab.dot(p.clone().sub(a)) if (n < 0) return a if (n > ab.length()) return b return a.clone().add(nab.multiplyScalar(n)) } function closestToSides(p, sides) { var minDist = 1e9 var ret sides.forEach(function (side) { var ct = closestToSegment(p, side[0], side[1]) var dist = ct.distanceTo(p) if (dist < minDist) { minDist = dist ret = ct } }) return ret } function closestPointToTriangle(p, a, b, c) { // if the point is inside the triangle then it's the closest point if (pointInTriangle(p, a, b, c)) return p // otherwise it's the closest point to one of the sides return closestToSides(p, [[a, b], [b, c], [a, c]]) } Is there an easy way to do this in babylon js or do i need to work on some conversion? Here's the playground I started: https://www.babylonjs-playground.com/indexStable.html#NSSAV4 The playground uses two spheres. Unfortunately I am not sure how to do this offhand. Thank you for the assistance!
  5. Bladetrick

    objFileLoader.js.map read failed

    You were right, as usual! I needed to add MIME types for the obj extension in the web config. Thank you for your help!
  6. Bladetrick

    objFileLoader.js.map read failed

    what's this? are you referring to a setting for babylon or like a browser setting? I'm on IE 11
  7. hi! So since I started using babylon js I've been creating a ton of little stub programs to test it out. Now i'm in the process of combining some of them in an ASP.net site and ran across an issue. The error I get is: SourceMap C:\TEMP\babylon.objFileLoader.js.map read failed: Could not find file 'C:\TEMP\babylon.objFileLoader.js.map'..Exception was thrown at line 24055, column 25 in http://localhost:50739/babylon.js 0x800a03f6 - JavaScript runtime error: Invalid character What's this mean? I've never seen a .map file before, nor had the error when working on my stubs. Anyone come across this before? Here's how I have included my files. They're literally copies of what I had used before: <script src="jquery-3.3.1.slim.min.js"></script> <script src="babylon.js"></script> <script src="babylon.objFileLoader.js"></script> Thanks! Carlos
  8. Turns out that was right. There were fragmented pieces overlapping the areas having problem. Thanks for the help!
  9. Bladetrick

    Render an OBJ string with Babylon JS?

    hey thanks! i'll give that a whirl in the AM. have a nice night!
  10. Apologies if the title is misleading. I wasn't quite sure how to shorten up what i wanted to say. Here goes: So I'm working on two asp.net pages. The first allows a user to upload an OBJ file to the server where it gets inserted into a database. The second page allows the user to select an OBJ file from the database and display it in the browser. I'm having problems visualizing how this is going to work, but I would like it to: Select a model from a combobox containing the list of available models in the database. Store that model in a string[] type variable then send it to the client side where its stored in some web control. A hidden input or other type. Use the AssetsManager to load the string[] (OBJ file) and render it to the browser. Are there any existing code samples that do this? I know babylon can load a JSON object and render it but what about an OBJ file in the form of a string/text value? Or if not, maybe a suggestion for a good OBJ to JSON converter? Or is it as simple as using JSON.stringify()? Thank you, Car
  11. depth fighting! how cool does that sound. I don't believe I have multiple meshes loaded but I'll take a look. By chance can depth fighting also occur when a mesh is broken? Like when two seams haven't been welded properly and kind of overlap each other to cover voids? We have a guy that does that... often I'll see what I can do with the playground. I need to read more about it as I am not sure how to include external files. Once I get it going, i'll post. Thanks, Delta
  12. Hello, Been loading models into a small test stub. Noticed that some models look a little glitchy when I rotate the arc camera around them. Here's a sample when one is first loaded up. And when I rotate it just a bit Any thoughts on why this might happen? Is it my mesh or..? Thank you!
  13. Bladetrick

    mesh is transparent from the other side

    i set my mesh's backFaceCulling = false and that took care of it. Thanks!
  14. Bladetrick

    mesh is transparent from the other side

    Hey thanks, Brian. Attached is my .obj I'll read the links you sent. Appreciate the help. Cockpit.obj
  15. I have this mesh loaded up. When I point the camera at it, this is what it looks like from under. However, when I rotate the camera around it, the mesh appears to become transparent. I don't see the outside. Just a view to the inside. Here's the view from above and turned a bit. I feel like I missed something easy somewhere. Anyone have any thoughts? Is this the way it was exported from the modeler or is there something I need to set in Babylon to see the outside. Thank you.