adizanni / floor3d-card

Your Home Digital Twin: aka floor3d-card. Visualize Home Assistant state and perform actions using objects in a 3D home model based on Three.js.
https://github.com/adizanni/floor3d-card
MIT License
444 stars 64 forks source link

Grouped/Nested Objects positioned wrong #110

Open ruegr opened 2 years ago

ruegr commented 2 years ago

Hi there,

Seems the root cause are not multiple materials but grouped/nested objects - see https://github.com/adizanni/floor3d-card/issues/110#issuecomment-1140404471

I'm using Blender and not SweetHome3D for modelling and discovered, that objects with more than one material are not positioned at the desired coordinates but at [0,0,0].

Simple test file in blender: Blender_  U__Blender_M12_homeassistant-reduced_positionbug-simpletest_positionbug-simpletest blend  28 05 2022 11_31_26_LI "Cube.001" is placed at [5,1,0.1] and has two materials - one half green and the other blue

Exported as glb and imported to floor3d-card: Home Assistant - Flur-Dashboard – Home Assistant 28 05 2022 11_36_45 The double-material cube is placed at [0,0,0] while the just-green cube is at the desired position

I checked the same file with the https://threejs.org/editor/ (same js-bib as floor3d-card): three js editor - Google Chrome 28 05 2022 11_40_15_LI Here the double-material cube is at the right position. It seems, that in the glb the cube is cuttet into to different objects, one for each material.

In the ThreeJS-Editor each new object is at the right position. In the floor3d-card there are different objects for each material too, but they are all placed at [0,0,0].

=> I think there is a bug in floor3d-card (and not ThreeJS) positioning such material-splitted objects

Test-Files (Blender & glb): positionbug-simpletest.zip

adizanni commented 2 years ago

Hello @ruegr, I need a bit of time as this is tricky and it is not my main supported flow. The flows that I use and test are:

  1. Sweethome -> Plugin -> Obj -> Card
  2. Sweethome -> Obj -> Card
  3. Sweethome -> Plugin -> Obj -> Objtogltf -> Card

Blender is a whole new big world for me; and I definetly discarded it as a sweethome obj to glb converter (it was doing too many changes to the object names). Using it as a modeling tool from scratch could work but I need to really get more acquaitened with the tool and maybe adapt the code to have less dependencies with Sweethome3d (ex levels or object groups, etc)

I accept that regardless of the modeling tool, if the model is displayed in three.js editor it should be displayed the same in the card but there are many factors preventing this not to work as expected. If nobody helps me in debugging the code this fix may take a significant amount of time

ruegr commented 2 years ago

Hi @adizanni,

yeah, Blender is a really nice tool but it has "some learning curve" ;-) One advantage i see are the object-ids - you can define them manually and the will stay the same no matter what you change / how often you export.

I investigated the failure a little bit further; the oberservation regarding multiple materials just seem to be a side effect. The root cause seems to be grouped/nested objects: Blender  U__Blender_M12_homeassistant-reduced_positionbug-simpletest_positionbug-simpletest2 blend  29 05 2022 10_32_51 Here the blue cube is a child of the green cube

Again in the ThreeJS-Editor everything looks good - CubeBlue is on top of CubeGreen and the outliner shows, that in the glb the cubes are still nested three js editor - Google Chrome 29 05 2022 10_34_39

But in floor3d-card CubeBlue is misplaced. I think it is not at [0,0,0], looks like [0,0,0] + [Offset_from_CubeGreen-Origin_to_CubeBlue-Origin] Home Assistant - Übersicht – Home Assistant 29 05 2022 10_37_37_LI

Test-Files (.blend and .glb): positionbug-simpletest2.zip

If i can help with further analysis please tell me!

adizanni commented 10 months ago

Hello @ruegr , it is more than a year and a half that you opened this ticket and I will get back at spending some effort on the card, notably try to support any type of modeling tool. I would really need the help of knowledgeable people. If you are interested please let me know....