868 }
869
870 if (this.colorMode !== ColorMode.Feed) {
871 var extruder = Number(tokenString.substring(1)) % this.extruderCount; 872 if (extruder < 0) extruder = 0;
873 this.currentColor = this.tools[extruder]?.color?.clone() ?? new Color3(1, 0, 0);
874 }
929
930 chunk(arr, chunkSize) {
931 var R = [];
932 for (var i = 0, len = arr.length; i < len; i += chunkSize) R.push(arr.slice(i, i + chunkSize)); 933 return R;
934 }
935
626 return;
627 }
628
629 var lines = file.split('\n'); 630
631 //Extract metadata from slicer to set render settings
632 this.slicer.processComments(lines, this);
24 var dynamicTexture = new DynamicTexture('DynamicTexture', 50, this.scene, true);
25 dynamicTexture.hasAlpha = true;
26 dynamicTexture.drawText(text, 5, 40, 'bold 36px Arial', color, 'transparent', true);
27 var plane = Mesh.CreatePlane('TextPlane', size, this.scene, true); 28 plane.material = new StandardMaterial('TextPlaneMaterial', this.scene);
29 plane.material.backFaceCulling = false;
30 plane.material.specularColor = new Color3(0, 0, 0);
89 box.material= edgeMaterial;
90}
91
92var ViewBoxCallback; 93
94export function registerViewBoxCallback(func) {
95 ViewBoxCallback = func;
Declare variables at the top of their scope as it improves code readability, performance and also helps in code navigation.
The vars-on-top
rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. This rule forces the programmer to represent that behavior by manually moving the variable declaration to the top of its containing scope.
// Variable declarations in a block:
function doSomething() {
var first;
if (true) {
first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomething() {
for (var i=0; i<10; i++) {}
}
function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomething() {
var i;
for (i=0; i<10; i++) {}
}