Open hunterforesee opened 2 years ago
I think I faced the same problem, always got an error about illegal characters at the end of the returned JSON.
I first solved it differently by placing
int index = json.LastIndexOf("}");
json = json.Remove(index + 1);
at the very top of the LoadAsync method in Importer.cs.
But now I tried your solution and it also works and surely is the cleaner way to go. You should make a PR with it.
Tried the top solution and worked perfectly. Had the same issue before.
Yes, Whenever the model has Unicode characters, getting this error. and @hunterforesee solution worked perfectly. Did anyone create PR?
// In GetGLBJson Method(Importer.cs), json is read via TextReader, it does not works properly when json string containg unicode character; //
private static string GetGLBJson(Stream stream, out long binChunkStart) { ‘’‘’ TextReader reader = new StreamReader(stream); char[] jsonChars = new char[chunkLength]; reader.Read(jsonChars, 0, (int) chunkLength); string json = new string(jsonChars); ‘’‘’
}
//May be It Should be Written Like this,Using Stream.Read Method private static string GetGLBJson(Stream stream, out long binChunkStart) { ‘’‘’ byte[] jsonBytes = new byte[chunkLength]; stream.Read(jsonBytes, 0, (int) chunkLength); string json = Encoding.Default.GetString(jsonBytes); ‘’‘’
}