Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After rotating a model, I get the wrong aabb values #1316

Open
hamza-hajji opened this issue Dec 28, 2023 · 6 comments
Open

After rotating a model, I get the wrong aabb values #1316

hamza-hajji opened this issue Dec 28, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@hamza-hajji
Copy link
Contributor

hamza-hajji commented Dec 28, 2023

Describe the bug
Rotating a model makes its aabb wrong

To Reproduce
Steps to reproduce the behavior:

  1. Open the https://xeokit.github.io/xeokit-sdk/examples/buildings/#xkt_vbo_Duplex example
  2. Rotate the model by 40° in Y axis
    viewer.scene.models.myModel.rotation = [0, 40, 0]
  3. check its abb, you get the wrong values

Expected behavior
The aabb is still right after rotation

Screenshots

I made a script that draws a transparent cube given an aabb for testing:

const makeBox = (aabb) => {
  new Mesh(viewer.scene, {
    geometry: new ReadableGeometry(
      viewer.scene,
      buildBoxGeometry({
        center: [
          (aabb[3] + aabb[0]) / 2,
          (aabb[4] + aabb[1]) / 2,
          (aabb[5] + aabb[2]) / 2,
        ],
        xSize: (aabb[3] - aabb[0]) / 2, // Half-size on each axis
        ySize: (aabb[4] - aabb[1]) / 2,
        zSize: (aabb[5] - aabb[2]) / 2,
      })
    ),
    material: new PhongMaterial(viewer.scene, {
      // diffuseMap: new Texture(viewer.scene, {
      //   src: "textures/diffuse/uvGrid2.jpg",
      // }),
      backfaces: true,
      alpha: 0.2,
    }),
  });
};

It is correct initially before rotation

image

But after rotating:

image

Desktop (please complete the following information):

  • Device: Laptop HP Zbook
  • OS: Windows 64bit
  • Browser: Chrome
  • Version 120.0.6099.130 (Official Build) (64-bit)
@paireks
Copy link
Member

paireks commented Feb 4, 2024

My observation after looking at it for a while, is that after the rotation (e.g. changing position doesn't seem to have a problem) the size of aabb seems probably fine, but its the position of aabb which is wrong.
I can't find out however why wrong aabb is actually calculated.
SceneModelEntity during get aabb() do this += this.origin of the aabb, so maybe there is something with this origin. But it's difficult to spot how this origin is being calculated and when.

@paireks
Copy link
Member

paireks commented Feb 15, 2024

I tried to dig a little further, found out that for some reason in web-ifc example there is no such problem after rotation

image

@paireks
Copy link
Member

paireks commented Feb 19, 2024

Few additional observations:

  • It looks like setting a quaternion instead of rotation also ends up with wrongly positioned AABB.
  • Setting position ends up with correct AABB.
  • In fact every SceneModelMesh has wrongly positioned AABB (but with the right size).
  • In web-ifc example every SceneModelMesh has this.origin = [0,0,0], while in xkt every SceneModelMesh has this.origin is [4.4000000432133675, 2.542399935674667, 8.900000043213367]

@paireks paireks added the bug Something isn't working label Apr 20, 2024
@intrida-dev
Copy link

intrida-dev commented May 8, 2024

Has this been fixed? #1379 seems to be closed.

@xeolabs
Copy link
Member

xeolabs commented May 8, 2024

@intrida-dev It has not been fixed. For distantly-placed models, I have not been able to make individual object rotations on objects work within xeokit's RTC tiles coordinate system. I'm not sure of a solution for that at this stage. Only translations currently work for all models.

@intrida-dev
Copy link

@xeolabs Ok. We will try applying translations until this gets fixed. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants