Compare commits
12 Commits
d503e64098
...
ljj
Author | SHA1 | Date | |
---|---|---|---|
fe872490d5 | |||
7154bbbbcc | |||
760b707116 | |||
e60c435fa6 | |||
86afe6a30d | |||
3ff2728466 | |||
3d5a77b732 | |||
496adee0b4 | |||
78c13c4131 | |||
c069b53636 | |||
7e7e51853d | |||
b01d143ea6 |
@ -5,7 +5,10 @@ VITE_APP_TITLE = 新能源项目管理平台
|
||||
VITE_APP_ENV = 'development'
|
||||
|
||||
# 开发环境
|
||||
VITE_APP_BASE_API = 'http://192.168.110.119:8899'
|
||||
# VITE_APP_BASE_API = 'http://192.168.110.119:8899'
|
||||
VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
# GO开发环境
|
||||
VITE_APP_BASE_API_GO = 'http://58.17.134.85:8919'
|
||||
|
||||
# 无人机接口地址
|
||||
|
||||
|
@ -15,6 +15,8 @@ VITE_APP_SNAILJOB_ADMIN = '/snail-job'
|
||||
|
||||
# 生产环境
|
||||
VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
# GO生产环境
|
||||
VITE_APP_BASE_API_GO = 'http://58.17.134.85:7363'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
@ -216,8 +216,8 @@
|
||||
<script src="/webrtc/jquery-1.12.2.min.js"></script>
|
||||
<script src="/webrtc/srs.sdk.js"></script>
|
||||
|
||||
<script src="./src/assets/sdk/YJEarth.min.js"></script>
|
||||
<script src="./src/utils/reconnecting-websocket.js"></script>
|
||||
<script src="/sdk/YJEarth.min.js"></script>
|
||||
<script src="/js/reconnecting-websocket.js"></script>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -14,7 +14,7 @@
|
||||
"lint:eslint": "eslint",
|
||||
"lint:eslint:fix": "eslint --fix",
|
||||
"prettier": "prettier --write .",
|
||||
"copy-cesium": "cpy 'src/assets/sdk/Cesium/{Workers,Assets,Widgets}' ./public/Cesium --flat --parents"
|
||||
"copy-cesium": "cpy './public/sdk/Cesium/{Workers,Assets,Widgets}' ./public/Cesium --flat --parents"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
19
public/js/YJEarth.min.js
vendored
Normal file
382
public/js/reconnecting-websocket.js
Normal file
@ -0,0 +1,382 @@
|
||||
// MIT License:
|
||||
//
|
||||
// Copyright (c) 2010-2012, Joe Walnes
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* This behaves like a WebSocket in every way, except if it fails to connect,
|
||||
* or it gets disconnected, it will repeatedly poll until it successfully connects
|
||||
* again.
|
||||
*
|
||||
* It is API compatible, so when you have:
|
||||
* ws = new WebSocket('ws://....');
|
||||
* you can replace with:
|
||||
* ws = new ReconnectingWebSocket('ws://....');
|
||||
*
|
||||
* The event stream will typically look like:
|
||||
* onconnecting
|
||||
* onopen
|
||||
* onmessage
|
||||
* onmessage
|
||||
* onclose // lost connection
|
||||
* onconnecting
|
||||
* onopen // sometime later...
|
||||
* onmessage
|
||||
* onmessage
|
||||
* etc...
|
||||
*
|
||||
* It is API compatible with the standard WebSocket API, apart from the following members:
|
||||
*
|
||||
* - `bufferedAmount`
|
||||
* - `extensions`
|
||||
* - `binaryType`
|
||||
*
|
||||
* Latest version: https://github.com/joewalnes/reconnecting-websocket/
|
||||
* - Joe Walnes
|
||||
*
|
||||
* Syntax
|
||||
* ======
|
||||
* var socket = new ReconnectingWebSocket(url, protocols, options);
|
||||
*
|
||||
* Parameters
|
||||
* ==========
|
||||
* url - The url you are connecting to.
|
||||
* protocols - Optional string or array of protocols.
|
||||
* options - See below
|
||||
*
|
||||
* Options
|
||||
* =======
|
||||
* Options can either be passed upon instantiation or set after instantiation:
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url);
|
||||
* socket.debug = true;
|
||||
* socket.reconnectInterval = 4000;
|
||||
*
|
||||
* debug
|
||||
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
|
||||
*
|
||||
* automaticOpen
|
||||
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
|
||||
*
|
||||
* reconnectInterval
|
||||
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
|
||||
*
|
||||
* maxReconnectInterval
|
||||
* - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
|
||||
*
|
||||
* reconnectDecay
|
||||
* - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
|
||||
*
|
||||
* timeoutInterval
|
||||
* - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
|
||||
*
|
||||
*/
|
||||
// (function (global, factory) {
|
||||
// if (typeof define === 'function' && define.amd) {
|
||||
// define([], factory);
|
||||
// } else if (typeof module !== 'undefined' && module.exports){
|
||||
// module.exports = factory();
|
||||
// } else {
|
||||
// global.ReconnectingWebSocket = factory();
|
||||
// }
|
||||
// })(this, function () {
|
||||
//
|
||||
// if (!('WebSocket' in window)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
function ReconnectingWebSocket(url, protocols, options) {
|
||||
|
||||
// Default settings
|
||||
var settings = {
|
||||
|
||||
/** Whether this instance should log debug messages. */
|
||||
debug: false,
|
||||
|
||||
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
|
||||
automaticOpen: true,
|
||||
|
||||
/** The number of milliseconds to delay before attempting to reconnect. */
|
||||
reconnectInterval: 1000,
|
||||
/** The maximum number of milliseconds to delay a reconnection attempt. */
|
||||
maxReconnectInterval: 30000,
|
||||
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
|
||||
reconnectDecay: 1.5,
|
||||
|
||||
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
|
||||
timeoutInterval: 2000,
|
||||
|
||||
/** The maximum number of reconnection attempts to make. Unlimited if null. */
|
||||
maxReconnectAttempts: null,
|
||||
|
||||
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
|
||||
binaryType: 'blob'
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
// Overwrite and define settings with options if they exist.
|
||||
for (var key in settings) {
|
||||
if (typeof options[key] !== 'undefined') {
|
||||
this[key] = options[key];
|
||||
} else {
|
||||
this[key] = settings[key];
|
||||
}
|
||||
}
|
||||
|
||||
// These should be treated as read-only properties
|
||||
|
||||
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
|
||||
this.url = url;
|
||||
|
||||
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
/**
|
||||
* The current state of the connection.
|
||||
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
|
||||
* Read only.
|
||||
*/
|
||||
this.readyState = WebSocket.CONNECTING;
|
||||
|
||||
/**
|
||||
* A string indicating the name of the sub-protocol the server selected; this will be one of
|
||||
* the strings specified in the protocols parameter when creating the WebSocket object.
|
||||
* Read only.
|
||||
*/
|
||||
this.protocol = null;
|
||||
|
||||
// Private state variables
|
||||
|
||||
var self = this;
|
||||
var ws;
|
||||
var forcedClose = false;
|
||||
var timedOut = false;
|
||||
var eventTarget = document.createElement('div');
|
||||
|
||||
// Wire up "on*" properties as event handlers
|
||||
|
||||
eventTarget.addEventListener('open', function (event) {
|
||||
self.onopen(event);
|
||||
});
|
||||
eventTarget.addEventListener('close', function (event) {
|
||||
self.onclose(event);
|
||||
});
|
||||
eventTarget.addEventListener('connecting', function (event) {
|
||||
self.onconnecting(event);
|
||||
});
|
||||
eventTarget.addEventListener('message', function (event) {
|
||||
self.onmessage(event);
|
||||
});
|
||||
eventTarget.addEventListener('error', function (event) {
|
||||
self.onerror(event);
|
||||
});
|
||||
|
||||
// Expose the API required by EventTarget
|
||||
|
||||
this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
|
||||
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
|
||||
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
|
||||
|
||||
/**
|
||||
* This function generates an event that is compatible with standard
|
||||
* compliant browsers and IE9 - IE11
|
||||
*
|
||||
* This will prevent the error:
|
||||
* Object doesn't support this action
|
||||
*
|
||||
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
|
||||
* @param s String The name that the event should use
|
||||
* @param args Object an optional object that the event will use
|
||||
*/
|
||||
function generateEvent(s, args) {
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(s, false, false, args);
|
||||
return evt;
|
||||
};
|
||||
|
||||
this.open = function (reconnectAttempt) {
|
||||
ws = new WebSocket(self.url, protocols || []);
|
||||
ws.binaryType = this.binaryType;
|
||||
|
||||
if (reconnectAttempt) {
|
||||
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eventTarget.dispatchEvent(generateEvent('connecting'));
|
||||
this.reconnectAttempts = 0;
|
||||
}
|
||||
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
|
||||
}
|
||||
|
||||
var localWs = ws;
|
||||
var timeout = setTimeout(function () {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
|
||||
}
|
||||
timedOut = true;
|
||||
localWs.close();
|
||||
timedOut = false;
|
||||
}, self.timeoutInterval);
|
||||
|
||||
ws.onopen = function (event) {
|
||||
clearTimeout(timeout);
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onopen', self.url);
|
||||
}
|
||||
self.protocol = ws.protocol;
|
||||
self.readyState = WebSocket.OPEN;
|
||||
self.reconnectAttempts = 0;
|
||||
var e = generateEvent('open');
|
||||
e.isReconnect = reconnectAttempt;
|
||||
reconnectAttempt = false;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
clearTimeout(timeout);
|
||||
ws = null;
|
||||
if (forcedClose) {
|
||||
self.readyState = WebSocket.CLOSED;
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
} else {
|
||||
self.readyState = WebSocket.CONNECTING;
|
||||
var e = generateEvent('connecting');
|
||||
e.code = event.code;
|
||||
e.reason = event.reason;
|
||||
e.wasClean = event.wasClean;
|
||||
eventTarget.dispatchEvent(e);
|
||||
if (!reconnectAttempt && !timedOut) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onclose', self.url);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
}
|
||||
|
||||
var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
|
||||
setTimeout(function () {
|
||||
self.reconnectAttempts++;
|
||||
self.open(true);
|
||||
}, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
|
||||
}
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
|
||||
}
|
||||
var e = generateEvent('message');
|
||||
e.data = event.data;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
ws.onerror = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('error'));
|
||||
};
|
||||
}
|
||||
|
||||
// Whether or not to create a websocket upon instantiation
|
||||
if (this.automaticOpen == true) {
|
||||
this.open(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits data to the server over the WebSocket connection.
|
||||
*
|
||||
* @param data a text string, ArrayBuffer or Blob to send to the server.
|
||||
*/
|
||||
this.send = function (data) {
|
||||
if (ws) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'send', self.url, data);
|
||||
}
|
||||
return ws.send(data);
|
||||
} else {
|
||||
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the WebSocket connection or connection attempt, if any.
|
||||
* If the connection is already CLOSED, this method does nothing.
|
||||
*/
|
||||
this.close = function (code, reason) {
|
||||
// Default CLOSE_NORMAL code
|
||||
if (typeof code == 'undefined') {
|
||||
code = 1000;
|
||||
}
|
||||
forcedClose = true;
|
||||
if (ws) {
|
||||
ws.close(code, reason);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional public API method to refresh the connection if still open (close, re-open).
|
||||
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
|
||||
*/
|
||||
this.refresh = function () {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
||||
* this indicates that the connection is ready to send and receive data.
|
||||
*/
|
||||
ReconnectingWebSocket.prototype.onopen = function (event) {
|
||||
};
|
||||
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
|
||||
ReconnectingWebSocket.prototype.onclose = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a connection begins being attempted. */
|
||||
ReconnectingWebSocket.prototype.onconnecting = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a message is received from the server. */
|
||||
ReconnectingWebSocket.prototype.onmessage = function (event) {
|
||||
};
|
||||
/** An event listener to be called when an error occurs. */
|
||||
ReconnectingWebSocket.prototype.onerror = function (event) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether all instances of ReconnectingWebSocket should log debug messages.
|
||||
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
|
||||
*/
|
||||
ReconnectingWebSocket.debugAll = false;
|
||||
|
||||
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
|
||||
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
|
||||
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
|
||||
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
|
||||
|
||||
// return ReconnectingWebSocket;
|
||||
// });
|
805
public/sdk/3rdparty/CesiumHeatmap.js
vendored
Normal file
@ -0,0 +1,805 @@
|
||||
/*
|
||||
* CesiumHeatmap.js v0.1 | Cesium Heatmap Library
|
||||
*
|
||||
* Works with heatmap.js v2.0.0: http://www.patrick-wied.at/static/heatmapjs/
|
||||
*/
|
||||
(function (window) {
|
||||
'use strict';
|
||||
function define_CesiumHeatmap() {
|
||||
var CesiumHeatmap = {
|
||||
defaults: {
|
||||
useEntitiesIfAvailable: true, //whether to use entities if a Viewer is supplied or always use an ImageryProvider
|
||||
minCanvasSize: 700, // minimum size (in pixels) for the heatmap canvas
|
||||
maxCanvasSize: 2000, // maximum size (in pixels) for the heatmap canvas
|
||||
radiusFactor: 60, // data point size factor used if no radius is given (the greater of height and width divided by this number yields the used radius)
|
||||
spacingFactor: 1.5, // extra space around the borders (point radius multiplied by this number yields the spacing)
|
||||
maxOpacity: 0.8, // the maximum opacity used if not given in the heatmap options object
|
||||
minOpacity: 0.1, // the minimum opacity used if not given in the heatmap options object
|
||||
blur: 0.85, // the blur used if not given in the heatmap options object
|
||||
gradient: { // the gradient used if not given in the heatmap options object
|
||||
'.3': 'blue',
|
||||
'.65': 'yellow',
|
||||
'.8': 'orange',
|
||||
'.95': 'red'
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/* Create a CesiumHeatmap instance
|
||||
*
|
||||
* cesium: the CesiumWidget or Viewer instance
|
||||
* bb: the WGS84 bounding box like {north, east, south, west}
|
||||
* options: a heatmap.js options object (see http://www.patrick-wied.at/static/heatmapjs/docs.html#h337-create)
|
||||
*/
|
||||
CesiumHeatmap.create = function (bb, options) {
|
||||
var instance = new CHInstance(bb, options);
|
||||
return instance;
|
||||
};
|
||||
|
||||
CesiumHeatmap._getContainer = function (width, height, id) {
|
||||
var c = document.createElement("div");
|
||||
if (id) {
|
||||
c.setAttribute("id", id);
|
||||
}
|
||||
c.setAttribute("style", "width: " + width + "px; height: " + height + "px; margin: 0px; display: none;");
|
||||
document.body.appendChild(c);
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(c)
|
||||
}, 500);
|
||||
return c;
|
||||
};
|
||||
|
||||
CesiumHeatmap._getImageryProvider = function (instance) {
|
||||
//var n = (new Date()).getTime();
|
||||
var d = instance._heatmap.getDataURL();
|
||||
//console.log("Create data URL: " + ((new Date()).getTime() - n));
|
||||
|
||||
//var n = (new Date()).getTime();
|
||||
var imgprov = new Cesium.SingleTileImageryProvider({
|
||||
url: d,
|
||||
rectangle: instance._rectangle
|
||||
});
|
||||
//console.log("Create imageryprovider: " + ((new Date()).getTime() - n));
|
||||
|
||||
imgprov._tilingScheme = new Cesium.WebMercatorTilingScheme({
|
||||
rectangleSouthwestInMeters: new Cesium.Cartesian2(instance._mbounds.west, instance._mbounds.south),
|
||||
rectangleNortheastInMeters: new Cesium.Cartesian2(instance._mbounds.east, instance._mbounds.north)
|
||||
});
|
||||
|
||||
return imgprov;
|
||||
};
|
||||
|
||||
CesiumHeatmap._getID = function (len) {
|
||||
var text = "";
|
||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
for (var i = 0; i < ((len) ? len : 8); i++)
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
var WMP = new Cesium.WebMercatorProjection();
|
||||
|
||||
/* Convert a WGS84 location into a mercator location
|
||||
*
|
||||
* p: the WGS84 location like {x: lon, y: lat}
|
||||
*/
|
||||
CesiumHeatmap.wgs84ToMercator = function (p) {
|
||||
var mp = WMP.project(Cesium.Cartographic.fromDegrees(p.x, p.y));
|
||||
return {
|
||||
x: mp.x,
|
||||
y: mp.y
|
||||
};
|
||||
};
|
||||
|
||||
/* Convert a WGS84 bounding box into a mercator bounding box
|
||||
*
|
||||
* bb: the WGS84 bounding box like {north, east, south, west}
|
||||
*/
|
||||
CesiumHeatmap.wgs84ToMercatorBB = function (bb) {
|
||||
var sw = WMP.project(Cesium.Cartographic.fromDegrees(bb.west, bb.south));
|
||||
var ne = WMP.project(Cesium.Cartographic.fromDegrees(bb.east, bb.north));
|
||||
return {
|
||||
north: ne.y,
|
||||
east: ne.x,
|
||||
south: sw.y,
|
||||
west: sw.x
|
||||
};
|
||||
};
|
||||
|
||||
/* Convert a mercator location into a WGS84 location
|
||||
*
|
||||
* p: the mercator lcation like {x, y}
|
||||
*/
|
||||
CesiumHeatmap.mercatorToWgs84 = function (p) {
|
||||
var wp = WMP.unproject(new Cesium.Cartesian3(p.x, p.y));
|
||||
return {
|
||||
x: wp.longitude,
|
||||
y: wp.latitude
|
||||
};
|
||||
};
|
||||
|
||||
/* Convert a mercator bounding box into a WGS84 bounding box
|
||||
*
|
||||
* bb: the mercator bounding box like {north, east, south, west}
|
||||
*/
|
||||
CesiumHeatmap.mercatorToWgs84BB = function (bb) {
|
||||
var sw = WMP.unproject(new Cesium.Cartesian3(bb.west, bb.south));
|
||||
var ne = WMP.unproject(new Cesium.Cartesian3(bb.east, bb.north));
|
||||
return {
|
||||
north: this.rad2deg(ne.latitude),
|
||||
east: this.rad2deg(ne.longitude),
|
||||
south: this.rad2deg(sw.latitude),
|
||||
west: this.rad2deg(sw.longitude)
|
||||
};
|
||||
};
|
||||
|
||||
/* Convert degrees into radians
|
||||
*
|
||||
* d: the degrees to be converted to radians
|
||||
*/
|
||||
CesiumHeatmap.deg2rad = function (d) {
|
||||
var r = d * (Math.PI / 180.0);
|
||||
return r;
|
||||
};
|
||||
|
||||
/* Convert radians into degrees
|
||||
*
|
||||
* r: the radians to be converted to degrees
|
||||
*/
|
||||
CesiumHeatmap.rad2deg = function (r) {
|
||||
var d = r / (Math.PI / 180.0);
|
||||
return d;
|
||||
};
|
||||
|
||||
return CesiumHeatmap;
|
||||
}
|
||||
|
||||
if (typeof (CesiumHeatmap) === 'undefined') {
|
||||
window.CesiumHeatmap = define_CesiumHeatmap();
|
||||
} else {
|
||||
console.log("CesiumHeatmap already defined.");
|
||||
}
|
||||
})(window);
|
||||
|
||||
/* Initiate a CesiumHeatmap instance
|
||||
*
|
||||
* c: CesiumWidget instance
|
||||
* bb: a WGS84 bounding box like {north, east, south, west}
|
||||
* o: a heatmap.js options object (see http://www.patrick-wied.at/static/heatmapjs/docs.html#h337-create)
|
||||
*/
|
||||
function CHInstance(bb, o) {
|
||||
if (!bb) {
|
||||
return null;
|
||||
}
|
||||
if (!o) {
|
||||
o = {};
|
||||
}
|
||||
|
||||
this._options = o;
|
||||
this._id = CesiumHeatmap._getID();
|
||||
|
||||
this._options.gradient = ((this._options.gradient) ? this._options.gradient : CesiumHeatmap.defaults.gradient);
|
||||
this._options.maxOpacity = ((this._options.maxOpacity) ? this._options.maxOpacity : CesiumHeatmap.defaults.maxOpacity);
|
||||
this._options.minOpacity = ((this._options.minOpacity) ? this._options.minOpacity : CesiumHeatmap.defaults.minOpacity);
|
||||
this._options.blur = ((this._options.blur) ? this._options.blur : CesiumHeatmap.defaults.blur);
|
||||
|
||||
this._mbounds = CesiumHeatmap.wgs84ToMercatorBB(bb);
|
||||
this._setWidthAndHeight(this._mbounds);
|
||||
|
||||
this._options.radius = Math.round((this._options.radius) ? this._options.radius : ((this.width > this.height) ? this.width / CesiumHeatmap.defaults.radiusFactor : this.height / CesiumHeatmap.defaults.radiusFactor));
|
||||
|
||||
this._spacing = this._options.radius * CesiumHeatmap.defaults.spacingFactor;
|
||||
this._xoffset = this._mbounds.west;
|
||||
this._yoffset = this._mbounds.south;
|
||||
|
||||
this.width = Math.round(this.width + this._spacing * 2);
|
||||
this.height = Math.round(this.height + this._spacing * 2);
|
||||
|
||||
this._mbounds.west -= this._spacing * this._factor;
|
||||
this._mbounds.east += this._spacing * this._factor;
|
||||
this._mbounds.south -= this._spacing * this._factor;
|
||||
this._mbounds.north += this._spacing * this._factor;
|
||||
|
||||
this.bounds = CesiumHeatmap.mercatorToWgs84BB(this._mbounds);
|
||||
|
||||
this._rectangle = Cesium.Rectangle.fromDegrees(this.bounds.west, this.bounds.south, this.bounds.east, this.bounds.north);
|
||||
this._container = CesiumHeatmap._getContainer(this.width, this.height, this._id);
|
||||
this._options.container = this._container;
|
||||
this._heatmap = h337.create(this._options);
|
||||
this._container.children[0].setAttribute("id", this._id + "-hm");
|
||||
}
|
||||
|
||||
/* Convert a WGS84 location to the corresponding heatmap location
|
||||
*
|
||||
* p: a WGS84 location like {x:lon, y:lat}
|
||||
*/
|
||||
CHInstance.prototype.wgs84PointToHeatmapPoint = function (p) {
|
||||
return this.mercatorPointToHeatmapPoint(CesiumHeatmap.wgs84ToMercator(p));
|
||||
};
|
||||
|
||||
/* Convert a mercator location to the corresponding heatmap location
|
||||
*
|
||||
* p: a WGS84 location like {x: lon, y:lat}
|
||||
*/
|
||||
CHInstance.prototype.mercatorPointToHeatmapPoint = function (p) {
|
||||
var pn = {};
|
||||
|
||||
pn.x = Math.round((p.x - this._xoffset) / this._factor + this._spacing);
|
||||
pn.y = Math.round((p.y - this._yoffset) / this._factor + this._spacing);
|
||||
pn.y = this.height - pn.y;
|
||||
|
||||
return pn;
|
||||
};
|
||||
|
||||
CHInstance.prototype._setWidthAndHeight = function (mbb) {
|
||||
this.width = ((mbb.east > 0 && mbb.west < 0) ? mbb.east + Math.abs(mbb.west) : Math.abs(mbb.east - mbb.west));
|
||||
this.height = ((mbb.north > 0 && mbb.south < 0) ? mbb.north + Math.abs(mbb.south) : Math.abs(mbb.north - mbb.south));
|
||||
this._factor = 1;
|
||||
|
||||
if (this.width > this.height && this.width > CesiumHeatmap.defaults.maxCanvasSize) {
|
||||
this._factor = this.width / CesiumHeatmap.defaults.maxCanvasSize;
|
||||
|
||||
if (this.height / this._factor < CesiumHeatmap.defaults.minCanvasSize) {
|
||||
this._factor = this.height / CesiumHeatmap.defaults.minCanvasSize;
|
||||
}
|
||||
} else if (this.height > this.width && this.height > CesiumHeatmap.defaults.maxCanvasSize) {
|
||||
this._factor = this.height / CesiumHeatmap.defaults.maxCanvasSize;
|
||||
|
||||
if (this.width / this._factor < CesiumHeatmap.defaults.minCanvasSize) {
|
||||
this._factor = this.width / CesiumHeatmap.defaults.minCanvasSize;
|
||||
}
|
||||
} else if (this.width < this.height && this.width < CesiumHeatmap.defaults.minCanvasSize) {
|
||||
this._factor = this.width / CesiumHeatmap.defaults.minCanvasSize;
|
||||
|
||||
if (this.height / this._factor > CesiumHeatmap.defaults.maxCanvasSize) {
|
||||
this._factor = this.height / CesiumHeatmap.defaults.maxCanvasSize;
|
||||
}
|
||||
} else if (this.height < this.width && this.height < CesiumHeatmap.defaults.minCanvasSize) {
|
||||
this._factor = this.height / CesiumHeatmap.defaults.minCanvasSize;
|
||||
|
||||
if (this.width / this._factor > CesiumHeatmap.defaults.maxCanvasSize) {
|
||||
this._factor = this.width / CesiumHeatmap.defaults.maxCanvasSize;
|
||||
}
|
||||
}
|
||||
|
||||
this.width = this.width / this._factor;
|
||||
this.height = this.height / this._factor;
|
||||
};
|
||||
|
||||
/* Set an array of heatmap locations
|
||||
*
|
||||
* min: the minimum allowed value for the data values
|
||||
* max: the maximum allowed value for the data values
|
||||
* data: an array of data points in heatmap coordinates and values like {x, y, value}
|
||||
*/
|
||||
CHInstance.prototype.setData = function (min, max, data) {
|
||||
|
||||
if (data && data.length > 0 && min !== null && min !== false && max !== null && max !== false) {
|
||||
this._heatmap.setData({
|
||||
min: min,
|
||||
max: max,
|
||||
data: data
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
/* Set an array of WGS84 locations
|
||||
*
|
||||
* min: the minimum allowed value for the data values
|
||||
* max: the maximum allowed value for the data values
|
||||
* data: an array of data points in WGS84 coordinates and values like { x:lon, y:lat, value }
|
||||
*/
|
||||
CHInstance.prototype.setWGS84Data = function (min, max, data) {
|
||||
|
||||
if (data && data.length > 0 && min !== null && min !== false && max !== null && max !== false) {
|
||||
var convdata = [];
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var gp = data[i];
|
||||
var hp = this.wgs84PointToHeatmapPoint(gp);
|
||||
if (gp.value || gp.value === 0) {
|
||||
hp.value = gp.value;
|
||||
}
|
||||
convdata.push(hp);
|
||||
}
|
||||
return this.setData(min, max, convdata);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/* Set whether or not the heatmap is shown on the map
|
||||
*
|
||||
* s: true means the heatmap is shown, false means the heatmap is hidden
|
||||
*/
|
||||
CHInstance.prototype.show = function (s) {
|
||||
if (this._layer) {
|
||||
this._layer.show = s;
|
||||
}
|
||||
};
|
||||
|
||||
/* DON'T TOUCH:
|
||||
*
|
||||
* heatmap.js v2.0.0 | JavaScript Heatmap Library: http://www.patrick-wied.at/static/heatmapjs/
|
||||
*
|
||||
* Copyright 2008-2014 Patrick Wied <heatmapjs@patrick-wied.at> - All rights reserved.
|
||||
* Dual licensed under MIT and Beerware license
|
||||
*
|
||||
* :: 2014-10-31 21:16
|
||||
*/
|
||||
(function (a, b, c) {
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = c()
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(c)
|
||||
} else {
|
||||
b[a] = c()
|
||||
}
|
||||
})("h337", this, function () {
|
||||
var a = {
|
||||
defaultRadius: 40,
|
||||
defaultRenderer: "canvas2d",
|
||||
defaultGradient: { .25: "rgb(0,0,255)", .55: "rgb(0,255,0)", .85: "yellow", 1: "rgb(255,0,0)" },
|
||||
defaultMaxOpacity: 1,
|
||||
defaultMinOpacity: 0,
|
||||
defaultBlur: .85,
|
||||
defaultXField: "x",
|
||||
defaultYField: "y",
|
||||
defaultValueField: "value",
|
||||
plugins: {}
|
||||
};
|
||||
var b = function h() {
|
||||
var b = function d(a) {
|
||||
this._coordinator = {};
|
||||
this._data = [];
|
||||
this._radi = [];
|
||||
this._min = 0;
|
||||
this._max = 1;
|
||||
this._xField = a["xField"] || a.defaultXField;
|
||||
this._yField = a["yField"] || a.defaultYField;
|
||||
this._valueField = a["valueField"] || a.defaultValueField;
|
||||
if (a["radius"]) {
|
||||
this._cfgRadius = a["radius"]
|
||||
}
|
||||
};
|
||||
var c = a.defaultRadius;
|
||||
b.prototype = {
|
||||
_organiseData: function (a, b) {
|
||||
var d = a[this._xField];
|
||||
var e = a[this._yField];
|
||||
var f = this._radi;
|
||||
var g = this._data;
|
||||
var h = this._max;
|
||||
var i = this._min;
|
||||
var j = a[this._valueField] || 1;
|
||||
var k = a.radius || this._cfgRadius || c;
|
||||
if (!g[d]) {
|
||||
g[d] = [];
|
||||
f[d] = []
|
||||
}
|
||||
if (!g[d][e]) {
|
||||
g[d][e] = j;
|
||||
f[d][e] = k
|
||||
} else {
|
||||
g[d][e] += j
|
||||
}
|
||||
if (g[d][e] > h) {
|
||||
if (!b) {
|
||||
this._max = g[d][e]
|
||||
} else {
|
||||
this.setDataMax(g[d][e])
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return { x: d, y: e, value: j, radius: k, min: i, max: h }
|
||||
}
|
||||
}, _unOrganizeData: function () {
|
||||
var a = [];
|
||||
var b = this._data;
|
||||
var c = this._radi;
|
||||
for (var d in b) {
|
||||
for (var e in b[d]) {
|
||||
a.push({ x: d, y: e, radius: c[d][e], value: b[d][e] })
|
||||
}
|
||||
}
|
||||
return { min: this._min, max: this._max, data: a }
|
||||
}, _onExtremaChange: function () {
|
||||
this._coordinator.emit("extremachange", { min: this._min, max: this._max })
|
||||
}, addData: function () {
|
||||
if (arguments[0].length > 0) {
|
||||
var a = arguments[0];
|
||||
var b = a.length;
|
||||
while (b--) {
|
||||
this.addData.call(this, a[b])
|
||||
}
|
||||
} else {
|
||||
var c = this._organiseData(arguments[0], true);
|
||||
if (c) {
|
||||
this._coordinator.emit("renderpartial", { min: this._min, max: this._max, data: [c] })
|
||||
}
|
||||
}
|
||||
return this
|
||||
}, setData: function (a) {
|
||||
var b = a.data;
|
||||
var c = b.length;
|
||||
this._data = [];
|
||||
this._radi = [];
|
||||
for (var d = 0; d < c; d++) {
|
||||
this._organiseData(b[d], false)
|
||||
}
|
||||
this._max = a.max;
|
||||
this._min = a.min || 0;
|
||||
this._onExtremaChange();
|
||||
this._coordinator.emit("renderall", this._getInternalData());
|
||||
return this
|
||||
}, removeData: function () {
|
||||
}, setDataMax: function (a) {
|
||||
this._max = a;
|
||||
this._onExtremaChange();
|
||||
this._coordinator.emit("renderall", this._getInternalData());
|
||||
return this
|
||||
}, setDataMin: function (a) {
|
||||
this._min = a;
|
||||
this._onExtremaChange();
|
||||
this._coordinator.emit("renderall", this._getInternalData());
|
||||
return this
|
||||
}, setCoordinator: function (a) {
|
||||
this._coordinator = a
|
||||
}, _getInternalData: function () {
|
||||
return { max: this._max, min: this._min, data: this._data, radi: this._radi }
|
||||
}, getData: function () {
|
||||
return this._unOrganizeData()
|
||||
}
|
||||
};
|
||||
return b
|
||||
}();
|
||||
var c = function i() {
|
||||
var a = function (a) {
|
||||
var b = a.gradient || a.defaultGradient;
|
||||
var c = document.createElement("canvas");
|
||||
var d = c.getContext("2d");
|
||||
c.width = 256;
|
||||
c.height = 1;
|
||||
var e = d.createLinearGradient(0, 0, 256, 1);
|
||||
for (var f in b) {
|
||||
e.addColorStop(f, b[f])
|
||||
}
|
||||
d.fillStyle = e;
|
||||
d.fillRect(0, 0, 256, 1);
|
||||
return d.getImageData(0, 0, 256, 1).data
|
||||
};
|
||||
var b = function (a, b) {
|
||||
var c = document.createElement("canvas");
|
||||
var d = c.getContext("2d");
|
||||
var e = a;
|
||||
var f = a;
|
||||
c.width = c.height = a * 2;
|
||||
if (b == 1) {
|
||||
d.beginPath();
|
||||
d.arc(e, f, a, 0, 2 * Math.PI, false);
|
||||
d.fillStyle = "rgba(0,0,0,1)";
|
||||
d.fill()
|
||||
} else {
|
||||
var g = d.createRadialGradient(e, f, a * b, e, f, a);
|
||||
g.addColorStop(0, "rgba(0,0,0,1)");
|
||||
g.addColorStop(1, "rgba(0,0,0,0)");
|
||||
d.fillStyle = g;
|
||||
d.fillRect(0, 0, 2 * a, 2 * a)
|
||||
}
|
||||
return c
|
||||
};
|
||||
var c = function (a) {
|
||||
var b = [];
|
||||
var c = a.min;
|
||||
var d = a.max;
|
||||
var e = a.radi;
|
||||
var a = a.data;
|
||||
var f = Object.keys(a);
|
||||
var g = f.length;
|
||||
while (g--) {
|
||||
var h = f[g];
|
||||
var i = Object.keys(a[h]);
|
||||
var j = i.length;
|
||||
while (j--) {
|
||||
var k = i[j];
|
||||
var l = a[h][k];
|
||||
var m = e[h][k];
|
||||
b.push({ x: h, y: k, value: l, radius: m })
|
||||
}
|
||||
}
|
||||
return { min: c, max: d, data: b }
|
||||
};
|
||||
|
||||
function d(b) {
|
||||
var c = b.container;
|
||||
var d = this.shadowCanvas = document.createElement("canvas");
|
||||
var e = this.canvas = b.canvas || document.createElement("canvas");
|
||||
var f = this._renderBoundaries = [1e4, 1e4, 0, 0];
|
||||
var g = getComputedStyle(b.container) || {};
|
||||
e.className = "heatmap-canvas";
|
||||
this._width = e.width = d.width = +g.width.replace(/px/, "");
|
||||
this._height = e.height = d.height = +g.height.replace(/px/, "");
|
||||
this.shadowCtx = d.getContext("2d");
|
||||
this.ctx = e.getContext("2d");
|
||||
e.style.cssText = d.style.cssText = "position:absolute;left:0;top:0;";
|
||||
c.style.position = "relative";
|
||||
c.appendChild(e);
|
||||
this._palette = a(b);
|
||||
this._templates = {};
|
||||
this._setStyles(b)
|
||||
}
|
||||
|
||||
d.prototype = {
|
||||
renderPartial: function (a) {
|
||||
this._drawAlpha(a);
|
||||
this._colorize()
|
||||
}, renderAll: function (a) {
|
||||
this._clear();
|
||||
this._drawAlpha(c(a));
|
||||
this._colorize()
|
||||
}, _updateGradient: function (b) {
|
||||
this._palette = a(b)
|
||||
}, updateConfig: function (a) {
|
||||
if (a["gradient"]) {
|
||||
this._updateGradient(a)
|
||||
}
|
||||
this._setStyles(a)
|
||||
}, setDimensions: function (a, b) {
|
||||
this._width = a;
|
||||
this._height = b;
|
||||
this.canvas.width = this.shadowCanvas.width = a;
|
||||
this.canvas.height = this.shadowCanvas.height = b
|
||||
}, _clear: function () {
|
||||
this.shadowCtx.clearRect(0, 0, this._width, this._height);
|
||||
this.ctx.clearRect(0, 0, this._width, this._height)
|
||||
}, _setStyles: function (a) {
|
||||
this._blur = a.blur == 0 ? 0 : a.blur || a.defaultBlur;
|
||||
if (a.backgroundColor) {
|
||||
this.canvas.style.backgroundColor = a.backgroundColor
|
||||
}
|
||||
this._opacity = (a.opacity || 0) * 255;
|
||||
this._maxOpacity = (a.maxOpacity || a.defaultMaxOpacity) * 255;
|
||||
this._minOpacity = (a.minOpacity || a.defaultMinOpacity) * 255;
|
||||
this._useGradientOpacity = !!a.useGradientOpacity
|
||||
}, _drawAlpha: function (a) {
|
||||
var c = this._min = a.min;
|
||||
var d = this._max = a.max;
|
||||
var a = a.data || [];
|
||||
var e = a.length;
|
||||
var f = 1 - this._blur;
|
||||
while (e--) {
|
||||
var g = a[e];
|
||||
var h = g.x;
|
||||
var i = g.y;
|
||||
var j = g.radius;
|
||||
var k = Math.min(g.value, d);
|
||||
var l = h - j;
|
||||
var m = i - j;
|
||||
var n = this.shadowCtx;
|
||||
var o;
|
||||
if (!this._templates[j]) {
|
||||
this._templates[j] = o = b(j, f)
|
||||
} else {
|
||||
o = this._templates[j]
|
||||
}
|
||||
n.globalAlpha = (k - c) / (d - c);
|
||||
n.drawImage(o, l, m);
|
||||
if (l < this._renderBoundaries[0]) {
|
||||
this._renderBoundaries[0] = l
|
||||
}
|
||||
if (m < this._renderBoundaries[1]) {
|
||||
this._renderBoundaries[1] = m
|
||||
}
|
||||
if (l + 2 * j > this._renderBoundaries[2]) {
|
||||
this._renderBoundaries[2] = l + 2 * j
|
||||
}
|
||||
if (m + 2 * j > this._renderBoundaries[3]) {
|
||||
this._renderBoundaries[3] = m + 2 * j
|
||||
}
|
||||
}
|
||||
}, _colorize: function () {
|
||||
var a = this._renderBoundaries[0];
|
||||
var b = this._renderBoundaries[1];
|
||||
var c = this._renderBoundaries[2] - a;
|
||||
var d = this._renderBoundaries[3] - b;
|
||||
var e = this._width;
|
||||
var f = this._height;
|
||||
var g = this._opacity;
|
||||
var h = this._maxOpacity;
|
||||
var i = this._minOpacity;
|
||||
var j = this._useGradientOpacity;
|
||||
if (a < 0) {
|
||||
a = 0
|
||||
}
|
||||
if (b < 0) {
|
||||
b = 0
|
||||
}
|
||||
if (a + c > e) {
|
||||
c = e - a
|
||||
}
|
||||
if (b + d > f) {
|
||||
d = f - b
|
||||
}
|
||||
var k = this.shadowCtx.getImageData(a, b, c, d);
|
||||
var l = k.data;
|
||||
var m = l.length;
|
||||
var n = this._palette;
|
||||
for (var o = 3; o < m; o += 4) {
|
||||
var p = l[o];
|
||||
var q = p * 4;
|
||||
if (!q) {
|
||||
continue
|
||||
}
|
||||
var r;
|
||||
if (g > 0) {
|
||||
r = g
|
||||
} else {
|
||||
if (p < h) {
|
||||
if (p < i) {
|
||||
r = i
|
||||
} else {
|
||||
r = p
|
||||
}
|
||||
} else {
|
||||
r = h
|
||||
}
|
||||
}
|
||||
l[o - 3] = n[q];
|
||||
l[o - 2] = n[q + 1];
|
||||
l[o - 1] = n[q + 2];
|
||||
l[o] = j ? n[q + 3] : r
|
||||
}
|
||||
k.data = l;
|
||||
this.ctx.putImageData(k, a, b);
|
||||
this._renderBoundaries = [1e3, 1e3, 0, 0]
|
||||
}, getValueAt: function (a) {
|
||||
var b;
|
||||
var c = this.shadowCtx;
|
||||
var d = c.getImageData(a.x, a.y, 1, 1);
|
||||
var e = d.data[3];
|
||||
var f = this._max;
|
||||
var g = this._min;
|
||||
b = Math.abs(f - g) * (e / 255) >> 0;
|
||||
return b
|
||||
}, getDataURL: function () {
|
||||
return this.canvas.toDataURL()
|
||||
}
|
||||
};
|
||||
return d
|
||||
}();
|
||||
var d = function j() {
|
||||
var b = false;
|
||||
if (a["defaultRenderer"] === "canvas2d") {
|
||||
b = c
|
||||
}
|
||||
return b
|
||||
}();
|
||||
var e = {
|
||||
merge: function () {
|
||||
var a = {};
|
||||
var b = arguments.length;
|
||||
for (var c = 0; c < b; c++) {
|
||||
var d = arguments[c];
|
||||
for (var e in d) {
|
||||
a[e] = d[e]
|
||||
}
|
||||
}
|
||||
return a
|
||||
}
|
||||
};
|
||||
var f = function k() {
|
||||
var c = function h() {
|
||||
function a() {
|
||||
this.cStore = {}
|
||||
}
|
||||
|
||||
a.prototype = {
|
||||
on: function (a, b, c) {
|
||||
var d = this.cStore;
|
||||
if (!d[a]) {
|
||||
d[a] = []
|
||||
}
|
||||
d[a].push(function (a) {
|
||||
return b.call(c, a)
|
||||
})
|
||||
}, emit: function (a, b) {
|
||||
var c = this.cStore;
|
||||
if (c[a]) {
|
||||
var d = c[a].length;
|
||||
for (var e = 0; e < d; e++) {
|
||||
var f = c[a][e];
|
||||
f(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return a
|
||||
}();
|
||||
var f = function (a) {
|
||||
var b = a._renderer;
|
||||
var c = a._coordinator;
|
||||
var d = a._store;
|
||||
c.on("renderpartial", b.renderPartial, b);
|
||||
c.on("renderall", b.renderAll, b);
|
||||
c.on("extremachange", function (b) {
|
||||
a._config.onExtremaChange && a._config.onExtremaChange({
|
||||
min: b.min,
|
||||
max: b.max,
|
||||
gradient: a._config["gradient"] || a._config["defaultGradient"]
|
||||
})
|
||||
});
|
||||
d.setCoordinator(c)
|
||||
};
|
||||
|
||||
function g() {
|
||||
var g = this._config = e.merge(a, arguments[0] || {});
|
||||
this._coordinator = new c;
|
||||
if (g["plugin"]) {
|
||||
var h = g["plugin"];
|
||||
if (!a.plugins[h]) {
|
||||
throw new Error("Plugin '" + h + "' not found. Maybe it was not registered.")
|
||||
} else {
|
||||
var i = a.plugins[h];
|
||||
this._renderer = new i.renderer(g);
|
||||
this._store = new i.store(g)
|
||||
}
|
||||
} else {
|
||||
this._renderer = new d(g);
|
||||
this._store = new b(g)
|
||||
}
|
||||
f(this)
|
||||
}
|
||||
|
||||
g.prototype = {
|
||||
addData: function () {
|
||||
this._store.addData.apply(this._store, arguments);
|
||||
return this
|
||||
}, removeData: function () {
|
||||
this._store.removeData && this._store.removeData.apply(this._store, arguments);
|
||||
return this
|
||||
}, setData: function () {
|
||||
this._store.setData.apply(this._store, arguments);
|
||||
return this
|
||||
}, setDataMax: function () {
|
||||
this._store.setDataMax.apply(this._store, arguments);
|
||||
return this
|
||||
}, setDataMin: function () {
|
||||
this._store.setDataMin.apply(this._store, arguments);
|
||||
return this
|
||||
}, configure: function (a) {
|
||||
this._config = e.merge(this._config, a);
|
||||
this._renderer.updateConfig(this._config);
|
||||
this._coordinator.emit("renderall", this._store._getInternalData());
|
||||
return this
|
||||
}, repaint: function () {
|
||||
this._coordinator.emit("renderall", this._store._getInternalData());
|
||||
return this
|
||||
}, getData: function () {
|
||||
return this._store.getData()
|
||||
}, getDataURL: function () {
|
||||
return this._renderer.getDataURL()
|
||||
}, getValueAt: function (a) {
|
||||
if (this._store.getValueAt) {
|
||||
return this._store.getValueAt(a)
|
||||
} else if (this._renderer.getValueAt) {
|
||||
return this._renderer.getValueAt(a)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
};
|
||||
return g
|
||||
}();
|
||||
var g = {
|
||||
create: function (a) {
|
||||
return new f(a)
|
||||
}, register: function (b, c) {
|
||||
a.plugins[b] = c
|
||||
}
|
||||
};
|
||||
return g
|
||||
});
|
7
public/sdk/3rdparty/clipboard.min.js
vendored
Normal file
21
public/sdk/3rdparty/easywasmplayer/EasyWasmPlayer.js
vendored
Normal file
BIN
public/sdk/3rdparty/easywasmplayer/libDecoder.wasm
vendored
Normal file
45
public/sdk/3rdparty/echarts.min.js
vendored
Normal file
BIN
public/sdk/3rdparty/element-ui/fonts/element-icons.ttf
vendored
Normal file
BIN
public/sdk/3rdparty/element-ui/fonts/element-icons.woff
vendored
Normal file
1
public/sdk/3rdparty/element-ui/icon.css
vendored
Normal file
1
public/sdk/3rdparty/element-ui/index.css
vendored
Normal file
1
public/sdk/3rdparty/element-ui/index.js
vendored
Normal file
1378
public/sdk/3rdparty/ewPlugins.min.js
vendored
Normal file
7199
public/sdk/3rdparty/fabric.min.js
vendored
Normal file
11964
public/sdk/3rdparty/flv.min.js
vendored
Normal file
717
public/sdk/3rdparty/heatmap.js
vendored
Normal file
@ -0,0 +1,717 @@
|
||||
/*
|
||||
* heatmap.js v2.0.5 | JavaScript Heatmap Library
|
||||
*
|
||||
* Copyright 2008-2016 Patrick Wied <heatmapjs@patrick-wied.at> - All rights reserved.
|
||||
* Dual licensed under MIT and Beerware license
|
||||
*
|
||||
* :: 2016-09-05 01:16
|
||||
*/
|
||||
;(function (name, context, factory) {
|
||||
// Supports UMD. AMD, CommonJS/Node.js and browser context
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = factory()
|
||||
// eslint-disable-next-line no-undef
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// eslint-disable-next-line no-undef
|
||||
define(factory)
|
||||
} else {
|
||||
context[name] = factory()
|
||||
}
|
||||
})('h337', this, function () {
|
||||
// Heatmap Config stores default values and will be merged with instance config
|
||||
var HeatmapConfig = {
|
||||
defaultRadius: 40,
|
||||
defaultRenderer: 'canvas2d',
|
||||
defaultGradient: {
|
||||
0.25: 'rgb(0,0,255)',
|
||||
0.55: 'rgb(0,255,0)',
|
||||
0.85: 'yellow',
|
||||
1.0: 'rgb(255,0,0)'
|
||||
},
|
||||
defaultMaxOpacity: 1,
|
||||
defaultMinOpacity: 0,
|
||||
defaultBlur: 0.85,
|
||||
defaultXField: 'x',
|
||||
defaultYField: 'y',
|
||||
defaultValueField: 'value',
|
||||
plugins: {}
|
||||
}
|
||||
var Store = (function StoreClosure() {
|
||||
var Store = function Store(config) {
|
||||
this._coordinator = {}
|
||||
this._data = []
|
||||
this._radi = []
|
||||
this._min = 10
|
||||
this._max = 1
|
||||
this._xField = config['xField'] || config.defaultXField
|
||||
this._yField = config['yField'] || config.defaultYField
|
||||
this._valueField = config['valueField'] || config.defaultValueField
|
||||
|
||||
if (config['radius']) {
|
||||
this._cfgRadius = config['radius']
|
||||
}
|
||||
}
|
||||
|
||||
var defaultRadius = HeatmapConfig.defaultRadius
|
||||
|
||||
Store.prototype = {
|
||||
// when forceRender = false -> called from setData, omits renderall event
|
||||
_organiseData: function (dataPoint, forceRender) {
|
||||
var x = dataPoint[this._xField]
|
||||
var y = dataPoint[this._yField]
|
||||
var radi = this._radi
|
||||
var store = this._data
|
||||
var max = this._max
|
||||
var min = this._min
|
||||
var value = dataPoint[this._valueField] || 1
|
||||
var radius = dataPoint.radius || this._cfgRadius || defaultRadius
|
||||
|
||||
if (!store[x]) {
|
||||
store[x] = []
|
||||
radi[x] = []
|
||||
}
|
||||
|
||||
if (!store[x][y]) {
|
||||
store[x][y] = value
|
||||
radi[x][y] = radius
|
||||
} else {
|
||||
store[x][y] += value
|
||||
}
|
||||
var storedVal = store[x][y]
|
||||
|
||||
if (storedVal > max) {
|
||||
if (!forceRender) {
|
||||
this._max = storedVal
|
||||
} else {
|
||||
this.setDataMax(storedVal)
|
||||
}
|
||||
return false
|
||||
} else if (storedVal < min) {
|
||||
if (!forceRender) {
|
||||
this._min = storedVal
|
||||
} else {
|
||||
this.setDataMin(storedVal)
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
value: value,
|
||||
radius: radius,
|
||||
min: min,
|
||||
max: max
|
||||
}
|
||||
}
|
||||
},
|
||||
_unOrganizeData: function () {
|
||||
var unorganizedData = []
|
||||
var data = this._data
|
||||
var radi = this._radi
|
||||
|
||||
for (var x in data) {
|
||||
for (var y in data[x]) {
|
||||
unorganizedData.push({
|
||||
x: x,
|
||||
y: y,
|
||||
radius: radi[x][y],
|
||||
value: data[x][y]
|
||||
})
|
||||
}
|
||||
}
|
||||
return {
|
||||
min: this._min,
|
||||
max: this._max,
|
||||
data: unorganizedData
|
||||
}
|
||||
},
|
||||
_onExtremaChange: function () {
|
||||
this._coordinator.emit('extremachange', {
|
||||
min: this._min,
|
||||
max: this._max
|
||||
})
|
||||
},
|
||||
addData: function () {
|
||||
if (arguments[0].length > 0) {
|
||||
var dataArr = arguments[0]
|
||||
var dataLen = dataArr.length
|
||||
while (dataLen--) {
|
||||
this.addData.call(this, dataArr[dataLen])
|
||||
}
|
||||
} else {
|
||||
// add to store
|
||||
var organisedEntry = this._organiseData(arguments[0], true)
|
||||
if (organisedEntry) {
|
||||
// if it's the first datapoint initialize the extremas with it
|
||||
if (this._data.length === 0) {
|
||||
this._min = this._max = organisedEntry.value
|
||||
}
|
||||
this._coordinator.emit('renderpartial', {
|
||||
min: this._min,
|
||||
max: this._max,
|
||||
data: [organisedEntry]
|
||||
})
|
||||
}
|
||||
}
|
||||
return this
|
||||
},
|
||||
setData: function (data) {
|
||||
var dataPoints = data.data
|
||||
var pointsLen = dataPoints.length
|
||||
|
||||
// reset data arrays
|
||||
this._data = []
|
||||
this._radi = []
|
||||
|
||||
for (var i = 0; i < pointsLen; i++) {
|
||||
this._organiseData(dataPoints[i], false)
|
||||
}
|
||||
this._max = data.max
|
||||
this._min = data.min || 0
|
||||
|
||||
this._onExtremaChange()
|
||||
this._coordinator.emit('renderall', this._getInternalData())
|
||||
return this
|
||||
},
|
||||
removeData: function () {
|
||||
// TODO: implement
|
||||
},
|
||||
setDataMax: function (max) {
|
||||
this._max = max
|
||||
this._onExtremaChange()
|
||||
this._coordinator.emit('renderall', this._getInternalData())
|
||||
return this
|
||||
},
|
||||
setDataMin: function (min) {
|
||||
this._min = min
|
||||
this._onExtremaChange()
|
||||
this._coordinator.emit('renderall', this._getInternalData())
|
||||
return this
|
||||
},
|
||||
setCoordinator: function (coordinator) {
|
||||
this._coordinator = coordinator
|
||||
},
|
||||
_getInternalData: function () {
|
||||
return {
|
||||
max: this._max,
|
||||
min: this._min,
|
||||
data: this._data,
|
||||
radi: this._radi
|
||||
}
|
||||
},
|
||||
getData: function () {
|
||||
return this._unOrganizeData()
|
||||
} /*,
|
||||
|
||||
TODO: rethink.
|
||||
|
||||
getValueAt: function(point) {
|
||||
var value;
|
||||
var radius = 100;
|
||||
var x = point.x;
|
||||
var y = point.y;
|
||||
var data = this._data;
|
||||
|
||||
if (data[x] && data[x][y]) {
|
||||
return data[x][y];
|
||||
} else {
|
||||
var values = [];
|
||||
// radial search for datapoints based on default radius
|
||||
for(var distance = 1; distance < radius; distance++) {
|
||||
var neighbors = distance * 2 +1;
|
||||
var startX = x - distance;
|
||||
var startY = y - distance;
|
||||
|
||||
for(var i = 0; i < neighbors; i++) {
|
||||
for (var o = 0; o < neighbors; o++) {
|
||||
if ((i == 0 || i == neighbors-1) || (o == 0 || o == neighbors-1)) {
|
||||
if (data[startY+i] && data[startY+i][startX+o]) {
|
||||
values.push(data[startY+i][startX+o]);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (values.length > 0) {
|
||||
return Math.max.apply(Math, values);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
return Store
|
||||
})()
|
||||
|
||||
var Canvas2dRenderer = (function Canvas2dRendererClosure() {
|
||||
var _getColorPalette = function (config) {
|
||||
var gradientConfig = config.gradient || config.defaultGradient
|
||||
var paletteCanvas = document.createElement('canvas')
|
||||
var paletteCtx = paletteCanvas.getContext('2d')
|
||||
|
||||
paletteCanvas.width = 256
|
||||
paletteCanvas.height = 1
|
||||
|
||||
var gradient = paletteCtx.createLinearGradient(0, 0, 256, 1)
|
||||
for (var key in gradientConfig) {
|
||||
gradient.addColorStop(key, gradientConfig[key])
|
||||
}
|
||||
|
||||
paletteCtx.fillStyle = gradient
|
||||
paletteCtx.fillRect(0, 0, 256, 1)
|
||||
|
||||
return paletteCtx.getImageData(0, 0, 256, 1).data
|
||||
}
|
||||
|
||||
var _getPointTemplate = function (radius, blurFactor) {
|
||||
var tplCanvas = document.createElement('canvas')
|
||||
var tplCtx = tplCanvas.getContext('2d')
|
||||
var x = radius
|
||||
var y = radius
|
||||
tplCanvas.width = tplCanvas.height = radius * 2
|
||||
|
||||
if (blurFactor == 1) {
|
||||
tplCtx.beginPath()
|
||||
tplCtx.arc(x, y, radius, 0, 2 * Math.PI, false)
|
||||
tplCtx.fillStyle = 'rgba(0,0,0,1)'
|
||||
tplCtx.fill()
|
||||
} else {
|
||||
var gradient = tplCtx.createRadialGradient(
|
||||
x,
|
||||
y,
|
||||
radius * blurFactor,
|
||||
x,
|
||||
y,
|
||||
radius
|
||||
)
|
||||
gradient.addColorStop(0, 'rgba(0,0,0,1)')
|
||||
gradient.addColorStop(1, 'rgba(0,0,0,0)')
|
||||
tplCtx.fillStyle = gradient
|
||||
tplCtx.fillRect(0, 0, 2 * radius, 2 * radius)
|
||||
}
|
||||
|
||||
return tplCanvas
|
||||
}
|
||||
|
||||
var _prepareData = function (data) {
|
||||
var renderData = []
|
||||
var min = data.min
|
||||
var max = data.max
|
||||
var radi = data.radi
|
||||
var data = data.data
|
||||
|
||||
var xValues = Object.keys(data)
|
||||
var xValuesLen = xValues.length
|
||||
|
||||
while (xValuesLen--) {
|
||||
var xValue = xValues[xValuesLen]
|
||||
var yValues = Object.keys(data[xValue])
|
||||
var yValuesLen = yValues.length
|
||||
while (yValuesLen--) {
|
||||
var yValue = yValues[yValuesLen]
|
||||
var value = data[xValue][yValue]
|
||||
var radius = radi[xValue][yValue]
|
||||
renderData.push({
|
||||
x: xValue,
|
||||
y: yValue,
|
||||
value: value,
|
||||
radius: radius
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
min: min,
|
||||
max: max,
|
||||
data: renderData
|
||||
}
|
||||
}
|
||||
|
||||
function Canvas2dRenderer(config) {
|
||||
var container = config.container
|
||||
var shadowCanvas = (this.shadowCanvas = document.createElement('canvas'))
|
||||
var canvas = (this.canvas =
|
||||
config.canvas || document.createElement('canvas'))
|
||||
var renderBoundaries = (this._renderBoundaries = [10000, 10000, 0, 0])
|
||||
|
||||
var computed = getComputedStyle(config.container) || {}
|
||||
|
||||
canvas.className = 'heatmap-canvas'
|
||||
|
||||
this._width = canvas.width = shadowCanvas.width =
|
||||
config.width || +computed.width.replace(/px/, '')
|
||||
this._height = canvas.height = shadowCanvas.height =
|
||||
config.height || +computed.height.replace(/px/, '')
|
||||
|
||||
this.shadowCtx = shadowCanvas.getContext('2d')
|
||||
this.ctx = canvas.getContext('2d')
|
||||
|
||||
// @TODO:
|
||||
// conditional wrapper
|
||||
|
||||
canvas.style.cssText = shadowCanvas.style.cssText =
|
||||
'position:absolute;left:0;top:0;'
|
||||
|
||||
container.style.position = 'relative'
|
||||
container.appendChild(canvas)
|
||||
|
||||
this._palette = _getColorPalette(config)
|
||||
this._templates = {}
|
||||
|
||||
this._setStyles(config)
|
||||
}
|
||||
|
||||
Canvas2dRenderer.prototype = {
|
||||
renderPartial: function (data) {
|
||||
if (data.data.length > 0) {
|
||||
this._drawAlpha(data)
|
||||
this._colorize()
|
||||
}
|
||||
},
|
||||
renderAll: function (data) {
|
||||
// reset render boundaries
|
||||
this._clear()
|
||||
if (data.data.length > 0) {
|
||||
this._drawAlpha(_prepareData(data))
|
||||
this._colorize()
|
||||
}
|
||||
},
|
||||
_updateGradient: function (config) {
|
||||
this._palette = _getColorPalette(config)
|
||||
},
|
||||
updateConfig: function (config) {
|
||||
if (config['gradient']) {
|
||||
this._updateGradient(config)
|
||||
}
|
||||
this._setStyles(config)
|
||||
},
|
||||
setDimensions: function (width, height) {
|
||||
this._width = width
|
||||
this._height = height
|
||||
this.canvas.width = this.shadowCanvas.width = width
|
||||
this.canvas.height = this.shadowCanvas.height = height
|
||||
},
|
||||
_clear: function () {
|
||||
this.shadowCtx.clearRect(0, 0, this._width, this._height)
|
||||
this.ctx.clearRect(0, 0, this._width, this._height)
|
||||
},
|
||||
_setStyles: function (config) {
|
||||
this._blur = config.blur == 0 ? 0 : config.blur || config.defaultBlur
|
||||
|
||||
if (config.backgroundColor) {
|
||||
this.canvas.style.backgroundColor = config.backgroundColor
|
||||
}
|
||||
|
||||
this._width = this.canvas.width = this.shadowCanvas.width =
|
||||
config.width || this._width
|
||||
this._height = this.canvas.height = this.shadowCanvas.height =
|
||||
config.height || this._height
|
||||
|
||||
this._opacity = (config.opacity || 0) * 255
|
||||
this._maxOpacity = (config.maxOpacity || config.defaultMaxOpacity) * 255
|
||||
this._minOpacity = (config.minOpacity || config.defaultMinOpacity) * 255
|
||||
this._useGradientOpacity = !!config.useGradientOpacity
|
||||
},
|
||||
_drawAlpha: function (data) {
|
||||
var min = (this._min = data.min)
|
||||
var max = (this._max = data.max)
|
||||
var data = data.data || []
|
||||
var dataLen = data.length
|
||||
// on a point basis?
|
||||
var blur = 1 - this._blur
|
||||
|
||||
while (dataLen--) {
|
||||
var point = data[dataLen]
|
||||
|
||||
var x = point.x
|
||||
var y = point.y
|
||||
var radius = point.radius
|
||||
// if value is bigger than max
|
||||
// use max as value
|
||||
var value = Math.min(point.value, max)
|
||||
var rectX = x - radius
|
||||
var rectY = y - radius
|
||||
var shadowCtx = this.shadowCtx
|
||||
|
||||
var tpl
|
||||
if (!this._templates[radius]) {
|
||||
this._templates[radius] = tpl = _getPointTemplate(radius, blur)
|
||||
} else {
|
||||
tpl = this._templates[radius]
|
||||
}
|
||||
// value from minimum / value range
|
||||
// => [0, 1]
|
||||
var templateAlpha = (value - min) / (max - min)
|
||||
// this fixes #176: small values are not visible because globalAlpha < .01 cannot be read from imageData
|
||||
shadowCtx.globalAlpha = templateAlpha < 0.01 ? 0.01 : templateAlpha
|
||||
|
||||
shadowCtx.drawImage(tpl, rectX, rectY)
|
||||
|
||||
// update renderBoundaries
|
||||
if (rectX < this._renderBoundaries[0]) {
|
||||
this._renderBoundaries[0] = rectX
|
||||
}
|
||||
if (rectY < this._renderBoundaries[1]) {
|
||||
this._renderBoundaries[1] = rectY
|
||||
}
|
||||
if (rectX + 2 * radius > this._renderBoundaries[2]) {
|
||||
this._renderBoundaries[2] = rectX + 2 * radius
|
||||
}
|
||||
if (rectY + 2 * radius > this._renderBoundaries[3]) {
|
||||
this._renderBoundaries[3] = rectY + 2 * radius
|
||||
}
|
||||
}
|
||||
},
|
||||
_colorize: function () {
|
||||
var x = this._renderBoundaries[0]
|
||||
var y = this._renderBoundaries[1]
|
||||
var width = this._renderBoundaries[2] - x
|
||||
var height = this._renderBoundaries[3] - y
|
||||
var maxWidth = this._width
|
||||
var maxHeight = this._height
|
||||
var opacity = this._opacity
|
||||
var maxOpacity = this._maxOpacity
|
||||
var minOpacity = this._minOpacity
|
||||
var useGradientOpacity = this._useGradientOpacity
|
||||
|
||||
if (x < 0) {
|
||||
x = 0
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0
|
||||
}
|
||||
if (x + width > maxWidth) {
|
||||
width = maxWidth - x
|
||||
}
|
||||
if (y + height > maxHeight) {
|
||||
height = maxHeight - y
|
||||
}
|
||||
|
||||
var img = this.shadowCtx.getImageData(x, y, width, height)
|
||||
var imgData = img.data
|
||||
var len = imgData.length
|
||||
var palette = this._palette
|
||||
|
||||
for (var i = 3; i < len; i += 4) {
|
||||
var alpha = imgData[i]
|
||||
var offset = alpha * 4
|
||||
|
||||
if (!offset) {
|
||||
continue
|
||||
}
|
||||
|
||||
var finalAlpha
|
||||
if (opacity > 0) {
|
||||
finalAlpha = opacity
|
||||
} else {
|
||||
if (alpha < maxOpacity) {
|
||||
if (alpha < minOpacity) {
|
||||
finalAlpha = minOpacity
|
||||
} else {
|
||||
finalAlpha = alpha
|
||||
}
|
||||
} else {
|
||||
finalAlpha = maxOpacity
|
||||
}
|
||||
}
|
||||
|
||||
imgData[i - 3] = palette[offset]
|
||||
imgData[i - 2] = palette[offset + 1]
|
||||
imgData[i - 1] = palette[offset + 2]
|
||||
imgData[i] = useGradientOpacity ? palette[offset + 3] : finalAlpha
|
||||
}
|
||||
|
||||
img.data = imgData
|
||||
this.ctx.putImageData(img, x, y)
|
||||
|
||||
this._renderBoundaries = [1000, 1000, 0, 0]
|
||||
},
|
||||
getValueAt: function (point) {
|
||||
var value
|
||||
var shadowCtx = this.shadowCtx
|
||||
var img = shadowCtx.getImageData(point.x, point.y, 1, 1)
|
||||
var data = img.data[3]
|
||||
var max = this._max
|
||||
var min = this._min
|
||||
|
||||
value = (Math.abs(max - min) * (data / 255)) >> 0
|
||||
|
||||
return value
|
||||
},
|
||||
getDataURL: function () {
|
||||
return this.canvas.toDataURL()
|
||||
}
|
||||
}
|
||||
|
||||
return Canvas2dRenderer
|
||||
})()
|
||||
|
||||
var Renderer = (function RendererClosure() {
|
||||
var rendererFn = false
|
||||
|
||||
if (HeatmapConfig['defaultRenderer'] === 'canvas2d') {
|
||||
rendererFn = Canvas2dRenderer
|
||||
}
|
||||
|
||||
return rendererFn
|
||||
})()
|
||||
|
||||
var Util = {
|
||||
merge: function () {
|
||||
var merged = {}
|
||||
var argsLen = arguments.length
|
||||
for (var i = 0; i < argsLen; i++) {
|
||||
var obj = arguments[i]
|
||||
for (var key in obj) {
|
||||
merged[key] = obj[key]
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
}
|
||||
// Heatmap Constructor
|
||||
var Heatmap = (function HeatmapClosure() {
|
||||
var Coordinator = (function CoordinatorClosure() {
|
||||
function Coordinator() {
|
||||
this.cStore = {}
|
||||
}
|
||||
|
||||
Coordinator.prototype = {
|
||||
on: function (evtName, callback, scope) {
|
||||
var cStore = this.cStore
|
||||
|
||||
if (!cStore[evtName]) {
|
||||
cStore[evtName] = []
|
||||
}
|
||||
cStore[evtName].push(function (data) {
|
||||
return callback.call(scope, data)
|
||||
})
|
||||
},
|
||||
emit: function (evtName, data) {
|
||||
var cStore = this.cStore
|
||||
if (cStore[evtName]) {
|
||||
var len = cStore[evtName].length
|
||||
for (var i = 0; i < len; i++) {
|
||||
var callback = cStore[evtName][i]
|
||||
callback(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Coordinator
|
||||
})()
|
||||
|
||||
var _connect = function (scope) {
|
||||
var renderer = scope._renderer
|
||||
var coordinator = scope._coordinator
|
||||
var store = scope._store
|
||||
|
||||
coordinator.on('renderpartial', renderer.renderPartial, renderer)
|
||||
coordinator.on('renderall', renderer.renderAll, renderer)
|
||||
coordinator.on('extremachange', function (data) {
|
||||
scope._config.onExtremaChange &&
|
||||
scope._config.onExtremaChange({
|
||||
min: data.min,
|
||||
max: data.max,
|
||||
gradient:
|
||||
scope._config['gradient'] || scope._config['defaultGradient']
|
||||
})
|
||||
})
|
||||
store.setCoordinator(coordinator)
|
||||
}
|
||||
|
||||
function Heatmap() {
|
||||
var config = (this._config = Util.merge(
|
||||
HeatmapConfig,
|
||||
arguments[0] || {}
|
||||
))
|
||||
this._coordinator = new Coordinator()
|
||||
if (config['plugin']) {
|
||||
var pluginToLoad = config['plugin']
|
||||
if (!HeatmapConfig.plugins[pluginToLoad]) {
|
||||
throw new Error(
|
||||
"Plugin '" +
|
||||
pluginToLoad +
|
||||
"' not found. Maybe it was not registered."
|
||||
)
|
||||
} else {
|
||||
var plugin = HeatmapConfig.plugins[pluginToLoad]
|
||||
// set plugin renderer and store
|
||||
this._renderer = new plugin.renderer(config)
|
||||
this._store = new plugin.store(config)
|
||||
}
|
||||
} else {
|
||||
this._renderer = new Renderer(config)
|
||||
this._store = new Store(config)
|
||||
}
|
||||
_connect(this)
|
||||
}
|
||||
|
||||
// @TODO:
|
||||
// add API documentation
|
||||
Heatmap.prototype = {
|
||||
addData: function () {
|
||||
this._store.addData.apply(this._store, arguments)
|
||||
return this
|
||||
},
|
||||
removeData: function () {
|
||||
this._store.removeData &&
|
||||
this._store.removeData.apply(this._store, arguments)
|
||||
return this
|
||||
},
|
||||
setData: function () {
|
||||
this._store.setData.apply(this._store, arguments)
|
||||
return this
|
||||
},
|
||||
setDataMax: function () {
|
||||
this._store.setDataMax.apply(this._store, arguments)
|
||||
return this
|
||||
},
|
||||
setDataMin: function () {
|
||||
this._store.setDataMin.apply(this._store, arguments)
|
||||
return this
|
||||
},
|
||||
configure: function (config) {
|
||||
this._config = Util.merge(this._config, config)
|
||||
this._renderer.updateConfig(this._config)
|
||||
this._coordinator.emit('renderall', this._store._getInternalData())
|
||||
return this
|
||||
},
|
||||
repaint: function () {
|
||||
this._coordinator.emit('renderall', this._store._getInternalData())
|
||||
return this
|
||||
},
|
||||
getData: function () {
|
||||
return this._store.getData()
|
||||
},
|
||||
getDataURL: function () {
|
||||
return this._renderer.getDataURL()
|
||||
},
|
||||
getValueAt: function (point) {
|
||||
if (this._store.getValueAt) {
|
||||
return this._store.getValueAt(point)
|
||||
} else if (this._renderer.getValueAt) {
|
||||
return this._renderer.getValueAt(point)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Heatmap
|
||||
})()
|
||||
|
||||
// core
|
||||
var heatmapFactory = {
|
||||
create: function (config) {
|
||||
return new Heatmap(config)
|
||||
},
|
||||
register: function (pluginKey, plugin) {
|
||||
HeatmapConfig.plugins[pluginKey] = plugin
|
||||
}
|
||||
}
|
||||
return heatmapFactory
|
||||
})
|
20
public/sdk/3rdparty/html2canvas.min.js
vendored
Normal file
9
public/sdk/3rdparty/jedate/jedate.min.js
vendored
Normal file
100
public/sdk/3rdparty/jedate/skin/jedate.css
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
@Name : jeDate V6.5.0 日期控件
|
||||
@Author: chen guojun
|
||||
@QQ群:516754269
|
||||
@官网:http://www.jemui.com/ 或 https://github.com/singod/jeDate
|
||||
*/
|
||||
@font-face {font-family: "jedatefont";
|
||||
src: url('jedatefont.eot?t=1510763148800'); /* IE9*/
|
||||
src: url('jedatefont.eot?t=1510763148800#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('jedatefont.woff?t=1510763148800') format('woff'),
|
||||
url('jedatefont.ttf?t=1510763148800') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
|
||||
url('jedatefont.svg?t=1510763148800#jedatefont') format('svg'); /* iOS 4.1- */
|
||||
}
|
||||
|
||||
.jedatefont {font-family:"jedatefont" !important;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
|
||||
.jedate{height:auto; font-family:'PingFangSC-Light','PingFang SC','Segoe UI','Lucida Grande','NotoSansHans-Light','Microsoft YaHei', '\5FAE\8F6F\96C5\9ED1', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif;font-size:12px; cursor:default;margin: 0;padding: 0;overflow: hidden;position: relative;border-radius:4px;display: inline-block;border: 1px solid #e2e2e2;box-shadow: 0 1px 6px rgba(0,0,0,.15);background-color:#fff;}
|
||||
.jedate *{margin: 0;padding: 0;list-style-type:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;font-style:normal;font-family:'PingFangSC-Light','PingFang SC','Segoe UI','Lucida Grande','NotoSansHans-Light','Microsoft YaHei', '\5FAE\8F6F\96C5\9ED1', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif;}
|
||||
|
||||
.jedate table thead,.jedate table td{border: 1px #fff solid;}
|
||||
.jedate ul,.jedate ol,.jedate li,.jedate dl{list-style-type:none;font-style:normal;font-weight: 300;}
|
||||
|
||||
.jedate .yearprev{left:0;font-size: 14px;}
|
||||
.jedate .monthprev{left:25px;font-size: 14px;}
|
||||
.jedate .yearnext{right:0;font-size: 14px;}
|
||||
.jedate .monthnext{right:25px;font-size: 14px;}
|
||||
.jedate .jedate-tips{position: absolute; top: 40%; left: 50%;z-index: 800; width: 200px; margin-left: -100px; line-height: 20px; padding: 15px; text-align: center; font-size: 12px; color: #ff0000;background-color: #FFFEF4;border: 1px rgb(247, 206, 57) solid;display: none;}
|
||||
.jedate .timecontent ul::-webkit-scrollbar,.jedate-menu::-webkit-scrollbar{height:6px;width:6px;margin-right:5px;background-color: #f5f5f5;transition:all 0.3s ease-in-out;border-radius:0px}
|
||||
.jedate .timecontent ul::-webkit-scrollbar-track,.jedate-menu::-webkit-scrollbar-track { -webkit-border-radius: 0px;border-radius: 0px;}
|
||||
.jedate .timecontent ul::-webkit-scrollbar-thumb,.jedate-menu::-webkit-scrollbar-thumb{-webkit-border-radius: 0px;border-radius: 0px;background: rgba(0,0,0,0.5); }
|
||||
.jedate .timecontent ul::-webkit-scrollbar-thumb:hover,.jedate-menu::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,0.6)}
|
||||
.jedate .timecontent ul::-webkit-scrollbar-thumb:active,.jedate-menu::-webkit-scrollbar-thumb:active{background:rgba(0,0,0,0.8)}
|
||||
.jedate .timecontent ul::-webkit-scrollbar-thumb:window-inactive,.jedate-menu::-webkit-scrollbar-thumb:window-inactive {background: rgba(0,0,0,0.4);}
|
||||
.jedate .jedate-hmsmask{width:100%;display: block;background-color: rgba(0,0,0,.7);background-color:#fff;position: absolute;top: 0;left:0;right:0;bottom: 36px;z-index: 100;}
|
||||
.jedatetipscon{color:#333; float:left; overflow:hidden;background-color: #FFFEF4; line-height:22px;padding:6px;border: 1px rgb(247, 206, 57) solid;font-style:normal;font-family: Arial, "\5b8b\4f53", 'sans-serif';font-size:12px;font-weight: 300;}
|
||||
.jedatetipscon p{padding: 0;margin: 0;font-size:12px;}
|
||||
.jedatetipscon p.red{color: #ff0000;}
|
||||
|
||||
.jedate.leftmenu{padding-left: 90px;}
|
||||
.jedate .jedate-menu{width:90px;position: absolute;top: 0;left:0;bottom: 0;z-index: 10;background: #f2f2f2;border-right: 1px solid #efefef;border-radius: 4px 0 0 4px;overflow:auto;display: block;padding:4px 0;}
|
||||
.jedate .jedate-menu p{height: 30px;line-height: 30px;padding-left: 8px;overflow:hidden;font-size: 12px;cursor: pointer;}
|
||||
.jedate .jedate-menu p:hover{background-color: #00A680;color:#FFFFFF;}
|
||||
.jedate .jedate-wrap{min-width:230px;background: #fff;overflow: hidden;}
|
||||
.jedate .jedate-pane{width: 230px;float: left;overflow: hidden;}
|
||||
.jedate .jedate-header{width:100%;height:36px;line-height: 36px;float: left;background-color: #f2f2f2;text-align: center;font-size: 14px;padding: 0 50px;position: relative;}
|
||||
.jedate .jedate-header em{width:25px;height:36px;line-height: 36px;position:absolute;color: #666;top:0;background-repeat: no-repeat;background-position: center center;cursor: pointer;}
|
||||
.jedate .jedate-header .ymbtn{padding: 8px;border-radius: 4px;cursor:pointer;font-size: 14px;}
|
||||
/* .jedate .jedate-header em:hover,.jedate .jedate-header .ymbtn:hover{color: #00A680;} */
|
||||
.jedate .jedate-content{width:100%;height: 220px;float: left;padding: 5px;overflow: hidden;}
|
||||
.jedate .jedate-content.bordge{border-left: 1px #e9e9e9 solid;}
|
||||
.jedate .jedate-content .yeartable,.jedate .jedate-content .monthtable{width: 100%;border-collapse: collapse;border-spacing: 0;border: 1px solid #fff;}
|
||||
.jedate .jedate-content .yeartable td,.jedate .jedate-content .monthtable td{width:73px;height: 51px;line-height: 51px;text-align:center; position:relative; overflow:hidden;font-size: 14px;}
|
||||
.jedate .jedate-content .yeartable td span,.jedate .jedate-content .monthtable td span{padding: 8px 10px;border: 1px solid #fff;}
|
||||
.jedate .jedate-content .yeartable td.action span,.jedate .jedate-content .monthtable td.action span,
|
||||
.jedate .jedate-content .yeartable td.action span:hover,.jedate .jedate-content .monthtable td.action span:hover{background-color:#00A680;border:1px #00A680 solid;color:#fff;}
|
||||
.jedate .jedate-content .yeartable td span:hover,.jedate .jedate-content .monthtable td span:hover{background-color:#f2f2f2;border: 1px #f2f2f2 solid;}
|
||||
.jedate .jedate-content .yeartable td.disabled span,.jedate .jedate-content .monthtable td.disabled span,
|
||||
.jedate .jedate-content .yeartable td.disabled span:hover,.jedate .jedate-content .monthtable td.disabled span:hover{color:#bbb;background-color:#fff;border: 1px solid #fff;}
|
||||
.jedate .jedate-content .yeartable td.contain span,.jedate .jedate-content .monthtable td.contain span,
|
||||
.jedate .jedate-content .yeartable td.contain span:hover,.jedate .jedate-content .monthtable td.contain span:hover{background-color: #D0F0E3;border:1px #D0F0E3 solid;}
|
||||
|
||||
.jedate.grid .daystable thead,.jedate.grid .daystable td{border: 1px #f2f2f2 solid;}
|
||||
.jedate .jedate-content .daystable{width: 100%;border-collapse: collapse;border-spacing: 0;border: 1px solid #fff;}
|
||||
.jedate .jedate-content .daystable thead{background-color:#fff;}
|
||||
.jedate .jedate-content .daystable th{width:31px;height:27px; text-align:center; position:relative; overflow:hidden;font-size: 12px;font-weight: 400;}
|
||||
.jedate .jedate-content .daystable td{width:31px;height:30px; text-align:center; position:relative; overflow:hidden;font-size: 14px;font-family: Arial, "\5b8b\4f53", 'sans-serif';}
|
||||
.jedate .jedate-content .daystable td .nolunar{line-height:29px;font-size: 14px;font-family: Arial, "\5b8b\4f53", 'sans-serif';}
|
||||
.jedate .jedate-content .daystable td .solar{height:14px;line-height:14px;font-size: 14px;padding-top: 2px;display: block;font-family: Arial, "\5b8b\4f53", 'sans-serif';}
|
||||
.jedate .jedate-content .daystable td .lunar{height:15px;line-height:15px;font-size: 12px;overflow:hidden;display: block;font-family: Arial, "\5b8b\4f53", 'sans-serif';color: #888;transform: scale(.95);}
|
||||
.jedate .jedate-content .daystable td.action,.jedate .jedate-content .daystable td.action:hover,
|
||||
.jedate .jedate-content .daystable td.action .lunar{background-color: #00A680;color:#fff;}
|
||||
.jedate .jedate-content .daystable td.other,.jedate .jedate-content .daystable td.other .nolunar,.jedate .jedate-content .daystable td.other .lunar{color:#00DDAA;}
|
||||
.jedate .jedate-content .daystable td.disabled,.jedate .jedate-content .daystable td.disabled .nolunar,.jedate .jedate-content .daystable td.disabled .lunar{ color:#bbb;}
|
||||
.jedate .jedate-content .daystable td.contain,.jedate .jedate-content .daystable td.contain:hover{background-color: #00DDAA;color:#fff;}
|
||||
.jedate .jedate-content .daystable td.disabled:hover{background-color:#fff;}
|
||||
.jedate .jedate-content .daystable td:hover{background-color:#f2f2f2;}
|
||||
.jedate .jedate-content .daystable td.red{ color:#ff0000;}
|
||||
.jedate .jedate-content .daystable td .marks{ width:5px; height:5px; background-color:#ff0000; -webkit-border-radius:50%;border-radius:50%; position:absolute; right:2px; top:4px;}
|
||||
.jedate .jedate-content .daystable td.action .marks{ width:5px; height:5px; background-color:#fff; -webkit-border-radius:50%;border-radius:50%; position:absolute; right:2px; top:4px;}
|
||||
|
||||
.jedate .jedate-time{overflow: hidden;padding-bottom: 4px; background-color:#fff;position: absolute;top:0;right: 0;z-index: 150;}
|
||||
.jedate .jedate-time .timepane{width:230px;float:left;}
|
||||
.jedate .jedate-time .timeheader{width: 100%;float:left;height: 36px;line-height: 36px;background-color: #f2f2f2;text-align: center;font-size: 14px;position: relative;}
|
||||
.jedate .jedate-time .timecontent{width: 100%;float:left;}
|
||||
.jedate .jedate-time .hmstitle{width: 211px;margin: 0 auto;overflow: hidden;padding-top: 4px;text-align: center;}
|
||||
.jedate .jedate-time .hmstitle p{width: 33.33%;float:left;height: 30px;line-height: 30px;font-size: 13px;}
|
||||
.jedate .jedate-time .hmslist{width: 211px;margin: 0 auto 6px auto;border: 1px solid #ddd;border-right: none;overflow: hidden;}
|
||||
.jedate .jedate-time .hmslist .hmsauto{height: 100%;margin: 0;text-align: center;}
|
||||
.jedate .jedate-time .hmslist ul {width: 70px;height: 174px;float: left;border-right: 1px solid #ddd;overflow: hidden;}
|
||||
.jedate .jedate-time .hmslist .hmsauto:hover ul {overflow-y: auto}
|
||||
.jedate .jedate-time .hmslist ul li {width: 130%;padding-left:26px;text-align: left;height: 25px;line-height: 25px;font-size: 14px;font-family: Arial, "\5b8b\4f53", 'sans-serif';}
|
||||
.jedate .jedate-time .hmslist ul li:hover{background-color: #F2F2F2;}
|
||||
.jedate .jedate-time .hmslist ul li.action,.jedate-time .hmslist ul li.action:hover{background-color: #00A680;color:#fff;}
|
||||
.jedate .jedate-time .hmslist ul li.disabled{ background-color: #fbfbfb;color:#ccc;}
|
||||
.jedate .jedate-time .hmslist ul li.disabled.action{ background-color: #00A680;color:#FFFFFF;filter:Alpha(opacity=30);opacity:.3; }
|
||||
|
||||
.jedate .jedate-footbtn{height: 36px;padding: 0 6px;border-top: 1px #e9e9e9 solid;overflow: hidden;}
|
||||
.jedate .jedate-footbtn .timecon{line-height:28px;padding:0 5px;background-color:#00A680;color:#fff;display:block;float: left;font-size: 12px;margin-top:4px;border-radius:4px;overflow: hidden;}
|
||||
.jedate .jedate-footbtn .btnscon{line-height:28px;margin-top:4px;display:block;float: right;font-size: 12px;border-radius:4px;overflow: hidden;}
|
||||
.jedate .jedate-footbtn .btnscon span{float:left; padding:0 5px;border-right: 1px #fff solid;background-color:#00A680;color:#fff;display:block;height:28px;line-height:28px;text-align:center;overflow:hidden;}
|
||||
.jedate .jedate-footbtn .btnscon span:last-child{border-right:none;}
|
BIN
public/sdk/3rdparty/jedate/skin/jedate.png
vendored
Normal file
After Width: | Height: | Size: 131 B |
BIN
public/sdk/3rdparty/jedate/skin/jedatefont.eot
vendored
Normal file
45
public/sdk/3rdparty/jedate/skin/jedatefont.svg
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<!--
|
||||
2013-9-30: Created.
|
||||
-->
|
||||
<svg>
|
||||
<metadata>
|
||||
Created by iconfont
|
||||
</metadata>
|
||||
<defs>
|
||||
|
||||
<font id="jedatefont" horiz-adv-x="1024" >
|
||||
<font-face
|
||||
font-family="jedatefont"
|
||||
font-weight="500"
|
||||
font-stretch="normal"
|
||||
units-per-em="1024"
|
||||
ascent="896"
|
||||
descent="-128"
|
||||
/>
|
||||
<missing-glyph />
|
||||
|
||||
<glyph glyph-name="x" unicode="x" horiz-adv-x="1001"
|
||||
d="M281 543q-27 -1 -53 -1h-83q-18 0 -36.5 -6t-32.5 -18.5t-23 -32t-9 -45.5v-76h912v41q0 16 -0.5 30t-0.5 18q0 13 -5 29t-17 29.5t-31.5 22.5t-49.5 9h-133v-97h-438v97zM955 310v-52q0 -23 0.5 -52t0.5 -58t-10.5 -47.5t-26 -30t-33 -16t-31.5 -4.5q-14 -1 -29.5 -0.5
|
||||
t-29.5 0.5h-32l-45 128h-439l-44 -128h-29h-34q-20 0 -45 1q-25 0 -41 9.5t-25.5 23t-13.5 29.5t-4 30v167h911zM163 247q-12 0 -21 -8.5t-9 -21.5t9 -21.5t21 -8.5q13 0 22 8.5t9 21.5t-9 21.5t-22 8.5zM316 123q-8 -26 -14 -48q-5 -19 -10.5 -37t-7.5 -25t-3 -15t1 -14.5
|
||||
t9.5 -10.5t21.5 -4h37h67h81h80h64h36q23 0 34 12t2 38q-5 13 -9.5 30.5t-9.5 34.5q-5 19 -11 39h-368zM336 498v228q0 11 2.5 23t10 21.5t20.5 15.5t34 6h188q31 0 51.5 -14.5t20.5 -52.5v-227h-327z" />
|
||||
|
||||
|
||||
|
||||
<glyph glyph-name="srightarrows" unicode="󭛅" d="M658.364 355.601l3.277 3.277c10.923 13.65299999 10.92300001 35.499-1e-8 48.606l-358.26299999 441.276c-10.923 13.65299999-28.399 13.107-39.868 0-10.923-13.65299999-10.92300001-35.499 0-48.606l338.057-416.154-338.603-417.246c-10.923-13.65299999-10.92300001-35.499 0-48.606s28.945-13.65299999 39.868 0l355.533 437.453zM470.494 858.044c-10.923-13.65299999-10.92300001-35.499 0-48.60600001l338.057-416.15399999-338.603-417.246c-10.923-13.65299999-10.92300001-35.499 0-48.606 10.923-13.65299999 28.945-13.65299999 39.868 0l356.079 438.545 3.277 3.27699999c10.923 13.65299999 10.92300001 35.499 0 48.60600001l-358.263 441.276c-11.469 12.561-29.491 12.561-40.414-1.092z" horiz-adv-x="1024" />
|
||||
|
||||
|
||||
<glyph glyph-name="drightarrows" unicode="󭘅" d="M445.646779-81.040479a25.502837 25.502837 0 0 0-18.128892 7.531534c-9.969049 10.011005-9.93425701 26.208918 0.076748 36.177967l413.84344601 412.08643-412.08540601 413.844469c-9.969049 10.012028-9.934257 26.209942 0.076748 36.178991 10.012028 9.970072 26.209942 9.93528 36.17899-0.076748l430.137551-431.972339a25.580608 25.580608 0 0 0-0.07674799-36.17899l-431.97131501-430.136528a25.50693 25.50693 0 0 0-18.051122-7.454786z" horiz-adv-x="1024" />
|
||||
|
||||
|
||||
<glyph glyph-name="dleftarrows-copy" unicode="󭘂" d="M578.353221 849.040479a25.502837 25.502837 0 0 0 18.128892-7.531534c9.969049-10.011005 9.93425701-26.208918-0.076748-36.177967l-413.84344601-412.08643 412.08540601-413.844469c9.969049-10.012028 9.934257-26.209942-0.076748-36.178991-10.012028-9.970072-26.209942-9.93528-36.17899 0.076748l-430.137551 431.972339a25.580608 25.580608 0 0 0 0.07674799 36.17899l431.97131501 430.136528a25.50693 25.50693 0 0 0 18.051122 7.454786z" horiz-adv-x="1024" />
|
||||
|
||||
|
||||
<glyph glyph-name="sleftarrows-copy" unicode="󭛂" d="M365.636 412.399l-3.277-3.277c-10.923-13.65299999-10.92300001-35.499 1e-8-48.606l358.26299999-441.276c10.923-13.65299999 28.399-13.107 39.868 0 10.923 13.65299999 10.92300001 35.499 0 48.606l-338.057 416.154 338.603 417.246c10.923 13.65299999 10.92300001 35.499 0 48.606s-28.945 13.65299999-39.868 0l-355.533-437.453zM553.506-90.04399999999998c10.923 13.65299999 10.92300001 35.499 0 48.60600001l-338.057 416.15399999 338.603 417.246c10.923 13.65299999 10.92300001 35.499 0 48.606-10.923 13.65299999-28.945 13.65299999-39.868 0l-356.079-438.545-3.277-3.27699999c-10.923-13.65299999-10.92300001-35.499 0-48.60600001l358.263-441.276c11.469-12.561 29.491-12.561 40.414 1.092z" horiz-adv-x="1024" />
|
||||
|
||||
|
||||
|
||||
|
||||
</font>
|
||||
</defs></svg>
|
After Width: | Height: | Size: 3.7 KiB |
BIN
public/sdk/3rdparty/jedate/skin/jedatefont.ttf
vendored
Normal file
BIN
public/sdk/3rdparty/jedate/skin/jedatefont.woff
vendored
Normal file
484
public/sdk/3rdparty/kriging.js
vendored
Normal file
@ -0,0 +1,484 @@
|
||||
// Extend the Array class
|
||||
Array.prototype.max = function() {
|
||||
return Math.max.apply(null, this);
|
||||
};
|
||||
Array.prototype.min = function() {
|
||||
return Math.min.apply(null, this);
|
||||
};
|
||||
Array.prototype.mean = function() {
|
||||
var i, sum;
|
||||
for(i=0,sum=0;i<this.length;i++)
|
||||
sum += this[i];
|
||||
return sum / this.length;
|
||||
};
|
||||
Array.prototype.pip = function(x, y) {
|
||||
var i, j, c = false;
|
||||
for(i=0,j=this.length-1;i<this.length;j=i++) {
|
||||
if( ((this[i][1]>y) != (this[j][1]>y)) &&
|
||||
(x<(this[j][0]-this[i][0]) * (y-this[i][1]) / (this[j][1]-this[i][1]) + this[i][0]) ) {
|
||||
c = !c;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
var kriging = function() {
|
||||
var kriging = {};
|
||||
|
||||
var createArrayWithValues = function(value, n) {
|
||||
var array = [];
|
||||
for ( var i = 0; i < n; i++) {
|
||||
array.push(value);
|
||||
}
|
||||
return array;
|
||||
},
|
||||
|
||||
// Matrix algebra
|
||||
kriging_matrix_diag = function(c, n) {
|
||||
var Z = createArrayWithValues(0, n * n);
|
||||
for(i=0;i<n;i++) Z[i*n+i] = c;
|
||||
return Z;
|
||||
},
|
||||
kriging_matrix_transpose = function(X, n, m) {
|
||||
var i, j, Z = Array(m*n);
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<m;j++)
|
||||
Z[j*n+i] = X[i*m+j];
|
||||
return Z;
|
||||
},
|
||||
kriging_matrix_scale = function(X, c, n, m) {
|
||||
var i, j;
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<m;j++)
|
||||
X[i*m+j] *= c;
|
||||
},
|
||||
kriging_matrix_add = function(X, Y, n, m) {
|
||||
var i, j, Z = Array(n*m);
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<m;j++)
|
||||
Z[i*m+j] = X[i*m+j] + Y[i*m+j];
|
||||
return Z;
|
||||
},
|
||||
// Naive matrix multiplication
|
||||
kriging_matrix_multiply = function(X, Y, n, m, p) {
|
||||
var i, j, k, Z = Array(n*p);
|
||||
for(i=0;i<n;i++) {
|
||||
for(j=0;j<p;j++) {
|
||||
Z[i*p+j] = 0;
|
||||
for(k=0;k<m;k++)
|
||||
Z[i*p+j] += X[i*m+k]*Y[k*p+j];
|
||||
}
|
||||
}
|
||||
return Z;
|
||||
},
|
||||
// Cholesky decomposition
|
||||
kriging_matrix_chol = function(X, n) {
|
||||
var i, j, k, sum, p = Array(n);
|
||||
for(i=0;i<n;i++) p[i] = X[i*n+i];
|
||||
for(i=0;i<n;i++) {
|
||||
for(j=0;j<i;j++)
|
||||
p[i] -= X[i*n+j]*X[i*n+j];
|
||||
if(p[i]<=0) return false;
|
||||
p[i] = Math.sqrt(p[i]);
|
||||
for(j=i+1;j<n;j++) {
|
||||
for(k=0;k<i;k++)
|
||||
X[j*n+i] -= X[j*n+k]*X[i*n+k];
|
||||
X[j*n+i] /= p[i];
|
||||
}
|
||||
}
|
||||
for(i=0;i<n;i++) X[i*n+i] = p[i];
|
||||
return true;
|
||||
},
|
||||
// Inversion of cholesky decomposition
|
||||
kriging_matrix_chol2inv = function(X, n) {
|
||||
var i, j, k, sum;
|
||||
for(i=0;i<n;i++) {
|
||||
X[i*n+i] = 1/X[i*n+i];
|
||||
for(j=i+1;j<n;j++) {
|
||||
sum = 0;
|
||||
for(k=i;k<j;k++)
|
||||
sum -= X[j*n+k]*X[k*n+i];
|
||||
X[j*n+i] = sum/X[j*n+j];
|
||||
}
|
||||
}
|
||||
for(i=0;i<n;i++)
|
||||
for(j=i+1;j<n;j++)
|
||||
X[i*n+j] = 0;
|
||||
for(i=0;i<n;i++) {
|
||||
X[i*n+i] *= X[i*n+i];
|
||||
for(k=i+1;k<n;k++)
|
||||
X[i*n+i] += X[k*n+i]*X[k*n+i];
|
||||
for(j=i+1;j<n;j++)
|
||||
for(k=j;k<n;k++)
|
||||
X[i*n+j] += X[k*n+i]*X[k*n+j];
|
||||
}
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<i;j++)
|
||||
X[i*n+j] = X[j*n+i];
|
||||
|
||||
},
|
||||
// Inversion via gauss-jordan elimination
|
||||
kriging_matrix_solve = function(X, n) {
|
||||
var m = n;
|
||||
var b = Array(n*n);
|
||||
var indxc = Array(n);
|
||||
var indxr = Array(n);
|
||||
var ipiv = Array(n);
|
||||
var i, icol, irow, j, k, l, ll;
|
||||
var big, dum, pivinv, temp;
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<n;j++) {
|
||||
if(i==j) b[i*n+j] = 1;
|
||||
else b[i*n+j] = 0;
|
||||
}
|
||||
for(j=0;j<n;j++) ipiv[j] = 0;
|
||||
for(i=0;i<n;i++) {
|
||||
big = 0;
|
||||
for(j=0;j<n;j++) {
|
||||
if(ipiv[j]!=1) {
|
||||
for(k=0;k<n;k++) {
|
||||
if(ipiv[k]==0) {
|
||||
if(Math.abs(X[j*n+k])>=big) {
|
||||
big = Math.abs(X[j*n+k]);
|
||||
irow = j;
|
||||
icol = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++(ipiv[icol]);
|
||||
|
||||
if(irow!=icol) {
|
||||
for(l=0;l<n;l++) {
|
||||
temp = X[irow*n+l];
|
||||
X[irow*n+l] = X[icol*n+l];
|
||||
X[icol*n+l] = temp;
|
||||
}
|
||||
for(l=0;l<m;l++) {
|
||||
temp = b[irow*n+l];
|
||||
b[irow*n+l] = b[icol*n+l];
|
||||
b[icol*n+l] = temp;
|
||||
}
|
||||
}
|
||||
indxr[i] = irow;
|
||||
indxc[i] = icol;
|
||||
|
||||
if(X[icol*n+icol]==0) return false; // Singular
|
||||
|
||||
pivinv = 1 / X[icol*n+icol];
|
||||
X[icol*n+icol] = 1;
|
||||
for(l=0;l<n;l++) X[icol*n+l] *= pivinv;
|
||||
for(l=0;l<m;l++) b[icol*n+l] *= pivinv;
|
||||
|
||||
for(ll=0;ll<n;ll++) {
|
||||
if(ll!=icol) {
|
||||
dum = X[ll*n+icol];
|
||||
X[ll*n+icol] = 0;
|
||||
for(l=0;l<n;l++) X[ll*n+l] -= X[icol*n+l]*dum;
|
||||
for(l=0;l<m;l++) b[ll*n+l] -= b[icol*n+l]*dum;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(l=(n-1);l>=0;l--)
|
||||
if(indxr[l]!=indxc[l]) {
|
||||
for(k=0;k<n;k++) {
|
||||
temp = X[k*n+indxr[l]];
|
||||
X[k*n+indxr[l]] = X[k*n+indxc[l]];
|
||||
X[k*n+indxc[l]] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
// Variogram models
|
||||
kriging_variogram_gaussian = function(h, nugget, range, sill, A) {
|
||||
return nugget + ((sill-nugget)/range)*
|
||||
( 1.0 - Math.exp(-(1.0/A)*Math.pow(h/range, 2)) );
|
||||
},
|
||||
kriging_variogram_exponential = function(h, nugget, range, sill, A) {
|
||||
return nugget + ((sill-nugget)/range)*
|
||||
( 1.0 - Math.exp(-(1.0/A) * (h/range)) );
|
||||
},
|
||||
kriging_variogram_spherical = function(h, nugget, range, sill, A) {
|
||||
if(h>range) return nugget + (sill-nugget)/range;
|
||||
return nugget + ((sill-nugget)/range)*
|
||||
( 1.5*(h/range) - 0.5*Math.pow(h/range, 3) );
|
||||
};
|
||||
|
||||
// Train using gaussian processes with bayesian priors
|
||||
kriging.train = function(t, x, y, model, sigma2, alpha) {
|
||||
var variogram = {
|
||||
t : t,
|
||||
x : x,
|
||||
y : y,
|
||||
nugget : 0.0,
|
||||
range : 0.0,
|
||||
sill : 0.0,
|
||||
A : 1/3,
|
||||
n : 0
|
||||
};
|
||||
switch(model) {
|
||||
case "gaussian":
|
||||
variogram.model = kriging_variogram_gaussian;
|
||||
break;
|
||||
case "exponential":
|
||||
variogram.model = kriging_variogram_exponential;
|
||||
break;
|
||||
case "spherical":
|
||||
variogram.model = kriging_variogram_spherical;
|
||||
break;
|
||||
};
|
||||
|
||||
// Lag distance/semivariance
|
||||
var i, j, k, l, n = t.length;
|
||||
var distance = Array((n*n-n)/2);
|
||||
for(i=0,k=0;i<n;i++)
|
||||
for(j=0;j<i;j++,k++) {
|
||||
distance[k] = Array(2);
|
||||
distance[k][0] = Math.pow(
|
||||
Math.pow(x[i]-x[j], 2)+
|
||||
Math.pow(y[i]-y[j], 2), 0.5);
|
||||
distance[k][1] = Math.abs(t[i]-t[j]);
|
||||
}
|
||||
distance.sort(function(a, b) { return a[0] - b[0]; });
|
||||
variogram.range = distance[(n*n-n)/2-1][0];
|
||||
|
||||
// Bin lag distance
|
||||
var lags = ((n*n-n)/2)>30?30:(n*n-n)/2;
|
||||
var tolerance = variogram.range/lags;
|
||||
var lag = createArrayWithValues(0,lags);
|
||||
var semi = createArrayWithValues(0,lags);
|
||||
if(lags<30) {
|
||||
for(l=0;l<lags;l++) {
|
||||
lag[l] = distance[l][0];
|
||||
semi[l] = distance[l][1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i=0,j=0,k=0,l=0;i<lags&&j<((n*n-n)/2);i++,k=0) {
|
||||
while( distance[j][0]<=((i+1)*tolerance) ) {
|
||||
lag[l] += distance[j][0];
|
||||
semi[l] += distance[j][1];
|
||||
j++;k++;
|
||||
if(j>=((n*n-n)/2)) break;
|
||||
}
|
||||
if(k>0) {
|
||||
lag[l] /= k;
|
||||
semi[l] /= k;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
if(l<2) return variogram; // Error: Not enough points
|
||||
}
|
||||
|
||||
// Feature transformation
|
||||
n = l;
|
||||
variogram.range = lag[n-1]-lag[0];
|
||||
var X = createArrayWithValues(1,2 * n);
|
||||
var Y = Array(n);
|
||||
var A = variogram.A;
|
||||
for(i=0;i<n;i++) {
|
||||
switch(model) {
|
||||
case "gaussian":
|
||||
X[i*2+1] = 1.0-Math.exp(-(1.0/A)*Math.pow(lag[i]/variogram.range, 2));
|
||||
break;
|
||||
case "exponential":
|
||||
X[i*2+1] = 1.0-Math.exp(-(1.0/A)*lag[i]/variogram.range);
|
||||
break;
|
||||
case "spherical":
|
||||
X[i*2+1] = 1.5*(lag[i]/variogram.range)-
|
||||
0.5*Math.pow(lag[i]/variogram.range, 3);
|
||||
break;
|
||||
};
|
||||
Y[i] = semi[i];
|
||||
}
|
||||
|
||||
// Least squares
|
||||
var Xt = kriging_matrix_transpose(X, n, 2);
|
||||
var Z = kriging_matrix_multiply(Xt, X, 2, n, 2);
|
||||
Z = kriging_matrix_add(Z, kriging_matrix_diag(1/alpha, 2), 2, 2);
|
||||
var cloneZ = Z.slice(0);
|
||||
if(kriging_matrix_chol(Z, 2))
|
||||
kriging_matrix_chol2inv(Z, 2);
|
||||
else {
|
||||
kriging_matrix_solve(cloneZ, 2);
|
||||
Z = cloneZ;
|
||||
}
|
||||
var W = kriging_matrix_multiply(kriging_matrix_multiply(Z, Xt, 2, 2, n), Y, 2, n, 1);
|
||||
|
||||
// Variogram parameters
|
||||
variogram.nugget = W[0];
|
||||
variogram.sill = W[1]*variogram.range+variogram.nugget;
|
||||
variogram.n = x.length;
|
||||
|
||||
// Gram matrix with prior
|
||||
n = x.length;
|
||||
var K = Array(n*n);
|
||||
for(i=0;i<n;i++) {
|
||||
for(j=0;j<i;j++) {
|
||||
K[i*n+j] = variogram.model(Math.pow(Math.pow(x[i]-x[j], 2)+
|
||||
Math.pow(y[i]-y[j], 2), 0.5),
|
||||
variogram.nugget,
|
||||
variogram.range,
|
||||
variogram.sill,
|
||||
variogram.A);
|
||||
K[j*n+i] = K[i*n+j];
|
||||
}
|
||||
K[i*n+i] = variogram.model(0, variogram.nugget,
|
||||
variogram.range,
|
||||
variogram.sill,
|
||||
variogram.A);
|
||||
}
|
||||
|
||||
// Inverse penalized Gram matrix projected to target vector
|
||||
var C = kriging_matrix_add(K, kriging_matrix_diag(sigma2, n), n, n);
|
||||
var cloneC = C.slice(0);
|
||||
if(kriging_matrix_chol(C, n))
|
||||
kriging_matrix_chol2inv(C, n);
|
||||
else {
|
||||
kriging_matrix_solve(cloneC, n);
|
||||
C = cloneC;
|
||||
}
|
||||
|
||||
// Copy unprojected inverted matrix as K
|
||||
var K = C.slice(0);
|
||||
var M = kriging_matrix_multiply(C, t, n, n, 1);
|
||||
variogram.K = K;
|
||||
variogram.M = M;
|
||||
|
||||
return variogram;
|
||||
};
|
||||
|
||||
// Model prediction
|
||||
kriging.predict = function(x, y, variogram) {
|
||||
var i, k = Array(variogram.n);
|
||||
for(i=0;i<variogram.n;i++)
|
||||
k[i] = variogram.model(Math.pow(Math.pow(x-variogram.x[i], 2)+
|
||||
Math.pow(y-variogram.y[i], 2), 0.5),
|
||||
variogram.nugget, variogram.range,
|
||||
variogram.sill, variogram.A);
|
||||
return kriging_matrix_multiply(k, variogram.M, 1, variogram.n, 1)[0];
|
||||
};
|
||||
kriging.variance = function(x, y, variogram) {
|
||||
var i, k = Array(variogram.n);
|
||||
for(i=0;i<variogram.n;i++)
|
||||
k[i] = variogram.model(Math.pow(Math.pow(x-variogram.x[i], 2)+
|
||||
Math.pow(y-variogram.y[i], 2), 0.5),
|
||||
variogram.nugget, variogram.range,
|
||||
variogram.sill, variogram.A);
|
||||
return variogram.model(0, variogram.nugget, variogram.range,
|
||||
variogram.sill, variogram.A)+
|
||||
kriging_matrix_multiply(kriging_matrix_multiply(k, variogram.K,
|
||||
1, variogram.n, variogram.n),
|
||||
k, 1, variogram.n, 1)[0];
|
||||
};
|
||||
|
||||
// Gridded matrices or contour paths
|
||||
kriging.grid = function(polygons, variogram, width) {
|
||||
var i, j, k, n = polygons.length;
|
||||
if(n==0) return;
|
||||
|
||||
// Boundaries of polygons space
|
||||
var xlim = [polygons[0][0][0], polygons[0][0][0]];
|
||||
var ylim = [polygons[0][0][1], polygons[0][0][1]];
|
||||
for(i=0;i<n;i++) // Polygons
|
||||
for(j=0;j<polygons[i].length;j++) { // Vertices
|
||||
if(polygons[i][j][0]<xlim[0])
|
||||
xlim[0] = polygons[i][j][0];
|
||||
if(polygons[i][j][0]>xlim[1])
|
||||
xlim[1] = polygons[i][j][0];
|
||||
if(polygons[i][j][1]<ylim[0])
|
||||
ylim[0] = polygons[i][j][1];
|
||||
if(polygons[i][j][1]>ylim[1])
|
||||
ylim[1] = polygons[i][j][1];
|
||||
}
|
||||
|
||||
// Alloc for O(n^2) space
|
||||
var xtarget, ytarget;
|
||||
var a = Array(2), b = Array(2);
|
||||
var lxlim = Array(2); // Local dimensions
|
||||
var lylim = Array(2); // Local dimensions
|
||||
var x = Math.ceil((xlim[1]-xlim[0])/width);
|
||||
var y = Math.ceil((ylim[1]-ylim[0])/width);
|
||||
|
||||
var A = Array(x+1);
|
||||
for(i=0;i<=x;i++) A[i] = Array(y+1);
|
||||
for(i=0;i<n;i++) {
|
||||
// Range for polygons[i]
|
||||
lxlim[0] = polygons[i][0][0];
|
||||
lxlim[1] = lxlim[0];
|
||||
lylim[0] = polygons[i][0][1];
|
||||
lylim[1] = lylim[0];
|
||||
for(j=1;j<polygons[i].length;j++) { // Vertices
|
||||
if(polygons[i][j][0]<lxlim[0])
|
||||
lxlim[0] = polygons[i][j][0];
|
||||
if(polygons[i][j][0]>lxlim[1])
|
||||
lxlim[1] = polygons[i][j][0];
|
||||
if(polygons[i][j][1]<lylim[0])
|
||||
lylim[0] = polygons[i][j][1];
|
||||
if(polygons[i][j][1]>lylim[1])
|
||||
lylim[1] = polygons[i][j][1];
|
||||
}
|
||||
|
||||
// Loop through polygon subspace
|
||||
a[0] = Math.floor(((lxlim[0]-((lxlim[0]-xlim[0])%width)) - xlim[0])/width);
|
||||
a[1] = Math.ceil(((lxlim[1]-((lxlim[1]-xlim[1])%width)) - xlim[0])/width);
|
||||
b[0] = Math.floor(((lylim[0]-((lylim[0]-ylim[0])%width)) - ylim[0])/width);
|
||||
b[1] = Math.ceil(((lylim[1]-((lylim[1]-ylim[1])%width)) - ylim[0])/width);
|
||||
for(j=a[0];j<=a[1];j++)
|
||||
for(k=b[0];k<=b[1];k++) {
|
||||
xtarget = xlim[0] + j*width;
|
||||
ytarget = ylim[0] + k*width;
|
||||
if(polygons[i].pip(xtarget, ytarget))
|
||||
A[j][k] = kriging.predict(xtarget,
|
||||
ytarget,
|
||||
variogram);
|
||||
}
|
||||
}
|
||||
A.xlim = xlim;
|
||||
A.ylim = ylim;
|
||||
A.zlim = [variogram.t.min(), variogram.t.max()];
|
||||
A.width = width;
|
||||
return A;
|
||||
};
|
||||
kriging.contour = function(value, polygons, variogram) {
|
||||
|
||||
};
|
||||
|
||||
// Plotting on the DOM
|
||||
kriging.plot = function(canvas, grid, xlim, ylim, colors) {
|
||||
// Clear screen
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Starting boundaries
|
||||
var range = [xlim[1]-xlim[0], ylim[1]-ylim[0], grid.zlim[1]-grid.zlim[0]];
|
||||
var i, j, x, y, z;
|
||||
var n = grid.length;
|
||||
var m = grid[0].length;
|
||||
var wx = Math.ceil(grid.width*canvas.width/(xlim[1]-xlim[0]));
|
||||
var wy = Math.ceil(grid.width*canvas.height/(ylim[1]-ylim[0]));
|
||||
for(i=0;i<n;i++)
|
||||
for(j=0;j<m;j++) {
|
||||
if(grid[i][j]==undefined) continue;
|
||||
x = canvas.width*(i*grid.width+grid.xlim[0]-xlim[0])/range[0];
|
||||
y = canvas.height*(1-(j*grid.width+grid.ylim[0]-ylim[0])/range[1]);
|
||||
z = (grid[i][j]-grid.zlim[0])/range[2];
|
||||
if(z<0.0) z = 0.0;
|
||||
if(z>1.0) z = 1.0;
|
||||
|
||||
ctx.fillStyle = colors[Math.floor((colors.length-1)*z)];
|
||||
ctx.fillRect(Math.round(x-wx/2), Math.round(y-wy/2), wx, wy);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
return kriging;
|
||||
}();
|
||||
// if (module && module.exports){
|
||||
// module.exports = kriging;
|
||||
// }
|
4
public/sdk/3rdparty/liveplayer/crossdomain.xml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<cross-domain-policy>
|
||||
<allow-access-from domain="*"/>
|
||||
</cross-domain-policy>
|
1
public/sdk/3rdparty/liveplayer/liveplayer-element.min.js
vendored
Normal file
BIN
public/sdk/3rdparty/liveplayer/liveplayer.swf
vendored
Normal file
2
public/sdk/3rdparty/md5.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<<o|u>>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<<t%32,n[14+(t+64>>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h<n.length;h+=16)c=l(r=c,e=f,o=i,u=a,n[h],7,-680876936),a=l(a,c,f,i,n[h+1],12,-389564586),i=l(i,a,c,f,n[h+2],17,606105819),f=l(f,i,a,c,n[h+3],22,-1044525330),c=l(c,f,i,a,n[h+4],7,-176418897),a=l(a,c,f,i,n[h+5],12,1200080426),i=l(i,a,c,f,n[h+6],17,-1473231341),f=l(f,i,a,c,n[h+7],22,-45705983),c=l(c,f,i,a,n[h+8],7,1770035416),a=l(a,c,f,i,n[h+9],12,-1958414417),i=l(i,a,c,f,n[h+10],17,-42063),f=l(f,i,a,c,n[h+11],22,-1990404162),c=l(c,f,i,a,n[h+12],7,1804603682),a=l(a,c,f,i,n[h+13],12,-40341101),i=l(i,a,c,f,n[h+14],17,-1502002290),c=g(c,f=l(f,i,a,c,n[h+15],22,1236535329),i,a,n[h+1],5,-165796510),a=g(a,c,f,i,n[h+6],9,-1069501632),i=g(i,a,c,f,n[h+11],14,643717713),f=g(f,i,a,c,n[h],20,-373897302),c=g(c,f,i,a,n[h+5],5,-701558691),a=g(a,c,f,i,n[h+10],9,38016083),i=g(i,a,c,f,n[h+15],14,-660478335),f=g(f,i,a,c,n[h+4],20,-405537848),c=g(c,f,i,a,n[h+9],5,568446438),a=g(a,c,f,i,n[h+14],9,-1019803690),i=g(i,a,c,f,n[h+3],14,-187363961),f=g(f,i,a,c,n[h+8],20,1163531501),c=g(c,f,i,a,n[h+13],5,-1444681467),a=g(a,c,f,i,n[h+2],9,-51403784),i=g(i,a,c,f,n[h+7],14,1735328473),c=v(c,f=g(f,i,a,c,n[h+12],20,-1926607734),i,a,n[h+5],4,-378558),a=v(a,c,f,i,n[h+8],11,-2022574463),i=v(i,a,c,f,n[h+11],16,1839030562),f=v(f,i,a,c,n[h+14],23,-35309556),c=v(c,f,i,a,n[h+1],4,-1530992060),a=v(a,c,f,i,n[h+4],11,1272893353),i=v(i,a,c,f,n[h+7],16,-155497632),f=v(f,i,a,c,n[h+10],23,-1094730640),c=v(c,f,i,a,n[h+13],4,681279174),a=v(a,c,f,i,n[h],11,-358537222),i=v(i,a,c,f,n[h+3],16,-722521979),f=v(f,i,a,c,n[h+6],23,76029189),c=v(c,f,i,a,n[h+9],4,-640364487),a=v(a,c,f,i,n[h+12],11,-421815835),i=v(i,a,c,f,n[h+15],16,530742520),c=m(c,f=v(f,i,a,c,n[h+2],23,-995338651),i,a,n[h],6,-198630844),a=m(a,c,f,i,n[h+7],10,1126891415),i=m(i,a,c,f,n[h+14],15,-1416354905),f=m(f,i,a,c,n[h+5],21,-57434055),c=m(c,f,i,a,n[h+12],6,1700485571),a=m(a,c,f,i,n[h+3],10,-1894986606),i=m(i,a,c,f,n[h+10],15,-1051523),f=m(f,i,a,c,n[h+1],21,-2054922799),c=m(c,f,i,a,n[h+8],6,1873313359),a=m(a,c,f,i,n[h+15],10,-30611744),i=m(i,a,c,f,n[h+6],15,-1560198380),f=m(f,i,a,c,n[h+13],21,1309151649),c=m(c,f,i,a,n[h+4],6,-145523070),a=m(a,c,f,i,n[h+11],10,-1120210379),i=m(i,a,c,f,n[h+2],15,718787259),f=m(f,i,a,c,n[h+9],21,-343485551),c=d(c,r),f=d(f,e),i=d(i,o),a=d(a,u);return[c,f,i,a]}function i(n){for(var t="",r=32*n.length,e=0;e<r;e+=8)t+=String.fromCharCode(n[e>>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e<t.length;e+=1)t[e]=0;for(var r=8*n.length,e=0;e<r;e+=8)t[e>>5]|=(255&n.charCodeAt(e/8))<<e%32;return t}function e(n){for(var t,r="0123456789abcdef",e="",o=0;o<n.length;o+=1)t=n.charCodeAt(o),e+=r.charAt(t>>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,16<e.length&&(e=c(e,8*n.length)),r=0;r<16;r+=1)o[r]=909522486^e[r],u[r]=1549556828^e[r];return t=c(o.concat(a(t)),512+8*t.length),i(c(u.concat(t),640))}(r(n),r(t))}function t(n,t,r){return t?r?u(t,n):e(u(t,n)):r?o(n):e(o(n))}"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:n.md5=t}(this);
|
||||
//# sourceMappingURL=md5.min.js.map
|
896
public/sdk/3rdparty/modelloader.js
vendored
Normal file
@ -0,0 +1,896 @@
|
||||
const _object_pattern = /^[og]\s*(.+)?/;
|
||||
const _material_library_pattern = /^mtllib /;
|
||||
const _material_use_pattern = /^usemtl /;
|
||||
const _map_use_pattern = /^usemap /;
|
||||
const _face_vertex_data_separator_pattern = /\s+/;
|
||||
|
||||
const _color = new Cesium.Color();
|
||||
|
||||
function ParserState() {
|
||||
const state = {
|
||||
objects: [],
|
||||
object: {},
|
||||
|
||||
vertices: [],
|
||||
normals: [],
|
||||
colors: [],
|
||||
uvs: [],
|
||||
|
||||
materials: {},
|
||||
materialLibraries: [],
|
||||
|
||||
startObject: function (name, fromDeclaration) {
|
||||
if (this.object && this.object.fromDeclaration === false) {
|
||||
this.object.name = name;
|
||||
this.object.fromDeclaration = (fromDeclaration !== false);
|
||||
return;
|
||||
}
|
||||
const previousMaterial = (this.object && typeof this.object.currentMaterial === 'function' ? this.object.currentMaterial() : undefined);
|
||||
if (this.object && typeof this.object._finalize === 'function') {
|
||||
this.object._finalize(true);
|
||||
}
|
||||
this.object = {
|
||||
name: name || '',
|
||||
fromDeclaration: (fromDeclaration !== false),
|
||||
|
||||
geometry: {
|
||||
vertices: [],
|
||||
normals: [],
|
||||
colors: [],
|
||||
uvs: [],
|
||||
hasUVIndices: false
|
||||
},
|
||||
materials: [],
|
||||
smooth: true,
|
||||
|
||||
startMaterial: function (name, libraries) {
|
||||
const previous = this._finalize(false);
|
||||
if (previous && (previous.inherited || previous.groupCount <= 0)) {
|
||||
this.materials.splice(previous.index, 1);
|
||||
}
|
||||
const material = {
|
||||
index: this.materials.length,
|
||||
name: name || '',
|
||||
mtllib: (Array.isArray(libraries) && libraries.length > 0 ? libraries[libraries.length - 1] : ''),
|
||||
smooth: (previous !== undefined ? previous.smooth : this.smooth),
|
||||
groupStart: (previous !== undefined ? previous.groupEnd : 0),
|
||||
groupEnd: -1,
|
||||
groupCount: -1,
|
||||
inherited: false,
|
||||
clone: function (index) {
|
||||
const cloned = {
|
||||
index: (typeof index === 'number' ? index : this.index),
|
||||
name: this.name,
|
||||
mtllib: this.mtllib,
|
||||
smooth: this.smooth,
|
||||
groupStart: 0,
|
||||
groupEnd: -1,
|
||||
groupCount: -1,
|
||||
inherited: false
|
||||
};
|
||||
cloned.clone = this.clone.bind(cloned);
|
||||
return cloned;
|
||||
}
|
||||
};
|
||||
this.materials.push(material);
|
||||
return material;
|
||||
},
|
||||
|
||||
currentMaterial: function () {
|
||||
if (this.materials.length > 0) {
|
||||
return this.materials[this.materials.length - 1];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
_finalize: function (end) {
|
||||
const lastMultiMaterial = this.currentMaterial();
|
||||
if (lastMultiMaterial && lastMultiMaterial.groupEnd === -1) {
|
||||
lastMultiMaterial.groupEnd = this.geometry.vertices.length / 3;
|
||||
lastMultiMaterial.groupCount = lastMultiMaterial.groupEnd - lastMultiMaterial.groupStart;
|
||||
lastMultiMaterial.inherited = false;
|
||||
}
|
||||
|
||||
if (end && this.materials.length > 1) {
|
||||
for (let mi = this.materials.length - 1; mi >= 0; mi--) {
|
||||
if (this.materials[mi].groupCount <= 0) {
|
||||
this.materials.splice(mi, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (end && this.materials.length === 0) {
|
||||
this.materials.push({
|
||||
name: '',
|
||||
smooth: this.smooth
|
||||
});
|
||||
}
|
||||
return lastMultiMaterial;
|
||||
}
|
||||
};
|
||||
|
||||
if (previousMaterial && previousMaterial.name && typeof previousMaterial.clone === 'function') {
|
||||
const declared = previousMaterial.clone(0);
|
||||
declared.inherited = true;
|
||||
this.object.materials.push(declared);
|
||||
}
|
||||
this.objects.push(this.object);
|
||||
},
|
||||
finalize: function () {
|
||||
if (this.object && typeof this.object._finalize === 'function') {
|
||||
this.object._finalize(true);
|
||||
}
|
||||
},
|
||||
parseVertexIndex: function (value, len) {
|
||||
const index = parseInt(value, 10);
|
||||
return (index >= 0 ? index - 1 : index + len / 3) * 3;
|
||||
},
|
||||
parseNormalIndex: function (value, len) {
|
||||
const index = parseInt(value, 10);
|
||||
return (index >= 0 ? index - 1 : index + len / 3) * 3;
|
||||
},
|
||||
parseUVIndex: function (value, len) {
|
||||
const index = parseInt(value, 10);
|
||||
return (index >= 0 ? index - 1 : index + len / 2) * 2;
|
||||
},
|
||||
addVertex: function (a, b, c) {
|
||||
const src = this.vertices;
|
||||
const dst = this.object.geometry.vertices;
|
||||
dst.push(src[a + 0], src[a + 1], src[a + 2]);
|
||||
dst.push(src[b + 0], src[b + 1], src[b + 2]);
|
||||
dst.push(src[c + 0], src[c + 1], src[c + 2]);
|
||||
},
|
||||
addVertexPoint: function (a) {
|
||||
const src = this.vertices;
|
||||
const dst = this.object.geometry.vertices;
|
||||
|
||||
dst.push(src[a + 0], src[a + 1], src[a + 2]);
|
||||
},
|
||||
addVertexLine: function (a) {
|
||||
const src = this.vertices;
|
||||
const dst = this.object.geometry.vertices;
|
||||
dst.push(src[a + 0], src[a + 1], src[a + 2]);
|
||||
},
|
||||
addNormal: function (a, b, c) {
|
||||
const src = this.normals;
|
||||
const dst = this.object.geometry.normals;
|
||||
|
||||
dst.push(src[a + 0], src[a + 1], src[a + 2]);
|
||||
dst.push(src[b + 0], src[b + 1], src[b + 2]);
|
||||
dst.push(src[c + 0], src[c + 1], src[c + 2]);
|
||||
},
|
||||
addFaceNormal: function (a, b, c) {
|
||||
console.warn("addFaceNormal");
|
||||
// const src = this.vertices;
|
||||
// const dst = this.object.geometry.normals;
|
||||
|
||||
// _vA.fromArray( src, a );
|
||||
// _vB.fromArray( src, b );
|
||||
// _vC.fromArray( src, c );
|
||||
|
||||
// _cb.subVectors( _vC, _vB );
|
||||
// _ab.subVectors( _vA, _vB );
|
||||
// _cb.cross( _ab );
|
||||
|
||||
// _cb.normalize();
|
||||
|
||||
// dst.push( _cb.x, _cb.y, _cb.z );
|
||||
// dst.push( _cb.x, _cb.y, _cb.z );
|
||||
// dst.push( _cb.x, _cb.y, _cb.z );
|
||||
},
|
||||
addColor: function (a, b, c) {
|
||||
const src = this.colors;
|
||||
const dst = this.object.geometry.colors;
|
||||
if (src[a] !== undefined) dst.push(src[a + 0], src[a + 1], src[a + 2]);
|
||||
if (src[b] !== undefined) dst.push(src[b + 0], src[b + 1], src[b + 2]);
|
||||
if (src[c] !== undefined) dst.push(src[c + 0], src[c + 1], src[c + 2]);
|
||||
},
|
||||
addUV: function (a, b, c) {
|
||||
const src = this.uvs;
|
||||
const dst = this.object.geometry.uvs;
|
||||
dst.push(src[a + 0], src[a + 1]);
|
||||
dst.push(src[b + 0], src[b + 1]);
|
||||
dst.push(src[c + 0], src[c + 1]);
|
||||
},
|
||||
addDefaultUV: function () {
|
||||
const dst = this.object.geometry.uvs;
|
||||
dst.push(0, 0);
|
||||
dst.push(0, 0);
|
||||
dst.push(0, 0);
|
||||
},
|
||||
addUVLine: function (a) {
|
||||
const src = this.uvs;
|
||||
const dst = this.object.geometry.uvs;
|
||||
dst.push(src[a + 0], src[a + 1]);
|
||||
},
|
||||
addFace: function (a, b, c, ua, ub, uc, na, nb, nc) {
|
||||
const vLen = this.vertices.length;
|
||||
let ia = this.parseVertexIndex(a, vLen);
|
||||
let ib = this.parseVertexIndex(b, vLen);
|
||||
let ic = this.parseVertexIndex(c, vLen);
|
||||
this.addVertex(ia, ib, ic);
|
||||
this.addColor(ia, ib, ic);
|
||||
if (na !== undefined && na !== '') {
|
||||
const nLen = this.normals.length;
|
||||
ia = this.parseNormalIndex(na, nLen);
|
||||
ib = this.parseNormalIndex(nb, nLen);
|
||||
ic = this.parseNormalIndex(nc, nLen);
|
||||
this.addNormal(ia, ib, ic);
|
||||
} else {
|
||||
this.addFaceNormal(ia, ib, ic);
|
||||
}
|
||||
if (ua !== undefined && ua !== '') {
|
||||
const uvLen = this.uvs.length;
|
||||
ia = this.parseUVIndex(ua, uvLen);
|
||||
ib = this.parseUVIndex(ub, uvLen);
|
||||
ic = this.parseUVIndex(uc, uvLen);
|
||||
this.addUV(ia, ib, ic);
|
||||
this.object.geometry.hasUVIndices = true;
|
||||
} else {
|
||||
this.addDefaultUV();
|
||||
}
|
||||
},
|
||||
addPointGeometry: function (vertices) {
|
||||
this.object.geometry.type = 'Points';
|
||||
const vLen = this.vertices.length;
|
||||
for (let vi = 0, l = vertices.length; vi < l; vi++) {
|
||||
const index = this.parseVertexIndex(vertices[vi], vLen);
|
||||
this.addVertexPoint(index);
|
||||
this.addColor(index);
|
||||
}
|
||||
},
|
||||
addLineGeometry: function (vertices, uvs) {
|
||||
this.object.geometry.type = 'Line';
|
||||
const vLen = this.vertices.length;
|
||||
const uvLen = this.uvs.length;
|
||||
for (let vi = 0, l = vertices.length; vi < l; vi++) {
|
||||
this.addVertexLine(this.parseVertexIndex(vertices[vi], vLen));
|
||||
}
|
||||
for (let uvi = 0, l = uvs.length; uvi < l; uvi++) {
|
||||
this.addUVLine(this.parseUVIndex(uvs[uvi], uvLen));
|
||||
}
|
||||
}
|
||||
};
|
||||
state.startObject('', false);
|
||||
return state;
|
||||
}
|
||||
|
||||
class AModelLoader {
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步调用
|
||||
* @param {*} url
|
||||
*/
|
||||
Load(url) {
|
||||
//解析obj数据
|
||||
return Cesium.Resource.fetchText(url).then((result) => {
|
||||
return this.Parse(result, url.substring(0, url.lastIndexOf('/') + 1));
|
||||
});
|
||||
}
|
||||
|
||||
Parse(text, path) {
|
||||
const state = new ParserState();
|
||||
if (text.indexOf('\r\n') !== -1) {
|
||||
text = text.replace(/\r\n/g, '\n');
|
||||
}
|
||||
if (text.indexOf('\\\n') !== -1) {
|
||||
text = text.replace(/\\\n/g, '');
|
||||
}
|
||||
const lines = text.split('\n');
|
||||
let result = [];
|
||||
for (let i = 0, l = lines.length; i < l; i++) {
|
||||
const line = lines[i].trimStart();
|
||||
if (line.length === 0) continue;
|
||||
const lineFirstChar = line.charAt(0);
|
||||
if (lineFirstChar === '#') continue;
|
||||
if (lineFirstChar === 'v') {
|
||||
const data = line.split(_face_vertex_data_separator_pattern);
|
||||
switch (data[0]) {
|
||||
case 'v':
|
||||
state.vertices.push(
|
||||
parseFloat(data[1]),
|
||||
parseFloat(data[2]),
|
||||
parseFloat(data[3])
|
||||
);
|
||||
if (data.length >= 7) {
|
||||
Cesium.Color.fromBytes(
|
||||
parseFloat(data[4]),
|
||||
parseFloat(data[5]),
|
||||
parseFloat(data[6]),
|
||||
1,
|
||||
_color
|
||||
);
|
||||
state.colors.push(_color.red, _color.green, _color.blue);
|
||||
} else {
|
||||
state.colors.push(undefined, undefined, undefined);
|
||||
}
|
||||
break;
|
||||
case 'vn':
|
||||
state.normals.push(
|
||||
parseFloat(data[1]),
|
||||
parseFloat(data[2]),
|
||||
parseFloat(data[3])
|
||||
);
|
||||
break;
|
||||
case 'vt':
|
||||
state.uvs.push(
|
||||
parseFloat(data[1]),
|
||||
parseFloat(data[2])
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (lineFirstChar === 'f') {
|
||||
const lineData = line.slice(1).trim();
|
||||
const vertexData = lineData.split(_face_vertex_data_separator_pattern);
|
||||
const faceVertices = [];
|
||||
for (let j = 0, jl = vertexData.length; j < jl; j++) {
|
||||
const vertex = vertexData[j];
|
||||
if (vertex.length > 0) {
|
||||
const vertexParts = vertex.split('/');
|
||||
faceVertices.push(vertexParts);
|
||||
}
|
||||
}
|
||||
const v1 = faceVertices[0];
|
||||
for (let j = 1, jl = faceVertices.length - 1; j < jl; j++) {
|
||||
const v2 = faceVertices[j];
|
||||
const v3 = faceVertices[j + 1];
|
||||
state.addFace(
|
||||
v1[0], v2[0], v3[0],
|
||||
v1[1], v2[1], v3[1],
|
||||
v1[2], v2[2], v3[2]
|
||||
);
|
||||
}
|
||||
} else if (lineFirstChar === 'l') {
|
||||
const lineParts = line.substring(1).trim().split(' ');
|
||||
let lineVertices = [];
|
||||
const lineUVs = [];
|
||||
if (line.indexOf('/') === -1) {
|
||||
lineVertices = lineParts;
|
||||
} else {
|
||||
for (let li = 0, llen = lineParts.length; li < llen; li++) {
|
||||
const parts = lineParts[li].split('/');
|
||||
if (parts[0] !== '') lineVertices.push(parts[0]);
|
||||
if (parts[1] !== '') lineUVs.push(parts[1]);
|
||||
}
|
||||
}
|
||||
state.addLineGeometry(lineVertices, lineUVs);
|
||||
} else if (lineFirstChar === 'p') {
|
||||
const lineData = line.slice(1).trim();
|
||||
const pointData = lineData.split(' ');
|
||||
state.addPointGeometry(pointData);
|
||||
} else if ((result = _object_pattern.exec(line)) !== null) {
|
||||
const name = (' ' + result[0].slice(1).trim()).slice(1);
|
||||
state.startObject(name);
|
||||
} else if (_material_use_pattern.test(line)) {
|
||||
state.object.startMaterial(line.substring(7).trim(), state.materialLibraries);
|
||||
} else if (_material_library_pattern.test(line)) {
|
||||
state.materialLibraries.push(line.substring(7).trim());
|
||||
} else if (_map_use_pattern.test(line)) {
|
||||
console.warn('Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');
|
||||
} else if (lineFirstChar === 's') {
|
||||
result = line.split(' ');
|
||||
if (result.length > 1) {
|
||||
const value = result[1].trim().toLowerCase();
|
||||
state.object.smooth = (value !== '0' && value !== 'off');
|
||||
} else {
|
||||
state.object.smooth = true;
|
||||
}
|
||||
const material = state.object.currentMaterial();
|
||||
if (material) material.smooth = state.object.smooth;
|
||||
} else {
|
||||
if (line === '\0') continue;
|
||||
console.warn('Unexpected line: "' + line + '"');
|
||||
}
|
||||
}
|
||||
|
||||
state.finalize();
|
||||
|
||||
const container = new Node();
|
||||
const hasPrimitives = !(state.objects.length === 1 && state.objects[0].geometry.vertices.length === 0);
|
||||
|
||||
if (hasPrimitives === true) {
|
||||
for (let i = 0, l = state.objects.length; i < l; i++) {
|
||||
const object = state.objects[i];
|
||||
const geometry = object.geometry;
|
||||
const materials = object.materials;
|
||||
if (geometry.vertices.length === 0) continue;
|
||||
|
||||
let mesh = new Mesh(this.context, geometry);
|
||||
for (let mi = 0, miLen = materials.length; mi < miLen; mi++) {
|
||||
const sourceMaterial = materials[mi];
|
||||
const materialHash = sourceMaterial.name + '_' + sourceMaterial.smooth + '_';
|
||||
let material = state.materials[materialHash];
|
||||
|
||||
if (this.materials !== null) {
|
||||
console.log("material");
|
||||
}
|
||||
|
||||
if (material === undefined) {
|
||||
material = new Material(this.context, geometry, path, sourceMaterial.mtllib);
|
||||
material.name = sourceMaterial.name;
|
||||
material.flatShading = sourceMaterial.smooth ? false : true;
|
||||
|
||||
state.materials[materialHash] = material;
|
||||
}
|
||||
mesh.setMaterial(material);
|
||||
}
|
||||
|
||||
mesh.name = object.name;
|
||||
|
||||
container.add(mesh);
|
||||
}
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Material {
|
||||
constructor(context, geometry, path, mtllib) {
|
||||
this.context = context;
|
||||
this.ready = false;
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 512; //默认
|
||||
canvas.height = 512; //默认
|
||||
this.canvas = canvas;
|
||||
|
||||
let promise = Cesium.Resource.fetchText(path + mtllib)
|
||||
.then(async (text) => {
|
||||
let result = [];
|
||||
const lines = text.split('\n');
|
||||
for (let i = 0, l = lines.length; i < l; i++) {
|
||||
const line = lines[i].trimStart();
|
||||
if (line.length === 0) continue;
|
||||
const t = line.split(' ')[0];
|
||||
if (t === "map_Kd") {
|
||||
let map = line.split(' ')[1];
|
||||
result.push({
|
||||
diffusemap: await this.loadTexture(path + map)
|
||||
})
|
||||
}
|
||||
}
|
||||
return Promise.all(result);
|
||||
});
|
||||
|
||||
//创建shader
|
||||
let vs = "attribute vec3 position;\n";
|
||||
let fs = "";
|
||||
|
||||
let outVS = "";
|
||||
|
||||
let hasNormal = false;
|
||||
let hasVertexColors = false;
|
||||
let hasSt = false;
|
||||
|
||||
if (geometry.normals.length > 0) {
|
||||
hasNormal = true;
|
||||
}
|
||||
//顶点色
|
||||
if (geometry.colors.length > 0) {
|
||||
hasVertexColors = true;
|
||||
}
|
||||
// UV
|
||||
if (geometry.hasUVIndices === true) {
|
||||
hasSt = true;
|
||||
}
|
||||
|
||||
if (hasNormal) {
|
||||
vs += "attribute vec3 normal;\n";
|
||||
|
||||
vs += "varying vec3 v_normal;\n";
|
||||
fs += "varying vec3 v_normal;\n";
|
||||
outVS += "v_normal = normal;\n";
|
||||
}
|
||||
|
||||
if (hasVertexColors) {
|
||||
vs += "attribute vec3 color;\n";
|
||||
|
||||
vs += "varying vec2 v_color;\n";
|
||||
fs += "varying vec2 v_color;\n";
|
||||
outVS += "v_color = color;\n";
|
||||
}
|
||||
|
||||
if (hasSt) {
|
||||
vs += "attribute vec2 uv;\n";
|
||||
vs += "varying vec2 v_uv;\n";
|
||||
|
||||
fs += "varying vec2 v_uv;\n";
|
||||
outVS += "v_uv = uv;\n";
|
||||
}
|
||||
|
||||
vs += `
|
||||
void main() {
|
||||
gl_Position = czm_modelViewProjection * vec4(position, 1.);
|
||||
${outVS}
|
||||
}
|
||||
`;
|
||||
|
||||
fs += `
|
||||
uniform sampler2D colorTexture;
|
||||
void main() {
|
||||
vec4 color = texture2D(colorTexture, v_uv);
|
||||
gl_FragColor = color;
|
||||
}
|
||||
`;
|
||||
|
||||
this.program = Cesium.ShaderProgram.fromCache({
|
||||
context: context,
|
||||
vertexShaderSource: vs,
|
||||
fragmentShaderSource: fs
|
||||
});
|
||||
|
||||
this.uniformMap = {};
|
||||
|
||||
let that = this;
|
||||
promise.then((images) => {
|
||||
for (let i = 0; i < images.length; i++) {
|
||||
const element = images[i];
|
||||
let diffusemap = element.diffusemap;
|
||||
this.uniformMap.colorTexture = () => {
|
||||
return diffusemap;
|
||||
};
|
||||
}
|
||||
that.ready = true;
|
||||
});
|
||||
}
|
||||
|
||||
updateColorTexture(video, width, height) {
|
||||
if (this.ready && Cesium.defined(video.videojs)) {
|
||||
video.videojs.play();
|
||||
let colorTexture = this.uniformMap.colorTexture();
|
||||
if (video.playing && video.timeupdate) {
|
||||
if (width !== colorTexture.width || height !== colorTexture.height) {
|
||||
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
|
||||
// 重新创建texture
|
||||
const canvasContext = this.canvas.getContext("2d");
|
||||
canvasContext.drawImage(
|
||||
video.dom,
|
||||
0,
|
||||
0,
|
||||
video.width,
|
||||
video.height,
|
||||
0,
|
||||
0,
|
||||
this.canvas.width,
|
||||
this.canvas.height
|
||||
);
|
||||
|
||||
let texture = new Cesium.Texture({
|
||||
context: this.context,
|
||||
source: this.canvas
|
||||
});
|
||||
|
||||
this.uniformMap.colorTexture = () => {
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
const canvasContext = this.canvas.getContext("2d");
|
||||
canvasContext.drawImage(
|
||||
video.dom,
|
||||
0,
|
||||
0,
|
||||
video.width,
|
||||
video.height,
|
||||
0,
|
||||
0,
|
||||
this.canvas.width,
|
||||
this.canvas.height
|
||||
);
|
||||
this.uniformMap.colorTexture().copyFrom({
|
||||
source: this.canvas
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setCommand(drawCommand) {
|
||||
drawCommand.shaderProgram = this.program;
|
||||
drawCommand.uniformMap = this.uniformMap;
|
||||
}
|
||||
|
||||
loadTexture(url) {
|
||||
return Cesium.Resource.fetchImage(url)
|
||||
.then((image) => {
|
||||
this.canvas.width = image.width;
|
||||
this.canvas.height = image.height;
|
||||
const canvasContext = this.canvas.getContext("2d");
|
||||
canvasContext.drawImage(
|
||||
image,
|
||||
0,
|
||||
0,
|
||||
image.width,
|
||||
image.height,
|
||||
0,
|
||||
0,
|
||||
this.canvas.width,
|
||||
this.canvas.height,
|
||||
);
|
||||
let texture = new Cesium.Texture({
|
||||
context: this.context,
|
||||
source: this.canvas,
|
||||
sampler: Cesium.Sampler.NEAREST
|
||||
});
|
||||
return texture;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Mesh {
|
||||
constructor(context, geometry) {
|
||||
this.name = undefined;
|
||||
this.geometry = geometry;
|
||||
const vaAttributes = [];
|
||||
let index = 0;
|
||||
|
||||
this.material = undefined;
|
||||
|
||||
//创建顶点索引
|
||||
const vertexBuffer = Cesium.Buffer.createVertexBuffer({
|
||||
context: context,
|
||||
typedArray: Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, geometry.vertices),
|
||||
usage: Cesium.BufferUsage.STATIC_DRAW
|
||||
});
|
||||
vaAttributes.push({
|
||||
index: index,
|
||||
enabled: true,
|
||||
vertexBuffer: vertexBuffer,
|
||||
componentDatatype: Cesium.ComponentDatatype.FLOAT,
|
||||
componentsPerAttribute: 3,
|
||||
normalize: false
|
||||
});
|
||||
//法线
|
||||
if (geometry.normals.length > 0) {
|
||||
index++;
|
||||
const normalBuffer = Cesium.Buffer.createVertexBuffer({
|
||||
context: context,
|
||||
typedArray: Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, geometry.normals),
|
||||
usage: Cesium.BufferUsage.STATIC_DRAW
|
||||
});
|
||||
|
||||
vaAttributes.push({
|
||||
index: index,
|
||||
enabled: true,
|
||||
vertexBuffer: normalBuffer,
|
||||
componentDatatype: Cesium.ComponentDatatype.FLOAT,
|
||||
componentsPerAttribute: 3,
|
||||
normalize: false
|
||||
});
|
||||
}
|
||||
//顶点色
|
||||
if (geometry.colors.length > 0) {
|
||||
index++;
|
||||
const colorBuffer = Cesium.Buffer.createVertexBuffer({
|
||||
context: context,
|
||||
typedArray: Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, geometry.colors),
|
||||
usage: Cesium.BufferUsage.STATIC_DRAW
|
||||
});
|
||||
|
||||
vaAttributes.push({
|
||||
index: index,
|
||||
enabled: true,
|
||||
vertexBuffer: colorBuffer,
|
||||
componentDatatype: Cesium.ComponentDatatype.FLOAT,
|
||||
componentsPerAttribute: 3,
|
||||
normalize: false
|
||||
});
|
||||
}
|
||||
// UV
|
||||
if (geometry.hasUVIndices === true) {
|
||||
index++;
|
||||
const uvBuffer = Cesium.Buffer.createVertexBuffer({
|
||||
context: context,
|
||||
typedArray: Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, geometry.uvs),
|
||||
usage: Cesium.BufferUsage.STATIC_DRAW
|
||||
});
|
||||
|
||||
vaAttributes.push({
|
||||
index: index,
|
||||
enabled: true,
|
||||
vertexBuffer: uvBuffer,
|
||||
componentDatatype: Cesium.ComponentDatatype.FLOAT,
|
||||
componentsPerAttribute: 2,
|
||||
normalize: false
|
||||
});
|
||||
}
|
||||
|
||||
const vertexArray = new Cesium.VertexArray({
|
||||
context: context,
|
||||
attributes: vaAttributes
|
||||
});
|
||||
|
||||
const renderState = Cesium.RenderState.fromCache({
|
||||
cull: {
|
||||
enabled: false
|
||||
},
|
||||
depthMask: true,
|
||||
depthTest: {
|
||||
enabled: true,
|
||||
}
|
||||
});
|
||||
|
||||
this.drawCommand = new Cesium.DrawCommand({
|
||||
owner: this,
|
||||
primitiveType: Cesium.PrimitiveType.TRIANGLES,
|
||||
vertexArray: vertexArray,
|
||||
renderState: renderState,
|
||||
pass: Cesium.Pass.OPAQUE,
|
||||
// debugShowBoundingVolume: true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setMaterial(material) {
|
||||
this.material = material;
|
||||
material.setCommand(this.drawCommand);
|
||||
}
|
||||
|
||||
update(frameState) {
|
||||
if (Cesium.defined(this.material)) {
|
||||
if (this.material.ready) {
|
||||
frameState.commandList.push(this.drawCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateVideo(camera, video, cullingVolume) {
|
||||
if (Cesium.defined(this.material)) {
|
||||
if (this.material.ready) {
|
||||
const visibility = cullingVolume.computeVisibility(this.drawCommand.boundingVolume);
|
||||
if (visibility >= 0 && this.material.ready) {
|
||||
//如果视频可见
|
||||
//计算level
|
||||
// cam
|
||||
let distance = camera.distanceToBoundingSphere(this.drawCommand.boundingVolume);
|
||||
let width = video.width;
|
||||
let height = video.height;
|
||||
if (distance >= 20 && distance < 100) {
|
||||
width = video.width / 2;
|
||||
height = video.height / 2;
|
||||
} else if (distance >= 100) {
|
||||
width = video.width / 10;
|
||||
height = video.height / 10;
|
||||
}
|
||||
this.material.updateColorTexture(video, width, height)
|
||||
} else {
|
||||
if (video.videojs) {
|
||||
video.videojs.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Node {
|
||||
constructor() {
|
||||
this._modelMatrix = Cesium.Matrix4.IDENTITY;
|
||||
|
||||
this.parent = null;
|
||||
this.children = [];
|
||||
|
||||
this.video = {
|
||||
videojs: null,
|
||||
dom: null,
|
||||
playing: false,
|
||||
timeupdate: false,
|
||||
width: 0,
|
||||
height: 0
|
||||
}
|
||||
}
|
||||
|
||||
get modelMatrix() {
|
||||
return this._modelMatrix;
|
||||
}
|
||||
|
||||
set modelMatrix(matrix) {
|
||||
this._modelMatrix = matrix.clone();
|
||||
this.updateModelMatrix();
|
||||
}
|
||||
|
||||
updateModelMatrix() {
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
const child = this.children[i];
|
||||
|
||||
child.drawCommand.modelMatrix = this._modelMatrix;
|
||||
//计算包围盒
|
||||
const sphere = Cesium.BoundingSphere.fromVertices(child.geometry.vertices);
|
||||
let newMat = Cesium.Matrix4.multiplyByTranslation(this._modelMatrix, sphere.center, new Cesium.Matrix4());
|
||||
sphere.center = Cesium.Matrix4.getTranslation(newMat, new Cesium.Cartesian3());
|
||||
child.drawCommand.boundingVolume = sphere;
|
||||
}
|
||||
}
|
||||
|
||||
setPosition(position) {
|
||||
Cesium.Matrix4.multiplyByTranslation(this._modelMatrix, position, this._modelMatrix);
|
||||
this.updateModelMatrix();
|
||||
}
|
||||
|
||||
add(object) {
|
||||
object.parent = this;
|
||||
this.children.push(object);
|
||||
}
|
||||
|
||||
update(frameState) {
|
||||
let camera = frameState.camera;
|
||||
const cullingVolume = camera.frustum.computeCullingVolume(
|
||||
camera.positionWC,
|
||||
camera.directionWC,
|
||||
camera.upWC
|
||||
);
|
||||
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
const child = this.children[i];
|
||||
child.update(frameState);
|
||||
|
||||
if (Cesium.defined(this.video.videojs)) {
|
||||
child.updateVideo(camera, this.video, cullingVolume);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置视频
|
||||
* @param {*} url
|
||||
*/
|
||||
setVideo(url) {
|
||||
this.video.playing = false;
|
||||
this.video.timeupdate = false;
|
||||
|
||||
let videoType = /^.+\.m3u8$/.test(url) ? "application/x-mpegURL" : "video/mp4";
|
||||
if (!Cesium.defined(this.video.videojs)) {
|
||||
//
|
||||
const video = document.createElement('video');
|
||||
video.setAttribute("id", "video_" + Cesium.createGuid());
|
||||
video.setAttribute('crossorigin', 'anonymous');
|
||||
video.setAttribute('muted', '');
|
||||
// video.muted = true;
|
||||
video.autoplay = true;
|
||||
video.loop = true;
|
||||
video.preload = "auto";
|
||||
video.style.display = 'none';
|
||||
video.width = 512;
|
||||
video.height = 512;
|
||||
video.style.objectFit = 'fill'
|
||||
|
||||
this.video.videojs = videojs(video, {
|
||||
techOrder: ['html5']
|
||||
}, () => {
|
||||
});
|
||||
|
||||
video.addEventListener('playing', () => {
|
||||
// console.log(video.videoWidth)
|
||||
// //获取video 宽高
|
||||
this.video.width = video.videoWidth;
|
||||
this.video.height = video.videoHeight;
|
||||
this.video.playing = true;
|
||||
}, true);
|
||||
|
||||
video.addEventListener('timeupdate', () => {
|
||||
this.video.timeupdate = true;
|
||||
}, true);
|
||||
|
||||
this.video.dom = video;
|
||||
// document.body.appendChild(video)
|
||||
}
|
||||
|
||||
this.video.videojs.src([{
|
||||
src: url,
|
||||
type: videoType
|
||||
}]);
|
||||
this.video.videojs.play();
|
||||
}
|
||||
}
|
1
public/sdk/3rdparty/modelloadermin.js
vendored
Normal file
2
public/sdk/3rdparty/pako.min.js
vendored
Normal file
1921
public/sdk/3rdparty/proj4.js
vendored
Normal file
382
public/sdk/3rdparty/reconnecting-websocket.js
vendored
Normal file
@ -0,0 +1,382 @@
|
||||
// MIT License:
|
||||
//
|
||||
// Copyright (c) 2010-2012, Joe Walnes
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* This behaves like a WebSocket in every way, except if it fails to connect,
|
||||
* or it gets disconnected, it will repeatedly poll until it successfully connects
|
||||
* again.
|
||||
*
|
||||
* It is API compatible, so when you have:
|
||||
* ws = new WebSocket('ws://....');
|
||||
* you can replace with:
|
||||
* ws = new ReconnectingWebSocket('ws://....');
|
||||
*
|
||||
* The event stream will typically look like:
|
||||
* onconnecting
|
||||
* onopen
|
||||
* onmessage
|
||||
* onmessage
|
||||
* onclose // lost connection
|
||||
* onconnecting
|
||||
* onopen // sometime later...
|
||||
* onmessage
|
||||
* onmessage
|
||||
* etc...
|
||||
*
|
||||
* It is API compatible with the standard WebSocket API, apart from the following members:
|
||||
*
|
||||
* - `bufferedAmount`
|
||||
* - `extensions`
|
||||
* - `binaryType`
|
||||
*
|
||||
* Latest version: https://github.com/joewalnes/reconnecting-websocket/
|
||||
* - Joe Walnes
|
||||
*
|
||||
* Syntax
|
||||
* ======
|
||||
* var socket = new ReconnectingWebSocket(url, protocols, options);
|
||||
*
|
||||
* Parameters
|
||||
* ==========
|
||||
* url - The url you are connecting to.
|
||||
* protocols - Optional string or array of protocols.
|
||||
* options - See below
|
||||
*
|
||||
* Options
|
||||
* =======
|
||||
* Options can either be passed upon instantiation or set after instantiation:
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url);
|
||||
* socket.debug = true;
|
||||
* socket.reconnectInterval = 4000;
|
||||
*
|
||||
* debug
|
||||
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
|
||||
*
|
||||
* automaticOpen
|
||||
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
|
||||
*
|
||||
* reconnectInterval
|
||||
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
|
||||
*
|
||||
* maxReconnectInterval
|
||||
* - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
|
||||
*
|
||||
* reconnectDecay
|
||||
* - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
|
||||
*
|
||||
* timeoutInterval
|
||||
* - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
|
||||
*
|
||||
*/
|
||||
// (function (global, factory) {
|
||||
// if (typeof define === 'function' && define.amd) {
|
||||
// define([], factory);
|
||||
// } else if (typeof module !== 'undefined' && module.exports){
|
||||
// module.exports = factory();
|
||||
// } else {
|
||||
// global.ReconnectingWebSocket = factory();
|
||||
// }
|
||||
// })(this, function () {
|
||||
//
|
||||
// if (!('WebSocket' in window)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
function ReconnectingWebSocket(url, protocols, options) {
|
||||
|
||||
// Default settings
|
||||
var settings = {
|
||||
|
||||
/** Whether this instance should log debug messages. */
|
||||
debug: false,
|
||||
|
||||
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
|
||||
automaticOpen: true,
|
||||
|
||||
/** The number of milliseconds to delay before attempting to reconnect. */
|
||||
reconnectInterval: 1000,
|
||||
/** The maximum number of milliseconds to delay a reconnection attempt. */
|
||||
maxReconnectInterval: 30000,
|
||||
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
|
||||
reconnectDecay: 1.5,
|
||||
|
||||
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
|
||||
timeoutInterval: 2000,
|
||||
|
||||
/** The maximum number of reconnection attempts to make. Unlimited if null. */
|
||||
maxReconnectAttempts: null,
|
||||
|
||||
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
|
||||
binaryType: 'blob'
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
// Overwrite and define settings with options if they exist.
|
||||
for (var key in settings) {
|
||||
if (typeof options[key] !== 'undefined') {
|
||||
this[key] = options[key];
|
||||
} else {
|
||||
this[key] = settings[key];
|
||||
}
|
||||
}
|
||||
|
||||
// These should be treated as read-only properties
|
||||
|
||||
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
|
||||
this.url = url;
|
||||
|
||||
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
/**
|
||||
* The current state of the connection.
|
||||
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
|
||||
* Read only.
|
||||
*/
|
||||
this.readyState = WebSocket.CONNECTING;
|
||||
|
||||
/**
|
||||
* A string indicating the name of the sub-protocol the server selected; this will be one of
|
||||
* the strings specified in the protocols parameter when creating the WebSocket object.
|
||||
* Read only.
|
||||
*/
|
||||
this.protocol = null;
|
||||
|
||||
// Private state variables
|
||||
|
||||
var self = this;
|
||||
var ws;
|
||||
var forcedClose = false;
|
||||
var timedOut = false;
|
||||
var eventTarget = document.createElement('div');
|
||||
|
||||
// Wire up "on*" properties as event handlers
|
||||
|
||||
eventTarget.addEventListener('open', function (event) {
|
||||
self.onopen(event);
|
||||
});
|
||||
eventTarget.addEventListener('close', function (event) {
|
||||
self.onclose(event);
|
||||
});
|
||||
eventTarget.addEventListener('connecting', function (event) {
|
||||
self.onconnecting(event);
|
||||
});
|
||||
eventTarget.addEventListener('message', function (event) {
|
||||
self.onmessage(event);
|
||||
});
|
||||
eventTarget.addEventListener('error', function (event) {
|
||||
self.onerror(event);
|
||||
});
|
||||
|
||||
// Expose the API required by EventTarget
|
||||
|
||||
this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
|
||||
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
|
||||
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
|
||||
|
||||
/**
|
||||
* This function generates an event that is compatible with standard
|
||||
* compliant browsers and IE9 - IE11
|
||||
*
|
||||
* This will prevent the error:
|
||||
* Object doesn't support this action
|
||||
*
|
||||
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
|
||||
* @param s String The name that the event should use
|
||||
* @param args Object an optional object that the event will use
|
||||
*/
|
||||
function generateEvent(s, args) {
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(s, false, false, args);
|
||||
return evt;
|
||||
};
|
||||
|
||||
this.open = function (reconnectAttempt) {
|
||||
ws = new WebSocket(self.url, protocols || []);
|
||||
ws.binaryType = this.binaryType;
|
||||
|
||||
if (reconnectAttempt) {
|
||||
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eventTarget.dispatchEvent(generateEvent('connecting'));
|
||||
this.reconnectAttempts = 0;
|
||||
}
|
||||
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
|
||||
}
|
||||
|
||||
var localWs = ws;
|
||||
var timeout = setTimeout(function () {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
|
||||
}
|
||||
timedOut = true;
|
||||
localWs.close();
|
||||
timedOut = false;
|
||||
}, self.timeoutInterval);
|
||||
|
||||
ws.onopen = function (event) {
|
||||
clearTimeout(timeout);
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onopen', self.url);
|
||||
}
|
||||
self.protocol = ws.protocol;
|
||||
self.readyState = WebSocket.OPEN;
|
||||
self.reconnectAttempts = 0;
|
||||
var e = generateEvent('open');
|
||||
e.isReconnect = reconnectAttempt;
|
||||
reconnectAttempt = false;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
clearTimeout(timeout);
|
||||
ws = null;
|
||||
if (forcedClose) {
|
||||
self.readyState = WebSocket.CLOSED;
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
} else {
|
||||
self.readyState = WebSocket.CONNECTING;
|
||||
var e = generateEvent('connecting');
|
||||
e.code = event.code;
|
||||
e.reason = event.reason;
|
||||
e.wasClean = event.wasClean;
|
||||
eventTarget.dispatchEvent(e);
|
||||
if (!reconnectAttempt && !timedOut) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onclose', self.url);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
}
|
||||
|
||||
var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
|
||||
setTimeout(function () {
|
||||
self.reconnectAttempts++;
|
||||
self.open(true);
|
||||
}, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
|
||||
}
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
|
||||
}
|
||||
var e = generateEvent('message');
|
||||
e.data = event.data;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
ws.onerror = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('error'));
|
||||
};
|
||||
}
|
||||
|
||||
// Whether or not to create a websocket upon instantiation
|
||||
if (this.automaticOpen == true) {
|
||||
this.open(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits data to the server over the WebSocket connection.
|
||||
*
|
||||
* @param data a text string, ArrayBuffer or Blob to send to the server.
|
||||
*/
|
||||
this.send = function (data) {
|
||||
if (ws) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'send', self.url, data);
|
||||
}
|
||||
return ws.send(data);
|
||||
} else {
|
||||
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the WebSocket connection or connection attempt, if any.
|
||||
* If the connection is already CLOSED, this method does nothing.
|
||||
*/
|
||||
this.close = function (code, reason) {
|
||||
// Default CLOSE_NORMAL code
|
||||
if (typeof code == 'undefined') {
|
||||
code = 1000;
|
||||
}
|
||||
forcedClose = true;
|
||||
if (ws) {
|
||||
ws.close(code, reason);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional public API method to refresh the connection if still open (close, re-open).
|
||||
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
|
||||
*/
|
||||
this.refresh = function () {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
||||
* this indicates that the connection is ready to send and receive data.
|
||||
*/
|
||||
ReconnectingWebSocket.prototype.onopen = function (event) {
|
||||
};
|
||||
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
|
||||
ReconnectingWebSocket.prototype.onclose = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a connection begins being attempted. */
|
||||
ReconnectingWebSocket.prototype.onconnecting = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a message is received from the server. */
|
||||
ReconnectingWebSocket.prototype.onmessage = function (event) {
|
||||
};
|
||||
/** An event listener to be called when an error occurs. */
|
||||
ReconnectingWebSocket.prototype.onerror = function (event) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether all instances of ReconnectingWebSocket should log debug messages.
|
||||
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
|
||||
*/
|
||||
ReconnectingWebSocket.debugAll = false;
|
||||
|
||||
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
|
||||
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
|
||||
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
|
||||
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
|
||||
|
||||
// return ReconnectingWebSocket;
|
||||
// });
|
48623
public/sdk/3rdparty/three/fonts/FZZongYi-M05S_regular.typeface.json
vendored
Normal file
65
public/sdk/3rdparty/three/jsm/geometries/TextGeometry.js
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Text = 3D Text
|
||||
*
|
||||
* parameters = {
|
||||
* font: <THREE.Font>, // font
|
||||
*
|
||||
* size: <float>, // size of the text
|
||||
* depth: <float>, // thickness to extrude text
|
||||
* curveSegments: <int>, // number of points on the curves
|
||||
*
|
||||
* bevelEnabled: <bool>, // turn on bevel
|
||||
* bevelThickness: <float>, // how deep into text bevel goes
|
||||
* bevelSize: <float>, // how far from text outline (including bevelOffset) is bevel
|
||||
* bevelOffset: <float> // how far from text outline does bevel start
|
||||
* }
|
||||
*/
|
||||
|
||||
import {
|
||||
ExtrudeGeometry
|
||||
} from '../../three.module.min.js';
|
||||
|
||||
class TextGeometry extends ExtrudeGeometry {
|
||||
|
||||
constructor( text, parameters = {} ) {
|
||||
|
||||
const font = parameters.font;
|
||||
|
||||
if ( font === undefined ) {
|
||||
|
||||
super(); // generate default extrude geometry
|
||||
|
||||
} else {
|
||||
|
||||
const shapes = font.generateShapes( text, parameters.size );
|
||||
|
||||
// translate parameters to ExtrudeGeometry API
|
||||
|
||||
if ( parameters.depth === undefined && parameters.height !== undefined ) {
|
||||
|
||||
console.warn( 'THREE.TextGeometry: .height is now depreciated. Please use .depth instead' ); // @deprecated, r163
|
||||
|
||||
}
|
||||
|
||||
parameters.depth = parameters.depth !== undefined ?
|
||||
parameters.depth : parameters.height !== undefined ?
|
||||
parameters.height : 50;
|
||||
|
||||
// defaults
|
||||
|
||||
if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
|
||||
if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
|
||||
if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
|
||||
|
||||
super( shapes, parameters );
|
||||
|
||||
}
|
||||
|
||||
this.type = 'TextGeometry';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { TextGeometry };
|
183
public/sdk/3rdparty/three/jsm/loaders/FontLoader.js
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
import {
|
||||
FileLoader,
|
||||
Loader,
|
||||
ShapePath
|
||||
} from '../../three.module.min.js';
|
||||
|
||||
class FontLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const loader = new FileLoader( this.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
const font = scope.parse( JSON.parse( text ) );
|
||||
|
||||
if ( onLoad ) onLoad( font );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( json ) {
|
||||
|
||||
return new Font( json );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
class Font {
|
||||
|
||||
constructor( data ) {
|
||||
|
||||
this.isFont = true;
|
||||
|
||||
this.type = 'Font';
|
||||
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
generateShapes( text, size = 100 ) {
|
||||
|
||||
const shapes = [];
|
||||
const paths = createPaths( text, size, this.data );
|
||||
|
||||
for ( let p = 0, pl = paths.length; p < pl; p ++ ) {
|
||||
|
||||
shapes.push( ...paths[ p ].toShapes() );
|
||||
|
||||
}
|
||||
|
||||
return shapes;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createPaths( text, size, data ) {
|
||||
|
||||
const chars = Array.from( text );
|
||||
const scale = size / data.resolution;
|
||||
const line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
|
||||
|
||||
const paths = [];
|
||||
|
||||
let offsetX = 0, offsetY = 0;
|
||||
|
||||
for ( let i = 0; i < chars.length; i ++ ) {
|
||||
|
||||
const char = chars[ i ];
|
||||
|
||||
if ( char === '\n' ) {
|
||||
|
||||
offsetX = 0;
|
||||
offsetY -= line_height;
|
||||
|
||||
} else {
|
||||
|
||||
const ret = createPath( char, scale, offsetX, offsetY, data );
|
||||
offsetX += ret.offsetX;
|
||||
paths.push( ret.path );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return paths;
|
||||
|
||||
}
|
||||
|
||||
function createPath( char, scale, offsetX, offsetY, data ) {
|
||||
|
||||
const glyph = data.glyphs[ char ] || data.glyphs[ '?' ];
|
||||
|
||||
if ( ! glyph ) {
|
||||
|
||||
console.error( 'THREE.Font: character "' + char + '" does not exists in font family ' + data.familyName + '.' );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const path = new ShapePath();
|
||||
|
||||
let x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
|
||||
|
||||
if ( glyph.o ) {
|
||||
|
||||
const outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
|
||||
|
||||
for ( let i = 0, l = outline.length; i < l; ) {
|
||||
|
||||
const action = outline[ i ++ ];
|
||||
|
||||
switch ( action ) {
|
||||
|
||||
case 'm': // moveTo
|
||||
|
||||
x = outline[ i ++ ] * scale + offsetX;
|
||||
y = outline[ i ++ ] * scale + offsetY;
|
||||
|
||||
path.moveTo( x, y );
|
||||
|
||||
break;
|
||||
|
||||
case 'l': // lineTo
|
||||
|
||||
x = outline[ i ++ ] * scale + offsetX;
|
||||
y = outline[ i ++ ] * scale + offsetY;
|
||||
|
||||
path.lineTo( x, y );
|
||||
|
||||
break;
|
||||
|
||||
case 'q': // quadraticCurveTo
|
||||
|
||||
cpx = outline[ i ++ ] * scale + offsetX;
|
||||
cpy = outline[ i ++ ] * scale + offsetY;
|
||||
cpx1 = outline[ i ++ ] * scale + offsetX;
|
||||
cpy1 = outline[ i ++ ] * scale + offsetY;
|
||||
|
||||
path.quadraticCurveTo( cpx1, cpy1, cpx, cpy );
|
||||
|
||||
break;
|
||||
|
||||
case 'b': // bezierCurveTo
|
||||
|
||||
cpx = outline[ i ++ ] * scale + offsetX;
|
||||
cpy = outline[ i ++ ] * scale + offsetY;
|
||||
cpx1 = outline[ i ++ ] * scale + offsetX;
|
||||
cpy1 = outline[ i ++ ] * scale + offsetY;
|
||||
cpx2 = outline[ i ++ ] * scale + offsetX;
|
||||
cpy2 = outline[ i ++ ] * scale + offsetY;
|
||||
|
||||
path.bezierCurveTo( cpx1, cpy1, cpx2, cpy2, cpx, cpy );
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { offsetX: glyph.ha * scale, path: path };
|
||||
|
||||
}
|
||||
|
||||
export { FontLoader, Font };
|
3173
public/sdk/3rdparty/three/jsm/loaders/SVGLoader.js
vendored
Normal file
7
public/sdk/3rdparty/three/three.min.js
vendored
Normal file
6
public/sdk/3rdparty/three/three.module.min.js
vendored
Normal file
88
public/sdk/3rdparty/turf.min.js
vendored
Normal file
881
public/sdk/3rdparty/tween.umd.js
vendored
Normal file
@ -0,0 +1,881 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TWEEN = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
*/
|
||||
var Easing = Object.freeze({
|
||||
Linear: Object.freeze({
|
||||
None: function (amount) {
|
||||
return amount;
|
||||
},
|
||||
In: function (amount) {
|
||||
return this.None(amount);
|
||||
},
|
||||
Out: function (amount) {
|
||||
return this.None(amount);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
return this.None(amount);
|
||||
},
|
||||
}),
|
||||
Quadratic: Object.freeze({
|
||||
In: function (amount) {
|
||||
return amount * amount;
|
||||
},
|
||||
Out: function (amount) {
|
||||
return amount * (2 - amount);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount;
|
||||
}
|
||||
return -0.5 * (--amount * (amount - 2) - 1);
|
||||
},
|
||||
}),
|
||||
Cubic: Object.freeze({
|
||||
In: function (amount) {
|
||||
return amount * amount * amount;
|
||||
},
|
||||
Out: function (amount) {
|
||||
return --amount * amount * amount + 1;
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount;
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
||||
},
|
||||
}),
|
||||
Quartic: Object.freeze({
|
||||
In: function (amount) {
|
||||
return amount * amount * amount * amount;
|
||||
},
|
||||
Out: function (amount) {
|
||||
return 1 - --amount * amount * amount * amount;
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount * amount;
|
||||
}
|
||||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
||||
},
|
||||
}),
|
||||
Quintic: Object.freeze({
|
||||
In: function (amount) {
|
||||
return amount * amount * amount * amount * amount;
|
||||
},
|
||||
Out: function (amount) {
|
||||
return --amount * amount * amount * amount * amount + 1;
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * amount * amount * amount * amount * amount;
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
||||
},
|
||||
}),
|
||||
Sinusoidal: Object.freeze({
|
||||
In: function (amount) {
|
||||
return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2);
|
||||
},
|
||||
Out: function (amount) {
|
||||
return Math.sin((amount * Math.PI) / 2);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
|
||||
},
|
||||
}),
|
||||
Exponential: Object.freeze({
|
||||
In: function (amount) {
|
||||
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
||||
},
|
||||
Out: function (amount) {
|
||||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * Math.pow(1024, amount - 1);
|
||||
}
|
||||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
||||
},
|
||||
}),
|
||||
Circular: Object.freeze({
|
||||
In: function (amount) {
|
||||
return 1 - Math.sqrt(1 - amount * amount);
|
||||
},
|
||||
Out: function (amount) {
|
||||
return Math.sqrt(1 - --amount * amount);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if ((amount *= 2) < 1) {
|
||||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
|
||||
}
|
||||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
||||
},
|
||||
}),
|
||||
Elastic: Object.freeze({
|
||||
In: function (amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
||||
},
|
||||
Out: function (amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if (amount === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (amount === 1) {
|
||||
return 1;
|
||||
}
|
||||
amount *= 2;
|
||||
if (amount < 1) {
|
||||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
||||
}
|
||||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
||||
},
|
||||
}),
|
||||
Back: Object.freeze({
|
||||
In: function (amount) {
|
||||
var s = 1.70158;
|
||||
return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
|
||||
},
|
||||
Out: function (amount) {
|
||||
var s = 1.70158;
|
||||
return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
|
||||
},
|
||||
InOut: function (amount) {
|
||||
var s = 1.70158 * 1.525;
|
||||
if ((amount *= 2) < 1) {
|
||||
return 0.5 * (amount * amount * ((s + 1) * amount - s));
|
||||
}
|
||||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
||||
},
|
||||
}),
|
||||
Bounce: Object.freeze({
|
||||
In: function (amount) {
|
||||
return 1 - Easing.Bounce.Out(1 - amount);
|
||||
},
|
||||
Out: function (amount) {
|
||||
if (amount < 1 / 2.75) {
|
||||
return 7.5625 * amount * amount;
|
||||
}
|
||||
else if (amount < 2 / 2.75) {
|
||||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
|
||||
}
|
||||
else if (amount < 2.5 / 2.75) {
|
||||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
|
||||
}
|
||||
else {
|
||||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
|
||||
}
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if (amount < 0.5) {
|
||||
return Easing.Bounce.In(amount * 2) * 0.5;
|
||||
}
|
||||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
||||
},
|
||||
}),
|
||||
generatePow: function (power) {
|
||||
if (power === void 0) { power = 4; }
|
||||
power = power < Number.EPSILON ? Number.EPSILON : power;
|
||||
power = power > 10000 ? 10000 : power;
|
||||
return {
|
||||
In: function (amount) {
|
||||
return Math.pow(amount, power);
|
||||
},
|
||||
Out: function (amount) {
|
||||
return 1 - Math.pow((1 - amount), power);
|
||||
},
|
||||
InOut: function (amount) {
|
||||
if (amount < 0.5) {
|
||||
return Math.pow((amount * 2), power) / 2;
|
||||
}
|
||||
return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
var now = function () { return performance.now(); };
|
||||
|
||||
/**
|
||||
* Controlling groups of tweens
|
||||
*
|
||||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
||||
* In these cases, you may want to create your own smaller groups of tween
|
||||
*/
|
||||
var Group = /** @class */ (function () {
|
||||
function Group() {
|
||||
this._tweens = {};
|
||||
this._tweensAddedDuringUpdate = {};
|
||||
}
|
||||
Group.prototype.getAll = function () {
|
||||
var _this = this;
|
||||
return Object.keys(this._tweens).map(function (tweenId) {
|
||||
return _this._tweens[tweenId];
|
||||
});
|
||||
};
|
||||
Group.prototype.removeAll = function () {
|
||||
this._tweens = {};
|
||||
};
|
||||
Group.prototype.add = function (tween) {
|
||||
this._tweens[tween.getId()] = tween;
|
||||
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
||||
};
|
||||
Group.prototype.remove = function (tween) {
|
||||
delete this._tweens[tween.getId()];
|
||||
delete this._tweensAddedDuringUpdate[tween.getId()];
|
||||
};
|
||||
Group.prototype.update = function (time, preserve) {
|
||||
if (time === void 0) { time = now(); }
|
||||
if (preserve === void 0) { preserve = false; }
|
||||
var tweenIds = Object.keys(this._tweens);
|
||||
if (tweenIds.length === 0) {
|
||||
return false;
|
||||
}
|
||||
// Tweens are updated in "batches". If you add a new tween during an
|
||||
// update, then the new tween will be updated in the next batch.
|
||||
// If you remove a tween during an update, it may or may not be updated.
|
||||
// However, if the removed tween was added during the current batch,
|
||||
// then it will not be updated.
|
||||
while (tweenIds.length > 0) {
|
||||
this._tweensAddedDuringUpdate = {};
|
||||
for (var i = 0; i < tweenIds.length; i++) {
|
||||
var tween = this._tweens[tweenIds[i]];
|
||||
var autoStart = !preserve;
|
||||
if (tween && tween.update(time, autoStart) === false && !preserve) {
|
||||
delete this._tweens[tweenIds[i]];
|
||||
}
|
||||
}
|
||||
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return Group;
|
||||
}());
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
var Interpolation = {
|
||||
Linear: function (v, k) {
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
var fn = Interpolation.Utils.Linear;
|
||||
if (k < 0) {
|
||||
return fn(v[0], v[1], f);
|
||||
}
|
||||
if (k > 1) {
|
||||
return fn(v[m], v[m - 1], m - f);
|
||||
}
|
||||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
||||
},
|
||||
Bezier: function (v, k) {
|
||||
var b = 0;
|
||||
var n = v.length - 1;
|
||||
var pw = Math.pow;
|
||||
var bn = Interpolation.Utils.Bernstein;
|
||||
for (var i = 0; i <= n; i++) {
|
||||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
|
||||
}
|
||||
return b;
|
||||
},
|
||||
CatmullRom: function (v, k) {
|
||||
var m = v.length - 1;
|
||||
var f = m * k;
|
||||
var i = Math.floor(f);
|
||||
var fn = Interpolation.Utils.CatmullRom;
|
||||
if (v[0] === v[m]) {
|
||||
if (k < 0) {
|
||||
i = Math.floor((f = m * (1 + k)));
|
||||
}
|
||||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
|
||||
}
|
||||
else {
|
||||
if (k < 0) {
|
||||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
|
||||
}
|
||||
if (k > 1) {
|
||||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
|
||||
}
|
||||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
|
||||
}
|
||||
},
|
||||
Utils: {
|
||||
Linear: function (p0, p1, t) {
|
||||
return (p1 - p0) * t + p0;
|
||||
},
|
||||
Bernstein: function (n, i) {
|
||||
var fc = Interpolation.Utils.Factorial;
|
||||
return fc(n) / fc(i) / fc(n - i);
|
||||
},
|
||||
Factorial: (function () {
|
||||
var a = [1];
|
||||
return function (n) {
|
||||
var s = 1;
|
||||
if (a[n]) {
|
||||
return a[n];
|
||||
}
|
||||
for (var i = n; i > 1; i--) {
|
||||
s *= i;
|
||||
}
|
||||
a[n] = s;
|
||||
return s;
|
||||
};
|
||||
})(),
|
||||
CatmullRom: function (p0, p1, p2, p3, t) {
|
||||
var v0 = (p2 - p0) * 0.5;
|
||||
var v1 = (p3 - p1) * 0.5;
|
||||
var t2 = t * t;
|
||||
var t3 = t * t2;
|
||||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
var Sequence = /** @class */ (function () {
|
||||
function Sequence() {
|
||||
}
|
||||
Sequence.nextId = function () {
|
||||
return Sequence._nextId++;
|
||||
};
|
||||
Sequence._nextId = 0;
|
||||
return Sequence;
|
||||
}());
|
||||
|
||||
var mainGroup = new Group();
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
var Tween = /** @class */ (function () {
|
||||
function Tween(_object, _group) {
|
||||
if (_group === void 0) { _group = mainGroup; }
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
this._pauseStart = 0;
|
||||
this._valuesStart = {};
|
||||
this._valuesEnd = {};
|
||||
this._valuesStartRepeat = {};
|
||||
this._duration = 1000;
|
||||
this._isDynamic = false;
|
||||
this._initialRepeat = 0;
|
||||
this._repeat = 0;
|
||||
this._yoyo = false;
|
||||
this._isPlaying = false;
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
this._startTime = 0;
|
||||
this._easingFunction = Easing.Linear.None;
|
||||
this._interpolationFunction = Interpolation.Linear;
|
||||
// eslint-disable-next-line
|
||||
this._chainedTweens = [];
|
||||
this._onStartCallbackFired = false;
|
||||
this._onEveryStartCallbackFired = false;
|
||||
this._id = Sequence.nextId();
|
||||
this._isChainStopped = false;
|
||||
this._propertiesAreSetUp = false;
|
||||
this._goToEnd = false;
|
||||
}
|
||||
Tween.prototype.getId = function () {
|
||||
return this._id;
|
||||
};
|
||||
Tween.prototype.isPlaying = function () {
|
||||
return this._isPlaying;
|
||||
};
|
||||
Tween.prototype.isPaused = function () {
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween.prototype.to = function (target, duration) {
|
||||
if (duration === void 0) { duration = 1000; }
|
||||
if (this._isPlaying)
|
||||
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
|
||||
this._valuesEnd = target;
|
||||
this._propertiesAreSetUp = false;
|
||||
this._duration = duration;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.duration = function (duration) {
|
||||
if (duration === void 0) { duration = 1000; }
|
||||
this._duration = duration;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.dynamic = function (dynamic) {
|
||||
if (dynamic === void 0) { dynamic = false; }
|
||||
this._isDynamic = dynamic;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.start = function (time, overrideStartingValues) {
|
||||
if (time === void 0) { time = now(); }
|
||||
if (overrideStartingValues === void 0) { overrideStartingValues = false; }
|
||||
if (this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
this._group && this._group.add(this);
|
||||
this._repeat = this._initialRepeat;
|
||||
if (this._reversed) {
|
||||
// If we were reversed (f.e. using the yoyo feature) then we need to
|
||||
// flip the tween direction back to forward.
|
||||
this._reversed = false;
|
||||
for (var property in this._valuesStartRepeat) {
|
||||
this._swapEndStartRepeatValues(property);
|
||||
this._valuesStart[property] = this._valuesStartRepeat[property];
|
||||
}
|
||||
}
|
||||
this._isPlaying = true;
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
this._onEveryStartCallbackFired = false;
|
||||
this._isChainStopped = false;
|
||||
this._startTime = time;
|
||||
this._startTime += this._delayTime;
|
||||
if (!this._propertiesAreSetUp || overrideStartingValues) {
|
||||
this._propertiesAreSetUp = true;
|
||||
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
|
||||
if (!this._isDynamic) {
|
||||
var tmp = {};
|
||||
for (var prop in this._valuesEnd)
|
||||
tmp[prop] = this._valuesEnd[prop];
|
||||
this._valuesEnd = tmp;
|
||||
}
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.startFromCurrentValues = function (time) {
|
||||
return this.start(time, true);
|
||||
};
|
||||
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
|
||||
for (var property in _valuesEnd) {
|
||||
var startValue = _object[property];
|
||||
var startValueIsArray = Array.isArray(startValue);
|
||||
var propType = startValueIsArray ? 'array' : typeof startValue;
|
||||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
|
||||
// If `to()` specifies a property that doesn't exist in the source object,
|
||||
// we should not set that property in the object
|
||||
if (propType === 'undefined' || propType === 'function') {
|
||||
continue;
|
||||
}
|
||||
// Check if an Array was provided as property value
|
||||
if (isInterpolationList) {
|
||||
var endValues = _valuesEnd[property];
|
||||
if (endValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
// Handle an array of relative values.
|
||||
// Creates a local copy of the Array with the start value at the front
|
||||
var temp = [startValue];
|
||||
for (var i = 0, l = endValues.length; i < l; i += 1) {
|
||||
var value = this._handleRelativeValue(startValue, endValues[i]);
|
||||
if (isNaN(value)) {
|
||||
isInterpolationList = false;
|
||||
console.warn('Found invalid interpolation list. Skipping.');
|
||||
break;
|
||||
}
|
||||
temp.push(value);
|
||||
}
|
||||
if (isInterpolationList) {
|
||||
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
|
||||
_valuesEnd[property] = temp;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// handle the deepness of the values
|
||||
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
|
||||
_valuesStart[property] = startValueIsArray ? [] : {};
|
||||
var nestedObject = startValue;
|
||||
for (var prop in nestedObject) {
|
||||
_valuesStart[property][prop] = nestedObject[prop];
|
||||
}
|
||||
// TODO? repeat nested values? And yoyo? And array values?
|
||||
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
|
||||
var endValues = _valuesEnd[property];
|
||||
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
|
||||
if (!this._isDynamic) {
|
||||
var tmp = {};
|
||||
for (var prop in endValues)
|
||||
tmp[prop] = endValues[prop];
|
||||
_valuesEnd[property] = endValues = tmp;
|
||||
}
|
||||
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
|
||||
}
|
||||
else {
|
||||
// Save the starting value, but only once unless override is requested.
|
||||
if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) {
|
||||
_valuesStart[property] = startValue;
|
||||
}
|
||||
if (!startValueIsArray) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
|
||||
}
|
||||
if (isInterpolationList) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
|
||||
}
|
||||
else {
|
||||
_valuesStartRepeat[property] = _valuesStart[property] || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Tween.prototype.stop = function () {
|
||||
if (!this._isChainStopped) {
|
||||
this._isChainStopped = true;
|
||||
this.stopChainedTweens();
|
||||
}
|
||||
if (!this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
this._group && this._group.remove(this);
|
||||
this._isPlaying = false;
|
||||
this._isPaused = false;
|
||||
if (this._onStopCallback) {
|
||||
this._onStopCallback(this._object);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.end = function () {
|
||||
this._goToEnd = true;
|
||||
this.update(Infinity);
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.pause = function (time) {
|
||||
if (time === void 0) { time = now(); }
|
||||
if (this._isPaused || !this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time;
|
||||
// eslint-disable-next-line
|
||||
this._group && this._group.remove(this);
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.resume = function (time) {
|
||||
if (time === void 0) { time = now(); }
|
||||
if (!this._isPaused || !this._isPlaying) {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += time - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
// eslint-disable-next-line
|
||||
this._group && this._group.add(this);
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.stopChainedTweens = function () {
|
||||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
||||
this._chainedTweens[i].stop();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.group = function (group) {
|
||||
if (group === void 0) { group = mainGroup; }
|
||||
this._group = group;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.delay = function (amount) {
|
||||
if (amount === void 0) { amount = 0; }
|
||||
this._delayTime = amount;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.repeat = function (times) {
|
||||
if (times === void 0) { times = 0; }
|
||||
this._initialRepeat = times;
|
||||
this._repeat = times;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.repeatDelay = function (amount) {
|
||||
this._repeatDelayTime = amount;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.yoyo = function (yoyo) {
|
||||
if (yoyo === void 0) { yoyo = false; }
|
||||
this._yoyo = yoyo;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.easing = function (easingFunction) {
|
||||
if (easingFunction === void 0) { easingFunction = Easing.Linear.None; }
|
||||
this._easingFunction = easingFunction;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.interpolation = function (interpolationFunction) {
|
||||
if (interpolationFunction === void 0) { interpolationFunction = Interpolation.Linear; }
|
||||
this._interpolationFunction = interpolationFunction;
|
||||
return this;
|
||||
};
|
||||
// eslint-disable-next-line
|
||||
Tween.prototype.chain = function () {
|
||||
var tweens = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
tweens[_i] = arguments[_i];
|
||||
}
|
||||
this._chainedTweens = tweens;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onStart = function (callback) {
|
||||
this._onStartCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onEveryStart = function (callback) {
|
||||
this._onEveryStartCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onUpdate = function (callback) {
|
||||
this._onUpdateCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onRepeat = function (callback) {
|
||||
this._onRepeatCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onComplete = function (callback) {
|
||||
this._onCompleteCallback = callback;
|
||||
return this;
|
||||
};
|
||||
Tween.prototype.onStop = function (callback) {
|
||||
this._onStopCallback = callback;
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* @returns true if the tween is still playing after the update, false
|
||||
* otherwise (calling update on a paused tween still returns true because
|
||||
* it is still playing, just paused).
|
||||
*/
|
||||
Tween.prototype.update = function (time, autoStart) {
|
||||
if (time === void 0) { time = now(); }
|
||||
if (autoStart === void 0) { autoStart = true; }
|
||||
if (this._isPaused)
|
||||
return true;
|
||||
var property;
|
||||
var elapsed;
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (!this._goToEnd && !this._isPlaying) {
|
||||
if (time > endTime)
|
||||
return false;
|
||||
if (autoStart)
|
||||
this.start(time, true);
|
||||
}
|
||||
this._goToEnd = false;
|
||||
if (time < this._startTime) {
|
||||
return true;
|
||||
}
|
||||
if (this._onStartCallbackFired === false) {
|
||||
if (this._onStartCallback) {
|
||||
this._onStartCallback(this._object);
|
||||
}
|
||||
this._onStartCallbackFired = true;
|
||||
}
|
||||
if (this._onEveryStartCallbackFired === false) {
|
||||
if (this._onEveryStartCallback) {
|
||||
this._onEveryStartCallback(this._object);
|
||||
}
|
||||
this._onEveryStartCallbackFired = true;
|
||||
}
|
||||
elapsed = (time - this._startTime) / this._duration;
|
||||
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
|
||||
var value = this._easingFunction(elapsed);
|
||||
// properties transformations
|
||||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
||||
if (this._onUpdateCallback) {
|
||||
this._onUpdateCallback(this._object, elapsed);
|
||||
}
|
||||
if (elapsed === 1) {
|
||||
if (this._repeat > 0) {
|
||||
if (isFinite(this._repeat)) {
|
||||
this._repeat--;
|
||||
}
|
||||
// Reassign starting values, restart by making startTime = now
|
||||
for (property in this._valuesStartRepeat) {
|
||||
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
|
||||
this._valuesStartRepeat[property] =
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
|
||||
}
|
||||
if (this._yoyo) {
|
||||
this._swapEndStartRepeatValues(property);
|
||||
}
|
||||
this._valuesStart[property] = this._valuesStartRepeat[property];
|
||||
}
|
||||
if (this._yoyo) {
|
||||
this._reversed = !this._reversed;
|
||||
}
|
||||
if (this._repeatDelayTime !== undefined) {
|
||||
this._startTime = time + this._repeatDelayTime;
|
||||
}
|
||||
else {
|
||||
this._startTime = time + this._delayTime;
|
||||
}
|
||||
if (this._onRepeatCallback) {
|
||||
this._onRepeatCallback(this._object);
|
||||
}
|
||||
this._onEveryStartCallbackFired = false;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (this._onCompleteCallback) {
|
||||
this._onCompleteCallback(this._object);
|
||||
}
|
||||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
||||
// Make the chained tweens start exactly at the time they should,
|
||||
// even if the `update()` method was called way past the duration of the tween
|
||||
this._chainedTweens[i].start(this._startTime + this._duration, false);
|
||||
}
|
||||
this._isPlaying = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
|
||||
for (var property in _valuesEnd) {
|
||||
// Don't update properties that do not exist in the source object
|
||||
if (_valuesStart[property] === undefined) {
|
||||
continue;
|
||||
}
|
||||
var start = _valuesStart[property] || 0;
|
||||
var end = _valuesEnd[property];
|
||||
var startIsArray = Array.isArray(_object[property]);
|
||||
var endIsArray = Array.isArray(end);
|
||||
var isInterpolationList = !startIsArray && endIsArray;
|
||||
if (isInterpolationList) {
|
||||
_object[property] = this._interpolationFunction(end, value);
|
||||
}
|
||||
else if (typeof end === 'object' && end) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._updateProperties(_object[property], start, end, value);
|
||||
}
|
||||
else {
|
||||
// Parses relative end values with start as base (e.g.: +10, -3)
|
||||
end = this._handleRelativeValue(start, end);
|
||||
// Protect against non numeric properties.
|
||||
if (typeof end === 'number') {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
_object[property] = start + (end - start) * value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Tween.prototype._handleRelativeValue = function (start, end) {
|
||||
if (typeof end !== 'string') {
|
||||
return end;
|
||||
}
|
||||
if (end.charAt(0) === '+' || end.charAt(0) === '-') {
|
||||
return start + parseFloat(end);
|
||||
}
|
||||
return parseFloat(end);
|
||||
};
|
||||
Tween.prototype._swapEndStartRepeatValues = function (property) {
|
||||
var tmp = this._valuesStartRepeat[property];
|
||||
var endValue = this._valuesEnd[property];
|
||||
if (typeof endValue === 'string') {
|
||||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
|
||||
}
|
||||
else {
|
||||
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
||||
}
|
||||
this._valuesEnd[property] = tmp;
|
||||
};
|
||||
return Tween;
|
||||
}());
|
||||
|
||||
var VERSION = '21.1.1';
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
* ----------------------------------------------
|
||||
*
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
var nextId = Sequence.nextId;
|
||||
/**
|
||||
* Controlling groups of tweens
|
||||
*
|
||||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
||||
* In these cases, you may want to create your own smaller groups of tweens.
|
||||
*/
|
||||
var TWEEN = mainGroup;
|
||||
// This is the best way to export things in a way that's compatible with both ES
|
||||
// Modules and CommonJS, without build hacks, and so as not to break the
|
||||
// existing API.
|
||||
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
|
||||
var getAll = TWEEN.getAll.bind(TWEEN);
|
||||
var removeAll = TWEEN.removeAll.bind(TWEEN);
|
||||
var add = TWEEN.add.bind(TWEEN);
|
||||
var remove = TWEEN.remove.bind(TWEEN);
|
||||
var update = TWEEN.update.bind(TWEEN);
|
||||
var exports$1 = {
|
||||
Easing: Easing,
|
||||
Group: Group,
|
||||
Interpolation: Interpolation,
|
||||
now: now,
|
||||
Sequence: Sequence,
|
||||
nextId: nextId,
|
||||
Tween: Tween,
|
||||
VERSION: VERSION,
|
||||
getAll: getAll,
|
||||
removeAll: removeAll,
|
||||
add: add,
|
||||
remove: remove,
|
||||
update: update,
|
||||
};
|
||||
|
||||
exports.Easing = Easing;
|
||||
exports.Group = Group;
|
||||
exports.Interpolation = Interpolation;
|
||||
exports.Sequence = Sequence;
|
||||
exports.Tween = Tween;
|
||||
exports.VERSION = VERSION;
|
||||
exports.add = add;
|
||||
exports.default = exports$1;
|
||||
exports.getAll = getAll;
|
||||
exports.nextId = nextId;
|
||||
exports.now = now;
|
||||
exports.remove = remove;
|
||||
exports.removeAll = removeAll;
|
||||
exports.update = update;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
25
public/sdk/3rdparty/video.min.js
vendored
Normal file
20722
public/sdk/3rdparty/videojs-contrib-hls.min.js
vendored
Normal file
20756
public/sdk/3rdparty/viewerCesiumNavigationMixin.min.js
vendored
Normal file
24129
public/sdk/3rdparty/wangeditor/index.js
vendored
Normal file
27
public/sdk/3rdparty/wangeditor/style.css
vendored
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_0.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_1.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_10.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_11.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_12.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_13.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_14.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_15.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_16.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_17.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_18.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_19.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_2.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_20.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_21.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_22.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_23.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_24.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_25.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_26.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_27.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_3.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_4.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_5.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_6.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_7.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_8.json
Normal file
1
public/sdk/Cesium/Assets/IAU2006_XYS/IAU2006_XYS_9.json
Normal file
BIN
public/sdk/Cesium/Assets/Images/bing_maps_credit.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
public/sdk/Cesium/Assets/Images/cesium_credit.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
public/sdk/Cesium/Assets/Images/google_earth_credit.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
public/sdk/Cesium/Assets/Images/ion-credit.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
public/sdk/Cesium/Assets/Textures/LensFlare/DirtMask.jpg
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
public/sdk/Cesium/Assets/Textures/LensFlare/StarBurst.jpg
Normal file
After Width: | Height: | Size: 191 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/0/0/0.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/0/1/0.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/0/0.jpg
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/0/1.jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/1/0.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/1/1.jpg
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/2/0.jpg
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/2/1.jpg
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/3/0.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/1/3/1.jpg
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/2/0/0.jpg
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/2/0/1.jpg
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/2/0/2.jpg
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/2/0/3.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
public/sdk/Cesium/Assets/Textures/NaturalEarthII/2/1/0.jpg
Normal file
After Width: | Height: | Size: 7.7 KiB |