vis-core 0.22.14 → 0.23.0

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.
@@ -90,7 +90,7 @@ const publicKeyPEM = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRz
90
90
  ).toString(CryptoJS.enc.Utf8), qe = JSON.parse($e), st = Date.now();
91
91
  return !qe.s || qe.s > st ? (this.token = void 0, "") : qe.e && qe.e < st ? (this.token = void 0, "") : (qe.isValid = Qe, qe);
92
92
  }
93
- }, version = "0.22.14";
93
+ }, version = "0.23.0";
94
94
  /**
95
95
  * @license
96
96
  * Copyright 2010-2024 Three.js Authors
@@ -38160,21 +38160,23 @@ class Arc extends A$1 {
38160
38160
  }
38161
38161
  update() {
38162
38162
  var s;
38163
- (s = this.helperMesh) != null && s.length && this.helperMesh.some((r, T) => {
38164
- if (r.position.distanceTo(this.helperMeshPosition[T]) > 0.01) {
38165
- this.helperMeshPosition[T].copy(r.position);
38166
- const Xe = new CubicBezierCurve3(
38167
- this.helperMeshPosition[0],
38168
- this.helperMeshPosition[1],
38169
- this.helperMeshPosition[2],
38170
- this.helperMeshPosition[3]
38171
- ).getPoints(1500);
38172
- return this.line.setGeometry(
38173
- Xe,
38174
- this.line.object3d.geometry.widthCallback
38175
- ), !0;
38176
- }
38177
- });
38163
+ if ((s = this.helperMesh) != null && s.length && this.helperMesh.find(
38164
+ (T, de) => T.position.distanceTo(this.helperMeshPosition[de]) > 0.01
38165
+ )) {
38166
+ this.helperMesh.forEach((Xe, Ke) => {
38167
+ this.helperMeshPosition[Ke].copy(Xe.position);
38168
+ });
38169
+ const de = new CubicBezierCurve3(
38170
+ this.helperMeshPosition[0],
38171
+ this.helperMeshPosition[1],
38172
+ this.helperMeshPosition[2],
38173
+ this.helperMeshPosition[3]
38174
+ ).getPoints(1500);
38175
+ this.line.setGeometry(
38176
+ de,
38177
+ this.line.object3d.geometry.widthCallback
38178
+ );
38179
+ }
38178
38180
  }
38179
38181
  setMList() {
38180
38182
  var r;
@@ -49359,15 +49361,14 @@ class History {
49359
49361
  const T = [...this.undos], de = T.length;
49360
49362
  let Xe = 0;
49361
49363
  const Ke = () => ei(this, null, function* () {
49362
- var Qe, _e, $e;
49363
49364
  const Je = performance.now();
49364
49365
  for (; T.length > 0 && performance.now() - Je < e; ) {
49365
49366
  if (this.editor._dispose) {
49366
49367
  r("dispose");
49367
49368
  return;
49368
49369
  }
49369
- const qe = T.shift(), st = (Qe = this.editor.hooks) != null && Qe.beforeExecuteUndo ? yield this.editor.hooks.beforeExecuteUndo(qe) : qe;
49370
- st && (yield this.executeUndo(st)), yield ($e = (_e = this.editor.hooks) == null ? void 0 : _e.afterExecuteUndo) == null ? void 0 : $e.call(_e, qe), Xe += 1;
49370
+ const Qe = T.shift(), _e = this.editor.scripts.events.beforeExecuteUndo.length ? this.editor.scripts.dispatch("beforeExecuteUndo", Qe) : Qe;
49371
+ _e && (yield this.executeUndo(_e)), this.editor.scripts.events.afterExecuteUndo.length && this.editor.scripts.dispatch("afterExecuteUndo", Qe), Xe += 1;
49371
49372
  }
49372
49373
  this.editor.emit("progress", {
49373
49374
  type: "还原场景",
@@ -49425,18 +49426,18 @@ class Viewport {
49425
49426
  }
49426
49427
  setVis(r) {
49427
49428
  return ei(this, arguments, function* (e, s = {}) {
49428
- var Xe, Ke;
49429
+ var Xe;
49429
49430
  if (!this.options.visFactories && (this.editor.setViewportVis(e), !this.options.visFactories)) {
49430
49431
  console.error("visFactories is not defined");
49431
49432
  return;
49432
49433
  }
49433
49434
  if (this.vis = this.options.visFactories, this.vis.visName !== e)
49434
49435
  throw new Error(`visName is not match, import {${e}}`);
49435
- const T = (Xe = this.editor.hooks) != null && Xe.beforeSetVisOptions ? this.editor.hooks.beforeSetVisOptions(s) : s;
49436
- this.vis.setOptions(ai(ai({}, T), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis.on("loaderProgress", (Je, Qe) => {
49436
+ const T = this.editor.scripts.events.beforeSetVisOptions.length ? this.editor.scripts.dispatch("beforeSetVisOptions", s) : s;
49437
+ this.vis.setOptions(ai(ai({}, T), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis.on("loaderProgress", (Ke, Je) => {
49437
49438
  this.editor.emit("progress", {
49438
49439
  type: "下载资源",
49439
- value: Je / Qe * 100 | 0
49440
+ value: Ke / Je * 100 | 0
49440
49441
  });
49441
49442
  }), this.vis.on("settingsChanged", () => {
49442
49443
  this.editor.emit("settingsChanged");
@@ -49444,7 +49445,7 @@ class Viewport {
49444
49445
  this.editor.emit("visShow");
49445
49446
  }), yield this.vis.init();
49446
49447
  const { pencil: de } = this.vis;
49447
- de.userData.EditorEnv = !this.editor.playing, this.editor.pencil = de, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (Ke = this.vis) == null || Ke.pencil.event.on("object3dListChange", () => {
49448
+ de.userData.EditorEnv = !this.editor.playing, this.editor.pencil = de, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (Xe = this.vis) == null || Xe.pencil.event.on("object3dListChange", () => {
49448
49449
  this.editor.changeSelectOption();
49449
49450
  });
49450
49451
  });
@@ -49621,7 +49622,54 @@ const compareVersion = (c, e) => {
49621
49622
  de.attributeName = de.attributeName.replace(Xe, `caId.${Xe}`);
49622
49623
  }
49623
49624
  }), compareVersion(c.c.version, "0.21.24") === -1 && c.h.u[0] && c.h.u[0].visType === "map" && (T = (r = c.v) == null ? void 0 : r.eo) != null && T.parentBgCurvatureResolution && (delete c.v.eo.parentBgCurvatureResolution, c.v.eo.parentBgTopSegments = 400), c;
49624
- }, jsonFetch = (c, e, s = !1) => {
49625
+ };
49626
+ class Scripts {
49627
+ constructor(e) {
49628
+ H0(this, "editor");
49629
+ H0(this, "events", {
49630
+ beforeSetVisOptions: [],
49631
+ beforeExecuteUndo: [],
49632
+ afterExecuteUndo: [],
49633
+ beforeShow: [],
49634
+ afterShow: []
49635
+ });
49636
+ H0(this, "source", "");
49637
+ this.editor = e;
49638
+ }
49639
+ add(e) {
49640
+ for (const s in e) {
49641
+ const r = s;
49642
+ this.events[r] && this.events[r].push(e[r].bind(e));
49643
+ }
49644
+ }
49645
+ fromJSON(e) {
49646
+ try {
49647
+ e = `
49648
+ return ${e}(vis);
49649
+ `;
49650
+ const s = new Function(e)();
49651
+ this.add(s), this.source = e;
49652
+ } catch (s) {
49653
+ console.error(s);
49654
+ }
49655
+ }
49656
+ toJSON() {
49657
+ return this.source;
49658
+ }
49659
+ clear() {
49660
+ Object.keys(this.events).forEach((e) => {
49661
+ this.events[e] = [];
49662
+ });
49663
+ }
49664
+ dispatch(e, ...s) {
49665
+ let r;
49666
+ for (const T of this.events[e])
49667
+ if (e === "beforeSetVisOptions" ? r = T(r != null ? r : s[0]) : r = T(this.editor.viewport.vis, ...s), r === !1)
49668
+ break;
49669
+ return r;
49670
+ }
49671
+ }
49672
+ const jsonFetch = (c, e, s = !1) => {
49625
49673
  const r = makePromiseCreator(!0), T = c.endsWith("gzip") || s;
49626
49674
  return window.fetch(c).then((de) => {
49627
49675
  let Xe = de;
@@ -49645,6 +49693,7 @@ class Editor {
49645
49693
  H0(this, "events", new EventEmitter());
49646
49694
  H0(this, "history");
49647
49695
  H0(this, "viewport");
49696
+ H0(this, "scripts");
49648
49697
  H0(this, "pencil");
49649
49698
  H0(this, "on", this.events.on.bind(this.events));
49650
49699
  H0(this, "emit", this.events.emit.bind(this.events));
@@ -49654,7 +49703,6 @@ class Editor {
49654
49703
  H0(this, "name");
49655
49704
  H0(this, "open", !1);
49656
49705
  H0(this, "options");
49657
- H0(this, "hooks");
49658
49706
  H0(this, "selectOption", []);
49659
49707
  H0(this, "selectOption2", []);
49660
49708
  H0(this, "checkSelectOption", throttle(
@@ -49673,7 +49721,7 @@ class Editor {
49673
49721
  processUndosMaxFrameTime: Number.MAX_VALUE
49674
49722
  }, e), this.events.setMaxListeners(9999999), this.viewport = new Viewport(this, {
49675
49723
  visFactories: e.visFactories
49676
- }), this.history = new History(this);
49724
+ }), this.history = new History(this), this.scripts = new Scripts(this);
49677
49725
  }
49678
49726
  getObjectMaterial(e, s) {
49679
49727
  if (!e)
@@ -49796,9 +49844,9 @@ class Editor {
49796
49844
  return ei(this, null, function* () {
49797
49845
  var r, T, de, Xe;
49798
49846
  try {
49799
- s && !n$1(s) && console.warn(
49847
+ s && !n$1(s) ? console.warn(
49800
49848
  "fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
49801
- ), this.hooks = s, window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49849
+ ) : s && this.scripts.add(s), window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49802
49850
  let Ke;
49803
49851
  if (typeof e == "string") {
49804
49852
  const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
@@ -49816,11 +49864,11 @@ class Editor {
49816
49864
  "vis-core 版本过低,可能会出现问题",
49817
49865
  "json:" + Ke.c.version,
49818
49866
  "sdk:" + this.sdkVersion
49819
- ), this.setConfig(Ke.c), this.history.fromJSON(Ke.h), this.viewport.fromJSON(Ke.v), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49867
+ ), this.setConfig(Ke.c), this.history.fromJSON(Ke.h), this.viewport.fromJSON(Ke.v), Ke.s && this.scripts.fromJSON(Ke.s), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49820
49868
  const Je = parseTexture(Ke.v.bg.texture);
49821
49869
  Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
49822
49870
  }
49823
- return (T = this.viewport.vis) == null || T.show(), (de = this.pencil.controls) == null || de.saveState(), this.select(null), console.timeEnd("vis-core:time.fromJSON"), window.postMessage({ type: "vis-core.fromJSON.end" }), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49871
+ return this.scripts.dispatch("beforeShow"), (T = this.viewport.vis) == null || T.show(), this.scripts.dispatch("afterShow"), (de = this.pencil.controls) == null || de.saveState(), this.select(null), console.timeEnd("vis-core:time.fromJSON"), window.postMessage({ type: "vis-core.fromJSON.end" }), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49824
49872
  var Je;
49825
49873
  (Je = this.viewport.vis) == null || Je.worker.dispose();
49826
49874
  }), Ke;
@@ -49860,7 +49908,7 @@ class Editor {
49860
49908
  return this.pencil ? (this.pencil.render(), this.pencil.renderer.domElement.toDataURL()) : "";
49861
49909
  }
49862
49910
  dispose() {
49863
- this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this._dispose = !0;
49911
+ this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this.scripts.clear(), this._dispose = !0;
49864
49912
  }
49865
49913
  }
49866
49914
  const BLOCKLISTED_GPUS = [
@@ -129774,14 +129822,11 @@ const objs$4 = Ki(ai({}, objs$5), {
129774
129822
  }, c.initMaterial = function() {
129775
129823
  return ei(this, null, function* () {
129776
129824
  const e = this.loader, s = (() => {
129777
- const r = new MeshStandardMaterial({
129825
+ const T = new MeshStandardMaterial({
129778
129826
  name: "顶面",
129779
129827
  map: e.getAsset("/image/map/hp.webp"),
129780
129828
  normalMap: e.getAsset("/image/map/shuchu2.webp")
129781
- }), T = this.options.drillDownTopMatTwo ? new MeshBasicMaterial({
129782
- name: "二级顶面",
129783
- color: new Color$1("#0d2425")
129784
- }) : null, de = new MeshBasicMaterial({
129829
+ }), de = new MeshBasicMaterial({
129785
129830
  name: "侧面",
129786
129831
  map: e.getAsset("/image/map/jianbian.webp")
129787
129832
  }), Xe = new it$1({
@@ -129799,14 +129844,41 @@ const objs$4 = Ki(ai({}, objs$5), {
129799
129844
  depthWrite: !1
129800
129845
  });
129801
129846
  return {
129802
- topMat: r,
129803
- topMatTwo: T,
129847
+ topMat: T,
129804
129848
  sideMat: de,
129805
129849
  lineMat: Xe,
129806
129850
  extrudeLineMat: Ke
129807
129851
  };
129808
- })();
129809
- this.mList.setMaterialObj("plane", s), this.mList.setShowMaterialList("area", ["plane#topMat", "plane#sideMat"], {
129852
+ })(), r = this.options.drillDownTopMatTwo ? (() => {
129853
+ const T = new MeshBasicMaterial({
129854
+ name: "二级顶面",
129855
+ color: new Color$1("#0d2425")
129856
+ }), de = new MeshBasicMaterial({
129857
+ name: "二级侧面",
129858
+ color: new Color$1("#0d2425")
129859
+ }), Xe = new it$1({
129860
+ name: "二级线",
129861
+ color: new Color$1("#73FEDD"),
129862
+ sizeAttenuation: 0,
129863
+ lineWidth: this.options.lineWidth,
129864
+ //@ts-ignore
129865
+ depthWrite: !1
129866
+ }), Ke = new it$1({
129867
+ name: "二级边线",
129868
+ color: new Color$1("#00FFED"),
129869
+ sizeAttenuation: 0,
129870
+ lineWidth: this.options.extrudeLineWidth,
129871
+ //@ts-ignore
129872
+ depthWrite: !1
129873
+ });
129874
+ return {
129875
+ topMat: T,
129876
+ sideMat: de,
129877
+ lineMat: Xe,
129878
+ extrudeLineMat: Ke
129879
+ };
129880
+ })() : null;
129881
+ this.mList.setMaterialObj("plane", s), r && this.mList.setMaterialObj("secondPlane", r), this.mList.setShowMaterialList("area", ["plane#topMat", "plane#sideMat"], {
129810
129882
  name: "板块"
129811
129883
  }), this.mList.setShowMaterialList("line", "plane#lineMat", {
129812
129884
  name: "板块线"
@@ -129821,13 +129893,10 @@ const objs$4 = Ki(ai({}, objs$5), {
129821
129893
  }, c.initMaterial = function() {
129822
129894
  return ei(this, null, function* () {
129823
129895
  const e = this.loader, s = (() => {
129824
- const r = new MeshBasicMaterial({
129896
+ const T = new MeshBasicMaterial({
129825
129897
  name: "顶面",
129826
129898
  color: new Color$1("#0d2425")
129827
- }), T = this.options.drillDownTopMatTwo ? new MeshBasicMaterial({
129828
- name: "二级顶面",
129829
- color: new Color$1("#0d2425")
129830
- }) : null, de = new MeshBasicMaterial({
129899
+ }), de = new MeshBasicMaterial({
129831
129900
  name: "侧面",
129832
129901
  map: e.getAsset("/image/map/jianbian.webp")
129833
129902
  }), Xe = new it$1({
@@ -129844,14 +129913,41 @@ const objs$4 = Ki(ai({}, objs$5), {
129844
129913
  depthWrite: !1
129845
129914
  });
129846
129915
  return {
129847
- topMatTwo: T,
129848
- topMat: r,
129916
+ topMat: T,
129849
129917
  sideMat: de,
129850
129918
  lineMat: Xe,
129851
129919
  extrudeLineMat: Ke
129852
129920
  };
129853
- })();
129854
- this.mList.setMaterialObj("plane", s), this.mList.setShowMaterialList("area", ["plane#topMat", "plane#sideMat"], {
129921
+ })(), r = this.options.drillDownTopMatTwo ? (() => {
129922
+ const T = new MeshBasicMaterial({
129923
+ name: "二级顶面",
129924
+ color: new Color$1("#0d2425")
129925
+ }), de = new MeshBasicMaterial({
129926
+ name: "二级侧面",
129927
+ color: new Color$1("#0d2425")
129928
+ }), Xe = new it$1({
129929
+ name: "二级线",
129930
+ color: new Color$1("#73FEDD"),
129931
+ sizeAttenuation: 0,
129932
+ lineWidth: this.options.lineWidth,
129933
+ //@ts-ignore
129934
+ depthWrite: !1
129935
+ }), Ke = new it$1({
129936
+ name: "二级边线",
129937
+ color: new Color$1("#00FFED"),
129938
+ sizeAttenuation: 0,
129939
+ lineWidth: this.options.extrudeLineWidth,
129940
+ //@ts-ignore
129941
+ depthWrite: !1
129942
+ });
129943
+ return {
129944
+ topMat: T,
129945
+ sideMat: de,
129946
+ lineMat: Xe,
129947
+ extrudeLineMat: Ke
129948
+ };
129949
+ })() : null;
129950
+ this.mList.setMaterialObj("plane", s), r && this.mList.setMaterialObj("secondPlane", r), this.mList.setShowMaterialList("area", ["plane#topMat", "plane#sideMat"], {
129855
129951
  name: "板块"
129856
129952
  }), this.mList.setShowMaterialList("line", "plane#lineMat", {
129857
129953
  name: "板块线"
@@ -130671,9 +130767,7 @@ const objs$4 = Ki(ai({}, objs$5), {
130671
130767
  depth: de,
130672
130768
  adcode: Xe
130673
130769
  }) {
130674
- const Je = this.mapHistory.length === 0, Qe = this.mList.getMaterialObj("plane"), _e = ai({}, Qe);
130675
- !Je && _e.topMatTwo && (_e.topMat = _e.topMatTwo);
130676
- const $e = yield this.drawController.draw(
130770
+ const Je = this.mapHistory.length !== 0 && this.options.drillDownTopMatTwo, Qe = Je ? "secondPlane" : "plane", _e = this.mList.getMaterialObj(Qe), $e = ai({}, _e), qe = yield this.drawController.draw(
130677
130771
  "PlaneMap",
130678
130772
  {
130679
130773
  geojson: s,
@@ -130685,7 +130779,7 @@ const objs$4 = Ki(ai({}, objs$5), {
130685
130779
  rotate: this.options.worldPacificCentre ? [-160, 0] : void 0,
130686
130780
  projectionType: this.options.projectionType
130687
130781
  },
130688
- materialOptions: _e,
130782
+ materialOptions: $e,
130689
130783
  bbox: T,
130690
130784
  topSegments: this.options.topSegments,
130691
130785
  lineOffset: this.options.lineOffset,
@@ -130693,19 +130787,19 @@ const objs$4 = Ki(ai({}, objs$5), {
130693
130787
  },
130694
130788
  this.group
130695
130789
  );
130696
- return $e.extrudelineArr && $e.extrudelineArr.forEach((qe) => {
130697
- qe.object3d.name = "板块边线", this.mList.setObject3d(qe.object3d, "extrudeLine", {
130698
- baseObject: qe,
130790
+ return Je || (qe.extrudelineArr && qe.extrudelineArr.forEach((st) => {
130791
+ st.object3d.name = "板块边线", this.mList.setObject3d(st.object3d, "extrudeLine", {
130792
+ baseObject: st,
130699
130793
  replace: !0
130700
- }), this.initBaseObjectUserData(qe);
130794
+ }), this.initBaseObjectUserData(st);
130701
130795
  }), this.mList.setObject3d(
130702
- $e.object3d,
130796
+ qe.object3d,
130703
130797
  Xe === 1e5 ? "chinaGroup" : "planeMapGroup",
130704
130798
  {
130705
- baseObject: $e,
130799
+ baseObject: qe,
130706
130800
  replace: !0
130707
130801
  }
130708
- ), $e;
130802
+ )), qe;
130709
130803
  });
130710
130804
  }
130711
130805
  handleBack() {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.22.14";
1
+ declare const _default: "0.23.0";
2
2
  export default _default;
@@ -74,7 +74,7 @@ export default class Base extends Event {
74
74
  tier0: boolean;
75
75
  constructor(options: BaseOptions);
76
76
  setOptions(options: Record<string, any>): void;
77
- get fromJSON(): (jsonOrUrl: Record<string, any> | string, hooks?: import("../../editor").Hooks) => Promise<Record<string, any>>;
77
+ get fromJSON(): (jsonOrUrl: Record<string, any> | string, scripts?: Record<string, any>) => Promise<Record<string, any>>;
78
78
  get baseObjectByUuid(): {
79
79
  (uuid: `arc${string}`, flag?: boolean): Arc;
80
80
  (uuid: `sprite${string}`, flag?: boolean): import("../all/objects/Sprite").default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-core",
3
- "version": "0.22.14",
3
+ "version": "0.23.0",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version && bundler",