Skip to content

Commit 5870a5b

Browse files
committed
docs: documentation added to classes/properties and functions
1 parent 384e6eb commit 5870a5b

File tree

17 files changed

+164
-8
lines changed

17 files changed

+164
-8
lines changed

src/components/CameraTargetMarker/CameraTargetMarker.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ import { Color, Group, Vector3 } from 'three'
88
* @expand
99
*/
1010
export type CameraTargetMarkerProps = {
11+
// radius in world units of the camera target marker
1112
radius?: number
13+
// opacity of the rendered marker
1214
opacity?: number,
15+
// color of the rendered marker
1316
color?: number | string | Color
17+
// fix/lock the position of the camera target marker to a specific position along the x-axis. Can be useful if you add multiple camera targets
1418
fixedX?: number
19+
// fix/lock the position of the camera target marker to a specific position along the y-axis. Can be useful if you add multiple camera targets
1520
fixedY?: number
21+
// fix/lock the position of the camera target marker to a specific position along the z-axis. Can be useful if you add multiple camera targets
1622
fixedZ?: number
23+
// render order
1724
renderOrder?: number
1825
}
1926

src/components/Distance/Distance.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import { DistanceContext } from './DistanceContext'
88
* @expand
99
*/
1010
export type DistanceProps = {
11+
// the minimal distance for which the child elements of this component is rendered
1112
min?: number,
13+
// the maximum distance for which the child elements of this component is rendered
1214
max: number,
15+
// if enabled, the child elements will only be loaded when within visible range, and will be unloaded/unmounted once it falls out of visible range
1316
onDemand?: boolean,
17+
// the elements that should be rendered when in visible range (min, max)
1418
children: ReactNode
1519
}
1620

src/components/Grids/BoxGrid/BoxGrid.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,51 @@ const pos = new Vector3()
1212
* @expand
1313
*/
1414
export type BoxGridProps = CommonComponentProps & {
15+
// size of the grid box in world units
1516
size?: Vec3,
17+
// the size of a grid cell in world units
1618
cellSize?: number,
19+
// number of sub divisions of a grid cell
1720
subDivisions?: number,
21+
// scale determining axes values and direction along each axis
1822
gridScale?: Vec3,
23+
// world coordinates of the grid origin (origo)
1924
gridOrigin?: Vec3,
25+
// the axes values at the specified origin (default 0,0,0)
2026
originValue?: Vec3,
27+
// line width as a factor of the cell size
2128
gridLineWidth?: number,
29+
// background color of the grid planes
2230
background?: string | Color | number,
31+
// opacity of the grid planes background color
2332
backgroundOpacity?: number,
33+
// opacity of the grid planes (including grid lines)
2434
opacity?: number,
35+
// the color of the major grid lines
2536
gridColorMajor?: string | number | Color,
37+
// the color of the minor/sub division grid lines
2638
gridColorMinor?: string | number | Color,
39+
// axes color
2740
axesColor?: string | number | Color,
41+
// axes line width as a factor of cell size
2842
axesLineWidth?: number,
43+
// the axes tick size as a factor of cell size
2944
axesTickSize?: number,
45+
// if enabled, project a shade of the objects within the grid planes, using an orthographic camera
3046
enableProjection?: boolean,
47+
// the color of the projected shade when projection is enabled
3148
projectionColor?: string | number | Color,
49+
// the quality/size of the projection texture used when projection is enabled
3250
projectionResolution?: number,
51+
// the update frequency of the projected texture when projection is enabled (ms)
3352
projectionRefreshRate?: number,
53+
// show rulers on the grid planes at the intersection point of the pointer
3454
showRulers?: boolean,
55+
// enable automatic sizing and positioning of the box grid according to its child elements
3556
autoSize?: boolean,
57+
// padding when autosize is enabled
3658
autoSizePadding?: number | Vec3 | BoxPadding,
59+
// update frequency in ms when autosize is enabled
3760
autoSizeUpdateRate?: number,
3861
}
3962

src/components/Grids/Grid/Grid.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,81 @@ import vertexShader from './shaders/vertex.glsl'
3131
* @expand
3232
*/
3333
export type GridProps = CommonComponentProps & {
34+
// which 2D plane to use for the grid (xz, xy or zy)
3435
plane: 'xz' | 'xy' | 'zy',
36+
// size of the grid plane in world units
3537
size: Vec2,
38+
// the size of a grid cell in world units
3639
cellSize?: number,
40+
// number of sub divisions of a grid cell
3741
subDivisions?: number,
42+
// world coordinates of the grid origin (origo)
3843
gridOrigin?: Vec2,
44+
// scale determining axes values and direction along each axis
3945
gridScale?: Vec2,
46+
// background color of the grid plane
4047
background?: string | Color | number,
48+
// opacity of the grid plane background color
4149
backgroundOpacity?: number,
50+
// opacity of the grid plane (including grid lines)
4251
opacity?: number,
52+
// the color of the major grid lines
4353
gridColorMajor?: string | number | Color,
54+
// the color of the minor/sub division grid lines
4455
gridColorMinor?: string | number | Color,
56+
// line width as a factor of the cell size
4557
gridLineWidth?: number,
58+
// show/hide axes including labels
4659
showAxes?: boolean,
60+
// show/hide axes labels if showAxes is true
4761
showAxesLabels?: boolean,
62+
// omit the first and last axis label if enabled
4863
trimAxesLabels?: boolean,
64+
// the relative offset of the axes in local coordinates
4965
axesOffset?: Vec2,
66+
// axes color
5067
axesColor?: string | number | Color,
68+
// axes line width as a factor of cell size
5169
axesLineWidth?: number,
70+
// the axes tick size as a factor of cell size
5271
axesTickSize?: number,
72+
// the axes values at the specified origin (default 0,0)
5373
originValue?: Vec2,
74+
// shows a radial grid if set to true
5475
radial?: boolean,
76+
// progressively adds new segments as distance from the center increases when using radial grid
5577
dynamicSegments?: boolean,
78+
// show rulers on the grid plane at the intersection point of the pointer
5679
showRulers?: boolean,
80+
// the color of the rulers
5781
rulerColor?: string | number | Color,
82+
// the ruler line width as a factor of the cell size
5883
rulerLineWidth?: number,
84+
// the ruler opacity
5985
rulerOpacity?: number,
86+
// offset along the axis perpendicular to the plane
6087
planeOffset?: number,
88+
// dynamically change cell size depending on camera distance (if set to true)
6189
dynamicCellSize?: boolean,
90+
// control thresholds and extremes when dynamic cell size is enabled
6291
cellSizeDistanceFactors?: number[][],
92+
// side to render
6393
side?: 'front' | 'back' | 'both',
94+
// allow a texture to be added to the grid plane
6495
texture?: Texture,
96+
// mixing factor for blending texture (if present) with the grid plane (0..1)
6597
textureMix?: number,
98+
// if enabled, project a shade of the objects within range onto the grid plane, using an orthographic camera
6699
enableProjection?: boolean,
100+
// determines the range used for projecting objects onto the plane when enableProjection is set to true
67101
projectionDistance?: number,
102+
// the color of the projected shade when projection is enabled
68103
projectionColor?: string | number | Color,
104+
// the quality/size of the projection texture used when projection is enabled
69105
projectionResolution?: number,
106+
// the update frequency of the projected texture when projection is enabled (ms)
70107
projectionRefreshRate?: number,
108+
// callback function for retrieving the grid coordinates when grid rulers are enabled
71109
onRulerUpdate?: ((coords: Vec2 | null) => void) | null,
72110
}
73111

src/components/Grids/Grid/UtmGrid.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useContext, useEffect, useState } from 'react'
2-
import { Grid, GridProps } from './Grid'
32
import { Vec2 } from '../../../sdk/types/common'
43
import { UtmAreaContext } from '../../UtmArea/UtmAreaContext'
4+
import { Grid, GridProps } from './Grid'
55

