How to use finish method in pytest-benchmark

Best Python code snippet using pytest-benchmark

belt_Array.js

Source:belt_Array.js Github

copy

Full Screen

1'use strict';2var Curry = require("./curry.js");3var Js_math = require("./js_math.js");4var Caml_primitive = require("./caml_primitive.js");5function get(arr, i) {6 if (i >= 0 && i < arr.length) {7 return /* Some */[arr[i]];8 } else {9 return /* None */0;10 }11}12function getExn(arr, i) {13 if (!(i >= 0 && i < arr.length)) {14 throw new Error("File \"belt_Array.ml\", line 41, characters 6-12");15 }16 return arr[i];17}18function set(arr, i, v) {19 if (i >= 0 && i < arr.length) {20 arr[i] = v;21 return true;22 } else {23 return false;24 }25}26function setExn(arr, i, v) {27 if (!(i >= 0 && i < arr.length)) {28 throw new Error("File \"belt_Array.ml\", line 47, characters 4-10");29 }30 arr[i] = v;31 return /* () */0;32}33function swapUnsafe(xs, i, j) {34 var tmp = xs[i];35 xs[i] = xs[j];36 xs[j] = tmp;37 return /* () */0;38}39function shuffleInPlace(xs) {40 var len = xs.length;41 for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){42 swapUnsafe(xs, i, Js_math.random_int(i, len));43 }44 return /* () */0;45}46function shuffle(xs) {47 var result = xs.slice(0);48 shuffleInPlace(result);49 return result;50}51function reverseInPlace(xs) {52 var len = xs.length;53 var xs$1 = xs;54 var ofs = 0;55 var len$1 = len;56 for(var i = 0 ,i_finish = (len$1 / 2 | 0) - 1 | 0; i <= i_finish; ++i){57 swapUnsafe(xs$1, ofs + i | 0, ((ofs + len$1 | 0) - i | 0) - 1 | 0);58 }59 return /* () */0;60}61function make(l, f) {62 if (l <= 0) {63 return /* array */[];64 } else {65 var res = new Array(l);66 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){67 res[i] = f;68 }69 return res;70 }71}72function reverse(xs) {73 var len = xs.length;74 var result = len > 0 ? new Array(len) : /* array */[];75 for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){76 result[i] = xs[(len - 1 | 0) - i | 0];77 }78 return result;79}80function makeByU(l, f) {81 if (l <= 0) {82 return /* array */[];83 } else {84 var res = l > 0 ? (f(0), new Array(l)) : /* array */[];85 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){86 res[i] = f(i);87 }88 return res;89 }90}91function makeBy(l, f) {92 return makeByU(l, Curry.__1(f));93}94function makeByAndShuffleU(l, f) {95 var u = makeByU(l, f);96 shuffleInPlace(u);97 return u;98}99function makeByAndShuffle(l, f) {100 return makeByAndShuffleU(l, Curry.__1(f));101}102function range(start, finish) {103 var cut = finish - start | 0;104 if (cut < 0) {105 return /* array */[];106 } else {107 var arr = new Array(cut + 1 | 0);108 for(var i = 0; i <= cut; ++i){109 arr[i] = start + i | 0;110 }111 return arr;112 }113}114function rangeBy(start, finish, step) {115 var cut = finish - start | 0;116 if (cut < 0 || step <= 0) {117 return /* array */[];118 } else {119 var nb = (cut / step | 0) + 1 | 0;120 var arr = new Array(nb);121 var cur = start;122 for(var i = 0 ,i_finish = nb - 1 | 0; i <= i_finish; ++i){123 arr[i] = cur;124 cur = cur + step | 0;125 }126 return arr;127 }128}129function zip(xs, ys) {130 var lenx = xs.length;131 var leny = ys.length;132 var len = lenx < leny ? lenx : leny;133 var s = len > 0 ? new Array(len) : /* array */[];134 for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){135 s[i] = /* tuple */[136 xs[i],137 ys[i]138 ];139 }140 return s;141}142function zipByU(xs, ys, f) {143 var lenx = xs.length;144 var leny = ys.length;145 var len = lenx < leny ? lenx : leny;146 var s = len > 0 ? (f(xs[0], ys[0]), new Array(len)) : /* array */[];147 for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){148 s[i] = f(xs[i], ys[i]);149 }150 return s;151}152function zipBy(xs, ys, f) {153 return zipByU(xs, ys, Curry.__2(f));154}155function concat(a1, a2) {156 var l1 = a1.length;157 var l2 = a2.length;158 var a1a2 = l1 > 0 ? new Array(l1 + l2 | 0) : /* array */[];159 for(var i = 0 ,i_finish = l1 - 1 | 0; i <= i_finish; ++i){160 a1a2[i] = a1[i];161 }162 for(var i$1 = 0 ,i_finish$1 = l2 - 1 | 0; i$1 <= i_finish$1; ++i$1){163 a1a2[l1 + i$1 | 0] = a2[i$1];164 }165 return a1a2;166}167function concatMany(arrs) {168 var lenArrs = arrs.length;169 var totalLen = 0;170 var firstArrWithLengthMoreThanZero = /* None */0;171 for(var i = 0 ,i_finish = lenArrs - 1 | 0; i <= i_finish; ++i){172 var len = arrs[i].length;173 totalLen = totalLen + len | 0;174 if (len > 0 && firstArrWithLengthMoreThanZero === /* None */0) {175 firstArrWithLengthMoreThanZero = /* Some */[arrs[i]];176 }177 178 }179 var match = firstArrWithLengthMoreThanZero;180 if (match) {181 var result = new Array(totalLen);182 totalLen = 0;183 for(var j = 0 ,j_finish = lenArrs - 1 | 0; j <= j_finish; ++j){184 var cur = arrs[j];185 for(var k = 0 ,k_finish = cur.length - 1 | 0; k <= k_finish; ++k){186 result[totalLen] = cur[k];187 totalLen = totalLen + 1 | 0;188 }189 }190 return result;191 } else {192 return /* array */[];193 }194}195function slice(a, offset, len) {196 if (len <= 0) {197 return /* array */[];198 } else {199 var lena = a.length;200 var ofs = offset < 0 ? Caml_primitive.caml_int_max(lena + offset | 0, 0) : offset;201 var hasLen = lena - ofs | 0;202 var copyLength = hasLen < len ? hasLen : len;203 if (copyLength <= 0) {204 return /* array */[];205 } else {206 var result = lena > 0 ? new Array(copyLength) : /* array */[];207 for(var i = 0 ,i_finish = copyLength - 1 | 0; i <= i_finish; ++i){208 result[i] = a[ofs + i | 0];209 }210 return result;211 }212 }213}214function fill(a, offset, len, v) {215 if (len > 0) {216 var lena = a.length;217 var ofs = offset < 0 ? Caml_primitive.caml_int_max(lena + offset | 0, 0) : offset;218 var hasLen = lena - ofs | 0;219 var fillLength = hasLen < len ? hasLen : len;220 if (fillLength > 0) {221 for(var i = ofs ,i_finish = (ofs + fillLength | 0) - 1 | 0; i <= i_finish; ++i){222 a[i] = v;223 }224 return /* () */0;225 } else {226 return 0;227 }228 } else {229 return 0;230 }231}232function blitUnsafe(a1, srcofs1, a2, srcofs2, blitLength) {233 if (srcofs2 <= srcofs1) {234 for(var j = 0 ,j_finish = blitLength - 1 | 0; j <= j_finish; ++j){235 a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0];236 }237 return /* () */0;238 } else {239 for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){240 a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0];241 }242 return /* () */0;243 }244}245function blit(a1, ofs1, a2, ofs2, len) {246 var lena1 = a1.length;247 var lena2 = a2.length;248 var srcofs1 = ofs1 < 0 ? Caml_primitive.caml_int_max(lena1 + ofs1 | 0, 0) : ofs1;249 var srcofs2 = ofs2 < 0 ? Caml_primitive.caml_int_max(lena2 + ofs2 | 0, 0) : ofs2;250 var blitLength = Caml_primitive.caml_int_min(len, Caml_primitive.caml_int_min(lena1 - srcofs1 | 0, lena2 - srcofs2 | 0));251 if (srcofs2 <= srcofs1) {252 for(var j = 0 ,j_finish = blitLength - 1 | 0; j <= j_finish; ++j){253 a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0];254 }255 return /* () */0;256 } else {257 for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){258 a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0];259 }260 return /* () */0;261 }262}263function forEachU(a, f) {264 for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){265 f(a[i]);266 }267 return /* () */0;268}269function forEach(a, f) {270 return forEachU(a, Curry.__1(f));271}272function mapU(a, f) {273 var l = a.length;274 var r = l > 0 ? (f(a[0]), new Array(l)) : /* array */[];275 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){276 r[i] = f(a[i]);277 }278 return r;279}280function map(a, f) {281 return mapU(a, Curry.__1(f));282}283function keepU(a, f) {284 var l = a.length;285 var r = l > 0 ? new Array(l) : /* array */[];286 var j = 0;287 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){288 var v = a[i];289 if (f(v)) {290 r[j] = v;291 j = j + 1 | 0;292 }293 294 }295 r.length = j;296 return r;297}298function keep(a, f) {299 return keepU(a, Curry.__1(f));300}301function keepMapU(a, f) {302 var l = a.length;303 var r = new Array(l);304 var j = 0;305 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){306 var v = a[i];307 var match = f(v);308 if (match) {309 r[j] = match[0];310 j = j + 1 | 0;311 }312 313 }314 r.length = j;315 return r;316}317function keepMap(a, f) {318 return keepMapU(a, Curry.__1(f));319}320function forEachWithIndexU(a, f) {321 for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){322 f(i, a[i]);323 }324 return /* () */0;325}326function forEachWithIndex(a, f) {327 return forEachWithIndexU(a, Curry.__2(f));328}329function mapWithIndexU(a, f) {330 var l = a.length;331 var r = l > 0 ? (f(0, a[0]), new Array(l)) : /* array */[];332 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){333 r[i] = f(i, a[i]);334 }335 return r;336}337function mapWithIndex(a, f) {338 return mapWithIndexU(a, Curry.__2(f));339}340function reduceU(a, x, f) {341 var r = x;342 for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){343 r = f(r, a[i]);344 }345 return r;346}347function reduce(a, x, f) {348 return reduceU(a, x, Curry.__2(f));349}350function reduceReverseU(a, x, f) {351 var r = x;352 for(var i = a.length - 1 | 0; i >= 0; --i){353 r = f(r, a[i]);354 }355 return r;356}357function reduceReverse(a, x, f) {358 return reduceReverseU(a, x, Curry.__2(f));359}360function reduceReverse2U(a, b, x, f) {361 var r = x;362 var len = Caml_primitive.caml_int_min(a.length, b.length);363 for(var i = len - 1 | 0; i >= 0; --i){364 r = f(r, a[i], b[i]);365 }366 return r;367}368function reduceReverse2(a, b, x, f) {369 return reduceReverse2U(a, b, x, Curry.__3(f));370}371function everyU(arr, b) {372 var len = arr.length;373 var arr$1 = arr;374 var _i = 0;375 var b$1 = b;376 var len$1 = len;377 while(true) {378 var i = _i;379 if (i === len$1) {380 return true;381 } else if (b$1(arr$1[i])) {382 _i = i + 1 | 0;383 continue ;384 } else {385 return false;386 }387 };388}389function every(arr, f) {390 return everyU(arr, Curry.__1(f));391}392function someU(arr, b) {393 var len = arr.length;394 var arr$1 = arr;395 var _i = 0;396 var b$1 = b;397 var len$1 = len;398 while(true) {399 var i = _i;400 if (i === len$1) {401 return false;402 } else if (b$1(arr$1[i])) {403 return true;404 } else {405 _i = i + 1 | 0;406 continue ;407 }408 };409}410function some(arr, f) {411 return someU(arr, Curry.__1(f));412}413function everyAux2(arr1, arr2, _i, b, len) {414 while(true) {415 var i = _i;416 if (i === len) {417 return true;418 } else if (b(arr1[i], arr2[i])) {419 _i = i + 1 | 0;420 continue ;421 } else {422 return false;423 }424 };425}426function every2U(a, b, p) {427 return everyAux2(a, b, 0, p, Caml_primitive.caml_int_min(a.length, b.length));428}429function every2(a, b, p) {430 return every2U(a, b, Curry.__2(p));431}432function some2U(a, b, p) {433 var arr1 = a;434 var arr2 = b;435 var _i = 0;436 var b$1 = p;437 var len = Caml_primitive.caml_int_min(a.length, b.length);438 while(true) {439 var i = _i;440 if (i === len) {441 return false;442 } else if (b$1(arr1[i], arr2[i])) {443 return true;444 } else {445 _i = i + 1 | 0;446 continue ;447 }448 };449}450function some2(a, b, p) {451 return some2U(a, b, Curry.__2(p));452}453function eqU(a, b, p) {454 var lena = a.length;455 var lenb = b.length;456 if (lena === lenb) {457 return everyAux2(a, b, 0, p, lena);458 } else {459 return false;460 }461}462function eq(a, b, p) {463 return eqU(a, b, Curry.__2(p));464}465function cmpU(a, b, p) {466 var lena = a.length;467 var lenb = b.length;468 if (lena > lenb) {469 return 1;470 } else if (lena < lenb) {471 return -1;472 } else {473 var arr1 = a;474 var arr2 = b;475 var _i = 0;476 var b$1 = p;477 var len = lena;478 while(true) {479 var i = _i;480 if (i === len) {481 return 0;482 } else {483 var c = b$1(arr1[i], arr2[i]);484 if (c === 0) {485 _i = i + 1 | 0;486 continue ;487 } else {488 return c;489 }490 }491 };492 }493}494function cmp(a, b, p) {495 return cmpU(a, b, Curry.__2(p));496}497function partitionU(a, f) {498 var l = a.length;499 var i = 0;500 var j = 0;501 var a1 = l > 0 ? new Array(l) : /* array */[];502 var a2 = l > 0 ? new Array(l) : /* array */[];503 for(var ii = 0 ,ii_finish = l - 1 | 0; ii <= ii_finish; ++ii){504 var v = a[ii];505 if (f(v)) {506 a1[i] = v;507 i = i + 1 | 0;508 } else {509 a2[j] = v;510 j = j + 1 | 0;511 }512 }513 a1.length = i;514 a2.length = j;515 return /* tuple */[516 a1,517 a2518 ];519}520function partition(a, f) {521 return partitionU(a, Curry.__1(f));522}523function unzip(a) {524 var l = a.length;525 var match;526 if (l > 0) {527 match = /* tuple */[528 new Array(l),529 new Array(l)530 ];531 } else {532 match = /* tuple */[533 /* array */[],534 /* array */[]535 ];536 }537 var a2 = match[1];538 var a1 = match[0];539 for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){540 var match$1 = a[i];541 a1[i] = match$1[0];542 a2[i] = match$1[1];543 }544 return /* tuple */[545 a1,546 a2547 ];548}549exports.get = get;550exports.getExn = getExn;551exports.set = set;552exports.setExn = setExn;553exports.shuffleInPlace = shuffleInPlace;554exports.shuffle = shuffle;555exports.reverseInPlace = reverseInPlace;556exports.reverse = reverse;557exports.make = make;558exports.range = range;559exports.rangeBy = rangeBy;560exports.makeByU = makeByU;561exports.makeBy = makeBy;562exports.makeByAndShuffleU = makeByAndShuffleU;563exports.makeByAndShuffle = makeByAndShuffle;564exports.zip = zip;565exports.zipByU = zipByU;566exports.zipBy = zipBy;567exports.unzip = unzip;568exports.concat = concat;569exports.concatMany = concatMany;570exports.slice = slice;571exports.fill = fill;572exports.blit = blit;573exports.blitUnsafe = blitUnsafe;574exports.forEachU = forEachU;575exports.forEach = forEach;576exports.mapU = mapU;577exports.map = map;578exports.keepU = keepU;579exports.keep = keep;580exports.keepMapU = keepMapU;581exports.keepMap = keepMap;582exports.forEachWithIndexU = forEachWithIndexU;583exports.forEachWithIndex = forEachWithIndex;584exports.mapWithIndexU = mapWithIndexU;585exports.mapWithIndex = mapWithIndex;586exports.partitionU = partitionU;587exports.partition = partition;588exports.reduceU = reduceU;589exports.reduce = reduce;590exports.reduceReverseU = reduceReverseU;591exports.reduceReverse = reduceReverse;592exports.reduceReverse2U = reduceReverse2U;593exports.reduceReverse2 = reduceReverse2;594exports.someU = someU;595exports.some = some;596exports.everyU = everyU;597exports.every = every;598exports.every2U = every2U;599exports.every2 = every2;600exports.some2U = some2U;601exports.some2 = some2;602exports.cmpU = cmpU;603exports.cmp = cmp;604exports.eqU = eqU;605exports.eq = eq;...

