Your Home Digital Twin: Interactive floor 3d plan

I was playing with it today and I’m very happy. You’ve done a really good job.

It takes like 2-3 sec to load my ground level of the house (150 MB) on my laptop.
But once loaded it is instant play. Even if one changes the tab and comes back there’s no reload.
Firefox is just a little bit faster than chrome.

There is a little bit annoying the object ID changing with obj change. Especially when one has 50+ lights in the house like mine.

Cheers,
us

1 Like

Thanks uss, I need this kind of extensive tests. Also any kind of suggestions to improve. The object ID changing is really something I cannot change (unless I build a custom export). Only way to reduce the impact, is to never delete objects. But I agree, it is annoying

In old Laptop it may also be necessary to activate the HW acceleration provided by the GPU in Chrome / Firefox. The browser itself has to be in the list of GPU enabled executables and inside Chrome / Firefox there are settings for HW acceleration. I will give ore hints in the README

I can;'t wait to implement this! One question before i do though. Does it / could it / will it support animations?

1 Like

Hello Jampez, I’m not familiar about the animation in Three.js; for sure it is not coming from SweetHome3D. For basic things like rotating a window pane when the windows is opened, this can be achieved (i’m actually working at it). But all type of animations need specific coding. To make an example: if you want to put a mannequin in a scene and you want it to move from room to room depending on the room presence, this requires a lot of coding and modeling (which point in the model is representing the room, etc.).

I’ve seen that you approved the inclusion of my repository as default in HACS, can you push the rest of the community to approve ? It is not urgent…

I created a tutorial with a step to step configuration of the card: from the SweetHome3D modeling to the binding of the model to the entities in a custom card. Here it is:

6 Likes

Yeah I was thinking about basic rotations or doors / windows opening. That would be a great improvement to my current floorplan haha.

I would love to help you out with getting it approved more to I have zero say in the community haha.

I can tell you from experience that although it takes a while it will happen.

1 Like

Andy,
I’ve been thinking to the problem of object name change. Been looking into SweetHome3D’s code.
I understand why the problem appears.

As far as I can see, there is a way to solve it.

  1. Make SweetHome3D export the o [object name] tag (it doesn’t do it now, one reason might be the fact that SweetHome3D accepts the same name for several different instances of the same object).
    If you look into the file
    SweetHome3D-6.5.2-src\src\com\eteks\sweethome3d\j3d\OBJWriter.java
    from line 335:
    private void writeNode(Node node, String nodeName, Transform3D parentTransformations)
    basically it parses the objects by calling itself and goes down for the children of the Group (see lines 343-347). Tests can be made to make it export the “o” tag.
    If export is ok, eventually, a SweetHome3D plugin can be written, basically the same code in plugin format.
  2. On the other side, floor3d-card has to get the o tag (which btw. has to have unique name) and use it as object name. In this way an object will always have the same name no matter what changes to the SweetHome3D design is made.

I can go into some details if I wasn’t clear enough.

Cheers,
us

1 Like

Hello uss,

very well spotted. I have to admit, I did not dare to go into SweetHome3D code, but now that you have pointed me to the file, we can work something out. This is the bad guy;

(line 372) objectName += String.valueOf(this.shapeIndex++);

ShapeIndex is recalculated at each export and it is not local to one tree branch. You are right it is a brute force way to ensure the o tags are unique.

Using the name of the root object (in the modify furniture dialog) as the root of the o tag and a ShapeIndex local to the branch, may solve the problem.

Are you looking into how to build a plugin ? I think that I would need some spare time to set myself into it…

I will look into, but after I finish preparing and seeding the lawn :slight_smile: . I’m already late!
In the mean time, will you check something on floor3d-card side?

Export a simple 2 objects obj from SweetHome3D.
Edit and insert o tags.
Can you do object select (defined by o tag) in floor3d-card?

Thanks,
us

1 Like

Hello uss, the o tag is well managed by the three.js library but it is not the one that can be used to build interaction with (build light, hide, etc.) I need more timeto confirm what I’m saying, with further testing. On the other hand if someone is up to develop the plugin, it is possible to use the g tag (I’m currently doing some discovery, but it will take a few weeks).

