From 78aaba8a32e86a789d8c3d034c79297532cd0441 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sun, 15 Aug 2021 21:43:11 +0200 Subject: [PATCH] Disable color settings with feature toggle. --- website/o3dv/js/featureset.js | 2 +- website/o3dv/js/sharingdialog.js | 29 ++++++++++------- website/o3dv/js/website.js | 55 ++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/website/o3dv/js/featureset.js b/website/o3dv/js/featureset.js index 32c904d..f4dfea8 100644 --- a/website/o3dv/js/featureset.js +++ b/website/o3dv/js/featureset.js @@ -1,4 +1,4 @@ OV.FeatureSet = { - + ColorSettings : false }; diff --git a/website/o3dv/js/sharingdialog.js b/website/o3dv/js/sharingdialog.js index 6a9e28d..2300136 100644 --- a/website/o3dv/js/sharingdialog.js +++ b/website/o3dv/js/sharingdialog.js @@ -23,8 +23,8 @@ OV.ShowSharingDialog = function (importer, settings, camera) let builder = OV.CreateUrlBuilder (); builder.AddModelUrls (params.files); builder.AddCamera (params.camera); - builder.AddBackground (params.background); - builder.AddColor (params.color); + builder.AddBackground (params.backgroundColor); + builder.AddColor (params.defaultColor); let hashParameters = builder.GetParameterList (); let embeddingCode = ''; @@ -79,14 +79,19 @@ OV.ShowSharingDialog = function (importer, settings, camera) embeddingCodeParams.camera = checked ? camera : null; embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); }); - AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', (checked) => { - embeddingCodeParams.background = checked ? settings.backgroundColor : null; - embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); - }); - AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', (checked) => { - embeddingCodeParams.color = checked ? settings.defaultColor : null; - embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); - }); + if (OV.FeatureSet.ColorSettings) { + AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', (checked) => { + embeddingCodeParams.backgroundColor = checked ? settings.backgroundColor : null; + embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); + }); + AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', (checked) => { + embeddingCodeParams.defaultColor = checked ? settings.defaultColor : null; + embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); + }); + } else { + embeddingCodeParams.backgroundColor = null; + embeddingCodeParams.defaultColor = null; + } embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); } @@ -112,8 +117,8 @@ OV.ShowSharingDialog = function (importer, settings, camera) let embeddingCodeParams = { files : modelFiles, camera : camera, - background : settings.backgroundColor, - color : settings.defaultColor + backgroundColor : settings.backgroundColor, + defaultColor : settings.defaultColor }; let dialog = new OV.ButtonDialog (); diff --git a/website/o3dv/js/website.js b/website/o3dv/js/website.js index 237f6de..e7c6dff 100644 --- a/website/o3dv/js/website.js +++ b/website/o3dv/js/website.js @@ -520,7 +520,10 @@ OV.Website = class } this.detailsPanel = new OV.DetailsSidebarPanel (this.parameters.sidebarDiv); - let settingsPanel = new OV.SettingsSidebarPanel (this.parameters.sidebarDiv); + let settingsPanel = null; + if (OV.FeatureSet.ColorSettings) { + settingsPanel = new OV.SettingsSidebarPanel (this.parameters.sidebarDiv); + } let sidebarPanels = [ { @@ -529,15 +532,17 @@ OV.Website = class image : 'details', title : 'Details panel', button : null - }, - { + } + ]; + if (OV.FeatureSet.ColorSettings) { + sidebarPanels.push ({ panelId : null, panel : settingsPanel, image : 'settings', title : 'Settings panel', button : null - } - ]; + }); + } for (let id = 0; id < sidebarPanels.length; id++) { let sidebarPanel = sidebarPanels[id]; @@ -554,27 +559,29 @@ OV.Website = class }); } - let defaultSettings = new OV.WebsiteSettings (); - settingsPanel.InitSettings ( - this.settings, - defaultSettings, - { - onBackgroundColorChange : (newVal) => { - this.settings.backgroundColor = newVal; - this.settings.SaveToCookies (this.cookieHandler); - this.viewer.SetBackgroundColor (newVal); - }, - onDefaultColorChange : (newVal) => { - this.settings.defaultColor = newVal; - this.settings.SaveToCookies (this.cookieHandler); - if (this.modelLoader.defaultMaterial !== null) { - OV.ReplaceDefaultMaterialColor (this.model, newVal); - this.modelLoader.ReplaceDefaultMaterialColor (newVal); + if (OV.FeatureSet.ColorSettings) { + let defaultSettings = new OV.WebsiteSettings (); + settingsPanel.InitSettings ( + this.settings, + defaultSettings, + { + onBackgroundColorChange : (newVal) => { + this.settings.backgroundColor = newVal; + this.settings.SaveToCookies (this.cookieHandler); + this.viewer.SetBackgroundColor (newVal); + }, + onDefaultColorChange : (newVal) => { + this.settings.defaultColor = newVal; + this.settings.SaveToCookies (this.cookieHandler); + if (this.modelLoader.defaultMaterial !== null) { + OV.ReplaceDefaultMaterialColor (this.model, newVal); + this.modelLoader.ReplaceDefaultMaterialColor (newVal); + } + this.viewer.Render (); } - this.viewer.Render (); } - } - ); + ); + } let show = this.cookieHandler.GetBoolVal ('ov_show_sidebar', true); ShowSidebar (this.sidebar, this.cookieHandler, sidebarPanels, show ? sidebarPanels[0].panelId : null);