Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual programming #210

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a0fdc9e
Added litegraph's library
NothersInGame Oct 23, 2018
b3f66ec
Included some libraries
NothersInGame Oct 23, 2018
09e8bca
Added nodes's button
NothersInGame Oct 23, 2018
a0aa8dd
All ended?
NothersInGame Oct 23, 2018
09d1e0c
Update editor.html
NothersInGame Oct 23, 2018
25dfc59
Added css to the blueprints
NothersInGame Oct 23, 2018
0ccc2c6
Update Editor.js
NothersInGame Oct 23, 2018
9be9ac9
litegraph fixed
NothersInGame Oct 24, 2018
93f66ae
Here'll be the nodes of the math of threeJS
NothersInGame Oct 24, 2018
0cb2251
Here the nodes that will modify the scene
NothersInGame Oct 24, 2018
ed2d91c
Some things not required but maybe will be util
NothersInGame Oct 24, 2018
35f63a6
Included new files that will contain three nodes
NothersInGame Oct 24, 2018
461b453
The native math of js
NothersInGame Oct 24, 2018
0f1f778
All could be included
NothersInGame Oct 24, 2018
d29fc85
changing more nodes
NothersInGame Oct 24, 2018
aee3929
imported the search box
NothersInGame Oct 24, 2018
8f24c15
Completely imported :smile:
NothersInGame Oct 24, 2018
e5e718f
Some minor bugs fixed
NothersInGame Oct 24, 2018
d603dbf
Tests adding nodes
NothersInGame Oct 24, 2018
cf11932
Adding more nodes
NothersInGame Oct 24, 2018
82edbfd
Still adding nodes
NothersInGame Oct 24, 2018
15c331a
a
NothersInGame Oct 24, 2018
3a8fca7
"ended"
NothersInGame Oct 24, 2018
3242064
Blueprints editor out of the tab size fixed
NothersInGame Oct 25, 2018
469a8bc
Let's try to make the blueprints serializable
NothersInGame Oct 25, 2018
29690fc
This could create a "visual script" in a very close future
NothersInGame Oct 25, 2018
9977288
This could fix a very weird error
NothersInGame Oct 26, 2018
c0f22da
Let's try to set the nodes to an object
NothersInGame Oct 26, 2018
a47006c
Now you can open the NodesTab just with double-clicking
NothersInGame Oct 26, 2018
9719541
Added getNodes method
NothersInGame Oct 26, 2018
ef9496e
Added SetFromString's method
NothersInGame Oct 26, 2018
5521ff7
Added SetNodes Method
NothersInGame Oct 26, 2018
28aaac8
Merge remote-tracking branch 'upstream/SearchTree'
NothersInGame Oct 26, 2018
4114f24
Deleted the merge's "things"
NothersInGame Oct 26, 2018
472d0b0
Merge remote-tracking branch 'upstream/master'
NothersInGame Oct 26, 2018
b3f50d8
let's try to do something
NothersInGame Oct 26, 2018
a827ab4
A white theme??
NothersInGame Oct 26, 2018
62a2595
This renamed too :smile:
NothersInGame Oct 26, 2018
33d9efd
Deleted this that just returns an error
NothersInGame Oct 26, 2018
47200a5
Fixed a very weird error
NothersInGame Oct 26, 2018
ddcb133
Still working in the themexd
NothersInGame Oct 26, 2018
94b4910
White theme ended??
NothersInGame Oct 26, 2018
1336e88
All fixed?
NothersInGame Oct 27, 2018
0efa89b
Bug "fixed" but there's another bug
NothersInGame Oct 27, 2018
d581eea
Added FPS controller example
NothersInGame Oct 27, 2018
fab9cb8
Thats all?
NothersInGame Oct 27, 2018
7f0fe28
Added NWJS for local tests
NothersInGame Oct 27, 2018
bf06ba0
We won't work in this actually
NothersInGame Oct 27, 2018
0581e63
Let's try to implement a basic "components" system
NothersInGame Oct 27, 2018
dd6a8df
Let's add more shaders :currency_exchange:
NothersInGame Oct 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 72 additions & 1 deletion .gitignore
Expand Up @@ -6,4 +6,75 @@ source/node_modules/
source/config
package-lock.json
*.db
*.log
*.log
source/chromedriver.exe
source/d3dcompiler_47.dll
source/ffmpeg.dll
source/icudtl.dat
source/libEGL.dll
source/libGLESv2.dll
source/locales/am.pak
source/locales/ar.pak
source/locales/bg.pak
source/locales/bn.pak
source/locales/ca.pak
source/locales/cs.pak
source/locales/da.pak
source/locales/de.pak
source/locales/el.pak
source/locales/en-GB.pak
source/locales/en-US.pak
source/locales/es-419.pak
source/locales/es.pak
source/locales/et.pak
source/locales/fa.pak
source/locales/fi.pak
source/locales/fil.pak
source/locales/fr.pak
source/locales/gu.pak
source/locales/he.pak
source/locales/hi.pak
source/locales/hr.pak
source/locales/hu.pak
source/locales/id.pak
source/locales/it.pak
source/locales/ja.pak
source/locales/kn.pak
source/locales/ko.pak
source/locales/lt.pak
source/locales/lv.pak
source/locales/ml.pak
source/locales/mr.pak
source/locales/ms.pak
source/locales/nb.pak
source/locales/nl.pak
source/locales/pl.pak
source/locales/pt-BR.pak
source/locales/pt-PT.pak
source/locales/ro.pak
source/locales/ru.pak
source/locales/sk.pak
source/locales/sl.pak
source/locales/sr.pak
source/locales/sv.pak
source/locales/sw.pak
source/locales/ta.pak
source/locales/te.pak
source/locales/th.pak
source/locales/tr.pak
source/locales/uk.pak
source/locales/vi.pak
source/locales/zh-CN.pak
source/locales/zh-TW.pak
source/nacl_irt_x86_64.nexe
source/natives_blob.bin
source/node.dll
source/nunu.exe
source/nw.dll
source/nw_100_percent.pak
source/nw_200_percent.pak
source/nw_elf.dll
source/nwjc.exe
source/payload.exe
source/resources.pak
source/snapshot_blob.bin
10,838 changes: 5,419 additions & 5,419 deletions docs/editor/files/tern/threejs.json

