Merge pull request #134 from hey24sheep/task/gltf_import_extra_properties

import gltf extra props
This commit is contained in:
Viktor Kovacs 2021-09-12 15:31:49 +02:00 committed by GitHub
commit 99626cc144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -638,18 +638,31 @@ OV.ImporterGltf = class extends OV.ImporterBase
ImportModelProperties (gltf)
{
let propertyGroup = new OV.PropertyGroup ('Asset properties');
for (let propertyName in gltf.asset) {
if (Object.prototype.hasOwnProperty.call (gltf.asset, propertyName)) {
if (typeof gltf.asset[propertyName] === 'string') {
const property = new OV.Property (OV.PropertyType.Text, propertyName, gltf.asset[propertyName]);
let propertyGroup = this.ImportModelPropertiesHelper('Asset properties', gltf.asset);
if (propertyGroup.PropertyCount() > 0) {
this.model.AddPropertyGroup (propertyGroup);
}
if (gltf.asset['extras']) {
let extraPropertyGroup = this.ImportModelPropertiesHelper('Extras', gltf.asset['extras']);
if (extraPropertyGroup.PropertyCount() > 0) {
this.model.AddPropertyGroup (extraPropertyGroup);
}
}
}
ImportModelPropertiesHelper (propertyGroupName, propertyObject)
{
let propertyGroup = new OV.PropertyGroup (propertyGroupName);
for (let propertyName in propertyObject) {
if (Object.prototype.hasOwnProperty.call (propertyObject, propertyName)) {
if (typeof propertyObject[propertyName] === 'string') {
const property = new OV.Property (OV.PropertyType.Text, propertyName, propertyObject[propertyName]);
propertyGroup.AddProperty (property);
}
}
}
if (propertyGroup.PropertyCount () > 0) {
this.model.AddPropertyGroup (propertyGroup);
}
return propertyGroup;
}
GetDefaultScene (gltf)