const
declarations for variables that are never reassigned JS-0242 920 renderer.renderAnimation = this.renderAnimation;
921 this.renderInstances.push(renderer);
922
923 let linesToRender = this.lines.slice(0, this.linesIndex - 1); 924 if (linesToRender != null && linesToRender.length > 0) {
925 await renderer.render(linesToRender);
926 }
892 async createMesh(scene) {
893 //Do a z belt fix for layer heights - so far they appear fixed but some values can be off on initial extrusions
894 if (this.zBelt) {
895 let minlh = this.lines[this.linesIndex - 1].layerHeight; 896 this.lines.forEach((l) => {
897 l.layerHeight = minlh;
898 });
714
715 async processLine(tokenString, lineNumber, filePosition, renderLine = true) {
716 //Remove the comments in the line
717 let commentIndex = tokenString.indexOf(';'); 718 if (commentIndex > -1) {
719 tokenString = tokenString.substring(0, commentIndex - 1).trim();
720 }
724 let commands = tokenString.match(/[GM]+[0-9.]+/g); //|S+
725
726 if (commands === null) {
727 let hasMove = tokenString.match(/[XYZ]+[+-]?[0-9.]+/g); 728 if (hasMove !== null) {
729 commands = this.lastCommand;
730 }
61 let cmyk = ['#00FFFF', '#FF00FF', '#FFFF00', '#000000', '#FFFFFF'];
62 //Create a default set of tools
63 for (let idx = 0; idx < 5; idx++) {
64 let tool = new Tool(); 65 tool.color = Color4.FromHexString(cmyk[idx]);
66 tool.diameter = 0.4;
67 this.tools.push(tool);
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);