Skip to content

Instantly share code, notes, and snippets.

View Ni55aN's full-sized avatar

Vitaliy Stoliarov Ni55aN

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ni55an on github.
  • I am ni55an (https://keybase.io/ni55an) on keybase.
  • I have a public key ASDETJjzMKW_YNAnmJtTVddxyIYIDsbVhHzHaVuwNzSCmAo

To claim this, I am signing this object:

{
"name": "wd-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "wdio wdio.conf.js",
"test:watch": "wdio wdio.conf.js --watch"
},
"author": "",
const LabMath = {
"маточікування": function avarage(arr) {
return arr.reduce((a, b) => a + b, 0) / arr.length;
},
"медіана": function(arr) {
return arr.sort((a, b) => a - b)[Math.floor(arr.length / 2)];
},
"напівсума «крайніх» спостережень": function(arr) {
return (Math.min(...arr) + Math.max(...arr)) / 2;
},
.alert {
position: absolute;
left: 0;
top: 0;
width: 100%;
background: rgba(255, 30,3, 0.7);
color: white;
padding: 1%;
font-size: 120%;
font-family: monospace;
snail = function(array) {
var side = 'top';
var result = [];
while(array.length > 0){
switch(side){
case 'top':
result.push(...cutRow(0, array));
side = 'right';
import * as THREE from 'three';
export class RealZoom {
constructor({ width, height }, diag) {
var diagPX = Math.sqrt(width ** 2 + height ** 2);
var screenWidthInch = width / diagPX * diag;
var screenWidthCM = 2.54 * screenWidthInch;
var viewWidthPX = window.innerWidth;
this.viewWidthCM = viewWidthPX / width * screenWidthCM;
}
@Ni55aN
Ni55aN / computeVertexNormals-angle.js
Last active November 7, 2021 22:58
three.js smooth normals with crease angle
function calcNormal( normals, normal, angle ){
let allowed = normals.filter( n => n.angleTo( normal ) < angle * Math.PI / 180 );
return allowed.reduce( (a, b) => a.clone().add( b ) ).normalize();
}
THREE.GeometryUtils.computeVertexNormals = function(geometry, angle){
geometry.computeFaceNormals();
var vertices = geometry.vertices.map( () => [] ); // vertices with normals array
function optimizeGeometry(geometry) {
var saveVerts = [];
geometry.vertices.forEach((vert, i) => {
var present = geometry.faces.some(face => {
return face[0] === i || face[1] === i || face[2] === i
});
if (present)
saveVerts.push(i);
const fs = require('fs');
const draco3d = require('draco3d');
const js2obj = require('./js2obj');
const decoderModule = draco3d.createDecoderModule({});
const encoderModule = draco3d.createEncoderModule({});
var data = fs.readFileSync('./testdata/bunny.drc');
class Perceptron {
constructor(layers, inputs) {
if (layers[0] !== inputs.length)
throw new Error("Invalid number of inputs");
this.l = layers;
this.activation = val => (val >= 0.5 ? 1 : 0);
this.learningRate = 0.1;
this.initWeights();