particle.subSelf()未定义不是函数

时间:2014-06-27 21:52:31

标签: javascript three.js particles

我试图用三角形给粒子提供速度和原点,但我不能添加原点

 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);
}

particle.addSelf(原点);这条线给了我一个未定义的功能,它与旧版本的三个版本一起工作正常,但我想从r52升级到r67,我发现很多问题,如果你有任何想法,我们将不胜感激。

1 个答案:

答案 0 :(得分:1)