1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00
trois/build/trois.module.cdn.min.js
Kevin Levron ce00e726f2 0.1.9
2021-03-05 09:17:16 +01:00

3 lines
55 KiB
JavaScript

import{h as e,toRef as t,watch as i}from"https://unpkg.com/vue@3.0.5/dist/vue.esm-browser.prod.js";import{Vector2 as r,Vector3 as s,Plane as n,Raycaster as a,WebGLRenderer as o,OrthographicCamera as h,PerspectiveCamera as u,Group as d,Scene as m,Color as c,BoxBufferGeometry as l,CircleBufferGeometry as f,ConeBufferGeometry as p,CylinderBufferGeometry as g,DodecahedronBufferGeometry as y,IcosahedronBufferGeometry as b,LatheBufferGeometry as v,OctahedronBufferGeometry as S,PolyhedronBufferGeometry as N,RingBufferGeometry as w,SphereBufferGeometry as x,TetrahedronBufferGeometry as _,TorusBufferGeometry as C,TorusKnotBufferGeometry as M,Curve as G,TubeBufferGeometry as I,AmbientLight as k,DirectionalLight as z,PointLight as P,SpotLight as R,FrontSide as B,MeshBasicMaterial as j,MeshLambertMaterial as E,TextureLoader as L,MeshMatcapMaterial as T,MeshPhongMaterial as O,MeshStandardMaterial as A,MeshPhysicalMaterial as F,ShaderChunk as U,UniformsUtils as D,ShaderLib as $,ShaderMaterial as H,MeshToonMaterial as W,CubeTextureLoader as V,CubeRefractionMapping as X,Mesh as q,PlaneBufferGeometry as Z,FontLoader as K,TextBufferGeometry as Y,WebGLCubeRenderTarget as J,RGBFormat as Q,LinearMipmapLinearFilter as ee,CubeCamera as te,BackSide as ie,DoubleSide as re,InstancedMesh as se,SpriteMaterial as ne,Sprite as ae}from"https://unpkg.com/three@0.125.2/build/three.module.js";import{OrbitControls as oe}from"https://unpkg.com/three@0.125.2/examples/jsm/controls/OrbitControls.js";import{EffectComposer as he}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/EffectComposer.js";import{RenderPass as ue}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/RenderPass.js";import{BokehPass as de}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/BokehPass.js";import{FilmPass as me}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/FilmPass.js";import{ShaderPass as ce}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/ShaderPass.js";import{FXAAShader as le}from"https://unpkg.com/three@0.125.2/examples/jsm/shaders/FXAAShader.js";import{HalftonePass as fe}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/HalftonePass.js";import{SMAAPass as pe}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/SMAAPass.js";import{UnrealBloomPass as ge}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/UnrealBloomPass.js";function ye(){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=[],h=[],u=[],d=new r,m=new s,c=new n(new s(0,0,1),0),l=new a,f=[],p={conf:e,renderer:null,camera:null,cameraCtrl:null,materials:{},scene:null,size:t,mouse:d,mouseV3:m,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 o({canvas:e.canvas,antialias:e.antialias,alpha:e.alpha}),p.renderer.autoClear=e.autoClear,e.orbit_ctrl&&(p.orbitCtrl=new oe(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.resize?(N(),window.addEventListener("resize",N)):w(300|e.width,150|e.height);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",b),p.mouse_move_element.addEventListener("mouseleave",v));e.click&&p.renderer.domElement.addEventListener("click",y);return i.forEach((function(e){return e()})),!0},dispose:function(){u=[],window.removeEventListener("resize",N),p.mouse_move_element&&(p.mouse_move_element.removeEventListener("mousemove",b),p.mouse_move_element.removeEventListener("mouseleave",v));p.renderer.domElement.removeEventListener("click",y),p.orbitCtrl&&p.orbitCtrl.dispose();this.renderer.dispose()},render:function(){p.orbitCtrl&&p.orbitCtrl.update();u.forEach((function(e){return e()})),p.renderer.render(p.scene,p.camera)},renderC:function(){p.orbitCtrl&&p.orbitCtrl.update();u.forEach((function(e){return e()})),p.composer.render()},setSize:w,onAfterInit:function(e){i.push(e)},onAfterResize:function(e){h.push(e)},offAfterResize:function(e){h=h.filter((function(t){return t!==e}))},onBeforeRender:function(e){u.push(e)},offBeforeRender:function(e){u=u.filter((function(t){return t!==e}))},addIntersectObject:function(e){-1===f.indexOf(e)&&f.push(e)},removeIntersectObject:function(e){var t=f.indexOf(e);-1!==t&&f.splice(t,1)}};function g(e){var i=e.target.getBoundingClientRect();d.x=(e.clientX-i.left)/t.width*2-1,d.y=-(e.clientY-i.top)/t.height*2+1}function y(e){g(e),l.setFromCamera(d,p.camera);for(var t=l.intersectObjects(f),i=0;i<t.length;i++){var r=t[i].object;r.onClick&&r.onClick(e)}}function b(e){g(e),S()}function v(e){S()}function S(t){if((e.mouse_over||e.mouse_raycast)&&(l.setFromCamera(d,p.camera),e.mouse_raycast&&(p.camera.getWorldDirection(c.normal),c.normal.normalize(),l.ray.intersectPlane(c,m)),e.mouse_over)){for(var i=l.intersectObjects(f),r=[].concat(f),s=0;s<i.length;s++){var n=i[s].object;!n.hover&&n.onHover&&(n.hover=!0,n.onHover(!0)),r.splice(r.indexOf(n),1)}for(var a=0;a<r.length;a++){var o=r[a];o.hover&&o.onHover&&(o.hover=!1,o.onHover(!1))}}}function N(){if("window"===e.resize)w(window.innerWidth,window.innerHeight);else{var t=p.renderer.domElement.parentNode;w(t.clientWidth,t.clientHeight)}h.forEach((function(e){return e()}))}function w(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 be={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:!1},shadow:Boolean,width:String,height:String},setup:function(){return{three:ye(),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 ve(e,t){t instanceof Object&&Object.entries(t).forEach((function(t){var i=t[0],r=t[1];e[i]=r}))}function Se(e,t){var i={};return Object.entries(e).forEach((function(e){var r=e[0],s=e[1];(!t||t&&!t.includes(r))&&(i[r]=s)})),i}function Ne(e,t,i){return e+(t-e)*(i=(i=i<0?0:i)>1?1:i)}function we(e,t,i){e.x=Ne(e.x,t.x,i),e.y=Ne(e.y,t.y,i)}function xe(e,t,i){e.x=Ne(e.x,t.x,i),e.y=Ne(e.y,t.y,i),e.z=Ne(e.z,t.z,i)}function _e(e,t,i){return e<t?t:e>i?i:e}function Ce(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 Me(e,r,s){if(e[r]){var n=t(e,r);ve(s,n.value),i(n,(function(){ve(s,n.value)}),{deep:!0})}}var Ge={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,s],default:{x:0,y:0,z:0}}},created:function(){var e=this;this.camera=new h(this.left,this.right,this.top,this.bottom,this.near,this.far),Me(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"},Ie={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,s],default:{x:0,y:0,z:0}},lookAt:{type:[Object,s],default:null}},created:function(){var e=this;this.camera=new u(this.fov,this.aspect,this.near,this.far),Me(this,"position",this.camera.position),this.lookAt&&this.camera.lookAt(this.lookAt.x,this.lookAt.y,this.lookAt.z),i((function(){return e.lookAt}),(function(t){e.camera.lookAt(t.x,t.y,t.z)}),{deep:!0}),["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"},ke={inject:{three:"three",scene:"scene",group:{default:null}},props:{position:Object,rotation:Object,scale:Object},provide:function(){return{group:this.group}},created:function(){this.parent=this.group?this.group:this.scene,this.group=new d,Me(this,"position",this.group.position),Me(this,"rotation",this.group.rotation),Me(this,"scale",this.group.scale),this.parent.add(this.group)},unmounted:function(){this.parent.remove(this.group)},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Group"},ze={inject:["three"],props:{id:String,background:[String,Number]},setup:function(e){var t=new m;return e.background&&(t.background=new c(e.background)),i((function(){return e.background}),(function(e){t.background=new c(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():[]}},Pe={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[]}},Re={extends:Pe,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 l(e,t,i,this.widthSegments,this.heightSegments,this.depthSegments)}}},Be={extends:Pe,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 f(this.radius,this.segments,this.thetaStart,this.thetaLength)}}},je={extends:Pe,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 p(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},Ee={extends:Pe,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 g(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},Le={extends:Pe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new y(this.radius,this.detail)}}},Te={extends:Pe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new b(this.radius,this.detail)}}},Oe={extends:Pe,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 v(this.points,this.segments,this.phiStart,this.phiLength)}}},Ae={extends:Pe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new S(this.radius,this.detail)}}},Fe={extends:Pe,props:{vertices:Array,indices:Array,radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new N(this.vertices,this.indices,this.radius,this.detail)}}},Ue={extends:Pe,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 w(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}}},De={extends:Pe,props:{radius:{type:Number,default:1},widthSegments:{type:Number,default:12},heightSegments:{type:Number,default:12}},methods:{createGeometry:function(){this.geometry=new x(this.radius,this.widthSegments,this.heightSegments)}}},$e={extends:Pe,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new _(this.radius,this.detail)}}},He={extends:Pe,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 C(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.arc)}}},We={extends:Pe,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 M(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q)}}},Ve={extends:Pe,props:{path:G,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 I(this.path,this.tubularSegments,this.radius,this.radiusSegments,this.closed)}}},Xe={inject:{scene:"scene",group:{default:null}},props:{color:{type:String,default:"#ffffff"},intensity:{type:Number,default:1},castShadow:{type:Boolean,default:!1},shadowMapSize:Object,position:Object},created:function(){this.parent=this.group?this.group:this.scene},mounted:function(){var e=this;Me(this,"position",this.light.position),this.light.target&&Me(this,"target",this.light.target.position),this.light.shadow&&(this.light.castShadow=this.castShadow,ve(this.light.shadow.mapSize,this.shadowMapSize)),["color","intensity","castShadow"].forEach((function(t){i((function(){return e[t]}),(function(){"color"===t?e.light.color=new c(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"},qe={extends:Xe,created:function(){this.light=new k(this.color,this.intensity)},__hmrId:"AmbientLight"},Ze={extends:Xe,props:{target:Object},created:function(){this.light=new z(this.color,this.intensity)},__hmrId:"DirectionalLight"},Ke={extends:Xe,props:{distance:{type:Number,default:0},decay:{type:Number,default:1}},created:function(){this.light=new P(this.color,this.intensity,this.distance,this.decay)},__hmrId:"PointLight"},Ye={extends:Xe,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 R(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"},Je={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:B},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"},Qe={extends:Je,methods:{createMaterial:function(){this.material=new j(Se(this.$props,["id"]))}},__hmrId:"BasicMaterial"},et={extends:Je,methods:{createMaterial:function(){this.material=new E(Se(this.$props,["id"]))}},__hmrId:"LambertMaterial"},tt={extends:Je,props:{src:String,name:String},methods:{createMaterial:function(){var e=this.name?Ce(this.name):this.src,t=Se(this.$props,["id","src","name"]);t.matcap=(new L).load(e),this.material=new T(t)}},__hmrId:"MatcapMaterial"},it={extends:Je,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 O(Se(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"},rt={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 r(1,1)}},roughness:{type:Number,default:1},refractionRatio:{type:Number,default:.98},wireframe:Boolean},st={extends:Je,props:rt,methods:{createMaterial:function(){this.material=new A(Se(this.$props,["id","normalScale"]))},addWatchers:function(){var e=this;Object.keys(rt).forEach((function(t){"normalScale"!==t&&i((function(){return e[t]}),(function(i){"emissive"===t?e.material[t].set(i):e.material[t]=i}))})),Me(this,"normalScale",this.material.normalScale)}},__hmrId:"StandardMaterial"},nt={extends:st,methods:{createMaterial:function(){this.material=new F(Se(this.$props,["id"]))}},__hmrId:"PhysicalMaterial"};var at,ot,ht,ut=U.meshphong_frag.slice(0,U.meshphong_frag.indexOf("void main() {")),dt=U.meshphong_frag.slice(U.meshphong_frag.indexOf("void main() {")),mt={uniforms:D.merge([$.phong.uniforms,{thicknessColor:{value:new c(6718871)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),vertexShader:"\n #define USE_UV\n "+U.meshphong_vert+"\n ",fragmentShader:"\n #define USE_UV\n #define SUBSURFACE\n\n "+ut+"\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 "+dt.replace("#include <lights_fragment_begin>",(at=U.lights_fragment_begin,ot="RE_Direct( directLight, geometry, material, reflectedLight );",ht="\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 ",at.split(ot).join(ht)))},ct={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:{color:{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=mt,t=D.clone(e.uniforms);Object.entries(this.$props).forEach((function(e){var i=e[0],r=e[1],s=i,n=r;["color","thicknessColor"].includes(i)&&("color"===i&&(s="diffuse"),n=new c(r)),["id","transparent","vertexColors"].includes(i)||(t[s].value=n)})),this.material=new H(Object.assign({},e,{uniforms:t,lights:!0,transparent:this.transparent,vertexColors:this.vertexColors}))}},__hmrId:"SubSurfaceMaterial"},lt={extends:Je,methods:{createMaterial:function(){this.material=new W(Se(this.$props,["id"]))}},__hmrId:"ToonMaterial"},ft={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 L).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[]}},pt={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 V).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=X,this.material.setProp("refractionRatio",this.refractionRatio))},onLoaded:function(){this.onLoad&&this.onLoad(),this.$emit("loaded")}},render:function(){return[]}},gt={inject:{three:"three",scene:"scene",rendererComponent:"rendererComponent",group:{default:null}},emits:["ready"],props:{materialId:String,position:Object,rotation:Object,scale:Object,castShadow:Boolean,receiveShadow:Boolean,onHover:Function,onClick:Function},created:function(){this.parent=this.group?this.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 q(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;Me(this,"position",this.mesh.position),Me(this,"rotation",this.mesh.rotation),Me(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"},yt={extends:gt,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 l(this.size,this.size,this.size):this.geometry=new l(this.width,this.height,this.depth)}},__hmrId:"Box"},bt={extends:gt,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 f(this.radius,this.segments,this.thetaStart,this.thetaLength)}},__hmrId:"Circle"},vt={extends:gt,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 p(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cone"},St={extends:gt,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 g(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cylinder"},Nt={extends:gt,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 y(this.radius,this.detail)}},__hmrId:"Dodecahedron"},wt={extends:gt,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 b(this.radius,this.detail)}},__hmrId:"Icosahedron"},xt={extends:gt,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 v(this.points,this.segments,this.phiStart,this.phiLength)}},__hmrId:"Lathe"},_t={extends:gt,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 S(this.radius,this.detail)}},__hmrId:"Octahedron"},Ct={extends:gt,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 Z(this.width,this.height,this.widthSegments,this.heightSegments)}},__hmrId:"Plane"},Mt={extends:gt,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 N(this.vertices,this.indices,this.radius,this.detail)}},__hmrId:"Polyhedron"},Gt={extends:gt,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 w(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}},__hmrId:"Ring"},It={extends:gt,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 x(this.radius,this.widthSegments,this.heightSegments)}},__hmrId:"Sphere"},kt={extends:gt,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 _(this.radius,this.detail)}},__hmrId:"Tetrahedron"},zt={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}},Pt={extends:gt,props:Object.assign({},zt),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 K).load(this.fontSrc,(function(t){e.font=t,e.createGeometry(),e.initMesh()}))},methods:{createGeometry:function(){this.geometry=new Y(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()}}},Rt={extends:gt,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 C(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.arc)}},__hmrId:"Torus"},Bt={extends:gt,props:{radius:{type:Number,default:.5},tube:{type:Number,default:.4},tubularSegments:{type:Number,default:64},radialSegments:{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 M(this.radius,this.tube,this.tubularSegments,this.radialSegments,this.p,this.q)}},__hmrId:"TorusKnot"},jt={extends:gt,props:{path:G,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 I(this.path,this.tubularSegments,this.radius,this.radialSegments,this.closed)}},__hmrId:"Tube"},Et={extends:gt,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 J(this.cubeRTSize,{format:Q,generateMipmaps:!0,minFilter:ee});this.cubeCamera=new te(this.cubeCameraNear,this.cubeCameraFar,e),Me(this,"position",this.cubeCamera.position),this.parent.add(this.cubeCamera),this.material.side=B,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=ie,this.materialBack.envMapIntensity=5,this.materialBack.metalness=1,this.materialBack.roughness=0,this.materialBack.opacity=.5,this.meshBack=new q(this.geometry,this.materialBack),Me(this,"position",this.meshBack.position),Me(this,"rotation",this.meshBack.rotation),Me(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"},Lt={emits:["loaded"],extends:gt,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 Z(1,1,1,1)},createMaterial:function(){this.material=new j({side:re,map:this.loadTexture()})},loadTexture:function(){return(new L).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"},Tt={inject:{three:"three",scene:"scene",group:{default:null}},props:{materialId:String,count:Number,position:Object,castShadow:Boolean,receiveShadow:Boolean},provide:function(){return{mesh:this}},created:function(){this.parent=this.group?this.group:this.scene},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 se(this.geometry,this.material,this.count),Me(this,"position",this.mesh.position),Me(this,"rotation",this.mesh.rotation),Me(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"},Ot={extends:gt,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 J(this.cubeRTSize,{format:Q,generateMipmaps:!0,minFilter:ee});this.cubeCamera=new te(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"},At={extends:gt,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 J(this.cubeRTSize,{mapping:X,format:Q,generateMipmaps:!0,minFilter:ee});this.cubeCamera=new te(this.cubeCameraNear,this.cubeCameraFar,e),Me(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"},Ft={emits:["ready","loaded"],inject:{three:"three",scene:"scene",group:{default:null}},props:{src:String,position:Object,scale:Object},created:function(){this.parent=this.group?this.group:this.scene},mounted:function(){this.texture=(new L).load(this.src,this.onLoaded),this.material=new ne({map:this.texture}),this.sprite=new ae(this.material),this.geometry=this.sprite.geometry,Me(this,"position",this.sprite.position),Me(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"},Ut={setup:function(){return{passes:[]}},inject:["three"],provide:function(){return{passes:this.passes}},mounted:function(){var e=this;this.three.onAfterInit((function(){e.composer=new he(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"},Dt={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"},$t={extends:Dt,mounted:function(){this.three.scene||console.error("Missing Scene"),this.three.camera||console.error("Missing Camera");var e=new ue(this.three.scene,this.three.camera);this.passes.push(e),this.pass=e},__hmrId:"RenderPass"},Ht={extends:Dt,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 de(this.three.scene,this.three.camera,e);this.passes.push(t),this.pass=t},__hmrId:"BokehPass"},Wt={extends:Dt,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 me(this.noiseIntensity,this.scanlinesIntensity,this.scanlinesCount,this.grayscale);this.passes.push(e),this.pass=e},__hmrId:"FilmPass"},Vt={extends:Dt,mounted:function(){var e=new ce(le);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"},Xt={extends:Dt,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 fe(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"},qt={extends:Dt,mounted:function(){var e=new pe(this.three.size.width,this.three.size.height);this.passes.push(e),this.pass=e},__hmrId:"SMAAPass"},Zt="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",Kt={uniforms:{tDiffuse:{value:null},blurRadius:{value:0},gradientRadius:{value:0},start:{value:new r},end:{value:new r},delta:{value:new r},texSize:{value:new r}},vertexShader:Zt,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 Yt(e,t,r,s){void 0===s&&(s="value"),e[t]&&(r[s]=e[t],i((function(){return e[t]}),(function(e){r[s]=e})))}var Jt={extends:Dt,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 ce(Kt),this.passes.push(this.pass),this.pass1=new ce(Kt),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,Yt(this,"blurRadius",t.blurRadius),Yt(this,"gradientRadius",t.gradientRadius),this.updateFocusLine(),["start","end"].forEach((function(t){i((function(){return e[t]}),e.updateFocusLine,{deep:!0})})),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 r).copy(this.end).sub(this.start).normalize();this.uniforms.delta.value.copy(e),this.uniforms1.delta.value.set(-e.y,e.x)}},__hmrId:"TiltShiftPass"},Qt={extends:Dt,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 r(this.three.size.width,this.three.size.height),t=new ge(e,this.strength,this.radius,this.threshold);this.passes.push(t),this.pass=t},__hmrId:"UnrealBloomPass"},ei={uniforms:{tDiffuse:{value:null},center:{value:new r(.5,.5)},strength:{value:0}},vertexShader:Zt,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 "},ti={extends:Dt,props:{center:{type:Object,default:{x:.5,y:.5}},strength:{type:Number,default:.5}},mounted:function(){this.pass=new ce(ei),this.passes.push(this.pass);var e=this.uniforms=this.pass.uniforms;Me(this,"center",e.center.value),Yt(this,"strength",e.strength)},__hmrId:"ZoomBlurPass"},ii=Object.freeze({__proto__:null,Renderer:be,OrthographicCamera:Ge,PerspectiveCamera:Ie,Camera:Ie,Group:ke,Scene:ze,BoxGeometry:Re,CircleGeometry:Be,ConeGeometry:je,CylinderGeometry:Ee,DodecahedronGeometry:Le,IcosahedronGeometry:Te,LatheGeometry:Oe,OctahedronGeometry:Ae,PolyhedronGeometry:Fe,RingGeometry:Ue,SphereGeometry:De,TetrahedronGeometry:$e,TorusGeometry:He,TorusKnotGeometry:We,TubeGeometry:Ve,AmbientLight:qe,DirectionalLight:Ze,PointLight:Ke,SpotLight:Ye,BasicMaterial:Qe,LambertMaterial:et,MatcapMaterial:tt,PhongMaterial:it,PhysicalMaterial:nt,StandardMaterial:st,SubSurfaceMaterial:ct,ToonMaterial:lt,Texture:ft,CubeTexture:pt,Mesh:gt,Box:yt,Circle:bt,Cone:vt,Cylinder:St,Dodecahedron:Nt,Icosahedron:wt,Lathe:xt,Octahedron:_t,Plane:Ct,Polyhedron:Mt,Ring:Gt,Sphere:It,Tetrahedron:kt,Text:Pt,Torus:Rt,TorusKnot:Bt,Tube:jt,Gem:Et,Image:Lt,InstancedMesh:Tt,MirrorMesh:Ot,RefractionMesh:At,Sprite:Ft,EffectComposer:Ut,RenderPass:$t,BokehPass:Ht,FilmPass:Wt,FXAAPass:Vt,HalftonePass:Xt,SMAAPass:qt,TiltShiftPass:Jt,UnrealBloomPass:Qt,ZoomBlurPass:ti,setFromProp:ve,propsValues:Se,lerp:Ne,lerpv2:we,lerpv3:xe,limit:_e,getMatcapUrl:Ce}),ri={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,ii[t])}))}};export{qe as AmbientLight,Qe as BasicMaterial,Ht as BokehPass,yt as Box,Re as BoxGeometry,Ie as Camera,bt as Circle,Be as CircleGeometry,vt as Cone,je as ConeGeometry,pt as CubeTexture,St as Cylinder,Ee as CylinderGeometry,Ze as DirectionalLight,Nt as Dodecahedron,Le as DodecahedronGeometry,Ut as EffectComposer,Vt as FXAAPass,Wt as FilmPass,Et as Gem,ke as Group,Xt as HalftonePass,wt as Icosahedron,Te as IcosahedronGeometry,Lt as Image,Tt as InstancedMesh,et as LambertMaterial,xt as Lathe,Oe as LatheGeometry,tt as MatcapMaterial,gt as Mesh,Ot as MirrorMesh,_t as Octahedron,Ae as OctahedronGeometry,Ge as OrthographicCamera,Ie as PerspectiveCamera,it as PhongMaterial,nt as PhysicalMaterial,Ct as Plane,Ke as PointLight,Mt as Polyhedron,Fe as PolyhedronGeometry,At as RefractionMesh,$t as RenderPass,be as Renderer,Gt as Ring,Ue as RingGeometry,qt as SMAAPass,ze as Scene,It as Sphere,De as SphereGeometry,Ye as SpotLight,Ft as Sprite,st as StandardMaterial,ct as SubSurfaceMaterial,kt as Tetrahedron,$e as TetrahedronGeometry,Pt as Text,ft as Texture,Jt as TiltShiftPass,lt as ToonMaterial,Rt as Torus,He as TorusGeometry,Bt as TorusKnot,We as TorusKnotGeometry,ri as TroisJSVuePlugin,jt as Tube,Ve as TubeGeometry,Qt as UnrealBloomPass,ti as ZoomBlurPass,Ce as getMatcapUrl,Ne as lerp,we as lerpv2,xe as lerpv3,_e as limit,Se as propsValues,ve as setFromProp};
//# sourceMappingURL=trois.module.cdn.min.js.map