Disable color settings with feature toggle.

This commit is contained in:
kovacsv 2021-08-15 21:43:11 +02:00
parent fe2836d632
commit 78aaba8a32
3 changed files with 49 additions and 37 deletions

View File

@ -1,4 +1,4 @@
OV.FeatureSet = OV.FeatureSet =
{ {
ColorSettings : false
}; };

View File

@ -23,8 +23,8 @@ OV.ShowSharingDialog = function (importer, settings, camera)
let builder = OV.CreateUrlBuilder (); let builder = OV.CreateUrlBuilder ();
builder.AddModelUrls (params.files); builder.AddModelUrls (params.files);
builder.AddCamera (params.camera); builder.AddCamera (params.camera);
builder.AddBackground (params.background); builder.AddBackground (params.backgroundColor);
builder.AddColor (params.color); builder.AddColor (params.defaultColor);
let hashParameters = builder.GetParameterList (); let hashParameters = builder.GetParameterList ();
let embeddingCode = ''; let embeddingCode = '';
@ -79,14 +79,19 @@ OV.ShowSharingDialog = function (importer, settings, camera)
embeddingCodeParams.camera = checked ? camera : null; embeddingCodeParams.camera = checked ? camera : null;
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
}); });
AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', (checked) => { if (OV.FeatureSet.ColorSettings) {
embeddingCodeParams.background = checked ? settings.backgroundColor : null; AddCheckboxLine (optionsSection, 'Use overridden background color', 'embed_background', (checked) => {
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); embeddingCodeParams.backgroundColor = checked ? settings.backgroundColor : null;
}); embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', (checked) => { });
embeddingCodeParams.color = checked ? settings.defaultColor : null; AddCheckboxLine (optionsSection, 'Use overridden default color', 'embed_color', (checked) => {
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); embeddingCodeParams.defaultColor = checked ? settings.defaultColor : null;
}); embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
});
} else {
embeddingCodeParams.backgroundColor = null;
embeddingCodeParams.defaultColor = null;
}
embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams)); embeddingCodeInput.val (GetEmbeddingCode (embeddingCodeParams));
} }
@ -112,8 +117,8 @@ OV.ShowSharingDialog = function (importer, settings, camera)
let embeddingCodeParams = { let embeddingCodeParams = {
files : modelFiles, files : modelFiles,
camera : camera, camera : camera,
background : settings.backgroundColor, backgroundColor : settings.backgroundColor,
color : settings.defaultColor defaultColor : settings.defaultColor
}; };
let dialog = new OV.ButtonDialog (); let dialog = new OV.ButtonDialog ();

View File

@ -520,7 +520,10 @@ OV.Website = class
} }
this.detailsPanel = new OV.DetailsSidebarPanel (this.parameters.sidebarDiv); 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 = [ let sidebarPanels = [
{ {
@ -529,15 +532,17 @@ OV.Website = class
image : 'details', image : 'details',
title : 'Details panel', title : 'Details panel',
button : null button : null
}, }
{ ];
if (OV.FeatureSet.ColorSettings) {
sidebarPanels.push ({
panelId : null, panelId : null,
panel : settingsPanel, panel : settingsPanel,
image : 'settings', image : 'settings',
title : 'Settings panel', title : 'Settings panel',
button : null button : null
} });
]; }
for (let id = 0; id < sidebarPanels.length; id++) { for (let id = 0; id < sidebarPanels.length; id++) {
let sidebarPanel = sidebarPanels[id]; let sidebarPanel = sidebarPanels[id];
@ -554,27 +559,29 @@ OV.Website = class
}); });
} }
let defaultSettings = new OV.WebsiteSettings (); if (OV.FeatureSet.ColorSettings) {
settingsPanel.InitSettings ( let defaultSettings = new OV.WebsiteSettings ();
this.settings, settingsPanel.InitSettings (
defaultSettings, this.settings,
{ defaultSettings,
onBackgroundColorChange : (newVal) => { {
this.settings.backgroundColor = newVal; onBackgroundColorChange : (newVal) => {
this.settings.SaveToCookies (this.cookieHandler); this.settings.backgroundColor = newVal;
this.viewer.SetBackgroundColor (newVal); this.settings.SaveToCookies (this.cookieHandler);
}, this.viewer.SetBackgroundColor (newVal);
onDefaultColorChange : (newVal) => { },
this.settings.defaultColor = newVal; onDefaultColorChange : (newVal) => {
this.settings.SaveToCookies (this.cookieHandler); this.settings.defaultColor = newVal;
if (this.modelLoader.defaultMaterial !== null) { this.settings.SaveToCookies (this.cookieHandler);
OV.ReplaceDefaultMaterialColor (this.model, newVal); if (this.modelLoader.defaultMaterial !== null) {
this.modelLoader.ReplaceDefaultMaterialColor (newVal); OV.ReplaceDefaultMaterialColor (this.model, newVal);
this.modelLoader.ReplaceDefaultMaterialColor (newVal);
}
this.viewer.Render ();
} }
this.viewer.Render ();
} }
} );
); }
let show = this.cookieHandler.GetBoolVal ('ov_show_sidebar', true); let show = this.cookieHandler.GetBoolVal ('ov_show_sidebar', true);
ShowSidebar (this.sidebar, this.cookieHandler, sidebarPanels, show ? sidebarPanels[0].panelId : null); ShowSidebar (this.sidebar, this.cookieHandler, sidebarPanels, show ? sidebarPanels[0].panelId : null);