rhgrafix

Replacing my path and image in playground fails

Recommended Posts

Hi,
  
I'm testing code at: https://www.babylonjs-playground.com/?shadows and want to try my own image for the ground. On line 35 I put “http://www.rhgrafix.com/images/ground.jpg” instead of "textures/ground.jpg", I control+click on it and sure enough my image comes up in browser, but when I hit Run I just get the default checkered image. Why is this happening? Thanks,

 

R.L. Hamm

Share this post


Link to post
Share on other sites

Hiya @rhgrafix, welcome to the forum.  This could be happening because of CORs security.  rhgrafix.com might need to be configured for CORs.

Try this...

https://tinyurl.com/ycgow6mn

It is a Google IMAGE search... for 'ground texture', and I set the tools for 'labeled-for-reUse'... AND added 'wikimedia'... because I KNOW wikimedia images are always CORs-clear.

So, click some of those images, get some URLs to some of those textures, and see if THOSE work as a URL for your texture.  IF they do, then yeah, your server needs to be CORs activated, and I have no idea how to do that.  Sorry.  Others know how... and so does a web search.

I also have a free github account, and it lets me store a few textures there, and that is a CORs-cleared way.  (I'm no pro on CORs stuff, sorry.  Web reading available)

Somewhere in your f12 browser tools, there may be a 'net' tab/choice... that will show the results of all file-retrievals attempts... that happened during the scene RUN.  In there, you might see a CORs security report... which might have happened when that texture tried to load.

Hope this helps.  Report back, please.  thx.

Share this post


Link to post
Share on other sites

Thanks for replying and for the link to the textures.

18 hours ago, Wingnut said:

Hiya @rhgrafix, welcome to the forum.

 I’ve never heard of CORs-clear images, I read up on it a bit and saw some code on mozilla.org but don’t understand yet where it goes. I do have a working version of it on my domain: http://www.rhgrafix.com/shadows.htm Is it the babylon playground that is rejecting my domain/image? I will ask my webhost (FastComet) on how to enable CORs, there was no trace of it in their help section. One more problem: When I was trying to run it local, on my C:drive, I have with my index, the folder “textures” with the 2 images in it, and the code calls as “textures/ground.jpg” and it won’t work, other similar pages work locally (I don’t have a server emulator except GitHub Desktop and I’m not using it). So I am using the same images from the playground, bypassing my domain and it doesn’t work, any ideas on that? Thanks much and Merry Christmas! R.L. Hamm

Share this post


Link to post
Share on other sites

It is not the playground which rejects the request but your host. It will reject the request as it does not accept request from the PG domain. You have to check with your webhost here

Regarding accessing local files: this should not work as this is against security constraints. The best option is to run a local server

Share this post


Link to post
Share on other sites
2 hours ago, Deltakosh said:

It is not the playground which rejects the request but your host. It will reject the request as it does not accept request from the PG domain. You have to check with your webhost here

Ok, thank you, I submitted a ticket to my domain. About the local server, I have certain indexes that work fine locally with an
"images" folder in same folder as the index.html, what exactly determines whether or not it works? Something in the js files that are called up?

Thanks!

Share this post


Link to post
Share on other sites

 

I finally got this resolved, I added SSL to my domain and now it works, it solved the same problem I was having on CodePen and probably explains why a slew of other places I tried didn't work. My domain host gives us free access to Let’s Encrypt which was a really easy fix, even I figured it out and set it up in about 2 minutes :O) . Now I know CORS exists, I don’t understand it but I hope I don’t have to deal with it anymore. I’m not sure how many other domain hosts offer free SSL (https) but please spread the word of this possible fix to paths to files not working, it caused me hours upon hours of frustration. Thanks again for helping me.

R.L. Hamm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.