From 252a8796ff62a0c4a5bffc13c65efde809e71654 Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 2 Apr 2026 21:09:39 +0200 Subject: [PATCH 1/3] Deferred compression to avoid contexts missmatch when using ExpressionJSON --- modules/wljs-editor/src/FrontendObject.wl | 47 ++++++++++++++----- modules/wljs-editor/src/FrontendObjectSync.wl | 10 ++-- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/modules/wljs-editor/src/FrontendObject.wl b/modules/wljs-editor/src/FrontendObject.wl index 244138e0..dda25d47 100644 --- a/modules/wljs-editor/src/FrontendObject.wl +++ b/modules/wljs-editor/src/FrontendObject.wl @@ -26,26 +26,45 @@ Objects = <||> Symbols = <||> -Compressed[string_String, {"ExpressionJSON", "ZLIB"}] := ImportByteArray[ByteArray[Developer`RawUncompress[BaseDecode[string]//Normal]], "ExpressionJSON"] +(* ::: Compression for large frontend objects :::*) + +Compressed[string_String, {"ExpressionJSON", "ZLIB"}] := ImportByteArray[ByteArray[Developer`RawUncompress[BaseDecode[string]//Normal]], "ExpressionJSON"] // ReleaseHold + +compression; + +(* [NOTE] This is a deferred compression method, i.e. it is only applied when the object is requested via net / link *) +(* Otherwise ExpressionJSON uncontrollably lifts the context from symbols depending where forntend object was created, *) +(* this leads to some symbols to be falsly assumed to be in Global`, which will throw errors on the frontend *) +(* The only way to avoid this is to deffer compression and ExpressionJSON convertion. *) +(* [FIXME] for the future: switch to Compress and WXF formats instead of JSON !!! *) + +(* apply only on large objects*) +compression[expr_, {"ExpressionJSON", "ZLIB", "Defer"}] := Hold[expr] /; (ByteCount[expr] < 0.1 * 1024 * 1024); + +SetAttributes[releaseCompression, HoldAll] + +releaseCompression[compression[expr_, {"ExpressionJSON", "ZLIB", "Defer"}]] := With[{arr = Normal[ExportByteArray[expr, "ExpressionJSON"] ]}, + With[{data = BaseEncode[ByteArray[Developer`RawCompress[arr] ] ]}, + Compressed[data, {"ExpressionJSON", "ZLIB"}] // Hold + ] +] + +releaseCompression[expr_] := expr + + -compress[expr_, f: {"ExpressionJSON", "ZLIB"}] := Hold[expr] -compress[expr_, f: {"ExpressionJSON", "ZLIB"}] := With[{arr = Normal[ExportByteArray[expr, "ExpressionJSON"] ]}, - With[{data = BaseEncode[ByteArray[Developer`RawCompress[arr] ] ]}, - Compressed[data, f] // Hold - ] -] /; (ByteCount[expr] > 0.1 * 1024 * 1024); CreateFrontEndObject[expr_, uid_String, OptionsPattern[] ] := With[{}, With[{ data = Switch[OptionValue["Store"] , "Kernel" - , <|"Private" -> compress[expr, {"ExpressionJSON", "ZLIB"}]|> + , <|"Private" -> compression[expr, {"ExpressionJSON", "ZLIB", "Defer"}]|> , "Frontend" - , <|"Public" -> compress[expr, {"ExpressionJSON", "ZLIB"}]|> + , <|"Public" -> compression[expr, {"ExpressionJSON", "ZLIB", "Defer"}]|> ,_ - , <|"Private" -> compress[expr, {"ExpressionJSON", "ZLIB"}], "Public" :> Objects[uid, "Private"]|> + , <|"Private" -> compression[expr, {"ExpressionJSON", "ZLIB", "Defer"}], "Public" :> Objects[uid, "Private"]|> ] }, If[!AssociationQ[Objects], @@ -69,7 +88,9 @@ CreateFrontEndObject[expr_, opts: OptionsPattern[] ] := CreateFrontEndObject[exp Options[CreateFrontEndObject] = {"Store" -> All} FrontEndRef[uid_String] := If[KeyExistsQ[Objects, uid], - Objects[uid, "Private"] // ReleaseHold + With[{o = Objects[uid, "Private"]}, + releaseCompression[o] (*Ehhhh Okay... we need to release it anyway *) + ] // ReleaseHold , $MissingHandler[uid, "Private"] // ReleaseHold ] @@ -79,7 +100,9 @@ FrontEndExecutable /: MakeBoxes[FrontEndExecutable[uid_String], StandardForm] := GetObject[uid_String] := With[{}, (*Echo["Getting object >> "<>uid];*) If[KeyExistsQ[Objects, uid], - Objects[uid, "Public"] + With[{ c = Objects[uid, "Public"] }, + releaseCompression[c] + ] , $Failed ] diff --git a/modules/wljs-editor/src/FrontendObjectSync.wl b/modules/wljs-editor/src/FrontendObjectSync.wl index 7adee42a..97995620 100644 --- a/modules/wljs-editor/src/FrontendObjectSync.wl +++ b/modules/wljs-editor/src/FrontendObjectSync.wl @@ -25,9 +25,13 @@ syncMonitor = ImportComponent[FileNameJoin[{rootDir, "templates", "SyncMonitor.w EventHandler[NotebookEditorChannel // EventClone, { "FetchFrontEndObject" -> Function[data, Echo["Sync >> requested from master kernel"]; - With[{promise = data["Promise"], kernel = GenericKernel`HashMap[ data["Kernel"] ]}, - With[{result = CoffeeLiqueur`Extensions`FrontendObject`Internal`Objects[data["UId"] ]}, - GenericKernel`Async[kernel, EventFire[promise, Resolve, result["Public"] ] ]; + With[{promise = data["Promise"], kernel = GenericKernel`HashMap[ data["Kernel"] ]}, + (* [FIXME] Include these symbols normally using Needs[] *) + (* we release any possible deferred compression wrappers *) + With[{result = CoffeeLiqueur`Extensions`FrontendObject`Internal`Objects[data["UId"] ]["Public"]}, + With[{c = CoffeeLiqueur`Extensions`FrontendObject`Internal`releaseCompression[result]}, + GenericKernel`Async[kernel, EventFire[promise, Resolve, c ] ]; + ]; ]; ]; ] From b5fcfe64167914ff5a402786b6b6a15f0c897acf Mon Sep 17 00:00:00 2001 From: Kirill Vasin Date: Thu, 2 Apr 2026 22:35:23 +0200 Subject: [PATCH 2/3] fix container layout offset & added Controls disable --- .../wljs-graphics3d-threejs/dist/kernel.js | 32 ++++++++++++------- .../dist/kernel.min.js | 2 +- modules/wljs-graphics3d-threejs/src/kernel.js | 32 ++++++++++++------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/modules/wljs-graphics3d-threejs/dist/kernel.js b/modules/wljs-graphics3d-threejs/dist/kernel.js index 71c89796..766216e4 100644 --- a/modules/wljs-graphics3d-threejs/dist/kernel.js +++ b/modules/wljs-graphics3d-threejs/dist/kernel.js @@ -5303,7 +5303,9 @@ if (!GUI && PathRendering) { /** * @type {HTMLElement} */ -const container = env.element; +const container = document.createElement('div'); +container.classList.add('relative'); +env.element.appendChild(container); /** * @type {[Number, Number]} @@ -5469,7 +5471,7 @@ env.local.renderer = renderer; //fix for translate-50% layout const layoutOffset = {x:0, y:0}; -if (container.classList.contains('slide-frontend-object')) { +if (env.element.classList.contains('slide-frontend-object')) { layoutOffset.x = -1.0; } @@ -5553,19 +5555,22 @@ if (PathRendering) { } let controlObject = { - init: (camera, dom) => { - controlObject.o = new OrbitControls( camera, domElement ); - controlObject.o.addEventListener('change', wakeFunction); - controlObject.o.target.set( 0, 1, 0 ); - controlObject.o.update(); - }, + init: (camera, dom) => { + controlObject.o = new OrbitControls( camera, domElement ); + controlObject.o.addEventListener('change', wakeFunction); + controlObject.o.target.set( 0, 1, 0 ); + controlObject.o.update(); + }, - dispose: () => { - - } -}; + dispose: () => { + } + }; +if ('Controls' in options && !(await interpretate(options.Controls))) { + controlObject.disabled = true; + domElement.style.pointerEvents = 'none'; +} if (options.Controls) { @@ -5755,6 +5760,8 @@ if (options.Controls) { } } + + env.local.controlObject = controlObject; @@ -6981,6 +6988,7 @@ core.Graphics3D.destroy = (args, env) => { if (env.local.labelContainer) env.local.labelContainer.remove(); if (env.local.guiContainer) env.local.guiContainer.remove(); env.local.rendererContainer.remove(); + env.local.element.remove(); }; core.Graphics3D.virtual = true; diff --git a/modules/wljs-graphics3d-threejs/dist/kernel.min.js b/modules/wljs-graphics3d-threejs/dist/kernel.min.js index 4d995e77..f0d6fad9 100644 --- a/modules/wljs-graphics3d-threejs/dist/kernel.min.js +++ b/modules/wljs-graphics3d-threejs/dist/kernel.min.js @@ -1,4 +1,4 @@ -var e={};Object.defineProperty(e,"__esModule",{value:!0});var t=e.default=void 0;const n=6/29,o=3*n*n,r=e=>Math.round(255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055))||0,a=e=>e>n?e*e*e:o*(e-4/29);t=e.default=({luminance:e,a:t,b:n})=>{const o=(e+16)/116,i=.96422*a(o+t/500),s=Number(a(o)),l=.82521*a(o-n/200);return{red:r(3.1338561*i-1.6168667*s-.4906146*l),green:r(-.9787684*i+1.9161415*s+.033454*l),blue:r(.0719453*i-.2289914*s+1.4052427*l)}};let i,s,l={};function c(e,t,n,o=!1,r=!1){const a=e/2,s=t/2,l=e/n,c=t/n,u=[],d=[.4*l,.4*c],h=new i.LineBasicMaterial({toneMapped:!1,color:new i.Color("gray")});r&&(u.push(new i.Vector3(a,s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(-a,s,0)),u.push(new i.Vector3(-a,-s,0)),o&&(u.push(new i.Vector3(-a,-s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(a,s,0))));for(let e=0;e<=n;e++){const t=l*e-a;u.push(new i.Vector3(t,-s,0)),u.push(new i.Vector3(t,1*d[1]-s,0)),o||(u.push(new i.Vector3(t,s,0)),u.push(new i.Vector3(t,s-1*d[1],0)))}for(let e=0;e<=n;e++){const t=c*e-s;u.push(new i.Vector3(a,t,0)),u.push(new i.Vector3(a-1*d[0],t,0)),u.push(new i.Vector3(-a,t,0)),u.push(new i.Vector3(1*d[0]-a,t,0))}return new i.LineSegments((new i.BufferGeometry).setFromPoints(u),h)}l.name="WebObjects/Graphics3D",interpretate.contextExpand(l),["AlignmentPoint","AspectRatio","AutomaticImageSize","Axes","AxesEdge","AxesLabel","AxesOrigin","AxesStyle","Background","BaselinePosition","BaseStyle","Boxed","BoxRatios","BoxStyle","ClipPlanes","ClipPlanesStyle","ColorOutput","ContentSelectable","ColorFunction","ControllerLinking","ControllerMethod","ControllerPath","CoordinatesToolOptions","DisplayFunction","Epilog","FaceGrids","FaceGridsStyle","FormatType","ImageMargins","ImagePadding","ImageSize","ImageSizeRaw","LabelStyle","Lighting","Method","PlotLabel","PlotRange","PlotRangePadding","PlotRegion","PreserveImageOptions","Prolog","RotationAction","SphericalRegion","Ticks","TicksStyle","TouchscreenAutoZoom","ViewAngle","ViewCenter","ViewMatrix","ViewPoint","ViewProjection","VertexTextureCoordinates","RTX","ViewRange","ViewVector","ViewVertical","Controls","PointerLockControls","VertexNormals","VertexColors"].map(e=>{l[e]=()=>e}),l.VertexNormals.update=()=>"VertexNormals",l.VertexColors.update=()=>"VertexColors",l.Void=(e,t)=>{console.log(e),console.warn("went to the void...")},l.Void.update=()=>{},l.Void.destroy=()=>{},l.CapForm=l.Void,l.Appearance=l.Void,l.All=()=>"All",l.LABColor=async(e,n)=>{let o;o=e.length>1?[await interpretate(e[0],n),await interpretate(e[1],n),await interpretate(e[2],n)]:await interpretate(e[0],n);const r=t({luminance:100*o[0],a:100*o[1],b:100*o[2]});return console.log("LAB color"),console.log(r),n.color=new i.Color(r.red/255,r.green/255,r.blue/255),e.length>3&&(n.opacity=await interpretate(e[3],n)),n.color},l.LABColor.update=()=>{},l.LinearFog=async(e,t)=>{let n=1,o=100,r=13421772;e.length>0&&(r=await interpretate(e[0],t)),e.length>1&&([n,o]=await interpretate(e[1],t)),t.global.scene.fog=new i.Fog(r,n,o)},l.Style=async(e,t)=>{const n=t,o=await core._getRules(e,t);o.FontSize&&(n.fontSize=o.FontSize),o.FontColor&&(n.color=o.FontColor),o.FontFamily&&(n.fontFamily=o.FontFamily);for(let t=1;t{const n=await core._getRules(e,t);return n.FontSize&&(t.fontSize=n.FontSize),n.FontFamily&&(t.fontFamily=n.FontFamily),await interpretate(e[0],t)},l.Dashing=(e,t)=>{console.log("Dashing not implemented")},l.Annotation=core.List,l.GraphicsGroup=async(e,t)=>{const n=new i.Group;let o={...t};o.mesh=n;for(const t of e)await interpretate(t,o);t.mesh.add(n)},l.Metalness=(e,t)=>{t.metalness=interpretate(e[0],t)},l.Emissive=async(e,t)=>{const n={...t};await interpretate(e[0],n),t.emissive=n.color,e.length>1&&(t.emissiveIntensity=await interpretate(e[1],n))},l.Glow=l.Emissive;l.Hue=async(e,t)=>{t.colorInherit=!1;let n=await Promise.all(e.map(e=>interpretate(e,t)));return n.length<3&&(n=[n[0],1,1]),n=((e,t,n,o=n-n*t/2,r=Math.min(o,1-o))=>[e,r?(n-o)/r:0,o])(...n),n=[n[0],(100*n[1]).toFixed(2),(100*n[2]).toFixed(2)],t.color=new i.Color("hsl("+(314*n[0]).toFixed(2)+","+n[1]+"%,"+n[2]+"%)"),t.color},l.EdgeForm=async(e,t)=>{t.edgecolor=await interpretate(e[0],{...t})},l.RGBColor=async(e,t)=>{if(t.colorInherit=!1,3!==e.length&&4!==e.length&&1!==e.length)return console.log("RGB format not implemented",e),void console.error("RGB values should be triple!");let n=[...e];1===e.length&&(n=await interpretate(e[0],t));const o=await interpretate(n[0],t),r=await interpretate(n[1],t),a=await interpretate(n[2],t);return t.color=new i.Color(o,r,a),t.color},l.GrayLevel=async(e,t)=>{t.colorInherit=!1;const n=await interpretate(e[0],t);return t.color=new i.Color(n,n,n),t.color},l.Roughness=(e,t)=>{const n=interpretate(e[0],t);"number"!=typeof n&&console.error("Opacity must have number value!"),console.log(n),t.roughness=n},l.Opacity=(e,t)=>{var n=interpretate(e[0],t);"number"!=typeof n&&console.error("Opacity must have number value!"),console.log(n),t.opacity=n},l.Scale=async(e,t)=>{const n=e[0];let o=await interpretate(e[1],t),r=e.length>2?await interpretate(e[2],t):[0,0,0];o instanceof NumericArrayObject&&(o=o.normal()),Array.isArray(o)||(o=[o,o,o]),r instanceof NumericArrayObject&&(r=r.normal());const a=new i.Group;await interpretate(n,{...t,mesh:a});const s=(new i.Matrix4).makeTranslation(-r[0],-r[1],-r[2]),l=(new i.Matrix4).makeScale(o[0],o[1],o[2]),c=(new i.Matrix4).makeTranslation(r[0],r[1],r[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);return a.applyMatrix4(u),t.mesh.add(a),t.local.group=a,t.local.scale=o.slice(),t.local.center=r.slice(),a},l.Scale.update=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal());const r=t.local.scale||[1,1,1],a=t.local.center||[0,0,0],s=(new i.Matrix4).makeTranslation(-a[0],-a[1],-a[2]),l=(new i.Matrix4).makeScale(1/r[0],1/r[1],1/r[2]),c=(new i.Matrix4).makeTranslation(a[0],a[1],a[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);t.local.group.applyMatrix4(u);const d=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),h=(new i.Matrix4).makeScale(n[0],n[1],n[2]),p=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),m=(new i.Matrix4).multiplyMatrices(p,h).multiply(d);t.local.group.applyMatrix4(m),t.local.scale=n.slice(),t.local.center=o.slice(),t.wake&&t.wake()},l.Scale.virtual=!0,l.Scale.destroy=()=>{},l.ImageScaled=(e,t)=>{},l.Thickness=async(e,t)=>{t.thickness=await interpretate(e[0],t)},l.AbsoluteThickness=async(e,t)=>{t.thickness=await interpretate(e[0],t)},l.Arrowheads=async(e,t)=>{let n=await interpretate(e[0],t);Array.isArray(n)?(n=n.flat(1/0)[0],t.arrowHeight=280*n,t.arrowRadius=180*n):(t.arrowHeight=280*n,t.arrowRadius=180*n)};const u={Tube:async(e,t)=>{let n=await interpretate(e[0],t),o=1;if(e.length>1&&(o=await interpretate(e[1],t)),t.radius&&(o=t.radius),o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject)n=n.buffer;else if(Array.isArray(n[0]))return void n.forEach(n=>interpretate(["Tube",["JSObject",n],...e.slice(1)],t));let r=[];const a=t.vertices.position.array;for(let e=0;econsole.error("Tube inside Complex does not support updates"),u.Tube.destroy=async(e,t)=>{t.local.tube&&t.local.tube.dispose()},u.Tube.virtual=!0,l.Cone=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=o.map(()=>n)),n[n.length-1]=0;const r=[o[0][0]-o[1][0],o[0][1]-o[1][0],o[0][2]-o[1][2]].map((e,t)=>o[0][t]+1e-4*e);o.unshift(r),n.unshift(1e-6);const a=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});k||(k=await Promise.resolve().then(function(){return j}),k=k.VariableTube);const i=new k(a,o,null,n,16,!1);t.mesh.add(i.mesh),t.local.tube=i,a.dispose()},l.Cone.update=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=o.map(()=>n)),n[n.length-1]=0;const r=[o[0][0]-o[1][0],o[0][1]-o[1][0],o[0][2]-o[1][2]].map((e,t)=>o[0][t]+1e-4*e);o.unshift(r),n.unshift(1e-6),t.local.tube.update(o,n),t.wake(!0)},l.Cone.virtual=!0,l.Cone.destroy=async(e,t)=>{t.local.tube.dispose()},l.Tube=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal());const r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});k||(k=await Promise.resolve().then(function(){return j}),k=k.VariableTube);const a=new k(r,o,null,n,16,!1);t.mesh.add(a.mesh),t.local.tube=a,r.dispose()},l.Tube.update=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),t.local.tube.update(o,n),t.wake(!0)},l.Tube.virtual=!0,l.Tube.destroy=async(e,t)=>{t.local.tube.dispose()},l.TubeArrow=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));const o=await interpretate(e[0],t),r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),a=new i.Vector3(...o[0]),s=new i.Vector3(...o[1]),l=a.clone().addScaledVector(s,-1),c=new i.CylinderGeometry(n,n,l.length(),32,1),u=new i.Mesh(c,r),d=new i.ConeGeometry(t.arrowRadius/100,t.arrowHeight/60,32),h=new i.Mesh(d,r);h.position.y=l.length()/2+t.arrowHeight/120;let p=new i.Group;p.add(u,h);var m=.5*Math.PI,f=s.clone().add(a).divideScalar(2),g=new i.Matrix4,y=new i.Matrix4;return new i.Matrix4,g.lookAt(s,a,new i.Vector3(0,1,0)),y.makeRotationX(m),g.multiply(y),t.local.matrix=p.matrix.clone(),p.applyMatrix4(g),p.position.addScaledVector(f,1),t.local.group=p,t.mesh.add(p),c.dispose(),d.dispose(),r.dispose(),p},l.TubeArrow.update=async(e,t)=>{const n=await interpretate(e[0],t),o=new i.Vector3(...n[0]),r=new i.Vector3(...n[1]);o.clone().addScaledVector(r,-1);var a=.5*Math.PI,s=r.clone().add(o).divideScalar(2),l=new i.Matrix4,c=new i.Matrix4;new i.Matrix4,l.lookAt(r,o,new i.Vector3(0,1,0)),c.makeRotationX(a),l.multiply(c),t.local.matrix.decompose(t.local.group.position,t.local.group.quaternion,t.local.group.scale),t.local.group.matrix.copy(t.local.matrix),t.local.group.applyMatrix4(l),t.local.group.position.addScaledVector(s,1),t.wake(!0)},l.Arrow=async(e,t)=>{let n;if(1===e.length){if("Tube"===e[0][0]||"TubeArrow"===e[0][0])return e[0][0]="TubeArrow",await interpretate(e[0],t);n=await interpretate(e[0],t)}else n=await interpretate(e[0],t);if(1===n.length&&(n=n[0]),n.length>2){var o=new i.BufferGeometry;const e=n.slice(0,-1);o.setAttribute("position",new i.BufferAttribute(new Float32Array(e.flat()),3));const r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1}),a=new i.Line(o,r);t.local.line=a,t.mesh.add(a)}const r=[new i.Vector4(...n[n.length-2],1),new i.Vector4(...n[n.length-1],1)];r.forEach(e=>{e=e.applyMatrix4(t.matrix)});const a=r[0].clone(),s=r[1].add(r[0].negate()),l=s.length(),c=new i.ArrowHelper(s.normalize(),a,l,t.color);return t.mesh.add(c),c.line.material.linewidth=t.thickness,t.local.arrow=c,c},l.Arrow.update=async(e,t)=>{let n;if(1===e.length){if("Tube"===e[0][0]||"TubeArrow"===e[0][0])return console.log("TUBE inside!"),await interpretate(e[0],t);n=await interpretate(e[0],t)}else n=await interpretate(e[0],t),n instanceof NumericArrayObject&&(n=n.normal());if(1===n.length&&(n=n[0]),t.local.line){const e=t.local.line.geometry.getAttribute("position"),o=n.slice(0,-1);e.needsUpdate=!0;for(let t=0;t{e=e.applyMatrix4(t.matrix)}),t.local.arrow.position.copy(o[0]);const r=o[1].add(o[0].negate()),a=r.length();t.local.arrow.setDirection(r.normalize()),t.local.arrow.setLength(a),t.wake(!0)},l.Arrow.destroy=async(e,t)=>{t.local.line&&t.local.line.dispose(),t.local.arrow&&t.local.arrow.dispose()},l.Arrow.virtual=!0,u.Point=async(e,t)=>{let n=await interpretate(e[0],t);const o=new i.BufferGeometry;if(o.setAttribute("position",t.vertices.position),n instanceof NumericArrayObject){const e=n.normal();o.setIndex(e.flat().map(e=>e-1))}else Array.isArray(n)||(n=[n]),o.setIndex(n.flat().map(e=>e-1));let r;t?.vertices?.colored?(o.setAttribute("color",t.vertices.colors),r=new i.PointsMaterial({vertexColors:!0,transparent:t.opacity<1,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112})):r=new i.PointsMaterial({color:t.color,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112}),t.local.material=r;const a=new i.Points(o,r);return t.local.geometry=o,t.mesh.add(a),t.local.points=a,t.local.points},u.Point.virtual=!0,u.Point.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},l.Point=async(e,t)=>{let n=await interpretate(e[0],t);const o=new i.BufferGeometry;let r;n instanceof NumericArrayObject?o.setAttribute("position",new i.Float32BufferAttribute(n.buffer,3)):o.setAttribute("position",new i.Float32BufferAttribute(new Float32Array(n.flat(1/0)),3)),r=new i.PointsMaterial({color:t.color,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112});const a=new i.Points(o,r);return t.local.geometry=o,t.mesh.add(a),t.local.points=a,t.local.material=r,t.local.points},l.Point.update=async(e,t)=>{let n=await interpretate(e[0],t);return n instanceof NumericArrayObject?t.local.geometry.setAttribute("position",new i.Float32BufferAttribute(n.buffer,3)):t.local.geometry.setAttribute("position",new i.Float32BufferAttribute(n.flat(1/0),3)),t.wake(!0),t.local.points},l.Point.destroy=async(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},l.Point.virtual=!0,l.Sphere=async(e,t)=>{var n=1;e.length>1&&(n=await interpretate(e[1],t));const o=new t.material({color:t.color,roughness:t.roughness,opacity:t.opacity,transparent:t.opacity<1,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});function r(e){const r=new i.Vector4(...e,1),a=new i.SphereGeometry(n,40,40),s=new i.Mesh(a,o);return s.position.set(r.x,r.y,r.z),s.castShadow=t.shadows,s.receiveShadow=t.shadows,t.mesh.add(s),a.dispose(),s}console.log(t.local);let a=await interpretate(e[0],t);return a instanceof NumericArrayObject&&(a=a.normal()),console.log("DRAW A SPHERE"),3===a.length?t.local.object=[r(a)]:(t.local.object=[],a.forEach(e=>{t.local.object.push(r(e))})),o.dispose(),t.local.object},l.Sphere.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[0],t);if(n instanceof NumericArrayObject&&(n=n.normal()),1==t.local.object.length&&(n=[n]),!t.Lerp){let e=0;return void n.forEach(n=>{t.local.object[e].position.set(...n),++e})}if(!t.local.lerp){console.log("creating worker for lerp of movements multiple..");const e={alpha:.05,target:n.map(e=>new i.Vector3(...e)),eval:()=>{for(let n=0;n{console.log("Sphere: destroy")},l.Sphere.virtual=!0,l.Sky=(e,t)=>{const n=new b;n.scale.setScalar(1e4),t.mesh.add(n),t.sky=n,t.sun=new i.Vector3;const o=n.material.uniforms;o.turbidity.value=10,o.rayleigh.value=2,o.mieCoefficient.value=.005,o.mieDirectionalG.value=.8},l._Water=(e,t)=>{const n=new i.PlaneGeometry(1e4,1e4),o=new y(n,{textureWidth:512,textureHeight:512,waterNormals:(new i.TextureLoader).load("textures/waternormals.jpg",function(e){e.wrapS=e.wrapT=i.RepeatWrapping}),sunDirection:new i.Vector3,sunColor:16777215,waterColor:7695,distortionScale:3.7,fog:!0});o.rotation.x=-Math.PI/2,t.mesh.add(o),t.water=o},l.Cube=async(e,t)=>{let n=new i.Vector3(0,0,0),o=new i.Vector3(1,1,1),r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);if("number"==typeof e)o.set(e,e,e);else if(Array.isArray(e))if(3===e.length)e.every(e=>"number"==typeof e)&&n.set(...e);else if(2===e.length){const[t,n]=e;"number"==typeof t&&"number"==typeof n&&(r.z=t,r.y=n)}}const a=new i.BoxGeometry(1,1,1),s=new t.material({color:t.color,transparent:!0,opacity:t.opacity,roughness:t.roughness,depthWrite:!0,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.copy(o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),t.local.geometry=l.geometry.clone(),t.local.box=l,a.dispose(),s.dispose(),l},l.Cube.update=async(e,t)=>{const n=t.local.box;if(!n)return void console.warn("No cube found to update.");let o=new i.Vector3(0,0,0),r=new i.Vector3(1,1,1),a=new i.Euler(0,0,0);for(const n of e){const e=await interpretate(n,t);if("number"==typeof e)r.set(e,e,e);else if(Array.isArray(e))if(3===e.length&&e.every(e=>"number"==typeof e))o.set(...e);else if(2===e.length){const[t,n]=e;"number"==typeof t&&"number"==typeof n&&(a.z=t,a.y=n)}}n.position.copy(o),n.rotation.copy(a),n.geometry.copy(t.local.geometry),n.geometry.applyMatrix4((new i.Matrix4).makeScale(r.x,r.y,r.z)),t.wake(!0)},l.Cube.destroy=async(e,t)=>{t.local.box.geometry.dispose()},l.Cube.virtual=!0,l.Cuboid=async(e,t)=>{var n,o,r;if(2===e.length){var a=[new i.Vector4(...await interpretate(e[1],t),1),new i.Vector4(...await interpretate(e[0],t),1)];o=a[0].clone().add(a[1]).divideScalar(2),n=a[0].clone().add(a[1].clone().negate())}else{if(1!==e.length)return void console.error("Expected 2 or 1 arguments");r=await interpretate(e[0],t),o=new i.Vector4(...r,1),n=new i.Vector4(1,1,1,1),o.add(n.clone().divideScalar(2))}const s=new i.BoxGeometry(1,1,1),l=new t.material({color:t.color,transparent:!0,opacity:t.opacity,roughness:t.roughness,depthWrite:!0,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),c=new i.Mesh(s,l);return c.position.set(o.x,o.y,o.z),t.local.geometry=c.geometry.clone(),c.geometry.applyMatrix4((new i.Matrix4).makeScale(n.x,n.y,n.z)),c.receiveShadow=t.shadows,c.castShadow=t.shadows,t.mesh.add(c),t.local.box=c,s.dispose(),l.dispose(),c},l.Cuboid.update=async(e,t)=>{var n,o,r;if(2===e.length){var a=[new i.Vector4(...await interpretate(e[1],t),1),new i.Vector4(...await interpretate(e[0],t),1)];o=a[0].clone().add(a[1]).divideScalar(2),n=a[0].clone().add(a[1].clone().negate())}else r=await interpretate(e[0],t),o=new i.Vector4(...r,1),n=new i.Vector4(1,1,1,1),o.add(n.clone().divideScalar(2));console.log(n.x,n.y,n.z),t.local.box.position.copy(o),t.local.box.geometry.copy(t.local.geometry),t.local.box.geometry.applyMatrix4((new i.Matrix4).makeScale(n.x,n.y,n.z)),t.wake(!0)},l.Cuboid.destroy=async(e,t)=>{t.local.box.geometry.dispose()},l.Cuboid.virtual=!0,l.Center=(e,t)=>"Center",l.Cylinder=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);1===o.length&&(o=o[0]),o[0]=new i.Vector3(...o[0]),o[1]=new i.Vector3(...o[1]);const r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});console.log(o);var a=(new i.Vector3).subVectors(o[1],o[0]);console.log(a);var s=new i.CylinderGeometry(n,n,1,32,4,!1);s.applyMatrix4((new i.Matrix4).makeTranslation(0,.5,0)),s.applyMatrix4((new i.Matrix4).makeRotationX(i.MathUtils.degToRad(90)));var l=new i.Mesh(s,r);l.receiveShadow=t.shadows,l.castShadow=t.shadows,l.position.copy(o[0]),t.local.g=l.geometry.clone(),l.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,a.length())),l.geometry.lookAt(a),t.local.cylinder=l,t.mesh.add(l)},l.Cylinder.update=async(e,t)=>{let n=await interpretate(e[0],t);1===n.length&&(n=n[0]),n[0]=new i.Vector3(...n[0]),n[1]=new i.Vector3(...n[1]);var o=(new i.Vector3).subVectors(n[1],n[0]);t.local.cylinder.position.copy(n[0]),t.local.cylinder.geometry.copy(t.local.g),t.local.cylinder.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,o.length())),t.local.cylinder.geometry.lookAt(o),t.wake(!0)},l.Cylinder.destroy=async(e,t)=>{t.local.cylinder.geometry.dispose(),t.local.g.dispose()},l.Cylinder.virtual=!0,l.Octahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.OctahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Tetrahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.TetrahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Icosahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.IcosahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Translate=async(e,t)=>{let n=new i.Group,o=await interpretate(e[1],t);o instanceof NumericArrayObject&&(o=o.normal());let r=Object.assign({},t);r.mesh=n,await interpretate(e[0],r),n.translateX(o[0]),n.translateY(o[1]),n.translateZ(o[2]),t.local.mesh=n,t.mesh.add(n)},l.Translate.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.mesh;if(t.Lerp){if(!t.local.lerp){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{o.position.lerp(e.target,.05)}};t.local.lerp=e,t.Handlers.push(e)}t.local.lerp.target.fromArray(n)}else o.position.set(n[0],n[1],n[2])},l.Translate.virtual=!0,l.Translate.destroy=(e,t)=>{t.local.mesh.removeFromParent()},l.LookAt=async(e,t)=>{const n=new i.Group,o=await interpretate(e[1],t);await interpretate(e[0],{...t,mesh:n});let r=(new i.Box3).setFromObject(n),a=r.max.clone().add(r.min).divideScalar(2);console.log("center: "),console.log(a);let l=(new i.Matrix4).makeTranslation(-a.x,-a.y,-a.z);n.applyMatrix4(l),n.lookAt(...o),n.rotation.x=s.PI/2,l=(new i.Matrix4).makeTranslation(a.x,a.y,a.z),n.applyMatrix4(l),t.local.group=n,t.mesh.add(n)},l.LookAt.update=async(e,t)=>{t.wake(!0);const n=await interpretate(e[1],t);t.local.group.lookAt(...n)},l.LookAt.virtual=!0;const d=(e,t)=>{let n=[];switch(t.local.type||(2==e.length?(console.warn("apply matrix3x3 + translation"),t.local.type="complex"):Array.isArray(e[0])?(t.local.type="normal",console.warn("apply matrix 3x3")):(console.warn("apply translation"),t.local.type="translation")),t.local.type){case"normal":n=e.map(e=>[...e,0]),n.push([0,0,0,1]),n=(new i.Matrix4).set(...aflatten(n));break;case"translation":n=(new i.Matrix4).makeTranslation(...e);break;case"complex":n=[...e[0]];const t=[...e[1]];n[0].push(t[0]),n[1].push(t[1]),n[2].push(t[2]),n.push([0,0,0,1]),n=(new i.Matrix4).set(...aflatten(n));break;default:throw"undefined type of matrix or vector"}return n};var h;function p(e){return new Promise(t=>setTimeout(t,e))}function m(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/(\S)_(\{([^{}]+)\}|([^\s{}]))/g,(e,t,n,o,r)=>t+""+(o??r)+"").replace(/(\S)\^(\{([^{}]+)\}|([^\s{}]))/g,(e,t,n,o,r)=>t+""+(o??r)+"")}l.Rotate=async(e,t)=>{let n=await interpretate(e[1],t),o=[0,0,1];e.length>2&&(o=await interpretate(e[2],t)),o instanceof NumericArrayObject&&(o=o.normal());const r=new i.Group;return await interpretate(e[0],{...t,mesh:r}),o=new i.Vector3(...o),r.rotateOnWorldAxis(o,n),t.mesh.add(r),t.local.group=r,t.local.angle=n,t.local.dir=o,r},l.Rotate.update=async(e,t)=>{let n=await interpretate(e[1],t);const o=n-t.local.angle;if(t.local.angle=n,e.length>2){let n=await interpretate(e[2],t);n instanceof NumericArrayObject&&(n=n.normal()),t.local.dir.fromArray(n),t.local.group.rotateOnWorldAxis(t.local.dir,o)}else t.local.group.rotateOnWorldAxis(t.local.dir,o);t.wake()},l.Rotate.virtual=!0,l.Rotate.destroy=(e,t)=>{},l.Scale=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal()),2===n.length&&(n=[n[0],n[1],1]),1===n.length&&(n=[n[0],n[0],n[0]]);const r=new i.Group;await interpretate(e[0],{...t,mesh:r});const a=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),s=(new i.Matrix4).makeScale(n[0],n[1],n[2]),l=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),c=(new i.Matrix4).multiplyMatrices(l,s).multiply(a);return r.applyMatrix4(c),t.mesh.add(r),t.local.group=r,t.local.scale=n.slice(),t.local.center=o.slice(),r},l.Scale.update=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal()),2===n.length&&(n=[n[0],n[1],1]),1===n.length&&(n=[n[0],n[0],n[0]]);const r=t.local.scale||[1,1,1],a=t.local.center||[0,0,0],s=(new i.Matrix4).makeTranslation(-a[0],-a[1],-a[2]),l=(new i.Matrix4).makeScale(1/r[0],1/r[1],1/r[2]),c=(new i.Matrix4).makeTranslation(a[0],a[1],a[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);t.local.group.applyMatrix4(u);const d=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),h=(new i.Matrix4).makeScale(n[0],n[1],n[2]),p=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),m=(new i.Matrix4).multiplyMatrices(p,h).multiply(d);t.local.group.applyMatrix4(m),t.local.scale=n.slice(),t.local.center=o.slice(),t.wake&&t.wake()},l.Scale.virtual=!0,l.Scale.destroy=(e,t)=>{},l.GeometricTransformation=async(e,t)=>{let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),n.length>3){console.warn("multiple matrixes"),t.local.entities=[];for(const o of n){const n=new i.Group,r=d(o,t);await interpretate(e[0],{...t,mesh:n}),n.matrixAutoUpdate=!1;const a={};a.quaternion=new i.Quaternion,a.position=new i.Vector3,a.scale=new i.Vector3,r.decompose(a.position,a.quaternion,a.scale),n.quaternion.copy(a.quaternion),n.position.copy(a.position),n.scale.copy(a.scale),n.updateMatrix(),a.group=n,t.mesh.add(n),t.local.entities.push(a)}return t.local.entities[0]}{console.warn("single matrix");const o=new i.Group,r=d(n,t);return await interpretate(e[0],{...t,mesh:o}),o.matrixAutoUpdate=!1,t.local.quaternion=new i.Quaternion,t.local.position=new i.Vector3,t.local.scale=new i.Vector3,r.decompose(t.local.position,t.local.quaternion,t.local.scale),o.quaternion.copy(t.local.quaternion),o.position.copy(t.local.position),o.scale.copy(t.local.scale),o.updateMatrix(),t.local.group=o,t.mesh.add(o),o}},l.GeometricTransformation.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),t.local.entities){console.log("multiple matrixes");for(let e=0;e{console.warn("Nothing to dispose!")},l.Entity=()=>{console.log("Entity is not supported inside Graphics3D")},l.GeometricTransformation.virtual=!0,l.GraphicsComplex=async(e,t)=>{var n=Object.assign({},t);const o=await core._getRules(e,{...t,hold:!0});let r,a=await interpretate(e[0],n);a instanceof NumericArrayObject?r=new Float32Array(a.buffer):(a=a.flat(),r=new Float32Array(a)),n.vertices={position:new i.BufferAttribute(r,3),colored:!1,onResize:[],handlers:[]},t.local.vertices=n.vertices;let s=[];if(t.local.fence=()=>{for(const e of s)e.resolve();s=[]},"VertexFence"in o&&(n.fence=()=>{const e=new Deferred;return s.push(e),e.promise}),"VertexColors"in o){let e=await interpretate(o.VertexColors,t);n.vertices.colored=!0,e instanceof NumericArrayObject?n.vertices.colors=new i.BufferAttribute(new Float32Array(e.buffer),3):(e[0]?.isColor&&(e=e.map(e=>[e.r,e.g,e.b])),n.vertices.colors=new i.BufferAttribute(new Float32Array(e.flat()),3))}if("VertexNormals"in o){const e=await interpretate(o.VertexNormals,t);e instanceof NumericArrayObject?n.vertices.normals=new i.BufferAttribute(new Float32Array(e.buffer),3):n.vertices.normals=new i.BufferAttribute(new Float32Array(e.flat()),3)}const c=new i.Group;t.local.group=c,n.context=[u,l],await interpretate(e[1],n),t.mesh.add(c)},l.Reflectivity=()=>{console.warn("not implemented")},l.GraphicsComplex.update=async(e,t)=>{t.wake(!0);let n,o=await interpretate(e[0],t);n=o instanceof NumericArrayObject?new Float32Array(o.buffer):new Float32Array(o.flat()),3*t.local.vertices.position.counte(t.local.vertices))),t.local.vertices.position.set(n),t.local.vertices.position.needsUpdate=!0;let r=!1;if(t.local.vertices.normals){r||(r=await core._getRules(e,{...t,hold:!0}));const n=await interpretate(r.VertexNormals,t);n instanceof NumericArrayObject?t.local.vertices.normals.set(new Float32Array(n.buffer)):t.local.vertices.normals.set(new Float32Array(n.flat())),t.local.vertices.normals.needsUpdate=!0}if(t.local.vertices.colored){r||(r=await core._getRules(e,{...t,hold:!0}));const n=await interpretate(r.VertexColors,t);n instanceof NumericArrayObject?t.local.vertices.colors.set(new Float32Array(n.buffer)):t.local.vertices.colors.set(new Float32Array(n.flat())),t.local.vertices.colors.needsUpdate=!0}for(let e=0;e{},l.GraphicsComplex.virtual=!0,u.Cylinder=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);1===o.length&&(o=o[0]);const r=t.vertices.position.array;let a=3*(o[0]-1);o[0]=new i.Vector3(r[a],r[a+1],r[a+2]),a=3*(o[1]-1),o[1]=new i.Vector3(r[a],r[a+1],r[a+2]);const s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});console.log(o);var l=(new i.Vector3).subVectors(o[1],o[0]);console.log(l);var c=new i.CylinderGeometry(n,n,1,32,4,!1);c.applyMatrix4((new i.Matrix4).makeTranslation(0,.5,0)),c.applyMatrix4((new i.Matrix4).makeRotationX(i.MathUtils.degToRad(90)));var u=new i.Mesh(c,s);u.receiveShadow=t.shadows,u.castShadow=t.shadows,u.position.copy(o[0]),u.geometry.clone(),u.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,l.length())),u.geometry.lookAt(l),t.mesh.add(u)},u.Sphere=async(e,t)=>{var n=1;e.length>1&&(n=await interpretate(e[1],t));const o=new t.material({color:t.color,roughness:t.roughness,opacity:t.opacity,transparent:t.opacity<1,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});function r(e){const r=new i.Vector3(...e),a=new i.SphereGeometry(n,40,40),s=new i.Mesh(a,o);return s.position.set(r.x,r.y,r.z),s.castShadow=t.shadows,s.receiveShadow=t.shadows,t.mesh.add(s),a.dispose(),s}let a=await interpretate(e[0],t);a instanceof NumericArrayObject&&(a=a.normal());const s=t.vertices.position.array;if(Array.isArray(a)){t.local.object=[];for(let e=0;e{var n;let o;n=new i.BufferGeometry,t.local.geometry=n,n.setAttribute("position",t.vertices.position),t.vertices.onResize.push(e=>u.Polygon.reassign(e,t.local));let r,a=await interpretate(e[0],t);if(a instanceof NumericArrayObject)switch(a.dims.length){case 1:console.warn("Odd case of polygons data..."),n.setIndex(a.normal().map(e=>e-1));break;case 2:switch(a.dims[a.dims.length-1]){case 3:r=new i.BufferAttribute(new Uint16Array(a.buffer.map(e=>e-1)),1);break;case 4:{const e=a.buffer.length,t=a.buffer,n=new Uint16Array(2*e);let o=0,s=0;for(;o1){let o=await interpretate(e[1],t);if("number"!=typeof o)return console.warn(e),void console.error("Unknow case for Polygon");n.setDrawRange(a-1,o),t.local.indexOffset=a-1,t.local.range=o,t.local.nonindexed=!0}else if(3===a[0].length&&3===a[a.length-1].length)r=t.vertices.position.array.length>65535?new i.BufferAttribute(new Uint32Array(a.flat().map(e=>e-1)),1):new i.BufferAttribute(new Uint16Array(a.flat().map(e=>e-1)),1);else{let e=[];if(Array.isArray(a[0]))for(let n=0;no[e]))}}else switch(a.length){case 3:e.push(...a);break;case 4:e.push(a[0],a[1],a[2]),e.push(a[0],a[2],a[3]);break;case 5:e.push(a[0],a[1],a[4]),e.push(a[1],a[2],a[3]),e.push(a[1],a[3],a[4]);break;case 6:e.push(a[0],a[1],a[5]),e.push(a[1],a[2],a[5]),e.push(a[5],a[2],a[4]),e.push(a[2],a[3],a[4]);break;default:const n=t.vertices.position.array;h||(h=(await Promise.resolve().then(function(){return pe})).default),console.warn("earcut");const o=[];for(let e=0;ea[e]))}console.log("Set Index"),e=e.flat(),t.local.range=e.length,r=t.vertices.position.array.length>65535?new i.Uint32BufferAttribute(new Uint32Array(e.map(e=>e-1)),1):new i.Uint16BufferAttribute(new Uint16Array(e.map(e=>e-1)),1)}}r&&(n.setIndex(r),r.needsUpdate=!0),t.local.indexes=r,t?.vertices?.normals?(t.local.geometry.setAttribute("normal",t.vertices.normals),t.local.normals=!0):(t.vertices.handlers.push(()=>{t.local.geometry.computeVertexNormals()}),t.local.geometry.computeVertexNormals()),t?.vertices?.colored?(n.setAttribute("color",t.vertices.colors),o=new t.material({vertexColors:!0,transparent:t.opacity<1,opacity:t.opacity,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte,side:i.DoubleSide})):o=new t.material({color:t.color,transparent:t.opacity<1,opacity:t.opacity,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte,side:i.DoubleSide}),o.side=i.DoubleSide;const s=new i.Mesh(n,o);return s.receiveShadow=t.shadows,s.castShadow=!0,t.mesh.add(s),t.local.material=o,t.local.poly=s,s},u.Polygon.reassign=(e,t)=>{console.warn("Reassign geometry of Polygon");const n=t.geometry;n.setAttribute("position",e.position),e.colored&&n.setAttribute("color",e.colors),t.normals&&n.setAttribute("normal",e.normals),t.nonindexed&&n.setDrawRange(t.indexOffset,t.range)},u.Polygon.update=async(e,t)=>{if(t.fence&&await t.fence(),t.local.nonindexed){const n=await interpretate(e[0],t),o=await interpretate(e[1],t);return t.local.indexOffset=n-1,t.local.range=o,3*t.vertices.position.count<3*o||t.local.geometry.setDrawRange(n-1,o),o<1e5&&(t.local.geometry.computeBoundingBox(),t.local.geometry.computeBoundingSphere()),void t.wake(!0)}let n,o=await interpretate(e[0],t);if(o instanceof NumericArrayObject)switch(o.dims[o.dims.length-1]){case 3:n=new Uint16Array(o.buffer.map(e=>e-1));break;case 4:{const e=o.buffer.length,t=o.buffer;n=new Uint16Array(2*e);let r=0,a=0;for(;re-1));break;case 4:{o=o.flat(1/0);const e=o.length,t=o;n=new Uint16Array(2*e);let r=0,a=0;for(;r3e4?Uint32Array:Uint16Array,o=i.BufferAttribute,r=new e(2*n.length);r.set(n);const a=new o(r,1);a.setUsage(i.StreamDrawUsage),a.needsUpdate=!0,t.local.indexes=a,t.local.geometry.setIndex(a),t.local.geometry.setDrawRange(0,n.length)}else t.local.indexes.set(n),t.local.indexes.needsUpdate=!0,t.local.geometry.setDrawRange(0,n.length);t.local.geometry.computeBoundingBox(),t.local.geometry.computeBoundingSphere()},u.Polygon.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},u.Polygon.virtual=!0,l.Polygon=async(e,t)=>{const n=await interpretate(e[0],t);if(Array.isArray(n)&&Array.isArray(n[0][0])){t.local.vmulti=!0;for(const e of n)await interpretate(["Polygon",["JSObject",e]],{...t});return}let o=n.length;n instanceof NumericArrayObject&&(o=n.dims[0]);const r=Array.from({length:o},(e,t)=>t+1),a={};t.local.indices=r,t.local.vertices=n,await interpretate(["GraphicsComplex",["__takeJSProperty",t.local,"vertices"],["Polygon",["__takeJSProperty",t.local,"indices"]],["Rule","'VertexFence'",!0]],{...t,global:{...t.global,stack:a}}),t.local.virtualStack=a,t.local.vpoly=Object.values(t.local.virtualStack).find(e=>"Polygon"==e.firstName),t.local.vcomplex=Object.values(t.local.virtualStack).find(e=>"GraphicsComplex"==e.firstName),t.local.vpoly.parent=void 0},l.__takeJSProperty=(e,t)=>e[0][e[1]],l.__takeJSProperty.update=l.__takeJSProperty,l.__takeJSProperty.destroy=l.__takeJSProperty,l.Polygon.update=async(e,t)=>{if(t.local.vmulti)throw"update of multiple polygons is not possible";const n=await interpretate(e[0],t);let o=n.length;n instanceof NumericArrayObject&&(o=n.dims[0]);const r=Array.from({length:o},(e,t)=>t+1);t.local.indices=r,t.local.vertices=n,t.local.vpoly.update(),await t.local.vcomplex.update()},l.Polygon.virtual=!0,l.Polygon.destroy=(e,t)=>{if(!t.local.vmulti)for(const e of Object.values(t.local.virtualStack))e.dispose()},l.Dodecahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.DodecahedronGeometry(1),s=new t.material({color:t.color,transparent:!0,opacity:t.opacity,depthWrite:!0,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Polyhedron=async(e,t)=>{if(e[1][1].length>4)return await interpretate(["GraphicsComplex",e[0],["Polygon",e[1]]],t);{const o=await interpretate(e[1],t).flat(4).map(e=>e-1),r=await interpretate(e[0],t).flat(4),a=new i.PolyhedronGeometry(r,o);var n=new t.material({color:t.color,transparent:!0,opacity:t.opacity,depthWrite:!0,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});const s=new i.Mesh(a,n);return s.receiveShadow=t.shadows,s.castShadow=t.shadows,t.mesh.add(s),a.dispose(),n.dispose(),s}},l.Specularity=(e,t)=>{},l.Inset=async(e,t)=>{let n,o=[0,0,0];const r=await core._getRules(e,t),a=Object.keys(r).length;e.length-a>1&&(o=await interpretate(e[1],t)),o instanceof NumericArrayObject&&(o=o.normal()),e.length-a>2&&await interpretate(e[2],t);const s=document.createElement("div");let c=new C.CSS2DObject(s);c.className="g3d-label",t.mesh.add(c),t.local.object=c;const u={};t.local.stack=u;const d={global:{...t.global,stack:u},inset:!0,element:s,context:l};return r.ImageSizeRaw&&(n=r.ImageSizeRaw),n&&(s.style.width=n[0]+"px",s.style.height=n[1]+"px"),async function(){let r=!1;"HoldForm"==e[0][0]&&(Array.isArray(e[0][1])&&"Offload"==e[0][1][0]||(r=!0));try{r||await interpretate(e[0],d)}catch(e){console.warn(e),r=!0}r&&await w(e[0],d);const a=s;await p(60);if((a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height)<10)for(let e=0;e<20&&(await p(300),!((a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height)>30));++e);let l={width:a.offsetWidth||a.firstChild?.offsetWidth||a.firstChild?.width,height:a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height};if(l.width instanceof SVGAnimatedLength&&(l.width=l.width.animVal.valueInSpecifiedUnits),l.height instanceof SVGAnimatedLength&&(l.height=l.height.animVal.valueInSpecifiedUnits),(l.width<1||!l.width)&&l.height>1){const e=a.getElementsByClassName("cm-scroller");e.length>0?l.width=e[0].firstChild.offsetWidth:l.width=1.66*l.height}n||(s.style.width=l.width+"px",s.style.height=l.height+"px"),t.local.box=l,c.position.copy(new i.Vector3(...o))}(),c},l.Inset.update=async(e,t)=>{let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.object;return o&&o.position.copy(new i.Vector3(...n)),t.wake(),o},l.Inset.destroy=async(e,t)=>{Object.values(t.local.stack).forEach(e=>{e.dead||e.dispose()})},l.Inset.virtual=!0,l.Text=async(e,t)=>{const n=document.createElement("span");let o;n.className="g3d-label";try{o=await interpretate(e[0],t)}catch(n){console.warn("Error interpreting input of Text. Could it be an undefined symbol?");const o=document.createElement("span");let r=new C.CSS2DObject(o);return o.className="g3d-label",r.position.copy(new i.Vector3(...await interpretate(e[1],t))),t.mesh.add(r),await w(e[0],{...t,element:o}),r}t.fontweight&&(n.style.fontWeight=t.fontweight),t.fontSize&&(n.style.fontSize=t.fontSize+"px"),t.fontFamily&&(n.style.fontFamily=t.fontFamily),t.colorInherit||(n.style.color=t.color.getStyle());let r=await interpretate(e[1],t);r instanceof NumericArrayObject&&(r=r.normal()),n.innerHTML=m(String(o)),t.local.text=n;const a=new C.CSS2DObject(n);a.position.copy(new i.Vector3(...r)),t.local.labelObject=a,t.mesh.add(a)},l.Text.update=async(e,t)=>{let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=await interpretate(e[0],t);t.local.text.innerHTML=m(String(o)),t.local.labelObject.position.copy(new i.Vector3(...n)),t.wake()},l.Text.destroy=()=>{},l.Text.virtual=!0;const f=["color","emissive","emissiveIntensity","roughness","metalness","ior","transmission","thinFilm","materialThickness","attenuationColor","attenuationDistance","opacity","clearcoat","clearcoatRoughness","sheenColor","sheenRoughness","iridescence","iridescenceIOR","iridescenceThickness","specularColor","specularIntensity","matte","flatShading","castShadow","shadows","fontSize"];let g;l.Directive=async(e,t)=>{const n=await core._getRules(e,{...t,hold:!0});if("List"==e[0][0])for(let n=1;n{},u.Arrow=async(e,t)=>{if(e.length>1&&(t.radius=.7*await interpretate(e[1],t)),"Tube"==e[0][0]){const n=await interpretate(e[0][1],t);if(Array.isArray(n[0]))n.forEach(e=>{const n=t.radius||1,o=e.map(()=>n);o[o.length-1]=.4*n,interpretate(["Tube",["JSObject",e],["JSObject",o]],{...t,radius:o})});else{const e=t.radius||1,o=n.map(()=>e);o[o.length-1]=.4*e,interpretate(["Tube",["JSObject",n],["JSObject",o]],{...t,radius:o})}}},u.Line=async(e,t)=>{let n=new i.BufferGeometry;n.setAttribute("position",t.vertices.position),t.local.geometry=n,t.vertices.onResize.push(e=>u.Line.reassign(e,t.local));let o,r,a=await interpretate(e[0],t);a instanceof NumericArrayObject&&(a=a.buffer),o=t.vertices.position.array.length>65535?new i.Uint32BufferAttribute(new Uint32Array(a.map(e=>e-1)),1):new i.BufferAttribute(new Uint16Array(a.map(e=>e-1)),1),t.local.indexes=o,n.setIndex(o),t.local.range=a.length,t?.vertices?.colored?(n.setAttribute("color",t.vertices.colors),r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,vertexColors:!0,transparent:t.opacity<1})):r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1});const s=new i.Line(n,r);return t.local.line=s,t.mesh.add(s),t.local.material=r,s},u.Line.virtual=!0,u.Line.update=async(e,t)=>{t.fence&&await t.fence();let n=await interpretate(e[0],t);n instanceof NumericArrayObject&&(n=n.buffer),n=n.map(e=>e-1),t.local.range=n.length;const o=t.local.geometry,r=t.local.indexes;if(r.count3e4,r=e?Uint32Array:Uint16Array,a=new(e?i.Uint32BufferAttribute:i.Uint16BufferAttribute)(new r(2*n.length),1);a.setUsage(i.StreamDrawUsage),a.set(n),a.needsUpdate=!0,o.setIndex(a),t.local.indexes=a}else r.set(n),r.needsUpdate=!0;o.setDrawRange(0,t.local.range),t.wake(!0)},u.Line.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},u.Line.reassign=(e,t)=>{console.warn("Reassign geometry of Line");const n=t.geometry;n.setAttribute("position",e.position),e.colored&&n.setAttribute("color",e.colors),n.setIndex(t.indexes),n.setDrawRange(0,t.range)},l.Line=async(e,t)=>{var n;const o=await interpretate(e[0],t);if(o instanceof NumericArrayObject)(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(o.buffer),3));else{if(0==o.length)return;if(Array.isArray(o[0][0])){console.log("Multiple");const e=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1});for(const r of o){(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(r.flat()),3));const o=new i.Line(n,e);t.local.lines||(t.local.lines=[]),t.local.lines.push(o),t.mesh.add(o)}return void e.dispose()}(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(o.flat()),3))}const r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1}),a=new i.Line(n,r);return t.local.line=a,t.mesh.add(a),t.local.line.geometry.computeBoundingBox(),a},l.Line.update=async(e,t)=>{if(t.local.lines)throw"update of multiple lines is not supported!";let n=await interpretate(e[0],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.line.geometry.getAttribute("position");o.needsUpdate=!0;for(let e=0;e{t.local.line&&t.local.line.geometry.dispose(),t.local.lines&&t.local.lines.forEach(e=>e.geometry.dispose())},l.Line.virtual=!0,l.ImageSize=()=>"ImageSize",l.Background=()=>"Background",l.AspectRatio=()=>"AspectRatio",l.Lighting=()=>"Lighting",l.Default=()=>"Default",l.None=()=>!1,l.Lightmap=()=>"Lightmap",l.Automatic=()=>"Automatic",l.AnimationFrameListener=async(e,t)=>{await interpretate(e[0],t);const n=await core._getRules(e,{...t,hold:!0});t.local.event=await interpretate(n.Event,t);const o={state:!0,eval:()=>{t.local.worker.state&&(server.kernel.io.poke(t.local.event),t.local.worker.state=!1)}};t.local.worker=o,t.Handlers.push(o)},l.AnimationFrameListener.update=async(e,t)=>{t.local.worker.state=!0},l.AnimationFrameListener.destroy=async(e,t)=>{console.warn("AnimationFrameListener does not exist anymore"),t.local.worker.eval=()=>{}},l.AnimationFrameListener.virtual=!0;let y=!1,b=!1;l.Camera=(e,t)=>{console.warn("temporary disabled")},l.LightProbe=(e,t)=>{},l.DefaultLighting=(e,t)=>{console.warn("temporary disabled")},l.SkyAndWater=async(e,t)=>{console.warn("temporary disabled")},l.Sky=async(e,t)=>{console.warn("temporary disabled")};const w=async(e,t={global:{}})=>{const n=String(interpretate.hash(e));let o,r;if(n in ObjectHashMap)o=ObjectHashMap[n];else{o=new ObjectStorage(n);try{r=await o.get()}catch(t){console.warn("Creating FE object by id "+n),await server.kernel.io.fetch("CoffeeLiqueur`Extensions`Graphics3D`Private`MakeExpressionBox",[JSON.stringify(e),n]),r=await o.get()}}r||(r=await o.get()),console.log("g3d: creating an object"),console.log("frontend executable");const a=t,i=new ExecutableObject("g3d-embeded-"+uuidv4(),a,r,!0);return i.assignScope(a),o.assign(i),await i.execute(),i};l["CoffeeLiqueur`Extensions`Graphics3D`Tools`WaterShader"]=async(e,t)=>{y||(await interpretate.shared.THREEWater.load(),y=interpretate.shared.THREEWater.Water);let n,o=await core._getRules(e,t);console.log("options:"),console.log(o),o.dims=o.Size||[1e4,1e4];const r=new i.PlaneGeometry(...o.dims);n=new y(r,{textureWidth:512,textureHeight:512,waterNormals:(new i.TextureLoader).load("https://cdn.statically.io/gh/JerryI/Mathematica-ThreeJS-graphics-engine/master/assets/waternormals.jpg",function(e){e.wrapS=e.wrapT=i.RepeatWrapping}),sunDirection:new i.Vector3(1,1,1),sunColor:16777215,waterColor:7695,distortionScale:3.7,fog:!0}),n.rotation.x=-Math.PI/2,t.local.water=n,t.global.scene.add(n);const a=t.local.sun||new i.Vector3(1,1,1);n.material.uniforms.sunDirection.value.copy(a).normalize(),t.local.handlers.push(function(){t.local.water.material.uniforms.time.value+=1/60})},l.Large=(e,t)=>1,l.Medium=(e,t)=>.7,l.Small=(e,t)=>.4;const v=async(e,t)=>{let n;e.ImageSize?(n=await interpretate(e.ImageSize,t),"number"==typeof n?n<10&&(n=2*core.DefaultWidth*n):n instanceof Array||(n=core.DefaultWidth),n instanceof Array||(n=[n,.618034*n])):n=t.imageSize?Array.isArray(t.imageSize)?t.imageSize:[t.imageSize,.618034*t.imageSize]:[core.DefaultWidth,.618034*core.DefaultWidth];if(function(){if(null!=navigator.userAgentData?.mobile)return navigator.userAgentData.mobile;const e=window.matchMedia?.("(pointer: coarse)").matches,t=window.matchMedia?.("(max-width: 768px)").matches,n=navigator.maxTouchPoints>0;return!(!e||!n&&!t)||/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}()){console.warn("Mobile device detected!");const e=2/devicePixelRatio;n[0]=n[0]*e,n[0]>250&&(n[0]=250),n[1]=n[1]*e}return n};let x=!1;l.PointLight=async(e,t)=>{const n={...t};let o=[0,0,10],r=16777215;const a=await core._getRules(e,t),s=Object.keys(a).length;t.local.olength=s,e.length-s>0&&(r=await interpretate(e[0],n)),e.length-s>1&&(o=await interpretate(e[1],t),o instanceof NumericArrayObject&&(o=o.normal()));let l=100,c=0,u=2;"number"==typeof a.Intensity&&(l=a.Intensity),"number"==typeof a.Distance&&(c=a.Distance),"number"==typeof a.Decay&&(u=a.Decay);const d=new i.PointLight(r,l,c,u);return d.castShadow=t.shadows,d.position.set(...o),d.shadow.bias=-.01,"number"==typeof a.ShadowBias&&(d.shadow.bias=a.ShadowBias),t.local.light=d,t.mesh.add(d),d},l.PointLight.update=async(e,t)=>{if(t.wake(!1,!0),e.length-t.local.olength>1){let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal()),t.local.light.position.set(...n)}},l.PointLight.destroy=(e,t)=>{t.local.light.dispose()},l.PointLight.virtual=!0,l.DirectionalLight=async(e,t)=>{const n={...t};let o=[0,0,10],r=[0,0,0],a=16777215;const s=await core._getRules(e,t),l=Object.keys(s).length;t.local.olength=l,e.length-l>0&&(a=await interpretate(e[0],n)),e.length-l>1&&(o=await interpretate(e[1],t),o instanceof NumericArrayObject&&(o=o.normal()),2==o.length&&(r=o[1],o=o[0]));let c=2;"number"==typeof s.Intensity&&(c=s.Intensity);const u=new i.DirectionalLight(a,c);return u.castShadow=t.shadows,u.position.set(...o),u.target.position.set(...r),u.shadow.bias=-.01,"number"==typeof s.ShadowBias&&(u.shadow.bias=s.ShadowBias),u.shadow.mapSize.height=1024,u.shadow.mapSize.width=1024,"number"==typeof s.ShadowMapSize&&(u.shadow.mapSize.height=s.ShadowMapSize,u.shadow.mapSize.width=s.ShadowMapSize),t.local.light=u,t.mesh.add(u),t.mesh.add(u.target),u},l.DirectionalLight.update=async(e,t)=>{if(t.wake(!1,!0),e.length-t.local.olength>1){let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),2==n.length){let e=n[1];n=n[0],t.local.light.target.position.set(...e)}t.local.light.position.set(...n)}},l.DirectionalLight.destroy=(e,t)=>{t.local.light.dispose()},l.DirectionalLight.virtual=!0,l.SpotLight=async(e,t)=>{const n={...t},o=await core._getRules(e,t),r=Object.keys(o).length;t.local.olength=r;let a=16777215;e.length-r>0&&(a=await interpretate(e[0],n));let s=[10,100,10],l=[0,0,0];e.length-r>1&&(s=await interpretate(e[1],t),s instanceof NumericArrayObject&&(s=s.normal()),2==s.length&&(l=s[1],s=s[0]));let c=Math.PI/3;e.length-r>2&&(c=await interpretate(e[2],t));let u=100;"number"==typeof o.Intensity&&(u=o.Intensity);let d=0;"number"==typeof o.Distance&&(d=o.Distance);let h=0;"number"==typeof o.Penumbra&&(h=o.Penumbra);let p=2;"number"==typeof o.Decay&&(p=o.Decay);const m=new i.SpotLight(a,u,d,c,h,p);return m.position.set(...s),m.target.position.set(...l),m.castShadow=t.shadows,m.shadow.bias=-.01,"number"==typeof o.ShadowBias&&(m.shadow.bias=o.ShadowBias),m.shadow.mapSize.height=1024,m.shadow.mapSize.width=1024,"number"==typeof o.ShadowMapSize&&(m.shadow.mapSize.height=o.ShadowMapSize,m.shadow.mapSize.width=o.ShadowMapSize),t.local.spotLight=m,t.mesh.add(m),t.mesh.add(m.target),m},l.SpotLight.update=async(e,t)=>{t.wake(!1,!0);const n=t.local.olength;if(e.length-n>1){let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),2==n.length){let e=n[1];if(n=n[0],t.Lerp){if(!t.local.lerp1){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{t.local.spotLight.position.lerp(e.target,.05)}};t.local.lerp1=e,t.Handlers.push(e)}if(t.local.lerp1.target.fromArray(n),!t.local.lerp2){console.log("creating worker for lerp of movements..");const n={alpha:.05,target:new i.Vector3(...e),eval:()=>{t.local.spotLight.target.position.lerp(n.target,.05)}};t.local.lerp2=n,t.Handlers.push(n)}t.local.lerp2.target.fromArray(e)}else t.local.spotLight.position.set(...n),t.local.spotLight.target.position.set(...e)}else if(t.Lerp){if(!t.local.lerp1){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{t.local.spotLight.position.lerp(e.target,.05)}};t.local.lerp1=e,t.Handlers.push(e)}t.local.lerp1.target.fromArray(n)}else t.local.spotLight.position.set(...n)}},l.SpotLight.destroy=async(e,t)=>{console.log("SpotLight destoyed")},l.SpotLight.virtual=!0,l.Shadows=async(e,t)=>{t.shadows=await interpretate(e[0],t)},l.HemisphereLight=async(e,t)=>{const n={...t},o=await core._getRules(e,t);e.length>0?await interpretate(e[0],n):n.color=16777147;const r=n.color;e.length>1?await interpretate(e[1],n):n.color=526368;const a=n.color;let s=1;e.length>2&&(s=await interpretate(e[2],t)),"number"==typeof o.Intensity&&(s=o.Intensity);const l=new i.HemisphereLight(r,a,s);t.global.scene.add(l)},l.MeshMaterial=async(e,t)=>{const n=await interpretate(e[0],t);t.material=n},l["CoffeeLiqueur`Extensions`Graphics3D`MeshMaterial"]=l.MeshMaterial,l.MeshPhysicalMaterial=()=>i.MeshPhysicalMaterial,l.MeshLambertMaterial=()=>i.MeshLambertMaterial,l.MeshPhongMaterial=()=>i.MeshPhongMaterial,l.MeshToonMaterial=()=>i.MeshToonMaterial,l.MeshFogMaterial=async(e,t)=>{let n=.01;return e.length>0&&(n=await interpretate(e[0],t)),function(){const e=new x.FogVolumeMaterial;return e.density=n,e}};let _,A,k,C,S=!1;l.EventListener=async(e,t)=>{const n=await interpretate(e[1],t),o={...t};let r=await interpretate(e[0],t);return Array.isArray(r)&&(r=r[0]),S||(await interpretate.shared.THREETransformControls.load(),S=interpretate.shared.THREETransformControls.TransformControls),n.forEach(e=>{l.EventListener[e.lhs](e.rhs,r,o)}),null},l.EventListener.transform=(e,t,n)=>{console.log(n),console.warn("Controls transform is enabled");const o=new S(n.camera,n.global.domElement),r=o.getHelper(),a=n.controlObject.o;o.attach(t),n.global.scene.add(r);const i=throttle((t,n,o)=>{server.kernel.emitt(e,`<|"position"->{${t.toFixed(4)}, ${n.toFixed(4)}, ${o.toFixed(4)}}|>`,"transform")});o.addEventListener("change",function(e){i(t.position.x,t.position.y,t.position.z)}),o.addEventListener("dragging-changed",function(e){console.log("changed"),a.enabled=!e.value})},l.EventListener.drag=(e,t,n)=>{console.log(n),console.warn("Controls transform is enabled");const o=new S(n.camera,n.global.domElement),r=o.getHelper(),a=n.controlObject.o;o.attach(t),n.global.scene.add(r);const i=throttle((t,n,o)=>{server.kernel.io.fire(e,[t,n,o],"drag")});o.addEventListener("change",function(e){i(t.position.x,t.position.y,t.position.z)}),o.addEventListener("dragging-changed",function(e){console.log("changed"),a.enabled=!e.value})};const E=e=>{const t=new FileReader;return t.readAsDataURL(e),new Promise(e=>{t.onloadend=()=>{e(t.result)}})};async function M(e,t){let n=e,o=!1,r=[0,0,0];if("None"==n){const e=document.createElement("span");let t=new C.CSS2DObject(e);return e.className="g3d-label",{offset:r,element:t}}if(Array.isArray(n))if("HoldForm"==n[0]){if(Array.isArray(n[1])&&"List"==n[1][0]){const e=await interpretate(n[1][2],t);n=["HoldForm",n[1][1]],Array.isArray(e)&&(r=e)}"string"==typeof n[1]&&"'"==n[1].charAt(0)?(o=!1,n=n[1]):o=!0}else if("List"==n[0]){const e=await interpretate(n[2],t);n=n[1],"HoldForm"==n[0]&&("string"==typeof n[1]&&"'"==n[1].charAt(0)?(o=!1,n=n[1]):o=!0),Array.isArray(e)&&(r=e)}const a=document.createElement("span");let i=new C.CSS2DObject(a);if(a.className="g3d-label",!o)try{const e=await interpretate(n,{...t});a.innerHTML=m(String(e))}catch(e){console.warn("Err:",e),o=!0}return o&&(console.warn("x-label: fallback to EditorView"),await w(n,{...t,element:a})),{offset:r,element:i}}l["Graphics3D`Serialize"]=async(e,t)=>{const n=await core._getRules(e,t);let o=t.element;n.TemporalDOM&&(o=document.createElement("div"),o.style.pointerEvents="none",o.style.opacity=0,o.style.position="absolute",document.body.appendChild(o)),await interpretate(e[0],{...t,element:o});const r=new Deferred;console.log(t.global),t.global.renderer.domElement.toBlob(function(e){r.resolve(e)},"image/png",1);const a=await r.promise;Object.values(t.global.stack).forEach(e=>{e.dispose()}),n.TemporalDOM&&o.remove();return await E(a)},l["Graphics3D`toDataURL"]=async(e,t)=>{const n=new Deferred;console.log(t.global),t.local.animateOnce(),t.local.renderer.domElement.toBlob(function(e){n.resolve(e)},"image/png",1);const o=await n.promise;return await E(o)},l["CoffeeLiqueur`Extensions`Graphics3D`Tools`toDataURL"]=l["Graphics3D`toDataURL"],l["CoffeeLiqueur`Extensions`Graphics3D`Tools`Serialize"]=l["Graphics3D`Serialize"],l.Top=()=>[0,0,1e3],l.Bottom=()=>[0,0,-1e3],l.Right=()=>[1e3,0,0],l.Left=()=>[-1e3,0,0],l.Front=()=>[0,1e3,0],l.Back=()=>[0,-1e3,0],l.Bold=()=>"Bold",l.Bold.update=l.Bold,l.Italic=()=>"Italic",l.Italic.update=l.Italic,l.FontSize=()=>"FontSize",l.FontSize.update=l.FontSize,l.FontFamily=()=>"FontFamily",l.FontFamily.update=l.FontFamily,core.Graphics3D=async(e,t)=>{await interpretate.shared.THREE.load(),i||(i=interpretate.shared.THREE.THREE,A=interpretate.shared.THREE.OrbitControls,_=interpretate.shared.THREE.RGBELoader,C=interpretate.shared.THREE.CSS2D,k=await Promise.resolve().then(function(){return j}),k=k.VariableTube),s=i.MathUtils;let n=!1,o=performance.now(),r=await core._getRules(e,{...t,context:l,hold:!0});0===Object.keys(r).length&&e.length>1&&(r=await core._getRules(e[1],{...t,context:l,hold:!0})),console.warn(r);let a,u=!0,d=[-40,20,30];if(r.ViewPoint){const ue=await interpretate(r.ViewPoint,{...t,context:l});Array.isArray(ue)&&"number"==typeof ue[0]&&"number"==typeof ue[1]&&"number"==typeof ue[2]&&(d=[ue[0],ue[2],ue[1]])}r.Axes&&(console.warn(r.PlotRange),a=await interpretate(r.PlotRange,t),u=!1);const h=(new i.Matrix4).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);let p=!1;if("RTX"in r)p=!0,x||(await interpretate.shared.THREERTX.load(),x=interpretate.shared.THREERTX.RTX);else if(r.Renderer){"PathTracing"==await interpretate(r.Renderer,t)&&(p=!0,x||(await interpretate.shared.THREERTX.load(),x=interpretate.shared.THREERTX.RTX))}!g&&p&&(g=(await Promise.resolve().then(function(){return Et})).GUI),t.local.handlers=[],t.local.prolog=[];const f=[],y=t.element,b=await v(r,t),S={topColor:16777215,bottomColor:6710886,multipleImportanceSampling:!1,stableNoise:!1,denoiseEnabled:!0,denoiseSigma:2.5,denoiseThreshold:.1,denoiseKSigma:1,environmentIntensity:1,environmentRotation:0,environmentBlur:0,backgroundBlur:0,bounces:5,sleepAfter:1e3,runInfinitely:!1,fadeDuration:300,stopAfterNFrames:60,samplesPerFrame:1,acesToneMapping:!0,resolutionScale:1,transparentTraversals:20,filterGlossyFactor:.5,tiles:1,renderDelay:100,minSamples:5,backgroundAlpha:0,checkerboardTransparency:!0,cameraProjection:"Orthographic",enablePathTracing:!0};if(r.MultipleImportanceSampling&&(S.multipleImportanceSampling=await interpretate(r.MultipleImportanceSampling,t)),"EnablePathTracing"in r&&(S.enablePathTracing=await interpretate(r.EnablePathTracing,t)),"AcesToneMapping"in r&&(S.acesToneMapping=await interpretate(r.AcesToneMapping,t)),r.Bounces&&(S.bounces=await interpretate(r.Bounces,t)),"FadeDuration"in r&&(S.fadeDuration=await interpretate(r.FadeDuration,t)),"RenderDelay"in r&&(S.renderDelay=await interpretate(r.RenderDelay,t)),"MinSamples"in r&&(S.minSamples=await interpretate(r.MinSamples,t)),"EnvironmentIntensity"in r&&(S.environmentIntensity=await interpretate(r.EnvironmentIntensity,t)),"SamplesPerFrame"in r&&(S.samplesPerFrame=await interpretate(r.SamplesPerFrame,t)),r.ViewProjection&&(S.cameraProjection=await interpretate(r.ViewProjection,t)),r.Background){const de=await interpretate(r.Background,{...t,context:l});r.Background=de,1==de?.isColor&&(S.backgroundAlpha=1)}let E,R,O,T,L,I,P,B,z,F,D;if(p||(S.resolutionScale=1),p&&(S.sleepAfter=1e4),r.SleepAfter&&(S.sleepAfter=await interpretate(r.SleepAfter,t)),p){E=new g({autoPlace:!1,name:"...",closed:!0}),R=document.createElement("div"),R.classList.add("graphics3d-controller"),R.appendChild(E.domElement),t.local.animateOnce=le;const he={Save:function(){le(),O.domElement.toBlob(function(e){var t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download="screenshot.png",t.click()},"image/png",1)}};E.add(he,"Save")}const N={near:0,far:2e3};let V=5;r.OrthographicCameraWidth&&(V=await interpretate(r.OrthographicCameraWidth,t)),r.CameraNearPlane&&(N.near=await interpretate(r.CameraNearPlane,t)),r.CameraFarPlane&&(N.far=await interpretate(r.CameraFarPlane,t)),O=new i.WebGLRenderer({antialias:!0}),O.toneMapping=i.ACESFilmicToneMapping,O.outputEncoding=i.sRGBEncoding,O.setClearColor(0,0),y.appendChild(O.domElement),t.local.rendererContainer=O.domElement,T=O.domElement,t.local.domElement=T,t.local.renderer=O;const G={x:0,y:0};y.classList.contains("slide-frontend-object")&&(G.x=-1);const U=new C.CSS2DRenderer({globalOffset:G});U.setSize(b[0],b[1]),U.domElement.style.position="absolute",U.domElement.style.top="0px",U.domElement.style.bottom="0px",U.domElement.style.marginTop="auto",U.domElement.style.marginBottom="auto",y.appendChild(U.domElement),t.local.labelContainer=U.domElement,T=U.domElement,b[0]>250&&b[1]>150&&p&&(t.local.guiContainer=R,y.appendChild(R));const H=b[0]/b[1];let W;p?(B=new x.PhysicalCamera(75,H,.025,500),B.position.set(-4,2,3)):(B=new i.PerspectiveCamera(75,H,.025,500),r.PerspectiveCameraZoom&&(B.zoom=await interpretate(r.PerspectiveCameraZoom,t)),O.shadowMap.enabled=!0),W=p?(e,r)=>{o=performance.now(),t.local.updateSceneNext=1==e,t.local.updateLightingNext=1==r,n&&t.local.wakeThreadUp()}:()=>{o=performance.now(),n&&t.local.wakeThreadUp()};const X=V/H;z=new i.OrthographicCamera(V/-2,V/2,X/2,X/-2,N.near,N.far),z.position.set(...d),P=z,D=new i.Scene,p&&(I=new x.WebGLPathTracer(O),I.minSamples=S.minSamples,I.renderDelay=S.renderDelay,I.fadeDuration=S.fadeDuration,I.multipleImportanceSampling=S.multipleImportanceSampling);let q={init:(e,t)=>{q.o=new A(e,T),q.o.addEventListener("change",W),q.o.target.set(0,1,0),q.o.update()},dispose:()=>{}};if(r.Controls&&"PointerLockControls"===await interpretate(r.Controls,t)){await interpretate.shared.THREEPointerLockControls.load();const pe=interpretate.shared.THREEPointerLockControls.PointerLockControls;q={init:(e,n)=>{q.o=new pe(e,n),D.add(q.o.getObject()),q.o.addEventListener("change",W),q.onKeyDown=function(e){if(e.preventDefault(),e.stopImmediatePropagation(),e.repeat)return!1;switch(W(),e.code){case"ArrowUp":case"KeyW":q.moveForward=!0;break;case"ArrowLeft":case"KeyA":q.moveLeft=!0;break;case"ArrowDown":case"KeyS":q.moveBackward=!0;break;case"ArrowRight":case"KeyD":q.moveRight=!0;break;case"Space":!0===q.canJump&&(q.velocity.y+=20),q.canJump=!1}return!1},q.onKeyUp=function(e){switch(e.preventDefault(),e.stopImmediatePropagation(),W(),e.code){case"ArrowUp":case"KeyW":q.moveForward=!1;break;case"ArrowLeft":case"KeyA":q.moveLeft=!1;break;case"ArrowDown":case"KeyS":q.moveBackward=!1;break;case"ArrowRight":case"KeyD":q.moveRight=!1}return!1},t.local.handlers.push(function(){if(!q.o||!q.o.isLocked)return;const e=performance.now(),t=(e-(q.prevTime||e))/1e3;q.prevTime=e,q.velocity.x*=.9,q.velocity.z*=.9,q.velocity.y-=39.2*t,q.direction.z=Number(q.moveForward)-Number(q.moveBackward),q.direction.x=Number(q.moveRight)-Number(q.moveLeft),q.direction.normalize(),(q.moveForward||q.moveBackward)&&(q.velocity.z-=100*q.direction.z*t),(q.moveLeft||q.moveRight)&&(q.velocity.x-=100*q.direction.x*t),q.o.moveRight(-q.velocity.x*t),q.o.moveForward(-q.velocity.z*t),q.o.getObject().position.y+=q.velocity.y*t;const n=q.o.getObject().position,o=new i.Raycaster;o.set(n,new i.Vector3(0,-1,0));const r=o.intersectObjects(D.children,!0);let a=.3;for(let e=0;e{document.removeEventListener("keydown",q.onKeyDown),document.removeEventListener("keyup",q.onKeyUp)}}}t.local.controlObject=q,q.init(P,T),L=q.o,t.local.controlObject=q,t.local.renderer=O,t.local.domElement=T,p&&L.addEventListener("change",()=>{I.updateCamera()});const Z=new i.Group,K=!1;if(r.TransitionType){"Linear"===await interpretate(r.TransitionType,t)&&(K=!0)}const Y={...t,context:l,numerical:!0,tostring:!1,matrix:h,material:i.MeshPhysicalMaterial,color:new i.Color(1,1,1),opacity:1,thickness:1,roughness:.5,edgecolor:new i.Color(0,0,0),mesh:Z,metalness:0,emissive:void 0,arrowHeight:30,arrowRadius:30,reflectivity:.5,clearcoat:0,shadows:!1,Lerp:K,camera:P,controlObject:q,fontSize:void 0,fontFamily:void 0,Handlers:f,wake:W,pointSize:.08,colorInherit:!0,emissiveIntensity:void 0,roughness:void 0,metalness:void 0,ior:void 0,transmission:void 0,thinFilm:void 0,materialThickness:void 0,attenuationColor:void 0,attenuationDistance:void 0,opacity:void 0,clearcoat:void 0,clearcoatRoughness:void 0,sheenColor:void 0,sheenRoughness:void 0,iridescence:void 0,iridescenceIOR:void 0,iridescenceThickness:void 0,specularColor:void 0,specularIntensity:void 0,matte:void 0};t.local.wakeThreadUp=()=>{n&&(n=!1,console.warn("g3d >> waking up!"),t.local.aid=requestAnimationFrame(re))},t.global.renderer=O,t.global.labelRenderer=U,t.global.domElement=T,t.global.scene=D,Y.camera=P,t.local.element=y,p&&(Y.PathRendering=!0),r.Prolog&&await interpretate(r.Prolog,Y),r.Axes&&a&&console.log("Drawing grid...");let J,$=!1;"Lighting"in r&&(r.Lighting?"List"==r.Lighting[0]?$=!1:"'Neutral'"==r.Lighting?Y.material=i.MeshBasicMaterial:$=!0:$=!0),await interpretate(e[0],Y),r.Epilog&&interpretate(r.Epilog,Y);const Q=e=>Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1];if(Array.isArray(a)&&Q(a[0])){const me=a[0],fe=Q(a[1])?a[1]:me,ge=Q(a[2])?a[2]:me,ye=.5*(me[1]+me[0]),be=.5*(fe[1]+fe[0]),we=.5*(ge[1]+ge[0]),ve=1.1;J={min:{x:(me[0]-ye)*ve+ye,y:(fe[0]-be)*ve+be,z:(ge[0]-we)*ve+we},max:{x:(me[1]-ye)*ve+ye,y:(fe[1]-be)*ve+be,z:(ge[1]-we)*ve+we}}}if(J||(J=(new i.Box3).setFromObject(Z)),r.Axes){const xe={x:[],y:[],z:[]};{function _e(e,t,n=8){const o=t-e;if(0===o)return{step:0,niceMin:e,niceMax:t,count:0};const r=o/n,a=Math.pow(10,Math.floor(Math.log10(r))),i=r/a;let s;s=i<1.5?1:i<3?2:i<7?5:10;const l=s*a,c=Math.floor(e/l)*l,u=Math.ceil(t/l)*l;return{step:l,niceMin:c,niceMax:u,count:Math.round((u-c)/l)}}const Ae=_e(J.min.x,J.max.x,8),ke=_e(J.min.y,J.max.y,8),Ce=_e(J.min.z,J.max.z,8),Se=[Ae.count,ke.count,Ce.count];function Ee({niceMin:e,step:t,count:n}){const o=Math.max(0,-Math.floor(Math.log10(t))),r=[];for(let a=0;a<=n;a++){let n=Number((e+t*a).toFixed(o));Math.abs(n){const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(0,0,e),n.offset=[-.7*De.x,.7*De.y,0],Z.add(n),xe.z.push(n)}),Me.slice(1,-1).forEach(e=>{const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(e,0,0),n.offset=[0,De.y,0],Z.add(n),xe.x.push(n)}),Re.slice(1,-1).forEach(e=>{const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(0,e,0),n.offset=[De.x,0,0],Z.add(n),xe.y.push(n)}),r.PlotLabel){let Xe=!1;if(Array.isArray(r.PlotLabel)&&"HoldForm"==r.PlotLabel[0][0]&&(Xe=!0),!Xe)try{const qe=await interpretate(r.PlotLabel,{...t,context:l});if(qe){const Ze=document.createElement("div");Ze.innerHTML=m(String(qe)),Ze.style="\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n text-align: center;\n font-size: small;\n ",Ze.className="g3d-label",y.appendChild(Ze)}}catch(Ke){Xe=!0}if(Xe){console.warn("Non textural PlotLabel!"),console.warn("Convert to text");const Ye=document.createElement("div");Ye.style="\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n text-align: center;\n font-size: small;\n ",Ye.className="g3d-label",y.appendChild(Ye),await w(r.PlotLabel,{...t,element:Ye})}}if(r.AxesLabel&&(r.AxesLabel=await interpretate(r.AxesLabel,{...t,context:l,hold:!0}),3==r?.AxesLabel?.length)){if(r.AxesLabel[0]){let Je=r.AxesLabel[0],{offset:$e,element:Qe}=await M(Je,t);Qe.position.copy(new i.Vector3((J.min.x+J.max.x)/2+$e[0],J.min.y+1,J.min.z+$e[2])),Z.add(Qe),Qe.offset=[0,3*(J.max.y-J.min.y)/Se[1]+$e[1],0],Qe.onlyVisible=!0,xe.x.push(Qe)}if(r.AxesLabel[1]){let et=r.AxesLabel[1],{offset:tt,element:nt}=await M(et,t);nt.position.copy(new i.Vector3(J.min.x+1,(J.min.y+J.max.y)/2+tt[1],J.min.z+tt[2])),Z.add(nt),nt.offset=[3*(J.max.x-J.min.x)/Se[0]+tt[0],0,0],nt.onlyVisible=!0,xe.y.push(nt)}if(r.AxesLabel[2]){let ot=r.AxesLabel[2],{offset:rt,element:at}=await M(ot,t);at.position.copy(new i.Vector3(J.min.x-1,J.min.y+1,(J.min.z+J.max.z)/2)+rt[2]),Z.add(at),at.offset=[-3*(J.max.x-J.min.x)/Se[0]/1.4+rt[0],3*(J.max.x-J.min.x)/Se[0]/1.4+rt[1],0],at.onlyVisible=!0,xe.z.push(at)}}let Ne=0,je=0;function Ve(e,t,n=0){const o=e instanceof DOMRect?e:e.getBoundingClientRect(),r=t instanceof DOMRect?t:t.getBoundingClientRect();return!(o.rightr.right-n)&&(!(o.bottomr.bottom-n)))}function Ge(e,t){return Ve(e.getBoundingClientRect(),t.getBoundingClientRect(),2)}function Ue(e,t=!1){if(e.length<2)return;const n=e[0].element.getBoundingClientRect(),o=e[e.length-1].element.getBoundingClientRect();Math.abs(n.left-o.left),Math.abs(n.top-o.top);let r,a=1;do{r=!1;for(let t=1;t*a{n%a===0?t||e.element.classList.remove("opacity-0"):e.onlyVisible||e.element.classList.add("opacity-0")})}let He=performance.now()-500;const We=e=>{if(u)return;if(performance.now()-He<100)return;He=performance.now();const t=L.getAzimuthalAngle(),n=L.getPolarAngle();z.layers.disable(10),z.layers.disable(11),z.layers.disable(12),z.layers.disable(13),z.layers.disable(14),z.layers.disable(15),t<1.57&&t>0&&1!=Ne&&(z.layers.enable(13),z.layers.enable(11),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x+e.offset[0],1*Fe.min.y-e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x-e.offset[0],1*Fe.min.y-e.offset[1],1*Fe.min.z+e.offset[2]))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x+e.offset[0],e.position.y,1*Fe.min.z)))),t<3.14&&t>1.57&&2!=Ne&&(z.layers.enable(11),z.layers.enable(12),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x-e.offset[0],1*Fe.min.y-e.offset[1],e.position.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x+e.offset[0],e.position.y,1*Fe.min.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x+e.offset[0],1*Fe.max.y+e.offset[1],1*Fe.min.z+e.offset[2])))),t<0&&t>-1.57&&3!=Ne&&(z.layers.enable(13),z.layers.enable(10),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x+e.offset[0],1*Fe.max.y+e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x+e.offset[0],1*Fe.min.y-e.offset[1],1*Fe.min.z+e.offset[2]))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x-e.offset[0],e.position.y,1*Fe.min.z)))),t<-1.57&&t>-3.14&&4!=Ne&&(z.layers.enable(10),z.layers.enable(12),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x-e.offset[0],1*Fe.max.y+e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,1*Fe.max.y+e.offset[1],1*Fe.min.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x-e.offset[0],e.position.y,1*Fe.min.z)))),n>1.57&&1!=je&&(z.layers.enable(14),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.max.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.max.z)))),n<1.57&&2!=je&&(z.layers.enable(15),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.min.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.min.z)))),Ue(xe.x),Ue(xe.y),Ue(xe.z)};u||setTimeout(We,100),L.addEventListener("end",We),E?.add({Grid:!u},"Grid").name("Grid").listen().onChange(e=>{e?(u=!1,We()):(z.layers.disable(10),z.layers.disable(11),z.layers.disable(12),z.layers.disable(13),z.layers.disable(14),z.layers.disable(15),u=!0)})}}if(Z.position.set(-(J.min.x+J.max.x)/2,-(J.min.y+J.max.y)/2,-(J.min.z+J.max.z)/2),r.Boxed){const it=[[[J.min.x,J.min.y,J.min.z],[J.max.x,J.min.y,J.min.z],[J.max.x,J.max.y,J.min.z],[J.min.x,J.max.y,J.min.z],[J.min.x,J.min.y,J.min.z]],[[J.min.x,J.min.y,J.max.z],[J.max.x,J.min.y,J.max.z],[J.max.x,J.max.y,J.max.z],[J.min.x,J.max.y,J.max.z],[J.min.x,J.min.y,J.max.z]],[[J.min.x,J.min.y,J.min.z],[J.min.x,J.min.y,J.max.z]],[[J.max.x,J.min.y,J.min.z],[J.max.x,J.min.y,J.max.z]],[[J.max.x,J.max.y,J.min.z],[J.max.x,J.max.y,J.max.z]],[[J.min.x,J.max.y,J.min.z],[J.min.x,J.max.y,J.max.z]]];for(const st of it)await interpretate(["Line",["JSObject",st]],{...Y})}if(r.Axes){const lt=Math.abs(Math.min(J.max.x-J.min.x,J.max.y-J.min.y,J.max.z-J.min.z)),ct=new i.AxesHelper(lt/2);ct.position.set((J.max.x+J.min.x)/2,(J.max.y+J.min.y)/2,(J.max.z+J.min.z)/2),Z.add(ct)}Z.applyMatrix4((new i.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1));let ee=[J.max.x-J.min.x,J.max.z-J.min.z,J.max.y-J.min.y],te=Math.max(...ee);const ne=Math.max(...ee);if("BoxRatios"in r){const ut=ee.map(e=>1/(e/te));console.warn("Rescaling....");let dt=await interpretate(r.BoxRatios,t);dt=[dt[0],dt[2],dt[1]],te=Math.max(...dt),dt=dt.map((e,t)=>ut[t]*e/te),console.log(te),ne>80&&(console.warn("Model is too large!"),dt=dt.map(e=>e/ne*10)),Z.applyMatrix4((new i.Matrix4).makeScale(...dt))}else{let ht=[1,1,1];ne>80&&(console.warn("Model is too large!"),ht=ht.map(e=>e/ne*10)),Z.applyMatrix4((new i.Matrix4).makeScale(...ht))}if(Z.position.add(new i.Vector3(0,1,0)),D.add(Z),J=(new i.Box3).setFromObject(Z),Y.camera.isOrthographicCamera){console.warn("fitting camera...");const pt=Y.camera;console.log(J);const mt=[J.max.x+J.min.x,J.max.y+J.min.y,J.max.z+J.min.z].map(e=>-e/2),ft=Math.max(J.max.x-J.min.x,J.max.y-J.min.y,J.max.z-J.min.z);console.log(ft),console.log(mt),pt.zoom=.55*Math.min(V/(J.max.x-J.min.x),X/(J.max.y-J.min.y)),r.OrthographicCameraZoom&&(pt.zoom=await interpretate(r.OrthographicCameraZoom,t)),pt.updateProjectionMatrix()}if(D.updateMatrixWorld(),$)if(r.Background&&p){if(r.Background.isColor){S.environmentIntensity=0;const gt=new x.GradientEquirectTexture;gt.topColor.set(16777215),gt.bottomColor.set(6710886),gt.update(),D.defaultEnvTexture=gt,D.environment=gt,D.background=gt}}else r.Background&&r.Background.isColor&&(D.background=r.Background);else((e,t,n)=>{if(n){const n=new t.GradientEquirectTexture;return n.topColor.set(16777215),n.bottomColor.set(6710886),n.update(),e.defaultEnvTexture=n,e.environment=n,void(e.background=n)}const o=new i.DirectionalLight(13210258,1.5);o.position.set(0,1,2),e.add(o);const r=new i.DirectionalLight(9619858,1.5);r.position.set(-1.732,1,-1),e.add(r);const a=new i.DirectionalLight(9605833,1.5);a.position.set(1.732,1,-1),e.add(a);var s=new i.HemisphereLight(15005439,526368,2);e.add(s)})(D,x,p);let oe,re;if(r.Background&&!p&&r.Background.isColor&&(D.background=r.Background),p&&(I.updateLights(),new x.BlurredEnvMapGenerator(O)),"Lightmap"in r){const yt=await interpretate(r.Lightmap,t);S.backgroundAlpha=1,oe=(new _).setDataType(i.FloatType).loadAsync(yt).then(e=>{if(p&&(F=e,function(){const e=new x.BlurredEnvMapGenerator(O),t=e.generate(F,.35);D.background=t,D.environment=t,D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha,S.backgroundAlpha<1&&(D.background=null);e.dispose(),I.updateEnvironment()}()),p)return;const t=ae.fromEquirectangular(e).texture;D.environment=t,D.background=t,e.dispose(),ae.dispose()})}if("BackgroundAlpha"in r&&(S.backgroundAlpha=await interpretate(r.BackgroundAlpha,t),S.backgroundAlpha<1&&(D.background=null)),!p){var ae=new i.PMREMGenerator(O);ae.compileEquirectangularShader()}function ie(e){"Perspective"===e?(P&&(B.position.copy(P.position),B.zoom=P.zoom),P=B):"Orthographic"===e&&(P&&(z.position.copy(P.position),z.zoom=P.zoom),P=z),L.object=P,p&&(I.camera=P),L.update(),t.local.camera=P,Y.camera=P,p&&I.reset()}function se(){W(),p&&(I.bounces=S.bounces,D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha),P.updateMatrixWorld(),S.backgroundAlpha<1?D.background=null:D.background=D.environment}function le(){if(p){if(t.local.updateSceneNext&&(I.setScene(D,P),t.local.updateSceneNext=!1),t.local.updateLightingNext&&(I.updateLights(),t.local.updateLightingNext=!1),S.samplesPerFrame>1)for(let e=0;e{e()})}if(p&&(D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha,S.backgroundAlpha<1&&(D.background=null),I.setScene(D,P),I.updateEnvironment(),I.updateLights()),"Lightmap"in r&&await Promise.all([oe]),re=()=>{le(),performance.now()-o>S.sleepAfter&&!S.runInfinitely?(n=!0,console.warn("g3d >> Sleeping...")):t.local.aid=requestAnimationFrame(re)},t.local.updateLightingNext=!1,t.local.updateSceneNext=!1,function(){const e=b[0],t=b[1],n=S.resolutionScale;p&&I.reset(),O.setSize(e,t),O.setPixelRatio(window.devicePixelRatio*n);const o=e/t;B.aspect=o,B.updateProjectionMatrix();const r=V/o;z.top=r/2,z.bottom=r/-2,z.updateProjectionMatrix()}(),ie(S.cameraProjection),p){D.backgroundAlpha=S.backgroundAlpha;const bt=E?.addFolder("Path Tracing");bt?.add(S,"runInfinitely"),bt?.add(S,"samplesPerFrame",1,50,1),bt?.add(S,"multipleImportanceSampling").onChange(()=>{I.multipleImportanceSampling=S.multipleImportanceSampling,I.updateLights(),I.updateMaterials()}),bt?.add(S,"environmentIntensity",0,3,.1).onChange(()=>{I.reset(),se(),I.updateEnvironment()}),bt?.add(S,"backgroundAlpha",0,1,.1).onChange(()=>{I.reset(),se(),I.updateEnvironment()}),bt?.add(S,"bounces",1,30,1).onChange(()=>{I.reset(),se()})}const ce=E?.addFolder("Camera");return ce?.add(S,"sleepAfter",1e3,3e4,10),ce?.add(S,"cameraProjection",["Perspective","Orthographic"]).onChange(e=>{ie(e),se()}),ce?.add(S,"acesToneMapping").onChange(e=>{O.toneMapping=e?i.ACESFilmicToneMapping:i.NoToneMapping,se()}),ce?.close(),re(),t},core.Graphics3D.destroy=(e,t)=>{console.log("Graphics3D was removed"),t.local.wakeThreadUp=()=>{},t.local.controlObject.dispose(),cancelAnimationFrame(t.local.aid),t.local.renderer.dispose(),t.local.renderer.forceContextLoss(),t.local.labelContainer&&t.local.labelContainer.remove(),t.local.guiContainer&&t.local.guiContainer.remove(),t.local.rendererContainer.remove()},core.Graphics3D.virtual=!0;const R={TypeReal:{},TypeInteger:{}},O={Real64:{context:R.TypeReal,constructor:Float64Array},Real32:{context:R.TypeReal,constructor:Float32Array},Integer32:{context:R.TypeInteger,constructor:Int32Array},Integer64:{context:R.TypeInteger,constructor:BigInt64Array},Integer16:{context:R.TypeInteger,constructor:Int16Array},Integer8:{context:R.TypeInteger,constructor:Int8Array},UnsignedInteger32:{context:R.TypeInteger,constructor:Uint32Array},UnsignedInteger64:{context:R.TypeInteger,constructor:BigUint64Array},UnsignedInteger16:{context:R.TypeInteger,constructor:Uint16Array},UnsignedInteger8:{context:R.TypeInteger,constructor:Uint8Array}};function T(e,t=[]){return Array.isArray(e)?(t.push(e.length),T(e[0],t)):t}const L=new RegExp(/^(-?\d+)(.?\d*)(\*\^)?(\d*)/),I=window.isNumeric;function P(e,t){if(Array.isArray(e[1]))for(let n=1;n{if("string"==typeof e){if(I(e))return parseInt(e);if(L.test(e)){let[t,n,o,r,a]=e.split(L);return n+="."===o?o+"0":o,r&&(n+="E"+a),parseFloat(n)}}return e}),t.index),t.index+=e.length-1}R.NumericArray=(e,t)=>{const n=O[interpretate(e[1])],o=[];let r=e[0].length-1;o.push(r),"List"===e[0][1][0]&&(r*=e[0][1].length-1,o.push(e[0][1].length-1),"List"===e[0][1][1][0]&&(r*=e[0][1][1].length-1,o.push(e[0][1][1].length-1)));const a=new n.constructor(r);return P(e[0],{index:0,array:a}),{buffer:a,dims:o}},R.NumericArray.update=R.NumericArray;const B={Real32:{constructor:Float32Array,convert:e=>{const t=e.dims[0]*e.dims[1]*e.dims[2],n=e.buffer,o=new Uint8ClampedArray(t);let r;for(r=0;r>>0;o[r]=e}return o}},Byte:{constructor:Uint8ClampedArray,convert:e=>e.buffer}};let z;l["CoffeeLiqueur`Extensions`Graphics3D`Private`SampledColorFunction"]=async(e,t)=>{const n=await interpretate(e[0],t);let o="RGB";return n[0].length>3&&(o="RGBA"),{colors:n,type:o}},core.Image3D=async(e,t)=>{await interpretate.shared.THREE.load(),i||(i=interpretate.shared.THREE.THREE,A=interpretate.shared.THREE.OrbitControls,_=interpretate.shared.THREE.RGBELoader,C=interpretate.shared.THREE.CSS2D,k=await Promise.resolve().then(function(){return j}),k=k.VariableTube),g||(g=(await Promise.resolve().then(function(){return Et})).GUI);const n=new g({autoPlace:!1,name:"...",closed:!0});z||(z=(await Promise.resolve().then(function(){return zr})).default);const o=await core._getRules(e,{...t,context:l,hold:!0});let r,a=await interpretate(e[0],{...t,context:[R,l]}),s="Real32";e.length-Object.keys(o).length>1&&(s=interpretate(e[1])),console.log(e),s=B[s],Array.isArray(a)&&(console.warn("Will be slow. Not a typed array"),a={buffer:a.flat(1/0),dims:T(a)}),r=s.convert(a),console.warn("ImageSize"),console.warn(a.dims);const c=a.dims[2],u=a.dims[1],d=a.dims[0],h={speed:1e-4,samplingRate:1,threshold:.5054,palette:"Greys",invertColor:!1,alphaScale:1.1916};"SamplingRate"in o&&(h.samplingRate=await interpretate(o.SamplingRate,t)),"InvertColor"in o&&(h.invertColor=await interpretate(o.InvertColor,t)),"AlphaScale"in o&&(h.alphaScale=await interpretate(o.AlphaScale,t)),"Palette"in o&&(h.palette=await interpretate(o.Palette,t));const p=new i.Data3DTexture(r,c,u,d);p.format=i.RedFormat,p.type=i.UnsignedByteType,p.minFilter=i.LinearFilter,p.magFilter=i.LinearFilter,p.wrapS=i.ClampToEdgeWrapping,p.wrapT=i.ClampToEdgeWrapping,p.wrapR=i.ClampToEdgeWrapping,p.needsUpdate=!0,t.local.volumeTexture=p;let m,f="Spectral";{const e=z.scale(f);m=(t,n)=>{const o=e(t/(n-1)).rgb();return o.push(255),o}}if("ColorFunction"in o){const e=await interpretate(o.ColorFunction,{...t,context:l});if(console.warn(e),"string"==typeof e){switch(e){case"XRay":h.invertColor=!0,f="Greys";break;case"GrayLevelOpacity":f="Greys";break;case"Automatic":break;default:f=e}const t=z.scale(f);m=(e,n)=>{const o=t(e/(n-1)).rgb();return o.push(255),o}}else if(e.type)switch(e.type){case"RGB":m=(t,n)=>{const o=e.colors[t].map(e=>Math.floor(255*e));return o.push(255),o};break;case"RGBA":m=(t,n)=>e.colors[t].map(e=>Math.floor(255*e));break;default:throw console.error(e),"unknown color format"}}const y=256,b=new Uint8Array(1024);for(let e=0;e density) {\n // Store the value if it is greater than the previous values.\n density = value;\n }\n\n // Early exit the loop when the maximum possible value is found or the exit point is reached. \n if (density >= 1.0 || t > tEnd) {\n break;\n }\n }\n\n // Convert the found value to a color by sampling the color palette texture.\n color.rgb = sampleColor(density).rgb;\n // Modify the alpha value of the color to make lower values more transparent.\n color.a = alphaScale * (invertColor ? 1.0 - density : density);\n\n // Return the color for the ray.\n return color;\n}\n\nvoid main() {\n // Determine the intersection of the ray and the box.\n vec3 rayDir = normalize(vDirection);\n vec3 aabbmin = vec3(-0.5);\n vec3 aabbmax = vec3(0.5);\n vec2 intersection = intersectAABB(vOrigin, rayDir, aabbmin, aabbmax);\n\n // Initialize the fragment color.\n vec4 color = vec4(0.0);\n\n // Check if the intersection is valid, i.e., if the near distance is smaller than the far distance.\n if (intersection.x <= intersection.y) {\n // Clamp the near intersection distance when the camera is inside the box so we do not start sampling behind the camera.\n intersection.x = max(intersection.x, 0.0);\n // Compute the entry and exit points for the ray.\n vec3 entryPoint = vOrigin + rayDir * intersection.x;\n vec3 exitPoint = vOrigin + rayDir * intersection.y;\n\n // Determine the sampling rate and step size.\n // Entry Exit Align Corner sampling as described in\n // Volume Raycasting Sampling Revisited by Steneteg et al. 2019\n vec3 dimensions = vec3(textureSize(dataTexture, 0));\n vec3 entryToExit = exitPoint - entryPoint;\n float samples = ceil(samplingRate * length(entryToExit * (dimensions - vec3(1.0))));\n float tEnd = length(entryToExit);\n float tIncr = tEnd / samples;\n float tStart = 0.5 * tIncr;\n\n // Determine the entry point in texture space to simplify texture sampling.\n vec3 texEntry = (entryPoint - aabbmin) / (aabbmax - aabbmin);\n\n // Sample the volume along the ray and convert samples to color.\n color = compose(color, texEntry, rayDir, samples, tStart, tEnd, tIncr);\n }\n\n // Return the fragment color.\n frag_color = color;\n}\n",side:i.BackSide,transparent:!0});t.local.material=E,S.material=E,v.add(S);let M=[core.DefaultWidth,core.DefaultWidth];if("ImageSize"in o){const e=await interpretate(o.ImageSize,t);Array.isArray(e)?M=e:"number"==typeof e&&(M=[e,e])}const O=M[0]/M[1],L=new i.PerspectiveCamera(45,O,.1,1e3);L.position.set(1,1,-1),L.lookAt(new i.Vector3(0,0,0));const I=new i.WebGLRenderer({antialias:!0,alpha:!0});I.setSize(M[0],M[1]),I.setPixelRatio(devicePixelRatio),t.element.appendChild(I.domElement),I.setClearColor(0,0);const P=new A(L,I.domElement);let F,D=performance.now(),N=!1;const V=()=>{D=performance.now(),N&&(console.log("wake"),N=!1,F())};n.add(h,"alphaScale",0,2).onChange(()=>{E.uniforms.alphaScale.value=h.alphaScale,V()}),n.add(h,"samplingRate",.1,4).onChange(()=>{E.uniforms.samplingRate.value=h.samplingRate,V()}),n.add(h,"invertColor").onChange(()=>{E.uniforms.invertColor.value=h.invertColor,V()}),P.addEventListener("change",V),F=()=>{E&&S.material.uniforms.cameraPosition.value.copy(L.position),I.render(v,L),performance.now()-D>100?(console.log("sleep"),N=!0):t.local.animation=requestAnimationFrame(F)};const G=document.createElement("div");G.classList.add("graphics3d-controller"),G.appendChild(n.domElement),M[0]>250&&M[1]>150&&t.element.appendChild(G);const U={Save:function(){I.render(v,L),I.domElement.toBlob(function(e){var t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download="screenshot.png",t.click()},"image/png",1)}};n.add(U,"Save"),F()},core.Image3D.virtual=!0,core.Image3D.destroy=(e,t)=>{console.warn("Dispose"),cancelAnimationFrame(t.local.animation),t.local.material.dispose(),t.local.colorTexture.dispose(),t.local.volumeTexture.dispose()},l.Ball=l.Sphere,await interpretate.shared.THREE.load();const F=interpretate.shared.THREE.THREE,D=F.BufferGeometry;F.Float32BufferAttribute,F.Vector2,F.Vector3;class N{constructor(e,t,n=64,o=1,r=8,a=!1){this.geometry=new D;let i=r;const s=N.generateRadial(o,i),l=N.generateNormal(o,i),c=N.generateBufferData(t,i,s,l);this.radialSegments=i,this.indices=new F.BufferAttribute(new Uint16Array(c.indices),1),this.geometry.setIndex(this.indices),this.vertices=new F.BufferAttribute(new Float32Array(c.vertices),3),this.normals=new F.BufferAttribute(new Float32Array(c.normals),3),this.geometry.setAttribute("position",this.vertices),this.geometry.setAttribute("normal",this.normals);const u=new F.Mesh(this.geometry,e);return this.mesh=u,this}dispose(){this.geometry.dispose()}update(e,t){const n=N.generateRadial(t,this.radialSegments),o=N.generateNormal(t,this.radialSegments),r=N.generateBufferData(e,this.radialSegments,n,o);this.indices.count>r.indices.length?(this.indices.set(new Uint16Array(r.indices)),this.vertices.set(new Float32Array(r.vertices)),this.normals.set(new Float32Array(r.normals)),this.geometry.setDrawRange(0,r.indices.length-1),this.indices.needsUpdate=!0,this.vertices.needsUpdate=!0,this.normals.needsUpdate=!0):this.indices.counta[e]}for(let t=0;t<=2*Math.PI;t+=r)n[0]=Math.cos(t),n[1]=Math.sin(t),a.push(n.map(t=>t*e));return()=>a}static generateNormal(e,t){const n=[],o=[],r=2*Math.PI/t,a=[];if(Array.isArray(e)){for(let e=0;e<=2*Math.PI;e+=r)o[0]=Math.cos(e),o[1]=Math.sin(e),n.push([...o]);for(let t=0;ta[e]}for(let e=0;e<=2*Math.PI;e+=r)a.push([Math.cos(e),Math.sin(e),0]);return()=>a}static generateBufferData(e,t,n,o){const r=[],a=[];let i=[];const s=[0,0,0],l=[0,0,0],c=[[1,0,0],[0,1,0],[0,0,1]];let u,d,h,p,m=[0,0,0],f=[0,0,0],g=[0,0,0],y=0;function b(){if(u=e[y],d=e[y+1],f[0]=d[0]-u[0],f[1]=d[1]-u[1],f[2]=d[2]-u[2],h=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]),0==h)return y++,void(i=i.slice(0,-6*t));p=h,f=f.map(e=>e/h);const b=c.map(e=>e[0]*f[0]+e[1]*f[1]+e[2]*f[2]);Math.abs(b[0])<=Math.abs(b[1])&&Math.abs(b[0])<=Math.abs(b[2])?(m[0]=1-b[0]*f[0],m[1]=0-b[0]*f[1],m[2]=0-b[0]*f[2]):Math.abs(b[1])<=Math.abs(b[2])&&Math.abs(b[1])<=Math.abs(b[0])?(m[0]=0-b[1]*f[0],m[1]=1-b[1]*f[1],m[2]=0-b[1]*f[2]):(m[0]=0-b[2]*f[0],m[1]=0-b[2]*f[1],m[2]=1-b[2]*f[2]),g[0]=m[2]*f[1]-m[1]*f[2],g[1]=m[0]*f[2]-m[2]*f[0],g[2]=m[1]*f[0]-m[0]*f[1];let w=n(y),v=o(y);const x=t;for(let e=0;ee/h);const i=c.map(e=>e[0]*f[0]+e[1]*f[1]+e[2]*f[2]);Math.abs(i[0])0)for(let r=t;r=t;r-=o)a=ce(r/o|0,e[r],e[r+1],a);return a&&oe(a,a.next)&&(ue(a),a=a.next),a}function G(e,t){if(!e)return e;t||(t=e);let n,o=e;do{if(n=!1,o.steiner||!oe(o,o.next)&&0!==ne(o.prev,o,o.next))o=o.next;else{if(ue(o),o=t=o.prev,o===o.next)break;n=!0}}while(n||o!==t);return t}function U(e,t,n,o,r,a,i){if(!e)return;!i&&a&&function(e,t,n,o){let r=e;do{0===r.z&&(r.z=J(r.x,r.y,t,n,o)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let o,r=e;e=null;let a=null;for(t=0;r;){t++;let i=r,s=0;for(let e=0;e0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(o=r,r=r.nextZ,s--):(o=i,i=i.nextZ,l--),a?a.nextZ=o:e=o,o.prevZ=a,a=o;r=i}a.nextZ=null,n*=2}while(t>1)}(r)}(e,o,r,a);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(a?W(e,o,r,a):H(e))t.push(l.i,e.i,c.i),ue(e),e=c.next,s=c.next;else if((e=c)===s){i?1===i?U(e=X(G(e),t),t,n,o,r,a,2):2===i&&q(e,t,n,o,r,a):U(G(e),t,n,o,r,a,1);break}}}function H(e){const t=e.prev,n=e,o=e.next;if(ne(t,n,o)>=0)return!1;const r=t.x,a=n.x,i=o.x,s=t.y,l=n.y,c=o.y,u=Math.min(r,a,i),d=Math.min(s,l,c),h=Math.max(r,a,i),p=Math.max(s,l,c);let m=o.next;for(;m!==t;){if(m.x>=u&&m.x<=h&&m.y>=d&&m.y<=p&&ee(r,s,a,l,i,c,m.x,m.y)&&ne(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function W(e,t,n,o){const r=e.prev,a=e,i=e.next;if(ne(r,a,i)>=0)return!1;const s=r.x,l=a.x,c=i.x,u=r.y,d=a.y,h=i.y,p=Math.min(s,l,c),m=Math.min(u,d,h),f=Math.max(s,l,c),g=Math.max(u,d,h),y=J(p,m,t,n,o),b=J(f,g,t,n,o);let w=e.prevZ,v=e.nextZ;for(;w&&w.z>=y&&v&&v.z<=b;){if(w.x>=p&&w.x<=f&&w.y>=m&&w.y<=g&&w!==r&&w!==i&&ee(s,u,l,d,c,h,w.x,w.y)&&ne(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==i&&ee(s,u,l,d,c,h,v.x,v.y)&&ne(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;w&&w.z>=y;){if(w.x>=p&&w.x<=f&&w.y>=m&&w.y<=g&&w!==r&&w!==i&&ee(s,u,l,d,c,h,w.x,w.y)&&ne(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=b;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==i&&ee(s,u,l,d,c,h,v.x,v.y)&&ne(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function X(e,t){let n=e;do{const o=n.prev,r=n.next.next;!oe(o,r)&&re(o,n,n.next,r)&&se(o,r)&&se(r,o)&&(t.push(o.i,n.i,r.i),ue(n),ue(n.next),n=e=r),n=n.next}while(n!==e);return G(n)}function q(e,t,n,o,r,a){let i=e;do{let e=i.next.next;for(;e!==i.prev;){if(i.i!==e.i&&te(i,e)){let s=le(i,e);return i=G(i,i.next),s=G(s,s.next),U(i,t,n,o,r,a,0),void U(s,t,n,o,r,a,0)}e=e.next}i=i.next}while(i!==e)}function Z(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function K(e,t){const n=function(e,t){let n=t;const o=e.x,r=e.y;let a,i=-1/0;if(oe(e,n))return n;do{if(oe(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=o&&e>i&&(i=e,a=n.x=n.x&&n.x>=l&&o!==n.x&&Q(ra.x||n.x===a.x&&Y(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;const o=le(n,e);return G(o,o.next),G(n,n.next)}function Y(e,t){return ne(e.prev,e,t.prev)<0&&ne(t.next,e,e.next)<0}function J(e,t,n,o,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-o)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $(e){let t=e,n=e;do{(t.x=(e-i)*(a-s)&&(e-i)*(o-s)>=(n-i)*(t-s)&&(n-i)*(a-s)>=(r-i)*(o-s)}function ee(e,t,n,o,r,a,i,s){return!(e===i&&t===s)&&Q(e,t,n,o,r,a,i,s)}function te(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&re(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(se(e,t)&&se(t,e)&&function(e,t){let n=e,o=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next}while(n!==e);return o}(e,t)&&(ne(e.prev,e,t.prev)||ne(e,t.prev,t))||oe(e,t)&&ne(e.prev,e,e.next)>0&&ne(t.prev,t,t.next)>0)}function ne(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function oe(e,t){return e.x===t.x&&e.y===t.y}function re(e,t,n,o){const r=ie(ne(e,t,n)),a=ie(ne(e,t,o)),i=ie(ne(n,o,e)),s=ie(ne(n,o,t));return r!==a&&i!==s||(!(0!==r||!ae(e,n,t))||(!(0!==a||!ae(e,o,t))||(!(0!==i||!ae(n,e,o))||!(0!==s||!ae(n,t,o)))))}function ae(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ie(e){return e>0?1:e<0?-1:0}function se(e,t){return ne(e.prev,e,e.next)<0?ne(e,t,e.next)>=0&&ne(e,e.prev,t)>=0:ne(e,t,e.prev)<0||ne(e,e.next,t)<0}function le(e,t){const n=de(e.i,e.x,e.y),o=de(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function ce(e,t,n,o){const r=de(e,t,n);return o?(r.next=o.next,r.prev=o,o.next.prev=r,o.next=r):(r.prev=r,r.next=r),r}function ue(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function de(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function he(e,t,n,o){let r=0;for(let a=t,i=n-o;a80*n){s=e[0],l=e[1];let t=s,o=l;for(let a=n;at&&(t=n),r>o&&(o=r)}c=Math.max(t-s,o-l),c=0!==c?32767/c:0}return U(a,i,n,s,l,c,0),i},deviation:function(e,t,n,o){const r=t&&t.length,a=r?t[0]*n:e.length;let i=Math.abs(he(e,0,a,n));if(r)for(let o=0,r=t.length;o=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(fe&&e.forEach&&e.forEach===fe)e.forEach(t,n);else if(e.length===e.length+0){var o,r=void 0;for(r=0,o=e.length;r1?ye.toArray(arguments):arguments[0];return ye.each(be,function(t){if(t.litmus(e))return ye.each(t.conversions,function(t,n){if(we=t.read(e),!1===ve&&!1!==we)return ve=we,we.conversionName=n,we.conversion=t,ye.BREAK}),ye.BREAK}),ve},_e=void 0,Ae={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),i=n*(1-r*t),s=n*(1-(1-r)*t),l=[[n,s,a],[i,n,a],[a,n,s],[a,i,n],[s,a,n],[n,a,i]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),r=Math.max(e,t,n),a=r-o,i=void 0;return 0===r?{h:NaN,s:0,v:0}:(i=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(i/=6)<0&&(i+=1),{h:360*i,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e);return o=this.hex_with_component(o,1,t),o=this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(_e=8*t)|e&~(255<<_e)}},ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ce=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Se=function(){function e(e,t){for(var n=0;n-1?t.length-t.indexOf(".")-1:0}var Ge=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=o||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,ye.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=Ve(r.__impliedStep),r}return Me(e,Ie),Se(e,[{key:"setValue",value:function(t){var n=t;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!==0&&(n=Math.round(n/this.__step)*this.__step),Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=Ve(e),this}}]),e}();var Ue=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,o));r.__truncationSuspended=!1;var a=r,i=void 0;function s(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=i-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),i=e.clientY}function c(){Fe.unbind(window,"mousemove",l),Fe.unbind(window,"mouseup",c),s()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Fe.bind(r.__input,"change",function(){var e=parseFloat(a.__input.value);ye.isNaN(e)||a.setValue(e)}),Fe.bind(r.__input,"blur",function(){s()}),Fe.bind(r.__input,"mousedown",function(e){Fe.bind(window,"mousemove",l),Fe.bind(window,"mouseup",c),i=e.clientY}),Fe.bind(r.__input,"keydown",function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,s())}),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Me(e,Ge),Se(e,[{key:"updateDisplay",value:function(){var t,n,o;return this.__input.value=this.__truncationSuspended?this.getValue():(t=this.getValue(),n=this.__precision,o=Math.pow(10,n),Math.round(t*o)/o),Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function He(e,t,n,o,r){return o+(e-t)/(n-t)*(r-o)}var We=function(){function e(t,n,o,r,a){Ce(this,e);var i=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:o,max:r,step:a})),s=i;function l(e){e.preventDefault();var t=s.__background.getBoundingClientRect();return s.setValue(He(e.clientX,t.left,t.right,s.__min,s.__max)),!1}function c(){Fe.unbind(window,"mousemove",l),Fe.unbind(window,"mouseup",c),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function u(e){var t=e.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(He(t,n.left,n.right,s.__min,s.__max))}function d(){Fe.unbind(window,"touchmove",u),Fe.unbind(window,"touchend",d),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return i.__background=document.createElement("div"),i.__foreground=document.createElement("div"),Fe.bind(i.__background,"mousedown",function(e){document.activeElement.blur(),Fe.bind(window,"mousemove",l),Fe.bind(window,"mouseup",c),l(e)}),Fe.bind(i.__background,"touchstart",function(e){if(1!==e.touches.length)return;Fe.bind(window,"touchmove",u),Fe.bind(window,"touchend",d),u(e)}),Fe.addClass(i.__background,"slider"),Fe.addClass(i.__foreground,"slider-fg"),i.updateDisplay(),i.__background.appendChild(i.__foreground),i.domElement.appendChild(i.__background),i}return Me(e,Ge),Se(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),Xe=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===o?"Fire":o,Fe.bind(r.__button,"click",function(e){return e.preventDefault(),a.fire(),!1}),Fe.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Me(e,Ie),Se(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(),qe=function(){function e(t,n){Ce(this,e);var o=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));o.__color=new Oe(o.getValue()),o.__temp=new Oe(0);var r=o;o.domElement=document.createElement("div"),Fe.makeSelectable(o.domElement,!1),o.__selector=document.createElement("div"),o.__selector.className="selector",o.__saturation_field=document.createElement("div"),o.__saturation_field.className="saturation-field",o.__field_knob=document.createElement("div"),o.__field_knob.className="field-knob",o.__field_knob_border="2px solid ",o.__hue_knob=document.createElement("div"),o.__hue_knob.className="hue-knob",o.__hue_field=document.createElement("div"),o.__hue_field.className="hue-field",o.__input=document.createElement("input"),o.__input.type="text",o.__input_textShadow="0 1px 1px ",Fe.bind(o.__input,"keydown",function(e){13===e.keyCode&&d.call(this)}),Fe.bind(o.__input,"blur",d),Fe.bind(o.__selector,"mousedown",function(){Fe.addClass(this,"drag").bind(window,"mouseup",function(){Fe.removeClass(r.__selector,"drag")})}),Fe.bind(o.__selector,"touchstart",function(){Fe.addClass(this,"drag").bind(window,"touchend",function(){Fe.removeClass(r.__selector,"drag")})});var a,i=document.createElement("div");function s(e){p(e),Fe.bind(window,"mousemove",p),Fe.bind(window,"touchmove",p),Fe.bind(window,"mouseup",c),Fe.bind(window,"touchend",c)}function l(e){m(e),Fe.bind(window,"mousemove",m),Fe.bind(window,"touchmove",m),Fe.bind(window,"mouseup",u),Fe.bind(window,"touchend",u)}function c(){Fe.unbind(window,"mousemove",p),Fe.unbind(window,"touchmove",p),Fe.unbind(window,"mouseup",c),Fe.unbind(window,"touchend",c),h()}function u(){Fe.unbind(window,"mousemove",m),Fe.unbind(window,"touchmove",m),Fe.unbind(window,"mouseup",u),Fe.unbind(window,"touchend",u),h()}function d(){var e=xe(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function h(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,a=n.clientY,i=(o-t.left)/(t.right-t.left),s=1-(a-t.top)/(t.bottom-t.top);return s>1?s=1:s<0&&(s=0),i>1?i=1:i<0&&(i=0),r.__color.v=s,r.__color.s=i,r.setValue(r.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return ye.extend(o.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),ye.extend(o.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:o.__field_knob_border+(o.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),ye.extend(o.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),ye.extend(o.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),ye.extend(i.style,{width:"100%",height:"100%",background:"none"}),Ke(i,"top","rgba(0,0,0,0)","#000"),ye.extend(o.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=o.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",ye.extend(o.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:o.__input_textShadow+"rgba(0,0,0,0.7)"}),Fe.bind(o.__saturation_field,"mousedown",s),Fe.bind(o.__saturation_field,"touchstart",s),Fe.bind(o.__field_knob,"mousedown",s),Fe.bind(o.__field_knob,"touchstart",s),Fe.bind(o.__hue_field,"mousedown",l),Fe.bind(o.__hue_field,"touchstart",l),o.__saturation_field.appendChild(i),o.__selector.appendChild(o.__field_knob),o.__selector.appendChild(o.__saturation_field),o.__selector.appendChild(o.__hue_field),o.__hue_field.appendChild(o.__hue_knob),o.domElement.appendChild(o.__input),o.domElement.appendChild(o.__selector),o.updateDisplay(),o}return Me(e,Ie),Se(e,[{key:"updateDisplay",value:function(){var e=xe(this.getValue());if(!1!==e){var t=!1;ye.each(Oe.COMPONENTS,function(n){if(!ye.isUndefined(e[n])&&!ye.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}},this),t&&ye.extend(this.__color.__state,e)}ye.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,o=255-n;ye.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,Ke(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),ye.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})}}]),e}(),Ze=["-moz-","-o-","-webkit-","-ms-",""];function Ke(e,t,n,o){e.style.background="",ye.each(Ze,function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+o+" 100%); "})}var Ye=function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(o)}catch(e){}},Je=function(e,t){var n=e[t];return ye.isArray(arguments[2])||ye.isObject(arguments[2])?new Ne(e,t,arguments[2]):ye.isNumber(n)?ye.isNumber(arguments[2])&&ye.isNumber(arguments[3])?ye.isNumber(arguments[4])?new We(e,t,arguments[2],arguments[3],arguments[4]):new We(e,t,arguments[2],arguments[3]):ye.isNumber(arguments[4])?new Ue(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Ue(e,t,{min:arguments[2],max:arguments[3]}):ye.isString(n)?new je(e,t):ye.isFunction(n)?new Xe(e,t,""):ye.isBoolean(n)?new De(e,t):null};var $e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},Qe=function(){function e(){Ce(this,e),this.backgroundElement=document.createElement("div"),ye.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Fe.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),ye.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Fe.bind(this.backgroundElement,"click",function(){t.hide()})}return Se(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),ye.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Fe.unbind(e.domElement,"webkitTransitionEnd",t),Fe.unbind(e.domElement,"transitionend",t),Fe.unbind(e.domElement,"oTransitionEnd",t)};Fe.bind(this.domElement,"webkitTransitionEnd",t),Fe.bind(this.domElement,"transitionend",t),Fe.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Fe.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Fe.getHeight(this.domElement)/2+"px"}}]),e}(),et=function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");Ye(et);var tt="Default",nt=function(){try{return!!window.localStorage}catch(e){return!1}}(),ot=void 0,rt=!0,at=void 0,it=!1,st=[],lt=function e(t){var n=this,o=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Fe.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=ye.defaults(o,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),o=ye.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),ye.isUndefined(o.load)?o.load={preset:tt}:o.preset&&(o.load.preset=o.preset),ye.isUndefined(o.parent)&&o.hideable&&st.push(this),o.resizable=ye.isUndefined(o.parent)&&o.resizable,o.autoPlace&&ye.isUndefined(o.scrollable)&&(o.scrollable=!0);var r,a=nt&&"true"===localStorage.getItem(mt(this,"isLocal")),i=void 0,s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return o.parent}},scrollable:{get:function(){return o.scrollable}},autoPlace:{get:function(){return o.autoPlace}},closeOnTop:{get:function(){return o.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:o.load.preset},set:function(e){n.parent?n.getRoot().preset=e:o.load.preset=e,function(e){for(var t=0;t1){var o=n.__li.nextElementSibling;return n.remove(),pt(e,n.object,n.property,{before:o,factoryArgs:[ye.toArray(arguments)]})}if(ye.isArray(t)||ye.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),pt(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof We){var o=new Ue(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});ye.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(e){var t=n[e],r=o[e];n[e]=o[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(o,e),t.apply(n,e)}}),Fe.addClass(t,"has-slider"),n.domElement.insertBefore(o.domElement,n.domElement.firstElementChild)}else if(n instanceof Ue){var r=function(t){if(ye.isNumber(n.__min)&&ye.isNumber(n.__max)){var o=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=pt(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(o),r&&a.listen(),a}return t};n.min=ye.compose(r,n.min),n.max=ye.compose(r,n.max)}else n instanceof De?(Fe.bind(t,"click",function(){Fe.fakeEvent(n.__checkbox,"click")}),Fe.bind(n.__checkbox,"click",function(e){e.stopPropagation()})):n instanceof Xe?(Fe.bind(t,"click",function(){Fe.fakeEvent(n.__button,"click")}),Fe.bind(t,"mouseover",function(){Fe.addClass(n.__button,"hover")}),Fe.bind(t,"mouseout",function(){Fe.removeClass(n.__button,"hover")})):n instanceof qe&&(Fe.addClass(t,"color"),n.updateDisplay=ye.compose(function(e){return t.style.borderLeftColor=n.__color.toString(),e},n.updateDisplay),n.updateDisplay());n.setValue=ye.compose(function(t){return e.getRoot().__preset_select&&n.isModified()&&dt(e.getRoot(),!0),t},n.setValue)}(e,l,r),e.__controllers.push(r),r}function mt(e,t){return document.location.href+"."+t}function ft(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function gt(e,t){t.style.display=e.useLocalStorage?"block":"none"}function yt(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function o(){Fe.removeClass(e.__closeButton,lt.CLASS_DRAG),Fe.unbind(window,"mousemove",n),Fe.unbind(window,"mouseup",o)}function r(r){return r.preventDefault(),t=r.clientX,Fe.addClass(e.__closeButton,lt.CLASS_DRAG),Fe.bind(window,"mousemove",n),Fe.bind(window,"mouseup",o),!1}e.__resize_handle=document.createElement("div"),ye.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Fe.bind(e.__resize_handle,"mousedown",r),Fe.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function bt(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function wt(e,t){var n={};return ye.each(e.__rememberedObjects,function(o,r){var a={},i=e.__rememberedObjectIndecesToControllers[r];ye.each(i,function(e,n){a[n]=t?e.initialValue:e.getValue()}),n[r]=a}),n}function vt(e){0!==e.length&&$e.call(window,function(){vt(e)}),ye.each(e,function(e){e.updateDisplay()})}lt.toggleHide=function(){it=!it,ye.each(st,function(e){e.domElement.style.display=it?"none":""})},lt.CLASS_AUTO_PLACE="a",lt.CLASS_AUTO_PLACE_CONTAINER="ac",lt.CLASS_MAIN="main",lt.CLASS_CONTROLLER_ROW="cr",lt.CLASS_TOO_TALL="taller-than-window",lt.CLASS_CLOSED="closed",lt.CLASS_CLOSE_BUTTON="close-button",lt.CLASS_CLOSE_TOP="close-top",lt.CLASS_CLOSE_BOTTOM="close-bottom",lt.CLASS_DRAG="drag",lt.DEFAULT_WIDTH=245,lt.TEXT_CLOSED="Close Controls",lt.TEXT_OPEN="Open Controls",lt._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||lt.toggleHide()},Fe.bind(window,"keydown",lt._keydownHandler,!1),ye.extend(lt.prototype,{add:function(e,t){return pt(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return pt(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;ye.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&at.removeChild(this.domElement);var e=this;ye.each(this.__folders,function(t){e.removeFolder(t)}),Fe.unbind(window,"keydown",lt._keydownHandler,!1),ut(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new lt(t);this.__folders[e]=n;var o=ct(this,n.domElement);return Fe.addClass(o,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],ut(e);var t=this;ye.each(e.__folders,function(t){e.removeFolder(t)}),ye.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Fe.getOffset(e.__ul).top,n=0;ye.each(e.__ul.childNodes,function(t){e.autoPlace&&t===e.__save_row||(n+=Fe.getHeight(t))}),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;ye.each(Array.prototype.slice.call(arguments),function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Fe.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Fe.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Fe.addClass(n,"button gears");var o=document.createElement("span");o.innerHTML="Save",Fe.addClass(o,"button"),Fe.addClass(o,"save");var r=document.createElement("span");r.innerHTML="New",Fe.addClass(r,"button"),Fe.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Fe.addClass(a,"button"),Fe.addClass(a,"revert");var i=e.__preset_select=document.createElement("select");e.load&&e.load.remembered?ye.each(e.load.remembered,function(t,n){ft(e,n,n===e.preset)}):ft(e,tt,!1);if(Fe.bind(i,"change",function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=wt(this)),e.folders={},ye.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=wt(this),dt(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[tt]=wt(this,!0)),this.load.remembered[e]=wt(this),this.preset=e,ft(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){ye.each(this.__controllers,function(t){this.getRoot().load.remembered?ht(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),ye.each(this.__folders,function(e){e.revert(e)}),e||dt(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&vt(this.__listening)},updateDisplay:function(){ye.each(this.__controllers,function(e){e.updateDisplay()}),ye.each(this.__folders,function(e){e.updateDisplay()})}});var xt={Color:Oe,math:Ae,interpret:xe},_t={Controller:Ie,BooleanController:De,OptionController:Ne,StringController:je,NumberController:Ge,NumberControllerBox:Ue,NumberControllerSlider:We,FunctionController:Xe,ColorController:qe},At={dom:Fe},kt={GUI:lt},Ct=lt,St={color:xt,controllers:_t,dom:At,gui:kt,GUI:Ct},Et=Object.freeze({__proto__:null,color:xt,controllers:_t,dom:At,gui:kt,GUI:Ct,default:St});const{min:Mt,max:Rt}=Math;var Ot=(e,t=0,n=1)=>Mt(Rt(t,e),n),Tt=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=Ot(e[t],0,255)):3===t&&(e[t]=Ot(e[t],0,1));return e};const Lt={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])Lt[`[object ${e}]`]=e.toLowerCase();function It(e){return Lt[Object.prototype.toString.call(e)]||"object"}var Pt=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):"object"==It(e[0])&&t?t.split("").filter(t=>void 0!==e[0][t]).map(t=>e[0][t]):e[0].slice(0),Bt=e=>{if(e.length<2)return null;const t=e.length-1;return"string"==It(e[t])?e[t].toLowerCase():null};const{PI:zt,min:Ft,max:Dt}=Math,Nt=e=>Math.round(100*e)/100,jt=e=>Math.round(100*e)/100,Vt=2*zt,Gt=zt/3,Ut=zt/180,Ht=180/zt;function Wt(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var Xt={format:{},autodetect:[]};var qt=class{constructor(...e){const t=this;if("object"===It(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=Bt(e),o=!1;if(!n){o=!0,Xt.sorted||(Xt.autodetect=Xt.autodetect.sort((e,t)=>t.p-e.p),Xt.sorted=!0);for(let t of Xt.autodetect)if(n=t.test(...e),n)break}if(!Xt.format[n])throw new Error("unknown format: "+e);{const r=Xt.format[n].apply(null,o?e:e.slice(0,-1));t._rgb=Tt(r)}3===t._rgb.length&&t._rgb.push(1)}toString(){return"function"==It(this.hex)?this.hex():`[${this._rgb.join(",")}]`}};const Zt=(...e)=>new qt(...e);Zt.version="3.2.0";var Kt=Zt;var Yt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};const Jt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$t=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Qt=e=>{if(e.match(Jt)){4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]);const t=parseInt(e,16);return[t>>16,t>>8&255,255&t,1]}if(e.match($t)){5!==e.length&&9!==e.length||(e=e.substr(1)),4===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error(`unknown hex color: ${e}`)},{round:en}=Math,tn=(...e)=>{let[t,n,o,r]=Pt(e,"rgba"),a=Bt(e)||"auto";void 0===r&&(r=1),"auto"===a&&(a=r<1?"rgba":"rgb"),t=en(t),n=en(n),o=en(o);let i="000000"+(t<<16|n<<8|o).toString(16);i=i.substr(i.length-6);let s="0"+en(255*r).toString(16);switch(s=s.substr(s.length-2),a.toLowerCase()){case"rgba":return`#${i}${s}`;case"argb":return`#${s}${i}`;default:return`#${i}`}};qt.prototype.name=function(){const e=tn(this._rgb,"rgb");for(let t of Object.keys(Yt))if(Yt[t]===e)return t.toLowerCase();return e},Xt.format.named=e=>{if(e=e.toLowerCase(),Yt[e])return Qt(Yt[e]);throw new Error("unknown color name: "+e)},Xt.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&"string"===It(e)&&Yt[e.toLowerCase()])return"named"}}),qt.prototype.alpha=function(e,t=!1){return void 0!==e&&"number"===It(e)?t?(this._rgb[3]=e,this):new qt([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},qt.prototype.clipped=function(){return this._rgb._clipped||!1};const nn={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},on=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function rn(e){const t=on.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);nn.labWhitePoint=e,nn.Xn=t[0],nn.Zn=t[1]}function an(){return nn.labWhitePoint}const sn=(...e)=>{e=Pt(e,"lab");const[t,n,o]=e,[r,a,i]=ln(t,n,o),[s,l,c]=un(r,a,i);return[s,l,c,e.length>3?e[3]:1]},ln=(e,t,n)=>{const{kE:o,kK:r,kKE:a,Xn:i,Yn:s,Zn:l}=nn,c=(e+16)/116,u=.002*t+c,d=c-.005*n,h=u*u*u,p=d*d*d;return[(h>o?h:(116*u-16)/r)*i,(e>a?Math.pow((e+16)/116,3):e/r)*s,(p>o?p:(116*d-16)/r)*l]},cn=e=>{const t=Math.sign(e);return((e=Math.abs(e))<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)*t},un=(e,t,n)=>{const{MtxAdaptMa:o,MtxAdaptMaI:r,MtxXYZ2RGB:a,RefWhiteRGB:i,Xn:s,Yn:l,Zn:c}=nn,u=s*o.m00+l*o.m10+c*o.m20,d=s*o.m01+l*o.m11+c*o.m21,h=s*o.m02+l*o.m12+c*o.m22,p=i.X*o.m00+i.Y*o.m10+i.Z*o.m20,m=i.X*o.m01+i.Y*o.m11+i.Z*o.m21,f=i.X*o.m02+i.Y*o.m12+i.Z*o.m22,g=(e*o.m00+t*o.m10+n*o.m20)*(p/u),y=(e*o.m01+t*o.m11+n*o.m21)*(m/d),b=(e*o.m02+t*o.m12+n*o.m22)*(f/h),w=g*r.m00+y*r.m10+b*r.m20,v=g*r.m01+y*r.m11+b*r.m21,x=g*r.m02+y*r.m12+b*r.m22;return[255*cn(w*a.m00+v*a.m10+x*a.m20),255*cn(w*a.m01+v*a.m11+x*a.m21),255*cn(w*a.m02+v*a.m12+x*a.m22)]},dn=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb"),[a,i,s]=pn(t,n,o),[l,c,u]=function(e,t,n){const{Xn:o,Yn:r,Zn:a,kE:i,kK:s}=nn,l=e/o,c=t/r,u=n/a,d=l>i?Math.pow(l,1/3):(s*l+16)/116,h=c>i?Math.pow(c,1/3):(s*c+16)/116,p=u>i?Math.pow(u,1/3):(s*u+16)/116;return[116*h-16,500*(d-h),200*(h-p)]}(a,i,s);return[l,c,u,...r.length>0&&r[0]<1?[r[0]]:[]]};function hn(e){const t=Math.sign(e);return((e=Math.abs(e))<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}const pn=(e,t,n)=>{e=hn(e/255),t=hn(t/255),n=hn(n/255);const{MtxRGB2XYZ:o,MtxAdaptMa:r,MtxAdaptMaI:a,Xn:i,Yn:s,Zn:l,As:c,Bs:u,Cs:d}=nn;let h=e*o.m00+t*o.m10+n*o.m20,p=e*o.m01+t*o.m11+n*o.m21,m=e*o.m02+t*o.m12+n*o.m22;const f=i*r.m00+s*r.m10+l*r.m20,g=i*r.m01+s*r.m11+l*r.m21,y=i*r.m02+s*r.m12+l*r.m22;let b=h*r.m00+p*r.m10+m*r.m20,w=h*r.m01+p*r.m11+m*r.m21,v=h*r.m02+p*r.m12+m*r.m22;return b*=f/c,w*=g/u,v*=y/d,h=b*a.m00+w*a.m10+v*a.m20,p=b*a.m01+w*a.m11+v*a.m21,m=b*a.m02+w*a.m12+v*a.m22,[h,p,m]};qt.prototype.lab=function(){return dn(this._rgb)};const mn=(...e)=>new qt(...e,"lab");Object.assign(Kt,{lab:mn,getLabWhitePoint:an,setLabWhitePoint:rn}),Xt.format.lab=sn,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"lab"))&&3===e.length)return"lab"}}),qt.prototype.darken=function(e=1){const t=this.lab();return t[0]-=nn.Kn*e,new qt(t,"lab").alpha(this.alpha(),!0)},qt.prototype.brighten=function(e=1){return this.darken(-e)},qt.prototype.darker=qt.prototype.darken,qt.prototype.brighter=qt.prototype.brighten,qt.prototype.get=function(e){const[t,n]=e.split("."),o=this[t]();if(n){const e=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(e>-1)return o[e];throw new Error(`unknown channel ${n} in mode ${t}`)}return o};const{pow:fn}=Math;qt.prototype.luminance=function(e,t="rgb"){if(void 0!==e&&"number"===It(e)){if(0===e)return new qt([0,0,0,this._rgb[3]],"rgb");if(1===e)return new qt([255,255,255,this._rgb[3]],"rgb");let n=this.luminance(),o=20;const r=(n,a)=>{const i=n.interpolate(a,.5,t),s=i.luminance();return Math.abs(e-s)<1e-7||!o--?i:s>e?r(n,i):r(i,a)},a=(n>e?r(new qt([0,0,0]),this):r(this,new qt([255,255,255]))).rgb();return new qt([...a,this._rgb[3]])}return gn(...this._rgb.slice(0,3))};const gn=(e,t,n)=>.2126*(e=yn(e))+.7152*(t=yn(t))+.0722*(n=yn(n)),yn=e=>(e/=255)<=.03928?e/12.92:fn((e+.055)/1.055,2.4);var bn={},wn=(e,t,n=.5,...o)=>{let r=o[0]||"lrgb";if(bn[r]||o.length||(r=Object.keys(bn)[0]),!bn[r])throw new Error(`interpolation mode ${r} is not defined`);return"object"!==It(e)&&(e=new qt(e)),"object"!==It(t)&&(t=new qt(t)),bn[r](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))};qt.prototype.mix=qt.prototype.interpolate=function(e,t=.5,...n){return wn(this,e,t,...n)},qt.prototype.premultiply=function(e=!1){const t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new qt([t[0]*n,t[1]*n,t[2]*n,n],"rgb")};const{sin:vn,cos:xn}=Math,_n=(...e)=>{let[t,n,o]=Pt(e,"lch");return isNaN(o)&&(o=0),o*=Ut,[t,xn(o)*n,vn(o)*n]},An=(...e)=>{e=Pt(e,"lch");const[t,n,o]=e,[r,a,i]=_n(t,n,o),[s,l,c]=sn(r,a,i);return[s,l,c,e.length>3?e[3]:1]},{sqrt:kn,atan2:Cn,round:Sn}=Math,En=(...e)=>{const[t,n,o]=Pt(e,"lab"),r=kn(n*n+o*o);let a=(Cn(o,n)*Ht+360)%360;return 0===Sn(1e4*r)&&(a=Number.NaN),[t,r,a]},Mn=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb"),[a,i,s]=dn(t,n,o),[l,c,u]=En(a,i,s);return[l,c,u,...r.length>0&&r[0]<1?[r[0]]:[]]};qt.prototype.lch=function(){return Mn(this._rgb)},qt.prototype.hcl=function(){return Wt(Mn(this._rgb))};const Rn=(...e)=>new qt(...e,"lch"),On=(...e)=>new qt(...e,"hcl");Object.assign(Kt,{lch:Rn,hcl:On}),Xt.format.lch=An,Xt.format.hcl=(...e)=>{const t=Wt(Pt(e,"hcl"));return An(...t)},["lch","hcl"].forEach(e=>Xt.autodetect.push({p:2,test:(...t)=>{if("array"===It(t=Pt(t,e))&&3===t.length)return e}})),qt.prototype.saturate=function(e=1){const t=this.lch();return t[1]+=nn.Kn*e,t[1]<0&&(t[1]=0),new qt(t,"lch").alpha(this.alpha(),!0)},qt.prototype.desaturate=function(e=1){return this.saturate(-e)},qt.prototype.set=function(e,t,n=!1){const[o,r]=e.split("."),a=this[o]();if(r){const e=o.indexOf(r)-("ok"===o.substr(0,2)?2:0);if(e>-1){if("string"==It(t))switch(t.charAt(0)){case"+":case"-":a[e]+=+t;break;case"*":a[e]*=+t.substr(1);break;case"/":a[e]/=+t.substr(1);break;default:a[e]=+t}else{if("number"!==It(t))throw new Error("unsupported value for Color.set");a[e]=t}const r=new qt(a,o);return n?(this._rgb=r._rgb,this):r}throw new Error(`unknown channel ${r} in mode ${o}`)}return a},qt.prototype.tint=function(e=.5,...t){return wn(this,"white",e,...t)},qt.prototype.shade=function(e=.5,...t){return wn(this,"black",e,...t)};bn.rgb=(e,t,n)=>{const o=e._rgb,r=t._rgb;return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"rgb")};const{sqrt:Tn,pow:Ln}=Math;bn.lrgb=(e,t,n)=>{const[o,r,a]=e._rgb,[i,s,l]=t._rgb;return new qt(Tn(Ln(o,2)*(1-n)+Ln(i,2)*n),Tn(Ln(r,2)*(1-n)+Ln(s,2)*n),Tn(Ln(a,2)*(1-n)+Ln(l,2)*n),"rgb")};bn.lab=(e,t,n)=>{const o=e.lab(),r=t.lab();return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"lab")};var In=(e,t,n,o)=>{let r,a,i,s,l,c,u,d,h,p,m,f;return"hsl"===o?(r=e.hsl(),a=t.hsl()):"hsv"===o?(r=e.hsv(),a=t.hsv()):"hcg"===o?(r=e.hcg(),a=t.hcg()):"hsi"===o?(r=e.hsi(),a=t.hsi()):"lch"===o||"hcl"===o?(o="hcl",r=e.hcl(),a=t.hcl()):"oklch"===o&&(r=e.oklch().reverse(),a=t.oklch().reverse()),"h"!==o.substr(0,1)&&"oklch"!==o||([i,l,u]=r,[s,c,d]=a),isNaN(i)||isNaN(s)?isNaN(i)?isNaN(s)?p=Number.NaN:(p=s,1!=u&&0!=u||"hsv"==o||(h=c)):(p=i,1!=d&&0!=d||"hsv"==o||(h=l)):(f=s>i&&s-i>180?s-(i+360):s180?s+360-i:s-i,p=i+n*f),void 0===h&&(h=l+n*(c-l)),m=u+n*(d-u),new qt("oklch"===o?[m,h,p]:[p,h,m],o)};const Pn=(e,t,n)=>In(e,t,n,"lch");bn.lch=Pn,bn.hcl=Pn;qt.prototype.num=function(){return((...e)=>{const[t,n,o]=Pt(e,"rgb");return(t<<16)+(n<<8)+o})(this._rgb)};const Bn=(...e)=>new qt(...e,"num");Object.assign(Kt,{num:Bn}),Xt.format.num=e=>{if("number"==It(e)&&e>=0&&e<=16777215){return[e>>16,e>>8&255,255&e,1]}throw new Error("unknown num color: "+e)},Xt.autodetect.push({p:5,test:(...e)=>{if(1===e.length&&"number"===It(e[0])&&e[0]>=0&&e[0]<=16777215)return"num"}});bn.num=(e,t,n)=>{const o=e.num(),r=t.num();return new qt(o+n*(r-o),"num")};const{floor:zn}=Math;qt.prototype.hcg=function(){return((...e)=>{const[t,n,o]=Pt(e,"rgb"),r=Ft(t,n,o),a=Dt(t,n,o),i=a-r,s=100*i/255,l=r/(255-i)*100;let c;return 0===i?c=Number.NaN:(t===a&&(c=(n-o)/i),n===a&&(c=2+(o-t)/i),o===a&&(c=4+(t-n)/i),c*=60,c<0&&(c+=360)),[c,s,l]})(this._rgb)};const Fn=(...e)=>new qt(...e,"hcg");Kt.hcg=Fn,Xt.format.hcg=(...e)=>{e=Pt(e,"hcg");let t,n,o,[r,a,i]=e;i*=255;const s=255*a;if(0===a)t=n=o=i;else{360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60;const e=zn(r),l=r-e,c=i*(1-a),u=c+s*(1-l),d=c+s*l,h=c+s;switch(e){case 0:[t,n,o]=[h,d,c];break;case 1:[t,n,o]=[u,h,c];break;case 2:[t,n,o]=[c,h,d];break;case 3:[t,n,o]=[c,u,h];break;case 4:[t,n,o]=[d,c,h];break;case 5:[t,n,o]=[h,c,u]}}return[t,n,o,e.length>3?e[3]:1]},Xt.autodetect.push({p:1,test:(...e)=>{if("array"===It(e=Pt(e,"hcg"))&&3===e.length)return"hcg"}});bn.hcg=(e,t,n)=>In(e,t,n,"hcg");const{cos:Dn}=Math,{min:Nn,sqrt:jn,acos:Vn}=Math;qt.prototype.hsi=function(){return((...e)=>{let t,[n,o,r]=Pt(e,"rgb");n/=255,o/=255,r/=255;const a=Nn(n,o,r),i=(n+o+r)/3,s=i>0?1-a/i:0;return 0===s?t=NaN:(t=(n-o+(n-r))/2,t/=jn((n-o)*(n-o)+(n-r)*(o-r)),t=Vn(t),r>o&&(t=Vt-t),t/=Vt),[360*t,s,i]})(this._rgb)};const Gn=(...e)=>new qt(...e,"hsi");Kt.hsi=Gn,Xt.format.hsi=(...e)=>{e=Pt(e,"hsi");let t,n,o,[r,a,i]=e;return isNaN(r)&&(r=0),isNaN(a)&&(a=0),r>360&&(r-=360),r<0&&(r+=360),r/=360,r<1/3?(o=(1-a)/3,t=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,n=1-(o+t)):r<2/3?(r-=1/3,t=(1-a)/3,n=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,o=1-(t+n)):(r-=2/3,n=(1-a)/3,o=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,t=1-(n+o)),t=Ot(i*t*3),n=Ot(i*n*3),o=Ot(i*o*3),[255*t,255*n,255*o,e.length>3?e[3]:1]},Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsi"))&&3===e.length)return"hsi"}});bn.hsi=(e,t,n)=>In(e,t,n,"hsi");const Un=(...e)=>{e=Pt(e,"hsl");const[t,n,o]=e;let r,a,i;if(0===n)r=a=i=255*o;else{const e=[0,0,0],s=[0,0,0],l=o<.5?o*(1+n):o+n-o*n,c=2*o-l,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&(e[t]-=1),6*e[t]<1?s[t]=c+6*(l-c)*e[t]:2*e[t]<1?s[t]=l:3*e[t]<2?s[t]=c+(l-c)*(2/3-e[t])*6:s[t]=c;[r,a,i]=[255*s[0],255*s[1],255*s[2]]}return e.length>3?[r,a,i,e[3]]:[r,a,i,1]},Hn=(...e)=>{e=Pt(e,"rgba");let[t,n,o]=e;t/=255,n/=255,o/=255;const r=Ft(t,n,o),a=Dt(t,n,o),i=(a+r)/2;let s,l;return a===r?(s=0,l=Number.NaN):s=i<.5?(a-r)/(a+r):(a-r)/(2-a-r),t==a?l=(n-o)/(a-r):n==a?l=2+(o-t)/(a-r):o==a&&(l=4+(t-n)/(a-r)),l*=60,l<0&&(l+=360),e.length>3&&void 0!==e[3]?[l,s,i,e[3]]:[l,s,i]};qt.prototype.hsl=function(){return Hn(this._rgb)};const Wn=(...e)=>new qt(...e,"hsl");Kt.hsl=Wn,Xt.format.hsl=Un,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsl"))&&3===e.length)return"hsl"}});bn.hsl=(e,t,n)=>In(e,t,n,"hsl");const{floor:Xn}=Math,{min:qn,max:Zn}=Math;qt.prototype.hsv=function(){return((...e)=>{e=Pt(e,"rgb");let[t,n,o]=e;const r=qn(t,n,o),a=Zn(t,n,o),i=a-r;let s,l,c;return c=a/255,0===a?(s=Number.NaN,l=0):(l=i/a,t===a&&(s=(n-o)/i),n===a&&(s=2+(o-t)/i),o===a&&(s=4+(t-n)/i),s*=60,s<0&&(s+=360)),[s,l,c]})(this._rgb)};const Kn=(...e)=>new qt(...e,"hsv");Kt.hsv=Kn,Xt.format.hsv=(...e)=>{e=Pt(e,"hsv");let t,n,o,[r,a,i]=e;if(i*=255,0===a)t=n=o=i;else{360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60;const e=Xn(r),s=r-e,l=i*(1-a),c=i*(1-a*s),u=i*(1-a*(1-s));switch(e){case 0:[t,n,o]=[i,u,l];break;case 1:[t,n,o]=[c,i,l];break;case 2:[t,n,o]=[l,i,u];break;case 3:[t,n,o]=[l,c,i];break;case 4:[t,n,o]=[u,l,i];break;case 5:[t,n,o]=[i,l,c]}}return[t,n,o,e.length>3?e[3]:1]},Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsv"))&&3===e.length)return"hsv"}});function Yn(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let o=t[0].length,r=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>r.map(t=>Array.isArray(e)?e.reduce((e,n,o)=>e+n*(t[o]||0),0):t.reduce((t,n)=>t+n*e,0)));return 1===n&&(a=a[0]),1===o?a.map(e=>e[0]):a}bn.hsv=(e,t,n)=>In(e,t,n,"hsv");const Jn=(...e)=>{e=Pt(e,"lab");const[t,n,o,...r]=e,[a,i,s]=(l=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],c=Yn([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[t,n,o]),Yn(l,c.map(e=>e**3)));var l,c;const[u,d,h]=un(a,i,s);return[u,d,h,...r.length>0&&r[0]<1?[r[0]]:[]]};const $n=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb");return[...function(e){const t=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],n=Yn([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e);return Yn(t,n.map(e=>Math.cbrt(e)))}(pn(t,n,o)),...r.length>0&&r[0]<1?[r[0]]:[]]};qt.prototype.oklab=function(){return $n(this._rgb)};const Qn=(...e)=>new qt(...e,"oklab");Object.assign(Kt,{oklab:Qn}),Xt.format.oklab=Jn,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"oklab"))&&3===e.length)return"oklab"}});bn.oklab=(e,t,n)=>{const o=e.oklab(),r=t.oklab();return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"oklab")};bn.oklch=(e,t,n)=>In(e,t,n,"oklch");const{pow:eo,sqrt:to,PI:no,cos:oo,sin:ro,atan2:ao}=Math;var io=(e,t="lrgb",n=null)=>{const o=e.length;n||(n=Array.from(new Array(o)).map(()=>1));const r=o/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=r}),e=e.map(e=>new qt(e)),"lrgb"===t)return so(e,n);const a=e.shift(),i=a.get(t),s=[];let l=0,c=0;for(let e=0;e{const r=e.get(t);u+=e.alpha()*n[o+1];for(let e=0;e=360;)t-=360;i[e]=t}else i[e]=i[e]/s[e];return u/=o,new qt(i,t).alpha(u>.99999?1:u,!0)};const so=(e,t)=>{const n=e.length,o=[0,0,0,0];for(let r=0;r.9999999&&(o[3]=1),new qt(Tt(o))},{pow:lo}=Math;function co(e){let t="rgb",n=Kt("#ccc"),o=0,r=[0,1],a=[0,1],i=[],s=[0,0],l=!1,c=[],u=!1,d=0,h=1,p=!1,m={},f=!0,g=1;const y=function(e){if((e=e||["#fff","#000"])&&"string"===It(e)&&Kt.brewer&&Kt.brewer[e.toLowerCase()]&&(e=Kt.brewer[e.toLowerCase()]),"array"===It(e)){1===e.length&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;te,w=e=>e;const v=function(e,o){let r,a;if(null==o&&(o=!1),isNaN(e)||null===e)return n;if(o)a=e;else if(l&&l.length>2){a=function(e){if(null!=l){const t=l.length-1;let n=0;for(;n=l[n];)n++;return n-1}return 0}(e)/(l.length-2)}else a=h!==d?(e-d)/(h-d):1;a=w(a),o||(a=b(a)),1!==g&&(a=lo(a,g)),a=s[0]+a*(1-s[0]-s[1]),a=Ot(a,0,1);const u=Math.floor(1e4*a);if(f&&m[u])r=m[u];else{if("array"===It(c))for(let e=0;e=n&&e===i.length-1){r=c[e];break}if(a>n&&am={};y(e);const _=function(e){const t=Kt(v(e));return u&&t[u]?t[u]():t};return _.classes=function(e){if(null!=e){if("array"===It(e))l=e,r=[e[0],e[e.length-1]];else{const t=Kt.analyze(r);l=0===e?[t.min,t.max]:Kt.limits(t,"e",e)}return _}return l},_.domain=function(e){if(!arguments.length)return a;a=e.slice(0),d=e[0],h=e[e.length-1],i=[];const t=c.length;if(e.length===t&&d!==h)for(let t of Array.from(e))i.push((t-d)/(h-d));else{for(let e=0;e2){const t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-d)/(h-d));n.every((e,n)=>t[n]===e)||(w=e=>{if(e<=0||e>=1)return e;let o=0;for(;e>=n[o+1];)o++;const r=(e-n[o])/(n[o+1]-n[o]);return t[o]+r*(t[o+1]-t[o])})}}return r=[d,h],_},_.mode=function(e){return arguments.length?(t=e,x(),_):t},_.range=function(e,t){return y(e),_},_.out=function(e){return u=e,_},_.spread=function(e){return arguments.length?(o=e,_):o},_.correctLightness=function(e){return null==e&&(e=!0),p=e,x(),b=p?function(e){const t=v(0,!0).lab()[0],n=v(1,!0).lab()[0],o=t>n;let r=v(e,!0).lab()[0];const a=t+(n-t)*e;let i=r-a,s=0,l=1,c=20;for(;Math.abs(i)>.01&&c-- >0;)(function(){o&&(i*=-1),i<0?(s=e,e+=.5*(l-e)):(l=e,e+=.5*(s-e)),r=v(e,!0).lab()[0],i=r-a})();return e}:e=>e,_},_.padding=function(e){return null!=e?("number"===It(e)&&(e=[e,e]),s=e,_):s},_.colors=function(t,n){arguments.length<2&&(n="hex");let o=[];if(0===arguments.length)o=c.slice(0);else if(1===t)o=[_(.5)];else if(t>1){const e=r[0],n=r[1]-e;o=function(e,t,n){let o=[],r=ea;r?t++:t--)o.push(t);return o}(0,t,!1).map(o=>_(e+o/(t-1)*n))}else{e=[];let t=[];if(l&&l.length>2)for(let e=1,n=l.length,o=1<=n;o?en;o?e++:e--)t.push(.5*(l[e-1]+l[e]));else t=r;o=t.map(e=>_(e))}return Kt[n]&&(o=o.map(e=>e[n]())),o},_.cache=function(e){return null!=e?(f=e,_):f},_.gamma=function(e){return null!=e?(g=e,_):g},_.nodata=function(e){return null!=e?(n=Kt(e),_):n},_}var uo=e=>{const t=function(e){let t,n,o,r;if(2===(e=e.map(e=>new qt(e))).length)[n,o]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>n[t]+e*(o[t]-n[t]));return new qt(t,"lab")};else if(3===e.length)[n,o,r]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*n[t]+2*(1-e)*e*o[t]+e*e*r[t]);return new qt(t,"lab")};else if(4===e.length){let a;[n,o,r,a]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*(1-e)*n[t]+3*(1-e)*(1-e)*e*o[t]+3*(1-e)*e*e*r[t]+e*e*e*a[t]);return new qt(t,"lab")}}else{if(!(e.length>=5))throw new RangeError("No point in running bezier with only one color.");{let n,o,r;n=e.map(e=>e.lab()),r=e.length-1,o=function(e){let t=[1,1];for(let n=1;nn.reduce((n,i,s)=>n+o[s]*t**(r-s)*e**s*i[a],0));return new qt(a,"lab")}}}return t}(e);return t.scale=()=>co(t),t};const{round:ho}=Math;qt.prototype.rgb=function(e=!0){return!1===e?this._rgb.slice(0,3):this._rgb.slice(0,3).map(ho)},qt.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?!1===e?t:ho(t):t)};const po=(...e)=>new qt(...e,"rgb");Object.assign(Kt,{rgb:po}),Xt.format.rgb=(...e)=>{const t=Pt(e,"rgba");return void 0===t[3]&&(t[3]=1),t},Xt.autodetect.push({p:3,test:(...e)=>{if("array"===It(e=Pt(e,"rgba"))&&(3===e.length||4===e.length&&"number"==It(e[3])&&e[3]>=0&&e[3]<=1))return"rgb"}});const mo=(e,t,n)=>{if(!mo[n])throw new Error("unknown blend mode "+n);return mo[n](e,t)},fo=e=>(t,n)=>{const o=Kt(n).rgb(),r=Kt(t).rgb();return Kt.rgb(e(o,r))},go=e=>(t,n)=>{const o=[];return o[0]=e(t[0],n[0]),o[1]=e(t[1],n[1]),o[2]=e(t[2],n[2]),o};mo.normal=fo(go(e=>e)),mo.multiply=fo(go((e,t)=>e*t/255)),mo.screen=fo(go((e,t)=>255*(1-(1-e/255)*(1-t/255)))),mo.overlay=fo(go((e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)))),mo.darken=fo(go((e,t)=>e>t?t:e)),mo.lighten=fo(go((e,t)=>e>t?e:t)),mo.dodge=fo(go((e,t)=>255===e||(e=t/255*255/(1-e/255))>255?255:e)),mo.burn=fo(go((e,t)=>255*(1-(1-t/255)/(e/255))));var yo=mo;const{pow:bo,sin:wo,cos:vo}=Math;function xo(e=300,t=-1.5,n=1,o=1,r=[0,1]){let a,i=0;"array"===It(r)?a=r[1]-r[0]:(a=0,r=[r,r]);const s=function(s){const l=Vt*((e+120)/360+t*s),c=bo(r[0]+a*s,o),u=(0!==i?n[0]+s*i:n)*c*(1-c)/2,d=vo(l),h=wo(l);return Kt(Tt([255*(c+u*(-.14861*d+1.78277*h)),255*(c+u*(-.29227*d-.90649*h)),255*(c+u*(1.97294*d)),1]))};return s.start=function(t){return null==t?e:(e=t,s)},s.rotations=function(e){return null==e?t:(t=e,s)},s.gamma=function(e){return null==e?o:(o=e,s)},s.hue=function(e){return null==e?n:("array"===It(n=e)?(i=n[1]-n[0],0===i&&(n=n[1])):i=0,s)},s.lightness=function(e){return null==e?r:("array"===It(e)?(r=e,a=e[1]-e[0]):(r=[e,e],a=0),s)},s.scale=()=>Kt.scale(s),s.hue(n),s}const{floor:_o,random:Ao}=Math;var ko=(e=Ao)=>{let t="#";for(let n=0;n<6;n++)t+="0123456789abcdef".charAt(_o(16*e()));return new qt(t,"hex")};const{log:Co,pow:So,floor:Eo,abs:Mo}=Math;function Ro(e,t=null){const n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===It(e)&&(e=Object.values(e)),e.forEach(e=>{t&&"object"===It(e)&&(e=e[t]),null==e||isNaN(e)||(n.values.push(e),n.sum+=e,en.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>Oo(n,e,t),n}function Oo(e,t="equal",n=7){"array"==It(e)&&(e=Ro(e));const{min:o,max:r}=e,a=e.values.sort((e,t)=>e-t);if(1===n)return[o,r];const i=[];if("c"===t.substr(0,1)&&(i.push(o),i.push(r)),"e"===t.substr(0,1)){i.push(o);for(let e=1;e 0");const e=Math.LOG10E*Co(o),t=Math.LOG10E*Co(r);i.push(o);for(let o=1;o200&&(c=!1)}const h={};for(let e=0;ee-t),i.push(p[0]);for(let e=1;e{e=new qt(e),t=new qt(t);const n=e.luminance(),o=t.luminance();return n>o?(n+.05)/(o+.05):(o+.05)/(n+.05)}; +var e={};Object.defineProperty(e,"__esModule",{value:!0});var t=e.default=void 0;const n=6/29,o=3*n*n,r=e=>Math.round(255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055))||0,a=e=>e>n?e*e*e:o*(e-4/29);t=e.default=({luminance:e,a:t,b:n})=>{const o=(e+16)/116,i=.96422*a(o+t/500),s=Number(a(o)),l=.82521*a(o-n/200);return{red:r(3.1338561*i-1.6168667*s-.4906146*l),green:r(-.9787684*i+1.9161415*s+.033454*l),blue:r(.0719453*i-.2289914*s+1.4052427*l)}};let i,s,l={};function c(e,t,n,o=!1,r=!1){const a=e/2,s=t/2,l=e/n,c=t/n,u=[],d=[.4*l,.4*c],h=new i.LineBasicMaterial({toneMapped:!1,color:new i.Color("gray")});r&&(u.push(new i.Vector3(a,s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(-a,s,0)),u.push(new i.Vector3(-a,-s,0)),o&&(u.push(new i.Vector3(-a,-s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(a,-s,0)),u.push(new i.Vector3(a,s,0))));for(let e=0;e<=n;e++){const t=l*e-a;u.push(new i.Vector3(t,-s,0)),u.push(new i.Vector3(t,1*d[1]-s,0)),o||(u.push(new i.Vector3(t,s,0)),u.push(new i.Vector3(t,s-1*d[1],0)))}for(let e=0;e<=n;e++){const t=c*e-s;u.push(new i.Vector3(a,t,0)),u.push(new i.Vector3(a-1*d[0],t,0)),u.push(new i.Vector3(-a,t,0)),u.push(new i.Vector3(1*d[0]-a,t,0))}return new i.LineSegments((new i.BufferGeometry).setFromPoints(u),h)}l.name="WebObjects/Graphics3D",interpretate.contextExpand(l),["AlignmentPoint","AspectRatio","AutomaticImageSize","Axes","AxesEdge","AxesLabel","AxesOrigin","AxesStyle","Background","BaselinePosition","BaseStyle","Boxed","BoxRatios","BoxStyle","ClipPlanes","ClipPlanesStyle","ColorOutput","ContentSelectable","ColorFunction","ControllerLinking","ControllerMethod","ControllerPath","CoordinatesToolOptions","DisplayFunction","Epilog","FaceGrids","FaceGridsStyle","FormatType","ImageMargins","ImagePadding","ImageSize","ImageSizeRaw","LabelStyle","Lighting","Method","PlotLabel","PlotRange","PlotRangePadding","PlotRegion","PreserveImageOptions","Prolog","RotationAction","SphericalRegion","Ticks","TicksStyle","TouchscreenAutoZoom","ViewAngle","ViewCenter","ViewMatrix","ViewPoint","ViewProjection","VertexTextureCoordinates","RTX","ViewRange","ViewVector","ViewVertical","Controls","PointerLockControls","VertexNormals","VertexColors"].map(e=>{l[e]=()=>e}),l.VertexNormals.update=()=>"VertexNormals",l.VertexColors.update=()=>"VertexColors",l.Void=(e,t)=>{console.log(e),console.warn("went to the void...")},l.Void.update=()=>{},l.Void.destroy=()=>{},l.CapForm=l.Void,l.Appearance=l.Void,l.All=()=>"All",l.LABColor=async(e,n)=>{let o;o=e.length>1?[await interpretate(e[0],n),await interpretate(e[1],n),await interpretate(e[2],n)]:await interpretate(e[0],n);const r=t({luminance:100*o[0],a:100*o[1],b:100*o[2]});return console.log("LAB color"),console.log(r),n.color=new i.Color(r.red/255,r.green/255,r.blue/255),e.length>3&&(n.opacity=await interpretate(e[3],n)),n.color},l.LABColor.update=()=>{},l.LinearFog=async(e,t)=>{let n=1,o=100,r=13421772;e.length>0&&(r=await interpretate(e[0],t)),e.length>1&&([n,o]=await interpretate(e[1],t)),t.global.scene.fog=new i.Fog(r,n,o)},l.Style=async(e,t)=>{const n=t,o=await core._getRules(e,t);o.FontSize&&(n.fontSize=o.FontSize),o.FontColor&&(n.color=o.FontColor),o.FontFamily&&(n.fontFamily=o.FontFamily);for(let t=1;t{const n=await core._getRules(e,t);return n.FontSize&&(t.fontSize=n.FontSize),n.FontFamily&&(t.fontFamily=n.FontFamily),await interpretate(e[0],t)},l.Dashing=(e,t)=>{console.log("Dashing not implemented")},l.Annotation=core.List,l.GraphicsGroup=async(e,t)=>{const n=new i.Group;let o={...t};o.mesh=n;for(const t of e)await interpretate(t,o);t.mesh.add(n)},l.Metalness=(e,t)=>{t.metalness=interpretate(e[0],t)},l.Emissive=async(e,t)=>{const n={...t};await interpretate(e[0],n),t.emissive=n.color,e.length>1&&(t.emissiveIntensity=await interpretate(e[1],n))},l.Glow=l.Emissive;l.Hue=async(e,t)=>{t.colorInherit=!1;let n=await Promise.all(e.map(e=>interpretate(e,t)));return n.length<3&&(n=[n[0],1,1]),n=((e,t,n,o=n-n*t/2,r=Math.min(o,1-o))=>[e,r?(n-o)/r:0,o])(...n),n=[n[0],(100*n[1]).toFixed(2),(100*n[2]).toFixed(2)],t.color=new i.Color("hsl("+(314*n[0]).toFixed(2)+","+n[1]+"%,"+n[2]+"%)"),t.color},l.EdgeForm=async(e,t)=>{t.edgecolor=await interpretate(e[0],{...t})},l.RGBColor=async(e,t)=>{if(t.colorInherit=!1,3!==e.length&&4!==e.length&&1!==e.length)return console.log("RGB format not implemented",e),void console.error("RGB values should be triple!");let n=[...e];1===e.length&&(n=await interpretate(e[0],t));const o=await interpretate(n[0],t),r=await interpretate(n[1],t),a=await interpretate(n[2],t);return t.color=new i.Color(o,r,a),t.color},l.GrayLevel=async(e,t)=>{t.colorInherit=!1;const n=await interpretate(e[0],t);return t.color=new i.Color(n,n,n),t.color},l.Roughness=(e,t)=>{const n=interpretate(e[0],t);"number"!=typeof n&&console.error("Opacity must have number value!"),console.log(n),t.roughness=n},l.Opacity=(e,t)=>{var n=interpretate(e[0],t);"number"!=typeof n&&console.error("Opacity must have number value!"),console.log(n),t.opacity=n},l.Scale=async(e,t)=>{const n=e[0];let o=await interpretate(e[1],t),r=e.length>2?await interpretate(e[2],t):[0,0,0];o instanceof NumericArrayObject&&(o=o.normal()),Array.isArray(o)||(o=[o,o,o]),r instanceof NumericArrayObject&&(r=r.normal());const a=new i.Group;await interpretate(n,{...t,mesh:a});const s=(new i.Matrix4).makeTranslation(-r[0],-r[1],-r[2]),l=(new i.Matrix4).makeScale(o[0],o[1],o[2]),c=(new i.Matrix4).makeTranslation(r[0],r[1],r[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);return a.applyMatrix4(u),t.mesh.add(a),t.local.group=a,t.local.scale=o.slice(),t.local.center=r.slice(),a},l.Scale.update=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal());const r=t.local.scale||[1,1,1],a=t.local.center||[0,0,0],s=(new i.Matrix4).makeTranslation(-a[0],-a[1],-a[2]),l=(new i.Matrix4).makeScale(1/r[0],1/r[1],1/r[2]),c=(new i.Matrix4).makeTranslation(a[0],a[1],a[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);t.local.group.applyMatrix4(u);const d=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),h=(new i.Matrix4).makeScale(n[0],n[1],n[2]),p=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),m=(new i.Matrix4).multiplyMatrices(p,h).multiply(d);t.local.group.applyMatrix4(m),t.local.scale=n.slice(),t.local.center=o.slice(),t.wake&&t.wake()},l.Scale.virtual=!0,l.Scale.destroy=()=>{},l.ImageScaled=(e,t)=>{},l.Thickness=async(e,t)=>{t.thickness=await interpretate(e[0],t)},l.AbsoluteThickness=async(e,t)=>{t.thickness=await interpretate(e[0],t)},l.Arrowheads=async(e,t)=>{let n=await interpretate(e[0],t);Array.isArray(n)?(n=n.flat(1/0)[0],t.arrowHeight=280*n,t.arrowRadius=180*n):(t.arrowHeight=280*n,t.arrowRadius=180*n)};const u={Tube:async(e,t)=>{let n=await interpretate(e[0],t),o=1;if(e.length>1&&(o=await interpretate(e[1],t)),t.radius&&(o=t.radius),o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject)n=n.buffer;else if(Array.isArray(n[0]))return void n.forEach(n=>interpretate(["Tube",["JSObject",n],...e.slice(1)],t));let r=[];const a=t.vertices.position.array;for(let e=0;econsole.error("Tube inside Complex does not support updates"),u.Tube.destroy=async(e,t)=>{t.local.tube&&t.local.tube.dispose()},u.Tube.virtual=!0,l.Cone=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=o.map(()=>n)),n[n.length-1]=0;const r=[o[0][0]-o[1][0],o[0][1]-o[1][0],o[0][2]-o[1][2]].map((e,t)=>o[0][t]+1e-4*e);o.unshift(r),n.unshift(1e-6);const a=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});k||(k=await Promise.resolve().then(function(){return j}),k=k.VariableTube);const i=new k(a,o,null,n,16,!1);t.mesh.add(i.mesh),t.local.tube=i,a.dispose()},l.Cone.update=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=o.map(()=>n)),n[n.length-1]=0;const r=[o[0][0]-o[1][0],o[0][1]-o[1][0],o[0][2]-o[1][2]].map((e,t)=>o[0][t]+1e-4*e);o.unshift(r),n.unshift(1e-6),t.local.tube.update(o,n),t.wake(!0)},l.Cone.virtual=!0,l.Cone.destroy=async(e,t)=>{t.local.tube.dispose()},l.Tube=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal());const r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});k||(k=await Promise.resolve().then(function(){return j}),k=k.VariableTube);const a=new k(r,o,null,n,16,!1);t.mesh.add(a.mesh),t.local.tube=a,r.dispose()},l.Tube.update=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);o instanceof NumericArrayObject&&(o=o.normal()),n instanceof NumericArrayObject&&(n=n.normal()),t.local.tube.update(o,n),t.wake(!0)},l.Tube.virtual=!0,l.Tube.destroy=async(e,t)=>{t.local.tube.dispose()},l.TubeArrow=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));const o=await interpretate(e[0],t),r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),a=new i.Vector3(...o[0]),s=new i.Vector3(...o[1]),l=a.clone().addScaledVector(s,-1),c=new i.CylinderGeometry(n,n,l.length(),32,1),u=new i.Mesh(c,r),d=new i.ConeGeometry(t.arrowRadius/100,t.arrowHeight/60,32),h=new i.Mesh(d,r);h.position.y=l.length()/2+t.arrowHeight/120;let p=new i.Group;p.add(u,h);var m=.5*Math.PI,f=s.clone().add(a).divideScalar(2),g=new i.Matrix4,y=new i.Matrix4;return new i.Matrix4,g.lookAt(s,a,new i.Vector3(0,1,0)),y.makeRotationX(m),g.multiply(y),t.local.matrix=p.matrix.clone(),p.applyMatrix4(g),p.position.addScaledVector(f,1),t.local.group=p,t.mesh.add(p),c.dispose(),d.dispose(),r.dispose(),p},l.TubeArrow.update=async(e,t)=>{const n=await interpretate(e[0],t),o=new i.Vector3(...n[0]),r=new i.Vector3(...n[1]);o.clone().addScaledVector(r,-1);var a=.5*Math.PI,s=r.clone().add(o).divideScalar(2),l=new i.Matrix4,c=new i.Matrix4;new i.Matrix4,l.lookAt(r,o,new i.Vector3(0,1,0)),c.makeRotationX(a),l.multiply(c),t.local.matrix.decompose(t.local.group.position,t.local.group.quaternion,t.local.group.scale),t.local.group.matrix.copy(t.local.matrix),t.local.group.applyMatrix4(l),t.local.group.position.addScaledVector(s,1),t.wake(!0)},l.Arrow=async(e,t)=>{let n;if(1===e.length){if("Tube"===e[0][0]||"TubeArrow"===e[0][0])return e[0][0]="TubeArrow",await interpretate(e[0],t);n=await interpretate(e[0],t)}else n=await interpretate(e[0],t);if(1===n.length&&(n=n[0]),n.length>2){var o=new i.BufferGeometry;const e=n.slice(0,-1);o.setAttribute("position",new i.BufferAttribute(new Float32Array(e.flat()),3));const r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1}),a=new i.Line(o,r);t.local.line=a,t.mesh.add(a)}const r=[new i.Vector4(...n[n.length-2],1),new i.Vector4(...n[n.length-1],1)];r.forEach(e=>{e=e.applyMatrix4(t.matrix)});const a=r[0].clone(),s=r[1].add(r[0].negate()),l=s.length(),c=new i.ArrowHelper(s.normalize(),a,l,t.color);return t.mesh.add(c),c.line.material.linewidth=t.thickness,t.local.arrow=c,c},l.Arrow.update=async(e,t)=>{let n;if(1===e.length){if("Tube"===e[0][0]||"TubeArrow"===e[0][0])return console.log("TUBE inside!"),await interpretate(e[0],t);n=await interpretate(e[0],t)}else n=await interpretate(e[0],t),n instanceof NumericArrayObject&&(n=n.normal());if(1===n.length&&(n=n[0]),t.local.line){const e=t.local.line.geometry.getAttribute("position"),o=n.slice(0,-1);e.needsUpdate=!0;for(let t=0;t{e=e.applyMatrix4(t.matrix)}),t.local.arrow.position.copy(o[0]);const r=o[1].add(o[0].negate()),a=r.length();t.local.arrow.setDirection(r.normalize()),t.local.arrow.setLength(a),t.wake(!0)},l.Arrow.destroy=async(e,t)=>{t.local.line&&t.local.line.dispose(),t.local.arrow&&t.local.arrow.dispose()},l.Arrow.virtual=!0,u.Point=async(e,t)=>{let n=await interpretate(e[0],t);const o=new i.BufferGeometry;if(o.setAttribute("position",t.vertices.position),n instanceof NumericArrayObject){const e=n.normal();o.setIndex(e.flat().map(e=>e-1))}else Array.isArray(n)||(n=[n]),o.setIndex(n.flat().map(e=>e-1));let r;t?.vertices?.colored?(o.setAttribute("color",t.vertices.colors),r=new i.PointsMaterial({vertexColors:!0,transparent:t.opacity<1,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112})):r=new i.PointsMaterial({color:t.color,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112}),t.local.material=r;const a=new i.Points(o,r);return t.local.geometry=o,t.mesh.add(a),t.local.points=a,t.local.points},u.Point.virtual=!0,u.Point.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},l.Point=async(e,t)=>{let n=await interpretate(e[0],t);const o=new i.BufferGeometry;let r;n instanceof NumericArrayObject?o.setAttribute("position",new i.Float32BufferAttribute(n.buffer,3)):o.setAttribute("position",new i.Float32BufferAttribute(new Float32Array(n.flat(1/0)),3)),r=new i.PointsMaterial({color:t.color,opacity:t.opacity,size:3.1*t.pointSize/.011111111111111112});const a=new i.Points(o,r);return t.local.geometry=o,t.mesh.add(a),t.local.points=a,t.local.material=r,t.local.points},l.Point.update=async(e,t)=>{let n=await interpretate(e[0],t);return n instanceof NumericArrayObject?t.local.geometry.setAttribute("position",new i.Float32BufferAttribute(n.buffer,3)):t.local.geometry.setAttribute("position",new i.Float32BufferAttribute(n.flat(1/0),3)),t.wake(!0),t.local.points},l.Point.destroy=async(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},l.Point.virtual=!0,l.Sphere=async(e,t)=>{var n=1;e.length>1&&(n=await interpretate(e[1],t));const o=new t.material({color:t.color,roughness:t.roughness,opacity:t.opacity,transparent:t.opacity<1,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});function r(e){const r=new i.Vector4(...e,1),a=new i.SphereGeometry(n,40,40),s=new i.Mesh(a,o);return s.position.set(r.x,r.y,r.z),s.castShadow=t.shadows,s.receiveShadow=t.shadows,t.mesh.add(s),a.dispose(),s}console.log(t.local);let a=await interpretate(e[0],t);return a instanceof NumericArrayObject&&(a=a.normal()),console.log("DRAW A SPHERE"),3===a.length?t.local.object=[r(a)]:(t.local.object=[],a.forEach(e=>{t.local.object.push(r(e))})),o.dispose(),t.local.object},l.Sphere.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[0],t);if(n instanceof NumericArrayObject&&(n=n.normal()),1==t.local.object.length&&(n=[n]),!t.Lerp){let e=0;return void n.forEach(n=>{t.local.object[e].position.set(...n),++e})}if(!t.local.lerp){console.log("creating worker for lerp of movements multiple..");const e={alpha:.05,target:n.map(e=>new i.Vector3(...e)),eval:()=>{for(let n=0;n{console.log("Sphere: destroy")},l.Sphere.virtual=!0,l.Sky=(e,t)=>{const n=new b;n.scale.setScalar(1e4),t.mesh.add(n),t.sky=n,t.sun=new i.Vector3;const o=n.material.uniforms;o.turbidity.value=10,o.rayleigh.value=2,o.mieCoefficient.value=.005,o.mieDirectionalG.value=.8},l._Water=(e,t)=>{const n=new i.PlaneGeometry(1e4,1e4),o=new y(n,{textureWidth:512,textureHeight:512,waterNormals:(new i.TextureLoader).load("textures/waternormals.jpg",function(e){e.wrapS=e.wrapT=i.RepeatWrapping}),sunDirection:new i.Vector3,sunColor:16777215,waterColor:7695,distortionScale:3.7,fog:!0});o.rotation.x=-Math.PI/2,t.mesh.add(o),t.water=o},l.Cube=async(e,t)=>{let n=new i.Vector3(0,0,0),o=new i.Vector3(1,1,1),r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);if("number"==typeof e)o.set(e,e,e);else if(Array.isArray(e))if(3===e.length)e.every(e=>"number"==typeof e)&&n.set(...e);else if(2===e.length){const[t,n]=e;"number"==typeof t&&"number"==typeof n&&(r.z=t,r.y=n)}}const a=new i.BoxGeometry(1,1,1),s=new t.material({color:t.color,transparent:!0,opacity:t.opacity,roughness:t.roughness,depthWrite:!0,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.copy(o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),t.local.geometry=l.geometry.clone(),t.local.box=l,a.dispose(),s.dispose(),l},l.Cube.update=async(e,t)=>{const n=t.local.box;if(!n)return void console.warn("No cube found to update.");let o=new i.Vector3(0,0,0),r=new i.Vector3(1,1,1),a=new i.Euler(0,0,0);for(const n of e){const e=await interpretate(n,t);if("number"==typeof e)r.set(e,e,e);else if(Array.isArray(e))if(3===e.length&&e.every(e=>"number"==typeof e))o.set(...e);else if(2===e.length){const[t,n]=e;"number"==typeof t&&"number"==typeof n&&(a.z=t,a.y=n)}}n.position.copy(o),n.rotation.copy(a),n.geometry.copy(t.local.geometry),n.geometry.applyMatrix4((new i.Matrix4).makeScale(r.x,r.y,r.z)),t.wake(!0)},l.Cube.destroy=async(e,t)=>{t.local.box.geometry.dispose()},l.Cube.virtual=!0,l.Cuboid=async(e,t)=>{var n,o,r;if(2===e.length){var a=[new i.Vector4(...await interpretate(e[1],t),1),new i.Vector4(...await interpretate(e[0],t),1)];o=a[0].clone().add(a[1]).divideScalar(2),n=a[0].clone().add(a[1].clone().negate())}else{if(1!==e.length)return void console.error("Expected 2 or 1 arguments");r=await interpretate(e[0],t),o=new i.Vector4(...r,1),n=new i.Vector4(1,1,1,1),o.add(n.clone().divideScalar(2))}const s=new i.BoxGeometry(1,1,1),l=new t.material({color:t.color,transparent:!0,opacity:t.opacity,roughness:t.roughness,depthWrite:!0,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),c=new i.Mesh(s,l);return c.position.set(o.x,o.y,o.z),t.local.geometry=c.geometry.clone(),c.geometry.applyMatrix4((new i.Matrix4).makeScale(n.x,n.y,n.z)),c.receiveShadow=t.shadows,c.castShadow=t.shadows,t.mesh.add(c),t.local.box=c,s.dispose(),l.dispose(),c},l.Cuboid.update=async(e,t)=>{var n,o,r;if(2===e.length){var a=[new i.Vector4(...await interpretate(e[1],t),1),new i.Vector4(...await interpretate(e[0],t),1)];o=a[0].clone().add(a[1]).divideScalar(2),n=a[0].clone().add(a[1].clone().negate())}else r=await interpretate(e[0],t),o=new i.Vector4(...r,1),n=new i.Vector4(1,1,1,1),o.add(n.clone().divideScalar(2));console.log(n.x,n.y,n.z),t.local.box.position.copy(o),t.local.box.geometry.copy(t.local.geometry),t.local.box.geometry.applyMatrix4((new i.Matrix4).makeScale(n.x,n.y,n.z)),t.wake(!0)},l.Cuboid.destroy=async(e,t)=>{t.local.box.geometry.dispose()},l.Cuboid.virtual=!0,l.Center=(e,t)=>"Center",l.Cylinder=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);1===o.length&&(o=o[0]),o[0]=new i.Vector3(...o[0]),o[1]=new i.Vector3(...o[1]);const r=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});console.log(o);var a=(new i.Vector3).subVectors(o[1],o[0]);console.log(a);var s=new i.CylinderGeometry(n,n,1,32,4,!1);s.applyMatrix4((new i.Matrix4).makeTranslation(0,.5,0)),s.applyMatrix4((new i.Matrix4).makeRotationX(i.MathUtils.degToRad(90)));var l=new i.Mesh(s,r);l.receiveShadow=t.shadows,l.castShadow=t.shadows,l.position.copy(o[0]),t.local.g=l.geometry.clone(),l.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,a.length())),l.geometry.lookAt(a),t.local.cylinder=l,t.mesh.add(l)},l.Cylinder.update=async(e,t)=>{let n=await interpretate(e[0],t);1===n.length&&(n=n[0]),n[0]=new i.Vector3(...n[0]),n[1]=new i.Vector3(...n[1]);var o=(new i.Vector3).subVectors(n[1],n[0]);t.local.cylinder.position.copy(n[0]),t.local.cylinder.geometry.copy(t.local.g),t.local.cylinder.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,o.length())),t.local.cylinder.geometry.lookAt(o),t.wake(!0)},l.Cylinder.destroy=async(e,t)=>{t.local.cylinder.geometry.dispose(),t.local.g.dispose()},l.Cylinder.virtual=!0,l.Octahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.OctahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Tetrahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.TetrahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Icosahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.IcosahedronGeometry(1),s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Translate=async(e,t)=>{let n=new i.Group,o=await interpretate(e[1],t);o instanceof NumericArrayObject&&(o=o.normal());let r=Object.assign({},t);r.mesh=n,await interpretate(e[0],r),n.translateX(o[0]),n.translateY(o[1]),n.translateZ(o[2]),t.local.mesh=n,t.mesh.add(n)},l.Translate.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.mesh;if(t.Lerp){if(!t.local.lerp){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{o.position.lerp(e.target,.05)}};t.local.lerp=e,t.Handlers.push(e)}t.local.lerp.target.fromArray(n)}else o.position.set(n[0],n[1],n[2])},l.Translate.virtual=!0,l.Translate.destroy=(e,t)=>{t.local.mesh.removeFromParent()},l.LookAt=async(e,t)=>{const n=new i.Group,o=await interpretate(e[1],t);await interpretate(e[0],{...t,mesh:n});let r=(new i.Box3).setFromObject(n),a=r.max.clone().add(r.min).divideScalar(2);console.log("center: "),console.log(a);let l=(new i.Matrix4).makeTranslation(-a.x,-a.y,-a.z);n.applyMatrix4(l),n.lookAt(...o),n.rotation.x=s.PI/2,l=(new i.Matrix4).makeTranslation(a.x,a.y,a.z),n.applyMatrix4(l),t.local.group=n,t.mesh.add(n)},l.LookAt.update=async(e,t)=>{t.wake(!0);const n=await interpretate(e[1],t);t.local.group.lookAt(...n)},l.LookAt.virtual=!0;const d=(e,t)=>{let n=[];switch(t.local.type||(2==e.length?(console.warn("apply matrix3x3 + translation"),t.local.type="complex"):Array.isArray(e[0])?(t.local.type="normal",console.warn("apply matrix 3x3")):(console.warn("apply translation"),t.local.type="translation")),t.local.type){case"normal":n=e.map(e=>[...e,0]),n.push([0,0,0,1]),n=(new i.Matrix4).set(...aflatten(n));break;case"translation":n=(new i.Matrix4).makeTranslation(...e);break;case"complex":n=[...e[0]];const t=[...e[1]];n[0].push(t[0]),n[1].push(t[1]),n[2].push(t[2]),n.push([0,0,0,1]),n=(new i.Matrix4).set(...aflatten(n));break;default:throw"undefined type of matrix or vector"}return n};var h;function p(e){return new Promise(t=>setTimeout(t,e))}function m(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/(\S)_(\{([^{}]+)\}|([^\s{}]))/g,(e,t,n,o,r)=>t+""+(o??r)+"").replace(/(\S)\^(\{([^{}]+)\}|([^\s{}]))/g,(e,t,n,o,r)=>t+""+(o??r)+"")}l.Rotate=async(e,t)=>{let n=await interpretate(e[1],t),o=[0,0,1];e.length>2&&(o=await interpretate(e[2],t)),o instanceof NumericArrayObject&&(o=o.normal());const r=new i.Group;return await interpretate(e[0],{...t,mesh:r}),o=new i.Vector3(...o),r.rotateOnWorldAxis(o,n),t.mesh.add(r),t.local.group=r,t.local.angle=n,t.local.dir=o,r},l.Rotate.update=async(e,t)=>{let n=await interpretate(e[1],t);const o=n-t.local.angle;if(t.local.angle=n,e.length>2){let n=await interpretate(e[2],t);n instanceof NumericArrayObject&&(n=n.normal()),t.local.dir.fromArray(n),t.local.group.rotateOnWorldAxis(t.local.dir,o)}else t.local.group.rotateOnWorldAxis(t.local.dir,o);t.wake()},l.Rotate.virtual=!0,l.Rotate.destroy=(e,t)=>{},l.Scale=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal()),2===n.length&&(n=[n[0],n[1],1]),1===n.length&&(n=[n[0],n[0],n[0]]);const r=new i.Group;await interpretate(e[0],{...t,mesh:r});const a=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),s=(new i.Matrix4).makeScale(n[0],n[1],n[2]),l=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),c=(new i.Matrix4).multiplyMatrices(l,s).multiply(a);return r.applyMatrix4(c),t.mesh.add(r),t.local.group=r,t.local.scale=n.slice(),t.local.center=o.slice(),r},l.Scale.update=async(e,t)=>{let n=await interpretate(e[1],t),o=e.length>2?await interpretate(e[2],t):[0,0,0];n instanceof NumericArrayObject&&(n=n.normal()),Array.isArray(n)||(n=[n,n,n]),o instanceof NumericArrayObject&&(o=o.normal()),2===n.length&&(n=[n[0],n[1],1]),1===n.length&&(n=[n[0],n[0],n[0]]);const r=t.local.scale||[1,1,1],a=t.local.center||[0,0,0],s=(new i.Matrix4).makeTranslation(-a[0],-a[1],-a[2]),l=(new i.Matrix4).makeScale(1/r[0],1/r[1],1/r[2]),c=(new i.Matrix4).makeTranslation(a[0],a[1],a[2]),u=(new i.Matrix4).multiplyMatrices(c,l).multiply(s);t.local.group.applyMatrix4(u);const d=(new i.Matrix4).makeTranslation(-o[0],-o[1],-o[2]),h=(new i.Matrix4).makeScale(n[0],n[1],n[2]),p=(new i.Matrix4).makeTranslation(o[0],o[1],o[2]),m=(new i.Matrix4).multiplyMatrices(p,h).multiply(d);t.local.group.applyMatrix4(m),t.local.scale=n.slice(),t.local.center=o.slice(),t.wake&&t.wake()},l.Scale.virtual=!0,l.Scale.destroy=(e,t)=>{},l.GeometricTransformation=async(e,t)=>{let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),n.length>3){console.warn("multiple matrixes"),t.local.entities=[];for(const o of n){const n=new i.Group,r=d(o,t);await interpretate(e[0],{...t,mesh:n}),n.matrixAutoUpdate=!1;const a={};a.quaternion=new i.Quaternion,a.position=new i.Vector3,a.scale=new i.Vector3,r.decompose(a.position,a.quaternion,a.scale),n.quaternion.copy(a.quaternion),n.position.copy(a.position),n.scale.copy(a.scale),n.updateMatrix(),a.group=n,t.mesh.add(n),t.local.entities.push(a)}return t.local.entities[0]}{console.warn("single matrix");const o=new i.Group,r=d(n,t);return await interpretate(e[0],{...t,mesh:o}),o.matrixAutoUpdate=!1,t.local.quaternion=new i.Quaternion,t.local.position=new i.Vector3,t.local.scale=new i.Vector3,r.decompose(t.local.position,t.local.quaternion,t.local.scale),o.quaternion.copy(t.local.quaternion),o.position.copy(t.local.position),o.scale.copy(t.local.scale),o.updateMatrix(),t.local.group=o,t.mesh.add(o),o}},l.GeometricTransformation.update=async(e,t)=>{t.wake(!0);let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),t.local.entities){console.log("multiple matrixes");for(let e=0;e{console.warn("Nothing to dispose!")},l.Entity=()=>{console.log("Entity is not supported inside Graphics3D")},l.GeometricTransformation.virtual=!0,l.GraphicsComplex=async(e,t)=>{var n=Object.assign({},t);const o=await core._getRules(e,{...t,hold:!0});let r,a=await interpretate(e[0],n);a instanceof NumericArrayObject?r=new Float32Array(a.buffer):(a=a.flat(),r=new Float32Array(a)),n.vertices={position:new i.BufferAttribute(r,3),colored:!1,onResize:[],handlers:[]},t.local.vertices=n.vertices;let s=[];if(t.local.fence=()=>{for(const e of s)e.resolve();s=[]},"VertexFence"in o&&(n.fence=()=>{const e=new Deferred;return s.push(e),e.promise}),"VertexColors"in o){let e=await interpretate(o.VertexColors,t);n.vertices.colored=!0,e instanceof NumericArrayObject?n.vertices.colors=new i.BufferAttribute(new Float32Array(e.buffer),3):(e[0]?.isColor&&(e=e.map(e=>[e.r,e.g,e.b])),n.vertices.colors=new i.BufferAttribute(new Float32Array(e.flat()),3))}if("VertexNormals"in o){const e=await interpretate(o.VertexNormals,t);e instanceof NumericArrayObject?n.vertices.normals=new i.BufferAttribute(new Float32Array(e.buffer),3):n.vertices.normals=new i.BufferAttribute(new Float32Array(e.flat()),3)}const c=new i.Group;t.local.group=c,n.context=[u,l],await interpretate(e[1],n),t.mesh.add(c)},l.Reflectivity=()=>{console.warn("not implemented")},l.GraphicsComplex.update=async(e,t)=>{t.wake(!0);let n,o=await interpretate(e[0],t);n=o instanceof NumericArrayObject?new Float32Array(o.buffer):new Float32Array(o.flat()),3*t.local.vertices.position.counte(t.local.vertices))),t.local.vertices.position.set(n),t.local.vertices.position.needsUpdate=!0;let r=!1;if(t.local.vertices.normals){r||(r=await core._getRules(e,{...t,hold:!0}));const n=await interpretate(r.VertexNormals,t);n instanceof NumericArrayObject?t.local.vertices.normals.set(new Float32Array(n.buffer)):t.local.vertices.normals.set(new Float32Array(n.flat())),t.local.vertices.normals.needsUpdate=!0}if(t.local.vertices.colored){r||(r=await core._getRules(e,{...t,hold:!0}));const n=await interpretate(r.VertexColors,t);n instanceof NumericArrayObject?t.local.vertices.colors.set(new Float32Array(n.buffer)):t.local.vertices.colors.set(new Float32Array(n.flat())),t.local.vertices.colors.needsUpdate=!0}for(let e=0;e{},l.GraphicsComplex.virtual=!0,u.Cylinder=async(e,t)=>{let n=1;e.length>1&&(n=await interpretate(e[1],t));let o=await interpretate(e[0],t);1===o.length&&(o=o[0]);const r=t.vertices.position.array;let a=3*(o[0]-1);o[0]=new i.Vector3(r[a],r[a+1],r[a+2]),a=3*(o[1]-1),o[1]=new i.Vector3(r[a],r[a+1],r[a+2]);const s=new t.material({color:t.color,transparent:t.opacity<1,roughness:t.roughness,opacity:t.opacity,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});console.log(o);var l=(new i.Vector3).subVectors(o[1],o[0]);console.log(l);var c=new i.CylinderGeometry(n,n,1,32,4,!1);c.applyMatrix4((new i.Matrix4).makeTranslation(0,.5,0)),c.applyMatrix4((new i.Matrix4).makeRotationX(i.MathUtils.degToRad(90)));var u=new i.Mesh(c,s);u.receiveShadow=t.shadows,u.castShadow=t.shadows,u.position.copy(o[0]),u.geometry.clone(),u.geometry.applyMatrix4((new i.Matrix4).makeScale(1,1,l.length())),u.geometry.lookAt(l),t.mesh.add(u)},u.Sphere=async(e,t)=>{var n=1;e.length>1&&(n=await interpretate(e[1],t));const o=new t.material({color:t.color,roughness:t.roughness,opacity:t.opacity,transparent:t.opacity<1,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});function r(e){const r=new i.Vector3(...e),a=new i.SphereGeometry(n,40,40),s=new i.Mesh(a,o);return s.position.set(r.x,r.y,r.z),s.castShadow=t.shadows,s.receiveShadow=t.shadows,t.mesh.add(s),a.dispose(),s}let a=await interpretate(e[0],t);a instanceof NumericArrayObject&&(a=a.normal());const s=t.vertices.position.array;if(Array.isArray(a)){t.local.object=[];for(let e=0;e{var n;let o;n=new i.BufferGeometry,t.local.geometry=n,n.setAttribute("position",t.vertices.position),t.vertices.onResize.push(e=>u.Polygon.reassign(e,t.local));let r,a=await interpretate(e[0],t);if(a instanceof NumericArrayObject)switch(a.dims.length){case 1:console.warn("Odd case of polygons data..."),n.setIndex(a.normal().map(e=>e-1));break;case 2:switch(a.dims[a.dims.length-1]){case 3:r=new i.BufferAttribute(new Uint16Array(a.buffer.map(e=>e-1)),1);break;case 4:{const e=a.buffer.length,t=a.buffer,n=new Uint16Array(2*e);let o=0,s=0;for(;o1){let o=await interpretate(e[1],t);if("number"!=typeof o)return console.warn(e),void console.error("Unknow case for Polygon");n.setDrawRange(a-1,o),t.local.indexOffset=a-1,t.local.range=o,t.local.nonindexed=!0}else if(3===a[0].length&&3===a[a.length-1].length)r=t.vertices.position.array.length>65535?new i.BufferAttribute(new Uint32Array(a.flat().map(e=>e-1)),1):new i.BufferAttribute(new Uint16Array(a.flat().map(e=>e-1)),1);else{let e=[];if(Array.isArray(a[0]))for(let n=0;no[e]))}}else switch(a.length){case 3:e.push(...a);break;case 4:e.push(a[0],a[1],a[2]),e.push(a[0],a[2],a[3]);break;case 5:e.push(a[0],a[1],a[4]),e.push(a[1],a[2],a[3]),e.push(a[1],a[3],a[4]);break;case 6:e.push(a[0],a[1],a[5]),e.push(a[1],a[2],a[5]),e.push(a[5],a[2],a[4]),e.push(a[2],a[3],a[4]);break;default:const n=t.vertices.position.array;h||(h=(await Promise.resolve().then(function(){return pe})).default),console.warn("earcut");const o=[];for(let e=0;ea[e]))}console.log("Set Index"),e=e.flat(),t.local.range=e.length,r=t.vertices.position.array.length>65535?new i.Uint32BufferAttribute(new Uint32Array(e.map(e=>e-1)),1):new i.Uint16BufferAttribute(new Uint16Array(e.map(e=>e-1)),1)}}r&&(n.setIndex(r),r.needsUpdate=!0),t.local.indexes=r,t?.vertices?.normals?(t.local.geometry.setAttribute("normal",t.vertices.normals),t.local.normals=!0):(t.vertices.handlers.push(()=>{t.local.geometry.computeVertexNormals()}),t.local.geometry.computeVertexNormals()),t?.vertices?.colored?(n.setAttribute("color",t.vertices.colors),o=new t.material({vertexColors:!0,transparent:t.opacity<1,opacity:t.opacity,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte,side:i.DoubleSide})):o=new t.material({color:t.color,transparent:t.opacity<1,opacity:t.opacity,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte,side:i.DoubleSide}),o.side=i.DoubleSide;const s=new i.Mesh(n,o);return s.receiveShadow=t.shadows,s.castShadow=!0,t.mesh.add(s),t.local.material=o,t.local.poly=s,s},u.Polygon.reassign=(e,t)=>{console.warn("Reassign geometry of Polygon");const n=t.geometry;n.setAttribute("position",e.position),e.colored&&n.setAttribute("color",e.colors),t.normals&&n.setAttribute("normal",e.normals),t.nonindexed&&n.setDrawRange(t.indexOffset,t.range)},u.Polygon.update=async(e,t)=>{if(t.fence&&await t.fence(),t.local.nonindexed){const n=await interpretate(e[0],t),o=await interpretate(e[1],t);return t.local.indexOffset=n-1,t.local.range=o,3*t.vertices.position.count<3*o||t.local.geometry.setDrawRange(n-1,o),o<1e5&&(t.local.geometry.computeBoundingBox(),t.local.geometry.computeBoundingSphere()),void t.wake(!0)}let n,o=await interpretate(e[0],t);if(o instanceof NumericArrayObject)switch(o.dims[o.dims.length-1]){case 3:n=new Uint16Array(o.buffer.map(e=>e-1));break;case 4:{const e=o.buffer.length,t=o.buffer;n=new Uint16Array(2*e);let r=0,a=0;for(;re-1));break;case 4:{o=o.flat(1/0);const e=o.length,t=o;n=new Uint16Array(2*e);let r=0,a=0;for(;r3e4?Uint32Array:Uint16Array,o=i.BufferAttribute,r=new e(2*n.length);r.set(n);const a=new o(r,1);a.setUsage(i.StreamDrawUsage),a.needsUpdate=!0,t.local.indexes=a,t.local.geometry.setIndex(a),t.local.geometry.setDrawRange(0,n.length)}else t.local.indexes.set(n),t.local.indexes.needsUpdate=!0,t.local.geometry.setDrawRange(0,n.length);t.local.geometry.computeBoundingBox(),t.local.geometry.computeBoundingSphere()},u.Polygon.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},u.Polygon.virtual=!0,l.Polygon=async(e,t)=>{const n=await interpretate(e[0],t);if(Array.isArray(n)&&Array.isArray(n[0][0])){t.local.vmulti=!0;for(const e of n)await interpretate(["Polygon",["JSObject",e]],{...t});return}let o=n.length;n instanceof NumericArrayObject&&(o=n.dims[0]);const r=Array.from({length:o},(e,t)=>t+1),a={};t.local.indices=r,t.local.vertices=n,await interpretate(["GraphicsComplex",["__takeJSProperty",t.local,"vertices"],["Polygon",["__takeJSProperty",t.local,"indices"]],["Rule","'VertexFence'",!0]],{...t,global:{...t.global,stack:a}}),t.local.virtualStack=a,t.local.vpoly=Object.values(t.local.virtualStack).find(e=>"Polygon"==e.firstName),t.local.vcomplex=Object.values(t.local.virtualStack).find(e=>"GraphicsComplex"==e.firstName),t.local.vpoly.parent=void 0},l.__takeJSProperty=(e,t)=>e[0][e[1]],l.__takeJSProperty.update=l.__takeJSProperty,l.__takeJSProperty.destroy=l.__takeJSProperty,l.Polygon.update=async(e,t)=>{if(t.local.vmulti)throw"update of multiple polygons is not possible";const n=await interpretate(e[0],t);let o=n.length;n instanceof NumericArrayObject&&(o=n.dims[0]);const r=Array.from({length:o},(e,t)=>t+1);t.local.indices=r,t.local.vertices=n,t.local.vpoly.update(),await t.local.vcomplex.update()},l.Polygon.virtual=!0,l.Polygon.destroy=(e,t)=>{if(!t.local.vmulti)for(const e of Object.values(t.local.virtualStack))e.dispose()},l.Dodecahedron=async(e,t)=>{let n=new i.Vector3(0,0,0),o=1,r=new i.Euler(0,0,0);for(const a of e){const e=await interpretate(a,t);"number"==typeof e?o=e:Array.isArray(e)&&(3===e.length&&e.every(e=>"number"==typeof e)?n.set(...e):2===e.length&&e.every(e=>"number"==typeof e)&&(r.z=e[0],r.y=e[1]))}const a=new i.DodecahedronGeometry(1),s=new t.material({color:t.color,transparent:!0,opacity:t.opacity,depthWrite:!0,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte}),l=new i.Mesh(a,s);return l.position.copy(n),l.scale.set(o,o,o),l.rotation.copy(r),l.receiveShadow=t.shadows,l.castShadow=t.shadows,t.mesh.add(l),a.dispose(),s.dispose(),l},l.Polyhedron=async(e,t)=>{if(e[1][1].length>4)return await interpretate(["GraphicsComplex",e[0],["Polygon",e[1]]],t);{const o=await interpretate(e[1],t).flat(4).map(e=>e-1),r=await interpretate(e[0],t).flat(4),a=new i.PolyhedronGeometry(r,o);var n=new t.material({color:t.color,transparent:!0,opacity:t.opacity,depthWrite:!0,roughness:t.roughness,metalness:t.metalness,emissive:t.emissive,emissiveIntensity:t.emissiveIntensity,ior:t.ior,transmission:t.transmission,thinFilm:t.thinFilm,thickness:t.materialThickness,attenuationColor:t.attenuationColor,attenuationDistance:t.attenuationDistance,clearcoat:t.clearcoat,clearcoatRoughness:t.clearcoatRoughness,sheenColor:t.sheenColor,sheenRoughness:t.sheenRoughness,iridescence:t.iridescence,iridescenceIOR:t.iridescenceIOR,iridescenceThickness:t.iridescenceThickness,specularColor:t.specularColor,specularIntensity:t.specularIntensity,matte:t.matte});const s=new i.Mesh(a,n);return s.receiveShadow=t.shadows,s.castShadow=t.shadows,t.mesh.add(s),a.dispose(),n.dispose(),s}},l.Specularity=(e,t)=>{},l.Inset=async(e,t)=>{let n,o=[0,0,0];const r=await core._getRules(e,t),a=Object.keys(r).length;e.length-a>1&&(o=await interpretate(e[1],t)),o instanceof NumericArrayObject&&(o=o.normal()),e.length-a>2&&await interpretate(e[2],t);const s=document.createElement("div");let c=new C.CSS2DObject(s);c.className="g3d-label",t.mesh.add(c),t.local.object=c;const u={};t.local.stack=u;const d={global:{...t.global,stack:u},inset:!0,element:s,context:l};return r.ImageSizeRaw&&(n=r.ImageSizeRaw),n&&(s.style.width=n[0]+"px",s.style.height=n[1]+"px"),async function(){let r=!1;"HoldForm"==e[0][0]&&(Array.isArray(e[0][1])&&"Offload"==e[0][1][0]||(r=!0));try{r||await interpretate(e[0],d)}catch(e){console.warn(e),r=!0}r&&await w(e[0],d);const a=s;await p(60);if((a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height)<10)for(let e=0;e<20&&(await p(300),!((a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height)>30));++e);let l={width:a.offsetWidth||a.firstChild?.offsetWidth||a.firstChild?.width,height:a.offsetHeight||a.firstChild?.offsetHeight||a.firstChild?.height};if(l.width instanceof SVGAnimatedLength&&(l.width=l.width.animVal.valueInSpecifiedUnits),l.height instanceof SVGAnimatedLength&&(l.height=l.height.animVal.valueInSpecifiedUnits),(l.width<1||!l.width)&&l.height>1){const e=a.getElementsByClassName("cm-scroller");e.length>0?l.width=e[0].firstChild.offsetWidth:l.width=1.66*l.height}n||(s.style.width=l.width+"px",s.style.height=l.height+"px"),t.local.box=l,c.position.copy(new i.Vector3(...o))}(),c},l.Inset.update=async(e,t)=>{let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.object;return o&&o.position.copy(new i.Vector3(...n)),t.wake(),o},l.Inset.destroy=async(e,t)=>{Object.values(t.local.stack).forEach(e=>{e.dead||e.dispose()})},l.Inset.virtual=!0,l.Text=async(e,t)=>{const n=document.createElement("span");let o;n.className="g3d-label";try{o=await interpretate(e[0],t)}catch(n){console.warn("Error interpreting input of Text. Could it be an undefined symbol?");const o=document.createElement("span");let r=new C.CSS2DObject(o);return o.className="g3d-label",r.position.copy(new i.Vector3(...await interpretate(e[1],t))),t.mesh.add(r),await w(e[0],{...t,element:o}),r}t.fontweight&&(n.style.fontWeight=t.fontweight),t.fontSize&&(n.style.fontSize=t.fontSize+"px"),t.fontFamily&&(n.style.fontFamily=t.fontFamily),t.colorInherit||(n.style.color=t.color.getStyle());let r=await interpretate(e[1],t);r instanceof NumericArrayObject&&(r=r.normal()),n.innerHTML=m(String(o)),t.local.text=n;const a=new C.CSS2DObject(n);a.position.copy(new i.Vector3(...r)),t.local.labelObject=a,t.mesh.add(a)},l.Text.update=async(e,t)=>{let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal());const o=await interpretate(e[0],t);t.local.text.innerHTML=m(String(o)),t.local.labelObject.position.copy(new i.Vector3(...n)),t.wake()},l.Text.destroy=()=>{},l.Text.virtual=!0;const f=["color","emissive","emissiveIntensity","roughness","metalness","ior","transmission","thinFilm","materialThickness","attenuationColor","attenuationDistance","opacity","clearcoat","clearcoatRoughness","sheenColor","sheenRoughness","iridescence","iridescenceIOR","iridescenceThickness","specularColor","specularIntensity","matte","flatShading","castShadow","shadows","fontSize"];let g;l.Directive=async(e,t)=>{const n=await core._getRules(e,{...t,hold:!0});if("List"==e[0][0])for(let n=1;n{},u.Arrow=async(e,t)=>{if(e.length>1&&(t.radius=.7*await interpretate(e[1],t)),"Tube"==e[0][0]){const n=await interpretate(e[0][1],t);if(Array.isArray(n[0]))n.forEach(e=>{const n=t.radius||1,o=e.map(()=>n);o[o.length-1]=.4*n,interpretate(["Tube",["JSObject",e],["JSObject",o]],{...t,radius:o})});else{const e=t.radius||1,o=n.map(()=>e);o[o.length-1]=.4*e,interpretate(["Tube",["JSObject",n],["JSObject",o]],{...t,radius:o})}}},u.Line=async(e,t)=>{let n=new i.BufferGeometry;n.setAttribute("position",t.vertices.position),t.local.geometry=n,t.vertices.onResize.push(e=>u.Line.reassign(e,t.local));let o,r,a=await interpretate(e[0],t);a instanceof NumericArrayObject&&(a=a.buffer),o=t.vertices.position.array.length>65535?new i.Uint32BufferAttribute(new Uint32Array(a.map(e=>e-1)),1):new i.BufferAttribute(new Uint16Array(a.map(e=>e-1)),1),t.local.indexes=o,n.setIndex(o),t.local.range=a.length,t?.vertices?.colored?(n.setAttribute("color",t.vertices.colors),r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,vertexColors:!0,transparent:t.opacity<1})):r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1});const s=new i.Line(n,r);return t.local.line=s,t.mesh.add(s),t.local.material=r,s},u.Line.virtual=!0,u.Line.update=async(e,t)=>{t.fence&&await t.fence();let n=await interpretate(e[0],t);n instanceof NumericArrayObject&&(n=n.buffer),n=n.map(e=>e-1),t.local.range=n.length;const o=t.local.geometry,r=t.local.indexes;if(r.count3e4,r=e?Uint32Array:Uint16Array,a=new(e?i.Uint32BufferAttribute:i.Uint16BufferAttribute)(new r(2*n.length),1);a.setUsage(i.StreamDrawUsage),a.set(n),a.needsUpdate=!0,o.setIndex(a),t.local.indexes=a}else r.set(n),r.needsUpdate=!0;o.setDrawRange(0,t.local.range),t.wake(!0)},u.Line.destroy=(e,t)=>{t.local.geometry.dispose(),t.local.material.dispose()},u.Line.reassign=(e,t)=>{console.warn("Reassign geometry of Line");const n=t.geometry;n.setAttribute("position",e.position),e.colored&&n.setAttribute("color",e.colors),n.setIndex(t.indexes),n.setDrawRange(0,t.range)},l.Line=async(e,t)=>{var n;const o=await interpretate(e[0],t);if(o instanceof NumericArrayObject)(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(o.buffer),3));else{if(0==o.length)return;if(Array.isArray(o[0][0])){console.log("Multiple");const e=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1});for(const r of o){(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(r.flat()),3));const o=new i.Line(n,e);t.local.lines||(t.local.lines=[]),t.local.lines.push(o),t.mesh.add(o)}return void e.dispose()}(n=new i.BufferGeometry).setAttribute("position",new i.BufferAttribute(new Float32Array(o.flat()),3))}const r=new i.LineBasicMaterial({linewidth:t.thickness,color:t.color,opacity:t.opacity,transparent:t.opacity<1}),a=new i.Line(n,r);return t.local.line=a,t.mesh.add(a),t.local.line.geometry.computeBoundingBox(),a},l.Line.update=async(e,t)=>{if(t.local.lines)throw"update of multiple lines is not supported!";let n=await interpretate(e[0],t);n instanceof NumericArrayObject&&(n=n.normal());const o=t.local.line.geometry.getAttribute("position");o.needsUpdate=!0;for(let e=0;e{t.local.line&&t.local.line.geometry.dispose(),t.local.lines&&t.local.lines.forEach(e=>e.geometry.dispose())},l.Line.virtual=!0,l.ImageSize=()=>"ImageSize",l.Background=()=>"Background",l.AspectRatio=()=>"AspectRatio",l.Lighting=()=>"Lighting",l.Default=()=>"Default",l.None=()=>!1,l.Lightmap=()=>"Lightmap",l.Automatic=()=>"Automatic",l.AnimationFrameListener=async(e,t)=>{await interpretate(e[0],t);const n=await core._getRules(e,{...t,hold:!0});t.local.event=await interpretate(n.Event,t);const o={state:!0,eval:()=>{t.local.worker.state&&(server.kernel.io.poke(t.local.event),t.local.worker.state=!1)}};t.local.worker=o,t.Handlers.push(o)},l.AnimationFrameListener.update=async(e,t)=>{t.local.worker.state=!0},l.AnimationFrameListener.destroy=async(e,t)=>{console.warn("AnimationFrameListener does not exist anymore"),t.local.worker.eval=()=>{}},l.AnimationFrameListener.virtual=!0;let y=!1,b=!1;l.Camera=(e,t)=>{console.warn("temporary disabled")},l.LightProbe=(e,t)=>{},l.DefaultLighting=(e,t)=>{console.warn("temporary disabled")},l.SkyAndWater=async(e,t)=>{console.warn("temporary disabled")},l.Sky=async(e,t)=>{console.warn("temporary disabled")};const w=async(e,t={global:{}})=>{const n=String(interpretate.hash(e));let o,r;if(n in ObjectHashMap)o=ObjectHashMap[n];else{o=new ObjectStorage(n);try{r=await o.get()}catch(t){console.warn("Creating FE object by id "+n),await server.kernel.io.fetch("CoffeeLiqueur`Extensions`Graphics3D`Private`MakeExpressionBox",[JSON.stringify(e),n]),r=await o.get()}}r||(r=await o.get()),console.log("g3d: creating an object"),console.log("frontend executable");const a=t,i=new ExecutableObject("g3d-embeded-"+uuidv4(),a,r,!0);return i.assignScope(a),o.assign(i),await i.execute(),i};l["CoffeeLiqueur`Extensions`Graphics3D`Tools`WaterShader"]=async(e,t)=>{y||(await interpretate.shared.THREEWater.load(),y=interpretate.shared.THREEWater.Water);let n,o=await core._getRules(e,t);console.log("options:"),console.log(o),o.dims=o.Size||[1e4,1e4];const r=new i.PlaneGeometry(...o.dims);n=new y(r,{textureWidth:512,textureHeight:512,waterNormals:(new i.TextureLoader).load("https://cdn.statically.io/gh/JerryI/Mathematica-ThreeJS-graphics-engine/master/assets/waternormals.jpg",function(e){e.wrapS=e.wrapT=i.RepeatWrapping}),sunDirection:new i.Vector3(1,1,1),sunColor:16777215,waterColor:7695,distortionScale:3.7,fog:!0}),n.rotation.x=-Math.PI/2,t.local.water=n,t.global.scene.add(n);const a=t.local.sun||new i.Vector3(1,1,1);n.material.uniforms.sunDirection.value.copy(a).normalize(),t.local.handlers.push(function(){t.local.water.material.uniforms.time.value+=1/60})},l.Large=(e,t)=>1,l.Medium=(e,t)=>.7,l.Small=(e,t)=>.4;const v=async(e,t)=>{let n;e.ImageSize?(n=await interpretate(e.ImageSize,t),"number"==typeof n?n<10&&(n=2*core.DefaultWidth*n):n instanceof Array||(n=core.DefaultWidth),n instanceof Array||(n=[n,.618034*n])):n=t.imageSize?Array.isArray(t.imageSize)?t.imageSize:[t.imageSize,.618034*t.imageSize]:[core.DefaultWidth,.618034*core.DefaultWidth];if(function(){if(null!=navigator.userAgentData?.mobile)return navigator.userAgentData.mobile;const e=window.matchMedia?.("(pointer: coarse)").matches,t=window.matchMedia?.("(max-width: 768px)").matches,n=navigator.maxTouchPoints>0;return!(!e||!n&&!t)||/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}()){console.warn("Mobile device detected!");const e=2/devicePixelRatio;n[0]=n[0]*e,n[0]>250&&(n[0]=250),n[1]=n[1]*e}return n};let x=!1;l.PointLight=async(e,t)=>{const n={...t};let o=[0,0,10],r=16777215;const a=await core._getRules(e,t),s=Object.keys(a).length;t.local.olength=s,e.length-s>0&&(r=await interpretate(e[0],n)),e.length-s>1&&(o=await interpretate(e[1],t),o instanceof NumericArrayObject&&(o=o.normal()));let l=100,c=0,u=2;"number"==typeof a.Intensity&&(l=a.Intensity),"number"==typeof a.Distance&&(c=a.Distance),"number"==typeof a.Decay&&(u=a.Decay);const d=new i.PointLight(r,l,c,u);return d.castShadow=t.shadows,d.position.set(...o),d.shadow.bias=-.01,"number"==typeof a.ShadowBias&&(d.shadow.bias=a.ShadowBias),t.local.light=d,t.mesh.add(d),d},l.PointLight.update=async(e,t)=>{if(t.wake(!1,!0),e.length-t.local.olength>1){let n=await interpretate(e[1],t);n instanceof NumericArrayObject&&(n=n.normal()),t.local.light.position.set(...n)}},l.PointLight.destroy=(e,t)=>{t.local.light.dispose()},l.PointLight.virtual=!0,l.DirectionalLight=async(e,t)=>{const n={...t};let o=[0,0,10],r=[0,0,0],a=16777215;const s=await core._getRules(e,t),l=Object.keys(s).length;t.local.olength=l,e.length-l>0&&(a=await interpretate(e[0],n)),e.length-l>1&&(o=await interpretate(e[1],t),o instanceof NumericArrayObject&&(o=o.normal()),2==o.length&&(r=o[1],o=o[0]));let c=2;"number"==typeof s.Intensity&&(c=s.Intensity);const u=new i.DirectionalLight(a,c);return u.castShadow=t.shadows,u.position.set(...o),u.target.position.set(...r),u.shadow.bias=-.01,"number"==typeof s.ShadowBias&&(u.shadow.bias=s.ShadowBias),u.shadow.mapSize.height=1024,u.shadow.mapSize.width=1024,"number"==typeof s.ShadowMapSize&&(u.shadow.mapSize.height=s.ShadowMapSize,u.shadow.mapSize.width=s.ShadowMapSize),t.local.light=u,t.mesh.add(u),t.mesh.add(u.target),u},l.DirectionalLight.update=async(e,t)=>{if(t.wake(!1,!0),e.length-t.local.olength>1){let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),2==n.length){let e=n[1];n=n[0],t.local.light.target.position.set(...e)}t.local.light.position.set(...n)}},l.DirectionalLight.destroy=(e,t)=>{t.local.light.dispose()},l.DirectionalLight.virtual=!0,l.SpotLight=async(e,t)=>{const n={...t},o=await core._getRules(e,t),r=Object.keys(o).length;t.local.olength=r;let a=16777215;e.length-r>0&&(a=await interpretate(e[0],n));let s=[10,100,10],l=[0,0,0];e.length-r>1&&(s=await interpretate(e[1],t),s instanceof NumericArrayObject&&(s=s.normal()),2==s.length&&(l=s[1],s=s[0]));let c=Math.PI/3;e.length-r>2&&(c=await interpretate(e[2],t));let u=100;"number"==typeof o.Intensity&&(u=o.Intensity);let d=0;"number"==typeof o.Distance&&(d=o.Distance);let h=0;"number"==typeof o.Penumbra&&(h=o.Penumbra);let p=2;"number"==typeof o.Decay&&(p=o.Decay);const m=new i.SpotLight(a,u,d,c,h,p);return m.position.set(...s),m.target.position.set(...l),m.castShadow=t.shadows,m.shadow.bias=-.01,"number"==typeof o.ShadowBias&&(m.shadow.bias=o.ShadowBias),m.shadow.mapSize.height=1024,m.shadow.mapSize.width=1024,"number"==typeof o.ShadowMapSize&&(m.shadow.mapSize.height=o.ShadowMapSize,m.shadow.mapSize.width=o.ShadowMapSize),t.local.spotLight=m,t.mesh.add(m),t.mesh.add(m.target),m},l.SpotLight.update=async(e,t)=>{t.wake(!1,!0);const n=t.local.olength;if(e.length-n>1){let n=await interpretate(e[1],t);if(n instanceof NumericArrayObject&&(n=n.normal()),2==n.length){let e=n[1];if(n=n[0],t.Lerp){if(!t.local.lerp1){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{t.local.spotLight.position.lerp(e.target,.05)}};t.local.lerp1=e,t.Handlers.push(e)}if(t.local.lerp1.target.fromArray(n),!t.local.lerp2){console.log("creating worker for lerp of movements..");const n={alpha:.05,target:new i.Vector3(...e),eval:()=>{t.local.spotLight.target.position.lerp(n.target,.05)}};t.local.lerp2=n,t.Handlers.push(n)}t.local.lerp2.target.fromArray(e)}else t.local.spotLight.position.set(...n),t.local.spotLight.target.position.set(...e)}else if(t.Lerp){if(!t.local.lerp1){console.log("creating worker for lerp of movements..");const e={alpha:.05,target:new i.Vector3(...n),eval:()=>{t.local.spotLight.position.lerp(e.target,.05)}};t.local.lerp1=e,t.Handlers.push(e)}t.local.lerp1.target.fromArray(n)}else t.local.spotLight.position.set(...n)}},l.SpotLight.destroy=async(e,t)=>{console.log("SpotLight destoyed")},l.SpotLight.virtual=!0,l.Shadows=async(e,t)=>{t.shadows=await interpretate(e[0],t)},l.HemisphereLight=async(e,t)=>{const n={...t},o=await core._getRules(e,t);e.length>0?await interpretate(e[0],n):n.color=16777147;const r=n.color;e.length>1?await interpretate(e[1],n):n.color=526368;const a=n.color;let s=1;e.length>2&&(s=await interpretate(e[2],t)),"number"==typeof o.Intensity&&(s=o.Intensity);const l=new i.HemisphereLight(r,a,s);t.global.scene.add(l)},l.MeshMaterial=async(e,t)=>{const n=await interpretate(e[0],t);t.material=n},l["CoffeeLiqueur`Extensions`Graphics3D`MeshMaterial"]=l.MeshMaterial,l.MeshPhysicalMaterial=()=>i.MeshPhysicalMaterial,l.MeshLambertMaterial=()=>i.MeshLambertMaterial,l.MeshPhongMaterial=()=>i.MeshPhongMaterial,l.MeshToonMaterial=()=>i.MeshToonMaterial,l.MeshFogMaterial=async(e,t)=>{let n=.01;return e.length>0&&(n=await interpretate(e[0],t)),function(){const e=new x.FogVolumeMaterial;return e.density=n,e}};let _,A,k,C,S=!1;l.EventListener=async(e,t)=>{const n=await interpretate(e[1],t),o={...t};let r=await interpretate(e[0],t);return Array.isArray(r)&&(r=r[0]),S||(await interpretate.shared.THREETransformControls.load(),S=interpretate.shared.THREETransformControls.TransformControls),n.forEach(e=>{l.EventListener[e.lhs](e.rhs,r,o)}),null},l.EventListener.transform=(e,t,n)=>{console.log(n),console.warn("Controls transform is enabled");const o=new S(n.camera,n.global.domElement),r=o.getHelper(),a=n.controlObject.o;o.attach(t),n.global.scene.add(r);const i=throttle((t,n,o)=>{server.kernel.emitt(e,`<|"position"->{${t.toFixed(4)}, ${n.toFixed(4)}, ${o.toFixed(4)}}|>`,"transform")});o.addEventListener("change",function(e){i(t.position.x,t.position.y,t.position.z)}),o.addEventListener("dragging-changed",function(e){console.log("changed"),a.enabled=!e.value})},l.EventListener.drag=(e,t,n)=>{console.log(n),console.warn("Controls transform is enabled");const o=new S(n.camera,n.global.domElement),r=o.getHelper(),a=n.controlObject.o;o.attach(t),n.global.scene.add(r);const i=throttle((t,n,o)=>{server.kernel.io.fire(e,[t,n,o],"drag")});o.addEventListener("change",function(e){i(t.position.x,t.position.y,t.position.z)}),o.addEventListener("dragging-changed",function(e){console.log("changed"),a.enabled=!e.value})};const E=e=>{const t=new FileReader;return t.readAsDataURL(e),new Promise(e=>{t.onloadend=()=>{e(t.result)}})};async function M(e,t){let n=e,o=!1,r=[0,0,0];if("None"==n){const e=document.createElement("span");let t=new C.CSS2DObject(e);return e.className="g3d-label",{offset:r,element:t}}if(Array.isArray(n))if("HoldForm"==n[0]){if(Array.isArray(n[1])&&"List"==n[1][0]){const e=await interpretate(n[1][2],t);n=["HoldForm",n[1][1]],Array.isArray(e)&&(r=e)}"string"==typeof n[1]&&"'"==n[1].charAt(0)?(o=!1,n=n[1]):o=!0}else if("List"==n[0]){const e=await interpretate(n[2],t);n=n[1],"HoldForm"==n[0]&&("string"==typeof n[1]&&"'"==n[1].charAt(0)?(o=!1,n=n[1]):o=!0),Array.isArray(e)&&(r=e)}const a=document.createElement("span");let i=new C.CSS2DObject(a);if(a.className="g3d-label",!o)try{const e=await interpretate(n,{...t});a.innerHTML=m(String(e))}catch(e){console.warn("Err:",e),o=!0}return o&&(console.warn("x-label: fallback to EditorView"),await w(n,{...t,element:a})),{offset:r,element:i}}l["Graphics3D`Serialize"]=async(e,t)=>{const n=await core._getRules(e,t);let o=t.element;n.TemporalDOM&&(o=document.createElement("div"),o.style.pointerEvents="none",o.style.opacity=0,o.style.position="absolute",document.body.appendChild(o)),await interpretate(e[0],{...t,element:o});const r=new Deferred;console.log(t.global),t.global.renderer.domElement.toBlob(function(e){r.resolve(e)},"image/png",1);const a=await r.promise;Object.values(t.global.stack).forEach(e=>{e.dispose()}),n.TemporalDOM&&o.remove();return await E(a)},l["Graphics3D`toDataURL"]=async(e,t)=>{const n=new Deferred;console.log(t.global),t.local.animateOnce(),t.local.renderer.domElement.toBlob(function(e){n.resolve(e)},"image/png",1);const o=await n.promise;return await E(o)},l["CoffeeLiqueur`Extensions`Graphics3D`Tools`toDataURL"]=l["Graphics3D`toDataURL"],l["CoffeeLiqueur`Extensions`Graphics3D`Tools`Serialize"]=l["Graphics3D`Serialize"],l.Top=()=>[0,0,1e3],l.Bottom=()=>[0,0,-1e3],l.Right=()=>[1e3,0,0],l.Left=()=>[-1e3,0,0],l.Front=()=>[0,1e3,0],l.Back=()=>[0,-1e3,0],l.Bold=()=>"Bold",l.Bold.update=l.Bold,l.Italic=()=>"Italic",l.Italic.update=l.Italic,l.FontSize=()=>"FontSize",l.FontSize.update=l.FontSize,l.FontFamily=()=>"FontFamily",l.FontFamily.update=l.FontFamily,core.Graphics3D=async(e,t)=>{await interpretate.shared.THREE.load(),i||(i=interpretate.shared.THREE.THREE,A=interpretate.shared.THREE.OrbitControls,_=interpretate.shared.THREE.RGBELoader,C=interpretate.shared.THREE.CSS2D,k=await Promise.resolve().then(function(){return j}),k=k.VariableTube),s=i.MathUtils;let n=!1,o=performance.now(),r=await core._getRules(e,{...t,context:l,hold:!0});0===Object.keys(r).length&&e.length>1&&(r=await core._getRules(e[1],{...t,context:l,hold:!0})),console.warn(r);let a,u=!0,d=[-40,20,30];if(r.ViewPoint){const ue=await interpretate(r.ViewPoint,{...t,context:l});Array.isArray(ue)&&"number"==typeof ue[0]&&"number"==typeof ue[1]&&"number"==typeof ue[2]&&(d=[ue[0],ue[2],ue[1]])}r.Axes&&(console.warn(r.PlotRange),a=await interpretate(r.PlotRange,t),u=!1);const h=(new i.Matrix4).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);let p=!1;if("RTX"in r)p=!0,x||(await interpretate.shared.THREERTX.load(),x=interpretate.shared.THREERTX.RTX);else if(r.Renderer){"PathTracing"==await interpretate(r.Renderer,t)&&(p=!0,x||(await interpretate.shared.THREERTX.load(),x=interpretate.shared.THREERTX.RTX))}!g&&p&&(g=(await Promise.resolve().then(function(){return Et})).GUI),t.local.handlers=[],t.local.prolog=[];const f=[],y=document.createElement("div");y.classList.add("relative"),t.element.appendChild(y);const b=await v(r,t),S={topColor:16777215,bottomColor:6710886,multipleImportanceSampling:!1,stableNoise:!1,denoiseEnabled:!0,denoiseSigma:2.5,denoiseThreshold:.1,denoiseKSigma:1,environmentIntensity:1,environmentRotation:0,environmentBlur:0,backgroundBlur:0,bounces:5,sleepAfter:1e3,runInfinitely:!1,fadeDuration:300,stopAfterNFrames:60,samplesPerFrame:1,acesToneMapping:!0,resolutionScale:1,transparentTraversals:20,filterGlossyFactor:.5,tiles:1,renderDelay:100,minSamples:5,backgroundAlpha:0,checkerboardTransparency:!0,cameraProjection:"Orthographic",enablePathTracing:!0};if(r.MultipleImportanceSampling&&(S.multipleImportanceSampling=await interpretate(r.MultipleImportanceSampling,t)),"EnablePathTracing"in r&&(S.enablePathTracing=await interpretate(r.EnablePathTracing,t)),"AcesToneMapping"in r&&(S.acesToneMapping=await interpretate(r.AcesToneMapping,t)),r.Bounces&&(S.bounces=await interpretate(r.Bounces,t)),"FadeDuration"in r&&(S.fadeDuration=await interpretate(r.FadeDuration,t)),"RenderDelay"in r&&(S.renderDelay=await interpretate(r.RenderDelay,t)),"MinSamples"in r&&(S.minSamples=await interpretate(r.MinSamples,t)),"EnvironmentIntensity"in r&&(S.environmentIntensity=await interpretate(r.EnvironmentIntensity,t)),"SamplesPerFrame"in r&&(S.samplesPerFrame=await interpretate(r.SamplesPerFrame,t)),r.ViewProjection&&(S.cameraProjection=await interpretate(r.ViewProjection,t)),r.Background){const de=await interpretate(r.Background,{...t,context:l});r.Background=de,1==de?.isColor&&(S.backgroundAlpha=1)}let E,R,O,T,L,I,P,B,z,F,D;if(p||(S.resolutionScale=1),p&&(S.sleepAfter=1e4),r.SleepAfter&&(S.sleepAfter=await interpretate(r.SleepAfter,t)),p){E=new g({autoPlace:!1,name:"...",closed:!0}),R=document.createElement("div"),R.classList.add("graphics3d-controller"),R.appendChild(E.domElement),t.local.animateOnce=le;const he={Save:function(){le(),O.domElement.toBlob(function(e){var t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download="screenshot.png",t.click()},"image/png",1)}};E.add(he,"Save")}const N={near:0,far:2e3};let V=5;r.OrthographicCameraWidth&&(V=await interpretate(r.OrthographicCameraWidth,t)),r.CameraNearPlane&&(N.near=await interpretate(r.CameraNearPlane,t)),r.CameraFarPlane&&(N.far=await interpretate(r.CameraFarPlane,t)),O=new i.WebGLRenderer({antialias:!0}),O.toneMapping=i.ACESFilmicToneMapping,O.outputEncoding=i.sRGBEncoding,O.setClearColor(0,0),y.appendChild(O.domElement),t.local.rendererContainer=O.domElement,T=O.domElement,t.local.domElement=T,t.local.renderer=O;const G={x:0,y:0};t.element.classList.contains("slide-frontend-object")&&(G.x=-1);const U=new C.CSS2DRenderer({globalOffset:G});U.setSize(b[0],b[1]),U.domElement.style.position="absolute",U.domElement.style.top="0px",U.domElement.style.bottom="0px",U.domElement.style.marginTop="auto",U.domElement.style.marginBottom="auto",y.appendChild(U.domElement),t.local.labelContainer=U.domElement,T=U.domElement,b[0]>250&&b[1]>150&&p&&(t.local.guiContainer=R,y.appendChild(R));const H=b[0]/b[1];let W;p?(B=new x.PhysicalCamera(75,H,.025,500),B.position.set(-4,2,3)):(B=new i.PerspectiveCamera(75,H,.025,500),r.PerspectiveCameraZoom&&(B.zoom=await interpretate(r.PerspectiveCameraZoom,t)),O.shadowMap.enabled=!0),W=p?(e,r)=>{o=performance.now(),t.local.updateSceneNext=1==e,t.local.updateLightingNext=1==r,n&&t.local.wakeThreadUp()}:()=>{o=performance.now(),n&&t.local.wakeThreadUp()};const X=V/H;z=new i.OrthographicCamera(V/-2,V/2,X/2,X/-2,N.near,N.far),z.position.set(...d),P=z,D=new i.Scene,p&&(I=new x.WebGLPathTracer(O),I.minSamples=S.minSamples,I.renderDelay=S.renderDelay,I.fadeDuration=S.fadeDuration,I.multipleImportanceSampling=S.multipleImportanceSampling);let q={init:(e,t)=>{q.o=new A(e,T),q.o.addEventListener("change",W),q.o.target.set(0,1,0),q.o.update()},dispose:()=>{}};if("Controls"in r&&!await interpretate(r.Controls)&&(q.disabled=!0,T.style.pointerEvents="none"),r.Controls&&"PointerLockControls"===await interpretate(r.Controls,t)){await interpretate.shared.THREEPointerLockControls.load();const pe=interpretate.shared.THREEPointerLockControls.PointerLockControls;q={init:(e,n)=>{q.o=new pe(e,n),D.add(q.o.getObject()),q.o.addEventListener("change",W),q.onKeyDown=function(e){if(e.preventDefault(),e.stopImmediatePropagation(),e.repeat)return!1;switch(W(),e.code){case"ArrowUp":case"KeyW":q.moveForward=!0;break;case"ArrowLeft":case"KeyA":q.moveLeft=!0;break;case"ArrowDown":case"KeyS":q.moveBackward=!0;break;case"ArrowRight":case"KeyD":q.moveRight=!0;break;case"Space":!0===q.canJump&&(q.velocity.y+=20),q.canJump=!1}return!1},q.onKeyUp=function(e){switch(e.preventDefault(),e.stopImmediatePropagation(),W(),e.code){case"ArrowUp":case"KeyW":q.moveForward=!1;break;case"ArrowLeft":case"KeyA":q.moveLeft=!1;break;case"ArrowDown":case"KeyS":q.moveBackward=!1;break;case"ArrowRight":case"KeyD":q.moveRight=!1}return!1},t.local.handlers.push(function(){if(!q.o||!q.o.isLocked)return;const e=performance.now(),t=(e-(q.prevTime||e))/1e3;q.prevTime=e,q.velocity.x*=.9,q.velocity.z*=.9,q.velocity.y-=39.2*t,q.direction.z=Number(q.moveForward)-Number(q.moveBackward),q.direction.x=Number(q.moveRight)-Number(q.moveLeft),q.direction.normalize(),(q.moveForward||q.moveBackward)&&(q.velocity.z-=100*q.direction.z*t),(q.moveLeft||q.moveRight)&&(q.velocity.x-=100*q.direction.x*t),q.o.moveRight(-q.velocity.x*t),q.o.moveForward(-q.velocity.z*t),q.o.getObject().position.y+=q.velocity.y*t;const n=q.o.getObject().position,o=new i.Raycaster;o.set(n,new i.Vector3(0,-1,0));const r=o.intersectObjects(D.children,!0);let a=.3;for(let e=0;e{document.removeEventListener("keydown",q.onKeyDown),document.removeEventListener("keyup",q.onKeyUp)}}}t.local.controlObject=q,q.init(P,T),L=q.o,t.local.controlObject=q,t.local.renderer=O,t.local.domElement=T,p&&L.addEventListener("change",()=>{I.updateCamera()});const Z=new i.Group,K=!1;if(r.TransitionType){"Linear"===await interpretate(r.TransitionType,t)&&(K=!0)}const Y={...t,context:l,numerical:!0,tostring:!1,matrix:h,material:i.MeshPhysicalMaterial,color:new i.Color(1,1,1),opacity:1,thickness:1,roughness:.5,edgecolor:new i.Color(0,0,0),mesh:Z,metalness:0,emissive:void 0,arrowHeight:30,arrowRadius:30,reflectivity:.5,clearcoat:0,shadows:!1,Lerp:K,camera:P,controlObject:q,fontSize:void 0,fontFamily:void 0,Handlers:f,wake:W,pointSize:.08,colorInherit:!0,emissiveIntensity:void 0,roughness:void 0,metalness:void 0,ior:void 0,transmission:void 0,thinFilm:void 0,materialThickness:void 0,attenuationColor:void 0,attenuationDistance:void 0,opacity:void 0,clearcoat:void 0,clearcoatRoughness:void 0,sheenColor:void 0,sheenRoughness:void 0,iridescence:void 0,iridescenceIOR:void 0,iridescenceThickness:void 0,specularColor:void 0,specularIntensity:void 0,matte:void 0};t.local.wakeThreadUp=()=>{n&&(n=!1,console.warn("g3d >> waking up!"),t.local.aid=requestAnimationFrame(re))},t.global.renderer=O,t.global.labelRenderer=U,t.global.domElement=T,t.global.scene=D,Y.camera=P,t.local.element=y,p&&(Y.PathRendering=!0),r.Prolog&&await interpretate(r.Prolog,Y),r.Axes&&a&&console.log("Drawing grid...");let J,$=!1;"Lighting"in r&&(r.Lighting?"List"==r.Lighting[0]?$=!1:"'Neutral'"==r.Lighting?Y.material=i.MeshBasicMaterial:$=!0:$=!0),await interpretate(e[0],Y),r.Epilog&&interpretate(r.Epilog,Y);const Q=e=>Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1];if(Array.isArray(a)&&Q(a[0])){const me=a[0],fe=Q(a[1])?a[1]:me,ge=Q(a[2])?a[2]:me,ye=.5*(me[1]+me[0]),be=.5*(fe[1]+fe[0]),we=.5*(ge[1]+ge[0]),ve=1.1;J={min:{x:(me[0]-ye)*ve+ye,y:(fe[0]-be)*ve+be,z:(ge[0]-we)*ve+we},max:{x:(me[1]-ye)*ve+ye,y:(fe[1]-be)*ve+be,z:(ge[1]-we)*ve+we}}}if(J||(J=(new i.Box3).setFromObject(Z)),r.Axes){const xe={x:[],y:[],z:[]};{function _e(e,t,n=8){const o=t-e;if(0===o)return{step:0,niceMin:e,niceMax:t,count:0};const r=o/n,a=Math.pow(10,Math.floor(Math.log10(r))),i=r/a;let s;s=i<1.5?1:i<3?2:i<7?5:10;const l=s*a,c=Math.floor(e/l)*l,u=Math.ceil(t/l)*l;return{step:l,niceMin:c,niceMax:u,count:Math.round((u-c)/l)}}const Ae=_e(J.min.x,J.max.x,8),ke=_e(J.min.y,J.max.y,8),Ce=_e(J.min.z,J.max.z,8),Se=[Ae.count,ke.count,Ce.count];function Ee({niceMin:e,step:t,count:n}){const o=Math.max(0,-Math.floor(Math.log10(t))),r=[];for(let a=0;a<=n;a++){let n=Number((e+t*a).toFixed(o));Math.abs(n){const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(0,0,e),n.offset=[-.7*De.x,.7*De.y,0],Z.add(n),xe.z.push(n)}),Me.slice(1,-1).forEach(e=>{const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(e,0,0),n.offset=[0,De.y,0],Z.add(n),xe.x.push(n)}),Re.slice(1,-1).forEach(e=>{const t=document.createElement("span");t.className="g3d-label opacity-0",t.textContent=String(e);const n=new C.CSS2DObject(t);n.position.set(0,e,0),n.offset=[De.x,0,0],Z.add(n),xe.y.push(n)}),r.PlotLabel){let Xe=!1;if(Array.isArray(r.PlotLabel)&&"HoldForm"==r.PlotLabel[0][0]&&(Xe=!0),!Xe)try{const qe=await interpretate(r.PlotLabel,{...t,context:l});if(qe){const Ze=document.createElement("div");Ze.innerHTML=m(String(qe)),Ze.style="\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n text-align: center;\n font-size: small;\n ",Ze.className="g3d-label",y.appendChild(Ze)}}catch(Ke){Xe=!0}if(Xe){console.warn("Non textural PlotLabel!"),console.warn("Convert to text");const Ye=document.createElement("div");Ye.style="\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n text-align: center;\n font-size: small;\n ",Ye.className="g3d-label",y.appendChild(Ye),await w(r.PlotLabel,{...t,element:Ye})}}if(r.AxesLabel&&(r.AxesLabel=await interpretate(r.AxesLabel,{...t,context:l,hold:!0}),3==r?.AxesLabel?.length)){if(r.AxesLabel[0]){let Je=r.AxesLabel[0],{offset:$e,element:Qe}=await M(Je,t);Qe.position.copy(new i.Vector3((J.min.x+J.max.x)/2+$e[0],J.min.y+1,J.min.z+$e[2])),Z.add(Qe),Qe.offset=[0,3*(J.max.y-J.min.y)/Se[1]+$e[1],0],Qe.onlyVisible=!0,xe.x.push(Qe)}if(r.AxesLabel[1]){let et=r.AxesLabel[1],{offset:tt,element:nt}=await M(et,t);nt.position.copy(new i.Vector3(J.min.x+1,(J.min.y+J.max.y)/2+tt[1],J.min.z+tt[2])),Z.add(nt),nt.offset=[3*(J.max.x-J.min.x)/Se[0]+tt[0],0,0],nt.onlyVisible=!0,xe.y.push(nt)}if(r.AxesLabel[2]){let ot=r.AxesLabel[2],{offset:rt,element:at}=await M(ot,t);at.position.copy(new i.Vector3(J.min.x-1,J.min.y+1,(J.min.z+J.max.z)/2)+rt[2]),Z.add(at),at.offset=[-3*(J.max.x-J.min.x)/Se[0]/1.4+rt[0],3*(J.max.x-J.min.x)/Se[0]/1.4+rt[1],0],at.onlyVisible=!0,xe.z.push(at)}}let Ne=0,je=0;function Ve(e,t,n=0){const o=e instanceof DOMRect?e:e.getBoundingClientRect(),r=t instanceof DOMRect?t:t.getBoundingClientRect();return!(o.rightr.right-n)&&(!(o.bottomr.bottom-n)))}function Ge(e,t){return Ve(e.getBoundingClientRect(),t.getBoundingClientRect(),2)}function Ue(e,t=!1){if(e.length<2)return;const n=e[0].element.getBoundingClientRect(),o=e[e.length-1].element.getBoundingClientRect();Math.abs(n.left-o.left),Math.abs(n.top-o.top);let r,a=1;do{r=!1;for(let t=1;t*a{n%a===0?t||e.element.classList.remove("opacity-0"):e.onlyVisible||e.element.classList.add("opacity-0")})}let He=performance.now()-500;const We=e=>{if(u)return;if(performance.now()-He<100)return;He=performance.now();const t=L.getAzimuthalAngle(),n=L.getPolarAngle();z.layers.disable(10),z.layers.disable(11),z.layers.disable(12),z.layers.disable(13),z.layers.disable(14),z.layers.disable(15),t<1.57&&t>0&&1!=Ne&&(z.layers.enable(13),z.layers.enable(11),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x+e.offset[0],1*Fe.min.y-e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x-e.offset[0],1*Fe.min.y-e.offset[1],1*Fe.min.z+e.offset[2]))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x+e.offset[0],e.position.y,1*Fe.min.z)))),t<3.14&&t>1.57&&2!=Ne&&(z.layers.enable(11),z.layers.enable(12),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x-e.offset[0],1*Fe.min.y-e.offset[1],e.position.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x+e.offset[0],e.position.y,1*Fe.min.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x+e.offset[0],1*Fe.max.y+e.offset[1],1*Fe.min.z+e.offset[2])))),t<0&&t>-1.57&&3!=Ne&&(z.layers.enable(13),z.layers.enable(10),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x+e.offset[0],1*Fe.max.y+e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x+e.offset[0],1*Fe.min.y-e.offset[1],1*Fe.min.z+e.offset[2]))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x-e.offset[0],e.position.y,1*Fe.min.z)))),t<-1.57&&t>-3.14&&4!=Ne&&(z.layers.enable(10),z.layers.enable(12),xe.z.forEach(e=>e.position.copy(new i.Vector3(1*Fe.max.x-e.offset[0],1*Fe.max.y+e.offset[1],e.position.z))),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,1*Fe.max.y+e.offset[1],1*Fe.min.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(1*Fe.min.x-e.offset[0],e.position.y,1*Fe.min.z)))),n>1.57&&1!=je&&(z.layers.enable(14),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.max.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.max.z)))),n<1.57&&2!=je&&(z.layers.enable(15),xe.x.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.min.z))),xe.y.forEach(e=>e.position.copy(new i.Vector3(e.position.x,e.position.y,1*Fe.min.z)))),Ue(xe.x),Ue(xe.y),Ue(xe.z)};u||setTimeout(We,100),L.addEventListener("end",We),E?.add({Grid:!u},"Grid").name("Grid").listen().onChange(e=>{e?(u=!1,We()):(z.layers.disable(10),z.layers.disable(11),z.layers.disable(12),z.layers.disable(13),z.layers.disable(14),z.layers.disable(15),u=!0)})}}if(Z.position.set(-(J.min.x+J.max.x)/2,-(J.min.y+J.max.y)/2,-(J.min.z+J.max.z)/2),r.Boxed){const it=[[[J.min.x,J.min.y,J.min.z],[J.max.x,J.min.y,J.min.z],[J.max.x,J.max.y,J.min.z],[J.min.x,J.max.y,J.min.z],[J.min.x,J.min.y,J.min.z]],[[J.min.x,J.min.y,J.max.z],[J.max.x,J.min.y,J.max.z],[J.max.x,J.max.y,J.max.z],[J.min.x,J.max.y,J.max.z],[J.min.x,J.min.y,J.max.z]],[[J.min.x,J.min.y,J.min.z],[J.min.x,J.min.y,J.max.z]],[[J.max.x,J.min.y,J.min.z],[J.max.x,J.min.y,J.max.z]],[[J.max.x,J.max.y,J.min.z],[J.max.x,J.max.y,J.max.z]],[[J.min.x,J.max.y,J.min.z],[J.min.x,J.max.y,J.max.z]]];for(const st of it)await interpretate(["Line",["JSObject",st]],{...Y})}if(r.Axes){const lt=Math.abs(Math.min(J.max.x-J.min.x,J.max.y-J.min.y,J.max.z-J.min.z)),ct=new i.AxesHelper(lt/2);ct.position.set((J.max.x+J.min.x)/2,(J.max.y+J.min.y)/2,(J.max.z+J.min.z)/2),Z.add(ct)}Z.applyMatrix4((new i.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1));let ee=[J.max.x-J.min.x,J.max.z-J.min.z,J.max.y-J.min.y],te=Math.max(...ee);const ne=Math.max(...ee);if("BoxRatios"in r){const ut=ee.map(e=>1/(e/te));console.warn("Rescaling....");let dt=await interpretate(r.BoxRatios,t);dt=[dt[0],dt[2],dt[1]],te=Math.max(...dt),dt=dt.map((e,t)=>ut[t]*e/te),console.log(te),ne>80&&(console.warn("Model is too large!"),dt=dt.map(e=>e/ne*10)),Z.applyMatrix4((new i.Matrix4).makeScale(...dt))}else{let ht=[1,1,1];ne>80&&(console.warn("Model is too large!"),ht=ht.map(e=>e/ne*10)),Z.applyMatrix4((new i.Matrix4).makeScale(...ht))}if(Z.position.add(new i.Vector3(0,1,0)),D.add(Z),J=(new i.Box3).setFromObject(Z),Y.camera.isOrthographicCamera){console.warn("fitting camera...");const pt=Y.camera;console.log(J);const mt=[J.max.x+J.min.x,J.max.y+J.min.y,J.max.z+J.min.z].map(e=>-e/2),ft=Math.max(J.max.x-J.min.x,J.max.y-J.min.y,J.max.z-J.min.z);console.log(ft),console.log(mt),pt.zoom=.55*Math.min(V/(J.max.x-J.min.x),X/(J.max.y-J.min.y)),r.OrthographicCameraZoom&&(pt.zoom=await interpretate(r.OrthographicCameraZoom,t)),pt.updateProjectionMatrix()}if(D.updateMatrixWorld(),$)if(r.Background&&p){if(r.Background.isColor){S.environmentIntensity=0;const gt=new x.GradientEquirectTexture;gt.topColor.set(16777215),gt.bottomColor.set(6710886),gt.update(),D.defaultEnvTexture=gt,D.environment=gt,D.background=gt}}else r.Background&&r.Background.isColor&&(D.background=r.Background);else((e,t,n)=>{if(n){const n=new t.GradientEquirectTexture;return n.topColor.set(16777215),n.bottomColor.set(6710886),n.update(),e.defaultEnvTexture=n,e.environment=n,void(e.background=n)}const o=new i.DirectionalLight(13210258,1.5);o.position.set(0,1,2),e.add(o);const r=new i.DirectionalLight(9619858,1.5);r.position.set(-1.732,1,-1),e.add(r);const a=new i.DirectionalLight(9605833,1.5);a.position.set(1.732,1,-1),e.add(a);var s=new i.HemisphereLight(15005439,526368,2);e.add(s)})(D,x,p);let oe,re;if(r.Background&&!p&&r.Background.isColor&&(D.background=r.Background),p&&(I.updateLights(),new x.BlurredEnvMapGenerator(O)),"Lightmap"in r){const yt=await interpretate(r.Lightmap,t);S.backgroundAlpha=1,oe=(new _).setDataType(i.FloatType).loadAsync(yt).then(e=>{if(p&&(F=e,function(){const e=new x.BlurredEnvMapGenerator(O),t=e.generate(F,.35);D.background=t,D.environment=t,D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha,S.backgroundAlpha<1&&(D.background=null);e.dispose(),I.updateEnvironment()}()),p)return;const t=ae.fromEquirectangular(e).texture;D.environment=t,D.background=t,e.dispose(),ae.dispose()})}if("BackgroundAlpha"in r&&(S.backgroundAlpha=await interpretate(r.BackgroundAlpha,t),S.backgroundAlpha<1&&(D.background=null)),!p){var ae=new i.PMREMGenerator(O);ae.compileEquirectangularShader()}function ie(e){"Perspective"===e?(P&&(B.position.copy(P.position),B.zoom=P.zoom),P=B):"Orthographic"===e&&(P&&(z.position.copy(P.position),z.zoom=P.zoom),P=z),L.object=P,p&&(I.camera=P),L.update(),t.local.camera=P,Y.camera=P,p&&I.reset()}function se(){W(),p&&(I.bounces=S.bounces,D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha),P.updateMatrixWorld(),S.backgroundAlpha<1?D.background=null:D.background=D.environment}function le(){if(p){if(t.local.updateSceneNext&&(I.setScene(D,P),t.local.updateSceneNext=!1),t.local.updateLightingNext&&(I.updateLights(),t.local.updateLightingNext=!1),S.samplesPerFrame>1)for(let e=0;e{e()})}if(p&&(D.environmentIntensity=S.environmentIntensity,D.backgroundIntensity=S.environmentIntensity,D.backgroundAlpha=S.backgroundAlpha,S.backgroundAlpha<1&&(D.background=null),I.setScene(D,P),I.updateEnvironment(),I.updateLights()),"Lightmap"in r&&await Promise.all([oe]),re=()=>{le(),performance.now()-o>S.sleepAfter&&!S.runInfinitely?(n=!0,console.warn("g3d >> Sleeping...")):t.local.aid=requestAnimationFrame(re)},t.local.updateLightingNext=!1,t.local.updateSceneNext=!1,function(){const e=b[0],t=b[1],n=S.resolutionScale;p&&I.reset(),O.setSize(e,t),O.setPixelRatio(window.devicePixelRatio*n);const o=e/t;B.aspect=o,B.updateProjectionMatrix();const r=V/o;z.top=r/2,z.bottom=r/-2,z.updateProjectionMatrix()}(),ie(S.cameraProjection),p){D.backgroundAlpha=S.backgroundAlpha;const bt=E?.addFolder("Path Tracing");bt?.add(S,"runInfinitely"),bt?.add(S,"samplesPerFrame",1,50,1),bt?.add(S,"multipleImportanceSampling").onChange(()=>{I.multipleImportanceSampling=S.multipleImportanceSampling,I.updateLights(),I.updateMaterials()}),bt?.add(S,"environmentIntensity",0,3,.1).onChange(()=>{I.reset(),se(),I.updateEnvironment()}),bt?.add(S,"backgroundAlpha",0,1,.1).onChange(()=>{I.reset(),se(),I.updateEnvironment()}),bt?.add(S,"bounces",1,30,1).onChange(()=>{I.reset(),se()})}const ce=E?.addFolder("Camera");return ce?.add(S,"sleepAfter",1e3,3e4,10),ce?.add(S,"cameraProjection",["Perspective","Orthographic"]).onChange(e=>{ie(e),se()}),ce?.add(S,"acesToneMapping").onChange(e=>{O.toneMapping=e?i.ACESFilmicToneMapping:i.NoToneMapping,se()}),ce?.close(),re(),t},core.Graphics3D.destroy=(e,t)=>{console.log("Graphics3D was removed"),t.local.wakeThreadUp=()=>{},t.local.controlObject.dispose(),cancelAnimationFrame(t.local.aid),t.local.renderer.dispose(),t.local.renderer.forceContextLoss(),t.local.labelContainer&&t.local.labelContainer.remove(),t.local.guiContainer&&t.local.guiContainer.remove(),t.local.rendererContainer.remove(),t.local.element.remove()},core.Graphics3D.virtual=!0;const R={TypeReal:{},TypeInteger:{}},O={Real64:{context:R.TypeReal,constructor:Float64Array},Real32:{context:R.TypeReal,constructor:Float32Array},Integer32:{context:R.TypeInteger,constructor:Int32Array},Integer64:{context:R.TypeInteger,constructor:BigInt64Array},Integer16:{context:R.TypeInteger,constructor:Int16Array},Integer8:{context:R.TypeInteger,constructor:Int8Array},UnsignedInteger32:{context:R.TypeInteger,constructor:Uint32Array},UnsignedInteger64:{context:R.TypeInteger,constructor:BigUint64Array},UnsignedInteger16:{context:R.TypeInteger,constructor:Uint16Array},UnsignedInteger8:{context:R.TypeInteger,constructor:Uint8Array}};function T(e,t=[]){return Array.isArray(e)?(t.push(e.length),T(e[0],t)):t}const L=new RegExp(/^(-?\d+)(.?\d*)(\*\^)?(\d*)/),I=window.isNumeric;function P(e,t){if(Array.isArray(e[1]))for(let n=1;n{if("string"==typeof e){if(I(e))return parseInt(e);if(L.test(e)){let[t,n,o,r,a]=e.split(L);return n+="."===o?o+"0":o,r&&(n+="E"+a),parseFloat(n)}}return e}),t.index),t.index+=e.length-1}R.NumericArray=(e,t)=>{const n=O[interpretate(e[1])],o=[];let r=e[0].length-1;o.push(r),"List"===e[0][1][0]&&(r*=e[0][1].length-1,o.push(e[0][1].length-1),"List"===e[0][1][1][0]&&(r*=e[0][1][1].length-1,o.push(e[0][1][1].length-1)));const a=new n.constructor(r);return P(e[0],{index:0,array:a}),{buffer:a,dims:o}},R.NumericArray.update=R.NumericArray;const B={Real32:{constructor:Float32Array,convert:e=>{const t=e.dims[0]*e.dims[1]*e.dims[2],n=e.buffer,o=new Uint8ClampedArray(t);let r;for(r=0;r>>0;o[r]=e}return o}},Byte:{constructor:Uint8ClampedArray,convert:e=>e.buffer}};let z;l["CoffeeLiqueur`Extensions`Graphics3D`Private`SampledColorFunction"]=async(e,t)=>{const n=await interpretate(e[0],t);let o="RGB";return n[0].length>3&&(o="RGBA"),{colors:n,type:o}},core.Image3D=async(e,t)=>{await interpretate.shared.THREE.load(),i||(i=interpretate.shared.THREE.THREE,A=interpretate.shared.THREE.OrbitControls,_=interpretate.shared.THREE.RGBELoader,C=interpretate.shared.THREE.CSS2D,k=await Promise.resolve().then(function(){return j}),k=k.VariableTube),g||(g=(await Promise.resolve().then(function(){return Et})).GUI);const n=new g({autoPlace:!1,name:"...",closed:!0});z||(z=(await Promise.resolve().then(function(){return zr})).default);const o=await core._getRules(e,{...t,context:l,hold:!0});let r,a=await interpretate(e[0],{...t,context:[R,l]}),s="Real32";e.length-Object.keys(o).length>1&&(s=interpretate(e[1])),console.log(e),s=B[s],Array.isArray(a)&&(console.warn("Will be slow. Not a typed array"),a={buffer:a.flat(1/0),dims:T(a)}),r=s.convert(a),console.warn("ImageSize"),console.warn(a.dims);const c=a.dims[2],u=a.dims[1],d=a.dims[0],h={speed:1e-4,samplingRate:1,threshold:.5054,palette:"Greys",invertColor:!1,alphaScale:1.1916};"SamplingRate"in o&&(h.samplingRate=await interpretate(o.SamplingRate,t)),"InvertColor"in o&&(h.invertColor=await interpretate(o.InvertColor,t)),"AlphaScale"in o&&(h.alphaScale=await interpretate(o.AlphaScale,t)),"Palette"in o&&(h.palette=await interpretate(o.Palette,t));const p=new i.Data3DTexture(r,c,u,d);p.format=i.RedFormat,p.type=i.UnsignedByteType,p.minFilter=i.LinearFilter,p.magFilter=i.LinearFilter,p.wrapS=i.ClampToEdgeWrapping,p.wrapT=i.ClampToEdgeWrapping,p.wrapR=i.ClampToEdgeWrapping,p.needsUpdate=!0,t.local.volumeTexture=p;let m,f="Spectral";{const e=z.scale(f);m=(t,n)=>{const o=e(t/(n-1)).rgb();return o.push(255),o}}if("ColorFunction"in o){const e=await interpretate(o.ColorFunction,{...t,context:l});if(console.warn(e),"string"==typeof e){switch(e){case"XRay":h.invertColor=!0,f="Greys";break;case"GrayLevelOpacity":f="Greys";break;case"Automatic":break;default:f=e}const t=z.scale(f);m=(e,n)=>{const o=t(e/(n-1)).rgb();return o.push(255),o}}else if(e.type)switch(e.type){case"RGB":m=(t,n)=>{const o=e.colors[t].map(e=>Math.floor(255*e));return o.push(255),o};break;case"RGBA":m=(t,n)=>e.colors[t].map(e=>Math.floor(255*e));break;default:throw console.error(e),"unknown color format"}}const y=256,b=new Uint8Array(1024);for(let e=0;e density) {\n // Store the value if it is greater than the previous values.\n density = value;\n }\n\n // Early exit the loop when the maximum possible value is found or the exit point is reached. \n if (density >= 1.0 || t > tEnd) {\n break;\n }\n }\n\n // Convert the found value to a color by sampling the color palette texture.\n color.rgb = sampleColor(density).rgb;\n // Modify the alpha value of the color to make lower values more transparent.\n color.a = alphaScale * (invertColor ? 1.0 - density : density);\n\n // Return the color for the ray.\n return color;\n}\n\nvoid main() {\n // Determine the intersection of the ray and the box.\n vec3 rayDir = normalize(vDirection);\n vec3 aabbmin = vec3(-0.5);\n vec3 aabbmax = vec3(0.5);\n vec2 intersection = intersectAABB(vOrigin, rayDir, aabbmin, aabbmax);\n\n // Initialize the fragment color.\n vec4 color = vec4(0.0);\n\n // Check if the intersection is valid, i.e., if the near distance is smaller than the far distance.\n if (intersection.x <= intersection.y) {\n // Clamp the near intersection distance when the camera is inside the box so we do not start sampling behind the camera.\n intersection.x = max(intersection.x, 0.0);\n // Compute the entry and exit points for the ray.\n vec3 entryPoint = vOrigin + rayDir * intersection.x;\n vec3 exitPoint = vOrigin + rayDir * intersection.y;\n\n // Determine the sampling rate and step size.\n // Entry Exit Align Corner sampling as described in\n // Volume Raycasting Sampling Revisited by Steneteg et al. 2019\n vec3 dimensions = vec3(textureSize(dataTexture, 0));\n vec3 entryToExit = exitPoint - entryPoint;\n float samples = ceil(samplingRate * length(entryToExit * (dimensions - vec3(1.0))));\n float tEnd = length(entryToExit);\n float tIncr = tEnd / samples;\n float tStart = 0.5 * tIncr;\n\n // Determine the entry point in texture space to simplify texture sampling.\n vec3 texEntry = (entryPoint - aabbmin) / (aabbmax - aabbmin);\n\n // Sample the volume along the ray and convert samples to color.\n color = compose(color, texEntry, rayDir, samples, tStart, tEnd, tIncr);\n }\n\n // Return the fragment color.\n frag_color = color;\n}\n",side:i.BackSide,transparent:!0});t.local.material=E,S.material=E,v.add(S);let M=[core.DefaultWidth,core.DefaultWidth];if("ImageSize"in o){const e=await interpretate(o.ImageSize,t);Array.isArray(e)?M=e:"number"==typeof e&&(M=[e,e])}const O=M[0]/M[1],L=new i.PerspectiveCamera(45,O,.1,1e3);L.position.set(1,1,-1),L.lookAt(new i.Vector3(0,0,0));const I=new i.WebGLRenderer({antialias:!0,alpha:!0});I.setSize(M[0],M[1]),I.setPixelRatio(devicePixelRatio),t.element.appendChild(I.domElement),I.setClearColor(0,0);const P=new A(L,I.domElement);let F,D=performance.now(),N=!1;const V=()=>{D=performance.now(),N&&(console.log("wake"),N=!1,F())};n.add(h,"alphaScale",0,2).onChange(()=>{E.uniforms.alphaScale.value=h.alphaScale,V()}),n.add(h,"samplingRate",.1,4).onChange(()=>{E.uniforms.samplingRate.value=h.samplingRate,V()}),n.add(h,"invertColor").onChange(()=>{E.uniforms.invertColor.value=h.invertColor,V()}),P.addEventListener("change",V),F=()=>{E&&S.material.uniforms.cameraPosition.value.copy(L.position),I.render(v,L),performance.now()-D>100?(console.log("sleep"),N=!0):t.local.animation=requestAnimationFrame(F)};const G=document.createElement("div");G.classList.add("graphics3d-controller"),G.appendChild(n.domElement),M[0]>250&&M[1]>150&&t.element.appendChild(G);const U={Save:function(){I.render(v,L),I.domElement.toBlob(function(e){var t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download="screenshot.png",t.click()},"image/png",1)}};n.add(U,"Save"),F()},core.Image3D.virtual=!0,core.Image3D.destroy=(e,t)=>{console.warn("Dispose"),cancelAnimationFrame(t.local.animation),t.local.material.dispose(),t.local.colorTexture.dispose(),t.local.volumeTexture.dispose()},l.Ball=l.Sphere,await interpretate.shared.THREE.load();const F=interpretate.shared.THREE.THREE,D=F.BufferGeometry;F.Float32BufferAttribute,F.Vector2,F.Vector3;class N{constructor(e,t,n=64,o=1,r=8,a=!1){this.geometry=new D;let i=r;const s=N.generateRadial(o,i),l=N.generateNormal(o,i),c=N.generateBufferData(t,i,s,l);this.radialSegments=i,this.indices=new F.BufferAttribute(new Uint16Array(c.indices),1),this.geometry.setIndex(this.indices),this.vertices=new F.BufferAttribute(new Float32Array(c.vertices),3),this.normals=new F.BufferAttribute(new Float32Array(c.normals),3),this.geometry.setAttribute("position",this.vertices),this.geometry.setAttribute("normal",this.normals);const u=new F.Mesh(this.geometry,e);return this.mesh=u,this}dispose(){this.geometry.dispose()}update(e,t){const n=N.generateRadial(t,this.radialSegments),o=N.generateNormal(t,this.radialSegments),r=N.generateBufferData(e,this.radialSegments,n,o);this.indices.count>r.indices.length?(this.indices.set(new Uint16Array(r.indices)),this.vertices.set(new Float32Array(r.vertices)),this.normals.set(new Float32Array(r.normals)),this.geometry.setDrawRange(0,r.indices.length-1),this.indices.needsUpdate=!0,this.vertices.needsUpdate=!0,this.normals.needsUpdate=!0):this.indices.counta[e]}for(let t=0;t<=2*Math.PI;t+=r)n[0]=Math.cos(t),n[1]=Math.sin(t),a.push(n.map(t=>t*e));return()=>a}static generateNormal(e,t){const n=[],o=[],r=2*Math.PI/t,a=[];if(Array.isArray(e)){for(let e=0;e<=2*Math.PI;e+=r)o[0]=Math.cos(e),o[1]=Math.sin(e),n.push([...o]);for(let t=0;ta[e]}for(let e=0;e<=2*Math.PI;e+=r)a.push([Math.cos(e),Math.sin(e),0]);return()=>a}static generateBufferData(e,t,n,o){const r=[],a=[];let i=[];const s=[0,0,0],l=[0,0,0],c=[[1,0,0],[0,1,0],[0,0,1]];let u,d,h,p,m=[0,0,0],f=[0,0,0],g=[0,0,0],y=0;function b(){if(u=e[y],d=e[y+1],f[0]=d[0]-u[0],f[1]=d[1]-u[1],f[2]=d[2]-u[2],h=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]),0==h)return y++,void(i=i.slice(0,-6*t));p=h,f=f.map(e=>e/h);const b=c.map(e=>e[0]*f[0]+e[1]*f[1]+e[2]*f[2]);Math.abs(b[0])<=Math.abs(b[1])&&Math.abs(b[0])<=Math.abs(b[2])?(m[0]=1-b[0]*f[0],m[1]=0-b[0]*f[1],m[2]=0-b[0]*f[2]):Math.abs(b[1])<=Math.abs(b[2])&&Math.abs(b[1])<=Math.abs(b[0])?(m[0]=0-b[1]*f[0],m[1]=1-b[1]*f[1],m[2]=0-b[1]*f[2]):(m[0]=0-b[2]*f[0],m[1]=0-b[2]*f[1],m[2]=1-b[2]*f[2]),g[0]=m[2]*f[1]-m[1]*f[2],g[1]=m[0]*f[2]-m[2]*f[0],g[2]=m[1]*f[0]-m[0]*f[1];let w=n(y),v=o(y);const x=t;for(let e=0;ee/h);const i=c.map(e=>e[0]*f[0]+e[1]*f[1]+e[2]*f[2]);Math.abs(i[0])0)for(let r=t;r=t;r-=o)a=ce(r/o|0,e[r],e[r+1],a);return a&&oe(a,a.next)&&(ue(a),a=a.next),a}function G(e,t){if(!e)return e;t||(t=e);let n,o=e;do{if(n=!1,o.steiner||!oe(o,o.next)&&0!==ne(o.prev,o,o.next))o=o.next;else{if(ue(o),o=t=o.prev,o===o.next)break;n=!0}}while(n||o!==t);return t}function U(e,t,n,o,r,a,i){if(!e)return;!i&&a&&function(e,t,n,o){let r=e;do{0===r.z&&(r.z=J(r.x,r.y,t,n,o)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let o,r=e;e=null;let a=null;for(t=0;r;){t++;let i=r,s=0;for(let e=0;e0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(o=r,r=r.nextZ,s--):(o=i,i=i.nextZ,l--),a?a.nextZ=o:e=o,o.prevZ=a,a=o;r=i}a.nextZ=null,n*=2}while(t>1)}(r)}(e,o,r,a);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(a?W(e,o,r,a):H(e))t.push(l.i,e.i,c.i),ue(e),e=c.next,s=c.next;else if((e=c)===s){i?1===i?U(e=X(G(e),t),t,n,o,r,a,2):2===i&&q(e,t,n,o,r,a):U(G(e),t,n,o,r,a,1);break}}}function H(e){const t=e.prev,n=e,o=e.next;if(ne(t,n,o)>=0)return!1;const r=t.x,a=n.x,i=o.x,s=t.y,l=n.y,c=o.y,u=Math.min(r,a,i),d=Math.min(s,l,c),h=Math.max(r,a,i),p=Math.max(s,l,c);let m=o.next;for(;m!==t;){if(m.x>=u&&m.x<=h&&m.y>=d&&m.y<=p&&ee(r,s,a,l,i,c,m.x,m.y)&&ne(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function W(e,t,n,o){const r=e.prev,a=e,i=e.next;if(ne(r,a,i)>=0)return!1;const s=r.x,l=a.x,c=i.x,u=r.y,d=a.y,h=i.y,p=Math.min(s,l,c),m=Math.min(u,d,h),f=Math.max(s,l,c),g=Math.max(u,d,h),y=J(p,m,t,n,o),b=J(f,g,t,n,o);let w=e.prevZ,v=e.nextZ;for(;w&&w.z>=y&&v&&v.z<=b;){if(w.x>=p&&w.x<=f&&w.y>=m&&w.y<=g&&w!==r&&w!==i&&ee(s,u,l,d,c,h,w.x,w.y)&&ne(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==i&&ee(s,u,l,d,c,h,v.x,v.y)&&ne(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;w&&w.z>=y;){if(w.x>=p&&w.x<=f&&w.y>=m&&w.y<=g&&w!==r&&w!==i&&ee(s,u,l,d,c,h,w.x,w.y)&&ne(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=b;){if(v.x>=p&&v.x<=f&&v.y>=m&&v.y<=g&&v!==r&&v!==i&&ee(s,u,l,d,c,h,v.x,v.y)&&ne(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function X(e,t){let n=e;do{const o=n.prev,r=n.next.next;!oe(o,r)&&re(o,n,n.next,r)&&se(o,r)&&se(r,o)&&(t.push(o.i,n.i,r.i),ue(n),ue(n.next),n=e=r),n=n.next}while(n!==e);return G(n)}function q(e,t,n,o,r,a){let i=e;do{let e=i.next.next;for(;e!==i.prev;){if(i.i!==e.i&&te(i,e)){let s=le(i,e);return i=G(i,i.next),s=G(s,s.next),U(i,t,n,o,r,a,0),void U(s,t,n,o,r,a,0)}e=e.next}i=i.next}while(i!==e)}function Z(e,t){let n=e.x-t.x;if(0===n&&(n=e.y-t.y,0===n)){n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return n}function K(e,t){const n=function(e,t){let n=t;const o=e.x,r=e.y;let a,i=-1/0;if(oe(e,n))return n;do{if(oe(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=o&&e>i&&(i=e,a=n.x=n.x&&n.x>=l&&o!==n.x&&Q(ra.x||n.x===a.x&&Y(a,n)))&&(a=n,u=t)}n=n.next}while(n!==s);return a}(e,t);if(!n)return t;const o=le(n,e);return G(o,o.next),G(n,n.next)}function Y(e,t){return ne(e.prev,e,t.prev)<0&&ne(t.next,e,e.next)<0}function J(e,t,n,o,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-o)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $(e){let t=e,n=e;do{(t.x=(e-i)*(a-s)&&(e-i)*(o-s)>=(n-i)*(t-s)&&(n-i)*(a-s)>=(r-i)*(o-s)}function ee(e,t,n,o,r,a,i,s){return!(e===i&&t===s)&&Q(e,t,n,o,r,a,i,s)}function te(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&re(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(se(e,t)&&se(t,e)&&function(e,t){let n=e,o=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next}while(n!==e);return o}(e,t)&&(ne(e.prev,e,t.prev)||ne(e,t.prev,t))||oe(e,t)&&ne(e.prev,e,e.next)>0&&ne(t.prev,t,t.next)>0)}function ne(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function oe(e,t){return e.x===t.x&&e.y===t.y}function re(e,t,n,o){const r=ie(ne(e,t,n)),a=ie(ne(e,t,o)),i=ie(ne(n,o,e)),s=ie(ne(n,o,t));return r!==a&&i!==s||(!(0!==r||!ae(e,n,t))||(!(0!==a||!ae(e,o,t))||(!(0!==i||!ae(n,e,o))||!(0!==s||!ae(n,t,o)))))}function ae(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ie(e){return e>0?1:e<0?-1:0}function se(e,t){return ne(e.prev,e,e.next)<0?ne(e,t,e.next)>=0&&ne(e,e.prev,t)>=0:ne(e,t,e.prev)<0||ne(e,e.next,t)<0}function le(e,t){const n=de(e.i,e.x,e.y),o=de(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function ce(e,t,n,o){const r=de(e,t,n);return o?(r.next=o.next,r.prev=o,o.next.prev=r,o.next=r):(r.prev=r,r.next=r),r}function ue(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function de(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function he(e,t,n,o){let r=0;for(let a=t,i=n-o;a80*n){s=e[0],l=e[1];let t=s,o=l;for(let a=n;at&&(t=n),r>o&&(o=r)}c=Math.max(t-s,o-l),c=0!==c?32767/c:0}return U(a,i,n,s,l,c,0),i},deviation:function(e,t,n,o){const r=t&&t.length,a=r?t[0]*n:e.length;let i=Math.abs(he(e,0,a,n));if(r)for(let o=0,r=t.length;o=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(fe&&e.forEach&&e.forEach===fe)e.forEach(t,n);else if(e.length===e.length+0){var o,r=void 0;for(r=0,o=e.length;r1?ye.toArray(arguments):arguments[0];return ye.each(be,function(t){if(t.litmus(e))return ye.each(t.conversions,function(t,n){if(we=t.read(e),!1===ve&&!1!==we)return ve=we,we.conversionName=n,we.conversion=t,ye.BREAK}),ye.BREAK}),ve},_e=void 0,Ae={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),i=n*(1-r*t),s=n*(1-(1-r)*t),l=[[n,s,a],[i,n,a],[a,n,s],[a,i,n],[s,a,n],[n,a,i]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),r=Math.max(e,t,n),a=r-o,i=void 0;return 0===r?{h:NaN,s:0,v:0}:(i=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(i/=6)<0&&(i+=1),{h:360*i,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e);return o=this.hex_with_component(o,1,t),o=this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(_e=8*t)|e&~(255<<_e)}},ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ce=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Se=function(){function e(e,t){for(var n=0;n-1?t.length-t.indexOf(".")-1:0}var Ge=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=o||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,ye.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=Ve(r.__impliedStep),r}return Me(e,Ie),Se(e,[{key:"setValue",value:function(t){var n=t;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!==0&&(n=Math.round(n/this.__step)*this.__step),Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=Ve(e),this}}]),e}();var Ue=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,o));r.__truncationSuspended=!1;var a=r,i=void 0;function s(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=i-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),i=e.clientY}function c(){Fe.unbind(window,"mousemove",l),Fe.unbind(window,"mouseup",c),s()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Fe.bind(r.__input,"change",function(){var e=parseFloat(a.__input.value);ye.isNaN(e)||a.setValue(e)}),Fe.bind(r.__input,"blur",function(){s()}),Fe.bind(r.__input,"mousedown",function(e){Fe.bind(window,"mousemove",l),Fe.bind(window,"mouseup",c),i=e.clientY}),Fe.bind(r.__input,"keydown",function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,s())}),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Me(e,Ge),Se(e,[{key:"updateDisplay",value:function(){var t,n,o;return this.__input.value=this.__truncationSuspended?this.getValue():(t=this.getValue(),n=this.__precision,o=Math.pow(10,n),Math.round(t*o)/o),Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function He(e,t,n,o,r){return o+(e-t)/(n-t)*(r-o)}var We=function(){function e(t,n,o,r,a){Ce(this,e);var i=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:o,max:r,step:a})),s=i;function l(e){e.preventDefault();var t=s.__background.getBoundingClientRect();return s.setValue(He(e.clientX,t.left,t.right,s.__min,s.__max)),!1}function c(){Fe.unbind(window,"mousemove",l),Fe.unbind(window,"mouseup",c),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function u(e){var t=e.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(He(t,n.left,n.right,s.__min,s.__max))}function d(){Fe.unbind(window,"touchmove",u),Fe.unbind(window,"touchend",d),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return i.__background=document.createElement("div"),i.__foreground=document.createElement("div"),Fe.bind(i.__background,"mousedown",function(e){document.activeElement.blur(),Fe.bind(window,"mousemove",l),Fe.bind(window,"mouseup",c),l(e)}),Fe.bind(i.__background,"touchstart",function(e){if(1!==e.touches.length)return;Fe.bind(window,"touchmove",u),Fe.bind(window,"touchend",d),u(e)}),Fe.addClass(i.__background,"slider"),Fe.addClass(i.__foreground,"slider-fg"),i.updateDisplay(),i.__background.appendChild(i.__foreground),i.domElement.appendChild(i.__background),i}return Me(e,Ge),Se(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",Ee(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),Xe=function(){function e(t,n,o){Ce(this,e);var r=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===o?"Fire":o,Fe.bind(r.__button,"click",function(e){return e.preventDefault(),a.fire(),!1}),Fe.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Me(e,Ie),Se(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(),qe=function(){function e(t,n){Ce(this,e);var o=Re(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));o.__color=new Oe(o.getValue()),o.__temp=new Oe(0);var r=o;o.domElement=document.createElement("div"),Fe.makeSelectable(o.domElement,!1),o.__selector=document.createElement("div"),o.__selector.className="selector",o.__saturation_field=document.createElement("div"),o.__saturation_field.className="saturation-field",o.__field_knob=document.createElement("div"),o.__field_knob.className="field-knob",o.__field_knob_border="2px solid ",o.__hue_knob=document.createElement("div"),o.__hue_knob.className="hue-knob",o.__hue_field=document.createElement("div"),o.__hue_field.className="hue-field",o.__input=document.createElement("input"),o.__input.type="text",o.__input_textShadow="0 1px 1px ",Fe.bind(o.__input,"keydown",function(e){13===e.keyCode&&d.call(this)}),Fe.bind(o.__input,"blur",d),Fe.bind(o.__selector,"mousedown",function(){Fe.addClass(this,"drag").bind(window,"mouseup",function(){Fe.removeClass(r.__selector,"drag")})}),Fe.bind(o.__selector,"touchstart",function(){Fe.addClass(this,"drag").bind(window,"touchend",function(){Fe.removeClass(r.__selector,"drag")})});var a,i=document.createElement("div");function s(e){p(e),Fe.bind(window,"mousemove",p),Fe.bind(window,"touchmove",p),Fe.bind(window,"mouseup",c),Fe.bind(window,"touchend",c)}function l(e){m(e),Fe.bind(window,"mousemove",m),Fe.bind(window,"touchmove",m),Fe.bind(window,"mouseup",u),Fe.bind(window,"touchend",u)}function c(){Fe.unbind(window,"mousemove",p),Fe.unbind(window,"touchmove",p),Fe.unbind(window,"mouseup",c),Fe.unbind(window,"touchend",c),h()}function u(){Fe.unbind(window,"mousemove",m),Fe.unbind(window,"touchmove",m),Fe.unbind(window,"mouseup",u),Fe.unbind(window,"touchend",u),h()}function d(){var e=xe(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function h(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,a=n.clientY,i=(o-t.left)/(t.right-t.left),s=1-(a-t.top)/(t.bottom-t.top);return s>1?s=1:s<0&&(s=0),i>1?i=1:i<0&&(i=0),r.__color.v=s,r.__color.s=i,r.setValue(r.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return ye.extend(o.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),ye.extend(o.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:o.__field_knob_border+(o.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),ye.extend(o.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),ye.extend(o.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),ye.extend(i.style,{width:"100%",height:"100%",background:"none"}),Ke(i,"top","rgba(0,0,0,0)","#000"),ye.extend(o.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=o.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",ye.extend(o.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:o.__input_textShadow+"rgba(0,0,0,0.7)"}),Fe.bind(o.__saturation_field,"mousedown",s),Fe.bind(o.__saturation_field,"touchstart",s),Fe.bind(o.__field_knob,"mousedown",s),Fe.bind(o.__field_knob,"touchstart",s),Fe.bind(o.__hue_field,"mousedown",l),Fe.bind(o.__hue_field,"touchstart",l),o.__saturation_field.appendChild(i),o.__selector.appendChild(o.__field_knob),o.__selector.appendChild(o.__saturation_field),o.__selector.appendChild(o.__hue_field),o.__hue_field.appendChild(o.__hue_knob),o.domElement.appendChild(o.__input),o.domElement.appendChild(o.__selector),o.updateDisplay(),o}return Me(e,Ie),Se(e,[{key:"updateDisplay",value:function(){var e=xe(this.getValue());if(!1!==e){var t=!1;ye.each(Oe.COMPONENTS,function(n){if(!ye.isUndefined(e[n])&&!ye.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}},this),t&&ye.extend(this.__color.__state,e)}ye.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,o=255-n;ye.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,Ke(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),ye.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})}}]),e}(),Ze=["-moz-","-o-","-webkit-","-ms-",""];function Ke(e,t,n,o){e.style.background="",ye.each(Ze,function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+o+" 100%); "})}var Ye=function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(o)}catch(e){}},Je=function(e,t){var n=e[t];return ye.isArray(arguments[2])||ye.isObject(arguments[2])?new Ne(e,t,arguments[2]):ye.isNumber(n)?ye.isNumber(arguments[2])&&ye.isNumber(arguments[3])?ye.isNumber(arguments[4])?new We(e,t,arguments[2],arguments[3],arguments[4]):new We(e,t,arguments[2],arguments[3]):ye.isNumber(arguments[4])?new Ue(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Ue(e,t,{min:arguments[2],max:arguments[3]}):ye.isString(n)?new je(e,t):ye.isFunction(n)?new Xe(e,t,""):ye.isBoolean(n)?new De(e,t):null};var $e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},Qe=function(){function e(){Ce(this,e),this.backgroundElement=document.createElement("div"),ye.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Fe.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),ye.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Fe.bind(this.backgroundElement,"click",function(){t.hide()})}return Se(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),ye.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Fe.unbind(e.domElement,"webkitTransitionEnd",t),Fe.unbind(e.domElement,"transitionend",t),Fe.unbind(e.domElement,"oTransitionEnd",t)};Fe.bind(this.domElement,"webkitTransitionEnd",t),Fe.bind(this.domElement,"transitionend",t),Fe.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Fe.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Fe.getHeight(this.domElement)/2+"px"}}]),e}(),et=function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");Ye(et);var tt="Default",nt=function(){try{return!!window.localStorage}catch(e){return!1}}(),ot=void 0,rt=!0,at=void 0,it=!1,st=[],lt=function e(t){var n=this,o=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Fe.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=ye.defaults(o,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),o=ye.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),ye.isUndefined(o.load)?o.load={preset:tt}:o.preset&&(o.load.preset=o.preset),ye.isUndefined(o.parent)&&o.hideable&&st.push(this),o.resizable=ye.isUndefined(o.parent)&&o.resizable,o.autoPlace&&ye.isUndefined(o.scrollable)&&(o.scrollable=!0);var r,a=nt&&"true"===localStorage.getItem(mt(this,"isLocal")),i=void 0,s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return o.parent}},scrollable:{get:function(){return o.scrollable}},autoPlace:{get:function(){return o.autoPlace}},closeOnTop:{get:function(){return o.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:o.load.preset},set:function(e){n.parent?n.getRoot().preset=e:o.load.preset=e,function(e){for(var t=0;t1){var o=n.__li.nextElementSibling;return n.remove(),pt(e,n.object,n.property,{before:o,factoryArgs:[ye.toArray(arguments)]})}if(ye.isArray(t)||ye.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),pt(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof We){var o=new Ue(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});ye.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(e){var t=n[e],r=o[e];n[e]=o[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(o,e),t.apply(n,e)}}),Fe.addClass(t,"has-slider"),n.domElement.insertBefore(o.domElement,n.domElement.firstElementChild)}else if(n instanceof Ue){var r=function(t){if(ye.isNumber(n.__min)&&ye.isNumber(n.__max)){var o=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=pt(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(o),r&&a.listen(),a}return t};n.min=ye.compose(r,n.min),n.max=ye.compose(r,n.max)}else n instanceof De?(Fe.bind(t,"click",function(){Fe.fakeEvent(n.__checkbox,"click")}),Fe.bind(n.__checkbox,"click",function(e){e.stopPropagation()})):n instanceof Xe?(Fe.bind(t,"click",function(){Fe.fakeEvent(n.__button,"click")}),Fe.bind(t,"mouseover",function(){Fe.addClass(n.__button,"hover")}),Fe.bind(t,"mouseout",function(){Fe.removeClass(n.__button,"hover")})):n instanceof qe&&(Fe.addClass(t,"color"),n.updateDisplay=ye.compose(function(e){return t.style.borderLeftColor=n.__color.toString(),e},n.updateDisplay),n.updateDisplay());n.setValue=ye.compose(function(t){return e.getRoot().__preset_select&&n.isModified()&&dt(e.getRoot(),!0),t},n.setValue)}(e,l,r),e.__controllers.push(r),r}function mt(e,t){return document.location.href+"."+t}function ft(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function gt(e,t){t.style.display=e.useLocalStorage?"block":"none"}function yt(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function o(){Fe.removeClass(e.__closeButton,lt.CLASS_DRAG),Fe.unbind(window,"mousemove",n),Fe.unbind(window,"mouseup",o)}function r(r){return r.preventDefault(),t=r.clientX,Fe.addClass(e.__closeButton,lt.CLASS_DRAG),Fe.bind(window,"mousemove",n),Fe.bind(window,"mouseup",o),!1}e.__resize_handle=document.createElement("div"),ye.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Fe.bind(e.__resize_handle,"mousedown",r),Fe.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function bt(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function wt(e,t){var n={};return ye.each(e.__rememberedObjects,function(o,r){var a={},i=e.__rememberedObjectIndecesToControllers[r];ye.each(i,function(e,n){a[n]=t?e.initialValue:e.getValue()}),n[r]=a}),n}function vt(e){0!==e.length&&$e.call(window,function(){vt(e)}),ye.each(e,function(e){e.updateDisplay()})}lt.toggleHide=function(){it=!it,ye.each(st,function(e){e.domElement.style.display=it?"none":""})},lt.CLASS_AUTO_PLACE="a",lt.CLASS_AUTO_PLACE_CONTAINER="ac",lt.CLASS_MAIN="main",lt.CLASS_CONTROLLER_ROW="cr",lt.CLASS_TOO_TALL="taller-than-window",lt.CLASS_CLOSED="closed",lt.CLASS_CLOSE_BUTTON="close-button",lt.CLASS_CLOSE_TOP="close-top",lt.CLASS_CLOSE_BOTTOM="close-bottom",lt.CLASS_DRAG="drag",lt.DEFAULT_WIDTH=245,lt.TEXT_CLOSED="Close Controls",lt.TEXT_OPEN="Open Controls",lt._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||lt.toggleHide()},Fe.bind(window,"keydown",lt._keydownHandler,!1),ye.extend(lt.prototype,{add:function(e,t){return pt(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return pt(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;ye.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&at.removeChild(this.domElement);var e=this;ye.each(this.__folders,function(t){e.removeFolder(t)}),Fe.unbind(window,"keydown",lt._keydownHandler,!1),ut(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new lt(t);this.__folders[e]=n;var o=ct(this,n.domElement);return Fe.addClass(o,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],ut(e);var t=this;ye.each(e.__folders,function(t){e.removeFolder(t)}),ye.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Fe.getOffset(e.__ul).top,n=0;ye.each(e.__ul.childNodes,function(t){e.autoPlace&&t===e.__save_row||(n+=Fe.getHeight(t))}),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;ye.each(Array.prototype.slice.call(arguments),function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Fe.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Fe.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Fe.addClass(n,"button gears");var o=document.createElement("span");o.innerHTML="Save",Fe.addClass(o,"button"),Fe.addClass(o,"save");var r=document.createElement("span");r.innerHTML="New",Fe.addClass(r,"button"),Fe.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Fe.addClass(a,"button"),Fe.addClass(a,"revert");var i=e.__preset_select=document.createElement("select");e.load&&e.load.remembered?ye.each(e.load.remembered,function(t,n){ft(e,n,n===e.preset)}):ft(e,tt,!1);if(Fe.bind(i,"change",function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=wt(this)),e.folders={},ye.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=wt(this),dt(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[tt]=wt(this,!0)),this.load.remembered[e]=wt(this),this.preset=e,ft(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){ye.each(this.__controllers,function(t){this.getRoot().load.remembered?ht(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),ye.each(this.__folders,function(e){e.revert(e)}),e||dt(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&vt(this.__listening)},updateDisplay:function(){ye.each(this.__controllers,function(e){e.updateDisplay()}),ye.each(this.__folders,function(e){e.updateDisplay()})}});var xt={Color:Oe,math:Ae,interpret:xe},_t={Controller:Ie,BooleanController:De,OptionController:Ne,StringController:je,NumberController:Ge,NumberControllerBox:Ue,NumberControllerSlider:We,FunctionController:Xe,ColorController:qe},At={dom:Fe},kt={GUI:lt},Ct=lt,St={color:xt,controllers:_t,dom:At,gui:kt,GUI:Ct},Et=Object.freeze({__proto__:null,color:xt,controllers:_t,dom:At,gui:kt,GUI:Ct,default:St});const{min:Mt,max:Rt}=Math;var Ot=(e,t=0,n=1)=>Mt(Rt(t,e),n),Tt=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=Ot(e[t],0,255)):3===t&&(e[t]=Ot(e[t],0,1));return e};const Lt={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])Lt[`[object ${e}]`]=e.toLowerCase();function It(e){return Lt[Object.prototype.toString.call(e)]||"object"}var Pt=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):"object"==It(e[0])&&t?t.split("").filter(t=>void 0!==e[0][t]).map(t=>e[0][t]):e[0].slice(0),Bt=e=>{if(e.length<2)return null;const t=e.length-1;return"string"==It(e[t])?e[t].toLowerCase():null};const{PI:zt,min:Ft,max:Dt}=Math,Nt=e=>Math.round(100*e)/100,jt=e=>Math.round(100*e)/100,Vt=2*zt,Gt=zt/3,Ut=zt/180,Ht=180/zt;function Wt(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var Xt={format:{},autodetect:[]};var qt=class{constructor(...e){const t=this;if("object"===It(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=Bt(e),o=!1;if(!n){o=!0,Xt.sorted||(Xt.autodetect=Xt.autodetect.sort((e,t)=>t.p-e.p),Xt.sorted=!0);for(let t of Xt.autodetect)if(n=t.test(...e),n)break}if(!Xt.format[n])throw new Error("unknown format: "+e);{const r=Xt.format[n].apply(null,o?e:e.slice(0,-1));t._rgb=Tt(r)}3===t._rgb.length&&t._rgb.push(1)}toString(){return"function"==It(this.hex)?this.hex():`[${this._rgb.join(",")}]`}};const Zt=(...e)=>new qt(...e);Zt.version="3.2.0";var Kt=Zt;var Yt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};const Jt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$t=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Qt=e=>{if(e.match(Jt)){4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]);const t=parseInt(e,16);return[t>>16,t>>8&255,255&t,1]}if(e.match($t)){5!==e.length&&9!==e.length||(e=e.substr(1)),4===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error(`unknown hex color: ${e}`)},{round:en}=Math,tn=(...e)=>{let[t,n,o,r]=Pt(e,"rgba"),a=Bt(e)||"auto";void 0===r&&(r=1),"auto"===a&&(a=r<1?"rgba":"rgb"),t=en(t),n=en(n),o=en(o);let i="000000"+(t<<16|n<<8|o).toString(16);i=i.substr(i.length-6);let s="0"+en(255*r).toString(16);switch(s=s.substr(s.length-2),a.toLowerCase()){case"rgba":return`#${i}${s}`;case"argb":return`#${s}${i}`;default:return`#${i}`}};qt.prototype.name=function(){const e=tn(this._rgb,"rgb");for(let t of Object.keys(Yt))if(Yt[t]===e)return t.toLowerCase();return e},Xt.format.named=e=>{if(e=e.toLowerCase(),Yt[e])return Qt(Yt[e]);throw new Error("unknown color name: "+e)},Xt.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&"string"===It(e)&&Yt[e.toLowerCase()])return"named"}}),qt.prototype.alpha=function(e,t=!1){return void 0!==e&&"number"===It(e)?t?(this._rgb[3]=e,this):new qt([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},qt.prototype.clipped=function(){return this._rgb._clipped||!1};const nn={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},on=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function rn(e){const t=on.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);nn.labWhitePoint=e,nn.Xn=t[0],nn.Zn=t[1]}function an(){return nn.labWhitePoint}const sn=(...e)=>{e=Pt(e,"lab");const[t,n,o]=e,[r,a,i]=ln(t,n,o),[s,l,c]=un(r,a,i);return[s,l,c,e.length>3?e[3]:1]},ln=(e,t,n)=>{const{kE:o,kK:r,kKE:a,Xn:i,Yn:s,Zn:l}=nn,c=(e+16)/116,u=.002*t+c,d=c-.005*n,h=u*u*u,p=d*d*d;return[(h>o?h:(116*u-16)/r)*i,(e>a?Math.pow((e+16)/116,3):e/r)*s,(p>o?p:(116*d-16)/r)*l]},cn=e=>{const t=Math.sign(e);return((e=Math.abs(e))<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)*t},un=(e,t,n)=>{const{MtxAdaptMa:o,MtxAdaptMaI:r,MtxXYZ2RGB:a,RefWhiteRGB:i,Xn:s,Yn:l,Zn:c}=nn,u=s*o.m00+l*o.m10+c*o.m20,d=s*o.m01+l*o.m11+c*o.m21,h=s*o.m02+l*o.m12+c*o.m22,p=i.X*o.m00+i.Y*o.m10+i.Z*o.m20,m=i.X*o.m01+i.Y*o.m11+i.Z*o.m21,f=i.X*o.m02+i.Y*o.m12+i.Z*o.m22,g=(e*o.m00+t*o.m10+n*o.m20)*(p/u),y=(e*o.m01+t*o.m11+n*o.m21)*(m/d),b=(e*o.m02+t*o.m12+n*o.m22)*(f/h),w=g*r.m00+y*r.m10+b*r.m20,v=g*r.m01+y*r.m11+b*r.m21,x=g*r.m02+y*r.m12+b*r.m22;return[255*cn(w*a.m00+v*a.m10+x*a.m20),255*cn(w*a.m01+v*a.m11+x*a.m21),255*cn(w*a.m02+v*a.m12+x*a.m22)]},dn=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb"),[a,i,s]=pn(t,n,o),[l,c,u]=function(e,t,n){const{Xn:o,Yn:r,Zn:a,kE:i,kK:s}=nn,l=e/o,c=t/r,u=n/a,d=l>i?Math.pow(l,1/3):(s*l+16)/116,h=c>i?Math.pow(c,1/3):(s*c+16)/116,p=u>i?Math.pow(u,1/3):(s*u+16)/116;return[116*h-16,500*(d-h),200*(h-p)]}(a,i,s);return[l,c,u,...r.length>0&&r[0]<1?[r[0]]:[]]};function hn(e){const t=Math.sign(e);return((e=Math.abs(e))<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}const pn=(e,t,n)=>{e=hn(e/255),t=hn(t/255),n=hn(n/255);const{MtxRGB2XYZ:o,MtxAdaptMa:r,MtxAdaptMaI:a,Xn:i,Yn:s,Zn:l,As:c,Bs:u,Cs:d}=nn;let h=e*o.m00+t*o.m10+n*o.m20,p=e*o.m01+t*o.m11+n*o.m21,m=e*o.m02+t*o.m12+n*o.m22;const f=i*r.m00+s*r.m10+l*r.m20,g=i*r.m01+s*r.m11+l*r.m21,y=i*r.m02+s*r.m12+l*r.m22;let b=h*r.m00+p*r.m10+m*r.m20,w=h*r.m01+p*r.m11+m*r.m21,v=h*r.m02+p*r.m12+m*r.m22;return b*=f/c,w*=g/u,v*=y/d,h=b*a.m00+w*a.m10+v*a.m20,p=b*a.m01+w*a.m11+v*a.m21,m=b*a.m02+w*a.m12+v*a.m22,[h,p,m]};qt.prototype.lab=function(){return dn(this._rgb)};const mn=(...e)=>new qt(...e,"lab");Object.assign(Kt,{lab:mn,getLabWhitePoint:an,setLabWhitePoint:rn}),Xt.format.lab=sn,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"lab"))&&3===e.length)return"lab"}}),qt.prototype.darken=function(e=1){const t=this.lab();return t[0]-=nn.Kn*e,new qt(t,"lab").alpha(this.alpha(),!0)},qt.prototype.brighten=function(e=1){return this.darken(-e)},qt.prototype.darker=qt.prototype.darken,qt.prototype.brighter=qt.prototype.brighten,qt.prototype.get=function(e){const[t,n]=e.split("."),o=this[t]();if(n){const e=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(e>-1)return o[e];throw new Error(`unknown channel ${n} in mode ${t}`)}return o};const{pow:fn}=Math;qt.prototype.luminance=function(e,t="rgb"){if(void 0!==e&&"number"===It(e)){if(0===e)return new qt([0,0,0,this._rgb[3]],"rgb");if(1===e)return new qt([255,255,255,this._rgb[3]],"rgb");let n=this.luminance(),o=20;const r=(n,a)=>{const i=n.interpolate(a,.5,t),s=i.luminance();return Math.abs(e-s)<1e-7||!o--?i:s>e?r(n,i):r(i,a)},a=(n>e?r(new qt([0,0,0]),this):r(this,new qt([255,255,255]))).rgb();return new qt([...a,this._rgb[3]])}return gn(...this._rgb.slice(0,3))};const gn=(e,t,n)=>.2126*(e=yn(e))+.7152*(t=yn(t))+.0722*(n=yn(n)),yn=e=>(e/=255)<=.03928?e/12.92:fn((e+.055)/1.055,2.4);var bn={},wn=(e,t,n=.5,...o)=>{let r=o[0]||"lrgb";if(bn[r]||o.length||(r=Object.keys(bn)[0]),!bn[r])throw new Error(`interpolation mode ${r} is not defined`);return"object"!==It(e)&&(e=new qt(e)),"object"!==It(t)&&(t=new qt(t)),bn[r](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))};qt.prototype.mix=qt.prototype.interpolate=function(e,t=.5,...n){return wn(this,e,t,...n)},qt.prototype.premultiply=function(e=!1){const t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new qt([t[0]*n,t[1]*n,t[2]*n,n],"rgb")};const{sin:vn,cos:xn}=Math,_n=(...e)=>{let[t,n,o]=Pt(e,"lch");return isNaN(o)&&(o=0),o*=Ut,[t,xn(o)*n,vn(o)*n]},An=(...e)=>{e=Pt(e,"lch");const[t,n,o]=e,[r,a,i]=_n(t,n,o),[s,l,c]=sn(r,a,i);return[s,l,c,e.length>3?e[3]:1]},{sqrt:kn,atan2:Cn,round:Sn}=Math,En=(...e)=>{const[t,n,o]=Pt(e,"lab"),r=kn(n*n+o*o);let a=(Cn(o,n)*Ht+360)%360;return 0===Sn(1e4*r)&&(a=Number.NaN),[t,r,a]},Mn=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb"),[a,i,s]=dn(t,n,o),[l,c,u]=En(a,i,s);return[l,c,u,...r.length>0&&r[0]<1?[r[0]]:[]]};qt.prototype.lch=function(){return Mn(this._rgb)},qt.prototype.hcl=function(){return Wt(Mn(this._rgb))};const Rn=(...e)=>new qt(...e,"lch"),On=(...e)=>new qt(...e,"hcl");Object.assign(Kt,{lch:Rn,hcl:On}),Xt.format.lch=An,Xt.format.hcl=(...e)=>{const t=Wt(Pt(e,"hcl"));return An(...t)},["lch","hcl"].forEach(e=>Xt.autodetect.push({p:2,test:(...t)=>{if("array"===It(t=Pt(t,e))&&3===t.length)return e}})),qt.prototype.saturate=function(e=1){const t=this.lch();return t[1]+=nn.Kn*e,t[1]<0&&(t[1]=0),new qt(t,"lch").alpha(this.alpha(),!0)},qt.prototype.desaturate=function(e=1){return this.saturate(-e)},qt.prototype.set=function(e,t,n=!1){const[o,r]=e.split("."),a=this[o]();if(r){const e=o.indexOf(r)-("ok"===o.substr(0,2)?2:0);if(e>-1){if("string"==It(t))switch(t.charAt(0)){case"+":case"-":a[e]+=+t;break;case"*":a[e]*=+t.substr(1);break;case"/":a[e]/=+t.substr(1);break;default:a[e]=+t}else{if("number"!==It(t))throw new Error("unsupported value for Color.set");a[e]=t}const r=new qt(a,o);return n?(this._rgb=r._rgb,this):r}throw new Error(`unknown channel ${r} in mode ${o}`)}return a},qt.prototype.tint=function(e=.5,...t){return wn(this,"white",e,...t)},qt.prototype.shade=function(e=.5,...t){return wn(this,"black",e,...t)};bn.rgb=(e,t,n)=>{const o=e._rgb,r=t._rgb;return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"rgb")};const{sqrt:Tn,pow:Ln}=Math;bn.lrgb=(e,t,n)=>{const[o,r,a]=e._rgb,[i,s,l]=t._rgb;return new qt(Tn(Ln(o,2)*(1-n)+Ln(i,2)*n),Tn(Ln(r,2)*(1-n)+Ln(s,2)*n),Tn(Ln(a,2)*(1-n)+Ln(l,2)*n),"rgb")};bn.lab=(e,t,n)=>{const o=e.lab(),r=t.lab();return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"lab")};var In=(e,t,n,o)=>{let r,a,i,s,l,c,u,d,h,p,m,f;return"hsl"===o?(r=e.hsl(),a=t.hsl()):"hsv"===o?(r=e.hsv(),a=t.hsv()):"hcg"===o?(r=e.hcg(),a=t.hcg()):"hsi"===o?(r=e.hsi(),a=t.hsi()):"lch"===o||"hcl"===o?(o="hcl",r=e.hcl(),a=t.hcl()):"oklch"===o&&(r=e.oklch().reverse(),a=t.oklch().reverse()),"h"!==o.substr(0,1)&&"oklch"!==o||([i,l,u]=r,[s,c,d]=a),isNaN(i)||isNaN(s)?isNaN(i)?isNaN(s)?p=Number.NaN:(p=s,1!=u&&0!=u||"hsv"==o||(h=c)):(p=i,1!=d&&0!=d||"hsv"==o||(h=l)):(f=s>i&&s-i>180?s-(i+360):s180?s+360-i:s-i,p=i+n*f),void 0===h&&(h=l+n*(c-l)),m=u+n*(d-u),new qt("oklch"===o?[m,h,p]:[p,h,m],o)};const Pn=(e,t,n)=>In(e,t,n,"lch");bn.lch=Pn,bn.hcl=Pn;qt.prototype.num=function(){return((...e)=>{const[t,n,o]=Pt(e,"rgb");return(t<<16)+(n<<8)+o})(this._rgb)};const Bn=(...e)=>new qt(...e,"num");Object.assign(Kt,{num:Bn}),Xt.format.num=e=>{if("number"==It(e)&&e>=0&&e<=16777215){return[e>>16,e>>8&255,255&e,1]}throw new Error("unknown num color: "+e)},Xt.autodetect.push({p:5,test:(...e)=>{if(1===e.length&&"number"===It(e[0])&&e[0]>=0&&e[0]<=16777215)return"num"}});bn.num=(e,t,n)=>{const o=e.num(),r=t.num();return new qt(o+n*(r-o),"num")};const{floor:zn}=Math;qt.prototype.hcg=function(){return((...e)=>{const[t,n,o]=Pt(e,"rgb"),r=Ft(t,n,o),a=Dt(t,n,o),i=a-r,s=100*i/255,l=r/(255-i)*100;let c;return 0===i?c=Number.NaN:(t===a&&(c=(n-o)/i),n===a&&(c=2+(o-t)/i),o===a&&(c=4+(t-n)/i),c*=60,c<0&&(c+=360)),[c,s,l]})(this._rgb)};const Fn=(...e)=>new qt(...e,"hcg");Kt.hcg=Fn,Xt.format.hcg=(...e)=>{e=Pt(e,"hcg");let t,n,o,[r,a,i]=e;i*=255;const s=255*a;if(0===a)t=n=o=i;else{360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60;const e=zn(r),l=r-e,c=i*(1-a),u=c+s*(1-l),d=c+s*l,h=c+s;switch(e){case 0:[t,n,o]=[h,d,c];break;case 1:[t,n,o]=[u,h,c];break;case 2:[t,n,o]=[c,h,d];break;case 3:[t,n,o]=[c,u,h];break;case 4:[t,n,o]=[d,c,h];break;case 5:[t,n,o]=[h,c,u]}}return[t,n,o,e.length>3?e[3]:1]},Xt.autodetect.push({p:1,test:(...e)=>{if("array"===It(e=Pt(e,"hcg"))&&3===e.length)return"hcg"}});bn.hcg=(e,t,n)=>In(e,t,n,"hcg");const{cos:Dn}=Math,{min:Nn,sqrt:jn,acos:Vn}=Math;qt.prototype.hsi=function(){return((...e)=>{let t,[n,o,r]=Pt(e,"rgb");n/=255,o/=255,r/=255;const a=Nn(n,o,r),i=(n+o+r)/3,s=i>0?1-a/i:0;return 0===s?t=NaN:(t=(n-o+(n-r))/2,t/=jn((n-o)*(n-o)+(n-r)*(o-r)),t=Vn(t),r>o&&(t=Vt-t),t/=Vt),[360*t,s,i]})(this._rgb)};const Gn=(...e)=>new qt(...e,"hsi");Kt.hsi=Gn,Xt.format.hsi=(...e)=>{e=Pt(e,"hsi");let t,n,o,[r,a,i]=e;return isNaN(r)&&(r=0),isNaN(a)&&(a=0),r>360&&(r-=360),r<0&&(r+=360),r/=360,r<1/3?(o=(1-a)/3,t=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,n=1-(o+t)):r<2/3?(r-=1/3,t=(1-a)/3,n=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,o=1-(t+n)):(r-=2/3,n=(1-a)/3,o=(1+a*Dn(Vt*r)/Dn(Gt-Vt*r))/3,t=1-(n+o)),t=Ot(i*t*3),n=Ot(i*n*3),o=Ot(i*o*3),[255*t,255*n,255*o,e.length>3?e[3]:1]},Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsi"))&&3===e.length)return"hsi"}});bn.hsi=(e,t,n)=>In(e,t,n,"hsi");const Un=(...e)=>{e=Pt(e,"hsl");const[t,n,o]=e;let r,a,i;if(0===n)r=a=i=255*o;else{const e=[0,0,0],s=[0,0,0],l=o<.5?o*(1+n):o+n-o*n,c=2*o-l,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&(e[t]-=1),6*e[t]<1?s[t]=c+6*(l-c)*e[t]:2*e[t]<1?s[t]=l:3*e[t]<2?s[t]=c+(l-c)*(2/3-e[t])*6:s[t]=c;[r,a,i]=[255*s[0],255*s[1],255*s[2]]}return e.length>3?[r,a,i,e[3]]:[r,a,i,1]},Hn=(...e)=>{e=Pt(e,"rgba");let[t,n,o]=e;t/=255,n/=255,o/=255;const r=Ft(t,n,o),a=Dt(t,n,o),i=(a+r)/2;let s,l;return a===r?(s=0,l=Number.NaN):s=i<.5?(a-r)/(a+r):(a-r)/(2-a-r),t==a?l=(n-o)/(a-r):n==a?l=2+(o-t)/(a-r):o==a&&(l=4+(t-n)/(a-r)),l*=60,l<0&&(l+=360),e.length>3&&void 0!==e[3]?[l,s,i,e[3]]:[l,s,i]};qt.prototype.hsl=function(){return Hn(this._rgb)};const Wn=(...e)=>new qt(...e,"hsl");Kt.hsl=Wn,Xt.format.hsl=Un,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsl"))&&3===e.length)return"hsl"}});bn.hsl=(e,t,n)=>In(e,t,n,"hsl");const{floor:Xn}=Math,{min:qn,max:Zn}=Math;qt.prototype.hsv=function(){return((...e)=>{e=Pt(e,"rgb");let[t,n,o]=e;const r=qn(t,n,o),a=Zn(t,n,o),i=a-r;let s,l,c;return c=a/255,0===a?(s=Number.NaN,l=0):(l=i/a,t===a&&(s=(n-o)/i),n===a&&(s=2+(o-t)/i),o===a&&(s=4+(t-n)/i),s*=60,s<0&&(s+=360)),[s,l,c]})(this._rgb)};const Kn=(...e)=>new qt(...e,"hsv");Kt.hsv=Kn,Xt.format.hsv=(...e)=>{e=Pt(e,"hsv");let t,n,o,[r,a,i]=e;if(i*=255,0===a)t=n=o=i;else{360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60;const e=Xn(r),s=r-e,l=i*(1-a),c=i*(1-a*s),u=i*(1-a*(1-s));switch(e){case 0:[t,n,o]=[i,u,l];break;case 1:[t,n,o]=[c,i,l];break;case 2:[t,n,o]=[l,i,u];break;case 3:[t,n,o]=[l,c,i];break;case 4:[t,n,o]=[u,l,i];break;case 5:[t,n,o]=[i,l,c]}}return[t,n,o,e.length>3?e[3]:1]},Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"hsv"))&&3===e.length)return"hsv"}});function Yn(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let o=t[0].length,r=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>r.map(t=>Array.isArray(e)?e.reduce((e,n,o)=>e+n*(t[o]||0),0):t.reduce((t,n)=>t+n*e,0)));return 1===n&&(a=a[0]),1===o?a.map(e=>e[0]):a}bn.hsv=(e,t,n)=>In(e,t,n,"hsv");const Jn=(...e)=>{e=Pt(e,"lab");const[t,n,o,...r]=e,[a,i,s]=(l=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],c=Yn([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[t,n,o]),Yn(l,c.map(e=>e**3)));var l,c;const[u,d,h]=un(a,i,s);return[u,d,h,...r.length>0&&r[0]<1?[r[0]]:[]]};const $n=(...e)=>{const[t,n,o,...r]=Pt(e,"rgb");return[...function(e){const t=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],n=Yn([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e);return Yn(t,n.map(e=>Math.cbrt(e)))}(pn(t,n,o)),...r.length>0&&r[0]<1?[r[0]]:[]]};qt.prototype.oklab=function(){return $n(this._rgb)};const Qn=(...e)=>new qt(...e,"oklab");Object.assign(Kt,{oklab:Qn}),Xt.format.oklab=Jn,Xt.autodetect.push({p:2,test:(...e)=>{if("array"===It(e=Pt(e,"oklab"))&&3===e.length)return"oklab"}});bn.oklab=(e,t,n)=>{const o=e.oklab(),r=t.oklab();return new qt(o[0]+n*(r[0]-o[0]),o[1]+n*(r[1]-o[1]),o[2]+n*(r[2]-o[2]),"oklab")};bn.oklch=(e,t,n)=>In(e,t,n,"oklch");const{pow:eo,sqrt:to,PI:no,cos:oo,sin:ro,atan2:ao}=Math;var io=(e,t="lrgb",n=null)=>{const o=e.length;n||(n=Array.from(new Array(o)).map(()=>1));const r=o/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=r}),e=e.map(e=>new qt(e)),"lrgb"===t)return so(e,n);const a=e.shift(),i=a.get(t),s=[];let l=0,c=0;for(let e=0;e{const r=e.get(t);u+=e.alpha()*n[o+1];for(let e=0;e=360;)t-=360;i[e]=t}else i[e]=i[e]/s[e];return u/=o,new qt(i,t).alpha(u>.99999?1:u,!0)};const so=(e,t)=>{const n=e.length,o=[0,0,0,0];for(let r=0;r.9999999&&(o[3]=1),new qt(Tt(o))},{pow:lo}=Math;function co(e){let t="rgb",n=Kt("#ccc"),o=0,r=[0,1],a=[0,1],i=[],s=[0,0],l=!1,c=[],u=!1,d=0,h=1,p=!1,m={},f=!0,g=1;const y=function(e){if((e=e||["#fff","#000"])&&"string"===It(e)&&Kt.brewer&&Kt.brewer[e.toLowerCase()]&&(e=Kt.brewer[e.toLowerCase()]),"array"===It(e)){1===e.length&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;te,w=e=>e;const v=function(e,o){let r,a;if(null==o&&(o=!1),isNaN(e)||null===e)return n;if(o)a=e;else if(l&&l.length>2){a=function(e){if(null!=l){const t=l.length-1;let n=0;for(;n=l[n];)n++;return n-1}return 0}(e)/(l.length-2)}else a=h!==d?(e-d)/(h-d):1;a=w(a),o||(a=b(a)),1!==g&&(a=lo(a,g)),a=s[0]+a*(1-s[0]-s[1]),a=Ot(a,0,1);const u=Math.floor(1e4*a);if(f&&m[u])r=m[u];else{if("array"===It(c))for(let e=0;e=n&&e===i.length-1){r=c[e];break}if(a>n&&am={};y(e);const _=function(e){const t=Kt(v(e));return u&&t[u]?t[u]():t};return _.classes=function(e){if(null!=e){if("array"===It(e))l=e,r=[e[0],e[e.length-1]];else{const t=Kt.analyze(r);l=0===e?[t.min,t.max]:Kt.limits(t,"e",e)}return _}return l},_.domain=function(e){if(!arguments.length)return a;a=e.slice(0),d=e[0],h=e[e.length-1],i=[];const t=c.length;if(e.length===t&&d!==h)for(let t of Array.from(e))i.push((t-d)/(h-d));else{for(let e=0;e2){const t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-d)/(h-d));n.every((e,n)=>t[n]===e)||(w=e=>{if(e<=0||e>=1)return e;let o=0;for(;e>=n[o+1];)o++;const r=(e-n[o])/(n[o+1]-n[o]);return t[o]+r*(t[o+1]-t[o])})}}return r=[d,h],_},_.mode=function(e){return arguments.length?(t=e,x(),_):t},_.range=function(e,t){return y(e),_},_.out=function(e){return u=e,_},_.spread=function(e){return arguments.length?(o=e,_):o},_.correctLightness=function(e){return null==e&&(e=!0),p=e,x(),b=p?function(e){const t=v(0,!0).lab()[0],n=v(1,!0).lab()[0],o=t>n;let r=v(e,!0).lab()[0];const a=t+(n-t)*e;let i=r-a,s=0,l=1,c=20;for(;Math.abs(i)>.01&&c-- >0;)(function(){o&&(i*=-1),i<0?(s=e,e+=.5*(l-e)):(l=e,e+=.5*(s-e)),r=v(e,!0).lab()[0],i=r-a})();return e}:e=>e,_},_.padding=function(e){return null!=e?("number"===It(e)&&(e=[e,e]),s=e,_):s},_.colors=function(t,n){arguments.length<2&&(n="hex");let o=[];if(0===arguments.length)o=c.slice(0);else if(1===t)o=[_(.5)];else if(t>1){const e=r[0],n=r[1]-e;o=function(e,t,n){let o=[],r=ea;r?t++:t--)o.push(t);return o}(0,t,!1).map(o=>_(e+o/(t-1)*n))}else{e=[];let t=[];if(l&&l.length>2)for(let e=1,n=l.length,o=1<=n;o?en;o?e++:e--)t.push(.5*(l[e-1]+l[e]));else t=r;o=t.map(e=>_(e))}return Kt[n]&&(o=o.map(e=>e[n]())),o},_.cache=function(e){return null!=e?(f=e,_):f},_.gamma=function(e){return null!=e?(g=e,_):g},_.nodata=function(e){return null!=e?(n=Kt(e),_):n},_}var uo=e=>{const t=function(e){let t,n,o,r;if(2===(e=e.map(e=>new qt(e))).length)[n,o]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>n[t]+e*(o[t]-n[t]));return new qt(t,"lab")};else if(3===e.length)[n,o,r]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*n[t]+2*(1-e)*e*o[t]+e*e*r[t]);return new qt(t,"lab")};else if(4===e.length){let a;[n,o,r,a]=e.map(e=>e.lab()),t=function(e){const t=[0,1,2].map(t=>(1-e)*(1-e)*(1-e)*n[t]+3*(1-e)*(1-e)*e*o[t]+3*(1-e)*e*e*r[t]+e*e*e*a[t]);return new qt(t,"lab")}}else{if(!(e.length>=5))throw new RangeError("No point in running bezier with only one color.");{let n,o,r;n=e.map(e=>e.lab()),r=e.length-1,o=function(e){let t=[1,1];for(let n=1;nn.reduce((n,i,s)=>n+o[s]*t**(r-s)*e**s*i[a],0));return new qt(a,"lab")}}}return t}(e);return t.scale=()=>co(t),t};const{round:ho}=Math;qt.prototype.rgb=function(e=!0){return!1===e?this._rgb.slice(0,3):this._rgb.slice(0,3).map(ho)},qt.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?!1===e?t:ho(t):t)};const po=(...e)=>new qt(...e,"rgb");Object.assign(Kt,{rgb:po}),Xt.format.rgb=(...e)=>{const t=Pt(e,"rgba");return void 0===t[3]&&(t[3]=1),t},Xt.autodetect.push({p:3,test:(...e)=>{if("array"===It(e=Pt(e,"rgba"))&&(3===e.length||4===e.length&&"number"==It(e[3])&&e[3]>=0&&e[3]<=1))return"rgb"}});const mo=(e,t,n)=>{if(!mo[n])throw new Error("unknown blend mode "+n);return mo[n](e,t)},fo=e=>(t,n)=>{const o=Kt(n).rgb(),r=Kt(t).rgb();return Kt.rgb(e(o,r))},go=e=>(t,n)=>{const o=[];return o[0]=e(t[0],n[0]),o[1]=e(t[1],n[1]),o[2]=e(t[2],n[2]),o};mo.normal=fo(go(e=>e)),mo.multiply=fo(go((e,t)=>e*t/255)),mo.screen=fo(go((e,t)=>255*(1-(1-e/255)*(1-t/255)))),mo.overlay=fo(go((e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)))),mo.darken=fo(go((e,t)=>e>t?t:e)),mo.lighten=fo(go((e,t)=>e>t?e:t)),mo.dodge=fo(go((e,t)=>255===e||(e=t/255*255/(1-e/255))>255?255:e)),mo.burn=fo(go((e,t)=>255*(1-(1-t/255)/(e/255))));var yo=mo;const{pow:bo,sin:wo,cos:vo}=Math;function xo(e=300,t=-1.5,n=1,o=1,r=[0,1]){let a,i=0;"array"===It(r)?a=r[1]-r[0]:(a=0,r=[r,r]);const s=function(s){const l=Vt*((e+120)/360+t*s),c=bo(r[0]+a*s,o),u=(0!==i?n[0]+s*i:n)*c*(1-c)/2,d=vo(l),h=wo(l);return Kt(Tt([255*(c+u*(-.14861*d+1.78277*h)),255*(c+u*(-.29227*d-.90649*h)),255*(c+u*(1.97294*d)),1]))};return s.start=function(t){return null==t?e:(e=t,s)},s.rotations=function(e){return null==e?t:(t=e,s)},s.gamma=function(e){return null==e?o:(o=e,s)},s.hue=function(e){return null==e?n:("array"===It(n=e)?(i=n[1]-n[0],0===i&&(n=n[1])):i=0,s)},s.lightness=function(e){return null==e?r:("array"===It(e)?(r=e,a=e[1]-e[0]):(r=[e,e],a=0),s)},s.scale=()=>Kt.scale(s),s.hue(n),s}const{floor:_o,random:Ao}=Math;var ko=(e=Ao)=>{let t="#";for(let n=0;n<6;n++)t+="0123456789abcdef".charAt(_o(16*e()));return new qt(t,"hex")};const{log:Co,pow:So,floor:Eo,abs:Mo}=Math;function Ro(e,t=null){const n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===It(e)&&(e=Object.values(e)),e.forEach(e=>{t&&"object"===It(e)&&(e=e[t]),null==e||isNaN(e)||(n.values.push(e),n.sum+=e,en.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>Oo(n,e,t),n}function Oo(e,t="equal",n=7){"array"==It(e)&&(e=Ro(e));const{min:o,max:r}=e,a=e.values.sort((e,t)=>e-t);if(1===n)return[o,r];const i=[];if("c"===t.substr(0,1)&&(i.push(o),i.push(r)),"e"===t.substr(0,1)){i.push(o);for(let e=1;e 0");const e=Math.LOG10E*Co(o),t=Math.LOG10E*Co(r);i.push(o);for(let o=1;o200&&(c=!1)}const h={};for(let e=0;ee-t),i.push(p[0]);for(let e=1;e{e=new qt(e),t=new qt(t);const n=e.luminance(),o=t.luminance();return n>o?(n+.05)/(o+.05):(o+.05)/(n+.05)}; /** * @license * diff --git a/modules/wljs-graphics3d-threejs/src/kernel.js b/modules/wljs-graphics3d-threejs/src/kernel.js index 8c8a8975..4bf9bcc2 100644 --- a/modules/wljs-graphics3d-threejs/src/kernel.js +++ b/modules/wljs-graphics3d-threejs/src/kernel.js @@ -5526,7 +5526,9 @@ if (!GUI && PathRendering) { /** * @type {HTMLElement} */ -const container = env.element; +const container = document.createElement('div'); +container.classList.add('relative'); +env.element.appendChild(container); /** * @type {[Number, Number]} @@ -5694,7 +5696,7 @@ env.local.renderer = renderer; //fix for translate-50% layout const layoutOffset = {x:0, y:0}; -if (container.classList.contains('slide-frontend-object')) { +if (env.element.classList.contains('slide-frontend-object')) { layoutOffset.x = -1.0; } @@ -5778,19 +5780,22 @@ if (PathRendering) { } let controlObject = { - init: (camera, dom) => { - controlObject.o = new OrbitControls( camera, domElement ); - controlObject.o.addEventListener('change', wakeFunction); - controlObject.o.target.set( 0, 1, 0 ); - controlObject.o.update(); - }, + init: (camera, dom) => { + controlObject.o = new OrbitControls( camera, domElement ); + controlObject.o.addEventListener('change', wakeFunction); + controlObject.o.target.set( 0, 1, 0 ); + controlObject.o.update(); + }, - dispose: () => { - - } -}; + dispose: () => { + } + } +if ('Controls' in options && !(await interpretate(options.Controls))) { + controlObject.disabled = true; + domElement.style.pointerEvents = 'none'; +} if (options.Controls) { @@ -5980,6 +5985,8 @@ if (options.Controls) { } } + + env.local.controlObject = controlObject; @@ -7209,6 +7216,7 @@ core.Graphics3D.destroy = (args, env) => { if (env.local.labelContainer) env.local.labelContainer.remove(); if (env.local.guiContainer) env.local.guiContainer.remove(); env.local.rendererContainer.remove(); + env.local.element.remove(); } core.Graphics3D.virtual = true From 8c0ae570974ce7779271c65d7ba9667f2f583c9f Mon Sep 17 00:00:00 2001 From: Kirill Vasin Date: Fri, 3 Apr 2026 05:22:49 +0200 Subject: [PATCH 3/3] updated release notes and readme --- README.md | 10 ++ .../Demos/Release notes/3.0.3.wln | 145 ++++++++++-------- 2 files changed, 92 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 0b1d0453..5d21fda8 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,16 @@ Typeset math input, syntactic sugar, multiple languages, and a fast, granular ev See how at [wljs.io](https://wljs.io/frontend/setup) +## Star History + + + + + + Star History Chart + + + ## Highlights ### Feels like Mathematica and Jupyter diff --git a/modules/wljs-demos-archive/Demos/Release notes/3.0.3.wln b/modules/wljs-demos-archive/Demos/Release notes/3.0.3.wln index 198addfb..d0856982 100644 --- a/modules/wljs-demos-archive/Demos/Release notes/3.0.3.wln +++ b/modules/wljs-demos-archive/Demos/Release notes/3.0.3.wln @@ -1,8 +1,8 @@ -<|"Notebook" -> <|"Controller" -> "357410a8-af61-4063-8556-d5d017f8df87", +<|"Notebook" -> <|"Controller" -> "13c6a253-2092-40b8-bee7-dbb3adc5bdd8", "FocusedCell" -> CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$419], "FocusedCellSelection" -> - {99, 98}, "HaveToSaveAs" -> False, "MessangerChannel" -> Messanger, - "ModalsChannel" -> "dbd46446-943a-482c-8a41-55d618176f0c", + CoffeeLiqueur`Notebook`Cells`CellObj`$416], "FocusedCellSelection" -> + {91, 90}, "HaveToSaveAs" -> False, "MessangerChannel" -> Messanger, + "ModalsChannel" -> "e5078e31-8e83-4e8d-9a08-a6cf3d11cb1f", "Objects" -> <|"ba444fb3-7f1e-4836-9025-b54f4dee96af" -> <|"Public" -> Hold[ CoffeeLiqueur`Extensions`FrontendObject`Internal`Compressed["eJzdnU1\ @@ -121,20 +121,23 @@ m3PrB/riz9zr579+9UPnp9u7h+6n1pfP2Ndv/x9TZEpV", {"ExpressionJSON", "PublicFields" -> {"Properties"}, "Quick" -> True, "Symbols" -> <||>, "TOC" -> {CoffeeLiqueur`Extensions`TOC`Private`heading[1, "Release notes *3.0.3*", CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$379]], + CoffeeLiqueur`Notebook`Cells`CellObj`$381]], CoffeeLiqueur`Extensions`TOC`Private`heading[2, "Window Throttling", CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$382]], + CoffeeLiqueur`Notebook`Cells`CellObj`$386]], CoffeeLiqueur`Extensions`TOC`Private`heading[2, "More tools for window management", CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$385]], + CoffeeLiqueur`Notebook`Cells`CellObj`$388]], CoffeeLiqueur`Extensions`TOC`Private`heading[2, "GPUArray symbols", CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$391]], + CoffeeLiqueur`Notebook`Cells`CellObj`$395]], CoffeeLiqueur`Extensions`TOC`Private`heading[2, "Copy cells as plain text", CoffeeLiqueur`Notebook`Cells`CellObj[ - CoffeeLiqueur`Notebook`Cells`CellObj`$406]]}, + CoffeeLiqueur`Notebook`Cells`CellObj`$407]], + CoffeeLiqueur`Extensions`TOC`Private`heading[2, "Misc", + CoffeeLiqueur`Notebook`Cells`CellObj[ + CoffeeLiqueur`Notebook`Cells`CellObj`$437]]}, "TrashedCells" -> {"rasterDensityPlotAnim[x Sin[y+t], {x, -5, 5}, {y, 0, \ 10}, {t, 0, 2Pi}, PlotPoints->50]", "rasterDensityPlotAnim[f_, {xs_, xmin_, \ xmax_}, {ys_, ymin_, ymax_}, {ts_, tmin_, tmax_}, OptionsPattern[]] := \n \ @@ -157,101 +160,101 @@ SeedRandom[123];\n Table[Evaluate[Sum[Sin[RandomReal[10, 2] . {x, y} + t], \ can make it dynamic manually or automatically:"}|>, "Cells" -> {<|"Data" -> ".md\n# Release notes *3.0.3*\n\n\n", "Display" -> "codemirror", "Hash" -> - "c9f80480-aeb6-4465-9c92-cfd2b81854f3", "Invisible" -> False, + "2b57d766-461b-4670-adc6-36d6d916dd56", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "# Release notes *3.0.3*\n\nThu 2 Apr 2026 12:02:14", "Display" -> "markdown", "Hash" -> - "c94948ab-108f-42be-9e12-bdac7bc69900", "Invisible" -> False, + "af1a4c4e-5892-4cdc-b74d-b57068fb2a5f", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\n## Window Throttling\nWe fixed unintended window \ throttling on some machines, when it is not focused or hidden. This is \ crucial for a long-living applications such as monitors (lab equipment), \ where some data has to be updated continuously for hours or days. ", "Display" -> "codemirror", "Hash" -> - "c2098bd7-4069-46a9-9243-1f5d6c4a2da2", "Invisible" -> False, + "de83861a-2a78-41c5-99d4-c4f43158634f", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "## Window Throttling\nWe fixed unintended window throttling \ on some machines, when it is not focused or hidden. This is crucial for a \ long-living applications such as monitors (lab equipment), where some data \ has to be updated continuously for hours or days. ", "Display" -> "markdown", - "Hash" -> "d12d825a-9581-4a9d-8217-f1b904c28deb", "Invisible" -> False, + "Hash" -> "a4256d35-bc98-4609-afdd-e0c87c06e754", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\n## More tools for window management\nWe added \ `WindowEventListener` akin to `SlideEventListener` used to capture global \ events. For example:", "Display" -> "codemirror", - "Hash" -> "1e4d4129-8fd1-4473-a3b5-92b8ffd9bd9a", "Invisible" -> False, + "Hash" -> "19ca0e7d-3537-4a4e-bcfc-f9f18fc0c47c", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "## More tools for window management\nWe added \ `WindowEventListener` akin to `SlideEventListener` used to capture global \ events. For example:", "Display" -> "markdown", - "Hash" -> "2d456206-ee63-48ea-9d10-eb86131248f9", "Invisible" -> False, + "Hash" -> "5c6b013f-2107-488a-8b0d-8f90913a3ee2", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "ev = EventObject[];\nWindowEventListener[ev]", "Display" -> "codemirror", "Hash" -> - "194dee8f-0f03-41e7-95b3-fd70034cc040", "Invisible" -> False, + "88ab5502-d301-46fe-ac58-3d4711c681ab", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "log = {};\nRefresh[log, 1]\nEventHandler[ev, {\n ev_ :> \ Function[Null,\n AppendTo[log, ev];\n ]\n}];", "Display" -> "codemirror", - "Hash" -> "7a893665-b7f9-43fd-9db3-282218131ab5", "Invisible" -> False, + "Hash" -> "5a912195-2118-41d4-8349-e841f84320a4", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\nIt can capture the following events from a window, where \ it is placed:\n- `\"Mounted\"` - when the component/window has been loaded\n- \ `\"Closed\"` - closing of a window\n- `\"Blur\"` - when a user removed focus \ from a window\n- `\"Focus\"` - when a user has focused a window\n\nThis \ component works in normal cells as well as on WLX. It does not occupy space \ and renders nothing.", "Display" -> "codemirror", - "Hash" -> "a78651c6-2814-4133-b8f4-7a11f6a8fc97", "Invisible" -> False, + "Hash" -> "c8a0538f-1b84-4587-bd06-43abdb66c1a2", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "It can capture the following events from a window, where it \ is placed:\n- `\"Mounted\"` - when the component/window has been loaded\n- \ `\"Closed\"` - closing of a window\n- `\"Blur\"` - when a user removed focus \ from a window\n- `\"Focus\"` - when a user has focused a window\n\nThis \ component works in normal cells as well as on WLX. It does not occupy space \ and renders nothing.", "Display" -> "markdown", - "Hash" -> "db8eb961-c4a1-42ff-97cf-70d78477f1b2", "Invisible" -> False, + "Hash" -> "c8de40a8-3807-43ef-aa49-b46792b51116", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\n## GPUArray symbols\nWe added a support for a recent \ feature of WL - GPU arrays. They effectively store a reference to a data on \ GPU, which can be used for cross-platform GPU computing (rather limited for \ now):", "Display" -> "codemirror", "Hash" -> - "bfa52046-9e22-411e-92a7-a46eb15a46b3", "Invisible" -> False, + "3d9b6a81-6ef8-41a2-a25c-b8d90d656bf7", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "## GPUArray symbols\nWe added a support for a recent feature \ of WL - GPU arrays. They effectively store a reference to a data on GPU, \ which can be used for cross-platform GPU computing (rather limited for now):"\ -, "Display" -> "markdown", "Hash" -> "e2514ac7-c315-49fe-b3d1-8caa622e47a6", +, "Display" -> "markdown", "Hash" -> "a1b98db4-e230-4593-ac1d-8c9d9ee53979", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "arr = Table[BitXor[i,j]//N, {i,127}, {j,127}];\ng = GPUArray[arr]", "Display" -> "codemirror", "Hash" -> - "0f862ea1-d999-4385-8ce1-48a34a5a33df", "Invisible" -> False, + "1ecd9e27-1515-41a0-bc22-04e60c952b0e", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "(*VB[*)BoxForm`temporalStorage$331093(*,*)(*\"1:eJxdkUmPolAAh\ JktmcyvmOmT0p2wo0wyh4eCCig0CqidPvAWZGtkU4RfPzrHuVSqKnX66hc8u9EXiqKaH3fRcNKeaz\ 8h3Tb6RFELxwN1HfZvI9pX3+jxzxH9Qo9H9BP3mxg99jTO6ljwuoOerofF8lRhuQdKR7pYbKZhEqi\ @@ -261,94 +264,110 @@ th5nTSYjZyDwtsKnxDRkpDkmIuZXKqemb0abNNpGZqiY2Cf+I/1zIv3dqsL3JBGHRlKftgF+ozpA4\ aH6VyOjozuZhWMT4NjMjfQpKtTW4Jrf5jklmGCVgCKrD7jWASsfUCl+OfpwfHdV+nxe/T5gf/rXdx\ LTrbfH4aE2C7y/l+7qy/kv83jqy3JCWpDmJPm2z3qYd6QvwvvjD8=\"*)(*]VB*)", "Display" -> "codemirror", "Hash" -> - "ef03103b-89f0-4f99-83e4-3bd2037c1176", "Invisible" -> False, + "77ec2b77-720e-4781-86ae-38639ad6ad3b", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\nDo math operation and plot it\n\n:::note\nNot all \ operations are supported on GPU. It may fallback to CPU version\n:::", "Display" -> "codemirror", "Hash" -> - "1f60ca3e-07ea-400b-a7df-71a9e6edeaf8", "Invisible" -> False, + "cbd89ecb-b44a-45b5-9c43-30a68e542574", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "Do math operation and plot it\n\n:::note\nNot all operations \ are supported on GPU. It may fallback to CPU version\n:::", "Display" -> "markdown", "Hash" -> - "16003381-7cf1-4c2d-8ee9-f408018a60c5", "Invisible" -> False, + "af6ae7e8-0e4b-44ac-a862-d081a495c6e2", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "g g - g // ArrayPlot ", "Display" -> "codemirror", - "Hash" -> "ab4bb767-5db8-4afc-9ac6-3a4a6cef0600", "Invisible" -> False, + "Hash" -> "67bb2f2a-75bb-4c2d-92e2-90e4be0d1a41", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "(*VB[*)(FrontEndRef[\"ba444fb3-7f1e-4836-9025-b54f4dee96af\"]\ )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJyWam\ JikJRnrmqcZpuqaWBib6VoaGJnqJpmapJmkpKZamiWmAQCFYxXe\"*)(*]VB*)", "Display" -> "codemirror", "Hash" -> - "bcfa852d-5ae9-4af8-abc3-0a88288d25bc", "Invisible" -> False, + "b6c5b1df-b67a-414c-ac54-e9734fe1fece", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\n## Copy cells as plain text\nWe added an option to copy \ a group of cells as `InputForm`, it automatically strips off all syntax sugar \ and marks input and output \ cells\n\n\n![](/attachments/Screenshot-2026-04-02-at-12.53.25-01e.png)\n", "Display" -> "codemirror", "Hash" -> - "93a97765-6e43-4db2-8c06-13846a9e00e0", "Invisible" -> False, + "181f797b-0530-43fa-8025-0388cdb586d5", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "## Copy cells as plain text\nWe added an option to copy a \ group of cells as `InputForm`, it automatically strips off all syntax sugar \ and marks input and output \ cells\n\n\n![](/attachments/Screenshot-2026-04-02-at-12.53.25-01e.png)", "Display" -> "markdown", "Hash" -> - "741c8fa9-37a3-4277-b80b-c7e9723c91d4", "Invisible" -> False, + "726aa7fe-585e-4bfb-9a3b-69c949cdb33e", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\nFor example:", "Display" -> "codemirror", - "Hash" -> "531e78a5-cc77-4c81-a796-014093b14d07", "Invisible" -> False, + "Hash" -> "e7ea81fd-874c-4e83-a54b-dc08a001a2d9", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "For example:", "Display" -> "markdown", - "Hash" -> "8643ccf3-edad-4822-850b-fce9a28ad72f", "Invisible" -> False, + "Hash" -> "c96be81e-21ec-438b-8162-a67fdac37859", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "Series[Sin[x], {x,0,2}]", "Display" -> "codemirror", - "Hash" -> "750e2e6e-0cf8-40d0-9562-e28569070b71", "Invisible" -> False, + "Hash" -> "d4023a7d-9e8f-4e4d-a9fb-f3cb8f4c8f59", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "(*VB[*)(SeriesData[x, 0, {1}, 1, 3, \ 1])(*,*)(*\"1:eJwlT11PwjAAXIwPxl8xedrKEocERN9alX0YUdbRZiM8TCmzcaVlbLEb8X/58xy\ YXC53l3u4u3qX0ebMMIz9ZUdPa17JknD2jX87q/sWIGgJbAuzkrP9Y1ZlS+2YrmMefhxzeMJgZVvA\ 6TqgN7hnoY7jF/mGxYwnHpSjPMAlF2m4KaZJKtTow9/Nn8ce2T6gxS2m6RfqM6qiyr9zo6zxiLyhK\ h8nM5g2ifQbquT8GmsY7HI3bGkCJ1EQL1rdTmqFgtqbhlTAHEH9KVjvuGFFELD/D513FNUFwxdHwb\ L167ZoTmlc1uwPHtBIXA==\"*)(*]VB*)", "Display" -> "codemirror", - "Hash" -> "d50d54be-0ea1-4a39-910e-9d9c826b21bd", "Invisible" -> False, + "Hash" -> "6e6d53d6-c989-4ce8-97bd-36fcfb18b66d", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> ".md\nCopied expression:", "Display" -> "codemirror", - "Hash" -> "25f069a9-a2a9-49a7-93d0-acc22a1b2a18", "Invisible" -> False, + "Hash" -> "d9f77916-2003-4f6e-a277-bf03e650484b", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", - "UID" -> Null, "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "Copied expression:", "Display" -> "markdown", - "Hash" -> "1fce3dba-7d4b-42b6-a719-63aff1cc796f", "Invisible" -> False, + "Hash" -> "af9c6617-d244-4928-afe1-9e374f7f8709", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Output", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, <|"Data" -> "(* ::: Input ::: *)\nSeries[Sin[x], {x,0,2}]\n\n(* ::: Output \ ::: *)\n(SeriesData[x, 0, {1}, 1, 3, 1])", "Display" -> "codemirror", - "Hash" -> "32ddd5b3-e2e2-4684-893b-15a6f57008b6", "Invisible" -> False, + "Hash" -> "0ee9070b-4656-44e5-99db-c93ee8e1a309", "Invisible" -> False, "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", "UID" -> Null, - "Notebook" -> "a2f235ff-2b98-4d6b-ad96-80ac07070793"|>}, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, + <|"Data" -> ".md\n## Misc\n- Various bug fixes related to compressed \ +entities like images, or large plots\n- Fixed `Graphics3D` pan and rotation \ +on custom WLX components; added `\"Controls\"` option to disable/enable \ +rotation", "Display" -> "codemirror", + "Hash" -> "8b90435d-6d57-40b2-8ac3-b41c2fa99ab7", "Invisible" -> False, + "MetaOnly" -> False, "Props" -> <|"Hidden" -> True|>, + "PublicFields" -> {"Properties"}, "State" -> "Idle", "Type" -> "Input", + "UID" -> Null, "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>, + <|"Data" -> "## Misc\n- Various bug fixes related to compressed entities \ +like images, or large plots\n- Fixed `Graphics3D` pan and rotation on custom \ +WLX components; added `\"Controls\"` option to disable/enable rotation", + "Display" -> "markdown", "Hash" -> + "06170a57-23aa-45e7-bc91-9587f4fbdff3", "Invisible" -> False, + "MetaOnly" -> False, "Props" -> <||>, "PublicFields" -> {"Properties"}, + "State" -> "Idle", "Type" -> "Output", "UID" -> Null, + "Notebook" -> "a68adedd-fdcb-4106-896a-c95c748d76f5"|>}, "serializer" -> "jsfn4"|>