The forum on this site is closed for new comments and posts. Continue the conversation in the new forum, and learn more here.

Particle question

  • Just bumping this. 

    Am I missing something? In most particles systems, you are able to emit from a moving point. This system does not seem to have this ability.


    Comment actions Permalink
  • Hi Karl,

    Our particle system is shader based, which makes it efficient for simulating many particles, but focused in a local space.

    However, you can simulate a world particle system by spawning multiple local particle systems in world space.

    Let's start by creating a script. In the Objects panel, press Add New > Empty Object. Then select that object and in its Inspector panel, press Add Component > Script. This object and this script will be our World Particle Controller.

    Select this script in the Resources panel to edit it. First let’s set up some input to help us. We need to know how long a particle system should last, how many particle system should exist in total, and how often we should create one. Then we need to have a reference to the particle system we’re going to copy. Make sure to connect your particle to this input.

    //@input float animationLength = 5
    //@input int maxParticleSystems = 50
    //@input float spawnInterval = 0.01
    //@input SceneObject particle

    Each copy of the particle system needs to have their own material so they can each have a different state. To do so, we will store a copy of the particle materials.

    // Store copy of original particle system
    var copyableMeshVisual = script.particle.getFirstComponent("Component.MeshVisual");
    var copyableMaterial = copyableMeshVisual.mainMaterial.clone();

    Then we’ll create some store to references all particle systems.

    // Initialize variables to store the particle systems in
    var instances = []; // Each particle system
    var startTimes = []; // When that particle system started
    var matPasses = []; // The particle system's material

    Finally, we’ll need to know the overall state of our world particle system.

    // Keep track of our particle systems
    var lastSpawnTime = 0; // When we last started a particle system
    var nextSpawnIdx = 0; // Index of the particle system we should modify next

    Next we will create all our different particle systems by dynamically creating an object and adding a copy of our particle’s mesh visual and materials.

    // Generate all our particle systems
    for (var i = 0; i < script.maxParticleSystems; i++) {
    var newObject = global.scene.createSceneObject("Particle_Trails");
    newObject.enabled = false;

    var mv = newObject.copyComponent(copyableMeshVisual);

    var material = mv.getMaterial(0).getPass(0);
    material.externalSeed = Math.random();


    Next let’s set up a loop to manage the created particle system over time.

    function onUpdate(eventData) {
    var event = script.createEvent("UpdateEvent");

    Finally, we’ll update our particle systems! For all particle systems, we need to update the time to progress the system forward. Additionally, every time our current time minus the last spawn time, is greater than our spawn interval, we position a particle system where we are and restart it.

    function updateWorldParticles(){
    var currentTime = getTime();
    var t = currentTime - lastSpawnTime;

    // Update all particle system's time
    for (var i = 0; i < script.maxParticleSystems; ++i) {
    var timeOffset = startTimes[i];
    var obj = instances[i];
    var pass = matPasses[i];
    var shaderTime = currentTime - timeOffset;

    if (shaderTime > script.animationLength)
    obj.enabled = false;
    pass.externalTime = new vec4(0.0,shaderTime,1.0,1.0);

    // Restart particle system's position at current pos as needed
    if (t > script.spawnInterval) {
    var currentPos = script.particle.getTransform().getWorldPosition();
    var index = nextSpawnIdx % script.maxParticleSystems;
    var instance = instances[index];

    lastSpawnTime = currentTime;
    startTimes[index] = currentTime;

    instance.enabled = true;
    instance.getTransform().setWorldPosition(new vec3(currentPos.x,currentPos.y,currentPos.z));


    Now, when you move around the particle system, you should see a trail of particles behind!

    Here’s a sample project to help you get started.

    Don’t forget to share your final result!


    Comment actions Permalink
  • Thanks, this really helps. I guess this was actually a scripting question!


    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?



Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:



What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!