Skip to content

Commit

Permalink
Nodejs compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhooper committed Oct 2, 2017
1 parent 34cc414 commit 808db12
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 53 deletions.
39 changes: 0 additions & 39 deletions Gruntfile.js

This file was deleted.

1 change: 0 additions & 1 deletion build/slice.0.1.0.min.js

This file was deleted.

13 changes: 10 additions & 3 deletions build/slice.0.1.0.js → build/slice.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
(function() {
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
window.sliceGeometry = require('./slice.js')(window.THREE);

},{"./slice.js":2}],2:[function(require,module,exports){
module.exports = function(THREE) {
"use strict";

var FRONT = 'front';
var BACK = 'back';
var STRADDLE = 'straddle';
var ON = 'on';

window.sliceGeometry = function(geom, plane) {
var sliceGeometry = function(geom, plane) {
var sliced = new THREE.Geometry();
var points;
var position;
Expand Down Expand Up @@ -158,4 +162,7 @@
return ON;
};

})();
return sliceGeometry;
};

},{}]},{},[1]);
1 change: 1 addition & 0 deletions build/slice.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
"name": "threejs-slice-geometry",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-copy": "^0.8.2",
"grunt-contrib-jasmine": "^0.9.2",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-uglify": "^0.11.0"
"three.js": "^0.73.0",
"browserify": "^14.4.0",
"jasmine": "^2.8.0",
"uglify-js": "^3.1.3"
},
"dependencies": {
"three.js": "^0.73.0"
"scripts": {
"test": "jasmine",
"build": "npm run clean && npm run browserify && npm run uglify",
"clean": "rm -rf build && mkdir build",
"browserify": "browserify src/browser.js -o build/slice.js",
"uglify": "uglifyjs build/slice.js -o build/slice.min.js"
}
}
11 changes: 11 additions & 0 deletions spec/support/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"spec_dir": "src/test",
"spec_files": [
"**/**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
1 change: 1 addition & 0 deletions src/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.sliceGeometry = require('./slice.js')(window.THREE);
7 changes: 4 additions & 3 deletions src/slice.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(function() {
module.exports = function(THREE) {
"use strict";

var FRONT = 'front';
var BACK = 'back';
var STRADDLE = 'straddle';
var ON = 'on';

window.sliceGeometry = function(geom, plane) {
var sliceGeometry = function(geom, plane) {
var sliced = new THREE.Geometry();
var points;
var position;
Expand Down Expand Up @@ -158,4 +158,5 @@
return ON;
};

})();
return sliceGeometry;
};
3 changes: 3 additions & 0 deletions src/test/slice.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var THREE = require('three');
var sliceGeometry = require('../slice.js')(THREE);

describe("three.js slice geometry", function() {
"use strict";

Expand Down

0 comments on commit 808db12

Please sign in to comment.