mirror of
https://github.com/troisjs/trois.git
synced 2024-11-27 22:12:01 +08:00
3 lines
79 KiB
JavaScript
3 lines
79 KiB
JavaScript
import{h as e,toRef as t,watch as i,inject as r,resolveComponent as n,openBlock as s,createBlock as a,withCtx as o,createVNode as h,renderSlot as u}from"vue";import{Vector2 as m,Vector3 as d,Plane as c,Raycaster as l,WebGLRenderer as f,OrthographicCamera as p,PerspectiveCamera as v,Group as y,Scene as g,Color as x,BoxBufferGeometry as b,CircleBufferGeometry as S,ConeBufferGeometry as w,CylinderBufferGeometry as N,DodecahedronBufferGeometry as C,IcosahedronBufferGeometry as z,LatheBufferGeometry as _,OctahedronBufferGeometry as M,PolyhedronBufferGeometry as P,RingBufferGeometry as T,SphereBufferGeometry as G,TetrahedronBufferGeometry as I,TorusBufferGeometry as R,TorusKnotBufferGeometry as j,Curve as L,TubeBufferGeometry as B,AmbientLight as E,DirectionalLight as k,PointLight as A,SpotLight as D,FrontSide as O,MeshBasicMaterial as U,MeshLambertMaterial as F,TextureLoader as $,MeshMatcapMaterial as W,MeshPhongMaterial as Z,MeshStandardMaterial as H,MeshPhysicalMaterial as q,ShaderChunk as V,UniformsUtils as X,ShaderLib as Y,ShaderMaterial as K,MeshToonMaterial as Q,CubeTextureLoader as J,CubeRefractionMapping as ee,Mesh as te,PlaneBufferGeometry as ie,FontLoader as re,TextBufferGeometry as ne,WebGLCubeRenderTarget as se,RGBFormat as ae,LinearMipmapLinearFilter as oe,CubeCamera as he,BackSide as ue,DoubleSide as me,InstancedMesh as de,SpriteMaterial as ce,Sprite as le,WebGLRenderTarget as fe,ObjectSpaceNormalMap as pe,Object3D as ve,Face3 as ye,MathUtils as ge,InstancedBufferAttribute as xe}from"three";import{OrbitControls as be}from"three/examples/jsm/controls/OrbitControls.js";import{EffectComposer as Se}from"three/examples/jsm/postprocessing/EffectComposer.js";import{RenderPass as we}from"three/examples/jsm/postprocessing/RenderPass.js";import{BokehPass as Ne}from"three/examples/jsm/postprocessing/BokehPass.js";import{FilmPass as Ce}from"three/examples/jsm/postprocessing/FilmPass.js";import{ShaderPass as ze}from"three/examples/jsm/postprocessing/ShaderPass.js";import{FXAAShader as _e}from"three/examples/jsm/shaders/FXAAShader.js";import{HalftonePass as Me}from"three/examples/jsm/postprocessing/HalftonePass.js";import{SMAAPass as Pe}from"three/examples/jsm/postprocessing/SMAAPass.js";import{UnrealBloomPass as Te}from"three/examples/jsm/postprocessing/UnrealBloomPass.js";import{Pass as Ge}from"three/examples/jsm/postprocessing/Pass.js";import{gsap as Ie,Power4 as Re}from"gsap";import{Geometry as je}from"three/examples/jsm/deprecated/Geometry.js";import{GLTFLoader as Le}from"three/examples/jsm/loaders/GLTFLoader.js";function Be(){var e={canvas:null,antialias:!0,alpha:!1,autoClear:!0,orbit_ctrl:!1,mouse_move:!1,mouse_raycast:!1,mouse_over:!1,click:!1,resize:!0,width:0,height:0},t={width:1,height:1,wWidth:1,wHeight:1,ratio:1},i=[],r=[],n=[],s=new m,a=new d,o=new c(new d(0,0,1),0),h=new l,u=[],p={conf:e,renderer:null,camera:null,cameraCtrl:null,materials:{},scene:null,size:t,mouse:s,mouseV3:a,init:function(t){t&&Object.entries(t).forEach((function(t){var i=t[0],r=t[1];e[i]=r}));if(!p.scene)return void console.error("Missing Scene");if(!p.camera)return void console.error("Missing Camera");p.renderer=new f({canvas:e.canvas,antialias:e.antialias,alpha:e.alpha}),p.renderer.autoClear=e.autoClear,e.orbit_ctrl&&(p.orbitCtrl=new be(p.camera,p.renderer.domElement),e.orbit_ctrl instanceof Object&&Object.entries(e.orbit_ctrl).forEach((function(e){var t=e[0],i=e[1];p.orbitCtrl[t]=i})));e.width&&e.height?S(e.width,e.height):e.resize&&(b(),window.addEventListener("resize",b));e.mouse_move=e.mouse_move||e.mouse_over,e.mouse_move&&("body"===e.mouse_move?p.mouse_move_element=document.body:p.mouse_move_element=p.renderer.domElement,p.mouse_move_element.addEventListener("mousemove",y),p.mouse_move_element.addEventListener("mouseleave",g));e.click&&p.renderer.domElement.addEventListener("click",v);return i.forEach((function(e){return e()})),!0},dispose:function(){n=[],window.removeEventListener("resize",b),p.mouse_move_element&&(p.mouse_move_element.removeEventListener("mousemove",y),p.mouse_move_element.removeEventListener("mouseleave",g));p.renderer.domElement.removeEventListener("click",v),p.orbitCtrl&&p.orbitCtrl.dispose();this.renderer.dispose()},render:function(){p.orbitCtrl&&p.orbitCtrl.update();n.forEach((function(e){return e()})),p.renderer.render(p.scene,p.camera)},renderC:function(){p.orbitCtrl&&p.orbitCtrl.update();n.forEach((function(e){return e()})),p.composer.render()},setSize:S,onAfterInit:function(e){i.push(e)},onAfterResize:function(e){r.push(e)},offAfterResize:function(e){r=r.filter((function(t){return t!==e}))},onBeforeRender:function(e){n.push(e)},offBeforeRender:function(e){n=n.filter((function(t){return t!==e}))},addIntersectObject:function(e){-1===u.indexOf(e)&&u.push(e)},removeIntersectObject:function(e){var t=u.indexOf(e);-1!==t&&u.splice(t,1)}};function v(e){s.x=e.clientX/t.width*2-1,s.y=-e.clientY/t.height*2+1,h.setFromCamera(s,p.camera);for(var i=h.intersectObjects(u),r=0;r<i.length;r++){var n=i[r].object;n.onClick&&n.onClick(e)}}function y(e){s.x=e.clientX/t.width*2-1,s.y=-e.clientY/t.height*2+1,x()}function g(e){x()}function x(t){if((e.mouse_over||e.mouse_raycast)&&(h.setFromCamera(s,p.camera),e.mouse_raycast&&(p.camera.getWorldDirection(o.normal),o.normal.normalize(),h.ray.intersectPlane(o,a)),e.mouse_over)){for(var i=h.intersectObjects(u),r=[].concat(u),n=0;n<i.length;n++){var m=i[n].object;!m.hover&&m.onHover&&(m.hover=!0,m.onHover(!0)),r.splice(r.indexOf(m),1)}for(var d=0;d<r.length;d++){var c=r[d];c.hover&&c.onHover&&(c.hover=!1,c.onHover(!1))}}}function b(){if("window"===e.resize)S(window.innerWidth,window.innerHeight);else{var t=p.renderer.domElement.parentNode;S(t.clientWidth,t.clientHeight)}r.forEach((function(e){return e()}))}function S(e,i){if(t.width=e,t.height=i,t.ratio=e/i,p.renderer.setSize(e,i,!1),p.camera.aspect=t.ratio,p.camera.updateProjectionMatrix(),p.composer&&p.composer.setSize(e,i),"OrthographicCamera"===p.camera.type)t.wWidth=p.camera.right-p.camera.left,t.wHeight=p.camera.top-p.camera.bottom;else{var r=function(){var e=p.camera.fov*Math.PI/180,t=2*Math.tan(e/2)*Math.abs(p.camera.position.z);return[t*p.camera.aspect,t]}();t.wWidth=r[0],t.wHeight=r[1]}}return p}var Ee={props:{antialias:Boolean,alpha:Boolean,autoClear:{type:Boolean,default:!0},mouseMove:{type:[Boolean,String],default:!1},mouseRaycast:{type:Boolean,default:!1},mouseOver:{type:Boolean,default:!1},click:{type:Boolean,default:!1},orbitCtrl:{type:[Boolean,Object],default:!1},resize:{type:[Boolean,String],default:!0},shadow:Boolean,width:String,height:String},setup:function(){return{three:Be(),raf:!0,onMountedCallbacks:[]}},provide:function(){return{three:this.three,rendererComponent:this}},mounted:function(){var e={canvas:this.$el,antialias:this.antialias,alpha:this.alpha,autoClear:this.autoClear,orbit_ctrl:this.orbitCtrl,mouse_move:this.mouseMove,mouse_raycast:this.mouseRaycast,mouse_over:this.mouseOver,click:this.click,resize:this.resize,width:this.width,height:this.height};this.three.init(e)&&(this.three.renderer.shadowMap.enabled=this.shadow,this.three.composer?this.animateC():this.animate()),this.onMountedCallbacks.forEach((function(e){return e()}))},beforeUnmount:function(){this.raf=!1,this.three.dispose()},methods:{onMounted:function(e){this.onMountedCallbacks.push(e)},onBeforeRender:function(e){this.three.onBeforeRender(e)},onAfterResize:function(e){this.three.onAfterResize(e)},animate:function(){this.raf&&requestAnimationFrame(this.animate),this.three.render()},animateC:function(){this.raf&&requestAnimationFrame(this.animateC),this.three.renderC()}},render:function(){return e("canvas",{},this.$slots.default())}};function ke(e,t){t instanceof Object&&Object.entries(t).forEach((function(t){var i=t[0],r=t[1];e[i]=r}))}function Ae(e,t){var i={};return Object.entries(e).forEach((function(e){var r=e[0],n=e[1];(!t||t&&!t.includes(r))&&(i[r]=n)})),i}function De(e,t,i){return e+(t-e)*(i=(i=i<0?0:i)>1?1:i)}function Oe(e,t,i){e.x=De(e.x,t.x,i),e.y=De(e.y,t.y,i)}function Ue(e,t,i){e.x=De(e.x,t.x,i),e.y=De(e.y,t.y,i),e.z=De(e.z,t.z,i)}function Fe(e,t,i){return e<t?t:e>i?i:e}function $e(e,t){return void 0===t&&(t=1024),"https://rawcdn.githack.com/emmelleppi/matcaps/9b36ccaaf0a24881a39062d05566c9e92be4aa0d/"+t+"/"+(""+e+function(e){switch(e){case 64:return"-64px";case 128:return"-128px";case 256:return"-256px";case 512:return"-512px";default:return""}}(t)+".png")}function We(e,r,n){if(e[r]){var s=t(e,r);ke(n,s.value),i(s,(function(){ke(n,s.value)}),{deep:!0})}}var Ze={inject:["three"],props:{left:{type:Number,default:-1},right:{type:Number,default:1},top:{type:Number,default:1},bottom:{type:Number,default:-1},near:{type:Number,default:.1},far:{type:Number,default:2e3},zoom:{type:Number,default:1},position:{type:[Object,d],default:{x:0,y:0,z:0}}},created:function(){var e=this;this.camera=new p(this.left,this.right,this.top,this.bottom,this.near,this.far),We(this,"position",this.camera.position),["left","right","top","bottom","near","far","zoom"].forEach((function(t){i((function(){return e[t]}),(function(){e.camera[t]=e[t],e.camera.updateProjectionMatrix()}))})),this.three.camera=this.camera},render:function(){return[]},__hmrId:"OrthographicCamera"},He={inject:["three"],props:{aspect:{type:Number,default:1},far:{type:Number,default:2e3},fov:{type:Number,default:50},near:{type:Number,default:.1},position:{type:[Object,d],default:{x:0,y:0,z:0}}},created:function(){var e=this;this.camera=new v(this.fov,this.aspect,this.near,this.far),We(this,"position",this.camera.position),["aspect","far","fov","near"].forEach((function(t){i((function(){return e[t]}),(function(){e.camera[t]=e[t],e.camera.updateProjectionMatrix()}))})),this.three.camera=this.camera},render:function(){return[]},__hmrId:"PerspectiveCamera"},qe={inject:["three","scene"],props:{position:Object,rotation:Object,scale:Object},setup:function(e){var t=r("group",r("scene")),i=new y;return We(e,"position",i.position),We(e,"rotation",i.rotation),We(e,"scale",i.scale),{parent:t,group:i}},provide:function(){return{group:this.group}},created:function(){this.parent.add(this.group)},unmounted:function(){this.parent.remove(this.group)},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Group"},Ve={inject:["three"],props:{id:String,background:[String,Number]},setup:function(e){var t=new g;return e.background&&(t.background=new x(e.background)),i((function(){return e.background}),(function(e){t.background=new x(e)})),{scene:t}},provide:function(){return{scene:this.scene}},mounted:function(){this.three.scene||(this.three.scene=this.scene)},methods:{},render:function(){return this.$slots.default?this.$slots.default():[]}},Xe={emits:["ready"],inject:["mesh"],props:{rotateX:Number,rotateY:Number,rotateZ:Number},created:function(){var e=this;this.mesh||console.error("Missing parent Mesh"),this.watchProps=[],Object.entries(this.$props).forEach((function(t){return e.watchProps.push(t[0])}))},beforeMount:function(){this.createGeometry(),this.rotateGeometry(),this.mesh.setGeometry(this.geometry)},mounted:function(){this.addWatchers()},unmounted:function(){this.geometry.dispose()},methods:{rotateGeometry:function(){this.rotateX&&this.geometry.rotateX(this.rotateX),this.rotateY&&this.geometry.rotateY(this.rotateY),this.rotateZ&&this.geometry.rotateZ(this.rotateZ)},addWatchers:function(){var e=this;this.watchProps.forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},refreshGeometry:function(){var e=this.geometry;this.createGeometry(),this.rotateGeometry(),this.mesh.setGeometry(this.geometry),e.dispose()}},render:function(){return[]}},Ye={extends:Xe,props:{size:Number,width:{type:Number,default:1},height:{type:Number,default:1},depth:{type:Number,default:1},widthSegments:{type:Number,default:1},heightSegments:{type:Number,default:1},depthSegments:{type:Number,default:1}},methods:{createGeometry:function(){var e=this.width,t=this.height,i=this.depth;this.size&&(e=this.size,t=this.size,i=this.size),this.geometry=new b(e,t,i,this.widthSegments,this.heightSegments,this.depthSegments)}}},Ke={extends:Xe,props:{radius:{type:Number,default:1},segments:{type:Number,default:8},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new S(this.radius,this.segments,this.thetaStart,this.thetaLength)}}},Qe={extends:Xe,props:{radius:{type:Number,default:1},height:{type:Number,default:1},radialSegments:{type:Number,default:8},heightSegments:{type:Number,default:1},openEnded:{type:Boolean,default:!1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new w(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},Je={extends:Xe,props:{radiusTop:{type:Number,default:1},radiusBottom:{type:Number,default:1},height:{type:Number,default:1},radialSegments:{type:Number,default:8},heightSegments:{type:Number,default:1},openEnded:{type:Boolean,default:!1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new N(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},et={extends:Xe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new C(this.radius,this.detail)}}},tt={extends:Xe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new z(this.radius,this.detail)}}},it={extends:Xe,props:{points:Array,segments:{type:Number,default:12},phiStart:{type:Number,default:0},phiLength:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new _(this.points,this.segments,this.phiStart,this.phiLength)}}},rt={extends:Xe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new M(this.radius,this.detail)}}},nt={extends:Xe,props:{vertices:Array,indices:Array,radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new P(this.vertices,this.indices,this.radius,this.detail)}}},st={extends:Xe,props:{innerRadius:{type:Number,default:.5},outerRadius:{type:Number,default:1},thetaSegments:{type:Number,default:8},phiSegments:{type:Number,default:1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new T(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}}},at={extends:Xe,props:{radius:{type:Number,default:1},widthSegments:{type:Number,default:12},heightSegments:{type:Number,default:12}},methods:{createGeometry:function(){this.geometry=new G(this.radius,this.widthSegments,this.heightSegments)}}},ot={extends:Xe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new I(this.radius,this.detail)}}},ht={extends:Xe,props:{radius:{type:Number,default:1},tube:{type:Number,default:.4},radialSegments:{type:Number,default:8},tubularSegments:{type:Number,default:6},arc:{type:Number,default:2*Math.PI}},methods:{createGeometry:function(){this.geometry=new R(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.arc)}}},ut={extends:Xe,props:{radius:{type:Number,default:1},tube:{type:Number,default:.4},radialSegments:{type:Number,default:64},tubularSegments:{type:Number,default:8},p:{type:Number,default:2},q:{type:Number,default:3}},methods:{createGeometry:function(){this.geometry=new j(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q)}}},mt={extends:Xe,props:{path:L,tubularSegments:{type:Number,default:64},radius:{type:Number,default:1},radiusSegments:{type:Number,default:8},closed:{type:Boolean,default:!1}},methods:{createGeometry:function(){this.geometry=new B(this.path,this.tubularSegments,this.radius,this.radiusSegments,this.closed)}}},dt={inject:["scene"],props:{color:{type:String,default:"#ffffff"},intensity:{type:Number,default:1},castShadow:{type:Boolean,default:!1},shadowMapSize:Object,position:Object},created:function(){this.parent=r("group",this.scene)},mounted:function(){var e=this;We(this,"position",this.light.position),this.light.target&&We(this,"target",this.light.target.position),this.light.shadow&&(this.light.castShadow=this.castShadow,ke(this.light.shadow.mapSize,this.shadowMapSize)),["color","intensity","castShadow"].forEach((function(t){i((function(){return e[t]}),(function(){"color"===t?e.light.color=new x(e.color):e.light[t]=e[t]}))})),this.parent.add(this.light),this.light.target&&this.parent.add(this.light.target)},unmounted:function(){this.parent.remove(this.light),this.light.target&&this.parent.remove(this.light.target)},render:function(){return[]},__hmrId:"Light"},ct={extends:dt,created:function(){this.light=new E(this.color,this.intensity)},__hmrId:"AmbientLight"},lt={extends:dt,props:{target:Object},created:function(){this.light=new k(this.color,this.intensity)},__hmrId:"DirectionalLight"},ft={extends:dt,props:{distance:{type:Number,default:0},decay:{type:Number,default:1}},created:function(){this.light=new A(this.color,this.intensity,this.distance,this.decay)},__hmrId:"PointLight"},pt={extends:dt,props:{angle:{type:Number,default:Math.PI/3},decay:{type:Number,default:1},distance:{type:Number,default:0},penumbra:{type:Number,default:0},target:Object},created:function(){var e=this;this.light=new D(this.color,this.intensity,this.distance,this.angle,this.penumbra,this.decay),["angle","decay","distance","penumbra"].forEach((function(t){i((function(){return e[t]}),(function(){e.light[t]=e[t]}))}))},__hmrId:"SpotLight"},vt={inject:["three","mesh"],props:{id:String,color:{type:[String,Number],default:"#ffffff"},depthTest:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!0},flatShading:Boolean,fog:{type:Boolean,default:!0},opacity:{type:Number,default:1},side:{type:Number,default:O},transparent:Boolean,vertexColors:Boolean},provide:function(){return{material:this}},beforeMount:function(){this.createMaterial(),this.id&&(this.three.materials[this.id]=this.material),this.mesh.setMaterial(this.material)},mounted:function(){this._addWatchers(),this.addWatchers&&this.addWatchers()},unmounted:function(){this.material.dispose(),this.id&&delete this.three.materials[this.id]},methods:{setProp:function(e,t,i){void 0===i&&(i=!1),this.material[e]=t,this.material.needsUpdate=i},setTexture:function(e,t){void 0===t&&(t="map"),this.setProp(t,e,!0)},_addWatchers:function(){var e=this;["color","depthTest","depthWrite","fog","opacity","side","transparent"].forEach((function(t){i((function(){return e[t]}),(function(){"color"===t?e.material.color.set(e.color):e.material[t]=e[t]}))}))}},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Material"},yt={extends:vt,methods:{createMaterial:function(){this.material=new U(Ae(this.$props,["id"]))}},__hmrId:"BasicMaterial"},gt={extends:vt,methods:{createMaterial:function(){this.material=new F(Ae(this.$props,["id"]))}},__hmrId:"LambertMaterial"},xt={extends:vt,props:{src:String,name:String},methods:{createMaterial:function(){var e=this.name?$e(this.name):this.src,t=Ae(this.$props,["id","src","name"]);t.matcap=(new $).load(e),this.material=new W(t)}},__hmrId:"MatcapMaterial"},bt={extends:vt,props:{emissive:{type:[Number,String],default:0},emissiveIntensity:{type:Number,default:1},reflectivity:{type:Number,default:1},shininess:{type:Number,default:30},specular:{type:[String,Number],default:1118481}},methods:{createMaterial:function(){this.material=new Z(Ae(this.$props,["id"]))},addWatchers:function(){var e=this;["emissive","emissiveIntensity","reflectivity","shininess","specular"].forEach((function(t){i((function(){return e[t]}),(function(i){"emissive"===t||"specular"===t?e.material[t].set(i):e.material[t]=i}))}))}},__hmrId:"PhongMaterial"},St={aoMapIntensity:{type:Number,default:1},bumpScale:{type:Number,default:1},displacementBias:{type:Number,default:0},displacementScale:{type:Number,default:1},emissive:{type:[Number,String],default:0},emissiveIntensity:{type:Number,default:1},envMapIntensity:{type:Number,default:1},lightMapIntensity:{type:Number,default:1},metalness:{type:Number,default:0},normalScale:{type:Object,default:function(){return new m(1,1)}},roughness:{type:Number,default:1},refractionRatio:{type:Number,default:.98},wireframe:Boolean},wt={extends:vt,props:St,methods:{createMaterial:function(){this.material=new H(Ae(this.$props,["id","normalScale"]))},addWatchers:function(){var e=this;Object.keys(St).forEach((function(t){"normalScale"!==t&&i((function(){return e[t]}),(function(i){"emissive"===t?e.material[t].set(i):e.material[t]=i}))})),We(this,"normalScale",this.material.normalScale)}},__hmrId:"StandardMaterial"},Nt={extends:wt,methods:{createMaterial:function(){this.material=new q(Ae(this.$props,["id"]))}},__hmrId:"PhysicalMaterial"};var Ct,zt,_t,Mt=V.meshphong_frag.slice(0,V.meshphong_frag.indexOf("void main() {")),Pt=V.meshphong_frag.slice(V.meshphong_frag.indexOf("void main() {")),Tt={uniforms:X.merge([Y.phong.uniforms,{thicknessColor:{value:new x(6718871)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),vertexShader:"\n #define USE_UV\n "+V.meshphong_vert+"\n ",fragmentShader:"\n #define USE_UV\n #define SUBSURFACE\n\n "+Mt+"\n\n uniform float thicknessPower;\n uniform float thicknessScale;\n uniform float thicknessDistortion;\n uniform float thicknessAmbient;\n uniform float thicknessAttenuation;\n uniform vec3 thicknessColor;\n\n void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {\n #ifdef USE_COLOR\n vec3 thickness = vColor * thicknessColor;\n #else\n vec3 thickness = thicknessColor;\n #endif\n vec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));\n float scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;\n vec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;\n reflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;\n }\n "+Pt.replace("#include <lights_fragment_begin>",(Ct=V.lights_fragment_begin,zt="RE_Direct( directLight, geometry, material, reflectedLight );",_t="\n RE_Direct( directLight, geometry, material, reflectedLight );\n #if defined( SUBSURFACE ) && defined( USE_UV )\n RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);\n #endif\n ",Ct.split(zt).join(_t)))},Gt={extends:{inject:["three","mesh"],props:{id:String,uniforms:Object,vertexShader:String,fragmentShader:String},beforeMount:function(){this.createMaterial(),this.id&&(this.three.materials[this.id]=this.material),this.mesh.setMaterial(this.material)},mounted:function(){this.addWatchers&&this.addWatchers()},unmounted:function(){this.material.dispose(),this.id&&delete this.three.materials[this.id]},render:function(){return[]},__hmrId:"ShaderMaterial"},props:{diffuse:{type:String,default:"#ffffff"},thicknessColor:{type:String,default:"#ffffff"},thicknessDistortion:{type:Number,default:.4},thicknessAmbient:{type:Number,default:.01},thicknessAttenuation:{type:Number,default:.7},thicknessPower:{type:Number,default:2},thicknessScale:{type:Number,default:4},transparent:{type:Boolean,default:!1},opacity:{type:Number,default:1},vertexColors:{type:Boolean,default:!1}},methods:{createMaterial:function(){var e=Tt,t=X.clone(e.uniforms);Object.entries(this.$props).forEach((function(e){var i=e[0],r=e[1];"diffuse"!==i&&"thicknessColor"!==i||(r=new x(r)),"id"!==i&&"transparent"!==i&&"vertexColors"!==i&&(t[i].value=r)})),this.material=new K(Object.assign({},e,{uniforms:t,lights:!0,transparent:this.transparent,vertexColors:this.vertexColors}))}},__hmrId:"SubSurfaceMaterial"},It={extends:vt,methods:{createMaterial:function(){this.material=new Q(Ae(this.$props,["id"]))}},__hmrId:"ToonMaterial"},Rt={inject:["material"],emits:["loaded"],props:{src:String,onLoad:Function,onProgress:Function,onError:Function,id:{type:String,default:"map"}},created:function(){var e=this;this.refreshTexture(),i((function(){return e.src}),this.refreshTexture)},unmounted:function(){this.material.setTexture(null,this.id),this.texture.dispose()},methods:{createTexture:function(){this.texture=(new $).load(this.src,this.onLoaded,this.onProgress,this.onError)},refreshTexture:function(){this.createTexture(),this.material.setTexture(this.texture,this.id)},onLoaded:function(){this.onLoad&&this.onLoad(),this.$emit("loaded")}},render:function(){return[]}},jt={inject:["material"],emits:["loaded"],props:{path:String,urls:{type:Array,default:["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"]},onLoad:Function,onProgress:Function,onError:Function,id:{type:String,default:"envMap"},refraction:Boolean,refractionRatio:{type:Number,default:.98}},created:function(){var e=this;this.refreshTexture(),i((function(){return e.path}),this.refreshTexture),i((function(){return e.urls}),this.refreshTexture)},unmounted:function(){this.material.setTexture(null,this.id),this.texture.dispose()},methods:{createTexture:function(){this.texture=(new J).setPath(this.path).load(this.urls,this.onLoaded,this.onProgress,this.onError)},refreshTexture:function(){this.createTexture(),this.material.setTexture(this.texture,this.id),this.refraction&&(this.texture.mapping=ee,this.material.setProp("refractionRatio",this.refractionRatio))},onLoaded:function(){this.onLoad&&this.onLoad(),this.$emit("loaded")}},render:function(){return[]}},Lt={inject:["three","scene","rendererComponent"],emits:["ready"],props:{materialId:String,position:Object,rotation:Object,scale:Object,castShadow:Boolean,receiveShadow:Boolean,onHover:Function,onClick:Function},created:function(){this.parent=r("group",this.scene)},provide:function(){return{mesh:this}},mounted:function(){this.geometry&&!this.mesh&&this.initMesh()},unmounted:function(){this.mesh&&(this.three.removeIntersectObject(this.mesh),this.parent.remove(this.mesh)),this.geometry&&this.geometry.dispose(),this.material&&!this.materialId&&this.material.dispose()},methods:{initMesh:function(){var e=this;!this.material&&this.materialId&&(this.material=this.three.materials[this.materialId]),this.mesh=new te(this.geometry,this.material),this.onHover&&(this.mesh.onHover=function(t){e.onHover({component:e,over:t})},this.three.addIntersectObject(this.mesh)),this.onClick&&(this.mesh.onClick=function(t){e.onClick({component:e,event:t})},this.three.addIntersectObject(this.mesh)),this.bindProps(),this.parent.add(this.mesh),this.$emit("ready")},bindProps:function(){var e=this;We(this,"position",this.mesh.position),We(this,"rotation",this.mesh.rotation),We(this,"scale",this.mesh.scale),["castShadow","receiveShadow"].forEach((function(t){e.mesh[t]=e[t],i((function(){return e[t]}),(function(){e.mesh[t]=e[t]}))})),i((function(){return e.materialId}),(function(){e.mesh.material=e.three.materials[e.materialId]}))},setGeometry:function(e){this.geometry=e,this.mesh&&(this.mesh.geometry=e)},setMaterial:function(e){this.material=e,this.mesh&&(this.mesh.material=e)},refreshGeometry:function(){var e=this.geometry;this.createGeometry(),this.mesh.geometry=this.geometry,e.dispose()}},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Mesh"},Bt={extends:Lt,props:{size:Number,width:{type:Number,default:1},height:{type:Number,default:1},depth:{type:Number,default:1},widthSegments:{type:Number,default:1},heightSegments:{type:Number,default:1},depthSegments:{type:Number,default:1}},created:function(){var e=this;this.createGeometry(),["size","width","height","depth","widthSegments","heightSegments","depthSegments"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.size?this.geometry=new b(this.size,this.size,this.size):this.geometry=new b(this.width,this.height,this.depth)}},__hmrId:"Box"},Et={extends:Lt,props:{radius:{type:Number,default:1},segments:{type:Number,default:8},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["radius","segments","thetaStart","thetaLength"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new S(this.radius,this.segments,this.thetaStart,this.thetaLength)}},__hmrId:"Circle"},kt={extends:Lt,props:{radius:{type:Number,default:1},height:{type:Number,default:1},radialSegments:{type:Number,default:8},heightSegments:{type:Number,default:1},openEnded:{type:Boolean,default:!1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["radius","height","radialSegments","heightSegments","openEnded","thetaStart","thetaLength"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new w(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cone"},At={extends:Lt,props:{radiusTop:{type:Number,default:1},radiusBottom:{type:Number,default:1},height:{type:Number,default:1},radialSegments:{type:Number,default:8},heightSegments:{type:Number,default:1},openEnded:{type:Boolean,default:!1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["radiusTop","radiusBottom","height","radialSegments","heightSegments","openEnded","thetaStart","thetaLength"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new N(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cylinder"},Dt={extends:Lt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new C(this.radius,this.detail)}},__hmrId:"Dodecahedron"},Ot={extends:Lt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new z(this.radius,this.detail)}},__hmrId:"Icosahedron"},Ut={extends:Lt,props:{points:Array,segments:{type:Number,default:12},phiStart:{type:Number,default:0},phiLength:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["points","segments","phiStart","phiLength"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new _(this.points,this.segments,this.phiStart,this.phiLength)}},__hmrId:"Lathe"},Ft={extends:Lt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new M(this.radius,this.detail)}},__hmrId:"Octahedron"},$t={extends:Lt,props:{width:{type:Number,default:1},height:{type:Number,default:1},widthSegments:{type:Number,default:1},heightSegments:{type:Number,default:1}},created:function(){var e=this;this.createGeometry();["width","height","widthSegments","heightSegments"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ie(this.width,this.height,this.widthSegments,this.heightSegments)}},__hmrId:"Plane"},Wt={extends:Lt,props:{vertices:Array,indices:Array,radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["vertices","indices","radius","detail"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new P(this.vertices,this.indices,this.radius,this.detail)}},__hmrId:"Polyhedron"},Zt={extends:Lt,props:{innerRadius:{type:Number,default:.5},outerRadius:{type:Number,default:1},thetaSegments:{type:Number,default:8},phiSegments:{type:Number,default:1},thetaStart:{type:Number,default:0},thetaLength:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["innerRadius","outerRadius","thetaSegments","phiSegments","thetaStart","thetaLength"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new T(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}},__hmrId:"Ring"},Ht={extends:Lt,props:{radius:Number,widthSegments:{type:Number,default:12},heightSegments:{type:Number,default:12}},watch:{radius:function(){this.refreshGeometry()},widthSegments:function(){this.refreshGeometry()},heightSegments:function(){this.refreshGeometry()}},created:function(){this.createGeometry()},methods:{createGeometry:function(){this.geometry=new G(this.radius,this.widthSegments,this.heightSegments)}},__hmrId:"Sphere"},qt={extends:Lt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new I(this.radius,this.detail)}},__hmrId:"Tetrahedron"},Vt={text:String,fontSrc:String,size:{type:Number,default:80},height:{type:Number,default:5},depth:{type:Number,default:1},curveSegments:{type:Number,default:12},bevelEnabled:{type:Boolean,default:!1},bevelThickness:{type:Number,default:10},bevelSize:{type:Number,default:8},bevelOffset:{type:Number,default:0},bevelSegments:{type:Number,default:5},align:{type:[Boolean,String],default:!1}},Xt={extends:Lt,props:Object.assign({},Vt),created:function(){var e=this;["text","size","height","curveSegments","bevelEnabled","bevelThickness","bevelSize","bevelOffset","bevelSegments","align"].forEach((function(t){i((function(){return e[t]}),(function(){e.font&&e.refreshGeometry()}))})),(new re).load(this.fontSrc,(function(t){e.font=t,e.createGeometry(),e.initMesh()}))},methods:{createGeometry:function(){this.geometry=new ne(this.text,{font:this.font,size:this.size,height:this.height,depth:this.depth,curveSegments:this.curveSegments,bevelEnabled:this.bevelEnabled,bevelThickness:this.bevelThickness,bevelSize:this.bevelSize,bevelOffset:this.bevelOffset,bevelSegments:this.bevelSegments}),"center"===this.align&&this.geometry.center()}}},Yt={extends:Lt,props:{radius:{type:Number,default:.5},tube:{type:Number,default:.4},radialSegments:{type:Number,default:8},tubularSegments:{type:Number,default:6},arc:{type:Number,default:2*Math.PI}},created:function(){var e=this;this.createGeometry();["radius","tube","radialSegments","tubularSegments","arc"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new R(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.arc)}},__hmrId:"Torus"},Kt={extends:Lt,props:{radius:{type:Number,default:.5},tube:{type:Number,default:.4},radialSegments:{type:Number,default:64},tubularSegments:{type:Number,default:8},p:{type:Number,default:2},q:{type:Number,default:3}},created:function(){var e=this;this.createGeometry();["radius","tube","radialSegments","tubularSegments","p","q"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new j(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q)}},__hmrId:"TorusKnot"},Qt={extends:Lt,props:{path:L,tubularSegments:{type:Number,default:64},radius:{type:Number,default:1},radialSegments:{type:Number,default:8},closed:{type:Boolean,default:!1}},created:function(){var e=this;this.createGeometry();["path","tubularSegments","radius","radialSegments","closed"].forEach((function(t){i((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new B(this.path,this.tubularSegments,this.radius,this.radialSegments,this.closed)}},__hmrId:"Tube"},Jt={extends:Lt,props:{cubeRTSize:{type:Number,default:256},cubeCameraNear:{type:Number,default:.1},cubeCameraFar:{type:Number,default:2e3},autoUpdate:Boolean},mounted:function(){this.initGem(),this.autoUpdate?this.three.onBeforeRender(this.updateCubeRT):this.rendererComponent.onMounted(this.updateCubeRT)},unmounted:function(){this.three.offBeforeRender(this.updateCubeRT),this.meshBack&&this.parent.remove(this.meshBack),this.materialBack&&this.materialBack.dispose()},methods:{initGem:function(){var e=new se(this.cubeRTSize,{format:ae,generateMipmaps:!0,minFilter:oe});this.cubeCamera=new he(this.cubeCameraNear,this.cubeCameraFar,e),We(this,"position",this.cubeCamera.position),this.parent.add(this.cubeCamera),this.material.side=O,this.material.envMap=e.texture,this.material.envMapIntensity=10,this.material.metalness=0,this.material.roughness=0,this.material.opacity=.75,this.material.transparent=!0,this.material.premultipliedAlpha=!0,this.material.needsUpdate=!0,this.materialBack=this.material.clone(),this.materialBack.side=ue,this.materialBack.envMapIntensity=5,this.materialBack.metalness=1,this.materialBack.roughness=0,this.materialBack.opacity=.5,this.meshBack=new te(this.geometry,this.materialBack),We(this,"position",this.meshBack.position),We(this,"rotation",this.meshBack.rotation),We(this,"scale",this.meshBack.scale),this.parent.add(this.meshBack)},updateCubeRT:function(){this.mesh.visible=!1,this.meshBack.visible=!1,this.cubeCamera.update(this.three.renderer,this.scene),this.mesh.visible=!0,this.meshBack.visible=!0}},__hmrId:"Gem"},ei={emits:["loaded"],extends:Lt,props:{src:String,width:Number,height:Number,keepSize:Boolean},created:function(){var e=this;this.createGeometry(),this.createMaterial(),this.initMesh(),i((function(){return e.src}),this.refreshTexture),["width","height"].forEach((function(t){i((function(){return e[t]}),e.resize)})),this.keepSize&&this.three.onAfterResize(this.resize)},methods:{createGeometry:function(){this.geometry=new ie(1,1,1,1)},createMaterial:function(){this.material=new U({side:me,map:this.loadTexture()})},loadTexture:function(){return(new $).load(this.src,this.onLoaded)},refreshTexture:function(){this.texture&&this.texture.dispose(),this.material.map=this.loadTexture(),this.material.needsUpdate=!0},onLoaded:function(e){this.texture=e,this.resize(),this.$emit("loaded")},resize:function(){if(this.texture){var e,t,i=this.three.size,r=this.texture.image.width/this.texture.image.height;this.width&&this.height?(e=this.width*i.wWidth/i.width,t=this.height*i.wHeight/i.height):this.width?t=(e=this.width*i.wWidth/i.width)/r:this.height&&(e=(t=this.height*i.wHeight/i.height)*r),this.mesh.scale.x=e,this.mesh.scale.y=t}}},__hmrId:"Image"},ti={inject:["three","scene"],props:{materialId:String,count:Number,position:Object,castShadow:Boolean,receiveShadow:Boolean},created:function(){this.parent=r("group",this.scene)},provide:function(){return{mesh:this}},beforeMount:function(){this.$slots.default||console.error("Missing Geometry")},mounted:function(){this.initMesh()},unmounted:function(){this.parent.remove(this.mesh)},methods:{initMesh:function(){var e=this;!this.material&&this.materialId&&(this.material=this.three.materials[this.materialId]),this.mesh=new de(this.geometry,this.material,this.count),We(this,"position",this.mesh.position),We(this,"rotation",this.mesh.rotation),We(this,"scale",this.mesh.scale),["castShadow","receiveShadow"].forEach((function(t){e.mesh[t]=e[t],i((function(){return e[t]}),(function(){e.mesh[t]=e[t]}))})),this.parent.add(this.mesh)},setGeometry:function(e){this.geometry=e,this.mesh&&(this.mesh.geometry=e)},setMaterial:function(e){this.material=e,this.mesh&&(this.mesh.material=e)}},render:function(){return this.$slots.default()},__hmrId:"InstancedMesh"},ii={extends:Lt,props:{cubeRTSize:{type:Number,default:256},cubeCameraNear:{type:Number,default:.1},cubeCameraFar:{type:Number,default:2e3},autoUpdate:Boolean},mounted:function(){this.initMirrorMesh(),this.autoUpdate?this.three.onBeforeRender(this.updateCubeRT):this.rendererComponent.onMounted(this.updateCubeRT)},unmounted:function(){this.three.offBeforeRender(this.updateCubeRT),this.cubeCamera&&this.parent.remove(this.cubeCamera)},methods:{initMirrorMesh:function(){var e=new se(this.cubeRTSize,{format:ae,generateMipmaps:!0,minFilter:oe});this.cubeCamera=new he(this.cubeCameraNear,this.cubeCameraFar,e),this.parent.add(this.cubeCamera),this.material.envMap=e.texture,this.material.needsUpdate=!0},updateCubeRT:function(){this.mesh.visible=!1,this.cubeCamera.update(this.three.renderer,this.scene),this.mesh.visible=!0}},__hmrId:"MirrorMesh"},ri={extends:Lt,props:{cubeRTSize:{type:Number,default:256},cubeCameraNear:{type:Number,default:.1},cubeCameraFar:{type:Number,default:2e3},refractionRatio:{type:Number,default:.98},autoUpdate:Boolean},mounted:function(){this.initMirrorMesh(),this.autoUpdate?this.three.onBeforeRender(this.updateCubeRT):this.rendererComponent.onMounted(this.updateCubeRT)},unmounted:function(){this.three.offBeforeRender(this.updateCubeRT),this.cubeCamera&&this.parent.remove(this.cubeCamera)},methods:{initMirrorMesh:function(){var e=new se(this.cubeRTSize,{mapping:ee,format:ae,generateMipmaps:!0,minFilter:oe});this.cubeCamera=new he(this.cubeCameraNear,this.cubeCameraFar,e),We(this,"position",this.cubeCamera.position),this.parent.add(this.cubeCamera),this.material.envMap=e.texture,this.material.refractionRatio=this.refractionRatio,this.material.needsUpdate=!0},updateCubeRT:function(){this.mesh.visible=!1,this.cubeCamera.update(this.three.renderer,this.scene),this.mesh.visible=!0}},__hmrId:"RefractionMesh"},ni={emits:["ready","loaded"],inject:["three","scene"],props:{src:String,position:Object,scale:Object},created:function(){this.parent=r("group",this.scene)},mounted:function(){this.texture=(new $).load(this.src,this.onLoaded),this.material=new ce({map:this.texture}),this.sprite=new le(this.material),this.geometry=this.sprite.geometry,We(this,"position",this.sprite.position),We(this,"scale",this.sprite.scale),this.parent.add(this.sprite),this.$emit("ready")},unmounted:function(){this.texture.dispose(),this.material.dispose(),this.parent.remove(this.sprite)},methods:{onLoaded:function(){this.updateUV(),this.$emit("loaded")},updateUV:function(){this.iWidth=this.texture.image.width,this.iHeight=this.texture.image.height,this.iRatio=this.iWidth/this.iHeight;var e=.5,t=.5;this.iRatio>1?t=.5/this.iRatio:e=.5/this.iRatio;var i=this.geometry.attributes.position.array;i[0]=-e,i[1]=-t,i[5]=e,i[6]=-t,i[10]=e,i[11]=t,i[15]=-e,i[16]=t,this.geometry.attributes.position.needsUpdate=!0}},render:function(){return[]},__hmrId:"Sprite"},si={setup:function(){return{passes:[]}},inject:["three"],provide:function(){return{passes:this.passes}},mounted:function(){var e=this;this.three.onAfterInit((function(){e.composer=new Se(e.three.renderer),e.three.renderer.autoClear=!1,e.passes.forEach((function(t){e.composer.addPass(t)})),e.three.composer=e.composer,e.resize(),e.three.onAfterResize(e.resize)}))},unmounted:function(){this.three.offAfterResize(this.resize)},methods:{resize:function(){this.composer.setSize(this.three.size.width,this.three.size.height)}},render:function(){return this.$slots.default()},__hmrId:"EffectComposer"},ai={inject:["three","passes"],beforeMount:function(){this.passes||console.error("Missing parent EffectComposer")},unmounted:function(){this.pass.dispose&&this.pass.dispose()},render:function(){return[]},__hmrId:"EffectPass"},oi={extends:ai,mounted:function(){this.three.scene||console.error("Missing Scene"),this.three.camera||console.error("Missing Camera");var e=new we(this.three.scene,this.three.camera);this.passes.push(e),this.pass=e},__hmrId:"RenderPass"},hi={extends:ai,props:{focus:{type:Number,default:1},aperture:{type:Number,default:.025},maxblur:{type:Number,default:.01}},watch:{focus:function(){this.pass.uniforms.focus.value=this.focus},aperture:function(){this.pass.uniforms.aperture.value=this.aperture},maxblur:function(){this.pass.uniforms.maxblur.value=this.maxblur}},mounted:function(){this.three.scene||console.error("Missing Scene"),this.three.camera||console.error("Missing Camera");var e={focus:this.focus,aperture:this.aperture,maxblur:this.maxblur,width:this.three.size.width,height:this.three.size.height},t=new Ne(this.three.scene,this.three.camera,e);this.passes.push(t),this.pass=t},__hmrId:"BokehPass"},ui={extends:ai,props:{noiseIntensity:{type:Number,default:.5},scanlinesIntensity:{type:Number,default:.05},scanlinesCount:{type:Number,default:4096},grayscale:{type:Number,default:0}},watch:{noiseIntensity:function(){this.pass.uniforms.nIntensity.value=this.noiseIntensity},scanlinesIntensity:function(){this.pass.uniforms.sIntensity.value=this.scanlinesIntensity},scanlinesCount:function(){this.pass.uniforms.sCount.value=this.scanlinesCount},grayscale:function(){this.pass.uniforms.grayscale.value=this.grayscale}},mounted:function(){var e=new Ce(this.noiseIntensity,this.scanlinesIntensity,this.scanlinesCount,this.grayscale);this.passes.push(e),this.pass=e},__hmrId:"FilmPass"},mi={extends:ai,mounted:function(){var e=new ze(_e);this.passes.push(e),this.pass=e,this.three.onAfterResize(this.resize)},unmounted:function(){this.three.offAfterResize(this.resize)},methods:{resize:function(){var e=this.pass.material.uniforms.resolution;e.value.x=1/this.three.size.width,e.value.y=1/this.three.size.height}},__hmrId:"FXAAPass"},di={extends:ai,props:{shape:{type:Number,default:1},radius:{type:Number,default:4},rotateR:{type:Number,default:Math.PI/12*1},rotateG:{type:Number,default:Math.PI/12*2},rotateB:{type:Number,default:Math.PI/12*3},scatter:{type:Number,default:0}},mounted:function(){var e=this,t=new Me(this.three.size.width,this.three.size.height,{});["shape","radius","rotateR","rotateG","rotateB","scatter"].forEach((function(r){t.uniforms[r].value=e[r],i((function(){return e[r]}),(function(){t.uniforms[r].value=e[r]}))})),this.passes.push(t),this.pass=t},__hmrId:"HalftonePass"},ci={extends:ai,mounted:function(){var e=new Pe(this.three.size.width,this.three.size.height);this.passes.push(e),this.pass=e},__hmrId:"SMAAPass"},li="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fi={uniforms:{tDiffuse:{value:null},blurRadius:{value:0},gradientRadius:{value:0},start:{value:new m},end:{value:new m},delta:{value:new m},texSize:{value:new m}},vertexShader:li,fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float blurRadius;\n uniform float gradientRadius;\n uniform vec2 start;\n uniform vec2 end;\n uniform vec2 delta;\n uniform vec2 texSize;\n varying vec2 vUv;\n\n float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n }\n\n void main() {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vUv * texSize - start, normal)) / gradientRadius) * blurRadius;\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 texel = texture2D(tDiffuse, vUv + delta / texSize * percent * radius);\n // vec4 texel2 = texture2D(tDiffuse, vUv + vec2(-delta.y, delta.x) / texSize * percent * radius);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n texel.rgb *= texel.a;\n // texel2.rgb *= texel2.a;\n\n color += texel * weight;\n total += 2.0 * weight;\n }\n\n gl_FragColor = color / total;\n\n /* switch back from pre-multiplied alpha */\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n }\n "};function pi(e,t,r,n){void 0===n&&(n="value"),e[t]&&(r[n]=e[t],i((function(){return e[t]}),(function(e){r[n]=e})))}var vi={extends:ai,props:{blurRadius:{type:Number,default:10},gradientRadius:{type:Number,default:100},start:{type:Object,default:{x:0,y:100}},end:{type:Object,default:{x:10,y:100}}},mounted:function(){var e=this;this.pass=new ze(fi),this.passes.push(this.pass),this.pass1=new ze(fi),this.passes.push(this.pass1);var t=this.uniforms=this.pass.uniforms,r=this.uniforms1=this.pass1.uniforms;r.blurRadius=t.blurRadius,r.gradientRadius=t.gradientRadius,r.start=t.start,r.end=t.end,r.texSize=t.texSize,pi(this,"blurRadius",t.blurRadius),pi(this,"gradientRadius",t.gradientRadius),this.updateFocusLine(),["start","end"].forEach((function(t){i((function(){return e[t]}),e.updateFocusLine)})),this.pass.setSize=function(e,i){t.texSize.value.set(e,i)}},methods:{updateFocusLine:function(){this.uniforms.start.value.copy(this.start),this.uniforms.end.value.copy(this.end);var e=(new m).copy(this.end).sub(this.start).normalize();this.uniforms.delta.value.copy(e),this.uniforms1.delta.value.set(-e.y,e.x)}},__hmrId:"TiltShiftPass"},yi={extends:ai,props:{strength:{type:Number,default:1.5},radius:{type:Number,default:0},threshold:{type:Number,default:0}},watch:{strength:function(){this.pass.strength=this.strength},radius:function(){this.pass.radius=this.radius},threshold:function(){this.pass.threshold=this.threshold}},mounted:function(){var e=new m(this.three.size.width,this.three.size.height),t=new Te(e,this.strength,this.radius,this.threshold);this.passes.push(t),this.pass=t},__hmrId:"UnrealBloomPass"},gi={uniforms:{tDiffuse:{value:null},center:{value:new m(.5,.5)},strength:{value:0}},vertexShader:li,fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 center;\n uniform float strength;\n varying vec2 vUv;\n\n float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n }\n \n void main() {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = center - vUv;\n \n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n \n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 texel = texture2D(tDiffuse, vUv + toCenter * percent * strength);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n texel.rgb *= texel.a;\n\n color += texel * weight;\n total += weight;\n }\n\n gl_FragColor = color / total;\n\n /* switch back from pre-multiplied alpha */\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n }\n "},xi={extends:ai,props:{center:{type:Object,default:{x:.5,y:.5}},strength:{type:Number,default:.5}},mounted:function(){this.pass=new ze(gi),this.passes.push(this.pass);var e=this.uniforms=this.pass.uniforms;We(this,"center",e.center.value),pi(this,"strength",e.strength)},__hmrId:"ZoomBlurPass"},bi="\n//\n// Description : Array and textureless GLSL 2D simplex noise function.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec2 mod289(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec3 permute(vec3 x) {\n return mod289(((x*34.0)+1.0)*x);\n}\n\nfloat snoise(vec2 v)\n{\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n // First corner\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n\n // Other corners\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n\n // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n\n // Normalise gradients implicitly by scaling m\n // Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n\n // Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n",Si={extends:ei,props:{widthSegments:{type:Number,default:20},heightSegments:{type:Number,default:20},timeCoef:{type:Number,default:.001},noiseCoef:{type:Number,default:1},zCoef:{type:Number,default:5},dispCoef:{type:Number,default:.05}},setup:function(e){var t={value:e.noiseCoef};i((function(){return e.noiseCoef}),(function(e){t.value=e}));var r={value:e.zCoef};i((function(){return e.zCoef}),(function(e){r.value=e}));var n={value:e.dispCoef};return i((function(){return e.dispCoef}),(function(e){n.value=e})),{uTime:{value:0},uNoiseCoef:t,uZCoef:r,uDispCoef:n}},mounted:function(){this.startTime=Date.now(),this.three.onBeforeRender(this.updateTime)},unmounted:function(){this.three.offBeforeRender(this.updateTime)},methods:{createGeometry:function(){this.geometry=new ie(1,1,this.widthSegments,this.heightSegments)},createMaterial:function(){var e=this;this.material=new U({side:me,map:this.loadTexture()}),this.material.onBeforeCompile=function(t){t.uniforms.uTime=e.uTime,t.uniforms.uNoiseCoef=e.uNoiseCoef,t.uniforms.uZCoef=e.uZCoef,t.uniforms.uDispCoef=e.uDispCoef,t.vertexShader="\n uniform float uTime;\n uniform float uNoiseCoef;\n uniform float uZCoef;\n varying float vNoise;\n "+bi+"\n "+t.vertexShader,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>"," \n vec3 p = vec3(position * uNoiseCoef);\n p.x += uTime;\n vNoise = snoise(p.xy);\n vec3 transformed = vec3(position);\n transformed.z += vNoise * uZCoef;\n "),t.fragmentShader="\n uniform float uDispCoef;\n varying float vNoise;\n "+t.fragmentShader,t.fragmentShader=t.fragmentShader.replace("#include <map_fragment>","\n vec4 texelColor = texture2D(map, vUv);\n vec4 dispTexel = texture2D(map, vUv + vec2(vNoise * uDispCoef, 0));\n texelColor.r = dispTexel.r;\n diffuseColor = texelColor;\n "),e.materialShader=t}},updateTime:function(){this.uTime.value=(Date.now()-this.startTime)*this.timeCoef}},__hmrId:"NoisyImage"},wi={extends:$t,props:{timeCoef:{type:Number,default:.001},noiseCoef:{type:Number,default:5},deltaCoef:{type:Number,default:1/512},displacementScale:{type:Number,default:5}},setup:function(e){var t={value:e.noiseCoef};i((function(){return e.noiseCoef}),(function(e){t.value=e}));var r={value:new m(e.deltaCoef,e.deltaCoef)};return i((function(){return e.deltaCoef}),(function(e){r.value.set(e,e)})),{uTime:{value:0},uNoiseCoef:t,uDelta:r}},mounted:function(){var e=this;this.init(),i((function(){return e.displacementScale}),(function(t){e.material.displacementScale=t})),this.startTime=Date.now(),this.three.onBeforeRender(this.update)},unmounted:function(){this.three.offBeforeRender(this.update),this.fsQuad.dispose(),this.dispRT.dispose(),this.dispMat.dispose(),this.normRT.dispose(),this.normMat.dispose()},methods:{init:function(){this.fsQuad=new Ge.FullScreenQuad,this.dispRT=new fe(512,512,{depthBuffer:!1,stencilBuffer:!1}),this.dispMat=new K({uniforms:{uTime:this.uTime,uNoiseCoef:this.uNoiseCoef},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n // gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n gl_Position = vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform float uTime;\n uniform float uNoiseCoef;\n varying vec2 vUv;\n \n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec4 permute(vec4 x) { return mod289(((x*34.0)+1.0)*x); }\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nfloat snoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n // First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n // Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n // Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n // Gradients: 7x7 points over a square, mapped onto an octahedron.\n // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n // Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n // Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\n void main() {\n vec2 p = vec2(vUv * uNoiseCoef);\n float noise = (snoise(vec3(p.x, p.y, uTime)) + 1.0) / 2.0;\n gl_FragColor = vec4(noise, 0.0, 0.0, 1.0);\n }\n "}),this.normRT=new fe(512,512,{depthBuffer:!1,stencilBuffer:!1}),this.normMat=new K({uniforms:{dispMap:{value:this.dispRT.texture},delta:this.uDelta},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n // gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n gl_Position = vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D dispMap;\n uniform vec2 delta;\n varying vec2 vUv;\n void main() {\n // gl_FragColor = vec4(0.5, 0.5, 1.0, 0.0);\n float x1 = texture2D(dispMap, vec2(vUv.x - delta.x, vUv.y)).r;\n float x2 = texture2D(dispMap, vec2(vUv.x + delta.x, vUv.y)).r;\n float y1 = texture2D(dispMap, vec2(vUv.x, vUv.y - delta.y)).r;\n float y2 = texture2D(dispMap, vec2(vUv.x, vUv.y + delta.y)).r;\n gl_FragColor = vec4(0.5 + (x1 - x2), 0.5 + (y1 - y2), 1.0, 1.0);\n }\n "}),this.material.displacementMap=this.dispRT.texture,this.material.displacementScale=this.displacementScale,this.material.normalMap=this.normRT.texture,this.material.normalMapType=pe},update:function(){this.uTime.value=(Date.now()-this.startTime)*this.timeCoef,this.renderDisp()},renderDisp:function(){this.renderMat(this.dispMat,this.dispRT),this.renderMat(this.normMat,this.normRT)},renderMat:function(e,t){var i=this.three.renderer;this.fsQuad.material=e;var r=i.getRenderTarget();i.setRenderTarget(t),this.fsQuad.render(i),i.setRenderTarget(r)}},__hmrId:"NoisyPlane"},Ni={extends:Ht,props:{radius:{type:Number,default:20},widthSegments:{type:Number,default:128},heightSegments:{type:Number,default:128},timeCoef:{type:Number,default:.001},noiseCoef:{type:Number,default:.05},dispCoef:{type:Number,default:5}},setup:function(e){var t={value:e.noiseCoef};i((function(){return e.noiseCoef}),(function(e){t.value=e}));var r={value:e.dispCoef};return i((function(){return e.dispCoef}),(function(e){r.value=e})),{uTime:{value:0},uNoiseCoef:t,uDispCoef:r}},mounted:function(){this.updateMaterial(),this.startTime=Date.now(),this.three.onBeforeRender(this.updateTime)},unmounted:function(){this.three.offBeforeRender(this.updateTime)},methods:{updateMaterial:function(){var e=this;this.material.onBeforeCompile=function(t){t.uniforms.uTime=e.uTime,t.uniforms.uNoiseCoef=e.uNoiseCoef,t.uniforms.uDispCoef=e.uDispCoef,t.vertexShader="\n uniform float uTime;\n uniform float uNoiseCoef;\n uniform float uDispCoef;\n varying float vNoise;\n \n//\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nfloat mod289(float x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec4 permute(vec4 x) { return mod289(((x*34.0)+1.0)*x); }\nfloat permute(float x) { return mod289(((x*34.0)+1.0)*x); }\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\nfloat taylorInvSqrt(float r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nvec4 grad4(float j, vec4 ip)\n{\n const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);\n vec4 p,s;\n\n p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;\n p.w = 1.5 - dot(abs(p.xyz), ones.xyz);\n s = vec4(lessThan(p, vec4(0.0)));\n p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www;\n\n return p;\n}\n\n// (sqrt(5) - 1)/4 = F4, used once below\n#define F4 0.309016994374947451\n\nfloat snoise(vec4 v)\n{\n const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4\n 0.276393202250021, // 2 * G4\n 0.414589803375032, // 3 * G4\n -0.447213595499958); // -1 + 4 * G4\n\n // First corner\n vec4 i = floor(v + dot(v, vec4(F4)) );\n vec4 x0 = v - i + dot(i, C.xxxx);\n\n // Other corners\n\n // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)\n vec4 i0;\n vec3 isX = step( x0.yzw, x0.xxx );\n vec3 isYZ = step( x0.zww, x0.yyz );\n // i0.x = dot( isX, vec3( 1.0 ) );\n i0.x = isX.x + isX.y + isX.z;\n i0.yzw = 1.0 - isX;\n // i0.y += dot( isYZ.xy, vec2( 1.0 ) );\n i0.y += isYZ.x + isYZ.y;\n i0.zw += 1.0 - isYZ.xy;\n i0.z += isYZ.z;\n i0.w += 1.0 - isYZ.z;\n\n // i0 now contains the unique values 0,1,2,3 in each channel\n vec4 i3 = clamp( i0, 0.0, 1.0 );\n vec4 i2 = clamp( i0-1.0, 0.0, 1.0 );\n vec4 i1 = clamp( i0-2.0, 0.0, 1.0 );\n\n vec4 x1 = x0 - i1 + C.xxxx;\n vec4 x2 = x0 - i2 + C.yyyy;\n vec4 x3 = x0 - i3 + C.zzzz;\n vec4 x4 = x0 + C.wwww;\n\n // Permutations\n i = mod289(i);\n float j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x);\n vec4 j1 = permute( permute( permute( permute (\n i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n + i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n + i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n + i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\n\n // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope\n // 7*7*6 = 294, which is close to the ring size 17*17 = 289.\n vec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ;\n\n vec4 p0 = grad4(j0, ip);\n vec4 p1 = grad4(j1.x, ip);\n vec4 p2 = grad4(j1.y, ip);\n vec4 p3 = grad4(j1.z, ip);\n vec4 p4 = grad4(j1.w, ip);\n\n // Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n p4 *= taylorInvSqrt(dot(p4,p4));\n\n // Mix contributions from the five corners\n vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0);\n vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0);\n m0 = m0 * m0;\n m1 = m1 * m1;\n return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\n\n}\n\n "+t.vertexShader,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>","\n vec4 p = vec4(vec3(position * uNoiseCoef), uTime);\n vNoise = snoise(p);\n vec3 transformed = vec3(position);\n transformed += normalize(position) * vNoise * uDispCoef;\n "),e.materialShader=t},this.material.needsupdate=!0},updateTime:function(){this.uTime.value=(Date.now()-this.startTime)*this.timeCoef}},__hmrId:"NoisySphere"},Ci={extends:Xt,props:{timeCoef:{type:Number,default:.001},noiseCoef:{type:Number,default:.015},zCoef:{type:Number,default:10}},setup:function(e){var t={value:e.noiseCoef};i((function(){return e.noiseCoef}),(function(e){t.value=e}));var r={value:e.zCoef};return i((function(){return e.zCoef}),(function(e){r.value=e})),{uTime:{value:0},uNoiseCoef:t,uZCoef:r}},mounted:function(){this.updateMaterial(),this.startTime=Date.now(),this.three.onBeforeRender(this.updateTime)},unmounted:function(){this.three.offBeforeRender(this.updateTime)},methods:{updateMaterial:function(){var e=this;this.material.onBeforeCompile=function(t){t.uniforms.uTime=e.uTime,t.uniforms.uNoiseCoef=e.uNoiseCoef,t.uniforms.uZCoef=e.uZCoef,t.vertexShader="\n uniform float uTime;\n uniform float uNoiseCoef;\n uniform float uZCoef;\n "+bi+"\n "+t.vertexShader,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>"," \n vec3 p = vec3(position * uNoiseCoef);\n p.x += uTime;\n float noise = snoise(p.xy);\n vec3 transformed = vec3(position);\n transformed.z += noise * uZCoef;\n "),e.materialShader=t},this.material.needsupdate=!0},updateTime:function(){this.uTime.value=(Date.now()-this.startTime)*this.timeCoef}},__hmrId:"NoisyText"},zi=function(e){var t=this;Object.entries(e).forEach((function(e){var i=e[0],r=e[1];t[i]=r})),this.o3d=new ve,this.uProgress={value:0},this.uvScale=new m,this.initMaterial(),this.initPlane()};zi.prototype.initMaterial=function(){var e=this;this.material=new U({side:me,transparent:!0,map:this.texture,onBeforeCompile:function(t){t.uniforms.progress=e.uProgress,t.uniforms.uvScale={value:e.uvScale},t.vertexShader="\n uniform float progress;\n uniform vec2 uvScale;\n\n attribute vec3 offset;\n attribute vec3 rotation;\n attribute vec2 uvOffset;\n\n mat3 rotationMatrixXYZ(vec3 r)\n {\n float cx = cos(r.x);\n float sx = sin(r.x);\n float cy = cos(r.y);\n float sy = sin(r.y);\n float cz = cos(r.z);\n float sz = sin(r.z);\n\n return mat3(\n cy * cz, cx * sz + sx * sy * cz, sx * sz - cx * sy * cz,\n -cy * sz, cx * cz - sx * sy * sz, sx * cz + cx * sy * sz,\n sy, -sx * cy, cx * cy\n );\n }\n "+t.vertexShader,t.vertexShader=t.vertexShader.replace("#include <uv_vertex>","\n #include <uv_vertex>\n vUv = vUv * uvScale + uvOffset;\n "),t.vertexShader=t.vertexShader.replace("#include <project_vertex>","\n mat3 rotMat = rotationMatrixXYZ(progress * rotation);\n transformed = rotMat * transformed;\n\n vec4 mvPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n\n mvPosition.xyz += progress * offset;\n\n mvPosition = modelViewMatrix * mvPosition;\n gl_Position = projectionMatrix * mvPosition;\n ")}})},zi.prototype.initPlane=function(){var e=this.screen,t=e.width,i=e.wWidth,r=e.wHeight;this.wSize=this.size*i/t,this.nx=Math.ceil(i/this.wSize)+1,this.ny=Math.ceil(r/this.wSize)+1,this.icount=this.nx*this.ny,this.initGeometry(),this.initUV(),this.initAnimAttributes(),this.imesh&&this.o3d.remove(this.imesh),this.imesh=new de(this.bGeometry,this.material,this.icount),this.o3d.add(this.imesh);for(var n=new ve,s=0,a=-(i-(i-this.nx*this.wSize))/2+this.dx,o=0;o<this.nx;o++){for(var h=-(r-(r-this.ny*this.wSize))/2+this.dy,u=0;u<this.ny;u++)n.position.set(a,h,0),n.updateMatrix(),this.imesh.setMatrixAt(s++,n.matrix),h+=this.wSize;a+=this.wSize}},zi.prototype.initGeometry=function(){var e=new je;e.vertices.push(new d(0,0,0)),e.vertices.push(new d(this.wSize,0,0)),e.vertices.push(new d(0,this.wSize,0)),e.vertices.push(new d(this.wSize,this.wSize,0)),e.faces.push(new ye(0,2,1)),e.faces.push(new ye(2,3,1)),e.faceVertexUvs[0].push([new m(0,0),new m(0,1),new m(1,0)]),e.faceVertexUvs[0].push([new m(0,1),new m(1,1),new m(1,0)]),this.dx=this.wSize/2,this.dy=this.wSize/2,e.translate(-this.dx,-this.dy,0),this.bGeometry=e.toBufferGeometry()},zi.prototype.initAnimAttributes=function(){for(var e=ge.randFloat,t=ge.randFloatSpread,i=new d,r=new Float32Array(3*this.icount),n=0;n<r.length;n+=3)1===this.anim?i.set(t(10),e(50,100),e(20,50)).toArray(r,n):i.set(t(20),t(20),e(20,200)).toArray(r,n);this.bGeometry.setAttribute("offset",new xe(r,3));for(var s=new Float32Array(3*this.icount),a=4*Math.PI,o=0;o<s.length;o+=3)s[o]=t(a),s[o+1]=t(a),s[o+2]=t(a);this.bGeometry.setAttribute("rotation",new xe(s,3))},zi.prototype.initUV=function(){var e=this.nx/this.ny,t=this.texture.image.width/this.texture.image.height;e>t?this.uvScale.set(1/this.nx,t/e/this.ny):this.uvScale.set(e/t/this.nx,1/this.ny);for(var i=this.uvScale.x*this.nx,r=this.uvScale.y*this.ny,n=new m,s=new Float32Array(2*this.icount),a=0;a<this.nx;a++)for(var o=0;o<this.ny;o++)n.set(this.uvScale.x*a+(1-i)/2,this.uvScale.y*o+(1-r)/2).toArray(s,2*(a*this.ny+o));this.bGeometry.setAttribute("uvOffset",new xe(s,2))},zi.prototype.setTexture=function(e){this.texture=e,this.material.map=e,this.initUV()},zi.prototype.resize=function(){this.initPlane()};var _i={props:{images:Array,events:{type:Object,default:function(){return{wheel:!0,click:!0,keyup:!0}}}},setup:function(){var e=function(){var e={loader:new $,count:0,textures:[],loadProgress:0,loadTextures:function(i,r){e.count=i.length,e.textures.splice(0),e.loadProgress=0,Promise.all(i.map(t)).then(r)},dispose:function(){e.textures.forEach((function(e){return e.dispose()}))}};return e;function t(t,i){return new Promise((function(r){e.loader.load(t.src,(function(t){e.loadProgress+=1/e.count,e.textures[i]=t,r(t)}))}))}}();return{textures:e.textures,loadTextures:e.loadTextures,progress:0,targetProgress:0}},mounted:function(){this.three=this.$refs.renderer.three,this.images.length<2?console.error("This slider needs at least 2 images."):this.loadTextures(this.images,this.init)},unmounted:function(){document.removeEventListener("click",this.onClick),document.removeEventListener("keyup",this.onKeyup),window.removeEventListener("wheel",this.onWheel)},methods:{init:function(){this.initScene(),Ie.fromTo(this.plane1.uProgress,{value:-2},{value:0,duration:2.5,ease:Re.easeOut}),this.events.click&&document.addEventListener("click",this.onClick),this.events.keyup&&document.addEventListener("keyup",this.onKeyup),this.events.wheel&&window.addEventListener("wheel",this.onWheel),this.three.onBeforeRender(this.updateProgress),this.three.onAfterResize(this.onResize)},initScene:function(){var e=this.three.renderer,t=this.$refs.scene.scene;this.plane1=new zi({renderer:e,screen:this.three.size,size:10,anim:1,texture:this.textures[0]}),this.plane2=new zi({renderer:e,screen:this.three.size,size:10,anim:2,texture:this.textures[1]}),this.setPlanesProgress(0),this.planes=new ve,this.planes.add(this.plane1.o3d),this.planes.add(this.plane2.o3d),t.add(this.planes)},onResize:function(){this.plane1.resize(),this.plane2.resize()},onWheel:function(e){e.deltaY>0?this.setTargetProgress(this.targetProgress+.05):this.setTargetProgress(this.targetProgress-.05)},onClick:function(e){e.clientY<this.three.size.height/2?this.navPrevious():this.navNext()},onKeyup:function(e){37===e.keyCode||38===e.keyCode?this.navPrevious():39!==e.keyCode&&40!==e.keyCode||this.navNext()},navNext:function(){Number.isInteger(this.targetProgress)?this.setTargetProgress(this.targetProgress+1):this.setTargetProgress(Math.ceil(this.targetProgress))},navPrevious:function(){Number.isInteger(this.targetProgress)?this.setTargetProgress(this.targetProgress-1):this.setTargetProgress(Math.floor(this.targetProgress))},setTargetProgress:function(e){this.targetProgress=e,this.targetProgress<0&&(this.progress+=this.images.length,this.targetProgress+=this.images.length)},updateProgress:function(){var e=De(this.progress,this.targetProgress,.1),t=e-this.progress;if(0!==t){var i=this.progress%1,r=e%1;if(t>0&&r<i||t<0&&i<r){var n=Math.floor(e)%this.images.length,s=(n+1)%this.images.length;this.plane1.setTexture(this.textures[n]),this.plane2.setTexture(this.textures[s])}this.progress=e,this.setPlanesProgress(this.progress%1)}},setPlanesProgress:function(e){this.plane1.uProgress.value=e,this.plane2.uProgress.value=-1+e,this.plane1.material.opacity=1-e,this.plane2.material.opacity=e,this.plane1.o3d.position.z=e,this.plane2.o3d.position.z=e-1}}};_i.render=function(e,t,i,r,u,m){var d=n("Camera"),c=n("Scene"),l=n("Renderer");return s(),a(l,{ref:"renderer",antialias:""},{default:o((function(){return[h(d,{ref:"camera",position:{z:150}},null,512),h(c,{ref:"scene"},null,512)]})),_:1},512)},_i.__file="src/components/sliders/Slider1.vue";var Mi={props:{src:String,cameraPosition:Object},mounted:function(){var e=this;this.renderer=this.$refs.renderer,(new Le).load(this.src,(function(t){e.renderer.three.scene.add(t.scene)}))}};Mi.render=function(e,t,i,r,m,d){var c=n("Camera"),l=n("Scene"),f=n("Renderer");return s(),a(f,{ref:"renderer","orbit-ctrl":{enableDamping:!0,dampingFactor:.05}},{default:o((function(){return[h(c,{ref:"camera",position:i.cameraPosition},null,8,["position"]),h(l,null,{default:o((function(){return[u(e.$slots,"default")]})),_:3})]})),_:1},8,["orbit-ctrl"])},Mi.__file="src/components/viewers/GLTFViewer.vue";var Pi=Object.freeze({__proto__:null,Renderer:Ee,OrthographicCamera:Ze,PerspectiveCamera:He,Camera:He,Group:qe,Scene:Ve,BoxGeometry:Ye,CircleGeometry:Ke,ConeGeometry:Qe,CylinderGeometry:Je,DodecahedronGeometry:et,IcosahedronGeometry:tt,LatheGeometry:it,OctahedronGeometry:rt,PolyhedronGeometry:nt,RingGeometry:st,SphereGeometry:at,TetrahedronGeometry:ot,TorusGeometry:ht,TorusKnotGeometry:ut,TubeGeometry:mt,AmbientLight:ct,DirectionalLight:lt,PointLight:ft,SpotLight:pt,BasicMaterial:yt,LambertMaterial:gt,MatcapMaterial:xt,PhongMaterial:bt,PhysicalMaterial:Nt,StandardMaterial:wt,SubSurfaceMaterial:Gt,ToonMaterial:It,Texture:Rt,CubeTexture:jt,Mesh:Lt,Box:Bt,Circle:Et,Cone:kt,Cylinder:At,Dodecahedron:Dt,Icosahedron:Ot,Lathe:Ut,Octahedron:Ft,Plane:$t,Polyhedron:Wt,Ring:Zt,Sphere:Ht,Tetrahedron:qt,Text:Xt,Torus:Yt,TorusKnot:Kt,Tube:Qt,Gem:Jt,Image:ei,InstancedMesh:ti,MirrorMesh:ii,RefractionMesh:ri,Sprite:ni,EffectComposer:si,RenderPass:oi,BokehPass:hi,FilmPass:ui,FXAAPass:mi,HalftonePass:di,SMAAPass:ci,TiltShiftPass:vi,UnrealBloomPass:yi,ZoomBlurPass:xi,NoisyImage:Si,NoisyPlane:wi,NoisySphere:Ni,NoisyText:Ci,Slider1:_i,GLTFViewer:Mi,setFromProp:ke,propsValues:Ae,lerp:De,lerpv2:Oe,lerpv3:Ue,limit:Fe,getMatcapUrl:$e}),Ti={install:function(e){["Camera","OrthographicCamera","PerspectiveCamera","Renderer","Scene","Group","BoxGeometry","CircleGeometry","ConeGeometry","CylinderGeometry","DodecahedronGeometry","IcosahedronGeometry","LatheGeometry","OctahedronGeometry","PolyhedronGeometry","RingGeometry","SphereGeometry","TetrahedronGeometry","TorusGeometry","TorusKnotGeometry","TubeGeometry","AmbientLight","DirectionalLight","PointLight","SpotLight","BasicMaterial","LambertMaterial","MatcapMaterial","PhongMaterial","PhysicalMaterial","ShaderMaterial","StandardMaterial","SubSurfaceMaterial","ToonMaterial","Texture","CubeTexture","Box","Circle","Cone","Cylinder","Dodecahedron","Icosahedron","Mesh","Lathe","Octahedron","Plane","Polyhedron","Ring","Sphere","Tetrahedron","Text","Torus","TorusKnot","Tube","Gem","Image","InstancedMesh","MirrorMesh","RefractionMesh","Sprite","BokehPass","EffectComposer","FilmPass","FXAAPass","HalftonePass","RenderPass","SAOPass","SMAAPass","TiltShiftPass","UnrealBloomPass","ZoomBlurPass","GLTFViewer"].forEach((function(t){e.component(t,Pi[t])}))}};export{ct as AmbientLight,yt as BasicMaterial,hi as BokehPass,Bt as Box,Ye as BoxGeometry,He as Camera,Et as Circle,Ke as CircleGeometry,kt as Cone,Qe as ConeGeometry,jt as CubeTexture,At as Cylinder,Je as CylinderGeometry,lt as DirectionalLight,Dt as Dodecahedron,et as DodecahedronGeometry,si as EffectComposer,mi as FXAAPass,ui as FilmPass,Mi as GLTFViewer,Jt as Gem,qe as Group,di as HalftonePass,Ot as Icosahedron,tt as IcosahedronGeometry,ei as Image,ti as InstancedMesh,gt as LambertMaterial,Ut as Lathe,it as LatheGeometry,xt as MatcapMaterial,Lt as Mesh,ii as MirrorMesh,Si as NoisyImage,wi as NoisyPlane,Ni as NoisySphere,Ci as NoisyText,Ft as Octahedron,rt as OctahedronGeometry,Ze as OrthographicCamera,He as PerspectiveCamera,bt as PhongMaterial,Nt as PhysicalMaterial,$t as Plane,ft as PointLight,Wt as Polyhedron,nt as PolyhedronGeometry,ri as RefractionMesh,oi as RenderPass,Ee as Renderer,Zt as Ring,st as RingGeometry,ci as SMAAPass,Ve as Scene,_i as Slider1,Ht as Sphere,at as SphereGeometry,pt as SpotLight,ni as Sprite,wt as StandardMaterial,Gt as SubSurfaceMaterial,qt as Tetrahedron,ot as TetrahedronGeometry,Xt as Text,Rt as Texture,vi as TiltShiftPass,It as ToonMaterial,Yt as Torus,ht as TorusGeometry,Kt as TorusKnot,ut as TorusKnotGeometry,Ti as TroisJSVuePlugin,Qt as Tube,mt as TubeGeometry,yi as UnrealBloomPass,xi as ZoomBlurPass,$e as getMatcapUrl,De as lerp,Oe as lerpv2,Ue as lerpv3,Fe as limit,Ae as propsValues,ke as setFromProp};
|
|
//# sourceMappingURL=trois.module.min.js.map
|