@shjjs/visual-ui 1.0.17 → 1.0.18

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.
Files changed (28) hide show
  1. package/es/commons/core/datasource/utils/axios.d.ts +70 -0
  2. package/es/commons/core/datasource/utils/axios.mjs +134 -0
  3. package/es/commons/core/datasource/utils/request.d.ts +1 -1
  4. package/es/commons/core/datasource/utils/request.mjs +1 -3
  5. package/es/components/commons-gaussian-splatting-view/index.vue.mjs +2 -2
  6. package/es/components/commons-gaussian-splatting-view/index.vue2.mjs +45 -46
  7. package/es/components/commons-product-model/index.vue.mjs +2 -2
  8. package/es/components/commons-product-model/index.vue2.mjs +58 -59
  9. package/es/components/commons-three-loader/index.vue.mjs +2 -2
  10. package/es/components/commons-three-loader/index.vue2.mjs +71 -72
  11. package/es/components/commons-three-loader3/index.vue.mjs +2 -2
  12. package/es/components/commons-three-loader3/index.vue2.mjs +45 -46
  13. package/es/widgets.css +1 -1
  14. package/lib/commons/core/datasource/utils/axios.js +1 -0
  15. package/lib/commons/core/datasource/utils/request.js +1 -1
  16. package/lib/components/commons-gaussian-splatting-view/index.vue.js +1 -1
  17. package/lib/components/commons-gaussian-splatting-view/index.vue2.js +1 -1
  18. package/lib/components/commons-product-model/index.vue.js +1 -1
  19. package/lib/components/commons-product-model/index.vue2.js +1 -1
  20. package/lib/components/commons-three-loader/index.vue.js +1 -1
  21. package/lib/components/commons-three-loader/index.vue2.js +1 -1
  22. package/lib/components/commons-three-loader3/index.vue.js +1 -1
  23. package/lib/components/commons-three-loader3/index.vue2.js +1 -1
  24. package/lib/widgets.css +1 -1
  25. package/package.json +1 -1
  26. package/es/commons/utils/babylon/ColorConvert.d.ts +0 -3
  27. package/es/commons/utils/babylon/ColorConvert.mjs +0 -21
  28. package/lib/commons/utils/babylon/ColorConvert.js +0 -1
@@ -1,14 +1,13 @@
1
- var U = Object.defineProperty;
2
- var W = (h, l, g) => l in h ? U(h, l, { enumerable: !0, configurable: !0, writable: !0, value: g }) : h[l] = g;
3
- var d = (h, l, g) => W(h, typeof l != "symbol" ? l + "" : l, g);
4
- import { defineComponent as k, watch as c, createElementBlock as F, openBlock as G, createElementVNode as V, createCommentVNode as K, normalizeClass as q, unref as A, toDisplayString as N, ref as L, onMounted as J, onBeforeUnmount as Y } from "vue";
1
+ var I = Object.defineProperty;
2
+ var _ = (h, l, m) => l in h ? I(h, l, { enumerable: !0, configurable: !0, writable: !0, value: m }) : h[l] = m;
3
+ var d = (h, l, m) => _(h, typeof l != "symbol" ? l + "" : l, m);
4
+ import { defineComponent as z, watch as f, createElementBlock as B, openBlock as D, createElementVNode as U, createCommentVNode as V, normalizeClass as K, unref as P, toDisplayString as W, ref as S, onMounted as q, onBeforeUnmount as N } from "vue";
5
5
  import "@babylonjs/loaders/glTF";