66
type GridConfig = {
77
origin: Vec2,
@@ -14,6 +14,7 @@ type GridConfig = {
1414
* @expand
1515
*/
1616
export type UtmGridProps = GridProps & {
17+
// use relative values for axes labels instead of absolute values if enabled
1718
relativeValues?: boolean
1819
}
1920

src/components/common.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,34 @@ import { Vec3 } from '../sdk'
77
* Common props for 3d components
88
*/
99
export type CommonComponentProps = {
10+
// will be added to the name property of the THREE.js Object3D instance
1011
name?: string
12+
// set the visible flag on the THREE.js Object3D instance
1113
visible?: boolean
14+
// set the userData object on the THREE.js Object3D instance
1215
userData?: Record<string, any>
16+
// set the position in parent's local coordinates
1317
position?: Vec3
18+
// set the castShadow property on the THREE.js Object3D instance.
1419
castShadow?: boolean
20+
// set the receiveShadow property on the THREE.js Object3D instance.
1521
receiveShadow?: boolean
22+
// set the renderOrder property on the THREE.js Object3D instance.
1623
renderOrder?: number
24+
// set the layers property on the THREE.js Object3D instance.
1725
layers?: Layers
1826
}
1927

2028
/**
2129
* Common props for 3d components that allow overriding shader materials
2230
*/
2331
export type CustomMaterialProps = {
32+
// custom material or array of materials for overriding default component material(s)
2433
customMaterial?: Material | Material[]
34+
// set a custom depth material if required
2535
customDepthMaterial?: Material
36+
// set a custom distance material if required
2637
customDistanceMaterial?: Material
38+
// callback to invoke when component is updated. Use this for setting/uppdaing uniforms in your custom material(s)
2739
onMaterialPropertiesChange?: (props: Record<string, any>, material: Material | Material[]) => void
2840
}

src/layers/layers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Layers } from 'three'
22

33
export const LAYERS = {
4-
NOT_EMITTER: 29,
5-
EMITTER: 30,
6-
OCCLUDER: 31,
4+
NOT_EMITTER: 29, // can be used to exclude an object from being used as an event emitter
5+
EMITTER: 30, // used internally to flag an object as an event emitter
6+
OCCLUDER: 31, // object will be considered in occlusion checks in the annotations system
77
}
88

99
export function createLayers(...values: number[]) {

src/sdk/geometries/curve/curve-3d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@ import { copyVec3, crossVec3, dotVec3, lengthVec3, normalizeVec3, rotateVec3 } f
77
* Interface for interpolating points on a 3d curve
88
*/
99
export interface Curve3D {
10+
// get a point at the normalized position (time) along the full curve (0 = start, 1 = end)
1011
getPointAt: (pos: number) => Vec3
12+
// get a number of samples along the curve, optionally specifying a start and end position
1113
getPoints: (nSamples: number, from?: number, to?: number) => Vec3[]
14+
// get the tangent at the normalized position (time) along the full curve (0 = start, 1 = end)
1215
getTangentAt: (pos: number) => Vec3
16+
// get a normal at the normalized position (time) along the full curve (0 = start, 1 = end)
1317
getNormalAt: (pos: number) => Vec3
18+
// get the bounding box of the full curve or optinally the segment between a from and/or to position
1419
getBoundingBox: (from?: number, to?: number) => {
1520
min: Vec3,
1621
max: Vec3,
1722
}
23+
// get the position, point and distance to this point from an abritary point
1824
nearest: (point: Vec3) => {
1925
position: number,
2026
point: Vec3,
2127
distance: number,
2228
}
29+
// the calculated length of the curve
2330
length: number,
31+
// when enabled, the curve will be closed having it's end point and start point joined
2432
closed: boolean,
2533
}
2634

src/sdk/geometries/curve/tube-geometry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ function generateTube(segments: TubeSegment[], radialSegments: number, closed: b
441441
return { vertices, indices, normals, uvs, vertexCount, indexCount }
442442
}
443443

444+
/**
445+
* Generates a fully customized tube geometry extruded from a curve.
446+
*/
444447
export function createTubeGeometry(curve: Curve3D, options: TubeGeometryOptions = {}) {
445448
const from = clamp(options.from || 0, 0, 1)
446449
const to = clamp(options.to || 1)

src/sdk/geometries/triangulate-grid-delaunay.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Delatin } from './delatin'
22

3-
3+
/**
4+
* Triangulate an elevation grid using Delaunay triangulation
5+
*/
46
export function triangulateGridDelaunay(grid: Float32Array, columns: number, scaleX = 1, scaleY = 1, nullValue: number = -1, maxError: number = 5) {
57
const width = columns
68
const height = grid.length / width

0 commit comments

Comments
 (0)