3

Babylon.js を使用して 3D 球体に画像を追加しようとすると、エラーが発生しますUncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Tainted canvases may not be loaded.

これが私のコードの書き方です。ここのチュートリアルに従いましたが、テクスチャを変更しようとするまで、すべてがうまく機能しました。

//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(画像をロードしようとしたもの)はプログラムに表示されませんが、他のすべては正常に機能します。

また、レッスン用のソースコードをダウンロードしてみましたが同じでしたので、私のブラウザ(Google Chrome)が関係しているのではないでしょうか。

4

2 に答える 2

5

セキュリティ上の問題がないことを確認するには、ファイルをローカルではなくウェブサーバーで使用する必要があります

于 2014-06-03T14:17:37.663 に答える