From 0de0c63175ba63fd7f7fcec97d65124fb3b455dd Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Sat, 19 Jun 2021 17:57:42 +0800
Subject: [PATCH] 创建实体调整

---
 widgets/modelDiagram/Widget.js |  344 ++++++++++-----------------------------------------------
 1 files changed, 61 insertions(+), 283 deletions(-)

diff --git a/widgets/modelDiagram/Widget.js b/widgets/modelDiagram/Widget.js
index d2cca48..998e536 100644
--- a/widgets/modelDiagram/Widget.js
+++ b/widgets/modelDiagram/Widget.js
@@ -33,306 +33,61 @@
 				// that.beginModelDiagram();
 				// that.beginCesium();
 
-				$('.seemodo').click(() => {
-					that.seemodo();
+				// 三个按钮事件
+				$('.jimu-widget-modelDiagram').find('.once').click(() => {
+					that.once();
 				})
-
-				$('.closemodo').click(() => {
-					that.closeModo();
+				$('.jimu-widget-modelDiagram').find('.always').click(() => {
+					that.always();
 				})
-				$('.beginPlay').click(() => {
-					that.beginPlay();
-				})
-				$('.stopPlay').click(() => {
+				$('.jimu-widget-modelDiagram').find('.stopPlay').click(() => {
 					that.stopPlay();
 				})
-				$('.closesmodelDiagram').click(() => {
-					console.log(3423)
-					$('.jimu-widget-modelDiagram').hide();
-					if (that.openEntity) {
-						that.map.entities.removeAll();
+
+				$('.jimu-widget-modelDiagram').find('.always').unbind("mousedown").bind("mousedown", function (event) {
+					if (event.which == 3) {
+						// console.log('you');
+						that.getInput();
+						var as = that.a - 0.00004
+							, bs = that.b - 0.00004;
+						for (var i = 1; i <= 7; i++) {
+							var aa = as * 100000;
+							aa += i;
+							aa = aa / 100000;
+							for (var n = 1; n <= 6; n++) {
+								var bb = bs * 100000;
+								bb += n;
+								bb = bb / 100000;
+								// console.log(aa,bb)
+								that.always(aa, bb);
+							}
+						}
+
+					} else if (event.which == 1) {
+						// console.log('zuo');
 					}
-				})
+				});
 
 			},
-			beginCesium: function (a = 116.058987, b = 28.973468, g = 1000) {
+			beginCesium: function (a = 116.058987, b = 28.973468, g = 1000, once = 'always') {
 				var viewer = this.map
 					, that = this
 					, url = "./images/gltf/Cesium_Man.glb";
-				// var startPosition = new Cesium.Cartesian3(
-				// 	116.058987,
-				// 	28.973468,
-				// 	1000
-				// );
-				// var endPosition = new Cesium.Cartesian3(
-				// 	116.158987,
-				// 	29.073468,
-				// 	1000
-				// );
-				// var position = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468);
-				//动态 //缺少viewer.timeline时间轴
-				//Make sure viewer is at the desired time.
-				//Make sure viewer is at the desired time.
-				// var start = Cesium.JulianDate.fromDate(new Date(2018, 11, 12, 15));
-				// var totalSeconds = 10;
-				// var stop = Cesium.JulianDate.addSeconds(
-				// 	start,
-				// 	totalSeconds,
-				// 	new Cesium.JulianDate()
-				// );
-				// viewer.clock.startTime = start.clone();
-				// viewer.clock.stopTime = stop.clone();
-				// viewer.clock.currentTime = start.clone();
-				// viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
-				// // console.log(viewer.timeline,111)
-				// viewer.timeline.zoomTo = function (startTime, stopTime) {
-				// 	//>>includeStart('debug', pragmas.debug);
-				// 	if (!defined(startTime)) {
-				// 		throw new DeveloperError("startTime is required.");
-				// 	}
-				// 	if (!defined(stopTime)) {
-				// 		throw new DeveloperError("stopTime is required");
-				// 	}
-				// 	if (JulianDate.lessThanOrEquals(stopTime, startTime)) {
-				// 		throw new DeveloperError("Start time must come before end time.");
-				// 	}
-				// 	//>>includeEnd('debug');
-
-				// 	this._startJulian = startTime;
-				// 	this._endJulian = stopTime;
-				// 	this._timeBarSecondsSpan = JulianDate.secondsDifference(stopTime, startTime);
-
-				// 	// If clock is not unbounded, clamp timeline range to clock.
-				// 	if (this._clock && this._clock.clockRange !== ClockRange$1.UNBOUNDED) {
-				// 		var clockStart = this._clock.startTime;
-				// 		var clockEnd = this._clock.stopTime;
-				// 		var clockSpan = JulianDate.secondsDifference(clockEnd, clockStart);
-				// 		var startOffset = JulianDate.secondsDifference(
-				// 			clockStart,
-				// 			this._startJulian
-				// 		);
-				// 		var endOffset = JulianDate.secondsDifference(clockEnd, this._endJulian);
-
-				// 		if (this._timeBarSecondsSpan >= clockSpan) {
-				// 			// if new duration longer than clock range duration, clamp to full range.
-				// 			this._timeBarSecondsSpan = clockSpan;
-				// 			this._startJulian = this._clock.startTime;
-				// 			this._endJulian = this._clock.stopTime;
-				// 		} else if (startOffset > 0) {
-				// 			// if timeline start is before clock start, shift right
-				// 			this._endJulian = JulianDate.addSeconds(
-				// 				this._endJulian,
-				// 				startOffset,
-				// 				new JulianDate()
-				// 			);
-				// 			this._startJulian = clockStart;
-				// 			this._timeBarSecondsSpan = JulianDate.secondsDifference(
-				// 				this._endJulian,
-				// 				this._startJulian
-				// 			);
-				// 		} else if (endOffset < 0) {
-				// 			// if timeline end is after clock end, shift left
-				// 			this._startJulian = JulianDate.addSeconds(
-				// 				this._startJulian,
-				// 				endOffset,
-				// 				new JulianDate()
-				// 			);
-				// 			this._endJulian = clockEnd;
-				// 			this._timeBarSecondsSpan = JulianDate.secondsDifference(
-				// 				this._endJulian,
-				// 				this._startJulian
-				// 			);
-				// 		}
-				// 	}
-
-				// 	this._makeTics();
-
-				// 	var evt = document.createEvent("Event");
-				// 	evt.initEvent("setzoom", true, true);
-				// 	evt.startJulian = this._startJulian;
-				// 	evt.endJulian = this._endJulian;
-				// 	evt.epochJulian = this._epochJulian;
-				// 	evt.totalSpan = this._timeBarSecondsSpan;
-				// 	evt.mainTicSpan = this._mainTicSpan;
-				// 	this._topDiv.dispatchEvent(evt);
-				// }
-				// viewer.timeline.zoomTo(start, stop);
-
-				// // Create a path for our vehicle by lerping between two positions.
-				// var position = new Cesium.SampledPositionProperty();
-				// var startPosition = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468, 1000);
-				// var endPosition = Cesium.Cartesian3.fromDegrees(116.158987, 29.073468, 1000);
-				// // var startPosition = new Cesium.Cartesian3(
-				// // 	-2379556.799372864,
-				// // 	-4665528.205030263,
-				// // 	3628013.106599678
-				// // );
-				// // var endPosition = new Cesium.Cartesian3(
-				// // 	-2379603.7074103747,
-				// // 	-4665623.48990283,
-				// // 	3627860.82704567
-				// // );
-				// // A velocity vector property will give us the entity's speed and direction at any given time.
-				// var velocityVectorProperty = new Cesium.VelocityVectorProperty(
-				// 	position,
-				// 	false
-				// );
-				// var velocityVector = new Cesium.Cartesian3();
-				// // Store the wheel's rotation over time in a SampledProperty.
-				// var wheelAngleProperty = new Cesium.SampledProperty(Number);
-				// var wheelAngle = 0;
-
-				// var numberOfSamples = 100;
-				// for (var i = 0; i <= numberOfSamples; ++i) {
-				// 	var factor = i / numberOfSamples;
-				// 	var time = Cesium.JulianDate.addSeconds(
-				// 		start,
-				// 		factor * totalSeconds,
-				// 		new Cesium.JulianDate()
-				// 	);
-
-				// 	// Lerp using a non-linear factor so that the vehicle accelerates.
-				// 	var locationFactor = Math.pow(factor, 2);
-				// 	var location = Cesium.Cartesian3.lerp(
-				// 		startPosition,
-				// 		endPosition,
-				// 		locationFactor,
-				// 		new Cesium.Cartesian3()
-				// 	);
-				// 	position.addSample(time, location);
-				// 	// Rotate the wheels based on how fast the vehicle is moving at each timestep.
-				// 	velocityVectorProperty.getValue(time, velocityVector);
-				// 	var metersPerSecond = Cesium.Cartesian3.magnitude(velocityVector);
-				// 	var wheelRadius = 0.52; //in meters.
-				// 	var circumference = Math.PI * wheelRadius * 2;
-				// 	var rotationsPerSecond = metersPerSecond / circumference;
-
-				// 	wheelAngle +=
-				// 		((Math.PI * 2 * totalSeconds) / numberOfSamples) *
-				// 		rotationsPerSecond;
-				// 	wheelAngleProperty.addSample(time, wheelAngle);
-				// }
-
-				// function updateSpeedLabel(time, result) {
-				// 	velocityVectorProperty.getValue(time, velocityVector);
-				// 	var metersPerSecond = Cesium.Cartesian3.magnitude(velocityVector);
-				// 	var kmPerHour = Math.round(metersPerSecond * 3.6);
-
-				// 	return kmPerHour + " km/hr";
-				// }
-
-				// var rotationProperty = new Cesium.CallbackProperty(function (
-				// 	time,
-				// 	result
-				// ) {
-				// 	return Cesium.Quaternion.fromAxisAngle(
-				// 		Cesium.Cartesian3.UNIT_X,
-				// 		wheelAngleProperty.getValue(time),
-				// 		result
-				// 	);
-				// },
-				// 	false);
-
-				// var wheelTransformation = new Cesium.NodeTransformationProperty({
-				// 	rotation: rotationProperty,
-				// });
-
-				// var nodeTransformations = {
-				// 	Wheels: wheelTransformation,
-				// 	Wheels_mid: wheelTransformation,
-				// 	Wheels_rear: wheelTransformation,
-				// };
-
-				// // Add our vehicle model.
-				// var vehicleEntity = viewer.entities.add({
-				// 	position: position,
-				// 	orientation: new Cesium.VelocityOrientationProperty(position), // Automatically set the vehicle's orientation to the direction it's facing.
-				// 	model: {
-				// 		uri: url,
-				// 		runAnimations: false,
-				// 		nodeTransformations: nodeTransformations,
-				// 	},
-				// 	label: {
-				// 		text: new Cesium.CallbackProperty(updateSpeedLabel, false),
-				// 		font: "20px sans-serif",
-				// 		showBackground: true,
-				// 		distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
-				// 			0.0,
-				// 			100.0
-				// 		),
-				// 		eyeOffset: new Cesium.Cartesian3(0, 3.5, 0),
-				// 	},
-				// });
-
-				// viewer.trackedEntity = vehicleEntity;
-				// vehicleEntity.viewFrom = new Cesium.Cartesian3(-10.0, 7.0, 4.0);
 
 				//静态
 				// var position = Cesium.Cartesian3.fromDegrees(116.058987, 28.973468, 1000);
 				var position = Cesium.Cartesian3.fromDegrees(a, b, g);
-				viewer.trackedEntity = viewer.entities.add({//viewer.trackedEntity跟随
+				that.entityPeople = viewer.entities.add({//viewer.trackedEntity跟随
 					name: url,
 					position: position,
 					model: {
 						uri: url,
 					},
 				});
-				that.entityPeople = viewer.trackedEntity;
+				if (once == 'once') {
+					viewer.trackedEntity = that.entityPeople;
+				}
 
-				// var viewModel = {// 以下是工具栏
-				// 	blackAndWhiteShow: false,
-				// 	blackAndWhiteGradations: 5.0,
-				// 	brightnessShow: false,
-				// 	brightnessValue: 0.5,
-				// 	nightVisionShow: false,
-				// 	silhouette: false,
-				// };
-
-				// Cesium.knockout.track(viewModel);
-				// var toolbar = document.getElementById("toolbarcesium");
-				// Cesium.knockout.applyBindings(viewModel, toolbar);
-				// for (var name in viewModel) {
-				// 	if (viewModel.hasOwnProperty(name)) {
-				// 		Cesium.knockout
-				// 			.getObservable(viewModel, name)
-				// 			.subscribe(updatePostProcess);
-				// 	}
-				// }
-
-				// if (
-				// 	!Cesium.PostProcessStageLibrary.isSilhouetteSupported(viewer.scene)
-				// ) {
-				// 	window.alert(
-				// 		"This browser does not support the silhouette post process."
-				// 	);
-				// }
-
-				// var stages = viewer.scene.postProcessStages;
-				// var silhouette = stages.add(
-				// 	Cesium.PostProcessStageLibrary.createSilhouetteStage()
-				// );
-				// var blackAndWhite = stages.add(
-				// 	Cesium.PostProcessStageLibrary.createBlackAndWhiteStage()
-				// );
-				// var brightness = stages.add(
-				// 	Cesium.PostProcessStageLibrary.createBrightnessStage()
-				// );
-				// var nightVision = stages.add(
-				// 	Cesium.PostProcessStageLibrary.createNightVisionStage()
-				// );
-
-				// function updatePostProcess() {
-				// 	silhouette.enabled = Boolean(viewModel.silhouette);
-				// 	silhouette.uniforms.color = Cesium.Color.YELLOW;
-				// 	blackAndWhite.enabled = Boolean(viewModel.blackAndWhiteShow);
-				// 	blackAndWhite.uniforms.gradations = Number(
-				// 		viewModel.blackAndWhiteGradations
-				// 	);
-				// 	brightness.enabled = Boolean(viewModel.brightnessShow);
-				// 	brightness.uniforms.brightness = Number(viewModel.brightnessValue);
-				// 	nightVision.enabled = Boolean(viewModel.nightVisionShow);
-				// }
-				// updatePostProcess();
 
 			},
 			entityPeople: '',
@@ -362,7 +117,7 @@
 			},
 			stopPlay: function () {
 				this.map.entities.removeAll();
-				clearInterval(this.time);
+				// clearInterval(this.time);
 			},
 			seemodo: function () {
 				var that = this;
@@ -376,15 +131,38 @@
 				// console.log('seedom')
 				// this.map.entities.remove(this.entityPeople)//删除entity
 			},
+			getInput: function () {
+				this.a = $('#modelDiagramjdu').val() == '' ? 116.058987 : +$('#modelDiagramjdu').val();
+				this.b = $('#modelDiagramwdu').val() == '' ? 28.973468 : +$('#modelDiagramwdu').val();
+				this.g = $('#modelDiagramgdu').val() == '' ? 1000 : +$('#modelDiagramgdu').val();
+			},
+			a: '',
+			b: '',
+			g: '',
+			//重复添加
+			always: function (aa = 'a', bb = 'b') {
+				this.getInput();
+				// console.log([a, b, g])
+				if (aa != 'a' && bb != 'b') {
+					this.beginCesium(aa, bb, this.g);
+				} else {
+					this.beginCesium(this.a, this.b, this.g);
+				}
+			},
+			//单次添加
+			once: function () {
+				this.stopPlay();
+				this.getInput();
+				// console.log([a, b, g])
+				this.beginCesium(this.a, this.b, this.g, 'once');
+			},
 			closeModo: function () {
 				if (this.openEntity) {
 					// this.map.entities.remove(this.entityPeople)//删除entity
 					// this.map.entities.remove(this.map.trackedEntity)//删除entity
 					this.map.entities.removeAll();
 				} else {
-					var a = $('#modelDiagramjdu').val() == '' ? 116.058987 : +$('#modelDiagramjdu').val();
-					var b = $('#modelDiagramwdu').val() == '' ? 28.973468 : +$('#modelDiagramwdu').val();
-					var g = $('#modelDiagramgdu').val() == '' ? 1000 : +$('#modelDiagramgdu').val();
+					this.getInput
 					// console.log([a, b, g])
 					this.beginCesium(a, b, g);
 				}

--
Gitblit v1.9.3