Jump to content

Replacing my path and image in playground fails


rhgrafix
 Share

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

Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
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!

Link to comment
Share on other sites

  • 2 weeks later...

 

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...