Skip to content

Commit

Permalink
Merge branch 'release/4.0.3'.
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbroz committed Jun 28, 2023
2 parents bc6713f + 4861d03 commit a6eb2e5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.3] - 2023-06-28

- Fixed
- Solved an issue with glTF geometry being broken in certain scenarios (kudos to [henrikbuchholz](https://github.com/henrikbuchholz)!)

## [4.0.2] - 2023-03-10

- Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forge-convert-utils",
"version": "4.0.2",
"version": "4.0.3",
"description": "Tools for converting Autodesk Forge file formats.",
"main": "lib/index.js",
"bin": {
Expand Down
22 changes: 11 additions & 11 deletions src/gltf/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class Writer {
default: // "meter" / "m"
scale = 1.0;
}

rootNode.matrix = [
left[0] * scale, up[0] * scale, front[0] * scale, 0,
left[1] * scale, up[1] * scale, front[1] * scale, 0,
Expand Down Expand Up @@ -385,15 +385,15 @@ export class Writer {

// Output index buffer
const indices = geometry.getIndices();
const indexBufferView = this.createBufferView(Buffer.from(indices.buffer));
const indexBufferView = this.createBufferView(Buffer.from(indices.buffer, indices.byteOffset, indices.byteLength));
const indexBufferViewID = this.addBufferView(indexBufferView);
const indexAccessor = this.createAccessor(indexBufferViewID, 5123, indexBufferView.byteLength / 2, 'SCALAR');
const indexAccessorID = this.addAccessor(indexAccessor);

// Output vertex buffer
const vertices = geometry.getVertices();
const positionBounds = this.computeBoundsVec3(vertices); // Compute bounds manually, just in case
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer));
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer, vertices.byteOffset, vertices.byteLength));
const positionBufferViewID = this.addBufferView(positionBufferView);
const positionAccessor = this.createAccessor(positionBufferViewID, 5126, positionBufferView.byteLength / 4 / 3, 'VEC3', positionBounds.min, positionBounds.max/*[fragmesh.min.x, fragmesh.min.y, fragmesh.min.z], [fragmesh.max.x, fragmesh.max.y, fragmesh.max.z]*/);
const positionAccessorID = this.addAccessor(positionAccessor);
Expand All @@ -402,7 +402,7 @@ export class Writer {
let normalAccessorID: number | undefined = undefined;
const normals = geometry.getNormals();
if (normals) {
const normalBufferView = this.createBufferView(Buffer.from(normals.buffer));
const normalBufferView = this.createBufferView(Buffer.from(normals.buffer, normals.byteOffset, normals.byteLength));
const normalBufferViewID = this.addBufferView(normalBufferView);
const normalAccessor = this.createAccessor(normalBufferViewID, 5126, normalBufferView.byteLength / 4 / 3, 'VEC3');
normalAccessorID = this.addAccessor(normalAccessor);
Expand All @@ -412,7 +412,7 @@ export class Writer {
let colorAccessorID: number | undefined = undefined;
const colors = geometry.getColors();
if (colors) {
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer));
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer, colors.byteOffset, colors.byteLength));
const colorBufferViewID = this.addBufferView(colorBufferView);
const colorAccessor = this.createAccessor(colorBufferViewID, 5126, colorBufferView.byteLength / 4 / 4, 'VEC4');
colorAccessorID = this.addAccessor(colorAccessor);
Expand All @@ -422,7 +422,7 @@ export class Writer {
let uvAccessorID: number | undefined = undefined;
if (geometry.getUvChannelCount() > 0 && outputUvs) {
const uvs = geometry.getUvs(0);
const uvBufferView = this.createBufferView(Buffer.from(uvs.buffer));
const uvBufferView = this.createBufferView(Buffer.from(uvs.buffer, uvs.byteOffset, uvs.byteLength));
const uvBufferViewID = this.addBufferView(uvBufferView);
const uvAccessor = this.createAccessor(uvBufferViewID, 5126, uvBufferView.byteLength / 4 / 2, 'VEC2');
uvAccessorID = this.addAccessor(uvAccessor);
Expand Down Expand Up @@ -460,15 +460,15 @@ export class Writer {

// Output index buffer
const indices = geometry.getIndices();
const indexBufferView = this.createBufferView(Buffer.from(indices.buffer));
const indexBufferView = this.createBufferView(Buffer.from(indices.buffer, indices.byteOffset, indices.byteLength));
const indexBufferViewID = this.addBufferView(indexBufferView);
const indexAccessor = this.createAccessor(indexBufferViewID, 5123, indexBufferView.byteLength / 2, 'SCALAR');
const indexAccessorID = this.addAccessor(indexAccessor);

// Output vertex buffer
const vertices = geometry.getVertices();
const positionBounds = this.computeBoundsVec3(vertices);
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer));
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer, vertices.byteOffset, vertices.byteLength));
const positionBufferViewID = this.addBufferView(positionBufferView);
const positionAccessor = this.createAccessor(positionBufferViewID, 5126, positionBufferView.byteLength / 4 / 3, 'VEC3', positionBounds.min, positionBounds.max);
const positionAccessorID = this.addAccessor(positionAccessor);
Expand All @@ -477,7 +477,7 @@ export class Writer {
let colorAccessorID: number | undefined = undefined;
const colors = geometry.getColors();
if (colors) {
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer));
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer, colors.byteOffset, colors.byteLength));
const colorBufferViewID = this.addBufferView(colorBufferView);
const colorAccessor = this.createAccessor(colorBufferViewID, 5126, colorBufferView.byteLength / 4 / 3, 'VEC3');
colorAccessorID = this.addAccessor(colorAccessor);
Expand Down Expand Up @@ -510,7 +510,7 @@ export class Writer {
// Output vertex buffer
const vertices = geometry.getVertices();
const positionBounds = this.computeBoundsVec3(vertices);
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer));
const positionBufferView = this.createBufferView(Buffer.from(vertices.buffer, vertices.byteOffset, vertices.byteLength));
const positionBufferViewID = this.addBufferView(positionBufferView);
const positionAccessor = this.createAccessor(positionBufferViewID, 5126, positionBufferView.byteLength / 4 / 3, 'VEC3', positionBounds.min, positionBounds.max);
const positionAccessorID = this.addAccessor(positionAccessor);
Expand All @@ -519,7 +519,7 @@ export class Writer {
let colorAccessorID: number | undefined = undefined;
const colors = geometry.getColors();
if (colors) {
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer));
const colorBufferView = this.createBufferView(Buffer.from(colors.buffer, colors.byteOffset, colors.byteLength));
const colorBufferViewID = this.addBufferView(colorBufferView);
const colorAccessor = this.createAccessor(colorBufferViewID, 5126, colorBufferView.byteLength / 4 / 3, 'VEC3');
colorAccessorID = this.addAccessor(colorAccessor);
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ mime-types@^2.1.12:
mime-db "1.51.0"

minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"

Expand Down

0 comments on commit a6eb2e5

Please sign in to comment.