Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Noob-Q: WebGL - Isolate multiple Instances

bollili
Registered User
Quote
2018-10-23 11:15:12

Hey there,

what I am doing right now:

- I added a behavior ("Before first drawing do something ") at the root node.
- There I added an action ("Execute Javascript").
- As JS I entered "sceneReady();"
- This "sceneReady();" is catched by the website which adds another texture to a material of a model

It works.

But, now my question: let's say, I want to have multiple instances of the same copperlicht scene on the website. For every instance I want to be able to add a different texture from outside.

I suppose the goal is, to put the engine in its own namespace/container/whatever, so that I can do something like "this.sceneReady();" ?

You may notice, that I don't know much about how Javascript works. So let me apologize, if this is already answered somewhere. I obviously aren't even aware of the correct terms to search for the right thing.


A bump into the right direction would be most appreciated.

Thanks!


srfstudio
Registered User
Quote
2018-10-24 21:52:24

Well the first thing that comes to my mind is that for each iframe-instance of your game on the website you will have to have separate iframe-code written. So why don't you just create different iframe id's for each iframe-instance & create an id check in your game, something similar to:
if window.frameElement.id is 1 than do action 1

That way, depending on a iframe's id that the game is being iframed in, you can have different textures or other actions in the game.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (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