Large diffs are not rendered by default.

Binary file added docs/examples/files/FPS.nsp
Binary file not shown.
16 changes: 16 additions & 0 deletions source/core/objects/script/Blueprints.js
@@ -0,0 +1,16 @@
function VisualScript(nodes) {
THREE.Group.call(this);

this.type = "Script";
this.name = "Visual";

this.nodes = (nodes !== undefined) ? nodes : {};
}

VisualScript.prototype = Object.create(THREE.Group.prototype);

VisualScript.prototype.setNodes = function(nodes) {
if (nodes !== undefined) {
this.nodes = nodes;
}
}
1 change: 1 addition & 0 deletions source/editor.html
Expand Up @@ -3,6 +3,7 @@
<html>
<head>
<meta charset="UTF-8">
<!-- THIS IS NOT THE OFFICIAL NUNU -->
</head>

<body onload="Editor.initialize();" onresize="Editor.resize();">
Expand Down
22 changes: 22 additions & 0 deletions source/editor/Editor.js
Expand Up @@ -139,7 +139,10 @@ include("core/objects/cameras/PerspectiveCamera.js");
include("core/objects/cameras/OrthographicCamera.js");
include("core/objects/audio/AudioEmitter.js");
include("core/objects/audio/PositionalAudio.js");

include("core/objects/script/Script.js");
include("core/objects/script/Blueprints.js");

include("core/objects/physics/PhysicsObject.js");
include("core/objects/spine/SpineAnimation.js");
include("core/objects/spine/SpineTexture.js");
Expand Down Expand Up @@ -258,13 +261,18 @@ include("lib/jszip.min.js");
include("lib/quickhull.js");
include("lib/ThreeCSG.js");

