Skip to content

Commit 66c1915

Browse files
committed
WIP.
1 parent 0b1e070 commit 66c1915

29 files changed

+1345
-2033
lines changed

build/physics-module.js

Lines changed: 390 additions & 690 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/physics-module.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/physics-module.min.js

Lines changed: 133 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/physics-module.module.js

Lines changed: 399 additions & 699 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/physics-module.module.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"start": "rollup -c -w -m inline",
9-
"build": "webpack"
9+
"build": "del build/*.js && cross-env NODE_ENV=production rollup -c && npm run minify",
10+
"minify": "java -jar node_modules/google-closure-compiler/compiler.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --language_in=ECMASCRIPT6_STRICT --externs tools/build/externs.js --js build/physics-module.js --js_output_file build/physics-module.min.js"
1011
},
1112
"repository": {
1213
"type": "git",
@@ -35,6 +36,7 @@
3536
"babel-register": "^6.18.0",
3637
"del": "^2.2.2",
3738
"express": "^4.14.0",
39+
"google-closure-compiler": "^20170910.0.0",
3840
"gulp": "^3.9.1",
3941
"rollup-plugin-babel": "^3.0.2",
4042
"rollup-plugin-commonjs": "^8.2.4",

rollup.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ export default {
6060
preferConst: true
6161
}),
6262
replace({'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)}),
63-
serve({
64-
contentBase: ['build', './'],
65-
port: 8001
66-
}),
63+
...(process.env.NODE_ENV == 'production' ? [] : [
64+
serve({
65+
contentBase: ['build', './'],
66+
port: 8001
67+
})
68+
]),
6769
],
6870

6971
targets: [

src/api.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,31 @@ const convertWorldPositionToObject = (position, object) => {
6868
const addObjectChildren = function (parent, object) {
6969
for (let i = 0; i < object.children.length; i++) {
7070
const child = object.children[i];
71-
const _physijs = child.component._physijs;
71+
const physics = child.component ? child.component.use('physics') : false;
72+
73+
if (physics) {
74+
const data = physics.data;
7275

73-
if (_physijs) {
7476
child.updateMatrix();
7577
child.updateMatrixWorld();
7678

7779
temp1Vector3.setFromMatrixPosition(child.matrixWorld);
7880
temp1Quat.setFromRotationMatrix(child.matrixWorld);
7981

80-
_physijs.position_offset = {
82+
data.position_offset = {
8183
x: temp1Vector3.x,
8284
y: temp1Vector3.y,
8385
z: temp1Vector3.z
8486
};
8587

86-
_physijs.rotation = {
88+
data.rotation = {
8789
x: temp1Quat.x,
8890
y: temp1Quat.y,
8991
z: temp1Quat.z,
9092
w: temp1Quat.w
9193
};
9294

93-
parent.component._physijs.children.push(_physijs);
95+
parent.component.use('physics').data.children.push(data);
9496
}
9597

9698
addObjectChildren(parent, child);

src/constraints/ConeTwistConstraint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export class ConeTwistConstraint {
1010
this.type = 'conetwist';
1111
this.appliedImpulse = 0;
1212
this.worldModule = null; // Will be redefined by .addConstraint
13-
this.objecta = objecta._physijs.id;
13+
this.objecta = objecta.use('physics').data.id;
1414
this.positiona = convertWorldPositionToObject(position, objecta).clone();
15-
this.objectb = objectb._physijs.id;
15+
this.objectb = objectb.use('physics').data.id;
1616
this.positionb = convertWorldPositionToObject(position, objectb).clone();
1717
this.axisa = {x: objecta.rotation.x, y: objecta.rotation.y, z: objecta.rotation.z};
1818
this.axisb = {x: objectb.rotation.x, y: objectb.rotation.y, z: objectb.rotation.z};

0 commit comments

Comments
 (0)