Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ES5 validation #741

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ jobs:
run: node js/meshopt_encoder.test.js
- name: test simplifier
run: node js/meshopt_simplifier.test.js
- name: check es5
run: |
npm install -g es-check
npx es-check es5 js/meshopt_decoder.js js/meshopt_encoder.js js/meshopt_simplifier.js
npx es-check --module es5 js/meshopt_decoder.module.js js/meshopt_encoder.module.js js/meshopt_simplifier.module.js
npx es-check es5 gltf/library.js

gltfpack:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"semi": true,
"singleQuote": true,
"printWidth": 150,
"trailingComma": "es5",
}
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}
},
onProgress,
onError,
onError
);

renderer = new THREE.WebGLRenderer();
Expand Down
2 changes: 1 addition & 1 deletion demo/simplify.html
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
}
},
onProgress,
onError,
onError
);
}

Expand Down
2 changes: 1 addition & 1 deletion gltf/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,5 +368,5 @@ if (typeof window === 'undefined' && typeof process !== 'undefined' && process.r
root.gltfpack = factory();
}
})(typeof self !== 'undefined' ? self : this, function () {
return { init, pack };
return { init: init, pack: pack };
});
24 changes: 12 additions & 12 deletions js/meshopt_simplifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var MeshoptSimplifier = (function () {
vertex_lock,
target_index_count,
target_error,
options,
options
) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
Expand Down Expand Up @@ -143,7 +143,7 @@ var MeshoptSimplifier = (function () {
target_index_count,
target_error,
options,
te,
te
);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
Expand Down Expand Up @@ -173,7 +173,7 @@ var MeshoptSimplifier = (function () {
vertex_colors,
vertex_colors_stride,
color_weight,
target_vertex_count,
target_vertex_count
) {
var sbrk = instance.exports.sbrk;
var ti = sbrk(target_vertex_count * 4);
Expand Down Expand Up @@ -210,7 +210,7 @@ var MeshoptSimplifier = (function () {

compactMesh: function (indices) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);

Expand All @@ -220,7 +220,7 @@ var MeshoptSimplifier = (function () {

simplify: function (indices, vertex_positions, vertex_positions_stride, target_index_count, target_error, flags) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
Expand All @@ -246,7 +246,7 @@ var MeshoptSimplifier = (function () {
vertex_positions_stride * 4,
target_index_count,
target_error,
options,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);

Expand All @@ -263,11 +263,11 @@ var MeshoptSimplifier = (function () {
vertex_lock,
target_index_count,
target_error,
flags,
flags
) {
assert(this.useExperimentalFeatures); // set useExperimentalFeatures to use this; note that this function is experimental and may change interface in a way that will require revising calling code
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
Expand Down Expand Up @@ -307,7 +307,7 @@ var MeshoptSimplifier = (function () {
vertex_lock ? new Uint8Array(vertex_lock) : null,
target_index_count,
target_error,
options,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);

Expand All @@ -322,7 +322,7 @@ var MeshoptSimplifier = (function () {
instance.exports.meshopt_simplifyScale,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_positions_stride * 4
);
},

Expand All @@ -345,7 +345,7 @@ var MeshoptSimplifier = (function () {
vertex_colors,
vertex_colors_stride * 4,
color_weight,
target_vertex_count,
target_vertex_count
);
} else {
return simplifyPoints(
Expand All @@ -356,7 +356,7 @@ var MeshoptSimplifier = (function () {
undefined,
0,
0,
target_vertex_count,
target_vertex_count
);
}
},
Expand Down
6 changes: 3 additions & 3 deletions js/meshopt_simplifier.module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const MeshoptSimplifier: {
vertex_positions_stride: number,
target_index_count: number,
target_error: number,
flags?: Flags[],
flags?: Flags[]
) => [Uint32Array, number];

// Experimental; requires useExperimentalFeatures to be set to true
Expand All @@ -30,7 +30,7 @@ export const MeshoptSimplifier: {
vertex_lock: boolean[] | null,
target_index_count: number,
target_error: number,
flags?: Flags[],
flags?: Flags[]
) => [Uint32Array, number];

getScale: (vertex_positions: Float32Array, vertex_positions_stride: number) => number;
Expand All @@ -42,6 +42,6 @@ export const MeshoptSimplifier: {
target_vertex_count: number,
vertex_colors?: Float32Array,
vertex_colors_stride?: number,
color_weight?: number,
color_weight?: number
) => Uint32Array;
};
24 changes: 12 additions & 12 deletions js/meshopt_simplifier.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var MeshoptSimplifier = (function () {
vertex_lock,
target_index_count,
target_error,
options,
options
) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
Expand Down Expand Up @@ -142,7 +142,7 @@ var MeshoptSimplifier = (function () {
target_index_count,
target_error,
options,
te,
te
);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
Expand Down Expand Up @@ -172,7 +172,7 @@ var MeshoptSimplifier = (function () {
vertex_colors,
vertex_colors_stride,
color_weight,
target_vertex_count,
target_vertex_count
) {
var sbrk = instance.exports.sbrk;
var ti = sbrk(target_vertex_count * 4);
Expand Down Expand Up @@ -209,7 +209,7 @@ var MeshoptSimplifier = (function () {

compactMesh: function (indices) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);

Expand All @@ -219,7 +219,7 @@ var MeshoptSimplifier = (function () {

simplify: function (indices, vertex_positions, vertex_positions_stride, target_index_count, target_error, flags) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
Expand All @@ -245,7 +245,7 @@ var MeshoptSimplifier = (function () {
vertex_positions_stride * 4,
target_index_count,
target_error,
options,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);

Expand All @@ -262,11 +262,11 @@ var MeshoptSimplifier = (function () {
vertex_lock,
target_index_count,
target_error,
flags,
flags
) {
assert(this.useExperimentalFeatures); // set useExperimentalFeatures to use this; note that this function is experimental and may change interface in a way that will require revising calling code
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array,
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
Expand Down Expand Up @@ -306,7 +306,7 @@ var MeshoptSimplifier = (function () {
vertex_lock ? new Uint8Array(vertex_lock) : null,
target_index_count,
target_error,
options,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);

Expand All @@ -321,7 +321,7 @@ var MeshoptSimplifier = (function () {
instance.exports.meshopt_simplifyScale,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_positions_stride * 4
);
},

Expand All @@ -344,7 +344,7 @@ var MeshoptSimplifier = (function () {
vertex_colors,
vertex_colors_stride * 4,
color_weight,
target_vertex_count,
target_vertex_count
);
} else {
return simplifyPoints(
Expand All @@ -355,7 +355,7 @@ var MeshoptSimplifier = (function () {
undefined,
0,
0,
target_vertex_count,
target_vertex_count
);
}
},
Expand Down