Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cylinder axis orientation, update deps, bump version to 0.10.0 #30

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dist/cannon-es.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8355,10 +8355,10 @@ var Cylinder = /*#__PURE__*/function (_ConvexPolyhedron) {
var cos = Math.cos;
var sin = Math.sin; // First bottom point

vertices.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), -height * 0.5));
vertices.push(new Vec3(radiusBottom * cos(0), -height * 0.5, -radiusBottom * sin(0)));
bottomface.push(0); // First top point

vertices.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), height * 0.5));
vertices.push(new Vec3(radiusTop * cos(0), height * 0.5, -radiusTop * sin(0)));
topface.push(1);

for (var i = 0; i < N; i++) {
Expand All @@ -8367,10 +8367,10 @@ var Cylinder = /*#__PURE__*/function (_ConvexPolyhedron) {

if (i < N - 1) {
// Bottom
vertices.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), -height * 0.5));
vertices.push(new Vec3(radiusBottom * cos(theta), -height * 0.5, -radiusBottom * sin(theta)));
bottomface.push(2 * i + 2); // Top

vertices.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), height * 0.5));
vertices.push(new Vec3(radiusTop * cos(theta), height * 0.5, -radiusTop * sin(theta)));
topface.push(2 * i + 3); // Face

faces.push([2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i]);
Expand All @@ -8380,12 +8380,12 @@ var Cylinder = /*#__PURE__*/function (_ConvexPolyhedron) {


if (N % 2 === 1 || i < N / 2) {
axes.push(new Vec3(cos(thetaN), sin(thetaN), 0));
axes.push(new Vec3(cos(thetaN), 0, -sin(thetaN)));
}
}

faces.push(topface);
axes.push(new Vec3(0, 0, 1)); // Reorder bottom face
axes.push(new Vec3(0, 1, 0)); // Reorder bottom face

var temp = [];

Expand Down
12 changes: 6 additions & 6 deletions dist/cannon-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -7764,10 +7764,10 @@ class Cylinder extends ConvexPolyhedron {
const cos = Math.cos;
const sin = Math.sin; // First bottom point

vertices.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), -height * 0.5));
vertices.push(new Vec3(radiusBottom * cos(0), -height * 0.5, -radiusBottom * sin(0)));
bottomface.push(0); // First top point

vertices.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), height * 0.5));
vertices.push(new Vec3(radiusTop * cos(0), height * 0.5, -radiusTop * sin(0)));
topface.push(1);

for (let i = 0; i < N; i++) {
Expand All @@ -7776,10 +7776,10 @@ class Cylinder extends ConvexPolyhedron {

if (i < N - 1) {
// Bottom
vertices.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), -height * 0.5));
vertices.push(new Vec3(radiusBottom * cos(theta), -height * 0.5, -radiusBottom * sin(theta)));
bottomface.push(2 * i + 2); // Top

vertices.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), height * 0.5));
vertices.push(new Vec3(radiusTop * cos(theta), height * 0.5, -radiusTop * sin(theta)));
topface.push(2 * i + 3); // Face

faces.push([2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i]);
Expand All @@ -7789,12 +7789,12 @@ class Cylinder extends ConvexPolyhedron {


if (N % 2 === 1 || i < N / 2) {
axes.push(new Vec3(cos(thetaN), sin(thetaN), 0));
axes.push(new Vec3(cos(thetaN), 0, -sin(thetaN)));
}
}

faces.push(topface);
axes.push(new Vec3(0, 0, 1)); // Reorder bottom face
axes.push(new Vec3(0, 1, 0)); // Reorder bottom face

const temp = [];

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cannon-es",
"version": "0.9.1",
"version": "0.10.0",
"description": "A lightweight 3D physics engine written in JavaScript.",
"homepage": "https://github.com/schteppe/cannon.js",
"author": "Stefan Hedman <[email protected]> (http://steffe.se)",
Expand Down Expand Up @@ -44,20 +44,20 @@
}
],
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-typescript": "^7.9.0",
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@babel/preset-typescript": "^7.10.1",
"gh-pages": "^2.2.0",
"husky": "^4.2.3",
"prettier": "^2.0.2",
"husky": "^4.2.5",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.2",
"rollup": "^2.2.0",
"rollup": "^2.15.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-size-snapshot": "^0.11.0",
"typescript": "^3.8.3"
"rollup-plugin-size-snapshot": "^0.12.0",
"typescript": "^3.9.5"
}
}
12 changes: 6 additions & 6 deletions src/shapes/Cylinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ export class Cylinder extends ConvexPolyhedron {
const sin = Math.sin

// First bottom point
vertices.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), -height * 0.5))
vertices.push(new Vec3(radiusBottom * cos(0), -height * 0.5, -radiusBottom * sin(0)))
bottomface.push(0)

// First top point
vertices.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), height * 0.5))
vertices.push(new Vec3(radiusTop * cos(0), height * 0.5, -radiusTop * sin(0)))
topface.push(1)

for (let i = 0; i < N; i++) {
const theta = ((2 * Math.PI) / N) * (i + 1)
const thetaN = ((2 * Math.PI) / N) * (i + 0.5)
if (i < N - 1) {
// Bottom
vertices.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), -height * 0.5))
vertices.push(new Vec3(radiusBottom * cos(theta), -height * 0.5, -radiusBottom * sin(theta)))
bottomface.push(2 * i + 2)
// Top
vertices.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), height * 0.5))
vertices.push(new Vec3(radiusTop * cos(theta), height * 0.5, -radiusTop * sin(theta)))
topface.push(2 * i + 3)

// Face
Expand All @@ -49,11 +49,11 @@ export class Cylinder extends ConvexPolyhedron {

// Axis: we can cut off half of them if we have even number of segments
if (N % 2 === 1 || i < N / 2) {
axes.push(new Vec3(cos(thetaN), sin(thetaN), 0))
axes.push(new Vec3(cos(thetaN), 0, -sin(thetaN)))
}
}
faces.push(topface)
axes.push(new Vec3(0, 0, 1))
axes.push(new Vec3(0, 1, 0))

// Reorder bottom face
const temp = []
Expand Down
Loading