在Official documentation中有一个程序,其中他们提到了Don McCurdy的aframe-extras的引用,以获得Aframe 1.2.0。但是当我使用生产链接的CDN运行程序时。它永远不会起作用。我也收到了下面的错误。

我的代码是:
<!
DOCTYPE html>
<html lang="en">
<head>
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
<title>Proyectos</title>
</head>
<body>
<a-scene physics>
<script>
AFRAME.registerPrimitive('a-ocean', {
// Attaches the `ocean` component by default.
// Defaults the ocean to be parallel to the ground.
defaultComponents: {
ocean: {},
rotation: {x: -90, y: 0, z: 0}
},
// Maps HTML attributes to the `ocean` component's properties.
mappings: {
width: 'ocean.width',
depth: 'ocean.depth',
density: 'ocean.density',
color: 'ocean.color',
opacity: 'ocean.opacity'
}
});
</script>
<a-ocean color="aqua" depth="100" width="100"></a-ocean>
</a-scene>
</body>
</html>发布于 2021-11-20 09:58:31
a-ocean是在a-frame中定义的,所以你不需要再次定义它,你应该可以直接使用它。这解释了第一个错误("a-ocean已注册“)。
不幸的是,它是使用THREE.js几何组件编写的,该组件在THREE.js r125中已被弃用。
这对应于A-Frame 1.2.0。
这解释了第二个错误("mergeVertices不是一个函数“)。
因此(直到有人更新了a-ocean)如果你想使用a-ocean,你必须使用A-Frame 1.1.0或更早的版本。
这段代码将给你一个基本的海洋
<html lang="en">
<head>
<script src="https://aframe.io/releases/1.1.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
<title>Proyectos</title>
</head>
<body>
<a-scene physics>
<a-ocean color="aqua" depth="100" width="100"></a-ocean>
</a-scene>
</body>
</html>在修复海洋方面,似乎已经在这方面做了一些工作:https://github.com/n5ro/aframe-extras/issues/362
这个问题包括修复的示例代码,但还没有人将其纳入公关...
https://stackoverflow.com/questions/70043784
复制相似问题