fdeng

Members
  • Content count

    13
  • Joined

  • Last visited

  1. fdeng

    Got wrong screen coordinates

    @dbawel @Pryme8 Thanks for your concern about this issue. I'v got the root cause: In my program, there are two viewport, so the scene.activeCameras has two cameras in it. To use the project function, var transformMatrix = this._scene.getTransformMatrix(); may not get the right transformation matrix. Instead, the transformation matrix should come from the active camera of the active viewport: var transformMatrix = this._activeport.activeCamera.getTranformationMatrix();
  2. fdeng

    Got wrong screen coordinates

    @dbawel I do need more help. Actually, the "screen coordinate" here , is I want to get the 2D coordinate of the pickedPoint on the canvas, not the real screen. I modified the PG in your post, adding these code in onPointerDown var transformMatrix = scene.getTransformMatrix(); var viewport = freeCamera.viewport.toGlobal(engine); var coordinates = BABYLON.Vector3.Project(pickResult.pickedPoint, BABYLON.Matrix.Identity(), transformMatrix, viewport); console.log("screen coordinates:", Math.ceil(coordinates.x), Math.ceil(coordinates.y)); Here is the new PG link: http://www.babylonjs-playground.com/index.html#17QBL9#2 In this PG, the "screen coordinate" is same as the mouse click position on canvas. But in my program, these code can not get the accurate coordinate of the pickedPoint I wonder what else factor may effect this result?
  3. Hi everyone, I'm trying to go from world to screen coordinates, this is my code: onPointerDown = function (evt) { console.log("pointer:", this._scene.pointerX, this._scene.pointerY); var pickResult = this._scene.pick(this._scene.pointerX, this._scene.pointerY, null, null, this._camera); if(pickResult.hit) { var transformMatrix = this._scene.getTransformMatrix(); var viewport = this._camera.viewport.toGlobal(this._engine); var coordinates = BABYLON.Vector3.Project(pickResult.pickedPoint, BABYLON.Matrix.Identity(), transformMatrix, viewport); console.log("screen coordinates:", coordinates.x, coordinates.y); } } But the screen coordinates I got is wrong: I've tried such code in PG, it works fine, but not working in my own code. So, any reason that may cause the wrong result?
  4. @Deltakosh I don't want to chip anything, I just want to select a rectangle area, and then scale up it to fill the render canvas size. @NasimiAsl Thanks for your PG demo, it can zoom in the selected area, but the scale is a little different than what I want. Your method is also a good choice if I can't find a better way to implement it
  5. Hi everyone, I need to select an area in the scene, and then enlarge it as frustum plane. Select an area by mouse: Enlarge the selected area as frustum plane: It seems babylon can not set a frustum plane directly, any idea to implement it?
  6. fdeng

    Babylon shows a different result

    @sable @brianzinn Thanks for you guys' help. I just found that I set the rotation of FreeCamera mistake, sorry, please ignore the mouse move issue. As the exporting tool I use has no such exporting option, I can't get a left handed model. Still, there is something trouble me, it seems that babylon has Y as the up-axis, the building is not standing correctly. Normally I should see the front, not the bottom of the building. (You can use ArcRotateCamera to have a look what the building is) could you please help me on this point. The PG is below: https://playground.babylonjs.com/#4QU0BY
  7. fdeng

    Babylon shows a different result

    @sable Hi, There is another issue with this right-hand model if the active camera is a FreeCamera. When the mouse moves in left - right direction, the model moves up - down, while move the mouse up - down, the model moves left - right. Can anybody tell me how to fix it?
  8. @dbawel, thanks for your useful info. @SvenFrankson, The meshes are converted from a model designed by Revit (a BIM design tool of Autodesk). about merging the meshes, I'll use uv2 to have a try, thanks a lot.
  9. @SvenFrankson, thanks for the advice. What I am trying is a very detailed building information model(BIM), a whole subway station with all kinds of building elements, structures, equipment, pipelines, and so on. There are more than 10k entities in this model, each entity has its own information, and must be pickable. As each entity is parsed to a mesh, so there are so many meshes need to draw. Besides merging the meshes, I have an thought but not sure if it is possible , and how to implement it. That is , can Babylon support to just draw the meshes in sight of the active camera? When camera moving or rotating, the meshes in the camera's view change as well, at every moment, only feed the meshes can be seen to draw.
  10. Hi Everyone, I want to render a very very big model in my project using BJS, but the performance is very poor(the fps is about 5), that is intolerable. Some info about my model: number of indices: 14349177 number of vertices: 7450965 number of meshs: 12043 As only color with RGBA is used for the meshs, I build a material map(148 materials included in the map) for(...){ var matId = br.readInt32(); var R = br.readFloat32(); var G = br.readFloat32(); var B = br.readFloat32(); var A = br.readFloat32(); var stdmat = new BABYLON.StandardMaterial(matId, scene); stdmat.diffuseColor = new BABYLON.Color3(R, G, B); stdmat.alpha = A; materialMap.push({ id: matId, material: stdmat}); } Mesh link the material in the map: var matItem = materialMap.getMaterial(object.matId); if (matItem === null) matItem = defaultMaterial; babylonMesh.material = matItem.material; Screen capture with instrumentation: Any advice to improve the performance of such a huge model? And, the draw calls is 13296, that is much more than the number of the materails I created. Which factors decide the draw calls, how can reduce it?
  11. fdeng

    Babylon shows a different result

    @sable Yes, it works after set scene.useRightHandedSystem = true;
  12. Hi Everyone, I'm a newbie to Babylon.js, I got a question need someone to help. When I load a 3D model (eg. obj format model) with Babylon.js, it shows a different result than I expected. The correct result should be : (The door is on the left side) But with Babylon.js, the model is like below : (the door is on the right side, it seems that all the meshs are rendered opposite direction) Can anybody tell me why? Is there a parameter that can be set to correct this issue?