(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports", "./core/PropertyNode.js", "./core/VarNode.js", "./inputs/ColorNode.js", "./inputs/FloatNode.js", "./inputs/Vector2Node.js", "./inputs/Vector3Node.js", "./inputs/Vector4Node.js", "./accessors/PositionNode.js", "./accessors/NormalNode.js", "./math/OperatorNode.js", "./math/CondNode.js", "./math/MathNode.js", "./utils/ArrayElementNode.js", "./utils/ConvertNode.js", "./utils/JoinNode.js", "./utils/SplitNode.js", "three"], factory); } else if (typeof exports !== "undefined") { factory(exports, require("./core/PropertyNode.js"), require("./core/VarNode.js"), require("./inputs/ColorNode.js"), require("./inputs/FloatNode.js"), require("./inputs/Vector2Node.js"), require("./inputs/Vector3Node.js"), require("./inputs/Vector4Node.js"), require("./accessors/PositionNode.js"), require("./accessors/NormalNode.js"), require("./math/OperatorNode.js"), require("./math/CondNode.js"), require("./math/MathNode.js"), require("./utils/ArrayElementNode.js"), require("./utils/ConvertNode.js"), require("./utils/JoinNode.js"), require("./utils/SplitNode.js"), require("three")); } else { var mod = { exports: {} }; factory(mod.exports, global.PropertyNode, global.VarNode, global.ColorNode, global.FloatNode, global.Vector2Node, global.Vector3Node, global.Vector4Node, global.PositionNode, global.NormalNode, global.OperatorNode, global.CondNode, global.MathNode, global.ArrayElementNode, global.ConvertNode, global.JoinNode, global.SplitNode, global.three); global.ShaderNode = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _PropertyNode, _VarNode, _ColorNode, _FloatNode, _Vector2Node, _Vector3Node, _Vector4Node, _PositionNode, _NormalNode, _OperatorNode, _CondNode, _MathNode, _ArrayElementNode, _ConvertNode, _JoinNode, _SplitNode, _three) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.vec4 = _exports.vec3 = _exports.vec2 = _exports.uniform = _exports.transformedNormalView = _exports.transformDirection = _exports.sub = _exports.sqrt = _exports.specularColor = _exports.sin = _exports.sign = _exports.saturate = _exports.round = _exports.roughness = _exports.pow4 = _exports.pow3 = _exports.pow2 = _exports.pow = _exports.positionWorld = _exports.positionViewDirection = _exports.positionView = _exports.positionLocal = _exports.normalize = _exports.normalWorld = _exports.normalView = _exports.normalLocal = _exports.negate = _exports.mul = _exports.mod = _exports.mix = _exports.min = _exports.metalness = _exports.max = _exports.lessThanEqual = _exports.join = _exports.inversesqrt = _exports.greaterThan = _exports.fract = _exports.floor = _exports.float = _exports.exp2 = _exports.exp = _exports.equal = _exports.element = _exports.dot = _exports.div = _exports.diffuseColor = _exports.dFdy = _exports.dFdx = _exports.cross = _exports.cos = _exports.cond = _exports.color = _exports.assign = _exports.and = _exports.alphaTest = _exports.addTo = _exports.add = _exports.abs = _exports.ShaderNode = _exports.RECIPROCAL_PI2 = _exports.RECIPROCAL_PI = _exports.PI_HALF = _exports.PI2 = _exports.PI = _exports.EPSILON = void 0; _PropertyNode = _interopRequireDefault(_PropertyNode); _VarNode = _interopRequireDefault(_VarNode); _ColorNode = _interopRequireDefault(_ColorNode); _FloatNode = _interopRequireDefault(_FloatNode); _Vector2Node = _interopRequireDefault(_Vector2Node); _Vector3Node = _interopRequireDefault(_Vector3Node); _Vector4Node = _interopRequireDefault(_Vector4Node); _PositionNode = _interopRequireDefault(_PositionNode); _NormalNode = _interopRequireDefault(_NormalNode); _OperatorNode = _interopRequireDefault(_OperatorNode); _CondNode = _interopRequireDefault(_CondNode); _MathNode = _interopRequireDefault(_MathNode); _ArrayElementNode = _interopRequireDefault(_ArrayElementNode); _ConvertNode = _interopRequireDefault(_ConvertNode); _JoinNode = _interopRequireDefault(_JoinNode); _SplitNode = _interopRequireDefault(_SplitNode); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } 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 _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } var NodeHandler = { construct: function construct(NodeClosure, params) { var inputs = params.shift(); return NodeClosure.apply(void 0, [ShaderNodeObjects(inputs)].concat(_toConsumableArray(params))); }, get: function get(node, prop) { if (typeof prop === 'string' && node[prop] === undefined) { if (/^[xyzwrgbastpq]{1,4}$/.test(prop) === true) { // accessing properties ( swizzle ) prop = prop.replace(/r|s/g, 'x').replace(/g|t/g, 'y').replace(/b|p/g, 'z').replace(/a|q/g, 'w'); return ShaderNodeObject(new _SplitNode.default(node, prop)); } else if (/^\d+$/.test(prop) === true) { // accessing array return ShaderNodeObject(new _ArrayElementNode.default(node, new _FloatNode.default(Number(prop)).setConst(true))); } } return node[prop]; } }; var ShaderNodeObject = function ShaderNodeObject(obj) { var type = typeof obj; if (type === 'number') { return ShaderNodeObject(new _FloatNode.default(obj).setConst(true)); } else if (type === 'object') { if (obj.isNode === true) { var node = obj; if (node.isProxyNode !== true) { node.isProxyNode = true; return new Proxy(node, NodeHandler); } } } return obj; }; var ShaderNodeObjects = function ShaderNodeObjects(objects) { for (var name in objects) { objects[name] = ShaderNodeObject(objects[name]); } return objects; }; var ShaderNodeArray = function ShaderNodeArray(array) { var len = array.length; for (var i = 0; i < len; i++) { array[i] = ShaderNodeObject(array[i]); } return array; }; var ShaderNodeProxy = function ShaderNodeProxy(NodeClass) { var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var factor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; if (scope === null) { return function () { for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) { params[_key] = arguments[_key]; } return ShaderNodeObject(_construct(NodeClass, _toConsumableArray(ShaderNodeArray(params)))); }; } else if (factor === null) { return function () { for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { params[_key2] = arguments[_key2]; } return ShaderNodeObject(_construct(NodeClass, [scope].concat(_toConsumableArray(ShaderNodeArray(params))))); }; } else { factor = ShaderNodeObject(factor); return function () { for (var _len3 = arguments.length, params = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { params[_key3] = arguments[_key3]; } return ShaderNodeObject(_construct(NodeClass, [scope].concat(_toConsumableArray(ShaderNodeArray(params)), [factor]))); }; } }; var ShaderNodeScript = function ShaderNodeScript(jsFunc) { return function (inputs, builder) { ShaderNodeObjects(inputs); return ShaderNodeObject(jsFunc(inputs, builder)); }; }; var ShaderNode = new Proxy(ShaderNodeScript, NodeHandler); // // Node Material Shader Syntax // _exports.ShaderNode = ShaderNode; var uniform = new ShaderNode(function (inputNode) { inputNode.setConst(false); return inputNode; }); _exports.uniform = uniform; var float = function float(val) { return ShaderNodeObject(new _FloatNode.default(val).setConst(true)); }; _exports.float = float; var color = function color() { for (var _len4 = arguments.length, params = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { params[_key4] = arguments[_key4]; } return ShaderNodeObject(new _ColorNode.default(_construct(_three.Color, params)).setConst(true)); }; _exports.color = color; var join = function join() { for (var _len5 = arguments.length, params = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { params[_key5] = arguments[_key5]; } return ShaderNodeObject(new _JoinNode.default(ShaderNodeArray(params))); }; _exports.join = join; var cond = function cond() { for (var _len6 = arguments.length, params = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { params[_key6] = arguments[_key6]; } return ShaderNodeObject(_construct(_CondNode.default, _toConsumableArray(ShaderNodeArray(params)))); }; _exports.cond = cond; var vec2 = function vec2() { var _params$; for (var _len7 = arguments.length, params = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { params[_key7] = arguments[_key7]; } if (((_params$ = params[0]) === null || _params$ === void 0 ? void 0 : _params$.isNode) === true) { return ShaderNodeObject(new _ConvertNode.default(params[0], 'vec2')); } else { // Providing one scalar value: This value is used for all components if (params.length === 1) { params[1] = params[0]; } return ShaderNodeObject(new _Vector2Node.default(_construct(_three.Vector2, params)).setConst(true)); } }; _exports.vec2 = vec2; var vec3 = function vec3() { var _params$2; for (var _len8 = arguments.length, params = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { params[_key8] = arguments[_key8]; } if (((_params$2 = params[0]) === null || _params$2 === void 0 ? void 0 : _params$2.isNode) === true) { return ShaderNodeObject(new _ConvertNode.default(params[0], 'vec3')); } else { // Providing one scalar value: This value is used for all components if (params.length === 1) { params[1] = params[2] = params[0]; } return ShaderNodeObject(new _Vector3Node.default(_construct(_three.Vector3, params)).setConst(true)); } }; _exports.vec3 = vec3; var vec4 = function vec4() { var _params$3; for (var _len9 = arguments.length, params = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { params[_key9] = arguments[_key9]; } if (((_params$3 = params[0]) === null || _params$3 === void 0 ? void 0 : _params$3.isNode) === true) { return ShaderNodeObject(new _ConvertNode.default(params[0], 'vec4')); } else { // Providing one scalar value: This value is used for all components if (params.length === 1) { params[1] = params[2] = params[3] = params[0]; } return ShaderNodeObject(new _Vector4Node.default(_construct(_three.Vector4, params)).setConst(true)); } }; _exports.vec4 = vec4; var addTo = function addTo(varNode) { for (var _len10 = arguments.length, params = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) { params[_key10 - 1] = arguments[_key10]; } varNode.node = add.apply(void 0, [varNode.node].concat(_toConsumableArray(ShaderNodeArray(params)))); return ShaderNodeObject(varNode); }; _exports.addTo = addTo; var add = ShaderNodeProxy(_OperatorNode.default, '+'); _exports.add = add; var sub = ShaderNodeProxy(_OperatorNode.default, '-'); _exports.sub = sub; var mul = ShaderNodeProxy(_OperatorNode.default, '*'); _exports.mul = mul; var div = ShaderNodeProxy(_OperatorNode.default, '/'); _exports.div = div; var equal = ShaderNodeProxy(_OperatorNode.default, '=='); _exports.equal = equal; var assign = ShaderNodeProxy(_OperatorNode.default, '='); _exports.assign = assign; var greaterThan = ShaderNodeProxy(_OperatorNode.default, '>'); _exports.greaterThan = greaterThan; var lessThanEqual = ShaderNodeProxy(_OperatorNode.default, '<='); _exports.lessThanEqual = lessThanEqual; var and = ShaderNodeProxy(_OperatorNode.default, '&&'); _exports.and = and; var element = ShaderNodeProxy(_ArrayElementNode.default); _exports.element = element; var normalLocal = new _NormalNode.default(_NormalNode.default.LOCAL); _exports.normalLocal = normalLocal; var normalWorld = new _NormalNode.default(_NormalNode.default.WORLD); _exports.normalWorld = normalWorld; var normalView = new _NormalNode.default(_NormalNode.default.VIEW); _exports.normalView = normalView; var transformedNormalView = new _VarNode.default(new _NormalNode.default(_NormalNode.default.VIEW), 'TransformedNormalView', 'vec3'); _exports.transformedNormalView = transformedNormalView; var positionLocal = new _PositionNode.default(_PositionNode.default.LOCAL); _exports.positionLocal = positionLocal; var positionWorld = new _PositionNode.default(_PositionNode.default.WORLD); _exports.positionWorld = positionWorld; var positionView = new _PositionNode.default(_PositionNode.default.VIEW); _exports.positionView = positionView; var positionViewDirection = new _PositionNode.default(_PositionNode.default.VIEW_DIRECTION); _exports.positionViewDirection = positionViewDirection; var PI = float(3.141592653589793); _exports.PI = PI; var PI2 = float(6.283185307179586); _exports.PI2 = PI2; var PI_HALF = float(1.5707963267948966); _exports.PI_HALF = PI_HALF; var RECIPROCAL_PI = float(0.3183098861837907); _exports.RECIPROCAL_PI = RECIPROCAL_PI; var RECIPROCAL_PI2 = float(0.15915494309189535); _exports.RECIPROCAL_PI2 = RECIPROCAL_PI2; var EPSILON = float(1e-6); _exports.EPSILON = EPSILON; var diffuseColor = new _PropertyNode.default('DiffuseColor', 'vec4'); _exports.diffuseColor = diffuseColor; var roughness = new _PropertyNode.default('Roughness', 'float'); _exports.roughness = roughness; var metalness = new _PropertyNode.default('Metalness', 'float'); _exports.metalness = metalness; var alphaTest = new _PropertyNode.default('AlphaTest', 'float'); _exports.alphaTest = alphaTest; var specularColor = new _PropertyNode.default('SpecularColor', 'color'); _exports.specularColor = specularColor; var abs = ShaderNodeProxy(_MathNode.default, 'abs'); _exports.abs = abs; var negate = ShaderNodeProxy(_MathNode.default, 'negate'); _exports.negate = negate; var floor = ShaderNodeProxy(_MathNode.default, 'floor'); _exports.floor = floor; var mod = ShaderNodeProxy(_MathNode.default, 'mod'); _exports.mod = mod; var cross = ShaderNodeProxy(_MathNode.default, 'cross'); _exports.cross = cross; var fract = ShaderNodeProxy(_MathNode.default, 'fract'); _exports.fract = fract; var round = ShaderNodeProxy(_MathNode.default, 'round'); _exports.round = round; var max = ShaderNodeProxy(_MathNode.default, 'max'); _exports.max = max; var min = ShaderNodeProxy(_MathNode.default, 'min'); _exports.min = min; var sin = ShaderNodeProxy(_MathNode.default, 'sin'); _exports.sin = sin; var cos = ShaderNodeProxy(_MathNode.default, 'cos'); _exports.cos = cos; var dot = ShaderNodeProxy(_MathNode.default, 'dot'); _exports.dot = dot; var normalize = ShaderNodeProxy(_MathNode.default, 'normalize'); _exports.normalize = normalize; var sqrt = ShaderNodeProxy(_MathNode.default, 'sqrt'); _exports.sqrt = sqrt; var inversesqrt = ShaderNodeProxy(_MathNode.default, 'inversesqrt'); _exports.inversesqrt = inversesqrt; var sign = ShaderNodeProxy(_MathNode.default, 'sign'); _exports.sign = sign; var dFdx = ShaderNodeProxy(_MathNode.default, 'dFdx'); _exports.dFdx = dFdx; var dFdy = ShaderNodeProxy(_MathNode.default, 'dFdy'); _exports.dFdy = dFdy; var pow = ShaderNodeProxy(_MathNode.default, 'pow'); _exports.pow = pow; var pow2 = ShaderNodeProxy(_MathNode.default, 'pow', 2); _exports.pow2 = pow2; var pow3 = ShaderNodeProxy(_MathNode.default, 'pow', 3); _exports.pow3 = pow3; var pow4 = ShaderNodeProxy(_MathNode.default, 'pow', 4); _exports.pow4 = pow4; var exp = ShaderNodeProxy(_MathNode.default, 'exp'); _exports.exp = exp; var exp2 = ShaderNodeProxy(_MathNode.default, 'exp2'); _exports.exp2 = exp2; var mix = ShaderNodeProxy(_MathNode.default, 'mix'); _exports.mix = mix; var saturate = ShaderNodeProxy(_MathNode.default, 'saturate'); _exports.saturate = saturate; var transformDirection = ShaderNodeProxy(_MathNode.default, 'transformDirection'); _exports.transformDirection = transformDirection; });