mirror of
https://gitee.com/ice-gl/icegl-three-vue-tres.git
synced 2025-04-05 06:22:43 +08:00
2 lines
3.3 KiB
JavaScript
2 lines
3.3 KiB
JavaScript
import{Y as M,az as S,aA as b,a2 as y,w as P,o as _,c as f,I as p,aa as v,U as w,a as u,C as x,D as L,B as z,a5 as B,a6 as k,a0 as $,ba as j,a9 as A,s as W,aC as F,av as I}from"./vendor-76c85ed2.js";import{_ as T}from"./loading.vue_vue_type_script_setup_true_lang-43ced0f9.js";const N=["object"],R=.2,D=M({__name:"airplane",props:{planet:{}},async setup(h){let e,i;const n=h,{scene:a}=([e,i]=S(()=>b("./plugins/earthSample/model/lowpolyPlanet/airplane.gltf")),e=await e,i(),e),t=a;t.rotation.set(0,Math.PI,0),a.traverse(s=>{s.isMesh&&(s.castShadow=!0)}),t.updateMatrixWorld();const{onLoop:c}=y();P(()=>n.planet,s=>{var d;if(!s)return;s.geometry.computeBoundingSphere();const r=Math.abs(((d=s.geometry.boundingSphere)==null?void 0:d.radius)|1);t.position.set(r,0,0),t.lookAt(s.position)});let o=0;return c(({delta:s})=>{if(!t||!n.planet)return;const r=Math.abs(n.planet.geometry.boundingSphere.radius)+.5;o+=s*R;const d=r*Math.cos(o),l=r*Math.sin(o);t.position.x=d,t.position.z=l,t.rotation.z=-Math.PI/2,t.rotation.y=-o,t.updateMatrixWorld()}),(s,r)=>(_(),f("primitive",{object:p(t)},null,8,N))}}),E=["object"],Q=M({__name:"cloud",props:{planet:{}},async setup(h){let e,i;const n=h,{scene:a}=([e,i]=S(()=>b("./plugins/earthSample/model/lowpolyPlanet/cloud.gltf")),e=await e,i(),e);v();const t=a.children[0];t.castShadow=!0;function c(l,m){const g=Math.random()*(m-l)+l;return Math.random()<.5?-g:g}t.position.set(c(-8,8),c(.5,1),c(-8,8));const o=c(.5,1);t.scale.set(o,o,o),t.updateMatrixWorld(),P(()=>n.planet,l=>{l&&(t.lookAt(l.position),t.updateMatrixWorld())});const{onLoop:s}=y();let r=c(-1,1)*Math.PI;const d=Math.random()/10;return s(({delta:l})=>{if(!t)return;const m=Math.abs(n.planet.geometry.boundingSphere.radius-.5);r+=l*d;const g=m*Math.cos(r),C=m*Math.sin(r);t.position.x=g,t.position.z=C,t.rotation.y=-r,t.lookAt(n.planet.position),t.updateMatrixWorld()}),(l,m)=>(_(),f("primitive",{object:p(a),"cast-shadow":""},null,8,E))}}),V=["object"],G=M({__name:"planet",async setup(h){let e,i;const{nodes:n}=([e,i]=S(()=>b("./plugins/earthSample/model/lowpolyPlanet/planet.gltf")),e=await e,i(),e),a=n.Planet,t=n.Icosphere;a.traverse(o=>{o.isMesh&&(o.receiveShadow=!0)});const{onLoop:c}=y();return c(({delta:o})=>{a&&(a.rotation.y+=o*.04,a.rotation.z+=o*.02,a.rotation.x+=o*.05,a.updateMatrixWorld())}),(o,s)=>(_(),f(x,null,[w("primitive",{object:p(a)},null,8,V),u(D,{planet:p(t)},null,8,["planet"]),(_(),f(x,null,L([1,2,3,4,5,6,7,8,9],r=>u(Q,{key:r,planet:p(t)},null,8,["planet"])),64))],64))}}),U=w("TresPerspectiveCamera",{position:[0,1,5],fov:75,near:.1,far:1e3},null,-1),Y=w("TresAmbientLight",{color:"#484068",intensity:1},null,-1),q=w("TresPointLight",{color:"#1BFFEF",position:[0,0,-8],intensity:80,"cast-shadow":""},null,-1),H=w("TresDirectionalLight",{position:[0,2,4],intensity:3,"cast-shadow":"","shadow-mapSize-width":2048,"shadow-mapSize-height":2048},null,-1),O=M({__name:"lowpolyPlanet",setup(h){const e={clearColor:"#11101B",shadows:!0,alpha:!1,outputColorSpace:$,shadowMapType:j,useLegacyLights:!0},i=v(0);return y().onLoop(({delta:n})=>{i.value+=.02*n}),(n,a)=>(_(),f(x,null,[u(T),u(p(k),B(e,{"window-size":""}),{default:z(()=>[U,u(p(A)),Y,(_(),W(F,null,{default:z(()=>[u(G)]),_:1})),u(p(I),{rotation:[0,i.value,0],radius:50,depth:50,count:5e3,size:.3,"size-attenuation":!0},null,8,["rotation"]),q,H]),_:1},16)],64))}});export{O as default};
|