Browse our Products

Aspose.3D for Java 22.4 Release Notes

Improvements and Changes

KeySummaryCategory
THREEDNET-1116Node’s EulerAngle confusion leads to wrong position after model rotationBug fix
THREEDNET-1137LayeredTexture imported from FBX may generate invalid GLTF fileBug fix
THREEDNET-1119Support for GLTF Custom Vertex AttributesNew Feature
THREEDNET-1129GLB to U3D Conversion resulted in wrong orientationNew Feature
THREEDNET-1121Point cloud export support in USD/USDZNew Feature
THREEDNET-1122Point cloud import support in USD/USDZNew Feature
THREEDNET-1113Loaded OBJ model lost texture coordinates vtBug fix
THREEDNET-1107The license cannot be loaded when the application is built as a single executable.Bug fix

API changes

All API changes in this version are needed to export user data in glTF through TriMesh, the user data in Mesh and VertexElementUserData will be supported in the next version.

Added method AddField in class com.aspose.threed.VertexDeclaration:

    /**
     * Add a new vertex field
     * @param dataType The data type of the vertex field
     * @param semantic How will this field used for
     * @param index The index for same field semantic, -1 for auto-generation
     * @param alias The alias name of the field
     */
    public VertexField addField(int dataType, VertexFieldSemantic semantic, int index, String alias);

The new AddField added a new paramter alias to specify the alias name of the field, it works exactly the same as the new added constructor of SemanticAttribute.

Added members to class com.aspose.threed.VertexField:

    /**
     * Field's alias 
     */
    public String getAlias();

Code snippet to export custom data to glTF

private static void writeVertex(DataOutputStream writer,
                                float px, float py, float pz,
                                float nx, float ny, float nz,
                                float u, float v,
                                float batchId)
        throws IOException
{
        writer.writeFloat(px);
        writer.writeFloat(py);
        writer.writeFloat(pz);

        writer.writeFloat(nx);
        writer.writeFloat(ny);
        writer.writeFloat(nz);

        writer.writeFloat(u);
        writer.writeFloat(v);

        writer.writeFloat(batchId);
}

private static void exportCustomFieldToGLTF()
        throws Exception
{
        byte[] verticesInBytes;
        try(var os = new ByteArrayOutputStream())
        {
            try(var writer = new DataOutputStream(os)) {
                writeVertex(writer, 1, 0, 0, 0, 1, 0, 0, 0, 1);
                writeVertex(writer, 1, 1, 0, 0, 1, 0, 0, 1, 2);
                writeVertex(writer, 0, 1, 0, 0, 1, 0, 1, 0, 3);
                writeVertex(writer, 0, 1, 1, 0, 1, 0, 1, 1, 4);
            }
            verticesInBytes = os.toByteArray();
        }
        var indices = new int[]
        {
                0, 1, 2,
                1, 2, 3
        };
        //create a vertex declaration
        VertexDeclaration vd = new VertexDeclaration();
        vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
        vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
        vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
        vd.addField(VertexFieldDataType.FLOAT, VertexFieldSemantic.USER_DATA, -1, "_BATCH_ID");
        //construct a TriMesh from raw bytes of vertices and indices
        var mesh = TriMesh.fromRawData(vd, verticesInBytes, indices, false);
        //create a scene with the mesh
        var scene = new Scene(mesh);
        //export the scene to a binary glTF file
        scene.save("test.glb", FileFormat.GLTF2_BINARY);
        // The GLTF primitive generated in the test.glb will be:
        // {"attributes" : {"POSITION" : 1, "NORMAL" : 3, "TEXCOORD_0" : 2, "_BATCH_ID" : 4}, "mode" : 4}
}


 
 English