本文介绍了合并Geometries和Mesh的三个js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

三个js ver67
当前代码是这样的 -

Three js ver67Current code something like this -

    var materials = [];
    var totalGeom = new THREE.Geometry();
    var cubeMat;
    for (var i = 0; i < dataSetArray.length; i++) {
        var ptColor = dataSetArray[i].color;
        var value = dataSetArray[i].value;
        var position = latLongToVector3(dataSetArray[i].y, dataSetArray[i].x, 600, 1);

        var cubeGeom = new THREE.BoxGeometry(5, 5, 1 + value / 20);


        cubeMat = new THREE.MeshLambertMaterial({
            color: new THREE.Color(ptColor),
            opacity: 0.6
        });


        materials.push(cubeMat);
        // cubeGeom.updateMatrix();

        var cubeMesh = new THREE.Mesh(cubeGeom, cubeMat);
        cubeMesh.position = position;
        cubeMesh.lookAt(scene.position);

        // totalGeom.merge(cubeMesh.geometry, cubeMesh.geometry.matrix);
        //THREE.GeometryUtils.setMaterialIndex(cubeMesh.geometry, i);
        THREE.GeometryUtils.merge(totalGeom, cubeMesh);
    }


    var total = new THREE.Mesh(totalGeom, new THREE.MeshFaceMaterial(materials));
    scene.add(total);

然而我收到消息

DEPRECATED :GeometryUtils的.merge()已移至Geometry。改为使用geometry.merge(geometry2,matrix,materialIndexOffset)。

DEPRECATED: GeometryUtils's .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.

在chrome dev工具中。

in chrome dev tools.

当我尝试像 -
totalGeom.merge(cubeMesh.geometry,cubeMesh.geometry.matrix);
而不是THREE.GeometryUtils.merge(totalGeom,cubeMesh);我得到例外。

When I try something like -totalGeom.merge(cubeMesh.geometry, cubeMesh.geometry.matrix); instead of THREE.GeometryUtils.merge(totalGeom, cubeMesh); I get exceptions.

我将如何进行上述合并?请帮忙。

How will I do the above merge? Please help.

推荐答案

这样做:

cubeMesh.updateMatrix();
totalGeom.merge( cubeMesh.geometry, cubeMesh.matrix );

如需进一步了解,请参阅源代码THREE.Geometry.merge ()

For a further understanding, see the source code of THREE.Geometry.merge().

three.js r.69

three.js r.69

这篇关于合并Geometries和Mesh的三个js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:59