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,31 @@
|
|
|
1
|
+
import { Line } from '../../../tools/geometry/Line';
|
|
2
|
+
import { Point } from '../../../tools/geometry/Point';
|
|
3
|
+
import type { TypeDash } from '../../../tools/types';
|
|
4
|
+
import type { TypeArrowHead } from '../arrow';
|
|
5
|
+
import type { OBJ_Arrow } from '../../FigurePrimitives/FigurePrimitiveTypes2D';
|
|
6
|
+
declare function lineSegmentsToPoints(lineSegments: Array<Array<Line>>, linePrimitives: boolean, borderIs: ("negative" | "positive" | "line" | Array<Array<Point>>) | undefined, corner: 'auto' | 'fill' | 'none', close: boolean): [Array<Point>, Array<Array<Point>>];
|
|
7
|
+
declare function joinLinesInPoint(line1: Line, lineNext: Line, corner: 'fill' | 'auto' | 'none'): void;
|
|
8
|
+
declare function joinLinesInTangent(mid: Line, midNext: Line, outside: Line, outsideNext: Line, corner: 'fill' | 'auto' | 'none'): void;
|
|
9
|
+
declare function makePolyLine(pointsIn: Array<Point>, width: number | undefined, close: boolean | undefined, widthIsIn: "mid" | "outside" | "inside" | "positive" | "negative" | number | undefined, cornerStyle: 'auto' | 'none' | 'radius' | 'fill', cornerSize?: number, cornerSides?: number, minAutoCornerAngle?: number, dash?: TypeDash, linePrimitives?: boolean, lineNum?: number, borderIs?: 'positive' | 'negative' | 'line' | Array<Array<Point>>, touchBorderBuffer?: number, arrowIn?: null | TypeArrowHead | {
|
|
10
|
+
start: OBJ_Arrow | TypeArrowHead;
|
|
11
|
+
end: OBJ_Arrow | TypeArrowHead;
|
|
12
|
+
} & OBJ_Arrow, precision?: number): [Array<Point>, Array<Array<Point>>, Array<Array<Point>>];
|
|
13
|
+
declare function makePolyLineCorners(pointsIn: Array<Point>, width: number | undefined, close: boolean | undefined, cornerLength: number, widthIs: "mid" | "outside" | "inside" | "positive" | "negative" | undefined, cornerStyle: 'auto' | 'none' | 'radius' | 'fill', cornerSize: number, cornerSides: number, minAutoCornerAngle?: number, linePrimitives?: boolean, lineNum?: number, drawBorderBuffer?: number): (Point[] | Point[][])[];
|
|
14
|
+
declare function addArrows(arrowIn: {
|
|
15
|
+
start?: {
|
|
16
|
+
head: TypeArrowHead;
|
|
17
|
+
length: number;
|
|
18
|
+
width: number;
|
|
19
|
+
barb: number;
|
|
20
|
+
tailWidth: number;
|
|
21
|
+
};
|
|
22
|
+
end?: {
|
|
23
|
+
head: TypeArrowHead;
|
|
24
|
+
length: number;
|
|
25
|
+
width: number;
|
|
26
|
+
barb: number;
|
|
27
|
+
tailWidth: number;
|
|
28
|
+
};
|
|
29
|
+
} | null | undefined, startArrowIn: [Point, Point], endArrowIn: [Point, Point], existingTriangles: Array<Point>, existingBorder: Array<Array<Point>>, existingTouchBorder: Array<Array<Point>>, drawBorderBuffer: number, lineWidth: number, onLine: boolean): [Point[], Point[][], Point[][]];
|
|
30
|
+
declare function makeFastPolyLine(pointsIn: Array<Point>, width: number, close: boolean): any[][];
|
|
31
|
+
export { joinLinesInPoint, lineSegmentsToPoints, joinLinesInTangent, makePolyLine, makePolyLineCorners, addArrows, makeFastPolyLine, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Point } from '../../../tools/g2';
|
|
2
|
+
declare function getPolygonPoints(options: {
|
|
3
|
+
radius: number;
|
|
4
|
+
innerRadius?: number;
|
|
5
|
+
rotation: number;
|
|
6
|
+
offset: Point;
|
|
7
|
+
sides: number;
|
|
8
|
+
sidesToDraw: number;
|
|
9
|
+
direction: 1 | -1;
|
|
10
|
+
}): Array<Point>;
|
|
11
|
+
declare function getTrisFillPolygon(center: Point, border: Array<Point>, sides: number, sidesToDraw: number): Array<Point>;
|
|
12
|
+
export { getPolygonPoints, getTrisFillPolygon, };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Point } from '../../tools/g2';
|
|
2
|
+
declare function getRectangleBorder(options: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
xAlign: 'left' | 'center' | 'right' | number;
|
|
6
|
+
yAlign: 'bottom' | 'middle' | 'top' | number;
|
|
7
|
+
corner: {
|
|
8
|
+
radius: number;
|
|
9
|
+
sides: number;
|
|
10
|
+
};
|
|
11
|
+
line?: {
|
|
12
|
+
widthIs: 'inside' | 'outside' | 'positive' | 'negative' | 'mid' | number;
|
|
13
|
+
width: number;
|
|
14
|
+
};
|
|
15
|
+
drawBorderBuffer: number | Array<Array<Point>>;
|
|
16
|
+
offset: Point;
|
|
17
|
+
}): Point[];
|
|
18
|
+
declare function rectangleBorderToTris(border: Array<Point>): Point[];
|
|
19
|
+
export { getRectangleBorder, rectangleBorderToTris, };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Point } from '../../tools/g2';
|
|
2
|
+
import type { TypeParsablePoint } from '../../tools/g2';
|
|
3
|
+
declare function getTriangleDirection(points: Array<Point>): 1 | -1;
|
|
4
|
+
export type OBJ_Triangle_Defined = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
top: 'left' | 'right' | 'center';
|
|
8
|
+
points?: Array<TypeParsablePoint>;
|
|
9
|
+
SSS?: [number, number, number];
|
|
10
|
+
ASA?: [number, number, number];
|
|
11
|
+
AAS?: [number, number, number];
|
|
12
|
+
SAS?: [number, number, number];
|
|
13
|
+
direction: 1 | -1;
|
|
14
|
+
xAlign: 'left' | 'center' | 'right' | number | 'a1' | 'a2' | 'a3' | 's1' | 's2' | 's3' | 'centroid' | 'points';
|
|
15
|
+
yAlign: 'bottom' | 'middle' | 'top' | number | 'a1' | 'a2' | 'a3' | 's1' | 's2' | 's3' | 'centroid' | 'points';
|
|
16
|
+
rotation: number | 's1' | 's2' | 's3' | {
|
|
17
|
+
side?: 's1' | 's2' | 's3';
|
|
18
|
+
angle?: number;
|
|
19
|
+
};
|
|
20
|
+
line?: {
|
|
21
|
+
widthIs: 'inside' | 'outside' | 'positive' | 'negative' | 'mid';
|
|
22
|
+
width: number;
|
|
23
|
+
};
|
|
24
|
+
drawBorderBuffer: number | Array<Array<TypeParsablePoint>>;
|
|
25
|
+
};
|
|
26
|
+
declare function getTriangleBorder(options: OBJ_Triangle_Defined): Point[];
|
|
27
|
+
export { getTriangleBorder, getTriangleDirection, };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import FontManager from '../FontManager';
|
|
2
|
+
import { FigureFont } from '../DrawingObjects/TextObject/TextObject';
|
|
3
|
+
import { NotificationManager } from '../../tools/tools';
|
|
4
|
+
import type { TypeColor } from '../../tools/types';
|
|
5
|
+
import type Scene from '../../tools/geometry/scene';
|
|
6
|
+
import type WebGLInstance from './webgl';
|
|
7
|
+
export type OBJ_AtlasMap = {
|
|
8
|
+
[char: string]: {
|
|
9
|
+
width: number;
|
|
10
|
+
ascent: number;
|
|
11
|
+
descent: number;
|
|
12
|
+
offsetX: number;
|
|
13
|
+
offsetY: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type OBJ_Atlas = {
|
|
17
|
+
font?: FigureFont;
|
|
18
|
+
loadColor?: TypeColor;
|
|
19
|
+
scene?: Scene;
|
|
20
|
+
maxCount?: number;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
map?: OBJ_AtlasMap;
|
|
23
|
+
};
|
|
24
|
+
export default class Atlas {
|
|
25
|
+
webgl: WebGLInstance;
|
|
26
|
+
font: FigureFont;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
src: HTMLImageElement | string;
|
|
29
|
+
fontID: string;
|
|
30
|
+
dimension: number;
|
|
31
|
+
loaded: boolean;
|
|
32
|
+
scene: Scene;
|
|
33
|
+
canvas: HTMLCanvasElement;
|
|
34
|
+
fontManager: FontManager;
|
|
35
|
+
notifications: NotificationManager;
|
|
36
|
+
map: OBJ_AtlasMap;
|
|
37
|
+
constructor(webgl: WebGLInstance, options: OBJ_Atlas);
|
|
38
|
+
srcLoaded(): void;
|
|
39
|
+
fontLoaded(): void;
|
|
40
|
+
recreate(): void;
|
|
41
|
+
createAtlas(scene?: Scene): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options used to compose vertex shader source code.
|
|
3
|
+
*
|
|
4
|
+
* Shader source code can be automatically composed for different vertex
|
|
5
|
+
* dimension (2D vs 3D), coloring and lighting options.
|
|
6
|
+
*
|
|
7
|
+
* Composed source code uses specific attribute, uniform and varying names.
|
|
8
|
+
* Attributes will need to be defined by the user in the `attributes` property
|
|
9
|
+
* of {@link OBJ_GenericGL}.
|
|
10
|
+
*
|
|
11
|
+
* Attributes:
|
|
12
|
+
* - `vec2 a_vertex`: used to define vertex positions when `dimension = 2`.
|
|
13
|
+
* - `vec4 a_vertex`: used to define vertex positions when `dimension = 3` -
|
|
14
|
+
* Note, for this case an attribute size of only 3 is needed as the fourth
|
|
15
|
+
* coordinate (w in the homogenous coordinate system) is automatically filled
|
|
16
|
+
* with a 1.
|
|
17
|
+
* - `vec4 a_color`: used to define the color of a vertex when `color = 'vertex'`
|
|
18
|
+
* - `vec2 a_texcoord`: used to define the texture coordinates to map the
|
|
19
|
+
* vertex to when `color = 'texture'`
|
|
20
|
+
* - `vec3 a_normal`: used to define the normal vector for a vertex used when
|
|
21
|
+
* `light = 'point'` or `light = 'directional'`
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* Uniforms will be defined and updated by FigureOne based on the color and
|
|
25
|
+
* transform of the primitive, and the scene being used to draw the primitive.
|
|
26
|
+
* Thus, the uniform variables listed below for are for informational purposes
|
|
27
|
+
* only.
|
|
28
|
+
*
|
|
29
|
+
* Uniforms:
|
|
30
|
+
* - `mat4 u_worldViewProjectionMatrix`: transfomration matrix that cascades
|
|
31
|
+
* projection, camera position, and any additional transformation of the shape
|
|
32
|
+
* - `float u_z`: define a specific z for all vertices when `dimension = 2`
|
|
33
|
+
* - `u_worldInverseTranspose`: transpose of inverse world matrix needed for
|
|
34
|
+
* to correctly transform normal vectors. Used when `light = 'point'` or
|
|
35
|
+
* `light = 'directional'`
|
|
36
|
+
* - `vec3 u_lightWorldPosition`: defines the position of a point source light
|
|
37
|
+
* used when `light = 'point'`
|
|
38
|
+
* - `mat4 u_worldMatrix`: defines the world matrix transform that orients the
|
|
39
|
+
* point source light relative to the shape used when `light = 'point'`.
|
|
40
|
+
*
|
|
41
|
+
* Varyings are passed from the vertex shader to the fragement shader. They are
|
|
42
|
+
* listed here in case the user wants to customize one shader, while relying on
|
|
43
|
+
* composition for the other. All varying expected by the composed shader will
|
|
44
|
+
* need to be defined in the custom shader.
|
|
45
|
+
*
|
|
46
|
+
* - `vec2 v_texcoord`: pass texture coordinates to fragment shader used when
|
|
47
|
+
* `color = 'texture'`
|
|
48
|
+
* - `vec4 v_color`: pass vertex specific color to fragment shader used when
|
|
49
|
+
* `color = 'vertex'`
|
|
50
|
+
* - `vec3 v_normal`: pass normals (transformed with `u_worldInverseTranspose`)
|
|
51
|
+
* to fragment shader used when `light = 'directional'` or `light = 'point'`
|
|
52
|
+
* - `vec3 v_vertexToLight`: pass vector between point source light and vertex
|
|
53
|
+
* to fragment shader used when `light = 'point'`
|
|
54
|
+
*
|
|
55
|
+
* @property {2 | 3} [dimension] (`2`)
|
|
56
|
+
* @property {'vertex' | 'uniform' | 'texture'} [color] (`uniform`)
|
|
57
|
+
* @property {'point' | 'directional' | null} [light] (`null`)
|
|
58
|
+
* @interface
|
|
59
|
+
* @group Shaders
|
|
60
|
+
*/
|
|
61
|
+
export type OBJ_VertexShader = {
|
|
62
|
+
light?: 'point' | 'directional' | null;
|
|
63
|
+
color?: 'vertex' | 'uniform' | 'texture';
|
|
64
|
+
dimension?: 2 | 3;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A vertex shader can be defined with either:
|
|
68
|
+
* - `{ src: string, vars: Array<string> }`: a shader source code string and a
|
|
69
|
+
* list of attributes and uniforms
|
|
70
|
+
* - `string`: an identifier to a built-in shader
|
|
71
|
+
* - {@link OBJ_VertexShader} `| Array<string | number | boolean>`: composing
|
|
72
|
+
* options for a composable shader
|
|
73
|
+
* @group Shaders
|
|
74
|
+
*/
|
|
75
|
+
export type TypeVertexShader = string | {
|
|
76
|
+
src: string;
|
|
77
|
+
vars?: Array<string>;
|
|
78
|
+
} | Array<string | number | boolean> | OBJ_VertexShader;
|
|
79
|
+
/**
|
|
80
|
+
* Options used to compose fragment shader source code.
|
|
81
|
+
*
|
|
82
|
+
* Shader source code can be automatically composed for different coloring and
|
|
83
|
+
* lighting options.
|
|
84
|
+
*
|
|
85
|
+
* Composed source code uses specific uniform and varying names.
|
|
86
|
+
*
|
|
87
|
+
* Uniforms will be defined and updated by FigureOne based on the color and
|
|
88
|
+
* transform of the primitive, and the scene being used to draw the primitive.
|
|
89
|
+
* Thus, the uniform variables listed below for are for informational purposes
|
|
90
|
+
* only.
|
|
91
|
+
*
|
|
92
|
+
* Uniforms:
|
|
93
|
+
* - `vec4 u_color`: global color for all vertices used all times. When
|
|
94
|
+
* `color = 'texture'` or `color = 'vertex'`, only the alpha channel of
|
|
95
|
+
* `u_color` is used.
|
|
96
|
+
* - `sampler2D u_texture`: texture used when `color = 'texture'`.
|
|
97
|
+
* - `vec3 u_directionalLight`: world space position of directional light
|
|
98
|
+
* source used when `light = 'directional'`
|
|
99
|
+
* - `float u_ambientLight`: ambient light used when `light = 'directional'` or
|
|
100
|
+
* `light = 'point'`.
|
|
101
|
+
*
|
|
102
|
+
* Varyings are passed from the vertex shader to the fragement shader. They are
|
|
103
|
+
* listed here in case the user wants to customize one shader, while relying on
|
|
104
|
+
* composition for the other.
|
|
105
|
+
*
|
|
106
|
+
* - `vec2 v_texcoord`: texture coordinates from vertex shader used when
|
|
107
|
+
* `color = 'texture'`
|
|
108
|
+
* - `vec4 v_color`: vertex specific color from vertex shader used when
|
|
109
|
+
* `color = 'vertex'`
|
|
110
|
+
* - `vec3 v_normal`: normals from vertex shader used when
|
|
111
|
+
* `light = 'directional'` or `light = 'point'`
|
|
112
|
+
* - `vec3 v_vertexToLight`: vector between point source light and vertex
|
|
113
|
+
* from vertex shader used when `light = 'point'`
|
|
114
|
+
*
|
|
115
|
+
* @property {2 | 3} [dimension] (`2`)
|
|
116
|
+
* @property {'vertex' | 'uniform' | 'texture'} [color] (`uniform`)
|
|
117
|
+
* @property {'point' | 'directional' | null} [light] (`null`)
|
|
118
|
+
* @interface
|
|
119
|
+
* @group Shaders
|
|
120
|
+
*/
|
|
121
|
+
export type OBJ_FragmentShader = {
|
|
122
|
+
light?: 'point' | 'directional' | null;
|
|
123
|
+
color?: 'vertex' | 'uniform' | 'texture';
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* A fragment shader can be defined with either:
|
|
127
|
+
* - `{ src: string, vars: Array<string> }`: a shader source code string and a
|
|
128
|
+
* list of attributes and uniforms
|
|
129
|
+
* - `string`: an identifier to a built-in shader
|
|
130
|
+
* - {@link OBJ_VertexShader} `| Array<string | number | boolean>`: composing
|
|
131
|
+
* options for a composable shader
|
|
132
|
+
* @group Shaders
|
|
133
|
+
*/
|
|
134
|
+
export type TypeFragmentShader = string | {
|
|
135
|
+
src: string;
|
|
136
|
+
vars?: Array<string>;
|
|
137
|
+
} | Array<string | number | boolean> | OBJ_FragmentShader;
|
|
138
|
+
declare const getShaders: (vName?: TypeVertexShader, fName?: TypeFragmentShader) => {
|
|
139
|
+
vertexSource: string;
|
|
140
|
+
fragmentSource: string;
|
|
141
|
+
vars: string[];
|
|
142
|
+
};
|
|
143
|
+
export default getShaders;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type WebGLInstance from './webgl';
|
|
2
|
+
export default class TargetTexture {
|
|
3
|
+
fb: WebGLFramebuffer | null;
|
|
4
|
+
webgl: WebGLInstance;
|
|
5
|
+
target: WebGLTexture | null;
|
|
6
|
+
depthBuffer: WebGLRenderbuffer | null;
|
|
7
|
+
constructor(webgl: WebGLInstance);
|
|
8
|
+
setFramebufferAttachmentSizes(width: number, height: number): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TypeFragmentShader, TypeVertexShader } from './shaders';
|
|
2
|
+
import TargetTexture from './target';
|
|
3
|
+
import FontManager from '../FontManager';
|
|
4
|
+
import { FunctionMap } from '../../tools/FunctionMap';
|
|
5
|
+
import Atlas from './Atlas';
|
|
6
|
+
import type { TypeColor } from '../../tools/types';
|
|
7
|
+
import type { OBJ_Atlas } from './Atlas';
|
|
8
|
+
declare class WebGLInstance {
|
|
9
|
+
gl: WebGLRenderingContext;
|
|
10
|
+
program: WebGLProgram;
|
|
11
|
+
lastUsedProgram: WebGLProgram | null;
|
|
12
|
+
textures: {
|
|
13
|
+
[name: string]: {
|
|
14
|
+
glTexture: WebGLTexture;
|
|
15
|
+
index: number;
|
|
16
|
+
state: 'loading' | 'loaded';
|
|
17
|
+
onLoad: Array<((b: boolean, n: number) => void) | string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
atlases: {
|
|
21
|
+
[atlasId: string]: Atlas;
|
|
22
|
+
};
|
|
23
|
+
programs: Array<{
|
|
24
|
+
vars: Array<string>;
|
|
25
|
+
vertexShader: {
|
|
26
|
+
src: string;
|
|
27
|
+
hash: number;
|
|
28
|
+
};
|
|
29
|
+
fragmentShader: {
|
|
30
|
+
src: string;
|
|
31
|
+
hash: number;
|
|
32
|
+
};
|
|
33
|
+
locations: Record<string, any>;
|
|
34
|
+
program: WebGLProgram;
|
|
35
|
+
}>;
|
|
36
|
+
targetTexture: null | TargetTexture;
|
|
37
|
+
fnMap: FunctionMap;
|
|
38
|
+
fontManager: FontManager;
|
|
39
|
+
addTexture(id: string, data: string | HTMLImageElement | HTMLCanvasElement, loadColor?: TypeColor, repeat?: boolean, onLoad?: null | string | ((b: boolean, n: number) => void), force?: boolean): number;
|
|
40
|
+
getAtlas(options: OBJ_Atlas): Atlas;
|
|
41
|
+
recreateAtlases(): void;
|
|
42
|
+
deleteTexture(id: string): void;
|
|
43
|
+
contextLost(): void;
|
|
44
|
+
setTextureData(id: string, image: Record<string, any> | TypeColor, // image data
|
|
45
|
+
repeat?: boolean): boolean;
|
|
46
|
+
onLoad(id: string): void;
|
|
47
|
+
cancel(id: string): void;
|
|
48
|
+
getProgram(vertexShader: TypeVertexShader, fragmentShader: TypeFragmentShader): number;
|
|
49
|
+
useProgram(programIndex: number): Record<string, any>;
|
|
50
|
+
constructor(canvas: HTMLCanvasElement, backgroundColor: Array<number>);
|
|
51
|
+
init(gl: WebGLRenderingContext): void;
|
|
52
|
+
resize(): void;
|
|
53
|
+
}
|
|
54
|
+
export default WebGLInstance;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare class GeneralFunctionMap {
|
|
2
|
+
map: {
|
|
3
|
+
[id: string]: {
|
|
4
|
+
fn: Function;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
constructor();
|
|
8
|
+
add(id: string, fn: Function): void;
|
|
9
|
+
exec(idOrFn: string | Function | null, ...args: any[]): any;
|
|
10
|
+
execOnMaps(idOrFn: string | Function | null, mapsIn: Array<Record<string, any>>, ...args: any[]): any;
|
|
11
|
+
}
|
|
12
|
+
declare class GlobalFunctionMap extends GeneralFunctionMap {
|
|
13
|
+
static instance: GlobalFunctionMap;
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Function Map
|
|
18
|
+
*
|
|
19
|
+
* In FigureOne {@link Recorder}, state is saved in stringified javascript
|
|
20
|
+
* objects. When the state includes a function (like a trigger method in an
|
|
21
|
+
* animation for example) then that function is referenced in the state object
|
|
22
|
+
* as a unique string id.
|
|
23
|
+
*
|
|
24
|
+
* When a geometry is loaded, functions that will be captured in state objects
|
|
25
|
+
* need to be added to a function map. Both {@link Figure} and
|
|
26
|
+
* {@link FigureElement} have attached function maps as the property `fnMap`.
|
|
27
|
+
* Therefore, the method is added to either the figure or element function map,
|
|
28
|
+
* with an associated unique string id, and that string id is used when the
|
|
29
|
+
* function is used. For example as defined callbacks, triggerAnimationStep and
|
|
30
|
+
* customAnimationStep callbacks, or recorder slide definitions (`entryState`,
|
|
31
|
+
* `steadyState`, `leaveState`, `exec`, `execDelta`).
|
|
32
|
+
*
|
|
33
|
+
* The funciton map has:
|
|
34
|
+
* - A map of functions
|
|
35
|
+
* - A link to a global map of functions (a singleton)
|
|
36
|
+
* - The ability to execute a function within the map
|
|
37
|
+
*
|
|
38
|
+
* @property {FunctionMap} global global function map
|
|
39
|
+
* @property {Object} map local function map where keys are unique identifiers
|
|
40
|
+
* and values are the associated functions
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Add a console function to a FunctionMap and execute it with a parameter
|
|
44
|
+
* figure.fnMap.add('toConsole', s => console.log(s));
|
|
45
|
+
* figure.fnMap.exec('toConsole', 'hello');
|
|
46
|
+
* @group Interactive Video
|
|
47
|
+
*/
|
|
48
|
+
declare class FunctionMap extends GeneralFunctionMap {
|
|
49
|
+
global: GlobalFunctionMap;
|
|
50
|
+
constructor();
|
|
51
|
+
/**
|
|
52
|
+
* Execute function with arguments.
|
|
53
|
+
*
|
|
54
|
+
* @param {string | Function | null} idOrFn If `string`, then a function
|
|
55
|
+
* in the local map or global map will be executed (local map takes
|
|
56
|
+
* precedence). If `Function`, then the
|
|
57
|
+
* function will be exectuted. If `null`, then nothing will happen.
|
|
58
|
+
* @param {any} ...args arguments to pass to function.
|
|
59
|
+
*/
|
|
60
|
+
exec(idOrFn: string | Function | null, ...args: any[]): any;
|
|
61
|
+
execOnMaps(idOrFn: string | Function | null, mapsIn: Array<Record<string, any>>, ...args: any[]): any;
|
|
62
|
+
/**
|
|
63
|
+
* Add a function to the map.
|
|
64
|
+
* @param {string} id unique identifier
|
|
65
|
+
* @param {Function} fn function to add
|
|
66
|
+
*/
|
|
67
|
+
add(id: string, fn: Function): void;
|
|
68
|
+
}
|
|
69
|
+
export { FunctionMap, GlobalFunctionMap };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import getCSSColors from './getCssColors';
|
|
2
|
+
import type { TypeColor } from './types';
|
|
3
|
+
declare function RGBToArray(color: string): Array<number>;
|
|
4
|
+
declare function HexToArray(color: string): Array<number>;
|
|
5
|
+
declare function cssColorToArray(cssColorString: string): Array<number> | null;
|
|
6
|
+
declare function colorToInt(color: TypeColor): number[];
|
|
7
|
+
declare function colorArrayToRGBA(color: TypeColor): string;
|
|
8
|
+
declare function colorArrayToRGB(color: TypeColor): string;
|
|
9
|
+
declare function areColorsSame(color1: TypeColor, color2: TypeColor, precision?: number): boolean;
|
|
10
|
+
declare function areColorsWithinDelta(color1: TypeColor, color2: TypeColor, delta?: number): boolean;
|
|
11
|
+
export { RGBToArray, HexToArray, cssColorToArray, colorArrayToRGB, colorArrayToRGBA, getCSSColors, areColorsSame, areColorsWithinDelta, colorToInt, };
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
* @property {TypeParsablePoint} [center] center position of the polygon
|
|
7
|
+
* @property {number} [radius] distance from center to polygon corner (`1`)
|
|
8
|
+
* @property {number} [sides] number of polygon sides (`4`)
|
|
9
|
+
* @property {number} [rotation] rotation offset for first polygon corner (`0`)
|
|
10
|
+
* @property {1 | -1} [direction] angular direction of corners - 1 is CCW in the
|
|
11
|
+
* XY plane (`1`)
|
|
12
|
+
* (`[0,, 0, 0]`)
|
|
13
|
+
* @property {Type3DMatrix | TypeParsableTransform} [transform] transform
|
|
14
|
+
* to apply to polygon
|
|
15
|
+
* @property {2 | 3} [tris] if defined, return an array of numbers representing
|
|
16
|
+
* the interlaced x/y/z components of points that define triangles that can draw
|
|
17
|
+
* the polygon. `2` returns just x/y components and `3` returns x/y/z
|
|
18
|
+
* components.
|
|
19
|
+
* @group Misc Geometry Creation
|
|
20
|
+
*/
|
|
21
|
+
export interface OBJ_PolygonPoints {
|
|
22
|
+
center?: TypeParsablePoint;
|
|
23
|
+
radius?: number;
|
|
24
|
+
sides?: number;
|
|
25
|
+
rotation?: number;
|
|
26
|
+
direction?: 1 | -1;
|
|
27
|
+
tris?: 2 | 3;
|
|
28
|
+
transform?: Type3DMatrix | TypeParsableTransform;
|
|
29
|
+
close?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @property {number} [innerRadius] distance from center to inside polygon
|
|
33
|
+
* corner
|
|
34
|
+
*
|
|
35
|
+
* @extends OBJ_PolygonPoints
|
|
36
|
+
* @group Misc Geometry Creation
|
|
37
|
+
*/
|
|
38
|
+
export interface OBJ_PolygonLinePoints extends OBJ_PolygonPoints {
|
|
39
|
+
innerRadius?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create points a regular polygon.
|
|
43
|
+
*
|
|
44
|
+
* Can return either:
|
|
45
|
+
* - Array<{@link Point}> - corners of a polygon
|
|
46
|
+
* - Array<`number`> - interlaced points of triangles used to a polygon fill
|
|
47
|
+
* @group Geometry Creation
|
|
48
|
+
*/
|
|
49
|
+
declare function polygon(options: OBJ_PolygonPoints): Point[] | number[];
|
|
50
|
+
/**
|
|
51
|
+
* Create a solid regular polygon line.
|
|
52
|
+
*
|
|
53
|
+
* Can return either:
|
|
54
|
+
* - Array<{@link Point}> - [inner corner 0, outer corner 0, inner corner 1,
|
|
55
|
+
* outer corner 1, inner corner 2...]
|
|
56
|
+
* - Array<`number`> - interlaced points of triangles used to draw a polygon line
|
|
57
|
+
* @group Geometry Creation
|
|
58
|
+
*/
|
|
59
|
+
declare function polygonLine(options: OBJ_PolygonLinePoints): Point[] | number[];
|
|
60
|
+
export { polygon, polygonLine, };
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { TypeParsableLine } from '../geometry/Line';
|
|
2
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
3
|
+
import type { Point } from '../geometry/Point';
|
|
4
|
+
/**
|
|
5
|
+
* Cone options object.
|
|
6
|
+
*
|
|
7
|
+
* By default, a cone with its base at the origin and its tip along the x axis
|
|
8
|
+
* will be created.
|
|
9
|
+
*
|
|
10
|
+
* @property {number} [sides] number of sides (`10`)
|
|
11
|
+
* @property {number} [radius] radius of cone base
|
|
12
|
+
* @property {'curve' | 'flat'} [normals] `flat` normals will make light
|
|
13
|
+
* shading across a face cone constant. `curve` will gradiate the shading. Use
|
|
14
|
+
* `curve` to make a surface look more round with fewer number of sides.
|
|
15
|
+
* (`flat`)
|
|
16
|
+
* @property {TypeParsableLine} [line] line that can position and
|
|
17
|
+
* orient the cone. First point of line is cone base center, and second point
|
|
18
|
+
* is cone tip.
|
|
19
|
+
* @property {number} [length] length of the cone along the x axis if
|
|
20
|
+
* `line` isn't defined (`1`)
|
|
21
|
+
* @property {number} [rotation] rotation of base - this is only noticable for
|
|
22
|
+
* small numbers of sides (`0`)
|
|
23
|
+
* @property {TypeParsableTransform} [transform] transform to apply to all
|
|
24
|
+
* points of cube
|
|
25
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
26
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
27
|
+
* representing two triangles per face and an
|
|
28
|
+
* associated normal for each point will be returned.
|
|
29
|
+
* @interface
|
|
30
|
+
* @group Misc Geometry Creation
|
|
31
|
+
*/
|
|
32
|
+
export type OBJ_ConePoints = {
|
|
33
|
+
sides?: number;
|
|
34
|
+
radius?: number;
|
|
35
|
+
normals?: 'curve' | 'flat';
|
|
36
|
+
line?: TypeParsableLine;
|
|
37
|
+
length?: number;
|
|
38
|
+
rotation?: number;
|
|
39
|
+
transform?: TypeParsableTransform;
|
|
40
|
+
lines?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Return points of a cone.
|
|
44
|
+
*
|
|
45
|
+
* The points can either represent the triangles that make up each face, or
|
|
46
|
+
* represent the start and end points lines that are the edges of each face of
|
|
47
|
+
* the cone.
|
|
48
|
+
*
|
|
49
|
+
* If the points represent triangles, then a second array of normal vectors
|
|
50
|
+
* for each point will be available.
|
|
51
|
+
*
|
|
52
|
+
* @property {OBJ_CubePoints} options cone options
|
|
53
|
+
* @return {[Array<Point>, Array<Point>]} an array of points and normals. If
|
|
54
|
+
* the points represent lines, then the array of normals will be empty.
|
|
55
|
+
* @group Geometry Creation
|
|
56
|
+
*/
|
|
57
|
+
export default function cone(options: OBJ_ConePoints): [Point[]] | [Point[], Point[]];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TypeParsablePoint, Point } from '../geometry/Point';
|
|
2
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
3
|
+
/**
|
|
4
|
+
* Cube options object.
|
|
5
|
+
*
|
|
6
|
+
* By default, a cube will be constructed around the origin, with the xyz axes
|
|
7
|
+
* being normal to the cube faces.
|
|
8
|
+
*
|
|
9
|
+
* @property {number} [side] side length (`1`)
|
|
10
|
+
* @property {TypeParsablePoint} [center] center point (`[0, 0]`)
|
|
11
|
+
* @property {TypeParsableTransform} [transform] transform to apply to all
|
|
12
|
+
* points of cube
|
|
13
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
14
|
+
* the 12 edges of the cube will be returned. If `false`, then points
|
|
15
|
+
* representing two triangles per face (12 triangles, 36 points) and an
|
|
16
|
+
* associated normal for each point will be returned. (`false`)
|
|
17
|
+
* @interface
|
|
18
|
+
* @group Misc Geometry Creation
|
|
19
|
+
*/
|
|
20
|
+
export type OBJ_CubePoints = {
|
|
21
|
+
side?: number;
|
|
22
|
+
center?: TypeParsablePoint;
|
|
23
|
+
transform?: TypeParsableTransform;
|
|
24
|
+
lines?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export default function cube(options: OBJ_CubePoints): [Point[]] | [Point[], Point[]];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TypeParsableLine } from '../geometry/Line';
|
|
2
|
+
import type { TypeParsableTransform } from '../geometry/Transform';
|
|
3
|
+
import type { Point } from '../geometry/Point';
|
|
4
|
+
/**
|
|
5
|
+
* Cylinder options object.
|
|
6
|
+
*
|
|
7
|
+
* By default, a cylinder along the x axis will be created.
|
|
8
|
+
*
|
|
9
|
+
* @property {number} [sides] number of cylinder sides (`10`)
|
|
10
|
+
* @property {number} [radius] radius of cylinder (`1`)
|
|
11
|
+
* @property {'curve' | 'flat'} [normals] `flat` normals will make
|
|
12
|
+
* shading (from light source) across a face cone constant.
|
|
13
|
+
* `curve` will gradiate the shading. Use `curve` to make a surface look more
|
|
14
|
+
* round with fewer number of sides. (`flat`)
|
|
15
|
+
* @property {TypeParsableLine} [line] line that can position and
|
|
16
|
+
* orient the cylinder. First point of line is cylinder base center, and second
|
|
17
|
+
* point is the top center.
|
|
18
|
+
* @property {number} [length] length of the cylinder if `line` isn't
|
|
19
|
+
* defined (`1`)
|
|
20
|
+
* @property {boolean | 1 | 2} [ends] `true` fills both ends of the cylinder.
|
|
21
|
+
* `false` does not fill ends. `1` fills only the first end. `2` fills only the
|
|
22
|
+
* the second end. (`true`)
|
|
23
|
+
* @property {number} [rotation] rotation of base - this is only noticable for
|
|
24
|
+
* small numbers of sides (`0`)
|
|
25
|
+
* @property {TypeParsableTransform} [transform] transform to apply to all
|
|
26
|
+
* points of cube
|
|
27
|
+
* @property {boolean} [lines] if `true` then points representing
|
|
28
|
+
* the edes of the faces will be returned. If `false`, then points
|
|
29
|
+
* representing two triangles per face and an
|
|
30
|
+
* associated normal for each point will be returned.
|
|
31
|
+
* @interface
|
|
32
|
+
* @group Misc Geometry Creation
|
|
33
|
+
*/
|
|
34
|
+
export type OBJ_CylinderPoints = {
|
|
35
|
+
sides?: number;
|
|
36
|
+
radius?: number;
|
|
37
|
+
normals?: 'curve' | 'flat';
|
|
38
|
+
line?: TypeParsableLine;
|
|
39
|
+
length?: number;
|
|
40
|
+
ends?: boolean | 1 | 2;
|
|
41
|
+
rotation?: number;
|
|
42
|
+
transform?: TypeParsableTransform;
|
|
43
|
+
lines?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export default function cylinder(options: OBJ_CylinderPoints): [Point[]] | [Point[], Point[]];
|