- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在学习 Three.js。我找不到关于 BoxBufferGeometry 与 BoxGeometry 之间区别的正确答案。帮助我。
最佳答案
[Primitive]Geometry
类是操作友好的,内存不友好的所有 JS 几何类。
这意味着定义此几何的每条数据都存储为某个类的实例(Vector3
、Vector2
、Face3
) 等等。这些都带有方便的方法,所以你可以用一些其他向量点一个顶点,平移顶点,修改 uv,修改法线等等。但它在内存和性能方面有开销(创建所有这些实例,存储它们)。
[Primitive]BufferGeometry
类是性能友好的几何类,它依赖类型化数组以 WebGL 友好格式存储数据。
这意味着顶点不是 Vector3
的数组而是类型化数组:
Array[v0,v1... vN]
vs:
Float32Array[v0x,v0y,v0z,v1x,v1y,v1z... vNx,vNy,vNz]
它们的存储效率更高,但更难操作。
如果你想修改一个顶点:
使用几何
//with Geometry you just get vertex 5 and have access to it's x...
//AND the methods of the class -> Vector3.add(Vector3)
myGeom.vertices[5].add(new THREE.Vector3(1,2,3))
使用BufferGeometry
//xyz are just numbers, so with a stride of 3
//we select x , and then the next two for y and z
//we have to know that the 15th number in this array is x of vertex 5...
const stride = 3
const index = 5
let offset = index * stride
myGeom.attributes.position.array[offset++] += 1
myGeom.attributes.position.array[offset++] += 2
myGeom.attributes.position.array[offset ] += 3
但是
THREE.BufferAttribute
确实有几种方法可以从该数组写入和读取内容。它仍然更加冗长:
//add x: 1 y: 2 z: 3 to 5th vertex
const index = 5
const attribute = myGeometry.attributes.position
const v3add = new THREE.Vector3(1,2,3)
attribute.setXYZ(
index,
attribute.getX(index) + v3add.x,
attribute.getY(index) + v3add.y,
attribute.getZ(index) + v3add.z
)
关于javascript - Three.js 中的 BoxBufferGeometry 与 BoxGeometry 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49956422/
我有一个每个面都有不同纹理的盒子,我试图基于它创建一个四边形球体,在球体中使用相同的盒子纹理。目前我正在尝试按照这篇文章将立方体转换为球体: http://mathproofs.blogspot.co
编辑 我发现每当我想添加HelperBox时都会出现巨大的盒子,我做了a JSFiddle这里没有任何因素影响第二个盒子的大小。然而,在我的代码中,有一些东西干扰了我的盒子,因为当我将助手添加到场景中
我制作了一个游戏,您可以在不使用网格的情况下向世界添加对象。现在我想做一条人行道。当您单击“创建路径”时,您可以在世界上的光线转换器位置添加一个点。添加第一个点后,您可以向世界添加第二个点。当这两个物
我正在尝试在地球上创建尖峰(球体几何)。尽管一切正常,但尖峰与地球仪不一致。我想让尖峰对齐如下图所示的东西。但是我的尖峰没有 lookAt(new THREE.Vector3(0,0,0)) 尽管提到
我看到了一些访问 THREE.BoxGeometry 面的解决方案: var geometry = new THREE.BoxGeometry(n,n,n) let faces = geometry.
简单的程序,以特定的高度和特定的颜色在特定的位置显示条形。 Three.js 新手,正在学习该框架。 当我运行脚本来加载栏位置、颜色、灯光、相机和控件时。我发现 Box 颜色是恒定的,基本网格体因此我
我正在学习 Three.js。我找不到关于 CubeGeometry 与 BoxGeometry 之间区别的正确答案。我得到了相同的输出。请帮忙。 **CubeGeometry:** var geom
我试图将数据从 html 表单传递到代表 boxGeometry 的 x、y 和 z 维度的三个参数。当我手动设置参数值时它工作正常,但当参数通过表单中输入的值设置时则不行。 HTML
我正在学习 Three.js。我找不到关于 BoxBufferGeometry 与 BoxGeometry 之间区别的正确答案。帮助我。 最佳答案 [Primitive]Geometry 类是操作友好
我是一名优秀的程序员,十分优秀!