6
- import { cloneDeep as f, isEqual as m } from "lodash";
7
- import { useResizeObserver as j } from "@vueuse/core";
8
- import { Engine as Q, Scene as X, Color4 as S, Color3 as b, DefaultRenderingPipeline as Z, DepthOfFieldEffectBlurLevel as C, Vector3 as v, DirectionalLight as $, ShadowGenerator as O, Tools as z, SceneLoader as ee } from "@babylonjs/core";
9
- import { hex2Color4 as T, hex2Color3 as w } from "../../commons/utils/babylon/ColorConvert.mjs";
10
- const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model" }), he = /* @__PURE__ */ k({
11
- ...te,
6
+ import { cloneDeep as c, isEqual as g } from "lodash";
7
+ import { useResizeObserver as J } from "@vueuse/core";
8
+ import { Engine as Y, Scene as j, Color4 as y, Color3 as b, DefaultRenderingPipeline as Q, DepthOfFieldEffectBlurLevel as A, Vector3 as v, DirectionalLight as X, ShadowGenerator as Z, Tools as G, SceneLoader as $ } from "@babylonjs/core";
9
+ const O = { class: "zerov-widget" }, ee = z({ name: "zv-commons-product-model" }), re = /* @__PURE__ */ z({
10
+ ...ee,
12
11
  props: {
13
12
  basicOption: {},
14
13
  basicEvents: {},
@@ -18,10 +17,10 @@ const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model"
18
17
  "on-load-success",
19
18
  "on-play-animation"
20
19
  ],
21
- setup(h, { expose: l, emit: g }) {
22
- const x = g, o = h, I = (i, s) => {
23
- const u = L(), y = L(), P = L(!0);
24
- class H {
20
+ setup(h, { expose: l, emit: m }) {
21
+ const x = m, o = h, T = (i, s) => {
22
+ const u = S(), w = S(), E = S(!0);
23
+ class k {
25
24
  // eslint-disable-next-line no-useless-constructor
26
25
  constructor(e) {
27
26
  // optional, but needed due to interface definitions
@@ -29,13 +28,13 @@ const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model"
29
28
  this.loadingUIText = e;
30
29
  }
31
30
  displayLoadingUI() {
32
- u.value && (P.value = !0);
31
+ u.value && (E.value = !0);
33
32
  }
34
33
  hideLoadingUI() {
35
- u.value && (P.value = !1);
34
+ u.value && (E.value = !1);
36
35
  }
37
36
  }
38
- class B {
37
+ class M {
39
38
  constructor(e, t, n) {
40
39
  d(this, "scene");
41
40
  d(this, "engine");
@@ -48,46 +47,46 @@ const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model"
48
47
  d(this, "defaultPipeline");
49
48
  this.canvas = e, this.option = t, this.events = n;
50
49
  try {
51
- this.engine = new Q(this.canvas, !0, {}, !1), this.engine.loadingScreen = new H(""), window.addEventListener("resize", () => {
50
+ this.engine = new Y(this.canvas, !0, {}, !1), this.engine.loadingScreen = new k(""), window.addEventListener("resize", () => {
52
51
  this.engine.resize();
53
52
  }), this.scene = this.createScene();
54
53
  } catch {
55
54
  }
56
55
  }
57
56
  createScene() {
58
- return this.engine.displayLoadingUI(), this.scene = new X(this.engine), this.option.scene.colorShow ? this.scene.clearColor = T(this.option.scene.color, new S(0, 0, 0, 0)) : this.scene.clearColor = new S(0, 0, 0, 0), this.scene.fogEnabled = this.option.scene.fogEnabled, this.scene.fogMode = this.option.scene.fogMode || 1, this.scene.fogColor = w(this.option.scene.fogColor, new b(1, 1, 1)), this.scene.fogEnd = this.option.scene.fogEnd || 60, this.scene.fogStart = this.option.scene.fogStart || 1, this.scene.fogDensity = this.option.scene.fogDensity || 0.1, this.scene.createDefaultCamera(!0, !1, !0), this.updateMeshs(this.scene), this.scene;
57
+ return this.engine.displayLoadingUI(), this.scene = new j(this.engine), this.option.scene.colorShow ? this.scene.clearColor = y.FromHexString(this.option.scene.color || "#000000") : this.scene.clearColor = new y(0, 0, 0, 0), this.scene.fogEnabled = this.option.scene.fogEnabled, this.scene.fogMode = this.option.scene.fogMode || 1, this.scene.fogColor = b.FromHexString(this.option.scene.fogColor || "#ffffff"), this.scene.fogEnd = this.option.scene.fogEnd || 60, this.scene.fogStart = this.option.scene.fogStart || 1, this.scene.fogDensity = this.option.scene.fogDensity || 0.1, this.scene.createDefaultCamera(!0, !1, !0), this.updateMeshs(this.scene), this.scene;
59
58
  }
60
59
  updateScenePipeline(e) {
61
- this.scene.activeCamera && e && (e.enabled ? (this.defaultPipeline || (this.defaultPipeline = new Z(
60
+ this.scene.activeCamera && e && (e.enabled ? (this.defaultPipeline || (this.defaultPipeline = new Q(
62
61
  "defaultPipeline",
63
62
  !0,
64
63
  this.scene,
65
64
  [this.scene.activeCamera]
66
- )), this.defaultPipeline.samples = e.samples ? 4 : 1, this.defaultPipeline.fxaaEnabled = e.fxaaEnabled, this.defaultPipeline.grainEnabled = e.grainEnabled, this.defaultPipeline.grain.intensity = e.grainIntensity, this.defaultPipeline.grain.animated = e.grainAnimated, this.defaultPipeline.bloomEnabled = e.bloomEnabled, this.defaultPipeline.bloomThreshold = e.bloomThreshold, this.defaultPipeline.bloomWeight = e.bloomWeight, this.defaultPipeline.bloomKernel = e.bloomKernel, this.defaultPipeline.bloomScale = e.bloomScale, this.defaultPipeline.depthOfFieldEnabled = e.depthOfFieldEnabled, e.depthOfFieldBlurLevel < 1 ? this.defaultPipeline.depthOfFieldBlurLevel = C.Low : e.depthOfFieldBlurLevel < 2 ? this.defaultPipeline.depthOfFieldBlurLevel = C.Medium : e.depthOfFieldBlurLevel < 3 && (this.defaultPipeline.depthOfFieldBlurLevel = C.High), this.defaultPipeline.depthOfField.focusDistance = e.depthOfFieldFocusDistance, this.defaultPipeline.depthOfField.fStop = e.depthOfFieldFStop, this.defaultPipeline.depthOfField.focalLength = e.depthOfFieldFocalLength, this.defaultPipeline.chromaticAberrationEnabled = e.chromaticAberrationEnabled, this.defaultPipeline.chromaticAberration.aberrationAmount = e.chromaticAberrationAberrationAmount, this.defaultPipeline.chromaticAberration.radialIntensity = e.chromaticAberrationRadialIntensity, e.chromaticAberrationDirection === 0 ? (this.defaultPipeline.chromaticAberration.direction.x = 0, this.defaultPipeline.chromaticAberration.direction.y = 0) : (this.defaultPipeline.chromaticAberration.direction.x = Math.sin(e.chromaticAberrationDirection), this.defaultPipeline.chromaticAberration.direction.y = Math.cos(e.chromaticAberrationDirection)), this.defaultPipeline.sharpenEnabled = e.sharpenEnabled, this.defaultPipeline.sharpen.edgeAmount = e.sharpenEdgeAmount, this.defaultPipeline.sharpen.colorAmount = e.sharpenColorAmount) : this.defaultPipeline && (this.defaultPipeline.dispose(), this.defaultPipeline = null));
65
+ )), this.defaultPipeline.samples = e.samples ? 4 : 1, this.defaultPipeline.fxaaEnabled = e.fxaaEnabled, this.defaultPipeline.grainEnabled = e.grainEnabled, this.defaultPipeline.grain.intensity = e.grainIntensity, this.defaultPipeline.grain.animated = e.grainAnimated, this.defaultPipeline.bloomEnabled = e.bloomEnabled, this.defaultPipeline.bloomThreshold = e.bloomThreshold, this.defaultPipeline.bloomWeight = e.bloomWeight, this.defaultPipeline.bloomKernel = e.bloomKernel, this.defaultPipeline.bloomScale = e.bloomScale, this.defaultPipeline.depthOfFieldEnabled = e.depthOfFieldEnabled, e.depthOfFieldBlurLevel < 1 ? this.defaultPipeline.depthOfFieldBlurLevel = A.Low : e.depthOfFieldBlurLevel < 2 ? this.defaultPipeline.depthOfFieldBlurLevel = A.Medium : e.depthOfFieldBlurLevel < 3 && (this.defaultPipeline.depthOfFieldBlurLevel = A.High), this.defaultPipeline.depthOfField.focusDistance = e.depthOfFieldFocusDistance, this.defaultPipeline.depthOfField.fStop = e.depthOfFieldFStop, this.defaultPipeline.depthOfField.focalLength = e.depthOfFieldFocalLength, this.defaultPipeline.chromaticAberrationEnabled = e.chromaticAberrationEnabled, this.defaultPipeline.chromaticAberration.aberrationAmount = e.chromaticAberrationAberrationAmount, this.defaultPipeline.chromaticAberration.radialIntensity = e.chromaticAberrationRadialIntensity, e.chromaticAberrationDirection === 0 ? (this.defaultPipeline.chromaticAberration.direction.x = 0, this.defaultPipeline.chromaticAberration.direction.y = 0) : (this.defaultPipeline.chromaticAberration.direction.x = Math.sin(e.chromaticAberrationDirection), this.defaultPipeline.chromaticAberration.direction.y = Math.cos(e.chromaticAberrationDirection)), this.defaultPipeline.sharpenEnabled = e.sharpenEnabled, this.defaultPipeline.sharpen.edgeAmount = e.sharpenEdgeAmount, this.defaultPipeline.sharpen.colorAmount = e.sharpenColorAmount) : this.defaultPipeline && (this.defaultPipeline.dispose(), this.defaultPipeline = null));
67
66
  }
68
67
  updateScene(e) {
69
- e.colorShow ? this.scene.clearColor = T(e.color, new S(1, 1, 1, 1)) : this.scene.clearColor = new S(0, 0, 0, 0), this.scene.fogEnabled = e.fogEnabled, this.scene.fogMode = e.fogMode || 1, this.scene.fogColor = w(e.fogColor, new b(1, 1, 1)), this.scene.fogEnd = e.fogEnd || 60, this.scene.fogStart = e.fogStart || 1, this.scene.fogDensity = e.fogDensity || 0.1;
68
+ e.colorShow ? this.scene.clearColor = y.FromHexString(e.color || "#000000") : this.scene.clearColor = new y(0, 0, 0, 0), this.scene.fogEnabled = e.fogEnabled, this.scene.fogMode = e.fogMode || 1, this.scene.fogColor = b.FromHexString(e.fogColor || "#ffffff"), this.scene.fogEnd = e.fogEnd || 60, this.scene.fogStart = e.fogStart || 1, this.scene.fogDensity = e.fogDensity || 0.1;
70
69
  }
71
70
  updateShadowsLight(e) {
72
71
  if (e.show) {
73
72
  if (this.shadowsLight) {
74
- this.shadowsLight.direction = new v(...e.direction), this.shadowsLight.position = new v(...e.position), this.shadowsLight.intensity = e.intensity, this.shadowsLight.diffuse = w(e.diffuse, b.White()), this.shadowGenerator.mapSize = e.mapSize;
73
+ this.shadowsLight.direction = new v(...e.direction), this.shadowsLight.position = new v(...e.position), this.shadowsLight.intensity = e.intensity, this.shadowsLight.diffuse = b.FromHexString(e.diffuse || "#ffffff"), this.shadowGenerator.mapSize = e.mapSize;
75
74
  return;
76
75
  }
77
- this.shadowsLight = new $("shadowsLight", new v(...e.direction), this.scene), this.shadowsLight.intensity = e.intensity || 0.6, this.shadowsLight.diffuse = w(e.diffuse, b.White()), this.shadowsLight.position = new v(...e.position), this.shadowGenerator = new O(e.mapSize, this.shadowsLight);
76
+ this.shadowsLight = new X("shadowsLight", new v(...e.direction), this.scene), this.shadowsLight.intensity = e.intensity || 0.6, this.shadowsLight.diffuse = b.FromHexString(e.diffuse || "#ffffff"), this.shadowsLight.position = new v(...e.position), this.shadowGenerator = new Z(e.mapSize, this.shadowsLight);
78
77
  } else
79
78
  this.shadowsLight && (this.shadowsLight.dispose(), this.shadowsLight = null);
80
79
  }
81
80
  updateCamera(e) {
82
81
  const t = this.scene.activeCamera;
83
- t && (e.radius && (t.radius = e.radius), t.beta = z.ToRadians(e.beta), t.alpha = z.ToRadians(e.alpha), t.useAutoRotationBehavior = e.autoRotation, t.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, t.panningSensibility = 1 / (e.panningSensibility || 0.01), t.lowerRadiusLimit = e.lowerRadiusLimit, t.upperRadiusLimit = e.upperRadiusLimit, t.lowerBetaLimit = 0, t.upperBetaLimit = Math.PI / 2.1);
82
+ t && (e.radius && (t.radius = e.radius), t.beta = G.ToRadians(e.beta), t.alpha = G.ToRadians(e.alpha), t.useAutoRotationBehavior = e.autoRotation, t.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, t.panningSensibility = 1 / (e.panningSensibility || 0.01), t.lowerRadiusLimit = e.lowerRadiusLimit, t.upperRadiusLimit = e.upperRadiusLimit, t.lowerBetaLimit = 0, t.upperBetaLimit = Math.PI / 2.1);
84
83
  }
85
84
  updateDefaultEnvironment(e) {
86
85
  this.environmentHelper && this.environmentHelper.dispose(), this.environmentHelper = this.scene.createDefaultEnvironment({
87
86
  // 是否创建地面
88
87
  createGround: e.createGround,
89
88
  // 地面颜色
90
- groundColor: w(e.groundColor, new b(1, 1, 1)),
89
+ groundColor: b.FromHexString(e.groundColor || "#ffffff"),
91
90
  // 地面大小
92
91
  groundSize: e.groundSize || 15,
93
92
  // 地面透明度
@@ -127,8 +126,8 @@ const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model"
127
126
  }), this.environmentHelper.ground && (this.environmentHelper.ground.position.y += 0.01);
128
127
  }
129
128
  updateMeshs(e) {
130
- e.meshes.forEach((t) => setTimeout(() => t.dispose())), ee.ImportMeshAsync("", this.option.meshs.url, "", e, (t) => {
131
- y.value = (t.loaded / t.total * 100).toFixed(2);
129
+ e.meshes.forEach((t) => setTimeout(() => t.dispose())), $.ImportMeshAsync("", this.option.meshs.url, "", e, (t) => {
130
+ w.value = (t.loaded / t.total * 100).toFixed(2);
132
131
  }).then((t) => {
133
132
  const n = t.meshes;
134
133
  if (this.option.animationGroups = e.animationGroups.map((r) => ({
@@ -169,71 +168,71 @@ const ie = { class: "zerov-widget" }, te = k({ name: "zv-commons-product-model"
169
168
  }
170
169
  }
171
170
  }
172
- const p = L();
173
- return J(() => {
174
- i.meshs && (p.value = new B(u.value, i, s).run(), j(u.value, (D) => {
171
+ const p = S();
172
+ return q(() => {
173
+ i.meshs && (p.value = new M(u.value, i, s).run(), J(u.value, (R) => {
175
174
  p.value && p.value.engine.resize();
176
175
  }));
177
- }), Y(() => {
176
+ }), N(() => {
178
177
  p.value && p.value.dispose();
179
178
  }), {
180
179
  canvasRef: u,
181
180
  babylon: p,
182
- Babylon: B,
183
- babylonLoadingStatus: P,
184
- babylonLoadingTitle: y
181
+ Babylon: M,
182
+ babylonLoadingStatus: E,
183
+ babylonLoadingTitle: w
185
184
  };
186
- }, { canvasRef: E, babylon: a, Babylon: M, babylonLoadingStatus: R, babylonLoadingTitle: _ } = I(o.basicOption, o.basicEvents);
185
+ }, { canvasRef: L, babylon: a, Babylon: C, babylonLoadingStatus: F, babylonLoadingTitle: H } = T(o.basicOption, o.basicEvents);
187
186
  return l({
188
187
  playAnimation: (i, s) => {
189
- const u = i[0].value, y = {
188
+ const u = i[0].value, w = {
190
189
  loop: i[1].keys[0].defaultValue,
191
190
  speedRatio: i[1].keys[1].defaultValue
192
191
  };
193
- a.value.playAnimation(u, y);
192
+ a.value.playAnimation(u, w);
194
193
  }
195
- }), c(() => f(o.basicOption.environment), (i, s) => {
196
- !m(i, s) && a.value && a.value.updateDefaultEnvironment(i);
194
+ }), f(() => c(o.basicOption.environment), (i, s) => {
195
+ !g(i, s) && a.value && a.value.updateDefaultEnvironment(i);
197
196
  }, {
198
197
  deep: !0
199
- }), c(() => f(o.basicOption.shadow), (i, s) => {
200
- !m(i, s) && a.value && a.value.updateShadowsLight(i);
198
+ }), f(() => c(o.basicOption.shadow), (i, s) => {
199
+ !g(i, s) && a.value && a.value.updateShadowsLight(i);
201
200
  }, {
202
201
  deep: !0
203
- }), c(() => f(o.basicOption.camera), (i, s) => {
204
- !m(i, s) && a.value && a.value.updateCamera(i);
202
+ }), f(() => c(o.basicOption.camera), (i, s) => {
203
+ !g(i, s) && a.value && a.value.updateCamera(i);
205
204
  }, {
206
205
  deep: !0
207
- }), c(() => f(o.basicOption.meshs), (i, s) => {
208
- !m(i, s) && a.value && (a.value.dispose(), a.value = new M(E.value, o.basicOption, o.basicEvents).run());
206
+ }), f(() => c(o.basicOption.meshs), (i, s) => {
207
+ !g(i, s) && a.value && (a.value.dispose(), a.value = new C(L.value, o.basicOption, o.basicEvents).run());
209
208
  }, {
210
209
  deep: !0
211
- }), c(() => f(o.basicOption.defaultAnimation), (i, s) => {
212
- !m(i, s) && a.value && (a.value.dispose(), a.value = new M(E.value, o.basicOption, o.basicEvents).run());
210
+ }), f(() => c(o.basicOption.defaultAnimation), (i, s) => {
211
+ !g(i, s) && a.value && (a.value.dispose(), a.value = new C(L.value, o.basicOption, o.basicEvents).run());
213
212
  }, {
214
213
  deep: !0
215
- }), c(() => f(o.basicOption.scene), (i, s) => {
216
- !m(i, s) && a.value && a.value.updateScene(i);
214
+ }), f(() => c(o.basicOption.scene), (i, s) => {
215
+ !g(i, s) && a.value && a.value.updateScene(i);
217
216
  }, {
218
217
  deep: !0
219
- }), c(() => f(o.basicOption.pipelineOption), (i, s) => {
220
- !m(i, s) && a.value && a.value.updateScenePipeline(i);
218
+ }), f(() => c(o.basicOption.pipelineOption), (i, s) => {
219
+ !g(i, s) && a.value && a.value.updateScenePipeline(i);
221
220
  }, {
222
221
  deep: !0
223
- }), (i, s) => (G(), F("div", ie, [
224
- V("canvas", {
222
+ }), (i, s) => (D(), B("div", O, [
223
+ U("canvas", {
225
224
  ref_key: "canvasRef",
226
- ref: E,
227
- class: q(["widget", { show: !A(R) }])
225
+ ref: L,
226
+ class: K(["widget", { show: !P(F) }])
228
227
  }, null, 2),
229
- A(R) ? (G(), F("div", {
228
+ P(F) ? (D(), B("div", {
230
229
  key: 0,
231
230
  ref: "babylonLoadingRef",
232
231
  class: "babylon-loading"
233
- }, " 正在加载模型...(" + N(A(_)) + "%) ", 513)) : K("", !0)
232
+ }, " 正在加载模型...(" + W(P(H)) + "%) ", 513)) : V("", !0)
234
233
  ]));
235
234
  }
236
235
  });
237
236
  export {
238
- he as default
237
+ re as default
239
238
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./index.vue2.mjs";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-5c0391e0"]]);
4
+ const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-2f6cb8d6"]]);
5
5
  export {
6
- m as default
6
+ f as default
7
7
  };
@@ -1,14 +1,13 @@
1
- var q = Object.defineProperty;
2
- var N = (f, u, b) => u in f ? q(f, u, { enumerable: !0, configurable: !0, writable: !0, value: b }) : f[u] = b;
3
- var v = (f, u, b) => N(f, typeof u != "symbol" ? u + "" : u, b);
4
- import { defineComponent as _, watch as r, createElementBlock as M, openBlock as I, createElementVNode as V, createCommentVNode as K, normalizeClass as J, unref as C, toDisplayString as Z, ref as w, onMounted as j, onBeforeUnmount as Q } from "vue";
1
+ var U = Object.defineProperty;
2
+ var k = (f, u, g) => u in f ? U(f, u, { enumerable: !0, configurable: !0, writable: !0, value: g }) : f[u] = g;
3
+ var v = (f, u, g) => k(f, typeof u != "symbol" ? u + "" : u, g);
4
+ import { defineComponent as I, watch as r, createElementBlock as T, openBlock as M, createElementVNode as q, createCommentVNode as N, normalizeClass as V, unref as E, toDisplayString as K, ref as L, onMounted as J, onBeforeUnmount as Z } from "vue";
5
5
  import "@babylonjs/loaders/glTF";
6
- import { cloneDeep as h, isEqual as d } from "lodash";
7
- import { Vector3 as c, Engine as X, Scene as Y, Color4 as P, Color3 as y, DefaultRenderingPipeline as $, DepthOfFieldEffectBlurLevel as R, ArcRotateCamera as O, Tools as A, HemisphericLight as ee, DirectionalLight as ie, PointLight as te, SceneLoader as se } from "@babylonjs/core";
8
- import { useResizeObserver as oe } from "@vueuse/core";
9
- import { hex2Color4 as W, hex2Color3 as L } from "../../commons/utils/babylon/ColorConvert.mjs";
10
- const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }), be = /* @__PURE__ */ _({
11
- ...ae,
6
+ import { cloneDeep as d, isEqual as h } from "lodash";
7
+ import { Vector3 as c, Engine as j, Scene as Q, Color4 as P, Color3 as y, DefaultRenderingPipeline as X, DepthOfFieldEffectBlurLevel as R, ArcRotateCamera as Y, Tools as S, HemisphericLight as $, DirectionalLight as O, PointLight as ee, SceneLoader as ie } from "@babylonjs/core";
8
+ import { useResizeObserver as te } from "@vueuse/core";
9
+ const se = { class: "zerov-widget" }, oe = I({ name: "zv-commons-three-loader" }), ce = /* @__PURE__ */ I({
10
+ ...oe,
12
11
  props: {
13
12
  basicOption: {},
14
13
  basicEvents: {},
@@ -18,10 +17,10 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
18
17
  "on-load-success",
19
18
  "on-play-animation"
20
19
  ],
21
- setup(f, { expose: u, emit: b }) {
22
- const x = b, a = f, G = (t, n) => {
23
- const p = w(), z = w(), S = w(!0);
24
- class k {
20
+ setup(f, { expose: u, emit: g }) {
21
+ const x = g, a = f, H = (t, n) => {
22
+ const b = L(), B = L(), A = L(!0);
23
+ class W {
25
24
  // eslint-disable-next-line no-useless-constructor
26
25
  constructor(e) {
27
26
  // optional, but needed due to interface definitions
@@ -29,13 +28,13 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
29
28
  this.loadingUIText = e;
30
29
  }
31
30
  displayLoadingUI() {
32
- p.value && (S.value = !0);
31
+ b.value && (A.value = !0);
33
32
  }
34
33
  hideLoadingUI() {
35
- p.value && (S.value = !1);
34
+ b.value && (A.value = !1);
36
35
  }
37
36
  }
38
- class F {
37
+ class D {
39
38
  constructor(e, s, i) {
40
39
  v(this, "scene");
41
40
  v(this, "engine");
@@ -43,17 +42,17 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
43
42
  v(this, "defaultPipeline");
44
43
  this.canvas = e, this.option = s, this.events = i;
45
44
  try {
46
- this.engine = new X(this.canvas, !0, {}, !1), this.engine.loadingScreen = new k(""), window.addEventListener("resize", () => {
45
+ this.engine = new j(this.canvas, !0, {}, !1), this.engine.loadingScreen = new W(""), window.addEventListener("resize", () => {
47
46
  this.engine.resize();
48
47
  }), this.scene = this.createScene();
49
48
  } catch {
50
49
  }
51
50
  }
52
51
  createScene() {
53
- return this.scene = new Y(this.engine), this.option.scene.colorShow ? this.scene.clearColor = W(this.option.scene.color, new P(1, 1, 1, 1)) : this.scene.clearColor = new P(0, 0, 0, 0), this.scene.fogEnabled = this.option.scene.fogEnabled, this.scene.fogMode = this.option.scene.fogMode || 1, this.scene.fogColor = L(this.option.scene.fogColor, new y(1, 1, 1)), this.scene.fogEnd = this.option.scene.fogEnd || 60, this.scene.fogStart = this.option.scene.fogStart || 1, this.scene.fogDensity = this.option.scene.fogDensity || 0.1, this.createCamera(this.option.camera, this.scene), this.createLights(this.option.lights, this.scene), this.createMeshs(this.scene), this.scene;
52
+ return this.scene = new Q(this.engine), this.option.scene.colorShow ? this.scene.clearColor = P.FromHexString(this.option.scene.color || "#000000") : this.scene.clearColor = new P(0, 0, 0, 0), this.scene.fogEnabled = this.option.scene.fogEnabled, this.scene.fogMode = this.option.scene.fogMode || 1, this.scene.fogColor = y.FromHexString(this.option.scene.fogColor || "#ffffff"), this.scene.fogEnd = this.option.scene.fogEnd || 60, this.scene.fogStart = this.option.scene.fogStart || 1, this.scene.fogDensity = this.option.scene.fogDensity || 0.1, this.createCamera(this.option.camera, this.scene), this.createLights(this.option.lights, this.scene), this.createMeshs(this.scene), this.scene;
54
53
  }
55
54
  updateScenePipeline(e) {
56
- this.scene.activeCamera && e && (e.enabled ? (this.defaultPipeline || (this.defaultPipeline = new $(
55
+ this.scene.activeCamera && e && (e.enabled ? (this.defaultPipeline || (this.defaultPipeline = new X(
57
56
  "defaultPipeline",
58
57
  !0,
59
58
  this.scene,
@@ -61,15 +60,15 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
61
60
  )), this.defaultPipeline.samples = e.samples ? 4 : 1, this.defaultPipeline.fxaaEnabled = e.fxaaEnabled, this.defaultPipeline.grainEnabled = e.grainEnabled, this.defaultPipeline.grain.intensity = e.grainIntensity, this.defaultPipeline.grain.animated = e.grainAnimated, this.defaultPipeline.bloomEnabled = e.bloomEnabled, this.defaultPipeline.bloomThreshold = e.bloomThreshold, this.defaultPipeline.bloomWeight = e.bloomWeight, this.defaultPipeline.bloomKernel = e.bloomKernel, this.defaultPipeline.bloomScale = e.bloomScale, this.defaultPipeline.depthOfFieldEnabled = e.depthOfFieldEnabled, e.depthOfFieldBlurLevel < 1 ? this.defaultPipeline.depthOfFieldBlurLevel = R.Low : e.depthOfFieldBlurLevel < 2 ? this.defaultPipeline.depthOfFieldBlurLevel = R.Medium : e.depthOfFieldBlurLevel < 3 && (this.defaultPipeline.depthOfFieldBlurLevel = R.High), this.defaultPipeline.depthOfField.focusDistance = e.depthOfFieldFocusDistance, this.defaultPipeline.depthOfField.fStop = e.depthOfFieldFStop, this.defaultPipeline.depthOfField.focalLength = e.depthOfFieldFocalLength, this.defaultPipeline.chromaticAberrationEnabled = e.chromaticAberrationEnabled, this.defaultPipeline.chromaticAberration.aberrationAmount = e.chromaticAberrationAberrationAmount, this.defaultPipeline.chromaticAberration.radialIntensity = e.chromaticAberrationRadialIntensity, e.chromaticAberrationDirection === 0 ? (this.defaultPipeline.chromaticAberration.direction.x = 0, this.defaultPipeline.chromaticAberration.direction.y = 0) : (this.defaultPipeline.chromaticAberration.direction.x = Math.sin(e.chromaticAberrationDirection), this.defaultPipeline.chromaticAberration.direction.y = Math.cos(e.chromaticAberrationDirection)), this.defaultPipeline.sharpenEnabled = e.sharpenEnabled, this.defaultPipeline.sharpen.edgeAmount = e.sharpenEdgeAmount, this.defaultPipeline.sharpen.colorAmount = e.sharpenColorAmount) : this.defaultPipeline && (this.defaultPipeline.dispose(), this.defaultPipeline = null));
62
61
  }
63
62
  updateScene(e) {
64
- e.colorShow ? this.scene.clearColor = W(e.color, new P(1, 1, 1, 1)) : this.scene.clearColor = new P(0, 0, 0, 0), this.scene.fogEnabled = e.fogEnabled, this.scene.fogMode = e.fogMode || 1, this.scene.fogColor = L(e.fogColor, new y(1, 1, 1)), this.scene.fogEnd = e.fogEnd || 60, this.scene.fogStart = e.fogStart || 1, this.scene.fogDensity = e.fogDensity || 0.1;
63
+ e.colorShow ? this.scene.clearColor = P.FromHexString(e.color || "#000000") : this.scene.clearColor = new P(0, 0, 0, 0), this.scene.fogEnabled = e.fogEnabled, this.scene.fogMode = e.fogMode || 1, this.scene.fogColor = y.FromHexString(e.fogColor || "#ffffff"), this.scene.fogEnd = e.fogEnd || 60, this.scene.fogStart = e.fogStart || 1, this.scene.fogDensity = e.fogDensity || 0.1;
65
64
  }
66
65
  createCamera(e, s) {
67
- const i = new O("", A.ToRadians(e.alpha || 90), A.ToRadians(e.beta || 75), e.radius || 1, new c(...e.target), s);
68
- i.attachControl(p.value, !0), i.useAutoRotationBehavior = e.autoRotation, i.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, i.zoomToMouseLocation = e.zoomToMouseLocation, i.lowerRadiusLimit = e.lowerRadiusLimit, i.upperRadiusLimit = e.upperRadiusLimit, i.minZ = 0.01;
66
+ const i = new Y("", S.ToRadians(e.alpha || 90), S.ToRadians(e.beta || 75), e.radius || 1, new c(...e.target), s);
67
+ i.attachControl(b.value, !0), i.useAutoRotationBehavior = e.autoRotation, i.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, i.zoomToMouseLocation = e.zoomToMouseLocation, i.lowerRadiusLimit = e.lowerRadiusLimit, i.upperRadiusLimit = e.upperRadiusLimit, i.minZ = 0.01;
69
68
  }
70
69
  updateCamera(e) {
71
70
  const s = this.scene.activeCamera;
72
- s && (e.radius && (s.radius = e.radius), s.beta = A.ToRadians(e.beta), s.alpha = A.ToRadians(e.alpha), s.useAutoRotationBehavior = e.autoRotation, s.zoomToMouseLocation = e.zoomToMouseLocation, s.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, s.lowerRadiusLimit = e.lowerRadiusLimit, s.upperRadiusLimit = e.upperRadiusLimit, s.target = new c(...e.target));
71
+ s && (e.radius && (s.radius = e.radius), s.beta = S.ToRadians(e.beta), s.alpha = S.ToRadians(e.alpha), s.useAutoRotationBehavior = e.autoRotation, s.zoomToMouseLocation = e.zoomToMouseLocation, s.wheelDeltaPercentage = e.wheelDeltaPercentage || 0.01, s.lowerRadiusLimit = e.lowerRadiusLimit, s.upperRadiusLimit = e.upperRadiusLimit, s.target = new c(...e.target));
73
72
  }
74
73
  createLights(e, s) {
75
74
  this.scene && this.scene.lights && this.scene.lights.forEach((i, l) => {
@@ -79,23 +78,23 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
79
78
  }), setTimeout(() => {
80
79
  e.forEach((i) => {
81
80
  if (i.type === "HemisphericLight") {
82
- const l = new ee("", new c(...i.direction), s);
83
- l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.groundColor = L(i.groundColor, y.White()), l.diffuse = L(i.diffuse, y.White());
81
+ const l = new $("", new c(...i.direction), s);
82
+ l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.groundColor = y.FromHexString(i.groundColor || "#ffffff"), l.diffuse = y.FromHexString(i.diffuse || "#ffffff");
84
83
  }
85
84
  if (i.type === "DirectionalLight") {
86
- const l = new ie("", new c(...i.direction), s);
87
- l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.diffuse = L(i.diffuse, y.White());
85
+ const l = new O("", new c(...i.direction), s);
86
+ l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.diffuse = y.FromHexString(i.diffuse || "#ffffff");
88
87
  }
89
88
  if (i.type === "PointLight") {
90
- const l = new te("", new c(...i.position), s);
91
- l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.diffuse = L(i.diffuse, y.White());
89
+ const l = new ee("", new c(...i.position), s);
90
+ l.intensity = i.intensity !== void 0 ? i.intensity : 0.5, l.diffuse = y.FromHexString(i.diffuse || "#ffffff");
92
91
  }
93
92
  });
94
93
  });
95
94
  }
96
95
  createMeshs(e) {
97
- e.meshes.forEach((s) => setTimeout(() => s.dispose())), se.ImportMeshAsync("", this.option.meshs.url, "", e, (s) => {
98
- z.value = (s.loaded / s.total * 100).toFixed(2);
96
+ e.meshes.forEach((s) => setTimeout(() => s.dispose())), ie.ImportMeshAsync("", this.option.meshs.url, "", e, (s) => {
97
+ B.value = (s.loaded / s.total * 100).toFixed(2);
99
98
  }).then((s) => {
100
99
  this.meshe = s.meshes, this.updateScenePipeline(this.option.pipelineOption), this.option.animationGroups = e.animationGroups.map((i) => ({
101
100
  uniqueId: i.uniqueId,
@@ -113,14 +112,14 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
113
112
  }
114
113
  setMeshSize(e) {
115
114
  if (e.autoSize) {
116
- const i = this.meshe[0].getBoundingInfo().boundingBox, g = 0.7 / (Math.max(
115
+ const i = this.meshe[0].getBoundingInfo().boundingBox, p = 0.7 / (Math.max(
117
116
  i.maximumWorld.x - i.minimumWorld.x,
118
117
  i.maximumWorld.y - i.minimumWorld.y,
119
118
  i.maximumWorld.z - i.minimumWorld.z
120
119
  ) || 1);
121
- this.meshe[0].scaling = new c(g, g, g);
122
- const H = i.centerWorld;
123
- this.meshe[0].position = this.meshe[0].position.subtract(H.multiplyByFloats(g, g, g)), this.meshe[0].rotation = new c(0, 0, 0);
120
+ this.meshe[0].scaling = new c(p, p, p);
121
+ const G = i.centerWorld;
122
+ this.meshe[0].position = this.meshe[0].position.subtract(G.multiplyByFloats(p, p, p)), this.meshe[0].rotation = new c(0, 0, 0);
124
123
  } else {
125
124
  const { position: s, scaling: i, rotation: l } = e;
126
125
  this.meshe[0].position.set(s[0] || 0, s[1] || 0, s[2] || 0), this.meshe[0].scaling.set(i[0] || 1, i[1] || 1, i[2] || 1), this.meshe[0].rotation = new c(l[0] || 0, l[1] || 0, l[2] || 0);
@@ -143,79 +142,79 @@ const ne = { class: "zerov-widget" }, ae = _({ name: "zv-commons-three-loader" }
143
142
  }
144
143
  }
145
144
  }
146
- const m = w();
147
- return j(() => {
148
- t.meshs && (m.value = new F(p.value, t, n).run(), oe(p.value, (T) => {
145
+ const m = L();
146
+ return J(() => {
147
+ t.meshs && (m.value = new D(b.value, t, n).run(), te(b.value, (z) => {
149
148
  m.value && m.value.engine.resize();
150
149
  }));
151
- }), Q(() => {
150
+ }), Z(() => {
152
151
  m.value && (m.value.dispose(), m.value.meshe = []);
153
152
  }), {
154
- canvasRef: p,
153
+ canvasRef: b,
155
154
  babylon: m,
156
- Babylon: F,
157
- babylonLoadingStatus: S,
158
- babylonLoadingTitle: z
155
+ Babylon: D,
156
+ babylonLoadingStatus: A,
157
+ babylonLoadingTitle: B
159
158
  };
160
- }, { canvasRef: E, babylon: o, Babylon: B, babylonLoadingStatus: D, babylonLoadingTitle: U } = G(a.basicOption, a.basicEvents);
159
+ }, { canvasRef: w, babylon: o, Babylon: C, babylonLoadingStatus: F, babylonLoadingTitle: _ } = H(a.basicOption, a.basicEvents);
161
160
  return u({
162
161
  playAnimation: (t, n) => {
163
162
  o.value.playAnimation(t, n);
164
163
  }
165
- }), r(() => h(a.basicOption.camera), (t, n) => {
166
- !d(t, n) && o.value && o.value.updateCamera(t);
164
+ }), r(() => d(a.basicOption.camera), (t, n) => {
165
+ !h(t, n) && o.value && o.value.updateCamera(t);
167
166
  }, {
168
167
  deep: !0
169
- }), r(() => h(a.basicOption.scene), (t, n) => {
170
- !d(t, n) && o.value && o.value.updateScene(t);
168
+ }), r(() => d(a.basicOption.scene), (t, n) => {
169
+ !h(t, n) && o.value && o.value.updateScene(t);
171
170
  }, {
172
171
  deep: !0
173
- }), r(() => h(a.basicOption.lights), (t, n) => {
174
- !d(t, n) && o.value && o.value.createLights(t, o.value.scene);
172
+ }), r(() => d(a.basicOption.lights), (t, n) => {
173
+ !h(t, n) && o.value && o.value.createLights(t, o.value.scene);
175
174
  }, {
176
175
  deep: !0
177
- }), r(() => h(a.basicOption.meshs.url), (t, n) => {
178
- !d(t, n) && o.value && (o.value.dispose(), o.value = new B(E.value, a.basicOption, a.basicEvents).run());
176
+ }), r(() => d(a.basicOption.meshs.url), (t, n) => {
177
+ !h(t, n) && o.value && (o.value.dispose(), o.value = new C(w.value, a.basicOption, a.basicEvents).run());
179
178
  }, {
180
179
  deep: !0
181
- }), r(() => h(a.basicOption.meshs.position), (t, n) => {
182
- !d(t, n) && o.value && o.value.meshe[0] && o.value.meshe[0].position.set(t[0], t[1], t[2]);
180
+ }), r(() => d(a.basicOption.meshs.position), (t, n) => {
181
+ !h(t, n) && o.value && o.value.meshe[0] && o.value.meshe[0].position.set(t[0], t[1], t[2]);
183
182
  }, {
184
183
  deep: !0
185
- }), r(() => h(a.basicOption.meshs.scaling), (t, n) => {
186
- !d(t, n) && o.value && o.value.meshe[0] && o.value.meshe[0].scaling.set(t[0], t[1], t[2]);
184
+ }), r(() => d(a.basicOption.meshs.scaling), (t, n) => {
185
+ !h(t, n) && o.value && o.value.meshe[0] && o.value.meshe[0].scaling.set(t[0], t[1], t[2]);
187
186
  }, {
188
187
  deep: !0
189
- }), r(() => h(a.basicOption.meshs.rotation), (t, n) => {
190
- !d(t, n) && o.value && o.value.meshe[0] && (o.value.meshe[0].rotation = new c(t[0], t[1], t[2]));
188
+ }), r(() => d(a.basicOption.meshs.rotation), (t, n) => {
189
+ !h(t, n) && o.value && o.value.meshe[0] && (o.value.meshe[0].rotation = new c(t[0], t[1], t[2]));
191
190
  }, {
192
191
  deep: !0
193
- }), r(() => h(a.basicOption.meshs.autoSize), (t, n) => {
194
- !d(t, n) && o.value && o.value.meshe[0] && o.value.setMeshSize(a.basicOption.meshs);
192
+ }), r(() => d(a.basicOption.meshs.autoSize), (t, n) => {
193
+ !h(t, n) && o.value && o.value.meshe[0] && o.value.setMeshSize(a.basicOption.meshs);
195
194
  }, {
196
195
  deep: !0
197
- }), r(() => h(a.basicOption.defaultAnimation), (t, n) => {
198
- !d(t, n) && o.value && (o.value.dispose(), o.value = new B(E.value, a.basicOption, a.basicEvents).run());
196
+ }), r(() => d(a.basicOption.defaultAnimation), (t, n) => {
197
+ !h(t, n) && o.value && (o.value.dispose(), o.value = new C(w.value, a.basicOption, a.basicEvents).run());
199
198
  }, {
200
199
  deep: !0
201
- }), r(() => h(a.basicOption.pipelineOption), (t, n) => {
202
- !d(t, n) && o.value && o.value.updateScenePipeline(t);
200
+ }), r(() => d(a.basicOption.pipelineOption), (t, n) => {
201
+ !h(t, n) && o.value && o.value.updateScenePipeline(t);
203
202
  }, {
204
203
  deep: !0
205
- }), (t, n) => (I(), M("div", ne, [
206
- V("canvas", {
204
+ }), (t, n) => (M(), T("div", se, [
205
+ q("canvas", {
207
206
  ref_key: "canvasRef",
208
- ref: E,
209
- class: J(["widget", { show: !C(D) }])
207
+ ref: w,
208
+ class: V(["widget", { show: !E(F) }])
210
209
  }, null, 2),
211
- C(D) ? (I(), M("div", {
210
+ E(F) ? (M(), T("div", {
212
211
  key: 0,
213
212
  ref: "babylonLoadingRef",
214
213
  class: "babylon-loading"
215
- }, " 正在加载模型...(" + Z(C(U)) + "%) ", 513)) : K("", !0)
214
+ }, " 正在加载模型...(" + K(E(_)) + "%) ", 513)) : N("", !0)
216
215
  ]));
217
216
  }
218
217
  });
219
218
  export {
220
- be as default
219
+ ce as default
221
220
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./index.vue2.mjs";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-1fb6b2cd"]]);
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-a993de78"]]);
5
5
  export {
6
- f as default
6
+ p as default
7
7
  };