Babylon3D: Standard Edition

Post your completed addons to share with the community

Post » Tue Jan 17, 2017 9:04 am

@X3M I posted the FreeCamera problem on the Babylon.js forums here:
http://www.html5gamedevs.com/topic/2774 ... n-on-move/

Hope somebody finds a solution or a way to fix it, i tried in all ways i know and never get the behaviour desired, also i want to create some kind of switch to deactivate/activate and use it as Walk/Jetpack.

---

About use babylon.js functions on C2, how optimized/fast will be compared with the babylon3D plugin? I mean, the same function using Babylon3D action or executing Babylon.js functions in events have any difference?
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Tue Jan 17, 2017 9:49 am

@matriax No they are the same, you simply execute the function with Browser->Execute javascript.
I will give you all the parameters you will need, although I'll post a video tutorial on my youtube channel after my basic tutorials :
The scene object:
this.runtime.scenes[ID]
ID: Is the scene ID you set in C2.
Example:
Code: Select all
Browser  |Execute javascript "this.runtime.scenes[0].clearColor.r = 255;"

Explanation: Change the scene 0 red color to 255.

The mesh object:
this.runtime.scenes[ID].getMeshByName("&"'mesh"+UID)
UID: Is the mesh UID.
Example:
Code: Select all
Browser  |Execute javascript "this.runtime.scenes[0].getMeshByName("&"'mesh3'"&").visiblity = 0.5;"

Explanation: Set the opacity of the mesh with UID 1 to 0.5

The light object:
this.runtime.scenes[ID].getLightByName("&"'light"+UID)
UID: Is the mesh UID.
Example:
Code: Select all
Browser  |Execute javascript "this.runtime.scenes[0].getLightByName("&"'light4'"&").intensity= 0.0;"

Explanation: Set the intensity of the light with UID 4 to 0.0

The camera object:
this.runtime.scenes[ID].getCameraByName(name)
name: Is the name you have given to the camera in the left properties tab (Property above scene ID )
Example:
Code: Select all
Browser  |Execute javascript "this.runtime.scenes[0].getCameraByName("&"'myCamera'"&").position += 1.0;"

Explanation: Move the camera named myCamera by 1 on the X axis

Visit the BabylonJS playground to experiment with your code
Last edited by X3M on Tue Jan 17, 2017 3:06 pm, edited 2 times in total.
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Tue Jan 17, 2017 2:38 pm

The first example works perfect, the other don't, maybe because they have a "" ?

Example
Code: Select all
Browser  |Execute javascript "this.runtime.scenes[0].getMeshByName("mesh3").visiblity = 0.5;"


I created a NewMesh = Cylinder, with Cylinder as object name and mesh name. This Cylinder have UID=27 on C2.

I tried this:
Code: Select all
"this.runtime.scenes[0].getMeshByName(""Cylinder"").visiblity = 0.5;"

Code: Select all
"this.runtime.scenes[0].getMeshByName(""Cylinder""+27).visiblity = 0.5;"

Code: Select all
"this.runtime.scenes[0].getMeshByName(""Cylinder""27).visiblity = 0.5;"

Code: Select all
"this.runtime.scenes[0].getMeshByName(""Cylinder+27"").visiblity = 0.5;"


But none worked. I added double "" to get working if not i get an error syntax on C2 expressions. How have to be done correctly? What i'm missing?
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Tue Jan 17, 2017 3:04 pm

@matriax Fixed , between it should be mesh27 and not Cylinder27
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

Post » Tue Jan 17, 2017 3:44 pm

the plugin is fully functional now?i mean is 100% ready for a game?
B
18
S
3
G
1
Posts: 248
Reputation: 2,353

Post » Tue Jan 17, 2017 4:31 pm

@X3M Waiting the video tutorial to see real examples working :S .

So seems for the Light and Mesh objects they refer to the UID: Light4, Mesh21,etc... but for the camera uses the mesh name in the left tab, not the C2 name, the one that uses Babylon that appear above "Scene ID".

I have the Light thing working now, on press I > Light2 to 0.0 intensity and the execute javascript works this:
Code: Select all
"this.runtime.scenes[0].getLightByName(""light2"").intensity= 0.0;"


But the mesh still not works. I have NewMesh objects and OBJ-Mesh and tried:
"this.runtime.scenes[0].getMeshByName("&"'mesh20'"&").visiblity = 0.5;"
"this.runtime.scenes[0].getMeshByName("&"'mesh24'"&").visiblity = 0.5;"
"this.runtime.scenes[0].getMeshByName("&"'mesh27'"&").visiblity = 0.5;"
etc.... But none worked.

The camera seems is detected but when i try to apply your javascript code i get this error:
Image
Code: Select all
"this.runtime.scenes[0].getCameraByName("&"'Camera'"&").position += 1.0;"
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Tue Jan 17, 2017 10:43 pm

@X3M Maybe it's me, but i'm trying adjust X/Y/Z coordinates and seems for each action i want to do even for the same plugin they changes.

Image

I was trying to set a bullet in front of the camera and for clone mesh the X/Z works in a way and for set position in other. In both cases the bullet appears in front the camera but for each action the axis works different?.
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Wed Jan 18, 2017 8:08 am

Found this when i tried to parent a NewMesh to the camera:
Image

---

EDIT2 - Y.rotation solved!!

In the post about avoid the Y.rotation Deltakosh posted this example:
http://www.babylonjs-playground.com/#GZ1YB
(thread: http://www.html5gamedevs.com/topic/2774 ... n-on-move/)

The thing that avoid the Y to fly is this:

Code: Select all
    camera._updatePosition = function() {
        this.cameraDirection.y = 0;
        this.position.addInPlace(this.cameraDirection);
    }


In execute javascript seems with only this already works:
Code: Select all
"this.runtime.scenes[0].getCameraByName(""camera"").cameraDirection.y = 0;"


This can be done actually with the Babylon3D actions? I tried some of them adding Y to 0 but none worked or this is another expresion? In that case will be great have the DIrections X/Y/Z for the next update with all the other minor fixes with camera degress,etc...
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Wed Jan 18, 2017 5:16 pm

The "execute javascript" for mesh works, the thing not works is change the visibility of the mesh.

I tried to change the visibility of a mesh picking by UID using the Babylon3D actions but nothing happens for OBJ-Mesh objects. On NewMesh objects works.

I tried to erase a mesh picking by UID using the execute javascript and works perfect:
Code: Select all
"this.runtime.scenes[0].getMeshByName(""mesh35"").dispose() ;"


Seems the problem is the "visibility" action for OBJ-Mesh ¿?. Or why works on NewMesh and not on OBJ.Mesh?
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

Post » Thu Jan 19, 2017 11:23 am

@X3M Seems the Nearest_Sampligmode and anisotropicFiltering is set on each texture. If you provide the action to enable or disable them, if we have a family called "3D_OBJ" i guess we will can do a: For each "3D_OBJ" > Set Nearest | Filtering=1, or whatever, right?

I tried with the execute javascript but i don't know exactly the code for that, i tried things like this:

Code: Select all
"this.runtime.scenes[0].getMeshByName(""mesh35"").Texture.NEAREST_SAMPLINGMODE);"

Code: Select all
"this.runtime.scenes[0].getMeshByName(""mesh35"").Texture.anisotropicFilteringLevel = 1;"


But i guess this is not how it works. I'm looking this playground example:
http://www.babylonjs-playground.com/#1IKIXK#5

Other example about SamplingMOde:
http://babylonjs-playground.com/#121HCT#0


How i access to the texture functions of a mesh with execute javascript to modify this things? Maybe for this things i have to have in mind the material name of the mesh to change their properties?
B
27
S
10
G
3
Posts: 596
Reputation: 4,644

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests