Error message: The function particle.subSelf() is not defined

I'm attempting to assign velocity and an origin to a particle using threes, but I'm having trouble adding the origin.

 function getOrigin() {
    return new THREE.Vector3(Weapon.vehicle.position.x, Weapon.vehicle.position.y, Weapon.vehicle.position.z);
}
function start() {
    time = Weapon.time;
    done = false;

    var origin = getOrigin();
    particles = new THREE.Geometry();
    var pMaterial = new THREE.ParticleBasicMaterial({
        color: Weapon.explosion.color,
        size: Weapon.explosion.size,
        map: THREE.ImageUtils.loadTexture("img/particula.png"),
        blending: THREE.AdditiveBlending,
        transparent: true
    });
    for(var p = 0; p < particleCount; p++) {
        // create a particle with random
        // position values, -250 -> 250
        var pX = (Math.random() * Weapon.vehicle.size.x) - (Weapon.vehicle.size.x / 2),
            pY = (Math.random() * Weapon.vehicle.size.y) - (Weapon.vehicle.size.y / 2),
            pZ = (Math.random() * Weapon.vehicle.size.z) - (Weapon.vehicle.size.z / 2),
            particle = new THREE.Vector3(pX, pY, pZ);

        // create a velocity vector
        particle.velocity = particle.clone();
        particle.addSelf(origin);

        // add it to the geometry
        particles.vertices.push(particle);
    }

    // create the particle system
    particleSystem = new THREE.ParticleSystem(particles, pMaterial);
    particleSystem.sortParticles = true;
    scene.add(particleSystem);
}

The line `particle.addSelf(origin);` is causing an issue as it's showing an undefined function. This was working fine with an older version of threes, but after upgrading from r52 to r67, I'm encountering multiple problems. If you have any insights or suggestions, your help would be greatly appreciated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am looking to switch themes on the homepage using a button from an imported component

I have successfully created a toggle button on my main page in app.js to switch between dark and light themes. However, I am facing difficulty in putting the button inside my nav component and using it from that page imported in app.js. Can anyone guide me ...

The issue of Node.js getting stuck arises when handling multiple recursive setTimeout calls

I am currently working on coding a class that has the ability to pause audio file playback. This class is designed to take raw PCM data, and you can specify how frequently sample chunks should be sent through by providing the class with this information. F ...

Error: JSON array contains unterminated string literal

Hey there, var favorites = 'Array ( [0] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "] [1] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "] [2] => [" 6 "," 1 "," 2 "," 5 "," 3 "," 4 "] ) '; I've been encountering a syntax error - an untermi ...

Problems with displaying Wordpress content on your web browser

I am having trouble getting my website content to display properly in a web browser, even though I built it using Wordpress. It appears that only the logo and the 'Services' bar are showing up on the page, while the rest seems to be missing. I s ...

React in response after waiting for the DOM element - Reactjs

Hey there! I'm working with a class component that looks like this: class SomeComponent extends Component { componentDidMount = () => { const divElement = document.getElementbyId('id'); // it may take a few moments for this ele ...

Can someone provide guidance on creating a Primeng Generic Group Array?

Here is my original object: users = [ {id: 1, name: "name1", company: "com1"}, {id: 2, name: "name2", company: "com2"}, {id: 3, name: "name3", company: "com1"}, {id: 4, name: "name4", company: "com2"}, {id: 5, name: "name5", company: "com3"}, ] ...

Steps to update the value of an object stored within an array

I have a collection of items stored in an array. Each item is represented by an object with properties. I want to update the value of a specific property within each object: var array=[{a:1, b:false}, {a:2, b:true}, {a:3, b:false}] My goal is to set the p ...

The promise is returning an undefined value when attempting to access the array within

I'm currently delving into NodeJS to create some automation scripts, but I've hit a roadblock that's stumping me. By utilizing the Google Spreadsheet API and the "promisify-node" package, I'm trying to fetch data from a spreadsheet and ...

Why is the last move of the previous player not displayed in this game of tic tac toe?

Why does the last move of the previous player not show up in this tic-tac-toe game? When it's the final turn, the square remains empty with neither an "O" nor an "X". What could be causing this issue? Here is the code snippet: The HTML code: <div ...

Need two clicks for React setState() to update the user interface

As someone who is new to React, I've come across a common issue that many developers face. Despite trying various solutions, I still find myself having to click twice to update the UI state. The first click triggers the event handler but does not upda ...

Using a custom function with Node.js middleware

Query regarding express middleware. Assume I have a route structured as shown below: router.route('/replies/:board') .post(bodyThreadIdVal, textVal, passVal, replyHandler.postReply) Now suppose I want to separate the first three middleware ...

Ways to substitute real Image with a placeholder image if the image is missing

Is there a way to replace an unavailable image with a dummy image in this code snippet? <div className="bg-[#F8F8F8] flex items-center justify-center px-2 py-10"> <Image src={image} alt="course image" width={100} height={10 ...

Can one utilize Javascript to write in plain text format?

Currently, using JavaScript I have a plain text containing data that is displayed within my form tags. Everything is functioning correctly, but now I need to update the values inside the code of my form tags in order for the changes to also be reflected in ...

What is the best way to update the value of the nearest input field?

I am working with a table that has multiple rows, all structured in the same way. I have created a DIV element that can be clicked. When a user clicks on the DIV, I want the value of the input field in the same row to change. However, with the current co ...

Continuously inserting new records to a JSON file using a while loop

Is there a way to continuously add key value pairs to a JSON object within a while loop? var sName = "string_"; var aKeys = ["1", "2", "3"]; var sKey = "key"; var n = 1; var aObj = {}; var l = aKeys.length; for(let i=0; i < l; i++){ while(n < 5) ...

How can I send dynamic props between pages using Next.js?

I am currently exploring Next.js and attempting to create a page (index.js) that fetches data about different countries and then displays this information. I would like each country element displayed on the page to have a button that leads to another page ...

Conceal items by clicking using raycasting technology

I'm trying to hide scene objects by clicking on them, but after following multiple tutorials on "raycaster", I'm having trouble identifying where the issue lies. When I open my HTML file, all the objects are hidden, even though I've removed ...

A guide on accessing the value of ng-model in an AngularJS controller

I am facing an issue with a simple view that contains an input text field where the user enters their name. The controller should retrieve this value and assign it to the employeeDescription variable. However, the ng-model value from the input field is not ...

Dynamic, AJAX-driven content is experiencing a 200 status code

Is it necessary for a single-page website, which dynamically loads content via ajax and utilizes browser session history stacking, to return a "200 Status" for each successful state change? The core code of my website is as follows: $(document).on('c ...

Error encountered in Angular $injector:unpr while attempting to initialize uibModal

I followed the ui-bootstrap tutorial to create my code. On my homepage, there is a button that triggers a modal window to open using ng-click. However, when I check the dev tools, I encounter the following error: Error: [$injector:unpr] Unknown provider: ...