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,1209 @@
|
|
|
1
|
+
/*global define*/
|
|
2
|
+
define([
|
|
3
|
+
'../Core/DeveloperError',
|
|
4
|
+
'../Core/combine',
|
|
5
|
+
'../Core/destroyObject',
|
|
6
|
+
'../Core/Math',
|
|
7
|
+
'../Core/Cartesian2',
|
|
8
|
+
'../Core/Cartesian3',
|
|
9
|
+
'../Core/Cartesian4',
|
|
10
|
+
'../Core/EncodedCartesian3',
|
|
11
|
+
'../Core/Matrix4',
|
|
12
|
+
'../Core/ComponentDatatype',
|
|
13
|
+
'../Core/IndexDatatype',
|
|
14
|
+
'../Core/PrimitiveType',
|
|
15
|
+
'../Core/BoundingSphere',
|
|
16
|
+
'../Renderer/BlendingState',
|
|
17
|
+
'../Renderer/BufferUsage',
|
|
18
|
+
'../Renderer/CommandLists',
|
|
19
|
+
'../Renderer/DrawCommand',
|
|
20
|
+
'../Renderer/VertexArrayFacade',
|
|
21
|
+
'./SceneMode',
|
|
22
|
+
'./Billboard',
|
|
23
|
+
'./HorizontalOrigin',
|
|
24
|
+
'../Shaders/BillboardCollectionVS',
|
|
25
|
+
'../Shaders/BillboardCollectionFS'
|
|
26
|
+
], function(
|
|
27
|
+
DeveloperError,
|
|
28
|
+
combine,
|
|
29
|
+
destroyObject,
|
|
30
|
+
CesiumMath,
|
|
31
|
+
Cartesian2,
|
|
32
|
+
Cartesian3,
|
|
33
|
+
Cartesian4,
|
|
34
|
+
EncodedCartesian3,
|
|
35
|
+
Matrix4,
|
|
36
|
+
ComponentDatatype,
|
|
37
|
+
IndexDatatype,
|
|
38
|
+
PrimitiveType,
|
|
39
|
+
BoundingSphere,
|
|
40
|
+
BlendingState,
|
|
41
|
+
BufferUsage,
|
|
42
|
+
CommandLists,
|
|
43
|
+
DrawCommand,
|
|
44
|
+
VertexArrayFacade,
|
|
45
|
+
SceneMode,
|
|
46
|
+
Billboard,
|
|
47
|
+
HorizontalOrigin,
|
|
48
|
+
BillboardCollectionVS,
|
|
49
|
+
BillboardCollectionFS) {
|
|
50
|
+
"use strict";
|
|
51
|
+
|
|
52
|
+
var SHOW_INDEX = Billboard.SHOW_INDEX;
|
|
53
|
+
var POSITION_INDEX = Billboard.POSITION_INDEX;
|
|
54
|
+
var PIXEL_OFFSET_INDEX = Billboard.PIXEL_OFFSET_INDEX;
|
|
55
|
+
var EYE_OFFSET_INDEX = Billboard.EYE_OFFSET_INDEX;
|
|
56
|
+
var HORIZONTAL_ORIGIN_INDEX = Billboard.HORIZONTAL_ORIGIN_INDEX;
|
|
57
|
+
var VERTICAL_ORIGIN_INDEX = Billboard.VERTICAL_ORIGIN_INDEX;
|
|
58
|
+
var SCALE_INDEX = Billboard.SCALE_INDEX;
|
|
59
|
+
var IMAGE_INDEX_INDEX = Billboard.IMAGE_INDEX_INDEX;
|
|
60
|
+
var COLOR_INDEX = Billboard.COLOR_INDEX;
|
|
61
|
+
var NUMBER_OF_PROPERTIES = Billboard.NUMBER_OF_PROPERTIES;
|
|
62
|
+
|
|
63
|
+
// PERFORMANCE_IDEA: Use vertex compression so we don't run out of
|
|
64
|
+
// vec4 attributes (WebGL minimum: 8)
|
|
65
|
+
var attributeIndices = {
|
|
66
|
+
positionHigh : 0,
|
|
67
|
+
positionLow : 1,
|
|
68
|
+
pixelOffset : 2,
|
|
69
|
+
eyeOffsetAndScale : 3,
|
|
70
|
+
textureCoordinatesAndImageSize : 4,
|
|
71
|
+
originAndShow : 5,
|
|
72
|
+
direction : 6,
|
|
73
|
+
pickColor : 7, // pickColor and color shared an index because pickColor is only used during
|
|
74
|
+
color : 7 // the 'pick' pass and 'color' is only used during the 'color' pass.
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Identifies to the VertexArrayFacade the attributes that are used only for the pick
|
|
78
|
+
// pass or only for the color pass.
|
|
79
|
+
var allPassPurpose = 'all';
|
|
80
|
+
var colorPassPurpose = 'color';
|
|
81
|
+
var pickPassPurpose = 'pick';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A renderable collection of billboards. Billboards are viewport-aligned
|
|
85
|
+
* images positioned in the 3D scene.
|
|
86
|
+
* <br /><br />
|
|
87
|
+
* <div align='center'>
|
|
88
|
+
* <img src='images/Billboard.png' width='400' height='300' /><br />
|
|
89
|
+
* Example billboards
|
|
90
|
+
* </div>
|
|
91
|
+
* <br /><br />
|
|
92
|
+
* Billboards are added and removed from the collection using {@link BillboardCollection#add}
|
|
93
|
+
* and {@link BillboardCollection#remove}. All billboards in a collection reference images
|
|
94
|
+
* from the same texture atlas, which is assigned using {@link BillboardCollection#setTextureAtlas}.
|
|
95
|
+
*
|
|
96
|
+
* @alias BillboardCollection
|
|
97
|
+
* @constructor
|
|
98
|
+
*
|
|
99
|
+
* @performance For best performance, prefer a few collections, each with many billboards, to
|
|
100
|
+
* many collections with only a few billboards each. Organize collections so that billboards
|
|
101
|
+
* with the same update frequency are in the same collection, i.e., billboards that do not
|
|
102
|
+
* change should be in one collection; billboards that change every frame should be in another
|
|
103
|
+
* collection; and so on.
|
|
104
|
+
*
|
|
105
|
+
* @see BillboardCollection#add
|
|
106
|
+
* @see BillboardCollection#remove
|
|
107
|
+
* @see BillboardCollection#setTextureAtlas
|
|
108
|
+
* @see Billboard
|
|
109
|
+
* @see TextureAtlas
|
|
110
|
+
* @see LabelCollection
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // Create a billboard collection with two billboards
|
|
114
|
+
* var billboards = new BillboardCollection();
|
|
115
|
+
* var atlas = context.createTextureAtlas({images : images});
|
|
116
|
+
* billboards.setTextureAtlas(atlas);
|
|
117
|
+
* billboards.add({
|
|
118
|
+
* position : { x : 1.0, y : 2.0, z : 3.0 },
|
|
119
|
+
* imageIndex : 0
|
|
120
|
+
* });
|
|
121
|
+
* billboards.add({
|
|
122
|
+
* position : { x : 4.0, y : 5.0, z : 6.0 },
|
|
123
|
+
* imageIndex : 1
|
|
124
|
+
* });
|
|
125
|
+
*/
|
|
126
|
+
var BillboardCollection = function() {
|
|
127
|
+
this._textureAtlas = undefined;
|
|
128
|
+
this._textureAtlasGUID = undefined;
|
|
129
|
+
this._destroyTextureAtlas = true;
|
|
130
|
+
this._sp = undefined;
|
|
131
|
+
this._rs = undefined;
|
|
132
|
+
this._vaf = undefined;
|
|
133
|
+
this._rsPick = undefined;
|
|
134
|
+
this._spPick = undefined;
|
|
135
|
+
|
|
136
|
+
this._billboards = [];
|
|
137
|
+
this._billboardsToUpdate = [];
|
|
138
|
+
this._billboardsRemoved = false;
|
|
139
|
+
this._createVertexArray = false;
|
|
140
|
+
|
|
141
|
+
this._propertiesChanged = new Uint32Array(NUMBER_OF_PROPERTIES);
|
|
142
|
+
|
|
143
|
+
this._maxSize = 0.0;
|
|
144
|
+
this._maxEyeOffset = 0.0;
|
|
145
|
+
this._maxScale = 1.0;
|
|
146
|
+
this._maxPixelOffset = 0.0;
|
|
147
|
+
this._allHorizontalCenter = true;
|
|
148
|
+
|
|
149
|
+
this._baseVolume = new BoundingSphere();
|
|
150
|
+
this._baseVolume2D = new BoundingSphere();
|
|
151
|
+
this._boundingVolume = new BoundingSphere();
|
|
152
|
+
|
|
153
|
+
this._commandLists = new CommandLists();
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The 4x4 transformation matrix that transforms each billboard in this collection from model to world coordinates.
|
|
157
|
+
* When this is the identity matrix, the billboards are drawn in world coordinates, i.e., Earth's WGS84 coordinates.
|
|
158
|
+
* Local reference frames can be used by providing a different transformation matrix, like that returned
|
|
159
|
+
* by {@link Transforms.eastNorthUpToFixedFrame}. This matrix is available to GLSL vertex and fragment
|
|
160
|
+
* shaders via {@link czm_model} and derived uniforms.
|
|
161
|
+
*
|
|
162
|
+
* @type Matrix4
|
|
163
|
+
*
|
|
164
|
+
* @see Transforms.eastNorthUpToFixedFrame
|
|
165
|
+
* @see czm_model
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* var center = ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-75.59777, 40.03883));
|
|
169
|
+
* billboards.modelMatrix = Transforms.eastNorthUpToFixedFrame(center);
|
|
170
|
+
* billboards.add({ imageIndex: 0, position : new Cartesian3(0.0, 0.0, 0.0) }); // center
|
|
171
|
+
* billboards.add({ imageIndex: 0, position : new Cartesian3(1000000.0, 0.0, 0.0) }); // east
|
|
172
|
+
* billboards.add({ imageIndex: 0, position : new Cartesian3(0.0, 1000000.0, 0.0) }); // north
|
|
173
|
+
* billboards.add({ imageIndex: 0, position : new Cartesian3(0.0, 0.0, 1000000.0) }); // up
|
|
174
|
+
* ]);
|
|
175
|
+
*/
|
|
176
|
+
this.modelMatrix = Matrix4.IDENTITY.clone();
|
|
177
|
+
this._modelMatrix = Matrix4.IDENTITY.clone();
|
|
178
|
+
|
|
179
|
+
this._mode = SceneMode.SCENE3D;
|
|
180
|
+
this._projection = undefined;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* If true, aligns all billboards to a pixel in screen space,
|
|
184
|
+
* providing a crisper image at the cost of jumpier motion.
|
|
185
|
+
* Defaults to false.
|
|
186
|
+
*
|
|
187
|
+
* @type Boolean
|
|
188
|
+
*/
|
|
189
|
+
this.clampToPixel = false;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The current morph transition time between 2D/Columbus View and 3D,
|
|
193
|
+
* with 0.0 being 2D or Columbus View and 1.0 being 3D.
|
|
194
|
+
*
|
|
195
|
+
* @type Number
|
|
196
|
+
*/
|
|
197
|
+
this.morphTime = this._mode.morphTime;
|
|
198
|
+
|
|
199
|
+
// The buffer usage for each attribute is determined based on the usage of the attribute over time.
|
|
200
|
+
this._buffersUsage = [
|
|
201
|
+
BufferUsage.STATIC_DRAW, // SHOW_INDEX
|
|
202
|
+
BufferUsage.STATIC_DRAW, // POSITION_INDEX
|
|
203
|
+
BufferUsage.STATIC_DRAW, // PIXEL_OFFSET_INDEX
|
|
204
|
+
BufferUsage.STATIC_DRAW, // EYE_OFFSET_INDEX
|
|
205
|
+
BufferUsage.STATIC_DRAW, // HORIZONTAL_ORIGIN_INDEX
|
|
206
|
+
BufferUsage.STATIC_DRAW, // VERTICAL_ORIGIN_INDEX
|
|
207
|
+
BufferUsage.STATIC_DRAW, // SCALE_INDEX
|
|
208
|
+
BufferUsage.STATIC_DRAW, // IMAGE_INDEX_INDEX
|
|
209
|
+
BufferUsage.STATIC_DRAW // COLOR_INDEX
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
var that = this;
|
|
213
|
+
this._uniforms = {
|
|
214
|
+
u_atlas : function() {
|
|
215
|
+
return that._textureAtlas.getTexture();
|
|
216
|
+
},
|
|
217
|
+
u_atlasSize : function() {
|
|
218
|
+
return that._textureAtlas.getTexture().getDimensions();
|
|
219
|
+
},
|
|
220
|
+
u_clampToPixel : function() {
|
|
221
|
+
return that.clampToPixel ? 1.0 : 0.0;
|
|
222
|
+
},
|
|
223
|
+
u_morphTime : function() {
|
|
224
|
+
return that.morphTime;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Creates and adds a billboard with the specified initial properties to the collection.
|
|
231
|
+
* The added billboard is returned so it can be modified or removed from the collection later.
|
|
232
|
+
*
|
|
233
|
+
* @memberof BillboardCollection
|
|
234
|
+
*
|
|
235
|
+
* @param {Object}[billboard=undefined] A template describing the billboard's properties as shown in Example 1.
|
|
236
|
+
*
|
|
237
|
+
* @return {Billboard} The billboard that was added to the collection.
|
|
238
|
+
*
|
|
239
|
+
* @performance Calling <code>add</code> is expected constant time. However, when
|
|
240
|
+
* {@link BillboardCollection#update} is called, the collection's vertex buffer
|
|
241
|
+
* is rewritten - an <code>O(n)</code> operation that also incurs CPU to GPU overhead. For
|
|
242
|
+
* best performance, add as many billboards as possible before calling <code>update</code>.
|
|
243
|
+
*
|
|
244
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
245
|
+
*
|
|
246
|
+
* @see BillboardCollection#remove
|
|
247
|
+
* @see BillboardCollection#removeAll
|
|
248
|
+
* @see BillboardCollection#update
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Example 1: Add a billboard, specifying all the default values.
|
|
252
|
+
* var b = billboards.add({
|
|
253
|
+
* show : true,
|
|
254
|
+
* position : new Cartesian3(0.0, 0.0, 0.0),
|
|
255
|
+
* pixelOffset : new Cartesian2(0.0, 0.0),
|
|
256
|
+
* eyeOffset : new Cartesian3(0.0, 0.0, 0.0),
|
|
257
|
+
* horizontalOrigin : HorizontalOrigin.CENTER,
|
|
258
|
+
* verticalOrigin : VerticalOrigin.CENTER,
|
|
259
|
+
* scale : 1.0,
|
|
260
|
+
* imageIndex : 0,
|
|
261
|
+
* color : new Color(1.0, 1.0, 1.0, 1.0)
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* // Example 2: Specify only the billboard's cartographic position.
|
|
265
|
+
* var b = billboards.add({
|
|
266
|
+
* position : ellipsoid.cartographicToCartesian(new Cartographic(longitude, latitude, height))
|
|
267
|
+
* });
|
|
268
|
+
*/
|
|
269
|
+
BillboardCollection.prototype.add = function(billboard) {
|
|
270
|
+
var b = new Billboard(billboard, this);
|
|
271
|
+
b._index = this._billboards.length;
|
|
272
|
+
|
|
273
|
+
this._billboards.push(b);
|
|
274
|
+
this._createVertexArray = true;
|
|
275
|
+
|
|
276
|
+
return b;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Removes a billboard from the collection.
|
|
281
|
+
*
|
|
282
|
+
* @memberof BillboardCollection
|
|
283
|
+
*
|
|
284
|
+
* @param {Billboard} billboard The billboard to remove.
|
|
285
|
+
*
|
|
286
|
+
* @return {Boolean} <code>true</code> if the billboard was removed; <code>false</code> if the billboard was not found in the collection.
|
|
287
|
+
*
|
|
288
|
+
* @performance Calling <code>remove</code> is expected constant time. However, when
|
|
289
|
+
* {@link BillboardCollection#update} is called, the collection's vertex buffer
|
|
290
|
+
* is rewritten - an <code>O(n)</code> operation that also incurs CPU to GPU overhead. For
|
|
291
|
+
* best performance, remove as many billboards as possible before calling <code>update</code>.
|
|
292
|
+
* If you intend to temporarily hide a billboard, it is usually more efficient to call
|
|
293
|
+
* {@link Billboard#setShow} instead of removing and re-adding the billboard.
|
|
294
|
+
*
|
|
295
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
296
|
+
*
|
|
297
|
+
* @see BillboardCollection#add
|
|
298
|
+
* @see BillboardCollection#removeAll
|
|
299
|
+
* @see BillboardCollection#update
|
|
300
|
+
* @see Billboard#setShow
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* var b = billboards.add(...);
|
|
304
|
+
* billboards.remove(b); // Returns true
|
|
305
|
+
*/
|
|
306
|
+
BillboardCollection.prototype.remove = function(billboard) {
|
|
307
|
+
if (this.contains(billboard)) {
|
|
308
|
+
this._billboards[billboard._index] = null; // Removed later
|
|
309
|
+
this._billboardsRemoved = true;
|
|
310
|
+
this._createVertexArray = true;
|
|
311
|
+
billboard._destroy();
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return false;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Removes all billboards from the collection.
|
|
320
|
+
*
|
|
321
|
+
* @performance <code>O(n)</code>. It is more efficient to remove all the billboards
|
|
322
|
+
* from a collection and then add new ones than to create a new collection entirely.
|
|
323
|
+
*
|
|
324
|
+
* @memberof BillboardCollection
|
|
325
|
+
*
|
|
326
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
327
|
+
*
|
|
328
|
+
* @see BillboardCollection#add
|
|
329
|
+
* @see BillboardCollection#remove
|
|
330
|
+
* @see BillboardCollection#update
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* billboards.add(...);
|
|
334
|
+
* billboards.add(...);
|
|
335
|
+
* billboards.removeAll();
|
|
336
|
+
*/
|
|
337
|
+
BillboardCollection.prototype.removeAll = function() {
|
|
338
|
+
this._destroyBillboards();
|
|
339
|
+
this._billboards = [];
|
|
340
|
+
this._billboardsToUpdate = [];
|
|
341
|
+
this._billboardsRemoved = false;
|
|
342
|
+
|
|
343
|
+
this._createVertexArray = true;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
function removeBillboards(billboardCollection) {
|
|
347
|
+
if (billboardCollection._billboardsRemoved) {
|
|
348
|
+
billboardCollection._billboardsRemoved = false;
|
|
349
|
+
|
|
350
|
+
var newBillboards = [];
|
|
351
|
+
var billboards = billboardCollection._billboards;
|
|
352
|
+
var length = billboards.length;
|
|
353
|
+
for (var i = 0, j = 0; i < length; ++i) {
|
|
354
|
+
var billboard = billboards[i];
|
|
355
|
+
if (billboard) {
|
|
356
|
+
billboard._index = j++;
|
|
357
|
+
newBillboards.push(billboard);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
billboardCollection._billboards = newBillboards;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
BillboardCollection.prototype._updateBillboard = function(billboard, propertyChanged) {
|
|
366
|
+
if (!billboard._dirty) {
|
|
367
|
+
this._billboardsToUpdate.push(billboard);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
++this._propertiesChanged[propertyChanged];
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Check whether this collection contains a given billboard.
|
|
375
|
+
*
|
|
376
|
+
* @memberof BillboardCollection
|
|
377
|
+
*
|
|
378
|
+
* @param {Billboard} billboard The billboard to check for.
|
|
379
|
+
*
|
|
380
|
+
* @return {Boolean} true if this collection contains the billboard, false otherwise.
|
|
381
|
+
*
|
|
382
|
+
* @see BillboardCollection#get
|
|
383
|
+
*/
|
|
384
|
+
BillboardCollection.prototype.contains = function(billboard) {
|
|
385
|
+
return typeof billboard !== 'undefined' && billboard._billboardCollection === this;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Returns the billboard in the collection at the specified index. Indices are zero-based
|
|
390
|
+
* and increase as billboards are added. Removing a billboard shifts all billboards after
|
|
391
|
+
* it to the left, changing their indices. This function is commonly used with
|
|
392
|
+
* {@link BillboardCollection#getLength} to iterate over all the billboards
|
|
393
|
+
* in the collection.
|
|
394
|
+
*
|
|
395
|
+
* @memberof BillboardCollection
|
|
396
|
+
*
|
|
397
|
+
* @param {Number} index The zero-based index of the billboard.
|
|
398
|
+
*
|
|
399
|
+
* @return {Billboard} The billboard at the specified index.
|
|
400
|
+
*
|
|
401
|
+
* @performance Expected constant time. If billboards were removed from the collection and
|
|
402
|
+
* {@link BillboardCollection#update} was not called, an implicit <code>O(n)</code>
|
|
403
|
+
* operation is performed.
|
|
404
|
+
*
|
|
405
|
+
* @exception {DeveloperError} index is required.
|
|
406
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
407
|
+
*
|
|
408
|
+
* @see BillboardCollection#getLength
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* // Toggle the show property of every billboard in the collection
|
|
412
|
+
* var len = billboards.getLength();
|
|
413
|
+
* for (var i = 0; i < len; ++i) {
|
|
414
|
+
* var b = billboards.get(i);
|
|
415
|
+
* b.setShow(!b.getShow());
|
|
416
|
+
* }
|
|
417
|
+
*/
|
|
418
|
+
BillboardCollection.prototype.get = function(index) {
|
|
419
|
+
if (typeof index === 'undefined') {
|
|
420
|
+
throw new DeveloperError('index is required.');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
removeBillboards(this);
|
|
424
|
+
return this._billboards[index];
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns the number of billboards in this collection. This is commonly used with
|
|
429
|
+
* {@link BillboardCollection#get} to iterate over all the billboards
|
|
430
|
+
* in the collection.
|
|
431
|
+
*
|
|
432
|
+
* @memberof BillboardCollection
|
|
433
|
+
*
|
|
434
|
+
* @return {Number} The number of billboards in this collection.
|
|
435
|
+
*
|
|
436
|
+
* @performance Expected constant time. If billboards were removed from the collection and
|
|
437
|
+
* {@link BillboardCollection#update} was not called, an implicit <code>O(n)</code>
|
|
438
|
+
* operation is performed.
|
|
439
|
+
*
|
|
440
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
441
|
+
*
|
|
442
|
+
* @see BillboardCollection#get
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* // Toggle the show property of every billboard in the collection
|
|
446
|
+
* var len = billboards.getLength();
|
|
447
|
+
* for (var i = 0; i < len; ++i) {
|
|
448
|
+
* var b = billboards.get(i);
|
|
449
|
+
* b.setShow(!b.getShow());
|
|
450
|
+
* }
|
|
451
|
+
*/
|
|
452
|
+
BillboardCollection.prototype.getLength = function() {
|
|
453
|
+
removeBillboards(this);
|
|
454
|
+
return this._billboards.length;
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* DOC_TBA
|
|
459
|
+
*
|
|
460
|
+
* @memberof BillboardCollection
|
|
461
|
+
*
|
|
462
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
463
|
+
*
|
|
464
|
+
* @see BillboardCollection#setTextureAtlas
|
|
465
|
+
* @see Billboard#setImageIndex
|
|
466
|
+
*/
|
|
467
|
+
BillboardCollection.prototype.getTextureAtlas = function() {
|
|
468
|
+
return this._textureAtlas;
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* DOC_TBA
|
|
473
|
+
*
|
|
474
|
+
* @memberof BillboardCollection
|
|
475
|
+
*
|
|
476
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
477
|
+
*
|
|
478
|
+
* @see BillboardCollection#getTextureAtlas
|
|
479
|
+
* @see Billboard#setImageIndex
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* // Assigns a texture atlas with two images to a billboard collection.
|
|
483
|
+
* // Two billboards, each referring to one of the images, are then
|
|
484
|
+
* // added to the collection.
|
|
485
|
+
* var billboards = new BillboardCollection();
|
|
486
|
+
* var images = [image0, image1];
|
|
487
|
+
* var atlas = context.createTextureAtlas({images : images});
|
|
488
|
+
* billboards.setTextureAtlas(atlas);
|
|
489
|
+
* billboards.add({
|
|
490
|
+
* // ...
|
|
491
|
+
* imageIndex : 0
|
|
492
|
+
* });
|
|
493
|
+
* billboards.add({
|
|
494
|
+
* // ...
|
|
495
|
+
* imageIndex : 1
|
|
496
|
+
* });
|
|
497
|
+
*/
|
|
498
|
+
BillboardCollection.prototype.setTextureAtlas = function(value) {
|
|
499
|
+
if (this._textureAtlas !== value) {
|
|
500
|
+
this._textureAtlas = this._destroyTextureAtlas && this._textureAtlas && this._textureAtlas.destroy();
|
|
501
|
+
this._textureAtlas = value;
|
|
502
|
+
this._createVertexArray = true; // New per-billboard texture coordinates
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Returns <code>true</code> if the texture atlas is destroyed when the collection is
|
|
508
|
+
* destroyed; otherwise, <code>false</code>.
|
|
509
|
+
*
|
|
510
|
+
* @memberof BillboardCollection
|
|
511
|
+
*
|
|
512
|
+
* @return <code>true</code> if the texture atlas is destroyed when the collection is
|
|
513
|
+
* destroyed; otherwise, <code>false</code>.
|
|
514
|
+
*
|
|
515
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
516
|
+
*
|
|
517
|
+
* @see BillboardCollection#setDestroyTextureAtlas
|
|
518
|
+
*/
|
|
519
|
+
BillboardCollection.prototype.getDestroyTextureAtlas = function() {
|
|
520
|
+
return this._destroyTextureAtlas;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Determines if the texture atlas is destroyed when the collection is destroyed. If the texture
|
|
525
|
+
* atlas is used by more than one collection, set this to <code>false</code>, and explicitly
|
|
526
|
+
* destroy the atlas to avoid attempting to destroy it multiple times.
|
|
527
|
+
*
|
|
528
|
+
* @memberof BillboardCollection
|
|
529
|
+
*
|
|
530
|
+
* @param {Boolean} value Indicates if the texture atlas is destroyed when the collection is destroyed.
|
|
531
|
+
*
|
|
532
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
533
|
+
*
|
|
534
|
+
* @see BillboardCollection#getDestroyTextureAtlas
|
|
535
|
+
* @see BillboardCollection#setTextureAtlas
|
|
536
|
+
* @see BillboardCollection#destroy
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* // Destroy a billboard collection but not its texture atlas.
|
|
540
|
+
*
|
|
541
|
+
* var atlas = context.createTextureAtlas({images : images});
|
|
542
|
+
* billboards.setTextureAtlas(atlas);
|
|
543
|
+
* billboards.setDestroyTextureAtlas(false);
|
|
544
|
+
* billboards = billboards.destroy();
|
|
545
|
+
* console.log(atlas.isDestroyed()); // False
|
|
546
|
+
*/
|
|
547
|
+
BillboardCollection.prototype.setDestroyTextureAtlas = function(value) {
|
|
548
|
+
this._destroyTextureAtlas = value;
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
function getDirectionsVertexBuffer(context) {
|
|
552
|
+
var sixteenK = 16 * 1024;
|
|
553
|
+
|
|
554
|
+
// Per-context cache for billboard collections
|
|
555
|
+
context._primitivesCache = context._primitivesCache || {};
|
|
556
|
+
var primitivesCache = context._primitivesCache;
|
|
557
|
+
primitivesCache._billboardCollection = primitivesCache._billboardCollection || {};
|
|
558
|
+
var c = primitivesCache._billboardCollection;
|
|
559
|
+
|
|
560
|
+
if (c.directionsVertexBuffer) {
|
|
561
|
+
return c.directionsVertexBuffer;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
c.directionsVertexBuffer = c.directionsVertexBuffer && c.directionsVertexBuffer.destroy();
|
|
565
|
+
|
|
566
|
+
var directions = new Uint8Array(sixteenK * 4 * 2);
|
|
567
|
+
for (var i = 0, j = 0; i < sixteenK; ++i) {
|
|
568
|
+
directions[j++] = 0;
|
|
569
|
+
directions[j++] = 0;
|
|
570
|
+
|
|
571
|
+
directions[j++] = 255;
|
|
572
|
+
directions[j++] = 0.0;
|
|
573
|
+
|
|
574
|
+
directions[j++] = 255;
|
|
575
|
+
directions[j++] = 255;
|
|
576
|
+
|
|
577
|
+
directions[j++] = 0.0;
|
|
578
|
+
directions[j++] = 255;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// PERFORMANCE_IDEA: Should we reference count billboard collections, and eventually delete this?
|
|
582
|
+
// Is this too much memory to allocate up front? Should we dynamically grow it?
|
|
583
|
+
c.directionsVertexBuffer = context.createVertexBuffer(directions, BufferUsage.STATIC_DRAW);
|
|
584
|
+
c.directionsVertexBuffer.setVertexArrayDestroyable(false);
|
|
585
|
+
return c.directionsVertexBuffer;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function getIndexBuffer(context) {
|
|
589
|
+
var sixteenK = 16 * 1024;
|
|
590
|
+
|
|
591
|
+
// Per-context cache for billboard collections
|
|
592
|
+
context._primitivesCache = context._primitivesCache || {};
|
|
593
|
+
var primitivesCache = context._primitivesCache;
|
|
594
|
+
primitivesCache._billboardCollection = primitivesCache._billboardCollection || {};
|
|
595
|
+
var c = primitivesCache._billboardCollection;
|
|
596
|
+
|
|
597
|
+
if (c.indexBuffer) {
|
|
598
|
+
return c.indexBuffer;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
var length = sixteenK * 6;
|
|
602
|
+
var indices = new Uint16Array(length);
|
|
603
|
+
for (var i = 0, j = 0; i < length; i += 6, j += 4) {
|
|
604
|
+
indices[i + 0] = j + 0;
|
|
605
|
+
indices[i + 1] = j + 1;
|
|
606
|
+
indices[i + 2] = j + 2;
|
|
607
|
+
|
|
608
|
+
indices[i + 3] = j + 0;
|
|
609
|
+
indices[i + 4] = j + 2;
|
|
610
|
+
indices[i + 5] = j + 3;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// PERFORMANCE_IDEA: Should we reference count billboard collections, and eventually delete this?
|
|
614
|
+
// Is this too much memory to allocate up front? Should we dynamically grow it?
|
|
615
|
+
c.indexBuffer = context.createIndexBuffer(indices, BufferUsage.STATIC_DRAW, IndexDatatype.UNSIGNED_SHORT);
|
|
616
|
+
c.indexBuffer.setVertexArrayDestroyable(false);
|
|
617
|
+
return c.indexBuffer;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
BillboardCollection.prototype.computeNewBuffersUsage = function() {
|
|
621
|
+
var buffersUsage = this._buffersUsage;
|
|
622
|
+
var usageChanged = false;
|
|
623
|
+
|
|
624
|
+
// PERFORMANCE_IDEA: Better heuristic to avoid ping-ponging. What about DYNAMIC_STREAM?
|
|
625
|
+
var properties = this._propertiesChanged;
|
|
626
|
+
for ( var k = 0; k < NUMBER_OF_PROPERTIES; ++k) {
|
|
627
|
+
var newUsage = (properties[k] === 0) ? BufferUsage.STATIC_DRAW : BufferUsage.STREAM_DRAW;
|
|
628
|
+
usageChanged = usageChanged || (buffersUsage[k] !== newUsage);
|
|
629
|
+
buffersUsage[k] = newUsage;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
return usageChanged;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
function createVAF(context, numberOfBillboards, buffersUsage) {
|
|
636
|
+
// Different billboard collections share the same vertex buffer for directions.
|
|
637
|
+
var directionVertexBuffer = getDirectionsVertexBuffer(context);
|
|
638
|
+
|
|
639
|
+
return new VertexArrayFacade(context, [{
|
|
640
|
+
index : attributeIndices.positionHigh,
|
|
641
|
+
componentsPerAttribute : 3,
|
|
642
|
+
componentDatatype : ComponentDatatype.FLOAT,
|
|
643
|
+
usage : buffersUsage[POSITION_INDEX]
|
|
644
|
+
}, {
|
|
645
|
+
index : attributeIndices.positionLow,
|
|
646
|
+
componentsPerAttribute : 3,
|
|
647
|
+
componentDatatype : ComponentDatatype.FLOAT,
|
|
648
|
+
usage : buffersUsage[POSITION_INDEX]
|
|
649
|
+
}, {
|
|
650
|
+
index : attributeIndices.pixelOffset,
|
|
651
|
+
componentsPerAttribute : 2,
|
|
652
|
+
componentDatatype : ComponentDatatype.FLOAT,
|
|
653
|
+
usage : buffersUsage[PIXEL_OFFSET_INDEX]
|
|
654
|
+
}, {
|
|
655
|
+
index : attributeIndices.eyeOffsetAndScale,
|
|
656
|
+
componentsPerAttribute : 4,
|
|
657
|
+
componentDatatype : ComponentDatatype.FLOAT,
|
|
658
|
+
usage : buffersUsage[SCALE_INDEX] // buffersUsage[EYE_OFFSET_INDEX] ignored
|
|
659
|
+
}, {
|
|
660
|
+
index : attributeIndices.textureCoordinatesAndImageSize,
|
|
661
|
+
componentsPerAttribute : 4,
|
|
662
|
+
normalize : true,
|
|
663
|
+
componentDatatype : ComponentDatatype.UNSIGNED_SHORT,
|
|
664
|
+
usage : buffersUsage[IMAGE_INDEX_INDEX]
|
|
665
|
+
}, {
|
|
666
|
+
index : attributeIndices.pickColor,
|
|
667
|
+
componentsPerAttribute : 4,
|
|
668
|
+
normalize : true,
|
|
669
|
+
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
|
|
670
|
+
usage : BufferUsage.STATIC_DRAW,
|
|
671
|
+
purpose : pickPassPurpose
|
|
672
|
+
}, {
|
|
673
|
+
index : attributeIndices.color,
|
|
674
|
+
componentsPerAttribute : 4,
|
|
675
|
+
normalize : true,
|
|
676
|
+
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
|
|
677
|
+
usage : buffersUsage[COLOR_INDEX],
|
|
678
|
+
purpose : colorPassPurpose
|
|
679
|
+
}, {
|
|
680
|
+
index : attributeIndices.originAndShow,
|
|
681
|
+
componentsPerAttribute : 3,
|
|
682
|
+
componentDatatype : ComponentDatatype.BYTE,
|
|
683
|
+
usage : buffersUsage[SHOW_INDEX] // buffersUsage[HORIZONTAL_ORIGIN_INDEX] and buffersUsage[VERTICAL_ORIGIN_INDEX] ignored
|
|
684
|
+
}, {
|
|
685
|
+
index : attributeIndices.direction,
|
|
686
|
+
vertexBuffer : directionVertexBuffer,
|
|
687
|
+
componentsPerAttribute : 2,
|
|
688
|
+
normalize : true,
|
|
689
|
+
componentDatatype : ComponentDatatype.UNSIGNED_BYTE
|
|
690
|
+
}], 4 * numberOfBillboards); // 4 vertices per billboard
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
///////////////////////////////////////////////////////////////////////////
|
|
694
|
+
|
|
695
|
+
// Four vertices per billboard. Each has the same position, etc., but a different screen-space direction vector.
|
|
696
|
+
|
|
697
|
+
// PERFORMANCE_IDEA: Save memory if a property is the same for all billboards, use a latched attribute state,
|
|
698
|
+
// instead of storing it in a vertex buffer.
|
|
699
|
+
|
|
700
|
+
var writePositionScratch = new EncodedCartesian3();
|
|
701
|
+
|
|
702
|
+
function writePosition(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
703
|
+
var i = (billboard._index * 4);
|
|
704
|
+
var position = billboard._getActualPosition();
|
|
705
|
+
|
|
706
|
+
if (billboardCollection._mode === SceneMode.SCENE3D) {
|
|
707
|
+
billboardCollection._baseVolume.expand(position, billboardCollection._baseVolume);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
EncodedCartesian3.fromCartesian(position, writePositionScratch);
|
|
711
|
+
|
|
712
|
+
var allPurposeWriters = vafWriters[allPassPurpose];
|
|
713
|
+
var positionHighWriter = allPurposeWriters[attributeIndices.positionHigh];
|
|
714
|
+
var high = writePositionScratch.high;
|
|
715
|
+
positionHighWriter(i + 0, high.x, high.y, high.z);
|
|
716
|
+
positionHighWriter(i + 1, high.x, high.y, high.z);
|
|
717
|
+
positionHighWriter(i + 2, high.x, high.y, high.z);
|
|
718
|
+
positionHighWriter(i + 3, high.x, high.y, high.z);
|
|
719
|
+
|
|
720
|
+
var positionLowWriter = allPurposeWriters[attributeIndices.positionLow];
|
|
721
|
+
var low = writePositionScratch.low;
|
|
722
|
+
positionLowWriter(i + 0, low.x, low.y, low.z);
|
|
723
|
+
positionLowWriter(i + 1, low.x, low.y, low.z);
|
|
724
|
+
positionLowWriter(i + 2, low.x, low.y, low.z);
|
|
725
|
+
positionLowWriter(i + 3, low.x, low.y, low.z);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function writePixelOffset(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
729
|
+
var i = (billboard._index * 4);
|
|
730
|
+
var pixelOffset = billboard.getPixelOffset();
|
|
731
|
+
billboardCollection._maxPixelOffset = Math.max(billboardCollection._maxPixelOffset, pixelOffset.x, pixelOffset.y);
|
|
732
|
+
|
|
733
|
+
var allPurposeWriters = vafWriters[allPassPurpose];
|
|
734
|
+
var writer = allPurposeWriters[attributeIndices.pixelOffset];
|
|
735
|
+
writer(i + 0, pixelOffset.x, pixelOffset.y);
|
|
736
|
+
writer(i + 1, pixelOffset.x, pixelOffset.y);
|
|
737
|
+
writer(i + 2, pixelOffset.x, pixelOffset.y);
|
|
738
|
+
writer(i + 3, pixelOffset.x, pixelOffset.y);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function writeEyeOffsetAndScale(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
742
|
+
var i = (billboard._index * 4);
|
|
743
|
+
var eyeOffset = billboard.getEyeOffset();
|
|
744
|
+
var scale = billboard.getScale();
|
|
745
|
+
billboardCollection._maxEyeOffset = Math.max(billboardCollection._maxEyeOffset, Math.abs(eyeOffset.x), Math.abs(eyeOffset.y), Math.abs(eyeOffset.z));
|
|
746
|
+
billboardCollection._maxScale = Math.max(billboardCollection._maxScale, scale);
|
|
747
|
+
|
|
748
|
+
var allPurposeWriters = vafWriters[allPassPurpose];
|
|
749
|
+
var writer = allPurposeWriters[attributeIndices.eyeOffsetAndScale];
|
|
750
|
+
writer(i + 0, eyeOffset.x, eyeOffset.y, eyeOffset.z, scale);
|
|
751
|
+
writer(i + 1, eyeOffset.x, eyeOffset.y, eyeOffset.z, scale);
|
|
752
|
+
writer(i + 2, eyeOffset.x, eyeOffset.y, eyeOffset.z, scale);
|
|
753
|
+
writer(i + 3, eyeOffset.x, eyeOffset.y, eyeOffset.z, scale);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
function writePickColor(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
757
|
+
var i = (billboard._index * 4);
|
|
758
|
+
var pickColor = billboard.getPickId(context).unnormalizedRgb;
|
|
759
|
+
|
|
760
|
+
var pickWriters = vafWriters[pickPassPurpose];
|
|
761
|
+
var writer = pickWriters[attributeIndices.pickColor];
|
|
762
|
+
writer(i + 0, pickColor.red, pickColor.green, pickColor.blue, 255);
|
|
763
|
+
writer(i + 1, pickColor.red, pickColor.green, pickColor.blue, 255);
|
|
764
|
+
writer(i + 2, pickColor.red, pickColor.green, pickColor.blue, 255);
|
|
765
|
+
writer(i + 3, pickColor.red, pickColor.green, pickColor.blue, 255);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function writeColor(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
769
|
+
var i = (billboard._index * 4);
|
|
770
|
+
var color = billboard.getColor();
|
|
771
|
+
|
|
772
|
+
var colorWriters = vafWriters[colorPassPurpose];
|
|
773
|
+
var writer = colorWriters[attributeIndices.color];
|
|
774
|
+
writer(i + 0, color.red * 255, color.green * 255, color.blue * 255, color.alpha * 255);
|
|
775
|
+
writer(i + 1, color.red * 255, color.green * 255, color.blue * 255, color.alpha * 255);
|
|
776
|
+
writer(i + 2, color.red * 255, color.green * 255, color.blue * 255, color.alpha * 255);
|
|
777
|
+
writer(i + 3, color.red * 255, color.green * 255, color.blue * 255, color.alpha * 255);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function writeOriginAndShow(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
781
|
+
var i = (billboard._index * 4);
|
|
782
|
+
var horizontalOrigin = billboard.getHorizontalOrigin().value;
|
|
783
|
+
var verticalOrigin = billboard.getVerticalOrigin().value;
|
|
784
|
+
var show = billboard.getShow();
|
|
785
|
+
|
|
786
|
+
// If the color alpha is zero, do not show this billboard. This lets us avoid providing
|
|
787
|
+
// color during the pick pass and also eliminates a discard in the fragment shader.
|
|
788
|
+
if (billboard.getColor().alpha === 0.0) {
|
|
789
|
+
show = false;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
billboardCollection._allHorizontalCenter = billboardCollection._allHorizontalCenter && horizontalOrigin === HorizontalOrigin.CENTER.value;
|
|
793
|
+
|
|
794
|
+
var allPurposeWriters = vafWriters[allPassPurpose];
|
|
795
|
+
var writer = allPurposeWriters[attributeIndices.originAndShow];
|
|
796
|
+
writer(i + 0, horizontalOrigin, verticalOrigin, show);
|
|
797
|
+
writer(i + 1, horizontalOrigin, verticalOrigin, show);
|
|
798
|
+
writer(i + 2, horizontalOrigin, verticalOrigin, show);
|
|
799
|
+
writer(i + 3, horizontalOrigin, verticalOrigin, show);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function writeTextureCoordinatesAndImageSize(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
803
|
+
var i = (billboard._index * 4);
|
|
804
|
+
var bottomLeftX = 0;
|
|
805
|
+
var bottomLeftY = 0;
|
|
806
|
+
var width = 0;
|
|
807
|
+
var height = 0;
|
|
808
|
+
var index = billboard.getImageIndex();
|
|
809
|
+
if (index !== -1) {
|
|
810
|
+
var imageRectangle = textureAtlasCoordinates[index];
|
|
811
|
+
if (typeof imageRectangle === 'undefined') {
|
|
812
|
+
throw new DeveloperError('Invalid billboard image index: ' + index);
|
|
813
|
+
}
|
|
814
|
+
bottomLeftX = imageRectangle.x;
|
|
815
|
+
bottomLeftY = imageRectangle.y;
|
|
816
|
+
width = imageRectangle.width;
|
|
817
|
+
height = imageRectangle.height;
|
|
818
|
+
}
|
|
819
|
+
var topRightX = bottomLeftX + width;
|
|
820
|
+
var topRightY = bottomLeftY + height;
|
|
821
|
+
|
|
822
|
+
billboardCollection._maxSize = Math.max(billboardCollection._maxSize, width, height);
|
|
823
|
+
|
|
824
|
+
var allPurposeWriters = vafWriters[allPassPurpose];
|
|
825
|
+
var writer = allPurposeWriters[attributeIndices.textureCoordinatesAndImageSize];
|
|
826
|
+
writer(i + 0, bottomLeftX * 65535, bottomLeftY * 65535, width * 65535, height * 65535); // Lower Left
|
|
827
|
+
writer(i + 1, topRightX * 65535, bottomLeftY * 65535, width * 65535, height * 65535); // Lower Right
|
|
828
|
+
writer(i + 2, topRightX * 65535, topRightY * 65535, width * 65535, height * 65535); // Upper Right
|
|
829
|
+
writer(i + 3, bottomLeftX * 65535, topRightY * 65535, width * 65535, height * 65535); // Upper Left
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function writeBillboard(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard) {
|
|
833
|
+
writePosition(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
834
|
+
writePixelOffset(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
835
|
+
writeEyeOffsetAndScale(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
836
|
+
writePickColor(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
837
|
+
writeColor(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
838
|
+
writeOriginAndShow(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
839
|
+
writeTextureCoordinatesAndImageSize(billboardCollection, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function recomputeActualPositions(billboardCollection, billboards, frameState, morphTime, modelMatrix, recomputeBoundingVolume) {
|
|
843
|
+
var boundingVolume;
|
|
844
|
+
if (frameState.mode === SceneMode.SCENE3D) {
|
|
845
|
+
boundingVolume = billboardCollection._baseVolume;
|
|
846
|
+
} else {
|
|
847
|
+
boundingVolume = billboardCollection._baseVolume2D;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
var length = billboards.length;
|
|
851
|
+
var positions = [];
|
|
852
|
+
for ( var i = 0; i < length; ++i) {
|
|
853
|
+
var billboard = billboards[i];
|
|
854
|
+
var position = billboard.getPosition();
|
|
855
|
+
var actualPosition = Billboard._computeActualPosition(position, frameState, morphTime, modelMatrix);
|
|
856
|
+
if (typeof actualPosition !== 'undefined') {
|
|
857
|
+
billboard._setActualPosition(actualPosition);
|
|
858
|
+
|
|
859
|
+
if (recomputeBoundingVolume) {
|
|
860
|
+
positions.push(actualPosition);
|
|
861
|
+
} else {
|
|
862
|
+
boundingVolume.expand(actualPosition, boundingVolume);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (recomputeBoundingVolume) {
|
|
868
|
+
BoundingSphere.fromPoints(positions, boundingVolume);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function updateMode(billboardCollection, frameState) {
|
|
873
|
+
var mode = frameState.mode;
|
|
874
|
+
var projection = frameState.scene2D.projection;
|
|
875
|
+
|
|
876
|
+
var billboards = billboardCollection._billboards;
|
|
877
|
+
var billboardsToUpdate = billboardCollection._billboardsToUpdate;
|
|
878
|
+
var morphTime = billboardCollection.morphTime;
|
|
879
|
+
var modelMatrix = billboardCollection._modelMatrix;
|
|
880
|
+
|
|
881
|
+
if (billboardCollection._mode !== mode ||
|
|
882
|
+
billboardCollection._projection !== projection ||
|
|
883
|
+
mode !== SceneMode.SCENE3D &&
|
|
884
|
+
!modelMatrix.equals(billboardCollection.modelMatrix)) {
|
|
885
|
+
|
|
886
|
+
billboardCollection._mode = mode;
|
|
887
|
+
billboardCollection._projection = projection;
|
|
888
|
+
billboardCollection.modelMatrix.clone(modelMatrix);
|
|
889
|
+
billboardCollection._createVertexArray = true;
|
|
890
|
+
|
|
891
|
+
if (mode === SceneMode.SCENE3D || mode === SceneMode.SCENE2D || mode === SceneMode.COLUMBUS_VIEW) {
|
|
892
|
+
recomputeActualPositions(billboardCollection, billboards, frameState, morphTime, modelMatrix, true);
|
|
893
|
+
}
|
|
894
|
+
} else if (mode === SceneMode.MORPHING) {
|
|
895
|
+
recomputeActualPositions(billboardCollection, billboards, frameState, morphTime, modelMatrix, true);
|
|
896
|
+
} else if (mode === SceneMode.SCENE2D || mode === SceneMode.COLUMBUS_VIEW) {
|
|
897
|
+
recomputeActualPositions(billboardCollection, billboardsToUpdate, frameState, morphTime, modelMatrix, false);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
var scratchCanvasDimensions = new Cartesian2();
|
|
902
|
+
var scratchToCenter = new Cartesian3();
|
|
903
|
+
var scratchProj = new Cartesian3();
|
|
904
|
+
function updateBoundingVolume(collection, context, frameState, boundingVolume) {
|
|
905
|
+
var camera = frameState.camera;
|
|
906
|
+
var frustum = camera.frustum;
|
|
907
|
+
|
|
908
|
+
var textureDimensions = collection._textureAtlas.getTexture().getDimensions();
|
|
909
|
+
var textureSize = Math.max(textureDimensions.x, textureDimensions.y);
|
|
910
|
+
|
|
911
|
+
var pixelScale;
|
|
912
|
+
var size;
|
|
913
|
+
var offset;
|
|
914
|
+
|
|
915
|
+
var toCenter = camera.getPositionWC().subtract(boundingVolume.center, scratchToCenter);
|
|
916
|
+
var proj = camera.getDirectionWC().multiplyByScalar(toCenter.dot(camera.getDirectionWC()), scratchProj);
|
|
917
|
+
var distance = Math.max(0.0, proj.magnitude() - boundingVolume.radius);
|
|
918
|
+
|
|
919
|
+
var canvas = context.getCanvas();
|
|
920
|
+
scratchCanvasDimensions.x = canvas.clientWidth;
|
|
921
|
+
scratchCanvasDimensions.y = canvas.clientHeight;
|
|
922
|
+
var pixelSize = frustum.getPixelSize(scratchCanvasDimensions, distance);
|
|
923
|
+
pixelScale = Math.max(pixelSize.x, pixelSize.y);
|
|
924
|
+
|
|
925
|
+
size = pixelScale * collection._maxScale * collection._maxSize * textureSize;
|
|
926
|
+
if (collection._allHorizontalCenter) {
|
|
927
|
+
size *= 0.5;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
offset = pixelScale * collection._maxPixelOffset + collection._maxEyeOffset;
|
|
931
|
+
boundingVolume.radius += size + offset;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* @private
|
|
936
|
+
*/
|
|
937
|
+
BillboardCollection.prototype.update = function(context, frameState, commandList) {
|
|
938
|
+
var textureAtlas = this._textureAtlas;
|
|
939
|
+
if (typeof textureAtlas === 'undefined') {
|
|
940
|
+
// Can't write billboard vertices until we have texture coordinates
|
|
941
|
+
// provided by a texture atlas
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
var textureAtlasCoordinates = textureAtlas.getTextureCoordinates();
|
|
946
|
+
if (textureAtlasCoordinates.length === 0) {
|
|
947
|
+
// Can't write billboard vertices until we have texture coordinates
|
|
948
|
+
// provided by a texture atlas
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
removeBillboards(this);
|
|
953
|
+
updateMode(this, frameState);
|
|
954
|
+
|
|
955
|
+
var billboards = this._billboards;
|
|
956
|
+
var length = billboards.length;
|
|
957
|
+
var properties = this._propertiesChanged;
|
|
958
|
+
|
|
959
|
+
var textureAtlasGUID = textureAtlas.getGUID();
|
|
960
|
+
var createVertexArray = this._createVertexArray || this._textureAtlasGUID !== textureAtlasGUID;
|
|
961
|
+
this._textureAtlasGUID = textureAtlasGUID;
|
|
962
|
+
|
|
963
|
+
var vafWriters;
|
|
964
|
+
|
|
965
|
+
// PERFORMANCE_IDEA: Round robin multiple buffers.
|
|
966
|
+
if (createVertexArray || this.computeNewBuffersUsage()) {
|
|
967
|
+
this._createVertexArray = false;
|
|
968
|
+
|
|
969
|
+
this._vaf = this._vaf && this._vaf.destroy();
|
|
970
|
+
|
|
971
|
+
if (length > 0) {
|
|
972
|
+
// PERFORMANCE_IDEA: Instead of creating a new one, resize like std::vector.
|
|
973
|
+
this._vaf = createVAF(context, billboards.length, this._buffersUsage);
|
|
974
|
+
vafWriters = this._vaf.writers;
|
|
975
|
+
|
|
976
|
+
// Rewrite entire buffer if billboards were added or removed.
|
|
977
|
+
for (var i = 0; i < length; ++i) {
|
|
978
|
+
var billboard = this._billboards[i];
|
|
979
|
+
billboard._dirty = false; // In case it needed an update.
|
|
980
|
+
writeBillboard(this, context, textureAtlasCoordinates, vafWriters, billboard);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Different billboard collections share the same index buffer.
|
|
984
|
+
this._vaf.commit(getIndexBuffer(context));
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
this._billboardsToUpdate = [];
|
|
988
|
+
} else {
|
|
989
|
+
// Billboards were modified, but none were added or removed.
|
|
990
|
+
|
|
991
|
+
var billboardsToUpdate = this._billboardsToUpdate;
|
|
992
|
+
var updateLength = billboardsToUpdate.length;
|
|
993
|
+
|
|
994
|
+
if (updateLength) {
|
|
995
|
+
var writers = [];
|
|
996
|
+
|
|
997
|
+
if (properties[POSITION_INDEX]) {
|
|
998
|
+
writers.push(writePosition);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
if (properties[PIXEL_OFFSET_INDEX]) {
|
|
1002
|
+
writers.push(writePixelOffset);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
if (properties[EYE_OFFSET_INDEX] || properties[SCALE_INDEX]) {
|
|
1006
|
+
writers.push(writeEyeOffsetAndScale);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
if (properties[IMAGE_INDEX_INDEX]) {
|
|
1010
|
+
writers.push(writeTextureCoordinatesAndImageSize);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if (properties[COLOR_INDEX]) {
|
|
1014
|
+
writers.push(writeColor);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (properties[HORIZONTAL_ORIGIN_INDEX] || properties[VERTICAL_ORIGIN_INDEX] || properties[SHOW_INDEX]) {
|
|
1018
|
+
writers.push(writeOriginAndShow);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
vafWriters = this._vaf.writers;
|
|
1022
|
+
|
|
1023
|
+
if ((updateLength / length) > 0.1) {
|
|
1024
|
+
// If more than 10% of billboard change, rewrite the entire buffer.
|
|
1025
|
+
|
|
1026
|
+
// PERFORMANCE_IDEA: I totally made up 10% :).
|
|
1027
|
+
|
|
1028
|
+
for (var m = 0; m < updateLength; ++m) {
|
|
1029
|
+
var b = billboardsToUpdate[m];
|
|
1030
|
+
b._dirty = false;
|
|
1031
|
+
|
|
1032
|
+
for ( var n = 0; n < writers.length; ++n) {
|
|
1033
|
+
writers[n](this, context, textureAtlasCoordinates, vafWriters, b);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
this._vaf.commit(getIndexBuffer(context));
|
|
1037
|
+
} else {
|
|
1038
|
+
for (var h = 0; h < updateLength; ++h) {
|
|
1039
|
+
var bb = billboardsToUpdate[h];
|
|
1040
|
+
bb._dirty = false;
|
|
1041
|
+
|
|
1042
|
+
for ( var o = 0; o < writers.length; ++o) {
|
|
1043
|
+
writers[o](this, context, textureAtlasCoordinates, vafWriters, bb);
|
|
1044
|
+
}
|
|
1045
|
+
this._vaf.subCommit(bb._index * 4, 4);
|
|
1046
|
+
}
|
|
1047
|
+
this._vaf.endSubCommits();
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
this._billboardsToUpdate = [];
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
for (var k = 0; k < NUMBER_OF_PROPERTIES; ++k) {
|
|
1055
|
+
properties[k] = 0;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if (typeof this._vaf === 'undefined' || typeof this._vaf.vaByPurpose === 'undefined') {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
var boundingVolume;
|
|
1063
|
+
var modelMatrix = Matrix4.IDENTITY;
|
|
1064
|
+
if (frameState.mode === SceneMode.SCENE3D) {
|
|
1065
|
+
modelMatrix = this.modelMatrix;
|
|
1066
|
+
boundingVolume = BoundingSphere.clone(this._baseVolume, this._boundingVolume);
|
|
1067
|
+
} else if (typeof this._baseVolume2D !== 'undefined') {
|
|
1068
|
+
boundingVolume = BoundingSphere.clone(this._baseVolume2D, this._boundingVolume);
|
|
1069
|
+
}
|
|
1070
|
+
updateBoundingVolume(this, context, frameState, boundingVolume);
|
|
1071
|
+
|
|
1072
|
+
var pass = frameState.passes;
|
|
1073
|
+
var va;
|
|
1074
|
+
var vaLength;
|
|
1075
|
+
var commands;
|
|
1076
|
+
var command;
|
|
1077
|
+
var j;
|
|
1078
|
+
this._commandLists.removeAll();
|
|
1079
|
+
if (pass.color) {
|
|
1080
|
+
if (typeof this._sp === 'undefined') {
|
|
1081
|
+
this._rs = context.createRenderState({
|
|
1082
|
+
depthTest : {
|
|
1083
|
+
enabled : true
|
|
1084
|
+
},
|
|
1085
|
+
blending : BlendingState.ALPHA_BLEND
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
this._sp = context.getShaderCache().getShaderProgram(BillboardCollectionVS, BillboardCollectionFS, attributeIndices);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
va = this._vaf.vaByPurpose[colorPassPurpose];
|
|
1092
|
+
vaLength = va.length;
|
|
1093
|
+
|
|
1094
|
+
commands = this._commandLists.colorList;
|
|
1095
|
+
commands.length = vaLength;
|
|
1096
|
+
for (j = 0; j < vaLength; ++j) {
|
|
1097
|
+
command = commands[j];
|
|
1098
|
+
if (typeof command === 'undefined') {
|
|
1099
|
+
command = commands[j] = new DrawCommand();
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
command.boundingVolume = boundingVolume;
|
|
1103
|
+
command.modelMatrix = modelMatrix;
|
|
1104
|
+
command.primitiveType = PrimitiveType.TRIANGLES;
|
|
1105
|
+
command.count = va[j].indicesCount;
|
|
1106
|
+
command.shaderProgram = this._sp;
|
|
1107
|
+
command.uniformMap = this._uniforms;
|
|
1108
|
+
command.vertexArray = va[j].va;
|
|
1109
|
+
command.renderState = this._rs;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (pass.pick) {
|
|
1113
|
+
if (typeof this._spPick === 'undefined') {
|
|
1114
|
+
this._rsPick = context.createRenderState({
|
|
1115
|
+
depthTest : {
|
|
1116
|
+
enabled : true
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
this._spPick = context.getShaderCache().getShaderProgram(
|
|
1121
|
+
'#define RENDER_FOR_PICK 1\n' + BillboardCollectionVS,
|
|
1122
|
+
'#define RENDER_FOR_PICK 1\n' + BillboardCollectionFS,
|
|
1123
|
+
attributeIndices);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
va = this._vaf.vaByPurpose[pickPassPurpose];
|
|
1127
|
+
vaLength = va.length;
|
|
1128
|
+
|
|
1129
|
+
commands = this._commandLists.pickList;
|
|
1130
|
+
commands.length = vaLength;
|
|
1131
|
+
for (j = 0; j < vaLength; ++j) {
|
|
1132
|
+
command = commands[j];
|
|
1133
|
+
if (typeof command === 'undefined') {
|
|
1134
|
+
command = commands[j] = new DrawCommand();
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
command.boundingVolume = boundingVolume;
|
|
1138
|
+
command.modelMatrix = modelMatrix;
|
|
1139
|
+
command.primitiveType = PrimitiveType.TRIANGLES;
|
|
1140
|
+
command.count = va[j].indicesCount;
|
|
1141
|
+
command.shaderProgram = this._spPick;
|
|
1142
|
+
command.uniformMap = this._uniforms;
|
|
1143
|
+
command.vertexArray = va[j].va;
|
|
1144
|
+
command.renderState = this._rsPick;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
if (!this._commandLists.empty()) {
|
|
1149
|
+
commandList.push(this._commandLists);
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Returns true if this object was destroyed; otherwise, false.
|
|
1155
|
+
* <br /><br />
|
|
1156
|
+
* If this object was destroyed, it should not be used; calling any function other than
|
|
1157
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
|
|
1158
|
+
*
|
|
1159
|
+
* @memberof BillboardCollection
|
|
1160
|
+
*
|
|
1161
|
+
* @return {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
|
|
1162
|
+
*
|
|
1163
|
+
* @see BillboardCollection#destroy
|
|
1164
|
+
*/
|
|
1165
|
+
BillboardCollection.prototype.isDestroyed = function() {
|
|
1166
|
+
return false;
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
|
|
1171
|
+
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
|
|
1172
|
+
* <br /><br />
|
|
1173
|
+
* Once an object is destroyed, it should not be used; calling any function other than
|
|
1174
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
|
|
1175
|
+
* assign the return value (<code>undefined</code>) to the object as done in the example.
|
|
1176
|
+
*
|
|
1177
|
+
* @memberof BillboardCollection
|
|
1178
|
+
*
|
|
1179
|
+
* @return {undefined}
|
|
1180
|
+
*
|
|
1181
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
1182
|
+
*
|
|
1183
|
+
* @see BillboardCollection#isDestroyed
|
|
1184
|
+
*
|
|
1185
|
+
* @example
|
|
1186
|
+
* billboards = billboards && billboards.destroy();
|
|
1187
|
+
*/
|
|
1188
|
+
BillboardCollection.prototype.destroy = function() {
|
|
1189
|
+
this._textureAtlas = this._destroyTextureAtlas && this._textureAtlas && this._textureAtlas.destroy();
|
|
1190
|
+
this._sp = this._sp && this._sp.release();
|
|
1191
|
+
this._spPick = this._spPick && this._spPick.release();
|
|
1192
|
+
this._vaf = this._vaf && this._vaf.destroy();
|
|
1193
|
+
this._destroyBillboards();
|
|
1194
|
+
|
|
1195
|
+
return destroyObject(this);
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
BillboardCollection.prototype._destroyBillboards = function() {
|
|
1199
|
+
var billboards = this._billboards;
|
|
1200
|
+
var length = billboards.length;
|
|
1201
|
+
for (var i = 0; i < length; ++i) {
|
|
1202
|
+
if (billboards[i]) {
|
|
1203
|
+
billboards[i]._destroy();
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
return BillboardCollection;
|
|
1209
|
+
});
|