ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

EON JS snippets

Sublime Text snippets for Custom JavaScript Library in Eon Studio

Labels EON, snippets

Details

Installs

  • Total 2K
  • Win 1K
  • Mac 433
  • Linux 251
Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

JavaScript Snippets for Sublime

Demo

Install

To install through Package Control, search for EON JS Snippets. If you still don"t have Package Control in Sublime Text, go get it. It"s pure awesomeness.

If you prefer to install it manually, you can download the package and put it inside your Packages directory. It should work but will not update automatically.

Timing Object

Timing.registerEvent(“ONCE

Timing.registerEvent("ONCE", time, null, function() {

    // do something once at time.
});

Timing.registerEvent(”OVER

Timing.registerEvent("OVER", time, null, function() {

    // do something every frame over time.
});

Timing.registerEvent(“OVER_EVERY

Timing.registerEvent("OVER_EVERY", time, every, null, function() {

    // do something every x seconds over time.
});

Timing.registerEvent(”EVERY

Timing.registerEvent("EVERY", time, null, function() {

    // do something every x seconds.
});

Timing.registerEvent(“FRAME

Timing.registerEvent("FRAME", null, function() {

    // do something every frame.
});

Global Actions

GA.setField

GA.setField("node", "field", value);

GA.getField

GA.getField("node", "field");

GA.getNode

GA.getNode("node");

GA.setProperty

GA.setProperty("property", value, object);

GA.find

GA.find("name", root, depth);

GA.findByProgID

GA.findByProgID("id", root, depth);

GA.addField

GA.addField("field");

Transform

Transform.position

Transform.position("node", [position], time);

Transform.orientation

Transform.orientation("node", [orientation], time);

Transform.scale

Transform.scale("node", [scale], time);

Transform.other

Transform.other("node", "field", value, time);

Transform.rotate

Transform.rotate("node", [axis], laptime, state);

Transform.position with callback

Transform.position("node", [position], time, function() {
    // do something
});

Transform.orientation with callback

Transform.orientation("node", [orientation], time, function() {
    // do something
});

Transform.scale with callback

Transform.scale("node", [scale], time, function() {
    // do something
});

Transform.other with callback

Transform.other("node", "field", value, time, function() {
    // do something
});

.pause

var TRANSFORM_EVENT = Transform.other("node", "field", value, time, function() {
    // do something
});

TRANSFORM_EVENT.pause();

.resume

var TRANSFORM_EVENT = Transform.other("node", "field", value, time, function() {
    // do something
});

TRANSFORM_EVENT.resume();

.cancel

var TRANSFORM_EVENT = Transform.other("node", "field", value, time, function() {
    // do something
});

TRANSFORM_EVENT.cancel();

Node Object

.name

var box = GA.getNode("Box1");

eon.Trace(box.name);
// Box1

.ref

var box = GA.getNode("Box1");

eon.Trace(box.ref);
// returns a reference to the current node.

.path

var box = GA.getNode("Box1");

box.path
// Simulation!Scene!_PUT-YOUR-SCENE-HERE_!Box1

.count

var box = GA.getNode("Box1");

box.count;
// 2

.start

var box = GA.getNode("Box1");

box.start;

.stop

var box = GA.getNode("Box1");

box.stop;

.getField

var box = GA.getNode("Box1");

box.getField("Position").value;

//parameters
.getField(field, debug, source);

.getField("SetRun", "DEBUG", "ClickSensor function");

.setField

var box = GA.getNode("Box1");

box.setField("Position",[5,5,5]);

//parameters
.setField(field, setvalue, debug, source);

.setField("SetRun", true, "DEBUG", "ClickSensor function");

.getFieldById

var box = GA.getNode("Box1");

box.getFieldById(7).value;
// returns the value of the nodes 7th field (position in this case)

.setFieldById

var box = GA.getNode("Box1");

box.setFieldById(7, [9,9,9]);
// sets the value of the nodes 7th field (position in this case) to 9,9,9

.parent

// using eon methods
var box     = eon.FindNode("Box1");
var parent4 = box.GetParentNode().GetParentNode().GetParentNode().GetParentNode();


// using library
var box = GA.getNode("Box1");

box.parent(4);
// returns the nodes 4th parent

box.parent();
// if no argument is given the first parent will be returned.

.parentName

// using eon methods
var box     = eon.FindNode("Box1");
var parent4 = box.GetParentNode().GetParentNode().GetParentNode().GetParentNode();
var name    = eon.GetNodeName(parent4);


// using library
var box = GA.getNode("Box1");

// acessing name after accesing nth parent
box.parent(4).name;

// accessing nth parent and returning name directly
box.parentName(4);

.parentRef

// using eon methods
var box     = eon.FindNode("Box1");
var parent4 = box.GetParentNode().GetParentNode().GetParentNode().GetParentNode();


// using library
var box = GA.getNode("Box1");

// acessing ref after accesing nth parent
box.parent(4).ref;

// accessing nth parent and returning ref directly
box.parentRef(4);

.child

// using eon methods
var box     = eon.FindNode("Box1");
var treeCh  = box.GetFieldByName("TreeChildren");
var child1  = treeCh.GetMFElement(0);


// using library
var box = GA.getNode("Box1");

box.child(1);
// returns the nodes 1st child.

box.child();
// if no argument is given the first child will be returned.

.childName

// using eon methods
var box     = eon.FindNode("Box1");
var treeCh  = box.GetFieldByName("TreeChildren");
var child1  = treeCh.GetMFElement(0);
var name    = eon.GetNodeName(child1);


// using library
var box = GA.getNode("Box1");

// acessing name after accesing nth child
box.child(2).name;

// accessing nth child and returning name directly
box.childName(2);

.childRef

// using eon methods
var box     = eon.FindNode("Box1");
var treeCh  = box.GetFieldByName("TreeChildren");
var child1  = treeCh.GetMFElement(0);


// using library
var box = GA.getNode("Box1");

// acessing ref after accesing nth parent
box.child(4).ref;

// accessing nth parent and returning ref directly
box.childRef(4);

.fieldCount

var box = GA.getNode("Box1");

box.fieldCount;
// returns 23, the number of field the box1 node has.

.find

var box = GA.getNode("Box1");

box.find("shape");

box.find("name", depth);
// Returns a collection of node-objects.

.show

var box = GA.getNode("Box1");

box.show;
// shows the box

.hide

var box = GA.getNode("Box1");

box.hide;
// shows the box

.position

var box = GA.getNode("Box1");
// starts with a position of [15,0,0]

box.position;
// 15,0,0
// returns the value of the current nodes position

box.position.x;
// 15
// returns the value of the current nodes x position

box.position = [43,2,19];
// changes position

box.position;
// 43,2,19

box.position.x = 4;
// changes the value of the x axis only

.orientation

var box = GA.getNode("Box1");
// starts with a orientation of [3,6,9]

box.orientation;
// 3,6,9
// returns the value of the current nodes orientation

box.orientation.y;
// 6
// returns the value of the current nodes y orientation

box.orientation = [7,14,21];
// changes orientation

box.orientation;
// 7,14,21

.scale

var box = GA.getNode("Box1");
// starts with a scale of [1,1,1]

box.scale;
// 1,1,1
// returns the value of the current nodes scale

box.scale.z;
// 1
// returns the value of the current nodes z scale

box.scale = [2,2,2];
// changes scale

box.scale;
// 2,2,2

.hidden

var box = GA.getNode("Box1");

box.hidden;
// returns false

box.hidden = true;
// hides the box frame

.worldPosition

var box = GA.getNode("Box1");
// starts with a worldPosition of [15,0,0]

box.worldPosition;
// 15,0,0
// returns the value of the current nodes worldPosition

box.worldPosition.x;
// 15
// returns the value of the current nodes x worldPosition

box.worldPosition = [43,2,19];
// changes worldPosition

box.worldPosition;
// 43,2,19

.worldOrientation

var box = GA.getNode("Box1");
// starts with a worldOrientation of [3,6,9]

box.worldOrientation;
// 3,6,9
// returns the value of the current nodes worldOrientation

box.worldOrientation.y;
// 6
// returns the value of the current nodes y worldOrientation

box.worldOrientation = [7,14,21];
// changes worldOrientation

box.worldOrientation;
// 7,14,21

.worldScale

var box = GA.getNode("Box1");
// starts with a worldScale of [1,1,1]

box.worldScale;
// 1,1,1
// returns the value of the current nodes worldScale

box.worldScale.z;
// 1
// returns the value of the current nodes z worldScale

box.worldScale = [2,2,2];
// changes worldScale

box.worldScale;
// 2,2,2

.ambientColor

var box = GA.getNode("Box1");

box.ambientColor = [0.8,0.5,0.3];
// as the box1 node is a frame and does not have an ambientColor field,
// nothing will happen, you will get a log stating the node does not have field (n)


box.child().child(1).ambientColor = [Math.random(),Math.random(),Math.random()];
// This has now accessed the first child which is a shape node,
// and then its 2nd child which is a shaderMaterial
// then it ambientColor field and applied a random value.

test.child().child(1).ambientColor;
// this will log out the current value of the field or null if the node does not have an ambientColor field.

/*  Notes : 
a nodes children always start counting from zero so it"s second child would be 1.
If materials/geometry on shape nodes are often referenced, they will not show up under treechildren.
However the above code should still work.
*/

.diffuseColor

var box = GA.getNode("Box1");

box.diffuseColor = [0.8,0.5,0.3];
// as the box1 node is a frame and does not have an diffuseColor field,
// nothing will happen, you will get a log stating the node does not have field (n)


box.child().child(1).diffuseColor = [Math.random(),Math.random(),Math.random()];
// This has now accessed the first child which is a shape node,
// and then its 2nd child which is a shaderMaterial
// then it diffuseColor field and applied a random value.

test.child().child(1).diffuseColor;
// this will log out the current value of the field or null if the node does not have an diffuseColor field.

/*  Notes : 
a nodes children always start counting from zero so it"s second child would be 1.
If materials/geometry on shape nodes are often referenced, they will not show up under treechildren.
However the above code should still work.
*/

.specularColor

var box = GA.getNode("Box1");

box.specularColor = [0.8,0.5,0.3];
// as the box1 node is a frame and does not have an specularColor field,
// nothing will happen, you will get a log stating the node does not have field (n)


box.child().child(1).specularColor = [Math.random(),Math.random(),Math.random()];
// This has now accessed the first child which is a shape node,
// and then its 2nd child which is a shaderMaterial
// then it specularColor field and applied a random value.

test.child().child(1).specularColor;
// this will log out the current value of the field or null if the node does not have an specularColor field.

/*  Notes : 
a nodes children always start counting from zero so it"s second child would be 1.
If materials/geometry on shape nodes are often referenced, they will not show up under treechildren.
However the above code should still work.
*/

.opacity

var box = GA.getNode("Box1");

box.opacity = 0.3;
// as the box1 node is a frame and does not have an opacity field,
// nothing will happen, you will get a log stating the node does not have field (n)


box.child().child(1).opacity = 0.4;
// This has now accessed the first child which is a shape node,
// and then its 2nd child which is a shaderMaterial
// then it opacity field and applied a random value.

test.child().child(1).opacity;
// this will log out the current value of the field or null if the node does not have an opacity field.

/*  Notes : 
a nodes children always start counting from zero so it"s second child would be 1.
If materials/geometry on shape nodes are often referenced, they will not show up under treechildren.
However the above code should still work.
*/

GetTarget Object

GetTarget

var MainClick = GetTarget("node");

function On_Click() {

    // call the .target method and assign it to a variable
      var pTarget = MainClick.target();

      // use .parent to access the nth parent and .name to access the name of the node 
      switch(pTarget.parent(1).name) {

    case "match 1":
      // do something
    break;

    case "match 2":
      // do something
    break;

    case "match 3":
      // do something
    break;

    default:
      // default case
    break;
  }
}

Wandifier Object

Wandifier

var wand = Wandifier("node", countDown, wandFunc, true);

function wandFunc(target) {

    // log out current targets name
    console.log(target);


    switch(target.name) {

        case "match 1":
          // do something
        break;

        case "match 2":
          // do something
        break;

        case "match 3":
          // do something
        break;

        default:
          // default case
        break;

    }
}

Wandifier Extended Parameters

var wand = Wandifier("node", countDown, wandFunc, true, "Reticle", scaleTo, scaleFrom);

function wandFunc(target) {

    // log out current targets name
    console.log(target);


    switch(target.name) {

        case "match 1":
          // do something
        break;

        case "match 2":
          // do something
        break;

        case "match 3":
          // do something
        break;

        default:
          // default case
        break;

    }
}

.countDown

// To view value
wand.countDown;

// To change value
wand.countDown = 1.5;

.intersected

//check if wand is intersecting
wand.intersected

.exclude

// exclude single shape
wand.exclude("Box1_Shape");

// or multiple shapes
wand.exclude(["Box1_Shape","Box2_Shape"]);

.reticleExclude

// exclude single shape
wand.reticleExclude("Box1_Shape");

// or multiple shapes
wand.reticleExclude(["Box1_Shape","Box2_Shape"]);

.removeExclude

// remove single shape
wand.removeExclude("Box1_Shape");

// or multiple
wand.removeExclude(["Box1_Shape","Box2_Shape"]);

// or all
wand.removeExclude("ALL");

.removeReticleExclude

// remove single shape
wand.removeReticleExclude("Box1_Shape");

// or multiple
wand.removeReticleExclude(["Box1_Shape","Box2_Shape"]);

// or all
wand.removeReticleExclude("ALL");

.reset

// removes all exclusions and resets wandifier
wand.reset;

.continuous

// Allows you to continuous click targets.
wand.continuous = true;

.selectAndClick

Turn on the selectAndClick Mode.
wand.selectAndClick(true,Click);

.ease

Select ease type to apply to reticle animation.
wand.ease = "easeoutback";

Update

Update.add

Update.add(function() {

    // something to update every frame
});

Update.clear

Update.clear();

Console

console.log

console.log("message");

console.list

console.list(object);

Alert

alert

alert("message", "title");

AudioController Object

AudioController

var Audio = AudioController("AudioGroup");

AnimationController Object

AnimationController

var Animation = AnimationController("AnimationGroup");

License

[MIT License] The MIT License (MIT) Copyright © 2016 Jaymie Timperley jaymie.timperley@eonreality.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.