|
@@ -63906,17 +63906,23 @@ void main() {
|
|
|
loadDone(object);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- viewer.loadModel({
|
|
|
- name: 'glb',
|
|
|
- glburl: prop.url, //0.3s
|
|
|
+
|
|
|
+ let info = {
|
|
|
+ name: prop.type,
|
|
|
transform : {
|
|
|
position : prop.position,
|
|
|
rotation : new Euler().setFromVector3(prop.rotation),
|
|
|
scale: new Vector3(prop.scale,prop.scale,prop.scale),
|
|
|
- }
|
|
|
-
|
|
|
- },callback,onprogress);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ if(prop.type == 'glb'){
|
|
|
+ info.glburl = prop.url;
|
|
|
+ }else {
|
|
|
+ info.objurl = prop.url;
|
|
|
+ info.mtlurl = prop.mtlurl;
|
|
|
+ }
|
|
|
+ viewer.loadModel(info ,callback,onprogress);
|
|
|
|
|
|
}
|
|
|
};
|
|
@@ -84744,6 +84750,7 @@ void main() {
|
|
|
this.domElement.tabIndex = 2222;
|
|
|
}
|
|
|
|
|
|
+ this.lastPointerUpTime = 0;
|
|
|
|
|
|
this.touches = [];
|
|
|
|
|
@@ -84766,7 +84773,7 @@ void main() {
|
|
|
this.domElement.addEventListener('mousewheel', this.onMouseWheel.bind(this), false);
|
|
|
this.domElement.addEventListener('DOMMouseScroll', this.onMouseWheel.bind(this), false); // Firefox
|
|
|
|
|
|
- this.domElement.addEventListener('dblclick', this.onDoubleClick.bind(this));
|
|
|
+ //this.domElement.addEventListener('dblclick', this.onDoubleClick.bind(this)); //因为双击时间间隔是跟随系统的所以不好判断
|
|
|
|
|
|
this.domElement.addEventListener('keydown', this.onKeyDown.bind(this));
|
|
|
window.addEventListener('keyup', this.onKeyUp.bind(this));
|
|
@@ -85057,7 +85064,7 @@ void main() {
|
|
|
});
|
|
|
//}
|
|
|
}
|
|
|
-
|
|
|
+ this.needSingleClick = false;//add
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
|
|
@@ -85215,6 +85222,7 @@ void main() {
|
|
|
if(isTouch && e.touches.length >= 1){
|
|
|
return
|
|
|
}
|
|
|
+ let now = Date.now();
|
|
|
|
|
|
|
|
|
if (this.logMessages) console.log(this.constructor.name + ': onMouseUp');
|
|
@@ -85222,7 +85230,7 @@ void main() {
|
|
|
e.preventDefault();
|
|
|
|
|
|
let pressDistance = this.mouseDownMouse.distanceTo(this.mouse);
|
|
|
- let pressTime = Date.now() - this.pointerDownTime;
|
|
|
+ let pressTime = now - this.pointerDownTime;
|
|
|
|
|
|
let noMovement = this.drag.pointerDelta.length() == 0;//this.getNormalizedDrag().length() === 0;
|
|
|
|
|
@@ -85301,7 +85309,9 @@ void main() {
|
|
|
pressDistance
|
|
|
}
|
|
|
));
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//if(!clickElement){
|
|
@@ -85312,7 +85322,32 @@ void main() {
|
|
|
pressDistance
|
|
|
}
|
|
|
));
|
|
|
- //}
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //增加 单击:
|
|
|
+ this.needSingleClick = true;
|
|
|
+ this.doubleClickTime = 200; //双击间隔时间
|
|
|
+ setTimeout(()=>{
|
|
|
+ if(this.needSingleClick){
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
+ this.getEventDesc(e,isTouch),
|
|
|
+ {
|
|
|
+ type: 'global_single_click',
|
|
|
+ pressDistance
|
|
|
+ }
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }, this.doubleClickTime+1);
|
|
|
+
|
|
|
+ //自行执行双击:
|
|
|
+
|
|
|
+ if(now - this.lastClickTime < this.doubleClickTime){
|
|
|
+ this.onDoubleClick(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.lastClickTime = now;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -85347,6 +85382,8 @@ void main() {
|
|
|
this.deselectAll();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onMouseUp (e) {
|
|
@@ -103286,7 +103323,10 @@ ENDSEC
|
|
|
}
|
|
|
if(!I)return;
|
|
|
|
|
|
- viewer.setView({position:I, duration:1000});
|
|
|
+ let dis = this.scene.view.position.distanceTo(I);
|
|
|
+ let distance = MathUtils.clamp(dis, 0.3, 3);
|
|
|
+
|
|
|
+ viewer.focusOnObject({ position:I }, 'point', null, {distance});
|
|
|
|
|
|
}
|
|
|
|
|
@@ -115021,7 +115061,7 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
- viewer.addEventListener('global_click',(e)=>{
|
|
|
+ viewer.addEventListener('global_single_click',(e)=>{
|
|
|
if(viewer.inputHandler.selection[0] ||//正在平移和旋转,不允许更换
|
|
|
viewer.scene.cameraAnimations.length //正在播放
|
|
|
){
|
|
@@ -115112,28 +115152,32 @@ ENDSEC
|
|
|
},
|
|
|
|
|
|
|
|
|
- focusOnSelect(object, duration = 400){
|
|
|
- let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld);
|
|
|
- let center = boundingBox.getCenter(new Vector3);
|
|
|
- let size = boundingBox.getSize(new Vector3);
|
|
|
- let maxSize = size.length(); //对角线长度
|
|
|
+ /* focusOnSelect(object, duration = 400){
|
|
|
+ let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld)
|
|
|
+ let center = boundingBox.getCenter(new THREE.Vector3)
|
|
|
+ let size = boundingBox.getSize(new THREE.Vector3)
|
|
|
+ let maxSize = size.length() //对角线长度
|
|
|
|
|
|
if(object.isPointcloud){
|
|
|
- maxSize /= 2;
|
|
|
+ maxSize /= 2
|
|
|
}
|
|
|
|
|
|
- let hfov = cameraLight.getHFOVForCamera(viewer.mainViewport.camera,true);
|
|
|
- let minRadius = maxSize / Math.tan(hfov/2);
|
|
|
+ let hfov = cameraLight.getHFOVForCamera(viewer.mainViewport.camera,true)
|
|
|
+ let minRadius = maxSize / Math.tan(hfov/2)
|
|
|
//viewer.mainViewport.view.lookAt(center)
|
|
|
viewer.mainViewport.view.setView({
|
|
|
position: center.clone().sub(viewer.mainViewport.view.direction.clone().multiplyScalar(minRadius)),
|
|
|
target: center,
|
|
|
duration
|
|
|
- }); //setView can cancel bump
|
|
|
+ }) //setView can cancel bump
|
|
|
+
|
|
|
+ }, */
|
|
|
+ focusOnSelect(object, duration = 400){
|
|
|
+ let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld);
|
|
|
+ viewer.focusOnObject({boundingBox}, 'boundingBox', duration );
|
|
|
|
|
|
},
|
|
|
|
|
|
-
|
|
|
setModelBtmHeight(model, z ){
|
|
|
|
|
|
//无论模型怎么缩放、旋转,都使最低点为z
|
|
@@ -126481,7 +126525,7 @@ ENDSEC
|
|
|
this.boundBox = new Mesh(new BoxGeometry(1,1,1,1));
|
|
|
this.boundBox.material.wireframe = true;
|
|
|
this.boundBox.up.set(0,0,1);
|
|
|
- this.boundBox.visible = false; //打开以检查box
|
|
|
+ viewer.updateVisible(this.boundBox, 'hidden', false);//打开以检查box
|
|
|
this.setObjectLayers(this.boundBox,'sceneObjects');
|
|
|
this.scene.scene.add(this.boundBox);
|
|
|
}
|