-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaframe-liquid-portal-shader.js
262 lines (218 loc) · 19.1 KB
/
aframe-liquid-portal-shader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["aframeLiquidPortalShader"] = factory();
else
root["aframeLiquidPortalShader"] = factory();
})(self, function() {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./src/liquid-portal-mouse.js":
/*!************************************!*\
!*** ./src/liquid-portal-mouse.js ***!
\************************************/
/***/ (() => {
AFRAME.registerComponent("liquid-portal-mouse", {
schema: {
moveFrac: { type: "number", default: 0.1 },
decayTime: { type: "number", default: 0.5 },
},
init: function () {
this.mouseCoords = { x: 0, y: 0 };
this.mouseMoveHandler = (evt) => {
this.mouseCoords.x = (evt.clientX / window.innerWidth) * 2 - 1;
this.mouseCoords.y = -(evt.clientY / window.innerHeight) * 2 + 1;
};
this.raycaster = new THREE.Raycaster();
this.targetCenter = new THREE.Vector2(0.5, 0.5);
this.currentCenter = new THREE.Vector2(0.5, 0.5);
this.effectStrength = 0.0;
},
play: function () {
window.addEventListener("mousemove", this.mouseMoveHandler, false);
},
pause: function () {
window.removeEventListener("mousemove", this.mouseMoveHandler, false);
},
tick: function (time, timeDelta) {
this.raycaster.setFromCamera(this.mouseCoords, this.el.sceneEl.camera);
let intersections = this.raycaster.intersectObject(
this.el.getObject3D("mesh")
);
if (intersections.length > 0) {
let mouseUV = intersections[0].uv;
this.targetCenter.set(mouseUV.x, mouseUV.y);
}
this.effectStrength += this.targetCenter.distanceTo(this.currentCenter);
this.effectStrength -= timeDelta / 1000 / this.data.decayTime;
this.effectStrength = Math.max(0.0, Math.min(this.effectStrength, 1.0));
this.currentCenter.lerp(this.targetCenter, this.data.moveFrac);
this.el.setAttribute("material", {
rippleCenter: this.currentCenter,
strength: this.effectStrength,
timeMsec: time,
});
},
});
/***/ }),
/***/ "./src/liquid-portal-shader.js":
/*!*************************************!*\
!*** ./src/liquid-portal-shader.js ***!
\*************************************/
/***/ (() => {
/**
* This string template literal does not modify the input string, but allows us
* to tag some strings as glsl snippets so that editors (e.g., VSCode) can
* syntax higlight them.
*/
function glsl(strs) {
return strs[0];
}
AFRAME.registerShader("liquid-portal", {
schema: {
timeMsec: { type: "time", is: "uniform" },
src: { type: "map", is: "uniform" },
rippleCenter: { type: "vec2", is: "uniform", default: { x: 0.5, y: 0.5 } },
numRipples: { type: "float", is: "uniform", default: 5 },
maxRippleOffset: { type: "float", is: "uniform", default: 0.01 },
rippleSpeed: { type: "float", is: "uniform", default: 0.1 },
twistRadius: { type: "float", is: "uniform", default: 0.25 },
maxTwist: { type: "float", is: "uniform", default: 1.0 },
strength: { type: "float", is: "uniform", default: 1.0 },
},
vertexShader: glsl`
precision highp float;
out vec2 v_uv;
void main() {
v_uv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: glsl`
precision highp float;
float PI = 3.14159;
uniform sampler2D src;
uniform float timeMsec;
uniform vec2 rippleCenter;
uniform float numRipples;
uniform float maxRippleOffset;
uniform float rippleSpeed;
uniform float twistRadius;
uniform float maxTwist;
uniform float strength;
in vec2 v_uv;
// --- Polar Coordinates --- //
vec2 toPolar(vec2 center, vec2 uv) {
vec2 offset = uv - center;
return vec2(atan(offset.x, offset.y), length(offset));
}
vec2 fromPolar(vec2 center, vec2 pc) {
float angle = pc[0];
float radius = pc[1];
return vec2(center.x + sin(angle) * radius, center.y + cos(angle) * radius);
}
// --- Main --- //
void main() {
vec2 pc = toPolar(rippleCenter, v_uv);
float r_offset = strength * maxRippleOffset * sin((pc[1] - timeMsec / 1000.0 * rippleSpeed) * 4.0 * PI * numRipples);
float tr = strength * twistRadius;
float mt = strength * maxTwist;
float a_offset = pc[1] < tr ? mix(0.0, mt * 2.0 * PI, tr - pc[1]) : 0.0;
pc[0] += a_offset;
pc[1] += r_offset;
vec2 uv = fromPolar(rippleCenter, pc);
vec4 color_rgba = texture2D(src, uv);
gl_FragColor = color_rgba;
}
`,
});
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _liquid_portal_shader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./liquid-portal-shader */ "./src/liquid-portal-shader.js");
/* harmony import */ var _liquid_portal_shader__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_liquid_portal_shader__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _liquid_portal_mouse__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./liquid-portal-mouse */ "./src/liquid-portal-mouse.js");
/* harmony import */ var _liquid_portal_mouse__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_liquid_portal_mouse__WEBPACK_IMPORTED_MODULE_1__);
})();
/******/ return __webpack_exports__;
/******/ })()
;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9hZnJhbWVMaXF1aWRQb3J0YWxTaGFkZXIvd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovL2FmcmFtZUxpcXVpZFBvcnRhbFNoYWRlci8uL3NyYy9saXF1aWQtcG9ydGFsLW1vdXNlLmpzIiwid2VicGFjazovL2FmcmFtZUxpcXVpZFBvcnRhbFNoYWRlci8uL3NyYy9saXF1aWQtcG9ydGFsLXNoYWRlci5qcyIsIndlYnBhY2s6Ly9hZnJhbWVMaXF1aWRQb3J0YWxTaGFkZXIvd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vYWZyYW1lTGlxdWlkUG9ydGFsU2hhZGVyL3dlYnBhY2svcnVudGltZS9jb21wYXQgZ2V0IGRlZmF1bHQgZXhwb3J0Iiwid2VicGFjazovL2FmcmFtZUxpcXVpZFBvcnRhbFNoYWRlci93ZWJwYWNrL3J1bnRpbWUvZGVmaW5lIHByb3BlcnR5IGdldHRlcnMiLCJ3ZWJwYWNrOi8vYWZyYW1lTGlxdWlkUG9ydGFsU2hhZGVyL3dlYnBhY2svcnVudGltZS9oYXNPd25Qcm9wZXJ0eSBzaG9ydGhhbmQiLCJ3ZWJwYWNrOi8vYWZyYW1lTGlxdWlkUG9ydGFsU2hhZGVyL3dlYnBhY2svcnVudGltZS9tYWtlIG5hbWVzcGFjZSBvYmplY3QiLCJ3ZWJwYWNrOi8vYWZyYW1lTGlxdWlkUG9ydGFsU2hhZGVyLy4vc3JjL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLENBQU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