Class Link3D
Object
Object3D
GeometryObject
Mesh
Link3D
Renderer for thick 3D links. Each link segment is expanded into a small open
prism in world coordinates, which gives links a proper depth relationship to
spheres and to other links while keeping the appearance unlit and simple.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMinimal unlit shader for world-space link prisms.Nested classes/interfaces inherited from class Object3D
Object3D.ObjectHandler, Object3D.Traverse -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Vector3Temporary storage for the link axis.private final Vector3Temporary helper axis used to construct an orthonormal basis around the link axis.private BufferAttributePer-vertex colors used to support directional gradients.private static final ColorFallback color used when link geometry does not provide vertex colors.private static final intNumber of rectangular side faces per link prism.private intNumber of link segments the current buffers were allocated for.private static final doubleThreshold used when choosing a helper axis for constructing the prism basis.private doubleCurrent link width in world coordinates.private intNumber of link segments stored in the current geometry.private ColorFallback color used when rebuilding links without explicit vertex colors.private GeometrySource line geometry used to rebuild thick-link prisms after width changes.private static final doubleSmallest admissible squared link length.private static final doubleSmallest admissible link width in world coordinates.private BufferAttributeVertex positions required by the renderer.private final Vector3Temporary first basis vector spanning the prism cross-section.private final Vector3Temporary second basis vector spanning the prism cross-section.private final ShaderMaterialMaterial wrapping the custom shader.private static final intNumber of triangle vertices used per rectangular side face.private static final intNumber of triangle vertices used per link segment.Fields inherited from class Mesh
__webglMorphTargetInfluences, morphTargetBase, morphTargetForcedOrder, morphTargetInfluencesFields inherited from class GeometryObject
geometry, materialFields inherited from class Object3D
__webglActive, __webglInit, _modelViewMatrix, _normalMatrix, children, DefaultUp, handler, id, isCastShadow, isFrustumCulled, isReceiveShadow, matrix, matrixAutoUpdate, matrixWorld, matrixWorldNeedsUpdate, name, parent, position, quaternion, rotation, rotationAutoUpdate, scale, up, visible -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Hide all links from this mesh while keeping the allocated buffers intact.private BufferAttributecreateAttribute(int vertices, int itemSize) Create a floating-point buffer attribute.private voidcreateGeometry(int links) Allocate or resize the buffer geometry used for the current link count while keeping the mesh and geometry instances stable.private voidensureGeometry(int links) Ensure that the backing geometry has capacity for the requested link count.private ColorgetVertexColor(List<Color> colors, int index, Color fallbackColor) Resolve the color for one line vertex.private voidForce the renderer to upload fresh GPU buffers for the current attributes.private voidMark all geometry buffers as dirty after an update.private voidRebuild the prism geometry from the cached source lines and current width.voidsetLineWidth(double lineWidth) Set the thickness of the rendered links in world coordinates.voidUpdate the links rendered by this mesh.voidUpdate the links rendered by this mesh.private intwriteFace(int vertexOffset, Vector3 start, Vector3 end, Color startColor, Color endColor, double uA, double vA, double uB, double vB) Write one rectangular side face of the link prism.private voidWrite one thick-link prism into the underlying buffers.private voidwriteVertex(int index, double x, double y, double z, Color color) Write one triangle vertex to the underlying buffers.Methods inherited from class Mesh
clone, clone, clone, createBuffers, deleteBuffers, initBuffers, raycast, renderBuffer, setBuffers, updateMorphTargetsMethods inherited from class GeometryObject
getGeometry, getMaterial, initCustomAttributes, setGeometry, setLineWidth, setMaterialMethods inherited from class Object3D
add, add, applyMatrix, clone, clone, getChildren, getChildrenByClass, getId, getMatrix, getMatrixWorld, getName, getObjectById, getObjectByName, getParent, getPosition, getQuaternion, getRenderDepth, getRotation, getScale, getUp, getWorldDirection, getWorldDirection, getWorldPosition, getWorldPosition, getWorldQuaternion, getWorldQuaternion, getWorldRotation, getWorldRotation, getWorldScale, getWorldScale, isCastShadow, isFrustumCulled, isMatrixAutoUpdate, isMatrixWorldNeedsUpdate, isReceiveShadow, isRotationAutoUpdate, isVisible, localToWorld, lookAt, remove, remove, rotateOnAxis, rotateX, rotateY, rotateZ, setCastShadow, setChildren, setFrustumCulled, setHandler, setMatrix, setMatrixAutoUpdate, setMatrixWorld, setMatrixWorldNeedsUpdate, setName, setParent, setPosition, setQuaternion, setReceiveShadow, setRenderDepth, setRotation, setRotationAutoUpdate, setRotationFromAxisAngle, setRotationFromEuler, setRotationFromMatrix, setRotationFromQuaternion, setScale, setUp, setVisible, toString, translateOnAxis, translateX, translateY, translateZ, traverse, traverseVisible, updateMatrix, updateMatrixWorld, worldToLocal
-
Field Details
-
FACES_PER_LINK
private static final int FACES_PER_LINKNumber of rectangular side faces per link prism.- See Also:
-
VERTICES_PER_FACE
private static final int VERTICES_PER_FACENumber of triangle vertices used per rectangular side face.- See Also:
-
VERTICES_PER_LINK
private static final int VERTICES_PER_LINKNumber of triangle vertices used per link segment.- See Also:
-
MIN_LINK_WIDTH
private static final double MIN_LINK_WIDTHSmallest admissible link width in world coordinates.- See Also:
-
MIN_AXIS_LENGTH2
private static final double MIN_AXIS_LENGTH2Smallest admissible squared link length.- See Also:
-
HELPER_AXIS_Z_THRESHOLD
private static final double HELPER_AXIS_Z_THRESHOLDThreshold used when choosing a helper axis for constructing the prism basis.- See Also:
-
DEFAULT_COLOR
Fallback color used when link geometry does not provide vertex colors. -
positionAttribute
Vertex positions required by the renderer. -
colorAttribute
Per-vertex colors used to support directional gradients. -
shaderMaterial
Material wrapping the custom shader. -
axis
Temporary storage for the link axis. -
axisHelper
Temporary helper axis used to construct an orthonormal basis around the link axis. -
radialU
Temporary first basis vector spanning the prism cross-section. -
radialV
Temporary second basis vector spanning the prism cross-section. -
linkCount
private int linkCountNumber of link segments stored in the current geometry. -
geometryLinkCount
private int geometryLinkCountNumber of link segments the current buffers were allocated for. -
lineWidth
private double lineWidthCurrent link width in world coordinates. -
linkGeometry
Source line geometry used to rebuild thick-link prisms after width changes. -
linkFallbackColor
Fallback color used when rebuilding links without explicit vertex colors.
-
-
Constructor Details
-
Link3D
public Link3D()Create an empty 3D link mesh.
-
-
Method Details
-
clear
public void clear()Hide all links from this mesh while keeping the allocated buffers intact. -
setLineWidth
public void setLineWidth(double lineWidth) Set the thickness of the rendered links in world coordinates.- Parameters:
lineWidth- the desired link width
-
rebuildLinks
private void rebuildLinks()Rebuild the prism geometry from the cached source lines and current width. -
createGeometry
private void createGeometry(int links) Allocate or resize the buffer geometry used for the current link count while keeping the mesh and geometry instances stable.- Parameters:
links- the number of link segments
-
ensureGeometry
private void ensureGeometry(int links) Ensure that the backing geometry has capacity for the requested link count.- Parameters:
links- the number of link segments to render
-
invalidateGpuBuffers
private void invalidateGpuBuffers()Force the renderer to upload fresh GPU buffers for the current attributes. Parallax caches WebGL buffers behind each attribute, so dynamic link updates must invalidate those handles explicitly. -
createAttribute
Create a floating-point buffer attribute.- Parameters:
vertices- the number of verticesitemSize- the number of components per vertex- Returns:
- the new attribute
-
markGeometryDirty
private void markGeometryDirty()Mark all geometry buffers as dirty after an update.