ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperLicht
Switch scene AND externally load mesh
Author Text

kingkohle
Registered User
Quote
2010-12-06 14:00:37

Hi pals,

since this comes down to coding I though I should rather try it here than in the CopperCube-Forum^^


I have arranged a button (2D overlay) in Coppercube with the action "when clicked do something". This should execute the following:

when clicked > gotoScenebyName > when switching the scene has completed >then load a specific mesh in that scene > get sure it loads everything properly (like: engine.ingComplete or else)

So when executed it should go to another scene and load a mesh in that switched scene - all done over one button. Isn't that possible?!

I tried it with that script, but it isn't working:

_______________

var engine = new CL3D.CopperLicht('3darea');

{
gotoSceneByName("OnlyThePlayer");

engine.load('copperlichtdata/mesh1.ccbjs');

engine.ingComplete = function()
{
alert("loading completed")
};

}
_______________


I think my code in general is crap. But shouldn´t it work somehow like this? Maybe with a line inserted to just load the mesh once the scene has changed.. Please help


Thx
KK


niko
Moderator
Quote
2010-12-06 16:29:43

From looking at your code, it looks fine. But I take a closer look at this and see if I can find your problem. This could take one or two days though.
Hint: Maybe you can find your problem yourself by simply taking a look into the JavaScript console, if there is any error. This is often the case.


kingkohle
Registered User
Quote
2010-12-06 18:51:16

I figured that the action "gotoSceneByName" isn't working at all. Here is the script executed by a button ("when clicked do something"):

------------------------------
var engine = new CL3D.CopperLicht('3darea');

{
engine.gotoSceneByName("OnlyThePlayer");
}
------------------------------

It definitely runs the script - but nothing happens. It doesn't even show a error in the JavaScript console..



The rest of the new script works fine (no JS-errors) and the mesh is loaded (plus texture):

------------------------------
var engine = new CL3D.CopperLicht('3darea');

{
engine.load('copperlichtdata/mesh1.ccbjs');

engine.getTextureManager().getCountOfTexturesToLoad();


engine.ingComplete = function()
{
alert("loading completed")
};

}
------------------------------


So why would the gotoScenebyName-method not work?

Thx
KK


niko
Moderator
Quote
2010-12-07 16:56:00

I'm not sure, currently, but I'll look into this within the next hours.


kingkohle
Registered User
Quote
2010-12-07 18:15:56

Cheers!!


kingkohle
Registered User
Quote
2010-12-10 14:36:01

Hi pals.. Niko worked it out and I wouldn´t mind sharing this:


It will explain how to call a user-defined function via a button. Remember that you can replace (in the HTML-file)

"startCopperLichtFromFile('3darea', 'copperlichtdata/test.ccbjs');"

with

"var engine = new CL3D.CopperLicht('3darea');
{ engine.load('copperlichtdata/test.ccbjs'); }"

Now additional functions may follow. In my case it switches to another scene AND externally loads a 3D-mesh.. Here is the full source-code:



...
html, head
...

<script type="text/javascript">
<!--

var engine = new CL3D.CopperLicht('3darea');
{
engine.load('copperlichtdata/test.ccbjs');

dosomething = function()
{
engine.gotoSceneByName("scene2");
}

loadcustommesh = function()
{
engine.load('copperlichtdata/mesh1.ccbjs');

engine.getTextureManager().getCountOfTexturesToLoad();
}
}

-->
</script>

...
rest of the html-file here
...


Then simply arrange a button in CopperCube with the action: "WhenClickedDoSomething" > "ExecuteJavaScript" > insert here: "dosomething(); loadcustommesh()"

(or however your functions are called..)

Hope this will help^^


Once you feel insulted by such a basic thread, please see my next post on "dynamically load external mesh"..^^ For a good solution I might pay some money. Lets get it on..


Regards
KK


madalin
Registered User
Quote
2015-05-25 01:23:28

This last code doesn’t load the specified mesh (mesh1.ccbjs) in the scene2 of test.ccbjs. Simply loads the mesh1.ccbjs and destroy (overwrite?) test.ccbjs.
I will mention that copperlict.js is the SDK one, not the copperlict.js generated by CopperCube when publish as WebGL.

HTML5 + javaScript buttons variant:

http://estudio3d.eu/coppercube/L...

CopperCube button (with two functions) variant:

http://estudio3d.eu/coppercube/t...

In this last example, when try to list the name of second scene we got error in console.log because scene2 doesn't exist in the new scene (sphere.ccbjs)

Do you know how to insert(?) new geometry without destroying the original scene?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.