//Non-tentone libraries
include("lib/litegraph.js");
include("lib/litegraph.css");

include("editor/style.css");

include("editor/locale/LocaleManager.js");
include("editor/locale/LocaleEN.js");

include("editor/theme/ThemeManager.js");
include("editor/theme/ThemeDark.js");
include("editor/theme/ThemeWhite.js");

include("editor/gui/element/Element.js");
include("editor/gui/element/DocumentBody.js");
Expand Down Expand Up @@ -326,6 +334,20 @@ include("editor/gui/tab/CodeEditor.js");
include("editor/gui/tab/AboutTab.js");
include("editor/gui/tab/TextEditor.js");

//Nodes tab
include("editor/gui/tab/nodes/NodesTab.js");

include("editor/gui/tab/nodes/EcMAMath.js");

include("editor/gui/tab/nodes/ThreeMath.js");
include("editor/gui/tab/nodes/ThreeScene.js");
include("editor/gui/tab/nodes/ThreeUtils.js");

//TODO: Components
include("editor/gui/components/ComponentManager.js");

//Still Nunu

include("editor/gui/tab/treeview/TreeView.js");
include("editor/gui/tab/treeview/TreeNode.js");

Expand Down
3 changes: 3 additions & 0 deletions source/editor/gui/components/ComponentManager.js
@@ -0,0 +1,3 @@
function ComponentManager() {
// body...
}
102 changes: 51 additions & 51 deletions source/editor/gui/element/SearchBox.js
@@ -1,52 +1,52 @@
"use strict";
/**
* Search box input element.
*
* @class SearchBox
* @extends {Element}
* @param {Element} parent Parent element.
*/
function SearchBox(parent)
{
Element.call(this, parent, "div");
/**
* Input text box of the search box.
*
* @property search
* @type {TextBox}
*/
this.search = new TextBox(this);
this.search.setMode(Element.TOP_RIGHT);
this.search.element.placeholder = "Search";
/**
* Search icon.
*
* @property searchIcon
* @type {DOM}
*/
this.searchIcon = new ImageContainer(this);
this.searchIcon.setImage(Editor.filePath + "icons/misc/search.png");
}
SearchBox.prototype = Object.create(Element.prototype);
SearchBox.prototype.setOnChange = function(callback)
{
this.search.setOnChange(callback);
};
SearchBox.prototype.updateSize = function()
{
Element.prototype.updateSize.call(this);
this.searchIcon.size.set(this.size.y * 0.6, this.size.y * 0.6);
this.searchIcon.position.set(this.size.y * 0.2, this.size.y * 0.2);
this.searchIcon.updateInterface();
this.search.size.set(this.size.x - this.size.y * 1.4, this.size.y * 0.8);
this.search.position.set(this.size.y * 0.2, this.size.y * 0.1);
this.search.updateInterface();
"use strict";

/**
* Search box input element.
*
* @class SearchBox
* @extends {Element}
* @param {Element} parent Parent element.
*/
function SearchBox(parent)
{
Element.call(this, parent, "div");

/**
* Input text box of the search box.
*
* @property search
* @type {TextBox}
*/
this.search = new TextBox(this);
this.search.setMode(Element.TOP_RIGHT);
this.search.element.placeholder = "Search";

/**
* Search icon.
*
* @property searchIcon
* @type {DOM}
*/
this.searchIcon = new ImageContainer(this);
this.searchIcon.setImage(Editor.filePath + "icons/misc/search.png");
}

SearchBox.prototype = Object.create(Element.prototype);

SearchBox.prototype.setOnChange = function(callback)
{
this.search.setOnChange(callback);
};

SearchBox.prototype.updateSize = function()
{
Element.prototype.updateSize.call(this);

this.searchIcon.size.set(this.size.y * 0.6, this.size.y * 0.6);
this.searchIcon.position.set(this.size.y * 0.2, this.size.y * 0.2);
this.searchIcon.updateInterface();

this.search.size.set(this.size.x - this.size.y * 1.4, this.size.y * 0.8);
this.search.position.set(this.size.y * 0.2, this.size.y * 0.1);
this.search.updateInterface();
};
7 changes: 6 additions & 1 deletion source/editor/gui/main/sidebar/AddObjectSideBar.js
Expand Up @@ -233,7 +233,7 @@ function AddObjectSideBar(parent)
//Add script
var addScript = new ButtonDrawer(parent);
addScript.setImage(Editor.filePath + "icons/script/script.png");
addScript.optionsPerLine = 1;
addScript.optionsPerLine = 2;
addScript.size.set(size, size);
addScript.position.set(0, 350);
addScript.optionsSize.set(size, size);
Expand All @@ -244,6 +244,11 @@ function AddObjectSideBar(parent)
{
Editor.addObject(new Script());
}, "JS Script");

