diff --git a/source/import/importergltf.js b/source/import/importergltf.js index 13c2aac..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; 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 @@
  • hundred_cubes.obj
  • icosahedron.obj
  • error.obj
  • +
  • Box.glb
  • diff --git a/website/o3dv/sidebar.js b/website/o3dv/sidebar.js index 4c1df2b..c19cd17 100644 --- a/website/o3dv/sidebar.js +++ b/website/o3dv/sidebar.js @@ -38,27 +38,20 @@ OV.Sidebar = class return this.visible; } - CreatePropertyTable () - { - this.Clear (); - let table = $('').addClass ('ov_property_table').appendTo (this.contentDiv); - return table; - } - AddProperty (table, property) { - let row = $('').appendTo (table); - let nameColum = $('').appendTo (table); - let nameColum = $('
    ').addClass ('ov_property_table_name').appendTo (row); - let valueColumn = $('').addClass ('ov_property_table_value').appendTo (row); + let row = $('
    ').addClass ('ov_property_table_row').appendTo (table); + let nameColum = $('
    ').addClass ('ov_property_table_cell ov_property_table_name').appendTo (row); + let valueColumn = $('
    ').addClass ('ov_property_table_cell ov_property_table_value').appendTo (row); nameColum.html (property.name + ':').attr ('title', property.name); this.DisplayPropertyValue (property, valueColumn); } AddCalculatedProperty (table, name, calculateValue) { - let row = $('
    ').addClass ('ov_property_table_name').appendTo (row); - let valueColumn = $('').addClass ('ov_property_table_value').appendTo (row); + let row = $('
    ').addClass ('ov_property_table_row').appendTo (table); + let nameColum = $('
    ').addClass ('ov_property_table_cell ov_property_table_name').appendTo (row); + let valueColumn = $('
    ').addClass ('ov_property_table_cell ov_property_table_value').appendTo (row); nameColum.html (name + ':').attr ('title', name); let obj = this; @@ -106,7 +99,7 @@ OV.Sidebar = class AddElementProperties (element) { this.Clear (); - let table = this.CreatePropertyTable (); + let table = $('
    ').addClass ('ov_property_table').appendTo (this.contentDiv); let boundingBox = OV.GetBoundingBox (element); let size = OV.SubCoord3D (boundingBox.max, boundingBox.min); this.AddProperty (table, new OV.Property (OV.PropertyType.Integer, 'Vertex Count', element.VertexCount ())); @@ -128,6 +121,13 @@ OV.Sidebar = class } return new OV.Property (OV.PropertyType.Number, null, volume); }); + if (element.PropertyCount () > 0) { + let customTable = $('
    ').addClass ('ov_property_table ov_property_table_custom').appendTo (this.contentDiv); + for (let i = 0; i < element.PropertyCount (); i++) { + const property = element.GetProperty (i); + this.AddProperty (customTable, property); + } + } this.Resize (); } @@ -143,7 +143,7 @@ OV.Sidebar = class } this.Clear (); - let table = this.CreatePropertyTable (); + let table = $('
    ').addClass ('ov_property_table').appendTo (this.contentDiv); this.AddProperty (table, new OV.Property (OV.PropertyType.Color, 'Color', material.diffuse)); this.AddProperty (table, new OV.Property (OV.PropertyType.Percent, 'Opacity', material.opacity)); AddTextureMap (this, table, 'Diffuse Map', material.diffuseMap); diff --git a/website/o3dv/website.css b/website/o3dv/website.css index 204759c..ecb1e79 100644 --- a/website/o3dv/website.css +++ b/website/o3dv/website.css @@ -657,34 +657,47 @@ div.ov_progress div.ov_progress_text text-align: center; } -table.ov_property_table +div.ov_property_table { - width: 100%; - border-collapse: collapse; + } -table.ov_property_table td +div.ov_property_table_custom +{ + margin-top: 8px; + padding-top: 8px; + border-top: 1px solid #dddddd; +} + +div.ov_property_table div.ov_property_table_row +{ + overflow: auto; +} + +div.ov_property_table div.ov_property_table_cell { padding: 4px 0px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; - display: inline-block; + box-sizing: border-box; } -table.ov_property_table td.ov_property_table_name +div.ov_property_table div.ov_property_table_name { - width: 45%; - padding-right: 8%; + width: 49%; + padding-right: 2%; + float: left; } -table.ov_property_table td.ov_property_table_value +div.ov_property_table div.ov_property_table_value { - width: 45%; + width: 49%; text-align: right; + float: left; } -table.ov_property_table div.ov_property_table_button +div.ov_property_table div.ov_property_table_button { color: #3393bd; cursor: pointer;