
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
three-dxf-viewer
Advanced tools
DXF viewer made using dxf parser and threejs. It generates a threejs object that can be used in any scene. It also has some utility classes:
You can try it here
npm install three-dxf-viewer
To use it just initialize the main class and launch getFromFile
or getFromPath
methods.
import { DXFViewer } from 'three-dxf-viewer';
// Suppose we have a font in our application
let font = 'fonts/helvetiker_regular.typeface.json';
// Suppose we have a file input and a loading div
var file = event.target.files[0];
// Get all the geometry generated by the viewer
const viewer = new DXFViewer();
let dxf = await viewr.getFromFile( file, font );
// Add the geometry to the scene
scene.addDXF( dxf );
More examples can be found in the example folder on github.
The viewer has some properties that can be used to customize the scene:
It shows the layers of the DXF file. It can be used to hide or show layers in the scene. For more information check the layer example in the example folder.
// We can get layers from viewer
console.log( viewer.layers );
It shows the system unit of the DXF file. It can be compared with the UNITS object to obtain a descriptive name.
import { UNITS } from 'three-dxf-viewer';
// We can get units from viewer
console.log( viewer.unit );
console.log( UNITS.Meters[ viewer.unit ] );
// Or can be compared with UNITS
console.log( viewer.unit === UNITS.Meters ? 'DXF on meters' : 'DXF on other units' );
The viewer caches geometries by default. This can be changed to avoid it.
// Cache can be changed to false to avoid caching
viewer.useCache = false;
There are 4 utilities that can be used optionally with the viewer:
By default the viewer will merge Block entities. however, it is possible to merge all entities to optimize drawing big DXF files.
import { Merger, DXFViewer } from 'three-dxf-viewer';
let dxf = await new DXFViewer().getFromPath( dxfFilePath, fontPath );
const mergedObject = new Merger().merge( dxf );
scene.add( mergedObject );
The select class can be used to select entities in the scene. It will highlight the selected entity. Selection can be done by clicking on the entity or pressing Ctrl and using the selection box.
import { Select, DXFViewer } from 'three-dxf-viewer';
let dxf = await new DXFViewer().getFromPath( dxfFilePath, fontPath );
const select = new Select( three.renderer.domElement, three.camera, dxf );
select.subscribe( 'select', ( selects ) => console.log( 'Selected entities', selects ) );
scene.add( dxf );
The hover class will highlight the hovered entity by the mouse.
import { Hover, DXFViewer } from 'three-dxf-viewer';
let dxf = await new DXFViewer().getFromPath( dxfFilePath, fontPath );
const hover = new Hover( three.renderer.domElement, three.camera, dxf );
hover.subscribe( 'hover', ( hovered ) => console.log( 'Hovered entity', hovered ) );
scene.add( dxf );
Snaps classes can store all the vertices in an efficient way. This allows to get the closest vertex to a point in the scene. This is useful for example to snap to the nearest vertex when drawing lines.
import { SnapsHelper } from 'three-dxf-viewer';
let dxf = await new DXFViewer().getFromPath( dxfFilePath, fontPath );
let snaps = new SnapsHelper( dxf, renderer, scene, camera, controls );
For a more detailed explanation, there is an example folder on how to use the viewer. Download it from github an launch it with:
npm install
npm run dev
The application will be available on http://localhost:9009
FAQs
DXF viewer using ThreeJS
The npm package three-dxf-viewer receives a total of 75 weekly downloads. As such, three-dxf-viewer popularity was classified as not popular.
We found that three-dxf-viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.