Hi oot4chi! I’m an AI-powered assistant here to help you with your questions about Needle Engine, three.js, and basic Unity or Blender inquiries. Please provide your OS, Needle Engine version, and the specific versions of Angular and three.js you’re using so I can assist you further!
2 replies left - GPT 4O thread_oZGIZoiYiaqxYuIqGKaQ0Lgp Reply to this message to continue the conversation
To set up Needle Engine with Angular 18, follow these steps:
Create Angular Project: Use Angular CLI to create a new project.
ng new my-needle-app
cd my-needle-app
Install Needle Engine: Install the Needle Engine from npm.
npm install @needle-tools/engine
Set Up Angular Configuration: In angular.json, configure the build options to include Web Workers support, if necessary.
Import Needle Engine: In your Angular component, import Needle Engine.
import { NeedleEngine } from '@needle-tools/engine';
To address the error related to GenerateMeshBVHWorker.js, ensure that you have the correct loader configuration set for worker files (like using a worker loader in Webpack) or try declaring the workers in your Angular project explicitly.
If you need more detailed help, please provide additional context about your project’s structure or configuration!
1 replies left - GPT 4O thread_oZGIZoiYiaqxYuIqGKaQ0Lgp Reply to this message to continue the conversation
Hi oot4chi! To configure Angular to support Web Workers, you need to adjust the angular.json file. Here’s a step-by-step guide:
Open angular.json: Locate the angular.json file in the root of your Angular project.
Find the Build Options: Look for the “projects” section, and then navigate to your specific project (usually named based on your project name). Under that, go to the “architect” → “build” section.
Add Web Worker Configuration: Under the “options” object, add the "webWorkerTsConfig" property to specify the TypeScript configuration for workers. Here is an example:
Hi, your angular project needs to add the three-mesh-bvh worker to webpack
For nextjs (which is also using webpack) we’re adding a custom loader. You can see the code in the node_modules/@needle-tools/engine/plugins/next/ directory
Hi marwi! To add a custom loader for the three-mesh-bvh worker in your Angular project, you’ll need to set up a similar configuration as described. Here’s how you can do it step-by-step:
Install Webpack: Ensure that you have Webpack installed in your Angular project if you don’t already.
Create Custom Loader: Create a file named meshbvhworker.cjs in your project directory (you can place it in the src folder or another preferred location) and include the code you provided:
/**
* @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' });
};`;
};
Update Webpack Configuration: The Angular CLI uses a default Webpack configuration, so you won’t have direct access to modify the Webpack configuration. You can use a custom Webpack configuration with Angular by using @angular-builders/custom-webpack. Install it: