LoginSignup
0
0

More than 3 years have passed since last update.

Magic Leap MagicScript Landscape Application. ParticleNode (Use PopcornFX)

Posted at

Prepare
Magic Leap One
https://www.magicleap.com/magic-leap-one

mlsdk v.0.20.0
https://creator.magicleap.com/downloads/lumin-sdk/overview

magic-script-cli v2.0.1
https://www.npmjs.com/package/magic-script-cli

PopcornFX 1.12.x editor (Latest)
https://wiki.popcornfx.com/index.php/PK-Editor_v1.12

Create Particle Package

No.1
TutorialParticles Download & Create New.
Project Name (Folder Name) : Project01.
Capture_000099.JPG
No.2
Import.
Capture_000098.JPG
No.3
Open Project01
Capture_000100.JPG
No.4
Menu: Edit -> Project Settings.
Capture_000103.JPG
No.5
Assets->Baking
Enter the Baking Root folder name.
Click New button.
Capture_000101.JPG
OKCapture_000102.JPG
No.6
After selecting Smoke 02, Bake.
Capture_000104.JPG
Bake Settings
Capture_000106.JPG
No.7
Bake complete. Load the project created in the BAKE folder from the application and use it.
Capture_000105.JPG

Create Project

magic-script init my-particle org.magicscript.particle "Particle"
cd my-particle
mkdir res

Place the Project 01 created in the BAKE folder in the res folder.

Code

Change app.package

DATAS = "digest.sha512.signed" : "." \
        "bin/" : "bin/" \
        "res/" : "res/"
OPTIONS = package/minApiLevel/2

Change app.js

import { 
    LandscapeApp
  , ui} from 'lumin';
const { UiButton } = ui;

export class App extends LandscapeApp {
  onAppStart () {
    let isPlay = false;
    const prism = this.requestNewPrism([1.0, 3.0, 1.0]);
    const res = prism.createParticlePackageResourceId(
      "res/Project01");

    const p = prism.createParticleNode(res);
    p.setEffectName("Particles/Smoke02.pkfx");
    p.setLocalPosition([0, -0.5, -0.4]);

    const button = UiButton.Create(prism, 'Play', 0, 0.1);
    button.onActivateSub(function (uiEventData) {
        if (isPlay)
        {
            p.stop();
            button.setText("Play");
        }
        else
        {
            p.play();
            button.setText("Stop");
        }
        isPlay = !isPlay;
    });
    prism.getRootNode().addChild(button);
    prism.getRootNode().addChild(p);
  }
}

Build

magic-script build -i

Run

magic-script run --port=10000

Reference
ParticleNode(Magic Script API Doc)
https://docs.magicscript.org/lumin.ParticleNode.html

magicscript
https://www.magicscript.org/

Thanks!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0