|
@@ -18,6 +18,61 @@ const ModelTypes = {
|
|
|
8 : {name:'动画模型'}
|
|
|
}
|
|
|
|
|
|
+function modelAddEdge(model){//没有贴图的模型加线框
|
|
|
+ if(model.props.raw.type != 3)return
|
|
|
+ let ifHasMap
|
|
|
+ setTimeout(()=>{
|
|
|
+ model.traverse(mesh=>{
|
|
|
+ if(mesh.material?.map) {
|
|
|
+ ifHasMap = true
|
|
|
+ return {stopContinue:true}
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ let changeMat = (oldMat)=>{
|
|
|
+ let mat
|
|
|
+ if( !(oldMat instanceof THREE.MeshStandardMaterial)){
|
|
|
+ mat = new THREE.MeshStandardMaterial()
|
|
|
+ mat.roughness = 0.9
|
|
|
+ mat.metalness = 0.3
|
|
|
+ }
|
|
|
+ if(mat != oldMat)oldMat.dispose()
|
|
|
+ //纯色的还是不能用BasicMaterial
|
|
|
+ return mat
|
|
|
+ }
|
|
|
+
|
|
|
+ ifHasMap || model.traverse(mesh=>{
|
|
|
+ if(mesh.isMesh){
|
|
|
+ let edge = new THREE.LineSegments(
|
|
|
+ new THREE.EdgesGeometry(mesh.geometry),
|
|
|
+ new THREE.LineBasicMaterial({ color: 0x333333 ,
|
|
|
+ polygonOffset: true, //是否开启多边形偏移
|
|
|
+ polygonOffsetFactor: -5, //多边形偏移因子 负值会使边线稍微靠近相机
|
|
|
+ polygonOffsetUnits: -4.0, //多边形偏移单位
|
|
|
+ })
|
|
|
+ )
|
|
|
+ edge.renderOrder = 20
|
|
|
+ edge.name = '手动加的线框'
|
|
|
+ mesh.add(edge)
|
|
|
+ edge.scale.copy(mesh.scale)
|
|
|
+ edge.rotation.copy(mesh.rotation)
|
|
|
+ edge.position.copy(mesh.position)
|
|
|
+
|
|
|
+ //最好用这个outline https://threejs.org/examples/?q=edge#webgl_postprocessing_sobel
|
|
|
+
|
|
|
+ if(mesh.material instanceof Array){//obj
|
|
|
+ mesh.material = mesh.material.map(m=>changeMat(m))
|
|
|
+ }else{
|
|
|
+ mesh.material = changeMat(mesh.material)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },100)
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
@@ -1140,6 +1195,12 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
bus.emit('changeSelect', !!e.selected)
|
|
|
})
|
|
|
let lastState = {}
|
|
|
+
|
|
|
+ //-----------加线框------
|
|
|
+ modelAddEdge(model)
|
|
|
+
|
|
|
+
|
|
|
+ //-----------------------
|
|
|
model.addEventListener('transformChanged', (e) => {
|
|
|
let msg = {byControl:!!e.byControl} //byControl代表是手动用控制轴修改 动画文件要改帧
|
|
|
if (!lastState.position || !model.position.equals(lastState.position)) {
|
|
@@ -2467,7 +2528,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
Potree.Log(`--开始加载--`, { font: { color: '#f68' } });
|
|
|
console.log('id:', prop.id, ', title:', prop.title, ', filename:', Potree.Common.getNameFromURL(prop.url), ', type:', prop.type, prop)
|
|
|
|
|
|
- prop.unlit = prop.renderType != 'normal'
|
|
|
+ prop.unlit = prop.renderType != 'normal'
|
|
|
prop.maximumScreenSpaceError = 70
|
|
|
prop.prefix = prop.raw.prefix
|
|
|
/* laserRoot != void 0 && (prop.prefix = laserRoot) //prefix for getdataset
|