dxf-viewer
Advanced tools
Comparing version 1.0.28 to 1.0.29
{ | ||
"name": "dxf-viewer", | ||
"version": "1.0.28", | ||
"version": "1.0.29", | ||
"description": "JavaScript DXF file viewer", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,4 +5,5 @@ import DxfParser from "./parser/DxfParser" | ||
export class DxfFetcher { | ||
constructor(url) { | ||
constructor(url, encoding = "utf-8") { | ||
this.url = url | ||
this.encoding = encoding | ||
} | ||
@@ -20,3 +21,3 @@ | ||
let buffer = "" | ||
let decoder = new TextDecoder("utf-8") | ||
let decoder = new TextDecoder(this.encoding) | ||
while(true) { | ||
@@ -41,2 +42,2 @@ const {done, value} = await reader.read() | ||
} | ||
} | ||
} |
@@ -358,2 +358,10 @@ import * as three from "three" | ||
/** | ||
* @return {?{maxX: number, maxY: number, minX: number, minY: number}} Scene bounds in model | ||
* space coordinates. Null if empty scene. | ||
*/ | ||
GetBounds() { | ||
return this.bounds | ||
} | ||
/** Subscribe to the specified event. The following events are defined: | ||
@@ -662,5 +670,5 @@ * * "loaded" - new scene loaded. | ||
canvasHeight: 300, | ||
/** Automatically resize canvas when the container is resized. This options | ||
* utilizes ResizeObserver API which is still not fully standardized. The specified canvas size | ||
* is ignored if the option is enabled. | ||
/** Automatically resize canvas when the container is resized. This options utilizes | ||
* ResizeObserver API which is still not fully standardized. The specified canvas size is | ||
* ignored if the option is enabled. | ||
*/ | ||
@@ -690,6 +698,16 @@ autoResize: false, | ||
sceneOptions: DxfScene.DefaultOptions, | ||
/** Retain the simple object representing the parsed DXF - will consume a lot of additional memory */ | ||
/** Retain the simple object representing the parsed DXF - will consume a lot of additional | ||
* memory. | ||
*/ | ||
retainParsedDxf: false, | ||
/** Whether to preserve the buffers until manually cleared or overwritten */ | ||
preserveDrawingBuffer: false | ||
/** Whether to preserve the buffers until manually cleared or overwritten. */ | ||
preserveDrawingBuffer: false, | ||
/** Encoding to use for decoding DXF file text content. DXF files newer than DXF R2004 (AC1018) | ||
* use UTF-8 encoding. Older files use some code page which is specified in $DWGCODEPAGE header | ||
* variable. Currently parser is implemented in such a way that encoding must be specified | ||
* before the content is parsed so there is no chance to use this variable dynamically. This may | ||
* be a subject for future changes. The specified value should be suitable for passing as | ||
* `TextDecoder` constructor `label` parameter. | ||
*/ | ||
fileEncoding: "utf-8" | ||
} | ||
@@ -696,0 +714,0 @@ |
@@ -154,3 +154,3 @@ import {DxfFetcher} from "./DxfFetcher" | ||
} | ||
const dxf = await new DxfFetcher(url).Fetch(progressCbk) | ||
const dxf = await new DxfFetcher(url, options.fileEncoding).Fetch(progressCbk) | ||
if (progressCbk) { | ||
@@ -230,2 +230,2 @@ progressCbk("prepare", 0, null) | ||
} | ||
} | ||
} |
@@ -31,3 +31,4 @@ /** See TextRenderer.DefaultOptions for default values and documentation. */ | ||
retainParsedDxf: boolean, | ||
preserveDrawingBuffer: boolean | ||
preserveDrawingBuffer: boolean, | ||
fileEncoding: string | ||
} | ||
@@ -61,2 +62,3 @@ | ||
GetOrigin(): THREE.Vector2 | ||
GetBounds(): {maxX: number, maxY: number, minX: number, minY: number} | null | ||
GetRenderer(): THREE.WebGLRenderer | null | ||
@@ -63,0 +65,0 @@ GetScene(): THREE.Scene |
@@ -385,3 +385,3 @@ import DxfArrayScanner from './DxfArrayScanner'; | ||
var tableRecords = table[tableDefinition.tableRecordsProperty]; | ||
if(tableRecords) { | ||
if (tableRecords) { | ||
if(tableRecords.constructor === Array){ | ||
@@ -395,2 +395,4 @@ actualCount = tableRecords.length; | ||
} | ||
} else { | ||
table[tableDefinition.tableRecordsProperty] = [] | ||
} | ||
@@ -397,0 +399,0 @@ curr = scanner.next(); |
@@ -1,4 +0,4 @@ | ||
import {DxfScene, Entity} from "./DxfScene" | ||
import {ShapePath} from "three/src/extras/core/ShapePath" | ||
import {ShapeUtils} from "three/src/extras/ShapeUtils" | ||
import {Entity} from "./DxfScene" | ||
import {ShapePath} from "three/src/extras/core/ShapePath.js" | ||
import {ShapeUtils} from "three/src/extras/ShapeUtils.js" | ||
import {Matrix3, Vector2} from "three" | ||
@@ -5,0 +5,0 @@ import {MTextFormatParser} from "./MTextFormatParser" |
774944
18872