renderer.render(scene, camera);
function splitSum(sum, splits) {
const nums = [sum];
while (nums.length !== splits) {
const { val, idx } = nums.reduce(
(a, v, i) => (v > a.val ? { idx: i, val: v } : a),
{ idx: -1, val: -Infinity }
);
/* // OR
const idx = Math.floor(nums.length * Math.random());
const val = nums[idx]; */
let a, b;
do {
a = Math.round(val * Math.random());
b = val - a;
} while (a === b || nums.includes(a) || nums.includes(b));
nums.splice(idx, 1, a, b);
}
return nums;
}
location.hash = hash
прокручивает страницу до якоря. Используй History API чтобы поменять урл в адресной строке. DracoEncoderModule
подключается глобально скриптом<script src="js/libs/draco/draco_encoder.js"></script>
<script src="js/libs/draco/draco_wasm_wrapper.js"></script>
$(function () {
let timeoutId = null;
$(".sidebar").hover(
function () {
timeoutId = setTimeout(() => {
$(this).addClass("sidebar_hovered");
}, 600);
},
function () {
// change to any color that was previously used.
clearTimeout(timeoutId);
$(this).removeClass("sidebar_hovered");
}
);
});
function parse(str) {
const result = [];
let openBrackets = 0;
let regExpString = "";
for (let i = 0; i < str.length; i++) {
const char = str[i];
if (char === "{") {
openBrackets++;
if (openBrackets === 1) {
continue;
}
}
else if (char === "}") {
openBrackets--;
if (openBrackets === 0) {
regExpString = regExpString.replace(/(^\/)|(\/$)/g, "");
result.push(new RegExp(regExpString));
regExpString = "";
continue;
}
}
if (openBrackets === 0) {
switch (char) {
case "0": {
result.push(/\d/);
break;
}
default: {
result.push(char);
}
}
}
else {
regExpString += char;
}
}
return result;
}
const str = "+1({/[1-9]/}00) 000 000{/[1-9]/}";
const r = parse(str);
console.log(r); // -> ["+", "1", "(", /[1-9]/, /\d/, /\d/, ")", " ", /\d/, /\d/, /\d/, " ", /\d/, /\d/, /\d/, /[1-9]/]