glTF: properly close opened stream and avoid caching them.
Fixed an issue when an animation track didn't have any translation or scale entries
This commit is contained in:
parent
c17c3e9605
commit
3f99c80109
@ -1,6 +1,7 @@
|
|||||||
package com.jme3.scene.plugins.gltf;
|
package com.jme3.scene.plugins.gltf;
|
||||||
|
|
||||||
import com.jme3.asset.AssetKey;
|
import com.jme3.asset.AssetKey;
|
||||||
|
import com.jme3.asset.cache.AssetCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Nehon on 09/09/2017.
|
* Created by Nehon on 09/09/2017.
|
||||||
@ -9,4 +10,9 @@ class BinDataKey extends AssetKey<Object> {
|
|||||||
public BinDataKey(String name) {
|
public BinDataKey(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends AssetCache> getCacheType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,8 @@ public class GltfLoader implements AssetLoader {
|
|||||||
return rootNode;
|
return rootNode;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AssetLoadException("An error occurred loading " + assetInfo.getKey().getName(), e);
|
throw new AssetLoadException("An error occurred loading " + assetInfo.getKey().getName(), e);
|
||||||
|
} finally {
|
||||||
|
stream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,6 +531,7 @@ public class GltfLoader implements AssetLoader {
|
|||||||
data = new byte[bufferLength];
|
data = new byte[bufferLength];
|
||||||
DataInputStream dataStream = new DataInputStream(input);
|
DataInputStream dataStream = new DataInputStream(input);
|
||||||
dataStream.readFully(data);
|
dataStream.readFully(data);
|
||||||
|
dataStream.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//no URI this should not happen in a gltf file, only in glb files.
|
//no URI this should not happen in a gltf file, only in glb files.
|
||||||
@ -1147,6 +1150,25 @@ public class GltfLoader implements AssetLoader {
|
|||||||
float[] weights;
|
float[] weights;
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (translations == null) {
|
||||||
|
translations = new Vector3f[times.length];
|
||||||
|
for (int i = 0; i < translations.length; i++) {
|
||||||
|
translations[i] = new Vector3f();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rotations == null) {
|
||||||
|
rotations = new Quaternion[times.length];
|
||||||
|
for (int i = 0; i < rotations.length; i++) {
|
||||||
|
rotations[i] = new Quaternion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scales == null) {
|
||||||
|
scales = new Vector3f[times.length];
|
||||||
|
for (int i = 0; i < scales.length; i++) {
|
||||||
|
scales[i] = new Vector3f().set(Vector3f.UNIT_XYZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (times[0] > 0) {
|
if (times[0] > 0) {
|
||||||
//Anim doesn't start at 0, JME can't handle that and will interpolate transforms linearly from 0 to the first frame of the anim.
|
//Anim doesn't start at 0, JME can't handle that and will interpolate transforms linearly from 0 to the first frame of the anim.
|
||||||
//we need to add a frame at 0 that copies the first real frame
|
//we need to add a frame at 0 that copies the first real frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user