Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Using external JS code
Tue, Nov 26 2013 2:57 PMPermanent Link

E.B

Hello,

Coppercube.exe (http://www.ambiera.com/coppercube/index.html) is a software that allows you to create, among other things, WebGL pages controlled by javascript that are written by the users and passed as argument in (for example) essai.ccbjs (see the following example) to file  copperlicht.js (attached file).

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <script type="text/javascript" src="copperlicht.js"></script>
</head>
<body>
   <div align="center">
      <canvas id="3darea" width="640" height="480" style="background-color:#000000">
      </canvas>
   </div>
   <script type="text/javascript">
   <!--
         startCopperLichtFromFile('3darea', 'essai.ccbjs', 'Loading $PROGRESS$...');
   -->
   </script>
   <br/>
   <div align="center">
      <small>Created using the <a href="CopperLicht" name="http://www.ambiera.com/copperlicht/index.html">CopperLicht">http://www.ambiera.com/copperlicht/index.html">CopperLicht
      JavaScript 3D Engine</a> and the <a href="CopperCube" name="http://www.ambiera.com/coppercube/index.html">CopperCube">http://www.ambiera.com/coppercube/index.html">CopperCube
      3D Editor</a></small>
   </div>
</body>
</html>



I try now to use JS functions of the software in EWB for controllinge WebGL scene from EWB. These JavaScript functions are given in the documentation (http://www.ambiera.com/coppercube/doc/index.html) and are coded in copperlight.js wich is an obsfurcated file. I tried several EWB statement (external) without work. How to write these lines of code?

For example, How should I write EWB code for using function startCopperLichtFromFile wich is not obsfurcated in
coppercube.js ?

For example, How shouldI write EWB code for using function ccbCloneSceneNode(node) wich is  obsfurcated in
coppercube.js ?

Using Windows object ?

Regards,

Eric.



Attachments: copperlicht.js
Wed, Nov 27 2013 10:46 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eric,

<< I try now to use JS functions of the software in EWB for controllinge
WebGL scene from EWB. These JavaScript functions are given in the
documentation (http://www.ambiera.com/coppercube/doc/index.html) and are
coded in copperlight.js wich is an obsfurcated file. I tried several EWB
statement (external) without work. How to write these lines of code? >>

This is going to be tough because the authors don't tell you what the types
of the various objects/parameters are, and you have to figure them out from
the source code/documentation.  IOW, it's going to take a while to do.

<< For example, How should I write EWB code for using function
startCopperLichtFromFile wich is not obsfurcated in coppercube.js ? >>

I have no idea without tracing through their entire source code.  The
parameters are easy (all strings), but the return value is an id object
instance, which they don't document anywhere.

You should contact them and see if they have any documentation that includes
the types of the various parameters along with how each object is defined in
the API.  This is basic API stuff, and just because it's JavaScript doesn't
mean that it isn't necessary for proper usage.  Google documents all of
their APIs with complete type definitions.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Nov 28 2013 2:51 PMPermanent Link

E.B

Ok Tim, I asked the developer of CopperCube for help.

In addition, you would like to excuse my maybe stupid question, but startCopperLichtFromFile function  seems to send nothing back and takes a canvas  and 3 strings as arguments . Can you show me how to use this function in EWB?



"Tim Young [Elevate Software]" wrote:

Eric,

<< I try now to use JS functions of the software in EWB for controllinge
WebGL scene from EWB. These JavaScript functions are given in the
documentation (http://www.ambiera.com/coppercube/doc/index.html) and are
coded in copperlight.js wich is an obsfurcated file. I tried several EWB
statement (external) without work. How to write these lines of code? >>

This is going to be tough because the authors don't tell you what the types
of the various objects/parameters are, and you have to figure them out from
the source code/documentation.  IOW, it's going to take a while to do.

<< For example, How should I write EWB code for using function
startCopperLichtFromFile wich is not obsfurcated in coppercube.js ? >>

I have no idea without tracing through their entire source code.  The
parameters are easy (all strings), but the return value is an id object
instance, which they don't document anywhere.

You should contact them and see if they have any documentation that includes
the types of the various parameters along with how each object is defined in
the API.  This is basic API stuff, and just because it's JavaScript doesn't
mean that it isn't necessary for proper usage.  Google documents all of
their APIs with complete type definitions.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Nov 28 2013 5:22 PMPermanent Link

Walter Matte

Tactical Business Corporation

From CopperLicht website....

<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <script type="text/javascript" src="copperlichtdata/copperlicht.js"></script>
</head>
<body>
 <div align="center">
   <canvas id="3darea" width="640" height="480" style="background-color:#000000">
     </canvas>
   </div>
   <script type="text/javascript">
   <!--
        startCopperLichtFromFile('3darea', 'copperlichtdata/coppercube.ccbjs');
   -->
   </script>
</body>
</html>


so in EWB unit declare:

external function startCopperLichtFromFile(const myelementid: string; const thefilename: string);


I only see 2 aguments in the example above... but if there are more... add more.....

Be sure to add the external js library to the external code list and copy it into you output folder.

Walter



E.B wrote:

Ok Tim, I asked the developer of CopperCube for help.

In addition, you would like to excuse my maybe stupid question, but startCopperLichtFromFile function  seems to send nothing back and takes a canvas  and 3 strings as arguments . Can you show me how to use this function in EWB?
Fri, Nov 29 2013 12:08 PMPermanent Link

E.B

Thanck you Walter. I thinck you forgot one thing : Being sure that
the 3DCanvas "3darea" has been created before calling startCopperLichtFromFile().

I tried many things before asking Tim. None of then worked.

The last  was (after having declared copperlicht.js as external in Project/Option/External,
and put essai.ccbjs file in root directory) :


*********************************
unit Unit1;

interface

uses WebCore, WebForms, WebCtrls;

type

  TForm1 = class(TForm)
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
     procedure Form1Create(Sender: TObject);
  private
     { Private declarations }
  public
     { Public declarations }
  end;

  external function ccbGetSceneNodeFromName(s:string):String;
  external function startCopperLichtFromFile(S1,S2:String);


var
  Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);
begin
  startCopperLichtFromFile('3darea','essai.ccbjs');

end;

end.
*********************************

AND       essai.html :

*********************************
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <script type="text/javascript" src="copperlicht.js"></script>
</head>
<body>
   <div align="center">
      <canvas id="3darea" width="640" height="480" style="background-color:#000000">
      </canvas>
   </div>
   <script type="text/javascript">
   <!--
         startCopperLichtFromFile('3darea', 'essai.ccbjs', 'Loading $PROGRESS$...');
   -->
   </script>
   <br/>
   <div align="center">
      <small>Created using the <a href="CopperLicht" name="http://www.ambiera.com/copperlicht/index.html">CopperLicht">http://www.ambiera.com/copperlicht/index.html">CopperLicht
      JavaScript 3D Engine</a> and the <a href="CopperCube" name="http://www.ambiera.com/coppercube/index.html">CopperCube">http://www.ambiera.com/coppercube/index.html">CopperCube
      3D Editor</a></small>
   </div>
</body>
</html>
*********************************

Eric.




From CopperLicht website....

<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <script type="text/javascript" src="copperlichtdata/copperlicht.js"></script>
</head>
<body>
 <div align="center">
   <canvas id="3darea" width="640" height="480" style="background-color:#000000">
     </canvas>
   </div>
   <script type="text/javascript">
   <!--
        startCopperLichtFromFile('3darea', 'copperlichtdata/coppercube.ccbjs');
   -->
   </script>
</body>
</html>


so in EWB unit declare:

external function startCopperLichtFromFile(const myelementid: string; const thefilename: string);


I only see 2 aguments in the example above... but if there are more... add more.....

Be sure to add the external js library to the external code list and copy it into you output folder.

Walter



E.B wrote:

Ok Tim, I asked the developer of CopperCube for help.

In addition, you would like to excuse my maybe stupid question, but startCopperLichtFromFile function  seems to send nothing back and takes a canvas  and 3 strings as arguments . Can you show me how to use this function in EWB?
Mon, Dec 2 2013 2:59 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eric,

<< Thanck you Walter. I thinck you forgot one thing : Being sure that the
3DCanvas "3darea" has been created before calling
startCopperLichtFromFile(). >>

If you need to create a 3D canvas context, then you're going to need to do
some further work in terms of external interfaces.  Currently, EWB only
includes external interfaces for 2D canvas contexts since the 3D context
support wasn't widespread yet.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Dec 2 2013 3:38 PMPermanent Link

E.B

Tim,

Would you like to see my last message ?

-->  http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&msg=3951&page=1

Here the entire page is built by Html code in a Tpage.

Why do EWB  doesn't reproduce the same page ?

the command   <canvas id="3darea" width="640" height="480" style="background-color:#000000">
creates a standart 2D canvas, exactly the same that is used in Tpaint component.

Eric.







"Tim Young [Elevate Software]" wrote:

Eric,

<< Thanck you Walter. I thinck you forgot one thing : Being sure that the
3DCanvas "3darea" has been created before calling
startCopperLichtFromFile(). >>

If you need to create a 3D canvas context, then you're going to need to do
some further work in terms of external interfaces.  Currently, EWB only
includes external interfaces for 2D canvas contexts since the 3D context
support wasn't widespread yet.

Tim Young
Elevate Software
www.elevatesoft.com
Image