cesium 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.md +259 -0
- data/README.rdoc +90 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/Assets/Assets.profile.js +8 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_0.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_1.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_10.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_11.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_12.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_13.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_14.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_15.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_16.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_17.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_18.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_19.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_2.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_20.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_21.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_22.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_23.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_24.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_25.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_26.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_27.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_3.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_4.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_5.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_6.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_7.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_8.json +1 -0
- data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_9.json +1 -0
- data/app/assets/javascripts/Assets/Textures/NE2_LR_LC_SR_W_DR_2048.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
- data/app/assets/javascripts/Assets/Textures/waterNormals.jpg +0 -0
- data/app/assets/javascripts/Assets/package.json +6 -0
- data/app/assets/javascripts/Cesium.js +320 -0
- data/app/assets/javascripts/Core/AnimationController.js +148 -0
- data/app/assets/javascripts/Core/AxisAlignedBoundingBox.js +243 -0
- data/app/assets/javascripts/Core/BoundingRectangle.js +364 -0
- data/app/assets/javascripts/Core/BoundingSphere.js +819 -0
- data/app/assets/javascripts/Core/BoxTessellator.js +93 -0
- data/app/assets/javascripts/Core/Cartesian2.js +762 -0
- data/app/assets/javascripts/Core/Cartesian3.js +861 -0
- data/app/assets/javascripts/Core/Cartesian4.js +762 -0
- data/app/assets/javascripts/Core/Cartographic.js +211 -0
- data/app/assets/javascripts/Core/CatmullRomSpline.js +232 -0
- data/app/assets/javascripts/Core/Clock.js +195 -0
- data/app/assets/javascripts/Core/ClockRange.js +37 -0
- data/app/assets/javascripts/Core/ClockStep.js +32 -0
- data/app/assets/javascripts/Core/Color.js +1629 -0
- data/app/assets/javascripts/Core/ComponentDatatype.js +119 -0
- data/app/assets/javascripts/Core/Core.profile.js +8 -0
- data/app/assets/javascripts/Core/CubeMapEllipsoidTessellator.js +198 -0
- data/app/assets/javascripts/Core/CubicRealPolynomial.js +251 -0
- data/app/assets/javascripts/Core/DefaultProxy.js +30 -0
- data/app/assets/javascripts/Core/DeveloperError.js +60 -0
- data/app/assets/javascripts/Core/EarthOrientationParameters.js +383 -0
- data/app/assets/javascripts/Core/EarthOrientationParametersSample.js +50 -0
- data/app/assets/javascripts/Core/Ellipsoid.js +539 -0
- data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +207 -0
- data/app/assets/javascripts/Core/EllipsoidalOccluder.js +151 -0
- data/app/assets/javascripts/Core/EncodedCartesian3.js +197 -0
- data/app/assets/javascripts/Core/Enumeration.js +67 -0
- data/app/assets/javascripts/Core/Event.js +122 -0
- data/app/assets/javascripts/Core/Extent.js +383 -0
- data/app/assets/javascripts/Core/ExtentTessellator.js +384 -0
- data/app/assets/javascripts/Core/FAR.js +13 -0
- data/app/assets/javascripts/Core/FeatureDetection.js +126 -0
- data/app/assets/javascripts/Core/Fullscreen.js +235 -0
- data/app/assets/javascripts/Core/GeographicProjection.js +107 -0
- data/app/assets/javascripts/Core/HermitePolynomialApproximation.js +176 -0
- data/app/assets/javascripts/Core/HermiteSpline.js +234 -0
- data/app/assets/javascripts/Core/Iau2006XysData.js +259 -0
- data/app/assets/javascripts/Core/Iau2006XysSample.js +36 -0
- data/app/assets/javascripts/Core/IndexDatatype.js +28 -0
- data/app/assets/javascripts/Core/Intersect.js +40 -0
- data/app/assets/javascripts/Core/IntersectionTests.js +359 -0
- data/app/assets/javascripts/Core/Interval.js +27 -0
- data/app/assets/javascripts/Core/Iso8601.js +46 -0
- data/app/assets/javascripts/Core/JulianDate.js +1228 -0
- data/app/assets/javascripts/Core/KeyboardEventModifier.js +38 -0
- data/app/assets/javascripts/Core/LagrangePolynomialApproximation.js +96 -0
- data/app/assets/javascripts/Core/LeapSecond.js +158 -0
- data/app/assets/javascripts/Core/LinearApproximation.js +98 -0
- data/app/assets/javascripts/Core/Math.js +532 -0
- data/app/assets/javascripts/Core/Matrix2.js +833 -0
- data/app/assets/javascripts/Core/Matrix3.js +1099 -0
- data/app/assets/javascripts/Core/Matrix4.js +2164 -0
- data/app/assets/javascripts/Core/MeshFilters.js +568 -0
- data/app/assets/javascripts/Core/Occluder.js +474 -0
- data/app/assets/javascripts/Core/OrientationInterpolator.js +109 -0
- data/app/assets/javascripts/Core/PlaneTessellator.js +74 -0
- data/app/assets/javascripts/Core/PolygonPipeline.js +792 -0
- data/app/assets/javascripts/Core/PolylinePipeline.js +90 -0
- data/app/assets/javascripts/Core/PrimitiveType.js +80 -0
- data/app/assets/javascripts/Core/QuadraticRealPolynomial.js +146 -0
- data/app/assets/javascripts/Core/QuarticRealPolynomial.js +339 -0
- data/app/assets/javascripts/Core/Quaternion.js +947 -0
- data/app/assets/javascripts/Core/Queue.js +95 -0
- data/app/assets/javascripts/Core/Ray.js +64 -0
- data/app/assets/javascripts/Core/ReferenceFrame.js +25 -0
- data/app/assets/javascripts/Core/RequestErrorEvent.js +35 -0
- data/app/assets/javascripts/Core/RuntimeError.js +59 -0
- data/app/assets/javascripts/Core/ScreenSpaceEventHandler.js +658 -0
- data/app/assets/javascripts/Core/ScreenSpaceEventType.js +149 -0
- data/app/assets/javascripts/Core/Shapes.js +230 -0
- data/app/assets/javascripts/Core/Spherical.js +192 -0
- data/app/assets/javascripts/Core/TaskProcessor.js +131 -0
- data/app/assets/javascripts/Core/TimeConstants.js +85 -0
- data/app/assets/javascripts/Core/TimeInterval.js +305 -0
- data/app/assets/javascripts/Core/TimeIntervalCollection.js +543 -0
- data/app/assets/javascripts/Core/TimeStandard.js +31 -0
- data/app/assets/javascripts/Core/Tipsify.js +285 -0
- data/app/assets/javascripts/Core/Transforms.js +614 -0
- data/app/assets/javascripts/Core/TridiagonalSystemSolver.js +102 -0
- data/app/assets/javascripts/Core/Visibility.js +38 -0
- data/app/assets/javascripts/Core/WebMercatorProjection.js +154 -0
- data/app/assets/javascripts/Core/WindingOrder.js +40 -0
- data/app/assets/javascripts/Core/binarySearch.js +69 -0
- data/app/assets/javascripts/Core/buildModuleUrl.js +77 -0
- data/app/assets/javascripts/Core/clone.js +21 -0
- data/app/assets/javascripts/Core/combine.js +81 -0
- data/app/assets/javascripts/Core/computeSunPosition.js +116 -0
- data/app/assets/javascripts/Core/createGuid.js +25 -0
- data/app/assets/javascripts/Core/defaultValue.js +22 -0
- data/app/assets/javascripts/Core/destroyObject.js +61 -0
- data/app/assets/javascripts/Core/freezeObject.js +20 -0
- data/app/assets/javascripts/Core/getImagePixels.js +46 -0
- data/app/assets/javascripts/Core/isLeapYear.js +30 -0
- data/app/assets/javascripts/Core/jsonp.js +116 -0
- data/app/assets/javascripts/Core/loadArrayBuffer.js +76 -0
- data/app/assets/javascripts/Core/loadImage.js +85 -0
- data/app/assets/javascripts/Core/loadJson.js +54 -0
- data/app/assets/javascripts/Core/loadText.js +78 -0
- data/app/assets/javascripts/Core/loadXML.js +76 -0
- data/app/assets/javascripts/Core/package.json +6 -0
- data/app/assets/javascripts/Core/pointInsideTriangle2D.js +41 -0
- data/app/assets/javascripts/Core/requestAnimationFrame.js +61 -0
- data/app/assets/javascripts/Core/throttleRequestByServer.js +74 -0
- data/app/assets/javascripts/Core/writeTextToCanvas.js +92 -0
- data/app/assets/javascripts/DynamicScene/CompositeDynamicObjectCollection.js +254 -0
- data/app/assets/javascripts/DynamicScene/CzmlBoolean.js +57 -0
- data/app/assets/javascripts/DynamicScene/CzmlCartesian2.js +96 -0
- data/app/assets/javascripts/DynamicScene/CzmlCartesian3.js +99 -0
- data/app/assets/javascripts/DynamicScene/CzmlCartographic.js +125 -0
- data/app/assets/javascripts/DynamicScene/CzmlColor.js +127 -0
- data/app/assets/javascripts/DynamicScene/CzmlDefaults.js +135 -0
- data/app/assets/javascripts/DynamicScene/CzmlHorizontalOrigin.js +59 -0
- data/app/assets/javascripts/DynamicScene/CzmlImage.js +61 -0
- data/app/assets/javascripts/DynamicScene/CzmlLabelStyle.js +59 -0
- data/app/assets/javascripts/DynamicScene/CzmlNumber.js +82 -0
- data/app/assets/javascripts/DynamicScene/CzmlString.js +56 -0
- data/app/assets/javascripts/DynamicScene/CzmlUnitCartesian3.js +99 -0
- data/app/assets/javascripts/DynamicScene/CzmlUnitQuaternion.js +172 -0
- data/app/assets/javascripts/DynamicScene/CzmlUnitSpherical.js +98 -0
- data/app/assets/javascripts/DynamicScene/CzmlVerticalOrigin.js +59 -0
- data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +245 -0
- data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +347 -0
- data/app/assets/javascripts/DynamicScene/DynamicColorMaterial.js +78 -0
- data/app/assets/javascripts/DynamicScene/DynamicCone.js +291 -0
- data/app/assets/javascripts/DynamicScene/DynamicConeVisualizer.js +350 -0
- data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +389 -0
- data/app/assets/javascripts/DynamicScene/DynamicDirectionsProperty.js +163 -0
- data/app/assets/javascripts/DynamicScene/DynamicEllipsoid.js +158 -0
- data/app/assets/javascripts/DynamicScene/DynamicEllipsoidVisualizer.js +277 -0
- data/app/assets/javascripts/DynamicScene/DynamicImageMaterial.js +136 -0
- data/app/assets/javascripts/DynamicScene/DynamicLabel.js +286 -0
- data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +341 -0
- data/app/assets/javascripts/DynamicScene/DynamicMaterialProperty.js +125 -0
- data/app/assets/javascripts/DynamicScene/DynamicObject.js +364 -0
- data/app/assets/javascripts/DynamicScene/DynamicObjectCollection.js +137 -0
- data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +299 -0
- data/app/assets/javascripts/DynamicScene/DynamicPath.js +214 -0
- data/app/assets/javascripts/DynamicScene/DynamicPathVisualizer.js +402 -0
- data/app/assets/javascripts/DynamicScene/DynamicPoint.js +184 -0
- data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +323 -0
- data/app/assets/javascripts/DynamicScene/DynamicPolygon.js +138 -0
- data/app/assets/javascripts/DynamicScene/DynamicPolygonVisualizer.js +251 -0
- data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +183 -0
- data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +268 -0
- data/app/assets/javascripts/DynamicScene/DynamicPositionProperty.js +525 -0
- data/app/assets/javascripts/DynamicScene/DynamicProperty.js +352 -0
- data/app/assets/javascripts/DynamicScene/DynamicPyramid.js +204 -0
- data/app/assets/javascripts/DynamicScene/DynamicPyramidVisualizer.js +302 -0
- data/app/assets/javascripts/DynamicScene/DynamicScene.profile.js +8 -0
- data/app/assets/javascripts/DynamicScene/DynamicVertexPositionsProperty.js +199 -0
- data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +155 -0
- data/app/assets/javascripts/DynamicScene/VisualizerCollection.js +181 -0
- data/app/assets/javascripts/DynamicScene/package.json +6 -0
- data/app/assets/javascripts/DynamicScene/processCzml.js +77 -0
- data/app/assets/javascripts/Renderer/BlendEquation.js +52 -0
- data/app/assets/javascripts/Renderer/BlendFunction.js +158 -0
- data/app/assets/javascripts/Renderer/BlendingState.js +64 -0
- data/app/assets/javascripts/Renderer/Buffer.js +141 -0
- data/app/assets/javascripts/Renderer/BufferUsage.js +48 -0
- data/app/assets/javascripts/Renderer/ClearCommand.js +40 -0
- data/app/assets/javascripts/Renderer/CommandLists.js +42 -0
- data/app/assets/javascripts/Renderer/Context.js +2805 -0
- data/app/assets/javascripts/Renderer/CubeMap.js +358 -0
- data/app/assets/javascripts/Renderer/CubeMapFace.js +202 -0
- data/app/assets/javascripts/Renderer/CullFace.js +50 -0
- data/app/assets/javascripts/Renderer/DepthFunction.js +95 -0
- data/app/assets/javascripts/Renderer/DrawCommand.js +96 -0
- data/app/assets/javascripts/Renderer/Framebuffer.js +435 -0
- data/app/assets/javascripts/Renderer/MipmapHint.js +50 -0
- data/app/assets/javascripts/Renderer/PickFramebuffer.js +178 -0
- data/app/assets/javascripts/Renderer/PixelDatatype.js +86 -0
- data/app/assets/javascripts/Renderer/PixelFormat.js +113 -0
- data/app/assets/javascripts/Renderer/Renderbuffer.js +102 -0
- data/app/assets/javascripts/Renderer/RenderbufferFormat.js +77 -0
- data/app/assets/javascripts/Renderer/Renderer.profile.js +8 -0
- data/app/assets/javascripts/Renderer/ShaderCache.js +121 -0
- data/app/assets/javascripts/Renderer/ShaderProgram.js +2402 -0
- data/app/assets/javascripts/Renderer/StencilFunction.js +95 -0
- data/app/assets/javascripts/Renderer/StencilOperation.js +95 -0
- data/app/assets/javascripts/Renderer/Texture.js +395 -0
- data/app/assets/javascripts/Renderer/TextureAtlas.js +472 -0
- data/app/assets/javascripts/Renderer/TextureAtlasBuilder.js +133 -0
- data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +41 -0
- data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +77 -0
- data/app/assets/javascripts/Renderer/TextureWrap.js +50 -0
- data/app/assets/javascripts/Renderer/UniformDatatype.js +218 -0
- data/app/assets/javascripts/Renderer/UniformState.js +799 -0
- data/app/assets/javascripts/Renderer/VertexArray.js +365 -0
- data/app/assets/javascripts/Renderer/VertexArrayFacade.js +574 -0
- data/app/assets/javascripts/Renderer/VertexLayout.js +49 -0
- data/app/assets/javascripts/Renderer/loadCubeMap.js +92 -0
- data/app/assets/javascripts/Renderer/package.json +6 -0
- data/app/assets/javascripts/Scene/AnimationCollection.js +249 -0
- data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +384 -0
- data/app/assets/javascripts/Scene/Billboard.js +680 -0
- data/app/assets/javascripts/Scene/BillboardCollection.js +1209 -0
- data/app/assets/javascripts/Scene/BingMapsImageryProvider.js +460 -0
- data/app/assets/javascripts/Scene/BingMapsStyle.js +55 -0
- data/app/assets/javascripts/Scene/Camera.js +358 -0
- data/app/assets/javascripts/Scene/CameraColumbusViewMode.js +30 -0
- data/app/assets/javascripts/Scene/CameraController.js +1258 -0
- data/app/assets/javascripts/Scene/CameraEventAggregator.js +270 -0
- data/app/assets/javascripts/Scene/CameraEventType.js +53 -0
- data/app/assets/javascripts/Scene/CameraFlightPath.js +495 -0
- data/app/assets/javascripts/Scene/CentralBody.js +817 -0
- data/app/assets/javascripts/Scene/CentralBodySurface.js +1120 -0
- data/app/assets/javascripts/Scene/CentralBodySurfaceShaderSet.js +107 -0
- data/app/assets/javascripts/Scene/ComplexConicSensorVolume.js +511 -0
- data/app/assets/javascripts/Scene/CompositePrimitive.js +454 -0
- data/app/assets/javascripts/Scene/CullingVolume.js +59 -0
- data/app/assets/javascripts/Scene/CustomSensorVolume.js +440 -0
- data/app/assets/javascripts/Scene/DiscardMissingTileImagePolicy.js +134 -0
- data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +412 -0
- data/app/assets/javascripts/Scene/EllipsoidTerrainProvider.js +182 -0
- data/app/assets/javascripts/Scene/FrameState.js +86 -0
- data/app/assets/javascripts/Scene/FrustumCommands.js +32 -0
- data/app/assets/javascripts/Scene/GeographicTilingScheme.js +265 -0
- data/app/assets/javascripts/Scene/HorizontalOrigin.js +39 -0
- data/app/assets/javascripts/Scene/Imagery.js +85 -0
- data/app/assets/javascripts/Scene/ImageryLayer.js +876 -0
- data/app/assets/javascripts/Scene/ImageryLayerCollection.js +403 -0
- data/app/assets/javascripts/Scene/ImageryProvider.js +185 -0
- data/app/assets/javascripts/Scene/ImageryProviderError.js +149 -0
- data/app/assets/javascripts/Scene/ImageryState.js +20 -0
- data/app/assets/javascripts/Scene/Label.js +706 -0
- data/app/assets/javascripts/Scene/LabelCollection.js +697 -0
- data/app/assets/javascripts/Scene/LabelStyle.js +39 -0
- data/app/assets/javascripts/Scene/Material.js +1177 -0
- data/app/assets/javascripts/Scene/NeverTileDiscardPolicy.js +38 -0
- data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +282 -0
- data/app/assets/javascripts/Scene/OrthographicFrustum.js +345 -0
- data/app/assets/javascripts/Scene/PerformanceDisplay.js +183 -0
- data/app/assets/javascripts/Scene/PerspectiveFrustum.js +239 -0
- data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +394 -0
- data/app/assets/javascripts/Scene/Polygon.js +886 -0
- data/app/assets/javascripts/Scene/Polyline.js +441 -0
- data/app/assets/javascripts/Scene/PolylineCollection.js +1532 -0
- data/app/assets/javascripts/Scene/Projections.js +93 -0
- data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +224 -0
- data/app/assets/javascripts/Scene/Scene.js +632 -0
- data/app/assets/javascripts/Scene/Scene.profile.js +8 -0
- data/app/assets/javascripts/Scene/SceneMode.js +51 -0
- data/app/assets/javascripts/Scene/SceneTransitioner.js +776 -0
- data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1063 -0
- data/app/assets/javascripts/Scene/SensorVolumeCollection.js +192 -0
- data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +295 -0
- data/app/assets/javascripts/Scene/SkyAtmosphere.js +239 -0
- data/app/assets/javascripts/Scene/SkyBox.js +231 -0
- data/app/assets/javascripts/Scene/TerrainProvider.js +229 -0
- data/app/assets/javascripts/Scene/TexturePool.js +154 -0
- data/app/assets/javascripts/Scene/Tile.js +322 -0
- data/app/assets/javascripts/Scene/TileDiscardPolicy.js +42 -0
- data/app/assets/javascripts/Scene/TileImagery.js +36 -0
- data/app/assets/javascripts/Scene/TileLoadQueue.js +123 -0
- data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +337 -0
- data/app/assets/javascripts/Scene/TileReplacementQueue.js +139 -0
- data/app/assets/javascripts/Scene/TileState.js +19 -0
- data/app/assets/javascripts/Scene/TilingScheme.js +213 -0
- data/app/assets/javascripts/Scene/VerticalOrigin.js +39 -0
- data/app/assets/javascripts/Scene/ViewportQuad.js +256 -0
- data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +374 -0
- data/app/assets/javascripts/Scene/WebMercatorTilingScheme.js +291 -0
- data/app/assets/javascripts/Scene/package.json +6 -0
- data/app/assets/javascripts/Shaders/BillboardCollectionFS.glsl +30 -0
- data/app/assets/javascripts/Shaders/BillboardCollectionFS.js +31 -0
- data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +68 -0
- data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +54 -0
- data/app/assets/javascripts/Shaders/BuiltinFunctions.glsl +927 -0
- data/app/assets/javascripts/Shaders/BuiltinFunctions.js +322 -0
- data/app/assets/javascripts/Shaders/CentralBodyFS.glsl +106 -0
- data/app/assets/javascripts/Shaders/CentralBodyFS.js +82 -0
- data/app/assets/javascripts/Shaders/CentralBodyFSDepth.glsl +20 -0
- data/app/assets/javascripts/Shaders/CentralBodyFSDepth.js +22 -0
- data/app/assets/javascripts/Shaders/CentralBodyFSPole.glsl +29 -0
- data/app/assets/javascripts/Shaders/CentralBodyFSPole.js +28 -0
- data/app/assets/javascripts/Shaders/CentralBodyVS.glsl +88 -0
- data/app/assets/javascripts/Shaders/CentralBodyVS.js +69 -0
- data/app/assets/javascripts/Shaders/CentralBodyVSDepth.glsl +9 -0
- data/app/assets/javascripts/Shaders/CentralBodyVSDepth.js +13 -0
- data/app/assets/javascripts/Shaders/CentralBodyVSPole.glsl +12 -0
- data/app/assets/javascripts/Shaders/CentralBodyVSPole.js +15 -0
- data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.glsl +448 -0
- data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.js +361 -0
- data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.glsl +19 -0
- data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.js +20 -0
- data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.glsl +886 -0
- data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.js +586 -0
- data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.glsl +126 -0
- data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.js +95 -0
- data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.glsl +14 -0
- data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.js +18 -0
- data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +40 -0
- data/app/assets/javascripts/Shaders/EllipsoidFS.js +38 -0
- data/app/assets/javascripts/Shaders/EllipsoidVS.glsl +26 -0
- data/app/assets/javascripts/Shaders/EllipsoidVS.js +16 -0
- data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.glsl +25 -0
- data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.js +23 -0
- data/app/assets/javascripts/Shaders/Materials/BlobMaterial.glsl +18 -0
- data/app/assets/javascripts/Shaders/Materials/BlobMaterial.js +19 -0
- data/app/assets/javascripts/Shaders/Materials/BrickMaterial.glsl +42 -0
- data/app/assets/javascripts/Shaders/Materials/BrickMaterial.js +36 -0
- data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.glsl +29 -0
- data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.js +27 -0
- data/app/assets/javascripts/Shaders/Materials/CementMaterial.glsl +19 -0
- data/app/assets/javascripts/Shaders/Materials/CementMaterial.js +20 -0
- data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.glsl +38 -0
- data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.js +32 -0
- data/app/assets/javascripts/Shaders/Materials/DotMaterial.glsl +17 -0
- data/app/assets/javascripts/Shaders/Materials/DotMaterial.js +18 -0
- data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.glsl +23 -0
- data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.js +24 -0
- data/app/assets/javascripts/Shaders/Materials/FacetMaterial.glsl +18 -0
- data/app/assets/javascripts/Shaders/Materials/FacetMaterial.js +19 -0
- data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.glsl +12 -0
- data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.js +15 -0
- data/app/assets/javascripts/Shaders/Materials/GrassMaterial.glsl +28 -0
- data/app/assets/javascripts/Shaders/Materials/GrassMaterial.js +26 -0
- data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.glsl +19 -0
- data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.js +21 -0
- data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.glsl +13 -0
- data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.js +16 -0
- data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.glsl +14 -0
- data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.js +17 -0
- data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.glsl +18 -0
- data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.js +19 -0
- data/app/assets/javascripts/Shaders/Materials/StripeMaterial.glsl +29 -0
- data/app/assets/javascripts/Shaders/Materials/StripeMaterial.js +26 -0
- data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.glsl +17 -0
- data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.js +19 -0
- data/app/assets/javascripts/Shaders/Materials/Water.glsl +91 -0
- data/app/assets/javascripts/Shaders/Materials/Water.js +60 -0
- data/app/assets/javascripts/Shaders/Materials/WoodMaterial.glsl +36 -0
- data/app/assets/javascripts/Shaders/Materials/WoodMaterial.js +31 -0
- data/app/assets/javascripts/Shaders/Noise.glsl +453 -0
- data/app/assets/javascripts/Shaders/Noise.js +242 -0
- data/app/assets/javascripts/Shaders/PolygonFS.glsl +27 -0
- data/app/assets/javascripts/Shaders/PolygonFS.js +23 -0
- data/app/assets/javascripts/Shaders/PolygonFSPick.glsl +6 -0
- data/app/assets/javascripts/Shaders/PolygonFSPick.js +11 -0
- data/app/assets/javascripts/Shaders/PolygonVS.glsl +38 -0
- data/app/assets/javascripts/Shaders/PolygonVS.js +39 -0
- data/app/assets/javascripts/Shaders/PolygonVSPick.glsl +30 -0
- data/app/assets/javascripts/Shaders/PolygonVSPick.js +32 -0
- data/app/assets/javascripts/Shaders/PolylineFS.glsl +6 -0
- data/app/assets/javascripts/Shaders/PolylineFS.js +11 -0
- data/app/assets/javascripts/Shaders/PolylineVS.glsl +34 -0
- data/app/assets/javascripts/Shaders/PolylineVS.js +35 -0
- data/app/assets/javascripts/Shaders/Ray.glsl +532 -0
- data/app/assets/javascripts/Shaders/Ray.js +357 -0
- data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.glsl +26 -0
- data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.js +22 -0
- data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.glsl +11 -0
- data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.js +14 -0
- data/app/assets/javascripts/Shaders/SensorVolume.glsl +43 -0
- data/app/assets/javascripts/Shaders/SensorVolume.js +31 -0
- data/app/assets/javascripts/Shaders/Shaders.profile.js +8 -0
- data/app/assets/javascripts/Shaders/SkyAtmosphereFS.glsl +70 -0
- data/app/assets/javascripts/Shaders/SkyAtmosphereFS.js +62 -0
- data/app/assets/javascripts/Shaders/SkyAtmosphereVS.glsl +131 -0
- data/app/assets/javascripts/Shaders/SkyAtmosphereVS.js +115 -0
- data/app/assets/javascripts/Shaders/SkyBoxFS.glsl +10 -0
- data/app/assets/javascripts/Shaders/SkyBoxFS.js +14 -0
- data/app/assets/javascripts/Shaders/SkyBoxVS.glsl +10 -0
- data/app/assets/javascripts/Shaders/SkyBoxVS.js +14 -0
- data/app/assets/javascripts/Shaders/ViewportQuadFS.glsl +16 -0
- data/app/assets/javascripts/Shaders/ViewportQuadFS.js +17 -0
- data/app/assets/javascripts/Shaders/ViewportQuadVS.glsl +10 -0
- data/app/assets/javascripts/Shaders/ViewportQuadVS.js +14 -0
- data/app/assets/javascripts/Shaders/package.json +6 -0
- data/app/assets/javascripts/ThirdParty/ThirdParty.profile.js +8 -0
- data/app/assets/javascripts/ThirdParty/Tween.js +678 -0
- data/app/assets/javascripts/ThirdParty/Uri.js +277 -0
- data/app/assets/javascripts/ThirdParty/measureText.js +197 -0
- data/app/assets/javascripts/ThirdParty/package.json +6 -0
- data/app/assets/javascripts/ThirdParty/sprintf.js +319 -0
- data/app/assets/javascripts/ThirdParty/when.js +748 -0
- data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.css +175 -0
- data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.html +52 -0
- data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.js +1237 -0
- data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.html +4 -0
- data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.js +349 -0
- data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.css +1 -0
- data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.js +47 -0
- data/app/assets/javascripts/Widgets/Dojo/checkForChromeFrame.js +71 -0
- data/app/assets/javascripts/Widgets/Images/Bing_Logo_51x19_White.png +0 -0
- data/app/assets/javascripts/Widgets/Images/Cesium_Logo_overlay.png +0 -0
- data/app/assets/javascripts/Widgets/Images/TimelineIcons.png +0 -0
- data/app/assets/javascripts/Widgets/Images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/Widgets/Images/animationBar.png +0 -0
- data/app/assets/javascripts/Widgets/Images/viewControlBar.png +0 -0
- data/app/assets/javascripts/Widgets/Timeline.css +113 -0
- data/app/assets/javascripts/Widgets/Timeline.js +629 -0
- data/app/assets/javascripts/Widgets/TimelineHighlightRange.js +51 -0
- data/app/assets/javascripts/Widgets/TimelineTrack.js +54 -0
- data/app/assets/javascripts/Widgets/Widgets.profile.js +8 -0
- data/app/assets/javascripts/Widgets/package.json +6 -0
- data/app/assets/javascripts/Workers/Workers.profile.js +8 -0
- data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +2015 -0
- data/app/assets/javascripts/Workers/createTaskProcessorWorker.js +55 -0
- data/app/assets/javascripts/Workers/createVerticesFromExtent.js +24 -0
- data/app/assets/javascripts/Workers/package.json +6 -0
- data/app/assets/javascripts/copyrightHeader.js +22 -0
- data/app/assets/javascripts/main.js +10 -0
- data/app/assets/stylesheets/cesium.css +4 -0
- data/app/controllers/cesium_controller.rb +4 -0
- data/app/helpers/cesium_helper.rb +2 -0
- data/app/views/cesium/index.html.erb +3 -0
- data/config/routes.rb +3 -0
- data/lib/cesium.rb +4 -0
- data/lib/cesium/engine.rb +4 -0
- data/lib/cesium/version.rb +3 -0
- data/lib/tasks/cesium_tasks.rake +4 -0
- data/test/cesium_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/adapters/jquery-adapter.js.coffee +4 -0
- data/test/dummy/app/assets/javascripts/app.js.coffee +11 -0
- data/test/dummy/app/assets/javascripts/application.js.coffee +73 -0
- data/test/dummy/app/assets/stylesheets/application.css +12 -0
- data/test/dummy/app/controllers/application_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +21 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/requirejs.yml +10 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/functional/cesium_controller_test.rb +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/helpers/cesium_helper_test.rb +4 -0
- metadata +641 -0
|
@@ -0,0 +1,2164 @@
|
|
|
1
|
+
/*global define*/
|
|
2
|
+
define([
|
|
3
|
+
'./Cartesian3',
|
|
4
|
+
'./Cartesian4',
|
|
5
|
+
'./defaultValue',
|
|
6
|
+
'./DeveloperError',
|
|
7
|
+
'./freezeObject',
|
|
8
|
+
'./Math',
|
|
9
|
+
'./Matrix3',
|
|
10
|
+
'./RuntimeError'
|
|
11
|
+
], function(
|
|
12
|
+
Cartesian3,
|
|
13
|
+
Cartesian4,
|
|
14
|
+
defaultValue,
|
|
15
|
+
DeveloperError,
|
|
16
|
+
freezeObject,
|
|
17
|
+
CesiumMath,
|
|
18
|
+
Matrix3,
|
|
19
|
+
RuntimeError) {
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A 4x4 matrix, indexable as a column-major order array.
|
|
24
|
+
* Constructor parameters are in row-major order for code readability.
|
|
25
|
+
* @alias Matrix4
|
|
26
|
+
* @constructor
|
|
27
|
+
*
|
|
28
|
+
* @param {Number} [column0Row0=0.0] The value for column 0, row 0.
|
|
29
|
+
* @param {Number} [column1Row0=0.0] The value for column 1, row 0.
|
|
30
|
+
* @param {Number} [column2Row0=0.0] The value for column 2, row 0.
|
|
31
|
+
* @param {Number} [column3Row0=0.0] The value for column 3, row 0.
|
|
32
|
+
* @param {Number} [column0Row1=0.0] The value for column 0, row 1.
|
|
33
|
+
* @param {Number} [column1Row1=0.0] The value for column 1, row 1.
|
|
34
|
+
* @param {Number} [column2Row1=0.0] The value for column 2, row 1.
|
|
35
|
+
* @param {Number} [column3Row1=0.0] The value for column 3, row 1.
|
|
36
|
+
* @param {Number} [column0Row2=0.0] The value for column 0, row 2.
|
|
37
|
+
* @param {Number} [column1Row2=0.0] The value for column 1, row 2.
|
|
38
|
+
* @param {Number} [column2Row2=0.0] The value for column 2, row 2.
|
|
39
|
+
* @param {Number} [column3Row2=0.0] The value for column 3, row 2.
|
|
40
|
+
* @param {Number} [column0Row3=0.0] The value for column 0, row 3.
|
|
41
|
+
* @param {Number} [column1Row3=0.0] The value for column 1, row 3.
|
|
42
|
+
* @param {Number} [column2Row3=0.0] The value for column 2, row 3.
|
|
43
|
+
* @param {Number} [column3Row3=0.0] The value for column 3, row 3.
|
|
44
|
+
*
|
|
45
|
+
* @see Matrix4.fromColumnMajorArray
|
|
46
|
+
* @see Matrix4.fromRowMajorArray
|
|
47
|
+
* @see Matrix4.fromRotationTranslation
|
|
48
|
+
* @see Matrix4.fromTranslation
|
|
49
|
+
* @see Matrix4.fromScale
|
|
50
|
+
* @see Matrix4.fromUniformScale
|
|
51
|
+
* @see Matrix4.fromCamera
|
|
52
|
+
* @see Matrix4.computePerspectiveFieldOfView
|
|
53
|
+
* @see Matrix4.computeOrthographicOffCenter
|
|
54
|
+
* @see Matrix4.computePerspectiveOffCenter
|
|
55
|
+
* @see Matrix4.computeInfinitePerspectiveOffCenter
|
|
56
|
+
* @see Matrix4.computeViewportTransformation
|
|
57
|
+
* @see Matrix2
|
|
58
|
+
* @see Matrix3
|
|
59
|
+
*/
|
|
60
|
+
var Matrix4 = function(column0Row0, column1Row0, column2Row0, column3Row0,
|
|
61
|
+
column0Row1, column1Row1, column2Row1, column3Row1,
|
|
62
|
+
column0Row2, column1Row2, column2Row2, column3Row2,
|
|
63
|
+
column0Row3, column1Row3, column2Row3, column3Row3) {
|
|
64
|
+
this[0] = defaultValue(column0Row0, 0.0);
|
|
65
|
+
this[1] = defaultValue(column0Row1, 0.0);
|
|
66
|
+
this[2] = defaultValue(column0Row2, 0.0);
|
|
67
|
+
this[3] = defaultValue(column0Row3, 0.0);
|
|
68
|
+
this[4] = defaultValue(column1Row0, 0.0);
|
|
69
|
+
this[5] = defaultValue(column1Row1, 0.0);
|
|
70
|
+
this[6] = defaultValue(column1Row2, 0.0);
|
|
71
|
+
this[7] = defaultValue(column1Row3, 0.0);
|
|
72
|
+
this[8] = defaultValue(column2Row0, 0.0);
|
|
73
|
+
this[9] = defaultValue(column2Row1, 0.0);
|
|
74
|
+
this[10] = defaultValue(column2Row2, 0.0);
|
|
75
|
+
this[11] = defaultValue(column2Row3, 0.0);
|
|
76
|
+
this[12] = defaultValue(column3Row0, 0.0);
|
|
77
|
+
this[13] = defaultValue(column3Row1, 0.0);
|
|
78
|
+
this[14] = defaultValue(column3Row2, 0.0);
|
|
79
|
+
this[15] = defaultValue(column3Row3, 0.0);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Duplicates a Matrix4 instance.
|
|
84
|
+
* @memberof Matrix4
|
|
85
|
+
*
|
|
86
|
+
* @param {Matrix4} matrix The matrix to duplicate.
|
|
87
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
88
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
89
|
+
*
|
|
90
|
+
* @exception {DeveloperError} matrix is required.
|
|
91
|
+
*/
|
|
92
|
+
Matrix4.clone = function(values, result) {
|
|
93
|
+
if (typeof values === 'undefined') {
|
|
94
|
+
throw new DeveloperError('values is required');
|
|
95
|
+
}
|
|
96
|
+
if (typeof result === 'undefined') {
|
|
97
|
+
return new Matrix4(values[0], values[4], values[8], values[12],
|
|
98
|
+
values[1], values[5], values[9], values[13],
|
|
99
|
+
values[2], values[6], values[10], values[14],
|
|
100
|
+
values[3], values[7], values[11], values[15]);
|
|
101
|
+
}
|
|
102
|
+
result[0] = values[0];
|
|
103
|
+
result[1] = values[1];
|
|
104
|
+
result[2] = values[2];
|
|
105
|
+
result[3] = values[3];
|
|
106
|
+
result[4] = values[4];
|
|
107
|
+
result[5] = values[5];
|
|
108
|
+
result[6] = values[6];
|
|
109
|
+
result[7] = values[7];
|
|
110
|
+
result[8] = values[8];
|
|
111
|
+
result[9] = values[9];
|
|
112
|
+
result[10] = values[10];
|
|
113
|
+
result[11] = values[11];
|
|
114
|
+
result[12] = values[12];
|
|
115
|
+
result[13] = values[13];
|
|
116
|
+
result[14] = values[14];
|
|
117
|
+
result[15] = values[15];
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Computes a Matrix4 instance from a column-major order array.
|
|
123
|
+
* @memberof Matrix4
|
|
124
|
+
* @function
|
|
125
|
+
*
|
|
126
|
+
* @param {Array} values The column-major order array.
|
|
127
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
128
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
129
|
+
*
|
|
130
|
+
* @exception {DeveloperError} values is required.
|
|
131
|
+
*/
|
|
132
|
+
Matrix4.fromColumnMajorArray = Matrix4.clone;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Computes a Matrix4 instance from a row-major order array.
|
|
136
|
+
* The resulting matrix will be in column-major order.
|
|
137
|
+
* @memberof Matrix4
|
|
138
|
+
*
|
|
139
|
+
* @param {Array} values The row-major order array.
|
|
140
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
141
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
142
|
+
*
|
|
143
|
+
* @exception {DeveloperError} values is required.
|
|
144
|
+
*/
|
|
145
|
+
Matrix4.fromRowMajorArray = function(values, result) {
|
|
146
|
+
if (typeof values === 'undefined') {
|
|
147
|
+
throw new DeveloperError('values is required.');
|
|
148
|
+
}
|
|
149
|
+
if (typeof result === 'undefined') {
|
|
150
|
+
return new Matrix4(values[0], values[1], values[2], values[3],
|
|
151
|
+
values[4], values[5], values[6], values[7],
|
|
152
|
+
values[8], values[9], values[10], values[11],
|
|
153
|
+
values[12], values[13], values[14], values[15]);
|
|
154
|
+
}
|
|
155
|
+
result[0] = values[0];
|
|
156
|
+
result[1] = values[4];
|
|
157
|
+
result[2] = values[8];
|
|
158
|
+
result[3] = values[12];
|
|
159
|
+
result[4] = values[1];
|
|
160
|
+
result[5] = values[5];
|
|
161
|
+
result[6] = values[9];
|
|
162
|
+
result[7] = values[13];
|
|
163
|
+
result[8] = values[2];
|
|
164
|
+
result[9] = values[6];
|
|
165
|
+
result[10] = values[10];
|
|
166
|
+
result[11] = values[14];
|
|
167
|
+
result[12] = values[3];
|
|
168
|
+
result[13] = values[7];
|
|
169
|
+
result[14] = values[11];
|
|
170
|
+
result[15] = values[15];
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Computes a Matrix4 instance from a Matrix3 representing the rotation
|
|
176
|
+
* and a Cartesian3 representing the translation.
|
|
177
|
+
* @memberof Matrix4
|
|
178
|
+
*
|
|
179
|
+
* @param {Matrix3} rotation The upper left portion of the matrix representing the rotation.
|
|
180
|
+
* @param {Cartesian3} translation The upper right portion of the matrix representing the translation.
|
|
181
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
182
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
183
|
+
*
|
|
184
|
+
* @exception {DeveloperError} rotation is required.
|
|
185
|
+
* @exception {DeveloperError} translation is required.
|
|
186
|
+
*/
|
|
187
|
+
Matrix4.fromRotationTranslation = function(rotation, translation, result) {
|
|
188
|
+
if (typeof rotation === 'undefined') {
|
|
189
|
+
throw new DeveloperError('rotation is required.');
|
|
190
|
+
}
|
|
191
|
+
if (typeof translation === 'undefined') {
|
|
192
|
+
throw new DeveloperError('translation is required.');
|
|
193
|
+
}
|
|
194
|
+
if (typeof result === 'undefined') {
|
|
195
|
+
return new Matrix4(rotation[0], rotation[3], rotation[6], translation.x,
|
|
196
|
+
rotation[1], rotation[4], rotation[7], translation.y,
|
|
197
|
+
rotation[2], rotation[5], rotation[8], translation.z,
|
|
198
|
+
0.0, 0.0, 0.0, 1.0);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
result[0] = rotation[0];
|
|
202
|
+
result[1] = rotation[1];
|
|
203
|
+
result[2] = rotation[2];
|
|
204
|
+
result[3] = 0.0;
|
|
205
|
+
result[4] = rotation[3];
|
|
206
|
+
result[5] = rotation[4];
|
|
207
|
+
result[6] = rotation[5];
|
|
208
|
+
result[7] = 0.0;
|
|
209
|
+
result[8] = rotation[6];
|
|
210
|
+
result[9] = rotation[7];
|
|
211
|
+
result[10] = rotation[8];
|
|
212
|
+
result[11] = 0.0;
|
|
213
|
+
result[12] = translation.x;
|
|
214
|
+
result[13] = translation.y;
|
|
215
|
+
result[14] = translation.z;
|
|
216
|
+
result[15] = 1.0;
|
|
217
|
+
return result;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Creates a Matrix4 instance from a Cartesian3 representing the translation.
|
|
222
|
+
* @memberof Matrix4
|
|
223
|
+
*
|
|
224
|
+
* @param {Cartesian3} translation The upper right portion of the matrix representing the translation.
|
|
225
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
226
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
227
|
+
*
|
|
228
|
+
* @see Matrix4.multiplyByTranslation
|
|
229
|
+
*
|
|
230
|
+
* @exception {DeveloperError} translation is required.
|
|
231
|
+
*/
|
|
232
|
+
Matrix4.fromTranslation = function(translation, result) {
|
|
233
|
+
return Matrix4.fromRotationTranslation(Matrix3.IDENTITY, translation, result);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Computes a Matrix4 instance representing a non-uniform scale.
|
|
238
|
+
* @memberof Matrix4
|
|
239
|
+
*
|
|
240
|
+
* @param {Cartesian3} scale The x, y, and z scale factors.
|
|
241
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
242
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
243
|
+
*
|
|
244
|
+
* @exception {DeveloperError} scale is required.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* // Creates
|
|
248
|
+
* // [7.0, 0.0, 0.0, 0.0]
|
|
249
|
+
* // [0.0, 8.0, 0.0, 0.0]
|
|
250
|
+
* // [0.0, 0.0, 9.0, 0.0]
|
|
251
|
+
* // [0.0, 0.0, 0.0, 1.0]
|
|
252
|
+
* var m = Matrix4.fromScale(new Cartesian3(7.0, 8.0, 9.0));
|
|
253
|
+
*/
|
|
254
|
+
Matrix4.fromScale = function(scale, result) {
|
|
255
|
+
if (typeof scale === 'undefined') {
|
|
256
|
+
throw new DeveloperError('scale is required.');
|
|
257
|
+
}
|
|
258
|
+
if (typeof result === 'undefined') {
|
|
259
|
+
return new Matrix4(
|
|
260
|
+
scale.x, 0.0, 0.0, 0.0,
|
|
261
|
+
0.0, scale.y, 0.0, 0.0,
|
|
262
|
+
0.0, 0.0, scale.z, 0.0,
|
|
263
|
+
0.0, 0.0, 0.0, 1.0);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
result[0] = scale.x;
|
|
267
|
+
result[1] = 0.0;
|
|
268
|
+
result[2] = 0.0;
|
|
269
|
+
result[3] = 0.0;
|
|
270
|
+
result[4] = 0.0;
|
|
271
|
+
result[5] = scale.y;
|
|
272
|
+
result[6] = 0.0;
|
|
273
|
+
result[7] = 0.0;
|
|
274
|
+
result[8] = 0.0;
|
|
275
|
+
result[9] = 0.0;
|
|
276
|
+
result[10] = scale.z;
|
|
277
|
+
result[11] = 0.0;
|
|
278
|
+
result[12] = 0.0;
|
|
279
|
+
result[13] = 0.0;
|
|
280
|
+
result[14] = 0.0;
|
|
281
|
+
result[15] = 1.0;
|
|
282
|
+
return result;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Computes a Matrix4 instance representing a uniform scale.
|
|
287
|
+
* @memberof Matrix4
|
|
288
|
+
*
|
|
289
|
+
* @param {Number} scale The uniform scale factor.
|
|
290
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
291
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
292
|
+
*
|
|
293
|
+
* @exception {DeveloperError} scale is required.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* // Creates
|
|
297
|
+
* // [2.0, 0.0, 0.0, 0.0]
|
|
298
|
+
* // [0.0, 2.0, 0.0, 0.0]
|
|
299
|
+
* // [0.0, 0.0, 2.0, 0.0]
|
|
300
|
+
* // [0.0, 0.0, 0.0, 1.0]
|
|
301
|
+
* var m = Matrix4.fromScale(2.0);
|
|
302
|
+
*/
|
|
303
|
+
Matrix4.fromUniformScale = function(scale, result) {
|
|
304
|
+
if (typeof scale !== 'number') {
|
|
305
|
+
throw new DeveloperError('scale is required.');
|
|
306
|
+
}
|
|
307
|
+
if (typeof result === 'undefined') {
|
|
308
|
+
return new Matrix4(scale, 0.0, 0.0, 0.0,
|
|
309
|
+
0.0, scale, 0.0, 0.0,
|
|
310
|
+
0.0, 0.0, scale, 0.0,
|
|
311
|
+
0.0, 0.0, 0.0, 1.0);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
result[0] = scale;
|
|
315
|
+
result[1] = 0.0;
|
|
316
|
+
result[2] = 0.0;
|
|
317
|
+
result[3] = 0.0;
|
|
318
|
+
result[4] = 0.0;
|
|
319
|
+
result[5] = scale;
|
|
320
|
+
result[6] = 0.0;
|
|
321
|
+
result[7] = 0.0;
|
|
322
|
+
result[8] = 0.0;
|
|
323
|
+
result[9] = 0.0;
|
|
324
|
+
result[10] = scale;
|
|
325
|
+
result[11] = 0.0;
|
|
326
|
+
result[12] = 0.0;
|
|
327
|
+
result[13] = 0.0;
|
|
328
|
+
result[14] = 0.0;
|
|
329
|
+
result[15] = 1.0;
|
|
330
|
+
return result;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
var fromCameraF = new Cartesian3();
|
|
334
|
+
var fromCameraS = new Cartesian3();
|
|
335
|
+
var fromCameraU = new Cartesian3();
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Computes a Matrix4 instance from a Camera.
|
|
339
|
+
* @memberof Matrix4
|
|
340
|
+
*
|
|
341
|
+
* @param {Camera} camera The camera to use.
|
|
342
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
343
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
344
|
+
*
|
|
345
|
+
* @exception {DeveloperError} camera is required.
|
|
346
|
+
* @exception {DeveloperError} camera.eye is required.
|
|
347
|
+
* @exception {DeveloperError} camera.target is required.
|
|
348
|
+
* @exception {DeveloperError} camera.up is required.
|
|
349
|
+
*/
|
|
350
|
+
Matrix4.fromCamera = function(camera, result) {
|
|
351
|
+
if (typeof camera === 'undefined') {
|
|
352
|
+
throw new DeveloperError('camera is required.');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var eye = camera.eye;
|
|
356
|
+
var target = camera.target;
|
|
357
|
+
var up = camera.up;
|
|
358
|
+
|
|
359
|
+
if (typeof eye === 'undefined') {
|
|
360
|
+
throw new DeveloperError('camera.eye is required.');
|
|
361
|
+
}
|
|
362
|
+
if (typeof target === 'undefined') {
|
|
363
|
+
throw new DeveloperError('camera.target is required.');
|
|
364
|
+
}
|
|
365
|
+
if (typeof up === 'undefined') {
|
|
366
|
+
throw new DeveloperError('camera.up is required.');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
Cartesian3.subtract(target, eye, fromCameraF).normalize(fromCameraF);
|
|
370
|
+
Cartesian3.cross(fromCameraF, up, fromCameraS).normalize(fromCameraS);
|
|
371
|
+
Cartesian3.cross(fromCameraS, fromCameraF, fromCameraU).normalize(fromCameraU);
|
|
372
|
+
|
|
373
|
+
var sX = fromCameraS.x;
|
|
374
|
+
var sY = fromCameraS.y;
|
|
375
|
+
var sZ = fromCameraS.z;
|
|
376
|
+
var fX = fromCameraF.x;
|
|
377
|
+
var fY = fromCameraF.y;
|
|
378
|
+
var fZ = fromCameraF.z;
|
|
379
|
+
var uX = fromCameraU.x;
|
|
380
|
+
var uY = fromCameraU.y;
|
|
381
|
+
var uZ = fromCameraU.z;
|
|
382
|
+
var eyeX = eye.x;
|
|
383
|
+
var eyeY = eye.y;
|
|
384
|
+
var eyeZ = eye.z;
|
|
385
|
+
var t0 = sX * -eyeX + sY * -eyeY+ sZ * -eyeZ;
|
|
386
|
+
var t1 = uX * -eyeX + uY * -eyeY+ uZ * -eyeZ;
|
|
387
|
+
var t2 = fX * eyeX + fY * eyeY + fZ * eyeZ;
|
|
388
|
+
|
|
389
|
+
//The code below this comment is an optimized
|
|
390
|
+
//version of the commented lines.
|
|
391
|
+
//Rather that create two matrices and then multiply,
|
|
392
|
+
//we just bake in the multiplcation as part of creation.
|
|
393
|
+
//var rotation = new Matrix4(
|
|
394
|
+
// sX, sY, sZ, 0.0,
|
|
395
|
+
// uX, uY, uZ, 0.0,
|
|
396
|
+
// -fX, -fY, -fZ, 0.0,
|
|
397
|
+
// 0.0, 0.0, 0.0, 1.0);
|
|
398
|
+
//var translation = new Matrix4(
|
|
399
|
+
// 1.0, 0.0, 0.0, -eye.x,
|
|
400
|
+
// 0.0, 1.0, 0.0, -eye.y,
|
|
401
|
+
// 0.0, 0.0, 1.0, -eye.z,
|
|
402
|
+
// 0.0, 0.0, 0.0, 1.0);
|
|
403
|
+
//return rotation.multiply(translation);
|
|
404
|
+
if (typeof result === 'undefined') {
|
|
405
|
+
return new Matrix4(
|
|
406
|
+
sX, sY, sZ, t0,
|
|
407
|
+
uX, uY, uZ, t1,
|
|
408
|
+
-fX, -fY, -fZ, t2,
|
|
409
|
+
0.0, 0.0, 0.0, 1.0);
|
|
410
|
+
}
|
|
411
|
+
result[0] = sX;
|
|
412
|
+
result[1] = uX;
|
|
413
|
+
result[2] = -fX;
|
|
414
|
+
result[3] = 0.0;
|
|
415
|
+
result[4] = sY;
|
|
416
|
+
result[5] = uY;
|
|
417
|
+
result[6] = -fY;
|
|
418
|
+
result[7] = 0.0;
|
|
419
|
+
result[8] = sZ;
|
|
420
|
+
result[9] = uZ;
|
|
421
|
+
result[10] = -fZ;
|
|
422
|
+
result[11] = 0.0;
|
|
423
|
+
result[12] = t0;
|
|
424
|
+
result[13] = t1;
|
|
425
|
+
result[14] = t2;
|
|
426
|
+
result[15] = 1.0;
|
|
427
|
+
return result;
|
|
428
|
+
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Computes a Matrix4 instance representing a perspective transformation matrix.
|
|
433
|
+
* @memberof Matrix4
|
|
434
|
+
*
|
|
435
|
+
* @param {Number} fovY The field of view along the Y axis in radians.
|
|
436
|
+
* @param {Number} aspectRatio The aspect ratio.
|
|
437
|
+
* @param {Number} near The distance to the near plane in meters.
|
|
438
|
+
* @param {Number} far The distance to the far plane in meters.
|
|
439
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
440
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
441
|
+
*
|
|
442
|
+
* @exception {DeveloperError} fovY must be in [0, PI).
|
|
443
|
+
* @exception {DeveloperError} aspectRatio must be greater than zero.
|
|
444
|
+
* @exception {DeveloperError} near must be greater than zero.
|
|
445
|
+
* @exception {DeveloperError} far must be greater than zero.
|
|
446
|
+
*/
|
|
447
|
+
Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
|
|
448
|
+
if (fovY <= 0.0 || fovY > Math.PI) {
|
|
449
|
+
throw new DeveloperError('fovY must be in [0, PI).');
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (aspectRatio <= 0.0) {
|
|
453
|
+
throw new DeveloperError('aspectRatio must be greater than zero.');
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (near <= 0.0) {
|
|
457
|
+
throw new DeveloperError('near must be greater than zero.');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (far <= 0.0) {
|
|
461
|
+
throw new DeveloperError('far must be greater than zero.');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
var bottom = Math.tan(fovY * 0.5);
|
|
465
|
+
|
|
466
|
+
var column1Row1 = 1.0 / bottom;
|
|
467
|
+
var column0Row0 = column1Row1 / aspectRatio;
|
|
468
|
+
var column2Row2 = (far + near) / (near - far);
|
|
469
|
+
var column3Row2 = (2.0 * far * near) / (near - far);
|
|
470
|
+
|
|
471
|
+
if (typeof result === 'undefined') {
|
|
472
|
+
return new Matrix4(column0Row0, 0.0, 0.0, 0.0,
|
|
473
|
+
0.0, column1Row1, 0.0, 0.0,
|
|
474
|
+
0.0, 0.0, column2Row2, column3Row2,
|
|
475
|
+
0.0, 0.0, -1.0, 0.0);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
result[0] = column0Row0;
|
|
479
|
+
result[1] = 0.0;
|
|
480
|
+
result[2] = 0.0;
|
|
481
|
+
result[3] = 0.0;
|
|
482
|
+
result[4] = 0.0;
|
|
483
|
+
result[5] = column1Row1;
|
|
484
|
+
result[6] = 0.0;
|
|
485
|
+
result[7] = 0.0;
|
|
486
|
+
result[8] = 0.0;
|
|
487
|
+
result[9] = 0.0;
|
|
488
|
+
result[10] = column2Row2;
|
|
489
|
+
result[11] = -1.0;
|
|
490
|
+
result[12] = 0.0;
|
|
491
|
+
result[13] = 0.0;
|
|
492
|
+
result[14] = column3Row2;
|
|
493
|
+
result[15] = 0.0;
|
|
494
|
+
return result;
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Computes a Matrix4 instance representing an orthographic transformation matrix.
|
|
499
|
+
* @memberof Matrix4
|
|
500
|
+
*
|
|
501
|
+
* @param {Number} left The number of meters to the left of the camera that will be in view.
|
|
502
|
+
* @param {Number} right The number of meters to the right of the camera that will be in view.
|
|
503
|
+
* @param {Number} bottom The number of meters below of the camera that will be in view.
|
|
504
|
+
* @param {Number} top The number of meters above of the camera that will be in view.
|
|
505
|
+
* @param {Number} near The distance to the near plane in meters.
|
|
506
|
+
* @param {Number} far The distance to the far plane in meters.
|
|
507
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
508
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
509
|
+
*
|
|
510
|
+
* @exception {DeveloperError} left is required.
|
|
511
|
+
* @exception {DeveloperError} right is required.
|
|
512
|
+
* @exception {DeveloperError} bottom is required.
|
|
513
|
+
* @exception {DeveloperError} top is required.
|
|
514
|
+
* @exception {DeveloperError} near is required.
|
|
515
|
+
* @exception {DeveloperError} far is required.
|
|
516
|
+
*/
|
|
517
|
+
Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
|
|
518
|
+
if (typeof left === 'undefined') {
|
|
519
|
+
throw new DeveloperError('left is required.');
|
|
520
|
+
}
|
|
521
|
+
if (typeof right === 'undefined') {
|
|
522
|
+
throw new DeveloperError('right is required.');
|
|
523
|
+
}
|
|
524
|
+
if (typeof bottom === 'undefined') {
|
|
525
|
+
throw new DeveloperError('bottom is required.');
|
|
526
|
+
}
|
|
527
|
+
if (typeof top === 'undefined') {
|
|
528
|
+
throw new DeveloperError('top is required.');
|
|
529
|
+
}
|
|
530
|
+
if (typeof near === 'undefined') {
|
|
531
|
+
throw new DeveloperError('near is required.');
|
|
532
|
+
}
|
|
533
|
+
if (typeof far === 'undefined') {
|
|
534
|
+
throw new DeveloperError('far is required.');
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
var a = 1.0 / (right - left);
|
|
538
|
+
var b = 1.0 / (top - bottom);
|
|
539
|
+
var c = 1.0 / (far - near);
|
|
540
|
+
|
|
541
|
+
var tx = -(right + left) * a;
|
|
542
|
+
var ty = -(top + bottom) * b;
|
|
543
|
+
var tz = -(far + near) * c;
|
|
544
|
+
a *= 2.0;
|
|
545
|
+
b *= 2.0;
|
|
546
|
+
c *= -2.0;
|
|
547
|
+
|
|
548
|
+
if (typeof result === 'undefined') {
|
|
549
|
+
return new Matrix4( a, 0.0, 0.0, tx,
|
|
550
|
+
0.0, b, 0.0, ty,
|
|
551
|
+
0.0, 0.0, c, tz,
|
|
552
|
+
0.0, 0.0, 0.0, 1.0);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
result[0] = a;
|
|
556
|
+
result[1] = 0.0;
|
|
557
|
+
result[2] = 0.0;
|
|
558
|
+
result[3] = 0.0;
|
|
559
|
+
result[4] = 0.0;
|
|
560
|
+
result[5] = b;
|
|
561
|
+
result[6] = 0.0;
|
|
562
|
+
result[7] = 0.0;
|
|
563
|
+
result[8] = 0.0;
|
|
564
|
+
result[9] = 0.0;
|
|
565
|
+
result[10] = c;
|
|
566
|
+
result[11] = 0.0;
|
|
567
|
+
result[12] = tx;
|
|
568
|
+
result[13] = ty;
|
|
569
|
+
result[14] = tz;
|
|
570
|
+
result[15] = 1.0;
|
|
571
|
+
return result;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Computes a Matrix4 instance representing an off center perspective transformation.
|
|
576
|
+
* @memberof Matrix4
|
|
577
|
+
*
|
|
578
|
+
* @param {Number} left The number of meters to the left of the camera that will be in view.
|
|
579
|
+
* @param {Number} right The number of meters to the right of the camera that will be in view.
|
|
580
|
+
* @param {Number} bottom The number of meters below of the camera that will be in view.
|
|
581
|
+
* @param {Number} top The number of meters above of the camera that will be in view.
|
|
582
|
+
* @param {Number} near The distance to the near plane in meters.
|
|
583
|
+
* @param {Number} far The distance to the far plane in meters.
|
|
584
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
585
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
586
|
+
*
|
|
587
|
+
* @exception {DeveloperError} left is required.
|
|
588
|
+
* @exception {DeveloperError} right is required.
|
|
589
|
+
* @exception {DeveloperError} bottom is required.
|
|
590
|
+
* @exception {DeveloperError} top is required.
|
|
591
|
+
* @exception {DeveloperError} near is required.
|
|
592
|
+
* @exception {DeveloperError} far is required.
|
|
593
|
+
*/
|
|
594
|
+
Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
|
|
595
|
+
if (typeof left === 'undefined') {
|
|
596
|
+
throw new DeveloperError('left is required.');
|
|
597
|
+
}
|
|
598
|
+
if (typeof right === 'undefined') {
|
|
599
|
+
throw new DeveloperError('right is required.');
|
|
600
|
+
}
|
|
601
|
+
if (typeof bottom === 'undefined') {
|
|
602
|
+
throw new DeveloperError('bottom is required.');
|
|
603
|
+
}
|
|
604
|
+
if (typeof top === 'undefined') {
|
|
605
|
+
throw new DeveloperError('top is required.');
|
|
606
|
+
}
|
|
607
|
+
if (typeof near === 'undefined') {
|
|
608
|
+
throw new DeveloperError('near is required.');
|
|
609
|
+
}
|
|
610
|
+
if (typeof far === 'undefined') {
|
|
611
|
+
throw new DeveloperError('far is required.');
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
var column0Row0 = 2.0 * near / (right - left);
|
|
615
|
+
var column1Row1 = 2.0 * near / (top - bottom);
|
|
616
|
+
var column2Row0 = (right + left) / (right - left);
|
|
617
|
+
var column2Row1 = (top + bottom) / (top - bottom);
|
|
618
|
+
var column2Row2 = -(far + near) / (far - near);
|
|
619
|
+
var column2Row3 = -1.0;
|
|
620
|
+
var column3Row2 = -2.0 * far * near / (far - near);
|
|
621
|
+
|
|
622
|
+
if (typeof result === 'undefined') {
|
|
623
|
+
return new Matrix4(column0Row0, 0.0, column2Row0, 0.0,
|
|
624
|
+
0.0, column1Row1, column2Row1, 0.0,
|
|
625
|
+
0.0, 0.0, column2Row2, column3Row2,
|
|
626
|
+
0.0, 0.0, column2Row3, 0.0);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
result[0] = column0Row0;
|
|
630
|
+
result[1] = 0.0;
|
|
631
|
+
result[2] = 0.0;
|
|
632
|
+
result[3] = 0.0;
|
|
633
|
+
result[4] = 0.0;
|
|
634
|
+
result[5] = column1Row1;
|
|
635
|
+
result[6] = 0.0;
|
|
636
|
+
result[7] = 0.0;
|
|
637
|
+
result[8] = column2Row0;
|
|
638
|
+
result[9] = column2Row1;
|
|
639
|
+
result[10] = column2Row2;
|
|
640
|
+
result[11] = column2Row3;
|
|
641
|
+
result[12] = 0.0;
|
|
642
|
+
result[13] = 0.0;
|
|
643
|
+
result[14] = column3Row2;
|
|
644
|
+
result[15] = 0.0;
|
|
645
|
+
return result;
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Computes a Matrix4 instance representing an infinite off center perspective transformation.
|
|
650
|
+
* @memberof Matrix4
|
|
651
|
+
*
|
|
652
|
+
* @param {Number} left The number of meters to the left of the camera that will be in view.
|
|
653
|
+
* @param {Number} right The number of meters to the right of the camera that will be in view.
|
|
654
|
+
* @param {Number} bottom The number of meters below of the camera that will be in view.
|
|
655
|
+
* @param {Number} top The number of meters above of the camera that will be in view.
|
|
656
|
+
* @param {Number} near The distance to the near plane in meters.
|
|
657
|
+
* @param {Number} far The distance to the far plane in meters.
|
|
658
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
659
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
660
|
+
*
|
|
661
|
+
* @exception {DeveloperError} left is required.
|
|
662
|
+
* @exception {DeveloperError} right is required.
|
|
663
|
+
* @exception {DeveloperError} bottom is required.
|
|
664
|
+
* @exception {DeveloperError} top is required.
|
|
665
|
+
* @exception {DeveloperError} near is required.
|
|
666
|
+
*/
|
|
667
|
+
Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
|
|
668
|
+
if (typeof left === 'undefined') {
|
|
669
|
+
throw new DeveloperError('left is required.');
|
|
670
|
+
}
|
|
671
|
+
if (typeof right === 'undefined') {
|
|
672
|
+
throw new DeveloperError('right is required.');
|
|
673
|
+
}
|
|
674
|
+
if (typeof bottom === 'undefined') {
|
|
675
|
+
throw new DeveloperError('bottom is required.');
|
|
676
|
+
}
|
|
677
|
+
if (typeof top === 'undefined') {
|
|
678
|
+
throw new DeveloperError('top is required.');
|
|
679
|
+
}
|
|
680
|
+
if (typeof near === 'undefined') {
|
|
681
|
+
throw new DeveloperError('near is required.');
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
var column0Row0 = 2.0 * near / (right - left);
|
|
685
|
+
var column1Row1 = 2.0 * near / (top - bottom);
|
|
686
|
+
var column2Row0 = (right + left) / (right - left);
|
|
687
|
+
var column2Row1 = (top + bottom) / (top - bottom);
|
|
688
|
+
var column2Row2 = -1.0;
|
|
689
|
+
var column2Row3 = -1.0;
|
|
690
|
+
var column3Row2 = -2.0 * near;
|
|
691
|
+
|
|
692
|
+
if (typeof result === 'undefined') {
|
|
693
|
+
return new Matrix4(column0Row0, 0.0, column2Row0, 0.0,
|
|
694
|
+
0.0, column1Row1, column2Row1, 0.0,
|
|
695
|
+
0.0, 0.0, column2Row2, column3Row2,
|
|
696
|
+
0.0, 0.0, column2Row3, 0.0);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
result[0] = column0Row0;
|
|
700
|
+
result[1] = 0.0;
|
|
701
|
+
result[2] = 0.0;
|
|
702
|
+
result[3] = 0.0;
|
|
703
|
+
result[4] = 0.0;
|
|
704
|
+
result[5] = column1Row1;
|
|
705
|
+
result[6] = 0.0;
|
|
706
|
+
result[7] = 0.0;
|
|
707
|
+
result[8] = column2Row0;
|
|
708
|
+
result[9] = column2Row1;
|
|
709
|
+
result[10] = column2Row2;
|
|
710
|
+
result[11] = column2Row3;
|
|
711
|
+
result[12] = 0.0;
|
|
712
|
+
result[13] = 0.0;
|
|
713
|
+
result[14] = column3Row2;
|
|
714
|
+
result[15] = 0.0;
|
|
715
|
+
return result;
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
var EMPTY_OBJECT = {};
|
|
719
|
+
/**
|
|
720
|
+
* Computes a Matrix4 instance that transforms from normalized device coordinates to window coordinates.
|
|
721
|
+
* @memberof Matrix4
|
|
722
|
+
*
|
|
723
|
+
* @param {Object}[viewport = { x : 0.0, y : 0.0, width : 0.0, height : 0.0 }] The viewport's corners as shown in Example 1.
|
|
724
|
+
* @param {Number}[nearDepthRange = 0.0] The near plane distance in window coordinates.
|
|
725
|
+
* @param {Number}[farDepthRange = 1.0] The far plane distance in window coordinates.
|
|
726
|
+
* @param {Matrix4} [result] The object in which the result will be stored, if undefined a new instance will be created.
|
|
727
|
+
* @returns The modified result parameter, or a new Matrix4 instance if one was not provided.
|
|
728
|
+
*
|
|
729
|
+
* @see czm_viewportTransformation
|
|
730
|
+
* @see Context#getViewport
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* // Example 1. Create viewport transformation using an explicit viewport and depth range.
|
|
734
|
+
* var m = Matrix4.computeViewportTransformation({
|
|
735
|
+
* x : 0.0,
|
|
736
|
+
* y : 0.0,
|
|
737
|
+
* width : 1024.0,
|
|
738
|
+
* height : 768.0
|
|
739
|
+
* }, 0.0, 1.0);
|
|
740
|
+
*
|
|
741
|
+
* // Example 2. Create viewport transformation using the context's viewport.
|
|
742
|
+
* var m = Matrix4.computeViewportTransformation(context.getViewport());
|
|
743
|
+
*/
|
|
744
|
+
Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
|
|
745
|
+
viewport = defaultValue(viewport, EMPTY_OBJECT);
|
|
746
|
+
var x = defaultValue(viewport.x, 0.0);
|
|
747
|
+
var y = defaultValue(viewport.y, 0.0);
|
|
748
|
+
var width = defaultValue(viewport.width, 0.0);
|
|
749
|
+
var height = defaultValue(viewport.height, 0.0);
|
|
750
|
+
nearDepthRange = defaultValue(nearDepthRange, 0.0);
|
|
751
|
+
farDepthRange = defaultValue(farDepthRange, 1.0);
|
|
752
|
+
|
|
753
|
+
var halfWidth = width * 0.5;
|
|
754
|
+
var halfHeight = height * 0.5;
|
|
755
|
+
var halfDepth = (farDepthRange - nearDepthRange) * 0.5;
|
|
756
|
+
|
|
757
|
+
var column0Row0 = halfWidth;
|
|
758
|
+
var column1Row1 = halfHeight;
|
|
759
|
+
var column2Row2 = halfDepth;
|
|
760
|
+
var column3Row0 = x + halfWidth;
|
|
761
|
+
var column3Row1 = y + halfHeight;
|
|
762
|
+
var column3Row2 = nearDepthRange + halfDepth;
|
|
763
|
+
var column3Row3 = 1.0;
|
|
764
|
+
|
|
765
|
+
if (typeof result === 'undefined') {
|
|
766
|
+
return new Matrix4(column0Row0, 0.0, 0.0, column3Row0,
|
|
767
|
+
0.0, column1Row1, 0.0, column3Row1,
|
|
768
|
+
0.0, 0.0, column2Row2, column3Row2,
|
|
769
|
+
0.0, 0.0, 0.0, column3Row3);
|
|
770
|
+
}
|
|
771
|
+
result[0] = column0Row0;
|
|
772
|
+
result[1] = 0.0;
|
|
773
|
+
result[2] = 0.0;
|
|
774
|
+
result[3] = 0.0;
|
|
775
|
+
result[4] = 0.0;
|
|
776
|
+
result[5] = column1Row1;
|
|
777
|
+
result[6] = 0.0;
|
|
778
|
+
result[7] = 0.0;
|
|
779
|
+
result[8] = 0.0;
|
|
780
|
+
result[9] = 0.0;
|
|
781
|
+
result[10] = column2Row2;
|
|
782
|
+
result[11] = 0.0;
|
|
783
|
+
result[12] = column3Row0;
|
|
784
|
+
result[13] = column3Row1;
|
|
785
|
+
result[14] = column3Row2;
|
|
786
|
+
result[15] = column3Row3;
|
|
787
|
+
return result;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Computes an Array from the provided Matrix4 instance.
|
|
792
|
+
* The array will be in column-major order.
|
|
793
|
+
* @memberof Matrix4
|
|
794
|
+
*
|
|
795
|
+
* @param {Matrix4} matrix The matrix to use..
|
|
796
|
+
* @param {Array} [result] The Array onto which to store the result.
|
|
797
|
+
* @return {Array} The modified Array parameter or a new Array instance if one was not provided.
|
|
798
|
+
*
|
|
799
|
+
* @exception {DeveloperError} matrix is required.
|
|
800
|
+
*/
|
|
801
|
+
Matrix4.toArray = function(matrix, result) {
|
|
802
|
+
if (typeof matrix === 'undefined') {
|
|
803
|
+
throw new DeveloperError('matrix is required');
|
|
804
|
+
}
|
|
805
|
+
if (typeof result === 'undefined') {
|
|
806
|
+
return [matrix[0], matrix[1], matrix[2], matrix[3],
|
|
807
|
+
matrix[4], matrix[5], matrix[6], matrix[7],
|
|
808
|
+
matrix[8], matrix[9], matrix[10], matrix[11],
|
|
809
|
+
matrix[12], matrix[13], matrix[14], matrix[15]];
|
|
810
|
+
}
|
|
811
|
+
result[0] = matrix[0];
|
|
812
|
+
result[1] = matrix[1];
|
|
813
|
+
result[2] = matrix[2];
|
|
814
|
+
result[3] = matrix[3];
|
|
815
|
+
result[4] = matrix[4];
|
|
816
|
+
result[5] = matrix[5];
|
|
817
|
+
result[6] = matrix[6];
|
|
818
|
+
result[7] = matrix[7];
|
|
819
|
+
result[8] = matrix[8];
|
|
820
|
+
result[9] = matrix[9];
|
|
821
|
+
result[10] = matrix[10];
|
|
822
|
+
result[11] = matrix[11];
|
|
823
|
+
result[12] = matrix[12];
|
|
824
|
+
result[13] = matrix[13];
|
|
825
|
+
result[14] = matrix[14];
|
|
826
|
+
result[15] = matrix[15];
|
|
827
|
+
return result;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Computes the array index of the element at the provided row and column.
|
|
832
|
+
* @memberof Matrix4
|
|
833
|
+
*
|
|
834
|
+
* @param {Number} row The zero-based index of the row.
|
|
835
|
+
* @param {Number} column The zero-based index of the column.
|
|
836
|
+
* @return {Number} The index of the element at the provided row and column.
|
|
837
|
+
*
|
|
838
|
+
* @exception {DeveloperError} row is required and must be 0, 1, 2, or 3.
|
|
839
|
+
* @exception {DeveloperError} column is required and must be 0, 1, 2, or 3.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* var myMatrix = new Matrix4();
|
|
843
|
+
* var column1Row0Index = Matrix4.getElementIndex(1, 0);
|
|
844
|
+
* var column1Row0 = myMatrix[column1Row0Index]
|
|
845
|
+
* myMatrix[column1Row0Index] = 10.0;
|
|
846
|
+
*/
|
|
847
|
+
Matrix4.getElementIndex = function(column, row) {
|
|
848
|
+
if (typeof row !== 'number' || row < 0 || row > 3) {
|
|
849
|
+
throw new DeveloperError('row is required and must be 0, 1, 2, or 3.');
|
|
850
|
+
}
|
|
851
|
+
if (typeof column !== 'number' || column < 0 || column > 3) {
|
|
852
|
+
throw new DeveloperError('column is required and must be 0, 1, 2, or 3.');
|
|
853
|
+
}
|
|
854
|
+
return column * 4 + row;
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Retrieves a copy of the matrix column at the provided index as a Cartesian4 instance.
|
|
859
|
+
* @memberof Matrix4
|
|
860
|
+
*
|
|
861
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
862
|
+
* @param {Number} index The zero-based index of the column to retrieve.
|
|
863
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
864
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
865
|
+
*
|
|
866
|
+
* @exception {DeveloperError} matrix is required.
|
|
867
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
868
|
+
*
|
|
869
|
+
* @see Cartesian4
|
|
870
|
+
*/
|
|
871
|
+
Matrix4.getColumn = function(matrix, index, result) {
|
|
872
|
+
if (typeof matrix === 'undefined') {
|
|
873
|
+
throw new DeveloperError('matrix is required.');
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (typeof index !== 'number' || index < 0 || index > 3) {
|
|
877
|
+
throw new DeveloperError('index is required and must be 0, 1, 2, or 3.');
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
var startIndex = index * 4;
|
|
881
|
+
var x = matrix[startIndex];
|
|
882
|
+
var y = matrix[startIndex + 1];
|
|
883
|
+
var z = matrix[startIndex + 2];
|
|
884
|
+
var w = matrix[startIndex + 3];
|
|
885
|
+
|
|
886
|
+
if (typeof result === 'undefined') {
|
|
887
|
+
return new Cartesian4(x, y, z, w);
|
|
888
|
+
}
|
|
889
|
+
result.x = x;
|
|
890
|
+
result.y = y;
|
|
891
|
+
result.z = z;
|
|
892
|
+
result.w = w;
|
|
893
|
+
return result;
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian4 instance.
|
|
898
|
+
* @memberof Matrix4
|
|
899
|
+
*
|
|
900
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
901
|
+
* @param {Number} index The zero-based index of the column to set.
|
|
902
|
+
* @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified column.
|
|
903
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
904
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
905
|
+
*
|
|
906
|
+
* @exception {DeveloperError} matrix is required.
|
|
907
|
+
* @exception {DeveloperError} cartesian is required.
|
|
908
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
909
|
+
*
|
|
910
|
+
* @see Cartesian4
|
|
911
|
+
*/
|
|
912
|
+
Matrix4.setColumn = function(matrix, index, cartesian, result) {
|
|
913
|
+
if (typeof matrix === 'undefined') {
|
|
914
|
+
throw new DeveloperError('matrix is required');
|
|
915
|
+
}
|
|
916
|
+
if (typeof cartesian === 'undefined') {
|
|
917
|
+
throw new DeveloperError('cartesian is required');
|
|
918
|
+
}
|
|
919
|
+
if (typeof index !== 'number' || index < 0 || index > 3) {
|
|
920
|
+
throw new DeveloperError('index is required and must be 0, 1, 2, or 3.');
|
|
921
|
+
}
|
|
922
|
+
result = Matrix4.clone(matrix, result);
|
|
923
|
+
var startIndex = index * 4;
|
|
924
|
+
result[startIndex] = cartesian.x;
|
|
925
|
+
result[startIndex + 1] = cartesian.y;
|
|
926
|
+
result[startIndex + 2] = cartesian.z;
|
|
927
|
+
result[startIndex + 3] = cartesian.w;
|
|
928
|
+
return result;
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Retrieves a copy of the matrix row at the provided index as a Cartesian4 instance.
|
|
933
|
+
* @memberof Matrix4
|
|
934
|
+
*
|
|
935
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
936
|
+
* @param {Number} index The zero-based index of the row to retrieve.
|
|
937
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
938
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
939
|
+
*
|
|
940
|
+
* @exception {DeveloperError} matrix is required.
|
|
941
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
942
|
+
*
|
|
943
|
+
* @see Cartesian4
|
|
944
|
+
*/
|
|
945
|
+
Matrix4.getRow = function(matrix, index, result) {
|
|
946
|
+
if (typeof matrix === 'undefined') {
|
|
947
|
+
throw new DeveloperError('matrix is required.');
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
if (typeof index !== 'number' || index < 0 || index > 3) {
|
|
951
|
+
throw new DeveloperError('index is required and must be 0, 1, 2, or 3.');
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
var x = matrix[index];
|
|
955
|
+
var y = matrix[index + 4];
|
|
956
|
+
var z = matrix[index + 8];
|
|
957
|
+
var w = matrix[index + 12];
|
|
958
|
+
|
|
959
|
+
if (typeof result === 'undefined') {
|
|
960
|
+
return new Cartesian4(x, y, z, w);
|
|
961
|
+
}
|
|
962
|
+
result.x = x;
|
|
963
|
+
result.y = y;
|
|
964
|
+
result.z = z;
|
|
965
|
+
result.w = w;
|
|
966
|
+
return result;
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian4 instance.
|
|
971
|
+
* @memberof Matrix4
|
|
972
|
+
*
|
|
973
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
974
|
+
* @param {Number} index The zero-based index of the row to set.
|
|
975
|
+
* @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified row.
|
|
976
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
977
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
978
|
+
*
|
|
979
|
+
* @exception {DeveloperError} matrix is required.
|
|
980
|
+
* @exception {DeveloperError} cartesian is required.
|
|
981
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
982
|
+
*
|
|
983
|
+
* @see Cartesian4
|
|
984
|
+
*/
|
|
985
|
+
Matrix4.setRow = function(matrix, index, cartesian, result) {
|
|
986
|
+
if (typeof matrix === 'undefined') {
|
|
987
|
+
throw new DeveloperError('matrix is required');
|
|
988
|
+
}
|
|
989
|
+
if (typeof cartesian === 'undefined') {
|
|
990
|
+
throw new DeveloperError('cartesian is required');
|
|
991
|
+
}
|
|
992
|
+
if (typeof index !== 'number' || index < 0 || index > 3) {
|
|
993
|
+
throw new DeveloperError('index is required and must be 0, 1, 2, or 3.');
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
result = Matrix4.clone(matrix, result);
|
|
997
|
+
result[index] = cartesian.x;
|
|
998
|
+
result[index + 4] = cartesian.y;
|
|
999
|
+
result[index + 8] = cartesian.z;
|
|
1000
|
+
result[index + 12] = cartesian.w;
|
|
1001
|
+
return result;
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Computes the product of two matrices.
|
|
1006
|
+
* @memberof Matrix4
|
|
1007
|
+
*
|
|
1008
|
+
* @param {Matrix4} left The first matrix.
|
|
1009
|
+
* @param {Matrix4} right The second matrix.
|
|
1010
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1011
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1012
|
+
*
|
|
1013
|
+
* @exception {DeveloperError} left is required.
|
|
1014
|
+
* @exception {DeveloperError} right is required.
|
|
1015
|
+
*/
|
|
1016
|
+
Matrix4.multiply = function(left, right, result) {
|
|
1017
|
+
if (typeof left === 'undefined') {
|
|
1018
|
+
throw new DeveloperError('left is required');
|
|
1019
|
+
}
|
|
1020
|
+
if (typeof right === 'undefined') {
|
|
1021
|
+
throw new DeveloperError('right is required');
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
var left0 = left[0];
|
|
1025
|
+
var left1 = left[1];
|
|
1026
|
+
var left2 = left[2];
|
|
1027
|
+
var left3 = left[3];
|
|
1028
|
+
var left4 = left[4];
|
|
1029
|
+
var left5 = left[5];
|
|
1030
|
+
var left6 = left[6];
|
|
1031
|
+
var left7 = left[7];
|
|
1032
|
+
var left8 = left[8];
|
|
1033
|
+
var left9 = left[9];
|
|
1034
|
+
var left10 = left[10];
|
|
1035
|
+
var left11 = left[11];
|
|
1036
|
+
var left12 = left[12];
|
|
1037
|
+
var left13 = left[13];
|
|
1038
|
+
var left14 = left[14];
|
|
1039
|
+
var left15 = left[15];
|
|
1040
|
+
|
|
1041
|
+
var right0 = right[0];
|
|
1042
|
+
var right1 = right[1];
|
|
1043
|
+
var right2 = right[2];
|
|
1044
|
+
var right3 = right[3];
|
|
1045
|
+
var right4 = right[4];
|
|
1046
|
+
var right5 = right[5];
|
|
1047
|
+
var right6 = right[6];
|
|
1048
|
+
var right7 = right[7];
|
|
1049
|
+
var right8 = right[8];
|
|
1050
|
+
var right9 = right[9];
|
|
1051
|
+
var right10 = right[10];
|
|
1052
|
+
var right11 = right[11];
|
|
1053
|
+
var right12 = right[12];
|
|
1054
|
+
var right13 = right[13];
|
|
1055
|
+
var right14 = right[14];
|
|
1056
|
+
var right15 = right[15];
|
|
1057
|
+
|
|
1058
|
+
var column0Row0 = left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;
|
|
1059
|
+
var column0Row1 = left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;
|
|
1060
|
+
var column0Row2 = left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;
|
|
1061
|
+
var column0Row3 = left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;
|
|
1062
|
+
|
|
1063
|
+
var column1Row0 = left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;
|
|
1064
|
+
var column1Row1 = left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;
|
|
1065
|
+
var column1Row2 = left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;
|
|
1066
|
+
var column1Row3 = left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;
|
|
1067
|
+
|
|
1068
|
+
var column2Row0 = left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;
|
|
1069
|
+
var column2Row1 = left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;
|
|
1070
|
+
var column2Row2 = left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;
|
|
1071
|
+
var column2Row3 = left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;
|
|
1072
|
+
|
|
1073
|
+
var column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;
|
|
1074
|
+
var column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;
|
|
1075
|
+
var column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;
|
|
1076
|
+
var column3Row3 = left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;
|
|
1077
|
+
|
|
1078
|
+
if (typeof result === 'undefined') {
|
|
1079
|
+
return new Matrix4(column0Row0, column1Row0, column2Row0, column3Row0,
|
|
1080
|
+
column0Row1, column1Row1, column2Row1, column3Row1,
|
|
1081
|
+
column0Row2, column1Row2, column2Row2, column3Row2,
|
|
1082
|
+
column0Row3, column1Row3, column2Row3, column3Row3);
|
|
1083
|
+
}
|
|
1084
|
+
result[0] = column0Row0;
|
|
1085
|
+
result[1] = column0Row1;
|
|
1086
|
+
result[2] = column0Row2;
|
|
1087
|
+
result[3] = column0Row3;
|
|
1088
|
+
result[4] = column1Row0;
|
|
1089
|
+
result[5] = column1Row1;
|
|
1090
|
+
result[6] = column1Row2;
|
|
1091
|
+
result[7] = column1Row3;
|
|
1092
|
+
result[8] = column2Row0;
|
|
1093
|
+
result[9] = column2Row1;
|
|
1094
|
+
result[10] = column2Row2;
|
|
1095
|
+
result[11] = column2Row3;
|
|
1096
|
+
result[12] = column3Row0;
|
|
1097
|
+
result[13] = column3Row1;
|
|
1098
|
+
result[14] = column3Row2;
|
|
1099
|
+
result[15] = column3Row3;
|
|
1100
|
+
return result;
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* Multiplies a transformation matrix (with a bottom row of <code>[0.0, 0.0, 0.0, 1.0]</code>)
|
|
1105
|
+
* by an implicit translation matrix defined by a {@link Cartesian3}. This is an optimization
|
|
1106
|
+
* for <code>Matrix4.multiply(m, Matrix4.fromTranslation(position), m);</code> with less allocations and arithmetic operations.
|
|
1107
|
+
*
|
|
1108
|
+
* @memberof Matrix4
|
|
1109
|
+
*
|
|
1110
|
+
* @param {Matrix4} matrix The matrix on the left-hand side.
|
|
1111
|
+
* @param {Cartesian3} translation The translation on the right-hand side.
|
|
1112
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1113
|
+
*
|
|
1114
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1115
|
+
*
|
|
1116
|
+
* @exception {DeveloperError} matrix is required.
|
|
1117
|
+
* @exception {DeveloperError} translation is required.
|
|
1118
|
+
*
|
|
1119
|
+
* @see Matrix4#fromTranslation
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* // Instead of Matrix4.multiply(m, Matrix4.fromTranslation(position), m);
|
|
1123
|
+
* Matrix4.multiplyByTranslation(m, position, m);
|
|
1124
|
+
*/
|
|
1125
|
+
Matrix4.multiplyByTranslation = function(matrix, translation, result) {
|
|
1126
|
+
if (typeof matrix === 'undefined') {
|
|
1127
|
+
throw new DeveloperError('matrix is required');
|
|
1128
|
+
}
|
|
1129
|
+
if (typeof translation === 'undefined') {
|
|
1130
|
+
throw new DeveloperError('translation is required');
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
var x = translation.x;
|
|
1134
|
+
var y = translation.y;
|
|
1135
|
+
var z = translation.z;
|
|
1136
|
+
|
|
1137
|
+
var tx = (x * matrix[0]) + (y * matrix[4]) + (z * matrix[8]) + matrix[12];
|
|
1138
|
+
var ty = (x * matrix[1]) + (y * matrix[5]) + (z * matrix[9]) + matrix[13];
|
|
1139
|
+
var tz = (x * matrix[2]) + (y * matrix[6]) + (z * matrix[10]) + matrix[14];
|
|
1140
|
+
|
|
1141
|
+
if (typeof result === 'undefined') {
|
|
1142
|
+
return new Matrix4(matrix[0], matrix[4], matrix[8], tx,
|
|
1143
|
+
matrix[1], matrix[5], matrix[9], ty,
|
|
1144
|
+
matrix[2], matrix[6], matrix[10], tz,
|
|
1145
|
+
matrix[3], matrix[7], matrix[11], matrix[15]);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
result[0] = matrix[0];
|
|
1149
|
+
result[1] = matrix[1];
|
|
1150
|
+
result[2] = matrix[2];
|
|
1151
|
+
result[3] = matrix[3];
|
|
1152
|
+
result[4] = matrix[4];
|
|
1153
|
+
result[5] = matrix[5];
|
|
1154
|
+
result[6] = matrix[6];
|
|
1155
|
+
result[7] = matrix[7];
|
|
1156
|
+
result[8] = matrix[8];
|
|
1157
|
+
result[9] = matrix[9];
|
|
1158
|
+
result[10] = matrix[10];
|
|
1159
|
+
result[11] = matrix[11];
|
|
1160
|
+
result[12] = tx;
|
|
1161
|
+
result[13] = ty;
|
|
1162
|
+
result[14] = tz;
|
|
1163
|
+
result[15] = matrix[15];
|
|
1164
|
+
return result;
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Multiplies a transformation matrix (with a bottom row of <code>[0.0, 0.0, 0.0, 1.0]</code>)
|
|
1169
|
+
* by an implicit uniform scale matrix. This is an optimization
|
|
1170
|
+
* for <code>Matrix4.multiply(m, Matrix4.fromScale(scale), m);</code> with less allocations and arithmetic operations.
|
|
1171
|
+
*
|
|
1172
|
+
* @memberof Matrix4
|
|
1173
|
+
*
|
|
1174
|
+
* @param {Matrix4} matrix The matrix on the left-hand side.
|
|
1175
|
+
* @param {Number} scale The uniform scale on the right-hand side.
|
|
1176
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1177
|
+
*
|
|
1178
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1179
|
+
*
|
|
1180
|
+
* @exception {DeveloperError} matrix is required.
|
|
1181
|
+
* @exception {DeveloperError} scale is required.
|
|
1182
|
+
*
|
|
1183
|
+
* @see Matrix4#fromUniformScale
|
|
1184
|
+
*
|
|
1185
|
+
* @example
|
|
1186
|
+
* // Instead of Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m);
|
|
1187
|
+
* Matrix4.multiplyByUniformScale(m, scale, m);
|
|
1188
|
+
*/
|
|
1189
|
+
Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
|
|
1190
|
+
if (typeof matrix === 'undefined') {
|
|
1191
|
+
throw new DeveloperError('matrix is required');
|
|
1192
|
+
}
|
|
1193
|
+
if (typeof scale !== 'number') {
|
|
1194
|
+
throw new DeveloperError('scale is required');
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
if (scale === 1.0) {
|
|
1198
|
+
return Matrix4.clone(matrix, result);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if (typeof result === 'undefined') {
|
|
1202
|
+
return new Matrix4(
|
|
1203
|
+
scale * matrix[0], scale * matrix[4], scale * matrix[8], matrix[12],
|
|
1204
|
+
scale * matrix[1], scale * matrix[5], scale * matrix[9], matrix[13],
|
|
1205
|
+
scale * matrix[2], scale * matrix[6], scale * matrix[10], matrix[14],
|
|
1206
|
+
0.0, 0.0, 0.0, 1.0);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
result[0] = scale * matrix[0];
|
|
1210
|
+
result[1] = scale * matrix[1];
|
|
1211
|
+
result[2] = scale * matrix[2];
|
|
1212
|
+
result[3] = 0.0;
|
|
1213
|
+
result[4] = scale * matrix[4];
|
|
1214
|
+
result[5] = scale * matrix[5];
|
|
1215
|
+
result[6] = scale * matrix[6];
|
|
1216
|
+
result[7] = 0.0;
|
|
1217
|
+
result[8] = scale * matrix[8];
|
|
1218
|
+
result[9] = scale * matrix[9];
|
|
1219
|
+
result[10] = scale * matrix[10];
|
|
1220
|
+
result[11] = 0.0;
|
|
1221
|
+
result[12] = matrix[12];
|
|
1222
|
+
result[13] = matrix[13];
|
|
1223
|
+
result[14] = matrix[14];
|
|
1224
|
+
result[15] = 1.0;
|
|
1225
|
+
return result;
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Computes the product of a matrix and a column vector.
|
|
1230
|
+
* @memberof Matrix4
|
|
1231
|
+
*
|
|
1232
|
+
* @param {Matrix4} matrix The matrix.
|
|
1233
|
+
* @param {Cartesian4} cartesian The vector.
|
|
1234
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
1235
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
1236
|
+
*
|
|
1237
|
+
* @exception {DeveloperError} matrix is required.
|
|
1238
|
+
* @exception {DeveloperError} cartesian is required.
|
|
1239
|
+
*/
|
|
1240
|
+
Matrix4.multiplyByVector = function(matrix, cartesian, result) {
|
|
1241
|
+
if (typeof matrix === 'undefined') {
|
|
1242
|
+
throw new DeveloperError('matrix is required');
|
|
1243
|
+
}
|
|
1244
|
+
if (typeof cartesian === 'undefined') {
|
|
1245
|
+
throw new DeveloperError('cartesian is required');
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
var vX = cartesian.x;
|
|
1249
|
+
var vY = cartesian.y;
|
|
1250
|
+
var vZ = cartesian.z;
|
|
1251
|
+
var vW = cartesian.w;
|
|
1252
|
+
|
|
1253
|
+
var x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;
|
|
1254
|
+
var y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;
|
|
1255
|
+
var z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;
|
|
1256
|
+
var w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;
|
|
1257
|
+
|
|
1258
|
+
if (typeof result === 'undefined') {
|
|
1259
|
+
return new Cartesian4(x, y, z, w);
|
|
1260
|
+
}
|
|
1261
|
+
result.x = x;
|
|
1262
|
+
result.y = y;
|
|
1263
|
+
result.z = z;
|
|
1264
|
+
result.w = w;
|
|
1265
|
+
return result;
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
var scratchPoint = new Cartesian4(0.0, 0.0, 0.0, 1.0);
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling {@link Matrix4.multiplyByVector}
|
|
1272
|
+
* with a {@link Cartesian4} with a <code>w</code> component of one.
|
|
1273
|
+
* @memberof Matrix4
|
|
1274
|
+
*
|
|
1275
|
+
* @param {Matrix4} matrix The matrix.
|
|
1276
|
+
* @param {Cartesian3} cartesian The point.
|
|
1277
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
1278
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
1279
|
+
*
|
|
1280
|
+
* @exception {DeveloperError} cartesian is required.
|
|
1281
|
+
* @exception {DeveloperError} matrix is required.
|
|
1282
|
+
*
|
|
1283
|
+
* @example
|
|
1284
|
+
* Cartesian3 p = new Cartesian3(1.0, 2.0, 3.0);
|
|
1285
|
+
* Matrix4.multiplyByPoint(matrix, p, result);
|
|
1286
|
+
* // A shortcut for
|
|
1287
|
+
* // Cartesian3 p = ...
|
|
1288
|
+
* // Matrix4.multiplyByVector(matrix, new Cartesian4(p.x, p.y, p.z, 1.0), result);
|
|
1289
|
+
*/
|
|
1290
|
+
Matrix4.multiplyByPoint = function(matrix, cartesian, result) {
|
|
1291
|
+
if (typeof cartesian === 'undefined') {
|
|
1292
|
+
throw new DeveloperError('cartesian is required');
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
scratchPoint.x = cartesian.x;
|
|
1296
|
+
scratchPoint.y = cartesian.y;
|
|
1297
|
+
scratchPoint.z = cartesian.z;
|
|
1298
|
+
// scratchPoint.w is one. See above.
|
|
1299
|
+
|
|
1300
|
+
return Matrix4.multiplyByVector(matrix, scratchPoint, result);
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* Computes the product of a matrix and a scalar.
|
|
1305
|
+
* @memberof Matrix4
|
|
1306
|
+
*
|
|
1307
|
+
* @param {Matrix4} matrix The matrix.
|
|
1308
|
+
* @param {Number} scalar The number to multiply by.
|
|
1309
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1310
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
1311
|
+
*
|
|
1312
|
+
* @exception {DeveloperError} matrix is required.
|
|
1313
|
+
* @exception {DeveloperError} scalar is required and must be a number.
|
|
1314
|
+
*/
|
|
1315
|
+
Matrix4.multiplyByScalar = function(matrix, scalar, result) {
|
|
1316
|
+
if (typeof matrix === 'undefined') {
|
|
1317
|
+
throw new DeveloperError('matrix is required');
|
|
1318
|
+
}
|
|
1319
|
+
if (typeof scalar !== 'number') {
|
|
1320
|
+
throw new DeveloperError('scalar is required and must be a number');
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
if (typeof result === 'undefined') {
|
|
1324
|
+
return new Matrix4(matrix[0] * scalar, matrix[4] * scalar, matrix[8] * scalar, matrix[12] * scalar,
|
|
1325
|
+
matrix[1] * scalar, matrix[5] * scalar, matrix[9] * scalar, matrix[13] * scalar,
|
|
1326
|
+
matrix[2] * scalar, matrix[6] * scalar, matrix[10] * scalar, matrix[14] * scalar,
|
|
1327
|
+
matrix[3] * scalar, matrix[7] * scalar, matrix[11] * scalar, matrix[15] * scalar);
|
|
1328
|
+
}
|
|
1329
|
+
result[0] = matrix[0] * scalar;
|
|
1330
|
+
result[1] = matrix[1] * scalar;
|
|
1331
|
+
result[2] = matrix[2] * scalar;
|
|
1332
|
+
result[3] = matrix[3] * scalar;
|
|
1333
|
+
result[4] = matrix[4] * scalar;
|
|
1334
|
+
result[5] = matrix[5] * scalar;
|
|
1335
|
+
result[6] = matrix[6] * scalar;
|
|
1336
|
+
result[7] = matrix[7] * scalar;
|
|
1337
|
+
result[8] = matrix[8] * scalar;
|
|
1338
|
+
result[9] = matrix[9] * scalar;
|
|
1339
|
+
result[10] = matrix[10] * scalar;
|
|
1340
|
+
result[11] = matrix[11] * scalar;
|
|
1341
|
+
result[12] = matrix[12] * scalar;
|
|
1342
|
+
result[13] = matrix[13] * scalar;
|
|
1343
|
+
result[14] = matrix[14] * scalar;
|
|
1344
|
+
result[15] = matrix[15] * scalar;
|
|
1345
|
+
return result;
|
|
1346
|
+
};
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Computes a negated copy of the provided matrix.
|
|
1350
|
+
* @memberof Matrix4
|
|
1351
|
+
*
|
|
1352
|
+
* @param {Matrix4} matrix The matrix to negate.
|
|
1353
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1354
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1355
|
+
*
|
|
1356
|
+
* @exception {DeveloperError} matrix is required.
|
|
1357
|
+
*/
|
|
1358
|
+
Matrix4.negate = function(matrix, result) {
|
|
1359
|
+
if (typeof matrix === 'undefined') {
|
|
1360
|
+
throw new DeveloperError('matrix is required');
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
if (typeof result === 'undefined') {
|
|
1364
|
+
return new Matrix4(-matrix[0], -matrix[4], -matrix[8], -matrix[12],
|
|
1365
|
+
-matrix[1], -matrix[5], -matrix[9], -matrix[13],
|
|
1366
|
+
-matrix[2], -matrix[6], -matrix[10], -matrix[14],
|
|
1367
|
+
-matrix[3], -matrix[7], -matrix[11], -matrix[15]);
|
|
1368
|
+
}
|
|
1369
|
+
result[0] = -matrix[0];
|
|
1370
|
+
result[1] = -matrix[1];
|
|
1371
|
+
result[2] = -matrix[2];
|
|
1372
|
+
result[3] = -matrix[3];
|
|
1373
|
+
result[4] = -matrix[4];
|
|
1374
|
+
result[5] = -matrix[5];
|
|
1375
|
+
result[6] = -matrix[6];
|
|
1376
|
+
result[7] = -matrix[7];
|
|
1377
|
+
result[8] = -matrix[8];
|
|
1378
|
+
result[9] = -matrix[9];
|
|
1379
|
+
result[10] = -matrix[10];
|
|
1380
|
+
result[11] = -matrix[11];
|
|
1381
|
+
result[12] = -matrix[12];
|
|
1382
|
+
result[13] = -matrix[13];
|
|
1383
|
+
result[14] = -matrix[14];
|
|
1384
|
+
result[15] = -matrix[15];
|
|
1385
|
+
return result;
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Computes the transpose of the provided matrix.
|
|
1390
|
+
* @memberof Matrix4
|
|
1391
|
+
*
|
|
1392
|
+
* @param {Matrix4} matrix The matrix to transpose.
|
|
1393
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1394
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1395
|
+
*
|
|
1396
|
+
* @exception {DeveloperError} matrix is required.
|
|
1397
|
+
*/
|
|
1398
|
+
Matrix4.transpose = function(matrix, result) {
|
|
1399
|
+
if (typeof matrix === 'undefined') {
|
|
1400
|
+
throw new DeveloperError('matrix is required');
|
|
1401
|
+
}
|
|
1402
|
+
if (typeof result === 'undefined') {
|
|
1403
|
+
return new Matrix4(matrix[0], matrix[1], matrix[2], matrix[3],
|
|
1404
|
+
matrix[4], matrix[5], matrix[6], matrix[7],
|
|
1405
|
+
matrix[8], matrix[9], matrix[10], matrix[11],
|
|
1406
|
+
matrix[12], matrix[13], matrix[14], matrix[15]);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
var matrix1 = matrix[1];
|
|
1410
|
+
var matrix2 = matrix[2];
|
|
1411
|
+
var matrix3 = matrix[3];
|
|
1412
|
+
var matrix6 = matrix[6];
|
|
1413
|
+
var matrix7 = matrix[7];
|
|
1414
|
+
var matrix11 = matrix[11];
|
|
1415
|
+
|
|
1416
|
+
result[0] = matrix[0];
|
|
1417
|
+
result[1] = matrix[4];
|
|
1418
|
+
result[2] = matrix[8];
|
|
1419
|
+
result[3] = matrix[12];
|
|
1420
|
+
result[4] = matrix1;
|
|
1421
|
+
result[5] = matrix[5];
|
|
1422
|
+
result[6] = matrix[9];
|
|
1423
|
+
result[7] = matrix[13];
|
|
1424
|
+
result[8] = matrix2;
|
|
1425
|
+
result[9] = matrix6;
|
|
1426
|
+
result[10] = matrix[10];
|
|
1427
|
+
result[11] = matrix[14];
|
|
1428
|
+
result[12] = matrix3;
|
|
1429
|
+
result[13] = matrix7;
|
|
1430
|
+
result[14] = matrix11;
|
|
1431
|
+
result[15] = matrix[15];
|
|
1432
|
+
return result;
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Compares the provided matrices componentwise and returns
|
|
1437
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1438
|
+
* @memberof Matrix4
|
|
1439
|
+
*
|
|
1440
|
+
* @param {Matrix4} [left] The first matrix.
|
|
1441
|
+
* @param {Matrix4} [right] The second matrix.
|
|
1442
|
+
* @return {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
1443
|
+
*/
|
|
1444
|
+
Matrix4.equals = function(left, right) {
|
|
1445
|
+
return (left === right) ||
|
|
1446
|
+
(typeof left !== 'undefined' &&
|
|
1447
|
+
typeof right !== 'undefined' &&
|
|
1448
|
+
left[0] === right[0] &&
|
|
1449
|
+
left[1] === right[1] &&
|
|
1450
|
+
left[2] === right[2] &&
|
|
1451
|
+
left[3] === right[3] &&
|
|
1452
|
+
left[4] === right[4] &&
|
|
1453
|
+
left[5] === right[5] &&
|
|
1454
|
+
left[6] === right[6] &&
|
|
1455
|
+
left[7] === right[7] &&
|
|
1456
|
+
left[8] === right[8] &&
|
|
1457
|
+
left[9] === right[9] &&
|
|
1458
|
+
left[10] === right[10] &&
|
|
1459
|
+
left[11] === right[11] &&
|
|
1460
|
+
left[12] === right[12] &&
|
|
1461
|
+
left[13] === right[13] &&
|
|
1462
|
+
left[14] === right[14] &&
|
|
1463
|
+
left[15] === right[15]);
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* Compares the provided matrices componentwise and returns
|
|
1468
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
1469
|
+
* <code>false</code> otherwise.
|
|
1470
|
+
* @memberof Matrix4
|
|
1471
|
+
*
|
|
1472
|
+
* @param {Matrix4} [left] The first matrix.
|
|
1473
|
+
* @param {Matrix4} [right] The second matrix.
|
|
1474
|
+
* @param {Number} epsilon The epsilon to use for equality testing.
|
|
1475
|
+
* @return {Boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
1476
|
+
*
|
|
1477
|
+
* @exception {DeveloperError} epsilon is required and must be a number.
|
|
1478
|
+
*/
|
|
1479
|
+
Matrix4.equalsEpsilon = function(left, right, epsilon) {
|
|
1480
|
+
if (typeof epsilon !== 'number') {
|
|
1481
|
+
throw new DeveloperError('epsilon is required and must be a number');
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
return (left === right) ||
|
|
1485
|
+
(typeof left !== 'undefined' &&
|
|
1486
|
+
typeof right !== 'undefined' &&
|
|
1487
|
+
Math.abs(left[0] - right[0]) <= epsilon &&
|
|
1488
|
+
Math.abs(left[1] - right[1]) <= epsilon &&
|
|
1489
|
+
Math.abs(left[2] - right[2]) <= epsilon &&
|
|
1490
|
+
Math.abs(left[3] - right[3]) <= epsilon &&
|
|
1491
|
+
Math.abs(left[4] - right[4]) <= epsilon &&
|
|
1492
|
+
Math.abs(left[5] - right[5]) <= epsilon &&
|
|
1493
|
+
Math.abs(left[6] - right[6]) <= epsilon &&
|
|
1494
|
+
Math.abs(left[7] - right[7]) <= epsilon &&
|
|
1495
|
+
Math.abs(left[8] - right[8]) <= epsilon &&
|
|
1496
|
+
Math.abs(left[9] - right[9]) <= epsilon &&
|
|
1497
|
+
Math.abs(left[10] - right[10]) <= epsilon &&
|
|
1498
|
+
Math.abs(left[11] - right[11]) <= epsilon &&
|
|
1499
|
+
Math.abs(left[12] - right[12]) <= epsilon &&
|
|
1500
|
+
Math.abs(left[13] - right[13]) <= epsilon &&
|
|
1501
|
+
Math.abs(left[14] - right[14]) <= epsilon &&
|
|
1502
|
+
Math.abs(left[15] - right[15]) <= epsilon);
|
|
1503
|
+
};
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Gets the translation portion of the provided matrix, assuming the matrix is a affine transformation matrix.
|
|
1507
|
+
* @memberof Matrix4
|
|
1508
|
+
*
|
|
1509
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
1510
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1511
|
+
* @return {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1512
|
+
*
|
|
1513
|
+
* @exception {DeveloperError} matrix is required.
|
|
1514
|
+
*
|
|
1515
|
+
* @see Cartesian3
|
|
1516
|
+
*/
|
|
1517
|
+
Matrix4.getTranslation = function(matrix, result) {
|
|
1518
|
+
if (typeof matrix === 'undefined') {
|
|
1519
|
+
throw new DeveloperError('matrix is required');
|
|
1520
|
+
}
|
|
1521
|
+
if (typeof result === 'undefined') {
|
|
1522
|
+
return new Cartesian3(matrix[12], matrix[13], matrix[14]);
|
|
1523
|
+
}
|
|
1524
|
+
result.x = matrix[12];
|
|
1525
|
+
result.y = matrix[13];
|
|
1526
|
+
result.z = matrix[14];
|
|
1527
|
+
return result;
|
|
1528
|
+
};
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Gets the upper left 3x3 rotation matrix of the provided matrix, assuming the matrix is a affine transformation matrix.
|
|
1532
|
+
* @memberof Matrix4
|
|
1533
|
+
*
|
|
1534
|
+
* @param {Matrix4} matrix The matrix to use.
|
|
1535
|
+
* @param {Matrix3} [result] The object onto which to store the result.
|
|
1536
|
+
* @return {Matrix3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1537
|
+
*
|
|
1538
|
+
* @exception {DeveloperError} matrix is required.
|
|
1539
|
+
*
|
|
1540
|
+
* @see Matrix3
|
|
1541
|
+
*/
|
|
1542
|
+
Matrix4.getRotation = function(matrix, result) {
|
|
1543
|
+
if (typeof matrix === 'undefined') {
|
|
1544
|
+
throw new DeveloperError('matrix is required');
|
|
1545
|
+
}
|
|
1546
|
+
if (typeof result === 'undefined') {
|
|
1547
|
+
return new Matrix3(matrix[0], matrix[4], matrix[8],
|
|
1548
|
+
matrix[1], matrix[5], matrix[9],
|
|
1549
|
+
matrix[2], matrix[6], matrix[10]);
|
|
1550
|
+
}
|
|
1551
|
+
result[0] = matrix[0];
|
|
1552
|
+
result[1] = matrix[1];
|
|
1553
|
+
result[2] = matrix[2];
|
|
1554
|
+
result[3] = matrix[4];
|
|
1555
|
+
result[4] = matrix[5];
|
|
1556
|
+
result[5] = matrix[6];
|
|
1557
|
+
result[6] = matrix[8];
|
|
1558
|
+
result[7] = matrix[9];
|
|
1559
|
+
result[8] = matrix[10];
|
|
1560
|
+
return result;
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* Computes the inverse of the provided matrix using Cramers Rule.
|
|
1565
|
+
* If the determinant is zero, the matrix can not be inverted, and an exception is thrown.
|
|
1566
|
+
* If the matrix is an affine transformation matrix, it is more efficient
|
|
1567
|
+
* to invert it with {@link #inverseTransformation}.
|
|
1568
|
+
* @memberof Matrix4
|
|
1569
|
+
*
|
|
1570
|
+
* @param {Matrix4} matrix The matrix to invert.
|
|
1571
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1572
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1573
|
+
*
|
|
1574
|
+
* @exception {DeveloperError} matrix is required.
|
|
1575
|
+
* @exception {RuntimeError} matrix is not invertible because its determinate is zero.
|
|
1576
|
+
*/
|
|
1577
|
+
Matrix4.inverse = function(matrix, result) {
|
|
1578
|
+
if (typeof matrix === 'undefined') {
|
|
1579
|
+
throw new DeveloperError('matrix is required');
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
//
|
|
1583
|
+
// Ported from:
|
|
1584
|
+
// ftp://download.intel.com/design/PentiumIII/sml/24504301.pdf
|
|
1585
|
+
//
|
|
1586
|
+
var src0 = matrix[0];
|
|
1587
|
+
var src1 = matrix[4];
|
|
1588
|
+
var src2 = matrix[8];
|
|
1589
|
+
var src3 = matrix[12];
|
|
1590
|
+
var src4 = matrix[1];
|
|
1591
|
+
var src5 = matrix[5];
|
|
1592
|
+
var src6 = matrix[9];
|
|
1593
|
+
var src7 = matrix[13];
|
|
1594
|
+
var src8 = matrix[2];
|
|
1595
|
+
var src9 = matrix[6];
|
|
1596
|
+
var src10 = matrix[10];
|
|
1597
|
+
var src11 = matrix[14];
|
|
1598
|
+
var src12 = matrix[3];
|
|
1599
|
+
var src13 = matrix[7];
|
|
1600
|
+
var src14 = matrix[11];
|
|
1601
|
+
var src15 = matrix[15];
|
|
1602
|
+
|
|
1603
|
+
// calculate pairs for first 8 elements (cofactors)
|
|
1604
|
+
var tmp0 = src10 * src15;
|
|
1605
|
+
var tmp1 = src11 * src14;
|
|
1606
|
+
var tmp2 = src9 * src15;
|
|
1607
|
+
var tmp3 = src11 * src13;
|
|
1608
|
+
var tmp4 = src9 * src14;
|
|
1609
|
+
var tmp5 = src10 * src13;
|
|
1610
|
+
var tmp6 = src8 * src15;
|
|
1611
|
+
var tmp7 = src11 * src12;
|
|
1612
|
+
var tmp8 = src8 * src14;
|
|
1613
|
+
var tmp9 = src10 * src12;
|
|
1614
|
+
var tmp10 = src8 * src13;
|
|
1615
|
+
var tmp11 = src9 * src12;
|
|
1616
|
+
|
|
1617
|
+
// calculate first 8 elements (cofactors)
|
|
1618
|
+
var dst0 = (tmp0 * src5 + tmp3 * src6 + tmp4 * src7) - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);
|
|
1619
|
+
var dst1 = (tmp1 * src4 + tmp6 * src6 + tmp9 * src7) - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);
|
|
1620
|
+
var dst2 = (tmp2 * src4 + tmp7 * src5 + tmp10 * src7) - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);
|
|
1621
|
+
var dst3 = (tmp5 * src4 + tmp8 * src5 + tmp11 * src6) - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);
|
|
1622
|
+
var dst4 = (tmp1 * src1 + tmp2 * src2 + tmp5 * src3) - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);
|
|
1623
|
+
var dst5 = (tmp0 * src0 + tmp7 * src2 + tmp8 * src3) - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);
|
|
1624
|
+
var dst6 = (tmp3 * src0 + tmp6 * src1 + tmp11 * src3) - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);
|
|
1625
|
+
var dst7 = (tmp4 * src0 + tmp9 * src1 + tmp10 * src2) - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);
|
|
1626
|
+
|
|
1627
|
+
// calculate pairs for second 8 elements (cofactors)
|
|
1628
|
+
tmp0 = src2 * src7;
|
|
1629
|
+
tmp1 = src3 * src6;
|
|
1630
|
+
tmp2 = src1 * src7;
|
|
1631
|
+
tmp3 = src3 * src5;
|
|
1632
|
+
tmp4 = src1 * src6;
|
|
1633
|
+
tmp5 = src2 * src5;
|
|
1634
|
+
tmp6 = src0 * src7;
|
|
1635
|
+
tmp7 = src3 * src4;
|
|
1636
|
+
tmp8 = src0 * src6;
|
|
1637
|
+
tmp9 = src2 * src4;
|
|
1638
|
+
tmp10 = src0 * src5;
|
|
1639
|
+
tmp11 = src1 * src4;
|
|
1640
|
+
|
|
1641
|
+
// calculate second 8 elements (cofactors)
|
|
1642
|
+
var dst8 = (tmp0 * src13 + tmp3 * src14 + tmp4 * src15) - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);
|
|
1643
|
+
var dst9 = (tmp1 * src12 + tmp6 * src14 + tmp9 * src15) - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);
|
|
1644
|
+
var dst10 = (tmp2 * src12 + tmp7 * src13 + tmp10 * src15) - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);
|
|
1645
|
+
var dst11 = (tmp5 * src12 + tmp8 * src13 + tmp11 * src14) - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);
|
|
1646
|
+
var dst12 = (tmp2 * src10 + tmp5 * src11 + tmp1 * src9) - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);
|
|
1647
|
+
var dst13 = (tmp8 * src11 + tmp0 * src8 + tmp7 * src10) - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);
|
|
1648
|
+
var dst14 = (tmp6 * src9 + tmp11 * src11 + tmp3 * src8) - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);
|
|
1649
|
+
var dst15 = (tmp10 * src10 + tmp4 * src8 + tmp9 * src9) - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);
|
|
1650
|
+
|
|
1651
|
+
// calculate determinant
|
|
1652
|
+
var det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
|
|
1653
|
+
|
|
1654
|
+
if (Math.abs(det) < CesiumMath.EPSILON20) {
|
|
1655
|
+
throw new RuntimeError('matrix is not invertible because its determinate is zero.');
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// calculate matrix inverse
|
|
1659
|
+
det = 1.0 / det;
|
|
1660
|
+
if (typeof result === 'undefined') {
|
|
1661
|
+
return new Matrix4(dst0 * det, dst4 * det, dst8 * det, dst12 * det,
|
|
1662
|
+
dst1 * det, dst5 * det, dst9 * det, dst13 * det,
|
|
1663
|
+
dst2 * det, dst6 * det, dst10 * det, dst14 * det,
|
|
1664
|
+
dst3 * det, dst7 * det, dst11 * det, dst15 * det);
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
result[0] = dst0 * det;
|
|
1668
|
+
result[1] = dst1 * det;
|
|
1669
|
+
result[2] = dst2 * det;
|
|
1670
|
+
result[3] = dst3 * det;
|
|
1671
|
+
result[4] = dst4 * det;
|
|
1672
|
+
result[5] = dst5 * det;
|
|
1673
|
+
result[6] = dst6 * det;
|
|
1674
|
+
result[7] = dst7 * det;
|
|
1675
|
+
result[8] = dst8 * det;
|
|
1676
|
+
result[9] = dst9 * det;
|
|
1677
|
+
result[10] = dst10 * det;
|
|
1678
|
+
result[11] = dst11 * det;
|
|
1679
|
+
result[12] = dst12 * det;
|
|
1680
|
+
result[13] = dst13 * det;
|
|
1681
|
+
result[14] = dst14 * det;
|
|
1682
|
+
result[15] = dst15 * det;
|
|
1683
|
+
return result;
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* Computes the inverse of the provided matrix assuming it is
|
|
1688
|
+
* an affine transformation matrix, where the upper left 3x3 elements
|
|
1689
|
+
* are a rotation matrix, and the upper three elements in the fourth
|
|
1690
|
+
* column are the translation. The bottom row is assumed to be [0, 0, 0, 1].
|
|
1691
|
+
* The matrix is not verified to be in the proper form.
|
|
1692
|
+
* This method is faster than computing the inverse for a general 4x4
|
|
1693
|
+
* matrix using {@link #inverse}.
|
|
1694
|
+
* @memberof Matrix4
|
|
1695
|
+
*
|
|
1696
|
+
* @param {Matrix4} matrix The matrix to invert.
|
|
1697
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1698
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1699
|
+
*
|
|
1700
|
+
* @exception {DeveloperError} matrix is required.
|
|
1701
|
+
*/
|
|
1702
|
+
Matrix4.inverseTransformation = function(matrix, result) {
|
|
1703
|
+
if (typeof matrix === 'undefined') {
|
|
1704
|
+
throw new DeveloperError('matrix is required');
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
//This function is an optimized version of the below 4 lines.
|
|
1708
|
+
//var rT = Matrix3.transpose(Matrix4.getRotation(matrix));
|
|
1709
|
+
//var rTN = Matrix3.negate(rT);
|
|
1710
|
+
//var rTT = Matrix3.multiplyByVector(rTN, Matrix4.getTranslation(matrix));
|
|
1711
|
+
//return Matrix4.fromRotationTranslation(rT, rTT, result);
|
|
1712
|
+
|
|
1713
|
+
var matrix0 = matrix[0];
|
|
1714
|
+
var matrix1 = matrix[1];
|
|
1715
|
+
var matrix2 = matrix[2];
|
|
1716
|
+
var matrix4 = matrix[4];
|
|
1717
|
+
var matrix5 = matrix[5];
|
|
1718
|
+
var matrix6 = matrix[6];
|
|
1719
|
+
var matrix8 = matrix[8];
|
|
1720
|
+
var matrix9 = matrix[9];
|
|
1721
|
+
var matrix10 = matrix[10];
|
|
1722
|
+
|
|
1723
|
+
var vX = matrix[12];
|
|
1724
|
+
var vY = matrix[13];
|
|
1725
|
+
var vZ = matrix[14];
|
|
1726
|
+
|
|
1727
|
+
var x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;
|
|
1728
|
+
var y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;
|
|
1729
|
+
var z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;
|
|
1730
|
+
|
|
1731
|
+
if (typeof result === 'undefined') {
|
|
1732
|
+
return new Matrix4(matrix0, matrix1, matrix2, x,
|
|
1733
|
+
matrix4, matrix5, matrix6, y,
|
|
1734
|
+
matrix8, matrix9, matrix10, z,
|
|
1735
|
+
0.0, 0.0, 0.0, 1.0);
|
|
1736
|
+
}
|
|
1737
|
+
result[0] = matrix0;
|
|
1738
|
+
result[1] = matrix4;
|
|
1739
|
+
result[2] = matrix8;
|
|
1740
|
+
result[3] = 0.0;
|
|
1741
|
+
result[4] = matrix1;
|
|
1742
|
+
result[5] = matrix5;
|
|
1743
|
+
result[6] = matrix9;
|
|
1744
|
+
result[7] = 0.0;
|
|
1745
|
+
result[8] = matrix2;
|
|
1746
|
+
result[9] = matrix6;
|
|
1747
|
+
result[10] = matrix10;
|
|
1748
|
+
result[11] = 0.0;
|
|
1749
|
+
result[12] = x;
|
|
1750
|
+
result[13] = y;
|
|
1751
|
+
result[14] = z;
|
|
1752
|
+
result[15] = 1.0;
|
|
1753
|
+
return result;
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* An immutable Matrix4 instance initialized to the identity matrix.
|
|
1758
|
+
* @memberof Matrix4
|
|
1759
|
+
*/
|
|
1760
|
+
Matrix4.IDENTITY = freezeObject(new Matrix4(1.0, 0.0, 0.0, 0.0,
|
|
1761
|
+
0.0, 1.0, 0.0, 0.0,
|
|
1762
|
+
0.0, 0.0, 1.0, 0.0,
|
|
1763
|
+
0.0, 0.0, 0.0, 1.0));
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* The index into Matrix4 for column 0, row 0.
|
|
1767
|
+
* @memberof Matrix4
|
|
1768
|
+
*/
|
|
1769
|
+
Matrix4.COLUMN0ROW0 = 0;
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* The index into Matrix4 for column 0, row 1.
|
|
1773
|
+
* @memberof Matrix4
|
|
1774
|
+
*/
|
|
1775
|
+
Matrix4.COLUMN0ROW1 = 1;
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* The index into Matrix4 for column 0, row 2.
|
|
1779
|
+
* @memberof Matrix4
|
|
1780
|
+
*/
|
|
1781
|
+
Matrix4.COLUMN0ROW2 = 2;
|
|
1782
|
+
|
|
1783
|
+
/**
|
|
1784
|
+
* The index into Matrix4 for column 0, row 3.
|
|
1785
|
+
* @memberof Matrix4
|
|
1786
|
+
*/
|
|
1787
|
+
Matrix4.COLUMN0ROW3 = 3;
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* The index into Matrix4 for column 1, row 0.
|
|
1791
|
+
* @memberof Matrix4
|
|
1792
|
+
*/
|
|
1793
|
+
Matrix4.COLUMN1ROW0 = 4;
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* The index into Matrix4 for column 1, row 1.
|
|
1797
|
+
* @memberof Matrix4
|
|
1798
|
+
*/
|
|
1799
|
+
Matrix4.COLUMN1ROW1 = 5;
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* The index into Matrix4 for column 1, row 2.
|
|
1803
|
+
* @memberof Matrix4
|
|
1804
|
+
*/
|
|
1805
|
+
Matrix4.COLUMN1ROW2 = 6;
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* The index into Matrix4 for column 1, row 3.
|
|
1809
|
+
* @memberof Matrix4
|
|
1810
|
+
*/
|
|
1811
|
+
Matrix4.COLUMN1ROW3 = 7;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* The index into Matrix4 for column 2, row 0.
|
|
1815
|
+
* @memberof Matrix4
|
|
1816
|
+
*/
|
|
1817
|
+
Matrix4.COLUMN2ROW0 = 8;
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* The index into Matrix4 for column 2, row 1.
|
|
1821
|
+
* @memberof Matrix4
|
|
1822
|
+
*/
|
|
1823
|
+
Matrix4.COLUMN2ROW1 = 9;
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* The index into Matrix4 for column 2, row 2.
|
|
1827
|
+
* @memberof Matrix4
|
|
1828
|
+
*/
|
|
1829
|
+
Matrix4.COLUMN2ROW2 = 10;
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* The index into Matrix4 for column 2, row 3.
|
|
1833
|
+
* @memberof Matrix4
|
|
1834
|
+
*/
|
|
1835
|
+
Matrix4.COLUMN2ROW3 = 11;
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* The index into Matrix4 for column 3, row 0.
|
|
1839
|
+
* @memberof Matrix4
|
|
1840
|
+
*/
|
|
1841
|
+
Matrix4.COLUMN3ROW0 = 12;
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* The index into Matrix4 for column 3, row 1.
|
|
1845
|
+
* @memberof Matrix4
|
|
1846
|
+
*/
|
|
1847
|
+
Matrix4.COLUMN3ROW1 = 13;
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* The index into Matrix4 for column 3, row 2.
|
|
1851
|
+
* @memberof Matrix4
|
|
1852
|
+
*/
|
|
1853
|
+
Matrix4.COLUMN3ROW2 = 14;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* The index into Matrix4 for column 3, row 3.
|
|
1857
|
+
* @memberof Matrix4
|
|
1858
|
+
*/
|
|
1859
|
+
Matrix4.COLUMN3ROW3 = 15;
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* Duplicates the provided Matrix4 instance.
|
|
1863
|
+
* @memberof Matrix4
|
|
1864
|
+
*
|
|
1865
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1866
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1867
|
+
*/
|
|
1868
|
+
Matrix4.prototype.clone = function(result) {
|
|
1869
|
+
return Matrix4.clone(this, result);
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Computes an Array from this Matrix4 instance.
|
|
1874
|
+
* @memberof Matrix4
|
|
1875
|
+
*
|
|
1876
|
+
* @param {Array} [result] The Array onto which to store the result.
|
|
1877
|
+
* @return {Array} The modified Array parameter or a new Array instance if one was not provided.
|
|
1878
|
+
*/
|
|
1879
|
+
Matrix4.prototype.toArray = function(result) {
|
|
1880
|
+
return Matrix4.toArray(this, result);
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* Retrieves a copy of the matrix column at the provided index as a Cartesian4 instance.
|
|
1885
|
+
* @memberof Matrix4
|
|
1886
|
+
*
|
|
1887
|
+
* @param {Number} index The zero-based index of the column to retrieve.
|
|
1888
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
1889
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
1890
|
+
*
|
|
1891
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
1892
|
+
*
|
|
1893
|
+
* @see Cartesian4
|
|
1894
|
+
*/
|
|
1895
|
+
Matrix4.prototype.getColumn = function(index, result) {
|
|
1896
|
+
return Matrix4.getColumn(this, index, result);
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* Computes a new matrix that replaces the specified column in this matrix with the provided Cartesian4 instance.
|
|
1901
|
+
* @memberof Matrix4
|
|
1902
|
+
*
|
|
1903
|
+
* @param {Number} index The zero-based index of the column to set.
|
|
1904
|
+
* @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified column.
|
|
1905
|
+
*
|
|
1906
|
+
* @exception {DeveloperError} cartesian is required.
|
|
1907
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
1908
|
+
*
|
|
1909
|
+
* @see Cartesian4
|
|
1910
|
+
*/
|
|
1911
|
+
Matrix4.prototype.setColumn = function(index, cartesian, result) {
|
|
1912
|
+
return Matrix4.setColumn(this, index, cartesian, result);
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Retrieves a copy of the matrix row at the provided index as a Cartesian4 instance.
|
|
1917
|
+
* @memberof Matrix4
|
|
1918
|
+
*
|
|
1919
|
+
* @param {Number} index The zero-based index of the row to retrieve.
|
|
1920
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
1921
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
1922
|
+
*
|
|
1923
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
1924
|
+
*
|
|
1925
|
+
* @see Cartesian4
|
|
1926
|
+
*/
|
|
1927
|
+
Matrix4.prototype.getRow = function(index, result) {
|
|
1928
|
+
return Matrix4.getRow(this, index, result);
|
|
1929
|
+
};
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* Computes a new matrix that replaces the specified row in this matrix with the provided Cartesian4 instance.
|
|
1933
|
+
* @memberof Matrix4
|
|
1934
|
+
*
|
|
1935
|
+
* @param {Number} index The zero-based index of the row to set.
|
|
1936
|
+
* @param {Cartesian4} cartesian The Cartesian whose values will be assigned to the specified row.
|
|
1937
|
+
*
|
|
1938
|
+
* @exception {DeveloperError} cartesian is required.
|
|
1939
|
+
* @exception {DeveloperError} index is required and must be 0, 1, 2, or 3.
|
|
1940
|
+
*
|
|
1941
|
+
* @see Cartesian4
|
|
1942
|
+
*/
|
|
1943
|
+
Matrix4.prototype.setRow = function(index, cartesian, result) {
|
|
1944
|
+
return Matrix4.setRow(this, index, cartesian, result);
|
|
1945
|
+
};
|
|
1946
|
+
|
|
1947
|
+
/**
|
|
1948
|
+
* Computes the product of this matrix and the provided matrix.
|
|
1949
|
+
* @memberof Matrix4
|
|
1950
|
+
*
|
|
1951
|
+
* @param {Matrix4} right The right hand side matrix.
|
|
1952
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1953
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1954
|
+
*
|
|
1955
|
+
* @exception {DeveloperError} right is required.
|
|
1956
|
+
*/
|
|
1957
|
+
Matrix4.prototype.multiply = function(right, result) {
|
|
1958
|
+
return Matrix4.multiply(this, right, result);
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* Multiplies this matrix, assuming it is a transformation matrix (with a bottom row of
|
|
1963
|
+
* <code>[0.0, 0.0, 0.0, 1.0]</code>), by an implicit translation matrix defined by a {@link Cartesian3}.
|
|
1964
|
+
*
|
|
1965
|
+
* @memberof Matrix4
|
|
1966
|
+
*
|
|
1967
|
+
* @param {Cartesian3} translation The translation on the right-hand side of the multiplication.
|
|
1968
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1969
|
+
*
|
|
1970
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1971
|
+
*
|
|
1972
|
+
* @exception {DeveloperError} translation is required.
|
|
1973
|
+
*/
|
|
1974
|
+
Matrix4.prototype.multiplyByTranslation = function(translation, result) {
|
|
1975
|
+
return Matrix4.multiplyByTranslation(this, translation, result);
|
|
1976
|
+
};
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Multiplies this matrix, assuming it is a transformation matrix (with a bottom row of
|
|
1980
|
+
* <code>[0.0, 0.0, 0.0, 1.0]</code>), by an implicit uniform scale matrix.
|
|
1981
|
+
*
|
|
1982
|
+
* @memberof Matrix4
|
|
1983
|
+
*
|
|
1984
|
+
* @param {Number} scale The scale on the right-hand side of the multiplication.
|
|
1985
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
1986
|
+
*
|
|
1987
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
1988
|
+
*
|
|
1989
|
+
* @exception {DeveloperError} scale is required.
|
|
1990
|
+
*/
|
|
1991
|
+
Matrix4.prototype.multiplyByUniformScale = function(scale, result) {
|
|
1992
|
+
return Matrix4.multiplyByUniformScale(this, scale, result);
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
/**
|
|
1996
|
+
* Computes the product of this matrix and a column vector.
|
|
1997
|
+
* @memberof Matrix4
|
|
1998
|
+
*
|
|
1999
|
+
* @param {Cartesian4} cartesian The vector.
|
|
2000
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
2001
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
2002
|
+
*
|
|
2003
|
+
* @exception {DeveloperError} cartesian is required.
|
|
2004
|
+
*/
|
|
2005
|
+
Matrix4.prototype.multiplyByVector = function(cartesian, result) {
|
|
2006
|
+
return Matrix4.multiplyByVector(this, cartesian, result);
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Computes the product of a matrix and a {@link Cartesian3}. This is equivalent to calling {@link Matrix4#multiplyByVector}
|
|
2011
|
+
* with a {@link Cartesian4} with a <code>w</code> component of one.
|
|
2012
|
+
* @memberof Matrix4
|
|
2013
|
+
*
|
|
2014
|
+
* @param {Cartesian3} cartesian The point.
|
|
2015
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
2016
|
+
* @return {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
2017
|
+
*
|
|
2018
|
+
* @exception {DeveloperError} cartesian is required.
|
|
2019
|
+
*/
|
|
2020
|
+
Matrix4.prototype.multiplyByPoint = function(cartesian, result) {
|
|
2021
|
+
return Matrix4.multiplyByPoint(this, cartesian, result);
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
/**
|
|
2025
|
+
* Computes the product of this matrix and a scalar.
|
|
2026
|
+
* @memberof Matrix4
|
|
2027
|
+
*
|
|
2028
|
+
* @param {Number} scalar The number to multiply by.
|
|
2029
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
2030
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
2031
|
+
*
|
|
2032
|
+
* @exception {DeveloperError} scalar is required and must be a number.
|
|
2033
|
+
*/
|
|
2034
|
+
Matrix4.prototype.multiplyByScalar = function(scalar, result) {
|
|
2035
|
+
return Matrix4.multiplyByScalar(this, scalar, result);
|
|
2036
|
+
};
|
|
2037
|
+
/**
|
|
2038
|
+
* Computes a negated copy of this matrix.
|
|
2039
|
+
* @memberof Matrix4
|
|
2040
|
+
*
|
|
2041
|
+
* @param {Matrix4} matrix The matrix to negate.
|
|
2042
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
2043
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
2044
|
+
*
|
|
2045
|
+
* @exception {DeveloperError} matrix is required.
|
|
2046
|
+
*/
|
|
2047
|
+
Matrix4.prototype.negate = function(result) {
|
|
2048
|
+
return Matrix4.negate(this, result);
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
/**
|
|
2052
|
+
* Computes the transpose of this matrix.
|
|
2053
|
+
* @memberof Matrix4
|
|
2054
|
+
*
|
|
2055
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
2056
|
+
* @return {Matrix4} The modified result parameter or a new Matrix4 instance if one was not provided.
|
|
2057
|
+
*/
|
|
2058
|
+
Matrix4.prototype.transpose = function(result) {
|
|
2059
|
+
return Matrix4.transpose(this, result);
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2062
|
+
/**
|
|
2063
|
+
* Compares this matrix to the provided matrix componentwise and returns
|
|
2064
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
2065
|
+
* @memberof Matrix4
|
|
2066
|
+
*
|
|
2067
|
+
* @param {Matrix4} [right] The right hand side matrix.
|
|
2068
|
+
* @return {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
2069
|
+
*/
|
|
2070
|
+
Matrix4.prototype.equals = function(right) {
|
|
2071
|
+
return Matrix4.equals(this, right);
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* Compares this matrix to the provided matrix componentwise and returns
|
|
2076
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
2077
|
+
* <code>false</code> otherwise.
|
|
2078
|
+
* @memberof Matrix4
|
|
2079
|
+
*
|
|
2080
|
+
* @param {Matrix4} [right] The right hand side matrix.
|
|
2081
|
+
* @param {Number} epsilon The epsilon to use for equality testing.
|
|
2082
|
+
* @return {Boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
2083
|
+
*
|
|
2084
|
+
* @exception {DeveloperError} epsilon is required and must be a number.
|
|
2085
|
+
*/
|
|
2086
|
+
Matrix4.prototype.equalsEpsilon = function(right, epsilon) {
|
|
2087
|
+
return Matrix4.equalsEpsilon(this, right, epsilon);
|
|
2088
|
+
};
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Computes a string representing this Matrix with each row being
|
|
2092
|
+
* on a separate line and in the format '(column0, column1, column2, column3)'.
|
|
2093
|
+
* @memberof Matrix4
|
|
2094
|
+
*
|
|
2095
|
+
* @return {String} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.
|
|
2096
|
+
*/
|
|
2097
|
+
Matrix4.prototype.toString = function() {
|
|
2098
|
+
return '(' + this[0] + ', ' + this[4] + ', ' + this[8] + ', ' + this[12] +')\n' +
|
|
2099
|
+
'(' + this[1] + ', ' + this[5] + ', ' + this[9] + ', ' + this[13] +')\n' +
|
|
2100
|
+
'(' + this[2] + ', ' + this[6] + ', ' + this[10] + ', ' + this[14] +')\n' +
|
|
2101
|
+
'(' + this[3] + ', ' + this[7] + ', ' + this[11] + ', ' + this[15] +')';
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* Gets the translation portion of this matrix, assuming the matrix is a affine transformation matrix.
|
|
2106
|
+
* @memberof Matrix4
|
|
2107
|
+
*
|
|
2108
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
2109
|
+
* @return {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
2110
|
+
*
|
|
2111
|
+
* @see Cartesian3
|
|
2112
|
+
*/
|
|
2113
|
+
Matrix4.prototype.getTranslation = function(result) {
|
|
2114
|
+
return Matrix4.getTranslation(this, result);
|
|
2115
|
+
};
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* Gets the upper left 3x3 rotation matrix of this matrix, assuming the matrix is a affine transformation matrix.
|
|
2119
|
+
* @memberof Matrix4
|
|
2120
|
+
*
|
|
2121
|
+
* @param {Matrix3} [result] The object onto which to store the result.
|
|
2122
|
+
* @return {Matrix3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
2123
|
+
*
|
|
2124
|
+
* @see Matrix3
|
|
2125
|
+
*/
|
|
2126
|
+
Matrix4.prototype.getRotation = function(result) {
|
|
2127
|
+
return Matrix4.getRotation(this, result);
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Computes the inverse of this matrix using Cramers Rule.
|
|
2132
|
+
* If the determinant is zero, the matrix can not be inverted, and an exception is thrown.
|
|
2133
|
+
* If the matrix is an affine transformation matrix, it is more efficient
|
|
2134
|
+
* to invert it with {@link #inverseTransformation}.
|
|
2135
|
+
* @memberof Matrix4
|
|
2136
|
+
*
|
|
2137
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
2138
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
2139
|
+
*
|
|
2140
|
+
* @exception {RuntimeError} matrix is not invertible because its determinate is zero.
|
|
2141
|
+
*/
|
|
2142
|
+
Matrix4.prototype.inverse = function(result) {
|
|
2143
|
+
return Matrix4.inverse(this, result);
|
|
2144
|
+
};
|
|
2145
|
+
|
|
2146
|
+
/**
|
|
2147
|
+
* Computes the inverse of this matrix assuming it is
|
|
2148
|
+
* an affine transformation matrix, where the upper left 3x3 elements
|
|
2149
|
+
* are a rotation matrix, and the upper three elements in the fourth
|
|
2150
|
+
* column are the translation. The bottom row is assumed to be [0, 0, 0, 1].
|
|
2151
|
+
* The matrix is not verified to be in the proper form.
|
|
2152
|
+
* This method is faster than computing the inverse for a general 4x4
|
|
2153
|
+
* matrix using {@link #inverse}.
|
|
2154
|
+
* @memberof Matrix4
|
|
2155
|
+
*
|
|
2156
|
+
* @param {Matrix4} [result] The object onto which to store the result.
|
|
2157
|
+
* @return {Matrix4} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
2158
|
+
*/
|
|
2159
|
+
Matrix4.prototype.inverseTransformation = function(result) {
|
|
2160
|
+
return Matrix4.inverseTransformation(this, result);
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
return Matrix4;
|
|
2164
|
+
});
|