mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-15 06:05:58 +08:00
Merge pull request #423 from agnat/finish_KHR_lights_puncutal
KHR_lights_punctual: parse light source references from scene nodes
This commit is contained in:
commit
b88e9cc52a
17
tiny_gltf.h
17
tiny_gltf.h
@ -1038,6 +1038,7 @@ class Node {
|
||||
std::string name;
|
||||
int skin;
|
||||
int mesh;
|
||||
int light; // light source index (KHR_lights_punctual)
|
||||
std::vector<int> children;
|
||||
std::vector<double> rotation; // length must be 0 or 4
|
||||
std::vector<double> scale; // length must be 0 or 3
|
||||
@ -5066,6 +5067,22 @@ static bool ParseNode(Node *node, std::string *err, const detail::json &o,
|
||||
}
|
||||
}
|
||||
|
||||
// KHR_lights_punctual: parse light source reference
|
||||
int light = -1;
|
||||
if (node->extensions.count("KHR_lights_punctual") != 0) {
|
||||
auto const& light_ext = node->extensions["KHR_lights_punctual"];
|
||||
if (light_ext.Has("light")) {
|
||||
light = light_ext.Get("light").GetNumberAsInt();
|
||||
} else {
|
||||
if (err) {
|
||||
*err += "Node has extension KHR_lights_punctual, but does not reference "
|
||||
"a light source.\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
node->light = light;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user