(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports", "../core/TempNode.js", "../core/FunctionNode.js", "../core/FunctionCallNode.js", "../inputs/FloatNode.js", "../accessors/PositionNode.js", "./Noise2DNode.js"], factory); } else if (typeof exports !== "undefined") { factory(exports, require("../core/TempNode.js"), require("../core/FunctionNode.js"), require("../core/FunctionCallNode.js"), require("../inputs/FloatNode.js"), require("../accessors/PositionNode.js"), require("./Noise2DNode.js")); } else { var mod = { exports: {} }; factory(mod.exports, global.TempNode, global.FunctionNode, global.FunctionCallNode, global.FloatNode, global.PositionNode, global.Noise2DNode); global.Noise3DNode = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _TempNode2, _FunctionNode, _FunctionCallNode, _FloatNode, _PositionNode, _Noise2DNode) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.Noise3DNode = void 0; 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 _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } 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 NOISE3D_SRC = "\nfloat noise3d( vec3 P, float amplitude, float pivot ) {\n\n\tvec3 Pi0 = floor(P); // Integer part for indexing\n\tvec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n\tPi0 = mod289(Pi0);\n\tPi1 = mod289(Pi1);\n\tvec3 Pf0 = fract(P); // Fractional part for interpolation\n\tvec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n\tvec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n\tvec4 iy = vec4(Pi0.yy, Pi1.yy);\n\tvec4 iz0 = Pi0.zzzz;\n\tvec4 iz1 = Pi1.zzzz;\n\n\tvec4 ixy = permute(permute(ix) + iy);\n\tvec4 ixy0 = permute(ixy + iz0);\n\tvec4 ixy1 = permute(ixy + iz1);\n\n\tvec4 gx0 = ixy0 * (1.0 / 7.0);\n\tvec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n\tgx0 = fract(gx0);\n\tvec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n\tvec4 sz0 = step(gz0, vec4(0.0));\n\tgx0 -= sz0 * (step(0.0, gx0) - 0.5);\n\tgy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n\tvec4 gx1 = ixy1 * (1.0 / 7.0);\n\tvec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n\tgx1 = fract(gx1);\n\tvec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n\tvec4 sz1 = step(gz1, vec4(0.0));\n\tgx1 -= sz1 * (step(0.0, gx1) - 0.5);\n\tgy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n\tvec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n\tvec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n\tvec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n\tvec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n\tvec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n\tvec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n\tvec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n\tvec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n\tvec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n\tg000 *= norm0.x;\n\tg010 *= norm0.y;\n\tg100 *= norm0.z;\n\tg110 *= norm0.w;\n\tvec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n\tg001 *= norm1.x;\n\tg011 *= norm1.y;\n\tg101 *= norm1.z;\n\tg111 *= norm1.w;\n\n\tfloat n000 = dot(g000, Pf0);\n\tfloat n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n\tfloat n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n\tfloat n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n\tfloat n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n\tfloat n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n\tfloat n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n\tfloat n111 = dot(g111, Pf1);\n\n\tvec3 fade_xyz = fade(Pf0);\n\tvec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n\tvec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n\tfloat n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n\treturn 2.2 * n_xyz * amplitude + pivot;\n\n}\n".trim(); var Noise3DNode = /*#__PURE__*/function (_TempNode) { _inherits(Noise3DNode, _TempNode); var _super = _createSuper(Noise3DNode); function Noise3DNode() { var _this; var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _PositionNode.PositionNode(); var amplitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _FloatNode.FloatNode(1.0); var pivot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new _FloatNode.FloatNode(0.0); _classCallCheck(this, Noise3DNode); _this = _super.call(this, 'f'); _this.position = position; _this.amplitude = amplitude; _this.pivot = pivot; return _this; } _createClass(Noise3DNode, [{ key: "generate", value: function generate(builder, output) { var noise3d = new _FunctionCallNode.FunctionCallNode(Noise3DNode.Nodes.noise3d, [this.position, this.amplitude, this.pivot]); return builder.format(noise3d.generate(builder, output), this.getType(builder), output); } }, { key: "copy", value: function copy(source) { _get(_getPrototypeOf(Noise3DNode.prototype), "copy", this).call(this, source); this.position = source.position; this.amplitude = source.amplitude; this.pivot = source.pivot; } }, { key: "toJSON", value: function toJSON(meta) { var data = this.getJSONNode(meta); if (!data) { data = this.createJSONNode(meta); data.position = this.position.toJSON(meta).uuid; data.amplitude = this.amplitude.toJSON(meta).uuid; data.pivot = this.pivot.toJSON(meta).uuid; } return data; } }]); return Noise3DNode; }(_TempNode2.TempNode); _exports.Noise3DNode = Noise3DNode; Noise3DNode.prototype.nodeType = 'Noise3D'; Noise3DNode.Nodes = function () { var noise3d = new _FunctionNode.FunctionNode(NOISE3D_SRC); noise3d.includes = [_Noise2DNode.Noise2DNode.Nodes.noiseCommon]; return { noise3d: noise3d }; }(); });