Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Problem loading Copperlicht engine

elmario
Registered User
Quote
2014-08-27 21:56:47

Hi,

I'm trying to load a scene through the following method

var Client = function(params) {
if(typeof io === 'undefined') {
alert('World server is down');
return;
}

if(!window.WebGLRenderingContext) {
alert('Your device does not support WebGL');
return;
}

this._network = io.connect(
'http://' + params.serverIp + ':' + params.serverPort
);

mfe$('client').attr('height', mfe$(window).height());
mfe$('client').attr('width', mfe$(window).width());
var engine = new CL3D.CopperLicht('client');
engine.load('/assets/client/scenes/SandwellDistrict/ME.ccbjs');

console.log(engine);
};



however even when I use the latest SDK version of Copperlicht, I receive an undefined error for the engine.load method, and when I log the variable, I only see obfuscated functions like so: http://i.gyazo.com/ea7b2bfc0c39ddc6e3016269778794b6.png

Even when I use startCopperlichtFromScene method, and assign this to engine, I get the same error.

What do I need to do so I can use the Copperlicht API?


niko
Moderator
Quote
2014-08-28 06:24:54

Do you get any error message?


skullboy99
Guest
Quote
2014-08-28 08:41:25

Change the canvas with another name,because you have defined a var with same name.


var engine = new CL3D.CopperLicht('another canvas');


Try it.


elmario
Registered User
Quote
2014-08-28 13:59:42

The error I get is
Uncaught TypeError: undefined is not a function main.js:43


In line 43 I have the following code


initEngine: function() {
var _this = this;
var engine = new CL3D.CopperLicht('clientCanvas');
engine.load('/assets/client/scenes/SandwellDistrict/ME.ccbjs');
console.log(engine);
},


I've tried with different versions of copperlicht, but I still have the same problem.


niko
Moderator
Quote
2014-08-28 18:44:28

Are you maybe using the copperlicht.js file generated by the CopperCube editor? That one doesn't have the .load function, you need the one from the CopperLicht SDK.

If this is not the problem, do you know how to add a breakpoint and step through your code? If so, at the place where you call engine.load, is engine an actual object? If not, then this is the problem. Maybe you just forgot to include the copperlicht.js file in your file, or similar. Just wild guessing.


elmario
Registered User
Quote
2014-08-28 22:08:59

Hi,

It started working now, I think the problem was cache even though I tried in a different browser.

Thanks for all your help Niko and Skullboy, I'll be sure to pickup a commercial licence ASAP. Btw I would like to ask a question about keyboard inputs - I'm using the default inputs WASD for players to move around using 3rd person camera, however it's interfering with the jQuery , meaning I cannot type WASD inside a text field! Is there a way to disable this through the API? I can't find anything in the docs

Cheers


elmario
Registered User
Quote
2014-08-29 05:00:46

Further to my question above, I also have one more which is puzzling me

By default I have a player in the scene named "PlayerMesh" which is the player himself. Now, when I make a clone of this PlayerMesh, using the API, and the following code:


createPlayer: function(data) {
var _this = this;
// console.log(this._player);
var mesh = this._player.createClone(
_this._scene.getRootSceneNode()
);

mesh.Name = 'OtherPlayerMesh' + data.playerData.characterId;

mesh.Data = data;

mesh.Pos.X = data.playerData.positionX;
mesh.Pos.Y = data.playerData.positionY;
mesh.Pos.Z = data.playerData.positionZ;

mesh.Rot.Y = 0;
mesh.Rot.Y = data.playerData.positionY;
mesh.Rot.Z = 0;
}


I see two people in the scene which is correct. However when I move my character using the WASD controls, this newly created mesh also moved around - despite the fact that I gave it a different name. What could be the problem? I think maybe I need to change the Id not just the Name, or maybe I'm changing it too late


niko
Moderator
Quote
2014-08-29 14:35:38

The reason for this is the following: The player you have has an animator attached to it, which reacts to keyboard input by moving the object it is attached to, namely the player object.
When you now clone the player object, you now have a second object which also has a clone of this animator attached to it. And it will do exactly the same.


Create reply:


Posted by: (you are not logged in)


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