|
@@ -22,12 +22,12 @@ var Viewer = function (index, dom) {
|
|
|
this.camera = new THREE.PerspectiveCamera();
|
|
|
this.camera.position.set(0, 0, 0.78);
|
|
|
this.control = new THREE.OrbitControls(this.camera, this.dom)
|
|
|
- this.control.enableDamping = true;
|
|
|
+ this.control.enableDamping = false;
|
|
|
this.control.dampingFactor = 0.4;
|
|
|
this.control.minDistance = 0.3;
|
|
|
this.control.maxDistance = 2;
|
|
|
|
|
|
- this.control.enablePan = true;
|
|
|
+ this.control.enablePan = false;
|
|
|
this.control.enableZoom = true;
|
|
|
|
|
|
this.setRenderer()
|
|
@@ -116,9 +116,9 @@ Viewer.prototype.hasChanged = function () {//判断画面是否改变了,改
|
|
|
|
|
|
//var changed = cameraChanged //|| !this.mouse.equals(this.previousState.mouse)
|
|
|
let changeSlightly
|
|
|
- if(cameraChanged){
|
|
|
- changeSlightly = math.closeTo(this.camera.position,this.previousState.position, 1e-2) &&
|
|
|
- math.closeTo(this.camera.quaternion,this.previousState.quaternion, 1e-3)
|
|
|
+ if (cameraChanged) {
|
|
|
+ changeSlightly = math.closeTo(this.camera.position, this.previousState.position, 1e-2) &&
|
|
|
+ math.closeTo(this.camera.quaternion, this.previousState.quaternion, 1e-3)
|
|
|
}
|
|
|
copy()
|
|
|
|
|
@@ -167,7 +167,7 @@ Viewer.prototype.animate = function () {
|
|
|
|
|
|
let changed = this.hasChanged()
|
|
|
if (changed.cameraChanged) {
|
|
|
- this.dispatchEvent({ type: 'view.changed', changeSlightly:changed.changeSlightly })
|
|
|
+ this.dispatchEvent({ type: 'view.changed', changeSlightly: changed.changeSlightly })
|
|
|
|
|
|
let label_ = this.labels.filter(e => e.elem[0].style.display == 'block')
|
|
|
label_.sort((a, b) => b.pos2d.z - a.pos2d.z)
|
|
@@ -229,29 +229,29 @@ Viewer.prototype.animate = function () {
|
|
|
object.traverse(function (child) {
|
|
|
if (child.isMesh) {
|
|
|
console.log(child);
|
|
|
- // if (child.name == "WL48_ping") {
|
|
|
- // let textrueLoader = new THREE.TextureLoader();
|
|
|
- // var emissiveTexture = textrueLoader.load("model/shadow.jpg");
|
|
|
- // // emissiveTexture.encoding = THREE.LinearEncoding;
|
|
|
- // child.material.emissiveMap = emissiveTexture;
|
|
|
- // child.material.emissiveIntensity = 0;
|
|
|
- // // let step = 1
|
|
|
- // // setInterval(() => {
|
|
|
-
|
|
|
- // // if (child.material.emissiveIntensity > 0.3) {
|
|
|
- // // step = -1
|
|
|
-
|
|
|
- // // }
|
|
|
-
|
|
|
- // // if (child.material.emissiveIntensity < 0) {
|
|
|
- // // step = 1
|
|
|
- // // }
|
|
|
-
|
|
|
- // // child.material.emissiveIntensity += 0.01 * step;
|
|
|
-
|
|
|
- // // }, 50);
|
|
|
- // child.material.emissive = new THREE.Color(0xffffff);
|
|
|
- // }
|
|
|
+ if (child.name == "WL48_ping") {
|
|
|
+ let textrueLoader = new THREE.TextureLoader();
|
|
|
+ var emissiveTexture = textrueLoader.load("model/shadow.jpg");
|
|
|
+ // emissiveTexture.encoding = THREE.LinearEncoding;
|
|
|
+ child.material.emissiveMap = emissiveTexture;
|
|
|
+ child.material.emissiveIntensity = 0;
|
|
|
+ let step = 1
|
|
|
+ setInterval(() => {
|
|
|
+
|
|
|
+ if (window.activetab == 'pic') {
|
|
|
+ if (child.material.emissiveIntensity > 0.3) {
|
|
|
+ step = -1
|
|
|
+ }
|
|
|
+ if (child.material.emissiveIntensity < 0) {
|
|
|
+ step = 1
|
|
|
+ }
|
|
|
+ child.material.emissiveIntensity += 0.01 * step;
|
|
|
+ }
|
|
|
+
|
|
|
+ }, 50);
|
|
|
+ child.material.emissive = new THREE.Color(0xffffff);
|
|
|
+ child.material.dispose();
|
|
|
+ }
|
|
|
/* if(child.geometry){
|
|
|
child.geometry.computeBoundingBox();
|
|
|
bound.union(child.geometry.boundingBox)
|
|
@@ -301,14 +301,10 @@ Viewer.prototype.animate = function () {
|
|
|
|
|
|
|
|
|
Viewer.prototype.onPointerMove = function (event) {
|
|
|
-
|
|
|
if (event.isPrimary === false) return;
|
|
|
-
|
|
|
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
|
|
mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
|
|
|
-
|
|
|
if (!this.pointerDownPos) this.checkIntersection();
|
|
|
-
|
|
|
}
|
|
|
Viewer.prototype.onPointerDown = function (event) {
|
|
|
if (event.isPrimary === false) return;
|
|
@@ -320,25 +316,25 @@ Viewer.prototype.onPointerDown = function (event) {
|
|
|
Viewer.prototype.onPointerUp = function (event) {
|
|
|
|
|
|
if (event.isPrimary === false) return;
|
|
|
+ this.dispatchEvent({ type: 'onPointerUp' })
|
|
|
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
|
|
mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
|
|
|
if (mouse.distanceTo(this.pointerDownPos) < 0.006) {//click
|
|
|
this.checkIntersection()
|
|
|
-
|
|
|
// if (this.intersects.length) {
|
|
|
// console.log(this.intersects[0].point);
|
|
|
// this.addLabel({ position: this.intersects[0].point })
|
|
|
// }
|
|
|
|
|
|
- var time = new Date().getTime();
|
|
|
- if (time - this.clickTime < 300) {
|
|
|
- if (this.intersects.length) {
|
|
|
- console.log('doubleClick');
|
|
|
- transitions.cancelById(0)
|
|
|
- transitions.start(lerp.vector(this.control.target, this.intersects[0].point), 600, null, 0/* Delay */, easing.easeInOutQuad, null, Transitions.doubleClick);
|
|
|
- }
|
|
|
- }
|
|
|
- this.clickTime = time;
|
|
|
+ // var time = new Date().getTime();
|
|
|
+ // if (time - this.clickTime < 300) {
|
|
|
+ // if (this.intersects.length) {
|
|
|
+ // console.log('doubleClick');
|
|
|
+ // transitions.cancelById(0)
|
|
|
+ // transitions.start(lerp.vector(this.control.target, this.intersects[0].point), 600, null, 0/* Delay */, easing.easeInOutQuad, null, Transitions.doubleClick);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // this.clickTime = time;
|
|
|
}
|
|
|
this.pointerDownPos = null
|
|
|
}
|
|
@@ -372,7 +368,7 @@ Viewer.prototype.checkIntersection = function () {
|
|
|
|
|
|
|
|
|
Viewer.prototype.removeAllLabels = function (data) {
|
|
|
- this.labels.forEach(label=>{
|
|
|
+ this.labels.forEach(label => {
|
|
|
label.dispose()
|
|
|
label = null
|
|
|
})
|
|
@@ -380,7 +376,7 @@ Viewer.prototype.removeAllLabels = function (data) {
|
|
|
}
|
|
|
|
|
|
Viewer.prototype.loadLabelsFromData = function (data) {
|
|
|
-
|
|
|
+
|
|
|
data.forEach(info => {
|
|
|
info.position = new THREE.Vector3().fromArray(info.posInModel).applyMatrix4(this.model.matrixWorld)
|
|
|
this.addLabel(info)
|