0
网络游戏
我试图用physijs做一个简单的网络在线游戏和Node.js的与three.js所,physijs和Node.js的
我发现了一个相关的源从这里(https://github.com/jjoe64/nodejs-physijs)
以下是我想要使用的基本服务器端代码。
'use strict';
var THREE = 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();
})();
的问题是,我这样的Node.js和socket.io的初学者,所以我不知道如何从这个服务器端代码到客户端的视口导入现场。 有没有客户端的示例代码?或者我如何使用套接字从服务器发送到客户端的场景信息?我如何显示它们?