ctrl+shift+p filters: :st2 :st3 :win :osx :linux
浏览

EON JS代码片段

jaymie-timperley 全部

Sublime Text的定制JavaScript库在Eon Studio中的代码片段

标签 EON, 代码片段

详细信息

安装

  • 总计 2K
  • Win 1K
  • Mac 432
  • Linux 251
8月6日 8月5日 8月4日 8月3日 8月2日 8月1日 7月31日 7月30日 7月29日 7月28日 7月27日 7月26日 7月25日 7月24日 7月23日 7月22日 7月21日 7月20日 7月19日 7月18日 7月17日 7月16日 7月15日 7月14日 7月13日 7月12日 7月11日 7月10日 7月9日 7月8日 7月7日 7月6日 7月5日 7月4日 7月3日 7月2日 7月1日 6月30日 6月29日 6月28日 6月27日 6月26日 6月25日 6月24日 6月23日
Windows 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 1 0 0 0
Mac 1 1 0 0 0 0 0 0 0 0 0 0 1 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

源代码
raw.​githubusercontent.​com

Sublime的JavaScript代码片段

Demo

安装

要通过Package Control安装,搜索EON JS Snippets。如果您在Sublime Text中还没有Package Control,请下载它。它非常酷。

如果您喜欢手动安装,可以下载软件包并将其放入您的Packages目录。它应该可以工作,但不能自动更新。

计时对象

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.
});

全局操作

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.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();

节点对象

.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

.环境颜色

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.
*/

.漫射颜色

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.
*/

.高光颜色

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.
*/

.透明度

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.
*/

获取目标对象

获取目标

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对象

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扩展参数

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;

    }
}

.倒计时

// To view value
wand.countDown;

// To change value
wand.countDown = 1.5;

.相交的

//check if wand is intersecting
wand.intersected

.排除

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

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

.标尺排除

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

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

.移除排除

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

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

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

.移除标尺排除

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

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

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

.重置

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

.连续的

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

.选择并点击

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

.缓和

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

更新

更新.add

Update.add(function() {

    // something to update every frame
});

更新.clear

Update.clear();

控制台

console.log

console.log("message");

console.list

console.list(object);

警报

alert

alert("message", "title");

AudioController对象

AudioController

var Audio = AudioController("AudioGroup");

AnimationController对象

AnimationController

var Animation = AnimationController("AnimationGroup");

许可

[MIT许可] MIT许可(MIT)版权© 2016 Jaymie Timperley [email protected]

特此授予,免费,任何获取此软件及其相关文档文件(“软件”)的人,无限制地处理软件的权利,包括但不限于使用、复制、修改、合并、出版、分发、再许可和/或出售软件副本的权利,并允许向软件提供的人这样做,前提是必须遵守以下条件

上述版权声明和此许可声明应包含在软件的所有副本或实质性部分中。

软件按“原样”提供,不包括任何 Warranty,无论是明确的还是隐含的,包括但不限于适销性、特定用途适用性和非侵权性。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论是通过合同、侵权或其他方式,源于、源于或在软件使用或其他处理中出现的软件。