【问题标题】:Difference between buffer geometry and geometry缓冲区几何和几何之间的区别
【发布时间】:2019-07-07 11:14:35
【问题描述】:

我是三个 JS 的新手,我研究了相机、渲染器、场景和几何等所有主题。通过几何的地方有几何和缓冲几何(比如conebufferGeometry和coneGeometry)。两者的特征相同。那么几何和缓冲区几何之间的区别是什么。这是否会影响性能或其他方面的任何东西

【问题讨论】:

    标签: three.js


    【解决方案1】:

    区别本质上在于底层数据结构(几何如何在内存中存储和处理顶点、面等)。

    出于学习目的,您不应该关心它,只需使用 ConeGeometry,直到遇到性能问题。那就再次进入正题,下次你会更加准备好分清两者的区别。

    请查看BufferGeometry

    网格、线或点几何的有效表示。包括 顶点位置、面索引、法线、颜色、UV 和自定义 缓冲区内的属性,减少传递所有这些数据的成本 到 GPU。

    要读取和编辑 BufferGeometry 属性中的数据,请参阅 BufferAttribute documentation.

    有关效率较低但更易于使用的几何图形表示,请参阅 几何。

    另一边Geometry

    Geometry 是 BufferGeometry 的用户友好替代方案。几何形状 使用对象存储属性(顶点位置、面、颜色等) 像 Vector3 或 Color 更容易阅读和编辑,但更少 比类型化数组更高效。

    对于大型或严肃的项目,首选 BufferGeometry。

    BufferGeometry 性能在这里解释:why-is-the-geometry-faster-than-buffergeometry

    【讨论】:

      【解决方案2】:

      几何最终会转换为缓冲几何,因此如果您没有任何性能问题,请在方便的情况下坚持使用几何。

      这里可以看到ConeGeometry调用了CylinderGeometry构造函数。

      CylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );
      

      https://github.com/mrdoob/three.js/blob/dev/src/geometries/ConeGeometry.js

      然后使用 CylinderBufferGeometry 创建 CylinderGeometry。

      this.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );
      

      https://github.com/mrdoob/three.js/blob/dev/src/geometries/CylinderGeometry.js

      【讨论】:

        猜你喜欢
        • 2020-10-03
        • 1970-01-01
        • 2021-06-17
        • 2011-04-27
        • 1970-01-01
        • 2016-12-04
        • 1970-01-01
        • 2023-03-15
        • 1970-01-01
        相关资源
        最近更新 更多