1AFRAME.registerComponent("cute-particles", { 2 schema: { 3 count: { type: "int", default: 80 }, 4 radius: { type: "number", default: 0.25 }, 5 size: { type: "number", default: 0.12 }, 6 height: { type: "number", default: 0.35 } 7 }, 8 init: function () { 9 const data = this.data; 10 const el = this.el; 11 const shapes = [ 12 { src: "#heart-img" }, 13 { src: "#star-img" } 14 ]; 15 16 for (let i = 0; i < data.count; i += 1) { 17 const p = document.createElement("a-entity"); 18 const sprite = document.createElement("a-plane"); 19 const angle = Math.random() * Math.PI * 2; 20 const r = Math.random() * data.radius; 21 const x = Math.cos(angle) * r; 22 const z = Math.sin(angle) * r; 23 const y = (Math.random() - 0.5) * data.height; 24 const floatY = y + (Math.random() * 0.2 + 0.08); 25 const floatX = x + (Math.random() - 0.5) * 0.05; 26 const floatZ = z + (Math.random() - 0.5) * 0.05; 27 const dur = 1400 + Math.random() * 1800; 28 const scale = data.size * (0.8 + Math.random() * 0.8); 29 const shape = shapes[i % shapes.length]; 30 31 sprite.setAttribute("width", 1); 32 sprite.setAttribute("height", 1); 33 sprite.setAttribute( 34 "material", 35 `shader: flat; src: ${shape.src}; transparent: true; alphaTest: 0.1; side: double; opacity: 0.95;` 36 ); 37 p.appendChild(sprite); 38 p.setAttribute("position", `${x} ${y} ${z}`); 39 p.setAttribute("scale", `${scale} ${scale} ${scale}`); 40 p.setAttribute( 41 "animation__bob", 42 `property: position; to: ${floatX} ${floatY} ${floatZ}; dir: alternate; dur: ${dur}; easing: easeInOutSine; loop: true;` 43 ); 44 p.setAttribute( 45 "animation__spin", 46 `property: rotation; to: ${Math.random() * 40} ${Math.random() * 360} ${Math.random() * 40}; dur: ${2000 + Math.random() * 2000}; easing: linear; loop: true;` 47 ); 48 p.setAttribute( 49 "animation__pulse", 50 `property: scale; to: ${scale * 1.1} ${scale * 1.1} ${scale * 1.1}; dir: alternate; dur: ${1200 + Math.random() * 1200}; easing: easeInOutSine; loop: true;` 51 ); 52 el.appendChild(p); 53 } 54 } 55 }); 56 57AFRAME.registerComponent("transparent-queue", { 58 init: function () { 59 this.el.addEventListener("model-loaded", (evt) => { 60 const mesh = evt.detail.model; 61 mesh.traverse((node) => { 62 if (node.isMesh && node.material) { 63 const materials = Array.isArray(node.material) 64 ? node.material 65 : [node.material]; 66 materials.forEach((mat) => { 67 mat.transparent = true; 68 mat.depthWrite = false; 69 }); 70 node.renderOrder = 10; 71 } 72 }); 73 }); 74 } 75 }); 76 77AFRAME.registerComponent("matrix-particles", { 78 schema: { 79 count: { type: "int", default: 600 }, 80 width: { type: "number", default: 1.6 }, 81 height: { type: "number", default: 1.0 }, 82 depth: { type: "number", default: 1.2 }, 83 speed: { type: "number", default: 0.05 }, 84 size: { type: "number", default: 0.01 }, 85 colSpacing: { type: "number", default: 0.04 }, 86 tail: { type: "number", default: 0.05 } 87 }, 88 init: function () { 89 const data = this.data; 90 this.particles = []; 91 this.columns = Math.max(1, Math.floor(data.width / data.colSpacing)); 92 for (let i = 0; i < data.count; i += 1) { 93 const p = document.createElement("a-plane"); 94 const width = data.size * 0.6; 95 const height = data.tail; 96 p.setAttribute("width", width); 97 p.setAttribute("height", height); 98 const baseOpacity = 0.45 + Math.random() * 0.5; 99 const head = Math.random() > 0.8; 100 p.setAttribute( 101 "material", 102 `shader: flat; color: ${head ? "#ccffcc" : "#00ff66"}; opacity: ${baseOpacity}; transparent: true; side: double;` 103 ); 104 const col = Math.floor(Math.random() * this.columns); 105 const x = (col - (this.columns - 1) / 2) * data.colSpacing; 106 const y = (Math.random() - 0.5) * data.height; 107 const z = -Math.random() * data.depth; 108 p.setAttribute("position", `${x} ${y} ${z}`); 109 p.setAttribute("rotation", "0 0 0"); 110 this.el.appendChild(p); 111 this.particles.push({ 112 el: p, 113 x, 114 y, 115 z, 116 speed: data.speed * (0.4 + Math.random() * 1.2), 117 baseOpacity, 118 flicker: Math.random() * Math.PI * 2 119 }); 120 } 121 }, 122 tick: function (time, delta) { 123 if (!delta) { 124 return; 125 } 126 const data = this.data; 127 const dy = data.speed * (delta / 16); 128 for (let i = 0; i < this.particles.length; i += 1) { 129 const p = this.particles[i]; 130 p.y -= dy * (p.speed / data.speed); 131 if (p.y < -data.height * 0.5) { 132 p.y = data.height * 0.5; 133 const col = Math.floor(Math.random() * this.columns); 134 p.x = (col - (this.columns - 1) / 2) * data.colSpacing; 135 p.z = -Math.random() * data.depth; 136 } 137 p.el.setAttribute("position", `${p.x} ${p.y} ${p.z}`); 138 const flicker = 0.65 + 0.35 * Math.sin(time * 0.003 + p.flicker); 139 p.el.setAttribute("material", "opacity", p.baseOpacity * flicker); 140 } 141 } 142 }); 143 144AFRAME.registerComponent("matrix-shader", { 145 schema: { 146 speed: { type: "number", default: 0.6 }, 147 density: { type: "number", default: 24.0 }, 148 glow: { type: "number", default: 1.2 } 149 }, 150 init: function () { 151 const data = this.data; 152 this.material = new THREE.ShaderMaterial({ 153 uniforms: { 154 time: { value: 0 }, 155 speed: { value: data.speed }, 156 density: { value: data.density }, 157 glow: { value: data.glow } 158 }, 159 vertexShader: ` 160 varying vec2 vUv; 161 varying vec3 vPos; 162 void main() { 163 vUv = uv; 164 vPos = position; 165 gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0
165); 166 } 167 `, 168 fragmentShader: ` 169 precision mediump float; 170 varying vec2 vUv; 171 varying vec3 vPos; 172 uniform float time; 173 uniform float speed; 174 uniform float density; 175 uniform float glow; 176 177 float rand(float n) { 178 return fract(sin(n) * 43758.5453123); 179 } 180 181 void main() { 182 float t = time * speed; 183 float col = floor(vUv.x * density); 184 float seed = rand(col + 1.0); 185 float fall = fract(vUv.y * 6.0 + t + seed * 3.0); 186 float head = smoothstep(0.98, 1.0, fall); 187 float tail = smoothstep(0.2, 0.0, fall); 188 float pulse = 0.35 + 0.65 * sin((vUv.y + t) * 8.0 + col); 189 float intensity = (head + tail * 0.6) * pulse; 190 vec3 base = vec3(0.0, 0.35, 0.05); 191 vec3 bright = vec3(0.2, 1.0, 0.35); 192 vec3 color = mix(base, bright, clamp(intensity * glow, 0.0, 1.0)); 193 gl_FragColor = vec4(color, 1.0); 194 } 195 `, 196 transparent: true 197 }); 198 199 this.meshes = []; 200 this.el.addEventListener("model-loaded", (evt) => { 201 const mesh = evt.detail.model; 202 mesh.traverse((node) => { 203 if (node.isMesh) { 204 node.material = this.material; 205 node.material.needsUpdate = true; 206 this.meshes.push(node); 207 } 208 }); 209 }); 210 }, 211 tick: function (time) { 212 if (this.material) { 213 this.material.uniforms.time.value = time * 0.001; 214 } 215 } 216 });
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.