First of all, we need to define our goal.
What do we actually want to accomplish.
From my point of view the group (object) name change is part of the problem.
It can be solved by writing a plugin based on the already existing code in SweetHome3D export .obj without much change on your side of the code.
But, thinking further, I reckon we need to find a way to get an action by clicking (double clicking, hold, whatever) associated with the object one is clicking on. The object can be any object, a light, a TV, a camera etc.
Like I am doing now in the picture element floor plan.
You do get an action now by double clicking a group to get the group name.
Another possible issue (using g instead of o) is the position of the light source you are turning on.
I don’t know how you do that (didn’t have time to check the code) but when you select a group you actually select the top most group of the object and associate the light source with it. If there are groups (part of the same object) underneath the top group, the light source might be obscured.

Please let me know what you are thinking.
Cheers,
us

1 Like

Hello uss, I do agree about setting goals.
Here what we are trying to achieve is the following:

  1. Preserve the name of the objects across multiple export of the same models;
  2. Still be able to bind objects to entities to visualize state or trigger actions

It will be impossible to achieve both without touching the OBJWriter class you pointed me to.
Sweethome3D is not natively exporting O tags and the G tags are built diregarding the pesistency of the names. As far as I could test, the O tag are not searchable by name in the Three.js library.
The light is not a problem, I create it by setting a point light at the center of the box containing the object. That is working in all contexts. Actions on objects can be achieved easily (I can do it by clicking on the object representing the light or by creating a new switch object that can be positioned somewhere else). What I propose is to redesign the OBJWriter (unfortunately we will loose forward compatibility): thanks to your help I’m getting some knowledge on the Plugin development. Not yet there but I’m definetly progressing

Hey, So i’ve been playing around with this today and wondering how I can hide a complex object?

This is what I have for hiding a garage door object:

**  - entity: cover.garage_door
    type3d: hide
    object_id: Door_47
    hide:
      state: closed
  - entity: cover.garage_door
    type3d: hide
    object_id: Grooves_46
    hide:
      state: closed
  - entity: cover.garage_door
    type3d: hide
    object_id: Handle_44
    hide:
      state: closed

I also have a car object that is far more complex and it would balloon my card code. Is there a way to select a single object id and it hide any object nested in it / associated to it?

1 Like

Unfortunately the Export to OBJ function in Sweethome3D does not group together the elements of an object. I’m checking how we can improve the export by building a specific Export to HASS plugin. See above discussion with uss. Not an easy one. You can always edit the obj file but it is a tedious activity…

Ah right. Fingers crossed for that then!

Is it possible to change the anchor point when panning / tilting / zooming etc?

As a workaround could you change object_id to a list of multiple object?

I can suggest you a dirty workaround, waiting for a better solution.
In Sweethome3D put your car in a new model (only the car), click on Export to OBJ format.
Retrieve the file.obj. Open it in an advanced editor such as Visual Studio Code.
Then follow these steps:

  1. In place of the first "g " tag put something like “g_your_car_name”
  2. Cmd-F to open find.
  3. Paste the string "g "
  4. Alt-Enter to select all of the instances of the string on the page.
  5. Cmd-L to broaden the selection to the entire line of each instance on the page.
  6. Delete/Backspace to remove those lines.
  7. change the first g line to “g your_car_name”

Save your file as car.obj and reimport it as furniture (from the menu, Furniture, Import Furniture) give it a new name and insert it into your catalog of objects.
Satrting from your car will be made of only one object when adding it to your home model.

1 Like

Hmmm. I must have messed it up somehow because after having followed the instructions and importing back into SH3D the id’s have just been swapped by my new one followed by some numbers :confused:

It also changed some of the models colours. Going to have to revisit this one. Thanks though!

That is normal after the export of the full home containing your new car, the car gets renamed to something like your_car_name_1_1, but you now have only one object representing your car.
You just have to change your hide element to the object_id your_car_name_1_1…

1 Like