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
471 stars 67 forks source link

Mapped objects causes performance issues #180

Closed keeema closed 6 months ago

keeema commented 7 months ago

I have model from sketchup exported via Collada to SweetHome, from SweetHome to obj and from obj to glb. It is fast in Sketchup or SweetHome and also in floor3d-card until I map object ids.

After mapping few object IDs and using them in entities it becomes very slow and twitchy.

object_groups:
          - object_group: SvetloVchod
            objects:
              - object_id: '1476_795'
              - object_id: '1458_777'
              - object_id: '1455_774'
              - object_id: '1435_754'
          - object_group: SvetloSeverniTerasa
            objects:
              - object_id: '3571_843'
              - object_id: '3553_825'
              - object_id: '3550_822'
              - object_id: '3530_802'
          - object_group: SvetloZapadniTerasa
            objects:
              - object_id: '11134_1067'
              - object_id: '11162_1095'
              - object_id: '11159_1092'
              - object_id: '11139_1072'
          - object_group: GarazovaVrataTop
            objects:
              - object_id: '114_115'
          - object_group: GarazovaVrata
            objects:
              - object_id: '130_131'
              - object_id: '130_132'
          - object_group: Vysavac
            objects:
              - object_id: '5730_955'
              - object_id: '5636_861'
              - object_id: '5629_854'
              - object_id: '5627_852'
          - object_group: KlimaObyvak
            objects:
              - object_id: '767_722'
              - object_id: '765_720'
              - object_id: '769_724'
              - object_id: '775_730'
              - object_id: '780_735'
          - object_group: KlimaChodba
            objects:
              - object_id: '1109_746'
              - object_id: '1099_736'
              - object_id: '1108_745'
              - object_id: '1103_740'
          - object_group: KameraVchod
            objects:
              - object_id: '45988_2073'
              - object_id: '44110_1964'
          - object_group: BranaPlocha
            objects:
              - object_id: '356_320'
          - object_group: Brana
            objects:
              - object_id: '356_320'
              - object_id: '357_321'
              - object_id: '355_319'
              - object_id: '354_318'
              - object_id: '357_321'
              - object_id: '357_321'
adizanni commented 7 months ago

In normal circumstances the object groups have no impact on performance. Only lights and animations are known to affect performance (mainly memory). I would need the full model to see what's going on

keeema commented 6 months ago

I will send it to an email.

adizanni commented 6 months ago

Hello Keema, the behaviour of light with object group is unpredictable, usually it is preferable to have multiple entity with the same light entity and different object id, if what you want to obtain is a led strip or a group light. I've tried to create a rotate object with one of your grouped object and it is working as expected. Also bear in mind that the card is not supporting too many lights. Lights are the most demanding for the model rendering in 3d (if you want to have the shadow effect).

keeema commented 6 months ago

OK, using light as switch might be the explanation for bad performance when I use it for gate or garage door. But what to use as simple switch instead of light? E.g. I have one entity for hide (the entity for door contact) and one entity for turning on and off but both are for garage door.

keeema commented 6 months ago

OK, I got it!

For entities other than light I can use gesture with domain switch and service toggle. And it can also be used to deal with many object ids for one light - it could be separated to one object for light and rest for gesture:

object_groups:
  - object_group: SvetloVchod1
    objects:
      - object_id: '1476_795'
      - object_id: '1455_774'
      - object_id: '1435_754'
  - object_group: SvetloVchod2
    objects:
      - object_id: '1458_777'
entities:
  - entity: switch.sonoff_10010e9531
    type3d: gesture
    object_id: <SvetloVchod1>
    gesture:
      domain: switch
      service: toggle
  - entity: switch.sonoff_10010e9531
    object_id: <SvetloVchod2>
    type3d: light
    light:
      lumens: '800'

Thank you for you help!