roavatar-renderer 1.5.9 → 1.5.11

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/README.md CHANGED
@@ -56,5 +56,7 @@ if (!(outfit instanceof Outfit)) throw new Error("Failed to get outfit")
56
56
  outfitRenderer.startAnimating()
57
57
  outfitRenderer.setMainAnimation("idle")
58
58
  ```
59
+ **RESULT:**
60
+ <img src="https://devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/9/f/a/d/9fadf25d9770b63e8a2e480369930cad94ad04aa.png">
59
61
 
60
62
  Also the OutfitRenderer code or RoAvatar source code is useful, especially ```avatarPreview.ts```
package/dist/index.d.ts CHANGED
@@ -873,18 +873,29 @@ export declare interface BundleDetails_Result {
873
873
  export declare const BundleTypes: string[];
874
874
 
875
875
  export declare const CACHE: {
876
- AssetBuffer: Map<string, Promise<ArrayBuffer | Response>>;
877
- RBX: Map<string, RBX>;
878
- Mesh: Map<string, FileMesh>;
879
- Image: Map<string, HTMLImageElement | Promise<HTMLImageElement | undefined> | undefined>;
880
- Thumbnails: Map<string, string | undefined>;
881
- ItemOwned: Map<string, [boolean, number]>;
882
- IsLayered: Map<number, boolean>;
883
- AvatarInventoryItem: Map<string, AvatarInventory_Result>;
884
- ItemDetails: Map<string, ItemDetail_Result>;
876
+ AssetBuffer: Cache_2<string, Promise<ArrayBuffer | Response>>;
877
+ RBX: Cache_2<string, RBX>;
878
+ Mesh: Cache_2<string, FileMesh>;
879
+ Image: Cache_2<string, HTMLImageElement | Promise<HTMLImageElement | undefined> | undefined>;
880
+ Thumbnails: Cache_2<string, string | undefined>;
881
+ ItemOwned: Cache_2<string, [boolean, number]>;
882
+ IsLayered: Cache_2<number, boolean>;
883
+ AvatarInventoryItem: Cache_2<string, AvatarInventory_Result>;
884
+ ItemDetails: Cache_2<string, ItemDetail_Result>;
885
885
  UserInfo: undefined;
886
886
  };
887
887
 
888
+ declare class Cache_2<K, V> {
889
+ map: Map<K, V>;
890
+ lastAccess: Map<K, number>;
891
+ maxEntries: number;
892
+ constructor(maxEntries?: number);
893
+ get(key: K): V | undefined;
894
+ set(key: K, value: V): Cache_2<K, V>;
895
+ has(key: K): boolean;
896
+ delete(key: K): boolean;
897
+ }
898
+
888
899
  /**
889
900
  * @category Mesh
890
901
  */
@@ -1432,6 +1443,8 @@ export declare const FLAGS: {
1432
1443
  THUMBNAIL_TIMEOUT: number;
1433
1444
  /**Always render attachments even when theyre set to not be visible */
1434
1445
  ALWAYS_SHOW_ATTACHMENTS: boolean;
1446
+ /**Multiplier for delta time used by renderer things (does not affect datamodel side of things but particles and such instead) */
1447
+ RENDERER_DELTA_TIME_MULTIPLIER: number;
1435
1448
  /**shows ThreeJS SkeletonHelper */
1436
1449
  SHOW_SKELETON_HELPER: boolean;
1437
1450
  /**if set the skeleton helper will only show if the instance has the name */
package/dist/index.js CHANGED
@@ -29863,6 +29863,7 @@ const FLAGS = {
29863
29863
  RENDERTARGET_TO_CANVASTEXTURE: false,
29864
29864
  THUMBNAIL_TIMEOUT: 500,
29865
29865
  ALWAYS_SHOW_ATTACHMENTS: false,
29866
+ RENDERER_DELTA_TIME_MULTIPLIER: 1,
29866
29867
  //skeleton
29867
29868
  SHOW_SKELETON_HELPER: false,
29868
29869
  SKELETON_HELPER_INSTANCE_NAME: void 0,
@@ -33749,11 +33750,10 @@ class Outfit {
33749
33750
  assetDetailsRequest.push({ itemType: "Asset", id: assetToAdd.id });
33750
33751
  }
33751
33752
  const assetDetails = await API.Catalog.GetItemDetails(auth, assetDetailsRequest);
33752
- if (assetDetails instanceof Response) {
33753
- return assetDetails;
33754
- }
33755
- for (const assetDetail of assetDetails.data) {
33756
- this.addAsset(assetDetail.id, assetDetail.assetType, assetDetail.name, assetDetail.supportsHeadShapes);
33753
+ if (!(assetDetails instanceof Response)) {
33754
+ for (const assetDetail of assetDetails.data) {
33755
+ this.addAsset(assetDetail.id, assetDetail.assetType, assetDetail.name, assetDetail.supportsHeadShapes);
33756
+ }
33757
33757
  }
33758
33758
  for (const asset of assetsToAdd) {
33759
33759
  const assetId = asset.id;
@@ -35721,16 +35721,49 @@ function _updateCurrentlyLoadingAssets(type, label) {
35721
35721
  const newCurrentlyLoading = currentlyLoadingAssets.length > 0;
35722
35722
  API.Events.OnLoadingAssets.Fire(newCurrentlyLoading, type, label);
35723
35723
  }
35724
+ class Cache {
35725
+ map = /* @__PURE__ */ new Map();
35726
+ lastAccess = /* @__PURE__ */ new Map();
35727
+ maxEntries;
35728
+ constructor(maxEntries = 250) {
35729
+ this.maxEntries = maxEntries;
35730
+ }
35731
+ get(key) {
35732
+ if (this.map.has(key)) {
35733
+ this.lastAccess.set(key, Date.now());
35734
+ }
35735
+ return this.map.get(key);
35736
+ }
35737
+ set(key, value) {
35738
+ this.map.set(key, value);
35739
+ this.lastAccess.set(key, Date.now());
35740
+ if (this.map.size > this.maxEntries) {
35741
+ const toDelete = [...this.lastAccess.entries()].reduce((min, current) => {
35742
+ return current[1] < min[1] ? current : min;
35743
+ });
35744
+ this.delete(toDelete[0]);
35745
+ }
35746
+ return this;
35747
+ }
35748
+ has(key) {
35749
+ return this.map.has(key);
35750
+ }
35751
+ delete(key) {
35752
+ const toReturn = this.map.delete(key);
35753
+ this.lastAccess.delete(key);
35754
+ return toReturn;
35755
+ }
35756
+ }
35724
35757
  const CACHE = {
35725
- "AssetBuffer": /* @__PURE__ */ new Map(),
35726
- "RBX": /* @__PURE__ */ new Map(),
35727
- "Mesh": /* @__PURE__ */ new Map(),
35728
- "Image": /* @__PURE__ */ new Map(),
35729
- "Thumbnails": /* @__PURE__ */ new Map(),
35730
- "ItemOwned": /* @__PURE__ */ new Map(),
35731
- "IsLayered": /* @__PURE__ */ new Map(),
35732
- "AvatarInventoryItem": /* @__PURE__ */ new Map(),
35733
- "ItemDetails": /* @__PURE__ */ new Map(),
35758
+ "AssetBuffer": new Cache(250),
35759
+ "RBX": new Cache(100),
35760
+ "Mesh": new Cache(250),
35761
+ "Image": new Cache(100),
35762
+ "Thumbnails": new Cache(1e3),
35763
+ "ItemOwned": new Cache(1e3),
35764
+ "IsLayered": new Cache(1e3),
35765
+ "AvatarInventoryItem": new Cache(1e3),
35766
+ "ItemDetails": new Cache(1e4),
35734
35767
  "UserInfo": void 0
35735
35768
  };
35736
35769
  const ContentMap = /* @__PURE__ */ new Map();
@@ -50248,7 +50281,7 @@ class EmitterGroupDesc extends RenderDesc {
50248
50281
  return this.results;
50249
50282
  }
50250
50283
  updateResults() {
50251
- const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10);
50284
+ const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10) * FLAGS.RENDERER_DELTA_TIME_MULTIPLIER;
50252
50285
  this.lastTime = this.time;
50253
50286
  for (const emitterDesc of this.emitterDescs) {
50254
50287
  emitterDesc.tick(dt, this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roavatar-renderer",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "description": "A renderer for Roblox avatars, used by the RoAvatar extension.",
5
5
  "author": "steinan",
6
6
  "type": "module",