1 |
- {"ast":null,"code":"import { Vector3 } from \"../Maths/math.vector.js\";\n/**\n * A cursor which tracks a point on a path\n */\nexport class PathCursor {\n /**\n * Initializes the path cursor\n * @param _path The path to track\n */\n constructor(_path) {\n this._path = _path;\n /**\n * Stores path cursor callbacks for when an onchange event is triggered\n */\n this._onchange = new Array();\n /**\n * The value of the path cursor\n */\n this.value = 0;\n /**\n * The animation array of the path cursor\n */\n this.animations = [];\n }\n /**\n * Gets the cursor point on the path\n * @returns A point on the path cursor at the cursor location\n */\n getPoint() {\n const point = this._path.getPointAtLengthPosition(this.value);\n return new Vector3(point.x, 0, point.y);\n }\n /**\n * Moves the cursor ahead by the step amount\n * @param step The amount to move the cursor forward\n * @returns This path cursor\n */\n moveAhead(step = 0.002) {\n this.move(step);\n return this;\n }\n /**\n * Moves the cursor behind by the step amount\n * @param step The amount to move the cursor back\n * @returns This path cursor\n */\n moveBack(step = 0.002) {\n this.move(-step);\n return this;\n }\n /**\n * Moves the cursor by the step amount\n * If the step amount is greater than one, an exception is thrown\n * @param step The amount to move the cursor\n * @returns This path cursor\n */\n move(step) {\n if (Math.abs(step) > 1) {\n // eslint-disable-next-line no-throw-literal\n throw \"step size should be less than 1.\";\n }\n this.value += step;\n this._ensureLimits();\n this._raiseOnChange();\n return this;\n }\n /**\n * Ensures that the value is limited between zero and one\n * @returns This path cursor\n */\n _ensureLimits() {\n while (this.value > 1) {\n this.value -= 1;\n }\n while (this.value < 0) {\n this.value += 1;\n }\n return this;\n }\n /**\n * Runs onchange callbacks on change (used by the animation engine)\n * @returns This path cursor\n */\n _raiseOnChange() {\n this._onchange.forEach(f => f(this));\n return this;\n }\n /**\n * Executes a function on change\n * @param f A path cursor onchange callback\n * @returns This path cursor\n */\n onchange(f) {\n this._onchange.push(f);\n return this;\n }\n}","map":{"version":3,"names":["Vector3","PathCursor","constructor","_path","_onchange","Array","value","animations","getPoint","point","getPointAtLengthPosition","x","y","moveAhead","step","move","moveBack","Math","abs","_ensureLimits","_raiseOnChange","forEach","f","onchange","push"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Animations/pathCursor.js"],"sourcesContent":["import { Vector3 } from \"../Maths/math.vector.js\";\n/**\n * A cursor which tracks a point on a path\n */\nexport class PathCursor {\n /**\n * Initializes the path cursor\n * @param _path The path to track\n */\n constructor(_path) {\n this._path = _path;\n /**\n * Stores path cursor callbacks for when an onchange event is triggered\n */\n this._onchange = new Array();\n /**\n * The value of the path cursor\n */\n this.value = 0;\n /**\n * The animation array of the path cursor\n */\n this.animations = [];\n }\n /**\n * Gets the cursor point on the path\n * @returns A point on the path cursor at the cursor location\n */\n getPoint() {\n const point = this._path.getPointAtLengthPosition(this.value);\n return new Vector3(point.x, 0, point.y);\n }\n /**\n * Moves the cursor ahead by the step amount\n * @param step The amount to move the cursor forward\n * @returns This path cursor\n */\n moveAhead(step = 0.002) {\n this.move(step);\n return this;\n }\n /**\n * Moves the cursor behind by the step amount\n * @param step The amount to move the cursor back\n * @returns This path cursor\n */\n moveBack(step = 0.002) {\n this.move(-step);\n return this;\n }\n /**\n * Moves the cursor by the step amount\n * If the step amount is greater than one, an exception is thrown\n * @param step The amount to move the cursor\n * @returns This path cursor\n */\n move(step) {\n if (Math.abs(step) > 1) {\n // eslint-disable-next-line no-throw-literal\n throw \"step size should be less than 1.\";\n }\n this.value += step;\n this._ensureLimits();\n this._raiseOnChange();\n return this;\n }\n /**\n * Ensures that the value is limited between zero and one\n * @returns This path cursor\n */\n _ensureLimits() {\n while (this.value > 1) {\n this.value -= 1;\n }\n while (this.value < 0) {\n this.value += 1;\n }\n return this;\n }\n /**\n * Runs onchange callbacks on change (used by the animation engine)\n * @returns This path cursor\n */\n _raiseOnChange() {\n this._onchange.forEach((f) => f(this));\n return this;\n }\n /**\n * Executes a function on change\n * @param f A path cursor onchange callback\n * @returns This path cursor\n */\n onchange(f) {\n this._onchange.push(f);\n return this;\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,yBAAyB;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AAI,CAAC;IACnB;IACA,OAAO,IAAI,CAACA,KAAK,GAAG,CAAC,EAAE;MACnB,IAAI,CAACA,KAAK,IAAI,CAAC;IACnB;IACA,OAAO,IAAI;EACf;EACA;AACJ;AACA;AACA;EACIc,cAAcA,CAAA,EAAG;IACb,IAAI,CAAChB,SAAS,CAACiB,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,IAAI;EACf;EACA;AACJ;AACA;AACA;AACA;EACIC,QAAQA,CAACD,CAAC,EAAE;IACR,IAAI,CAAClB,SAAS,CAACoB,IAAI,CAACF,CAAC,CAAC;IACtB,OAAO,IAAI;EACf;AACJ","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|