@duet3d/gcodeviewer 3.7.0-alpha.1 → 3.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +35 -5
- package/dist/index.es.js +35 -5
- package/dist/lineshader.d.ts +2 -1
- package/dist/processor.d.ts +6 -2
- package/dist/viewer-proxy.d.ts +4 -0
- package/dist/viewer.d.ts +2 -0
- package/package.json +1 -1
package/dist/lineshader.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default class LineShaderMaterial {
|
|
|
7
7
|
toolBuffer: UniformBuffer;
|
|
8
8
|
renderMode: number;
|
|
9
9
|
isLineMesh: boolean;
|
|
10
|
-
static readonly vertexShader = "\n #define THIN_INSTANCES\n precision highp float;\n \n\n attribute vec3 position;\n attribute vec3 normal;\n\n attribute float filePosition;\n attribute vec3 pickColor;\n attribute float tool;\n attribute float feedRate;\n attribute float filePositionEnd;\n attribute float isPerimeter;\n attribute vec3 baseColor;\n\n uniform mat4 viewProjection;\n uniform mat4 worldView;\n uniform mat4 view;\n\n uniform float animationLength;\n uniform float currentPosition;\n uniform vec4 toolColors[20];\n uniform vec3 focusedPickColor;\n uniform float maxFeedRate;\n uniform float minFeedRate;\n uniform bool progressMode;\n uniform vec4 progressColor;\n uniform bool showSupports;\n uniform bool showTravels;\n uniform float utime;\n uniform int renderMode;\n\n uniform bool alphaMode;\n uniform bool lineMesh;\n\n varying vec3 eye_normal;\n flat out vec3 vDiffColor;\n flat out float fIsPerimeter;\n flat out float bDiscard;\n flat out float fShow;\n flat out float focused;\n\n #include<instancesDeclaration>\n\n void main()\n {\n #include<instancesVertex>\n
|
|
10
|
+
static readonly vertexShader = "\n #define THIN_INSTANCES\n precision highp float;\n \n\n attribute vec3 position;\n attribute vec3 normal;\n\n attribute float filePosition;\n attribute vec3 pickColor;\n attribute float tool;\n attribute float feedRate;\n attribute float filePositionEnd;\n attribute float isPerimeter;\n attribute vec3 baseColor;\n\n uniform mat4 viewProjection;\n uniform mat4 worldView;\n uniform mat4 view;\n\n uniform float animationLength;\n uniform float currentPosition;\n uniform vec4 toolColors[20];\n uniform vec3 focusedPickColor;\n uniform float maxFeedRate;\n uniform float minFeedRate;\n uniform bool progressMode;\n uniform vec4 progressColor;\n uniform bool showSupports;\n uniform bool showTravels;\n uniform float utime;\n uniform int renderMode;\n\n uniform bool alphaMode;\n uniform bool lineMesh;\n uniform bool perimeterOnly;\n\n varying vec3 eye_normal;\n flat out vec3 vDiffColor;\n flat out float fIsPerimeter;\n flat out float bDiscard;\n flat out float fShow;\n flat out float focused;\n\n #include<instancesDeclaration>\n\n void main()\n {\n #include<instancesVertex>\n\n fIsPerimeter = isPerimeter;\n bDiscard = 0.;\n\n // Non-perimeter geometry (infill, travels) is dropped entirely in perimeter-only mode\n if(perimeterOnly && isPerimeter < 1.0)\n {\n bDiscard = 1.;\n }\n\n switch(renderMode){\n case 0: \n vDiffColor = baseColor.rgb; \n break; // use default diffuse color;\n case 1:\n if(tool < 255.0)\n {\n vDiffColor = toolColors[int(tool)].rgb;\n }\n else\n {\n vDiffColor = vec3(1,0,0); //Travel Color Make Configurable at some point\n }\n break;\n case 2:\n float m = (feedRate - minFeedRate) / (maxFeedRate - minFeedRate);\n vDiffColor = mix(vec3(0,0,1), vec3(1,0,0), m); \n break;\n case 5:\n vDiffColor = pickColor.rgb;\n break;\n }\n\n fShow = currentPosition - filePosition;\n focused = 0.;\n\n if(focusedPickColor == pickColor && !(currentPosition >= filePosition && currentPosition <= filePositionEnd)) \n {\n vDiffColor = vec3(1, 1, 1) - vDiffColor.rgb;\n focused = 1.;\n }\n else if (tool >= 254.0) //Travel\n {\n if(fShow >= 0.0 && fShow < animationLength / 8.0)\n {\n vDiffColor = mix(vec3(1.0, 0.0, 0.0), vec3(0.5,0.0,0.0), fShow / animationLength / 2.0);\n }\n else if (showTravels && fShow >= 0.0)\n {\n vDiffColor = vec3(0.3, 0.5, 0.8); // persistent travel lines\n }\n else\n {\n bDiscard = 1.;\n }\n }\n else //Extrusion\n {\n if (fShow >= 0.0 && fShow < animationLength) \n { \n if(currentPosition < filePositionEnd){\n // float animation = smoothstep(0.0, 1.0, fract(utime / 50.0));\n float animation = sin(2.0 * 3.1415 * utime / 1000.0) * 0.5 + 0.5;\n vDiffColor = mix(vec3(0, 0, 1), vec3(0,1,0), animation);\n }\n else \n {\n vDiffColor = mix(vec3(1, 1, 1) - vDiffColor.rgb, vDiffColor.rgb, fShow / animationLength);\n }\n }\n else if (fShow >= 0.0 && progressMode) \n {\n vDiffColor = progressColor.rgb;\n }\n else if(fShow < 0.0 && !alphaMode && !progressMode)\n {\n bDiscard = 1.;\n }\n }\n\n //Final Results\n gl_Position = viewProjection * finalWorld * vec4(position, 1.0);\n mat4 n =transpose(inverse(worldView * finalWorld));\n eye_normal = (n * (vec4(normal , 1.0) * vec4(position,1.)) ).xyz;\n }";
|
|
11
11
|
static readonly fragmentShader = "\n precision highp float;\n #include<helperFunctions>\n\n const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);\n const vec3 LIGHT_FRONT_DIR = vec3(0.0, 0.0, 1.0);\n \n // x = ambient, y = top diffuse, z = front diffuse, w = global\n const vec4 light_intensity = vec4(0.45, 0.7, 0.75, 0.75);\n varying vec3 eye_normal;\n\n uniform bool lineMesh;\n uniform bool alphaMode;\n uniform bool progressMode;\n uniform float alphaValue;\n\n flat in vec3 vDiffColor;\n flat in float fIsPerimeter;\n flat in float bDiscard;\n flat in float fShow;\n flat in float focused;\n const vec3 lowerBound = vec3(0.3,0.3,0.3);\n\n void main(){\n\n if( bDiscard > 0.0) {\n discard;\n }\n\n vec4 diffuseColor = vec4(vDiffColor, 1);\n\n if(focused > 0.) \n {\n diffuseColor.a = 1.0;\n }\n else\n {\n diffuseColor.a = fShow >= 0.0 || !alphaMode ? 0.99 : alphaValue;\n }\n \n if(lineMesh) {\n if(fIsPerimeter < 1.0)\n {\n if(all(lessThan(diffuseColor.rgb,lowerBound.rgb))) {\n diffuseColor = vec4(diffuseColor.rgb + lowerBound, diffuseColor.a);\n }\n else {\n diffuseColor = vec4(diffuseColor.rgb - lowerBound, diffuseColor.a);\n }\n }\n else\n {\n diffuseColor = vec4(diffuseColor.rgb, diffuseColor.a);\n }\n gl_FragColor = diffuseColor;\n }\n else\n {\n vec3 normal = normalize(eye_normal);\n float NdotL = abs(dot(normal, LIGHT_TOP_DIR));\n float intensity = light_intensity.x + NdotL * light_intensity.y;\n NdotL = abs(dot(normal, LIGHT_FRONT_DIR));\n intensity += NdotL * light_intensity.z;\n gl_FragColor = vec4(diffuseColor.rgb * light_intensity.w * intensity, diffuseColor.a);\n }\n }";
|
|
12
12
|
constructor(scene: Scene);
|
|
13
13
|
buildMaterial(): void;
|
|
@@ -22,6 +22,7 @@ export default class LineShaderMaterial {
|
|
|
22
22
|
setAlphaValue(value: number): void;
|
|
23
23
|
setProgressMode(mode: boolean): void;
|
|
24
24
|
setShowTravels(show: boolean): void;
|
|
25
|
+
setPerimeterOnly(mode: boolean): void;
|
|
25
26
|
setProgressColor(color: number[]): void;
|
|
26
27
|
setLineMesh(mode: boolean): void;
|
|
27
28
|
showSupports(show: boolean): void;
|
package/dist/processor.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export default class Processor {
|
|
|
19
19
|
focusedColorId: number;
|
|
20
20
|
lastMeshMode: number;
|
|
21
21
|
perimeterOnly: boolean;
|
|
22
|
-
originalFile: string;
|
|
22
|
+
originalFile: string | undefined;
|
|
23
|
+
private cancelRequested;
|
|
23
24
|
nozzle: Nozzle | null;
|
|
24
25
|
positionTracker: Map<number, {
|
|
25
26
|
x: number;
|
|
@@ -61,6 +62,8 @@ export default class Processor {
|
|
|
61
62
|
diameter?: number;
|
|
62
63
|
}[]): void;
|
|
63
64
|
cleanup(): void;
|
|
65
|
+
cancelLoad(): void;
|
|
66
|
+
private throwIfCancelled;
|
|
64
67
|
dispose(): void;
|
|
65
68
|
loadFile(file: any): Promise<void>;
|
|
66
69
|
private loadFileStreamed;
|
|
@@ -74,6 +77,7 @@ export default class Processor {
|
|
|
74
77
|
getFileSize(): number;
|
|
75
78
|
getGCodeInRange(filePos: any, count?: number): void;
|
|
76
79
|
updateFilePosition(position: number, animate?: boolean): void;
|
|
80
|
+
private closestPositionData;
|
|
77
81
|
private updateNozzlePositionInstant;
|
|
78
82
|
private updateNozzlePositionAnimated;
|
|
79
83
|
animateNozzleToPosition(targetPosition: number): Promise<void>;
|
|
@@ -81,7 +85,7 @@ export default class Processor {
|
|
|
81
85
|
private buildMeshesFromWasmBuffers;
|
|
82
86
|
private createMeshesFromWasmBuffers;
|
|
83
87
|
private applyWasmBuffersToMesh;
|
|
84
|
-
setPerimeterOnly(perimeterOnly:
|
|
88
|
+
setPerimeterOnly(perimeterOnly: boolean): void;
|
|
85
89
|
showSupports(show: any): void;
|
|
86
90
|
startNozzleAnimation(): void;
|
|
87
91
|
pauseNozzleAnimation(): void;
|
package/dist/viewer-proxy.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export default class ViewerProxy {
|
|
2
2
|
private webWorker;
|
|
3
3
|
mainCanvas: HTMLCanvasElement | null;
|
|
4
|
+
private registeredListeners;
|
|
4
5
|
constructor(canvas: HTMLCanvasElement);
|
|
6
|
+
private addTrackedListener;
|
|
5
7
|
private onmessage;
|
|
6
8
|
passThru: any;
|
|
7
9
|
private onerror;
|
|
@@ -25,6 +27,7 @@ export default class ViewerProxy {
|
|
|
25
27
|
pauseNozzleAnimation(): void;
|
|
26
28
|
resumeNozzleAnimation(): void;
|
|
27
29
|
stopNozzleAnimation(): void;
|
|
30
|
+
setAllowSeek(enabled: boolean): void;
|
|
28
31
|
showViewBox(visible: boolean): void;
|
|
29
32
|
setCameraDirection(direction: {
|
|
30
33
|
x: number;
|
|
@@ -69,5 +72,6 @@ export default class ViewerProxy {
|
|
|
69
72
|
showObjectLabels(visible: boolean): void;
|
|
70
73
|
enableWasmProcessing(): Promise<void>;
|
|
71
74
|
getProcessingStats(): Promise<any>;
|
|
75
|
+
private removeAllListeners;
|
|
72
76
|
cloneEvent(event: any): {};
|
|
73
77
|
}
|
package/dist/viewer.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export default class Viewer {
|
|
|
34
34
|
buildObjects: BuildObjects | null;
|
|
35
35
|
zTopClipValue: number | null;
|
|
36
36
|
zBottomClipValue: number | null;
|
|
37
|
+
allowSeek: boolean;
|
|
37
38
|
offscreen: boolean;
|
|
38
39
|
lastFrameUpdate: number;
|
|
39
40
|
renderTimeout: number;
|
|
@@ -59,6 +60,7 @@ export default class Viewer {
|
|
|
59
60
|
frameToPrint(): void;
|
|
60
61
|
postPrintBounds(): void;
|
|
61
62
|
registerClipIgnore(mesh: any): void;
|
|
63
|
+
setAllowSeek(enabled: boolean): void;
|
|
62
64
|
showViewBox(visible: boolean): void;
|
|
63
65
|
setBackgroundColor(hexColor: string): void;
|
|
64
66
|
setCameraInertia(enabled: boolean): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duet3d/gcodeviewer",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.2",
|
|
4
4
|
"description": "G-code viewer and processor library with Babylon.js rendering and a Rust/WASM parsing fast path",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|