1/*! © 2011â2026 Georg Luif · georgluif.at · All rights reserved. */ 2import*as n from"./three.module.min.js";import{createTrail as V}from"./trail-math.js";const R=32,X=.7,D=1,H=1.3,U=7,L=.35,N=14,Y=.8;function Z(){const h=[];function m(r,z,k){r.applyMatrix4(k);const M=r.getAttribute("position").count,A=new n.Color(z),y=new Float32Array(M*3);for(let p=0;p<M;p++)y[p*3]=A.r,y[p*3+1]=A.g,y[p*3+2]=A.b;r.setAttribute("color",new n.BufferAttribute(y,3)),h.push(r.index?r.toNonIndexed():r)}const s=function(r,z,k,M,A,y,p){const _=new n.Matrix4().makeScale(M||1,A||1,y||1);return p&&_.premultiply(new n.Matrix4().makeRotationX(p)),_.premultiply(new n.Matrix4().makeTranslation(r,z,k))};m(new n.SphereGeometry(.13,10,7),"#ffd23f",s(0,.12,0,1,.82,1.3)),m(new n.ConeGeometry(.05,.12,6),"#f7c22e",s(0,.17,-.17,1,1,1,-2.1)),m(new n.SphereGeometry(.085,10,7),"#ffdc55",s(0,.26,.11)),m(new n.ConeGeometry(.035,.08,6),"#ff8a1f",s(0,.245,.21,1.4,1,.7,Math.PI/2)),m(new n.SphereGeometry(.016,6,4),"#1d1a16",s(.05,.285,.17)),m(new n.SphereGeometry(.016,6,4),"#1d1a16",s(-.05,.285,.17));let w=0;for(const r of h)w+=r.getAttribute("position").count;const S=new Float32Array(w*3),u=new Float32Array(w*3),e=new Float32Array(w*3);let g=0;for(const r of h)S.set(r.getAttribute("position").array,g*3),u.set(r.getAttribute("normal").array,g*3),e.set(r.getAttribute("color").array,g*3),g+=r.getAttribute("position").count,r.dispose();const d=new n.BufferGeometry;return d.setAttribute("position",new n.BufferAttribute(S,3)),d.setAttribute("normal",new n.BufferAttribute(u,3)),d.setAttribute("color",new n.BufferAttribute(e,3)),d.computeBoundingSphere(),d}export function createDucklings(h){const m=h.scene,s=h.runtime,w=h.sfx||null,S=h.listener||null,u=new Map;let e=null;const g=new n.Matrix4,d=new n.Quaternion,r=new n.Euler(0,0,0,"YXZ"),z=new n.Vector3,k=new n.Vector3,M={x:0,y:0,z:0,yaw:0};function A(){if(e)return e;const o=new n.MeshLambertMaterial({vertexColors:!0});return e=new n.InstancedMesh(Z(),o,R),e.name="ducklings",e.count=0,e.frustumCulled=!1,e.castShadow=!!h.shadows,e.raycast=function(){},m.add(e),e}function y(o,x,f,b){const a=o==null?"self":String(o),G=performance.now()/1e3;let i=u.get(a);if(i){i.until=G+f,i.lead=b;return}const c=b();if(c){i={lead:b,trail:V({spacing:.1,max:160}),ducks:[],until:G+f,rippleT:0,peepT:1+Math.random()*2};for(let E=0;E<x;E++){const T=Math.random()*Math.PI*2,l=.3+Math.random()*.5;i.ducks.push({x:c.x+Math.cos(T)*l,y:c.y,z:c.z+Math.sin(T)*l,yaw:Math.random()*6,t:Math.random()*3,pop:0,phase:Math.random()*6})}i.trail.push(c.x,c.y,c.z),u.set(a,i),A()}}function p(o,x){const f=s.water&&s.water.at?s.water.at(o,x):null;return f?{y:f.level-.03,wet:!0}:{y:s.groundHeight(o,x),wet:!1}}function _(o){if(!u.size)return e&&(e.count=0),!1;const x=performance.now()/1e3;let f=0;const b=S?S():null;return u.forEach(function(a,G){const i=a.lead(),c=!i||x>=a.until;i&&a.trail.push(i.x,i.y,i.z);let E=0;a.rippleT-=o;const T=a.rippleT<=0;T&&(a.rippleT=Y);for(let l=0;l<a.ducks.length;l++){const t=a.ducks[l];if(t.t+=o,t.pop=c?Math.max(0,t.pop-o/L):Math.min(1,t.pop+o/L),t.pop<=0&&c)continue;if(E++,a.trail.sample(D+X*l,M)){const v=1-Math.exp(-U*o),I=t.x,F=t.z;t.x+=(M.x-t.x)*v,t.z+=(M.z-t.z)*v;const B=Math.hypot(t.x-I,t.z-F)/Math.max(1e-4,o);B>.15&&(t.yaw=Math.atan2(t.x-I,t.z-F)),t.moving=B}const P=p(t.x,t.z),C=Math.sin(t.t*14+t.phase),O=P.wet?.012*Math.sin(t.t*2.3+t.phase):t.moving>.2?.035*Math.abs(C):0;if(t.y=P.y+O,P.wet&&T&&t.moving>.3&&s.water.ripple&&s.water.ripple(t.x,t.z,.25),f<R){const v=H*(.85+.15*(l*.37%1)),I=t.pop<1?1-Math.pow(1-t.pop,3):1;r.set(0,t.yaw,P.wet?.04*Math.sin(t.t*1.7):t.moving>.2?.18*C:0),d.setFromEuler(r),z.setScalar(v*I),g.compose(k.set(t.x,t.y,t.z),d,z),e.setMatrixAt(f++,g)}}if(a.peepT-=o,a.peepT<=0&&!c&&w&&w.peep&&a.ducks.length){a.peepT=.9+Math.random()*2.2;const l=a.ducks[Math.floor(Math.random()*a.ducks.length)],t=b?Math.hypot(b.x-l.x,b.z-l.z):0;t<N&&w.peep(1-t/N)}c&&E===0&&u.delete(G)}),e&&(e.count=f,e.instanceMatrix.needsUpdate=!0),f>0}return{spawn:y,update:_,count:function(){let o=0;return u.forEach(function(x){o+=x.ducks.length}),o},clear:function(o){u.delete(o==null?"self":String(o))},dispose:function(){u.clear(),e&&(m.remove(e),e.geometry.dispose(),e.material.dispose(),e.dispose(),e=null)}}}
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.