three.js r70:合并three.PlaneBufferGeometries的问题
three.js r70: issues merging THREE.PlaneBufferGeometries
我正试图在使用THRE.PlaneBufferGeometry创建的缓冲区几何体上使用新的(在r70中引入的)THRE.BufferGeometriy.merge功能,但在随后的渲染调用中遇到了一个错误(合并本身工作正常,没有错误)。
- Chrome中的错误消息:
Uncaught TypeError: Cannot read property 'array' of undefined
- Firefox中的错误消息:
TypeError: this.attributes.position is undefined
- 受影响的代码行:非缩小r70构建中的第8679行:缓冲区几何体的computeBoundingSphere中的
var positions = this.attributes.position.array;
我能够将测试用例简化为一个简单的立方体模型(试图将立方体的所有面合并为一个BufferGeometry):
var camera, geometry, matrix, mesh, nx, ny, nz, px, py, pz, renderer, scene;
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x888888);
document.body.appendChild(renderer.domElement);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 70;
camera.position.x = 70;
camera.position.y = 70;
camera.lookAt(new THREE.Vector3(0,0,0));
matrix = new THREE.Matrix4();
px = new THREE.PlaneBufferGeometry(50, 50);
px.applyMatrix(matrix.makeRotationY(Math.PI / 2));
px.applyMatrix(matrix.makeTranslation(25, 0, 0));
nx = new THREE.PlaneBufferGeometry(50, 50);
nx.applyMatrix(matrix.makeRotationY(-Math.PI / 2));
nx.applyMatrix(matrix.makeTranslation(-25, 0, 0));
py = new THREE.PlaneBufferGeometry(50, 50);
py.applyMatrix(matrix.makeRotationX(-Math.PI / 2));
py.applyMatrix(matrix.makeTranslation(0, 25, 0));
ny = new THREE.PlaneBufferGeometry(50, 50);
ny.applyMatrix(matrix.makeRotationX(Math.PI / 2));
ny.applyMatrix(matrix.makeTranslation(0, -25, 0));
pz = new THREE.PlaneBufferGeometry(50, 50);
pz.applyMatrix(matrix.makeTranslation(0, 0, 25));
nz = new THREE.PlaneBufferGeometry(50, 50);
nz.applyMatrix(matrix.makeRotationY(Math.PI));
nz.applyMatrix(matrix.makeTranslation(0, 0, -25));
geometry = new THREE.BufferGeometry();
geometry.merge(px);
geometry.merge(nx);
geometry.merge(py);
geometry.merge(ny);
geometry.merge(pz);
geometry.merge(nz);
mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({color: 0xff0000}));
scene.add(mesh);
renderer.render(scene, camera);
这是一个:
- 使用PlaneBufferGeometry的破碎场景:http://jsfiddle.net/chrmoritz/gpt2xjmb/
- 使用法线PlaneGeometry的工作场景:http://jsfiddle.net/chrmoritz/gpt2xjmb/1/
根据我的理解,THREE.PlaneBufferGeometry应该注意使用顶点位置设置BufferGeometry的位置属性。是我做错了什么,还是这是threejsr70中的一个错误?
您可以使用:
var bg = new BufferGeometry().fromGeometry(geometry);
以获得合并的BufferGeometry。我在我的项目中也遇到了同样的问题,因为这条消息,我需要一个丑陋的解决方案。是否有任何错误报告或修复?
这个github问题结束时的代码应该可以工作。
https://github.com/mrdoob/three.js/issues/6188
我不知道为什么它没有被拉出来。
更新:我刚刚注意到你是
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 将PHP变量传递给jQuery时遇到问题
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- 参数变量出现ngTable指令问题
- 剑道网格jQuery动画()问题
- Potree/Three.js测量问题
- Three.js CanvasRenderer,在将图像纹理设置为平面时出现问题
- three.js r70:合并three.PlaneBufferGeometries的问题
- 在three.js中绘制半个球体的问题
- Three.js-渲染问题-动画正在动摇
- Three.js Javascript对象转换问题
- 在 Three.js 中将经度和纬度转换为 xyz(以便旋转相机)时出现问题
- 在 Three.JS 中对齐来自两个单独对象的面时出现问题
- Three.js-Chrome新的更新问题
- 在Three,js中着色网格中的问题
- iPhone上的Three.js项目-事件问题(选择和拖动对象)
- 在Three.js中实现GLSL着色器的问题
- 批量加载THREE.Mesh()时添加名称的问题
- 在three.js中合并模型和材料的问题
- 在three.js中正确渲染模型的问题