|
36 | 36 |
|
37 | 37 | package com.jme3.gde.blender;
|
38 | 38 |
|
| 39 | +import com.jme3.plugins.json.JsonArray; |
| 40 | +import com.jme3.plugins.json.JsonElement; |
| 41 | +import com.jme3.plugins.json.JsonObject; |
| 42 | +import com.jme3.plugins.json.JsonPrimitive; |
39 | 43 | import java.lang.reflect.Array;
|
40 | 44 | import java.util.*;
|
41 | 45 |
|
42 | 46 | import org.slf4j.*;
|
43 | 47 |
|
44 |
| -import com.google.gson.*; |
45 |
| - |
46 | 48 | import com.jme3.scene.Spatial;
|
47 | 49 | import com.jme3.scene.plugins.gltf.*;
|
48 | 50 |
|
@@ -77,11 +79,19 @@ public Object handleExtras( GltfLoader loader, String parentName,
|
77 | 79 | log.debug("handleExtras(" + loader + ", " + parentName + ", " + parent + ", " + extras + ", " + input + ")");
|
78 | 80 |
|
79 | 81 | // Only interested in composite objects
|
80 |
| - if( !extras.isJsonObject() ) { |
| 82 | + JsonObject jo = null; |
| 83 | + try { |
| 84 | + jo = extras.getAsJsonObject(); |
| 85 | + } |
| 86 | + catch(Exception e) { |
| 87 | + log.warn("Skipping extras:" + extras, e); |
| 88 | + } |
| 89 | + |
| 90 | + if(jo == null) { |
81 | 91 | log.warn("Skipping extras:" + extras);
|
82 | 92 | return input;
|
83 | 93 | }
|
84 |
| - JsonObject jo = extras.getAsJsonObject(); |
| 94 | + |
85 | 95 | apply(input, jo);
|
86 | 96 | return input;
|
87 | 97 | }
|
@@ -120,15 +130,21 @@ protected void applyToSpatial( Spatial spatial, JsonObject extras ) {
|
120 | 130 | }
|
121 | 131 |
|
122 | 132 | protected Object toAttribute( JsonElement el, boolean nested ) {
|
123 |
| - if( el.isJsonObject() ) { |
| 133 | + try { |
124 | 134 | return toAttribute(el.getAsJsonObject(), nested);
|
125 |
| - } else if( el.isJsonArray() ) { |
| 135 | + } catch (Exception e) { |
| 136 | + } |
| 137 | + |
| 138 | + try { |
126 | 139 | return toAttribute(el.getAsJsonArray(), nested);
|
127 |
| - } else if( el.isJsonPrimitive() ) { |
| 140 | + } catch (Exception e) { |
| 141 | + } |
| 142 | + |
| 143 | + try { |
128 | 144 | return toAttribute(el.getAsJsonPrimitive(), nested);
|
129 |
| - } else if( el.isJsonNull() ) { |
130 |
| - return null; |
| 145 | + } catch (Exception e) { |
131 | 146 | }
|
| 147 | + |
132 | 148 | log.warn("Unhandled extras element:" + el);
|
133 | 149 | return null;
|
134 | 150 | }
|
|
0 commit comments