Re: Sweet Home 3D JS Online

by Puybaret » Mon May 01, 2023 7:11 pm

I forgot to mention textures libraries. Actually, it works more or less the same with SH3T files and the two additional [font=courier new]texturesCatalogURLs[/font] / [font=courier new]texturesResourcesURLBase[/font] to configure [font=courier new]application[/font] JavaScript variable in [font=courier new]index.jsp[/font].

For example, if you try with [font=courier new]Contributions.sh3t[/font] available here saved in SweetHome3DJS root folder and Tomcat installation folder in [font=courier new]/Applications/apache-tomcat-9.0.41[/font], the following PropertiesToJson command will extract .json and texture image files :

Code: Select all

java -cp tools/json/lib/json-20190722.jar:tools/json/src com.eteks.sweethome3d.json.PropertiesToJson . Contributions.sh3t /Applications/apache-tomcat-9.0.41/webapps/SweetHome3DJS-7.1/lib/resources Contributions /Applications/apache-tomcat-9.0.41/webapps/SweetHome3DJS-7.1/lib/resources/textures/Contributions lib/resources/textures/Contributions true
Comparing with the PropertiesToJson command previously used for furniture libraries, you just need to change file and folder names.

Then, adding the Contributions library to the configuration of JavaScript [font=courier new]application[/font] in [font=courier new]index.jsp[/font] will give:

Code: Select all

var application = new SweetHome3DJSApplication(
    {furnitureCatalogURLs: [urlBase + "/lib/resources/DefaultFurnitureCatalog.json", 
                            urlBase + "/lib/resources/BlendSwap-CC-0.json"],
     furnitureResourcesURLBase: urlBase + "/",
     texturesCatalogURLs: [urlBase + "/lib/resources/DefaultTexturesCatalog.json", 
                           urlBase + "/lib/resources/Contributions.json"],
     texturesResourcesURLBase: urlBase + "/",
     readHomeURL: urlBase + "/readHome.jsp?home=%s",
and adding it to the textures libraries managed by user preferences in [font=courier new]writeHomeEdits.jsp[/font] will lead to the following declaration:

Code: Select all

serverUserPreferences = new ServerUserPreferences(
    new URL [] {new URL(serverBaseUrl, "lib/resources/DefaultFurnitureCatalog.json"), 
                new URL(serverBaseUrl, "lib/resources/BlendSwap-CC-0.json")}, serverBaseUrl,
    new URL [] {new URL(serverBaseUrl, "lib/resources/DefaultTexturesCatalog.json"),
                new URL(serverBaseUrl, "lib/resources/Contributions.json")}, serverBaseUrl);
Good luck!