MCPcopy Create free account
hub / github.com/melonjs/melonJS / parseOBJString

Function parseOBJString

packages/melonjs/tests/mesh.spec.js:307–329  ·  view source on GitHub ↗

* Helper: parse an OBJ string synchronously by feeding it to the parser internals. * We bypass the fetch/preload and call parseOBJ directly via a dynamic import.

(text)

Source from the content-addressed store, hash-verified

305 * We bypass the fetch/preload and call parseOBJ directly via a dynamic import.
306 */
307async function parseOBJString(text) {
308 // The parseOBJ function is not exported, so we test via preloadOBJ indirectly
309 // or we can import the module and access it. For now, test via the cache.
310 // We'll use a data URL approach with the preload function.
311 const name = "test_" + Math.random();
312 const blob = new Blob([text], { type: "text/plain" });
313 const url = URL.createObjectURL(blob);
314
315 return new Promise((resolve, reject) => {
316 preloadOBJ(
317 { name, src: url },
318 () => {
319 URL.revokeObjectURL(url);
320 resolve(objList[name]);
321 },
322 (err) => {
323 URL.revokeObjectURL(url);
324 reject(err);
325 },
326 {},
327 );
328 });
329}
330
331describe("OBJ Parser", () => {
332 it("parses vertices and faces", async () => {

Callers 1

mesh.spec.jsFile · 0.85

Calls 2

preloadOBJFunction · 0.90
randomMethod · 0.80

Tested by

no test coverage detected