diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b056bd5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://www.paypal.com/donate?hosted_button_id=N8V9R8JFH2SE2'] diff --git a/package.json b/package.json index c131c87..84b34b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "online-3d-viewer", "description": "Online 3D Viewer", - "version": "0.7.6", + "version": "0.7.7", "repository": "github:kovacsv/Online3DViewer", "license": "MIT", "devDependencies": { diff --git a/source/export/exporterbase.js b/source/export/exporterbase.js index b35c7ab..27d3d34 100644 --- a/source/export/exporterbase.js +++ b/source/export/exporterbase.js @@ -3,7 +3,6 @@ OV.ExportedFile = class constructor (name) { this.name = name; - this.url = null; this.content = null; } @@ -17,16 +16,6 @@ OV.ExportedFile = class this.name = name; } - GetUrl () - { - return this.url; - } - - SetUrl (url) - { - this.url = url; - } - GetContent () { return this.content; diff --git a/source/export/exportergltf.js b/source/export/exportergltf.js index 238ce7c..b931487 100644 --- a/source/export/exportergltf.js +++ b/source/export/exportergltf.js @@ -50,7 +50,7 @@ OV.ExporterGltf = class extends OV.ExporterBase let textureIndex = fileNameToIndex[fileName]; if (textureIndex === undefined) { let textureFile = new OV.ExportedFile (fileName); - textureFile.SetUrl (texture.url); + textureFile.SetContent (texture.buffer); files.push (textureFile); textureIndex = mainJson.textures.length; @@ -244,19 +244,10 @@ OV.ExporterGltf = class extends OV.ExporterBase } } - function AddBufferView (mainJson, offset, length) - { - mainJson.bufferViews.push ({ - buffer : 0, - byteOffset : offset, - byteLength : length, - }); - return offset + length; - } - let mainJson = { asset : { - version : '2.0' + version : '2.0', + generator : 'https://3dviewer.net' }, scene : 0, scenes : [ diff --git a/source/export/exporterobj.js b/source/export/exporterobj.js index 98b65f0..51bea6d 100644 --- a/source/export/exporterobj.js +++ b/source/export/exporterobj.js @@ -25,7 +25,7 @@ OV.ExporterObj = class extends OV.ExporterBase }); if (fileIndex === -1) { let textureFile = new OV.ExportedFile (fileName); - textureFile.SetUrl (texture.url); + textureFile.SetContent (texture.buffer); files.push (textureFile); } } @@ -37,6 +37,7 @@ OV.ExporterObj = class extends OV.ExporterBase files.push (objFile); let mtlWriter = new OV.TextWriter (); + mtlWriter.WriteLine (this.GetHeaderText ()); for (let materialIndex = 0; materialIndex < model.MaterialCount (); materialIndex++) { let material = model.GetMaterial (materialIndex); mtlWriter.WriteArrayLine (['newmtl', this.GetExportedMaterialName (material.name)]); @@ -52,6 +53,7 @@ OV.ExporterObj = class extends OV.ExporterBase mtlFile.SetContent (mtlWriter.GetText ()); let objWriter = new OV.TextWriter (); + objWriter.WriteLine (this.GetHeaderText ()); objWriter.WriteArrayLine (['mtllib', mtlFile.GetName ()]); let vertexOffset = 0; let normalOffset = 0; @@ -105,4 +107,9 @@ OV.ExporterObj = class extends OV.ExporterBase objFile.SetContent (objWriter.GetText ()); } + + GetHeaderText () + { + return '# exported by https://3dviewer.net'; + } }; diff --git a/source/external/three.model.loader.js b/source/external/three.model.loader.js index 6e7a0d2..62154d4 100644 --- a/source/external/three.model.loader.js +++ b/source/external/three.model.loader.js @@ -12,12 +12,7 @@ OV.ThreeModelLoader = class this.callbacks = callbacks; } - SetDefaultColor (defaultColor) - { - this.importer.SetDefaultColor (defaultColor); - } - - LoadFromUrlList (urls) + LoadFromUrlList (urls, settings) { if (this.inProgress) { return; @@ -27,11 +22,11 @@ OV.ThreeModelLoader = class this.inProgress = true; this.callbacks.onLoadStart (); this.importer.LoadFilesFromUrls (urls, function () { - obj.OnFilesLoaded (); + obj.OnFilesLoaded (settings); }); } - LoadFromFileList (files) + LoadFromFileList (files, settings) { if (this.inProgress) { return; @@ -41,11 +36,11 @@ OV.ThreeModelLoader = class this.inProgress = true; this.callbacks.onLoadStart (); this.importer.LoadFilesFromFileObjects (files, function () { - obj.OnFilesLoaded (); + obj.OnFilesLoaded (settings); }); } - ReloadFiles () + ReloadFiles (settings) { if (this.inProgress) { return; @@ -53,15 +48,15 @@ OV.ThreeModelLoader = class this.inProgress = true; this.callbacks.onLoadStart (); - this.OnFilesLoaded (); + this.OnFilesLoaded (settings); } - OnFilesLoaded () + OnFilesLoaded (settings) { let obj = this; this.callbacks.onImportStart (); OV.RunTaskAsync (function () { - obj.importer.Import ({ + obj.importer.Import (settings, { success : function (importResult) { obj.OnModelImported (importResult); }, diff --git a/source/import/importer.js b/source/import/importer.js index 4575172..7883d1e 100644 --- a/source/import/importer.js +++ b/source/import/importer.js @@ -179,6 +179,14 @@ OV.FileList = class } }; +OV.ImportSettings = class +{ + constructor () + { + this.defaultColor = new OV.Color (200, 200, 200); + } +}; + OV.ImportErrorCode = { NoImportableFile : 1, @@ -207,7 +215,7 @@ OV.ImportResult = class } }; -OV.ImporterBuffers = class +OV.ImportBuffers = class { constructor (getBufferCallback) { @@ -260,7 +268,6 @@ OV.Importer = class new OV.ImporterGltf () ]; this.fileList = new OV.FileList (this.importers); - this.defaultColor = new OV.Color (200, 200, 200); this.model = null; this.usedFiles = []; this.missingFiles = []; @@ -276,12 +283,7 @@ OV.Importer = class this.LoadFiles (fileList, OV.FileSource.File, onReady); } - SetDefaultColor (defaultColor) - { - this.defaultColor = defaultColor; - } - - Import (callbacks) + Import (settings, callbacks) { let mainFile = this.fileList.GetMainFile (); if (mainFile === null || mainFile.file === null || mainFile.file.content === null) { @@ -300,7 +302,7 @@ OV.Importer = class let obj = this; let importer = mainFile.importer; - let buffers = new OV.ImporterBuffers (function (fileName) { + let buffers = new OV.ImportBuffers (function (fileName) { let fileBuffer = null; let file = obj.fileList.FindFileByPath (fileName); if (file === null || file.content === null) { @@ -316,7 +318,7 @@ OV.Importer = class importer.Import (mainFile.file.content, mainFile.file.extension, { getDefaultMaterial : function () { let material = new OV.Material (); - material.diffuse = obj.defaultColor; + material.diffuse = settings.defaultColor; return material; }, getFileBuffer : function (filePath) { 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 285feaf..6f4695d 100644 --- a/source/parameters/parameterlist.js +++ b/source/parameters/parameterlist.js @@ -1,5 +1,15 @@ OV.ParameterConverter = { + IntegerToString (integer) + { + return integer.toString (); + }, + + StringToInteger (str) + { + return parseInt (str, 10); + }, + NumberToString (number) { let precision = 5; @@ -11,6 +21,22 @@ OV.ParameterConverter = return parseFloat (str); }, + ModelUrlsToString : function (urls) + { + if (urls === null) { + return null; + } + return urls.join (','); + }, + + StringToModelUrls : function (str) + { + if (str === null || str.length === 0) { + return null; + } + return str.split (','); + }, + CameraToString : function (camera) { if (camera === null) { @@ -24,12 +50,12 @@ OV.ParameterConverter = return cameraParameters; }, - StringToCamera : function (urlParam) + StringToCamera : function (str) { - if (urlParam === null || urlParam.length === 0) { + if (str === null || str.length === 0) { return null; } - let paramParts = urlParam.split (','); + let paramParts = str.split (','); if (paramParts.length !== 9) { return null; } @@ -41,20 +67,34 @@ OV.ParameterConverter = return camera; }, - ModelUrlsToString : function (urls) + ColorToString : function (color) { - if (urls === null) { + if (color === null) { return null; } - return urls.join (','); + let colorParameters = [ + this.IntegerToString (color.r), + this.IntegerToString (color.g), + this.IntegerToString (color.b) + ].join (','); + return colorParameters; }, - StringToModelUrls : function (urlParam) + StringToColor : function (str) { - if (urlParam === null || urlParam.length === 0) { + if (str === null || str.length === 0) { return null; } - return urlParam.split (','); + let paramParts = str.split (','); + if (paramParts.length !== 3) { + return null; + } + let color = new OV.Color ( + this.StringToInteger (paramParts[0]), + this.StringToInteger (paramParts[1]), + this.StringToInteger (paramParts[2]) + ); + return color; } }; @@ -63,7 +103,7 @@ OV.ParameterListBuilder = class constructor (separator) { this.separator = separator; - this.urlParams = ''; + this.paramList = ''; } AddModelUrls (urls) @@ -78,36 +118,42 @@ OV.ParameterListBuilder = class return this; } + AddColor (color) + { + this.AddUrlPart ('color', OV.ParameterConverter.ColorToString (color)); + return this; + } + AddUrlPart (keyword, urlPart) { if (keyword === null || urlPart === null) { return; } - if (this.urlParams.length > 0) { - this.urlParams += this.separator; + if (this.paramList.length > 0) { + this.paramList += this.separator; } - this.urlParams += keyword + '=' + urlPart; + this.paramList += keyword + '=' + urlPart; } - GetUrlParams () + GetParameterList () { - return this.urlParams; + return this.paramList; } }; OV.ParameterListParser = class { - constructor (urlParams, separator) + constructor (paramList, separator) { this.separator = separator; - this.urlParams = urlParams; + this.paramList = paramList; } GetModelUrls () { // detect legacy links - if (this.urlParams.indexOf ('=') === -1) { - return this.urlParams.split (','); + if (this.paramList.indexOf ('=') === -1) { + return this.paramList.split (','); } let keywordParams = this.GetKeywordParams ('model'); @@ -119,14 +165,20 @@ OV.ParameterListParser = class let keywordParams = this.GetKeywordParams ('camera'); return OV.ParameterConverter.StringToCamera (keywordParams); } + + GetColor () + { + let colorParams = this.GetKeywordParams ('color'); + return OV.ParameterConverter.StringToColor (colorParams); + } GetKeywordParams (keyword) { - if (this.urlParams === null || this.urlParams.length === 0) { + if (this.paramList === null || this.paramList.length === 0) { return null; } let keywordToken = keyword + '='; - let urlParts = this.urlParams.split (this.separator); + let urlParts = this.paramList.split (this.separator); for (let i = 0; i < urlParts.length; i++) { let urlPart = urlParts[i]; if (urlPart.startsWith (keywordToken)) { @@ -147,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.GetUrlParams (); + return builder.GetParameterList (); }; diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index 32c60ee..1f3f88d 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -1,19 +1,5 @@ OV.Init3DViewerElements = function () { - function SetCamera (element, viewer, importResult) - { - let camera = null; - let cameraParams = element.getAttribute ('camera'); - if (cameraParams) { - camera = OV.ParameterConverter.StringToCamera (cameraParams); - } - if (camera !== null) { - viewer.SetCamera (camera); - } else { - viewer.SetUpVector (importResult.upVector, false); - } - } - function LoadElement (element) { let canvas = document.createElement ('canvas'); @@ -50,7 +36,16 @@ OV.Init3DViewerElements = function () return true; }); viewer.AdjustClippingPlanes (boundingSphere); - SetCamera (element, viewer, importResult); + let camera = null; + let cameraParams = element.getAttribute ('camera'); + if (cameraParams) { + camera = OV.ParameterConverter.StringToCamera (cameraParams); + } + if (camera !== null) { + viewer.SetCamera (camera); + } else { + viewer.SetUpVector (importResult.upVector, false); + } viewer.FitToWindow (boundingSphere, false); }, onTextureLoaded : function () { @@ -71,7 +66,16 @@ OV.Init3DViewerElements = function () return; } - loader.LoadFromUrlList (modelUrls); + let settings = new OV.ImportSettings (); + let colorParams = element.getAttribute ('color'); + if (colorParams) { + let color = OV.ParameterConverter.StringToColor (colorParams); + if (color !== null) { + settings.defaultColor = color; + } + } + + loader.LoadFromUrlList (modelUrls, settings); return { element: element, viewer: viewer diff --git a/source/viewer/viewer.js b/source/viewer/viewer.js index 6be3c01..e5acfe0 100644 --- a/source/viewer/viewer.js +++ b/source/viewer/viewer.js @@ -387,7 +387,7 @@ OV.Viewer = class this.ResizeRenderer (width, height); } this.Render (); - let url = this.renderer.domElement.toDataURL(); + let url = this.renderer.domElement.toDataURL (); if (originalSize !== null) { this.ResizeRenderer ( parseInt (originalSize.x, 10), diff --git a/test/tests/exporter_test.js b/test/tests/exporter_test.js index 83f1702..10b4241 100644 --- a/test/tests/exporter_test.js +++ b/test/tests/exporter_test.js @@ -12,15 +12,15 @@ function CreateTestModel () material1.diffuseMap = new OV.TextureMap (); material1.diffuseMap.name = 'textures/texture1.png'; material1.diffuseMap.url = 'texture1_url'; - material1.diffuseMap.buffer = new ArrayBuffer (4); + material1.diffuseMap.buffer = new ArrayBuffer (1); material1.specularMap = new OV.TextureMap (); material1.specularMap.name = 'textures/texture2.png'; material1.specularMap.url = 'texture2_url'; - material1.specularMap.buffer = new ArrayBuffer (4); + material1.specularMap.buffer = new ArrayBuffer (2); material1.bumpMap = new OV.TextureMap (); material1.bumpMap.name = 'textures/texture3.png'; material1.bumpMap.url = 'texture3_url'; - material1.bumpMap.buffer = new ArrayBuffer (4); + material1.bumpMap.buffer = new ArrayBuffer (3); model.AddMaterial (material1); let material2 = new OV.Material (); @@ -74,6 +74,7 @@ describe ('Exporter', function () { assert.strictEqual (mtlFile.GetName (), 'model.mtl'); assert.strictEqual (mtlFile.GetContent (), [ + '# exported by https://3dviewer.net', 'newmtl TestMaterial1', 'Ka 0 0 0', 'Kd 1 0 0', @@ -95,6 +96,7 @@ describe ('Exporter', function () { assert.strictEqual (objFile.GetName (), 'model.obj'); assert.strictEqual (objFile.GetContent (), [ + '# exported by https://3dviewer.net', 'mtllib model.mtl', 'g TestMesh1', 'v 0 0 1', @@ -121,18 +123,15 @@ describe ('Exporter', function () { let textureFile1 = result[2]; assert.strictEqual (textureFile1.GetName (), 'texture1.png'); - assert.strictEqual (textureFile1.GetUrl (), 'texture1_url'); - assert.strictEqual (textureFile1.GetContent (), null); + assert.strictEqual (textureFile1.GetContent ().byteLength, 1); let textureFile2 = result[3]; assert.strictEqual (textureFile2.GetName (), 'texture2.png'); - assert.strictEqual (textureFile2.GetUrl (), 'texture2_url'); - assert.strictEqual (textureFile2.GetContent (), null); + assert.strictEqual (textureFile2.GetContent ().byteLength, 2); let textureFile3 = result[4]; assert.strictEqual (textureFile3.GetName (), 'texture3.png'); - assert.strictEqual (textureFile3.GetUrl (), 'texture3_url'); - assert.strictEqual (textureFile3.GetContent (), null); + assert.strictEqual (textureFile3.GetContent ().byteLength, 3); }); it ('Stl Export', function () { @@ -305,8 +304,7 @@ describe ('Exporter', function () { assert.strictEqual (binFile.GetName (), 'model.bin'); assert.strictEqual (textureFile.GetName (), 'texture1.png'); - assert.strictEqual (textureFile.GetUrl (), 'texture1_url'); - assert.strictEqual (textureFile.GetContent (), null); + assert.strictEqual (textureFile.GetContent ().byteLength, 1); let contentBuffer = gltfFile.GetContent (); let importer = new OV.ImporterGltf (); diff --git a/test/tests/importer_test.js b/test/tests/importer_test.js index 2e5b7f8..b7b9cf5 100644 --- a/test/tests/importer_test.js +++ b/test/tests/importer_test.js @@ -4,7 +4,8 @@ var path = require ('path'); function ImportFilesWithImporter (importer, files, callbacks) { importer.LoadFilesFromFileObjects (files, function () { - importer.Import ({ + let settings = new OV.ImportSettings (); + importer.Import (settings, { success : function (importResult) { callbacks.success (importer, importResult); }, @@ -239,18 +240,21 @@ describe ('Importer Test', function () { new FileObject ('stl', 'single_triangle.stl') ]; let theImporter = new OV.Importer (); - theImporter.SetDefaultColor (new OV.Color (200, 0, 0)); - ImportFilesWithImporter (theImporter, files, { - success : function (importer, importResult) { - assert (!OV.IsModelEmpty (importResult.model)); - assert.deepStrictEqual (importResult.usedFiles, ['single_triangle.stl']); - assert.deepStrictEqual (importResult.missingFiles, []); - let material = importResult.model.GetMaterial (0); - assert.deepStrictEqual (material.diffuse, new OV.Color (200, 0, 0)); - }, - error : function (importer, importError) { - assert.fail (); - } + theImporter.LoadFilesFromFileObjects (files, function () { + let settings = new OV.ImportSettings (); + settings.defaultColor = new OV.Color (200, 0, 0); + theImporter.Import (settings, { + success : function (importResult) { + assert (!OV.IsModelEmpty (importResult.model)); + assert.deepStrictEqual (importResult.usedFiles, ['single_triangle.stl']); + assert.deepStrictEqual (importResult.missingFiles, []); + let material = importResult.model.GetMaterial (0); + assert.deepStrictEqual (material.diffuse, new OV.Color (200, 0, 0)); + }, + error : function (importError) { + assert.fail (); + } + }); }); }); }); 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/test/tests/parameterlist_test.js b/test/tests/parameterlist_test.js index 62fa89c..9515eac 100644 --- a/test/tests/parameterlist_test.js +++ b/test/tests/parameterlist_test.js @@ -8,12 +8,15 @@ describe ('Parameter List', function () { new OV.Coord3D (0.0, 0.0, 0.0), new OV.Coord3D (0.0, 0.0, 1.0) ); - let urlParams1 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetUrlParams (); - let urlParams2 = OV.CreateUrlBuilder ().AddCamera (camera).GetUrlParams (); - let urlParams3 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetUrlParams (); + let color = new OV.Color (1, 2, 3); + let urlParams1 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetParameterList (); + let urlParams2 = OV.CreateUrlBuilder ().AddCamera (camera).GetParameterList (); + let urlParams3 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetParameterList (); + let urlParams4 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).AddColor (color).GetParameterList (); assert.strictEqual (urlParams1, 'model=a.txt,b.txt'); assert.strictEqual (urlParams2, 'camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000'); assert.strictEqual (urlParams3, 'model=a.txt,b.txt$camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000'); + assert.strictEqual (urlParams4, 'model=a.txt,b.txt$camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000$color=1,2,3'); }); it ('Parameter list parser', function () { @@ -22,22 +25,31 @@ describe ('Parameter List', function () { new OV.Coord3D (1.0, 1.0, 1.0), new OV.Coord3D (0.0, 0.0, 0.0), new OV.Coord3D (0.0, 0.0, 1.0) - ); + ); + let color = new OV.Color (1, 2, 3); let urlParamsLegacy = 'a.txt,b.txt'; let urlParams1 = 'model=a.txt,b.txt'; let urlParams2 = 'camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000'; let urlParams3 = 'model=a.txt,b.txt$camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000'; + let urlParams4 = 'model=a.txt,b.txt$camera=1.0000,1.0000,1.0000,0.0000,0.0000,0.0000,0.0000,0.0000,1.0000$color=1,2,3'; let parserLegacy = OV.CreateUrlParser (urlParamsLegacy); assert.deepStrictEqual (parserLegacy.GetModelUrls (), modelUrls); assert.deepStrictEqual (parserLegacy.GetCamera (), null); let parser1 = OV.CreateUrlParser (urlParams1); assert.deepStrictEqual (parser1.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser1.GetCamera (), null); + assert.deepStrictEqual (parser1.GetColor (), null); let parser2 = OV.CreateUrlParser (urlParams2); assert.deepStrictEqual (parser2.GetModelUrls (), null); assert.deepStrictEqual (parser2.GetCamera (), camera); + assert.deepStrictEqual (parser2.GetColor (), null); let parser3 = OV.CreateUrlParser (urlParams3); assert.deepStrictEqual (parser3.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser3.GetCamera (), camera); + assert.deepStrictEqual (parser3.GetColor (), null); + let parser4 = OV.CreateUrlParser (urlParams4); + assert.deepStrictEqual (parser4.GetModelUrls (), modelUrls); + assert.deepStrictEqual (parser4.GetCamera (), camera); + assert.deepStrictEqual (parser4.GetColor (), color); }); }); diff --git a/test/utils/testfiles.js b/test/utils/testfiles.js index 7c9b6c0..4b87c90 100644 --- a/test/utils/testfiles.js +++ b/test/utils/testfiles.js @@ -52,7 +52,7 @@ module.exports = content = testUtils.GetArrayBufferFileContent (folder, fileName); } var extension = OV.GetFileExtension (fileName); - let buffers = new OV.ImporterBuffers (function (filePath) { + let buffers = new OV.ImportBuffers (function (filePath) { let extension = OV.GetFileExtension (filePath); let knownFormats = importer.GetKnownFileFormats (); let format = OV.FileFormat.Binary; diff --git a/tools/config.json b/tools/config.json index 51eac2c..7226b92 100644 --- a/tools/config.json +++ b/tools/config.json @@ -54,6 +54,7 @@ "website/o3dv/treeview.js", "website/o3dv/modal.js", "website/o3dv/dialogs.js", + "website/o3dv/exportdialog.js", "website/o3dv/modeldata.js", "website/o3dv/info.js", "website/o3dv/menu.js", diff --git a/tools/sandbox/embed_iframe.html b/tools/sandbox/embed_iframe.html index 33ee9bf..f035251 100644 --- a/tools/sandbox/embed_iframe.html +++ b/tools/sandbox/embed_iframe.html @@ -30,6 +30,16 @@ width=360 height=240 style="border:1px solid #eeeeee;"> + + '; return embeddingCode; @@ -314,6 +121,12 @@ OV.ShowEmbeddingDialog = function (importer, camera) modelFiles.push (file.fileUrl); } + let embeddingParams = { + files : modelFiles, + camera : camera, + color : null + }; + let dialog = new OV.ButtonDialog (); let urlsTextArea = $('