|
@@ -22244,7 +22244,7 @@
|
|
|
}
|
|
|
MergeEditor.modelAdded(model);
|
|
|
};
|
|
|
- if (prop.type == 'glb') {
|
|
|
+ if (prop.type == 'obj' || prop.type == 'glb') {
|
|
|
var callback = object => {
|
|
|
object.isModel = true;
|
|
|
object.traverse(e => e.material && (e.material.transparent = true));
|
|
@@ -82035,12 +82035,13 @@
|
|
|
if (mesh.material) {
|
|
|
var mats = mesh.material instanceof Array ? mesh.material : [mesh.material];
|
|
|
mats.forEach(mat => {
|
|
|
- if (mat.map) {
|
|
|
- if (!mat.map.image) {
|
|
|
+ var map = mat.map;
|
|
|
+ if (map) {
|
|
|
+ if (!map.image) {
|
|
|
console.error('!mat.map.image ??', mat.map.uuid); //obj可能会
|
|
|
return;
|
|
|
}
|
|
|
- texArea += mat.map.image.width * mat.map.image.height;
|
|
|
+ texArea += map.image.width * map.image.height;
|
|
|
//visi && (visiTexArea += a)
|
|
|
}
|
|
|
});
|
|
@@ -86239,24 +86240,32 @@
|
|
|
//Potree.Utils.makeTexDontResize(child.material.map)
|
|
|
//console.log(child.name, 'roughness',child.material.roughness,'metalness',child.material.metalness)
|
|
|
|
|
|
- if (fileInfo_.unlit && !(child.material instanceof BasicMaterial) /* || object.fileType == 'glb' */) {
|
|
|
- //注释掉是因为已经写入到loader文件里了
|
|
|
- //let material = new THREE.MeshBasicMaterial({map:child.material.map})
|
|
|
- var material = new BasicMaterial({
|
|
|
- map: child.material.map,
|
|
|
- opacity: child.material.opacity,
|
|
|
- color: child.material.color
|
|
|
- }); //很奇怪glb的图会使原本的MeshBasicMaterial 会偏暗,所以自己重新写
|
|
|
- //child.material.dispose()
|
|
|
- child.material = material;
|
|
|
- }
|
|
|
- if (fileInfo_.useStandandMat && !(child.material instanceof MeshStandardMaterial)) {
|
|
|
- child.material = new MeshStandardMaterial();
|
|
|
- child.material.roughness = 0.7;
|
|
|
- child.material.metalness = 0.5;
|
|
|
+ var changeMat = oldMat => {
|
|
|
+ var mat = oldMat;
|
|
|
+ if (fileInfo_.unlit && !(oldMat instanceof BasicMaterial) /* || object.fileType == 'glb' */) {
|
|
|
+ //注释掉是因为已经写入到loader文件里了
|
|
|
+ //mat = new THREE.MeshBasicMaterial({map:oldMat.map})
|
|
|
+ mat = new BasicMaterial({
|
|
|
+ map: oldMat.map,
|
|
|
+ opacity: oldMat.opacity,
|
|
|
+ color: oldMat.color
|
|
|
+ }); //很奇怪glb的图会使原本的MeshBasicMaterial 会偏暗,所以自己重新写
|
|
|
+ //oldMat.dispose()
|
|
|
+ }
|
|
|
+ if (fileInfo_.useStandandMat && !(oldMat instanceof MeshStandardMaterial)) {
|
|
|
+ mat = new MeshStandardMaterial();
|
|
|
+ mat.roughness = 0.7;
|
|
|
+ mat.metalness = 0.5;
|
|
|
+ }
|
|
|
+ //纯色的还是不能用BasicMaterial
|
|
|
+ return mat;
|
|
|
+ };
|
|
|
+ if (child.material instanceof Array) {
|
|
|
+ //obj
|
|
|
+ child.material = child.material.map(m => changeMat(m));
|
|
|
+ } else {
|
|
|
+ child.material = changeMat(child.material);
|
|
|
}
|
|
|
-
|
|
|
- //纯色的还是不能用BasicMaterial
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -86294,11 +86303,8 @@
|
|
|
async loadModel(fileInfo, done, onProgress_, onError) {
|
|
|
console.log('开始加载', fileInfo.name, Common.getNameFromURL(fileInfo.url));
|
|
|
var boundingBox = new Box3();
|
|
|
- /* if(!Potree.settings.boundAddObjs){
|
|
|
- boundingBox.min.set(-0.5,-0.5,-0.5); boundingBox.max.set(0.5,0.5,0.5)
|
|
|
- } */
|
|
|
if (fileInfo.objurl) {
|
|
|
- fileInfo.url = fileInfo.objurl, fileInfo.fileType = 'obj'; //兼容最早的
|
|
|
+ /* fileInfo.url = fileInfo.objurl, */fileInfo.fileType = 'obj'; //兼容最早的
|
|
|
}
|
|
|
if (fileInfo.url instanceof Array) {
|
|
|
if (fileInfo.url.length == 1) {
|
|
@@ -86331,6 +86337,19 @@
|
|
|
}
|
|
|
};
|
|
|
if (fileInfo.fileType == 'obj') {
|
|
|
+ var a = fileInfo.url.split('/');
|
|
|
+ var tails = a.pop().split('.');
|
|
|
+ var head = a.join('/') + '/';
|
|
|
+ var name = tails[0],
|
|
|
+ fileType = tails[1];
|
|
|
+ if (fileType == 'obj') {
|
|
|
+ fileInfo.objurl || (fileInfo.objurl = fileInfo.url);
|
|
|
+ fileInfo.mtlurl || (fileInfo.mtlurl = head + name + '.mtl');
|
|
|
+ } else {
|
|
|
+ fileInfo.fileType = 'glb';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fileInfo.fileType == 'obj') {
|
|
|
//暂时不支持数组
|
|
|
if (fileInfo.mtlurl) {
|
|
|
loaders.mtlLoader.load(fileInfo.mtlurl, materials => {
|