首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么文档中的ocean程序不工作并显示错误?

为什么文档中的ocean程序不工作并显示错误?
EN

Stack Overflow用户
提问于 2021-11-20 06:40:05
回答 1查看 28关注 0票数 2

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

我的代码是:

代码语言:javascript
复制
<!

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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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或更早的版本。

这段代码将给你一个基本的海洋

代码语言:javascript
复制
<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

这个问题包括修复的示例代码,但还没有人将其纳入公关...

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70043784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档