Source: infra-sk/dist/uniform-mouse-sk-bundle.js

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./modules/uniform-mouse-sk/uniform-mouse-sk-demo.ts");
/******/ })
/************************************************************************/
/******/ ({

/***/ "../node_modules/common-sk/modules/dom.js":
/*!************************************************!*\
  !*** ../node_modules/common-sk/modules/dom.js ***!
  \************************************************/
/*! exports provided: DomReady, $, $$, findParent, findParentSafe */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomReady", function() { return DomReady; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$", function() { return $; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$$", function() { return $$; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findParent", function() { return findParent; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findParentSafe", function() { return findParentSafe; });
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/** @module common-sk/modules/dom */
/**
 * A Promise that resolves when DOMContentLoaded has fired.
 */
const DomReady = new Promise((resolve) => {
    if (document.readyState !== 'loading') {
        // If readyState is already past loading then
        // DOMContentLoaded has already fired, so just resolve.
        resolve();
    }
    else {
        document.addEventListener('DOMContentLoaded', resolve);
    }
});
/** @function $
 *
 * @description Returns a real JS array of DOM elements that match the CSS selector.
 *
 * @param query CSS selector string.
 * @param ele The Element to start the search from.
 * @returns Array of DOM Elements that match the CSS selector.
 *
 */
function $(query, ele = document) {
    return Array.from(ele.querySelectorAll(query));
}
/** @function $$
 *
 * @description Returns the first DOM element that matches the CSS query selector.
 *
 * @param query CSS selector string.
 * @param ele The Element to start the search from.
 * @returns The first Element in DOM order that matches the CSS selector.
 */
function $$(query, ele = document) {
    return ele.querySelector(query);
}
/**
 * Find the first parent of 'ele' with the given 'nodeName'.
 *
 * @param ele - The element to start searching a.
 * @param nodeName - The node name we are looking for.
 * @returns Either 'ele' or the first parent of 'ele' that has the nodeName of 'nodeName'. Returns null if none are found.
 *
 * @example
 *
 *   findParent(ele, 'DIV')
 *
 */
function findParent(ele, nodeName) {
    while (ele !== null) {
        if (ele.nodeName === nodeName) {
            return ele;
        }
        ele = ele.parentElement;
    }
    return null;
}
/**
 * Find the first parent of 'ele' with the given 'nodeName'. Just like findParent, but TypeScript typesafe.
 *
 * @param ele - The element to start searching a.
 * @param nodeName - The lower-case node name we are looking for, e.g. 'div'.
 * @returns Either 'ele' or the first parent of 'ele' that has the nodeName of 'nodeName'. Returns null if none are found.
 *
 * @example
 *
 *   findParentSafe(ele, 'div')
 *
 */
function findParentSafe(ele, nodeName) {
    while (ele !== null) {
        if (ele.nodeName.toLowerCase() === nodeName) {
            return ele;
        }
        ele = ele.parentElement;
    }
    return null;
}
//# sourceMappingURL=dom.js.map

/***/ }),

/***/ "../node_modules/elements-sk/define.js":
/*!*********************************************!*\
  !*** ../node_modules/elements-sk/define.js ***!
  \*********************************************/
/*! exports provided: define */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "define", function() { return define; });
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/** @module elements-sk/define */
/**
 * Define a custom element definition. It will only define a tag name once
 * and will log an error if there's an attempt to define a tag name a second
 * time. This is useful for tests since you can't undefine a custom element.
 *
 * See also https://github.com/karma-runner/karma/issues/412
 *
 * @param tagName - The name of the tag.
 * @param cl - The class for the given tag.
 *
 * @example
 *
 * Instead of:
 *
 *     window.customElements.define('my-element', class extends HTMLElement {...});
 *
 * Use:
 *
 *     import { define } from 'elements-sk/define'
 *     define('my-element', class extends HTMLElement {...});
 *
 */
function define(tagName, cl) {
    if (window.customElements.get(tagName) === undefined) {
        window.customElements.define(tagName, cl);
    }
    else {
        console.log(`Multiple registration attempts for ${tagName}. ` +
            'This should only happen during testing, ' +
            'it\'s probably an error outside of testing.');
    }
}
//# sourceMappingURL=define.js.map

/***/ }),

/***/ "./modules/uniform-mouse-sk/index.ts":
/*!*******************************************!*\
  !*** ./modules/uniform-mouse-sk/index.ts ***!
  \*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__webpack_require__(/*! ./uniform-mouse-sk */ "./modules/uniform-mouse-sk/uniform-mouse-sk.ts");
__webpack_require__(/*! ./uniform-mouse-sk.scss */ "./modules/uniform-mouse-sk/uniform-mouse-sk.scss");


/***/ }),

/***/ "./modules/uniform-mouse-sk/uniform-mouse-sk-demo.ts":
/*!***********************************************************!*\
  !*** ./modules/uniform-mouse-sk/uniform-mouse-sk-demo.ts ***!
  \***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const dom_1 = __webpack_require__(/*! common-sk/modules/dom */ "../node_modules/common-sk/modules/dom.js");
__webpack_require__(/*! ./index */ "./modules/uniform-mouse-sk/index.ts");
const mouseUniformControl = dom_1.$$('uniform-mouse-sk');
mouseUniformControl.elementToMonitor = dom_1.$$('canvas');
const applyUniformValues = () => {
    const uniforms = [0, 0, 0, 0];
    dom_1.$('uniform-mouse-sk').forEach((ele) => {
        ele.applyUniformValues(uniforms);
    });
    dom_1.$$('#results').innerText = uniforms.toString();
};
dom_1.$$('canvas').addEventListener('mousemove', applyUniformValues);
dom_1.$$('canvas').addEventListener('mousedown', applyUniformValues);
dom_1.$$('canvas').addEventListener('mouseup', applyUniformValues);
dom_1.$$('canvas').addEventListener('click', applyUniformValues);


