From cb3593b8a7bfcd9637fe931c600b5c01fe0d9f59 Mon Sep 17 00:00:00 2001 From: jywarren Date: Wed, 25 May 2016 23:39:53 -0400 Subject: [PATCH] fixed physics!!! --- dist/starsandcrafts-server.js | 25 +++++++------------------ server/index.html | 14 ++++++++++++-- src/StarsAndCrafts.Server.js | 2 +- src/things/StarsAndCrafts.Asteroid.js | 7 ------- src/things/StarsAndCrafts.Model.js | 3 --- src/things/StarsAndCrafts.Torpedo.js | 5 +---- 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/dist/starsandcrafts-server.js b/dist/starsandcrafts-server.js index 9ad60ff..4f9ccae 100644 --- a/dist/starsandcrafts-server.js +++ b/dist/starsandcrafts-server.js @@ -56825,6 +56825,7 @@ module.exports = SC.Interface = Class.extend({ }); },{"peerjs":6,"three":18}],22:[function(require,module,exports){ +(function (global){ StarsAndCrafts = SC = {}; module.exports = SC; @@ -56833,7 +56834,7 @@ var Class = require('resig-class'), THREE = require('three'); // inject Three.js -var Physijs = require('physijs-browserify')(THREE); +global.Physijs = require('physijs-browserify')(THREE); Physijs.scripts.worker = '../../node_modules/physijs-browserify/libs/physi-worker.js'; Physijs.scripts.ammo = 'ammo.js'; @@ -56928,6 +56929,7 @@ SC.Server = Class.extend({ }); +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./StarsAndCrafts.Cosmos.js":19,"./StarsAndCrafts.Events.js":20,"./StarsAndCrafts.Interface.js":21,"./Util.js":23,"./things/StarsAndCrafts.Asteroid.js":25,"./things/StarsAndCrafts.Comet.js":26,"./things/StarsAndCrafts.Model.js":27,"./things/StarsAndCrafts.Star.js":28,"./things/StarsAndCrafts.Thing.js":29,"./things/StarsAndCrafts.Torpedo.js":30,"jquery":1,"physijs-browserify":14,"resig-class":15,"three":18,"three-fly-controls":16}],23:[function(require,module,exports){ module.exports = { @@ -57481,13 +57483,6 @@ THREE.GPUParticleContainer.prototype.constructor = THREE.GPUParticleContainer; },{"three":18}],25:[function(require,module,exports){ var THREE = require('three'); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - -Physijs.scripts.worker = '../../node_modules/physijs-browserify/libs/physi-worker.js'; -Physijs.scripts.ammo = 'ammo.js'; - - module.exports = StarsAndCrafts.Thing.extend({ // for now, Objects are just mesh. @@ -57549,7 +57544,7 @@ module.exports = StarsAndCrafts.Thing.extend({ }); -},{"physijs-browserify":14,"three":18}],26:[function(require,module,exports){ +},{"three":18}],26:[function(require,module,exports){ var THREE = require('three'); THREE.GPUParticleSystem = require('./../lib/GPUParticleSystem.js'); @@ -57632,9 +57627,6 @@ module.exports = StarsAndCrafts.Thing.extend({ var THREE = require('three'); THREE.STLLoader = require('three-stl-loader')(THREE); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - module.exports = StarsAndCrafts.Model = Class.extend({ @@ -57689,7 +57681,7 @@ module.exports = StarsAndCrafts.Model = Class.extend({ }); -},{"physijs-browserify":14,"three":18,"three-stl-loader":17}],28:[function(require,module,exports){ +},{"three":18,"three-stl-loader":17}],28:[function(require,module,exports){ var THREE = require('three'); module.exports = Class.extend({ @@ -57806,9 +57798,6 @@ module.exports = Class.extend({ var THREE = require('three'), Class = require('resig-class'); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - module.exports = StarsAndCrafts.Thing.extend({ init: function(_server, options) { @@ -57828,7 +57817,7 @@ module.exports = StarsAndCrafts.Thing.extend({ _server.transparentMaterial = _server.transparentMaterial || new THREE.MeshLambertMaterial({ color: 0xaaaa00, - opacity: .5, + opacity: 0, transparent: true }); _server.transparentMaterial.depthWrite = false; @@ -57916,4 +57905,4 @@ module.exports = StarsAndCrafts.Thing.extend({ }); -},{"physijs-browserify":14,"resig-class":15,"three":18}]},{},[22]); +},{"resig-class":15,"three":18}]},{},[22]); diff --git a/server/index.html b/server/index.html index f0bdd97..8d0499e 100644 --- a/server/index.html +++ b/server/index.html @@ -49,12 +49,22 @@ var server = new StarsAndCrafts.Server(); - torpedo = new SC.Torpedo(server); - SC.Scenarios['asteroids'](server); + torpedo = new SC.Torpedo(server); + SC.Scenarios['eros'](server); + setInterval(function() { + + torpedo.mesh.setLinearVelocity({ + x: Math.sin(server.clock.elapsedTime / 3), + y: Math.cos(server.clock.elapsedTime / 3), + z: 0 + }); + + },50); + diff --git a/src/StarsAndCrafts.Server.js b/src/StarsAndCrafts.Server.js index 7897c9b..fe8ed4f 100644 --- a/src/StarsAndCrafts.Server.js +++ b/src/StarsAndCrafts.Server.js @@ -6,7 +6,7 @@ var Class = require('resig-class'), THREE = require('three'); // inject Three.js -var Physijs = require('physijs-browserify')(THREE); +global.Physijs = require('physijs-browserify')(THREE); Physijs.scripts.worker = '../../node_modules/physijs-browserify/libs/physi-worker.js'; Physijs.scripts.ammo = 'ammo.js'; diff --git a/src/things/StarsAndCrafts.Asteroid.js b/src/things/StarsAndCrafts.Asteroid.js index 282648a..3899a3f 100644 --- a/src/things/StarsAndCrafts.Asteroid.js +++ b/src/things/StarsAndCrafts.Asteroid.js @@ -1,12 +1,5 @@ var THREE = require('three'); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - -Physijs.scripts.worker = '../../node_modules/physijs-browserify/libs/physi-worker.js'; -Physijs.scripts.ammo = 'ammo.js'; - - module.exports = StarsAndCrafts.Thing.extend({ // for now, Objects are just mesh. diff --git a/src/things/StarsAndCrafts.Model.js b/src/things/StarsAndCrafts.Model.js index 6efaaa2..e75ea6f 100644 --- a/src/things/StarsAndCrafts.Model.js +++ b/src/things/StarsAndCrafts.Model.js @@ -1,9 +1,6 @@ var THREE = require('three'); THREE.STLLoader = require('three-stl-loader')(THREE); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - module.exports = StarsAndCrafts.Model = Class.extend({ diff --git a/src/things/StarsAndCrafts.Torpedo.js b/src/things/StarsAndCrafts.Torpedo.js index b76d41f..6324eaf 100644 --- a/src/things/StarsAndCrafts.Torpedo.js +++ b/src/things/StarsAndCrafts.Torpedo.js @@ -1,9 +1,6 @@ var THREE = require('three'), Class = require('resig-class'); -// inject Three.js -var Physijs = require('physijs-browserify')(THREE); - module.exports = StarsAndCrafts.Thing.extend({ init: function(_server, options) { @@ -23,7 +20,7 @@ module.exports = StarsAndCrafts.Thing.extend({ _server.transparentMaterial = _server.transparentMaterial || new THREE.MeshLambertMaterial({ color: 0xaaaa00, - opacity: .5, + opacity: 0, transparent: true }); _server.transparentMaterial.depthWrite = false;