Three.js: RGBELoader magic header check

Created on 5 Dec 2020  ·  3Comments  ·  Source: mrdoob/three.js

Describe the bug

RGBELoader checks for magic token at the start of the file:
https://github.com/mrdoob/three.js/blob/1e161eaeedee694861ec480f04b632443f64dbb4/examples/jsm/loaders/RGBELoader.js#L149-L154

I have a file that has the said header:
image
Loader doesn't recognize the magic token though.

Here's what line contents are when printed to console:
image

Now the curious part here is if you try to copy that and check the match again:
image
All looks good, however, if you try it on the line directly, you will see this:
image

The problem is that there's a 
 at the end (carriage return):
image
image

A bit extra:
image
It looks like both 13 and 10 are interpreted as NEW_LINE char by the ingestion function fget

To Reproduce

  • can't share the file at this moment

Code


Live example

  • can't share the file at this moment

Expected behavior

I'm not sure, I believe this should be treated as a valid header. This problem did not occur when using r107, so it looks like a regression bug. But perhaps someone more familiar with the RGBE spec can clarify.

Screenshots

see above

Platform:

  • Device: [Desktop]
  • OS: [Windows]
  • Browser: [Chrome]
  • Three.js version: [r??? - yes, 123]
Bug Loaders

Most helpful comment

I can't find anything online that states the bytes that come after #?RADIANCE should be restricted. This reference on the spec seems to indicate that it's enough for the first bytes be #?RADIANCE and that a newline does not need to follow.

Changing magic_token_re from this

magic_token_re = /^#\?(\S+)$/

to this

magic_token_re = /^#\?(\S+)/

seems like a fix.

All 3 comments

I can't find anything online that states the bytes that come after #?RADIANCE should be restricted. This reference on the spec seems to indicate that it's enough for the first bytes be #?RADIANCE and that a newline does not need to follow.

Changing magic_token_re from this

magic_token_re = /^#\?(\S+)$/

to this

magic_token_re = /^#\?(\S+)/

seems like a fix.

@Usnul do you mind testing that fix?

Yes, this works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

konijn picture konijn  ·  3Comments

seep picture seep  ·  3Comments

akshaysrin picture akshaysrin  ·  3Comments

scrubs picture scrubs  ·  3Comments

filharvey picture filharvey  ·  3Comments