var Sandbox = Sandbox || {};//定义一个变量Sandbox,它是类?还是变量?左边是全局变量,右边是??哪里来的对象 如果是null,那么赋值为{} (function() { "use strict"; /*global Cesium,console*/ /** * @constructor */ Cesium.Sandbox = function() { var canvas = document.getElementById("glCanvas"); var scene = new Cesium.Scene(canvas); var primitives = scene.getPrimitives(); var ellipsoid = Cesium.Ellipsoid.WGS84; // TODO: make multiple tile providers available var bing = new Cesium.BingMapsTileProvider({ server : "dev.virtualearth.net", mapStyle : Cesium.BingMapsStyle.AERIAL }); var cb = new Cesium.CentralBody(scene.getCamera(), ellipsoid); cb.dayTileProvider = bing; cb.nightImageSource = "Images/land_ocean_ice_lights_2048.jpg"; cb.specularMapSource = "Images/earthspec1k.jpg"; cb.cloudsMapSource = "Images/earthcloudmaptrans.jpg"; cb.bumpMapSource = "Images/earthbump1k.jpg"; cb.showSkyAtmosphere = true; cb.showGroundAtmosphere = true; primitives.setCentralBody(cb); scene.getCamera().getControllers().addSpindle(); scene.getCamera().getControllers().get(0).mouseConstrainedZAxis = true; scene.getCamera().getControllers().addFreeLook(); scene.getCamera().frustum.near = 100.0; this._scene = scene; this._ellipsoid = ellipsoid; scene.setAnimation(function() { var camera = scene.getCamera(); var cameraPosition = new Cesium.Cartesian4(camera.position.x, camera.position.y, camera.position.z, 1.0); var v = camera.transform.multiplyWithVector(cameraPosition).getXYZ(); scene.setSunPosition(v); // In case of canvas resize canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight; scene.getContext().setViewport({ x : 0, y : 0, width : canvas.width, height : canvas.height }); scene.getCamera().frustum.aspectRatio = canvas.clientWidth / canvas.clientHeight; var s = Cesium.Sandbox.getCurrentCodeSnippet(); if (s && s.animate) { s.animate(); } }); (function tick() { try { scene.render(); } catch (e) { // Live editing can create invalid states, e.g., a conic sensor with inner half-angle // greater than outer half-angle, which cause exceptions. We swallow the exceptions // to avoid losing the animation frame. console.log(e.message); } Cesium.requestAnimationFrame(tick); }()); canvas.oncontextmenu = function(e) { e.preventDefault(); }; canvas.onselectstart = function(e) { e.preventDefault(); }; }; Cesium.Sandbox.prototype.getScene = function() { return this._scene; }; Cesium.Sandbox.prototype.getEllipsoid = function() { return this._ellipsoid; }; Cesium.Sandbox.prototype.clearScene = function() { var scene = this._scene; scene.getPrimitives().removeAll(); scene.getAnimations().removeAll(); }; }());
在main.js中引用
Editor.js
/*global Sandbox,ace,require,define*/ /** * Constructs an instance of a Javascript Ace editor. * * @param {String} id The id of the DOM element to be converted to an editor * * @constructor */ Sandbox.Editor = function(id) {//数组中的对象1 define('ace/mode/cesium', function(require, exports, module) { var oop = require("pilot/oop"); var TextMode = require("ace/mode/text").Mode; var Tokenizer = require("ace/tokenizer").Tokenizer; var WorkerClient = require("ace/worker/worker_client").WorkerClient; var CesiumHighlightRules = require("ace/mode/cesium_highlight_rules").CesiumHighlightRules;
这里Cesium也是一个变量。。。?Cesium也是一个{}?
js 中{},[]中括号,大括号使用详解:
一、{ } 大括号,表示定义一个对象,大部分情况下要有成对的属性和值,或是函数。
如:var LangShen = {"Name":"Langshen","AGE":"28"};
上面声明了一个名为“LangShen”的对象,多个属性或函数用,(逗号)隔开,因为是对象的属性,
参考:https://www.jb51.net/article/27119.htm
该写法,在JSON数据结构中经常用,除此之外,我们平时写函数组的时候,也经常用到,如:
var LangShen = { Name = function(){ return "LangShen"; }, Age = function(){ return "28"; } }
function中又包含着function。。。
Cesium对象新加的的属性名AxisAlignedBoundingBox,是一个函数属性,在js中函数其实就是类。
函数属性如何初始化?
https://wenku.baidu.com/view/6921fecac2c708a1284ac850ad02de80d4d80634.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2021-06-04 SpringCloud In Action微服务框架项目实战
2021-06-04 Spring Cloud入门
2018-06-04 SqueezeNet:AlexNet-level Accuracy with 50x fewer parameters and less than 0.5Mb model size
2018-06-04 Densely Connected Convolutional Networks(緊密相連卷積網絡)
2018-06-04 FractalNet(分形网络)
2018-06-04 Network in Network(NiN)
2018-06-04 fatal error C1083: 无法打开包括文件:“psimpl_reference.h”: No such file or directory d:\documents\visual studio 2008\projects\test123\test123\test123dlg.cpp