mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-16 07:39:11 +02:00
Merge pull request #694 from ctrlaltdavid/fix/import-json-textures
Support relative JSON URLs in model textures property
This commit is contained in:
commit
cf26f6bc4b
2 changed files with 27 additions and 7 deletions
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -1040,7 +1041,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
* @property {boolean} groupCulled=false - <code>true</code> if the mesh parts of the model are LOD culled as a group,
|
||||
* <code>false</code> if separate mesh parts are LOD culled individually.
|
||||
*
|
||||
* @example <caption>Rez a Vive tracker puck.</caption>
|
||||
* @example <caption>Rez a cowboy hat.</caption>
|
||||
* var entity = Entities.addEntity({
|
||||
* type: "Model",
|
||||
* position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0.75, z: -2 })),
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Simon Walton on Oct 15, 2018.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -247,8 +248,7 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
// model
|
||||
"modelURL",
|
||||
"animation.url",
|
||||
// FIXME: Handle models' "textures" and "originalTextures" properties which include URLs. Note that Particles
|
||||
// also has a "textures" property.
|
||||
"textures",
|
||||
// image
|
||||
"imageURL",
|
||||
// web
|
||||
|
@ -258,7 +258,7 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
"ambientLight.ambientURL",
|
||||
"skybox.url",
|
||||
// particles
|
||||
"textures",
|
||||
//"textures", Already specified for model entity type.
|
||||
// materials
|
||||
"materialURL",
|
||||
// ...shared
|
||||
|
@ -292,11 +292,30 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
}
|
||||
} else {
|
||||
if (entityObject.contains(key) && entityObject[key].isString()) {
|
||||
const QString url = entityObject[key].toString();
|
||||
const QString value = entityObject[key].toString();
|
||||
|
||||
if (url.startsWith("./") || url.startsWith("../")) {
|
||||
entityObject[key] = _relativeURL.resolved(url).toString();
|
||||
if (value.startsWith("./") || value.startsWith("../")) {
|
||||
// URL value.
|
||||
entityObject[key] = _relativeURL.resolved(value).toString();
|
||||
isDirty = true;
|
||||
} else if (value.startsWith("{")) {
|
||||
// Object with URL values.
|
||||
auto document = QJsonDocument::fromJson(value.toUtf8());
|
||||
if (!document.isNull()) {
|
||||
auto object = document.object();
|
||||
bool isObjectUpdated = false;
|
||||
for (const QString& key : object.keys()) {
|
||||
auto value = object[key].toString();
|
||||
if (value.startsWith("./") || value.startsWith("../")) {
|
||||
object[key] = _relativeURL.resolved(value).toString();
|
||||
isObjectUpdated = true;
|
||||
}
|
||||
}
|
||||
if (isObjectUpdated) {
|
||||
entityObject[key] = QString(QJsonDocument(object).toJson());
|
||||
isDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue