SourceTermAnalysisSystem_vue/node_modules/meshoptimizer/meshopt_simplifier.module.js

593 lines
52 KiB
JavaScript
Raw Normal View History

2026-05-15 10:22:44 +08:00
// This file is part of meshoptimizer library and is distributed under the terms of MIT License.
// Copyright (C) 2016-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
var MeshoptSimplifier = (function () {
// Built with clang version 19.1.5-wasi-sdk
// Built from meshoptimizer 0.25
var wasm =
'b9H79Tebbbe:Gez9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999Gluuuueu9GiuuueuiXCdilvorlwiDqkxmPbssbelve9Weiiviebeoweuec:G:Pdkr;7eko9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95br8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bw8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbDQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bqX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbkQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bxX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2Wbma9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbPl79IV9RbsDwebcekdOAq:d;OeCdbk:J1eo3ue99euE99Cue9:8Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:rjjjb8AdnabaeSmbabaeadcdtz:qjjjb8AkdnamcdGTmbalcrfci4gHcbyd1:jjjbHjjjjbbheasc:Cefasyd;8egOcdtfaeBdbasaOcefBd;8eaecbaHz:rjjjbhAcbhlcbhednadTmbcbhlabheadhHinaAaeydbgOci4fgCaCRbbgCceaOcrGgOtV86bbaCcu7aO4ceGalfhlaeclfheaHcufgHmbkcualcdtalcFFFFi0Ehekaecbyd1:jjjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd1:jjjbHjjjjbbhHasc:Cefasyd;8egCcdtfaHBdbasaCcefBd;8eaHcFeaOz:rjjjbhQdnadTmbaecufhLcbhKindndnaQabaXcdtfgYydbgCc:v;t;h;Ev2aLGgOcdtfgAydbgHcuSmbceheinazaHcdtfydbaCSmdaOaefhHaecefheaQaHaLGgOcdtfgAydbgHcu9hmbkkazaKcdtfaCBdbaAaKBdbaKhHaKcefhKkaYaHBdbaXcefgXad9hmbkkaQcbyd:m:jjjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd1:jjjbHjjjjbbhKasc:Cefasyd;8egecdtfaKBdbasaKBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd1:jjjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd1:jjjbHjjjjbbhCasc:Cefasyd;8egHcdtfaCBdbasaHcefBd;8ea3cbyd1:jjjbHjjjjbbhYasc:Cefasyd;8egHcdtfaYBdbasaHcefBd;8eaCaYaialavazasc:Cefz:djjjbalcbyd1:jjjbHjjjjbbh5asc:Cefasyd;8egHcdtfa5BdbasaHcefBd;8ea3cbyd1:jjjbHjjjjbbhHasc:Cefasyd;8egOcdtfaHBdbasaOcefBd;8ea3cbyd1:jjjbHjjjjbbhOasc:Cefasyd;8egAcdtfaOBdbasaAcefBd;8eaHcFeaez:rjjjbh8EaOcFeaez:rjjjbh8FdnalTmbaEcwfhaindnaKa8AgOcefg8AcdtfydbgAaKaOcdtgefydbgHSmbaAaH9RhhaEaHcitfhga8Faefh8Ja8Eaefh8KcbhQindndnagaQcitfydbgLaO9hmba8KaOBdba8JaOBdbxekdnaKaLcdtg8LfgeclfydbgHaeydbgeSmbaEaecitgAfydbaOSmeaHae9Rh8Maecu7aHfhXaaaAfhHcbheinaXaeSmeaecefheaHydbhAaHcwfhHaAaO9hmbkaea8M6meka8Fa8LfgeaOaLaeydbcuSEBdba8KaLaOa8KydbcuSEBdbkaQcefgQah9hmbkka8Aal9hmbkaChHaYhOa8FhAa8EhQcbheindndnaeaHydbgL9hmbdnaeaOydbgL9hmbaQydbhLdnaAydbgXcu9hmbaLcu9hmba5aefcb86bbxikdnaXcuSmbaLcuSmbaeaXSmbaCaXcdtfydbaCaLcdtfydb9hmba5aefcd86bbxika5aefh8KdnaeaXSmbaeaLSmba8Kce86bbxika8Kcl86bbxdkdnaeaYaLcdtgXfydb9hmbdnaAydbg8KcuSmbaea8KSmbaQydbghcuSmbaeahSmba8FaXfydbggcuSmbagaLSmba8EaXfydbgXcuSmbaXaLSmbdnaCa8KcdtfydbgLaCaXcdtfydb9hmbaLaCahcdtfydbgXSmbaXaCagcdtfydb9hmba5aefcd86bbxlka5aefcl86bbxika5aefcl86bbxdka5aefcl86bbxeka5aefa5aLfRbb86bbkaHclfhHaOclfhOaAclfhAaQclfhQalaecefge9hmbkdnamcaGTmbaEcwfh8Jcbh8Nindndna5a8NfgyRbbg8Pc9:fPibebekdndndnaCa8Ncdtfydbgea8N9hmbdnaqmbcbhgxdkdnazTmbcbhga8NheinagaqazaecdtgefydbfRbbcdGce4VhgaYaefydbgea8N9hmbxikkcbhga8NheinagaqaefRbbcdGce4VhgaYaecdtfydbgea8N9hmbxdkka5aefRbbhexeka8NheindnaKaecdtgafgeclfydbgHaeydbgeSmbaHae9Rh8AaEaecitfh8MaCaafh8Lcbh8Kina8Ma8KcitfydbgXhednindnaKaecdtgLfgeclfydbgHaeydbgeSmbdnaCaEaecitgOfydbcdtfydba8LydbgQ9hmbcehexikaHae9Rhhaecu7aHfhAa8JaOfhHcbheinaAaeSmeaecefheaHydbhOaHcwfhHaCaOcdtfydbaQ9hmbkaeah6hexdkaYaLfydbgeaX9hmbkcbhekagaece7Vhga8Kcefg8Ka8A9hmbkkaYaafydbgea8N9hmbka8PciagceGEhekayae86bbka8Ncefg8Nal9hmbkkdnaqTmbdndnazTmbazheaChHalhOindnaqaeydbfRbbceGTmba5aHydbfcl86bbkaeclfheaHclfhHaOcufgOmbxdkkaChealhHindnaqRbbceGTmba5aeydbfcl86bbkaqcefhqaeclfheaHcufgHmbkkaChealhOa5hHindna5aeydbfRbbcl9hmbaHcl86bbkaeclfheaHcefhHaOcufgOmbkkamceGTmba5healhHindnaeRbbce9hmbaecl86bbkaecefheaHcufgHmbkkcbhIcualcx2alc;v:Q;v:Qe0Ecbyd1:jjjbHjjjjbbhaasc:Cefasyd;8egecdtfaaBdbasaecefBd;8easc:qefcbBdbas9cb83i1eaaaialavazasc1efz:ejjjbh8RdndnaDmbcbh8Scbh8Lxekcbh8LawhecbhHindnaeIdbJbbbb9ETmbasa8LcdtfaHBdba8Lcefh8LkaeclfheaDaHcefgH9hmbkcua8Lal2gecdtaecFFFFi0Ecbyd1:jjjbHjjjjbbh8Sasc:Cefasyd;8egecdtfa8SBdbasaecefBd;8ealTmbdna8Lmbcbh8Lxekarcd4hXdnazTmba8Lcdth8KcbhLa8ShKinaoazaLcdtfydbaX2cdtfhQasheaKhHa8LhOinaHaQaeydbcdtgAfIdbawaAfI
var wasmpack = new Uint8Array([
32, 0, 65, 2, 1, 106, 34, 33, 3, 128, 11, 4, 13, 64, 6, 253, 10, 7, 15, 116, 127, 5, 8, 12, 40, 16, 19, 54, 20, 9, 27, 255, 113, 17, 42, 67,
24, 23, 146, 148, 18, 14, 22, 45, 70, 69, 56, 114, 101, 21, 25, 63, 75, 136, 108, 28, 118, 29, 73, 115,
]);
if (typeof WebAssembly !== 'object') {
return {
supported: false,
};
}
var instance;
var ready = WebAssembly.instantiate(unpack(wasm), {}).then(function (result) {
instance = result.instance;
instance.exports.__wasm_call_ctors();
});
function unpack(data) {
var result = new Uint8Array(data.length);
for (var i = 0; i < data.length; ++i) {
var ch = data.charCodeAt(i);
result[i] = ch > 96 ? ch - 97 : ch > 64 ? ch - 39 : ch + 4;
}
var write = 0;
for (var i = 0; i < data.length; ++i) {
result[write++] = result[i] < 60 ? wasmpack[result[i]] : (result[i] - 60) * 64 + result[++i];
}
return result.buffer.slice(0, write);
}
function assert(cond) {
if (!cond) {
throw new Error('Assertion failed');
}
}
function bytes(view) {
return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
}
function reorder(fun, indices, vertices) {
var sbrk = instance.exports.sbrk;
var ip = sbrk(indices.length * 4);
var rp = sbrk(vertices * 4);
var heap = new Uint8Array(instance.exports.memory.buffer);
var indices8 = bytes(indices);
heap.set(indices8, ip);
var unique = fun(rp, ip, indices.length, vertices);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var remap = new Uint32Array(vertices);
new Uint8Array(remap.buffer).set(heap.subarray(rp, rp + vertices * 4));
indices8.set(heap.subarray(ip, ip + indices.length * 4));
sbrk(ip - sbrk(0));
for (var i = 0; i < indices.length; ++i) indices[i] = remap[indices[i]];
return [remap, unique];
}
function maxindex(source) {
var result = 0;
for (var i = 0; i < source.length; ++i) {
var index = source[i];
result = result < index ? index : result;
}
return result;
}
function simplify(fun, indices, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_index_count, target_error, options) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
var ti = sbrk(index_count * 4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var si = sbrk(index_count * 4);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
heap.set(bytes(indices), si);
var result = fun(ti, si, index_count, sp, vertex_count, vertex_positions_stride, target_index_count, target_error, options, te);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var target = new Uint32Array(result);
bytes(target).set(heap.subarray(ti, ti + result * 4));
var error = new Float32Array(1);
bytes(error).set(heap.subarray(te, te + 4));
sbrk(te - sbrk(0));
return [target, error[0]];
}
function simplifyAttr(
fun,
indices,
index_count,
vertex_positions,
vertex_count,
vertex_positions_stride,
vertex_attributes,
vertex_attributes_stride,
attribute_weights,
vertex_lock,
target_index_count,
target_error,
options
) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
var ti = sbrk(index_count * 4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var sa = sbrk(vertex_count * vertex_attributes_stride);
var sw = sbrk(attribute_weights.length * 4);
var si = sbrk(index_count * 4);
var vl = vertex_lock ? sbrk(vertex_count) : 0;
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
heap.set(bytes(vertex_attributes), sa);
heap.set(bytes(attribute_weights), sw);
heap.set(bytes(indices), si);
if (vertex_lock) {
heap.set(bytes(vertex_lock), vl);
}
var result = fun(
ti,
si,
index_count,
sp,
vertex_count,
vertex_positions_stride,
sa,
vertex_attributes_stride,
sw,
attribute_weights.length,
vl,
target_index_count,
target_error,
options,
te
);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var target = new Uint32Array(result);
bytes(target).set(heap.subarray(ti, ti + result * 4));
var error = new Float32Array(1);
bytes(error).set(heap.subarray(te, te + 4));
sbrk(te - sbrk(0));
return [target, error[0]];
}
function simplifyUpdate(
fun,
indices,
index_count,
vertex_positions,
vertex_count,
vertex_positions_stride,
vertex_attributes,
vertex_attributes_stride,
attribute_weights,
vertex_lock,
target_index_count,
target_error,
options
) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var sa = sbrk(vertex_count * vertex_attributes_stride);
var sw = sbrk(attribute_weights.length * 4);
var si = sbrk(index_count * 4);
var vl = vertex_lock ? sbrk(vertex_count) : 0;
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
heap.set(bytes(vertex_attributes), sa);
heap.set(bytes(attribute_weights), sw);
heap.set(bytes(indices), si);
if (vertex_lock) {
heap.set(bytes(vertex_lock), vl);
}
var result = fun(
si,
index_count,
sp,
vertex_count,
vertex_positions_stride,
sa,
vertex_attributes_stride,
sw,
attribute_weights.length,
vl,
target_index_count,
target_error,
options,
te
);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
bytes(indices).set(heap.subarray(si, si + result * 4));
bytes(vertex_positions).set(heap.subarray(sp, sp + vertex_count * vertex_positions_stride));
bytes(vertex_attributes).set(heap.subarray(sa, sa + vertex_count * vertex_attributes_stride));
var error = new Float32Array(1);
bytes(error).set(heap.subarray(te, te + 4));
sbrk(te - sbrk(0));
return [result, error[0]];
}
function simplifyScale(fun, vertex_positions, vertex_count, vertex_positions_stride) {
var sbrk = instance.exports.sbrk;
var sp = sbrk(vertex_count * vertex_positions_stride);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
var result = fun(sp, vertex_count, vertex_positions_stride);
sbrk(sp - sbrk(0));
return result;
}
function simplifyPoints(
fun,
vertex_positions,
vertex_count,
vertex_positions_stride,
vertex_colors,
vertex_colors_stride,
color_weight,
target_vertex_count
) {
var sbrk = instance.exports.sbrk;
var ti = sbrk(target_vertex_count * 4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var sc = sbrk(vertex_count * vertex_colors_stride);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
if (vertex_colors) {
heap.set(bytes(vertex_colors), sc);
}
var result = fun(ti, sp, vertex_count, vertex_positions_stride, sc, vertex_colors_stride, color_weight, target_vertex_count);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var target = new Uint32Array(result);
bytes(target).set(heap.subarray(ti, ti + result * 4));
sbrk(ti - sbrk(0));
return target;
}
function simplifySloppy(
fun,
indices,
index_count,
vertex_positions,
vertex_count,
vertex_positions_stride,
vertex_lock,
target_index_count,
target_error
) {
var sbrk = instance.exports.sbrk;
var te = sbrk(4);
var ti = sbrk(index_count * 4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var si = sbrk(index_count * 4);
var vl = vertex_lock ? sbrk(vertex_count) : 0;
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
heap.set(bytes(indices), si);
if (vertex_lock) {
heap.set(bytes(vertex_lock), vl);
}
var result = fun(ti, si, index_count, sp, vertex_count, vertex_positions_stride, vl, target_index_count, target_error, te);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var target = new Uint32Array(result);
bytes(target).set(heap.subarray(ti, ti + result * 4));
var error = new Float32Array(1);
bytes(error).set(heap.subarray(te, te + 4));
sbrk(te - sbrk(0));
return [target, error[0]];
}
function simplifyPrune(fun, indices, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_error) {
var sbrk = instance.exports.sbrk;
var ti = sbrk(index_count * 4);
var sp = sbrk(vertex_count * vertex_positions_stride);
var si = sbrk(index_count * 4);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(bytes(vertex_positions), sp);
heap.set(bytes(indices), si);
var result = fun(ti, si, index_count, sp, vertex_count, vertex_positions_stride, target_error);
// heap may have grown
heap = new Uint8Array(instance.exports.memory.buffer);
var target = new Uint32Array(result);
bytes(target).set(heap.subarray(ti, ti + result * 4));
sbrk(ti - sbrk(0));
return target;
}
var simplifyOptions = {
LockBorder: 1,
Sparse: 2,
ErrorAbsolute: 4,
Prune: 8,
Regularize: 16,
Permissive: 32,
_InternalDebug: 1 << 30, // internal, don't use!
};
return {
ready: ready,
supported: true,
compactMesh: function (indices) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
return reorder(instance.exports.meshopt_optimizeVertexFetchRemap, indices32, maxindex(indices) + 1);
},
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
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(target_index_count >= 0 && target_index_count <= indices.length);
assert(target_index_count % 3 == 0);
assert(target_error >= 0);
var options = 0;
for (var i = 0; i < (flags ? flags.length : 0); ++i) {
assert(flags[i] in simplifyOptions);
options |= simplifyOptions[flags[i]];
}
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
var result = simplify(
instance.exports.meshopt_simplify,
indices32,
indices.length,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
target_index_count,
target_error,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);
return result;
},
simplifyWithAttributes: function (
indices,
vertex_positions,
vertex_positions_stride,
vertex_attributes,
vertex_attributes_stride,
attribute_weights,
vertex_lock,
target_index_count,
target_error,
flags
) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(vertex_attributes instanceof Float32Array);
assert(vertex_attributes.length == vertex_attributes_stride * (vertex_positions.length / vertex_positions_stride));
assert(vertex_attributes_stride >= 0);
assert(vertex_lock == null || vertex_lock instanceof Uint8Array);
assert(vertex_lock == null || vertex_lock.length == vertex_positions.length / vertex_positions_stride);
assert(target_index_count >= 0 && target_index_count <= indices.length);
assert(target_index_count % 3 == 0);
assert(target_error >= 0);
assert(Array.isArray(attribute_weights));
assert(vertex_attributes_stride >= attribute_weights.length);
assert(attribute_weights.length <= 32);
for (var i = 0; i < attribute_weights.length; ++i) {
assert(attribute_weights[i] >= 0);
}
var options = 0;
for (var i = 0; i < (flags ? flags.length : 0); ++i) {
assert(flags[i] in simplifyOptions);
options |= simplifyOptions[flags[i]];
}
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
var result = simplifyAttr(
instance.exports.meshopt_simplifyWithAttributes,
indices32,
indices.length,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_attributes,
vertex_attributes_stride * 4,
new Float32Array(attribute_weights),
vertex_lock,
target_index_count,
target_error,
options
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);
return result;
},
simplifyWithUpdate: function (
indices,
vertex_positions,
vertex_positions_stride,
vertex_attributes,
vertex_attributes_stride,
attribute_weights,
vertex_lock,
target_index_count,
target_error,
flags
) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(vertex_attributes instanceof Float32Array);
assert(vertex_attributes.length == vertex_attributes_stride * (vertex_positions.length / vertex_positions_stride));
assert(vertex_attributes_stride >= 0);
assert(vertex_lock == null || vertex_lock instanceof Uint8Array);
assert(vertex_lock == null || vertex_lock.length == vertex_positions.length / vertex_positions_stride);
assert(target_index_count >= 0 && target_index_count <= indices.length);
assert(target_index_count % 3 == 0);
assert(target_error >= 0);
assert(Array.isArray(attribute_weights));
assert(vertex_attributes_stride >= attribute_weights.length);
assert(attribute_weights.length <= 32);
for (var i = 0; i < attribute_weights.length; ++i) {
assert(attribute_weights[i] >= 0);
}
var options = 0;
for (var i = 0; i < (flags ? flags.length : 0); ++i) {
assert(flags[i] in simplifyOptions);
options |= simplifyOptions[flags[i]];
}
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
var result = simplifyUpdate(
instance.exports.meshopt_simplifyWithUpdate,
indices32,
indices.length,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_attributes,
vertex_attributes_stride * 4,
new Float32Array(attribute_weights),
vertex_lock,
target_index_count,
target_error,
options
);
if (indices !== indices32) {
// copy back indices if they were converted to Uint32Array
for (var i = 0; i < result[0]; ++i) {
indices[i] = indices32[i];
}
}
return result;
},
getScale: function (vertex_positions, vertex_positions_stride) {
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
return simplifyScale(
instance.exports.meshopt_simplifyScale,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4
);
},
simplifyPoints: function (vertex_positions, vertex_positions_stride, target_vertex_count, vertex_colors, vertex_colors_stride, color_weight) {
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(target_vertex_count >= 0 && target_vertex_count <= vertex_positions.length / vertex_positions_stride);
if (vertex_colors) {
assert(vertex_colors instanceof Float32Array);
assert(vertex_colors.length % vertex_colors_stride == 0);
assert(vertex_colors_stride >= 3);
assert(vertex_positions.length / vertex_positions_stride == vertex_colors.length / vertex_colors_stride);
return simplifyPoints(
instance.exports.meshopt_simplifyPoints,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_colors,
vertex_colors_stride * 4,
color_weight,
target_vertex_count
);
} else {
return simplifyPoints(
instance.exports.meshopt_simplifyPoints,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
undefined,
0,
0,
target_vertex_count
);
}
},
simplifySloppy: function (indices, vertex_positions, vertex_positions_stride, vertex_lock, target_index_count, target_error) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(vertex_lock == null || vertex_lock instanceof Uint8Array);
assert(vertex_lock == null || vertex_lock.length == vertex_positions.length / vertex_positions_stride);
assert(target_index_count >= 0 && target_index_count <= indices.length);
assert(target_index_count % 3 == 0);
assert(target_error >= 0);
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
var result = simplifySloppy(
instance.exports.meshopt_simplifySloppy,
indices32,
indices.length,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
vertex_lock,
target_index_count,
target_error
);
result[0] = indices instanceof Uint32Array ? result[0] : new indices.constructor(result[0]);
return result;
},
simplifyPrune: function (indices, vertex_positions, vertex_positions_stride, target_error) {
assert(
indices instanceof Uint32Array || indices instanceof Int32Array || indices instanceof Uint16Array || indices instanceof Int16Array
);
assert(indices.length % 3 == 0);
assert(vertex_positions instanceof Float32Array);
assert(vertex_positions.length % vertex_positions_stride == 0);
assert(vertex_positions_stride >= 3);
assert(target_error >= 0);
var indices32 = indices.BYTES_PER_ELEMENT == 4 ? indices : new Uint32Array(indices);
var result = simplifyPrune(
instance.exports.meshopt_simplifyPrune,
indices32,
indices.length,
vertex_positions,
vertex_positions.length / vertex_positions_stride,
vertex_positions_stride * 4,
target_error
);
result = indices instanceof Uint32Array ? result : new indices.constructor(result);
return result;
},
};
})();
export { MeshoptSimplifier };