我试图有一个glb模型显示在一个简单的HTML网页,我正在建设。为了做到这一点,我遵循来自Model Viewer的API文档。我不确定为什么模型不能正确显示:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta http-equiv = "x-ua-compatible" content = "IE=edge">
<meta name = "viewport" content= "width=device-width, initial-scale=1.0">
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<title>portfolio</title>
<style>
.box {display:flex;}
mode-viewer {width: 800px; height: 500px; margin:0, auto}
</style>
</head>
<body>
<div class = "box">
<div>Hey check this out</div>
<div>
<model-viewer camera-controls alt="Model" src="assets/Model/Tavern.glb">
</model-viewer>
</div>
</div>
</body>
</html>该文件存储在资源文件夹中,并且路径正确。这就是结果
Outcome有什么建议吗?
编辑:我读过一些帖子,提到在加载glb文件时出现错误,但我没有收到这些错误。
发布于 2021-09-15 01:18:44
放入包含http://localhost的absoulute url示例:http://localhost/glb/assets/Model/Tavern.glb
请确保您的路径是正确的,因为当我在更改url后检查一切正常时,请检查以下代码片段:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta http-equiv = "x-ua-compatible" content = "IE=edge">
<meta name = "viewport" content= "width=device-width, initial-scale=1.0">
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<title>portfolio</title>
<style>
.box {display:flex;}
mode-viewer {width: 800px; height: 500px; margin:0, auto}
</style>
</head>
<body>
<div class = "box">
<div>Hey check this out</div>
<div style="border:1px solid black">
<model-viewer camera-controls alt="Model" src="https://modelviewer.dev/shared-assets/models/shishkebab.glb">
</model-viewer>
</div>
</div>
</body>
</html>
https://stackoverflow.com/questions/69185593
复制相似问题