From 774e32af5bbbe3e0ae9b135932163d2f069560d3 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Thu, 1 Apr 2021 18:19:10 +0200 Subject: [PATCH 01/25] Update version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6eef821..0269686 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "online-3d-viewer", "description": "Online 3D Viewer", - "version": "0.7.4", + "version": "0.7.5", "repository": "github:kovacsv/Online3DViewer", "license": "MIT", "devDependencies": { From b60305dd194409939a9e9a65abde2a852af402be Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 09:25:41 +0200 Subject: [PATCH 02/25] Possibility to set the default material color for importer in case of no-material surfaces. --- source/external/three.model.loader.js | 5 +++++ source/import/importer.js | 8 +++++++- test/tests/importer_test.js | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/source/external/three.model.loader.js b/source/external/three.model.loader.js index 236ded1..7e6157e 100644 --- a/source/external/three.model.loader.js +++ b/source/external/three.model.loader.js @@ -12,6 +12,11 @@ OV.ThreeModelLoader = class this.callbacks = callbacks; } + SetDefaultColor (defaultColor) + { + this.importer.SetDefaultColor (defaultColor); + } + LoadFromUrlList (urls) { if (this.inProgress) { diff --git a/source/import/importer.js b/source/import/importer.js index 3bd5825..4575172 100644 --- a/source/import/importer.js +++ b/source/import/importer.js @@ -260,6 +260,7 @@ 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 = []; @@ -275,6 +276,11 @@ OV.Importer = class this.LoadFiles (fileList, OV.FileSource.File, onReady); } + SetDefaultColor (defaultColor) + { + this.defaultColor = defaultColor; + } + Import (callbacks) { let mainFile = this.fileList.GetMainFile (); @@ -310,7 +316,7 @@ OV.Importer = class importer.Import (mainFile.file.content, mainFile.file.extension, { getDefaultMaterial : function () { let material = new OV.Material (); - material.diffuse = new OV.Color (200, 200, 200); + material.diffuse = obj.defaultColor; return material; }, getFileBuffer : function (filePath) { diff --git a/test/tests/importer_test.js b/test/tests/importer_test.js index 0e375b4..2e5b7f8 100644 --- a/test/tests/importer_test.js +++ b/test/tests/importer_test.js @@ -233,4 +233,24 @@ describe ('Importer Test', function () { } }); }); + + it ('Default color', function () { + let files = [ + 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 (); + } + }); + }); }); From 473da0905229366868bfac970dc97b0d1a3fd060 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:05:18 +0200 Subject: [PATCH 03/25] Add function to reload the same model again. --- source/external/three.model.loader.js | 15 +++++++++++++-- source/viewer/domviewer.js | 4 ++-- website/o3dv/loader.js | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source/external/three.model.loader.js b/source/external/three.model.loader.js index 7e6157e..6e7a0d2 100644 --- a/source/external/three.model.loader.js +++ b/source/external/three.model.loader.js @@ -44,11 +44,22 @@ OV.ThreeModelLoader = class obj.OnFilesLoaded (); }); } + + ReloadFiles () + { + if (this.inProgress) { + return; + } + + this.inProgress = true; + this.callbacks.onLoadStart (); + this.OnFilesLoaded (); + } OnFilesLoaded () { let obj = this; - this.callbacks.onFilesLoaded (); + this.callbacks.onImportStart (); OV.RunTaskAsync (function () { obj.importer.Import ({ success : function (importResult) { @@ -65,7 +76,7 @@ OV.ThreeModelLoader = class OnModelImported (importResult) { let obj = this; - this.callbacks.onModelImported (); + this.callbacks.onVisualizationStart (); OV.ConvertModelToThreeMeshes (importResult.model, { onTextureLoaded : function () { obj.callbacks.onTextureLoaded (); diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index 45f9c90..4692c74 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -23,10 +23,10 @@ OV.Init3DViewerElements = function () element.appendChild (progressDiv); progressDiv.innerHTML = 'Loading model...'; }, - onFilesLoaded : function () { + onImportStart : function () { progressDiv.innerHTML = 'Importing model...'; }, - onModelImported : function () { + onVisualizationStart : function () { progressDiv.innerHTML = 'Visualizing model...'; }, onModelFinished : function (importResult, threeMeshes) { diff --git a/website/o3dv/loader.js b/website/o3dv/loader.js index 5060807..d84bd47 100644 --- a/website/o3dv/loader.js +++ b/website/o3dv/loader.js @@ -40,10 +40,10 @@ OV.InitModelLoader = function (modelLoader, callbacks) progressDialog = new OV.ProgressDialog (); progressDialog.Show ('Loading Model'); }, - onFilesLoaded : function () { + onImportStart : function () { progressDialog.SetText ('Importing Model'); }, - onModelImported : function () { + onVisualizationStart : function () { progressDialog.SetText ('Visualizing Model'); }, onModelFinished : function (importResult, threeMeshes) { From 6d23481619c6bc0f3be026d2b0f968986e67eeb3 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:05:47 +0200 Subject: [PATCH 04/25] Use the camera recommended by the importer in case of no camera defined during embedding or self-hosting. --- source/viewer/domviewer.js | 23 +++++++++++++++-------- tools/sandbox/embed_iframe.html | 15 ++++++++++----- tools/sandbox/embed_selfhost.html | 28 ++++++++++++++++++++++------ website/o3dv/embed.js | 10 ++++++---- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index 4692c74..5e13a7b 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -1,5 +1,19 @@ OV.Init3DViewerElements = function () { + function SetCamera (element, viewer, importResult) + { + let camera = null; + let cameraParams = element.getAttribute ('camera'); + if (cameraParams) { + camera = OV.UrlParamConverter.UrlParameterToCamera (cameraParams); + } + if (camera !== null) { + viewer.SetCamera (camera); + } else { + viewer.SetUpVector (importResult.upVector, false); + } + } + function LoadElement (element) { let canvas = document.createElement ('canvas'); @@ -37,6 +51,7 @@ OV.Init3DViewerElements = function () return true; }); viewer.AdjustClippingPlanes (boundingSphere); + SetCamera (element, viewer, importResult); viewer.FitToWindow (boundingSphere, false); }, onTextureLoaded : function () { @@ -57,14 +72,6 @@ OV.Init3DViewerElements = function () return; } - let cameraParams = element.getAttribute ('camera'); - if (cameraParams) { - let camera = OV.UrlParamConverter.UrlParameterToCamera (cameraParams); - if (camera !== null) { - viewer.SetCamera (camera); - } - } - loader.LoadFromUrlList (modelUrls); } diff --git a/tools/sandbox/embed_iframe.html b/tools/sandbox/embed_iframe.html index 7841e2c..3bc6c9b 100644 --- a/tools/sandbox/embed_iframe.html +++ b/tools/sandbox/embed_iframe.html @@ -12,22 +12,27 @@ + diff --git a/tools/sandbox/embed_selfhost.html b/tools/sandbox/embed_selfhost.html index 5c435f0..f063df0 100644 --- a/tools/sandbox/embed_selfhost.html +++ b/tools/sandbox/embed_selfhost.html @@ -19,19 +19,35 @@ div.online_3d_viewer { float: left; + border: 1px solid #eeeeee; + margin: 0px 4px 4px 0px; } -
+ width="360" height="240" + model="../../test/testfiles/3ds/cube_four_instances.3ds,../../test/testfiles/3ds/texture.png"> +
+
+
+
+
+
+
+
-
-
diff --git a/website/o3dv/embed.js b/website/o3dv/embed.js index 9659904..9b6ee6f 100644 --- a/website/o3dv/embed.js +++ b/website/o3dv/embed.js @@ -20,10 +20,6 @@ OV.Embed = class if (urls === null) { return; } - let camera = this.hashHandler.GetCameraFromHash (); - if (camera !== null) { - this.viewer.SetCamera (camera); - } this.modelLoader.LoadFromUrlList (urls); let hashParameters = OV.CreateUrlParameters (urls, null); let websiteUrl = this.parameters.websiteLinkDiv.attr ('href') + '#' + hashParameters; @@ -45,6 +41,12 @@ OV.Embed = class return true; }); this.viewer.AdjustClippingPlanes (boundingSphere); + let camera = this.hashHandler.GetCameraFromHash (); + if (camera !== null) { + this.viewer.SetCamera (camera); + } else { + this.viewer.SetUpVector (importResult.upVector, false); + } this.viewer.FitToWindow (boundingSphere, false); } From 8e7bebaf5feaab4f0900acf8e1ee11ffb2d80945 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:38:53 +0200 Subject: [PATCH 05/25] Rename urlutils to paramutils. --- source/{viewer/urlutils.js => parameters/paramutils.js} | 0 tools/config.json | 4 ++-- website/embed.html | 2 +- website/index.html | 2 +- website/o3dv/hashhandler.js | 5 ++--- 5 files changed, 6 insertions(+), 7 deletions(-) rename source/{viewer/urlutils.js => parameters/paramutils.js} (100%) diff --git a/source/viewer/urlutils.js b/source/parameters/paramutils.js similarity index 100% rename from source/viewer/urlutils.js rename to source/parameters/paramutils.js diff --git a/tools/config.json b/tools/config.json index 722cd6b..7c7aafe 100644 --- a/tools/config.json +++ b/tools/config.json @@ -42,11 +42,11 @@ "source/export/exporter.js", "source/external/three.converter.js", "source/external/three.model.loader.js", + "source/parameters/paramutils.js", "source/viewer/domutils.js", "source/viewer/navigation.js", "source/viewer/viewer.js", - "source/viewer/domviewer.js", - "source/viewer/urlutils.js" + "source/viewer/domviewer.js" ], "website_files" : [ "website/o3dv/utils.js", diff --git a/website/embed.html b/website/embed.html index 1a3c815..2b052db 100644 --- a/website/embed.html +++ b/website/embed.html @@ -55,11 +55,11 @@ + - diff --git a/website/index.html b/website/index.html index 064aa4d..5cc2ddb 100644 --- a/website/index.html +++ b/website/index.html @@ -55,11 +55,11 @@ + - diff --git a/website/o3dv/hashhandler.js b/website/o3dv/hashhandler.js index b7c9eaf..87fc927 100644 --- a/website/o3dv/hashhandler.js +++ b/website/o3dv/hashhandler.js @@ -42,9 +42,8 @@ OV.HashHandler = class SetModelFilesToHash (files) { - let builder = new OV.UrlParamBuilder (); - builder.AddModelUrls (files); - this.SetHash (builder.GetUrlParams ()); + let params = OV.CreateUrlParameters (files, null); + this.SetHash (params); } GetFromHash (keyword) From cafb7171f9973bd0221dd39e2e9e83c9d24ad82d Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:49:01 +0200 Subject: [PATCH 06/25] Add parameter handling utilities. --- .../{paramutils.js => parameterlist.js} | 24 +++++++++---------- source/viewer/domviewer.js | 4 ++-- test/tests/urlutils_test.js | 14 +++++------ tools/config.json | 2 +- website/embed.html | 2 +- website/index.html | 2 +- website/o3dv/hashhandler.js | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) rename source/parameters/{paramutils.js => parameterlist.js} (82%) diff --git a/source/parameters/paramutils.js b/source/parameters/parameterlist.js similarity index 82% rename from source/parameters/paramutils.js rename to source/parameters/parameterlist.js index 98c2587..a12bc78 100644 --- a/source/parameters/paramutils.js +++ b/source/parameters/parameterlist.js @@ -1,6 +1,6 @@ -OV.UrlParamConverter = +OV.ParameterConverter = { - CameraToUrlParameter : function (camera) + CameraToString : function (camera) { if (camera === null) { return null; @@ -14,7 +14,7 @@ OV.UrlParamConverter = return cameraParameters; }, - UrlParameterToCamera : function (urlParam) + StringToCamera : function (urlParam) { if (urlParam === null || urlParam.length === 0) { return null; @@ -31,7 +31,7 @@ OV.UrlParamConverter = return camera; }, - ModelUrlsToUrlParameter : function (urls) + ModelUrlsToString : function (urls) { if (urls === null) { return null; @@ -39,7 +39,7 @@ OV.UrlParamConverter = return urls.join (','); }, - UrlParameterToModelUrls : function (urlParam) + StringToModelUrls : function (urlParam) { if (urlParam === null || urlParam.length === 0) { return null; @@ -48,7 +48,7 @@ OV.UrlParamConverter = } }; -OV.UrlParamBuilder = class +OV.ParameterListBuilder = class { constructor () { @@ -57,13 +57,13 @@ OV.UrlParamBuilder = class AddModelUrls (urls) { - this.AddUrlPart ('model', OV.UrlParamConverter.ModelUrlsToUrlParameter (urls)); + this.AddUrlPart ('model', OV.ParameterConverter.ModelUrlsToString (urls)); return this; } AddCamera (camera) { - this.AddUrlPart ('camera', OV.UrlParamConverter.CameraToUrlParameter (camera)); + this.AddUrlPart ('camera', OV.ParameterConverter.CameraToString (camera)); return this; } @@ -84,7 +84,7 @@ OV.UrlParamBuilder = class } }; -OV.UrlParamParser = class +OV.ParameterListParser = class { constructor (urlParams) { @@ -99,13 +99,13 @@ OV.UrlParamParser = class } let keywordParams = this.GetKeywordParams ('model'); - return OV.UrlParamConverter.UrlParameterToModelUrls (keywordParams); + return OV.ParameterConverter.StringToModelUrls (keywordParams); } GetCamera () { let keywordParams = this.GetKeywordParams ('camera'); - return OV.UrlParamConverter.UrlParameterToCamera (keywordParams); + return OV.ParameterConverter.StringToCamera (keywordParams); } GetKeywordParams (keyword) @@ -127,7 +127,7 @@ OV.UrlParamParser = class OV.CreateUrlParameters = function (urls, camera) { - let builder = new OV.UrlParamBuilder (); + let builder = new OV.ParameterListBuilder (); builder.AddModelUrls (urls); builder.AddCamera (camera); return builder.GetUrlParams (); diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index 5e13a7b..94a8bd6 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -5,7 +5,7 @@ OV.Init3DViewerElements = function () let camera = null; let cameraParams = element.getAttribute ('camera'); if (cameraParams) { - camera = OV.UrlParamConverter.UrlParameterToCamera (cameraParams); + camera = OV.ParameterConverter.StringToCamera (cameraParams); } if (camera !== null) { viewer.SetCamera (camera); @@ -67,7 +67,7 @@ OV.Init3DViewerElements = function () return; } - let modelUrls = OV.UrlParamConverter.UrlParameterToModelUrls (modelParams); + let modelUrls = OV.ParameterConverter.StringToModelUrls (modelParams); if (modelUrls === null || modelUrls.length === 0) { return; } diff --git a/test/tests/urlutils_test.js b/test/tests/urlutils_test.js index 6ed14e0..681cf94 100644 --- a/test/tests/urlutils_test.js +++ b/test/tests/urlutils_test.js @@ -8,9 +8,9 @@ describe ('Url Utils', function () { new OV.Coord3D (0.0, 0.0, 0.0), new OV.Coord3D (0.0, 0.0, 1.0) ); - let urlParams1 = new OV.UrlParamBuilder ().AddModelUrls (modelUrls).GetUrlParams (); - let urlParams2 = new OV.UrlParamBuilder ().AddCamera (camera).GetUrlParams (); - let urlParams3 = new OV.UrlParamBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetUrlParams (); + let urlParams1 = new OV.ParameterListBuilder ().AddModelUrls (modelUrls).GetUrlParams (); + let urlParams2 = new OV.ParameterListBuilder ().AddCamera (camera).GetUrlParams (); + let urlParams3 = new OV.ParameterListBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetUrlParams (); 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'); @@ -27,16 +27,16 @@ describe ('Url Utils', function () { 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 parserLegacy = new OV.UrlParamParser (urlParamsLegacy); + let parserLegacy = new OV.ParameterListParser (urlParamsLegacy); assert.deepStrictEqual (parserLegacy.GetModelUrls (), modelUrls); assert.deepStrictEqual (parserLegacy.GetCamera (), null); - let parser1 = new OV.UrlParamParser (urlParams1); + let parser1 = new OV.ParameterListParser (urlParams1); assert.deepStrictEqual (parser1.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser1.GetCamera (), null); - let parser2 = new OV.UrlParamParser (urlParams2); + let parser2 = new OV.ParameterListParser (urlParams2); assert.deepStrictEqual (parser2.GetModelUrls (), null); assert.deepStrictEqual (parser2.GetCamera (), camera); - let parser3 = new OV.UrlParamParser (urlParams3); + let parser3 = new OV.ParameterListParser (urlParams3); assert.deepStrictEqual (parser3.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser3.GetCamera (), camera); }); diff --git a/tools/config.json b/tools/config.json index 7c7aafe..51eac2c 100644 --- a/tools/config.json +++ b/tools/config.json @@ -42,7 +42,7 @@ "source/export/exporter.js", "source/external/three.converter.js", "source/external/three.model.loader.js", - "source/parameters/paramutils.js", + "source/parameters/parameterlist.js", "source/viewer/domutils.js", "source/viewer/navigation.js", "source/viewer/viewer.js", diff --git a/website/embed.html b/website/embed.html index 2b052db..879990f 100644 --- a/website/embed.html +++ b/website/embed.html @@ -55,7 +55,7 @@ - + diff --git a/website/index.html b/website/index.html index 5cc2ddb..0e85d52 100644 --- a/website/index.html +++ b/website/index.html @@ -55,7 +55,7 @@ - + diff --git a/website/o3dv/hashhandler.js b/website/o3dv/hashhandler.js index 87fc927..ee7e5d9 100644 --- a/website/o3dv/hashhandler.js +++ b/website/o3dv/hashhandler.js @@ -30,13 +30,13 @@ OV.HashHandler = class GetCameraFromHash () { - let parser = new OV.UrlParamParser (this.GetHash ()); + let parser = new OV.ParameterListParser (this.GetHash ()); return parser.GetCamera (); } GetModelFilesFromHash () { - let parser = new OV.UrlParamParser (this.GetHash ()); + let parser = new OV.ParameterListParser (this.GetHash ()); return parser.GetModelUrls (); } From c7eb2f2cb83b55834610f4b3041ab47931a9af8a Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:50:34 +0200 Subject: [PATCH 07/25] Rename urlutils_test to parameterlist_test. --- test/tests/{urlutils_test.js => parameterlist_test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/tests/{urlutils_test.js => parameterlist_test.js} (100%) diff --git a/test/tests/urlutils_test.js b/test/tests/parameterlist_test.js similarity index 100% rename from test/tests/urlutils_test.js rename to test/tests/parameterlist_test.js From 8853c00e14fdc5638227ad27ac3b4f67df85f8cd Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 10:51:13 +0200 Subject: [PATCH 08/25] Rename test cases. --- test/tests/parameterlist_test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests/parameterlist_test.js b/test/tests/parameterlist_test.js index 681cf94..847fdd6 100644 --- a/test/tests/parameterlist_test.js +++ b/test/tests/parameterlist_test.js @@ -1,7 +1,7 @@ var assert = require ('assert'); -describe ('Url Utils', function () { - it ('Url builder', function () { +describe ('Parameter list', function () { + it ('Parameter list builder', function () { let modelUrls = ['a.txt', 'b.txt']; let camera = new OV.Camera ( new OV.Coord3D (1.0, 1.0, 1.0), @@ -16,7 +16,7 @@ describe ('Url Utils', function () { 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'); }); - it ('Url parser', function () { + it ('Parameter list parser', function () { let modelUrls = ['a.txt', 'b.txt']; let camera = new OV.Camera ( new OV.Coord3D (1.0, 1.0, 1.0), From 69b15ff559592459716d4938166a03ef16145864 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 11:03:45 +0200 Subject: [PATCH 09/25] Add separator parameter for parameter builder and parser. --- source/parameters/parameterlist.js | 46 ++++++++++++++++++++++-------- test/tests/parameterlist_test.js | 16 +++++------ website/o3dv/hashhandler.js | 4 +-- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/source/parameters/parameterlist.js b/source/parameters/parameterlist.js index a12bc78..285feaf 100644 --- a/source/parameters/parameterlist.js +++ b/source/parameters/parameterlist.js @@ -1,15 +1,25 @@ OV.ParameterConverter = { + NumberToString (number) + { + let precision = 5; + return number.toPrecision (precision); + }, + + StringToNumber (str) + { + return parseFloat (str); + }, + CameraToString : function (camera) { if (camera === null) { return null; } - let precision = 5; let cameraParameters = [ - camera.eye.x.toPrecision (precision), camera.eye.y.toPrecision (precision), camera.eye.z.toPrecision (precision), - camera.center.x.toPrecision (precision), camera.center.y.toPrecision (precision), camera.center.z.toPrecision (precision), - camera.up.x.toPrecision (precision), camera.up.y.toPrecision (precision), camera.up.z.toPrecision (precision) + this.NumberToString (camera.eye.x), this.NumberToString (camera.eye.y), this.NumberToString (camera.eye.z), + this.NumberToString (camera.center.x), this.NumberToString (camera.center.y), this.NumberToString (camera.center.z), + this.NumberToString (camera.up.x), this.NumberToString (camera.up.y), this.NumberToString (camera.up.z) ].join (','); return cameraParameters; }, @@ -24,9 +34,9 @@ OV.ParameterConverter = return null; } let camera = new OV.Camera ( - new OV.Coord3D (parseFloat (paramParts[0]), parseFloat (paramParts[1]), parseFloat (paramParts[2])), - new OV.Coord3D (parseFloat (paramParts[3]), parseFloat (paramParts[4]), parseFloat (paramParts[5])), - new OV.Coord3D (parseFloat (paramParts[6]), parseFloat (paramParts[7]), parseFloat (paramParts[8])) + new OV.Coord3D (this.StringToNumber (paramParts[0]), this.StringToNumber (paramParts[1]), this.StringToNumber (paramParts[2])), + new OV.Coord3D (this.StringToNumber (paramParts[3]), this.StringToNumber (paramParts[4]), this.StringToNumber (paramParts[5])), + new OV.Coord3D (this.StringToNumber (paramParts[6]), this.StringToNumber (paramParts[7]), this.StringToNumber (paramParts[8])) ); return camera; }, @@ -50,8 +60,9 @@ OV.ParameterConverter = OV.ParameterListBuilder = class { - constructor () + constructor (separator) { + this.separator = separator; this.urlParams = ''; } @@ -73,7 +84,7 @@ OV.ParameterListBuilder = class return; } if (this.urlParams.length > 0) { - this.urlParams += '$'; + this.urlParams += this.separator; } this.urlParams += keyword + '=' + urlPart; } @@ -86,8 +97,9 @@ OV.ParameterListBuilder = class OV.ParameterListParser = class { - constructor (urlParams) + constructor (urlParams, separator) { + this.separator = separator; this.urlParams = urlParams; } @@ -114,7 +126,7 @@ OV.ParameterListParser = class return null; } let keywordToken = keyword + '='; - let urlParts = this.urlParams.split ('$'); + let urlParts = this.urlParams.split (this.separator); for (let i = 0; i < urlParts.length; i++) { let urlPart = urlParts[i]; if (urlPart.startsWith (keywordToken)) { @@ -125,9 +137,19 @@ OV.ParameterListParser = class } }; +OV.CreateUrlBuilder = function () +{ + return new OV.ParameterListBuilder ('$'); +}; + +OV.CreateUrlParser = function (urlParams) +{ + return new OV.ParameterListParser (urlParams, '$'); +}; + OV.CreateUrlParameters = function (urls, camera) { - let builder = new OV.ParameterListBuilder (); + let builder = OV.CreateUrlBuilder (); builder.AddModelUrls (urls); builder.AddCamera (camera); return builder.GetUrlParams (); diff --git a/test/tests/parameterlist_test.js b/test/tests/parameterlist_test.js index 847fdd6..62fa89c 100644 --- a/test/tests/parameterlist_test.js +++ b/test/tests/parameterlist_test.js @@ -1,6 +1,6 @@ var assert = require ('assert'); -describe ('Parameter list', function () { +describe ('Parameter List', function () { it ('Parameter list builder', function () { let modelUrls = ['a.txt', 'b.txt']; let camera = new OV.Camera ( @@ -8,9 +8,9 @@ describe ('Parameter list', function () { new OV.Coord3D (0.0, 0.0, 0.0), new OV.Coord3D (0.0, 0.0, 1.0) ); - let urlParams1 = new OV.ParameterListBuilder ().AddModelUrls (modelUrls).GetUrlParams (); - let urlParams2 = new OV.ParameterListBuilder ().AddCamera (camera).GetUrlParams (); - let urlParams3 = new OV.ParameterListBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetUrlParams (); + let urlParams1 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetUrlParams (); + let urlParams2 = OV.CreateUrlBuilder ().AddCamera (camera).GetUrlParams (); + let urlParams3 = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).GetUrlParams (); 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'); @@ -27,16 +27,16 @@ describe ('Parameter list', function () { 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 parserLegacy = new OV.ParameterListParser (urlParamsLegacy); + let parserLegacy = OV.CreateUrlParser (urlParamsLegacy); assert.deepStrictEqual (parserLegacy.GetModelUrls (), modelUrls); assert.deepStrictEqual (parserLegacy.GetCamera (), null); - let parser1 = new OV.ParameterListParser (urlParams1); + let parser1 = OV.CreateUrlParser (urlParams1); assert.deepStrictEqual (parser1.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser1.GetCamera (), null); - let parser2 = new OV.ParameterListParser (urlParams2); + let parser2 = OV.CreateUrlParser (urlParams2); assert.deepStrictEqual (parser2.GetModelUrls (), null); assert.deepStrictEqual (parser2.GetCamera (), camera); - let parser3 = new OV.ParameterListParser (urlParams3); + let parser3 = OV.CreateUrlParser (urlParams3); assert.deepStrictEqual (parser3.GetModelUrls (), modelUrls); assert.deepStrictEqual (parser3.GetCamera (), camera); }); diff --git a/website/o3dv/hashhandler.js b/website/o3dv/hashhandler.js index ee7e5d9..3564e33 100644 --- a/website/o3dv/hashhandler.js +++ b/website/o3dv/hashhandler.js @@ -30,13 +30,13 @@ OV.HashHandler = class GetCameraFromHash () { - let parser = new OV.ParameterListParser (this.GetHash ()); + let parser = OV.CreateUrlParser (this.GetHash ()); return parser.GetCamera (); } GetModelFilesFromHash () { - let parser = new OV.ParameterListParser (this.GetHash ()); + let parser = OV.CreateUrlParser (this.GetHash ()); return parser.GetModelUrls (); } From 0b77192ac5d99b331a587a8b1745c19baaf3d6ea Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 11:06:02 +0200 Subject: [PATCH 10/25] Delete unused code. --- website/o3dv/hashhandler.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/website/o3dv/hashhandler.js b/website/o3dv/hashhandler.js index 3564e33..081f88f 100644 --- a/website/o3dv/hashhandler.js +++ b/website/o3dv/hashhandler.js @@ -46,23 +46,6 @@ OV.HashHandler = class this.SetHash (params); } - GetFromHash (keyword) - { - let hash = this.GetHash (); - if (hash.length === 0) { - return null; - } - let keywordToken = keyword + '='; - let hashParts = hash.split ('$'); - for (let i = 0; i < hashParts.length; i++) { - let hashPart = hashParts[i]; - if (hashPart.startsWith (keywordToken)) { - return hashPart.substr (keywordToken.length); - } - } - return null; - } - GetHash () { return window.location.hash.substr (1); From f76408ae1c93c010b273acbf3c6158904eb90f0d Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 12:35:35 +0200 Subject: [PATCH 11/25] Add cookies policy. --- tools/create_package.py | 8 ++++- website/info/cookies.html | 74 +++++++++++++++++++++++++++++++++++++++ website/info/index.html | 5 +++ website/info/info.css | 1 + 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 website/info/cookies.html diff --git a/tools/create_package.py b/tools/create_package.py index 28678f1..fc7e663 100644 --- a/tools/create_package.py +++ b/tools/create_package.py @@ -60,7 +60,13 @@ def CreateDestinationDir (config, rootDir, websiteDir, version, testBuild): 'o3dv/o3dv.website.min.js' ] - for htmlFileName in ['index.html', 'embed.html', os.path.join ('info', 'index.html')]: + htmlFileNames = [ + 'index.html', + 'embed.html', + os.path.join ('info', 'index.html'), + os.path.join ('info', 'cookies.html') + ] + for htmlFileName in htmlFileNames: htmlFilePath = os.path.join (websiteDir, htmlFileName) replacer = Tools.TokenReplacer (htmlFilePath, False) replacer.ReplaceTokenFileLinks ('', '', libFiles, None) diff --git a/website/info/cookies.html b/website/info/cookies.html new file mode 100644 index 0000000..ccc92df --- /dev/null +++ b/website/info/cookies.html @@ -0,0 +1,74 @@ + + + + + + + + + Online 3D Viewer Cookies Policy + + + + + + + + + + + + +
+

Online 3D Viewer Cookies Policy

+ +

+ Like most similar websites, Online 3D Viewer (the "Website") uses cookies. + On this page we explain more about cookies and how we use them. +

+

What are cookies?

+

+ Cookies are a small text files that are stored in your web browser that allows Online 3D Viewer or a third party to recognize you. + Cookies can be used to collect, store and share bits of information about your activities across websites, including on + Online 3D Viewer Website. +

+

+ Cookies might be used for the following purposes: +

+
    +
  • To provide analytics
  • +
  • To store your preferences
  • +
+

+ Online 3D Viewer uses both session cookies and persistent cookies. +

+

+ A session cookie is used to identify a particular visit to our Website. These cookies expire after a short time, + or when you close your web browser after using our Website. We use these cookies to identify you during a single browsing session, + such as when you visit our Website. +

+

+ A persistent cookie will remain on your devices for a set period of time specified in the cookie. + We use these cookies where we need to identify you over a longer period of time. For example, + we would use a persistent cookie to store your preferences on the Website. +

+

How do third parties use cookies on the Website?

+

+ Third party companies like analytics companies use cookies to collect user information on an anonymous basis. + They may use that information to build a profile of your activities on the Online 3D Viewer Website and + other websites that you've visited. +

+

What are your cookies options?

+

+ If you don't like the idea of cookies or certain types of cookies, you can change your browser's settings to + delete cookies that have already been set and to not accept new cookies. To learn more about how to do this, + visit the help pages of your browser. +

+

+ Please note, however, that if you delete cookies or do not accept them, you might not be able to use all of + the features we offer, you may not be able to store your preferences, and some of our pages might not display properly. +

+
+ + + diff --git a/website/info/index.html b/website/info/index.html index d8f97bc..5a994b3 100644 --- a/website/info/index.html +++ b/website/info/index.html @@ -42,6 +42,7 @@
  • Self-hosted viewer
  • Exporting models
  • +
  • Cookies policy
  • @@ -225,6 +226,10 @@ After that select the format you would like to export to, and download the resulting files one by one.

    +

    Cookies policy

    +

    + You can check the policy at the Cookies Policy page. +

    diff --git a/website/info/info.css b/website/info/info.css index f985fb8..ab19c32 100644 --- a/website/info/info.css +++ b/website/info/info.css @@ -74,6 +74,7 @@ h3 p { + text-align: justify; margin: 10px 0px; line-height: 25px; } From ab26b0508b48232b1f6182f403c916a8f2ab9834 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 12:39:13 +0200 Subject: [PATCH 12/25] Add codecov badge. --- README.md | 1 + codecov.yml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 codecov.yml diff --git a/README.md b/README.md index 9306dfa..62564f7 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This repository contains the source code of the https://3dviewer.net website. Th [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/kovacsv/Online3DViewer.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kovacsv/Online3DViewer/context:javascript) +[![codecov](https://codecov.io/gh/kovacsv/Online3DViewer/branch/master/graph/badge.svg?token=xD8Kek6gQz)](https://codecov.io/gh/kovacsv/Online3DViewer) ## Documentation diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..c31f84a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +coverage: + range: 50..80 + round: down + precision: 0 From 6df45bbf4b976e9def23a344da353d68fb3be8cb Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 15:59:01 +0200 Subject: [PATCH 13/25] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 62564f7..c823372 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Online 3D Viewer -This repository contains the source code of the https://3dviewer.net website. The website can open several 3D file formats and visualize the model in your browser. +This repository contains the source code of the https://3dviewer.net website and the library behind it: +- The website can open several 3D file formats and visualize the model in your browser. +- The library allows you to visualize 3D models easily in your website. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From dc07b8757953b514373edb9c5fb996704908df8f Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 15:59:42 +0200 Subject: [PATCH 14/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c823372..d305ec0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repository contains the source code of the https://3dviewer.net website and the library behind it: - The website can open several 3D file formats and visualize the model in your browser. -- The library allows you to visualize 3D models easily in your website. +- The library allows you to visualize 3D models easily on your own website. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From 1b2924a2493fd5d760070b6db9e7fe2f6dd07a43 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 16:00:22 +0200 Subject: [PATCH 15/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d305ec0..6abc39e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Online 3D Viewer -This repository contains the source code of the https://3dviewer.net website and the library behind it: +This repository contains the source code of the https://3dviewer.net website and the library behind it. - The website can open several 3D file formats and visualize the model in your browser. - The library allows you to visualize 3D models easily on your own website. From d88f9a4c855134787825f6df079843bec1c834fc Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 16:21:38 +0200 Subject: [PATCH 16/25] Typo fix. --- website/info/cookies.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/info/cookies.html b/website/info/cookies.html index ccc92df..a1ef165 100644 --- a/website/info/cookies.html +++ b/website/info/cookies.html @@ -28,7 +28,7 @@

    What are cookies?

    - Cookies are a small text files that are stored in your web browser that allows Online 3D Viewer or a third party to recognize you. + Cookies are small text files that are stored in your web browser that allows Online 3D Viewer or a third party to recognize you. Cookies can be used to collect, store and share bits of information about your activities across websites, including on Online 3D Viewer Website.

    From 2cfbc59821da6d98fa090f5f7cb975770cdf8865 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 16:42:54 +0200 Subject: [PATCH 17/25] Add another self-host example. --- tools/sandbox/embed_iframe.html | 60 +++++++++++++++--------------- tools/sandbox/embed_selfhost2.html | 25 +++++++++++++ 2 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 tools/sandbox/embed_selfhost2.html diff --git a/tools/sandbox/embed_iframe.html b/tools/sandbox/embed_iframe.html index 3bc6c9b..33ee9bf 100644 --- a/tools/sandbox/embed_iframe.html +++ b/tools/sandbox/embed_iframe.html @@ -2,39 +2,39 @@ - - - - - Online 3D Viewer + + + + + Online 3D Viewer - - - - - + + + + + diff --git a/tools/sandbox/embed_selfhost2.html b/tools/sandbox/embed_selfhost2.html new file mode 100644 index 0000000..a59f9a2 --- /dev/null +++ b/tools/sandbox/embed_selfhost2.html @@ -0,0 +1,25 @@ + + + + + + + + Online 3D Viewer + + + + + + + +
    +
    + + + From d43477d726c4bec08432a119c6cee91b1d0f90ba Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 18:52:00 +0200 Subject: [PATCH 18/25] Self-hosted viewers should detect size automatically based on the size of the container div #43 Now the viewer's size is based on the parent container's size (not the width and height attribute) so it's possible to style the parent container with css and even use it in fullscreen. --- source/viewer/domviewer.js | 26 ++++-- tools/sandbox/embed_selfhost.html | 53 ----------- tools/sandbox/embed_selfhost2.html | 25 ----- tools/sandbox/embed_selfhost_fullscreen.html | 80 ++++++++++++++++ tools/sandbox/embed_selfhost_multiple.html | 98 ++++++++++++++++++++ tools/sandbox/embed_selfhost_single.html | 69 ++++++++++++++ tools/update_includes.py | 20 +++- 7 files changed, 285 insertions(+), 86 deletions(-) delete mode 100644 tools/sandbox/embed_selfhost.html delete mode 100644 tools/sandbox/embed_selfhost2.html create mode 100644 tools/sandbox/embed_selfhost_fullscreen.html create mode 100644 tools/sandbox/embed_selfhost_multiple.html create mode 100644 tools/sandbox/embed_selfhost_single.html diff --git a/source/viewer/domviewer.js b/source/viewer/domviewer.js index 94a8bd6..32c60ee 100644 --- a/source/viewer/domviewer.js +++ b/source/viewer/domviewer.js @@ -22,10 +22,9 @@ OV.Init3DViewerElements = function () let viewer = new OV.Viewer (); viewer.Init (canvas); - let width = parseInt (element.getAttribute ('width')); - let height = parseInt (element.getAttribute ('height')); - element.style.width = width + 'px'; - element.style.height = height + 'px'; + let width = element.clientWidth; + let height = element.clientHeight; + console.log (element.clientHeight); viewer.Resize (width, height); let loader = new OV.ThreeModelLoader (); @@ -45,7 +44,7 @@ OV.Init3DViewerElements = function () }, onModelFinished : function (importResult, threeMeshes) { element.removeChild (progressDiv); - canvas.style.display = 'initial'; + canvas.style.display = 'inherit'; viewer.AddMeshes (threeMeshes); let boundingSphere = viewer.GetBoundingSphere (function (meshUserData) { return true; @@ -73,13 +72,28 @@ OV.Init3DViewerElements = function () } loader.LoadFromUrlList (modelUrls); + return { + element: element, + viewer: viewer + }; } + let viewerElements = []; window.addEventListener ('load', function () { let elements = document.getElementsByClassName ('online_3d_viewer'); for (let i = 0; i < elements.length; i++) { let element = elements[i]; - LoadElement (element); + let viewerElement = LoadElement (element); + viewerElements.push (viewerElement); + } + }); + + window.addEventListener ('resize', function () { + for (let i = 0; i < viewerElements.length; i++) { + let viewerElement = viewerElements[i]; + let width = viewerElement.element.clientWidth; + let height = viewerElement.element.clientHeight; + viewerElement.viewer.Resize (width, height); } }); }; diff --git a/tools/sandbox/embed_selfhost.html b/tools/sandbox/embed_selfhost.html deleted file mode 100644 index f063df0..0000000 --- a/tools/sandbox/embed_selfhost.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - Online 3D Viewer - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - diff --git a/tools/sandbox/embed_selfhost2.html b/tools/sandbox/embed_selfhost2.html deleted file mode 100644 index a59f9a2..0000000 --- a/tools/sandbox/embed_selfhost2.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - Online 3D Viewer - - - - - - - -
    -
    - - - diff --git a/tools/sandbox/embed_selfhost_fullscreen.html b/tools/sandbox/embed_selfhost_fullscreen.html new file mode 100644 index 0000000..a0c9465 --- /dev/null +++ b/tools/sandbox/embed_selfhost_fullscreen.html @@ -0,0 +1,80 @@ + + + + + + + + Online 3D Viewer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tools/sandbox/embed_selfhost_multiple.html b/tools/sandbox/embed_selfhost_multiple.html new file mode 100644 index 0000000..447fa32 --- /dev/null +++ b/tools/sandbox/embed_selfhost_multiple.html @@ -0,0 +1,98 @@ + + + + + + + + + Online 3D Viewer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + diff --git a/tools/sandbox/embed_selfhost_single.html b/tools/sandbox/embed_selfhost_single.html new file mode 100644 index 0000000..19ad383 --- /dev/null +++ b/tools/sandbox/embed_selfhost_single.html @@ -0,0 +1,69 @@ + + + + + + + + Online 3D Viewer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + diff --git a/tools/update_includes.py b/tools/update_includes.py index 3288d41..166c793 100644 --- a/tools/update_includes.py +++ b/tools/update_includes.py @@ -19,8 +19,12 @@ def Main (argv): config = json.load (configJson) rootDir = os.path.abspath ('..') - for htmlFileName in ['index.html', 'embed.html']: - htmlFilePath = os.path.join (rootDir, 'website', htmlFileName) + websiteFiles = [ + os.path.join ('website', 'index.html'), + os.path.join ('website', 'embed.html') + ] + for htmlFileName in websiteFiles: + htmlFilePath = os.path.join (rootDir, htmlFileName) replacer = Tools.TokenReplacer (htmlFilePath, True) libFiles = Tools.CreateFileList (config['lib_files'], 'libs/', '../libs/') importerFiles = Tools.CreateFileList (config['importer_files'], 'source/', '../source/') @@ -29,6 +33,18 @@ def Main (argv): replacer.ReplaceTokenFileLinks ('', '', importerFiles, None) replacer.ReplaceTokenFileLinks ('', '', websiteFiles, None) replacer.WriteToFile (htmlFilePath) + + sandboxFiles = [ + os.path.join ('tools', 'sandbox', 'embed_selfhost_single.html'), + os.path.join ('tools', 'sandbox', 'embed_selfhost_multiple.html'), + os.path.join ('tools', 'sandbox', 'embed_selfhost_fullscreen.html') + ] + for htmlFileName in sandboxFiles: + htmlFilePath = os.path.join (rootDir, htmlFileName) + replacer = Tools.TokenReplacer (htmlFilePath, True) + importerFiles = Tools.CreateFileList (config['importer_files'], 'source/', '../../source/') + replacer.ReplaceTokenFileLinks ('', '', importerFiles, None) + replacer.WriteToFile (htmlFilePath) return 0 From 21a45d99c2ccab941823435151c0520ec2902619 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Fri, 2 Apr 2021 21:57:43 +0200 Subject: [PATCH 19/25] Handle viewer and embed resize internally. --- website/embed.html | 10 +--------- website/index.html | 10 +--------- website/o3dv/embed.js | 5 +++++ website/o3dv/website.js | 5 +++++ 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/website/embed.html b/website/embed.html index 879990f..8b6ef56 100644 --- a/website/embed.html +++ b/website/embed.html @@ -82,21 +82,13 @@ diff --git a/website/index.html b/website/index.html index 0e85d52..2808d18 100644 --- a/website/index.html +++ b/website/index.html @@ -79,10 +79,8 @@ diff --git a/website/o3dv/embed.js b/website/o3dv/embed.js index 9b6ee6f..fc90441 100644 --- a/website/o3dv/embed.js +++ b/website/o3dv/embed.js @@ -25,6 +25,11 @@ OV.Embed = class let websiteUrl = this.parameters.websiteLinkDiv.attr ('href') + '#' + hashParameters; this.parameters.websiteLinkDiv.attr ('href', websiteUrl); } + + let obj = this; + $(window).on ('resize', function () { + obj.Resize (); + }); } Resize () diff --git a/website/o3dv/website.js b/website/o3dv/website.js index 8c14d64..1984567 100644 --- a/website/o3dv/website.js +++ b/website/o3dv/website.js @@ -32,6 +32,11 @@ OV.Website = class this.Resize (); this.OnHashChange (); + + let obj = this; + $(window).on ('resize', function () { + obj.Resize (); + }); } Resize () From 6aea8feb6f904a5aa7bbeabacc7f3316097fd5ff Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 08:35:21 +0200 Subject: [PATCH 20/25] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6abc39e..8e09e2f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # Online 3D Viewer -This repository contains the source code of the https://3dviewer.net website and the library behind it. -- The website can open several 3D file formats and visualize the model in your browser. -- The library allows you to visualize 3D models easily on your own website. +This repository contains the source code of the https://3dviewer.net website and the library behind it. Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. + +There are two different purpose of this repository: +- **Online 3D Viewer Website:** Full source code of the web solution. It uses the Online 3D Viewer Engine under the hood. +- **Online 3D Viewer Engine:** Library to visualize models easily on your own website. See more in the developer documentation. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From f05164cc1d628f96768227d96b0f476629031e42 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 08:40:09 +0200 Subject: [PATCH 21/25] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8e09e2f..0b0b005 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,13 @@ This repository contains the source code of the https://3dviewer.net website and the library behind it. Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. -There are two different purpose of this repository: -- **Online 3D Viewer Website:** Full source code of the web solution. It uses the Online 3D Viewer Engine under the hood. -- **Online 3D Viewer Engine:** Library to visualize models easily on your own website. See more in the developer documentation. +### Online 3D Viewer Website + +Full source code of the web solution all of the pages and functions. It uses Online 3D Viewer Engine under the hood. + +### Online 3D Viewer Engine + +Library to visualize models easily on your own website. See more in the developer documentation. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From a9c5afb09e328c6857b7dd17430cc7f280fae9e8 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 08:41:53 +0200 Subject: [PATCH 22/25] Update README.md --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0b0b005..406aa5c 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,8 @@ This repository contains the source code of the https://3dviewer.net website and the library behind it. Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. -### Online 3D Viewer Website - -Full source code of the web solution all of the pages and functions. It uses Online 3D Viewer Engine under the hood. - -### Online 3D Viewer Engine - -Library to visualize models easily on your own website. See more in the developer documentation. +* **Online 3D Viewer Website**: Source code of the web solution with all of the pages and functions. It uses the engine under the hood. +* **Online 3D Viewer Engine**: Sorce code of the library to visualize models easily on your own website. See more information in the developer documentation. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From 13c92419274516bd3f1a38291312e4e3894a78af Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 08:47:28 +0200 Subject: [PATCH 23/25] Update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 406aa5c..da82121 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ This repository contains the source code of the https://3dviewer.net website and the library behind it. Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. -* **Online 3D Viewer Website**: Source code of the web solution with all of the pages and functions. It uses the engine under the hood. -* **Online 3D Viewer Engine**: Sorce code of the library to visualize models easily on your own website. See more information in the developer documentation. - [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/kovacsv/Online3DViewer.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kovacsv/Online3DViewer/context:javascript) @@ -12,8 +9,10 @@ This repository contains the source code of the https://3dviewer.net website and ## Documentation -- [User Documentation](https://3dviewer.net/info) -- [Developer Documentation](https://github.com/kovacsv/Online3DViewer/wiki) +The repository is separated into two parts. See more information in the [Developer Documentation](https://github.com/kovacsv/Online3DViewer/wiki). + +* **Online 3D Viewer Website**: Source code of the web solution with all of the pages and functions. +* **Online 3D Viewer Engine**: Source code of the library to visualize models easily. ## Supported file formats From 87037cf54204176f8d34fb7ecf29ead728ac7037 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 09:00:30 +0200 Subject: [PATCH 24/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da82121..c34b2ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Online 3D Viewer -This repository contains the source code of the https://3dviewer.net website and the library behind it. Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. +Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. This repository contains the source code of the https://3dviewer.net website and the library behind it. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer) From a92185b38194c991b14a82c552a8b0be98a744d2 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 3 Apr 2021 09:01:05 +0200 Subject: [PATCH 25/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c34b2ad..176b553 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Online 3D Viewer -Online 3D Viewer is a free and open source web solution to visualize and explore 3D models right in your browser. This repository contains the source code of the https://3dviewer.net website and the library behind it. +Online 3D Viewer (https://3dviewer.net) is a free and open source web solution to visualize and explore 3D models right in your browser. This repository contains the source code of the website and the library behind it. [![Build status](https://ci.appveyor.com/api/projects/status/exypq43a8kjby5n0?svg=true)](https://ci.appveyor.com/project/kovacsv/online3dviewer) [![Build Status](https://travis-ci.com/kovacsv/Online3DViewer.svg?branch=master)](https://travis-ci.com/kovacsv/Online3DViewer)