Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dxf-viewer

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dxf-viewer - npm Package Compare versions

Comparing version 1.0.24 to 1.0.25

src/DxfScene.js.orig

2

package.json
{
"name": "dxf-viewer",
"version": "1.0.24",
"version": "1.0.25",
"description": "JavaScript DXF file viewer",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -37,3 +37,3 @@ # DXF viewer [![npm](https://img.shields.io/npm/v/dxf-viewer)](https://www.npmjs.com/package/dxf-viewer)

There are still many incomplete features. I will try to implement some of them when I have some
time. Anything useful implemented in the corporate repository will be merged here as well.
time. Most significant reason for missing implementation is lack of corresponding sample files.

@@ -54,3 +54,4 @@ * Stream parsing for input file. Currently, mostly relying on dxf-parser package which is not

* Smoothed polyline (curve-fit/spline-fit addition vertices).
* Hatching
* Some features in hatching implementation: outer hatching style, solid/gradient infill, MPolygon
support, double lines, boundaries defined by external entities.
* Block instancing in a grid. Grid attributes are ignored now.

@@ -57,0 +58,0 @@ * Dimensions-specific features and styles (various pre-defined arrowhead blocks, text positioning

@@ -118,2 +118,6 @@ import * as three from "three"

GetDxf() {
return this.parsedDxf
}
SetSize(width, height) {

@@ -171,5 +175,6 @@ this._EnsureRenderer()

this.worker = new DxfWorker(workerFactory ? workerFactory() : null)
const scene = await this.worker.Load(url, fonts, this.options, progressCbk)
const {scene, dxf} = await this.worker.Load(url, fonts, this.options, progressCbk)
await this.worker.Destroy()
this.worker = null
this.parsedDxf = dxf

@@ -684,2 +689,4 @@ this.origin = scene.origin

sceneOptions: DxfScene.DefaultOptions,
/** Retain the simple object representing the parsed DXF - will consume a lot of additional memory */
retainParsedDxf: false,
}

@@ -686,0 +693,0 @@

@@ -80,3 +80,3 @@ import {DxfFetcher} from "./DxfFetcher"

case DxfWorker.WorkerMsg.LOAD: {
const scene = await this._Load(
const {scene, dxf} = await this._Load(
data.url,

@@ -89,3 +89,3 @@ data.fonts,

transfers.push(scene.transforms)
return scene
return {scene, dxf}
}

@@ -162,3 +162,3 @@ case DxfWorker.WorkerMsg.DESTROY:

await dxfScene.Build(dxf, fontFetchers)
return dxfScene.scene
return {scene: dxfScene.scene, dxf: options.retainParsedDxf === true ? dxf : undefined }
}

@@ -165,0 +165,0 @@

@@ -437,4 +437,6 @@ // Forked from three/examples/js/controls/OrbitControls.js to implement additional features (e.g.

// orthographic
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom /
element.clientWidth / window.devicePixelRatio, scope.object.matrix );
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom /
element.clientHeight / window.devicePixelRatio, scope.object.matrix );

@@ -574,3 +576,4 @@ } else {

panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
panDelta.subVectors( panEnd, panStart )
.multiplyScalar( scope.panSpeed * window.devicePixelRatio );

@@ -594,4 +597,5 @@ pan( panDelta.x, panDelta.y );

const canvasRect = scope.domElement.getBoundingClientRect()
const zoomCenter = new THREE.Vector2(event.clientX - canvasRect.left,
event.clientY - canvasRect.top)
const zoomCenter = new THREE.Vector2(
(event.clientX - canvasRect.left) * window.devicePixelRatio,
(event.clientY - canvasRect.top) * window.devicePixelRatio)

@@ -690,3 +694,4 @@ if ( event.deltaY < 0 ) {

(event.touches[0].clientX + event.touches[1].clientX) / 2 - canvasRect.left,
(event.touches[0].clientY + event.touches[1].clientY) / 2 - canvasRect.top );
(event.touches[0].clientY + event.touches[1].clientY) / 2 - canvasRect.top )
.multiplyScalar(window.devicePixelRatio);

@@ -760,3 +765,4 @@ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;

panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
panDelta.subVectors( panEnd, panStart )
.multiplyScalar( scope.panSpeed * window.devicePixelRatio );

@@ -763,0 +769,0 @@ pan( panDelta.x, panDelta.y );

@@ -7,2 +7,3 @@ import DxfArrayScanner from './DxfArrayScanner';

import AttDef from './entities/attdef';
import Attribute from './entities/attribute'
import Circle from './entities/circle';

@@ -20,2 +21,3 @@ import Dimension from './entities/dimension';

import Text from './entities/text';
import Hatch from './entities/hatch';
import dimStyleCodes from './DimStyleCodes';

@@ -38,2 +40,3 @@ //import Vertex from './entities/';

dxfParser.registerEntityHandler(AttDef);
dxfParser.registerEntityHandler(Attribute);
dxfParser.registerEntityHandler(Circle);

@@ -51,2 +54,3 @@ dxfParser.registerEntityHandler(Dimension);

dxfParser.registerEntityHandler(Text);
dxfParser.registerEntityHandler(Hatch);
//dxfParser.registerEntityHandler(require('./entities/vertex'));

@@ -688,2 +692,77 @@ }

