Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javascript performance question

0 views
Skip to first unread message

Andrew Jorgensen

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Does anyone know if it's more efficient to put all of your scripts into
one great script with many functions? or to make separate script nodes for
everything? And is it better to manipulate values internally using SFNode's
or externally through ROUTE's?
Also if someone is a big advocate of Java over javascript I'd like to
hear your oppinions. Perfomance is my main concern here. What's really
fastest? (I'll most likely be using CosmoPlayer.)

Thanx, Andrew Jorgensen ajo...@neptune.cs.byu.edu
http://neptune.cs.byu.edu/~ajorge/ (please excuse the mess)

Evgeny Demidov

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to
Hi Andrew Jorgensen:

> Also if someone is a big advocate of Java over javascript I'd like to
> hear your oppinions. Perfomance is my main concern here. What's really
> fastest? (I'll most likely be using CosmoPlayer.)

"Due to JIT compiler Java applets are more then 20 times faster then Java
Script!"
http://www.people.nnov.ru/fractal/VRML/3DLab.htm

You can test it with the "Mandelbrot's mountains" applet and "Generated
"on-the-fly" scenes" (the last works under NC only). I didn't finish JS
MHill.wrl because big JavaScripts are unstable ("Out of Memory" error).

Evgeny


P Flavin

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to
Java gives much better performance than Javascript, and
offers better support for Object-Oriented-Programming,
support for GUI components, and file processing ...

Java3D may give additional benefits ...

| Mesh Deformations : Human Animation with Seamless Flexing
| -----------------------------------------------------------------------
| " A Seamless Shape For H-Anim Compliant Bodies " ( VRML 99 Paper )
| ----------------------------------------------------------
| - by Christian Babski & Daniel Thalmann, Swiss F.I.T.
| - EXCELLENT paper ! ! ! _ a MUST READ _ ( 9 pages, 2 meg )
|
| Overview, Paper ( Great ! ! ), Demo :
| http://ligwww.epfl.ch/~babski/StandardBody/Deformation/
| http://ligwww.epfl.ch/~babski/StandardBody/Deformation/vrml99.pdf.gz
| http://ligwww.epfl.ch/~babski/StandardBody/Deformation/
| Worlds/Cow/Scenes/cow_scene.wrl
|
| | 3.4.2 Language Choice
| |
| | The presented method was first implemented in javascript [13]
| | ... However depending on the amount and type of calculation to
| | be performed, this interpreted language only allows to obtain
| | a low framerate ... the framerate decreases drastically down
| | to an unacceptable level ( less than one frame per second )...
| |
| | some functionalities, such as rotation vector manipulation,
| | [ are ] not well implemented in some plug-ins.
| |
| | For all the reasons, we switched to ___ Java ___ ...
| | It offers the needed power of a compiled language
| | for performing this kind of calculation.
| |
| Note : Javascript, the method that was tried and rejected for
| failing to meet performance and reliability requirements is
| the same " PROTO and Script " technique loudly proclaimed
| as the solution by those with less experience and expertise.
|
| Java works, Scripts have failed : they proved to be too slow
| and the plug-in viewers failed to provide reliable support, and
| they support modern Object-Oriented-Programming styles too weakly
| with respect to competing solutions ( Java is clearly superior ).
|
http://www.vrml.org/WorkingGroups/h-anim/hypermail/2000/0138.html


> > ... Java over javascript ... Perfomance is my main


> > concern here. What's really fastest ?

> > ( I'll most likely be using CosmoPlayer. )


>
> " Due to JIT compiler Java applets are more then 20 times
> faster then Java Script ! "
>
> http://www.people.nnov.ru/fractal/VRML/3DLab.htm
>
> You can test it with the "Mandelbrot's mountains" applet and
> "Generated "on-the-fly" scenes" (the last works under NC only).
> I didn't finish JS MHill.wrl because big JavaScripts are unstable
> ("Out of Memory" error).
>

Evgeny Demidov <dem...@ipm.sci-nnov.ru> wrote

Exactly right, your experience is confirmed by others.

Serious VRML developers should sign up for the www-vrml
mail list :

http://www.web3d.org/www-vrml/


VRML and Java is a great combination.

I use VRML with Java three ways :

- VRML EAI ( VRML plug-in with Java interface )
- VRML Java 1.1 Viewers for Web Animation ( no plug-in )
- VRML Loader with Java3D and OpenGL layer ( for speed )

" YOU Control Avatars " VRML Web Applet, Java3D Intro ...
http://www.frontiernet.net/~imaging/H-Anim_Avatars.html

" VRML EAI FAQ & DEMO " ( People Poser )
http://www.frontiernet.net/~imaging/HAnimPoser.html
http://www.frontiernet.net/~imaging/eaifaq.html

etc ...
http://www.frontiernet.net/~imaging/java3dviewer.html
http://www.frontiernet.net/~imaging/java3d_and_vrml.html

VRML with Java is good for :

1 ) general web use where visitors may not have
or be willing or able to install the plug-in.

2 ) applications where there are complex behaviors
( games & human modeling ) ... the things that I find
most interesting.

" VRML Java Viewers " ... a growing list, a growing trend ...
http://www.anfyteam.com/dev/
http://www.blaxxun.com/products/blaxxun3d/showcase/index.html
http://www-4.ibm.com/software/net.media/
http://www.shout3d.com/about.html
http://www.parallelgraphics.com/products/jet/examples/
http://www.frontiernet.net/~imaging/java3dviewer.html
Next Up : Mozilla with Java3D ( expected this Summer )

IBM recognizes the value of 3D for doing business on the web :

|
In parallel with the evolution of HTML, the VRML standard
established the feasibility of treating a 3D scene as composed
of visual and aural objects. MPEG-4, heavily influenced by
VRML is an emerging standard for presenting, over possibly
low-bandwidth networks, complex 3D scenes composed of
visual/aural objects, which change in real-time, in response
to user interactions. An MPEG-4 player can be seen as containing
lower-level JMF-like media players for audio, video, 3D
animation and so forth. In addition, the MPEG-4 player contains
an intelligent media controller that understands the purpose behind
the content being presented, and can interpret in this context the
meaning of user interactions with it.
|
http://www-4.ibm.com/software/developer/library/jmf/jmfwhite.html

" 3D - add VRML objects to your Web page without plug-ins "
|
http://www-4.ibm.com/software/net.media/

-- Paul, Java Developer & Web Animator.
------------------------------------------------------------------------
" Imaging the Imagined : Modeling with Math & a Keyboard "


Andrew Jorgensen

unread,
Jul 14, 2000, 3:00:00 AM7/14/00
to
Thanks for the input, I may go ahead and use java instead. I like
embedding my scripts though. I'd still really like to know if it's better to
have one big script node that handles averything? or several tiny scripts
for each part? I guess this is a question of how it's handled in the
browser. Does each script have it's own thread? does the browser evaluate
the entire script each time an eventIn is called. Can anyone give me some
input on this?

P Flavin <anim...@rochester.rr.com> wrote in message
news:EVEb5.8806$PD4.3...@typhoon.nyroc.rr.com...

Blaikie

unread,
Jul 15, 2000, 3:00:00 AM7/15/00
to
i can tel u this much. Scripts, java or otherwise aren't threaded. when an
eventIn is received by a script the entire function (and any functions
called by teh initial function) are given highest priority by the plugin.
the browser will cease to function while processing is completed.
i wrote a tankgame in VRML, and the random terrain generation has this
effect since it is so complex. i did create a fake method of threading
(didn't try using Java threads, since my game was written using javascript).
db

P Flavin

unread,
Jul 15, 2000, 3:00:00 AM7/15/00
to
Your Tank Game is good program ... I'm just suggesting
that perhaps you're at the point where the complexity of
the program ( relatively high ) is moving into an area where
the Object-Oriented-Programming features of Java become
increasing beneficial and the simpler scripts start to become
increasing difficult to work with ... not that it can't be done.

> ... Scripts, java or otherwise aren't threaded.

Java is not Javascript, or a script, and it supports threads.

> when an eventIn is received by a script the entire function
> (and any functions called by teh initial function) are given
> highest priority by the plugin. the browser will cease to function
> while processing is completed.

There certainly are lots of limitations, I'm not up on
all the details, with my Dart Player ( and perhaps Ping-
Pong players later ) I'm trying to design it to live within
the limitations :

Calculate the projectile's path, put it into
PositionInterpolators and Fire the event and
design it so nothing has to be changed on
the fly until that event is complete.

With Darts and Ping-Pong you have a few
critical points ( when the Dart or Ball is
thrown or hit ) but most of the time you don't
care what's going on ... the program calculates
the path of the ballistic object, determines where
it's going, what it's going to hit, when it's going
to 'arrive' and you just ignore everything until
the next collision occurs ( which you know in
advance ). With a Ping-Pong game I might have
to limit it so it can only be hit as passes it reaches
the end of table and then the player on the receiving
end has either placed his paddle in a position to
intercept it or not ... so I would be avoiding a
generalized interception problem of two moving
objects and reducing it to one object reaching a point
( at a known time and location ).

> i wrote a tankgame in VRML, and the random terrain
> generation has this effect since it is so complex. i did

> create a fake method of threading ( didn't try using Java


> threads, since my game was written using javascript ).
> db
>

Blaikie <david_...@hotmail.com> wrote

Java has support for threads by the way ... though
as you said the plug-in may want to handle events
sequentially and not concurrently.

I avoid using the Script node because it seems to
be less portable, and am shifting away from
interfacing to the plug-in, in part because as you
said for some thing it processes events one at time
when you'd like to have several things going on
simultaneously, and I think Java viewers with
built in support for multiple threads will give
me greater control, more options, and a better future.

I'm not saying you did anything wrong ...
think about Java ... it's a good solution for lots
of problems, not everything ... and some of my
stuff works with Java3D ( with an OpenGL layer )
so I could transition to Java3D Scene Graphs if
they offer better options than the ( basically similar )
VRML Scene Graph.

If I run into a wall, I'll change directions.

Someone recently posted this, it's about a
Robotics Combat Game where you design and
build your own Robot Warrier :

we have been creating a j3d Robotic construction/combat
game. We are now ready for beta testing. The beta test is open to the
public but I would like as many j3d programmers in it as possible : )

For a quick overview of the game check out :

http://pc.ign.com/news/21882.html

For the whole story and to register go to the main site :

www.roboforge.com

- - - - -

A neat idea, we will be seeing more stuff like that
in the future. The above uses Java3D and it can be
very tricky and I'm not really recomennding it ...

Andrew Jorgensen

unread,
Jul 15, 2000, 3:00:00 AM7/15/00
to
Thanks Blaikie, this is exactly the kind of information I was looking for.
I think I might start to use Java instead of JavaScript, at least for the more
complex stuff. It'll mean learning the Java vrml API, but I don't mind, I was
gonna learn it sooner or later anyway.
Are ROUTEs generally faster than Scripts? (Referring to the ability to
import the Node into the Script and manipulate it's values internally)

Many Thanks,
Andrew Jorgensen

Blaikie wrote:

> i can tel u this much. Scripts, java or otherwise aren't threaded. when an


> eventIn is received by a script the entire function (and any functions
> called by teh initial function) are given highest priority by the plugin.
> the browser will cease to function while processing is completed.

> i wrote a tankgame in VRML, and the random terrain generation has this
> effect since it is so complex. i did create a fake method of threading

> (didn't try using Java threads, since my game was written using javascript).
> db


Blaikie

unread,
Jul 16, 2000, 3:00:00 AM7/16/00
to
yes java is better, it is a programming language, etc. But with the
advantages of OOP etc, come the disadvantages of having to learn a very
complex programming problem and paradigm. I could write my game with little
knowledge of programming, all i needed to know was algorithm design (i had
only done Qbasic previously, and looked at Java, but couldn't get a handle
on it). OOP is not really required if the PROTO or EXTERNPROTO is used
correctly, or even juse using seperate Script nodes, does exactly the same
as OOP, it groups processes and variables together, precisely the aim of
OOP.
db

Blaikie

unread,
Jul 16, 2000, 3:00:00 AM7/16/00
to
when your refer to the capacity to map a SFNode, you are talking about
directOutput enabled script nodes. And no i can't tell u if there is any
speed difference, try running a world with a lot of them and c, i doubt the
difference would be significant, if any.
db

Evgeny Demidov

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Hi Andrew Jorgensen:

> I think I might start to use Java instead of JavaScript, at least for the more
> complex stuff. It'll mean learning the Java vrml API, but I don't mind, I was
> gonna learn it sooner or later anyway.

There is not very big difference in using Java or JavaScript really. I usually
start with JS (more simple for debugging) then (if I get "Out of memory" or it is
too slow) you can rewrite Script to Java. You can use Java sources from my pages
as examples
http://www.ipm.sci-nnov.ru/~DEMIDOV/VRML/

Evgeny


0 new messages