diff --git a/StartServerPy.bat b/StartServerPy.bat index 69a4f71..05f649c 100644 --- a/StartServerPy.bat +++ b/StartServerPy.bat @@ -1 +1 @@ -python -m http.server 8000 +python -m http.server 8080 diff --git a/package.json b/package.json index 5e6cd8e..fa2a452 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "online-3d-viewer", "description": "Online 3D Viewer", - "version": "0.7.14", + "version": "0.7.15", "repository": "github:kovacsv/Online3DViewer", "license": "MIT", "devDependencies": { diff --git a/sandbox/embed_selfhost_fullscreen.html b/sandbox/embed_selfhost_fullscreen.html index eeef69e..ead9190 100644 --- a/sandbox/embed_selfhost_fullscreen.html +++ b/sandbox/embed_selfhost_fullscreen.html @@ -27,6 +27,7 @@ + diff --git a/sandbox/embed_selfhost_multiple.html b/sandbox/embed_selfhost_multiple.html index 4f43e90..86c67bc 100644 --- a/sandbox/embed_selfhost_multiple.html +++ b/sandbox/embed_selfhost_multiple.html @@ -28,6 +28,7 @@ + diff --git a/sandbox/embed_selfhost_single.html b/sandbox/embed_selfhost_single.html index 99ef519..c8488a9 100644 --- a/sandbox/embed_selfhost_single.html +++ b/sandbox/embed_selfhost_single.html @@ -27,6 +27,7 @@ + diff --git a/sandbox/embed_selfhost_single_scroll.html b/sandbox/embed_selfhost_single_scroll.html index 25e28d9..ddd4511 100644 --- a/sandbox/embed_selfhost_single_scroll.html +++ b/sandbox/embed_selfhost_single_scroll.html @@ -27,6 +27,7 @@ + diff --git a/source/external/rhinoimporter.js b/source/external/rhinoimporter.js index 0b2ff74..0fd5c56 100644 --- a/source/external/rhinoimporter.js +++ b/source/external/rhinoimporter.js @@ -75,6 +75,7 @@ OV.Importer3dm = class extends OV.ImporterBase ImportRhinoDocument (rhinoDoc) { this.InitRhinoInstances (rhinoDoc); + this.ImportRhinoUserStrings (rhinoDoc); this.ImportRhinoGeometry (rhinoDoc); } @@ -95,6 +96,11 @@ OV.Importer3dm = class extends OV.ImporterBase } } + ImportRhinoUserStrings (rhinoDoc) + { + // TODO: https://github.com/mcneel/rhino3dm/issues/303 + } + ImportRhinoGeometry (rhinoDoc) { let rhinoObjects = rhinoDoc.objects (); @@ -113,7 +119,7 @@ OV.Importer3dm = class extends OV.ImporterBase if (rhinoAttributes.isInstanceDefinitionObject && rhinoInstanceReferences.length === 0) { return; } - + let rhinoMesh = null; let deleteMesh = false; @@ -174,6 +180,12 @@ OV.Importer3dm = class extends OV.ImporterBase let mesh = new OV.Mesh (); mesh.SetName (rhinoAttributes.name); + let userStrings = rhinoAttributes.getUserStrings (); + for (let i = 0; i < userStrings.length; i++) { + let userString = userStrings[i]; + mesh.AddProperty (new OV.Property (OV.PropertyType.Text, userString[0], userString[1])); + } + let materialIndex = this.GetMaterialIndex (rhinoDoc, rhinoObject, rhinoInstanceReferences); let threeJson = rhinoMesh.toThreejsJSON (); let vertices = threeJson.data.attributes.position.array; @@ -246,7 +258,7 @@ OV.Importer3dm = class extends OV.ImporterBase } } else if (rhinoAttributes.materialSource === rhino.ObjectMaterialSource.MaterialFromLayer) { let layerIndex = rhinoAttributes.layerIndex; - if (layerIndex > 0) { + if (layerIndex > -1) { let layer = rhinoDoc.layers ().get (layerIndex); let layerMaterialIndex = layer.renderMaterialIndex; if (layerMaterialIndex > -1) { diff --git a/source/import/importergltf.js b/source/import/importergltf.js index e2f6972..2f49956 100644 --- a/source/import/importergltf.js +++ b/source/import/importergltf.js @@ -476,6 +476,8 @@ OV.ImporterGltf = class extends OV.ImporterBase ProcessMainFile (gltf) { + this.ImportModelProperties (gltf); + let unsupportedExtensions = this.gltfExtensions.GetUnsupportedExtensions (gltf.extensionsRequired); if (unsupportedExtensions.length > 0) { this.SetError (); @@ -504,6 +506,18 @@ OV.ImporterGltf = class extends OV.ImporterBase } } + ImportModelProperties (gltf) + { + for (let propertyName in gltf.asset) { + if (gltf.asset.hasOwnProperty (propertyName)) { + if (typeof gltf.asset[propertyName] === 'string') { + const property = new OV.Property (OV.PropertyType.Text, propertyName, gltf.asset[propertyName]); + this.model.AddProperty (property); + } + } + } + } + GetDefaultScene (gltf) { let defaultSceneIndex = gltf.scene || 0; @@ -726,6 +740,8 @@ OV.ImporterGltf = class extends OV.ImporterBase this.model.AddMesh (mesh); if (gltfMesh.name !== undefined) { mesh.SetName (gltfMesh.name); + } else if (gltfNode.name !== undefined) { + mesh.SetName (gltfNode.name); } for (let i = 0; i < gltfMesh.primitives.length; i++) { diff --git a/source/model/element.js b/source/model/element.js index 238a257..639769f 100644 --- a/source/model/element.js +++ b/source/model/element.js @@ -3,6 +3,7 @@ OV.Element = class constructor () { this.name = ''; + this.properties = []; } GetName () @@ -35,6 +36,22 @@ OV.Element = class return 0; } + PropertyCount () + { + return this.properties.length; + } + + AddProperty (property) + { + this.properties.push (property); + return this.properties.length - 1; + } + + GetProperty (index) + { + return this.properties[index]; + } + EnumerateVertices (onVertex) { diff --git a/source/model/modelutils.js b/source/model/modelutils.js index c321a9b..c077589 100644 --- a/source/model/modelutils.js +++ b/source/model/modelutils.js @@ -2,13 +2,7 @@ OV.CalculateTriangleNormal = function (v0, v1, v2) { let v = OV.SubCoord3D (v1, v0); let w = OV.SubCoord3D (v2, v0); - - let normal = new OV.Coord3D ( - v.y * w.z - v.z * w.y, - v.z * w.x - v.x * w.z, - v.x * w.y - v.y * w.x - ); - + let normal = OV.CrossVector3D (v, w); normal.Normalize (); return normal; }; diff --git a/source/model/property.js b/source/model/property.js new file mode 100644 index 0000000..f99d72e --- /dev/null +++ b/source/model/property.js @@ -0,0 +1,18 @@ +OV.PropertyType = +{ + Text : 1, + Integer : 2, + Number : 3, + Percent : 4, + Color : 5 +}; + +OV.Property = class +{ + constructor (type, name, value) + { + this.type = type; + this.name = name; + this.value = value; + } +}; diff --git a/test/tests/model_test.js b/test/tests/model_test.js index 6189302..1c92a18 100644 --- a/test/tests/model_test.js +++ b/test/tests/model_test.js @@ -184,6 +184,20 @@ describe ('Model Finalization', function() { }); }); +describe ('Model Properties', function() { + let model = new OV.Model (); + model.AddProperty (new OV.Property (OV.PropertyType.Text, 'name 01', 'value 01')); + model.AddProperty (new OV.Property (OV.PropertyType.Integer, 'name 02', 2)); + model.AddProperty (new OV.Property (OV.PropertyType.Number, 'name 03', 3.5)); + assert.strictEqual (model.PropertyCount (), 3); + assert.strictEqual (model.GetProperty (0).name, 'name 01'); + assert.strictEqual (model.GetProperty (0).value, 'value 01'); + assert.strictEqual (model.GetProperty (1).name, 'name 02'); + assert.strictEqual (model.GetProperty (1).value, 2); + assert.strictEqual (model.GetProperty (2).name, 'name 03'); + assert.strictEqual (model.GetProperty (2).value, 3.5); +}); + describe ('Color Conversion', function() { it ('Color equality check', function () { assert (OV.ColorIsEqual (new OV.Color (10, 20, 30), new OV.Color (10, 20, 30))); diff --git a/tools/config.json b/tools/config.json index 51bebd3..2ff3718 100644 --- a/tools/config.json +++ b/tools/config.json @@ -22,6 +22,7 @@ "source/io/fileutils.js", "source/model/material.js", "source/model/triangle.js", + "source/model/property.js", "source/model/element.js", "source/model/mesh.js", "source/model/meshbuffer.js", @@ -64,6 +65,7 @@ "website_files" : [ "website/o3dv/featureset.js", "website/o3dv/utils.js", + "website/o3dv/cookies.js", "website/o3dv/toolbar.js", "website/o3dv/treeview.js", "website/o3dv/modal.js", @@ -72,10 +74,10 @@ "website/o3dv/exportdialog.js", "website/o3dv/sharingdialog.js", "website/o3dv/settingsdialog.js", - "website/o3dv/quantitiesdialog.js", + "website/o3dv/cookiedialog.js", "website/o3dv/modeldata.js", - "website/o3dv/info.js", "website/o3dv/navigator.js", + "website/o3dv/sidebar.js", "website/o3dv/hashhandler.js", "website/o3dv/website.css", "website/o3dv/loader.js", diff --git a/website/assets/images/3dviewer_net_logo_social.svg b/website/assets/images/3dviewer_net_logo_social.svg index 394c7c3..e6433b3 100644 --- a/website/assets/images/3dviewer_net_logo_social.svg +++ b/website/assets/images/3dviewer_net_logo_social.svg @@ -1,256 +1 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/website/assets/images/3dviewer_net_start_page.png b/website/assets/images/3dviewer_net_start_page.png index f062512..973e0c3 100644 Binary files a/website/assets/images/3dviewer_net_start_page.png and b/website/assets/images/3dviewer_net_start_page.png differ diff --git a/website/assets/images/header/github.svg b/website/assets/images/header/github.svg index b7779c8..0085e51 100644 --- a/website/assets/images/header/github.svg +++ b/website/assets/images/header/github.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/website/assets/images/header/github_hover.svg b/website/assets/images/header/github_hover.svg index 1a7ddc8..8b93c2e 100644 --- a/website/assets/images/header/github_hover.svg +++ b/website/assets/images/header/github_hover.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/website/assets/images/sidebar/close.svg b/website/assets/images/sidebar/close.svg new file mode 100644 index 0000000..abc131e --- /dev/null +++ b/website/assets/images/sidebar/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/assets/images/tree/details.svg b/website/assets/images/toolbar/details.svg similarity index 100% rename from website/assets/images/tree/details.svg rename to website/assets/images/toolbar/details.svg diff --git a/website/assets/images/toolbar/details_blue.svg b/website/assets/images/toolbar/details_blue.svg new file mode 100644 index 0000000..4b76fbf --- /dev/null +++ b/website/assets/images/toolbar/details_blue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/embed.html b/website/embed.html index 8d08058..f265780 100644 --- a/website/embed.html +++ b/website/embed.html @@ -35,6 +35,7 @@ + @@ -78,6 +79,7 @@ + @@ -86,10 +88,10 @@ - + - + diff --git a/website/examples.html b/website/examples.html index c1361e2..b71285c 100644 --- a/website/examples.html +++ b/website/examples.html @@ -16,6 +16,7 @@