赞
踩
- //modelList为要销毁的模型
- destoryModels(modelList){
- //销毁服务器
- if(modelList.length!=0){
- modelList.forEach(currObj => {
- // 判断类型
- if(currObj instanceof THREE.Scene){
- var children = currObj.children;
- for(var i = 0; i< children.length; i++){
- this.deleteGroup(children[i]);
- }
- }else{
- this.deleteGroup(currObj);
- }
- this.scene.remove(currObj);
- });
- }
- },
- //删除group,释放内存
- deleteGroup(group) {
- if (!group) return;
- //删除掉所有的模型组内的mesh
- group.traverse(function (item) {
- if (item instanceof THREE.Mesh) {
- item.geometry.dispose(); //删除几何体
- item.material.dispose(); //删除材质
- }
- });
- },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。