如何允许 <model-viewer> 显示带有元内容安全策略的 .glb 文件在 HTML 中渲染 myfile.glb

问题描述 投票:0回答:0

这是一个简单的网页,以 .glb 格式显示 blender 文件

`<!DOCTYPE html>
<html>
  <head>
  <title>Render myfile.glb in HTML</title>
  <meta http-equiv="Content-Security-Policy" content="default-src https://ajax.googleapis.com/ajax/libs/model-viewer/3.0.0/ filesystem 'self' ">
  <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.0.0/model-viewer.min.js"></script>
  </head>
  <body>
  <model-viewer src="myfile.glb"></model-viewer>
  </body>
</html>
`

html 文件和文件 myfile.glb 位于服务器上的同一目录中。浏览器不显示该文件。

firefox 的调试器状态:

内容安全策略:该页面的设置阻止了资源加载 https://ajax.googleapis.com/ajax/libs/model-viewer/3.0.0/model-viewer.min.js(“默认-源”)。

我该怎么做才能显示这个文件?这一定是一个愚蠢的错误,但也许其他人也有同样的问题......提前谢谢你。


我尝试了多种内容安全设置。 我在我的 PC 中尝试了一个本地文件(由于其他内容安全原因不起作用)。

我尝试了这里所说的一切:

https://blender.stackexchange.com/questions/286346/how-to-set-content-security-when-displaying-a-glb-file-in-html

没有成功——在 Firefox、Chrome 或 Opera 上都没有。

content-security-policy
© www.soinside.com 2019 - 2024. All rights reserved.