使用a标签的 click 事件以及 URL.createObjectURL 方法
适合小文件的下载(无后端)
const buffer = new Float32Array([1, 2, 3, 4, 5]) // 创建一个类型数组,大小为 20 bytes
// 创建 blob 对象,第一个参数可以放置多个变量,这里放一个就好了
const blob = new Blob([buffer], {
type: "application/octet-stream"| /** | |
| * Need Cesium.js 1.7x environment. | |
| */ | |
| var viewer = new Cesium.Viewer("cesiumContainer"); | |
| viewer.scene.globe.depthTestAgainstTerrain = true; | |
| viewer.camera.setView({ | |
| destination : new Cesium.Cartesian3(-2644963.9889313546, 5763731.142118295, 2199400.7089496767), //世界坐标系下的一个坐标点 | |
| orientation : {//旋转角度 | |
| heading :6.075, |
| /** | |
| * @description 需要 Cesium.js 环境 | |
| */ | |
| const viewer = new Cesium.Viewer("cesiumContainer"); | |
| viewer.scene.globe.depthTestAgainstTerrain = true; | |
| const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); | |
| handler.setInputAction(function(click){ | |
| const cart = viewer.scene.pickPosition(click.position); |
| vec4 czm_computePosition() | |
| { | |
| vec4 p; | |
| if (czm_morphTime == 1.0) | |
| { | |
| p = czm_translateRelativeToEye(position3DHigh, position3DLow); | |
| } | |
| else if (czm_morphTime == 0.0) | |
| { | |
| p = czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy); |
| /** | |
| * 计算双线性内插点的值 | |
| * @param {Point} pt 目标点位 | |
| * @param {Point} p1 左上 | |
| * @param {Point} p2 右上 | |
| * @param {Point} p3 左下 | |
| * @param {Point} p4 右下 | |
| * | |
| * @returns {Number} pt的插值结果 | |
| */ |
| /** | |
| * 将矩阵(二维数组形式)转置的高效方法 | |
| * @param {Array[][]} arr 二维数组,子数组中元素个数应一致 | |
| */ | |
| export function transpose(arr) { | |
| return arr[0].map((_, i) => arr.map(row => row[i])) | |
| } |
| import Matrix2 from '../core/mat2.js' | |
| import Matrix3, { transpose, multiply, } from '../core/mat3.js' | |
| /** | |
| * 雅可比迭代法求解实对称矩阵的特征向量、特征值 | |
| * @param {Matrix2 | Matrix3} matrix 二维数组,当前支持二维、三维迭代求解 | |
| * @returns {Object} 返回一个对象 obj, obj.eigenVectors 是特征向量(二维数组),obj.eigenValues 是特征值(一维数组) | |
| */ | |
| function jacobi(matrix) { | |
| const length = matrix.length === undefined ? matrix.dimensions : matrix.length |
| import localForage from 'localforage' | |
| // 创建仓库对象,并创建名为 “test” 的 indexeddb 以及 名为 “testidb” 的表 | |
| const store = localForage.createInstance({ | |
| driver: localForage.INDEXEDDB, | |
| name: "test", | |
| storeName: "testidb" | |
| }) | |
| // 设置 key-value |
| function friendlyFileSize(sizeInBytes) { | |
| if(sizeInBytes < 1024) { | |
| return `${sizeInBytes} Bytes`; | |
| } else if(sizeInBytes >= 1024 && sizeInBytes < 1048576) { | |
| return `${(sizeInBytes/1024).toFixed(2)} KB`; | |
| } else if(sizeInBytes >= 1048576) { | |
| return `${(sizeInBytes/1048576).toFixed(2)} MB`; | |
| } | |
| } |
| function main() { | |
| let last = 0 | |
| // 上次渲染的值(此处初始化为一个整数) | |
| let lastState = Math.floor(Math.random() * 10) | |
| const canWeRender = function() { | |
| // 这次渲染的值 | |
| const currentState = Math.floor(Math.random() * 10) | |
| // 比较二者是否一致,如果一致,则false,否则true | |
| if (currentState === lastState) { | |
| console.log("lastState eq. currentState. Will not render.") |