@gamelearn/arcade-components 3.16.2 → 3.17.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.
@@ -20,7 +20,7 @@ var Nc = (l, e, n, t) => ({
20
20
  import * as React$2 from "react";
21
21
  import React__default, { useRef, useEffect, useCallback, createContext, useReducer, forwardRef, useImperativeHandle, useMemo, useContext, useLayoutEffect, useState } from "react";
22
22
  import { OrbitControls, PerspectiveCamera as PerspectiveCamera$1 } from "@react-three/drei";
23
- import { Renderer, SceneResource, CameraControls, SettingsController, EnvironmentWrapper, QualityManager, HtmlPro } from "@gamelearn/arcade-three-core";
23
+ import { Renderer, SceneResource, CameraControls, SettingsController, EnvironmentWrapper, QualityManager, HtmlPro, ProgressManager, AssetLoader } from "@gamelearn/arcade-three-core";
24
24
  import { useThree, useFrame } from "@react-three/fiber";
25
25
  import { Vector3, Box3, AnimationUtils, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, LineSegments, Line as Line$3, LineLoop, Points, Group as Group$3, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Sphere, Interpolant, Raycaster, LoopRepeat } from "three";
26
26
  import require$$0 from "react-dom";
@@ -35670,9 +35670,9 @@ let Group$1 = class extends Container_1.Container {
35670
35670
  Group$2.Group = Group$1;
35671
35671
  Group$1.prototype.nodeType = "Group";
35672
35672
  (0, Global_1$i._registerNode)(Group$1);
35673
- var Animation$2 = {};
35674
- Object.defineProperty(Animation$2, "__esModule", { value: !0 });
35675
- Animation$2.Animation = void 0;
35673
+ var Animation$3 = {};
35674
+ Object.defineProperty(Animation$3, "__esModule", { value: !0 });
35675
+ Animation$3.Animation = void 0;
35676
35676
  const Global_1$h = Global, Util_1$8 = Util, now = function() {
35677
35677
  return Global_1$h.glob.performance && Global_1$h.glob.performance.now ? function() {
35678
35678
  return Global_1$h.glob.performance.now();
@@ -35680,7 +35680,7 @@ const Global_1$h = Global, Util_1$8 = Util, now = function() {
35680
35680
  return (/* @__PURE__ */ new Date()).getTime();
35681
35681
  };
35682
35682
  }();
35683
- let Animation$1 = class su {
35683
+ let Animation$2 = class su {
35684
35684
  constructor(e, n) {
35685
35685
  this.id = su.animIdCounter++, this.frame = {
35686
35686
  time: 0,
@@ -35754,14 +35754,14 @@ let Animation$1 = class su {
35754
35754
  this.animRunning || (this.animRunning = !0, Util_1$8.Util.requestAnimFrame(this._animationLoop));
35755
35755
  }
35756
35756
  };
35757
- Animation$2.Animation = Animation$1;
35758
- Animation$1.animations = [];
35759
- Animation$1.animIdCounter = 0;
35760
- Animation$1.animRunning = !1;
35757
+ Animation$3.Animation = Animation$2;
35758
+ Animation$2.animations = [];
35759
+ Animation$2.animIdCounter = 0;
35760
+ Animation$2.animRunning = !1;
35761
35761
  var Tween$1 = {};
35762
35762
  (function(l) {
35763
35763
  Object.defineProperty(l, "__esModule", { value: !0 }), l.Easings = l.Tween = void 0;
35764
- const e = Util, n = Animation$2, t = Node$1, s = Global;
35764
+ const e = Util, n = Animation$3, t = Node$1, s = Global;
35765
35765
  var o = {
35766
35766
  node: 1,
35767
35767
  duration: 1,
@@ -35990,7 +35990,7 @@ var Tween$1 = {};
35990
35990
  })(Tween$1);
35991
35991
  (function(l) {
35992
35992
  Object.defineProperty(l, "__esModule", { value: !0 }), l.Konva = void 0;
35993
- const e = Global, n = Util, t = Node$1, s = Container$2, o = Stage$1, d = Layer$2, f = FastLayer$1, h = Group$2, u = DragAndDrop, p = Shape, _ = Animation$2, b = Tween$1, S = Context$2, E = Canvas$1;
35993
+ const e = Global, n = Util, t = Node$1, s = Container$2, o = Stage$1, d = Layer$2, f = FastLayer$1, h = Group$2, u = DragAndDrop, p = Shape, _ = Animation$3, b = Tween$1, S = Context$2, E = Canvas$1;
35994
35994
  l.Konva = n.Util._assign(e.Konva, {
35995
35995
  Util: n.Util,
35996
35996
  Transform: n.Transform,
@@ -37623,7 +37623,7 @@ Factory_1$l.Factory.addGetterSetter(Ring, "outerRadius", 0, (0, Validators_1$l.g
37623
37623
  var Sprite$1 = {};
37624
37624
  Object.defineProperty(Sprite$1, "__esModule", { value: !0 });
37625
37625
  Sprite$1.Sprite = void 0;
37626
- const Factory_1$k = Factory, Shape_1$5 = Shape, Animation_1 = Animation$2, Validators_1$k = Validators, Global_1$5 = Global;
37626
+ const Factory_1$k = Factory, Shape_1$5 = Shape, Animation_1 = Animation$3, Validators_1$k = Validators, Global_1$5 = Global;
37627
37627
  class Sprite extends Shape_1$5.Shape {
37628
37628
  constructor(e) {
37629
37629
  super(e), this._updated = !0, this.anim = new Animation_1.Animation(() => {
@@ -59199,7 +59199,7 @@ _forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt
59199
59199
  });
59200
59200
  var GSCache = function l(e, n) {
59201
59201
  this.id = _gsID++, e._gsap = this, this.target = e, this.harness = n, this.get = n ? n.get : _getProperty, this.set = n ? n.getSetter : _getSetter;
59202
- }, Animation = /* @__PURE__ */ function() {
59202
+ }, Animation$1 = /* @__PURE__ */ function() {
59203
59203
  function l(n) {
59204
59204
  this.vars = n, this._delay = +n.delay || 0, (this._repeat = n.repeat === 1 / 0 ? -2 : n.repeat || 0) && (this._rDelay = n.repeatDelay || 0, this._yoyo = !!n.yoyo || !!n.yoyoEase), this._ts = 1, _setDuration(this, +n.duration, 1, 1), this.data = n.data, _context && (this._ctx = _context, _context.data.push(this)), _tickerActive || _ticker.wake();
59205
59205
  }
@@ -59303,7 +59303,7 @@ var GSCache = function l(e, n) {
59303
59303
  _interrupt(this);
59304
59304
  }, l;
59305
59305
  }();
59306
- _setDefaults(Animation.prototype, {
59306
+ _setDefaults(Animation$1.prototype, {
59307
59307
  _time: 0,
59308
59308
  _start: 0,
59309
59309
  _end: 0,
@@ -59396,7 +59396,7 @@ var Timeline = /* @__PURE__ */ function(l) {
59396
59396
  return this;
59397
59397
  }, n.add = function(s, o) {
59398
59398
  var d = this;
59399
- if (_isNumber(o) || (o = _parsePosition(this, o, s)), !(s instanceof Animation)) {
59399
+ if (_isNumber(o) || (o = _parsePosition(this, o, s)), !(s instanceof Animation$1)) {
59400
59400
  if (_isArray(s))
59401
59401
  return s.forEach(function(f) {
59402
59402
  return d.add(f, o);
@@ -59512,7 +59512,7 @@ var Timeline = /* @__PURE__ */ function(l) {
59512
59512
  }
59513
59513
  }
59514
59514
  }, e;
59515
- }(Animation);
59515
+ }(Animation$1);
59516
59516
  _setDefaults(Timeline.prototype, {
59517
59517
  _lock: 0,
59518
59518
  _hasPause: 0,
@@ -59768,7 +59768,7 @@ var Tween = /* @__PURE__ */ function(l) {
59768
59768
  }, e.killTweensOf = function(s, o, d) {
59769
59769
  return _globalTimeline.killTweensOf(s, o, d);
59770
59770
  }, e;
59771
- }(Animation);
59771
+ }(Animation$1);
59772
59772
  _setDefaults(Tween.prototype, {
59773
59773
  _targets: [],
59774
59774
  _lazy: 0,
@@ -60073,7 +60073,7 @@ var _media = [], _listeners = {}, _emptyArray = [], _lastMediaTime = 0, _context
60073
60073
  globals: _addGlobal,
60074
60074
  Tween,
60075
60075
  Timeline,
60076
- Animation,
60076
+ Animation: Animation$1,
60077
60077
  getCache: _getCache,
60078
60078
  _removeLinkedListItem,
60079
60079
  reverting: function l() {
@@ -61178,50 +61178,71 @@ function DialogComponent({
61178
61178
  )
61179
61179
  ] });
61180
61180
  }
61181
- function AnimationComponent({ animation: l, loopTimes: e, resource: n, enableInteraction: t, makeDefault: s, emitEvent: o }) {
61182
- const [d, f] = useState(!1), h = useThree((_) => _.scene), u = useMemo(() => new GLTFLoader(), []), p = useRef(1);
61181
+ const activeCache = ProgressManager.request("AssetLoader").cache, assetLoader = new AssetLoader(void 0, activeCache);
61182
+ function Animation({ animation: l, loopTimes: e, onAnimationFinish: n, onAnimationSave: t, resource: s, makeDefault: o, emitEvent: d }) {
61183
+ const f = useThree((p) => p.scene), h = useRef(1), u = useRef();
61183
61184
  return useEffect(() => {
61184
- f(!1);
61185
- }, [n.uid, l == null ? void 0 : l.url]), useEffect(() => {
61186
- if (!d) {
61187
- const _ = h.getObjectByProperty("uid", n.uid);
61188
- if (_ && l && _.skeletonId === l.skeletonId)
61189
- if (s)
61190
- o({
61191
- type: "saveAnimation",
61192
- payload: { uid: n.uid, animation: l.id, index: _.index }
61193
- }), o({ type: "success" });
61185
+ if (!u.current) {
61186
+ const p = f.getObjectByProperty("uid", s.uid);
61187
+ if (p && l && p.skeletonId === l.skeletonId)
61188
+ if (o)
61189
+ t({ uid: s.uid, animation: l.id, index: p.index }), n(l);
61194
61190
  else {
61195
- const b = t;
61196
- b || o({ type: "success" });
61197
- const S = _.userData.animator, E = () => {
61198
- S.getAction(l.url).setLoop(LoopRepeat, 1 / 0), p.current = 0;
61199
- function v() {
61200
- p.current += 1, p.current >= e && (S.mix("idle"), b && o({ type: "success" }), S.removeEventListener("loop", v));
61201
- }
61202
- S.mix(l.url), S.addEventListener("loop", v), f(!0);
61191
+ const _ = p.userData.animator, b = () => {
61192
+ _.getAction(l.url).setLoop(LoopRepeat, 1 / 0), h.current = 1;
61193
+ function E() {
61194
+ h.current >= e && (_.mix("idle"), n(l), _.removeEventListener("loop", E)), h.current += 1;
61195
+ }
61196
+ _.mix(l.url).then((g) => {
61197
+ g && _.addEventListener("loop", E);
61198
+ });
61203
61199
  };
61204
- S.getAction(l.url) ? E() : u.load(l.url, (g) => {
61205
- S.register(l.url, g.animations[0]), E();
61200
+ _.getAction(l.url) ? b() : assetLoader.load(l.url, (S) => {
61201
+ _.register(l.url, S.animations[0]), b();
61206
61202
  });
61207
61203
  }
61208
61204
  else
61209
- o({ type: "success" });
61205
+ n(l);
61206
+ u.current = l.id;
61210
61207
  }
61211
61208
  }, [
61212
- h,
61213
- l == null ? void 0 : l.url,
61209
+ f,
61210
+ l.url,
61214
61211
  e,
61215
- o,
61216
61212
  d,
61217
- u,
61218
- n.uid,
61219
- s,
61213
+ s.uid,
61214
+ o,
61220
61215
  l,
61216
+ s,
61221
61217
  n,
61222
61218
  t
61223
61219
  ]), null;
61224
61220
  }
61221
+ function MultipleAnimation({ animations: l = [], enableInteraction: e, emitEvent: n }) {
61222
+ const [t, s] = useState(!1), o = l.length, d = useRef(0), f = () => {
61223
+ d.current += 1, d.current >= o && s(!0);
61224
+ }, h = (u) => {
61225
+ n({
61226
+ type: "saveAnimation",
61227
+ payload: u
61228
+ });
61229
+ };
61230
+ return useEffect(() => {
61231
+ t && n({ type: "success" });
61232
+ }, [n, t]), useEffect(() => {
61233
+ e && s(!0);
61234
+ }, [e]), l.map(({ animation: u, resource: p, ..._ }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
61235
+ Animation,
61236
+ {
61237
+ animation: u,
61238
+ resource: p,
61239
+ ..._,
61240
+ onAnimationSave: h,
61241
+ onAnimationFinish: f
61242
+ },
61243
+ `${u.id}_${p.uid}`
61244
+ ));
61245
+ }
61225
61246
  function EmailPill({ text: l, error: e, handleClick: n }) {
61226
61247
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
61227
61248
  "div",
@@ -61388,7 +61409,7 @@ function ReferralComponent({ emitEvent: l, text: e, rewards: n, referrals: t })
61388
61409
  ] }) });
61389
61410
  }
61390
61411
  export {
61391
- AnimationComponent,
61412
+ MultipleAnimation as AnimationComponent,
61392
61413
  AutoEvaluation as AutoEvaluationComponent,
61393
61414
  CardsSelectorPuzzleComponent,
61394
61415
  CartelComponent,