//Visual script
addScript.addOption(Editor.filePath + "icons/script/blocks.png", function() {
Editor.addObject(new VisualScript());
}, "Visual script");

//Effects
var addEffects = new ButtonDrawer(parent);
Expand Down
1 change: 1 addition & 0 deletions source/editor/gui/tab/camera/CameraEditor.js
Expand Up @@ -81,6 +81,7 @@ function CameraEditor(parent, closeable, container, index)
addRenderPassButton("Dot Screen", DotScreenPass);
addRenderPassButton("Sobel", SobelPass);
self.form.nextRow();
self.form.nextRow();
addRenderPassButton(Locale.copy, CopyPass);
self.form.nextRow();

Expand Down
50 changes: 50 additions & 0 deletions source/editor/gui/tab/nodes/EcMAMath.js
@@ -0,0 +1,50 @@
function pi() {
return Math.PI;
}

function round(toRound) {
return Math.round(toRound);
}

function pow(x, y) {
return Math.pow(x,y);
}

function sqrt(x) {
return Math.sqrt(x);
}

function abs(x) {
return Math.abs(x);
}

function ceil(x) {
return Math.ceil(x);
}

function floor(x) {
return Math.floor(x);
}

function sin(x) {
return Math.sin(x);
}

function cos(x) {
return Math.cos(x);
}

function random() {
return Math.random();
}

LiteGraph.wrapFunctionAsNode("Math/PI", pi, null, "number");
LiteGraph.wrapFunctionAsNode("Math/Round", round, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Pow", pow, ["number", "number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Sqrt", sqrt, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Abs", abs, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Ceil", ceil, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Floor", floor, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Sin", sin, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Cos", cos, ["number"], "number");
LiteGraph.wrapFunctionAsNode("Math/Random", random, ["number"], "number");
43 changes: 43 additions & 0 deletions source/editor/gui/tab/nodes/NodesTab.js
@@ -0,0 +1,43 @@
"use strict";

function NodesTab(parent, closeable, container, index)
{

TabElement.call(this, parent, closeable, container, index, "Blueprint", Editor.filePath + "icons/script/blocks.png");

this.element.style.backgroundColor = Editor.theme.barColor;

this.canvas = document.createElement("canvas");
this.canvas.width = 1000;
this.canvas.height = 1000;
this.canvas.id = "nodeed";

this.element.appendChild(this.canvas);

this.graph = new LGraph();

this.lcanvas = new LGraphCanvas("#nodeed", this.graph);

this.graph.start();
}

NodesTab.prototype = Object.create(TabElement.prototype);

NodesTab.prototype.getNodes = function() {
return this.graph.serialize();
}

NodesTab.prototype.setNodes = function(nodes) {
this.graph.setFromString(nodes);
}

NodesTab.prototype.updateSize = function()
{
TabElement.prototype.updateSize.call(this);

this.canvas.width = this.size.x;
this.canvas.height = this.size.y;

this.canvas.style.width = (this.size.x) + "px";
this.canvas.style.height = (this.size.y) + "px";
};
1 change: 1 addition & 0 deletions source/editor/gui/tab/nodes/ThreeMath.js
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions source/editor/gui/tab/nodes/ThreeScene.js
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions source/editor/gui/tab/nodes/ThreeUtils.js
@@ -0,0 +1 @@