figureone 0.15.10 → 1.0.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.
- package/figureone.min.js +1 -1
- package/index.js +79167 -0
- package/package.json +15 -1
- package/types/index.d.ts +132 -0
- package/types/js/figure/Animation/Animation.d.ts +36 -0
- package/types/js/figure/Animation/AnimationBuilder.d.ts +173 -0
- package/types/js/figure/Animation/AnimationManager.d.ts +392 -0
- package/types/js/figure/Animation/AnimationStep/CustomStep.d.ts +99 -0
- package/types/js/figure/Animation/AnimationStep/DelayStep.d.ts +24 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ColorAnimationStep.d.ts +203 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/OpacityAnimationStep.d.ts +220 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PositionAnimationStep.d.ts +124 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseAnimationStep.d.ts +137 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/PulseTransformAnimationStep.d.ts +52 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/RotationAnimationStep.d.ts +119 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScaleAnimationStep.d.ts +93 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/ScenarioAnimationStep.d.ts +204 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep/TransformAnimationStep.d.ts +163 -0
- package/types/js/figure/Animation/AnimationStep/ElementAnimationStep.d.ts +56 -0
- package/types/js/figure/Animation/AnimationStep/ParallelAnimationStep.d.ts +70 -0
- package/types/js/figure/Animation/AnimationStep/SerialAnimationStep.d.ts +84 -0
- package/types/js/figure/Animation/AnimationStep/TriggerStep.d.ts +106 -0
- package/types/js/figure/Animation/AnimationStep.d.ts +110 -0
- package/types/js/figure/DrawContext2D.d.ts +9 -0
- package/types/js/figure/DrawingObjects/DrawingObject.d.ts +45 -0
- package/types/js/figure/DrawingObjects/GLObject/GLObject.d.ts +146 -0
- package/types/js/figure/DrawingObjects/HTMLObject/HTMLObject.d.ts +29 -0
- package/types/js/figure/DrawingObjects/TextObject/TextObject.d.ts +94 -0
- package/types/js/figure/DrawingObjects/TextObject/glyphMeasures.d.ts +7 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexGeneric.d.ts +21 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexObject.d.ts +0 -0
- package/types/js/figure/DrawingObjects/VertexObject/VertexText.d.ts +34 -0
- package/types/js/figure/Element.d.ts +1212 -0
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +118 -0
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +20 -0
- package/types/js/figure/Equation/Elements/Bounds.d.ts +49 -0
- package/types/js/figure/Equation/Elements/Color.d.ts +7 -0
- package/types/js/figure/Equation/Elements/Container.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Element.d.ts +95 -0
- package/types/js/figure/Equation/Elements/Fraction.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Lines.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Matrix.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Offset.d.ts +5 -0
- package/types/js/figure/Equation/Elements/Scale.d.ts +5 -0
- package/types/js/figure/Equation/Equation.d.ts +984 -0
- package/types/js/figure/Equation/EquationForm.d.ts +139 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +3367 -0
- package/types/js/figure/Equation/EquationSymbols.d.ts +1646 -0
- package/types/js/figure/Equation/HTMLEquation.d.ts +56 -0
- package/types/js/figure/Equation/Symbols/AngleBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Arrow.d.ts +17 -0
- package/types/js/figure/Equation/Symbols/Bar.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Box.d.ts +11 -0
- package/types/js/figure/Equation/Symbols/Brace.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Bracket.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Division.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Integral.d.ts +7 -0
- package/types/js/figure/Equation/Symbols/Line.d.ts +5 -0
- package/types/js/figure/Equation/Symbols/Product.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Radical.d.ts +9 -0
- package/types/js/figure/Equation/Symbols/SquareBracket.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/Strike.d.ts +8 -0
- package/types/js/figure/Equation/Symbols/Sum.d.ts +6 -0
- package/types/js/figure/Equation/Symbols/SymbolNew.d.ts +15 -0
- package/types/js/figure/Equation/Symbols/Vinculum.d.ts +6 -0
- package/types/js/figure/Figure.d.ts +711 -0
- package/types/js/figure/FigureCollections/Angle.d.ts +766 -0
- package/types/js/figure/FigureCollections/Axis.d.ts +517 -0
- package/types/js/figure/FigureCollections/Axis3.d.ts +118 -0
- package/types/js/figure/FigureCollections/Button.d.ts +195 -0
- package/types/js/figure/FigureCollections/EquationLabel.d.ts +77 -0
- package/types/js/figure/FigureCollections/FigureCollections.d.ts +122 -0
- package/types/js/figure/FigureCollections/Legend.d.ts +270 -0
- package/types/js/figure/FigureCollections/Line.d.ts +587 -0
- package/types/js/figure/FigureCollections/Plot.d.ts +558 -0
- package/types/js/figure/FigureCollections/PolyLine.d.ts +487 -0
- package/types/js/figure/FigureCollections/Rectangle.d.ts +235 -0
- package/types/js/figure/FigureCollections/SlideNavigator.d.ts +255 -0
- package/types/js/figure/FigureCollections/Slider.d.ts +155 -0
- package/types/js/figure/FigureCollections/Text.d.ts +307 -0
- package/types/js/figure/FigureCollections/Toggle.d.ts +185 -0
- package/types/js/figure/FigureCollections/Trace.d.ts +237 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitive2DText.d.ts +119 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGLText.d.ts +94 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveGesture.d.ts +536 -0
- package/types/js/figure/FigurePrimitives/FigureElementPrimitiveMorph.d.ts +175 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes.d.ts +788 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes2D.d.ts +1324 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitiveTypes3D.d.ts +1105 -0
- package/types/js/figure/FigurePrimitives/FigurePrimitives.d.ts +173 -0
- package/types/js/figure/FigurePrimitives/Generic.d.ts +5 -0
- package/types/js/figure/FigurePrimitives/Text.d.ts +17 -0
- package/types/js/figure/FontManager.d.ts +113 -0
- package/types/js/figure/Gesture.d.ts +39 -0
- package/types/js/figure/Recorder/Recorder.d.ts +291 -0
- package/types/js/figure/Recorder/parseState.d.ts +3 -0
- package/types/js/figure/Recorder/recorder.worker.d.ts +1 -0
- package/types/js/figure/Recorder/state.d.ts +7 -0
- package/types/js/figure/SlideNavigator.d.ts +606 -0
- package/types/js/figure/TimeKeeper.d.ts +174 -0
- package/types/js/figure/geometries/arc.d.ts +18 -0
- package/types/js/figure/geometries/arrow.d.ts +215 -0
- package/types/js/figure/geometries/buffer.d.ts +4 -0
- package/types/js/figure/geometries/copy/copy.d.ts +178 -0
- package/types/js/figure/geometries/ellipse.d.ts +17 -0
- package/types/js/figure/geometries/line.d.ts +13 -0
- package/types/js/figure/geometries/lines/corners.d.ts +7 -0
- package/types/js/figure/geometries/lines/dashes.d.ts +23 -0
- package/types/js/figure/geometries/lines/lines.d.ts +31 -0
- package/types/js/figure/geometries/polygon/polygon.d.ts +12 -0
- package/types/js/figure/geometries/rectangle.d.ts +19 -0
- package/types/js/figure/geometries/triangle.d.ts +27 -0
- package/types/js/figure/webgl/Atlas.d.ts +42 -0
- package/types/js/figure/webgl/shaders.d.ts +143 -0
- package/types/js/figure/webgl/target.d.ts +9 -0
- package/types/js/figure/webgl/webgl.d.ts +54 -0
- package/types/js/tools/FunctionMap.d.ts +69 -0
- package/types/js/tools/color.d.ts +11 -0
- package/types/js/tools/colorNames.d.ts +2 -0
- package/types/js/tools/d2/polygon.d.ts +60 -0
- package/types/js/tools/d2/triangles.d.ts +0 -0
- package/types/js/tools/d3/cone.d.ts +57 -0
- package/types/js/tools/d3/cube.d.ts +26 -0
- package/types/js/tools/d3/cylinder.d.ts +45 -0
- package/types/js/tools/d3/line3.d.ts +55 -0
- package/types/js/tools/d3/prism.d.ts +49 -0
- package/types/js/tools/d3/revolve.d.ts +87 -0
- package/types/js/tools/d3/sphere.d.ts +33 -0
- package/types/js/tools/d3/surface.d.ts +47 -0
- package/types/js/tools/g2.d.ts +242 -0
- package/types/js/tools/geometry/Bounds.d.ts +446 -0
- package/types/js/tools/geometry/Line.d.ts +314 -0
- package/types/js/tools/geometry/Path.d.ts +67 -0
- package/types/js/tools/geometry/Plane.d.ts +201 -0
- package/types/js/tools/geometry/Point.d.ts +359 -0
- package/types/js/tools/geometry/Rect.d.ts +115 -0
- package/types/js/tools/geometry/Transform.d.ts +623 -0
- package/types/js/tools/geometry/angle.d.ts +105 -0
- package/types/js/tools/geometry/common.d.ts +9 -0
- package/types/js/tools/geometry/coordinates.d.ts +30 -0
- package/types/js/tools/geometry/deceleration.d.ts +13 -0
- package/types/js/tools/geometry/polygon.d.ts +4 -0
- package/types/js/tools/geometry/quaternion.d.ts +15 -0
- package/types/js/tools/geometry/scene.d.ts +282 -0
- package/types/js/tools/geometry/tools.d.ts +8 -0
- package/types/js/tools/geometry/types.d.ts +2 -0
- package/types/js/tools/getCssColors.d.ts +1 -0
- package/types/js/tools/getCssVariables.d.ts +4 -0
- package/types/js/tools/getImageData.d.ts +1 -0
- package/types/js/tools/getScssColors.d.ts +2 -0
- package/types/js/tools/htmlGenerator.d.ts +85 -0
- package/types/js/tools/m2.d.ts +24 -0
- package/types/js/tools/m3.d.ts +71 -0
- package/types/js/tools/math.d.ts +112 -0
- package/types/js/tools/morph.d.ts +651 -0
- package/types/js/tools/styleSheets.d.ts +3 -0
- package/types/js/tools/tools.d.ts +281 -0
- package/types/js/tools/types.d.ts +305 -0
- package/figureone.worker.js +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { TypeParsablePoint, Point } from '../geometry/Point';
|
|
2
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
3
|
+
/**
|
|
4
|
+
* Arrow definition object for a 3D line.
|
|
5
|
+
*
|
|
6
|
+
* @property {'start' | 'end' | 'all'} [ends] which end to put an arrow where
|
|
7
|
+
* `'start'` is `p1` and `'end'` is `p2` (`'end'`)
|
|
8
|
+
* @property {number} [width] width of arrow (line width * 2.5)
|
|
9
|
+
* @property {number} [length] length of arrow (arrow width * 3)
|
|
10
|
+
* @interface
|
|
11
|
+
* @group Misc Geometry Creation
|
|
12
|
+
*/
|
|
13
|
+
export type OBJ_Line3Arrow = {
|
|
14
|
+
ends?: 'start' | 'end' | 'all';
|
|
15
|
+
width?: number;
|
|
16
|
+
length?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 3D line options object.
|
|
20
|
+
*
|
|
21
|
+
* A 3D line is a cylinder with optional arrows on the end. Unlike a 2D line,
|
|
22
|
+
* the arrow profiles can only be simple triangles.
|
|
23
|
+
*
|
|
24
|
+
* @property {TypeParsablePoint} [p1] (`[0, 0, 0]`)
|
|
25
|
+
* @property {TypeParsablePoint} [p2] (default: `p1 + [1, 0, 0]`)
|
|
26
|
+
* @property {number} [width] width of line
|
|
27
|
+
* @property {OBJ_Line3Arrow | boolean} [arrow] define to use arrows at one or
|
|
28
|
+
* both ends of the line
|
|
29
|
+
* @property {number} [sides] number of sides (`10`)
|
|
30
|
+
* @property {'curve' | 'flat'} [normals] `flat` normals will make light
|
|
31
|
+
* shading across a line face constant. `curve` will gradiate the shading. Use
|
|
32
|
+
* `curve` to make a surface look more round with fewer number of sides.
|
|
33
|
+
* (`curve`)
|
|
34
|
+
* @property {number} [rotation] rotation of line around its axis - this is
|
|
35
|
+
* only noticable for small numbers of sides (`0`)
|
|
36
|
+
* @property {TypeParsableTransform} [transform] transform to apply to line
|
|
37
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
38
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
39
|
+
* representing two triangles per face and an
|
|
40
|
+
* associated normal for each point will be returned.
|
|
41
|
+
* @interface
|
|
42
|
+
* @group Misc Geometry Creation
|
|
43
|
+
*/
|
|
44
|
+
export type OBJ_Line3Points = {
|
|
45
|
+
p1?: TypeParsablePoint;
|
|
46
|
+
p2?: TypeParsablePoint;
|
|
47
|
+
width?: number;
|
|
48
|
+
arrow?: OBJ_Line3Arrow | boolean | null;
|
|
49
|
+
sides?: number;
|
|
50
|
+
normals?: 'curve' | 'flat';
|
|
51
|
+
transform?: TypeParsableTransform;
|
|
52
|
+
lines?: boolean;
|
|
53
|
+
rotation?: number;
|
|
54
|
+
};
|
|
55
|
+
export default function line3(options: OBJ_Line3Points): [Point[]] | [Point[], Point[]];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Point } from '../geometry/Point';
|
|
2
|
+
import type { TypeParsablePoint } from '../geometry/Point';
|
|
3
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
4
|
+
/**
|
|
5
|
+
* Prism options object.
|
|
6
|
+
*
|
|
7
|
+
* A prism base is defined in the XY plane, and it's length extends
|
|
8
|
+
* into +z. Use `transform` to orient it in any other way.
|
|
9
|
+
*
|
|
10
|
+
* Triangles will be created for the ends if the base is convex. If the base
|
|
11
|
+
* is not convex, use `baseTriangles` to define the triangles.
|
|
12
|
+
*
|
|
13
|
+
* @property {number} [base] base border points defined in the XY plane - the
|
|
14
|
+
* points should be defined in the counter-clock-wise direction.
|
|
15
|
+
* @property {Array<TypeParsablePoint>} baseTriangles triangles in the XY plane
|
|
16
|
+
* that create the base fill. If the base is convex, then the triangles can be
|
|
17
|
+
* auto-generated and this property left undefined.
|
|
18
|
+
* @property {number} [length] length of the prism
|
|
19
|
+
* @property {TypeParsableTransform} [transform] transform to apply to all
|
|
20
|
+
* points of prism
|
|
21
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
22
|
+
* the edges of the prism will be returned. If `false`, then points
|
|
23
|
+
* representing triangle bases and associated normals will be returned.
|
|
24
|
+
* (`false`)
|
|
25
|
+
* @interface
|
|
26
|
+
* @group Misc Geometry Creation
|
|
27
|
+
*/
|
|
28
|
+
export type OBJ_PrismPoints = {
|
|
29
|
+
base?: Array<TypeParsablePoint>;
|
|
30
|
+
baseTriangles?: Array<TypeParsablePoint>;
|
|
31
|
+
length?: number;
|
|
32
|
+
transform?: TypeParsableTransform;
|
|
33
|
+
lines?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Return points of a prism.
|
|
37
|
+
*
|
|
38
|
+
* The points can either represent the triangles that make up each base, or
|
|
39
|
+
* represent the start and end points lines that are the edges of the prism.
|
|
40
|
+
*
|
|
41
|
+
* If the points represent triangles, then a second array of normal vectors
|
|
42
|
+
* for each point will be available.
|
|
43
|
+
*
|
|
44
|
+
* @property {OBJ_PrismPoints} options cube options
|
|
45
|
+
* @return {[Array<Point>, Array<Point>]} an array of points and normals. If
|
|
46
|
+
* the points represent lines, then the array of normals will be empty.
|
|
47
|
+
* @group Geometry Creation
|
|
48
|
+
*/
|
|
49
|
+
export default function prism(options: OBJ_PrismPoints): [Point[]] | [Point[], Point[]];
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Point } from '../geometry/Point';
|
|
2
|
+
import type { TypeParsablePoint } from '../geometry/Point';
|
|
3
|
+
import type { Type3DMatrix } from '../m3';
|
|
4
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
5
|
+
/**
|
|
6
|
+
* Options object for {@link revolve}.
|
|
7
|
+
*
|
|
8
|
+
* Revolve (or radially sweep) a profile in the XY plane around the x axis to
|
|
9
|
+
* form a 3D surface.
|
|
10
|
+
*
|
|
11
|
+
* @property {Array<TypeParsablePoint>} profile XY plane profile to be radially
|
|
12
|
+
* swept around the x axis
|
|
13
|
+
* @property {number} [sides] number of sides in the radial sweep
|
|
14
|
+
* @property {'flat' | 'curveRows' | 'curveRadial' | 'curve'} [normals]
|
|
15
|
+
* `flat` normals will make shading (from a light source) across a face of the
|
|
16
|
+
* object a constant color. `curveProfile` will gradiate the shading along the
|
|
17
|
+
* profile. `curveRadial` will gradiate the shading around the radial sweep.
|
|
18
|
+
* `curve` will gradiate the shading both around the radial sweep and along the
|
|
19
|
+
* profile. Use `curve`, `curveProfile`, or `curveRadial` to make a surface
|
|
20
|
+
* look more round with fewer number of sides.
|
|
21
|
+
* @property {number} [rotation] by default the profile will start in the XY
|
|
22
|
+
* plane and sweep around the x axis following the right hand rule. Use
|
|
23
|
+
* `rotation` to start the sweep at some angle where 0º is in the XY for +y and
|
|
24
|
+
* 90º is in the XZ plane for +z. initial angle of the revolve rotation
|
|
25
|
+
* @property {TypeParsablePoint} [axis] orient the shape so its axis is along
|
|
26
|
+
* this vector
|
|
27
|
+
* @property {TypeParsablePoint} [position] offset the final vertices such that
|
|
28
|
+
* the original (0, 0) point in the profile moves to position (this step
|
|
29
|
+
* happens after the rotation)
|
|
30
|
+
* @property {TypeParsableTransform} [transform] apply a final transform to
|
|
31
|
+
* shape
|
|
32
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
33
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
34
|
+
* representing two triangles per face and an
|
|
35
|
+
* associated normal for each point will be returned.
|
|
36
|
+
* @interface
|
|
37
|
+
* @group Misc Geometry Creation
|
|
38
|
+
*/
|
|
39
|
+
export type OBJ_RevolvePoints = {
|
|
40
|
+
sides?: number;
|
|
41
|
+
profile?: Array<TypeParsablePoint>;
|
|
42
|
+
normals?: 'flat' | 'curveProfile' | 'curveRadial' | 'curve';
|
|
43
|
+
axis?: TypeParsablePoint;
|
|
44
|
+
rotation?: number;
|
|
45
|
+
position?: TypeParsablePoint;
|
|
46
|
+
transform?: TypeParsableTransform;
|
|
47
|
+
lines?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type OBJ_RevolveDefined = {
|
|
50
|
+
sides: number;
|
|
51
|
+
profile: Array<Point>;
|
|
52
|
+
normals: 'flat' | 'curveProfile' | 'curveRadial' | 'curve';
|
|
53
|
+
matrix: Type3DMatrix;
|
|
54
|
+
rotation: number;
|
|
55
|
+
position: Point;
|
|
56
|
+
transform?: TypeParsableTransform;
|
|
57
|
+
};
|
|
58
|
+
declare function getLathePoints(o: OBJ_RevolveDefined): Point[][];
|
|
59
|
+
/**
|
|
60
|
+
* Return points of a 3D surface created by revolving (or radially sweeping) a
|
|
61
|
+
* 2D profile around an axis.
|
|
62
|
+
*
|
|
63
|
+
* The points can either represent the triangles that make up each face, or
|
|
64
|
+
* represent the start and end points lines that are the edges of each face of
|
|
65
|
+
* the cone.
|
|
66
|
+
*
|
|
67
|
+
* If the points represent triangles, then a second array of normal vectors
|
|
68
|
+
* for each point will be available.
|
|
69
|
+
*
|
|
70
|
+
* A profile is defined in the XY plane, and then revolved around the x axis.
|
|
71
|
+
*
|
|
72
|
+
* The resulting points can oriented and positioned by defining a axis and
|
|
73
|
+
* position. The axis directs the x axis (around which the profile was
|
|
74
|
+
* rotated) to any direction. The position then offsets the transformed points
|
|
75
|
+
* in 3D space, there the original (0, 0, [0]) point is translated to
|
|
76
|
+
* (position.x, position.y, position.z)
|
|
77
|
+
*
|
|
78
|
+
* All profile points must have a y value that is not 0, with the exceptions of
|
|
79
|
+
* the ends which can be 0.
|
|
80
|
+
*
|
|
81
|
+
* @param {OBJ_Revolve} options
|
|
82
|
+
* @return {[Array<Point>, Array<Point>]} an array of points and normals. If
|
|
83
|
+
* the points represent lines, then the array of normals will be empty.
|
|
84
|
+
* @group Geometry Creation
|
|
85
|
+
*/
|
|
86
|
+
declare function revolve(options: OBJ_RevolvePoints): [Point[]] | [Point[], Point[]];
|
|
87
|
+
export { revolve, getLathePoints, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
2
|
+
import type { Point, TypeParsablePoint } from '../geometry/Point';
|
|
3
|
+
/**
|
|
4
|
+
* Sphere options object.
|
|
5
|
+
*
|
|
6
|
+
* By default, a sphere with its base at the origin will be created.
|
|
7
|
+
*
|
|
8
|
+
* @property {number} [sides] number of sides around sphere's half great circle
|
|
9
|
+
* (`10`)
|
|
10
|
+
* @property {number} [radius] radius of sphere (`1`)
|
|
11
|
+
* @property {'curve' | 'flat'} [normals] `flat` normals will make light
|
|
12
|
+
* shading across a face cone constant. `curve` will gradiate the shading. Use
|
|
13
|
+
* `curve` to make a surface look more round with fewer number of sides.
|
|
14
|
+
* (`flat`)
|
|
15
|
+
* @property {TypeParsablePoint} [center] center position of sphere (`[0, 0]`)
|
|
16
|
+
* @property {TypeParsableTransform} [transform] transform to apply to all
|
|
17
|
+
* points of cube
|
|
18
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
19
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
20
|
+
* representing two triangles per face and an
|
|
21
|
+
* associated normal for each point will be returned.
|
|
22
|
+
* @interface
|
|
23
|
+
* @group Misc Geometry Creation
|
|
24
|
+
*/
|
|
25
|
+
export type OBJ_SpherePoints = {
|
|
26
|
+
sides?: number;
|
|
27
|
+
radius?: number;
|
|
28
|
+
normals?: 'curve' | 'flat';
|
|
29
|
+
center?: TypeParsablePoint;
|
|
30
|
+
transform?: TypeParsableTransform;
|
|
31
|
+
lines?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export default function sphere(options: OBJ_SpherePoints): [Point[]] | [Point[], Point[]];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Point } from '../geometry/Point';
|
|
2
|
+
import type { TypeParsablePoint } from '../geometry/Point';
|
|
3
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
4
|
+
declare function getSurfaceNormals(surfacePoints: Array<Array<Point>>): Point[][];
|
|
5
|
+
declare function getTriangles(surfacePoints: Array<Array<Point>>): Point[];
|
|
6
|
+
declare function getLines(surfacePoints: Array<Array<Point>>): Point[];
|
|
7
|
+
declare function getFlatNormals(surfaceNormals: Array<Array<Point>>, surfacePoints: Array<Array<Point>>): Point[];
|
|
8
|
+
declare function getCurveNormals(surfaceNormals: Array<Array<Point>>, surfacePoints: Array<Array<Point>>, curve: 'curveColumns' | 'curveRows' | 'curve', closeColumns: boolean, closeRows: boolean): Point[];
|
|
9
|
+
/**
|
|
10
|
+
* Options object for defining a 3D surface.
|
|
11
|
+
*
|
|
12
|
+
* @property {Array<Array<TypeParsablePoint>>} [points] A grid of points that
|
|
13
|
+
* define a 3D surface
|
|
14
|
+
* @property {'curveColumns' | 'curveRows' | 'curve' | 'flat'} [normals]
|
|
15
|
+
* `flat` normals will make shading (from a light source) across a face of the
|
|
16
|
+
* object a constant color. `curveRows` will gradiate the shading along the
|
|
17
|
+
* rows of the grid. `curveColumns` will gradiate the shading along the columns
|
|
18
|
+
* of the grid. `curve` will gradiate the shading along both rows and columns.
|
|
19
|
+
* Use `curve`, `curveRows`, or `curveColumns` to make a surface
|
|
20
|
+
* look more round with fewer number of sides.
|
|
21
|
+
* @property {boolean} [closeColumns] Set to `true` if first row and last row are
|
|
22
|
+
* the same, and normals is `'curveRows'` or `'curve'` to get correct normal
|
|
23
|
+
* calculations (`false`)
|
|
24
|
+
* @property {boolean} [closeRows] Set to `true` if first row and last
|
|
25
|
+
* column are the same, and normals is `'curveColumns'` or `'curve'` to get
|
|
26
|
+
* correct normal calculations (`false`)
|
|
27
|
+
* @property {TypeParsableTransform} [transform] apply a final transform to
|
|
28
|
+
* shape
|
|
29
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
30
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
31
|
+
* representing two triangles per face and an
|
|
32
|
+
* associated normal for each point will be returned.
|
|
33
|
+
* @property {boolean} [invertNormals] if `true`, all normals will be inverted
|
|
34
|
+
* @interface
|
|
35
|
+
* @group Misc Geometry Creation
|
|
36
|
+
*/
|
|
37
|
+
export type OBJ_SurfacePoints = {
|
|
38
|
+
points?: Array<Array<TypeParsablePoint>>;
|
|
39
|
+
normals?: 'curveColumns' | 'curveRows' | 'curve' | 'flat';
|
|
40
|
+
closeColumns?: boolean;
|
|
41
|
+
closeRows?: boolean;
|
|
42
|
+
transform?: TypeParsableTransform;
|
|
43
|
+
lines?: boolean;
|
|
44
|
+
invertNormals?: boolean;
|
|
45
|
+
};
|
|
46
|
+
declare function surface(options: OBJ_SurfacePoints): [Point[], Point[]];
|
|
47
|
+
export { getTriangles, getFlatNormals, getCurveNormals, getSurfaceNormals, getLines, surface, };
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type { TypeParsablePoint } from './geometry/Point';
|
|
2
|
+
import { getPoint, isParsablePoint, getPoints, getScale, parsePoint, Point } from './geometry/Point';
|
|
3
|
+
import { toDelta } from './geometry/Path';
|
|
4
|
+
import { Plane, getPlane, isParsablePlane, getNormal } from './geometry/Plane';
|
|
5
|
+
import type { TypeParsablePlane } from './geometry/Plane';
|
|
6
|
+
import type { OBJ_TranslationPath } from './geometry/Path';
|
|
7
|
+
import { Line, getLine } from './geometry/Line';
|
|
8
|
+
import { Transform, getTransform, isParsableTransform, angleFromVectors, directionToAxisAngle } from './geometry/Transform';
|
|
9
|
+
import { decelerateValue, decelerateVector } from './geometry/deceleration';
|
|
10
|
+
import type { TypeParsableLine } from './geometry/Line';
|
|
11
|
+
import type { TypeParsableRect } from './geometry/Rect';
|
|
12
|
+
import type { TypeTransformValue, TypeParsableTransform } from './geometry/Transform';
|
|
13
|
+
import { Rect, getRect } from './geometry/Rect';
|
|
14
|
+
import { rectToPolar, polarToRect } from './geometry/coordinates';
|
|
15
|
+
import { RectBounds, LineBounds, Bounds, RangeBounds, getBounds } from './geometry/Bounds';
|
|
16
|
+
import type { TypeParsableBounds } from './geometry/Bounds';
|
|
17
|
+
import { deg, minAngleDiff, getDeltaAngle3D, getDeltaAngle, normAngleTo90, threePointAngle, threePointAngleMin, normAngle, clipAngle } from './geometry/angle';
|
|
18
|
+
import type { TypeRotationDirection } from './geometry/angle';
|
|
19
|
+
import { sphericalToCartesian, cartesianToSpherical } from './geometry/common';
|
|
20
|
+
import sphere from './d3/sphere';
|
|
21
|
+
import { revolve, getLathePoints } from './d3/revolve';
|
|
22
|
+
import cone from './d3/cone';
|
|
23
|
+
import line3 from './d3/line3';
|
|
24
|
+
import cylinder from './d3/cylinder';
|
|
25
|
+
import cube from './d3/cube';
|
|
26
|
+
import prism from './d3/prism';
|
|
27
|
+
import * as surface from './d3/surface';
|
|
28
|
+
import { pointsToNumbers, numbersToPoints, toNumbers, toPoints } from './geometry/tools';
|
|
29
|
+
import { polygon, polygonLine } from './d2/polygon';
|
|
30
|
+
type Type3Components = [number, number, number];
|
|
31
|
+
type Type2Components = [number, number];
|
|
32
|
+
export type { TypeParsableTransform, TypeTransformValue, TypeParsablePoint, TypeParsableRect, TypeParsableLine, Type3Components, Type2Components, TypeParsablePlane, TypeRotationDirection, OBJ_TranslationPath, TypeParsableBounds, };
|
|
33
|
+
declare function isTransformArrayZero(transformValue: TypeTransformValue, threshold?: number): boolean;
|
|
34
|
+
declare function spaceToSpaceTransform(s1: {
|
|
35
|
+
x: {
|
|
36
|
+
min: number;
|
|
37
|
+
span: number;
|
|
38
|
+
};
|
|
39
|
+
y: {
|
|
40
|
+
min: number;
|
|
41
|
+
span: number;
|
|
42
|
+
};
|
|
43
|
+
z: {
|
|
44
|
+
min: number;
|
|
45
|
+
span: number;
|
|
46
|
+
};
|
|
47
|
+
}, s2: {
|
|
48
|
+
x: {
|
|
49
|
+
min: number;
|
|
50
|
+
span: number;
|
|
51
|
+
};
|
|
52
|
+
y: {
|
|
53
|
+
min: number;
|
|
54
|
+
span: number;
|
|
55
|
+
};
|
|
56
|
+
z: {
|
|
57
|
+
min: number;
|
|
58
|
+
span: number;
|
|
59
|
+
};
|
|
60
|
+
}): Transform;
|
|
61
|
+
declare function spaceToSpaceScale(s1: {
|
|
62
|
+
x: {
|
|
63
|
+
bottomLeft: number;
|
|
64
|
+
width: number;
|
|
65
|
+
};
|
|
66
|
+
y: {
|
|
67
|
+
bottomLeft: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
z: {
|
|
71
|
+
bottomLeft: number;
|
|
72
|
+
height: number;
|
|
73
|
+
};
|
|
74
|
+
}, s2: {
|
|
75
|
+
x: {
|
|
76
|
+
bottomLeft: number;
|
|
77
|
+
width: number;
|
|
78
|
+
};
|
|
79
|
+
y: {
|
|
80
|
+
bottomLeft: number;
|
|
81
|
+
height: number;
|
|
82
|
+
};
|
|
83
|
+
z: {
|
|
84
|
+
bottomLeft: number;
|
|
85
|
+
height: number;
|
|
86
|
+
};
|
|
87
|
+
}): Point;
|
|
88
|
+
declare function comparePoints(p: Point, currentMin: Point, currentMax: Point, firstPoint: boolean): {
|
|
89
|
+
min: Point;
|
|
90
|
+
max: Point;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Buffer for rectangle, where `left`, `bottom`, `right` and `top` are
|
|
94
|
+
* the buffer values for a rectangle's left, bottom, right and top sides
|
|
95
|
+
* respectively.
|
|
96
|
+
* @interface
|
|
97
|
+
* @group Misc Geometry
|
|
98
|
+
*/
|
|
99
|
+
export type OBJ_Buffer = {
|
|
100
|
+
left: number;
|
|
101
|
+
bottom: number;
|
|
102
|
+
right: number;
|
|
103
|
+
top: number;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Buffer for rectangle can be:
|
|
107
|
+
*
|
|
108
|
+
* - `number`: left, bottom, right, top buffer all the same
|
|
109
|
+
* - [`number`, `number`]: left/right and bottom/top buffer values
|
|
110
|
+
* - [`number`, `number`, `number`, `number`]: left, bottom, right,
|
|
111
|
+
* top buffer values
|
|
112
|
+
* - `{ left? number, bottom?: number, right?: number, top?: number}`:
|
|
113
|
+
* object definition where default values are `0`.
|
|
114
|
+
*
|
|
115
|
+
* Can use {@link getBuffer} to convert the parsable buffer into
|
|
116
|
+
* @group Misc Geometry
|
|
117
|
+
*/
|
|
118
|
+
export type TypeParsableBuffer = number | [number, number] | [number, number, number, number] | {
|
|
119
|
+
left?: number;
|
|
120
|
+
right?: number;
|
|
121
|
+
top?: number;
|
|
122
|
+
bottom?: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Convert a parsable buffer into a buffer.
|
|
126
|
+
* @return {OBJ_Buffer}
|
|
127
|
+
* @group Misc Geometry
|
|
128
|
+
*/
|
|
129
|
+
declare function getBuffer(buffer: TypeParsableBuffer): OBJ_Buffer;
|
|
130
|
+
declare function isBuffer(input: any): boolean;
|
|
131
|
+
declare function getBoundingRect(pointArrays: Array<Point> | Array<Array<Point>>, buffer?: TypeParsableBuffer): Rect;
|
|
132
|
+
declare function getBoundingBorder(pointArrays: Array<Point> | Array<Array<Point>>, buffer?: TypeParsableBuffer): Point[];
|
|
133
|
+
declare function randomPoint(withinRect: Rect): Point;
|
|
134
|
+
declare function getMaxTimeFromVelocity(startTransform: Transform, stopTransform: Transform, velocityTransform: Transform | number, rotDirection?: 0 | 1 | -1 | 2): number;
|
|
135
|
+
declare function getMoveTime(startTransform: Transform | Array<Transform>, stopTransform: Transform | Array<Transform>, rotDirection?: 0 | 1 | -1 | 2, translationVelocity?: Point, // 0.5 figure units/s
|
|
136
|
+
rotationVelocity?: Point, // 60º/s
|
|
137
|
+
scaleVelocity?: Point): number;
|
|
138
|
+
declare function quadBezierPoints(p0: Point, p1: Point, p2: Point, sides: number): Point[];
|
|
139
|
+
/**
|
|
140
|
+
* Get center of a triangle
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* const getTriangleCenter = Fig.getTriangleCenter;
|
|
144
|
+
*
|
|
145
|
+
* const center = getTriangleCenter([0, 0], [1, 0], [0, 1]);
|
|
146
|
+
* console.log(center);
|
|
147
|
+
* // Point {x: 0.3333333333333333, y: 0.3333333333333333}
|
|
148
|
+
* @group 2D Geometry Tools
|
|
149
|
+
*/
|
|
150
|
+
declare function getTriangleCenter(p1: TypeParsablePoint, p2: TypeParsablePoint, p3: TypeParsablePoint): Point;
|
|
151
|
+
/**
|
|
152
|
+
* A border is an array of points defining a contigous, closed border.
|
|
153
|
+
*
|
|
154
|
+
* `Array<TypeParsablePoint> | Array<Array<TypeParsablePoint>>`
|
|
155
|
+
*
|
|
156
|
+
* If a border is not contigous, but rather is several "islands" of contigous,
|
|
157
|
+
* closed borders, then an array of point arrays can be used, where each point
|
|
158
|
+
* array is one island.
|
|
159
|
+
* @group Misc Geometry
|
|
160
|
+
*/
|
|
161
|
+
export type TypeParsableBorder = Array<TypeParsablePoint> | Array<Array<TypeParsablePoint>>;
|
|
162
|
+
/**
|
|
163
|
+
* A border is an array of point arrays. Each point array is a contigous, closed
|
|
164
|
+
* border. Several point arrays represent a border that is several separate
|
|
165
|
+
* borders.
|
|
166
|
+
*
|
|
167
|
+
* `TypeBorder = Array<Array<Point>>`
|
|
168
|
+
* @group Misc Geometry
|
|
169
|
+
*/
|
|
170
|
+
export type TypeBorder = Array<Array<Point>>;
|
|
171
|
+
declare function getBorder(border: Array<TypeParsablePoint> | Array<Array<TypeParsablePoint>> | string | number | TypeParsableBuffer): Array<Array<Point>> | string | TypeParsableBuffer;
|
|
172
|
+
export type TypeXAlign = 'left' | 'right' | 'center' | number | string;
|
|
173
|
+
export type TypeYAlign = 'bottom' | 'top' | 'middle' | number | string;
|
|
174
|
+
declare function getPositionInRect(r: TypeParsableRect, xAlign?: TypeXAlign, yAlign?: TypeYAlign): Point;
|
|
175
|
+
/**
|
|
176
|
+
* Surface grid options object.
|
|
177
|
+
*
|
|
178
|
+
* Two components must be a fixed [min, max, step].
|
|
179
|
+
*
|
|
180
|
+
* One component must be a function that takes in two components
|
|
181
|
+
* (x, y), (x, z), or (y, z) and outputs the third (z, y or x repsectively).
|
|
182
|
+
* @interface
|
|
183
|
+
* @group Misc Shapes
|
|
184
|
+
*/
|
|
185
|
+
export type OBJ_SurfaceGrid = {
|
|
186
|
+
x: ((a: number, b: number) => number) | [number, number, number];
|
|
187
|
+
y: ((a: number, b: number) => number) | [number, number, number];
|
|
188
|
+
z: ((a: number, b: number) => number) | [number, number, number];
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Create a matrix of points that define a surface.
|
|
192
|
+
*
|
|
193
|
+
* 
|
|
194
|
+
*
|
|
195
|
+
* Start with a grid of points in two components (x, y), (x, z), or (y, z), and
|
|
196
|
+
* define the third component (z, y or x repsectively) based on the first two.
|
|
197
|
+
*
|
|
198
|
+
* Resulting matrix can be used to create a 3D surface.
|
|
199
|
+
*
|
|
200
|
+
* @see {OBJ_Surface}
|
|
201
|
+
*
|
|
202
|
+
* @param {OBJ_SurfaceGrid} [components]
|
|
203
|
+
* @return {<Array<Array<Point>>}
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const { Figure, surfaceGrid } = Fig;
|
|
207
|
+
*
|
|
208
|
+
* // Orthographic scene with camera oriented so z is up
|
|
209
|
+
* const figure = new Figure({
|
|
210
|
+
* scene: {
|
|
211
|
+
* style: 'orthographic',
|
|
212
|
+
* camera: { up: [0, 0, 1], position: [1, 0.5, 0.5] },
|
|
213
|
+
* },
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* // Use surfaceGrid to generate a 3D surface from an xy grid
|
|
217
|
+
* const points = surfaceGrid({
|
|
218
|
+
* x: [-0.8, 0.8, 0.02],
|
|
219
|
+
* y: [-0.8, 0.8, 0.02],
|
|
220
|
+
* z: (x, y) => 1 / ((x * 5) ** 2 + (y * 5) ** 2 + 1),
|
|
221
|
+
* });
|
|
222
|
+
*
|
|
223
|
+
* figure.add([
|
|
224
|
+
* {
|
|
225
|
+
* make: 'surface',
|
|
226
|
+
* points,
|
|
227
|
+
* color: [1, 0, 0, 1],
|
|
228
|
+
* normals: 'curve',
|
|
229
|
+
* },
|
|
230
|
+
* {
|
|
231
|
+
* make: 'surface',
|
|
232
|
+
* points,
|
|
233
|
+
* lines: true,
|
|
234
|
+
* color: [0, 0, 0, 1],
|
|
235
|
+
* position: [0, 0, 0.0001],
|
|
236
|
+
* },
|
|
237
|
+
* { make: 'cameraControl', axis: [0, 0, 1] },
|
|
238
|
+
* ]);
|
|
239
|
+
* @group Misc Shapes
|
|
240
|
+
*/
|
|
241
|
+
declare function surfaceGrid(components: OBJ_SurfaceGrid): Point[][];
|
|
242
|
+
export { Point, Line, minAngleDiff, deg, normAngle, Transform, Rect, spaceToSpaceTransform, getBoundingRect, polarToRect, rectToPolar, getDeltaAngle, getDeltaAngle3D, normAngleTo90, threePointAngle, threePointAngleMin, randomPoint, getMaxTimeFromVelocity, getMoveTime, parsePoint, clipAngle, spaceToSpaceScale, getPoint, getScale, getPoints, quadBezierPoints, getRect, getTransform, getLine, decelerateValue, RectBounds, LineBounds, RangeBounds, getBounds, Bounds, getTriangleCenter, getBoundingBorder, getBorder, comparePoints, isBuffer, getPositionInRect, isParsablePoint, isParsableTransform, isTransformArrayZero, Plane, getPlane, isParsablePlane, toDelta, sphericalToCartesian, cartesianToSpherical, getNormal, sphere, revolve, cylinder, cone, line3, cube, prism, surface, getLathePoints, decelerateVector, numbersToPoints, pointsToNumbers, toNumbers, toPoints, polygon, polygonLine, angleFromVectors, directionToAxisAngle, surfaceGrid, getBuffer, };
|