glTF: prevent direct loading of .bin files.
This commit is contained in:
parent
d606c30a52
commit
21fbaf8f11
@ -0,0 +1,12 @@
|
|||||||
|
package com.jme3.scene.plugins.gltf;
|
||||||
|
|
||||||
|
import com.jme3.asset.AssetKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Nehon on 09/09/2017.
|
||||||
|
*/
|
||||||
|
class BinDataKey extends AssetKey<Object> {
|
||||||
|
public BinDataKey(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.jme3.scene.plugins.gltf;
|
package com.jme3.scene.plugins.gltf;
|
||||||
|
|
||||||
import com.jme3.asset.AssetInfo;
|
import com.jme3.asset.*;
|
||||||
import com.jme3.asset.AssetLoader;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -11,6 +10,11 @@ import java.io.IOException;
|
|||||||
public class BinLoader implements AssetLoader {
|
public class BinLoader implements AssetLoader {
|
||||||
@Override
|
@Override
|
||||||
public Object load(AssetInfo assetInfo) throws IOException {
|
public Object load(AssetInfo assetInfo) throws IOException {
|
||||||
|
|
||||||
|
if (!(assetInfo.getKey() instanceof BinDataKey)) {
|
||||||
|
throw new AssetLoadException(".bin files cannot be loaded directly, load the associated .gltf file");
|
||||||
|
}
|
||||||
|
|
||||||
return assetInfo.openStream();
|
return assetInfo.openStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,8 @@ public class GltfLoader implements AssetLoader {
|
|||||||
throw new AssetLoadException("Cannot load " + uri + ", a .bin extension is required.");
|
throw new AssetLoadException("Cannot load " + uri + ", a .bin extension is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream input = (InputStream) info.getManager().loadAsset(info.getKey().getFolder() + uri);
|
BinDataKey key = new BinDataKey(info.getKey().getFolder() + uri);
|
||||||
|
InputStream input = (InputStream) info.getManager().loadAsset(key);
|
||||||
data = new byte[bufferLength];
|
data = new byte[bufferLength];
|
||||||
input.read(data);
|
input.read(data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user