gpt4 book ai didi

javascript - 无法在 WebGL 中渲染来自 S3 存储桶的图像

转载 作者:行者123 更新时间:2023-12-03 10:16:23 24 4
gpt4 key购买 nike

当我的 JavaScript 应用程序尝试从我的 Amazon S3 帐户加载图像并在 WebGL 中渲染它时,浏览器会抛出 CORS 错误。我更改了 S3 存储桶的 CORS 配置以允许访问:

<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>

不幸的是,当我尝试从 S3 存储桶渲染图像时,浏览器仍然会抛出 CORS 错误。

我是不是漏掉了一个步骤?或者,这只是正常现象吗?换句话说,无论文件的域是否允许通过适当的 CORS 配置进行访问,WebGL 是否总是拒绝跨域文件?

最佳答案

According to MDN

In order to load it with CORS as a WebGL texture, we set the crossOrigin attribute on it:

var earthImage = new Image();
earthImage.crossOrigin = "anonymous";

Now we load it as usual:

earthImage.onload = function() {
// whatever you usually to do load WebGL textures
};
earthImage.src = "http://khm0.googleapis.com/kh?v=95&x=0&y=0&z=0";

关于javascript - 无法在 WebGL 中渲染来自 S3 存储桶的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29852645/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com