123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- import buildModuleUrl from "../Core/buildModuleUrl.js";
- import Cartesian3 from "../Core/Cartesian3.js";
- import defaultValue from "../Core/defaultValue.js";
- import defined from "../Core/defined.js";
- import destroyObject from "../Core/destroyObject.js";
- import Ellipsoid from "../Core/Ellipsoid.js";
- import IauOrientationAxes from "../Core/IauOrientationAxes.js";
- import Matrix3 from "../Core/Matrix3.js";
- import Matrix4 from "../Core/Matrix4.js";
- import Simon1994PlanetaryPositions from "../Core/Simon1994PlanetaryPositions.js";
- import Transforms from "../Core/Transforms.js";
- import EllipsoidPrimitive from "./EllipsoidPrimitive.js";
- import Material from "./Material.js";
- function Moon(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),
- depthTestEnabled: false,
- _owner: this,
- });
- this._ellipsoidPrimitive.material.translucent = false;
- this._axes = new IauOrientationAxes();
- }
- Object.defineProperties(Moon.prototype, {
-
- ellipsoid: {
- get: function () {
- return this._ellipsoid;
- },
- },
- });
- var icrfToFixed = new Matrix3();
- var rotationScratch = new Matrix3();
- var translationScratch = new Cartesian3();
- var scratchCommandList = [];
- Moon.prototype.update = function (frameState) {
- 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
- );
- var savedCommandList = frameState.commandList;
- frameState.commandList = scratchCommandList;
- scratchCommandList.length = 0;
- ellipsoidPrimitive.update(frameState);
- frameState.commandList = savedCommandList;
- return scratchCommandList.length === 1 ? scratchCommandList[0] : undefined;
- };
- Moon.prototype.isDestroyed = function () {
- return false;
- };
- Moon.prototype.destroy = function () {
- this._ellipsoidPrimitive =
- this._ellipsoidPrimitive && this._ellipsoidPrimitive.destroy();
- return destroyObject(this);
- };
- export default Moon;
|