roavatar-renderer 1.9.0 → 1.9.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.d.ts +6 -1
- package/dist/index.js +46 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,11 @@ export declare class AccessoryWrapper extends InstanceWrapper {
|
|
|
72
72
|
static requiredProperties: string[];
|
|
73
73
|
setup(): void;
|
|
74
74
|
created(): void;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @returns [bodyAttachment, handleAttachment] or undefined
|
|
78
|
+
*/
|
|
79
|
+
getBodyAccessoryAttachmentPair(): [Instance, Instance] | undefined;
|
|
75
80
|
AccessoryBuildWeld(): void;
|
|
76
81
|
}
|
|
77
82
|
|
|
@@ -1894,7 +1899,7 @@ export declare function getOffsetArray(inner: FileMesh, outer: FileMesh): ([Vec3
|
|
|
1894
1899
|
|
|
1895
1900
|
export declare function getOriginalAttachmentOrientation(attachment: Instance): Vector3;
|
|
1896
1901
|
|
|
1897
|
-
export declare function getOriginalAttachmentPosition(attachment: Instance): Vector3;
|
|
1902
|
+
export declare function getOriginalAttachmentPosition(attachment: Instance, currentScale: Vector3): Vector3;
|
|
1898
1903
|
|
|
1899
1904
|
export declare function getOriginalSize(part: Instance): Vector3;
|
|
1900
1905
|
|
package/dist/index.js
CHANGED
|
@@ -44164,8 +44164,12 @@ class AccessoryWrapper extends InstanceWrapper {
|
|
|
44164
44164
|
this.AccessoryBuildWeld();
|
|
44165
44165
|
});
|
|
44166
44166
|
}
|
|
44167
|
-
|
|
44168
|
-
|
|
44167
|
+
/**
|
|
44168
|
+
*
|
|
44169
|
+
* @returns [bodyAttachment, handleAttachment] or undefined
|
|
44170
|
+
*/
|
|
44171
|
+
getBodyAccessoryAttachmentPair() {
|
|
44172
|
+
if (this.instance.parent) {
|
|
44169
44173
|
const humanoid = this.instance.parent.FindFirstChildOfClass("Humanoid");
|
|
44170
44174
|
if (humanoid) {
|
|
44171
44175
|
const handle = this.instance.FindFirstChild("Handle");
|
|
@@ -44184,11 +44188,24 @@ class AccessoryWrapper extends InstanceWrapper {
|
|
|
44184
44188
|
}
|
|
44185
44189
|
}
|
|
44186
44190
|
}
|
|
44191
|
+
if (bodyAttachment && accessoryAttachment) return [bodyAttachment, accessoryAttachment];
|
|
44192
|
+
}
|
|
44193
|
+
}
|
|
44194
|
+
}
|
|
44195
|
+
}
|
|
44196
|
+
AccessoryBuildWeld() {
|
|
44197
|
+
if (this.instance.parent && this.instance.className === "Accessory") {
|
|
44198
|
+
const humanoid = this.instance.parent.FindFirstChildOfClass("Humanoid");
|
|
44199
|
+
if (humanoid) {
|
|
44200
|
+
const handle = this.instance.FindFirstChild("Handle");
|
|
44201
|
+
if (handle) {
|
|
44202
|
+
const attachmentPair = this.getBodyAccessoryAttachmentPair();
|
|
44187
44203
|
const oldAccessoryWeld = handle.FindFirstChild("AccessoryWeld");
|
|
44188
44204
|
if (oldAccessoryWeld) {
|
|
44189
44205
|
oldAccessoryWeld.Destroy();
|
|
44190
44206
|
}
|
|
44191
|
-
if (
|
|
44207
|
+
if (attachmentPair) {
|
|
44208
|
+
const [bodyAttachment, accessoryAttachment] = attachmentPair;
|
|
44192
44209
|
const weld = new Instance("Weld");
|
|
44193
44210
|
weld.addProperty(new Property("Name", DataType.String), "AccessoryWeld");
|
|
44194
44211
|
weld.addProperty(new Property("Archivable", DataType.Bool), true);
|
|
@@ -44475,9 +44492,9 @@ function getOriginalSize(part) {
|
|
|
44475
44492
|
}
|
|
44476
44493
|
return originalSize;
|
|
44477
44494
|
}
|
|
44478
|
-
function scaleChildrenOfPart(part, scaleVector,
|
|
44495
|
+
function scaleChildrenOfPart(part, scaleVector, alreadyScaledAttachment) {
|
|
44479
44496
|
for (const child of part.GetDescendants()) {
|
|
44480
|
-
if (child.className === "Attachment" &&
|
|
44497
|
+
if (child.className === "Attachment" && child !== alreadyScaledAttachment) {
|
|
44481
44498
|
let originalPosition = child.Prop("Position");
|
|
44482
44499
|
originalPosition = originalPosition.multiply(scaleVector);
|
|
44483
44500
|
const newCF = child.Prop("CFrame").clone();
|
|
@@ -44491,10 +44508,11 @@ function scaleChildrenOfPart(part, scaleVector, scaleAttachment = true) {
|
|
|
44491
44508
|
}
|
|
44492
44509
|
}
|
|
44493
44510
|
}
|
|
44494
|
-
function originalChildrenOfPart(part) {
|
|
44511
|
+
function originalChildrenOfPart(part, originalSize, currentSize) {
|
|
44512
|
+
const currentScale = currentSize.divide(originalSize);
|
|
44495
44513
|
for (const child of part.GetDescendants()) {
|
|
44496
44514
|
if (child.className === "Attachment") {
|
|
44497
|
-
const originalPosition = getOriginalAttachmentPosition(child);
|
|
44515
|
+
const originalPosition = getOriginalAttachmentPosition(child, currentScale);
|
|
44498
44516
|
const originalOrientation = getOriginalAttachmentOrientation(child);
|
|
44499
44517
|
const newCF = child.Prop("CFrame").clone();
|
|
44500
44518
|
newCF.Position = [originalPosition.X, originalPosition.Y, originalPosition.Z];
|
|
@@ -44502,7 +44520,7 @@ function originalChildrenOfPart(part) {
|
|
|
44502
44520
|
child.setProperty("CFrame", newCF);
|
|
44503
44521
|
} else if (child.className === "SpecialMesh") {
|
|
44504
44522
|
if (child.Prop("MeshType") !== MeshType.Head) {
|
|
44505
|
-
const orignalScale = getOriginalMeshScale(child);
|
|
44523
|
+
const orignalScale = getOriginalMeshScale(child, currentScale);
|
|
44506
44524
|
child.setProperty("Scale", orignalScale);
|
|
44507
44525
|
}
|
|
44508
44526
|
}
|
|
@@ -44593,32 +44611,36 @@ function ScaleAccessory(accessory, bodyScaleVector, headScaleVector, bodyTypeSca
|
|
|
44593
44611
|
} else {
|
|
44594
44612
|
warn(false, "Failed to find attached part for accessory:", accessory);
|
|
44595
44613
|
}
|
|
44596
|
-
originalChildrenOfPart(handle);
|
|
44597
44614
|
const originalSize = getOriginalSize(handle);
|
|
44598
|
-
|
|
44615
|
+
originalChildrenOfPart(handle, originalSize, handle.Prop("Size"));
|
|
44616
|
+
let hasAdjusted = void 0;
|
|
44617
|
+
let attachmentPair = void 0;
|
|
44599
44618
|
const accessoryDescs = humanoidDescription.GetChildren();
|
|
44600
44619
|
for (const accessoryDesc of accessoryDescs) {
|
|
44601
44620
|
if (accessoryDesc.className === "AccessoryDescription") {
|
|
44602
|
-
if (accessoryDesc.Prop("Instance") === accessory) {
|
|
44603
|
-
const
|
|
44604
|
-
|
|
44605
|
-
|
|
44606
|
-
|
|
44621
|
+
if (accessoryDesc.Prop("Instance") === accessory && accessory.IsA("Accessory")) {
|
|
44622
|
+
const accessoryW = accessory.w;
|
|
44623
|
+
attachmentPair = accessoryW.getBodyAccessoryAttachmentPair();
|
|
44624
|
+
if (attachmentPair) {
|
|
44625
|
+
const handleAttachment = attachmentPair[1];
|
|
44626
|
+
hasAdjusted = handleAttachment;
|
|
44627
|
+
adjustAttachment(handleAttachment, accessoryDesc.Prop("Position"), accessoryDesc.Prop("Rotation"), accessoryDesc.Prop("Scale"), resultScale);
|
|
44607
44628
|
}
|
|
44608
44629
|
const adjustScale = accessoryDesc.Prop("Scale");
|
|
44609
44630
|
resultScale = resultScale.multiply(adjustScale);
|
|
44610
44631
|
}
|
|
44611
44632
|
}
|
|
44612
44633
|
}
|
|
44613
|
-
scaleChildrenOfPart(handle, resultScale,
|
|
44634
|
+
scaleChildrenOfPart(handle, resultScale, hasAdjusted);
|
|
44614
44635
|
handle.setProperty("Size", originalSize.multiply(resultScale));
|
|
44615
44636
|
if (accessory.className === "Accessory") {
|
|
44616
44637
|
const accessoryWrapper = new AccessoryWrapper(accessory);
|
|
44617
44638
|
accessoryWrapper.AccessoryBuildWeld();
|
|
44618
44639
|
}
|
|
44619
44640
|
}
|
|
44620
|
-
function getOriginalMeshScale(mesh) {
|
|
44641
|
+
function getOriginalMeshScale(mesh, currentScale) {
|
|
44621
44642
|
let originalScale = mesh.Prop("Scale");
|
|
44643
|
+
originalScale = originalScale.divide(currentScale);
|
|
44622
44644
|
const originalScaleValue = mesh.FindFirstChild(originalSizeName);
|
|
44623
44645
|
if (originalScaleValue) {
|
|
44624
44646
|
originalScale = originalScaleValue.Prop("Value");
|
|
@@ -44630,12 +44652,13 @@ function getOriginalMeshScale(mesh) {
|
|
|
44630
44652
|
}
|
|
44631
44653
|
return originalScale;
|
|
44632
44654
|
}
|
|
44633
|
-
function getOriginalAttachmentPosition(attachment) {
|
|
44655
|
+
function getOriginalAttachmentPosition(attachment, currentScale) {
|
|
44634
44656
|
const originalPosition = attachment.FindFirstChild(originalPositionName);
|
|
44635
44657
|
if (originalPosition) {
|
|
44636
44658
|
return originalPosition.Prop("Value");
|
|
44637
44659
|
}
|
|
44638
|
-
|
|
44660
|
+
let position = attachment.Prop("Position");
|
|
44661
|
+
position = position.divide(currentScale);
|
|
44639
44662
|
const attachmentLocationValue = new Instance("Vector3Value");
|
|
44640
44663
|
attachmentLocationValue.addProperty(new Property("Name", DataType.String), originalPositionName);
|
|
44641
44664
|
attachmentLocationValue.addProperty(new Property("Value", DataType.Vector3), position);
|
|
@@ -44656,7 +44679,9 @@ function getOriginalAttachmentOrientation(attachment) {
|
|
|
44656
44679
|
}
|
|
44657
44680
|
function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercent, wideToNarrow) {
|
|
44658
44681
|
const partName = part.Prop("Name");
|
|
44682
|
+
const currentSize = part.Prop("Size");
|
|
44659
44683
|
const originalSize = getOriginalSize(part);
|
|
44684
|
+
const currentScale = currentSize.divide(originalSize);
|
|
44660
44685
|
let newScaleVector = bodyScaleVector;
|
|
44661
44686
|
if (partName == "Head") {
|
|
44662
44687
|
newScaleVector = headScaleVector;
|
|
@@ -44706,7 +44731,7 @@ function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercen
|
|
|
44706
44731
|
if (mesh.Prop("MeshType") == MeshType.Head) {
|
|
44707
44732
|
headScale = Vector3.new(1, 1, 1);
|
|
44708
44733
|
}
|
|
44709
|
-
const originalScale = getOriginalMeshScale(mesh);
|
|
44734
|
+
const originalScale = getOriginalMeshScale(mesh, currentScale);
|
|
44710
44735
|
if (mesh.Prop("MeshType") !== MeshType.Head) {
|
|
44711
44736
|
mesh.setProperty("Scale", originalScale.multiply(scale).multiply(headScale));
|
|
44712
44737
|
}
|
|
@@ -44736,7 +44761,7 @@ function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercen
|
|
|
44736
44761
|
part.setProperty("Size", originalSize.multiply(scale).multiply(newScaleVector));
|
|
44737
44762
|
for (const child of part.GetDescendants()) {
|
|
44738
44763
|
if (child.className === "Attachment") {
|
|
44739
|
-
const originalAttachment = getOriginalAttachmentPosition(child);
|
|
44764
|
+
const originalAttachment = getOriginalAttachmentPosition(child, currentScale);
|
|
44740
44765
|
const ogCF = child.Prop("CFrame").clone();
|
|
44741
44766
|
const newPos = originalAttachment.multiply(scale).multiply(newScaleVector);
|
|
44742
44767
|
ogCF.Position = [newPos.X, newPos.Y, newPos.Z];
|