UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 5.82 kB
import{V as e,T as a}from"./index-BPURObVq.esm.min.js";const l=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],s=[()=>1,e=>e.y,e=>e.z,e=>e.x,e=>e.x*e.y,e=>e.y*e.z,e=>3*e.z*e.z-1,e=>e.x*e.z,e=>e.x*e.x-e.y*e.y],c=(e,a)=>l[e]*s[e](a),t=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class r{constructor(){this.preScaled=!1,this.l00=e.Zero(),this.l1_1=e.Zero(),this.l10=e.Zero(),this.l11=e.Zero(),this.l2_2=e.Zero(),this.l2_1=e.Zero(),this.l20=e.Zero(),this.l21=e.Zero(),this.l22=e.Zero()}addLight(e,l,s){a.Vector3[0].set(l.r,l.g,l.b);const t=a.Vector3[0],r=a.Vector3[1];t.scaleToRef(s,r),r.scaleToRef(c(0,e),a.Vector3[2]),this.l00.addInPlace(a.Vector3[2]),r.scaleToRef(c(1,e),a.Vector3[2]),this.l1_1.addInPlace(a.Vector3[2]),r.scaleToRef(c(2,e),a.Vector3[2]),this.l10.addInPlace(a.Vector3[2]),r.scaleToRef(c(3,e),a.Vector3[2]),this.l11.addInPlace(a.Vector3[2]),r.scaleToRef(c(4,e),a.Vector3[2]),this.l2_2.addInPlace(a.Vector3[2]),r.scaleToRef(c(5,e),a.Vector3[2]),this.l2_1.addInPlace(a.Vector3[2]),r.scaleToRef(c(6,e),a.Vector3[2]),this.l20.addInPlace(a.Vector3[2]),r.scaleToRef(c(7,e),a.Vector3[2]),this.l21.addInPlace(a.Vector3[2]),r.scaleToRef(c(8,e),a.Vector3[2]),this.l22.addInPlace(a.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(t[0]),this.l1_1.scaleInPlace(t[1]),this.l10.scaleInPlace(t[2]),this.l11.scaleInPlace(t[3]),this.l2_2.scaleInPlace(t[4]),this.l2_1.scaleInPlace(t[5]),this.l20.scaleInPlace(t[6]),this.l21.scaleInPlace(t[7]),this.l22.scaleInPlace(t[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(l[0]),this.l1_1.scaleInPlace(l[1]),this.l10.scaleInPlace(l[2]),this.l11.scaleInPlace(l[3]),this.l2_2.scaleInPlace(l[4]),this.l2_1.scaleInPlace(l[5]),this.l20.scaleInPlace(l[6]),this.l21.scaleInPlace(l[7]),this.l22.scaleInPlace(l[8])}updateFromArray(a){return e.FromArrayToRef(a[0],0,this.l00),e.FromArrayToRef(a[1],0,this.l1_1),e.FromArrayToRef(a[2],0,this.l10),e.FromArrayToRef(a[3],0,this.l11),e.FromArrayToRef(a[4],0,this.l2_2),e.FromArrayToRef(a[5],0,this.l2_1),e.FromArrayToRef(a[6],0,this.l20),e.FromArrayToRef(a[7],0,this.l21),e.FromArrayToRef(a[8],0,this.l22),this}updateFromFloatsArray(a){return e.FromFloatsToRef(a[0],a[1],a[2],this.l00),e.FromFloatsToRef(a[3],a[4],a[5],this.l1_1),e.FromFloatsToRef(a[6],a[7],a[8],this.l10),e.FromFloatsToRef(a[9],a[10],a[11],this.l11),e.FromFloatsToRef(a[12],a[13],a[14],this.l2_2),e.FromFloatsToRef(a[15],a[16],a[17],this.l2_1),e.FromFloatsToRef(a[18],a[19],a[20],this.l20),e.FromFloatsToRef(a[21],a[22],a[23],this.l21),e.FromFloatsToRef(a[24],a[25],a[26],this.l22),this}static FromArray(e){return(new r).updateFromArray(e)}static FromPolynomial(e){const a=new r;return a.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),a.l1_1=e.y.scale(.977204),a.l10=e.z.scale(.977204),a.l11=e.x.scale(.977204),a.l2_2=e.xy.scale(1.16538),a.l2_1=e.yz.scale(1.16538),a.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),a.l21=e.zx.scale(1.16538),a.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),a.l1_1.scaleInPlace(-1),a.l11.scaleInPlace(-1),a.l2_1.scaleInPlace(-1),a.l21.scaleInPlace(-1),a.scaleInPlace(Math.PI),a}}class o{constructor(){this.x=e.Zero(),this.y=e.Zero(),this.z=e.Zero(),this.xx=e.Zero(),this.yy=e.Zero(),this.zz=e.Zero(),this.xy=e.Zero(),this.yz=e.Zero(),this.zx=e.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=r.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){a.Vector3[0].copyFromFloats(e.r,e.g,e.b);const l=a.Vector3[0];this.xx.addInPlace(l),this.yy.addInPlace(l),this.zz.addInPlace(l)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),a.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),a.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(a.Vector3[0]).addInPlace(a.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(a.Vector3[0]).subtractInPlace(a.Vector3[1]),this.zz.copyFrom(e.l00),a.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(a.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return(new o).updateFromHarmonics(e)}static FromArray(a){const l=new o;return e.FromArrayToRef(a[0],0,l.x),e.FromArrayToRef(a[1],0,l.y),e.FromArrayToRef(a[2],0,l.z),e.FromArrayToRef(a[3],0,l.xx),e.FromArrayToRef(a[4],0,l.yy),e.FromArrayToRef(a[5],0,l.zz),e.FromArrayToRef(a[6],0,l.yz),e.FromArrayToRef(a[7],0,l.zx),e.FromArrayToRef(a[8],0,l.xy),l}}export{r as S,o as a}; //# sourceMappingURL=sphericalPolynomial.pure-CsRKkAN3.esm.min.js.map