Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cesium_dev_kit

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cesium_dev_kit - npm Package Compare versions

Comparing version 1.0.4 to 1.0.41

66

dist/index.js

@@ -9,3 +9,5 @@ "use strict";

var _libs = require("./libs");
let Cesium = null;
var alternateCesium = _interopRequireWildcard(require("cesium"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const prototypeExtends = function (viewer, cesiumGlobal) {

@@ -39,6 +41,54 @@ function _inner(parents, children) {

};
function initCesium(cesiumGlobal, containerId, BaseMapConfig, MapImageryList = []) {
Cesium = cesiumGlobal;
/**
* 初始化入口函数
* @param {*} param0
* {
* cesiumGlobal:{Object} ceiusm全局对象
* containerId:{String} 容器id
* viewerConfig:{Object} viewer基础配置
* 【参数格式】:{与官网一致}
* extreaConfig:{Object }
* 【参数格式】:
* {
* initNavigate:true,指南针,
* logo:true,// 是否显示logo
* depthTest:true, //开启深度检测
* }
* MapImageryList:{Array} 配置底图,每一个元素格式为
* 【参数格式】 :
* [{
* id: 3,
name: '',
type: '',//ImageryProvider类型
classConfig: {
url: 链接地址
},
interfaceConfig: {},
offset: '0,0',
invertswitch: 0,
filterRGB: '#ffffff',
showswitch: 1,
weight: 13,
createtime: 创建时间
updatetime: 更新时间,
}]
*
* }
* @returns
*/
function initCesium({
cesiumGlobal = alternateCesium,
containerId,
viewerConfig = {},
extreaConfig = {},
MapImageryList = []
}) {
const initCom = new _initConf.Controller(cesiumGlobal);
const _viewer = initCom.init(containerId, BaseMapConfig, MapImageryList);
const _viewer = initCom.init({
containerId,
viewerConfig,
extreaConfig,
MapImageryList
});

@@ -59,2 +109,5 @@ // 合并对象,实现继承

const _analysis = protoExtends([_libs.Base, _libs.Draw, _libs.Plugin], _libs.Analysis);
const _attackArrowObj = new _libs.AttackArrow(_viewer, cesiumGlobal);
const _straightArrowObj = new _libs.StraightArrow(_viewer, cesiumGlobal);
const _pincerArrowObj = new _libs.PincerArrow(_viewer, cesiumGlobal);
return {

@@ -72,4 +125,7 @@ viewer: _viewer,

base: _base,
analysis: _analysis
analysis: _analysis,
attackArrowObj: _attackArrowObj,
straightArrowObj: _straightArrowObj,
pincerArrowObj: _pincerArrowObj
};
}

15

dist/initConf.js

@@ -21,3 +21,8 @@ "use strict";

}
init(containerId, BaseMapConfig, MapImageryList = []) {
init({
containerId,
viewerConfig,
extreaConfig,
MapImageryList
}) {
const mapID = containerId;

@@ -67,5 +72,5 @@ let imageryProviderConfig = new Cesium.SingleTileImageryProvider({

vConfig = Object.assign(vConfig, BaseMapConfig); // 后台接口配置 融合替换 默认配置
vConfig = Object.assign(vConfig, viewerConfig); // 后台接口配置 融合替换 默认配置
const viewer = new Cesium.Viewer(mapID, vConfig);
if (!BaseMapConfig['logo']) {
if (!extreaConfig['logo']) {
const cC = viewer.cesiumWidget.creditContainer;

@@ -76,3 +81,3 @@ cC.style.display = 'none'; // 影藏logo

// 是否开启深度参数
if (BaseMapConfig['depthTest']) {
if (extreaConfig['depthTest']) {
// 设置开启深度检测

@@ -86,3 +91,3 @@ viewer.scene.globe.depthTestAgainstTerrain = true;

// 是否需要 初始化 cesium-navigation 控件
if (BaseMapConfig['initNavigate']) {
if (extreaConfig['initNavigate']) {
this.initCesiumNavigation(viewer);

@@ -89,0 +94,0 @@ }

@@ -941,7 +941,11 @@ "use strict";

},
removeHandler() {
this._viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
this._viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
this._viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
/**
*
* @param {*} eventNameArr handler名称数组,如['LEFT_CLICK','MOUSE_MOVE']
*/
removeHandlerByName(eventNameArr = []) {
eventNameArr.forEach(eHandler => {
this._viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType[eHandler]);
});
}
};

@@ -11,2 +11,7 @@ "use strict";

let Cesium = null;
let currManualFlag = {};
let pickedObject;
let dragEntity;
let mode = 'move';
let _global_viewer = null;
/**

@@ -19,2 +24,3 @@ * 控件模块

this._viewer = viewer;
_global_viewer = viewer;
Cesium = cesiumGlobal;

@@ -340,4 +346,5 @@ this._installFileDragDropHandler();

*/
showPrimitiveMatrixPanel(primitives) {
let primitive = primitives._delegate || primitives,
showPrimitiveMatrixPanel(param) {
let primitive = param.primitives._delegate || param.primitives,
primitives = param.primitives,
// 全局定义

@@ -347,7 +354,7 @@ viewer = this._viewer;

// eslint-disable-next-line no-unused-vars
const update3dtilesMaxtrix = function (params) {
const update3dtilesMaxtrix = function (currParam) {
//旋转
let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));
let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));
let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));
let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(currParam.rx));
let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(currParam.ry));
let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(currParam.rz));
let rotationX = Cesium.Matrix4.fromRotationTranslation(mx);

@@ -357,3 +364,3 @@ let rotationY = Cesium.Matrix4.fromRotationTranslation(my);

//平移
let position = Cesium.Cartesian3.fromDegrees(params.tx, params.ty, params.tz);
let position = Cesium.Cartesian3.fromDegrees(currParam.tx, currParam.ty, currParam.tz);
let m = Cesium.Transforms.eastNorthUpToFixedFrame(position);

@@ -370,4 +377,20 @@ let scale = Cesium.Matrix4.fromUniformScale(0.85);

};
let gui = new dat.GUI();
let gui = null;
if (param && param.elementId) {
gui = new dat.GUI({
autoPlace: false
});
var customContainer = document.getElementById(param.elementId);
customContainer.appendChild(gui.domElement);
} else {
gui = new dat.GUI();
}
/* Here is the update */
var resetSliders = function (name, val) {
for (var i = 0; i < gui.__controllers.length; i++) {
if (!gui.__controllers.property == name) {
gui.__controllers[i].setValue(val);
}
}
};
//高度

@@ -538,2 +561,17 @@ let heightMatrix = {

rotation.open();
if (param.cb) {
let getModelInfo = gui.addFolder('获取调整后的模型矩阵');
getModelInfo.add({
'getModelMaterix': () => {
primitive.readyPromise.then(data => {
let modelTransformMatrix = data.root.transform;
param.cb({
modelTransformMatrix,
modelMatrix: primitives.modelMatrix
});
});
}
}, 'getModelMaterix').name('获取模型矩阵');
getModelInfo.open();
}
gui.__closeButton.innerHTML = '收缩面板';

@@ -751,5 +789,16 @@ },

*/
showEntityOrientationEditPanel: function (Entity) {
if (Entity) {
showEntityOrientationEditPanel: function (param = {}) {
if (param.entity) {
let Entity = param.entity;
var gui = new dat.GUI();
// 修改gui原本的位置,如果提供绑定的父元素id<elementId>就将gui domEmelemt append到对应的dom
if (param && param.elementId) {
gui = new dat.GUI({
autoPlace: false
});
var customContainer = document.getElementById(param.elementId);
customContainer.appendChild(gui.domElement);
} else {
gui = new dat.GUI();
}
var OrientationObj = new function () {

@@ -764,15 +813,144 @@ this.heading = 360;

OrientationObj.heading = value;
Entity.orientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
let changeOrientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
Entity.orientation = changeOrientation;
param.cb && param.cb({
orientation: changeOrientation
});
});
Orientation.add(OrientationObj, 'pitch', 0, 360, 1).name('航向').onChange(function (value) {
OrientationObj.pitch = value;
Entity.orientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
let changeOrientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
Entity.orientation = changeOrientation;
param.cb && param.cb({
orientation: changeOrientation
});
});
Orientation.add(OrientationObj, 'roll', 0, 360, 1).name('翻转').onChange(function (value) {
OrientationObj.roll = value;
Entity.orientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
let changeOrientation = Cesium.Transforms.headingPitchRollQuaternion(Entity.position.getValue($this._viewer.clock.currentTime), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(OrientationObj.heading), Cesium.Math.toRadians(OrientationObj.pitch), Cesium.Math.toRadians(OrientationObj.roll)));
Entity.orientation = changeOrientation;
param.cb && param.cb({
orientation: changeOrientation
});
});
Orientation.open();
}
},
/**
* 定义事件
*/
definedMouseEvent({
targetEntity,
ctrlFlag
}) {
dragEntity = targetEntity;
currManualFlag = ctrlFlag;
this.bindHandelEvent({
leftDown: this.defLeftDown,
mouseMove: this.defMouseMove,
mouseWheel: this.defMouseWheel,
leftUp: this.defLeftUp
});
},
defMouseMove(movement) {
if (currManualFlag.leftDown && pickedObject) {
//鼠标在场景中移动的位置
let ray = _global_viewer.camera.getPickRay(movement.endPosition);
//鼠标在移动过程中与三维场景中移动的坐标位置
let cartesian = _global_viewer.scene.globe.pick(ray, _global_viewer.scene);
//改变鼠标样式
document.body.style.cursor = 'pointer';
if (pickedObject && pickedObject.id && mode === "move") {
//获取到物体当前的位置
let currentTime = Cesium.JulianDate.fromDate(new Date());
let positionC3 = dragEntity.position.getValue(currentTime);
let catographic = Cesium.Cartographic.fromCartesian(positionC3);
let height = Number(catographic.height.toFixed(3));
//动态回调改变物体的位置
dragEntity.position = new Cesium.CallbackProperty(() => {
let cartographic = _global_viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
let longitude = Cesium.Math.toDegrees(cartographic.longitude);
let latitude = Cesium.Math.toDegrees(cartographic.latitude);
let position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
return position;
}, false);
} else if (pickedObject && pickedObject.id && mode === "rotate") {
let currentTime = Cesium.JulianDate.fromDate(new Date());
let center = dragEntity.position.getValue(currentTime);
//获取鼠标移动起始位置与地球球面求交的开始位置和结束位置
let start = _global_viewer.scene.camera.pickEllipsoid(movement.startPosition);
let end = _global_viewer.scene.camera.pickEllipsoid(movement.endPosition);
//计算旋转轴
const vector2 = Cesium.Cartesian3.subtract(center, end, new Cesium.Cartesian3());
//归一化
const normal = Cesium.Cartesian3.normalize(vector2, new Cesium.Cartesian3());
//计算起始点的旋转角度
let startNormal = Cesium.Cartesian3.subtract(start, center, new Cesium.Cartesian3());
let endNormal = Cesium.Cartesian3.subtract(end, center, new Cesium.Cartesian3());
let angleBetween = Cesium.Cartesian3.angleBetween(startNormal, endNormal);
//旋转因子
const rotate = 100;
//计算出朝向
const quaternion = Cesium.Quaternion.fromAxisAngle(normal, angleBetween * rotate);
dragEntity.orientation = quaternion;
}
}
},
defLeftDown(movement) {
//选中物体
pickedObject = _global_viewer.scene.pick(movement.position);
if (Cesium.defined(pickedObject) && mode) {
//选中
currManualFlag.selected = true;
currManualFlag.leftDown = true;
} else {
currManualFlag.selected = false;
}
},
defMouseWheel(movement) {
if (pickedObject && pickedObject.id && mode === "scale") {
//计算出当前盒子的尺寸
let currentTime = Cesium.JulianDate.fromDate(new Date());
let dimensions = dragEntity.box.dimensions.getValue(currentTime);
//计算缩放因子
let scale = movement > 0 ? 2 : 0.5;
dragEntity.box.dimensions = new Cesium.CallbackProperty(() => {
let cartesian3 = Cesium.Cartesian3.multiplyByScalar(dimensions, scale, new Cesium.Cartesian3());
return cartesian3;
}, false);
}
},
defLeftUp(movement) {
currManualFlag.leftDown = false;
document.body.style.cursor = 'default';
},
/**
* 移动模型
* @param {*} mode
*/
manualMoveModel: function (modifyMode) {
mode = modifyMode;
this._viewer.scene.screenSpaceCameraController.enableRotate = false;
this._viewer.scene.screenSpaceCameraController.enableZoom = true;
},
/**
* 旋转模型
* @param {*} mode
*/
manualRotateModel: function (modifyMode) {
mode = modifyMode;
this._viewer.scene.screenSpaceCameraController.enableRotate = false;
this._viewer.scene.screenSpaceCameraController.enableZoom = true;
},
/**
* 缩放模型
* @param {*} mode
*/
manualScaleModel: function (modifyMode) {
mode = modifyMode;
this._viewer.scene.screenSpaceCameraController.enableZoom = false;
}
};

@@ -12,2 +12,8 @@ "use strict";

});
Object.defineProperty(exports, "AttackArrow", {
enumerable: true,
get: function () {
return _AttackArrow.AttackArrow;
}
});
Object.defineProperty(exports, "Base", {

@@ -67,2 +73,8 @@ enumerable: true,

});
Object.defineProperty(exports, "PincerArrow", {
enumerable: true,
get: function () {
return _PincerArrow.PincerArrow;
}
});
Object.defineProperty(exports, "Plugin", {

@@ -86,2 +98,8 @@ enumerable: true,

});
Object.defineProperty(exports, "StraightArrow", {
enumerable: true,
get: function () {
return _StraightArrow.StraightArrow;
}
});
var _Graphics = require("./Graphics");

@@ -99,2 +117,5 @@ var _Material = require("./Material");

var _Plugin = require("./Plugin");
var _Analysis = require("./Analysis");
var _Analysis = require("./Analysis");
var _AttackArrow = require("./plot/AttackArrow");
var _StraightArrow = require("./plot/StraightArrow");
var _PincerArrow = require("./plot/PincerArrow");
{
"name": "cesium_dev_kit",
"version": "1.0.4",
"version": "1.0.41",
"description": "本项目是一个封装 Cesium 基本操作的工具包,提供简单的方法调用来实现复杂的 API 操作;节省阅读 Cesium 原文档时间,从而降低入门难度增加学习信心,同时也希望能提高工作效率",

@@ -24,6 +24,9 @@ "main": "index.js",

"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4"
"cesium": "1.84.0",
"dat.gui": "^0.7.9",
"echarts": "4.2.1",
"libgif": "0.0.3",
"@turf/turf": "^6.5.0",
"concaveman": "^1.1.1"
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc