admin管理员组文章数量:1415697
When I try to add an image to a 3d sphere using Babylon.js, I get the error Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded.
This is how I've written my code. I've followed the tutorial here and everything has worked prefectly until I try to change the textures.
//Creation of spheres
var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 10.0, 6.0, scene);
var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 2.0, 7.0, scene);
var sphere3 = BABYLON.Mesh.CreateSphere("Sphere3", 10.0, 8.0, scene);
//Positioning the meshes
sphere1.position.x = 10;
sphere3.position.x = -10;
//Textures
var sphere1texture = new BABYLON.StandardMaterial("sphere1texture", scene);
var sphere2texture = new BABYLON.StandardMaterial("sphere2texture", scene);
var sphere3texture = new BABYLON.StandardMaterial("sphere3texture", scene);
sphere1texture.alpha = 0.75
sphere2texture.diffuseTexture = new BABYLON.Texture("./texture1.jpg", scene);
sphere2
(the one I tried to load the image to) doesn't show up in the program, but everything else works fine.
Also, I tried downloading the source code for the lesson and the same thing happened, so I'm guessing its something to do with my browser (Google Chrome).
When I try to add an image to a 3d sphere using Babylon.js, I get the error Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded.
This is how I've written my code. I've followed the tutorial here and everything has worked prefectly until I try to change the textures.
//Creation of spheres
var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 10.0, 6.0, scene);
var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 2.0, 7.0, scene);
var sphere3 = BABYLON.Mesh.CreateSphere("Sphere3", 10.0, 8.0, scene);
//Positioning the meshes
sphere1.position.x = 10;
sphere3.position.x = -10;
//Textures
var sphere1texture = new BABYLON.StandardMaterial("sphere1texture", scene);
var sphere2texture = new BABYLON.StandardMaterial("sphere2texture", scene);
var sphere3texture = new BABYLON.StandardMaterial("sphere3texture", scene);
sphere1texture.alpha = 0.75
sphere2texture.diffuseTexture = new BABYLON.Texture("./texture1.jpg", scene);
sphere2
(the one I tried to load the image to) doesn't show up in the program, but everything else works fine.
Also, I tried downloading the source code for the lesson and the same thing happened, so I'm guessing its something to do with my browser (Google Chrome).
Share Improve this question edited Nov 28, 2014 at 14:16 user719662 asked Jun 2, 2014 at 17:31 alexanderd5398alexanderd5398 3271 gold badge4 silver badges18 bronze badges2 Answers
Reset to default 5You have to use your files on a webserver and not locally to ensure there is no security issues
You can load assets only if your app runned on the local or global server. If not, http request cant be pleted.
本文标签: javascriptcan39t load texture with Babylonjs on ChromeStack Overflow
版权声明:本文标题:javascript - can't load texture with Babylon.js on Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745237963a2649149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论