roman_44 Posted February 19, 2016 Author Share Posted February 19, 2016 On 2/17/2016 at 0:46 PM, adam said: There is some code at the beginning of the default LoadImage function to clean the url. You might need to include that in the new function. url = BABYLON.Tools.CleanUrl(url); Hey Adam, I tried your code and it looks like this: I commented responseType because it is not working with it. Now the requests are sending fine with my header. But it gets error: Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. I don't understand why are you trying to put xhr.response to the img.src. Img.src should be path I think. And image data should be somewhere in object. But I don't know where exactly and cannot find any information about it. And probably the interesting question is why another img elements from html are sending with session cookies in headers, and this img elements which created in Babylon are not. Quote Link to comment Share on other sites More sharing options...
roman_44 Posted February 19, 2016 Author Share Posted February 19, 2016 Ok, looks like I found real issue (I hope so) Same page in Firefox and in Crome. Firrefox requests generated by Babylon have cookies in headers, but in Crome they are not Any Ideas why??? And this is with default Babylon LoadImage function. Quote Link to comment Share on other sites More sharing options...
adam Posted February 19, 2016 Share Posted February 19, 2016 You might just want to do something like this: http://www.babylonjs-playground.com/#1TLCGX Quote Link to comment Share on other sites More sharing options...
roman_44 Posted February 19, 2016 Author Share Posted February 19, 2016 48 minutes ago, adam said: You might just want to do something like this: http://www.babylonjs-playground.com/#1TLCGX I know that I can manually create diffuseTexture or even download file first and then put in on texture. But the problem is that I'm developing a big app. Where I have a lot of scenes exported from 3dMax which already have a lot of textures. I'm getting scene by SceenLoader.load and I have hundreds of meshes, some of them have diffuse texture some of them not. So it just a big deal to disable downloading pictures when scene loads through sceneLoader from exported babylon file and after that try to manually download all pictures and include them as diffuse textures for appropriate meshes. So I have to have automated scene upload through SceneLoader.load as well as my session cookies in request headers. Quote Link to comment Share on other sites More sharing options...
adam Posted February 19, 2016 Share Posted February 19, 2016 The code I wanted you to look at isn't disabling anything: var loadImage = BABYLON.Tools.LoadImage; BABYLON.Tools.LoadImage = function(url, onload, onerror, database) { var xhr = new XMLHttpRequest(); //xhr.setRequestHeader("[KEY]", "[VALUE]"); xhr.open("GET", url); xhr.send(); return loadImage(url, onload, onerror, database); } It is just overriding the default loadImage so that you can set the header using XMLHttpRequest. roman_44 1 Quote Link to comment Share on other sites More sharing options...
roman_44 Posted February 19, 2016 Author Share Posted February 19, 2016 Sorry, my fault. Missed your top lines.... Yeah. I put this code and it is finally works :)))) It even automatically puts cookies which is awesome :))) Adam, thank you so much for your time and patience What do you think is it ok to loose all other functionality from default LoadImage function? It is a lot of other stuff there, database and other if's which I dont understand. Appreciate your help! Quote Link to comment Share on other sites More sharing options...
adam Posted February 19, 2016 Share Posted February 19, 2016 No problem. You are not losing any functionality because the loadImage var saves the default BabylonJS LoadImage and then the new load image function calls it at the end of the function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.