Sweet Home 3D Forum Category:Help Forum:Developers Thread: Easiest way to change furniture data in an actively running desktop instance (maybe through a plugin)?
No member browsing this thread
Thread Status: Active Total posts in this thread: 2
Joined: Nov 23, 2020
Post Count: 1
Status:
Offline
Easiest way to change furniture data in an actively running desktop instance (maybe through a plugin)?
So what I'm trying to do is, have a plugin, that allows me to load positional data from somewhere (sql, REST, w/e) in real time every x time units, and then immediately apply it to the currently loaded furniture so that they are also immediately updated in the 3D view.
I want to make use of the desktop client, NOT The java browser version, which I want to put back into its coffin asap.
I have done some research and so far have found 2 APIs.
The JavaScript API is closed to the Java API but is not exactly the same of course. First, two different languages with programming styles and different libraries can't lead to the same API. For example, Java lists were replaced by JavaScript arrays and Java BigDecimal class was replaced by Big class in big.js. Then, Sweet Home 3D JS isn't as complete as Sweet Home Java yet, so the JavaScript API contains less classes at the moment.
Almost all Java classes of com.eteks.sweethome3d.model and com.eteks.sweethome3d.viewcontroller packages + HomeXMLHandler class are automatically translated with JSweet which helps to keep a similar API (even if the Java package names weren't kept in JavaScript). Other classes like 3D classes and UI classes are manually translated and use a similar API too when possible.
Plug-ins are written in Java. They don't have any counterpart in JavaScript but I don't think it would have some meaning. You can program any additional feature in JavaScript by just using Sweet Home 3D JS API in a customized web page.
Which one is better suited for which purpose?
Quickly said, Java API is for the desktop installer version of Sweet Home 3D and JS API for the online web version.
To help you start writing Java plug-ins, read plug-in developer's guide. If you target a web version, read that guide too because it will give you a general idea of Sweet Home 3D API, download SweetHome3DJS source code, build the project reading README.TXT included in the source code, and inspire yourself from testHomeModifications in testHome.js. You could also have a look at Sweet Home 3D Online guide if you don't want to handle the server part yourself.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator