mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
3 lines
59 KiB
JavaScript
3 lines
59 KiB
JavaScript
import{h as e,toRef as t,watch as r,createApp as i}from"https://unpkg.com/vue@3.0.7/dist/vue.esm-browser.prod.js";import{Vector2 as s,Vector3 as n,Plane as a,Raycaster as o,WebGLRenderer as h,OrthographicCamera as u,PerspectiveCamera as d,Group as m,Scene as c,Color as l,BoxGeometry as f,CircleGeometry as p,ConeGeometry as g,CylinderGeometry as y,DodecahedronGeometry as b,IcosahedronGeometry as v,LatheGeometry as S,OctahedronGeometry as x,PolyhedronGeometry as w,RingGeometry as N,SphereGeometry as _,TetrahedronGeometry as M,TorusGeometry as C,TorusKnotGeometry as G,Curve as k,TubeGeometry as z,AmbientLight as L,DirectionalLight as I,HemisphereLight as j,PointLight as P,RectAreaLight as R,SpotLight as B,FrontSide as E,MeshBasicMaterial as T,MeshLambertMaterial as O,TextureLoader as A,MeshMatcapMaterial as F,MeshPhongMaterial as U,MeshStandardMaterial as D,MeshPhysicalMaterial as $,ShaderMaterial as H,ShaderChunk as W,UniformsUtils as X,ShaderLib as V,MeshToonMaterial as q,UVMapping as Z,ClampToEdgeWrapping as K,LinearFilter as Y,LinearMipmapLinearFilter as J,CubeTextureLoader as Q,CubeRefractionMapping as ee,Mesh as te,BoxBufferGeometry as re,CircleBufferGeometry as ie,ConeBufferGeometry as se,CylinderBufferGeometry as ne,DodecahedronBufferGeometry as ae,IcosahedronBufferGeometry as oe,LatheBufferGeometry as he,OctahedronBufferGeometry as ue,PlaneBufferGeometry as de,PolyhedronBufferGeometry as me,RingBufferGeometry as ce,SphereBufferGeometry as le,TetrahedronBufferGeometry as fe,FontLoader as pe,TextBufferGeometry as ge,TorusBufferGeometry as ye,TorusKnotBufferGeometry as be,CatmullRomCurve3 as ve,WebGLCubeRenderTarget as Se,RGBFormat as xe,CubeCamera as we,BackSide as Ne,DoubleSide as _e,InstancedMesh as Me,SpriteMaterial as Ce,Sprite as Ge}from"https://unpkg.com/three@0.125.2/build/three.module.js";import{OrbitControls as ke}from"https://unpkg.com/three@0.125.2/examples/jsm/controls/OrbitControls.js";import{RectAreaLightUniformsLib as ze}from"https://unpkg.com/three@0.125.2/examples/jsm/lights/RectAreaLightUniformsLib.js";import{RectAreaLightHelper as Le}from"https://unpkg.com/three@0.125.2/examples/jsm/helpers/RectAreaLightHelper.js";import{GLTFLoader as Ie}from"https://unpkg.com/three@0.125.2/examples/jsm/loaders/GLTFLoader.js";import{FBXLoader as je}from"https://unpkg.com/three@0.125.2/examples/jsm/loaders/FBXLoader.js";import{EffectComposer as Pe}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/EffectComposer.js";import{RenderPass as Re}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/RenderPass.js";import{BokehPass as Be}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/BokehPass.js";import{FilmPass as Ee}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/FilmPass.js";import{ShaderPass as Te}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/ShaderPass.js";import{FXAAShader as Oe}from"https://unpkg.com/three@0.125.2/examples/jsm/shaders/FXAAShader.js";import{HalftonePass as Ae}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/HalftonePass.js";import{SMAAPass as Fe}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/SMAAPass.js";import{UnrealBloomPass as Ue}from"https://unpkg.com/three@0.125.2/examples/jsm/postprocessing/UnrealBloomPass.js";function De(){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},r=[],i=[],u=[],d=new s,m=new n,c=new a(new n(0,0,1),0),l=new o,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 r=t[0],i=t[1];e[r]=i}));if(!p.scene)return void console.error("Missing Scene");if(!p.camera)return void console.error("Missing Camera");p.renderer=new h({canvas:e.canvas,antialias:e.antialias,alpha:e.alpha}),p.renderer.autoClear=e.autoClear,e.orbit_ctrl&&(p.orbitCtrl=new ke(p.camera,p.renderer.domElement),e.orbit_ctrl instanceof Object&&Object.entries(e.orbit_ctrl).forEach((function(e){var t=e[0],r=e[1];p.orbitCtrl[t]=r})));e.resize?(x(),window.addEventListener("resize",x)):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 r.forEach((function(e){return e()})),!0},dispose:function(){u=[],window.removeEventListener("resize",x),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){r.push(e)},onAfterResize:function(e){i.push(e)},offAfterResize:function(e){i=i.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 r=e.target.getBoundingClientRect();d.x=(e.clientX-r.left)/t.width*2-1,d.y=-(e.clientY-r.top)/t.height*2+1}function y(e){g(e),l.setFromCamera(d,p.camera);for(var t=l.intersectObjects(f),r=0;r<t.length;r++){var i=t[r].object;i.onClick&&i.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 r=l.intersectObjects(f),i=[].concat(f),s=0;s<r.length;s++){var n=r[s].object;!n.hover&&n.onHover&&(n.hover=!0,n.onHover(!0)),i.splice(i.indexOf(n),1)}for(var a=0;a<i.length;a++){var o=i[a];o.hover&&o.onHover&&(o.hover=!1,o.onHover(!1))}}}function x(){if("window"===e.resize)w(window.innerWidth,window.innerHeight);else{var t=p.renderer.domElement.parentNode;w(t.clientWidth,t.clientHeight)}i.forEach((function(e){return e()}))}function w(e,r){if(t.width=e,t.height=r,t.ratio=e/r,p.renderer.setSize(e,r,!1),p.camera.aspect=t.ratio,p.camera.updateProjectionMatrix(),p.composer&&p.composer.setSize(e,r),"OrthographicCamera"===p.camera.type)t.wWidth=p.camera.right-p.camera.left,t.wHeight=p.camera.top-p.camera.bottom;else{var i=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=i[0],t.wHeight=i[1]}}return p}var $e={name:"Renderer",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:De(),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.renderer=this.three.renderer,this.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())},__hmrId:"Renderer"};function He(e,t){t instanceof Object&&Object.entries(t).forEach((function(t){var r=t[0],i=t[1];e[r]=i}))}function We(e,t,r){t.forEach((function(t){Xe(e,t,r)}))}function Xe(e,i,s,n){n||(n=i);var a=t(e,i);a.value instanceof Object?(He(s[n],a.value),r(a,(function(e){He(s[n],e)}),{deep:!0})):(a.value&&(s[n]=e[i]),r(a,(function(e){s[n]=e})))}function Ve(e,t){var r={};return Object.entries(e).forEach((function(e){var i=e[0],s=e[1];(!t||t&&!t.includes(i))&&(r[i]=s)})),r}function qe(e,t,r){return e+(t-e)*(r=(r=r<0?0:r)>1?1:r)}function Ze(e,t,r){e.x=qe(e.x,t.x,r),e.y=qe(e.y,t.y,r)}function Ke(e,t,r){e.x=qe(e.x,t.x,r),e.y=qe(e.y,t.y,r),e.z=qe(e.z,t.z,r)}function Ye(e,t,r){return e<t?t:e>r?r:e}function Je(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")}var Qe="\nvarying vec2 vUv;\nvoid main(){\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n}",et="\nvarying vec2 vUv;\nvoid main() {\n gl_FragColor = vec4(vUv.x, vUv.y, 0., 1.0);\n}",tt={name:"OrthographicCamera",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,default:{x:0,y:0,z:0}}},created:function(){var e=this;this.camera=new u(this.left,this.right,this.top,this.bottom,this.near,this.far),Xe(this,"position",this.camera),["left","right","top","bottom","near","far","zoom"].forEach((function(t){r((function(){return e[t]}),(function(){e.camera[t]=e[t],e.camera.updateProjectionMatrix()}))})),this.three.camera=this.camera},render:function(){return[]},__hmrId:"OrthographicCamera"},rt={name:"PerspectiveCamera",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,default:{x:0,y:0,z:0}},lookAt:{type:Object,default:null}},created:function(){var e=this;this.camera=new d(this.fov,this.aspect,this.near,this.far),Xe(this,"position",this.camera),this.lookAt&&this.camera.lookAt(this.lookAt.x,this.lookAt.y,this.lookAt.z),r((function(){return e.lookAt}),(function(t){e.camera.lookAt(t.x,t.y,t.z)}),{deep:!0}),["aspect","far","fov","near"].forEach((function(t){r((function(){return e[t]}),(function(){e.camera[t]=e[t],e.camera.updateProjectionMatrix()}))})),this.three.camera=this.camera},render:function(){return[]},__hmrId:"PerspectiveCamera"},it={name:"Object3D",inject:["three","scene","rendererComponent"],props:{position:{type:Object,default:{x:0,y:0,z:0}},rotation:{type:Object,default:{x:0,y:0,z:0}},scale:{type:Object,default:{x:1,y:1,z:1}},lookAt:{type:Object,default:null}},unmounted:function(){this._parent&&this._parent.remove(this.o3d)},methods:{initObject3D:function(e){var t=this;this.o3d=e,Xe(this,"position",this.o3d),Xe(this,"rotation",this.o3d),Xe(this,"scale",this.o3d),this.lookAt&&this.o3d.lookAt(this.lookAt.x,this.lookAt.y,this.lookAt.z),r((function(){return t.lookAt}),(function(e){t.o3d.lookAt(e.x,e.y,e.z)}),{deep:!0});for(var i=this.$parent;i;){if(i.add){i.add(this.o3d),this._parent=i;break}i=i.$parent}this._parent||console.error("Missing parent (Scene, Group...)")},add:function(e){this.o3d.add(e)},remove:function(e){this.o3d.remove(e)}},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Object3D"},st={name:"Group",extends:it,created:function(){this.group=new m,this.initObject3D(this.group)},__hmrId:"Group"},nt={name:"Scene",inject:["three"],props:{id:String,background:[String,Number]},setup:function(e){var t=new c;return e.background&&(t.background=new l(e.background)),r((function(){return e.background}),(function(e){t.background.set(e)})),{scene:t}},provide:function(){return{scene:this.scene}},mounted:function(){this.three.scene||(this.three.scene=this.scene)},methods:{add:function(e){this.scene.add(e)},remove:function(e){this.scene.remove(e)}},render:function(){return this.$slots.default?this.$slots.default():[]},__hmrId:"Scene"},at={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])})),this.createGeometry(),this.rotateGeometry(),this.mesh.setGeometry(this.geometry),this.addWatchers()},unmounted:function(){this.geometry.dispose()},methods:{addWatchers:function(){var e=this;this.watchProps.forEach((function(t){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},rotateGeometry:function(){this.rotateX&&this.geometry.rotateX(this.rotateX),this.rotateY&&this.geometry.rotateY(this.rotateY),this.rotateZ&&this.geometry.rotateZ(this.rotateZ)},refreshGeometry:function(){var e=this.geometry;this.createGeometry(),this.rotateGeometry(),this.mesh.setGeometry(this.geometry),e.dispose()}},render:function(){return[]}},ot={extends:at,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,r=this.depth;this.size&&(e=this.size,t=this.size,r=this.size),this.geometry=new f(e,t,r,this.widthSegments,this.heightSegments,this.depthSegments)}}},ht={extends:at,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 p(this.radius,this.segments,this.thetaStart,this.thetaLength)}}},ut={extends:at,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 g(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},dt={extends:at,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 y(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}}},mt={extends:at,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new b(this.radius,this.detail)}}},ct={extends:at,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new v(this.radius,this.detail)}}},lt={extends:at,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 S(this.points,this.segments,this.phiStart,this.phiLength)}}},ft={extends:at,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new x(this.radius,this.detail)}}},pt={extends:at,props:{vertices:Array,indices:Array,radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new w(this.vertices,this.indices,this.radius,this.detail)}}},gt={extends:at,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 N(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}}},yt={extends:at,props:{radius:{type:Number,default:1},widthSegments:{type:Number,default:12},heightSegments:{type:Number,default:12}},methods:{createGeometry:function(){this.geometry=new _(this.radius,this.widthSegments,this.heightSegments)}}},bt={extends:at,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},methods:{createGeometry:function(){this.geometry=new M(this.radius,this.detail)}}},vt={extends:at,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)}}},St={extends:at,props:{radius:{type:Number,default:1},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}},methods:{createGeometry:function(){this.geometry=new G(this.radius,this.tube,this.tubularSegments,this.radialSegments,this.p,this.q)}}},xt={extends:at,props:{path:k,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 z(this.path,this.tubularSegments,this.radius,this.radiusSegments,this.closed)}}},wt={extends:it,name:"Light",props:{color:{type:String,default:"#ffffff"},intensity:{type:Number,default:1},castShadow:{type:Boolean,default:!1},shadowMapSize:{type:Object,default:{x:512,y:512}},shadowCamera:{type:Object,default:{}}},unmounted:function(){this.light.target&&this.$parent.remove(this.light.target)},methods:{initLight:function(){var e=this;this.light.target&&Xe(this,"target",this.light.target,"position"),this.light.shadow&&(this.light.castShadow=this.castShadow,He(this.light.shadow.mapSize,this.shadowMapSize),He(this.light.shadow.camera,this.shadowCamera)),["color","intensity","castShadow"].forEach((function(t){r((function(){return e[t]}),(function(){"color"===t?e.light.color.set(e.color):e.light[t]=e[t]}))})),this.initObject3D(this.light),this.light.target&&this.$parent.add(this.light.target)}},__hmrId:"Light"},Nt={extends:wt,created:function(){this.light=new L(this.color,this.intensity),this.initLight()},__hmrId:"AmbientLight"},_t={extends:wt,props:{target:Object},created:function(){this.light=new I(this.color,this.intensity),this.initLight()},__hmrId:"DirectionalLight"},Mt={extends:wt,props:{groundColor:{type:String,default:"#444444"}},created:function(){var e=this;this.light=new j(this.color,this.groundColor,this.intensity),r((function(){return e.groundColor}),(function(t){e.light.groundColor.set(t)})),this.initLight()},__hmrId:"HemisphereLight"},Ct={extends:wt,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),this.initLight()},__hmrId:"PointLight"},Gt={extends:wt,props:{width:{type:Number,default:10},height:{type:Number,default:10},helper:Boolean},created:function(){var e=this;ze.init(),this.light=new R(this.color,this.intensity,this.width,this.height),["width","height"].forEach((function(t){r((function(){return e[t]}),(function(){e.light[t]=e[t]}))})),this.helper&&(this.lightHelper=new Le(this.light),this.$parent.add(this.lightHelper)),this.initLight()},unmounted:function(){this.lightHelper&&this.$parent.remove(this.lightHelper)},__hmrId:"RectAreaLight"},kt={extends:wt,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 B(this.color,this.intensity,this.distance,this.angle,this.penumbra,this.decay),["angle","decay","distance","penumbra"].forEach((function(t){r((function(){return e[t]}),(function(){e.light[t]=e[t]}))})),this.initLight()},__hmrId:"SpotLight"},zt={inject:["three","mesh"],props:{color:{type:[String,Number],default:"#ffffff"},depthTest:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!0},fog:{type:Boolean,default:!0},opacity:{type:Number,default:1},side:{type:Number,default:E},transparent:Boolean,vertexColors:Boolean},provide:function(){return{material:this}},created:function(){this.createMaterial(),this.mesh.setMaterial(this.material),this._addWatchers(),this.addWatchers&&this.addWatchers()},unmounted:function(){this.material.dispose()},methods:{setProp:function(e,t,r){void 0===r&&(r=!1),this.material[e]=t,this.material.needsUpdate=r},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){r((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"},Lt={wireframe:{type:Boolean,default:!1},wireframeLinewidth:{type:Number,default:1}},It={extends:zt,props:Object.assign({},Lt),methods:{createMaterial:function(){this.material=new T(Ve(this.$props))},addWatchers:function(){We(this,Object.keys(Lt),this.material)}},__hmrId:"BasicMaterial"},jt={extends:zt,props:Object.assign({},Lt),methods:{createMaterial:function(){this.material=new O(Ve(this.$props))},addWatchers:function(){We(this,Object.keys(Lt),this.material)}},__hmrId:"LambertMaterial"},Pt={extends:zt,props:{src:String,name:String,flatShading:Boolean},methods:{createMaterial:function(){var e=this.name?Je(this.name):this.src,t=Ve(this.$props,["src","name"]);t.matcap=(new A).load(e),this.material=new F(t)},addWatchers:function(){}},__hmrId:"MatcapMaterial"},Rt={extends:zt,props:Object.assign({},{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},flatShading:Boolean},Lt),methods:{createMaterial:function(){this.material=new U(Ve(this.$props))},addWatchers:function(){var e=this;["emissive","emissiveIntensity","reflectivity","shininess","specular"].forEach((function(t){r((function(){return e[t]}),(function(r){"emissive"===t||"specular"===t?e.material[t].set(r):e.material[t]=r}))})),We(this,Object.keys(Lt),this.material)}},__hmrId:"PhongMaterial"},Bt={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:{x:1,y:1}},roughness:{type:Number,default:1},refractionRatio:{type:Number,default:.98},flatShading:Boolean},Et={extends:zt,props:Object.assign({},Bt,Lt),methods:{createMaterial:function(){this.material=new D(Ve(this.$props,["normalScale"]))},addWatchers:function(){var e=this;Object.keys(Bt).forEach((function(t){"normalScale"!==t&&r((function(){return e[t]}),(function(r){"emissive"===t?e.material[t].set(r):e.material[t]=r}))})),Xe(this,"normalScale",this.material),We(this,Object.keys(Lt),this.material)}},__hmrId:"StandardMaterial"},Tt={extends:Et,props:{flatShading:Boolean},methods:{createMaterial:function(){this.material=new $(Ve(this.$props))},addWatchers:function(){}},__hmrId:"PhysicalMaterial"},Ot={inject:["three","mesh"],props:{uniforms:{type:Object,default:function(){return{}}},vertexShader:{type:String,default:Qe},fragmentShader:{type:String,default:et}},created:function(){var e=this;this.createMaterial(),["vertexShader","fragmentShader"].forEach((function(t){r((function(){return e[t]}),(function(){e.material.dispose(),e.createMaterial()}))}))},unmounted:function(){this.material.dispose()},methods:{createMaterial:function(){this.material=new H(Ve(this.$props)),this.mesh.setMaterial(this.material)}},render:function(){return[]},__hmrId:"ShaderMaterial"};var At,Ft,Ut,Dt=W.meshphong_frag.slice(0,W.meshphong_frag.indexOf("void main() {")),$t=W.meshphong_frag.slice(W.meshphong_frag.indexOf("void main() {")),Ht={uniforms:X.merge([V.phong.uniforms,{thicknessColor:{value:new l(16777215)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),vertexShader:"\n #define USE_UV\n "+W.meshphong_vert+"\n ",fragmentShader:"\n #define USE_UV\n #define SUBSURFACE\n\n "+Dt+"\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 "+$t.replace("#include <lights_fragment_begin>",(At=W.lights_fragment_begin,Ft="RE_Direct( directLight, geometry, material, reflectedLight );",Ut="\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(Ft).join(Ut)))},Wt={inject:["three","mesh"],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}},created:function(){this.createMaterial(),this.mesh.setMaterial(this.material)},unmounted:function(){this.material.dispose()},methods:{createMaterial:function(){var e=Ht,t=X.clone(e.uniforms);Object.entries(this.$props).forEach((function(e){var r=e[0],i=e[1],s=r,n=i;["color","thicknessColor"].includes(r)&&("color"===r&&(s="diffuse"),n=new l(i)),["transparent","vertexColors"].includes(r)||(t[s].value=n)})),this.material=new H(Object.assign({},e,{uniforms:t,lights:!0,transparent:this.transparent,vertexColors:this.vertexColors}))}},render:function(){return[]},__hmrId:"SubSurfaceMaterial"},Xt={extends:zt,props:Object.assign({},Lt),methods:{createMaterial:function(){this.material=new q(Ve(this.$props))},addWatchers:function(){We(this,Object.keys(Lt),this.material)}},__hmrId:"ToonMaterial"},Vt={inject:["material"],emits:["loaded"],props:{id:{type:String,default:"map"},src:String,onLoad:Function,onProgress:Function,onError:Function,mapping:{type:Number,default:Z},wrapS:{type:Number,default:K},wrapT:{type:Number,default:K},magFilter:{type:Number,default:Y},minFilter:{type:Number,default:J},repeat:{type:Object,default:{x:1,y:1}},rotation:{type:Number,default:0},center:{type:Object,default:{x:0,y:0}}},created:function(){var e=this;this.refreshTexture(),r((function(){return e.src}),this.refreshTexture)},unmounted:function(){this.material.setTexture(null,this.id),this.texture.dispose()},methods:{createTexture:function(){var e=this;this.texture=(new A).load(this.src,this.onLoaded,this.onProgress,this.onError);["mapping","wrapS","wrapT","magFilter","minFilter","repeat","rotation","rotation","center"].forEach((function(t){Xe(e,t,e.texture)}))},refreshTexture:function(){this.createTexture(),this.material.setTexture(this.texture,this.id)},onLoaded:function(){this.onLoad&&this.onLoad(),this.$emit("loaded")}},render:function(){return[]}},qt={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(),r((function(){return e.path}),this.refreshTexture),r((function(){return e.urls}),this.refreshTexture)},unmounted:function(){this.material.setTexture(null,this.id),this.texture.dispose()},methods:{createTexture:function(){this.texture=(new Q).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[]}},Zt={extends:it,name:"Mesh",props:{castShadow:Boolean,receiveShadow:Boolean,onHover:Function,onClick:Function},provide:function(){return{mesh:this}},mounted:function(){this.mesh||this.loading||this.initMesh()},methods:{initMesh:function(){var e=this;this.mesh=new te(this.geometry,this.material),["castShadow","receiveShadow"].forEach((function(t){e.mesh[t]=e[t],r((function(){return e[t]}),(function(){e.mesh[t]=e[t]}))})),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.initObject3D(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)},refreshGeometry:function(){var e=this.geometry;this.createGeometry(),this.mesh.geometry=this.geometry,e.dispose()}},unmounted:function(){this.mesh&&this.three.removeIntersectObject(this.mesh),this.geometry&&this.geometry.dispose(),this.material&&this.material.dispose()},__hmrId:"Mesh"},Kt={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.size?this.geometry=new re(this.size,this.size,this.size):this.geometry=new re(this.width,this.height,this.depth)}},__hmrId:"Box"},Yt={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ie(this.radius,this.segments,this.thetaStart,this.thetaLength)}},__hmrId:"Circle"},Jt={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new se(this.radius,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cone"},Qt={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ne(this.radiusTop,this.radiusBottom,this.height,this.radialSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength)}},__hmrId:"Cylinder"},er={extends:Zt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ae(this.radius,this.detail)}},__hmrId:"Dodecahedron"},tr={extends:Zt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new oe(this.radius,this.detail)}},__hmrId:"Icosahedron"},rr={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new he(this.points,this.segments,this.phiStart,this.phiLength)}},__hmrId:"Lathe"},ir={extends:Zt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ue(this.radius,this.detail)}},__hmrId:"Octahedron"},sr={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new de(this.width,this.height,this.widthSegments,this.heightSegments)}},__hmrId:"Plane"},nr={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new me(this.vertices,this.indices,this.radius,this.detail)}},__hmrId:"Polyhedron"},ar={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ce(this.innerRadius,this.outerRadius,this.thetaSegments,this.phiSegments,this.thetaStart,this.thetaLength)}},__hmrId:"Ring"},or={extends:Zt,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 le(this.radius,this.widthSegments,this.heightSegments)}},__hmrId:"Sphere"},hr={extends:Zt,props:{radius:{type:Number,default:1},detail:{type:Number,default:0}},created:function(){var e=this;this.createGeometry();["radius","detail"].forEach((function(t){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new fe(this.radius,this.detail)}},__hmrId:"Tetrahedron"},ur={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}},dr={extends:Zt,props:Object.assign({},ur),data:function(){return{loading:!0}},created:function(){var e=this;["text","size","height","curveSegments","bevelEnabled","bevelThickness","bevelSize","bevelOffset","bevelSegments","align"].forEach((function(t){r((function(){return e[t]}),(function(){e.font&&e.refreshGeometry()}))})),(new pe).load(this.fontSrc,(function(t){e.loading=!1,e.font=t,e.createGeometry(),e.initMesh()}))},methods:{createGeometry:function(){this.geometry=new ge(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()}}},mr={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new ye(this.radius,this.tube,this.radialSegments,this.tubularSegments,this.arc)}},__hmrId:"Torus"},cr={extends:Zt,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){r((function(){return e[t]}),(function(){e.refreshGeometry()}))}))},methods:{createGeometry:function(){this.geometry=new be(this.radius,this.tube,this.tubularSegments,this.radialSegments,this.p,this.q)}},__hmrId:"TorusKnot"},lr={extends:Zt,props:{path:k,points:Array,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();["tubularSegments","radius","radialSegments","closed"].forEach((function(t){r((function(){return e[t]}),(function(t){e.refreshGeometry()}))})),r((function(){return e.points}),(function(){fr(e.geometry,e.points)}))},methods:{createGeometry:function(){var e;this.points?e=new ve(this.points):this.path?e=this.path:console.error("Missing path curve or points."),this.geometry=new z(e,this.tubularSegments,this.radius,this.radialSegments,this.closed)},updateCurve:function(e){fr(this.geometry,e)}},__hmrId:"Tube"};function fr(e,t){var r=new ve(t),i=e.parameters,s=i.radialSegments,a=i.radius,o=i.tubularSegments,h=i.closed,u=r.computeFrenetFrames(o,h);e.tangents=u.tangents,e.normals=u.normals,e.binormals=u.binormals,e.parameters.path=r;for(var d,m=e.attributes.position.array,c=e.attributes.normal.array,l=new n,f=0;f<o;f++)p(f);function p(e){d=r.getPointAt(e/o,d);for(var t=u.normals[e],i=u.binormals[e],n=0;n<=s;n++){var h=n/s*Math.PI*2,f=Math.sin(h),p=-Math.cos(h);l.x=p*t.x+f*i.x,l.y=p*t.y+f*i.y,l.z=p*t.z+f*i.z,l.normalize();var g=3*(e*(s+1)+n);c[g]=l.x,c[g+1]=l.y,c[g+2]=l.z,m[g]=d.x+a*l.x,m[g+1]=d.y+a*l.y,m[g+2]=d.z+a*l.z}}p(o),e.attributes.position.needsUpdate=!0,e.attributes.normal.needsUpdate=!0}var pr={extends:Zt,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:xe,generateMipmaps:!0,minFilter:J});this.cubeCamera=new we(this.cubeCameraNear,this.cubeCameraFar,e),Xe(this,"position",this.cubeCamera),this.$parent.add(this.cubeCamera),this.material.side=E,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=Ne,this.materialBack.envMapIntensity=5,this.materialBack.metalness=1,this.materialBack.roughness=0,this.materialBack.opacity=.5,this.meshBack=new te(this.geometry,this.materialBack),Xe(this,"position",this.meshBack),Xe(this,"rotation",this.meshBack),Xe(this,"scale",this.meshBack),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"},gr={emits:["loaded"],extends:Zt,props:{src:String,width:Number,height:Number,keepSize:Boolean},created:function(){var e=this;this.createGeometry(),this.createMaterial(),this.initMesh(),r((function(){return e.src}),this.refreshTexture),["width","height"].forEach((function(t){r((function(){return e[t]}),e.resize)})),this.keepSize&&this.three.onAfterResize(this.resize)},methods:{createGeometry:function(){this.geometry=new de(1,1,1,1)},createMaterial:function(){this.material=new T({side:_e,map:this.loadTexture()})},loadTexture:function(){return(new A).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,r=this.three.size,i=this.texture.image.width/this.texture.image.height;this.width&&this.height?(e=this.width*r.wWidth/r.width,t=this.height*r.wHeight/r.height):this.width?t=(e=this.width*r.wWidth/r.width)/i:this.height&&(e=(t=this.height*r.wHeight/r.height)*i),this.mesh.scale.x=e,this.mesh.scale.y=t}}},__hmrId:"Image"},yr={extends:it,props:{castShadow:Boolean,receiveShadow:Boolean,count:Number},provide:function(){return{mesh:this}},beforeMount:function(){this.$slots.default||console.error("Missing Geometry")},created:function(){this.initMesh()},methods:{initMesh:function(){var e=this;this.mesh=new Me(this.geometry,this.material,this.count),["castShadow","receiveShadow"].forEach((function(t){e.mesh[t]=e[t],r((function(){return e[t]}),(function(){e.mesh[t]=e[t]}))})),this.initObject3D(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)}},__hmrId:"InstancedMesh"},br={extends:Zt,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:xe,generateMipmaps:!0,minFilter:J});this.cubeCamera=new we(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"},vr={extends:Zt,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:xe,generateMipmaps:!0,minFilter:J});this.cubeCamera=new we(this.cubeCameraNear,this.cubeCameraFar,e),Xe(this,"position",this.cubeCamera),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"},Sr={extends:it,emits:["loaded"],props:{src:String},data:function(){return{loading:!0}},created:function(){this.texture=(new A).load(this.src,this.onLoaded),this.material=new Ce({map:this.texture}),this.sprite=new Ge(this.material),this.geometry=this.sprite.geometry,this.initObject3D(this.sprite)},unmounted:function(){this.texture.dispose(),this.material.dispose()},methods:{onLoaded:function(){this.loading=!1,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 r=this.geometry.attributes.position.array;r[0]=-e,r[1]=-t,r[5]=e,r[6]=-t,r[10]=e,r[11]=t,r[15]=-e,r[16]=t,this.geometry.attributes.position.needsUpdate=!0}},__hmrId:"Sprite"},xr={extends:it,emits:["loaded"],props:{src:String},created:function(){var e=this;(new Ie).load(this.src,(function(t){e.$emit("loaded",t),e.initObject3D(t.scene)}))}},wr={extends:it,emits:["loaded"],props:{src:String},created:function(){var e=this;(new je).load(this.src,(function(t){e.$emit("loaded",t),e.initObject3D(t)}))}},Nr={setup:function(){return{passes:[]}},inject:["three"],provide:function(){return{passes:this.passes}},mounted:function(){var e=this;this.three.onAfterInit((function(){e.composer=new Pe(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"},_r={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"},Mr={extends:_r,mounted:function(){this.three.scene||console.error("Missing Scene"),this.three.camera||console.error("Missing Camera");var e=new Re(this.three.scene,this.three.camera);this.passes.push(e),this.pass=e},__hmrId:"RenderPass"},Cr={extends:_r,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 Be(this.three.scene,this.three.camera,e);this.passes.push(t),this.pass=t},__hmrId:"BokehPass"},Gr={extends:_r,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 Ee(this.noiseIntensity,this.scanlinesIntensity,this.scanlinesCount,this.grayscale);this.passes.push(e),this.pass=e},__hmrId:"FilmPass"},kr={extends:_r,mounted:function(){var e=new Te(Oe);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"},zr={extends:_r,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 Ae(this.three.size.width,this.three.size.height,{});["shape","radius","rotateR","rotateG","rotateB","scatter"].forEach((function(i){t.uniforms[i].value=e[i],r((function(){return e[i]}),(function(){t.uniforms[i].value=e[i]}))})),this.passes.push(t),this.pass=t},__hmrId:"HalftonePass"},Lr={extends:_r,mounted:function(){var e=new Fe(this.three.size.width,this.three.size.height);this.passes.push(e),this.pass=e},__hmrId:"SMAAPass"},Ir="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",jr={uniforms:{tDiffuse:{value:null},blurRadius:{value:0},gradientRadius:{value:0},start:{value:new s},end:{value:new s},delta:{value:new s},texSize:{value:new s}},vertexShader:Ir,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 "},Pr={extends:_r,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 Te(jr),this.passes.push(this.pass),this.pass1=new Te(jr),this.passes.push(this.pass1);var t=this.uniforms=this.pass.uniforms,i=this.uniforms1=this.pass1.uniforms;i.blurRadius=t.blurRadius,i.gradientRadius=t.gradientRadius,i.start=t.start,i.end=t.end,i.texSize=t.texSize,Xe(this,"blurRadius",t.blurRadius,"value"),Xe(this,"gradientRadius",t.gradientRadius,"value"),this.updateFocusLine(),["start","end"].forEach((function(t){r((function(){return e[t]}),e.updateFocusLine,{deep:!0})})),this.pass.setSize=function(e,r){t.texSize.value.set(e,r)}},methods:{updateFocusLine:function(){this.uniforms.start.value.copy(this.start),this.uniforms.end.value.copy(this.end);var e=(new s).copy(this.end).sub(this.start).normalize();this.uniforms.delta.value.copy(e),this.uniforms1.delta.value.set(-e.y,e.x)}},__hmrId:"TiltShiftPass"},Rr={extends:_r,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 s(this.three.size.width,this.three.size.height),t=new Ue(e,this.strength,this.radius,this.threshold);this.passes.push(t),this.pass=t},__hmrId:"UnrealBloomPass"},Br={uniforms:{tDiffuse:{value:null},center:{value:new s(.5,.5)},strength:{value:0}},vertexShader:Ir,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 "},Er={extends:_r,props:{center:{type:Object,default:{x:.5,y:.5}},strength:{type:Number,default:.5}},mounted:function(){this.pass=new Te(Br),this.passes.push(this.pass);var e=this.uniforms=this.pass.uniforms;Xe(this,"center",e.center,"value"),Xe(this,"strength",e.strength,"value")},__hmrId:"ZoomBlurPass"},Tr=Object.freeze({__proto__:null,Renderer:$e,OrthographicCamera:tt,PerspectiveCamera:rt,Camera:rt,Group:st,Scene:nt,BoxGeometry:ot,CircleGeometry:ht,ConeGeometry:ut,CylinderGeometry:dt,DodecahedronGeometry:mt,IcosahedronGeometry:ct,LatheGeometry:lt,OctahedronGeometry:ft,PolyhedronGeometry:pt,RingGeometry:gt,SphereGeometry:yt,TetrahedronGeometry:bt,TorusGeometry:vt,TorusKnotGeometry:St,TubeGeometry:xt,AmbientLight:Nt,DirectionalLight:_t,HemisphereLight:Mt,PointLight:Ct,RectAreaLight:Gt,SpotLight:kt,BasicMaterial:It,LambertMaterial:jt,MatcapMaterial:Pt,PhongMaterial:Rt,PhysicalMaterial:Tt,ShaderMaterial:Ot,StandardMaterial:Et,SubSurfaceMaterial:Wt,ToonMaterial:Xt,Texture:Vt,CubeTexture:qt,Mesh:Zt,Box:Kt,Circle:Yt,Cone:Jt,Cylinder:Qt,Dodecahedron:er,Icosahedron:tr,Lathe:rr,Octahedron:ir,Plane:sr,Polyhedron:nr,Ring:ar,Sphere:or,Tetrahedron:hr,Text:dr,Torus:mr,TorusKnot:cr,Tube:lr,Gem:pr,Image:gr,InstancedMesh:yr,MirrorMesh:br,RefractionMesh:vr,Sprite:Sr,GLTFModel:xr,FBXModel:wr,EffectComposer:Nr,RenderPass:Mr,BokehPass:Cr,FilmPass:Gr,FXAAPass:kr,HalftonePass:zr,SMAAPass:Lr,TiltShiftPass:Pr,UnrealBloomPass:Rr,ZoomBlurPass:Er,setFromProp:He,bindProps:We,bindProp:Xe,propsValues:Ve,lerp:qe,lerpv2:Ze,lerpv3:Ke,limit:Ye,getMatcapUrl:Je,defaultVertexShader:Qe,defaultFragmentShader:et}),Or={install:function(e){["Camera","OrthographicCamera","PerspectiveCamera","Renderer","Scene","Group","AmbientLight","DirectionalLight","HemisphereLight","PointLight","RectAreaLight","SpotLight","BasicMaterial","LambertMaterial","MatcapMaterial","PhongMaterial","PhysicalMaterial","ShaderMaterial","StandardMaterial","SubSurfaceMaterial","ToonMaterial","Texture","CubeTexture","Mesh","Box","BoxGeometry","Circle","CircleGeometry","Cone","ConeGeometry","Cylinder","CylinderGeometry","Dodecahedron","DodecahedronGeometry","Icosahedron","IcosahedronGeometry","Lathe","LatheGeometry","Octahedron","OctahedronGeometry","Plane","Polyhedron","PolyhedronGeometry","Ring","RingGeometry","Sphere","SphereGeometry","Tetrahedron","TetrahedronGeometry","Text","Torus","TorusGeometry","TorusKnot","TorusKnotGeometry","Tube","TubeGeometry","Gem","Image","InstancedMesh","MirrorMesh","RefractionMesh","Sprite","FBXModel","GLTFModel","BokehPass","EffectComposer","FilmPass","FXAAPass","HalftonePass","RenderPass","SAOPass","SMAAPass","TiltShiftPass","UnrealBloomPass","ZoomBlurPass","GLTFViewer"].forEach((function(t){e.component(t,Tr[t])}))}};function Ar(e){return i(e).use(Or)}export{Nt as AmbientLight,It as BasicMaterial,Cr as BokehPass,Kt as Box,ot as BoxGeometry,rt as Camera,Yt as Circle,ht as CircleGeometry,Jt as Cone,ut as ConeGeometry,qt as CubeTexture,Qt as Cylinder,dt as CylinderGeometry,_t as DirectionalLight,er as Dodecahedron,mt as DodecahedronGeometry,Nr as EffectComposer,wr as FBXModel,kr as FXAAPass,Gr as FilmPass,xr as GLTFModel,pr as Gem,st as Group,zr as HalftonePass,Mt as HemisphereLight,tr as Icosahedron,ct as IcosahedronGeometry,gr as Image,yr as InstancedMesh,jt as LambertMaterial,rr as Lathe,lt as LatheGeometry,Pt as MatcapMaterial,Zt as Mesh,br as MirrorMesh,ir as Octahedron,ft as OctahedronGeometry,tt as OrthographicCamera,rt as PerspectiveCamera,Rt as PhongMaterial,Tt as PhysicalMaterial,sr as Plane,Ct as PointLight,nr as Polyhedron,pt as PolyhedronGeometry,Gt as RectAreaLight,vr as RefractionMesh,Mr as RenderPass,$e as Renderer,ar as Ring,gt as RingGeometry,Lr as SMAAPass,nt as Scene,Ot as ShaderMaterial,or as Sphere,yt as SphereGeometry,kt as SpotLight,Sr as Sprite,Et as StandardMaterial,Wt as SubSurfaceMaterial,hr as Tetrahedron,bt as TetrahedronGeometry,dr as Text,Vt as Texture,Pr as TiltShiftPass,Xt as ToonMaterial,mr as Torus,vt as TorusGeometry,cr as TorusKnot,St as TorusKnotGeometry,Or as TroisJSVuePlugin,lr as Tube,xt as TubeGeometry,Rr as UnrealBloomPass,Er as ZoomBlurPass,Xe as bindProp,We as bindProps,Ar as createApp,et as defaultFragmentShader,Qe as defaultVertexShader,Je as getMatcapUrl,qe as lerp,Ze as lerpv2,Ke as lerpv3,Ye as limit,Ve as propsValues,He as setFromProp};
|
|
//# sourceMappingURL=trois.module.cdn.min.js.map
|