|
@@ -70613,9 +70613,22 @@
|
|
|
this.updateMemoryUsage()
|
|
|
},{once:true})
|
|
|
}) */
|
|
|
-
|
|
|
- this.changeModelPointCount(model, 'add');
|
|
|
- this.updateMemoryUsage();
|
|
|
+ var weightUpdate = () => {
|
|
|
+ this.changeModelPointCount(model, 'add');
|
|
|
+ this.updateMemoryUsage();
|
|
|
+ };
|
|
|
+ if (model.fileType == 'obj') {
|
|
|
+ //要等待贴图都加载完
|
|
|
+ if (viewer.fileManager.loading) {
|
|
|
+ viewer.addEventListener('managerOnLoad', e => {
|
|
|
+ weightUpdate();
|
|
|
+ }, {
|
|
|
+ once: true
|
|
|
+ }); //如果onError了咋办,暂时无法定位manager加载的哪个模型的
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ weightUpdate();
|
|
|
+ }
|
|
|
},
|
|
|
removeModel(model) {
|
|
|
var _model$panos;
|
|
@@ -78264,8 +78277,7 @@
|
|
|
*
|
|
|
*
|
|
|
*/
|
|
|
- var minRadius = 2,
|
|
|
- maxRadius = 300;
|
|
|
+ var standartMinRadius = 2;
|
|
|
class OrbitControls$1 extends EventDispatcher {
|
|
|
constructor(viewer, viewport) {
|
|
|
super();
|
|
@@ -78290,6 +78302,8 @@
|
|
|
this.tweens = [];
|
|
|
this.dollyStart = new Vector2();
|
|
|
this.dollyEnd = new Vector2();
|
|
|
+ this.minRadius = standartMinRadius;
|
|
|
+ this.maxRadius = 300;
|
|
|
this.keys = {
|
|
|
FORWARD: ['W'.charCodeAt(0), 38],
|
|
|
BACKWARD: ['S'.charCodeAt(0), 40],
|
|
@@ -78362,6 +78376,7 @@
|
|
|
var resolvedRadius = this.currentViewport.view.radius + this.radiusDelta;
|
|
|
this.radiusDelta += -e.delta * resolvedRadius * 0.1;
|
|
|
this.stopTweens();
|
|
|
+ this.updateRadius();
|
|
|
};
|
|
|
var dblclick = e => {
|
|
|
if (!this.enabled) return;
|
|
@@ -78446,28 +78461,10 @@
|
|
|
this.viewer.addEventListener('focusOnObject', o => {
|
|
|
if (o.position && o.CamTarget) {
|
|
|
var distance = o.position.distanceTo(o.CamTarget);
|
|
|
- if (distance < minRadius) minRadius = distance * 0.5; //融合页面当focus一个很小的物体时,需要将minRadius也调小
|
|
|
- }
|
|
|
- });
|
|
|
- this.viewer.addEventListener('camera_changed', e => {
|
|
|
- if (e.viewport == this.currentViewport) {
|
|
|
- var _viewer$inputHandler$, _viewer$inputHandler$2;
|
|
|
- var model = ((_viewer$inputHandler$ = viewer.inputHandler.intersect) === null || _viewer$inputHandler$ === void 0 ? void 0 : _viewer$inputHandler$.object) || ((_viewer$inputHandler$2 = viewer.inputHandler.intersect) === null || _viewer$inputHandler$2 === void 0 ? void 0 : _viewer$inputHandler$2.pointcloud);
|
|
|
- if (model) this.updateRadiusByModel(model, viewer.inputHandler.intersect.location.distanceTo(this.currentViewport.view.position));else {
|
|
|
- /* let disToGroundInDir = Math.abs(this.currentViewport.camera.position.z / this.currentViewport.view.direction.z) //相机和地面交点距离
|
|
|
- maxRadius = Math.max(2, disToGroundInDir*1.5)//越靠近地面速度越慢,防止移动来移动去久了之后距离模型很近但radius很大
|
|
|
-
|
|
|
- minRadius = disToGroundInDir * 0.9 //防止在高空放大很慢(注:不要把mesh放到地平线以下,否则hover mesh时很快,不hover又很慢)
|
|
|
- console.log('changeRadius common', minRadius, maxRadius) */
|
|
|
- if (!viewer.bound || viewer.bound.boundSize.x == 0) return;
|
|
|
- var boundFloor = viewer.bound.boundingBox.clone();
|
|
|
- var dis1 = boundFloor.distanceToPoint(viewer.mainViewport.view.position);
|
|
|
- boundFloor.max.z = boundFloor.min.z;
|
|
|
- var dis2 = boundFloor.distanceToPoint(viewer.mainViewport.view.position);
|
|
|
- minRadius = Math.max(2, dis1 * 0.5);
|
|
|
- maxRadius = Math.max(4, dis2 * 1.5);
|
|
|
- //console.log('changeRadius common', minRadius, maxRadius)
|
|
|
- }
|
|
|
+ //if(distance < minRadius) minRadius = distance * 0.5 //融合页面当focus一个很小的物体时,需要将minRadius也调小
|
|
|
+ this.minRadius = Math.min(standartMinRadius, distance * 0.5);
|
|
|
+ console.log('focus dis', distance);
|
|
|
+ //console.log('minRadius',this.minRadius)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -78559,12 +78556,26 @@
|
|
|
|
|
|
zoomToLocation(mouse) {
|
|
|
var I = viewer.inputHandler.intersect;
|
|
|
- if (!I) return;
|
|
|
- var object = I.object || I.pointcloud;
|
|
|
- I = I.location;
|
|
|
- if (!I || !object) return;
|
|
|
+ var object;
|
|
|
+ if (I) {
|
|
|
+ object = I.object || I.pointcloud;
|
|
|
+ I = I.location;
|
|
|
+ } else {
|
|
|
+ //点击空白处(地面)
|
|
|
+ var {
|
|
|
+ x,
|
|
|
+ y
|
|
|
+ } = Potree.Utils.getPointerPosAtHeight(0, viewer.inputHandler.pointer);
|
|
|
+ I = new Vector3(x, y, 0);
|
|
|
+ }
|
|
|
var dis = this.currentViewport.view.position.distanceTo(I);
|
|
|
- var distance = this.updateRadiusByModel(object, dis);
|
|
|
+ var distance;
|
|
|
+ if (object) {
|
|
|
+ distance = this.updateRadiusByModel(object, dis);
|
|
|
+ } else {
|
|
|
+ distance = Math.min(dis, 50); //方便从高空回到地面
|
|
|
+ this.updateRadius();
|
|
|
+ }
|
|
|
viewer.focusOnObject({
|
|
|
position: I
|
|
|
}, 'point', null, {
|
|
@@ -78578,11 +78589,25 @@
|
|
|
var size = bound.getSize(new Vector3());
|
|
|
var len = size.length();
|
|
|
var distance = MathUtils.clamp(dis, 0.8 * object.scale.x, Math.max(len * 0.1, 3 * object.scale.x));
|
|
|
- minRadius = distance;
|
|
|
- maxRadius = dis * 2;
|
|
|
- //console.log('updateRadiusByModel',minRadius, maxRadius)
|
|
|
+ this.minRadius = Math.min(distance, standartMinRadius);
|
|
|
+ this.maxRadius = dis * 2;
|
|
|
+ console.log('maxRadius hasIntersect', this.maxRadius);
|
|
|
return distance;
|
|
|
}
|
|
|
+ updateRadius() {
|
|
|
+ var _viewer$inputHandler$, _viewer$inputHandler$2;
|
|
|
+ var model = ((_viewer$inputHandler$ = viewer.inputHandler.intersect) === null || _viewer$inputHandler$ === void 0 ? void 0 : _viewer$inputHandler$.object) || ((_viewer$inputHandler$2 = viewer.inputHandler.intersect) === null || _viewer$inputHandler$2 === void 0 ? void 0 : _viewer$inputHandler$2.pointcloud);
|
|
|
+ if (model) {
|
|
|
+ this.updateRadiusByModel(model, viewer.inputHandler.intersect.location.distanceTo(this.currentViewport.view.position));
|
|
|
+ } else {
|
|
|
+ if (!viewer.bound || viewer.bound.boundSize.x == 0) return;
|
|
|
+ var boundFloor = viewer.bound.boundingBox.clone();
|
|
|
+ boundFloor.max.z = boundFloor.min.z;
|
|
|
+ var dis2 = boundFloor.distanceToPoint(viewer.mainViewport.view.position);
|
|
|
+ this.maxRadius = Math.max(4, dis2 * 5);
|
|
|
+ console.log('maxRadius noIntersect', this.maxRadius);
|
|
|
+ }
|
|
|
+ }
|
|
|
stopTweens() {
|
|
|
this.tweens.forEach(e => e.stop());
|
|
|
this.tweens = [];
|
|
@@ -78655,14 +78680,10 @@
|
|
|
var radius = view.radius + _progression * this.radiusDelta;
|
|
|
var _V = view.direction.multiplyScalar(-radius);
|
|
|
var _position = new Vector3().addVectors(view.getPivot(), _V);
|
|
|
- if (radius > maxRadius) {
|
|
|
- radius = maxRadius;
|
|
|
- }
|
|
|
+ radius = Math.min(radius, this.maxRadius);
|
|
|
if (this.constantlyForward) {
|
|
|
- // 到达中心点后还能继续向前移动,也就是能推进中心点
|
|
|
- if (radius < minRadius) {
|
|
|
- radius = minRadius;
|
|
|
- }
|
|
|
+ // 到达中心点后还能继续向前移动,也就是能推进中心点
|
|
|
+ radius = Math.max(radius, this.minRadius);
|
|
|
}
|
|
|
view.radius = radius;
|
|
|
view.position.copy(_position);
|
|
@@ -80663,7 +80684,6 @@
|
|
|
|
|
|
*/
|
|
|
|
|
|
- var manager = new LoadingManager();
|
|
|
var loaders = {};
|
|
|
var mapArea;
|
|
|
var shelterHistory = [];
|
|
@@ -80693,6 +80713,7 @@
|
|
|
|
|
|
window.viewer = this;
|
|
|
mapArea = mapArea_;
|
|
|
+ this.setLoaders();
|
|
|
if (this.renderer.capabilities.isWebGL2) {
|
|
|
Potree.settings.isWebgl2 = true; //是否启用webgl2
|
|
|
}
|
|
@@ -81095,14 +81116,7 @@
|
|
|
this.modules.Alignment.init();
|
|
|
this.images360 = new Images360(this);
|
|
|
this.scene.scene.add(this.objs);
|
|
|
- loaders = {
|
|
|
- objLoader: new OBJLoader(manager),
|
|
|
- mtlLoader: new MTLLoader(manager),
|
|
|
- glbLoader: new GLTFLoader(undefined, this.renderer, Potree.settings.libsUrl),
|
|
|
- plyLoader: new PLYLoader(manager),
|
|
|
- dxfLoader: new DxfLoader(),
|
|
|
- shapeLoader: new Potree.ShapefileLoader()
|
|
|
- };
|
|
|
+
|
|
|
//add test
|
|
|
/* const environment = new RoomEnvironment();
|
|
|
const pmremGenerator = new THREE.PMREMGenerator( this.renderer );
|
|
@@ -81444,7 +81458,7 @@
|
|
|
mats.forEach(mat => {
|
|
|
if (mat.map) {
|
|
|
if (!mat.map.image) {
|
|
|
- console.error('!mat.map.image ??'); //obj可能会
|
|
|
+ console.error('!mat.map.image ??', mat.map.uuid); //obj可能会
|
|
|
return;
|
|
|
}
|
|
|
texArea += mat.map.image.width * mat.map.image.height;
|
|
@@ -84446,7 +84460,7 @@
|
|
|
{
|
|
|
boundSize.x *= scale; //稍微放大一些,不然会靠到屏幕边缘
|
|
|
boundSize.y *= scale;
|
|
|
- var min = 0.0001;
|
|
|
+ var min = 1;
|
|
|
boundSize.x = Math.max(min, boundSize.x);
|
|
|
boundSize.y = Math.max(min, boundSize.y);
|
|
|
}
|
|
@@ -85508,6 +85522,34 @@
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
+ setLoaders() {
|
|
|
+ this.fileManager = new LoadingManager(); //整体的load manager
|
|
|
+ this.fileManager.onLoad = () => {
|
|
|
+ console.log('All resources have been loaded');
|
|
|
+ this.fileManager.loading = false;
|
|
|
+ this.dispatchEvent('managerOnLoad');
|
|
|
+ // 在这里可以执行模型渲染、动画等操作
|
|
|
+ };
|
|
|
+
|
|
|
+ // 设置加载进度的回调函数(可选)
|
|
|
+ this.fileManager.onProgress = (item, loaded, total) => {
|
|
|
+ if (loaded < total) this.fileManager.loading = true;
|
|
|
+ console.log("Loading ".concat(item, ": ").concat(loaded, " of ").concat(total));
|
|
|
+ };
|
|
|
+
|
|
|
+ // 设置加载失败的回调函数(可选)
|
|
|
+ this.fileManager.onError = url => {
|
|
|
+ console.error("Failed to load resource: ".concat(url));
|
|
|
+ };
|
|
|
+ loaders = {
|
|
|
+ objLoader: new OBJLoader(this.fileManager),
|
|
|
+ mtlLoader: new MTLLoader(this.fileManager),
|
|
|
+ glbLoader: new GLTFLoader(undefined, this.renderer, Potree.settings.libsUrl),
|
|
|
+ plyLoader: new PLYLoader(this.fileManager),
|
|
|
+ dxfLoader: new DxfLoader(),
|
|
|
+ shapeLoader: new Potree.ShapefileLoader()
|
|
|
+ };
|
|
|
+ }
|
|
|
modelLoaded(object) {
|
|
|
var fileInfo_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
var done = arguments.length > 2 ? arguments[2] : undefined;
|