0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Magic Leap MagicScript Landscape Application. LightNode

0
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

magic-script-polyfills v2.2.0
https://www.npmjs.com/package/magic-script-polyfills

3d model file
https://poly.google.com/view/esWz3QtmDCX

Create Project

magic-script init my-light org.magicscript.light "Light"
cd my-light
mkdir res

place 3d model file in res folder.

Code

Change app.package

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

Change app.js

import { LandscapeApp, ui, utils } from 'lumin';
const { UiLinearLayout, UiToggle, Alignment } = ui;
const { LightType } = utils;

export class App extends LandscapeApp {
  onAppStart () {
    const prism = this.requestNewPrism([0.5, 0.5, 0.5]);
    const topLayout = UiLinearLayout.Create(prism);
    const light = prism.createLightNode();
    light.setType(LightType.Point);
    light.setLocalPosition([0, 0.2, 0]);
    light.setColor([0.0, 1.0, 0.0]);
    light.setVisible(false);
    prism.getRootNode().addChild(light);
    
    const resource = 
            prism.createModelResourceId("res/ar-poop-vroom.glb", 0.2);
    const model = prism.createModelNode(resource);
    const toggle = UiToggle.Create(prism, 'ON');
    toggle.onActivateSub((event) => {
      if (toggle.getOn()) {
        light.setVisible(true);
        toggle.setText('OFF');
      } else {
        light.setVisible(false);
        toggle.setText('ON');
      }
    });
    topLayout.addItem(model, [0, 0, 0.02, 0]
      , Alignment.BOTTOM_CENTER);
    topLayout.addItem(toggle, [0, 0, 0.02, 0]
      , Alignment.BOTTOM_CENTER);
    prism.getRootNode().addChild(topLayout);
  }
}

Build

magic-script build -i

Run

magic-script run --port=10000

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

Light Nodes (LightNode)(Guide C++)
https://creator.magicleap.com/learn/guides/lrt-lightnode

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?