Full Screen

Full Screen

lighting.js.consoleStripped.js

Source:lighting.js.consoleStripped.js Github

copy

Full Screen

1define("dojox/gfx3d/lighting", [2 "dojo/_base/lang",3 "dojo/_base/Color", // dojo.Color4 "dojo/_base/declare", // declare5 "dojox/gfx/_base",6 "./_base"7],function(lang,Color,declare,gfx,gfx3d) {8 var lite = gfx3d.lighting = {9 // color utilities10 black: function(){11 return {r: 0, g: 0, b: 0, a: 1};12 },13 white: function(){14 return {r: 1, g: 1, b: 1, a: 1};15 },16 toStdColor: function(c){17 c = gfx.normalizeColor(c);18 return {r: c.r / 255, g: c.g / 255, b: c.b / 255, a: c.a};19 },20 fromStdColor: function(c){21 return new Color([Math.round(255 * c.r), Math.round(255 * c.g), Math.round(255 * c.b), c.a]);22 },23 scaleColor: function(s, c){24 return {r: s * c.r, g: s * c.g, b: s * c.b, a: s * c.a};25 },26 addColor: function(a, b){27 return {r: a.r + b.r, g: a.g + b.g, b: a.b + b.b, a: a.a + b.a};28 },29 multiplyColor: function(a, b){30 return {r: a.r * b.r, g: a.g * b.g, b: a.b * b.b, a: a.a * b.a};31 },32 saturateColor: function(c){33 return {34 r: c.r < 0 ? 0 : c.r > 1 ? 1 : c.r,35 g: c.g < 0 ? 0 : c.g > 1 ? 1 : c.g,36 b: c.b < 0 ? 0 : c.b > 1 ? 1 : c.b,37 a: c.a < 0 ? 0 : c.a > 1 ? 1 : c.a38 };39 },40 mixColor: function(c1, c2, s){41 return lite.addColor(lite.scaleColor(s, c1), lite.scaleColor(1 - s, c2));42 },43 diff2Color: function(c1, c2){44 var r = c1.r - c2.r;45 var g = c1.g - c2.g;46 var b = c1.b - c2.b;47 var a = c1.a - c2.a;48 return r * r + g * g + b * b + a * a;49 },50 length2Color: function(c){51 return c.r * c.r + c.g * c.g + c.b * c.b + c.a * c.a;52 },53 54 // vector utilities55 //TODO: move vector utilities from this file to vector.js56 dot: function(a, b){57 return a.x * b.x + a.y * b.y + a.z * b.z;58 },59 scale: function(s, v){60 return {x: s * v.x, y: s * v.y, z: s * v.z};61 },62 add: function(a, b){63 return {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z};64 },65 saturate: function(v){66 return Math.min(Math.max(v, 0), 1);67 },68 length: function(v){69 return Math.sqrt(gfx3d.lighting.dot(v, v));70 },71 normalize: function(v){72 return lite.scale(1 / lite.length(v), v);73 },74 faceforward: function(n, i){75 var p = gfx3d.lighting;76 var s = p.dot(i, n) < 0 ? 1 : -1;77 return p.scale(s, n);78 },79 reflect: function(i, n){80 var p = gfx3d.lighting;81 return p.add(i, p.scale(-2 * p.dot(i, n), n));82 },83 84 // lighting utilities85 diffuse: function(normal, lights){86 var c = lite.black();87 for(var i = 0; i < lights.length; ++i){88 var l = lights[i],89 d = lite.dot(lite.normalize(l.direction), normal);90 c = lite.addColor(c, lite.scaleColor(d, l.color));91 }92 return lite.saturateColor(c);93 },94 specular: function(normal, v, roughness, lights){95 var c = lite.black();96 for(var i = 0; i < lights.length; ++i){97 var l = lights[i],98 h = lite.normalize(lite.add(lite.normalize(l.direction), v)),99 s = Math.pow(Math.max(0, lite.dot(normal, h)), 1 / roughness);100 c = lite.addColor(c, lite.scaleColor(s, l.color));101 }102 return lite.saturateColor(c);103 },104 phong: function(normal, v, size, lights){105 normal = lite.normalize(normal);106 var c = lite.black();107 for(var i = 0; i < lights.length; ++i){108 var l = lights[i],109 r = lite.reflect(lite.scale(-1, lite.normalize(v)), normal),110 s = Math.pow(Math.max(0, lite.dot(r, lite.normalize(l.direction))), size);111 c = lite.addColor(c, lite.scaleColor(s, l.color));112 }113 return lite.saturateColor(c);114 }115 };116 // this lighting model is derived from RenderMan Interface Specification Version 3.2117 declare("dojox.gfx3d.lighting.Model", null, {118 constructor: function(incident, lights, ambient, specular){119 this.incident = lite.normalize(incident);120 this.lights = [];121 for(var i = 0; i < lights.length; ++i){122 var l = lights[i];123 this.lights.push({direction: lite.normalize(l.direction), color: lite.toStdColor(l.color)});124 }125 this.ambient = lite.toStdColor(ambient.color ? ambient.color : "white");126 this.ambient = lite.scaleColor(ambient.intensity, this.ambient);127 this.ambient = lite.scaleColor(this.ambient.a, this.ambient);128 this.ambient.a = 1;129 this.specular = lite.toStdColor(specular ? specular : "white");130 this.specular = lite.scaleColor(this.specular.a, this.specular);131 this.specular.a = 1;132 this.npr_cool = {r: 0, g: 0, b: 0.4, a: 1};133 this.npr_warm = {r: 0.4, g: 0.4, b: 0.2, a: 1};134 this.npr_alpha = 0.2;135 this.npr_beta = 0.6;136 this.npr_scale = 0.6;137 },138 constant: function(normal, finish, pigment){139 pigment = lite.toStdColor(pigment);140 var alpha = pigment.a, color = lite.scaleColor(alpha, pigment);141 color.a = alpha;142 return lite.fromStdColor(lite.saturateColor(color));143 },144 matte: function(normal, finish, pigment){145 if(typeof finish == "string"){ finish = lite.finish[finish]; }146 pigment = lite.toStdColor(pigment);147 normal = lite.faceforward(lite.normalize(normal), this.incident);148 var ambient = lite.scaleColor(finish.Ka, this.ambient),149 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),150 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),151 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)));152 color.a = pigment.a;153 return lite.fromStdColor(lite.saturateColor(color));154 },155 metal: function(normal, finish, pigment){156 if(typeof finish == "string"){ finish = lite.finish[finish]; }157 pigment = lite.toStdColor(pigment);158 normal = lite.faceforward(lite.normalize(normal), this.incident);159 var v = lite.scale(-1, this.incident), specular, color,160 ambient = lite.scaleColor(finish.Ka, this.ambient),161 shadow = lite.saturate(-4 * lite.dot(normal, this.incident));162 if("phong" in finish){163 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));164 }else{165 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));166 }167 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, ambient), lite.multiplyColor(this.specular, specular)));168 color.a = pigment.a;169 return lite.fromStdColor(lite.saturateColor(color));170 },171 plastic: function(normal, finish, pigment){172 if(typeof finish == "string"){ finish = lite.finish[finish]; }173 pigment = lite.toStdColor(pigment);174 normal = lite.faceforward(lite.normalize(normal), this.incident);175 var v = lite.scale(-1, this.incident), specular, color,176 ambient = lite.scaleColor(finish.Ka, this.ambient),177 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),178 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights));179 if("phong" in finish){180 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));181 }else{182 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));183 }184 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)), lite.multiplyColor(this.specular, specular)));185 color.a = pigment.a;186 return lite.fromStdColor(lite.saturateColor(color));187 },188 npr: function(normal, finish, pigment){189 if(typeof finish == "string"){ finish = lite.finish[finish]; }190 pigment = lite.toStdColor(pigment);191 normal = lite.faceforward(lite.normalize(normal), this.incident);192 var ambient = lite.scaleColor(finish.Ka, this.ambient),193 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),194 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),195 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse))),196 cool = lite.addColor(this.npr_cool, lite.scaleColor(this.npr_alpha, color)),197 warm = lite.addColor(this.npr_warm, lite.scaleColor(this.npr_beta, color)),198 d = (1 + lite.dot(this.incident, normal)) / 2,199 color = lite.scaleColor(this.npr_scale, lite.addColor(color, lite.mixColor(cool, warm, d)));200 color.a = pigment.a;201 return lite.fromStdColor(lite.saturateColor(color));202 }203 });204 // POV-Ray basic finishes205 206 gfx3d.lighting.finish = {207 208 // Default209 210 defaults: {Ka: 0.1, Kd: 0.6, Ks: 0.0, roughness: 0.05},211 212 dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, roughness: 0.15},213 shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.001},214 glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.0001},215 216 phong_dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, phong: 0.5, phong_size: 1},217 phong_shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 200},218 phong_glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 300},219 220 luminous: {Ka: 1.0, Kd: 0.0, Ks: 0.0, roughness: 0.05},221 222 // Metals223 224 // very soft and dull225 metalA: {Ka: 0.35, Kd: 0.3, Ks: 0.8, roughness: 1/20},226 // fairly soft and dull227 metalB: {Ka: 0.30, Kd: 0.4, Ks: 0.7, roughness: 1/60},228 // medium reflectivity, holds color well229 metalC: {Ka: 0.25, Kd: 0.5, Ks: 0.8, roughness: 1/80},230 // highly hard and polished, high reflectivity231 metalD: {Ka: 0.15, Kd: 0.6, Ks: 0.8, roughness: 1/100},232 // very highly polished and reflective233 metalE: {Ka: 0.10, Kd: 0.7, Ks: 0.8, roughness: 1/120}234 };235 return lite;...

Full Screen

Full Screen

lighting.js.uncompressed.js

Source:lighting.js.uncompressed.js Github

copy

Full Screen

1define("dojox/gfx3d/lighting", [2 "dojo/_base/lang",3 "dojo/_base/Color", // dojo.Color4 "dojo/_base/declare", // declare5 "dojox/gfx/_base",6 "./_base"7],function(lang,Color,declare,gfx,gfx3d) {8 var lite = gfx3d.lighting = {9 // color utilities10 black: function(){11 return {r: 0, g: 0, b: 0, a: 1};12 },13 white: function(){14 return {r: 1, g: 1, b: 1, a: 1};15 },16 toStdColor: function(c){17 c = gfx.normalizeColor(c);18 return {r: c.r / 255, g: c.g / 255, b: c.b / 255, a: c.a};19 },20 fromStdColor: function(c){21 return new Color([Math.round(255 * c.r), Math.round(255 * c.g), Math.round(255 * c.b), c.a]);22 },23 scaleColor: function(s, c){24 return {r: s * c.r, g: s * c.g, b: s * c.b, a: s * c.a};25 },26 addColor: function(a, b){27 return {r: a.r + b.r, g: a.g + b.g, b: a.b + b.b, a: a.a + b.a};28 },29 multiplyColor: function(a, b){30 return {r: a.r * b.r, g: a.g * b.g, b: a.b * b.b, a: a.a * b.a};31 },32 saturateColor: function(c){33 return {34 r: c.r < 0 ? 0 : c.r > 1 ? 1 : c.r,35 g: c.g < 0 ? 0 : c.g > 1 ? 1 : c.g,36 b: c.b < 0 ? 0 : c.b > 1 ? 1 : c.b,37 a: c.a < 0 ? 0 : c.a > 1 ? 1 : c.a38 };39 },40 mixColor: function(c1, c2, s){41 return lite.addColor(lite.scaleColor(s, c1), lite.scaleColor(1 - s, c2));42 },43 diff2Color: function(c1, c2){44 var r = c1.r - c2.r;45 var g = c1.g - c2.g;46 var b = c1.b - c2.b;47 var a = c1.a - c2.a;48 return r * r + g * g + b * b + a * a;49 },50 length2Color: function(c){51 return c.r * c.r + c.g * c.g + c.b * c.b + c.a * c.a;52 },53 54 // vector utilities55 //TODO: move vector utilities from this file to vector.js56 dot: function(a, b){57 return a.x * b.x + a.y * b.y + a.z * b.z;58 },59 scale: function(s, v){60 return {x: s * v.x, y: s * v.y, z: s * v.z};61 },62 add: function(a, b){63 return {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z};64 },65 saturate: function(v){66 return Math.min(Math.max(v, 0), 1);67 },68 length: function(v){69 return Math.sqrt(gfx3d.lighting.dot(v, v));70 },71 normalize: function(v){72 return lite.scale(1 / lite.length(v), v);73 },74 faceforward: function(n, i){75 var p = gfx3d.lighting;76 var s = p.dot(i, n) < 0 ? 1 : -1;77 return p.scale(s, n);78 },79 reflect: function(i, n){80 var p = gfx3d.lighting;81 return p.add(i, p.scale(-2 * p.dot(i, n), n));82 },83 84 // lighting utilities85 diffuse: function(normal, lights){86 var c = lite.black();87 for(var i = 0; i < lights.length; ++i){88 var l = lights[i],89 d = lite.dot(lite.normalize(l.direction), normal);90 c = lite.addColor(c, lite.scaleColor(d, l.color));91 }92 return lite.saturateColor(c);93 },94 specular: function(normal, v, roughness, lights){95 var c = lite.black();96 for(var i = 0; i < lights.length; ++i){97 var l = lights[i],98 h = lite.normalize(lite.add(lite.normalize(l.direction), v)),99 s = Math.pow(Math.max(0, lite.dot(normal, h)), 1 / roughness);100 c = lite.addColor(c, lite.scaleColor(s, l.color));101 }102 return lite.saturateColor(c);103 },104 phong: function(normal, v, size, lights){105 normal = lite.normalize(normal);106 var c = lite.black();107 for(var i = 0; i < lights.length; ++i){108 var l = lights[i],109 r = lite.reflect(lite.scale(-1, lite.normalize(v)), normal),110 s = Math.pow(Math.max(0, lite.dot(r, lite.normalize(l.direction))), size);111 c = lite.addColor(c, lite.scaleColor(s, l.color));112 }113 return lite.saturateColor(c);114 }115 };116 // this lighting model is derived from RenderMan Interface Specification Version 3.2117 declare("dojox.gfx3d.lighting.Model", null, {118 constructor: function(incident, lights, ambient, specular){119 this.incident = lite.normalize(incident);120 this.lights = [];121 for(var i = 0; i < lights.length; ++i){122 var l = lights[i];123 this.lights.push({direction: lite.normalize(l.direction), color: lite.toStdColor(l.color)});124 }125 this.ambient = lite.toStdColor(ambient.color ? ambient.color : "white");126 this.ambient = lite.scaleColor(ambient.intensity, this.ambient);127 this.ambient = lite.scaleColor(this.ambient.a, this.ambient);128 this.ambient.a = 1;129 this.specular = lite.toStdColor(specular ? specular : "white");130 this.specular = lite.scaleColor(this.specular.a, this.specular);131 this.specular.a = 1;132 this.npr_cool = {r: 0, g: 0, b: 0.4, a: 1};133 this.npr_warm = {r: 0.4, g: 0.4, b: 0.2, a: 1};134 this.npr_alpha = 0.2;135 this.npr_beta = 0.6;136 this.npr_scale = 0.6;137 },138 constant: function(normal, finish, pigment){139 pigment = lite.toStdColor(pigment);140 var alpha = pigment.a, color = lite.scaleColor(alpha, pigment);141 color.a = alpha;142 return lite.fromStdColor(lite.saturateColor(color));143 },144 matte: function(normal, finish, pigment){145 if(typeof finish == "string"){ finish = lite.finish[finish]; }146 pigment = lite.toStdColor(pigment);147 normal = lite.faceforward(lite.normalize(normal), this.incident);148 var ambient = lite.scaleColor(finish.Ka, this.ambient),149 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),150 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),151 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)));152 color.a = pigment.a;153 return lite.fromStdColor(lite.saturateColor(color));154 },155 metal: function(normal, finish, pigment){156 if(typeof finish == "string"){ finish = lite.finish[finish]; }157 pigment = lite.toStdColor(pigment);158 normal = lite.faceforward(lite.normalize(normal), this.incident);159 var v = lite.scale(-1, this.incident), specular, color,160 ambient = lite.scaleColor(finish.Ka, this.ambient),161 shadow = lite.saturate(-4 * lite.dot(normal, this.incident));162 if("phong" in finish){163 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));164 }else{165 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));166 }167 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, ambient), lite.multiplyColor(this.specular, specular)));168 color.a = pigment.a;169 return lite.fromStdColor(lite.saturateColor(color));170 },171 plastic: function(normal, finish, pigment){172 if(typeof finish == "string"){ finish = lite.finish[finish]; }173 pigment = lite.toStdColor(pigment);174 normal = lite.faceforward(lite.normalize(normal), this.incident);175 var v = lite.scale(-1, this.incident), specular, color,176 ambient = lite.scaleColor(finish.Ka, this.ambient),177 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),178 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights));179 if("phong" in finish){180 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));181 }else{182 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));183 }184 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)), lite.multiplyColor(this.specular, specular)));185 color.a = pigment.a;186 return lite.fromStdColor(lite.saturateColor(color));187 },188 npr: function(normal, finish, pigment){189 if(typeof finish == "string"){ finish = lite.finish[finish]; }190 pigment = lite.toStdColor(pigment);191 normal = lite.faceforward(lite.normalize(normal), this.incident);192 var ambient = lite.scaleColor(finish.Ka, this.ambient),193 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),194 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),195 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse))),196 cool = lite.addColor(this.npr_cool, lite.scaleColor(this.npr_alpha, color)),197 warm = lite.addColor(this.npr_warm, lite.scaleColor(this.npr_beta, color)),198 d = (1 + lite.dot(this.incident, normal)) / 2,199 color = lite.scaleColor(this.npr_scale, lite.addColor(color, lite.mixColor(cool, warm, d)));200 color.a = pigment.a;201 return lite.fromStdColor(lite.saturateColor(color));202 }203 });204 // POV-Ray basic finishes205 206 gfx3d.lighting.finish = {207 208 // Default209 210 defaults: {Ka: 0.1, Kd: 0.6, Ks: 0.0, roughness: 0.05},211 212 dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, roughness: 0.15},213 shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.001},214 glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.0001},215 216 phong_dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, phong: 0.5, phong_size: 1},217 phong_shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 200},218 phong_glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 300},219 220 luminous: {Ka: 1.0, Kd: 0.0, Ks: 0.0, roughness: 0.05},221 222 // Metals223 224 // very soft and dull225 metalA: {Ka: 0.35, Kd: 0.3, Ks: 0.8, roughness: 1/20},226 // fairly soft and dull227 metalB: {Ka: 0.30, Kd: 0.4, Ks: 0.7, roughness: 1/60},228 // medium reflectivity, holds color well229 metalC: {Ka: 0.25, Kd: 0.5, Ks: 0.8, roughness: 1/80},230 // highly hard and polished, high reflectivity231 metalD: {Ka: 0.15, Kd: 0.6, Ks: 0.8, roughness: 1/100},232 // very highly polished and reflective233 metalE: {Ka: 0.10, Kd: 0.7, Ks: 0.8, roughness: 1/120}234 };235 return lite;...

Full Screen

Full Screen

lighting.js

Source:lighting.js Github

copy

Full Screen

1define([2 "dojo/_base/lang",3 "dojo/_base/Color", // dojo.Color4 "dojo/_base/declare", // declare5 "dojox/gfx/_base",6 "./_base"7],function(lang,Color,declare,gfx,gfx3d) {8 var lite = gfx3d.lighting = {9 // color utilities10 black: function(){11 return {r: 0, g: 0, b: 0, a: 1};12 },13 white: function(){14 return {r: 1, g: 1, b: 1, a: 1};15 },16 toStdColor: function(c){17 c = gfx.normalizeColor(c);18 return {r: c.r / 255, g: c.g / 255, b: c.b / 255, a: c.a};19 },20 fromStdColor: function(c){21 return new Color([Math.round(255 * c.r), Math.round(255 * c.g), Math.round(255 * c.b), c.a]);22 },23 scaleColor: function(s, c){24 return {r: s * c.r, g: s * c.g, b: s * c.b, a: s * c.a};25 },26 addColor: function(a, b){27 return {r: a.r + b.r, g: a.g + b.g, b: a.b + b.b, a: a.a + b.a};28 },29 multiplyColor: function(a, b){30 return {r: a.r * b.r, g: a.g * b.g, b: a.b * b.b, a: a.a * b.a};31 },32 saturateColor: function(c){33 return {34 r: c.r < 0 ? 0 : c.r > 1 ? 1 : c.r,35 g: c.g < 0 ? 0 : c.g > 1 ? 1 : c.g,36 b: c.b < 0 ? 0 : c.b > 1 ? 1 : c.b,37 a: c.a < 0 ? 0 : c.a > 1 ? 1 : c.a38 };39 },40 mixColor: function(c1, c2, s){41 return lite.addColor(lite.scaleColor(s, c1), lite.scaleColor(1 - s, c2));42 },43 diff2Color: function(c1, c2){44 var r = c1.r - c2.r;45 var g = c1.g - c2.g;46 var b = c1.b - c2.b;47 var a = c1.a - c2.a;48 return r * r + g * g + b * b + a * a;49 },50 length2Color: function(c){51 return c.r * c.r + c.g * c.g + c.b * c.b + c.a * c.a;52 },53 54 // vector utilities55 //TODO: move vector utilities from this file to vector.js56 dot: function(a, b){57 return a.x * b.x + a.y * b.y + a.z * b.z;58 },59 scale: function(s, v){60 return {x: s * v.x, y: s * v.y, z: s * v.z};61 },62 add: function(a, b){63 return {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z};64 },65 saturate: function(v){66 return Math.min(Math.max(v, 0), 1);67 },68 length: function(v){69 return Math.sqrt(gfx3d.lighting.dot(v, v));70 },71 normalize: function(v){72 return lite.scale(1 / lite.length(v), v);73 },74 faceforward: function(n, i){75 var p = gfx3d.lighting;76 var s = p.dot(i, n) < 0 ? 1 : -1;77 return p.scale(s, n);78 },79 reflect: function(i, n){80 var p = gfx3d.lighting;81 return p.add(i, p.scale(-2 * p.dot(i, n), n));82 },83 84 // lighting utilities85 diffuse: function(normal, lights){86 var c = lite.black();87 for(var i = 0; i < lights.length; ++i){88 var l = lights[i],89 d = lite.dot(lite.normalize(l.direction), normal);90 c = lite.addColor(c, lite.scaleColor(d, l.color));91 }92 return lite.saturateColor(c);93 },94 specular: function(normal, v, roughness, lights){95 var c = lite.black();96 for(var i = 0; i < lights.length; ++i){97 var l = lights[i],98 h = lite.normalize(lite.add(lite.normalize(l.direction), v)),99 s = Math.pow(Math.max(0, lite.dot(normal, h)), 1 / roughness);100 c = lite.addColor(c, lite.scaleColor(s, l.color));101 }102 return lite.saturateColor(c);103 },104 phong: function(normal, v, size, lights){105 normal = lite.normalize(normal);106 var c = lite.black();107 for(var i = 0; i < lights.length; ++i){108 var l = lights[i],109 r = lite.reflect(lite.scale(-1, lite.normalize(v)), normal),110 s = Math.pow(Math.max(0, lite.dot(r, lite.normalize(l.direction))), size);111 c = lite.addColor(c, lite.scaleColor(s, l.color));112 }113 return lite.saturateColor(c);114 }115 };116 // this lighting model is derived from RenderMan Interface Specification Version 3.2117 declare("dojox.gfx3d.lighting.Model", null, {118 constructor: function(incident, lights, ambient, specular){119 this.incident = lite.normalize(incident);120 this.lights = [];121 for(var i = 0; i < lights.length; ++i){122 var l = lights[i];123 this.lights.push({direction: lite.normalize(l.direction), color: lite.toStdColor(l.color)});124 }125 this.ambient = lite.toStdColor(ambient.color ? ambient.color : "white");126 this.ambient = lite.scaleColor(ambient.intensity, this.ambient);127 this.ambient = lite.scaleColor(this.ambient.a, this.ambient);128 this.ambient.a = 1;129 this.specular = lite.toStdColor(specular ? specular : "white");130 this.specular = lite.scaleColor(this.specular.a, this.specular);131 this.specular.a = 1;132 this.npr_cool = {r: 0, g: 0, b: 0.4, a: 1};133 this.npr_warm = {r: 0.4, g: 0.4, b: 0.2, a: 1};134 this.npr_alpha = 0.2;135 this.npr_beta = 0.6;136 this.npr_scale = 0.6;137 },138 constant: function(normal, finish, pigment){139 pigment = lite.toStdColor(pigment);140 var alpha = pigment.a, color = lite.scaleColor(alpha, pigment);141 color.a = alpha;142 return lite.fromStdColor(lite.saturateColor(color));143 },144 matte: function(normal, finish, pigment){145 if(typeof finish == "string"){ finish = lite.finish[finish]; }146 pigment = lite.toStdColor(pigment);147 normal = lite.faceforward(lite.normalize(normal), this.incident);148 var ambient = lite.scaleColor(finish.Ka, this.ambient),149 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),150 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),151 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)));152 color.a = pigment.a;153 return lite.fromStdColor(lite.saturateColor(color));154 },155 metal: function(normal, finish, pigment){156 if(typeof finish == "string"){ finish = lite.finish[finish]; }157 pigment = lite.toStdColor(pigment);158 normal = lite.faceforward(lite.normalize(normal), this.incident);159 var v = lite.scale(-1, this.incident), specular, color,160 ambient = lite.scaleColor(finish.Ka, this.ambient),161 shadow = lite.saturate(-4 * lite.dot(normal, this.incident));162 if("phong" in finish){163 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));164 }else{165 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));166 }167 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, ambient), lite.multiplyColor(this.specular, specular)));168 color.a = pigment.a;169 return lite.fromStdColor(lite.saturateColor(color));170 },171 plastic: function(normal, finish, pigment){172 if(typeof finish == "string"){ finish = lite.finish[finish]; }173 pigment = lite.toStdColor(pigment);174 normal = lite.faceforward(lite.normalize(normal), this.incident);175 var v = lite.scale(-1, this.incident), specular, color,176 ambient = lite.scaleColor(finish.Ka, this.ambient),177 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),178 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights));179 if("phong" in finish){180 specular = lite.scaleColor(shadow * finish.Ks * finish.phong, lite.phong(normal, v, finish.phong_size, this.lights));181 }else{182 specular = lite.scaleColor(shadow * finish.Ks, lite.specular(normal, v, finish.roughness, this.lights));183 }184 color = lite.scaleColor(pigment.a, lite.addColor(lite.multiplyColor(pigment, lite.addColor(ambient, diffuse)), lite.multiplyColor(this.specular, specular)));185 color.a = pigment.a;186 return lite.fromStdColor(lite.saturateColor(color));187 },188 npr: function(normal, finish, pigment){189 if(typeof finish == "string"){ finish = lite.finish[finish]; }190 pigment = lite.toStdColor(pigment);191 normal = lite.faceforward(lite.normalize(normal), this.incident);192 var ambient = lite.scaleColor(finish.Ka, this.ambient),193 shadow = lite.saturate(-4 * lite.dot(normal, this.incident)),194 diffuse = lite.scaleColor(shadow * finish.Kd, lite.diffuse(normal, this.lights)),195 color = lite.scaleColor(pigment.a, lite.multiplyColor(pigment, lite.addColor(ambient, diffuse))),196 cool = lite.addColor(this.npr_cool, lite.scaleColor(this.npr_alpha, color)),197 warm = lite.addColor(this.npr_warm, lite.scaleColor(this.npr_beta, color)),198 d = (1 + lite.dot(this.incident, normal)) / 2,199 color = lite.scaleColor(this.npr_scale, lite.addColor(color, lite.mixColor(cool, warm, d)));200 color.a = pigment.a;201 return lite.fromStdColor(lite.saturateColor(color));202 }203 });204 // POV-Ray basic finishes205 206 gfx3d.lighting.finish = {207 208 // Default209 210 defaults: {Ka: 0.1, Kd: 0.6, Ks: 0.0, roughness: 0.05},211 212 dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, roughness: 0.15},213 shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.001},214 glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, roughness: 0.0001},215 216 phong_dull: {Ka: 0.1, Kd: 0.6, Ks: 0.5, phong: 0.5, phong_size: 1},217 phong_shiny: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 200},218 phong_glossy: {Ka: 0.1, Kd: 0.6, Ks: 1.0, phong: 1.0, phong_size: 300},219 220 luminous: {Ka: 1.0, Kd: 0.0, Ks: 0.0, roughness: 0.05},221 222 // Metals223 224 // very soft and dull225 metalA: {Ka: 0.35, Kd: 0.3, Ks: 0.8, roughness: 1/20},226 // fairly soft and dull227 metalB: {Ka: 0.30, Kd: 0.4, Ks: 0.7, roughness: 1/60},228 // medium reflectivity, holds color well229 metalC: {Ka: 0.25, Kd: 0.5, Ks: 0.8, roughness: 1/80},230 // highly hard and polished, high reflectivity231 metalD: {Ka: 0.15, Kd: 0.6, Ks: 0.8, roughness: 1/100},232 // very highly polished and reflective233 metalE: {Ka: 0.10, Kd: 0.7, Ks: 0.8, roughness: 1/120}234 };235 return lite;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-benchmark automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful