roavatar-renderer 1.4.0 → 1.4.1

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/index.js CHANGED
@@ -29630,10 +29630,19 @@ class InstanceWrapper {
29630
29630
  log(false, "Registered InstanceWrapper:", ClassNameToWrapper);
29631
29631
  }
29632
29632
  //virtual functions
29633
+ /**
29634
+ * @virtual
29635
+ */
29633
29636
  created() {
29634
29637
  }
29638
+ /**
29639
+ * @virtual
29640
+ */
29635
29641
  destroy() {
29636
29642
  }
29643
+ /**
29644
+ * @virtual
29645
+ */
29637
29646
  preRender() {
29638
29647
  }
29639
29648
  }
@@ -29764,6 +29773,9 @@ class Color3 {
29764
29773
  clone() {
29765
29774
  return new Color3(this.R, this.G, this.B);
29766
29775
  }
29776
+ isSame(other) {
29777
+ return this.R === other.R && this.G === other.G && this.B === other.B;
29778
+ }
29767
29779
  toColor3uint8() {
29768
29780
  return new Color3uint8(Math.round(this.R * 255), Math.round(this.G * 255), Math.round(this.B * 255));
29769
29781
  }
@@ -29808,6 +29820,9 @@ class NumberSequenceKeypoint {
29808
29820
  clone() {
29809
29821
  return new NumberSequenceKeypoint(this.time, this.value, this.envelope);
29810
29822
  }
29823
+ isSame(other) {
29824
+ return this.time === other.time && this.value === other.value && this.envelope === other.envelope;
29825
+ }
29811
29826
  }
29812
29827
  class NumberSequence {
29813
29828
  keypoints = [];
@@ -29821,6 +29836,13 @@ class NumberSequence {
29821
29836
  }
29822
29837
  return copy;
29823
29838
  }
29839
+ isSame(other) {
29840
+ if (this.keypoints.length !== other.keypoints.length) return false;
29841
+ for (let i = 0; i < this.keypoints.length; i++) {
29842
+ if (!this.keypoints[i].isSame(other.keypoints[i])) return false;
29843
+ }
29844
+ return true;
29845
+ }
29824
29846
  getLowerKey(time2) {
29825
29847
  let resultKey = null;
29826
29848
  for (const key of this.keypoints) {
@@ -29876,6 +29898,9 @@ class ColorSequenceKeypoint {
29876
29898
  clone() {
29877
29899
  return new ColorSequenceKeypoint(this.time, this.value.R, this.value.G, this.value.B);
29878
29900
  }
29901
+ isSame(other) {
29902
+ return this.time === other.time && this.value.isSame(other.value);
29903
+ }
29879
29904
  }
29880
29905
  class ColorSequence {
29881
29906
  keypoints = [];
@@ -29891,6 +29916,13 @@ class ColorSequence {
29891
29916
  }
29892
29917
  return copy;
29893
29918
  }
29919
+ isSame(other) {
29920
+ if (this.keypoints.length !== other.keypoints.length) return false;
29921
+ for (let i = 0; i < this.keypoints.length; i++) {
29922
+ if (!this.keypoints[i].isSame(other.keypoints[i])) return false;
29923
+ }
29924
+ return true;
29925
+ }
29894
29926
  getLowerKey(time2) {
29895
29927
  let resultKey = null;
29896
29928
  for (const key of this.keypoints) {
@@ -30078,17 +30110,23 @@ let lastInstanceId = 0;
30078
30110
  const AllInstances = [];
30079
30111
  class Instance {
30080
30112
  _id;
30113
+ /**
30114
+ * @deprecated Use .Prop("Name") instead
30115
+ */
30081
30116
  _name;
30082
30117
  //USED TO MAKE VIEWING EASIER
30083
30118
  className;
30119
+ /**
30120
+ * @deprecated Do not use this directly
30121
+ */
30084
30122
  _properties = /* @__PURE__ */ new Map();
30085
30123
  _referencedBy = [];
30086
30124
  _connectionReferences = [];
30087
- children = [];
30125
+ _children = [];
30088
30126
  parent = void 0;
30089
30127
  destroyed = false;
30090
- hasWrappered = false;
30091
- canGC = true;
30128
+ _hasWrappered = false;
30129
+ //private _canGC: boolean = true
30092
30130
  classID;
30093
30131
  //dont use this to identify instance class, it is only used during file loading
30094
30132
  objectFormat;
@@ -30123,8 +30161,8 @@ class Instance {
30123
30161
  }
30124
30162
  createWrapper() {
30125
30163
  const wrapper = GetWrapperForInstance(this);
30126
- if (wrapper && !this.hasWrappered) {
30127
- this.hasWrappered = true;
30164
+ if (wrapper && !this._hasWrappered) {
30165
+ this._hasWrappered = true;
30128
30166
  wrapper.created();
30129
30167
  }
30130
30168
  }
@@ -30242,6 +30280,13 @@ class Instance {
30242
30280
  name = this.fixPropertyName(name);
30243
30281
  return !!this._properties.get(name);
30244
30282
  }
30283
+ /**
30284
+ * Returns the value of a property
30285
+ * @param name Name of property
30286
+ * @returns Property's value
30287
+ *
30288
+ * @throws When property doesn't exist, PropOrDefault is a safer alternative
30289
+ */
30245
30290
  Property(name) {
30246
30291
  let property = this._properties.get(name);
30247
30292
  if (property) return property.value;
@@ -30285,6 +30330,13 @@ class Instance {
30285
30330
  throw new Error(`Property: ${name} does not exist`);
30286
30331
  }
30287
30332
  }
30333
+ /**
30334
+ * Returns the value of a property
30335
+ * @param name Name of property
30336
+ * @returns Property's value
30337
+ *
30338
+ * @throws When property doesn't exist, PropOrDefault is a safer alternative
30339
+ */
30288
30340
  Prop(name) {
30289
30341
  return this.Property(name);
30290
30342
  }
@@ -30305,9 +30357,9 @@ class Instance {
30305
30357
  throw new Error("Cannot set parent of instance to a destroyed instance");
30306
30358
  }
30307
30359
  if (this.parent) {
30308
- const index = this.parent.children.indexOf(this);
30360
+ const index = this.parent._children.indexOf(this);
30309
30361
  if (index !== -1) {
30310
- this.parent.children.splice(index, 1);
30362
+ this.parent._children.splice(index, 1);
30311
30363
  }
30312
30364
  }
30313
30365
  const originalParent = this.parent;
@@ -30316,7 +30368,7 @@ class Instance {
30316
30368
  originalParent.ChildRemoved.Fire(this);
30317
30369
  }
30318
30370
  if (instance) {
30319
- instance.children.push(this);
30371
+ instance._children.push(this);
30320
30372
  }
30321
30373
  if (fireEvents) {
30322
30374
  if (instance) {
@@ -30373,7 +30425,7 @@ class Instance {
30373
30425
  }
30374
30426
  GetChildren() {
30375
30427
  const childrenList = [];
30376
- for (const child of this.children) {
30428
+ for (const child of this._children) {
30377
30429
  childrenList.push(child);
30378
30430
  }
30379
30431
  return childrenList;
@@ -30403,7 +30455,7 @@ class Instance {
30403
30455
  return this.FindFirstChild(name);
30404
30456
  }
30405
30457
  FindFirstChildOfClass(className) {
30406
- for (const child of this.children) {
30458
+ for (const child of this._children) {
30407
30459
  if (child.className === className) {
30408
30460
  return child;
30409
30461
  }
@@ -30411,7 +30463,7 @@ class Instance {
30411
30463
  }
30412
30464
  FindLastChildOfClass(className) {
30413
30465
  let lastChild = void 0;
30414
- for (const child of this.children) {
30466
+ for (const child of this._children) {
30415
30467
  if (child.className === className) {
30416
30468
  lastChild = child;
30417
30469
  }
@@ -30527,7 +30579,7 @@ class RBX {
30527
30579
  treeGenerated = false;
30528
30580
  xmlString;
30529
30581
  get instances() {
30530
- return this.dataModel.children;
30582
+ return this.dataModel.GetChildren();
30531
30583
  }
30532
30584
  constructor() {
30533
30585
  this.reset();
@@ -31421,6 +31473,10 @@ class RBX {
31421
31473
  }
31422
31474
  return buffer2;
31423
31475
  }
31476
+ /**
31477
+ * Generates if needed hierarchy and returns root instance
31478
+ * @returns Root instance
31479
+ */
31424
31480
  generateTree() {
31425
31481
  if (this.treeGenerated) {
31426
31482
  warn(false, "Tree already generated");
@@ -32876,10 +32932,12 @@ class Outfit {
32876
32932
  return HumanoidDescription;
32877
32933
  }
32878
32934
  //TODO: Implement
32935
+ /** @deprecated */
32879
32936
  async fromHumanoidDescription(rootDocument) {
32880
32937
  const humanoidDescription = rootDocument.querySelector(".HumanoidDescription");
32881
32938
  log(false, humanoidDescription);
32882
32939
  }
32940
+ /** @deprecated */
32883
32941
  async downloadHumanoidDescription() {
32884
32942
  const humanoidDescription = await this.toHumanoidDescription();
32885
32943
  if (humanoidDescription) {
@@ -44926,6 +44984,12 @@ class RenderDesc extends DisposableDesc {
44926
44984
  }
44927
44985
  this.virtualFromRenderDesc(other);
44928
44986
  }
44987
+ transferFrom(other) {
44988
+ this.virtualTransferFrom(other);
44989
+ }
44990
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44991
+ virtualTransferFrom(_other) {
44992
+ }
44929
44993
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
44930
44994
  virtualFromRenderDesc(_other) {
44931
44995
  throw new Error("Virtual method virtualFromRenderDesc called");
@@ -45331,7 +45395,6 @@ class EmitterDesc extends DisposableDesc {
45331
45395
  passedTime = 0;
45332
45396
  lockedToPart = false;
45333
45397
  lifetime = new NumberRange(1, 1);
45334
- rate = 10;
45335
45398
  spreadAngle = new Vector22(0, 0);
45336
45399
  speed = new NumberRange(1, 1);
45337
45400
  rotation = new NumberRange(0, 0);
@@ -45344,9 +45407,6 @@ class EmitterDesc extends DisposableDesc {
45344
45407
  zOffset = 0;
45345
45408
  offset = new Vector32();
45346
45409
  shapeInOut = 0;
45347
- colorTexture;
45348
- alphaTexture;
45349
- texture;
45350
45410
  opacity = 1;
45351
45411
  lightEmission = 1;
45352
45412
  blending = AdditiveBlending;
@@ -45354,16 +45414,52 @@ class EmitterDesc extends DisposableDesc {
45354
45414
  size = new NumberSequence();
45355
45415
  transparency = new NumberSequence([new NumberSequenceKeypoint(0, 0, 0)]);
45356
45416
  normalizeSizeKeypointTime = true;
45417
+ //requires recompilation
45418
+ rate = 10;
45419
+ colorTexture;
45420
+ alphaTexture;
45421
+ texture;
45422
+ //results
45357
45423
  instanceOpacityBuffer;
45358
45424
  instanceColorBuffer;
45359
45425
  instanceSeedTimeBuffer;
45360
45426
  result;
45361
45427
  particles = [];
45428
+ initialParticleCount = 0;
45362
45429
  get maxCount() {
45363
- return Math.max(Math.ceil(this.lifetime.Max * this.rate) * 2, 1);
45430
+ const calculatedMax = Math.max(Math.ceil(this.lifetime.Max * this.rate) * 2, 1);
45431
+ const particleMax = this.initialParticleCount + calculatedMax;
45432
+ return particleMax;
45433
+ }
45434
+ needsRegeneration(other) {
45435
+ return this.texture === other.texture && this.alphaTexture === other.alphaTexture && this.colorTexture === other.colorTexture && this.rate === other.rate;
45364
45436
  }
45365
45437
  isSame(other) {
45366
- return this.lifetime.isSame(other.lifetime) && this.rate === other.rate && this.texture === other.texture;
45438
+ return !this.needsRegeneration(other) && this.lockedToPart === other.lockedToPart && this.lifetime.isSame(other.lifetime) && this.spreadAngle.isSame(other.spreadAngle) && this.speed.isSame(other.speed) && this.rotation.isSame(other.rotation) && this.rotationSpeed.isSame(other.rotationSpeed) && this.localAcceleration.isSame(other.localAcceleration) && this.acceleration.isSame(other.acceleration) && this.drag === other.drag && this.timeScale === other.timeScale && this.orientation === other.orientation && this.zOffset === other.zOffset && this.offset.isSame(other.offset) && this.shapeInOut === other.shapeInOut && this.opacity === other.opacity && this.lightEmission === other.lightEmission && this.blending === other.blending && this.color.isSame(other.color) && this.size.isSame(other.size) && this.transparency.isSame(other.transparency) && this.normalizeSizeKeypointTime === other.normalizeSizeKeypointTime;
45439
+ }
45440
+ fromEmitterDesc(other) {
45441
+ this.lockedToPart = other.lockedToPart;
45442
+ this.lifetime = other.lifetime.clone();
45443
+ this.rate = other.rate;
45444
+ this.spreadAngle = other.spreadAngle.clone();
45445
+ this.speed = other.speed.clone();
45446
+ this.rotation = other.rotation.clone();
45447
+ this.rotationSpeed = other.rotationSpeed.clone();
45448
+ this.localAcceleration = other.localAcceleration.clone();
45449
+ this.acceleration = other.acceleration.clone();
45450
+ this.drag = other.drag;
45451
+ this.timeScale = other.timeScale;
45452
+ this.orientation = other.orientation;
45453
+ this.zOffset = other.zOffset;
45454
+ this.offset = other.offset.clone();
45455
+ this.shapeInOut = other.shapeInOut;
45456
+ this.opacity = other.opacity;
45457
+ this.lightEmission = other.lightEmission;
45458
+ this.blending = other.blending;
45459
+ this.color = other.color.clone();
45460
+ this.size = other.size.clone();
45461
+ this.transparency = other.transparency.clone();
45462
+ this.normalizeSizeKeypointTime = other.normalizeSizeKeypointTime;
45367
45463
  }
45368
45464
  dispose(renderer, scene) {
45369
45465
  const mesh = this.result;
@@ -45589,17 +45685,14 @@ class EmitterGroupDesc extends RenderDesc {
45589
45685
  if (this.needsRegeneration(other)) {
45590
45686
  return false;
45591
45687
  }
45592
- if (this.time !== other.time) {
45593
- return false;
45594
- }
45595
- return true;
45688
+ return this.time === other.time;
45596
45689
  }
45597
45690
  needsRegeneration(other) {
45598
45691
  if (this.emitterDescs.length !== other.emitterDescs.length) {
45599
45692
  return true;
45600
45693
  }
45601
45694
  for (let i = 0; i < this.emitterDescs.length; i++) {
45602
- if (!this.emitterDescs[i].isSame(other.emitterDescs[i])) {
45695
+ if (!this.emitterDescs[i].needsRegeneration(other.emitterDescs[i])) {
45603
45696
  return true;
45604
45697
  }
45605
45698
  }
@@ -45611,6 +45704,17 @@ class EmitterGroupDesc extends RenderDesc {
45611
45704
  this.lowerBound = other.lowerBound;
45612
45705
  this.higherBound = other.higherBound;
45613
45706
  this.emitterDir = other.emitterDir;
45707
+ for (let i = 0; i < this.emitterDescs.length; i++) {
45708
+ this.emitterDescs[i].fromEmitterDesc(other.emitterDescs[i]);
45709
+ }
45710
+ }
45711
+ virtualTransferFrom(other) {
45712
+ if (this.emitterDescs.length === other.emitterDescs.length) {
45713
+ for (let i = 0; i < this.emitterDescs.length; i++) {
45714
+ this.emitterDescs[i].particles = other.emitterDescs[i].particles;
45715
+ this.emitterDescs[i].initialParticleCount = this.emitterDescs[i].particles.length;
45716
+ }
45717
+ }
45614
45718
  }
45615
45719
  fromInstance(child) {
45616
45720
  this.instance = child;
@@ -47753,6 +47857,11 @@ class HumanoidDescriptionWrapper extends InstanceWrapper {
47753
47857
  return void 0;
47754
47858
  }
47755
47859
  }
47860
+ /**
47861
+ * Update the data of the HumanoidDescription to match that inside an Outfit
47862
+ * @param outfit
47863
+ * @returns HumanoidDescription or Response if it fails
47864
+ */
47756
47865
  async fromOutfit(outfit) {
47757
47866
  this.instance.setProperty("BodyTypeScale", outfit.scale.bodyType);
47758
47867
  this.instance.setProperty("ProportionScale", outfit.scale.proportion);
@@ -49161,10 +49270,12 @@ class RBXRendererScene {
49161
49270
  ambientLight;
49162
49271
  directionalLight;
49163
49272
  directionalLight2;
49273
+ /** Forces viewport to be within bounds */
49164
49274
  setRect(bounds) {
49165
49275
  this.viewport = [bounds.left, window.innerHeight - bounds.bottom, bounds.width, bounds.height];
49166
49276
  this.scissor = [...this.viewport];
49167
49277
  }
49278
+ /** Makes viewport size 0x0, invisible */
49168
49279
  noRect() {
49169
49280
  this.viewport = [0, 0, 0, 0];
49170
49281
  this.scissor = [0, 0, 0, 0];
@@ -49667,6 +49778,7 @@ class RBXRenderer {
49667
49778
  }
49668
49779
  } else {
49669
49780
  if (!renderScene.isRenderingMesh.get(instance)) {
49781
+ if (oldDesc) newDesc.transferFrom(oldDesc);
49670
49782
  newDesc.results = oldDesc?.results;
49671
49783
  renderScene.renderDescs.set(instance, newDesc);
49672
49784
  renderScene.isRenderingMesh.set(instance, true);
@@ -50463,10 +50575,12 @@ export {
50463
50575
  FindFirstMatchingAttachment,
50464
50576
  FullBodyColors,
50465
50577
  GetAttachedPart,
50578
+ GetWrapperForInstance,
50466
50579
  HSR,
50467
50580
  HumanoidDescriptionWrapper,
50468
50581
  HumanoidRigType,
50469
50582
  Instance,
50583
+ InstanceWrapper,
50470
50584
  ItemInfo,
50471
50585
  ItemSort,
50472
50586
  LayeredAssetTypes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roavatar-renderer",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A renderer for Roblox avatars, used by the RoAvatar extension.",
5
5
  "author": "steinan",
6
6
  "type": "module",
@@ -46,6 +46,7 @@
46
46
  "eslint-plugin-react-hooks": "^5.2.0",
47
47
  "eslint-plugin-react-refresh": "^0.4.22",
48
48
  "globals": "^16.4.0",
49
+ "typedoc": "^0.28.19",
49
50
  "typescript": "~5.9.3",
50
51
  "typescript-eslint": "^8.45.0",
51
52
  "vite": "^7.1.7",