我试图用以下方法加载glTF模型 陀螺仪 在glitch.com继 框架文件. 你可以看看完整的项目和代码。此处. 当我在本地运行代码时,一切都能如期进行,但当我运行glitch.com应用程序时,我得到的是一个 未捕获的异常。对象3 浏览器控制台中的错误。这是我使用的HTML。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chaitén VR 3</title>
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="scripts/camera-listener.js"></script>
</head>
<body>
<a-scene
stats
renderer="antialias: true; colorManagement: true; sortObjects: true; physicallyCorrectLights: true; maxCanvasWidth: 1920; maxCanvasHeight: 1920;"
gltf-model="dracoDecoderPath: scripts/draco_decoder">
<a-assets timeout="69000">
<a-asset-item
id="cave"
src="https://cdn.glitch.com/b8b66d5a-73ec-4bfe-8bfc-6ac0f5e30e89%2Fcueva_6_dcompress_1.gltf">
</a-asset-item>
</a-assets>
<a-sky
color="#000">
</a-sky>
<a-gltf-model
src="#cave"
scale="1 1 1"
position="0 0 -10"
rotation="-90 90 0"
shadow="cast: true"
sound="src: https://cdn.glitch.com/b8b66d5a-73ec-4bfe-8bfc-6ac0f5e30e89%2Fcave_1.mp3; autoplay: true; loop: true; volume: 2">
</a-gltf-model>
<a-entity
id="camera"
camera
look-controls
wasd-controls="acceleration:150"
position="-4.5 1.6 -1">
</a-entity>
<a-entity
id="light"
light="type: point; intensity: 15; distance: 10; decay: 1; shadowCameraVisible: false;"
position="-4.5 1.6 0.35">
</a-entity>
<a-entity camera-listener></a-entity>
</a-scene>
</body>
我在Blender 2.82中创建了原始的glTF并使用了 glTF管道 来将模型转换为Draco glTF。
我检查了这个文件。time_draco_decode.html。 并发现。
// It is recommended to always pull your Draco JavaScript and WASM decoders
// from this URL. Users will benefit from having the Draco decoder in cache
// as more sites start using the static URL.
let decoderPath = 'https://www.gstatic.com/draco/v1/decoders/';
我使用了这个路径,现在应用程序运行正常。