PageSourceSearch

https://www.davidjfox.com/assets/distance-CEyMmWwd.js

js davidjfox.com collected 2026-10-10 02:44:45 UTC 2,725 bytes, 5 lines download raw bytes

1import{WebGLRenderer as W,SRGBColorSpace as k,Scene as B,Color as p,FogExp2 as V,PerspectiveCamera as _,Mesh as g,SphereGeometry as j,ShaderMaterial as q,BackSide as H,HemisphereLight as I,DirectionalLight as X,PlaneGeometry as A,MeshStandardMaterial as L,MathUtils as C,BufferAttribute as N}from"./three.module-DK_4hUQZ.js";import{h as O}from"./terrain-DuI6-Zo9.js";function Z(o,F){const n=new W({canvas:o,antialias:!0,powerPreference:"low-power"});n.setPixelRatio(Math.min(devicePixelRatio,innerWidth<600?1.5:1.75)),n.outputColorSpace=k;const t=new B,v=new p("#a7bdc7");t.fog=new V(v,.037);const i=new _(35,1,.05,800);i.position.set(0,.18,7),i.lookAt(0,.18,-20);const f=new g(new j(450,24,12),new q({uniforms:{horizon:{value:v},top:{value:new p("#4f7a94")}},vertexShader:"varying vec3 d;void main(){d=position;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}",fragmentShader:`uniform vec3 horizon,top;varying vec3 d;void main(){
2      float h=smoothstep(0.10,0.60,max(normalize(d).y,0.0));
3      gl_FragColor=vec4(mix(horizon,top,h),1.0);
4      #include <colorspace_fragment>
5    }`,side:H,depthWrite:!1}));f.position.copy(i.position),t.add(f),t.add(new I("#dbe8ef","#66694b",1.8));const b=new X("#fff0d2",2.1);b.position.set(-5,7,3),t.add(b);const l=new g(new A(800,800),new L({color:"#707959",roughness:1}));l.rotation.x=-Math.PI/2,l.position.y=-.005,t.add(l);const a=new A(8,5,160,100);a.rotateX(-Math.PI/2);const c=a.attributes.position,x=new Float32Array(c.count*3),R=new p("#717b56"),E=new p("#b4af9f");for(let e=0;e<c.count;e++){const s=c.getX(e),z=c.getZ(e),G=C.smoothstep(Math.min(4-Math.abs(s),2.5-Math.abs(z)),0,.6),P=O(s-.4,z-4.4)*G;c.setY(e,P);const w=R.clone().lerp(E,C.smoothstep(P,.2,1.4));x.set([w.r,w.g,w.b],e*3)}
5a.setAttribute("color",new N(x,3)),a.computeVertexNormals();const h=new g(a,new L({vertexColors:!0,roughness:1}));h.position.z=-5,t.add(h);let u=!1,m=!1,r=0;function D(){r=0,!m&&u&&!document.hidden&&n.render(t,i)}function d(){!m&&u&&!document.hidden&&!r&&(r=requestAnimationFrame(D))}function M(){const e=o.clientWidth,s=o.clientHeight;!e||!s||(n.setSize(e,s,!1),i.aspect=e/s,i.updateProjectionMatrix(),d())}const y=new ResizeObserver(M);y.observe(o),document.addEventListener("visibilitychange",d);const S=e=>{e.preventDefault(),F()};return o.addEventListener("webglcontextlost",S),M(),{setDistance(e){h.position.z=-5-e*.65,d()},setVisible(e){u=e,e?d():(cancelAnimationFrame(r),r=0)},dispose(){if(!m){m=!0,cancelAnimationFrame(r),y.disconnect(),document.removeEventListener("visibilitychange",d),o.removeEventListener("webglcontextlost",S);for(const e of[f,l,h])e.geometry.dispose(),e.material.dispose();n.dispose(),n.forceContextLoss()}}}}export{Z as createDistanceScene};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.