roavatar-renderer 1.9.0 → 1.9.2
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 +47 -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,37 @@ 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;
|
|
44618
|
+
const beforeAdjustmentResultScale = resultScale.clone();
|
|
44599
44619
|
const accessoryDescs = humanoidDescription.GetChildren();
|
|
44600
44620
|
for (const accessoryDesc of accessoryDescs) {
|
|
44601
44621
|
if (accessoryDesc.className === "AccessoryDescription") {
|
|
44602
|
-
if (accessoryDesc.Prop("Instance") === accessory) {
|
|
44603
|
-
const
|
|
44604
|
-
|
|
44605
|
-
|
|
44606
|
-
|
|
44622
|
+
if (accessoryDesc.Prop("Instance") === accessory && accessory.IsA("Accessory")) {
|
|
44623
|
+
const accessoryW = accessory.w;
|
|
44624
|
+
attachmentPair = accessoryW.getBodyAccessoryAttachmentPair();
|
|
44625
|
+
if (attachmentPair) {
|
|
44626
|
+
const handleAttachment = attachmentPair[1];
|
|
44627
|
+
hasAdjusted = handleAttachment;
|
|
44628
|
+
adjustAttachment(handleAttachment, accessoryDesc.Prop("Position"), accessoryDesc.Prop("Rotation"), accessoryDesc.Prop("Scale"), resultScale);
|
|
44607
44629
|
}
|
|
44608
44630
|
const adjustScale = accessoryDesc.Prop("Scale");
|
|
44609
44631
|
resultScale = resultScale.multiply(adjustScale);
|
|
44610
44632
|
}
|
|
44611
44633
|
}
|
|
44612
44634
|
}
|
|
44613
|
-
scaleChildrenOfPart(handle,
|
|
44635
|
+
scaleChildrenOfPart(handle, beforeAdjustmentResultScale, hasAdjusted);
|
|
44614
44636
|
handle.setProperty("Size", originalSize.multiply(resultScale));
|
|
44615
44637
|
if (accessory.className === "Accessory") {
|
|
44616
44638
|
const accessoryWrapper = new AccessoryWrapper(accessory);
|
|
44617
44639
|
accessoryWrapper.AccessoryBuildWeld();
|
|
44618
44640
|
}
|
|
44619
44641
|
}
|
|
44620
|
-
function getOriginalMeshScale(mesh) {
|
|
44642
|
+
function getOriginalMeshScale(mesh, currentScale) {
|
|
44621
44643
|
let originalScale = mesh.Prop("Scale");
|
|
44644
|
+
originalScale = originalScale.divide(currentScale);
|
|
44622
44645
|
const originalScaleValue = mesh.FindFirstChild(originalSizeName);
|
|
44623
44646
|
if (originalScaleValue) {
|
|
44624
44647
|
originalScale = originalScaleValue.Prop("Value");
|
|
@@ -44630,12 +44653,13 @@ function getOriginalMeshScale(mesh) {
|
|
|
44630
44653
|
}
|
|
44631
44654
|
return originalScale;
|
|
44632
44655
|
}
|
|
44633
|
-
function getOriginalAttachmentPosition(attachment) {
|
|
44656
|
+
function getOriginalAttachmentPosition(attachment, currentScale) {
|
|
44634
44657
|
const originalPosition = attachment.FindFirstChild(originalPositionName);
|
|
44635
44658
|
if (originalPosition) {
|
|
44636
44659
|
return originalPosition.Prop("Value");
|
|
44637
44660
|
}
|
|
44638
|
-
|
|
44661
|
+
let position = attachment.Prop("Position");
|
|
44662
|
+
position = position.divide(currentScale);
|
|
44639
44663
|
const attachmentLocationValue = new Instance("Vector3Value");
|
|
44640
44664
|
attachmentLocationValue.addProperty(new Property("Name", DataType.String), originalPositionName);
|
|
44641
44665
|
attachmentLocationValue.addProperty(new Property("Value", DataType.Vector3), position);
|
|
@@ -44656,7 +44680,9 @@ function getOriginalAttachmentOrientation(attachment) {
|
|
|
44656
44680
|
}
|
|
44657
44681
|
function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercent, wideToNarrow) {
|
|
44658
44682
|
const partName = part.Prop("Name");
|
|
44683
|
+
const currentSize = part.Prop("Size");
|
|
44659
44684
|
const originalSize = getOriginalSize(part);
|
|
44685
|
+
const currentScale = currentSize.divide(originalSize);
|
|
44660
44686
|
let newScaleVector = bodyScaleVector;
|
|
44661
44687
|
if (partName == "Head") {
|
|
44662
44688
|
newScaleVector = headScaleVector;
|
|
@@ -44706,7 +44732,7 @@ function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercen
|
|
|
44706
44732
|
if (mesh.Prop("MeshType") == MeshType.Head) {
|
|
44707
44733
|
headScale = Vector3.new(1, 1, 1);
|
|
44708
44734
|
}
|
|
44709
|
-
const originalScale = getOriginalMeshScale(mesh);
|
|
44735
|
+
const originalScale = getOriginalMeshScale(mesh, currentScale);
|
|
44710
44736
|
if (mesh.Prop("MeshType") !== MeshType.Head) {
|
|
44711
44737
|
mesh.setProperty("Scale", originalScale.multiply(scale).multiply(headScale));
|
|
44712
44738
|
}
|
|
@@ -44736,7 +44762,7 @@ function ScaleCharacterPart(part, bodyScaleVector, headScaleVector, anthroPercen
|
|
|
44736
44762
|
part.setProperty("Size", originalSize.multiply(scale).multiply(newScaleVector));
|
|
44737
44763
|
for (const child of part.GetDescendants()) {
|
|
44738
44764
|
if (child.className === "Attachment") {
|
|
44739
|
-
const originalAttachment = getOriginalAttachmentPosition(child);
|
|
44765
|
+
const originalAttachment = getOriginalAttachmentPosition(child, currentScale);
|
|
44740
44766
|
const ogCF = child.Prop("CFrame").clone();
|
|
44741
44767
|
const newPos = originalAttachment.multiply(scale).multiply(newScaleVector);
|
|
44742
44768
|
ogCF.Position = [newPos.X, newPos.Y, newPos.Z];
|