• Content Count

  • Joined

  • Last visited

Everything posted by Bladetrick

  1. Hail! I was perusing the site and found the documentation on the action manager. So I created this playground to swap the camera target on double click. It seems to work ok but i noticed that when I change the camera target, the camera's pivot point stays the same. How do I get it to pivot around the selected mesh? Also, I noticed that sometimes I have to double click more than once to change target. Is that because I'm trying to swap too fast?
  2. I didn't know what to expect hehe. I just noticed it. I recognize the symbol for mesh but that was it. i guess i was thrown off by the fact that it had the same layer name. i'll look that transformNode thing up, thank you!
  3. Hello again, I downloaded the debug layer Inspector and started using it in a project. Here's what happens: 1. I load up a model and move the camera around it. (no problem) 2. Open the inspector and use it (no problem) 3. Move the camera again and get (edit: found out the error doesn't occur when mouse zooming in and out... only when mouse rotating) Unhandled exception at line 15475, column 147 in http://xxx/babylon.js 0x800a139e - JavaScript runtime error: InvalidStateError This behavior only occurs when then inspector has been opened and continues even after the inspector has been closed. Also, once closed, the inspector will not come back up again when calling it. Only a refresh of the page resets things right. Anyone have any problems with this before? Edit again: oh and I just ran into Unhandled exception at line 1, column 104738 in http://xxx/Inspector.js 0x800a138f - JavaScript runtime error: Unable to get property 'dispose' of undefined or null reference when trying to close the inspector with its X button
  4. hello! What does this symbol mean? I notice it has no visibility and no vertex count. Thank you, Carlos
  5. Ok, forget it all. I'm dumb. I'm so new to this still that I was making things overcomplicated and also noticed i was looking at(and using) the wrong set of coordinates. Yes, the meshes were returning 0,0,0; however, the closest facet i calculated had real values that I can work with. Thanks all. Helped a lot to work it through.
  6. I apologize, I didn't give enough information. Here's situation. 1. Object is loaded. This works. 2. I read some data points in from a database and create spheres at those locations. This works. 3. Determine closest mesh to sphere. This works. 4. Determine closest point on closest mesh to sphere. This is where I get the 0,0,0 Doesn't work so the rest don't either 5. Cast ray from sphere to closest point on closest mesh. The meshes are stationary and will not move, rotate, translate, etc. The only movement is from the camera. Its probably just a matter of me coding this wrong but here's a playground illustrating it: In the playground I'm getting them to shoot to the mesh. but it is still hitting the center and not the closest point on the mesh. So that's one problem. Still having issues with my models having positions of 0,0,0 though on my project. Wish I could post those. Both rays shoot the center of the meshes instead of the closest point. eps, I inherited the meshes. Raggar, I checked and all the pivot points are centered to object, but I guess I don't understand why it matters if there will be no transformations on the meshes. Thanks all edit: side note... for some reason the rays are only visible from certain angles so you'll have to rotate. not sure why that is.
  7. this OBJ file was generated with 3DS Max. Another odd thing i noticed is that there are multiples of each mesh. Like there are 5-7 meshes that get generated for steering wheel, for example
  8. Both position and getAbsolutePosition() come out with 0, 0, 0 for all meshes
  9. From the links suggested I figured out how things worked; however, I have another problem on my end. I started a new topic here in case anyone wants to take a looksee: Again thanks for all the advice up to this point
  10. hello! I have an OBJ file that contains a vehicle. The vehicle has multiple layers to it (left front tire, passenger door, etc), each one loading up as its own mesh. I am starting to notice that, though the model loads correctly and looks fine, the mesh.positions are all listed as [0,0,0]. When trying to cast a ray from some arbitrary origin vector to the closest mesh, they all shoot to the world's 0,0,0 and, either miss the target completely (no hit) or hit some other mesh that's in the way. Any thoughts on how to find the real locations of these meshes? Thank you.
  11. i used getClosestFaceAtLocalCoordinates and it works, though the point it came up with is not the closest that I can see. i don't know. I'll do some more reading/testing and let you know my results. Thanks all, for the help/ideas!
  12. You're right, Jerome. I rearranged it and got it to load properly; however, my point (a sphere) is close as heck and it still gives a value of null. Not sure what I'm doing wrong. I'm just trying to cast a ray to the closest facet/point
  13. Thanks, that's giving me a good starting point to work with. I'm reading on partitioning more carefully and playing with the updated playground. Question, though: When using var index = mesh.getClosestFacetAtCoordinates(dot.position.x, dot.position.y, dot.position.z, nearestpoint); on the playground I get the following error: Line 38:22 - Cannot read property 'getClosestFacetAtCoordinates' of undefined even though the intellisense picked it up fine. am I doing something wrong here? Thanks again.
  14. Hello! I was noticing that .getClosestFacetAtCoordinates results in index == null given the parameters below. In what situation can this occur? The nearestMesh is valid from what I can see. It occurs fairly often in this set of data i'm using. nearestpoint = BABYLON.Vector3.Zero(); var index = nearestMesh.getClosestFacetAtCoordinates(-20.5, 115, 226, nearestpoint); // If i change the second parameter to 115 I get a facet index. if (index != null) { worldPos = nearestMesh.getFacetPosition(index); } I noticed that if i switch the second paramter's value by just 2, I get an index back. Does this mean that the distance between the given point and a mesh facet has a limit for it to work? Thanks for the help!
  15. So it turned out that, I had forgotten to include serving that extension in the mime settings of my web.config file. I'd gotten the OBJ, just forgot the MTL. Thanks for the help everyone
  16. Hello and apologies, i do not have a playground for it. I'll see if i can reproduce it with something i can put on a playground then get back to you
  17. Hello! I was wondering, is there still no way of utilizing the .mtl file that is exported with an OBJ file in babylon js? I was reading the objectfile loader and assets manager documentation and it seemed like this was the case; however, maybe I misunderstood or its outdated? Thank you!
  18. 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!
  19. 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?
  20. 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:
  21. 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 =; // 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 >= 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 = 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: The playground uses two spheres. Unfortunately I am not sure how to do this offhand. Thank you for the assistance!
  22. You were right, as usual! I needed to add MIME types for the obj extension in the web config. Thank you for your help!
  23. what's this? are you referring to a setting for babylon or like a browser setting? I'm on IE 11
  24. 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 site and ran across an issue. The error I get is: SourceMap C:\TEMP\ read failed: Could not find file 'C:\TEMP\'..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