var parseStyles = function () {
var styles = {};
var style = {};
var styleName;
log.debug('Style {');
curr = scanner.next();
while (!groupIs(0, END_OF_TABLE_VALUE)) {
switch (curr.code) {
case 100:
style.subClassMarker = curr.value;
curr = scanner.next();
break;
case 2:
style.styleName = curr.value;
styleName = curr.value;
curr = scanner.next();
break;
case 70:
style.standardFlag = curr.value;
curr = scanner.next();
break;
case 40:
style.fixedTextHeight = curr.value;
curr = scanner.next();
break;
case 41:
style.widthFactor = curr.value;
curr = scanner.next();
break;
case 50:
style.obliqueAngle = curr.value;
curr = scanner.next();
break;
case 71:
style.textGenerationFlag = curr.value;
curr = scanner.next();
break;
case 42:
style.lastHeight = curr.value;
curr = scanner.next();
break;
case 3:
style.font = curr.value;
curr = scanner.next();
break;
case 4:
style.bigFont = curr.value;
curr = scanner.next();
break;
case 1071:
style.extendedFont = curr.value;
curr = scanner.next();
break;
case 0:
if (curr.value === 'STYLE') {
log.debug('}');
styles[styleName] = style;
log.debug('Style {');
style = {};
styleName = undefined;
curr = scanner.next();
}
break;
default:
logUnhandledGroup(curr);
curr = scanner.next();
break;
}
}
log.debug('}');
styles[styleName] = style;
return styles;
};
var tableDefinitions = {

@@ -713,3 +792,9 @@ VPORT: {

parseTableRecords: parseDimStyles
}
},
STYLE: {
tableRecordsProperty: 'styles',
tableName: 'style',
dxfSymbolName: 'STYLE',
parseTableRecords: parseStyles,
},
};

@@ -716,0 +801,0 @@

@@ -27,3 +27,2 @@

entity.endAngle = Math.PI / 180 * curr.value;
entity.angleLength = entity.endAngle - entity.startAngle; // angleLength is deprecated
break;

@@ -30,0 +29,0 @@ case 210:

@@ -0,4 +1,3 @@

import * as helpers from '../ParseHelpers';
import * as helpers from '../ParseHelpers'
export default function EntityParser() {}

@@ -8,8 +7,8 @@

EntityParser.prototype.parseEntity = function(scanner, curr) {
EntityParser.prototype.parseEntity = function (scanner, curr) {
var entity = {
type: curr.value,
scale: 1,
textStyle: 'STANDARD'
};
textStyle: 'STANDARD',
};
curr = scanner.next();

@@ -20,68 +19,69 @@ while (curr !== 'EOF') {

}
switch(curr.code) {
case 1:
entity.text = curr.value;
break;
case 2:
entity.tag = curr.value;
break;
case 3:
entity.prompt = curr.value;
break;
case 7:
entity.textStyle = curr.value;
break;
case 10: // X coordinate of 'first alignment point'
entity.startPoint = helpers.parsePoint(scanner);
break;
case 11: // X coordinate of 'second alignment point'
entity.endPoint = helpers.parsePoint(scanner);
break;
case 39:
entity.thickness = curr.value;
break;
case 40:
entity.textHeight = curr.value;
break;
case 41:
entity.scale = curr.value;
break;
case 50:
entity.rotation = curr.value;
break;
case 51:
entity.obliqueAngle = curr.value;
break;
case 70:
entity.invisible = !!(curr.value & 0x01);
entity.constant = !!(curr.value & 0x02);
entity.verificationRequired = !!(curr.value & 0x04);
entity.preset = !!(curr.value & 0x08);
break;
case 71:
entity.backwards = !!(curr.value & 0x02);
entity.mirrored = !!(curr.value & 0x04);
break;
case 72:
// TODO: enum values?
entity.horizontalJustification = curr.value;
break;
case 73:
entity.fieldLength = curr.value;
break;
case 74:
// TODO: enum values?
entity.verticalJustification = curr.value;
break;
case 100:
break;
case 101:
helpers.skipEmbeddedObject(scanner);
break;
case 210:
entity.extrusionDirection = helpers.parsePoint(scanner);
break;
default:
helpers.checkCommonEntityProperties(entity, curr, scanner);
break;
switch (curr.code) {
case 1:
entity.text = curr.value;
break;
case 2:
entity.tag = curr.value;
break;
case 3:
entity.prompt = curr.value;
break;
case 7:
entity.textStyle = curr.value;
break;
break;
case 10: // X coordinate of 'first alignment point'
entity.startPoint = helpers.parsePoint(scanner);
break;
case 11: // X coordinate of 'second alignment point'
entity.endPoint = helpers.parsePoint(scanner);
break;
case 39:
entity.thickness = curr.value;
break;
case 40:
entity.textHeight = curr.value;
break;
case 41:
entity.scale = curr.value;
break;
case 50:
entity.rotation = curr.value;
break;
case 51:
entity.obliqueAngle = curr.value;
break;
case 70:
entity.invisible = !!(curr.value & 0x01);
entity.constant = !!(curr.value & 0x02);
entity.verificationRequired = !!(curr.value & 0x04);
entity.preset = !!(curr.value & 0x08);
break;
case 71:
entity.backwards = !!(curr.value & 0x02);
entity.mirrored = !!(curr.value & 0x04);
break;
case 72:
// TODO: enum values?
entity.horizontalJustification = curr.value;
break;
case 73:
entity.fieldLength = curr.value;
break;
case 74:
// TODO: enum values?
entity.verticalJustification = curr.value;
break;
case 100:
break;
case 101:
helpers.skipEmbeddedObject(scanner);
break;
case 210:
entity.extrusionDirection = helpers.parsePoint(scanner);
break;
default:
helpers.checkCommonEntityProperties(entity, curr, scanner);
break;
}

@@ -88,0 +88,0 @@ curr = scanner.next();

@@ -26,5 +26,7 @@

case 41:
/* Already in radians. */
entity.startAngle = curr.value;
break;
case 42:
/* Already in radians. */
entity.endAngle = curr.value;

@@ -31,0 +33,0 @@ break;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc