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
454 stars 65 forks source link

Error when adding .obj to new card #158

Closed mcmikemn closed 1 year ago

mcmikemn commented 1 year ago

Checklist:

Release with the issue: floor3d-card (aka Your Home Digital Twin) 1.5.3

Last working release (if known):

Browser and Operating System: Firefox 114.0.2 in Ubuntu 22.04.2

Description of problem: I get a generic error message when I point the Floor 3d card to my exported .obj/.mtl files. I exported my .obj/mtl files from SweetHome3D 7.1. I tried 2 different .sh3d files.

When I added a card with the default demo home.glb, the card loads and functions fine.

Javascript errors shown in the web inspector (if applicable):

Logger: frontend.js.latest.202307051
Source: components/system_log/__init__.py:257
First occurred: 10:52:12 AM (29 occurrences)
Last logged: 11:47:40 AM

https://<mydomain>/hacsfiles/floor3d-card/floor3d-card.js?hacstag=361776538153:2288:34538 Error:
https://<mydomain>/hacsfiles/floor3d-card/floor3d-card.js?hacstag=361776538153:2356:4523 Error:
https://<mydomain>/hacsfiles/floor3d-card/floor3d-card.js?hacstag=361776538152:2356:4523 Error:
https://<mydomain>/frontend_latest/core-YHzXXjIBEdQ.js:1:5725 SyntaxError: JSON.parse: bad control character in string literal at line 1 column 35715171 of the JSON data

Additional information: Floor3d Card is a fantastic idea! I hope I can get it to work for me!

adizanni commented 1 year ago

Hello @mcmikemn, it is an unusual error, as a start, can you please share the YAML configuration ? Second, the home.json file is optional, try to load the model without the home.json file. If your model is very big there could be some limitations I have never tested, such as the size of the json file.

mcmikemn commented 1 year ago

Thanks for the quick reply, @adizanni!

Here's the yaml for the Floor3d card:

type: custom:floor3d-card
path: /local/basement3d/
name: Basement
objfile: Basement.obj
lock_camera: 'no'
header: 'yes'
click: 'no'
overlay: 'no'
backgroundColor: '#aaaaaa'
hideLevelsMenu: 'no'
globalLightPower: '0.8'
shadow: 'no'
extralightmode: 'no'
show_axes: 'no'
sky: 'no'
overlay_bgcolor: transparent
overlay_fgcolor: black
overlay_alignment: top-left
overlay_width: '33'
overlay_height: '20'
north:
  x: 0
  z: -1
camera_position:
  x: 609.3072605703628
  'y': 905.5330092468828
  z: 376.66437610591277
camera_rotate:
  x: -1.0930244719682243
  'y': 0.5200808414019678
  z: 0.7648717152512469
camera_target:
  x: 37.36890424945437
  'y': 18.64464320782064
  z: -82.55051697031719
object_groups:
  - object_group: RoundTable
    objects:
      - object_id: Round_table_1
      - object_id: Round_table_2
      - object_id: Round_table_3
  - object_group: EntranceDoor
    objects:
      - object_id: Door_9
      - object_id: Door_7
      - object_id: Door_5
entities:
  - entity: binary_sensor.lumi_lumi_sensor_motion_aq2_ac9f8e07_ias_zone
    type3d: door
    object_id: <EntranceDoor>
    door:
      doortype: swing
      direction: inner
      hinge: Door_3
      percentage: '90'
  - entity: binary_sensor.pixel_4_xl_is_charging
    type3d: hide
    object_id: <RoundTable>
    hide:
      state: 'off'
  - entity: light.basement_stairs_lights
    type3d: light
    object_id: Bowl_2
    light:
      lumens: '800'
zoom_areas:
  - zoom: ''
mtlfile: Basement.mtl

When I exported from SweetHome3D, no .json file was included. Is that a problem?

What counts as "very big" regarding the size of the model?

adizanni commented 1 year ago

Please remove all references to the sample objects (object groups and entities), these are only valid when you use the sample model and are causing the card to fail because the objects do not exist anymore. Nevertheless the error message you receive is not the usual one for this problem and it may reveal other issues. Try and let me know

mcmikemn commented 1 year ago

That did the trick. Thanks. Why were demo object groups and entities included in the yaml? Am I running an old version of Floor3d Card?

adizanni commented 1 year ago

When you add a card from the gallery it comes with a sample model and sample objects attached to your entities. When you change the model you need to remove the references to the old model. I realized it is not very intuitive and I need to change the sample behavior.

mcmikemn commented 1 year ago

Thanks for the explanation and the help!

mcmikemn commented 1 year ago

This wasn't a bug, and @adizanni clarified what the fix was.