db4568fe5a60a47d4175156df1d37b1e97604e6053c38acd37591c8b32cf823b.json 12 KB

1
  1. {"ast":null,"code":"import { Logger } from \"../Misc/logger.js\";\nimport { Vector3 } from \"./math.vector.js\";\n/**\n * Class representing an isovector a vector containing 2 INTEGER coordinates\n * x axis is horizontal\n * y axis is 60 deg counter clockwise from positive y axis\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _IsoVector {\n /**\n * Creates a new isovector from the given x and y coordinates\n * @param x defines the first coordinate, must be an integer\n * @param y defines the second coordinate, must be an integer\n */\n constructor( /** [0] defines the first coordinate */\n x = 0, /** [0] defines the second coordinate */\n y = 0) {\n this.x = x;\n this.y = y;\n if (x !== Math.floor(x)) {\n x = Math.floor(x);\n Logger.Warn(\"x is not an integer, floor(x) used\");\n }\n if (y !== Math.floor(y)) {\n y = Math.floor(y);\n Logger.Warn(\"y is not an integer, floor(y) used\");\n }\n }\n // Operators\n /**\n * Gets a new IsoVector copied from the IsoVector\n * @returns a new IsoVector\n */\n clone() {\n return new _IsoVector(this.x, this.y);\n }\n /**\n * Rotates one IsoVector 60 degrees counter clockwise about another\n * Please note that this is an in place operation\n * @param other an IsoVector a center of rotation\n * @returns the rotated IsoVector\n */\n rotate60About(other) {\n //other IsoVector\n const x = this.x;\n this.x = other.x + other.y - this.y;\n this.y = x + this.y - other.x;\n return this;\n }\n /**\n * Rotates one IsoVector 60 degrees clockwise about another\n * Please note that this is an in place operation\n * @param other an IsoVector as center of rotation\n * @returns the rotated IsoVector\n */\n rotateNeg60About(other) {\n const x = this.x;\n this.x = x + this.y - other.y;\n this.y = other.x + other.y - x;\n return this;\n }\n /**\n * For an equilateral triangle OAB with O at isovector (0, 0) and A at isovector (m, n)\n * Rotates one IsoVector 120 degrees counter clockwise about the center of the triangle\n * Please note that this is an in place operation\n * @param m integer a measure a Primary triangle of order (m, n) m > n\n * @param n >= 0 integer a measure for a Primary triangle of order (m, n)\n * @returns the rotated IsoVector\n */\n rotate120(m, n) {\n //m, n integers\n if (m !== Math.floor(m)) {\n m = Math.floor(m);\n Logger.Warn(\"m not an integer only floor(m) used\");\n }\n if (n !== Math.floor(n)) {\n n = Math.floor(n);\n Logger.Warn(\"n not an integer only floor(n) used\");\n }\n const x = this.x;\n this.x = m - x - this.y;\n this.y = n + x;\n return this;\n }\n /**\n * For an equilateral triangle OAB with O at isovector (0, 0) and A at isovector (m, n)\n * Rotates one IsoVector 120 degrees clockwise about the center of the triangle\n * Please note that this is an in place operation\n * @param m integer a measure a Primary triangle of order (m, n) m > n\n * @param n >= 0 integer a measure for a Primary triangle of order (m, n)\n * @returns the rotated IsoVector\n */\n rotateNeg120(m, n) {\n //m, n integers\n if (m !== Math.floor(m)) {\n m = Math.floor(m);\n Logger.Warn(\"m is not an integer, floor(m) used\");\n }\n if (n !== Math.floor(n)) {\n n = Math.floor(n);\n Logger.Warn(\"n is not an integer, floor(n) used\");\n }\n const x = this.x;\n this.x = this.y - n;\n this.y = m + n - x - this.y;\n return this;\n }\n /**\n * Transforms an IsoVector to one in Cartesian 3D space based on an isovector\n * @param origin an IsoVector\n * @param isoGridSize\n * @returns Point as a Vector3\n */\n toCartesianOrigin(origin, isoGridSize) {\n const point = Vector3.Zero();\n point.x = origin.x + 2 * this.x * isoGridSize + this.y * isoGridSize;\n point.y = origin.y + Math.sqrt(3) * this.y * isoGridSize;\n return point;\n }\n // Statics\n /**\n * Gets a new IsoVector(0, 0)\n * @returns a new IsoVector\n */\n static Zero() {\n return new _IsoVector(0, 0);\n }\n}","map":{"version":3,"names":["Logger","Vector3","_IsoVector","constructor","x","y","Math","floor","Warn","clone","rotate60About","other","rotateNeg60About","rotate120","m","n","rotateNeg120","toCartesianOrigin","origin","isoGridSize","point","Zero","sqrt"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Maths/math.isovector.js"],"sourcesContent":["import { Logger } from \"../Misc/logger.js\";\nimport { Vector3 } from \"./math.vector.js\";\n/**\n * Class representing an isovector a vector containing 2 INTEGER coordinates\n * x axis is horizontal\n * y axis is 60 deg counter clockwise from positive y axis\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _IsoVector {\n /**\n * Creates a new isovector from the given x and y coordinates\n * @param x defines the first coordinate, must be an integer\n * @param y defines the second coordinate, must be an integer\n */\n constructor(\n /** [0] defines the first coordinate */\n x = 0, \n /** [0] defines the second coordinate */\n y = 0) {\n this.x = x;\n this.y = y;\n if (x !== Math.floor(x)) {\n x = Math.floor(x);\n Logger.Warn(\"x is not an integer, floor(x) used\");\n }\n if (y !== Math.floor(y)) {\n y = Math.floor(y);\n Logger.Warn(\"y is not an integer, floor(y) used\");\n }\n }\n // Operators\n /**\n * Gets a new IsoVector copied from the IsoVector\n * @returns a new IsoVector\n */\n clone() {\n return new _IsoVector(this.x, this.y);\n }\n /**\n * Rotates one IsoVector 60 degrees counter clockwise about another\n * Please note that this is an in place operation\n * @param other an IsoVector a center of rotation\n * @returns the rotated IsoVector\n */\n rotate60About(other) {\n //other IsoVector\n const x = this.x;\n this.x = other.x + other.y - this.y;\n this.y = x + this.y - other.x;\n return this;\n }\n /**\n * Rotates one IsoVector 60 degrees clockwise about another\n * Please note that this is an in place operation\n * @param other an IsoVector as center of rotation\n * @returns the rotated IsoVector\n */\n rotateNeg60About(other) {\n const x = this.x;\n this.x = x + this.y - other.y;\n this.y = other.x + other.y - x;\n return this;\n }\n /**\n * For an equilateral triangle OAB with O at isovector (0, 0) and A at isovector (m, n)\n * Rotates one IsoVector 120 degrees counter clockwise about the center of the triangle\n * Please note that this is an in place operation\n * @param m integer a measure a Primary triangle of order (m, n) m > n\n * @param n >= 0 integer a measure for a Primary triangle of order (m, n)\n * @returns the rotated IsoVector\n */\n rotate120(m, n) {\n //m, n integers\n if (m !== Math.floor(m)) {\n m = Math.floor(m);\n Logger.Warn(\"m not an integer only floor(m) used\");\n }\n if (n !== Math.floor(n)) {\n n = Math.floor(n);\n Logger.Warn(\"n not an integer only floor(n) used\");\n }\n const x = this.x;\n this.x = m - x - this.y;\n this.y = n + x;\n return this;\n }\n /**\n * For an equilateral triangle OAB with O at isovector (0, 0) and A at isovector (m, n)\n * Rotates one IsoVector 120 degrees clockwise about the center of the triangle\n * Please note that this is an in place operation\n * @param m integer a measure a Primary triangle of order (m, n) m > n\n * @param n >= 0 integer a measure for a Primary triangle of order (m, n)\n * @returns the rotated IsoVector\n */\n rotateNeg120(m, n) {\n //m, n integers\n if (m !== Math.floor(m)) {\n m = Math.floor(m);\n Logger.Warn(\"m is not an integer, floor(m) used\");\n }\n if (n !== Math.floor(n)) {\n n = Math.floor(n);\n Logger.Warn(\"n is not an integer, floor(n) used\");\n }\n const x = this.x;\n this.x = this.y - n;\n this.y = m + n - x - this.y;\n return this;\n }\n /**\n * Transforms an IsoVector to one in Cartesian 3D space based on an isovector\n * @param origin an IsoVector\n * @param isoGridSize\n * @returns Point as a Vector3\n */\n toCartesianOrigin(origin, isoGridSize) {\n const point = Vector3.Zero();\n point.x = origin.x + 2 * this.x * isoGridSize + this.y * isoGridSize;\n point.y = origin.y + Math.sqrt(3) * this.y * isoGridSize;\n return point;\n }\n // Statics\n /**\n * Gets a new IsoVector(0, 0)\n * @returns a new IsoVector\n */\n static Zero() {\n return new _IsoVector(0, 0);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,CAAC;EACpB;AACJ;AACA;AACA;AACA;EACIC,WAAWA,CAAA,CACX;EACAC,CAAC,GAAG,CAAC,EACL;EACAC,CAAC,GAAG,CAAC,EAAE;IACH,IAAI,CAACD,CAAC,GAAGA,CAAC;IACV,IAAI,CAACC,CAAC,GAAGA,CAAC;IACV,IAAID,CAAC,KAAKE,IAAI,CAACC,KAAK,CAACH,CAAC,CAAC,EAAE;MACrBA,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACH,CAAC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