Jump to content

[BJS vs. 3JS] Spinning Cube - Test 1


3Dlove
 Share

Recommended Posts

Hello guys,

 

I am coding demos in order to compare BJS and 3JS :)

 

Here is my first demo :

 

 

I'll put online the following demos on the next week ;)

 

 

To begin, I've some questions :

 

1- Why BJS FPS have an average of 10 FPS less than 3JS ? (tests on IE with just 1 tab : BJS ~47, 3JS ~57)

 

2- Do we need to do a similar function to

"renderer.setPixelRatio( window.devicePixelRatio );    // to keep same scale, dimensions ratio on mobile device"

under BJS?

 

3- Is perspective camera of 3JS = free camera of BJS ?

 

4- How edit my onWindowResize function in order to have the same results with BJS as 3JS ?

 

Have a nice night

Link to comment
Share on other sites

Hello,

1- 2- 3-
OK thanks :)

4-
My onWindowResize function is located in functions.js file.
In 3JS, if user zoom on page with Ctrl Key and mouse wheel, the scene is drawing again and keep the same size and positions at screen.
I would like to know how to do the same with BJS.


5- For me, I need engine.setSize( width, height );
because I didn't put height and width canvas's attributes.
I tried without setSize and with that :
    <canvas id="canvas" width="100%" height="100%"></canvas>
but that doesn't work, it's like I put 100px instead of 100%.


6- There something that I don't understand : Why do we need to name Meshes ? What is the goal of that ?


I began a comparaison : http://martinstosch.free.fr/3JS%20vs%20BJS.html

Link to comment
Share on other sites

4. use engine.setHardwareScalingLevel(1.0 / (window.devicePixelRatio || 1.0))

 

5. HUm that *should* work :) This is what engine.resize is doing:

public resize(): void {            this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);        }

With setSize = 

public setSize(width: number, height: number): void {            this._renderingCanvas.width = width;            this._renderingCanvas.height = height;            this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();        }

6. You do not have to actually. You can leave this value to null or whatever. The engine does not need it. But this is for you. You can then find a mesh by Name with scene.getMeshByName, or by ID (generated by the engine and unique) with scene.getMeshById or even through the tag system (http://doc.babylonjs.com/page.php?p=22521

Link to comment
Share on other sites

Ok for 6 =)

Here is an example :
http://martinstosch.free.fr/example1.html

(you can download it with librarys here : http://martinstosch.free.fr/example1.zip)

7- How to have an fullscreen window (with others element) and not just a fullscreen canvas ?
I tried something by mixing with Threex, you can see it in my example, but the problem is that the camera isn't replacing at center in fullscreen mode and the canvas doesn't resize with the entire height of the screen (black part at the botoom)

you can see the problem in attached pictures.
 

post-13247-0-20276300-1425823843_thumb.p

post-13247-0-06304700-1425823848_thumb.p

Link to comment
Share on other sites

Hi guys... I did a little experimenting with this, too.

http://playground.babylonjs.com/#24AC3D

The 'p' key seems to be working correctly for the playground version of the demo.  (You might have to click on the canvas before using the 'p' key.)  Grab a zip, take it home, test it there, 3dLove.

This doesn't mean it will work for your project, 3DL, but it should, and you won't need any "THREE" libraries.  :)

Ok, that's all the information I have on this, so far.  Party on, and keep us posted on your discoveries, 3dLove.  (thx)

Link to comment
Share on other sites

Why do you use the features of ThreeJS knowing that you can do with BabylonJS
 

// CSShtml, body {    overflow: hidden;    width: 100%;    height: 100%;    margin: 0;    padding: 0;    position:fixed;}canvas {    width: 100%;    height: 100%;    position:fixed;    overflow: hidden;}//JSwindow.addEventListener("resize", function () {    engine.resize();}, false);
Link to comment
Share on other sites

:)  If an 11 yr old Haitian girl, who gets to use a computer for 3 hours every Sunday morning to come to our forum and be with us... started crying uncontrollably and commits suicide today...  well... you know.  (nah, that won't happen).  :)

 

And you didn't even say "hi".  haha

Link to comment
Share on other sites

Hello guys,

 

Thanks a lot =)

 

The problem was that I used :

<canvas id="canvas" width="100%" height="100%"></canvas>

instead of :

<canvas id="canvas" style="width: 100%; height: 100%"></canvas>

The second problem is that I want a WINDOW fullscreen (with the others DOM element) and not just a CANVAS fullscreen.

 

That's work with my first's problem's correction mixed with THREEx.FullScreen.js, but if you have a better solution to do WINDOW fullscreen, I would be very glad =)

Link to comment
Share on other sites

@3DLove

 

This is confusing but the HTML5 canvas element has width and height properties expressed in pixels. No need to add 'px'. Default values are 300 x 150 pixels.

If you don't specify any other size in the CSS style attributes, the canvas will be sized with these values.

Now, if you add some CSS size properties, for example expressed in percentage of canvas element container (div or body), this percentage will then applied to the initial values.

 

Thus you can define a 640x480 px canvas and stretch it 100% of the browser windows whatever its size, or stretch if even full screen.

 

This is a famous way for 2D games : compute everything lower resolution (so faster) and let the browser interpolate to bigger resolution with acceptable accuracy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...