vis-core 0.22.15 → 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.
- package/dist/editor/index.d.ts +3 -7
- package/dist/editor/scripts.d.ts +19 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/index.module.js +63 -17
- package/dist/version.d.ts +1 -1
- package/dist/vis/base/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.module.js
CHANGED
|
@@ -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.
|
|
93
|
+
}, version = "0.23.0";
|
|
94
94
|
/**
|
|
95
95
|
* @license
|
|
96
96
|
* Copyright 2010-2024 Three.js Authors
|
|
@@ -49361,15 +49361,14 @@ class History {
|
|
|
49361
49361
|
const T = [...this.undos], de = T.length;
|
|
49362
49362
|
let Xe = 0;
|
|
49363
49363
|
const Ke = () => ei(this, null, function* () {
|
|
49364
|
-
var Qe, _e, $e;
|
|
49365
49364
|
const Je = performance.now();
|
|
49366
49365
|
for (; T.length > 0 && performance.now() - Je < e; ) {
|
|
49367
49366
|
if (this.editor._dispose) {
|
|
49368
49367
|
r("dispose");
|
|
49369
49368
|
return;
|
|
49370
49369
|
}
|
|
49371
|
-
const
|
|
49372
|
-
|
|
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;
|
|
49373
49372
|
}
|
|
49374
49373
|
this.editor.emit("progress", {
|
|
49375
49374
|
type: "还原场景",
|
|
@@ -49427,18 +49426,18 @@ class Viewport {
|
|
|
49427
49426
|
}
|
|
49428
49427
|
setVis(r) {
|
|
49429
49428
|
return ei(this, arguments, function* (e, s = {}) {
|
|
49430
|
-
var Xe
|
|
49429
|
+
var Xe;
|
|
49431
49430
|
if (!this.options.visFactories && (this.editor.setViewportVis(e), !this.options.visFactories)) {
|
|
49432
49431
|
console.error("visFactories is not defined");
|
|
49433
49432
|
return;
|
|
49434
49433
|
}
|
|
49435
49434
|
if (this.vis = this.options.visFactories, this.vis.visName !== e)
|
|
49436
49435
|
throw new Error(`visName is not match, import {${e}}`);
|
|
49437
|
-
const T =
|
|
49438
|
-
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", (
|
|
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) => {
|
|
49439
49438
|
this.editor.emit("progress", {
|
|
49440
49439
|
type: "下载资源",
|
|
49441
|
-
value:
|
|
49440
|
+
value: Ke / Je * 100 | 0
|
|
49442
49441
|
});
|
|
49443
49442
|
}), this.vis.on("settingsChanged", () => {
|
|
49444
49443
|
this.editor.emit("settingsChanged");
|
|
@@ -49446,7 +49445,7 @@ class Viewport {
|
|
|
49446
49445
|
this.editor.emit("visShow");
|
|
49447
49446
|
}), yield this.vis.init();
|
|
49448
49447
|
const { pencil: de } = this.vis;
|
|
49449
|
-
de.userData.EditorEnv = !this.editor.playing, this.editor.pencil = de, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (
|
|
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", () => {
|
|
49450
49449
|
this.editor.changeSelectOption();
|
|
49451
49450
|
});
|
|
49452
49451
|
});
|
|
@@ -49623,7 +49622,54 @@ const compareVersion = (c, e) => {
|
|
|
49623
49622
|
de.attributeName = de.attributeName.replace(Xe, `caId.${Xe}`);
|
|
49624
49623
|
}
|
|
49625
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;
|
|
49626
|
-
}
|
|
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) => {
|
|
49627
49673
|
const r = makePromiseCreator(!0), T = c.endsWith("gzip") || s;
|
|
49628
49674
|
return window.fetch(c).then((de) => {
|
|
49629
49675
|
let Xe = de;
|
|
@@ -49647,6 +49693,7 @@ class Editor {
|
|
|
49647
49693
|
H0(this, "events", new EventEmitter());
|
|
49648
49694
|
H0(this, "history");
|
|
49649
49695
|
H0(this, "viewport");
|
|
49696
|
+
H0(this, "scripts");
|
|
49650
49697
|
H0(this, "pencil");
|
|
49651
49698
|
H0(this, "on", this.events.on.bind(this.events));
|
|
49652
49699
|
H0(this, "emit", this.events.emit.bind(this.events));
|
|
@@ -49656,7 +49703,6 @@ class Editor {
|
|
|
49656
49703
|
H0(this, "name");
|
|
49657
49704
|
H0(this, "open", !1);
|
|
49658
49705
|
H0(this, "options");
|
|
49659
|
-
H0(this, "hooks");
|
|
49660
49706
|
H0(this, "selectOption", []);
|
|
49661
49707
|
H0(this, "selectOption2", []);
|
|
49662
49708
|
H0(this, "checkSelectOption", throttle(
|
|
@@ -49675,7 +49721,7 @@ class Editor {
|
|
|
49675
49721
|
processUndosMaxFrameTime: Number.MAX_VALUE
|
|
49676
49722
|
}, e), this.events.setMaxListeners(9999999), this.viewport = new Viewport(this, {
|
|
49677
49723
|
visFactories: e.visFactories
|
|
49678
|
-
}), this.history = new History(this);
|
|
49724
|
+
}), this.history = new History(this), this.scripts = new Scripts(this);
|
|
49679
49725
|
}
|
|
49680
49726
|
getObjectMaterial(e, s) {
|
|
49681
49727
|
if (!e)
|
|
@@ -49798,9 +49844,9 @@ class Editor {
|
|
|
49798
49844
|
return ei(this, null, function* () {
|
|
49799
49845
|
var r, T, de, Xe;
|
|
49800
49846
|
try {
|
|
49801
|
-
s && !n$1(s)
|
|
49847
|
+
s && !n$1(s) ? console.warn(
|
|
49802
49848
|
"fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
|
|
49803
|
-
)
|
|
49849
|
+
) : s && this.scripts.add(s), window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
|
|
49804
49850
|
let Ke;
|
|
49805
49851
|
if (typeof e == "string") {
|
|
49806
49852
|
const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
|
|
@@ -49818,11 +49864,11 @@ class Editor {
|
|
|
49818
49864
|
"vis-core 版本过低,可能会出现问题",
|
|
49819
49865
|
"json:" + Ke.c.version,
|
|
49820
49866
|
"sdk:" + this.sdkVersion
|
|
49821
|
-
), 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) {
|
|
49822
49868
|
const Je = parseTexture(Ke.v.bg.texture);
|
|
49823
49869
|
Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
|
|
49824
49870
|
}
|
|
49825
|
-
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(() => {
|
|
49826
49872
|
var Je;
|
|
49827
49873
|
(Je = this.viewport.vis) == null || Je.worker.dispose();
|
|
49828
49874
|
}), Ke;
|
|
@@ -49862,7 +49908,7 @@ class Editor {
|
|
|
49862
49908
|
return this.pencil ? (this.pencil.render(), this.pencil.renderer.domElement.toDataURL()) : "";
|
|
49863
49909
|
}
|
|
49864
49910
|
dispose() {
|
|
49865
|
-
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;
|
|
49866
49912
|
}
|
|
49867
49913
|
}
|
|
49868
49914
|
const BLOCKLISTED_GPUS = [
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.
|
|
1
|
+
declare const _default: "0.23.0";
|
|
2
2
|
export default _default;
|
package/dist/vis/base/index.d.ts
CHANGED
|
@@ -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,
|
|
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;
|