PageSourceSearch

https://pupwife.com/scripts/followers/jellypuff/medusaeUtils.js

js pupwife.com collected 2026-09-30 15:05:27 UTC 4,672 bytes, 183 lines download raw bytes

1/**
2 * Geometry / link / face helpers ported from particulate-medusae (Artistic-2.0).
3 */
4(function (global) {
5    'use strict';
6
7    var Geometry = {};
8    var Links = {};
9    var Faces = {};
10
11    Geometry.point = function (x, y, z, buffer) {
12        buffer.push(x, y, z);
13        return buffer;
14    };
15
16    Geometry.circle = function (segments, radius, y, buffer) {
17        var step = Math.PI * 2 / segments;
18        var angle = 0;
19        var x;
20        var z;
21        var i;
22        for (i = 0; i < segments; i++) {
23            x = Math.cos(angle) * radius;
24            z = Math.sin(angle) * radius;
25            buffer.push(x, y, z);
26            angle += step;
27        }
28        return buffer;
29    };
30
31    Links.line = function (index, howMany, buffer) {
32        var a;
33        var b;
34        var i;
35        for (i = 0; i < howMany - 1; i++) {
36            a = index + i;
37            b = index + i + 1;
38            buffer.push(a, b);
39        }
40        return buffer;
41    };
42
43    Links.loop = function (index, howMany, buffer) {
44        var a;
45        var b;
46        var i;
47        for (i = 0; i < howMany - 1; i++) {
48            a = index + i;
49            b = index + i + 1;
50            buffer.push(a, b);
51        }
52        a = index;
53        b = index + howMany - 1;
54        buffer.push(a, b);
55        return buffer;
56    };
57
58    Links.rings = function (index0, index1, howMany, buffer) {
59        var a;
60        var b;
61        var i;
62        for (i = 0; i < howMany; i++) {
63            a = index0 + i;
64            b = index1 + i;
65            buffer.push(a, b);
66        }
67        return buffer;
68    };
69
70    Links.radial = function (indexCenter, index, howMany, buffer) {
71        var b;
72        var i;
73        for (i = 0; i < howMany; i++) {
74            b = index + i;
75            buffer.push(indexCenter, b);
76        }
77        return buffer;
78    };
79
80    Faces.quad = function (a, b, c, d, buffer) {
81        buffer.push(a, b, c, c, d, a);
82        return buffer;
83    };
84
85    Faces.quadDoubleSide = function (a, b, c, d, buffer) {
86        buffer.push(
87            a, b, c,
88            c, d, a,
89            d, c, b,
90            b, a, d
91        );
92        return buffer;
93    };
94
95    Faces.radial = function (indexCenter, index, howMany, buffer) {
96        var b;
97        var c;
98        var i;
99        var il;
100        for (i = 0, il = howMany - 1; i < il; i++) {
101            b = index + i + 1;
102            c = index + i;
103            buffer.push(indexCenter, b, c);
104        }
105        b = index;
106        c = index + howMany - 1;
107        buffer.push(indexCenter, b, c);
108        return buffer;
109    };
110
111    Faces.rings = function (index0, index1, howMany, buffer) {
112        var a;
113        var b;
114        var c;
115        var d;
116        var i;
117        var il;
118        for (i = 0, il = howMany - 1; i < il; i++) {
119            a = index0 + i;
120            b = index0 + i + 1;
121            c = index1 + i + 1;
122            d = index1 + i;
123            buffer.push(a, b, c, c, d, a);
124        }
125        a = index0 + howMany - 1;
126        b = index0;
127        c = index1;
128        d = index1 + howMany - 1;
129        buffer.push(a, b, c, c, d, a);
130        return buffer;
131    };
132
133    function Looper(context, update, render, delta) {
134        var stepTime = 0;
135        var targetDelta = delta || (1 / 30 * 1000);
136        var maxDelta = targetDelta;
137        var isLooping = false;
138        var lastTime;
139        var self = this;
140
141        function animateStep(frameDelta) {
142            stepTime += frameDelta;
143            var steps = Math.floor(stepTime / targetDelta);
144            if (steps > 0) {
145                stepTime -= steps * targetDelta;
146                self.didUpdate = true;
147            }
148            while (steps > 0) {
149                context[update].call(context, targetDelta);
150                steps--;
151            }
152            var stepProgress = stepTime / targetDelta;
153            context[render].call(context, frameDelta, stepProgress);
154        }
155
156        function animate() {
157            if (!isLooping) return;
158            var time = Date.now();
159            var frameDelta = Math.min(maxDelta, time - lastTime);
160            self.didUpdate = false;
161            animateStep(frameDelta);
162            global.requestAnimationFrame(animate);
163            lastTime = time;
164        }
165
166        this.stop = function () {
167            isLooping = false;
168        };
169
170        this.start = function () {
171            lastTime = Date.now();
172            isLooping = true;
173            animate();
174        };
175    }
176
177    global.JellypuffMedusaeUtils = {
178        Geometry: Geometry,
179        Links: Links,
180        Faces: Faces,
181        Looper: Looper
182    };
183})(typeof window !== 'undefined' ? window : this);

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.