Babylon.js와 Chrome에 텍스처를로드 할 수 없습니다
-
20-12-2019 - |
문제
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 크롬)와 관련이있는 것을 추측합니다.
해결책
웹 서버에서 파일을 사용하고 보안 문제가 없는지 로컬로 파일을 사용해야합니다
다른 팁
로컬 또는 글로벌 서버에서 앱이 흘러 나오는 경우에만 자산을로드 할 수 있습니다.그렇지 않은 경우, HTTP 요청이 완료 될 수 없습니다.
제휴하지 않습니다 StackOverflow