facebookarchive / react-360

Create amazing 360 and VR content using React
https://facebook.github.io/react-360
Other
8.73k stars 1.23k forks source link

MTL file changes when ?hotreload specified on URL error out #337

Closed jgwinner closed 7 years ago

jgwinner commented 7 years ago

Description

Bug - when MTL files generate an error when saved and the scene is reloaded via ?hotreload on the URL, but not when clicking 'refresh' (so the file itself is really OK).

Expected behavior

I would expect the MTL file changes to be read in

Actual behavior

Error in the browser console: TransformError F:/ReactVR/SpaceGallery/static_assets/OneTri.mtl: Unexpected character '#' (1:0)

Reproduction

Make a change to an .MTL file. For example, change:

Blender MTL File: 'OneTri.blend'

Material Count: 1

newmtl BaseMat Ns 96.078431 Ka 1.000000 1.000000 1.000000 Kd 0.040445 0.300599 0.066583 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 1.000000 illum 2

to

Blender MTL File: 'OneTri.blend'

Material Count: 1

newmtl BaseMat Ns 96.078431 Ka 1.000000 1.000000 1.000000 Kd 0.040445 0.300599 0.066583 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 0.500000 illum 2

Solution

If you click "Refresh" the modified MTL file is parsed correctly. I haven't looked at the code :( to see what's wrong, but my guess is maybe partial loading of MTL files on the fly isn't so easy. Still, it's an odd error message. I even used a hex editor to look at the file contents to make sure my editor wasn't messing around with line ends.

Oh - looks like it happens with .OBJ files as well; if I move some verts I get the same error. (I was editing .mtl files to manually change some paths when I noticed this - not sure people would want to edit .OBJ files, but they would probably re-export them and expect the world to update.

Additional Information

larrylin28 commented 7 years ago

This is the issue related to hot reloading in react native metro bundler. I think the best approach is ignore the file in rn-cli.config.js by adding .mtl files in getBlacklistRE

jgwinner commented 7 years ago

Ok. Is this an issue here or somewhere else?

Makes sense, although I do need the changes in the .MTL to persist, so the error is OK just means I have to (manually) hit refresh.

Good info about the rn-cli-config.js , thanks.

== John ==

larrylin28 commented 7 years ago

Cheers, @jgwinner