3d改变构件颜色

40次阅读

共计 871 个字符,预计需要花费 3 分钟才能阅读完成。

// 修改颜色

overrideColorOnFragments(fragIds,color,objs,sceneName) {var material = new THREE.MeshPhongMaterial( { color: "#"+color,emissive:"#"+color,transparent:true})
    material.opacity=0.8;
    for (var j=0; j<fragIds.length; j++) {var mesh = viewer.impl.getRenderProxy(viewer.model, fragIds[j]);
        var myProxy = new THREE.Mesh(mesh.geometry, material);
        var box = new THREE.BoundingBoxHelper(myProxy ,0xffffff);
        myProxy.matrix.copy(mesh.matrixWorld);
        myProxy.matrixAutoUpdate = false;
        myProxy.matrixWorldNeedsUpdate = true;
        myProxy.frustumCulled = false;
        myProxy.dbid = objs[0];
        this.viewer.impl.addOverlay(sceneName, myProxy);
    }
}

overrideColorOnObj(objs,color,sceneName) {// initOverlays(color)
    var _this = this;
    this.viewer.getObjectTree(function(objTree) {for (var i=0; i<objs.length; i++) {var frags = [];
            objTree.enumNodeFragments(objs[i], function(fragId) {frags.push(fragId);
                _this.overrideColorOnFragments(frags,color,objs,sceneName);
            });

        }
    });
}

正文完
 0