Remove internal phase comments and format code
Strip all Phase references, TODO/FUTURE roadmap notes, and internal planning comments from the codebase. Run Prettier for consistent formatting across all Java files.
This commit is contained in:
@@ -77,8 +77,10 @@ public final class GlbParserUtils {
|
||||
// ---- Accessor reading utilities ----
|
||||
|
||||
public static float[] readFloatAccessor(
|
||||
JsonArray accessors, JsonArray bufferViews,
|
||||
ByteBuffer binData, int accessorIdx
|
||||
JsonArray accessors,
|
||||
JsonArray bufferViews,
|
||||
ByteBuffer binData,
|
||||
int accessorIdx
|
||||
) {
|
||||
JsonObject accessor = accessors.get(accessorIdx).getAsJsonObject();
|
||||
int count = accessor.get("count").getAsInt();
|
||||
@@ -88,9 +90,14 @@ public final class GlbParserUtils {
|
||||
|
||||
int bvIdx = accessor.get("bufferView").getAsInt();
|
||||
JsonObject bv = bufferViews.get(bvIdx).getAsJsonObject();
|
||||
int byteOffset = (bv.has("byteOffset") ? bv.get("byteOffset").getAsInt() : 0)
|
||||
+ (accessor.has("byteOffset") ? accessor.get("byteOffset").getAsInt() : 0);
|
||||
int byteStride = bv.has("byteStride") ? bv.get("byteStride").getAsInt() : 0;
|
||||
int byteOffset =
|
||||
(bv.has("byteOffset") ? bv.get("byteOffset").getAsInt() : 0) +
|
||||
(accessor.has("byteOffset")
|
||||
? accessor.get("byteOffset").getAsInt()
|
||||
: 0);
|
||||
int byteStride = bv.has("byteStride")
|
||||
? bv.get("byteStride").getAsInt()
|
||||
: 0;
|
||||
|
||||
int totalElements = count * components;
|
||||
float[] result = new float[totalElements];
|
||||
@@ -102,7 +109,10 @@ public final class GlbParserUtils {
|
||||
int pos = byteOffset + i * stride;
|
||||
for (int c = 0; c < components; c++) {
|
||||
binData.position(pos + c * componentSize);
|
||||
result[i * components + c] = readComponentAsFloat(binData, componentType);
|
||||
result[i * components + c] = readComponentAsFloat(
|
||||
binData,
|
||||
componentType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +120,10 @@ public final class GlbParserUtils {
|
||||
}
|
||||
|
||||
public static int[] readIntAccessor(
|
||||
JsonArray accessors, JsonArray bufferViews,
|
||||
ByteBuffer binData, int accessorIdx
|
||||
JsonArray accessors,
|
||||
JsonArray bufferViews,
|
||||
ByteBuffer binData,
|
||||
int accessorIdx
|
||||
) {
|
||||
JsonObject accessor = accessors.get(accessorIdx).getAsJsonObject();
|
||||
int count = accessor.get("count").getAsInt();
|
||||
@@ -121,9 +133,14 @@ public final class GlbParserUtils {
|
||||
|
||||
int bvIdx = accessor.get("bufferView").getAsInt();
|
||||
JsonObject bv = bufferViews.get(bvIdx).getAsJsonObject();
|
||||
int byteOffset = (bv.has("byteOffset") ? bv.get("byteOffset").getAsInt() : 0)
|
||||
+ (accessor.has("byteOffset") ? accessor.get("byteOffset").getAsInt() : 0);
|
||||
int byteStride = bv.has("byteStride") ? bv.get("byteStride").getAsInt() : 0;
|
||||
int byteOffset =
|
||||
(bv.has("byteOffset") ? bv.get("byteOffset").getAsInt() : 0) +
|
||||
(accessor.has("byteOffset")
|
||||
? accessor.get("byteOffset").getAsInt()
|
||||
: 0);
|
||||
int byteStride = bv.has("byteStride")
|
||||
? bv.get("byteStride").getAsInt()
|
||||
: 0;
|
||||
|
||||
int totalElements = count * components;
|
||||
int[] result = new int[totalElements];
|
||||
@@ -135,22 +152,31 @@ public final class GlbParserUtils {
|
||||
int pos = byteOffset + i * stride;
|
||||
for (int c = 0; c < components; c++) {
|
||||
binData.position(pos + c * componentSize);
|
||||
result[i * components + c] = readComponentAsInt(binData, componentType);
|
||||
result[i * components + c] = readComponentAsInt(
|
||||
binData,
|
||||
componentType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float readComponentAsFloat(ByteBuffer buf, int componentType) {
|
||||
public static float readComponentAsFloat(
|
||||
ByteBuffer buf,
|
||||
int componentType
|
||||
) {
|
||||
return switch (componentType) {
|
||||
case FLOAT -> buf.getFloat();
|
||||
case BYTE -> buf.get() / 127.0f;
|
||||
case UNSIGNED_BYTE -> (buf.get() & 0xFF) / 255.0f;
|
||||
case SHORT -> buf.getShort() / 32767.0f;
|
||||
case UNSIGNED_SHORT -> (buf.getShort() & 0xFFFF) / 65535.0f;
|
||||
case UNSIGNED_INT -> (buf.getInt() & 0xFFFFFFFFL) / (float) 0xFFFFFFFFL;
|
||||
default -> throw new IllegalArgumentException("Unknown component type: " + componentType);
|
||||
case UNSIGNED_INT -> (buf.getInt() & 0xFFFFFFFFL) /
|
||||
(float) 0xFFFFFFFFL;
|
||||
default -> throw new IllegalArgumentException(
|
||||
"Unknown component type: " + componentType
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -162,7 +188,9 @@ public final class GlbParserUtils {
|
||||
case UNSIGNED_SHORT -> buf.getShort() & 0xFFFF;
|
||||
case UNSIGNED_INT -> buf.getInt();
|
||||
case FLOAT -> (int) buf.getFloat();
|
||||
default -> throw new IllegalArgumentException("Unknown component type: " + componentType);
|
||||
default -> throw new IllegalArgumentException(
|
||||
"Unknown component type: " + componentType
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -173,7 +201,9 @@ public final class GlbParserUtils {
|
||||
case "VEC3" -> 3;
|
||||
case "VEC4" -> 4;
|
||||
case "MAT4" -> 16;
|
||||
default -> throw new IllegalArgumentException("Unknown accessor type: " + type);
|
||||
default -> throw new IllegalArgumentException(
|
||||
"Unknown accessor type: " + type
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -182,7 +212,9 @@ public final class GlbParserUtils {
|
||||
case BYTE, UNSIGNED_BYTE -> 1;
|
||||
case SHORT, UNSIGNED_SHORT -> 2;
|
||||
case UNSIGNED_INT, FLOAT -> 4;
|
||||
default -> throw new IllegalArgumentException("Unknown component type: " + componentType);
|
||||
default -> throw new IllegalArgumentException(
|
||||
"Unknown component type: " + componentType
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -191,13 +223,18 @@ public final class GlbParserUtils {
|
||||
/**
|
||||
* Deep-copy an AnimationClip (preserves original data before MC conversion).
|
||||
*/
|
||||
public static GltfData.AnimationClip deepCopyClip(GltfData.AnimationClip clip) {
|
||||
Quaternionf[][] rawRotations = new Quaternionf[clip.rotations().length][];
|
||||
public static GltfData.AnimationClip deepCopyClip(
|
||||
GltfData.AnimationClip clip
|
||||
) {
|
||||
Quaternionf[][] rawRotations =
|
||||
new Quaternionf[clip.rotations().length][];
|
||||
for (int j = 0; j < clip.rotations().length; j++) {
|
||||
if (clip.rotations()[j] != null) {
|
||||
rawRotations[j] = new Quaternionf[clip.rotations()[j].length];
|
||||
for (int f = 0; f < clip.rotations()[j].length; f++) {
|
||||
rawRotations[j][f] = new Quaternionf(clip.rotations()[j][f]);
|
||||
rawRotations[j][f] = new Quaternionf(
|
||||
clip.rotations()[j][f]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,15 +243,20 @@ public final class GlbParserUtils {
|
||||
rawTranslations = new Vector3f[clip.translations().length][];
|
||||
for (int j = 0; j < clip.translations().length; j++) {
|
||||
if (clip.translations()[j] != null) {
|
||||
rawTranslations[j] = new Vector3f[clip.translations()[j].length];
|
||||
rawTranslations[j] =
|
||||
new Vector3f[clip.translations()[j].length];
|
||||
for (int f = 0; f < clip.translations()[j].length; f++) {
|
||||
rawTranslations[j][f] = new Vector3f(clip.translations()[j][f]);
|
||||
rawTranslations[j][f] = new Vector3f(
|
||||
clip.translations()[j][f]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new GltfData.AnimationClip(
|
||||
clip.timestamps().clone(), rawRotations, rawTranslations,
|
||||
clip.timestamps().clone(),
|
||||
rawRotations,
|
||||
rawTranslations,
|
||||
clip.frameCount()
|
||||
);
|
||||
}
|
||||
@@ -225,7 +267,10 @@ public final class GlbParserUtils {
|
||||
* Convert an animation clip's rotations and translations to MC space.
|
||||
* Negate qx/qy for rotations and negate tx/ty for translations.
|
||||
*/
|
||||
public static void convertAnimationToMinecraftSpace(GltfData.AnimationClip clip, int jointCount) {
|
||||
public static void convertAnimationToMinecraftSpace(
|
||||
GltfData.AnimationClip clip,
|
||||
int jointCount
|
||||
) {
|
||||
if (clip == null) return;
|
||||
|
||||
Quaternionf[][] rotations = clip.rotations();
|
||||
|
||||
Reference in New Issue
Block a user