mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 04:15:54 +08:00
fix spot light parsingg
This commit is contained in:
parent
b2d7d88dbc
commit
4557b6aa22
21
tiny_gltf.h
21
tiny_gltf.h
@ -3699,22 +3699,12 @@ static bool ParsePerspectiveCamera(PerspectiveCamera *camera, std::string *err,
|
|||||||
|
|
||||||
static bool ParseSpotLight(SpotLight *light,
|
static bool ParseSpotLight(SpotLight *light,
|
||||||
std::string *err, const json &o) {
|
std::string *err, const json &o) {
|
||||||
double innerConeAngle = 0.0;
|
ParseNumberProperty(&light->innerConeAngle, err, o, "innerConeAngle", false);
|
||||||
if (!ParseNumberProperty(&innerConeAngle, err, o, "innerConeAngle", true, "SpotLight")) {
|
ParseNumberProperty(&light->outerConeAngle, err, o, "outerConeAngle", false);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
double outerConeAngle = 0.0;
|
|
||||||
if (!ParseNumberProperty(&outerConeAngle, err, o, "outerConeAngle", true, "SpotLight")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParseExtensionsProperty(&light->extensions, err, o);
|
ParseExtensionsProperty(&light->extensions, err, o);
|
||||||
ParseExtrasProperty(&light->extras, o);
|
ParseExtrasProperty(&light->extras, o);
|
||||||
|
|
||||||
light->innerConeAngle = innerConeAngle;
|
|
||||||
light->outerConeAngle = outerConeAngle;
|
|
||||||
|
|
||||||
// TODO(syoyo): Validate parameter values.
|
// TODO(syoyo): Validate parameter values.
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3826,7 +3816,11 @@ static bool ParseCamera(Camera *camera, std::string *err, const json &o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool ParseLight(Light *light, std::string *err, const json &o) {
|
static bool ParseLight(Light *light, std::string *err, const json &o) {
|
||||||
if (light->type.compare("spot") == 0) {
|
if (!ParseStringProperty(&light->type, err, o, "type", true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (light->type == "spot") {
|
||||||
if (o.find("spot") == o.end()) {
|
if (o.find("spot") == o.end()) {
|
||||||
if (err) {
|
if (err) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@ -3853,7 +3847,6 @@ static bool ParseLight(Light *light, std::string *err, const json &o) {
|
|||||||
|
|
||||||
ParseStringProperty(&light->name, err, o, "name", false);
|
ParseStringProperty(&light->name, err, o, "name", false);
|
||||||
ParseNumberArrayProperty(&light->color, err, o, "color", false);
|
ParseNumberArrayProperty(&light->color, err, o, "color", false);
|
||||||
ParseStringProperty(&light->type, err, o, "type", true);
|
|
||||||
ParseNumberProperty(&light->range, err, o, "range", false);
|
ParseNumberProperty(&light->range, err, o, "range", false);
|
||||||
ParseNumberProperty(&light->intensity, err, o, "intensity", false);
|
ParseNumberProperty(&light->intensity, err, o, "intensity", false);
|
||||||
ParseExtensionsProperty(&light->extensions, err, o);
|
ParseExtensionsProperty(&light->extensions, err, o);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user