roavatar-renderer 1.8.0 → 1.8.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 +7 -0
- package/dist/index.js +72 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1837,8 +1837,15 @@ export declare function getCameraCFrameForAvatarNonCustomized(rig: Instance): CF
|
|
|
1837
1837
|
*/
|
|
1838
1838
|
export declare function getCameraCFrameForHeadshotCustomized(rig: Instance, fov: number, yRot: number, distance: number): CFrame | undefined;
|
|
1839
1839
|
|
|
1840
|
+
export declare function getCameraCFrameForHeadshotNonCustomized(rig: Instance, newLighting?: boolean): {
|
|
1841
|
+
cframe: CFrame;
|
|
1842
|
+
fov: number;
|
|
1843
|
+
};
|
|
1844
|
+
|
|
1840
1845
|
export declare function getCharacterTorsoCFrame(character: Instance): CFrame;
|
|
1841
1846
|
|
|
1847
|
+
export declare function getCloseupCameraCFrame(character: Instance, newLighting?: boolean): Instance;
|
|
1848
|
+
|
|
1842
1849
|
/**
|
|
1843
1850
|
* @category Mesh
|
|
1844
1851
|
*/
|
package/dist/index.js
CHANGED
|
@@ -48650,6 +48650,11 @@ class ObjectDesc extends RenderDesc {
|
|
|
48650
48650
|
}
|
|
48651
48651
|
if (this.materialDesc.result) {
|
|
48652
48652
|
this.materialDesc.updateResult();
|
|
48653
|
+
if (this.results) {
|
|
48654
|
+
for (const result of this.results) {
|
|
48655
|
+
result.visible = this.materialDesc.visible;
|
|
48656
|
+
}
|
|
48657
|
+
}
|
|
48653
48658
|
}
|
|
48654
48659
|
}
|
|
48655
48660
|
static shouldRenderInstance(instance) {
|
|
@@ -62894,6 +62899,63 @@ function getAvatarCameraCFrame(character, applyEmote, isFallbackEmoteApplied, fi
|
|
|
62894
62899
|
setupCamera(camera, cameraOptions);
|
|
62895
62900
|
return camera;
|
|
62896
62901
|
}
|
|
62902
|
+
function getCloseupCameraCFrame(character, newLighting = true) {
|
|
62903
|
+
const cameraOffsetX = 0;
|
|
62904
|
+
const cameraOffsetY = 0;
|
|
62905
|
+
const baseHatZoom = 30;
|
|
62906
|
+
const maxHatZoom = 100;
|
|
62907
|
+
const headAttachments = [];
|
|
62908
|
+
const head = character.FindFirstChild("Head");
|
|
62909
|
+
let headPos = new Vector3();
|
|
62910
|
+
let headCF = new CFrame();
|
|
62911
|
+
if (head) {
|
|
62912
|
+
headPos = head.Prop("Position");
|
|
62913
|
+
headCF = head.Prop("CFrame");
|
|
62914
|
+
for (const child of head.GetChildren()) {
|
|
62915
|
+
if (child.IsA("Attachment")) {
|
|
62916
|
+
headAttachments.push(child.Prop("Name"));
|
|
62917
|
+
}
|
|
62918
|
+
}
|
|
62919
|
+
}
|
|
62920
|
+
let maxDimension = 0;
|
|
62921
|
+
for (const child of character.GetChildren()) {
|
|
62922
|
+
if (child.IsA("Accessory")) {
|
|
62923
|
+
const handle = child.FindFirstChild("Handle");
|
|
62924
|
+
if (handle) {
|
|
62925
|
+
const handlePos = handle.Prop("Position");
|
|
62926
|
+
let hasHeadAttachment = false;
|
|
62927
|
+
for (const att of handle.GetChildren()) {
|
|
62928
|
+
if (att.IsA("Attachment") && headAttachments.includes(att.Prop("Name"))) {
|
|
62929
|
+
hasHeadAttachment = true;
|
|
62930
|
+
break;
|
|
62931
|
+
}
|
|
62932
|
+
}
|
|
62933
|
+
if (hasHeadAttachment) {
|
|
62934
|
+
const size = handle.Prop("Size").divide(new Vector3(2, 2, 2)).add(handlePos).minus(headPos);
|
|
62935
|
+
size.Z = 0;
|
|
62936
|
+
if (size.magnitude() > maxDimension) {
|
|
62937
|
+
maxDimension = size.magnitude();
|
|
62938
|
+
}
|
|
62939
|
+
}
|
|
62940
|
+
}
|
|
62941
|
+
}
|
|
62942
|
+
}
|
|
62943
|
+
const maxHatOffset = 0.5;
|
|
62944
|
+
maxDimension = Math.min(1, maxDimension / 3);
|
|
62945
|
+
maxDimension *= maxDimension;
|
|
62946
|
+
const viewOffset = headCF.multiply(new CFrame(cameraOffsetX, cameraOffsetY + maxHatOffset * maxDimension, 0.1));
|
|
62947
|
+
let yAngle = -Math.PI / 16;
|
|
62948
|
+
if (newLighting) {
|
|
62949
|
+
yAngle = 0;
|
|
62950
|
+
}
|
|
62951
|
+
const positionOffset = headCF.clone();
|
|
62952
|
+
const toAdd = multiply(normalize(CFrame.Angles(0, yAngle, 0).lookVector()), [3, 3, 3]);
|
|
62953
|
+
positionOffset.Position = add(positionOffset.Position, toAdd);
|
|
62954
|
+
const camera = createThumbnailCamera();
|
|
62955
|
+
camera.setProperty("CFrame", CFrame.lookAt(positionOffset.Position, viewOffset.Position));
|
|
62956
|
+
camera.setProperty("FieldOfView", baseHatZoom + (maxHatZoom - baseHatZoom) * maxDimension);
|
|
62957
|
+
return camera;
|
|
62958
|
+
}
|
|
62897
62959
|
function getCorners(cframe, size) {
|
|
62898
62960
|
const halfX = size.X / 2;
|
|
62899
62961
|
const halfY = size.Y / 2;
|
|
@@ -62959,7 +63021,7 @@ function getExtents(cframe, parts) {
|
|
|
62959
63021
|
function getExtentsWorld(rig) {
|
|
62960
63022
|
const rigParts = [];
|
|
62961
63023
|
for (const child of rig.GetDescendants()) {
|
|
62962
|
-
if (child.createWrapper()?.IsA("BasePart")) {
|
|
63024
|
+
if (child.createWrapper()?.IsA("BasePart") && !(child.Prop("Name") === "HumanoidRootPart")) {
|
|
62963
63025
|
rigParts.push(child);
|
|
62964
63026
|
}
|
|
62965
63027
|
}
|
|
@@ -63021,6 +63083,13 @@ function getCameraCFrameForHeadshotCustomized(rig, fov2, yRot, distance2) {
|
|
|
63021
63083
|
return cameraCF;
|
|
63022
63084
|
}
|
|
63023
63085
|
}
|
|
63086
|
+
function getCameraCFrameForHeadshotNonCustomized(rig, newLighting = true) {
|
|
63087
|
+
const camera = getCloseupCameraCFrame(rig, newLighting);
|
|
63088
|
+
const cameraCF = camera.Prop("CFrame");
|
|
63089
|
+
const cameraFOV = camera.Prop("FieldOfView");
|
|
63090
|
+
camera.Destroy();
|
|
63091
|
+
return { cframe: cameraCF, fov: cameraFOV };
|
|
63092
|
+
}
|
|
63024
63093
|
function getCameraCFrameForAvatarCustomized(rig, fov2, yRot) {
|
|
63025
63094
|
const camera = getAvatarCameraCFrame(rig, void 0, void 0, fov2, {
|
|
63026
63095
|
optCameraYRot: yRot,
|
|
@@ -64211,7 +64280,9 @@ export {
|
|
|
64211
64280
|
getCameraCFrameForAvatarCustomized,
|
|
64212
64281
|
getCameraCFrameForAvatarNonCustomized,
|
|
64213
64282
|
getCameraCFrameForHeadshotCustomized,
|
|
64283
|
+
getCameraCFrameForHeadshotNonCustomized,
|
|
64214
64284
|
getCharacterTorsoCFrame,
|
|
64285
|
+
getCloseupCameraCFrame,
|
|
64215
64286
|
getDistIndexArray,
|
|
64216
64287
|
getExtents,
|
|
64217
64288
|
getExtentsCenter,
|