
Security News
CISA Extends MITRE Contract as Crisis Accelerates Alternative CVE Coordination Efforts
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
A mesh replacement for `THREE.Line`. Instead of using GL_LINE, it uses a strip of billboarded triangles. This is a fork of [spite/THREE.MeshLine](https://github.com/spite/THREE.MeshLine).
A mesh replacement for THREE.Line
. Instead of using GL_LINE, it uses a strip of billboarded triangles. This is a fork of spite/THREE.MeshLine.
npm install meshline
import * as THREE from 'three'
import { MeshLineGeometry, MeshLineMaterial } from 'meshline'
First, create the list of numbers that will define the 3D points for the line.
const points = []
for (let j = 0; j < Math.PI; j += (2 * Math.PI) / 100) {
points.push(Math.cos(j), Math.sin(j), 0)
}
Once you have that, you can create a new MeshLineGeometry
, and call .setPoints()
passing the list of points.
const geometry = new MeshLineGeometry()
geometry.setPoints(points)
Note: .setPoints
accepts a second parameter, which is a function to define the width in each point along the line. By default that value is 1, making the line width 1 * lineWidth in the material.
// p is a decimal percentage of the number of points
// ie. point 200 of 250 points, p = 0.8
geometry.setPoints(geometry, p => 2) // makes width 2 * lineWidth
geometry.setPoints(geometry, p => 1 - p) // makes width taper
geometry.setPoints(geometry, p => 2 + Math.sin(50 * p)) // makes width sinusoidal
Cou can also provide a BufferGeometry
by calling .setGeometry()
instead.
geometry.setGeometry(myGeometry)
MeshLineGeometry
needs to be paired with MeshLineMaterial
.
const material = new MeshLineMaterial(options)
By default it's a white material of width 1 unit.
MeshLineMaterial
has several attributes to control the appereance of the MeshLine
:
map
- a THREE.Texture
to paint along the line (requires useMap
set to true)useMap
- tells the material to use map
(0 - solid color, 1 use texture)alphaMap
- a THREE.Texture
to use as alpha along the line (requires useAlphaMap
set to true)useAlphaMap
- tells the material to use alphaMap
(0 - no alpha, 1 modulate alpha)repeat
- THREE.Vector2 to define the texture tiling (applies to map and alphaMap)color
- THREE.Color
to paint the line width, or tint the texture withopacity
- alpha value from 0 to 1 (requires transparent
set to true
)alphaTest
- cutoff value from 0 to 1dashArray
- the length and space between dashes. (0 - no dash)dashOffset
- defines the location where the dash will begin. Ideal to animate the line.dashRatio
- defines the ratio between that is visible or not (0 - more visible, 1 - more invisible).resolution
- THREE.Vector2
specifying the canvas size (REQUIRED)sizeAttenuation
- constant lineWidth regardless of distance (1 is 1px on screen) (0 - attenuate, 1 - don't)lineWidth
- float defining width (if sizeAttenuation
is true, it's world units; else is screen pixels)If you're rendering transparent lines or using a texture with alpha map, you should set depthTest
to false
, transparent
to true
and blending
to an appropriate blending mode, or use alphaTest
.
Finally, we create a mesh and add it to the scene:
const mesh = new THREE.Mesh(geometry, material)
scene.add(mesh)
You can optionally add raycast support with the following.
import { raycast } from 'meshline'
mesh.raycast = raycast
Meshline can be used declaritively. This is how it would look like in react-three-fiber. You can try it live here.
import { Canvas, extend } from '@react-three/fiber'
import { MeshLineGeometry, MeshLineMaterial, raycast } from 'meshline'
extend({ MeshLine, MeshLineMaterial })
function Line({ points, width, color }) {
return (
<Canvas>
<mesh raycast={raycast}>
<meshLineGeometry points={points} />
<meshLineMaterial
transparent
depthTest={false}
lineWidth={width}
color={color}
dashArray={0.05}
dashRatio={0.95}
/>
</mesh>
</Canvas>
)
}
Dynamic line widths can be set along each point using the widthCallback
prop.
<meshLineGeometry points={points} widthCallback={pointWidth => pointWidth * Math.random()} />
FAQs
A mesh replacement for `THREE.Line`. Instead of using GL_LINE, it uses a strip of billboarded triangles. This is a fork of [spite/THREE.MeshLine](https://github.com/spite/THREE.MeshLine), previously maintained by studio [Utsuboco](https://github.com/utsub
The npm package meshline receives a total of 339,574 weekly downloads. As such, meshline popularity was classified as popular.
We found that meshline demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Product
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
Research
The Socket Research Team investigates a malicious npm package that appears to be an Advcash integration but triggers a reverse shell during payment success, targeting servers handling transactions.