123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- define([
- '../Core/buildModuleUrl',
- '../Core/Cartesian3',
- '../Core/defaultValue',
- '../Core/defined',
- '../Core/defineProperties',
- '../Core/destroyObject',
- '../Core/Ellipsoid',
- '../Core/IauOrientationAxes',
- '../Core/Matrix3',
- '../Core/Matrix4',
- '../Core/Simon1994PlanetaryPositions',
- '../Core/Transforms',
- './EllipsoidPrimitive',
- './Material'
- ], function(
- buildModuleUrl,
- Cartesian3,
- defaultValue,
- defined,
- defineProperties,
- destroyObject,
- Ellipsoid,
- IauOrientationAxes,
- Matrix3,
- Matrix4,
- Simon1994PlanetaryPositions,
- Transforms,
- EllipsoidPrimitive,
- Material) {
- "use strict";
-
- var Moon = function(options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
- var url = options.textureUrl;
- if (!defined(url)) {
- url = buildModuleUrl('Assets/Textures/moonSmall.jpg');
- }
-
- this.show = defaultValue(options.show, true);
-
- this.textureUrl = url;
- this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.MOON);
-
- this.onlySunLighting = defaultValue(options.onlySunLighting, true);
- this._ellipsoidPrimitive = new EllipsoidPrimitive({
- radii : this.ellipsoid.radii,
- material : Material.fromType(Material.ImageType),
- _owner : this
- });
- this._ellipsoidPrimitive.material.translucent = false;
- this._axes = new IauOrientationAxes();
- };
- defineProperties(Moon.prototype, {
-
- ellipsoid : {
- get : function() {
- return this._ellipsoid;
- }
- }
- });
- var icrfToFixed = new Matrix3();
- var rotationScratch = new Matrix3();
- var translationScratch = new Cartesian3();
-
- Moon.prototype.update = function(context, frameState, commandList) {
- if (!this.show) {
- return;
- }
- var ellipsoidPrimitive = this._ellipsoidPrimitive;
- ellipsoidPrimitive.material.uniforms.image = this.textureUrl;
- ellipsoidPrimitive.onlySunLighting = this.onlySunLighting;
- var date = frameState.time;
- if (!defined(Transforms.computeIcrfToFixedMatrix(date, icrfToFixed))) {
- Transforms.computeTemeToPseudoFixedMatrix(date, icrfToFixed);
- }
- var rotation = this._axes.evaluate(date, rotationScratch);
- Matrix3.transpose(rotation, rotation);
- Matrix3.multiply(icrfToFixed, rotation, rotation);
- var translation = Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame(date, translationScratch);
- Matrix3.multiplyByVector(icrfToFixed, translation, translation);
- Matrix4.fromRotationTranslation(rotation, translation, ellipsoidPrimitive.modelMatrix);
- ellipsoidPrimitive.update(context, frameState, commandList);
- };
-
- Moon.prototype.isDestroyed = function() {
- return false;
- };
-
- Moon.prototype.destroy = function() {
- this._ellipsoidPrimitive = this._ellipsoidPrimitive && this._ellipsoidPrimitive.destroy();
- return destroyObject(this);
- };
- return Moon;
- });
|