Skip to content

Commit

Permalink
Merge pull request #8941 from CesiumGS/ts-geometry
Browse files Browse the repository at this point in the history
Fix geometry creation in TypeScript
  • Loading branch information
kring authored Jun 10, 2020
2 parents 15e99b0 + a6d0a2c commit dce2bef
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Fixed JSDoc and TypeScript type definitions for `EllipsoidTangentPlane.fromPoints`, which takes an array of `Cartesian3`, not a single instance. [#8928](https://github.com/CesiumGS/cesium/pull/8928)
- Fixed JSDoc and TypeScript type definitions for `EntityCollection.getById` and `CompositeEntityCollection.getById`, which can both return undefined. [#8928](https://github.com/CesiumGS/cesium/pull/8928)
- Fixed JSDoc and TypeScript type definitions for `Viewer` options parameter, which was incorrectly listed as required.
- Fixed TypeScript type definitions to allow the creation of `GeometryInstance` instances using `XXXGeometry` classes. [#8941](https://github.com/CesiumGS/cesium/pull/8941).
- Fixed a memory leak where some 3D Tiles requests were being unintentionally retained after the requests were cancelled. [#8843](https://github.com/CesiumGS/cesium/pull/8843)

### 1.70.0 - 2020-06-01
Expand Down
25 changes: 25 additions & 0 deletions Source/Core/GeometryFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import DeveloperError from "../Core/DeveloperError.js";

/**
* Base class for all geometry creation utility classes that can be passed to {@link GeometryInstance}
* for asynchronous geometry creation.
*
* @constructor
* @class
* @abstract
*/
function GeometryFactory() {
DeveloperError.throwInstantiationError();
}

/**
* Returns a geometry.
*
* @param {GeometryFactory} geometryFactory A description of the circle.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
GeometryFactory.createGeometry = function (geometryFactory) {
DeveloperError.throwInstantiationError();
};

export default GeometryFactory;
2 changes: 1 addition & 1 deletion Source/Core/GeometryInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Matrix4 from "./Matrix4.js";
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Geometry} options.geometry The geometry to instance.
* @param {Geometry|GeometryFactory} options.geometry The geometry to instance.
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The model matrix that transforms to transform the geometry from model to world coordinates.
* @param {Object} [options.id] A user-defined object to return when the instance is picked with {@link Scene#pick} or get/set per-instance attributes with {@link Primitive#getGeometryInstanceAttributes}.
* @param {Object} [options.attributes] Per-instance attributes like a show or color attribute shown in the example below.
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/PlaneGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import VertexFormat from "./VertexFormat.js";
* @alias PlaneGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Object} [options] Object with the following properties:
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/SimplePolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var generateArcOptionsScratch = {
* Computes the geometric representation of a simple polyline, including its vertices, indices, and a bounding sphere.
*
* @param {SimplePolylineGeometry} simplePolylineGeometry A description of the polyline.
* @returns {Geometry} The computed vertices and indices.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
SimplePolylineGeometry.createGeometry = function (simplePolylineGeometry) {
var positions = simplePolylineGeometry._positions;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/SphereGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ SphereGeometry.unpack = function (array, startingIndex, result) {
* Computes the geometric representation of a sphere, including its vertices, indices, and a bounding sphere.
*
* @param {SphereGeometry} sphereGeometry A description of the sphere.
* @returns {Geometry} The computed vertices and indices.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
SphereGeometry.createGeometry = function (sphereGeometry) {
return EllipsoidGeometry.createGeometry(sphereGeometry._ellipsoidGeometry);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/SphereOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ SphereOutlineGeometry.unpack = function (array, startingIndex, result) {
* Computes the geometric representation of an outline of a sphere, including its vertices, indices, and a bounding sphere.
*
* @param {SphereOutlineGeometry} sphereGeometry A description of the sphere outline.
* @returns {Geometry} The computed vertices and indices.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
SphereOutlineGeometry.createGeometry = function (sphereGeometry) {
return EllipsoidOutlineGeometry.createGeometry(
Expand Down
Loading

0 comments on commit dce2bef

Please sign in to comment.