@visactor/vrender-animate 1.0.0-alpha.21 → 1.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,9 @@ export declare class RotateBySphereAnimate extends ACustomAnimate<any> {
12
12
  params: RotateSphereParams;
13
13
  theta: number;
14
14
  phi: number;
15
- onStart(): void;
16
15
  onBind(): void;
16
+ onFirstRun(): void;
17
+ onStart(): void;
17
18
  onEnd(): void;
18
19
  onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
19
20
  }
@@ -7,20 +7,27 @@ Object.defineProperty(exports, "__esModule", {
7
7
  const vutils_1 = require("@visactor/vutils"), custom_animate_1 = require("./custom-animate");
8
8
 
9
9
  class RotateBySphereAnimate extends custom_animate_1.ACustomAnimate {
10
+ onBind() {
11
+ super.onBind(), this.propKeys = [ "x", "y", "z", "alpha", "zIndex" ];
12
+ }
13
+ onFirstRun() {
14
+ super.onFirstRun();
15
+ const finalAttribute = this.target.getFinalAttribute();
16
+ finalAttribute && this.target.setAttributes(finalAttribute);
17
+ }
10
18
  onStart() {
11
- const {center: center, r: r} = "function" == typeof this.params ? this.params() : this.params, startX = this.target.getComputedAttribute("x"), startY = this.target.getComputedAttribute("y"), startZ = this.target.getComputedAttribute("z"), phi = Math.acos((startY - center.y) / r);
19
+ super.onStart();
20
+ const {center: center, r: r} = "function" == typeof this.params ? this.params() : this.params, startX = this.target.finalAttribute.x, startY = this.target.finalAttribute.y, startZ = this.target.finalAttribute.z, phi = Math.acos((startY - center.y) / r);
12
21
  let theta = Math.acos((startX - center.x) / r / Math.sin(phi));
13
22
  startZ - center.z < 0 && (theta = vutils_1.pi2 - theta), this.theta = theta, this.phi = phi;
14
23
  }
15
- onBind() {
16
- super.onBind();
17
- }
18
24
  onEnd() {}
19
25
  onUpdate(end, ratio, out) {
20
26
  if (null == this.phi || null == this.theta) return;
21
- const {center: center, r: r, cb: cb} = "function" == typeof this.params ? this.params() : this.params, deltaAngle = 2 * Math.PI * ratio, theta = this.theta + deltaAngle, phi = this.phi, x = r * Math.sin(phi) * Math.cos(theta) + center.x, y = r * Math.cos(phi) + center.y, z = r * Math.sin(phi) * Math.sin(theta) + center.z;
22
- for (out.x = x, out.y = y, out.z = z, out.alpha = theta + vutils_1.pi / 2; out.alpha > vutils_1.pi2; ) out.alpha -= vutils_1.pi2;
23
- out.alpha = vutils_1.pi2 - out.alpha, out.zIndex = -1e4 * out.z, cb && cb(out);
27
+ const target = this.target, {center: center, r: r, cb: cb} = "function" == typeof this.params ? this.params() : this.params, deltaAngle = 2 * Math.PI * ratio, theta = this.theta + deltaAngle, phi = this.phi, x = r * Math.sin(phi) * Math.cos(theta) + center.x, y = r * Math.cos(phi) + center.y, z = r * Math.sin(phi) * Math.sin(theta) + center.z;
28
+ for (target.attribute.x = x, target.attribute.y = y, target.attribute.z = z, target.attribute.alpha = theta + vutils_1.pi / 2; target.attribute.alpha > vutils_1.pi2; ) target.attribute.alpha -= vutils_1.pi2;
29
+ target.attribute.alpha = vutils_1.pi2 - target.attribute.alpha, target.attribute.zIndex = -1e4 * target.attribute.z,
30
+ cb && cb(out);
24
31
  }
25
32
  }
26
33
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,qDAAkD;AAUlD,MAAa,qBAAsB,SAAQ,+BAAmB;IAK5D,OAAO;QACL,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACtF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,M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AAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACzD,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEV,GAAG,CAAC,KAAK,GAAG,KAAK,GAAG,WAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,KAAK,GAAG,YAAG,EAAE;YACtB,GAAG,CAAC,KAAK,IAAI,YAAG,CAAC;SAClB;QACD,GAAG,CAAC,KAAK,GAAG,YAAG,GAAG,GAAG,CAAC,KAAK,CAAC;QAE5B,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAE5B,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;CACF;AArDD,sDAqDC","file":"sphere.js","sourcesContent":["import { pi, pi2 } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ntype RotateSphereParams =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onStart(): void {\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.getComputedAttribute('x');\n const startY = this.target.getComputedAttribute('y');\n const startZ = this.target.getComputedAttribute('z');\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onBind() {\n super.onBind();\n return;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n out.x = x;\n out.y = y;\n out.z = z;\n // out.beta = phi;\n out.alpha = theta + pi / 2;\n while (out.alpha > pi2) {\n out.alpha -= pi2;\n }\n out.alpha = pi2 - out.alpha;\n\n out.zIndex = out.z * -10000;\n\n cb && cb(out);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,qDAAkD;AAUlD,MAAa,qBAAsB,SAAQ,+BAAmB;IAK5D,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QAQf,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAGrD,CAAC;IAED,UAAU;QACR,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACvD,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,I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Params =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onBind(): void {\n super.onBind();\n\n // const to: Record<string, number> = {};\n // const from: Record<string, number> = this.from ?? {};\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n\n // this.props = to;\n this.propKeys = ['x', 'y', 'z', 'alpha', 'zIndex'];\n // this.from = from;\n // this.to = to;\n }\n\n onFirstRun(): void {\n super.onFirstRun();\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n }\n\n onStart(): void {\n super.onStart();\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.finalAttribute.x;\n const startY = this.target.finalAttribute.y;\n const startZ = this.target.finalAttribute.z;\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const target = this.target;\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n target.attribute.x = x;\n target.attribute.y = y;\n target.attribute.z = z;\n // out.beta = phi;\n target.attribute.alpha = theta + pi / 2;\n while (target.attribute.alpha > pi2) {\n target.attribute.alpha -= pi2;\n }\n target.attribute.alpha = pi2 - target.attribute.alpha;\n\n target.attribute.zIndex = target.attribute.z * -10000;\n cb && cb(out);\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -3476,11 +3476,23 @@ class GroupFadeOut extends CommonOut {
3476
3476
  }
3477
3477
 
3478
3478
  class RotateBySphereAnimate extends ACustomAnimate {
3479
+ onBind() {
3480
+ super.onBind();
3481
+ this.propKeys = ['x', 'y', 'z', 'alpha', 'zIndex'];
3482
+ }
3483
+ onFirstRun() {
3484
+ super.onFirstRun();
3485
+ const finalAttribute = this.target.getFinalAttribute();
3486
+ if (finalAttribute) {
3487
+ this.target.setAttributes(finalAttribute);
3488
+ }
3489
+ }
3479
3490
  onStart() {
3491
+ super.onStart();
3480
3492
  const { center, r } = typeof this.params === 'function' ? this.params() : this.params;
3481
- const startX = this.target.getComputedAttribute('x');
3482
- const startY = this.target.getComputedAttribute('y');
3483
- const startZ = this.target.getComputedAttribute('z');
3493
+ const startX = this.target.finalAttribute.x;
3494
+ const startY = this.target.finalAttribute.y;
3495
+ const startZ = this.target.finalAttribute.z;
3484
3496
  const phi = Math.acos((startY - center.y) / r);
3485
3497
  let theta = Math.acos((startX - center.x) / r / Math.sin(phi));
3486
3498
  if (startZ - center.z < 0) {
@@ -3489,10 +3501,6 @@ class RotateBySphereAnimate extends ACustomAnimate {
3489
3501
  this.theta = theta;
3490
3502
  this.phi = phi;
3491
3503
  }
3492
- onBind() {
3493
- super.onBind();
3494
- return;
3495
- }
3496
3504
  onEnd() {
3497
3505
  return;
3498
3506
  }
@@ -3500,6 +3508,7 @@ class RotateBySphereAnimate extends ACustomAnimate {
3500
3508
  if (this.phi == null || this.theta == null) {
3501
3509
  return;
3502
3510
  }
3511
+ const target = this.target;
3503
3512
  const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;
3504
3513
  const deltaAngle = Math.PI * 2 * ratio;
3505
3514
  const theta = this.theta + deltaAngle;
@@ -3507,15 +3516,15 @@ class RotateBySphereAnimate extends ACustomAnimate {
3507
3516
  const x = r * Math.sin(phi) * Math.cos(theta) + center.x;
3508
3517
  const y = r * Math.cos(phi) + center.y;
3509
3518
  const z = r * Math.sin(phi) * Math.sin(theta) + center.z;
3510
- out.x = x;
3511
- out.y = y;
3512
- out.z = z;
3513
- out.alpha = theta + pi / 2;
3514
- while (out.alpha > pi2) {
3515
- out.alpha -= pi2;
3516
- }
3517
- out.alpha = pi2 - out.alpha;
3518
- out.zIndex = out.z * -10000;
3519
+ target.attribute.x = x;
3520
+ target.attribute.y = y;
3521
+ target.attribute.z = z;
3522
+ target.attribute.alpha = theta + pi / 2;
3523
+ while (target.attribute.alpha > pi2) {
3524
+ target.attribute.alpha -= pi2;
3525
+ }
3526
+ target.attribute.alpha = pi2 - target.attribute.alpha;
3527
+ target.attribute.zIndex = target.attribute.z * -10000;
3519
3528
  cb && cb(out);
3520
3529
  }
3521
3530
  }
@@ -12,8 +12,9 @@ export declare class RotateBySphereAnimate extends ACustomAnimate<any> {
12
12
  params: RotateSphereParams;
13
13
  theta: number;
14
14
  phi: number;
15
- onStart(): void;
16
15
  onBind(): void;
16
+ onFirstRun(): void;
17
+ onStart(): void;
17
18
  onEnd(): void;
18
19
  onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
19
20
  }
@@ -3,20 +3,27 @@ import { pi, pi2 } from "@visactor/vutils";
3
3
  import { ACustomAnimate } from "./custom-animate";
4
4
 
5
5
  export class RotateBySphereAnimate extends ACustomAnimate {
6
+ onBind() {
7
+ super.onBind(), this.propKeys = [ "x", "y", "z", "alpha", "zIndex" ];
8
+ }
9
+ onFirstRun() {
10
+ super.onFirstRun();
11
+ const finalAttribute = this.target.getFinalAttribute();
12
+ finalAttribute && this.target.setAttributes(finalAttribute);
13
+ }
6
14
  onStart() {
7
- const {center: center, r: r} = "function" == typeof this.params ? this.params() : this.params, startX = this.target.getComputedAttribute("x"), startY = this.target.getComputedAttribute("y"), startZ = this.target.getComputedAttribute("z"), phi = Math.acos((startY - center.y) / r);
15
+ super.onStart();
16
+ const {center: center, r: r} = "function" == typeof this.params ? this.params() : this.params, startX = this.target.finalAttribute.x, startY = this.target.finalAttribute.y, startZ = this.target.finalAttribute.z, phi = Math.acos((startY - center.y) / r);
8
17
  let theta = Math.acos((startX - center.x) / r / Math.sin(phi));
9
18
  startZ - center.z < 0 && (theta = pi2 - theta), this.theta = theta, this.phi = phi;
10
19
  }
11
- onBind() {
12
- super.onBind();
13
- }
14
20
  onEnd() {}
15
21
  onUpdate(end, ratio, out) {
16
22
  if (null == this.phi || null == this.theta) return;
17
- const {center: center, r: r, cb: cb} = "function" == typeof this.params ? this.params() : this.params, deltaAngle = 2 * Math.PI * ratio, theta = this.theta + deltaAngle, phi = this.phi, x = r * Math.sin(phi) * Math.cos(theta) + center.x, y = r * Math.cos(phi) + center.y, z = r * Math.sin(phi) * Math.sin(theta) + center.z;
18
- for (out.x = x, out.y = y, out.z = z, out.alpha = theta + pi / 2; out.alpha > pi2; ) out.alpha -= pi2;
19
- out.alpha = pi2 - out.alpha, out.zIndex = -1e4 * out.z, cb && cb(out);
23
+ const target = this.target, {center: center, r: r, cb: cb} = "function" == typeof this.params ? this.params() : this.params, deltaAngle = 2 * Math.PI * ratio, theta = this.theta + deltaAngle, phi = this.phi, x = r * Math.sin(phi) * Math.cos(theta) + center.x, y = r * Math.cos(phi) + center.y, z = r * Math.sin(phi) * Math.sin(theta) + center.z;
24
+ for (target.attribute.x = x, target.attribute.y = y, target.attribute.z = z, target.attribute.alpha = theta + pi / 2; target.attribute.alpha > pi2; ) target.attribute.alpha -= pi2;
25
+ target.attribute.alpha = pi2 - target.attribute.alpha, target.attribute.zIndex = -1e4 * target.attribute.z,
26
+ cb && cb(out);
20
27
  }
21
28
  }
22
29
  //# sourceMappingURL=sphere.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,MAAM,OAAO,qBAAsB,SAAQ,cAAmB;IAK5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\n\ntype RotateSphereParams =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onStart(): void {\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.getComputedAttribute('x');\n const startY = this.target.getComputedAttribute('y');\n const startZ = this.target.getComputedAttribute('z');\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onBind() {\n super.onBind();\n return;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n out.x = x;\n out.y = y;\n out.z = z;\n // out.beta = phi;\n out.alpha = theta + pi / 2;\n while (out.alpha > pi2) {\n out.alpha -= pi2;\n }\n out.alpha = pi2 - out.alpha;\n\n out.zIndex = out.z * -10000;\n\n cb && cb(out);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,MAAM,OAAO,qBAAsB,SAAQ,cAAmB;IAK5D,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QAQf,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,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G,EAAE;YACnC,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC;SAC/B;QACD,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAEtD,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QACtD,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;CACF","file":"sphere.js","sourcesContent":["import { pi, pi2 } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ntype RotateSphereParams =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onBind(): void {\n super.onBind();\n\n // const to: Record<string, number> = {};\n // const from: Record<string, number> = this.from ?? {};\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n\n // this.props = to;\n this.propKeys = ['x', 'y', 'z', 'alpha', 'zIndex'];\n // this.from = from;\n // this.to = to;\n }\n\n onFirstRun(): void {\n super.onFirstRun();\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n }\n\n onStart(): void {\n super.onStart();\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.finalAttribute.x;\n const startY = this.target.finalAttribute.y;\n const startZ = this.target.finalAttribute.z;\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const target = this.target;\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n target.attribute.x = x;\n target.attribute.y = y;\n target.attribute.z = z;\n // out.beta = phi;\n target.attribute.alpha = theta + pi / 2;\n while (target.attribute.alpha > pi2) {\n target.attribute.alpha -= pi2;\n }\n target.attribute.alpha = pi2 - target.attribute.alpha;\n\n target.attribute.zIndex = target.attribute.z * -10000;\n cb && cb(out);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-animate",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.22",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@visactor/vutils": "1.0.4",
16
- "@visactor/vrender-core": "1.0.0-alpha.21"
16
+ "@visactor/vrender-core": "1.0.0-alpha.22"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rushstack/eslint-patch": "~1.1.4",