Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
JavaScript API Wrapper

pk12
Registered User
Quote
2016-12-29 00:10:10

I've created an object-oriented wrapper for the JavaScript API with some additional features.

Currently the majority of API is implemented (Node, Mesh, Vertex, Index, Material, etc.) + features like setTimeout/setInterval and encodeJSON/decodeJSON.

You can download it and read the documentation at https://github.com/pkorzeniewski...

Please report any bugs you find and share ideas for improvements!

I hope you'll find it useful :)


niko
Moderator
Quote
2016-12-29 09:06:06

Hey, that's really cool! Seemed to have been a lot of work?


pk12
Registered User
Quote
2016-12-30 20:08:36

Not that much really, I've started writing this wrapper for a game I'm currently working on in CC and I thought why not publish it :)

Btw. there're two important features missing in the CC API right now in my opinion:

1. ccbGetSceneNodeParent - there's ccbSetSceneNodeParent available so I'm wondering if there's some technical limitation for this?

2. ccbSetSceneNodeCustomProperty/ccbGetSceneNodeCustomProperty - these functions would set/get number, string and boolean values (objects can be encoded to JSON and stored as string)

Would it be possible to implement these functions in next CC version?


niko
Moderator
Quote
2017-01-01 07:34:46

Yes, ccbGetSceneNodeParent is missing, you are right. But what should be the difference between ccbSetSceneNodeProperty and ccbSetSceneNodeCustomProperty?


pk12
Registered User
Quote
2017-01-01 19:58:27

With ccbSetSceneNodeProperty we can't set custom properties, neither can we store them in the object:
var n1 = ccbGetSceneNodeFromName("myNode");

// shows error "Property does not exist: hello"
ccbSetSceneNodeProperty(n1, "hello", "world");

n1.hello = "world";

var n2 = ccbGetSceneNodeFromName("myNode");

// doesn't work - the property doesn't exist
print(n2.hello);



niko
Moderator
Quote
2017-01-02 09:08:05

Ah! Ok, that makes sense.


madalin
Registered User
Quote
2017-01-06 22:01:48

Thank you. I really appreciate.


just_in_case
Moderator
Quote
2017-01-07 18:58:05

Great job done by you! @pk12 ... Thanks a lot..


pk12
Registered User
Quote
2017-01-15 16:40:12

New version (1.2.0) uses now an internal nodes tree to implement .getParent() and allow storing custom data :)

Example:
var myFolder = ccb.node.get('myFolder');
var myNode = ccb.node.get('myNode');

myNode.setParent(myFolder);

// prints "myFolder"
print(myNode.getParent().getName())

myNode.myCustomData = "Hello world!";

// true
myNode.myCustomData === ccb.node.get('myNode').myCustomData



niko
Moderator
Quote
2017-01-16 07:57:47

Woha :)


pk12
Registered User
Quote
2017-01-17 23:59:31

@niko: one more important thing missing in the API - getting type of given scene node, ccbGetSceneNodeProperty('Type') throws an error "Property does not exist: Type"


wild-master
Registered User
Quote
2017-10-22 20:05:00

Hello, pk12.

Your JavaScript API Wrapper isn't on github now. Are you willing to share it again?

I downloaded a behavior called "Randomize Nodes Positions" from http://marshtownmadness.com and your wrapper is included in the zip file, but I don't know if it's the newest version.

I followed the installation instructions, but I see these errors:

1.
Verifying file 'action_JSAPIWrapper.js' ...
action_JSAPIWrapper.js:9:ReferenceError: ccbCloneSceneNode is not defined


2.
Running plugin script plugin_JSAPIWrapper.js
C:\Users\owner\Documents\CopperCube\plugins\plugin_JSAPIWrapper.js:1:ReferenceError: ccbCloneSceneNode is not defined


How should I fix those problems?

I have a very important question about your JavaScript Wrapper:
Can it be used to retrieve the current positions of Child nodes? If I use the ccbGetSceneNodeProperty() function of CopperCube to check the position of a Child node, only its starting position will be reported, even when the Parent object moves to a new position and carries the Child node with it. If a Child node starts at the "100, 0, 0" position, that's the only position that will ever be known by the engine, even when it's at a new location.

Can your project retrieve the updated positions of Child nodes? Can you please show a code sample to show how it can be done?

The documentation included in the zip file show a function called getPosition(), but I don't know how to use it, and I cannot test it because your project probably cannot function while the errors I showed above are still happening.


DouweDabbe
Guest
Quote
2021-08-20 10:37:22

Did anyone capture the Apiwrapper ?

https://github.com/pkorzeniewski

is empty

or is it totally outdated by now ?


Create reply:


Posted by: (you are not logged in)


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