【问题标题】:can't load texture with Babylon.js on Chrome无法在 Chrome 上使用 Babylon.js 加载纹理
【发布时间】:2014-06-02 17:31:57
【问题描述】:

当我尝试使用 Babylon.js 将图像添加到 3d 球体时,我收到错误 Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded.

这就是我编写代码的方式。我已经按照教程here 进行操作,在我尝试更改纹理之前,一切都运行良好。

//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(我试图加载图像的那个)没有出现在程序中,但其他一切正常。

另外,我尝试下载本课程的源代码,但发生了同样的事情,所以我猜测它与我的浏览器(谷歌浏览器)有关。

【问题讨论】:

    标签: javascript google-chrome textures assets babylonjs


    【解决方案1】:

    您必须在网络服务器上使用您的文件,而不是在本地使用,以确保没有安全问题

    【讨论】:

      【解决方案2】:

      只有当您的应用在本地或全局服务器上运行时,您才能加载资产。否则,http请求无法完成。

      【讨论】:

        猜你喜欢
        • 2020-02-21
        • 2012-10-03
        • 2014-12-28
        • 2018-11-18
        • 2018-02-08
        • 1970-01-01
        • 1970-01-01
        • 2016-04-14
        • 1970-01-01
        相关资源
        最近更新 更多