1 Star 0 Fork 0

cai/集成threejs的cesium的demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server.js 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
Kangning Li 提交于 8年前 . add Cesium ThreeJS demo
"use strict";
var mime = require('mime');
var restify = require('restify');
var yargs = require('yargs');
yargs.options({
'port': {
'default': 8080,
'description': 'Port to listen on.'
},
'public': {
'type': 'boolean',
'default': false,
'description': 'Run a public server that listens on all interfaces.'
},
'production': {
'type': 'boolean',
'default': false,
'description': 'Run the built version of the code.'
}
});
var argv = yargs.argv;
var server = restify.createServer();
//The built in gzipResponse gzips everything, including compressed files.
//This disables gzipping for specific routes and files.
var gzipResponse = restify.gzipResponse();
server.use(function (req, res, next) {
var url = req.url;
//Tiles are pre-gzipped.
if (/\/3DTiles\/(.*)/.test(url)) {
res.header('Content-Encoding', 'gzip');
next();
return;
}
//Don't gzip things that are likely gzipped already.
var contentType = mime.lookup(url);
if (/^(image|audio|video)\//.test(contentType)) {
next();
return;
}
gzipResponse(req, res, next);
});
server.get(/.*/, restify.serveStatic({
directory: argv.production ? 'build' : 'public',
default: 'index.html',
maxAge: 0
}));
server.listen(argv.port, argv.public ? undefined : 'localhost', function () {
console.log('%s listening at %s', server.name, server.url);
});
var shuttingDown = false;
function shutdown() {
if (shuttingDown) {
return;
}
shuttingDown = true;
console.log("Closing server connections...");
server.close(function () {
console.log("Shutdown successfull.");
process.exit(0);
});
}
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/caiming1/cesium-threejs-demo.git
git@gitee.com:caiming1/cesium-threejs-demo.git
caiming1
cesium-threejs-demo
集成threejs的cesium的demo
main

搜索帮助