Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
addScene() with Overlay2D probleme

xakiru
Registered User
Quote
2012-04-11 15:21:01

Hi everybody,

I've got a little probleme and i don't know if it's a bug or I'm doing it in the wrong way. here is my case, i load first file1.ccbj in canvas1, then i load file2.ccbj to canvas2, then i try to get a scene from the seconde canvas and add it to the first loaded engine.


var engine1 = startCopperLichtFromFile('Canvas1', 'file1.ccbj');
engine1.ingComplete=function (){
var engine2 = startCopperLichtFromFile('Canvas2', 'file2.ccbj');
engine2.ingComplete=function (){
engine1.addScene(engine2.getScene());
}
}

All is working file, the probleme is when I have Overlay2D in the scene that will be imported, the text dont show correctly in the engine1.


thanks by advence.


niko
Moderator
Quote
2012-04-11 15:46:23

Hm, I'm not sure if this would work, it wasn't designed so you can switch scenes and data between to instances of an engine, on different canvases. I'm surprised this works at all :)


xakiru
Registered User
Quote
2012-04-11 15:49:11

Is there a way to get scenes from different files ?


niko
Moderator
Quote
2012-04-11 16:15:51

Sure, just use

engine.load('somefile.ccbjs');



xakiru
Registered User
Quote
2012-04-11 16:32:15

I'm stupid, Think you bro, You made my day !


madalin
Registered User
Quote
2015-05-25 03:42:01

engine.load('somefile.ccbjs');
destroy the content of the original file, if not saved and added on reloading. (IMO)

So I tried the code of @xakiru - he said that worked:


<script type="text/javascript">

var engineSphere = startCopperLichtFromFile('spherearea', 'copperlichtdata/sphere.ccbjs');
var savedBuffer = null;
engineSphere.OnLoa_dingComplete = function() {
console.log("sphere complete");
var sceneSphere = engineSphere.getScene();
if (sceneSphere) {
savedBuffer = sceneSphere.getSceneNodeFromName('sphereMesh1');
//shows buffered javaScript object == sphereMesh1
console.log(savedBuffer)
}
}

var engine = startCopperLichtFromFile('cubearea', 'copperlichtdata/cube.ccbjs');
var cubeSceneNode = null;
engine.OnLoa_dingComplete = function() {
console.log("cube complete");
var scene = engine.getScene();
if (scene){
loadModel = function(){
console.log("savedBuffer before addChild");
console.log(savedBuffer);
scene.getRootSceneNode().addChild(savedBuffer);
}
// find the cube scene node
cubeSceneNode = scene.getSceneNodeFromName('cubeMesh1');
// also, force the 3d engine to update the scene every frame
scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME);
}
}

document. = function(event){
var key = String.fromCharCode(event.keyCode);
// when pressed 'F', move the cube scene node a bit up
if (key == 'F' && cubeSceneNode) cubeSceneNode.Pos.Y += 5;
// when pressed 'G', move the cube scene node a bit down
if (key == 'G' && cubeSceneNode) cubeSceneNode.Pos.Y -= 5;
// we need to call the key handler of the 3d engine as well, so that the user is
// able to move the camera using the keys
engine.handleKeyDown(event);
};

</script>
<button ="loadModel()">Load Sphere</button>


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

Even if I used the same engine and same scene – in different <DIV>'s, or engine= new CL3D.CopperLicht(), engine.load() - It seems that we could control only the engine loaded in the first <DIV> - see arrow keys and F, G keys implemented from tutorial2.
On trying to copy the node from one engine to another I’ve got the same error message: WebGL: INVALID_OPERATION: bind(‘something’): object not from this context. for all elements of the javascript object.
The javascript object was copied but empty (only has his name and appear in nodes list)
What does it mean “not for this context” webgl buffer binding error for copperlicht?
How could I transfer nodes between running ccbj files?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible 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


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact