Three.js-如何使用Three.js冒烟?

Ram*_*elm 1 javascript particles three.js smoke

我想创造出在天空中吹起的褐色烟雾。

我该如何创建呢?

Fal*_*ele 6

ShaderParticleEngine收到改写为three.js-r72重型 API的变化,所以我更新这个答案。看到这个答案历史的比较和/或设置ShaderParticleEngine 0.8/ three.js-r71


现在,它允许用户微调甚至更多的参数,因此您可以创建这种美丽的扭曲烟雾:

坠机现场冒出浓烟

屏幕截图中发射器的示例设置:

var loader = new THREE.TextureLoader();
var url = 'assets/images/particles/cloudSml.png';
var texture = loader.load( url );

var particleGroupCrash = new SPE.Group({
    texture: {
        value: texture
    },
    blending: THREE.NormalBlending
});

var crashemitter = new SPE.Emitter({

    maxAge: { value: 12 },
    position: { 
        value: new THREE.Vector3( 0, 0, 0 ),
        spread: new THREE.Vector3( 1, 0.5, 2 ),
    },
    size: {
        value: [ 2, 8 ],
        spread: [ 0, 1, 2 ]
    },
    acceleration: {
        value: new THREE.Vector3( 0, 0, 0 ),
    },
    rotation: {
        axis: new THREE.Vector3( 0, 1, 0 ),
        spread: new THREE.Vector3( 0, 20, 0 ),
        angle: 100 * Math.PI / 180,
    },
    velocity: {
        value: new THREE.Vector3( 0, 1, -0.5 ),
        spread: new THREE.Vector3( 0.25, 0.1, 0.25 )
    },
    opacity: {
        value: [ 0.2, 0.5, 0 ]
    },
    color: {
        value: [ new THREE.Color( 0x333333 ), new THREE.Color( 0x111111 ) ],
        spread: [ new THREE.Vector3( 0.2, 0.1, 0.1 ), new THREE.Vector3( 0, 0, 0 ) ]
    },
    particleCount: 600,
});
Run Code Online (Sandbox Code Playgroud)

Three.js R73

  • 图片的一点:) r72也有一个粒子引擎http://threejs.org/examples/#webgl_gpu_particle_system (2认同)