diff --git a/source/external/three.model.loader.js b/source/external/three.model.loader.js index cfcc28f..181263d 100644 --- a/source/external/three.model.loader.js +++ b/source/external/three.model.loader.js @@ -12,16 +12,6 @@ OV.ThreeModelLoader = class this.callbacks = callbacks; } - GetDefaultColor () - { - return this.importer.GetDefaultColor (); - } - - SetDefaultColor (defaultColor) - { - this.importer.SetDefaultColor (defaultColor); - } - LoadFromUrlList (urls) { if (this.inProgress) { diff --git a/source/model/modelentities.js b/source/model/modelentities.js index 958c754..69cc7ba 100644 --- a/source/model/modelentities.js +++ b/source/model/modelentities.js @@ -25,23 +25,6 @@ OV.Color = class this.b = b; // 0 .. 255 } - ToHexString () - { - function IntegerToHex (intVal) - { - let result = parseInt (intVal, 10).toString (16); - while (result.length < 2) { - result = '0' + result; - } - return result; - } - - let r = IntegerToHex (this.r); - let g = IntegerToHex (this.g); - let b = IntegerToHex (this.b); - return r + g + b; - } - Clone () { return new OV.Color (this.r, this.g, this.b); @@ -253,3 +236,37 @@ OV.Triangle = class return cloned; } }; + +OV.ColorToHexString = function (color) +{ + function IntegerToHex (intVal) + { + let result = parseInt (intVal, 10).toString (16); + while (result.length < 2) { + result = '0' + result; + } + return result; + } + + let r = IntegerToHex (color.r); + let g = IntegerToHex (color.g); + let b = IntegerToHex (color.b); + return r + g + b; +}; + +OV.HexStringToColor = function (hexString) +{ + if (hexString.length !== 6) { + return null; + } + + let r = parseInt (hexString.substr (0, 2), 16); + let g = parseInt (hexString.substr (2, 2), 16); + let b = parseInt (hexString.substr (4, 2), 16); + return new OV.Color (r, g, b); +}; + +OV.ColorIsEqual = function (a, b) +{ + return a.r === b.r && a.g === b.g && a.b === b.b; +}; diff --git a/source/parameters/parameterlist.js b/source/parameters/parameterlist.js index 46af611..6f4695d 100644 --- a/source/parameters/parameterlist.js +++ b/source/parameters/parameterlist.js @@ -199,10 +199,9 @@ OV.CreateUrlParser = function (urlParams) return new OV.ParameterListParser (urlParams, '$'); }; -OV.CreateUrlParameters = function (urls, camera) +OV.CreateModelUrlParameters = function (urls) { let builder = OV.CreateUrlBuilder (); builder.AddModelUrls (urls); - builder.AddCamera (camera); return builder.GetParameterList (); }; diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index f61b410..3a51b2e 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -70,7 +70,8 @@ OV.Init3DViewerElements = function () if (colorParams) { let color = OV.ParameterConverter.StringToColor (colorParams); if (color !== null) { - loader.SetDefaultColor (color); + let importer = loader.GetImporter (); + importer.SetDefaultColor (color); } } diff --git a/test/tests/model_test.js b/test/tests/model_test.js index 52fbbcc..5031851 100644 --- a/test/tests/model_test.js +++ b/test/tests/model_test.js @@ -150,3 +150,19 @@ describe ('Model Finalization', function() { assert.strictEqual (normal.z, 0.7071067811865475); }); }); + +describe ('Color Conversion', function() { + it ('Color equality check', function () { + assert (OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 20, 30))); + assert (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (11, 20, 30))); + assert (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 21, 30))); + assert (!OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 20, 31))); + }); + + it ('Color hex string conversion', function () { + let color = new OV.Color (10, 20, 30); + let hexString = '0a141e'; + assert.strictEqual (OV.ColorToHexString (color), hexString); + assert.deepStrictEqual (OV.HexStringToColor (hexString), color); + }); +}); diff --git a/website/o3dv/dialogs.js b/website/o3dv/dialogs.js index e98b72a..10ece86 100644 --- a/website/o3dv/dialogs.js +++ b/website/o3dv/dialogs.js @@ -1,3 +1,8 @@ +OV.FeatureSet = +{ + SetDefaultColor : false +}; + OV.ProgressDialog = class { constructor () @@ -287,13 +292,28 @@ OV.ShowExportDialog = function (model) OV.ShowEmbeddingDialog = function (importer, camera) { - function GetEmbeddingCode (files, camera, useCameraCheck) + function AddCheckboxLine (parentDiv, text, onChange) { + let line = $('