Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试在three.js中渲染圆柱体,失败,错误为“0”;无法读取属性';类型';“未定义”的定义;_Javascript_Three.js - Fatal编程技术网

Javascript 尝试在three.js中渲染圆柱体,失败,错误为“0”;无法读取属性';类型';“未定义”的定义;

Javascript 尝试在three.js中渲染圆柱体,失败,错误为“0”;无法读取属性';类型';“未定义”的定义;,javascript,three.js,Javascript,Three.js,我有一个很大的three.js代码,当我向其中添加一个简单的圆柱体时,它会使渲染器崩溃: const lineGeometry=new Three.CylinderBufferGeometry(1.0,//radiusTop 1.0,//半径底部 1.0,//高度 7,1)//径向/高度段 this.line=新的三点网格(线几何体、材质) this.add(this.line) // ... 后来。。。 viewer.render() 崩溃发生在渲染期间,在renderBufferDirec

我有一个很大的three.js代码,当我向其中添加一个简单的圆柱体时,它会使渲染器崩溃:

const lineGeometry=new Three.CylinderBufferGeometry(1.0,//radiusTop
1.0,//半径底部
1.0,//高度
7,1)//径向/高度段
this.line=新的三点网格(线几何体、材质)
this.add(this.line)
// ... 后来。。。
viewer.render()
崩溃发生在渲染期间,在
renderBufferDirect
(实际上是
renderer.setIndex
)中,并且似乎是由于此几何体具有
index
属性而导致的。three.js WebGLRenderer.js中崩溃的代码如下:

if(索引!==null){
attribute=attributes.get(index);//返回未定义的
渲染器=IndexedBufferrender;
renderer.setIndex(attribute);//此处未定义属性,导致崩溃
}
失败是由于
属性
未定义。几何体本身只有属性
position
normal
uv
,但我不确定这就是它失败的原因

我试图减少这种情况,但当然在一个小例子中效果很好-(

看起来
索引
位置
数组中的一组有效索引:

index: Uint16BufferAttribute {name: "", array: Uint16Array(84), itemSize: 1, count: 84, normalized: false, …}
attributes:
position: Float32BufferAttribute {name: "", array: Float32Array(138), itemSize: 3, count: 46, normalized: false, …}
normal: Float32BufferAttribute {name: "", array: Float32Array(138), itemSize: 3, count: 46, normalized: false, …}
uv: Float32BufferAttribute {name: "", array: Float32Array(92), itemSize: 2, count: 46, normalized: false, …}
所以我不确定attributes.get(index)
应该做什么,以及我需要为它提供什么才能使它工作。任何帮助都非常感谢


这是使用three.js r111顺便说一句。

嗯,我算出来了。我的
lineGeometry
有一个重复的
buffergeometry.id
,所以它在
WebGLObjects.update()中被跳过
从未更新过。至于我是如何得到一个重复的ID的,这仍然有待解决。

在一个有效的简化示例中,行
attribute=attributes.get(index)
返回一个包含
WebGLBuffer
的对象,该对象看起来像索引数组的表示形式。那么,我搞砸了什么会导致失败呢?我有两个three.js的副本——一个由子模块导入并“汇总”,另一个由模块导入。所以他们在争夺ID。