import { defineComponent as z, ref as Z, onMounted as q, onBeforeUnmount as K, watch as h, createElementBlock as N, openBlock as W, createElementVNode as Y, normalizeClass as J } from "vue";
import "@babylonjs/loaders/glTF";
import * as t from "@babylonjs/core";
import { cloneDeep as b, isEqual as f } from "lodash";
import "../text-text-basic/index.mjs";
import "../text-table-basic/index.mjs";
import "../chart-other-gauge/index.mjs";
import "../chart-other-gauge-stage/index.mjs";
import "../chart-other-gauge-grade/index.mjs";
import "../chart-other-word-cloud/index.mjs";
import "../chart-other-liquidfill/index.mjs";
import "../chart-other-funnel/index.mjs";
import "../chart-other-force/index.mjs";
import "../chart-other-radar/index.mjs";
import "../chart-other-funnel-split/index.mjs";
import "../chart-other-funnel-contrast/index.mjs";
import "../chart-other-candlestick-basic/index.mjs";
import "../chart-other-candlestick-shanghai/index.mjs";
import "../chart-other-candlestick-demo/index.mjs";
import "../chart-other-heatmap/index.mjs";
import "../chart-other-force2/index.mjs";
import "../chart-other-graph-basic/index.mjs";
import "../chart-other-graph-basic2/index.mjs";
import "../chart-other-graph-calendar/index.mjs";
import "../chart-other-tree-line/index.mjs";
import "../chart-other-treemap-basic/index.mjs";
import "../chart-other-sunburst-basic/index.mjs";
import "../chart-other-sunburst-basic2/index.mjs";
import "../chart-other-sunburst-basic3/index.mjs";
import "../chart-other-sunburst-basic4/index.mjs";
import "../chart-other-sunburst-book/index.mjs";
import "../chart-other-sunburst-radius/index.mjs";
import "../chart-other-sunburst-flavors/index.mjs";
import "../chart-other-parallel-basic/index.mjs";
import "../chart-other-parallel-mul/index.mjs";
import "../chart-other-circular-graph/index.mjs";
import "../map-earth-basic/index.mjs";
import "../map-earth-cool-tech/index.mjs";
import "../map-earth-particle/index.mjs";
import "../map-earth-hacker/index.mjs";
import "../map-earth-fly-line/index.mjs";
import "../chart-other-grid-percentage/index.mjs";
import "../chart-other-radar-stack/index.mjs";
import "../chart-other-funnel2/index.mjs";
import "../chart-other-label-gauge/index.mjs";
import "../chart-other-theme-river/index.mjs";
import "../chart-other-tree/index.mjs";
import "../chart-other-treemap/index.mjs";
import "../commons-product-model/index.mjs";
import "../commons-vr-photo/index.mjs";
import "../commons-vr-video/index.mjs";
import "../commons-three-loader/index.mjs";
import "./index.mjs";
import "../commons-loop-iterator/index.mjs";
import "../commons-gaussian-splatting-view/index.mjs";
import "../commons-babylon/index.mjs";
import "../commons-svg/index.mjs";
import "../commons-weather/index.mjs";
import "../commons-weather-dynamic/index.mjs";
import "../media-wavesurfer/index.mjs";
import "../interaction-tabs/index.mjs";
import "../interaction-tabs2/index.mjs";
import "../interaction-button/index.mjs";
import "../interaction-button-image/index.mjs";
import "../interaction-select/index.mjs";
import "../interaction-input/index.mjs";
import "../interaction-radio/index.mjs";
import "../interaction-slider/index.mjs";
import "../interaction-switch/index.mjs";
import "../interaction-data-picker/index.mjs";
import "../interaction-button-refresh/index.mjs";
import "../media-image/index.mjs";
import "../text-title/index.mjs";
import "../commons-qrcode/index.mjs";
import "../media-video/index.mjs";
import "../media-audio/index.mjs";
import "../text-real-time/index.mjs";
import "../media-carousel/index.mjs";
import "../media-carousel-slides/index.mjs";
import "../media-iframe-carousel/index.mjs";
import "../media-iframe/index.mjs";
import "../media-m3u8/index.mjs";
import "../media-m3u8-dynamic/index.mjs";
import "../media-audio-dynamic/index.mjs";
import "../media-video-dynamic/index.mjs";
import "../media-image-dynamic/index.mjs";
import "../media-iframe-dynamic/index.mjs";
import "../media-flv/index.mjs";
import "../commons-echarts/index.mjs";
import "../text-over-number/index.mjs";
import "../text-table-scroll/index.mjs";
import "../text-carousel/index.mjs";
import "../text-row-scroll/index.mjs";
import "../text-text-dynamic/index.mjs";
import "../text-count-down/index.mjs";
import "../graphical-circle/index.mjs";
import "../graphical-diamond/index.mjs";
import "../graphical-hexagon/index.mjs";
import "../graphical-isosceles-triangle/index.mjs";
import "../graphical-pentagon/index.mjs";
import "../graphical-rect/index.mjs";
import "../graphical-right-triangle/index.mjs";
import "../scene-map3d/index.mjs";
import "../scene-amap2d/index.mjs";
import "../scene-amap3d/index.mjs";
import "../scene-vr/index.mjs";
import "../scene-unity-iframe/index.mjs";
import "../scene-unity-webgl/index.mjs";
import "../scene-ue-iframe/index.mjs";
import "../scene-ue-shj/index.mjs";
import "../scene-default/index.mjs";
import "../interaction/tabs/index.mjs";
import "../interaction/tabs-icon/index.mjs";
import "../interaction/button/index.mjs";
import "../interaction/date-picker/src/date-picker/index.mjs";
import "../interaction/date-picker/src/date-picker-range/index.mjs";
import "../text/list/index.mjs";
import "../chart/src/bar/basic/index.mjs";
import "../chart/src/bar/animation/index.mjs";
import "../chart/src/bar/contrast/index.mjs";
import "../chart/src/bar/contrast2/index.mjs";
import "../chart/src/bar/contrast3/index.mjs";
import "../chart/src/bar/gradient-column-chart/index.mjs";
import "../chart/src/bar/horizontal/index.mjs";
import "../chart/src/bar/horizontal-stack/index.mjs";
import "../chart/src/bar/line-bar/index.mjs";
import "../chart/src/bar/line-bar2/index.mjs";
import "../chart/src/bar/loop/index.mjs";
import "../chart/src/bar/mini/index.mjs";
import "../chart/src/bar/polar/index.mjs";
import "../chart/src/bar/polar-stack/index.mjs";
import "../chart/src/bar/polar2/index.mjs";
import "../chart/src/bar/radius-circle/index.mjs";
import "../chart/src/bar/rank/index.mjs";
import "../chart/src/bar/segmented-progress/index.mjs";
import "../chart/src/bar/spire/index.mjs";
import "../chart/src/bar/stack/index.mjs";
import "../chart/src/bar/stack-line/index.mjs";
import "../chart/src/bar/stack2/index.mjs";
import "../chart/src/bar/stack3/index.mjs";
import "../chart/src/bar/staggered/index.mjs";
import "../chart/src/bar/three/index.mjs";
import "../chart/src/bar/waterfall/index.mjs";
import "../chart/src/bar/zebra/index.mjs";
import "../chart/src/line/area-gradient/index.mjs";
import "../chart/src/line/area-highlight/index.mjs";
import "../chart/src/line/area-highlight2/index.mjs";
import "../chart/src/line/basic/index.mjs";
import "../chart/src/line/bump/index.mjs";
import "../chart/src/line/dashed/index.mjs";
import "../chart/src/line/ladder/index.mjs";
import "../chart/src/line/logarithm/index.mjs";
import "../chart/src/line/multix/index.mjs";
import "../chart/src/line/polar-double/index.mjs";
import "../chart/src/line/rain-flow/index.mjs";
import "../chart/src/line/scale/index.mjs";
import "../chart/src/line/smooth/index.mjs";
import "../chart/src/line/smooth-area/index.mjs";
import "../chart/src/line/stack/index.mjs";
import "../chart/src/line/stack-area/index.mjs";
import "../chart/src/line/temp/index.mjs";
import "../chart/src/line/vertical/index.mjs";
import "../chart/src/map/basic/index.mjs";
import "../chart/src/map/bmap-basic/index.mjs";
import "../chart/src/map/bmap-heatmap/index.mjs";
import "../chart/src/map/bmap-rich/index.mjs";
import "../chart/src/map/customize/index.mjs";
import "../chart/src/map/lines/index.mjs";
import "../chart/src/map/scatter/index.mjs";
import "../chart/src/pie/3d/index.mjs";
import "../chart/src/pie/basic/index.mjs";
import "../chart/src/pie/basic2/index.mjs";
import "../chart/src/pie/customized/index.mjs";
import "../chart/src/pie/index/index.mjs";
import "../chart/src/pie/interval/index.mjs";
import "../chart/src/pie/legend-scroll/index.mjs";
import "../chart/src/pie/radius/index.mjs";
import "../chart/src/pie/rose/index.mjs";
import "../chart/src/pie/round/index.mjs";
import "../chart/src/pie/sunburst/index.mjs";
import "../chart/src/scatter/basic/index.mjs";
import "../chart/src/scatter/basic2/index.mjs";
import "../chart/src/scatter/bubble/index.mjs";
import "../chart/src/scatter/ripples/index.mjs";
/* empty css                        */
/* empty css                               */
import "../../plugins/datasource/utils/request.mjs";
import "../../plugins/datasource/utils/wsManager.mjs";
import { SHJParseEvent as k } from "../../plugins/event/index.mjs";
const U = { class: "zerov-widget" }, X = z({ name: "zv-commons-three-loader3" }), Co = /* @__PURE__ */ z({
  ...X,
  props: {
    basicOption: {},
    basicEvents: {},
    useEvents: {}
  },
  emits: [
    "on-load-success",
    "on-play-animation"
  ],
  setup(V, { expose: P, emit: _ }) {
    const i = V, S = _;
    let v, o, n, c, u, m, w, g, l, O, s, a;
    const A = () => {
      n || (n = new t.ArcRotateCamera(
        "Camera",
        i.basicOption.camera.alpha,
        i.basicOption.camera.beta,
        i.basicOption.camera.radius,
        new t.Vector3(
          i.basicOption.camera.target[0],
          i.basicOption.camera.target[1],
          i.basicOption.camera.target[2]
        ),
        o
      )), n.alpha = i.basicOption.camera.alpha, n.beta = i.basicOption.camera.beta, n.radius = i.basicOption.camera.radius, n.target = new t.Vector3(
        i.basicOption.camera.target[0],
        i.basicOption.camera.target[1],
        i.basicOption.camera.target[2]
      ), n.lowerRadiusLimit = i.basicOption.camera.lowerRadiusLimit, n.upperRadiusLimit = i.basicOption.camera.upperRadiusLimit, n.lowerBetaLimit = t.Tools.ToRadians(i.basicOption.camera.lowerBetaLimit), n.upperBetaLimit = t.Tools.ToRadians(i.basicOption.camera.upperBetaLimit), n.useBouncingBehavior = i.basicOption.camera.useBouncingBehavior, n.wheelDeltaPercentage = i.basicOption.camera.wheelDeltaPercentage || 0.01, n.useAutoRotationBehavior = i.basicOption.camera.autoRotation, n.panningSensibility = 1 / (i.basicOption.camera.panningSensibility || 0.01), n.attachControl(T.value, !0);
    }, E = () => {
      o || (o = new t.Scene(v)), o.environmentTexture = t.CubeTexture.CreateFromPrefilteredData(i.basicOption.scene.environmentTexture, o), o.environmentIntensity = i.basicOption.scene.environmentIntensity, i.basicOption.scene.colorShow ? o.clearColor = t.Color4.FromHexString(i.basicOption.scene.color || "#000000") : o.clearColor = new t.Color4(0, 0, 0, 0), o.fogEnabled = i.basicOption.scene.fogEnabled, o.fogMode = i.basicOption.scene.fogMode || 1, o.fogColor = t.Color3.FromHexString(i.basicOption.scene.fogColor || "#ffffff"), o.fogEnd = i.basicOption.scene.fogEnd || 2e3, o.fogStart = i.basicOption.scene.fogStart || 1, o.fogDensity = i.basicOption.scene.fogDensity * 1e-4;
    }, B = () => {
      if (c || (c = new t.DirectionalLight("dirLight", new t.Vector3(
        i.basicOption.directionalLight.direction[0],
        i.basicOption.directionalLight.direction[1],
        i.basicOption.directionalLight.direction[2]
      ), o)), c.direction = new t.Vector3(
        i.basicOption.directionalLight.direction[0],
        i.basicOption.directionalLight.direction[1],
        i.basicOption.directionalLight.direction[2]
      ), c.position = new t.Vector3(
        i.basicOption.directionalLight.position[0],
        i.basicOption.directionalLight.position[1],
        i.basicOption.directionalLight.position[2]
      ), c.diffuse = t.Color3.FromHexString(i.basicOption.directionalLight.diffuse || "#ffffff"), c.intensity = i.basicOption.directionalLight.intensity, c.shadowMinZ = i.basicOption.directionalLight.shadowMinZ, c.shadowMaxZ = i.basicOption.directionalLight.shadowMaxZ, c.autoCalcShadowZBounds = i.basicOption.directionalLight.autoCalcShadowZBounds, i.basicOption.directionalLight.shadowGenerator.enable) {
        const { mapSize: e, transparencyShadow: r, usePercentageCloserFiltering: p, bias: d } = i.basicOption.directionalLight.shadowGenerator;
        if (!m && (m = new t.ShadowGenerator(e, c), s))
          for (let L = 0; L < s.length; L++)
            i.basicOption.meshes.isCasterShadow && m && m.addShadowCaster(s[L], !0);
        m.mapSize = e, m.transparencyShadow = r, m.usePercentageCloserFiltering = p, m.bias = d;
      } else
        m && (m.dispose(), m = null);
      i.basicOption.directionalLight.lightGizmo && i.basicOption.directionalLight.lightGizmo.enable ? (u || (u = new t.LightGizmo(), u.light = c), u.scaleRatio = i.basicOption.directionalLight.lightGizmo.scaleRatio) : u && (u.dispose(), u = null);
    }, F = () => {
      w || (w = new t.HemisphericLight("light", new t.Vector3(
        i.basicOption.hemisphericLight.direction[0],
        i.basicOption.hemisphericLight.direction[1],
        i.basicOption.hemisphericLight.direction[2]
      ), o)), w.direction = new t.Vector3(
        i.basicOption.hemisphericLight.direction[0],
        i.basicOption.hemisphericLight.direction[1],
        i.basicOption.hemisphericLight.direction[2]
      ), w.intensity = i.basicOption.hemisphericLight.intensity, w.diffuse = t.Color3.FromHexString(i.basicOption.hemisphericLight.diffuse || "#ffffff"), i.basicOption.hemisphericLight.lightGizmo && i.basicOption.hemisphericLight.lightGizmo.enable ? (g || (g = new t.LightGizmo(), g.light = w), g.scaleRatio = i.basicOption.hemisphericLight.lightGizmo.scaleRatio) : g && (g.dispose(), g = null);
    }, R = () => {
      if (i.basicOption.ground.enable) {
        const { width: e, height: r, position: p, rotation: d, scaling: L, material: y, receiveShadows: I } = i.basicOption.ground;
        l || (l = t.MeshBuilder.CreateGround("ground", { width: e, height: r }, o)), l.position = new t.Vector3(
          p[0],
          p[1],
          p[2]
        ), l.rotation = new t.Vector3(
          t.Tools.ToRadians(d[0]),
          t.Tools.ToRadians(d[1]),
          t.Tools.ToRadians(d[2])
        ), l.scaling = new t.Vector3(
          L[0],
          L[1],
          L[2]
        );
        const x = new t.StandardMaterial("", o);
        x.emissiveTexture = new t.Texture(y.emissiveTexture, o), x.diffuseTexture = new t.Texture(y.emissiveTexture, o), x.ambientTexture = new t.Texture(y.emissiveTexture, o), x.diffuseColor = new t.Color3(1, 1, 1), x.opacityTexture = new t.Texture(y.opacityTexture, o), l.material = x, l.receiveShadows = I;
      } else
        l && (l.dispose(), l = null);
    }, G = () => {
      if (i.basicOption.skybox.enable) {
        const { size: e } = i.basicOption.skybox;
        O || (O = t.MeshBuilder.CreateBox("skyBox", { size: e }, o));
        const r = new t.StandardMaterial("skyBox", o);
        r.backFaceCulling = !1, r.reflectionTexture = t.CubeTexture.CreateFromPrefilteredData(i.basicOption.scene.environmentTexture, o), r.reflectionTexture.coordinatesMode = t.Texture.SKYBOX_MODE, r.diffuseColor = new t.Color3(1, 1, 1), r.specularColor = new t.Color3(1, 1, 1), r.disableLighting = !0, O.material = r, O.isPickable = !1;
      } else
        O && (O.dispose(), O = null);
    }, M = (e, r = {
      loop: !1,
      speedRatio: 1
    }) => {
      if (o) {
        o.stopAllAnimations();
        const p = o.getAnimationGroupByName(e);
        p && (S("on-play-animation"), k.parseEvents(i.useEvents, "on-play-animation"), p.start(r.loop, r.speedRatio, p.from, p.to, !1));
      }
    }, C = async () => {
      s || (s = (await t.SceneLoader.ImportMeshAsync("", i.basicOption.meshes.url, "", o)).meshes), s[0].position = new t.Vector3(
        i.basicOption.meshes.position[0],
        i.basicOption.meshes.position[1],
        i.basicOption.meshes.position[2]
      ), s[0].scaling = new t.Vector3(
        i.basicOption.meshes.scaling[0],
        i.basicOption.meshes.scaling[1],
        i.basicOption.meshes.scaling[2]
      ), s[0].rotation = new t.Vector3(
        t.Tools.ToRadians(i.basicOption.meshes.rotation[0]),
        t.Tools.ToRadians(i.basicOption.meshes.rotation[1]),
        t.Tools.ToRadians(i.basicOption.meshes.rotation[2])
      );
      for (let e = 0; e < s.length; e++)
        s[e].isPickable = !1, s[e].receiveShadows = i.basicOption.meshes.isCasterShadow, i.basicOption.meshes.isCasterShadow && m && m.addShadowCaster(s[e], !0);
      i.basicOption.animationGroups = o.animationGroups.map((e) => ({ uniqueId: e.uniqueId, name: e.name })), i.basicEvents && (i.basicEvents.function[0].args[0].select = o.animationGroups.map((e) => ({ name: e.name, value: e.name }))), i.basicOption.defaultAnimation && i.basicOption.defaultAnimation.name ? M(i.basicOption.defaultAnimation.name, {
        loop: i.basicOption.defaultAnimation.loop,
        speedRatio: i.basicOption.defaultAnimation.speedRatio
      }) : o.animationGroups && o.animationGroups[0] && o.animationGroups[0].stop();
    }, D = () => {
      const e = i.basicOption.pipelineOption;
      e && e.enabled ? (a || (a = new t.DefaultRenderingPipeline(
        "defaultPipeline",
        !0,
        o,
        [n]
      )), a.samples = e.samples ? 4 : 1, a.fxaaEnabled = e.fxaaEnabled, a.grainEnabled = e.grainEnabled, a.grain.intensity = e.grainIntensity, a.grain.animated = e.grainAnimated, a.bloomEnabled = e.bloomEnabled, a.bloomThreshold = e.bloomThreshold, a.bloomWeight = e.bloomWeight, a.bloomKernel = e.bloomKernel, a.bloomScale = e.bloomScale, a.depthOfFieldEnabled = e.depthOfFieldEnabled, e.depthOfFieldBlurLevel < 1 ? a.depthOfFieldBlurLevel = t.DepthOfFieldEffectBlurLevel.Low : e.depthOfFieldBlurLevel < 2 ? a.depthOfFieldBlurLevel = t.DepthOfFieldEffectBlurLevel.Medium : e.depthOfFieldBlurLevel < 3 && (a.depthOfFieldBlurLevel = t.DepthOfFieldEffectBlurLevel.High), a.depthOfField.focusDistance = e.depthOfFieldFocusDistance, a.depthOfField.fStop = e.depthOfFieldFStop, a.depthOfField.focalLength = e.depthOfFieldFocalLength, a.chromaticAberrationEnabled = e.chromaticAberrationEnabled, a.chromaticAberration.aberrationAmount = e.chromaticAberrationAberrationAmount, a.chromaticAberration.radialIntensity = e.chromaticAberrationRadialIntensity, e.chromaticAberrationDirection === 0 ? (a.chromaticAberration.direction.x = 0, a.chromaticAberration.direction.y = 0) : (a.chromaticAberration.direction.x = Math.sin(e.chromaticAberrationDirection), a.chromaticAberration.direction.y = Math.cos(e.chromaticAberrationDirection)), a.sharpenEnabled = e.sharpenEnabled, a.sharpen.edgeAmount = e.sharpenEdgeAmount, a.sharpen.colorAmount = e.sharpenColorAmount) : a && (a.dispose(), a = null);
    }, H = function(e) {
      E(), A(), F(), B(), R(), G(), C(), D(), S("on-load-success"), k.parseEvents(i.useEvents, "on-load-success");
    }, T = Z();
    return q(() => {
      v = new t.Engine(T.value, !0), v && i.basicOption.meshes.url && (H(), v.runRenderLoop(function() {
        o && o.render();
      }));
    }), K(() => {
      o.dispose(), v.dispose();
    }), P({
      playAnimation: (e, r) => {
        const p = r[0].value, d = {
          loop: r[1].keys[0].defaultValue,
          speedRatio: r[1].keys[1].defaultValue
        };
        M(p, d);
      }
    }), h(() => b(i.basicOption.camera), (e, r) => {
      !f(e, r) && n && A();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.scene), (e, r) => {
      !f(e, r) && o && E();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.directionalLight), (e, r) => {
      f(e, r) || B();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.hemisphericLight), (e, r) => {
      f(e, r) || F();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.ground), (e, r) => {
      f(e, r) || R();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.skybox), (e, r) => {
      f(e, r) || G();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.meshes), (e, r) => {
      !f(e, r) && s && e.url === r.url && C();
    }, {
      deep: !0
    }), h(() => b(i.basicOption.meshes.url), (e, r) => {
      f(e, r) || (o.meshes.forEach((p, d) => {
        d > 1 && p.dispose();
      }), s = null, C());
    }, {
      deep: !0
    }), h(() => b(i.basicOption.pipelineOption), (e, r) => {
      f(e, r) || D();
    }, {
      deep: !0
    }), (e, r) => (W(), N("div", U, [
      Y("canvas", {
        ref_key: "canvasRef",
        ref: T,
        class: J(["widget", { show: !0 }])
      }, null, 512)
    ]));
  }
});
export {
  Co as default
};
