UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

19 lines (17 loc) 755 B
// Transform the mesh bvh worker to include a default export function that returns a worker instance. // This is needed to make the worker work with webpack 5. // See https://forum.needle.tools/t/import-error-in-generatemeshbvhworker-needle-and-nextjs-integration /** * @param {string} source */ module.exports = function (source, _map) { if (source.includes("Modified by Needle")) return source; console.log("Transform mesh-bvh-worker") return `// Modified by Needle const workerCode = ${JSON.stringify(source)}; const blob = new Blob([workerCode], { type: 'application/javascript' }); const workerUrl = URL.createObjectURL(blob); export default function() { return new Worker(workerUrl, { type: 'module' }); };`; };