代码拉取完成,页面将自动刷新
"use strict";(self.webpackChunkintroduce=self.webpackChunkintroduce||[]).push([[838],{6838:(qt,R,m)=>{m.r(R),m.d(R,{DevModule:()=>Nt});var A=m(6895),D=m(9541),s=m(6682),C=m(2549),p=m(7152),P=m(3025),x=m(9011),v=m(6497);class z extends s.x12{constructor(a,t){const e=new s.u9r;e.setAttribute("position",new s.a$l([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),e.computeBoundingSphere(),super(e,new s.nls({fog:!1})),this.light=a,this.color=t,this.type="RectAreaLightHelper";const c=new s.u9r;c.setAttribute("position",new s.a$l([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),c.computeBoundingSphere(),this.add(new s.Kj0(c,new s.vBJ({side:s._Li,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const a=this.material.color,t=Math.max(a.r,a.g,a.b);t>1&&a.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}var o=m(8256);const O=["container"];let j=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.radius=0,this.params={render:{toneMapping:0,toneMappingExposure:1},lights:{directional:{intensity:3,color:16777215,helper:!0,bias:-.002594,position:{x:-1.1,y:2.4,z:3.6}},ambient:{intensity:1,color:16777215},hemisphereLight:{top:16777215,bottom:3159317,intensity:0,helper:!0,height:1}}},this.fillLights={},this.animate=()=>{this.controls&&this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.initScene(),this.addLight(),this.loadModel(),this.initGUI()}initScene(){const t=this.width=this.container.nativeElement.offsetWidth,i=this.height=this.container.nativeElement.offsetHeight,e=this.scene=new s.xsS,n=this.camera=new s.cPb(50,t/i,.1,100);n.position.set(-15,5,15);const r=this.renderer=new s.CP7({antialias:!0,alpha:!0});r.setSize(t,i),r.setPixelRatio(Math.min(devicePixelRatio,2)),r.outputColorSpace=s.KI_,r.shadowMap.enabled=!0,r.shadowMap.type=s.ntZ,r.toneMapping=this.params.render.toneMapping,r.toneMappingExposure=this.params.render.toneMappingExposure,this.renderer2.appendChild(this.container.nativeElement,this.renderer.domElement),this.controls=new p.z(n,r.domElement),e.add(new s.VLJ(10,10)),e.add(new s.y8_(5)),r.setAnimationLoop(this.animate)}addEnvironmentLight(){(new P.x).load("assets/texture/cannon_1k.hdr",t=>{const i=new s.anP(this.renderer);i.compileEquirectangularShader(),this.scene.environment=i.fromEquirectangular(t).texture,t.dispose(),i.dispose()})}addLight(){{const t=this.directionalLight=new s.Ox3(this.params.lights.directional.color,this.params.lights.directional.intensity);t.castShadow=!0,t.position.set(this.params.lights.directional.position.x,this.params.lights.directional.position.y,this.params.lights.directional.position.z),t.shadow.bias=this.params.lights.directional.bias,t.shadow.mapSize.width=2048,t.shadow.mapSize.height=2048,this.scene.add(t);const i=this.directionalLightHelper=new s.Rki(t.shadow.camera);i.visible=this.params.lights.directional.helper,this.scene.add(i)}{const t=this.ambientLight=new s.Mig(this.params.lights.ambient.color,this.params.lights.ambient.intensity);this.scene.add(t)}{const t=this.hemisphereLight=new s.vmT(this.params.lights.hemisphereLight.top,this.params.lights.hemisphereLight.bottom,this.params.lights.hemisphereLight.intensity);t.position.y=this.params.lights.hemisphereLight.height,this.scene.add(t);const i=this.hemisphereLightHelper=new s.Qpg(t,1,15658734);i.visible=this.params.lights.hemisphereLight.helper,this.scene.add(i)}}reConfigLight(){this.directionalLight.shadow.camera.near=1,this.directionalLight.shadow.camera.far=3*this.radius,this.directionalLight.shadow.camera.left=-this.radius/2,this.directionalLight.shadow.camera.right=this.radius/2,this.directionalLight.shadow.camera.top=this.radius/2,this.directionalLight.shadow.camera.bottom=-this.radius/2,this.directionalLight.shadow.camera.updateProjectionMatrix(),this.directionalLightHelper.update(),(t=>{{const i=new s.T_f(16777215,0,this.radius,this.radius);i.position.x=-this.radius/2,i.rotation.y=-Math.PI/2,this.scene.add(i);const e=new z(i,16711935);this.scene.add(e),this.fillLights.left={light:i,helper:e}}{const i=new s.T_f(16777215,0,this.radius,this.radius);i.position.y=this.radius/2,i.rotation.x=-Math.PI/2,this.scene.add(i);const e=new z(i,65535);this.scene.add(e),this.fillLights.top={light:i,helper:e}}{const i=new s.T_f(16777215,0,this.radius,this.radius);i.position.z=this.radius/2,this.scene.add(i);const e=new z(i,16776960);this.scene.add(e),this.fillLights.front={light:i,helper:e}}})()}loadModel(){const t=new x._;t.setDecoderPath("assets/lib/draco/"),(new v.E).setDRACOLoader(t).load("assets/model/Hall.glb",i=>{let e=i.scene.getObjectByName("Cover");e&&(e.visible=!1),i.scene.rotation.y=Math.PI/4,i.scene.traverse(c=>{c.isMesh&&(c.receiveShadow=c.castShadow=!0)});let n=(new s.ZzF).setFromObject(i.scene);this.radius=n.getSize(new s.Pa4).length();const r=n.getCenter(new s.Pa4);this.camera.position.copy(r),this.controls.target=r.clone(),this.camera.position.y+=this.radius/2,this.camera.position.z+=this.radius,this.scene.add(i.scene),this.reConfigLight()})}initGUI(){const t=this.gui=new C.XS;(i=>{i.open(),i.add(this.params.render,"toneMapping",{NoToneMapping:s.uL9,LinearToneMapping:s.EoG,ReinhardToneMapping:s.CdI,CineonToneMapping:s.YGz,ACESFilmicToneMapping:s.LY2,CustomToneMapping:s.dZ3}).onChange(e=>this.renderer.toneMapping=Number.parseInt(e)),i.add(this.params.render,"toneMappingExposure",0,10).step(.001).onChange(e=>this.renderer.toneMappingExposure=e)})(t.addFolder("ToneMappings")),(i=>{i.open(),(e=>{e.open(),e.addColor(this.params.lights.directional,"color").onChange(n=>this.directionalLight.color.set(n)),e.add(this.params.lights.directional,"intensity",0,10).step(.01).onChange(n=>this.directionalLight.intensity=n),e.add(this.directionalLight.shadow.camera,"near",0,100).onChange(n=>{this.directionalLight.shadow.camera.near=n,this.directionalLight.shadow.camera.updateProjectionMatrix(),this.directionalLightHelper.update()}),e.add(this.directionalLight.shadow.camera,"far",0,100).onChange(n=>{this.directionalLight.shadow.camera.far=n,this.directionalLight.shadow.camera.updateProjectionMatrix(),this.directionalLightHelper.update()}),e.add(this.directionalLight.shadow,"bias",-.01,0).name("bias").step(1e-6).onChange(n=>{this.directionalLight.shadow.bias=n,this.directionalLight.shadow.camera.updateProjectionMatrix()}),e.add(this.params.lights.directional,"helper",!0,!1).onChange(n=>this.directionalLightHelper.visible=n),["x","y","z"].forEach(n=>{e.add(this.params.lights.directional.position,n,-10,10).step(.1).onChange(r=>{this.directionalLight.position[n]=r,this.directionalLightHelper.update()})})})(i.addFolder("Directional")),(e=>{e.open(),e.addColor(this.params.lights.ambient,"color").onChange(n=>this.ambientLight.color.set(n)),e.add(this.params.lights.ambient,"intensity",0,10).step(.01).onChange(n=>this.ambientLight.intensity=n)})(i.addFolder("Ambient")),(e=>{e.open(),e.addColor(this.params.lights.hemisphereLight,"top").onChange(n=>this.hemisphereLight.color.set(n)),e.addColor(this.params.lights.hemisphereLight,"bottom").onChange(n=>this.hemisphereLight.groundColor.set(n)),e.add(this.params.lights.hemisphereLight,"intensity",0,10).step(.01).onChange(n=>this.hemisphereLight.intensity=n),e.add(this.params.lights.hemisphereLight,"helper",!0,!1).onChange(n=>this.hemisphereLightHelper.visible=n),e.add(this.params.lights.hemisphereLight,"height",-10,10).step(.01).onChange(n=>this.hemisphereLight.position.y=n)})(i.addFolder("Hemisphere")),(e=>{e.open(),setTimeout(()=>{["left","top","front"].forEach(n=>{e.add(this.fillLights[n].light,"intensity",0,10).step(.01).onChange(r=>this.fillLights[n].light.intensity=r)})},2e3)})(i.addFolder("FillLight"))})(t.addFolder("Light"))}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-light-config"]],viewQuery:function(t,i){if(1&t&&o.Gf(O,5),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first)}},decls:2,vars:0,consts:[[1,"container"],["container",""]],template:function(t,i){1&t&&o._UZ(0,"div",0,1)},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#f6eacd}"]}),h})();const W=["container"],Z=["canvasElement"];let V=(()=>{class h{constructor(t){this.renderer2=t,this.isDrawing=!1,this.begin=i=>{this.isDrawing=!0},this.end=i=>{this.isDrawing=!1},this.draw=i=>{if(!this.isDrawing)return;const e=i.offsetX,n=i.offsetY;let r=this.getPixelByCoords(this.imageData,e,n);r[0]=0,r[1]=0,r[2]=0,this.putPixelByCoords(this.imageData,e,n,r),this.ctx.putImageData(this.imageData,0,0)},window.model=this}ngAfterViewInit(){this.renderer2.setAttribute(this.canvasElement.nativeElement,"width","4px"),this.renderer2.setAttribute(this.canvasElement.nativeElement,"height","4px"),this.ctx=this.canvasElement.nativeElement.getContext("2d"),this.ctx&&(this.loadImage(),this.canvasElement.nativeElement.addEventListener("mousedown",this.begin),this.canvasElement.nativeElement.addEventListener("mouseup",this.end),this.canvasElement.nativeElement.addEventListener("mousemove",this.draw))}loadImage(){const t=document.createElement("img");t.onload=()=>{this.renderer2.setAttribute(this.canvasElement.nativeElement,"width",`${t.naturalWidth}px`),this.renderer2.setAttribute(this.canvasElement.nativeElement,"height",`${t.naturalHeight}px`),this.ctx.drawImage(t,0,0),this.imageData=this.ctx.getImageData(0,0,t.naturalWidth,t.naturalHeight)},t.src="assets/a.jpg"}getPixelByCoords(t,i,e){const n=4*t.width*e+4*i;return[Number(t.data[n]),Number(t.data[n+1]),Number(t.data[n+2])]}putPixelByCoords(t,i,e,n){const r=4*t.width*e+4*i;t.data[r]=n[0],t.data[r+1]=n[1],t.data[r+2]=n[2]}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-canvas-coords"]],viewQuery:function(t,i){if(1&t&&(o.Gf(W,5),o.Gf(Z,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",null,2),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;display:flex;justify-content:center;align-items:center}"]}),h})();const Q=["container"],U=["canvasElement"];let J=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.params={core:-.2,kernel:[-.2,-.2,-.2,-.2,1,-.2,-.2,-.2,-.2],weight:1},this.canvasClick=i=>{this.detect()},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.renderer2.setAttribute(this.canvasElement.nativeElement,"width","4px"),this.renderer2.setAttribute(this.canvasElement.nativeElement,"height","4px"),this.ctx=this.canvasElement.nativeElement.getContext("2d"),this.ctx&&(this.loadImage(),this.canvasElement.nativeElement.addEventListener("click",this.canvasClick),this.initGUI())}loadImage(){const t=document.createElement("img");t.onload=()=>{this.width=t.naturalWidth,this.height=t.naturalHeight,this.renderer2.setAttribute(this.canvasElement.nativeElement,"width",`${t.naturalWidth}px`),this.renderer2.setAttribute(this.canvasElement.nativeElement,"height",`${t.naturalHeight}px`),this.ctx.drawImage(t,0,0),this.imageData=this.ctx.getImageData(0,0,t.naturalWidth,t.naturalHeight)},t.src="assets/a.jpg"}getPixelByCoords(t,i,e){const n=4*t.width*e+4*i;return[Number(t.data[n]),Number(t.data[n+1]),Number(t.data[n+2])]}putPixelByCoords(t,i,e,n){const r=4*t.width*e+4*i;t.data[r]=n[0],t.data[r+1]=n[1],t.data[r+2]=n[2]}detect(){for(let t=0;t<this.height;t++)for(let i=0;i<this.width;i++)this.detectCoords(this.imageData,i,t);this.ctx.putImageData(this.imageData,0,0)}detectCoords(t,i,e){const n=[];n.push(this.getPixelByCoords(t,i-1,e-1)),n.push(this.getPixelByCoords(t,i,e-1)),n.push(this.getPixelByCoords(t,i+1,e-1)),n.push(this.getPixelByCoords(t,i-1,e)),n.push(this.getPixelByCoords(t,i,e)),n.push(this.getPixelByCoords(t,i+1,e)),n.push(this.getPixelByCoords(t,i-1,e+1)),n.push(this.getPixelByCoords(t,i,e+1)),n.push(this.getPixelByCoords(t,i+1,e+1));for(let c=0;c<n.length;c++)n[c][0]*=this.params.kernel[c],n[c][1]*=this.params.kernel[c],n[c][2]*=this.params.kernel[c];const r=[0,0,0];for(let c=0;c<n.length;c++)r[0]+=n[c][0],r[1]+=n[c][1],r[2]+=n[c][2];r[0]/=this.params.weight,r[1]/=this.params.weight,r[2]/=this.params.weight,this.putPixelByCoords(t,i,e,r)}computeKernelWeight(t){const i=t.reduce((e,n)=>e+n);return i<=0?1:i}initGUI(){(this.gui=new C.XS).add(this.params,"core",-1,1).step(.01).onChange(i=>{this.params.kernel[0]=i,this.params.kernel[1]=i,this.params.kernel[2]=i,this.params.kernel[3]=i,this.params.kernel[5]=i,this.params.kernel[6]=i,this.params.kernel[7]=i,this.params.kernel[8]=i})}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-canvas-coords"]],viewQuery:function(t,i){if(1&t&&(o.Gf(Q,5),o.Gf(U,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",null,2),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;display:flex;justify-content:center;align-items:center}"]}),h})();const N=["container"],X=["videoElement"],Y=["swapElement"],q=["targetElement"];let $=(()=>{class h{constructor(){this.params={core:-.2,kernel:[-.2,-.2,-.2,-.2,1,-.2,-.2,-.2,-.2],weight:1},this.width=0,this.height=0,this.detect=()=>{requestAnimationFrame(this.detect),this.ctxSwap.drawImage(this.videoElement.nativeElement,0,0);let t=this.ctxSwap.getImageData(0,0,this.width,this.height);for(let i=0;i<this.height;i++)for(let e=0;e<this.width;e++)this.detectCoords(t,e,i);this.ctxTarget.putImageData(t,0,0)},window.model=this}ngAfterViewInit(){this.ctxSwap=this.swapElement.nativeElement.getContext("2d",{willReadFrequently:!0}),this.ctxTarget=this.targetElement.nativeElement.getContext("2d"),navigator.mediaDevices.getUserMedia({video:!0}).then(t=>{this.videoElement.nativeElement.srcObject=t;const{width:i,height:e}=t.getTracks()[0].getSettings();this.width=i||0,this.height=e||0,this.videoElement.nativeElement.width=i,this.videoElement.nativeElement.height=e,this.swapElement.nativeElement.width=i,this.swapElement.nativeElement.height=e,this.targetElement.nativeElement.width=i,this.targetElement.nativeElement.height=e,this.detect()}).catch(t=>{alert("\u83b7\u53d6\u76f8\u673a\u9519\u8bef")}),this.initGUI()}ngOnDestroy(){this.gui&&this.gui.destroy()}getPixelByCoords(t,i,e){const n=4*t.width*e+4*i;return[Number(t.data[n]),Number(t.data[n+1]),Number(t.data[n+2]),Number(t.data[n+3])]}putPixelByCoords(t,i,e,n){const r=4*t.width*e+4*i;t.data[r]=n[0],t.data[r+1]=n[1],t.data[r+2]=n[2]}detectCoords(t,i,e){const n=[];n.push(this.getPixelByCoords(t,i-1,e-1)),n.push(this.getPixelByCoords(t,i,e-1)),n.push(this.getPixelByCoords(t,i+1,e-1)),n.push(this.getPixelByCoords(t,i-1,e)),n.push(this.getPixelByCoords(t,i,e)),n.push(this.getPixelByCoords(t,i+1,e)),n.push(this.getPixelByCoords(t,i-1,e+1)),n.push(this.getPixelByCoords(t,i,e+1)),n.push(this.getPixelByCoords(t,i+1,e+1));for(let c=0;c<n.length;c++)n[c][0]*=this.params.kernel[c],n[c][1]*=this.params.kernel[c],n[c][2]*=this.params.kernel[c];const r=[0,0,0];for(let c=0;c<n.length;c++)r[0]+=n[c][0],r[1]+=n[c][1],r[2]+=n[c][2];r[0]/=this.params.weight,r[1]/=this.params.weight,r[2]/=this.params.weight,this.putPixelByCoords(t,i,e,r)}computeKernelWeight(t){const i=t.reduce((e,n)=>e+n);return i<=0?1:i}initGUI(){this.gui=new C.XS,this.gui.add(this.params,"core",-1,1).step(.01).onChange(t=>{this.params.kernel[0]=t,this.params.kernel[1]=t,this.params.kernel[2]=t,this.params.kernel[3]=t,this.params.kernel[5]=t,this.params.kernel[6]=t,this.params.kernel[7]=t,this.params.kernel[8]=t,this.params.weight=this.computeKernelWeight(this.params.kernel)})}}return h.\u0275fac=function(t){return new(t||h)},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-detect-video"]],viewQuery:function(t,i){if(1&t&&(o.Gf(N,5),o.Gf(X,5),o.Gf(Y,5),o.Gf(q,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.videoElement=e.first),o.iGM(e=o.CRH())&&(i.swapElement=e.first),o.iGM(e=o.CRH())&&(i.targetElement=e.first)}},decls:8,vars:0,consts:[[1,"container"],["container",""],["autoplay","","muted","","playsinline",""],["videoElement",""],[1,"swap"],["swapElement",""],[1,"target"],["targetElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"video",2,3)(4,"canvas",4,5)(6,"canvas",6,7),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:black}.container[_ngcontent-%COMP%] video[_ngcontent-%COMP%]{display:none}.container[_ngcontent-%COMP%] .swap[_ngcontent-%COMP%]{display:none}"]}),h})();var u=m(3738);const tt=["container"],et=["canvasElement"];let it=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene()}initScene(){const t=this.scene=new s.xsS,i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),t.add(new s.VLJ(10,10)),t.add(new s.y8_(5)),e.setAnimationLoop(this.animate)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(tt,5),o.Gf(et,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const nt=["container"],st=["canvasElement"];let ot=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.initModels()}initScene(){const t=this.scene=new s.xsS,i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,8,12);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),t.add(new s.VLJ(10,10)),t.add(new s.y8_(5)),e.setAnimationLoop(this.animate)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.person.position.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}initModels(){this.group=new s.ZAu,this.scene.add(this.group);const t=new s.DvJ(.2,.2,.2);t.translate(0,.1,0);for(let i=-5;i<=5;i++)for(let e=-5;e<=5;e++){const n=new s.Kj0(t,new s.vBJ({color:16777215*Math.random()}));n.position.set(e,0,i),n.add(new s.ejS(new s.TOt(t),new s.nls({color:0}))),this.group.add(n)}this.person=new s.Kj0(new s.DvJ(.5,.5,.5),new s.vBJ({color:16777215})),this.person.add(new s.ejS(new s.TOt(this.person.geometry),new s.nls({color:0}))),this.person.add(new s.Kj0(new s.xo$(1),new s.vBJ({color:65535,transparent:!0,opacity:.4}))),this.scene.add(this.person)}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(nt,5),o.Gf(st,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%], .container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const at=["container"],rt=["canvasElement"];let ht=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,this.params={color:"#6495ED"},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.addLights(),this.initMesh(),this.initGUI()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.toneMapping=s.YGz,e.toneMappingExposure=1.75,e.shadowMap.enabled=!0,e.shadowMap.type=s.ntZ,e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),e.setAnimationLoop(this.animate)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}initMesh(){console.log(s.rBU.lights);const t=new s.Kj0(new s.xo$(1,128,128),new s.jyz({lights:!0,uniforms:{...s.rBU.lights,uColor:{value:new s.Ilk(this.params.color)},uGlossiness:{value:4}},vertexShader:"\n#include <common>\n#include <shadowmap_pars_vertex>\n\nvarying vec3 vNormal;\nvarying vec3 vViewDir;\n\nvoid main() {\n\n #include <beginnormal_vertex>\n #include <defaultnormal_vertex>\n\n #include <begin_vertex>\n\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n\n vec4 modelPosition = modelMatrix * vec4(position, 1.0);\n vec4 viewPosition = viewMatrix * modelPosition;\n vec4 clipPosition = projectionMatrix * viewPosition;\n\n vNormal = normalize(normalMatrix * normal);\n vViewDir = normalize(-viewPosition.xyz);\n\n gl_Position = clipPosition;\n\n}\n ",fragmentShader:"\n#include <common>\n#include <packing>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n\nuniform vec3 uColor;\nuniform float uGlossiness;\n\nvarying vec3 vNormal;\nvarying vec3 vViewDir;\n\nvoid main() {\n // shadow map\n DirectionalLightShadow directionalShadow = directionalLightShadows[0];\n\n float shadow = getShadow(\n directionalShadowMap[0],\n directionalShadow.shadowMapSize,\n directionalShadow.shadowBias,\n directionalShadow.shadowRadius,\n vDirectionalShadowCoord[0]\n );\n\n // directional light\n float NdotL = dot(vNormal, directionalLights[0].direction);\n float lightIntensity = smoothstep(0.0, 0.01, NdotL * shadow);\n vec3 directionalLight = directionalLights[0].color * lightIntensity;\n\n // specular reflection\n vec3 halfVector = normalize(directionalLights[0].direction + vViewDir);\n float NdotH = dot(vNormal, halfVector);\n\n float specularIntensity = pow(NdotH * lightIntensity, 1000.0 / uGlossiness);\n float specularIntensitySmooth = smoothstep(0.05, 0.1, specularIntensity);\n\n vec3 specular = specularIntensitySmooth * directionalLights[0].color;\n\n // rim lighting\n float rimDot = 1.0 - dot(vViewDir, vNormal);\n float rimAmount = 0.6;\n\n float rimThreshold = 0.2;\n float rimIntensity = rimDot * pow(NdotL, rimThreshold);\n rimIntensity = smoothstep(rimAmount - 0.01, rimAmount + 0.01, rimIntensity);\n\n vec3 rim = rimIntensity * directionalLights[0].color;\n\n gl_FragColor = vec4(uColor * (ambientLightColor + directionalLight + specular + rim), 1.0);\n}\n "}));t.castShadow=!0,this.scene.add(t);const i=new s.Kj0(new s._12(1,1,1),new s.Wid({color:8025973}));i.receiveShadow=!0,i.scale.setScalar(10),i.rotation.x=.5*-Math.PI,i.position.y=-1,this.scene.add(i)}addLights(){const t=new s.Ox3(16314854,.5);t.position.set(4,4,4),t.castShadow=!0,t.shadow.mapSize.width=4096,t.shadow.mapSize.height=4096,t.shadow.camera.near=2,t.shadow.camera.far=15,this.scene.add(t);const i=new s.Mig(16777215,1);this.scene.add(i)}initGUI(){}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-toon-shader"]],viewQuery:function(t,i){if(1&t&&(o.Gf(at,5),o.Gf(rt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%], .container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const ct=["container"],dt=["canvasElement"];let lt=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.torus&&(this.torus.rotation.y-=.01),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.initEnvironmentLight(),this.initMaterial(),this.addMesh()}initScene(){const t=this.scene=new s.xsS;t.background=new s.Ilk(16777215);const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),t.add(new s.VLJ(10,10)),t.add(new s.y8_(5)),e.setAnimationLoop(this.animate)}initEnvironmentLight(){(new P.x).load("assets/texture/cannon_1k.hdr",e=>{const n=new s.anP(this.renderer);n.compileEquirectangularShader(),this.scene.environment=n.fromEquirectangular(e).texture,e.dispose(),n.dispose()});const t=new s.Mig(16777215,.5);this.scene.add(t);const i=new s.Ox3(16777215,1);i.position.set(0,20,20),this.scene.add(i)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}addMesh(){const t=(new s.dpR).load("assets/texture/threeTone.jpg");t.minFilter=t.magFilter=s.TyD;const i=this.torus=new s.Kj0(new s.FE5(1,.3,128,128),new s.IKL({color:"mediumpurple",gradientMap:t}));this.addEdgeLine(i),this.scene.add(i)}addEdgeLine(t){const i=new s.Kj0(t.geometry,this.outlineMaterial);t.add(i)}initMaterial(){this.outlineMaterial=new s.jyz({side:s._Li,vertexShader:"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position + normal * .02, 1.);\n }\n ",fragmentShader:"\n void main() {\n gl_FragColor = vec4(0., 0.,0.,1.);\n }\n "})}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-cartoon-shader"]],viewQuery:function(t,i){if(1&t&&(o.Gf(ct,5),o.Gf(dt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%], .container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();var H=m(6821);const mt=["container"],pt=["canvasElement"];let ut=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.lightHelpers.forEach(i=>i.update()),this.progressiveSurfacemap.update(this.camera,200,!0),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,this.lightHelpers=[],this.lights=[],this.params={enable:!0,blurEdges:!0,BlendWindow:200},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.initEnvironment(),this.loadModel(),this.initGUI()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,0,2);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0,alpha:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.shadowMap.enabled=!0,e.shadowMap.type=s.ntZ,e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=100,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),this.progressiveSurfacemap=new H.n(e),e.setAnimationLoop(this.animate)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}initEnvironment(){(new P.x).load("assets/texture/cannon_1k.hdr",i=>{i.mapping=s.dSO,this.scene.environment=i});const t=this.ambientLight=new s.Mig(16777215,1);this.scene.add(t)}randomLights(t){const i=this.lightGroup=new s.ZAu;i.position.copy(t.position),this.scene.add(i);const e=new s.Kj0(new s.xo$(t.radius),new s.vBJ({color:5592405,wireframe:!0,transparent:!0,opacity:.2}));i.add(e);for(let n=0;n<t.amount;n++){let r=this.randomSphere(t.radius);const c=new s.Ox3(t.color,t.intensity/t.amount);c.castShadow=!0,c.position.copy(r),c.shadow.mapSize.width=128,c.shadow.mapSize.height=128,c.shadow.camera.near=.2,c.shadow.camera.far=100,i.add(c);const d=new s.cBI(c,.1);this.scene.add(d),this.lightHelpers.push(d),c.add(this.genAnchor()),this.lights.push(c)}}randomSphere(t){const i=Math.random()*(Math.PI- -Math.PI)-Math.PI,e=Math.random()*(Math.PI- -Math.PI)-Math.PI,n=t*Math.sin(i),r=t*Math.cos(i),c=Math.random()*n,d=c*Math.cos(e),l=c*Math.sin(e);return new s.Pa4(d,r,l)}addLights(){this.randomLights({position:new s.Pa4(5,5,10),amount:4,color:16777215,intensity:2,radius:4}),this.randomLights({position:new s.Pa4(-5,5,9),amount:4,color:16777215,intensity:2,radius:5})}genAnchor(){return new s.Kj0(new s.DvJ(.02,.02,.02),new s.Wid({color:16777215*Math.random(),roughness:Math.random(),metalness:Math.random()}))}addAnchor(t){const i=new s.Kj0(new s.DvJ(.02,.02,.02),new s.Wid({color:16777215*Math.random(),roughness:Math.random(),metalness:Math.random()}));i.position.copy(t),this.scene.add(i)}loadModel(){const t=new s._12(10,10,10),i=new s.vBJ({color:16777215}),e=new s.Kj0(t,i);e.position.z=-.130976,this.scene.add(e);const n=new x._;n.setDecoderPath("assets/lib/draco/"),(new v.E).setDRACOLoader(n).load("assets/model/shop/Shirt.glb",r=>{this.shirt=r.scene.getObjectByName("Shirt"),this.shirt&&this.shirt.material.color.setHex(15711566),this.scene.add(r.scene),this.addLights(),this.progressiveSurfacemap.addObjectsToLightMap([...this.lights,this.shirt,e])})}initGUI(){}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(mt,5),o.Gf(pt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#ECE9E2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const gt=["container"],wt=["canvasElement"];let ft=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.controls.enabled&&this.controls.update(),this.params.reposition&&this.reposition(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,this.amount=8,this.radius=2,this.meshes=[],this.params={reposition:!1},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.addMesh(),this.initGUI()}initScene(){const t=this.scene=new s.xsS,i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),t.add(new s.y8_(5)),e.setAnimationLoop(this.animate)}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}genAnchor(t=1){return new s.Kj0(new s.DvJ(t,t,t),new s.vBJ({color:16777215*Math.random()}))}hemisphereRandom(t){const i=this.getRangeRandom(.5*-Math.PI,.5*Math.PI),e=t*Math.sin(i),n=t*Math.cos(i),r=this.getRangeRandom(-Math.PI,Math.PI),c=e,d=c*Math.sin(r),l=c*Math.cos(r);return new s.Pa4(d,n,l)}getRangeRandom(t,i){return Math.random()*(i-t)+t}addMesh(){const t=this.group=new s.ZAu;t.position.set(0,2,0),this.scene.add(t),t.add(new s.Kj0(new s.xo$(this.radius),new s.vBJ({color:"lightgray",wireframe:!0})));for(let i=0;i<this.amount;i++){const e=this.genAnchor(.2);e.position.copy(this.hemisphereRandom(this.radius)),t.add(e),this.meshes.push(e)}}reposition(){this.meshes.forEach(t=>{t.position.copy(this.hemisphereRandom(this.radius))})}initGUI(){const t=this.gui=new C.XS;t.add(this.params,"reposition"),console.log(this.group),t.add(this.group.position,"y",-10,10).name("\u9ad8\u5ea6").step(.1),t.add(this.group.rotation,"x",-Math.PI,Math.PI).step(.001).name("\u65cb\u8f6c X"),t.add(this.group.rotation,"y",-Math.PI,Math.PI).step(.001).name("\u65cb\u8f6c Y"),t.add(this.group.rotation,"z",-Math.PI,Math.PI).step(.001).name("\u65cb\u8f6c Z")}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(gt,5),o.Gf(wt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();var I=m(5861);const yt=["container"],vt=["canvasElement"];let Ct=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.controls.enabled&&this.controls.update(),this.updateShadowMap(),this.renderer.render(this.scene,this.camera)},this.objects=[],this.color=new s.Ilk,this.params={enable:!1,blurEdges:!0,blendWindow:200},this.shadowMapSize=512,this.lightMapSize=1024,this.lightCount=8,this.lightIntensity=4,this.ambientRadius=5,this.lightRadius=5,this.lights=[],this.lightHelpers=[],this.maxFrame=120,this.frame=0,this.ambientWeight=.5,this.lightPosition=new s.Pa4(-20,10,-10),window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){var t=this;return(0,I.Z)(function*(){t.width=t.container.nativeElement.offsetWidth,t.height=t.container.nativeElement.offsetHeight,t.initScene(),yield t.addEnvironmentLight().then(),yield t.loadModel().then(),t.initLight(),t.initGUI()})()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,e.toneMapping=s.LY2,e.shadowMap.enabled=!0,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),e.setAnimationLoop(this.animate)}addEnvironmentLight(){return new Promise(t=>{(new P.x).load("assets/texture/aristea_wreck_1k.hdr",i=>{const e=new s.anP(this.renderer);e.compileEquirectangularShader(),this.scene.environment=e.fromEquirectangular(i).texture,this.scene.background=this.scene.environment,this.scene.backgroundBlurriness=.8,i.dispose(),e.dispose(),t("")})})}loadModel(){return new Promise(t=>{const i=new x._;i.setDecoderPath("assets/lib/draco/"),(new v.E).setDRACOLoader(i).load("assets/model/dev/monkey.glb",c=>{c.scene.traverse(d=>{d.isMesh&&(this.m=d,d.receiveShadow=d.castShadow=!0,this.objects.push(d))}),this.scene.add(c.scene)});const e=new s.Kj0(new s.xo$(.5).translate(0,.5,0),new s.Wid({color:this.getRandomColor(),roughness:1,metalness:1}));e.position.set(2,0,0),e.receiveShadow=e.castShadow=!0,this.scene.add(e),this.objects.push(e);const n=new s.Kj0(new s.DvJ(1,1,1).translate(0,.5,0),new s.Wid({color:this.getRandomColor(),roughness:.3,metalness:0}));n.position.set(-2,0,0),n.castShadow=n.receiveShadow=!0,this.scene.add(n),this.objects.push(n);const r=new s.Kj0(new s._12(10,10).rotateX(.5*-Math.PI),new s.xoR({color:16777215}));r.receiveShadow=r.castShadow=!0,this.scene.add(r),this.objects.push(r),t("")})}getRandomColor(){return"#"+this.color.setHSL(Math.random(),.5,.5).getHexString()}initLight(){for(let t=0;t<this.lightCount;t++){const i=new s.Ox3(16777215,this.lightIntensity/this.lightCount);i.castShadow=!0,i.shadow.camera.near=1,i.shadow.camera.far=5e3,i.shadow.mapSize.width=i.shadow.mapSize.height=this.shadowMapSize,this.lights.push(i);const e=this.genAnchor(.5);e.visible=!1,this.lightHelpers.push(e),this.scene.add(e)}}genAnchor(t=1){return new s.Kj0(new s.DvJ(t,t,t),new s.vBJ({color:16777215*Math.random()}))}calc(){this.params.enable=!1,this.progressive=new H.n(this.renderer,this.lightMapSize),this.progressive.addObjectsToLightMap([...this.objects,...this.lights]),this.frame=0,this.params.enable=!0}hemisphereRandom(t){const i=this.getRangeRandom(.5*-Math.PI,.5*Math.PI),e=t*Math.sin(i),n=t*Math.cos(i),r=this.getRangeRandom(-Math.PI,Math.PI),c=e,d=c*Math.sin(r),l=c*Math.cos(r);return new s.Pa4(d,n,l)}getRangeRandom(t,i){return Math.random()*(i-t)+t}initGUI(){const t=this.gui=new C.XS;(i=>{i.add(this.scene,"backgroundBlurriness",0,1).step(.01).name("translate")})(t.addFolder("Scene")),(i=>{i.open(),i.add({calc:()=>{this.calc()}},"calc"),i.add({frame:this.maxFrame},"frame",0,120).step(1).onChange(e=>{this.maxFrame=e}),i.add({ambient:this.ambientWeight},"ambient",0,1).step(.001).onChange(e=>{this.ambientWeight=e})})(t.addFolder("Lights")),(i=>{i.open(),["x","y","z"].forEach(e=>{i.add({[`${e}`]:0},e,-5,5).step(.001).onChange(n=>{!this.m||(this.m.position[e]=n,this.params.blendWindow=10,this.frame=0,this.params.enable=!0)})})})(t.addFolder("Move"))}updateShadowMap(){if(this.params.enable){if(this.frame>=this.maxFrame)return console.log("done",this.frame),void(this.params.enable=!1);this.frame++,this.progressive.update(this.camera,this.params.blendWindow,this.params.blurEdges),this.params.blendWindow=10,this.lights.forEach((t,i)=>{if(Math.random()>this.ambientWeight){const e=new s.Pa4(this.lightPosition.x+Math.random()*this.lightRadius,this.lightPosition.y+Math.random()*this.lightRadius,this.lightPosition.z+Math.random()*this.lightRadius);t.position.copy(e),this.lightHelpers[i].position.copy(e)}else{const e=this.hemisphereRandom(this.ambientRadius);e.y+=10,t.position.copy(e),this.lightHelpers[i].position.copy(e)}})}}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(yt,5),o.Gf(vt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();var xt=m(9749),G=m(2648);const Mt=["container"],Pt=["canvasElement"];let _t=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.controls.enabled&&this.controls.update(),this.dynamicShadow&&this.dynamicShadow.update(),this.renderer.render(this.scene,this.camera)},this.color=new s.Ilk,this.moveMonkey=()=>{!this.monkey||xt.ZP.to(this.monkey.position,{duration:.2,z:8*Math.random()-4,onComplete:()=>{this.dynamicShadow&&this.dynamicShadow.refresh()}})},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy(),this.interval&&clearInterval(this.interval)}ngAfterViewInit(){var t=this;return(0,I.Z)(function*(){t.width=t.container.nativeElement.offsetWidth,t.height=t.container.nativeElement.offsetHeight,t.initScene(),yield t.addEnvironmentLight().then(),yield t.initModels().then(),t.initDynamicShadow(),t.interval=setInterval(t.moveMonkey,2e3)})()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(-3,2,4);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,e.toneMapping=s.LY2,e.shadowMap.enabled=!0,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),this.group=new s.ZAu,this.scene.add(this.group),e.setAnimationLoop(this.animate)}addEnvironmentLight(){return new Promise(t=>{(new P.x).load("assets/texture/cannon_1k.hdr",i=>{const e=new s.anP(this.renderer);e.compileEquirectangularShader(),this.scene.environment=this.scene.background=e.fromEquirectangular(i).texture,this.scene.backgroundBlurriness=1,i.dispose(),e.dispose(),t("")})})}initModels(){const t=new x._;return t.setDecoderPath("assets/lib/draco/"),new Promise(i=>{(new v.E).setDRACOLoader(t).load("assets/model/dev/monkey.glb",e=>{e.scene.traverse(d=>{d.isMesh&&(d.receiveShadow=d.castShadow=!0,this.monkey=d)}),this.group.add(e.scene);const n=new s.Kj0(new s.xo$(.5).translate(0,.5,0),new s.Wid({color:this.getRandomColor(),roughness:0,metalness:1}));n.position.set(2,0,0),n.castShadow=n.receiveShadow=!0,this.group.add(n);const r=new s.Kj0(new s.DvJ(1,1,1).translate(0,.5,0),new s.Wid({color:this.getRandomColor(),roughness:1}));r.castShadow=r.receiveShadow=!0,r.position.set(-2,0,0),this.group.add(r);const c=new s.Kj0(new s._12(10,10).rotateX(.5*-Math.PI),new s.Wid({color:16777215,roughness:1,envMapIntensity:0}));c.receiveShadow=c.castShadow=!0,this.group.add(c),i("")})})}getRandomColor(){return"#"+this.color.setHSL(Math.random(),.5,.5).getHexString()}initDynamicShadow(){const t=this.gui=new C.XS;this.dynamicShadow=new G.C(this.camera,this.renderer,this.group,{},t)}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(Mt,5),o.Gf(Pt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const bt=["container"],St=["canvasElement"];let Et=(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.controls.enabled&&this.controls.update(),this.helper&&this.helper.update(),this.dynamicShadow&&this.dynamicShadow.update(),this.renderer.render(this.scene,this.camera)},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.addMesh(),this.addLight(),this.initGUI(),this.addShadowMap()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0,alpha:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,e.shadowMap.enabled=!0,e.shadowMap.type=s.ntZ,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),e.setAnimationLoop(this.animate)}addMesh(){const t=new s.Wid({color:16777215,roughness:1});{const i=new s.Kj0(new s._12(10,10).rotateX(.5*-Math.PI),t);i.receiveShadow=!0,this.scene.add(i)}{const i=new s.Kj0(new s.DvJ(1,1,1).translate(0,.5,0),t);i.castShadow=i.receiveShadow=!0,i.position.set(-.6,0,0),this.scene.add(i)}{const i=new s.Kj0(new s.DvJ(1,2,1).translate(0,1,0),t);i.castShadow=i.receiveShadow=!0,i.position.set(.6,0,0),this.scene.add(i)}}addLight(){const t=this.light=new s.Ox3(16777215,1);t.castShadow=!0,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize.width=t.shadow.mapSize.height=512,t.position.set(4,4,4),t.shadow.bias=14e-5,this.scene.add(t);const i=new s.Rki(t.shadow.camera);this.scene.add(i)}initGUI(){const t=this.gui=new C.XS;t.hide(),(i=>{i.open(),i.add(this.light.shadow,"bias",-1,1).step(1e-5),i.add(this.light,"intensity",0,10).step(.01)})(t.addFolder("Light"))}addShadowMap(){this.dynamicShadow=new G.C(this.camera,this.renderer,this.scene,{},this.gui)}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(bt,5),o.Gf(St,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})();const Ft=new s.Pa4,zt=new s.Pa4,kt=new s.Pa4;class E{constructor(a=new s.Pa4(0,0,0),t=new s.Pa4(0,1,0),i=1){this.start=a,this.end=t,this.radius=i}clone(){return new E(this.start.clone(),this.end.clone(),this.radius)}set(a,t,i){this.start.copy(a),this.end.copy(t),this.radius=i}copy(a){this.start.copy(a.start),this.end.copy(a.end),this.radius=a.radius}getCenter(a){return a.copy(this.end).add(this.start).multiplyScalar(.5)}translate(a){this.start.add(a),this.end.add(a)}checkAABBAxis(a,t,i,e,n,r,c,d,l){return(n-a<l||n-i<l)&&(a-r<l||i-r<l)&&(c-t<l||c-e<l)&&(t-d<l||e-d<l)}intersectsBox(a){return this.checkAABBAxis(this.start.x,this.start.y,this.end.x,this.end.y,a.min.x,a.max.x,a.min.y,a.max.y,this.radius)&&this.checkAABBAxis(this.start.x,this.start.z,this.end.x,this.end.z,a.min.x,a.max.x,a.min.z,a.max.z,this.radius)&&this.checkAABBAxis(this.start.y,this.start.z,this.end.y,this.end.z,a.min.y,a.max.y,a.min.z,a.max.z,this.radius)}lineLineMinimumPoints(a,t){const i=Ft.copy(a.end).sub(a.start),e=zt.copy(t.end).sub(t.start),n=kt.copy(t.start).sub(a.start),r=i.dot(e),c=i.dot(i),d=e.dot(e),l=e.dot(n),w=i.dot(n);let y,f;const M=c*d-r*r;if(Math.abs(M)<1e-10){const B=-l/d,K=(r-l)/d;Math.abs(B-.5)<Math.abs(K-.5)?(y=0,f=B):(y=1,f=K)}else y=(l*r+w*d)/M,f=(y*r-l)/d;return f=Math.max(0,Math.min(1,f)),y=Math.max(0,Math.min(1,y)),[i.multiplyScalar(y).add(a.start),e.multiplyScalar(f).add(t.start)]}}const _=new s.Pa4,b=new s.Pa4,g=new s.JOQ,T=new s.Zzh,Lt=new s.Zzh,F=new s.aLr,S=new E;class L{constructor(a){this.triangles=[],this.box=a,this.subTrees=[]}addTriangle(a){return this.bounds||(this.bounds=new s.ZzF),this.bounds.min.x=Math.min(this.bounds.min.x,a.a.x,a.b.x,a.c.x),this.bounds.min.y=Math.min(this.bounds.min.y,a.a.y,a.b.y,a.c.y),this.bounds.min.z=Math.min(this.bounds.min.z,a.a.z,a.b.z,a.c.z),this.bounds.max.x=Math.max(this.bounds.max.x,a.a.x,a.b.x,a.c.x),this.bounds.max.y=Math.max(this.bounds.max.y,a.a.y,a.b.y,a.c.y),this.bounds.max.z=Math.max(this.bounds.max.z,a.a.z,a.b.z,a.c.z),this.triangles.push(a),this}calcBox(){return this.box=this.bounds.clone(),this.box.min.x-=.01,this.box.min.y-=.01,this.box.min.z-=.01,this}split(a){if(!this.box)return;const t=[],i=b.copy(this.box.max).sub(this.box.min).multiplyScalar(.5);for(let n=0;n<2;n++)for(let r=0;r<2;r++)for(let c=0;c<2;c++){const d=new s.ZzF,l=_.set(n,r,c);d.min.copy(this.box.min).add(l.multiply(i)),d.max.copy(d.min).add(i),t.push(new L(d))}let e;for(;e=this.triangles.pop();)for(let n=0;n<t.length;n++)t[n].box.intersectsTriangle(e)&&t[n].triangles.push(e);for(let n=0;n<t.length;n++){const r=t[n].triangles.length;r>8&&a<16&&t[n].split(a+1),0!==r&&this.subTrees.push(t[n])}return this}build(){return this.calcBox(),this.split(0),this}getRayTriangles(a,t){for(let i=0;i<this.subTrees.length;i++){const e=this.subTrees[i];if(a.intersectsBox(e.box))if(e.triangles.length>0)for(let n=0;n<e.triangles.length;n++)-1===t.indexOf(e.triangles[n])&&t.push(e.triangles[n]);else e.getRayTriangles(a,t)}return t}triangleCapsuleIntersect(a,t){t.getPlane(g);const i=g.distanceToPoint(a.start)-a.radius,e=g.distanceToPoint(a.end)-a.radius;if(i>0&&e>0||i<-a.radius&&e<-a.radius)return!1;const n=Math.abs(i/(Math.abs(i)+Math.abs(e))),r=_.copy(a.start).lerp(a.end,n);if(t.containsPoint(r))return{normal:g.normal.clone(),point:r.clone(),depth:Math.abs(Math.min(i,e))};const c=a.radius*a.radius,d=T.set(a.start,a.end),l=[[t.a,t.b],[t.b,t.c],[t.c,t.a]];for(let w=0;w<l.length;w++){const y=Lt.set(l[w][0],l[w][1]),[f,M]=a.lineLineMinimumPoints(d,y);if(f.distanceToSquared(M)<c)return{normal:f.clone().sub(M).normalize(),point:M.clone(),depth:a.radius-f.distanceTo(M)}}return!1}triangleSphereIntersect(a,t){if(t.getPlane(g),!a.intersectsPlane(g))return!1;const i=Math.abs(g.distanceToSphere(a)),e=a.radius*a.radius-i*i,n=g.projectPoint(a.center,_);if(t.containsPoint(a.center))return{normal:g.normal.clone(),point:n.clone(),depth:Math.abs(g.distanceToSphere(a))};const r=[[t.a,t.b],[t.b,t.c],[t.c,t.a]];for(let c=0;c<r.length;c++){T.set(r[c][0],r[c][1]),T.closestPointToPoint(n,!0,b);const d=b.distanceToSquared(a.center);if(d<e)return{normal:a.center.clone().sub(b).normalize(),point:b.clone(),depth:a.radius-Math.sqrt(d)}}return!1}getSphereTriangles(a,t){for(let i=0;i<this.subTrees.length;i++){const e=this.subTrees[i];if(a.intersectsBox(e.box))if(e.triangles.length>0)for(let n=0;n<e.triangles.length;n++)-1===t.indexOf(e.triangles[n])&&t.push(e.triangles[n]);else e.getSphereTriangles(a,t)}}getCapsuleTriangles(a,t){for(let i=0;i<this.subTrees.length;i++){const e=this.subTrees[i];if(a.intersectsBox(e.box))if(e.triangles.length>0)for(let n=0;n<e.triangles.length;n++)-1===t.indexOf(e.triangles[n])&&t.push(e.triangles[n]);else e.getCapsuleTriangles(a,t)}}sphereIntersect(a){F.copy(a);const t=[];let i,e=!1;this.getSphereTriangles(a,t);for(let n=0;n<t.length;n++)(i=this.triangleSphereIntersect(F,t[n]))&&(e=!0,F.center.add(i.normal.multiplyScalar(i.depth)));if(e){const n=F.center.clone().sub(a.center),r=n.length();return{normal:n.normalize(),depth:r}}return!1}capsuleIntersect(a){S.copy(a);const t=[];let i,e=!1;this.getCapsuleTriangles(S,t);for(let n=0;n<t.length;n++)(i=this.triangleCapsuleIntersect(S,t[n]))&&(e=!0,S.translate(i.normal.multiplyScalar(i.depth)));if(e){const n=S.getCenter(new s.Pa4).sub(a.getCenter(_)),r=n.length();return{normal:n.normalize(),depth:r}}return!1}rayIntersect(a){if(0===a.direction.length())return;const t=[];let i,e,n=1e100;this.getRayTriangles(a,t);for(let r=0;r<t.length;r++){const c=a.intersectTriangle(t[r].a,t[r].b,t[r].c,!0,_);if(c){const d=c.sub(a.origin).length();n>d&&(e=c.clone().add(a.origin),n=d,i=t[r])}}return n<1e100&&{distance:n,triangle:i,position:e}}fromGraphNode(a){return a.updateWorldMatrix(!0,!0),a.traverse(t=>{if(!0===t.isMesh){let i,e=!1;null!==t.geometry.index?(e=!0,i=t.geometry.toNonIndexed()):i=t.geometry;const n=i.getAttribute("position");for(let r=0;r<n.count;r+=3){const c=(new s.Pa4).fromBufferAttribute(n,r),d=(new s.Pa4).fromBufferAttribute(n,r+1),l=(new s.Pa4).fromBufferAttribute(n,r+2);c.applyMatrix4(t.matrixWorld),d.applyMatrix4(t.matrixWorld),l.applyMatrix4(t.matrixWorld),this.addTriangle(new s.CJI(c,d,l))}e&&i.dispose()}}),this.build(),this}}class Rt extends s.ejS{constructor(a,t=16776960){super(new s.u9r,new s.nls({color:t,toneMapped:!1})),this.octree=a,this.color=t,this.type="OctreeHelper",this.update()}update(){const a=[];(function t(i){for(let e=0;e<i.length;e++){const n=i[e].box.min,r=i[e].box.max;a.push(r.x,r.y,r.z),a.push(n.x,r.y,r.z),a.push(n.x,r.y,r.z),a.push(n.x,n.y,r.z),a.push(n.x,n.y,r.z),a.push(r.x,n.y,r.z),a.push(r.x,n.y,r.z),a.push(r.x,r.y,r.z),a.push(r.x,r.y,n.z),a.push(n.x,r.y,n.z),a.push(n.x,r.y,n.z),a.push(n.x,n.y,n.z),a.push(n.x,n.y,n.z),a.push(r.x,n.y,n.z),a.push(r.x,n.y,n.z),a.push(r.x,r.y,n.z),a.push(r.x,r.y,r.z),a.push(r.x,r.y,n.z),a.push(n.x,r.y,r.z),a.push(n.x,r.y,n.z),a.push(n.x,n.y,r.z),a.push(n.x,n.y,n.z),a.push(r.x,n.y,r.z),a.push(r.x,n.y,n.z),t(i[e].subTrees)}})(this.octree.subTrees),this.geometry.dispose(),this.geometry=new s.u9r,this.geometry.setAttribute("position",new s.a$l(a,3))}dispose(){this.geometry.dispose(),this.material.dispose()}}const At=["container"],Dt=["canvasElement"],It=["container"],Gt=["canvasElement"],Kt=["container"],Ot=["canvasElement"],Wt=["container"],Zt=["canvasElement"],Vt=function(h){return{display:h}},Qt=function(h){return{top:h}},Ut=[{path:"",redirectTo:"light-config",pathMatch:"full"},{path:"light-config",component:j},{path:"00",component:it},{path:"01",component:V},{path:"02",component:J},{path:"03",component:$},{path:"04",component:ot},{path:"05",component:ht},{path:"06",component:lt},{path:"07",component:ut},{path:"08",component:ft},{path:"09",component:Ct},{path:"10",component:_t},{path:"11",component:Et},{path:"12",component:(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.STEPS_PER_FRAME=5,this.clock=new s.SUY,this.worldOctree=new L,this.playerCollider=new E(new s.Pa4(0,.35,0),new s.Pa4(0,1,0),.35),this.playerVelocity=new s.Pa4,this.playerDirection=new s.Pa4,this.keyStates={},this.ready=!1,this.animate=()=>{this.stats.update(),this.ready&&this.checkCollider(),this.renderer.render(this.scene,this.camera)},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.initLight(),this.loadModel()}initScene(){const t=this.scene=new s.xsS,i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,2,5),i.rotation.order="YXZ";const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,e.shadowMap.enabled=!0,e.shadowMap.type=s.dwk,e.toneMapping=s.LY2,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),t.add(new s.VLJ(10,10)),t.add(new s.y8_(5)),e.setAnimationLoop(this.animate)}loadModel(){const t=new x._;return t.setDecoderPath("assets/lib/draco/"),new Promise(i=>{(new v.E).setDRACOLoader(t).load("assets/model/dev/Building.glb",e=>{e.scene.traverse(n=>{n.isMesh&&(n.receiveShadow=n.castShadow=!0,n.material&&n.material.map&&(n.material.map.anisotropy=4))}),this.scene.add(e.scene),this.worldOctree.fromGraphNode(e.scene),this.helper=new Rt(this.worldOctree),this.helper.visible=!1,this.scene.add(this.helper)})})}initLight(){{const t=new s.vmT(9290206,26253,1.5);t.position.set(2,1,1),this.scene.add(t)}{const t=new s.Ox3(16777215,2.5);t.position.set(-5,25,-1),t.castShadow=!0,t.shadow.camera.near=.01,t.shadow.camera.far=500,t.shadow.camera.right=30,t.shadow.camera.left=-30,t.shadow.camera.top=30,t.shadow.camera.bottom=-30,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,t.shadow.radius=4,t.shadow.bias=-6e-5,this.scene.add(t)}}onMousedown(){this.container.nativeElement.requestPointerLock(),this.ready=!0}onMousemove(t){!document.pointerLockElement||(this.camera.rotation.y-=t.movementX/500,this.camera.rotation.x-=t.movementY/500)}onKeydown(t){this.keyStates[t.code]=!0}onKeyup(t){this.keyStates[t.code]=!1}checkCollider(){const t=Math.min(.05,this.clock.getDelta())/this.STEPS_PER_FRAME;for(let i=0;i<this.STEPS_PER_FRAME;i++)this.controls(t),this.updatePlayer(t),this.teleportPlayerIfOob()}getForwardVector(){return this.camera.getWorldDirection(this.playerDirection),this.playerDirection.y=0,this.playerDirection.normalize(),this.playerDirection}getSideVector(){return this.camera.getWorldDirection(this.playerDirection),this.playerDirection.y=0,this.playerDirection.normalize(),this.playerDirection.cross(this.camera.up),this.playerDirection}controls(t){const i=25*t;this.keyStates.KeyW&&this.playerVelocity.add(this.getForwardVector().multiplyScalar(i)),this.keyStates.KeyS&&this.playerVelocity.add(this.getForwardVector().multiplyScalar(-i)),this.keyStates.KeyA&&this.playerVelocity.add(this.getSideVector().multiplyScalar(-i)),this.keyStates.KeyD&&this.playerVelocity.add(this.getSideVector().multiplyScalar(i))}playerCollisions(){const t=this.worldOctree.capsuleIntersect(this.playerCollider);t&&this.playerCollider.translate(t.normal.multiplyScalar(t.depth))}updatePlayer(t){let i=Math.exp(-4*t)-1;this.playerVelocity.addScaledVector(this.playerVelocity,i);const e=this.playerVelocity.clone().multiplyScalar(t);this.playerCollider.translate(e),this.playerCollisions(),this.camera.position.copy(this.playerCollider.end)}teleportPlayerIfOob(){this.camera.position.y<=-25&&(this.playerCollider.start.set(0,.35,0),this.playerCollider.end.set(0,1,0),this.playerCollider.radius=.35,this.camera.position.copy(this.playerCollider.end),this.camera.rotation.set(0,0,0))}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(At,5),o.Gf(Dt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("mousedown",function(){return i.onMousedown()})("mousemove",function(n){return i.onMousemove(n)})("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})()},{path:"16",component:(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.time=0,this.animate=()=>{this.stats.update(),this.controls.enabled&&this.controls.update(),this.time+=.01,this.material&&(this.material.uniforms.time.value=this.time),this.renderer.render(this.scene,this.camera)},window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.initModel()}initScene(){(this.scene=new s.xsS).background=new s.Ilk(15658734);const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,1.6,1);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.stats=new u,this.renderer2.appendChild(this.container.nativeElement,this.stats.dom),e.setAnimationLoop(this.animate)}initEnvironment(){(new P.x).load("assets/texture/cannon_1k.hdr",t=>{t.mapping=s.dSO,this.scene.environment=t,t.dispose()})}initModel(){(new v.E).load("assets/model/dev/cube.glb",t=>{const e=100,n=new s.SPe(t.scene.children[0].geometry,this.genMaterial(),e*e);this.scene.add(n);const r=new s.Tme,c=new Float32Array(e*e);let d=0;for(let l=-49.5;l<50;l++)for(let w=-49.5;w<50;w++)c[d]=2*Math.random(),r.position.set(l,0,w),r.updateMatrix(),n.setMatrixAt(d++,r.matrix);n.instanceMatrix.needsUpdate=!0,n.geometry.setAttribute("aRandom",new s.lb7(c,1))})}genMaterial(){return this.material=new s.jyz({side:s.ehD,uniforms:{time:{value:0},uMatcap:{value:(new s.dpR).load("assets/texture/765938_1F1009_A59C7C_C9A382-64px.png")},uScan:{value:(new s.dpR).load("assets/texture/scan.png")}},vertexShader:"\n attribute float aRandom;\n\n uniform float time;\n\n\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n\n void main() {\n vec4 mvPosition = modelMatrix * instanceMatrix * vec4(position, 1.);\n vNormal = normalMatrix * mat3(instanceMatrix) * normal;\n float offset = aRandom + sin(time + 15. * aRandom);\n offset *= .2;\n mvPosition.y += offset;\n mvPosition = viewMatrix * mvPosition;\n gl_Position = projectionMatrix * mvPosition;\n\n vUv = uv;\n vViewPosition = -mvPosition.xyz;\n vWorldPosition = (modelMatrix * instanceMatrix * vec4(position, 1.)).xyz;\n vWorldPosition.y += offset;\n }\n ",fragmentShader:"\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n\n uniform sampler2D uMatcap;\n uniform sampler2D uScan;\n uniform float time;\n\n void main() {\n vec3 normal = normalize(vNormal);\n vec3 viewDir = normalize(vViewPosition);\n vec3 x = normalize(vec3(viewDir.z, 0., -viewDir.x));\n vec3 y = cross(viewDir, x);\n vec2 uv = vec2(dot(x, normal), dot(y, normal)) * .495 + .5;\n vec4 matcapColor = texture2D(uMatcap, uv);\n\n vec2 scanUv = fract(vWorldPosition.xz);\n if (vNormal.y < 0.){\n scanUv = fract(vec2(vUv.x*50., vUv.y * 4.));\n }\n vec4 scanMask = texture2D(uScan, scanUv);\n\n vec3 origin = vec3(0.);\n float dist = distance(vWorldPosition, origin);\n float radialMove = fract(dist - time);\n // radialMove *= 1. - smoothstep(1., 3., dist);\n radialMove *= 1. - step(time, dist);\n float scanMix = smoothstep(.3, 0., 1. - radialMove);\n scanMix *= 1. - scanMask.a * 5.;\n scanMix += smoothstep(.1, 0., 1. - radialMove) * 1.5;\n\n vec3 scanColor = mix(vec3(1.), vec3(1.), scanMix * .5);\n\n\n gl_FragColor = vec4(vNormal, 1.);\n gl_FragColor = vec4(vec3(scanMask.r), 1.);\n gl_FragColor = vec4(vec3(dist), 1.);\n gl_FragColor = vec4(vec3(scanMix), 1.);\n gl_FragColor = vec4(scanColor, 1.);\n\n gl_FragColor = matcapColor;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, scanColor, scanMix * .5);\n }\n "}),this.material}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(It,5),o.Gf(Gt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})()},{path:"17",component:(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.flyAnimate(),this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.1,this.time=0,window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.generateMaterials(),this.loadModel(),this.addFly()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,-2.683319637050938,38.992411384317094);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.controls.target.set(0,-2.6,38.5),this.controls.enableDamping=!0,this.stats=new u,e.setAnimationLoop(this.animate)}onResize(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(devicePixelRatio),this.camera.aspect=this.width/this.height,this.camera.updateProjectionMatrix()}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}generateMaterials(){const t=(new s.dpR).load("assets/model/country-road.png");t.colorSpace=s.KI_,t.flipY=!1,this.material=new s.jyz({side:s.ehD,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{uTexture:{value:t}},vertexShader:"\n varying vec2 vUv;\n attribute float random;\n\n void main() {\n vUv = uv;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.);\n\n gl_PointSize = (200. + 1000. * random) * (1. / - mvPosition.z) * .1;\n\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D uTexture;\n\n void main() {\n vec4 color = texture2D(uTexture, vUv);\n float dist = length(gl_PointCoord.xy - vec2(0.5));\n float alpha = smoothstep(0.49, 0.3, dist);\n gl_FragColor = vec4(color.rgb * 1.3, alpha / 2.);\n }\n "})}loadModel(){const t=(new x._).setDecoderPath("assets/lib/draco/");(new v.E).setDRACOLoader(t).load("assets/model/country-road.glb",i=>{console.log(i.scene);const e=i.scene.getObjectByName("Road");if(!e)return;const n=e.geometry;if(!n)return;const r=n.attributes.position.count,c=[];for(let l=0;l<r;l++)c.push(Math.random());n.setAttribute("random",new s.TlE(new Float32Array(c),1));const d=new s.woe(n,this.material);this.scene.add(d)})}generateFlyMaterial(){return this.flyMaterial=new s.jyz({side:s.ehD,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{uTime:{value:0}},vertexShader:"\n varying vec2 vUv;\n uniform float uTime;\n attribute float offset;\n attribute float size;\n\n void main() {\n\n vUv = uv;\n\n float life = mod(uTime / 10. + offset * 3., 3.);\n\n float sizeKoef = smoothstep(3., 2., life);\n sizeKoef *= smoothstep(0., 1., life);\n\n float gsize = (100. + 1000. * size) * 2.;\n gsize *= sizeKoef;\n vec3 newpos = position;\n\n newpos.y += life * 10.;\n newpos.x += sin(life * 10. + offset);\n vec4 mvPosition = modelViewMatrix * vec4(newpos, 1.);\n\n gl_PointSize = gsize * ( 1. / - mvPosition.z );\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n void main() {\n float dist = length(gl_PointCoord.xy - vec2(0.5));\n float alpha = smoothstep(0.49, 0.3, dist);\n gl_FragColor = vec4(0.791, 0.728, 0.681, alpha / 2.);\n }\n "}),this.flyMaterial}addFly(){const i=new s.u9r,e=[],n=[],r=[];for(let d=0;d<1e3;d++)e.push(300*(Math.random()-.5),100*(Math.random()-.5),1e3*(Math.random()-.5)),n.push(Math.random()),r.push(Math.random());i.setAttribute("position",new s.TlE(new Float32Array(e),3)),i.setAttribute("offset",new s.TlE(new Float32Array(n),1)),i.setAttribute("size",new s.TlE(new Float32Array(r),1));const c=new s.woe(i,this.generateFlyMaterial());this.scene.add(c)}flyAnimate(){!this.flyMaterial||(this.time+=.05,this.flyMaterial.uniforms.uTime.value=this.time)}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(Kt,5),o.Gf(Ot,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("resize",function(){return i.onResize()},!1,o.Jf7)("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:4,vars:0,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.qZA())},styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}"]}),h})()},{path:"18",component:(()=>{class h{constructor(t){this.renderer2=t,this.width=0,this.height=0,this.animate=()=>{this.stats.update(),this.walk(),this.flyAnimate(),this.controls.enabled&&this.controls.update(),this.renderer.render(this.scene,this.camera)},this.keys={},this.direction=new s.Pa4(0,0,0),this.panSpeed=.2,this.percent=0,this.time=0,window.model=this}ngOnDestroy(){this.gui&&this.gui.destroy()}ngAfterViewInit(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.initScene(),this.generateMaterials(),this.addFly(),this.loadModel()}initScene(){this.scene=new s.xsS;const i=this.camera=new s.cPb(70,this.width/this.height,.1,4e3);i.position.set(0,0,0);const e=this.renderer=new s.CP7({canvas:this.canvasElement.nativeElement,antialias:!0});e.setSize(this.width,this.height),e.setPixelRatio(devicePixelRatio),e.outputColorSpace=s.KI_,this.renderer2.appendChild(this.container.nativeElement,e.domElement),this.controls=new p.z(i,e.domElement),this.controls.maxDistance=2e3,this.controls.target.set(0,0,-1),this.stats=new u,e.setAnimationLoop(this.animate)}onResize(){this.width=this.container.nativeElement.offsetWidth,this.height=this.container.nativeElement.offsetHeight,this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(devicePixelRatio),this.camera.aspect=this.width/this.height,this.camera.updateProjectionMatrix()}onKeydown(t){this.keys[t.key]=!0,this.calcKeyboardDirection()}onKeyup(t){this.keys[t.key]=!1,this.calcKeyboardDirection()}walk(){if(this.direction.length()<.5)return;const t=this.camera.getWorldDirection(new s.Pa4);t.y=0,t.normalize();const i=Math.atan2(-this.direction.z,this.direction.x);t.applyAxisAngle(new s.Pa4(0,1,0),i-Math.PI/2),t.normalize();const e=t.multiplyScalar(this.panSpeed);this.camera.position.add(e),this.controls.target.add(e)}calcKeyboardDirection(){const t=new s.Pa4(0,0,0);this.keys.a&&(t.x-=1),this.keys.d&&(t.x+=1),this.keys.w&&(t.z-=1),this.keys.s&&(t.z+=1),this.direction.copy(t.normalize())}generateMaterials(){const t=(new s.dpR).load("assets/model/forest.jpg");t.colorSpace=s.KI_,t.flipY=!1,this.material=new s.jyz({side:s.ehD,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{uTexture:{value:t}},vertexShader:"\n varying vec2 vUv;\n attribute float random;\n\n void main() {\n vUv = uv;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.);\n\n gl_PointSize = (200. + 1000. * random) * (1. / - mvPosition.z) * .5;\n\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D uTexture;\n\n void main() {\n vec4 color = texture2D(uTexture, vUv);\n float dist = length(gl_PointCoord.xy - vec2(0.5));\n float alpha = smoothstep(0.49, 0.3, dist);\n gl_FragColor = vec4(color.rgb * 1., alpha / 2.);\n }\n "})}loadModel(){const t=(new x._).setDecoderPath("assets/lib/draco/");(new v.E).setDRACOLoader(t).load("assets/model/forest.glb",i=>{console.log(i.scene);const e=i.scene.getObjectByName("Mesh");if(!e)return;const n=e.geometry;if(!n)return;const r=n.attributes.position.count,c=[];for(let l=0;l<r;l++)c.push(Math.random());n.setAttribute("random",new s.TlE(new Float32Array(c),1));const d=new s.woe(n,this.material);this.scene.add(d)},i=>{this.percent=Math.floor(i.loaded/(i.total||1358744)*100)})}generateFlyMaterial(){return this.flyMaterial=new s.jyz({side:s.ehD,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{uTime:{value:0}},vertexShader:"\n varying vec2 vUv;\n uniform float uTime;\n attribute float offset;\n attribute float size;\n\n void main() {\n\n vUv = uv;\n\n float life = mod(uTime / 10. + offset * 3., 3.);\n\n float sizeKoef = smoothstep(3., 2., life);\n sizeKoef *= smoothstep(0., 1., life);\n\n float gsize = (100. + 1000. * size) * 2.;\n gsize *= sizeKoef;\n vec3 newpos = position;\n\n newpos.y += life * 10.;\n newpos.x += sin(life * 10. + offset);\n vec4 mvPosition = modelViewMatrix * vec4(newpos, 1.);\n\n gl_PointSize = gsize * ( 1. / - mvPosition.z );\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n void main() {\n float dist = length(gl_PointCoord.xy - vec2(0.5));\n float alpha = smoothstep(0.49, 0.3, dist);\n gl_FragColor = vec4(0.791, 0.728, 0.681, alpha / 2.);\n }\n "}),this.flyMaterial}addFly(){const i=new s.u9r,e=[],n=[],r=[];for(let d=0;d<1e3;d++)e.push(300*(Math.random()-.5),100*(Math.random()-.5),1e3*(Math.random()-.5)),n.push(Math.random()),r.push(Math.random());i.setAttribute("position",new s.TlE(new Float32Array(e),3)),i.setAttribute("offset",new s.TlE(new Float32Array(n),1)),i.setAttribute("size",new s.TlE(new Float32Array(r),1));const c=new s.woe(i,this.generateFlyMaterial());this.scene.add(c)}flyAnimate(){!this.flyMaterial||(this.time+=.05,this.flyMaterial.uniforms.uTime.value=this.time)}}return h.\u0275fac=function(t){return new(t||h)(o.Y36(o.Qsj))},h.\u0275cmp=o.Xpm({type:h,selectors:[["app-three-template"]],viewQuery:function(t,i){if(1&t&&(o.Gf(Wt,5),o.Gf(Zt,5)),2&t){let e;o.iGM(e=o.CRH())&&(i.container=e.first),o.iGM(e=o.CRH())&&(i.canvasElement=e.first)}},hostBindings:function(t,i){1&t&&o.NdJ("resize",function(){return i.onResize()},!1,o.Jf7)("keydown",function(n){return i.onKeydown(n)},!1,o.Jf7)("keyup",function(n){return i.onKeyup(n)},!1,o.Jf7)},decls:8,vars:7,consts:[[1,"container"],["container",""],[1,"webgl"],["canvasElement",""],[1,"loading",3,"ngStyle"],[1,"bg",3,"ngStyle"]],template:function(t,i){1&t&&(o.TgZ(0,"div",0,1),o._UZ(2,"canvas",2,3),o.TgZ(4,"div",4)(5,"span"),o._uU(6),o.qZA(),o._UZ(7,"div",5),o.qZA()()),2&t&&(o.xp6(4),o.Q6J("ngStyle",o.VKq(3,Vt,100===i.percent?"none":"")),o.xp6(2),o.hij("",i.percent,"%"),o.xp6(1),o.Q6J("ngStyle",o.VKq(5,Qt,100-i.percent+"%")))},dependencies:[A.PC],styles:[".container[_ngcontent-%COMP%]{width:100vw;height:100vh;background:#d4d7e2}.container[_ngcontent-%COMP%] .webgl[_ngcontent-%COMP%]{width:100vw;height:100vh}.container[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:100px;height:100px;border-radius:50%;background:#000000AA;border:4px solid darkgoldenrod;display:flex;justify-content:center;align-items:center;overflow:hidden}.container[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{color:#fff;letter-spacing:2px;text-align:center;line-height:100px;font-size:16px;z-index:10}.container[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%] .bg[_ngcontent-%COMP%]{width:100px;height:100px;background:goldenrod;position:absolute;left:0;top:100%}"]}),h})()}];let Jt=(()=>{class h{}return h.\u0275fac=function(t){return new(t||h)},h.\u0275mod=o.oAB({type:h}),h.\u0275inj=o.cJS({imports:[D.Bz.forChild(Ut),D.Bz]}),h})(),Nt=(()=>{class h{}return h.\u0275fac=function(t){return new(t||h)},h.\u0275mod=o.oAB({type:h}),h.\u0275inj=o.cJS({imports:[A.ez,Jt]}),h})()}}]);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。