rastapasta/react-native-gl-model-view

source.zip is undefined

Dylan-Wells-at-LION opened this issue · 13 comments

Hi there.

I was getting the error message "source.zip is undefined" and I traced it to the method loadModel in BaseModelView.js. In that method, it expects the props source and onLoadModelStart. Neither of these props are being passed, but model, texture, and all the transformation props are.

In the examples, I see model and texture are top level props, but it now seems to want a JSON object in the top level prop source, so presumably the examples are just out of date?

Doing this solve "source.zip is undefined" bug but now I get Unhandled JS Exception: TypeError: null is not an object (evaluating '(0, _resolveAssetSource2.default)(source.model).uri') which seems to indicate my model is in the wrong location?

You say to add the model/texture to the root of the Xcode using the editor. Based on the screenshot, does it look like the model/texture (apple.obj/jpg) is in the right place?

screen shot 2018-05-10 at 2 38 49 pm

I've made some progress (maybe) by providing the source like this:
<ModelView source={ { model: { uri: './apple.obj' }, texture: { uri: './apple.jpg' } } } scale={1} translateZ={-2} rotateZ={270} style={{flex: 1}} />

But now my issue is an Unhandled Promise Rejection (unsupported URL). So far I've tried 'apple.obj' and './apple.obj'

screen shot 2018-05-10 at 4 55 49 pm

Any assistance would be greatly appreciated. I know this isn't StackOverflow but I'd really love to use this library.

Made it this far by loading the .obj from a URL:
Loading model at /Users/dev2/Library/Developer/CoreSimulator/Devices/1234CAB4-FA95-4F0E-881B-FAA1EF7FC91B/data/Containers/Data/Application/E2BD36BE-6F6E-410D-948F-CEEF2BE9A437/Documents/rct-3d-model-view/apple.obj

Looks like my obj and image are now in the right directory but I'm getting a blank screen but at the moment it seems to be a styling issue, though these messages do show up not long after that one, not sure if it's related:
2018-05-10 17:28:59.916002-0700 aamapp[3684:27201726] [] nw_connection_get_connected_socket 4279 Connection has no connected handler

Hi Dylan. I'm having a hard time following you here. The library never supported loaded anything else than a string for the source prop. The source prop should only have your file name without the path (e.g. apple.obj) and be located at the root of your project. In the screenshot you posted, the aamapp folder is not the root. You should move your texture and your model under the blue xcode icon, like that:

project

Also, can you tell me where you found the BaseModelView.js file? I don't think we have such a file in the project, and I definitely can't find it via github or locally. Can you try running the examples? They are working on my machine and you should just have to mimic their structure to get a working prototype of your project.

If nothing works and it's possible for you, you can also send me your project and I'll give it a look.

Hi Patrice, thanks for your response. It would appear that I accidentally installed an unrelated project with yarn called react-native-3d-model-view and tried to make it work using the instructions in this repo which would explain... a lot. I'm a bit stunned by that.

My build is now failing because GLModelView.h from GLView cannot be found. I installed GLView using pods but I'm not sure what else has to be done after that. I made a copy of GLModelView.h and placed it in a folder where it appears to be looking for it but that didn't seem to do the trick.

Could you please elaborate on where to place the GLView files?

screen shot 2018-05-11 at 9 47 05 am

I placed all the GLView files here, and they seem to be getting found but plenty of new errors to work on:

screen shot 2018-05-11 at 10 02 44 am
screen shot 2018-05-11 at 10 02 49 am

I got rid of the bulk of errors by changing

#if __has_include("RCTBridge.h") #import "RCTBridge.h" #else #import <React/RCTBridge.h> #endif

to just #import <React/RCTBridge.h> in RNGLModelViewManager.m

Can't say I really understand the implications of that though...

All that's left is the "incompatible operand types" error and it seems to be coming from this block:
screen shot 2018-05-11 at 10 30 31 am

Wow, good catch. I must have been really tired when I was writing that code. The brackets for red, green and blue are obviously not matching at the right places. Can you match them like the "alpha" line and tell me if it's working for you? I will do a hotfix very soon so you won't have to keep that patch for a long time, but it's just to unblock you in the meantime.

I fixed the brackets to match alpha, and that got rid of those error. Thanks!

Not sure what this is about though, is this because of the warnings where it says "___ was built for newer iOS Version (8.2) than being linked (8.0)"?

screen shot 2018-05-11 at 10 57 57 am

It might be, I'm not sure about this error. Maybe try updating xcode (if that's feasible for you) and see if it fixes the errors for you. The example project is running fine for me now after fixing the brackets.

I updated XCode and that didn't seem to work. On stackoverflow people suggested that resources needed to be added to this Compile Sources list. I got rid of the above errors by adding these files to Compile Sources:

screen shot 2018-05-11 at 3 52 06 pm

Now my build is failing because Cannot find interface declaration for UIColor. UIKit.framework is added to the Linked Frameworks and Libraries so that's not the issue.

An answer on stack that I found and am currently investigating:

This can happen when foo.h #imports "bar.h" and bar.h #imports "foo.h" (or sometimes its a chain of three or more header files importing each other in a circle) and it leads to spurious errors like the one you're seeing.

Hi, thanks for all your help last week. I finally got it working by starting fresh and following the example more closely. If you don't mind, I was having some issues with texture mapping. Models I download off the internet such as from turbosquid rarely seem to have their textures mapped properly. Is this controllable at the React level? Or is there a specific type of mapping that this tool expects?

Unfortunately it's not possible right now. If the model has more than a single texture or the texture isn't mapped properly, we can't control it yet. The texture is mapped by following the uv coordinates in the model, so if the artists did the mapping properly, it should work like a charm. Otherwise, you'd have to open the model in an external 3D software and do it yourself.

By the way, I will close this issue now since the original problem has been solved. Feel free to open a new issue related to this problem or if you want to request a new feature!

@Dylan-at-LION hi. i got same errors. can you share your work project?