Skip to content

MeshLazy ​

Experimental

Interfaces ​

InterfaceDescription
ClipUniformsClip box uniforms shared by the primitive's shader and injected three.js materials.
MeshColorInputsInputs of writeColors.

Variables ​

VariableDescription
DEFAULT_FACE_NORMALS_EPSILONPlotly's lighting.facenormalsepsilon default.
DEFAULT_LIGHTINGThe rig used for three.js material types when a figure has no scene.lighting: Plotly's default light (lightposition (1e5, 1e5, 0), moving with the view) with Plotly's default ambient and diffuse strengths.
DEFAULT_MESH_COLORPlotly's mesh3d default color (#444… is the line color; the surface default is this gray).
DEFAULT_VERTEX_NORMALS_EPSILONPlotly's lighting.vertexnormalsepsilon default.
HIDDEN_INTENSITYIntensities that are not finite are written as this and discarded by the shader.
MESH_FRAGMENT_SHADER-
MESH_SORT_LIMITAbove this many triangles, sortTriangles: 'auto' leaves a translucent mesh unsorted.
MESH_VERTEX_SHADER-
PLOTLY_LIGHTING-
PLOTLY_LIGHTPOSITIONPlotly's lightposition default (clip space).

Functions ​

FunctionDescription
applyMaterialParamsSet a spec's parameters on the material's matching properties (see the module comment).
clipToViewUn-project a Plotly lightposition (clip space) into view space through the camera's inverse projection (column-major), as gl-mesh3d does. Writes [x, y, z, 1], or a direction [x, y, z, 0] when the point is at infinity.
computeFaceNormalsPlotly's face normals, one per triangle (3 * triangleCount floats), in data space. See the module comment for epsilon and scale.
computeVertexNormalsPlotly's angle-weighted vertex normals, one per vertex (positions.length floats), in data space. See the module comment for epsilon and scale.
computeViewLightsThe lights of spec in view space for the Plotly shader, scaled by the trace's lighting: ambient and hemisphere light by ambient; directional lights keep their color (the shader multiplies diffuse and specular). Without a spec: Plotly's single white light at lightposition and a white ambient light.
cornerVertexVertex of corner k (triangle floor(k / 3)).
createLightRigCreate a LightRig (default: DEFAULT_LIGHTING).
createMeshPrimitiveCreate a MeshPrimitive. object: an existing (placeholder) mesh to draw into.
createThreeMaterialCreate the three.js material of spec (a three.js type), seeded from Plotly's lighting, with the clip box injected. The caller disposes it and material.userData.gradient (toon).
createToonGradientA toon gradient of steps bands (nearest-filtered, so the shading steps).
createViewLights-
defaultNormalScaleDefault normal scale: each axis' finite extent mapped to 2 (Plotly's scene cube), 1 for flat or empty axes.
gatherVerticesCopy per-vertex values (size floats per vertex) to drawn items, e.g. positions or normals of expanded geometry.
hasTranslucencyWhether any drawn color is translucent (alpha < 1).
injectClipDiscard fragments outside the clip box in a three.js material (HC_CLIP define).
intensityOriginCenter of the finite range of values (0 when none): the intensity origin.
isThreeMaterialTypeWhether a material type is drawn with a three.js material (not the primitive's shader).
isValidTriangleWhether all three vertices of triangle t are valid.
isValidVertexWhether vertex v has finite, visible coordinates (and exists).
itemVertexInput vertex of drawn item i.
lightViewPositionView-space direction or position of a directional light (see DirectionalLightSpec).
meshColorSource-
meshTriangleCountNumber of triangles: indices.length / 3, or vertexCount / 3 without indices.
needsColorAttributeWhether the drawn items need a per-item color attribute: always for per-vertex / per-face colors and for intensity mapped on the CPU (three.js materials); for one color, or intensity in the shader, only to carry per-vertex alpha.
orderTranslucentGive the translucent meshes among objects (searched recursively) render orders base, base + step, … from the farthest to the nearest (view depth of their world bounding box center), for scenes where three.js' own depth sort doesn't apply. Returns the next free order.
reorderTrianglesWrite index reordered by triangle order into out.
resolveMeshLightingPlotly's defaults for missing or non-finite values, clamped to Plotly's attribute ranges.
shininessFromRoughnessPhong shininess with the highlight width of a Beckmann roughness (2 / r² - 2).
sortTrianglesByDepthTriangle draw order, farthest first. centroids holds 3 floats per triangle in the mesh's local space (NaN: invalid, drawn first); modelView is the column-major model-view matrix (only its third row, the view-space z, is read). Returns order (triangle indices).
srgbToLinearsRGB → linear (three.js materials expect linear vertex colors).
triangleCentroidsCentroids (3 floats per triangle) of drawn triangles; NaN for invalid triangles.
writeColorsPer-item RGBA colors (straight alpha, per-vertex alpha multiplied in). In the Plotly shader's intensity mode the RGB is unused (white) and only alpha is carried.
writeIntensityPer-item intensity relative to origin (float32 keeps precision for values with a large common offset): per vertex, or per triangle ('cell', expanded layouts). Non-finite and missing values become HIDDEN_INTENSITY.

References ​

DirectionalLightSpec ​

Re-exports DirectionalLightSpec


LightingSpec ​

Re-exports LightingSpec


LightRig ​

Re-exports LightRig


LightSpace ​

Re-exports LightSpace


MeshColorSource ​

Re-exports MeshColorSource


MeshData ​

Re-exports MeshData


MeshIndexArray ​

Re-exports MeshIndexArray


MeshInput ​

Re-exports MeshInput


MeshLayout ​

Re-exports MeshLayout


MeshLighting ​

Re-exports MeshLighting


MeshMaterialSpec ​

Re-exports MeshMaterialSpec


MeshMaterialType ​

Re-exports MeshMaterialType


MeshPrimitive ​

Re-exports MeshPrimitive


MeshShaderHooks ​

Re-exports MeshShaderHooks


ViewLights ​

Re-exports ViewLights

Released under the MIT License.