(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports", "../core/Node.js", "../inputs/FloatNode.js", "../accessors/UVNode.js", "../math/MathNode.js", "../math/OperatorNode.js", "../utils/SplitNode.js", "../utils/JoinNode.js"], factory); } else if (typeof exports !== "undefined") { factory(exports, require("../core/Node.js"), require("../inputs/FloatNode.js"), require("../accessors/UVNode.js"), require("../math/MathNode.js"), require("../math/OperatorNode.js"), require("../utils/SplitNode.js"), require("../utils/JoinNode.js")); } else { var mod = { exports: {} }; factory(mod.exports, global.Node, global.FloatNode, global.UVNode, global.MathNode, global.OperatorNode, global.SplitNode, global.JoinNode); global.SpriteSheetUVNode = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _Node2, _FloatNode, _UVNode, _MathNode, _OperatorNode, _SplitNode, _JoinNode) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.default = void 0; _Node2 = _interopRequireDefault(_Node2); _FloatNode = _interopRequireDefault(_FloatNode); _UVNode = _interopRequireDefault(_UVNode); _MathNode = _interopRequireDefault(_MathNode); _OperatorNode = _interopRequireDefault(_OperatorNode); _SplitNode = _interopRequireDefault(_SplitNode); _JoinNode = _interopRequireDefault(_JoinNode); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var SpriteSheetUVNode = /*#__PURE__*/function (_Node) { _inherits(SpriteSheetUVNode, _Node); var _super = _createSuper(SpriteSheetUVNode); function SpriteSheetUVNode(countNode) { var _this; var uvNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _UVNode.default(); var frameNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _FloatNode.default(0).setConst(true); _classCallCheck(this, SpriteSheetUVNode); _this = _super.call(this, 'vec2'); _this.countNode = countNode; _this.uvNode = uvNode; _this.frameNode = frameNode; return _this; } _createClass(SpriteSheetUVNode, [{ key: "generate", value: function generate(builder) { var count = this.countNode; var uv = this.uvNode; var frame = this.frameNode; var one = new _FloatNode.default(1).setConst(true); var width = new _SplitNode.default(count, 'x'); var height = new _SplitNode.default(count, 'y'); var total = new _OperatorNode.default('*', width, height); var roundFrame = new _MathNode.default(_MathNode.default.FLOOR, new _MathNode.default(_MathNode.default.MOD, frame, total)); var frameNum = new _OperatorNode.default('+', roundFrame, one); var cell = new _MathNode.default(_MathNode.default.MOD, roundFrame, width); var row = new _MathNode.default(_MathNode.default.CEIL, new _OperatorNode.default('/', frameNum, width)); var rowInv = new _OperatorNode.default('-', height, row); var scale = new _OperatorNode.default('/', one, count); var uvFrameOffset = new _JoinNode.default([new _OperatorNode.default('*', cell, new _SplitNode.default(scale, 'x')), new _OperatorNode.default('*', rowInv, new _SplitNode.default(scale, 'y'))]); var uvScale = new _OperatorNode.default('*', uv, scale); var uvFrame = new _OperatorNode.default('+', uvScale, uvFrameOffset); return uvFrame.build(builder, this.getNodeType(builder)); } }]); return SpriteSheetUVNode; }(_Node2.default); var _default = SpriteSheetUVNode; _exports.default = _default; });