/***/ }),

/***/ "./modules/uniform-mouse-sk/uniform-mouse-sk.scss":
/*!********************************************************!*\
  !*** ./modules/uniform-mouse-sk/uniform-mouse-sk.scss ***!
  \********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),

/***/ "./modules/uniform-mouse-sk/uniform-mouse-sk.ts":
/*!******************************************************!*\
  !*** ./modules/uniform-mouse-sk/uniform-mouse-sk.ts ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.UniformMouseSk = void 0;
/**
 * @module modules/uniform-mouse-sk
 * @description <h2><code>uniform-mouse-sk</code></h2>
 *
 * Control to handle mouse position and clicks as a uniform.
 *
 * Note this control doesn't display anything.
 *
 * See https://www.shadertoy.com/view/Mss3zH for an explanation of how the
 * iMouse uniform behaves.
 */
const define_1 = __webpack_require__(/*! elements-sk/define */ "../node_modules/elements-sk/define.js");
const defaultUniform = {
    name: 'iMouse',
    rows: 4,
    columns: 1,
    slot: 0,
};
class UniformMouseSk extends HTMLElement {
    constructor() {
        super(...arguments);
        this._uniform = defaultUniform;
        this._elementToMonitor = null;
        this.location = [0, 0];
        this.lastClick = [1, 1];
        this.mouseDown = false;
        this.mouseClick = false;
    }
    applyUniformValues(uniforms) {
        uniforms[this._uniform.slot] = this.location[0];
        uniforms[this._uniform.slot + 1] = this.location[1];
        uniforms[this._uniform.slot + 2] = Math.abs(this.lastClick[0]) * (this.mouseDown ? 1 : -1);
        uniforms[this._uniform.slot + 3] = Math.abs(this.lastClick[1]) * (this.mouseClick ? 1 : -1);
    }
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    restoreUniformValues(uniforms) {
        // This is a noop, we don't restore predefined uniform values.
    }
    onRAF() {
        // noop.
    }
    needsRAF() {
        return false;
    }
    get elementToMonitor() {
        return this._elementToMonitor;
    }
    set elementToMonitor(val) {
        if (this.elementToMonitor === val) {
            return;
        }
        if (this.elementToMonitor) {
            this._elementToMonitor.removeEventListener('mouseup', this.mouseUpHandler.bind(this));
            this._elementToMonitor.removeEventListener('mousedown', this.mouseDownHandler.bind(this));
            this._elementToMonitor.removeEventListener('mousemove', this.mouseMoveHandler.bind(this));
            this._elementToMonitor.removeEventListener('click', this.clickHandler.bind(this));
        }
        this._elementToMonitor = val;
        this._elementToMonitor.addEventListener('mouseup', this.mouseUpHandler.bind(this));
        this._elementToMonitor.addEventListener('mousedown', this.mouseDownHandler.bind(this));
        this._elementToMonitor.addEventListener('mousemove', this.mouseMoveHandler.bind(this));
        this._elementToMonitor.addEventListener('click', this.clickHandler.bind(this));
    }
    mouseUpHandler(e) {
        this.mouseDown = false;
        this.location = [e.offsetX, e.offsetY];
    }
    mouseDownHandler(e) {
        this.mouseDown = true;
        this.location = [e.offsetX, e.offsetY];
    }
    mouseMoveHandler(e) {
        if (this.mouseDown) {
            this.location = [e.offsetX, e.offsetY];
        }
    }
    clickHandler(e) {
        this.lastClick = [e.offsetX, e.offsetY];
        this.mouseClick = true;
    }
    get uniform() {
        return this._uniform;
    }
    set uniform(val) {
        if (val.columns !== 4 || val.rows !== 1) {
            throw new Error('The mouse uniform must be a float4.');
        }
        this._uniform = val;
    }
}
exports.UniformMouseSk = UniformMouseSk;
define_1.define('uniform-mouse-sk', UniformMouseSk);


/***/ })

/******/ });
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4uL25vZGVfbW9kdWxlcy9jb21tb24tc2svbW9kdWxlcy9kb20uanMiLCJ3ZWJwYWNrOi8vLy4uL25vZGVfbW9kdWxlcy9lbGVtZW50cy1zay9kZWZpbmUuanMiLCJ3ZWJwYWNrOi8vLy4vbW9kdWxlcy91bmlmb3JtLW1vdXNlLXNrL2luZGV4LnRzIiwid2VicGFjazovLy8uL21vZHVsZXMvdW5pZm9ybS1tb3VzZS1zay91bmlmb3JtLW1vdXNlLXNrLWRlbW8udHMiLCJ3ZWJwYWNrOi8vLy4vbW9kdWxlcy91bmlmb3JtLW1vdXNlLXNrL3VuaWZvcm0tbW91c2Utc2suc2NzcyIsIndlYnBhY2s6Ly8vLi9tb2R1bGVzL3VuaWZvcm0tbW91c2Utc2svdW5pZm9ybS1tb3VzZS1zay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO1FBQUE7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBOztRQUVBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO1FBQ0E7OztRQUdBO1FBQ0E7O1FBRUE7UUFDQTs7UUFFQTtRQUNBO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