Wednesday 15 September 2010

javascript - Online game with THREE.js, physijs and Node.js -



javascript - Online game with THREE.js, physijs and Node.js -

i'm trying create simple web online game using physijs , node.js

i found related source here (https://github.com/jjoe64/nodejs-physijs)

and below basic server-side code want use.

'use strict'; var 3 = require('./libs/three.js'); var ammo = require('./libs/ammo.js'); var physijs = require('./libs/physi.js')(three, ammo); ///////////////// // game var initscene, render, renderer, scene, camera, box_falling; initscene = function() { scene = new physijs.scene; // box box_falling = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x888888 }) ); scene.add( box_falling ); // box var box = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x880088 }), 0 ); box.position.y = -20; scene.add( box ); settimeout( render, 200 ); }; render = function() { scene.simulate(); // run physics settimeout( render, 200 ); }; ////////////////// // web socket var io = require('socket.io').listen(8088); (function() { io.sockets.on('connection', function (socket) { console.log('client conneted'); }); // start physijs scene initscene(); })();

the problem is, beginner of node.js , socket.io, not know how import scene server-side code client's viewport. there client-side sample code of this? or how can emit scene info server client using sockets? how can display them?

you should have physics beingness calculated on server side , client side in synchronizedream way, , render scene date on client side. take @ source ironbane.

javascript node.js three.js physijs

No comments:

Post a Comment