Skip to content

Commit

Permalink
Added Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpoeter committed Jan 9, 2023
1 parent 4313fbd commit 4c45609
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# 🚀 Welcome to your new awesome project!
# Poky.ts

This project has been created using **webpack-cli**, you can now run
Poky is a simple 3D 3DOF (Degrees of Freedom) Robotic Arm with inverse kinematic calculations.

## Install

```
npm run build
npm install poky.ts
```

or
or

```
yarn build
git clone https://github.com/cloud-automation/poky.ts
cd poky.ts
npm install
npm run serve
```


## Embed

```
import Poky from 'poky.ts'
/* instantiate poky with a dom element id like '#sandbox' */
const poky = new Poky('sandbox')
## License
MIT
to bundle your application
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}

#overlay {
display:none;
position:fixed;
inset: 0;
box-sizing: border-box;
Expand All @@ -40,7 +41,7 @@
}

#app, #app * {

display:none;
pointer-events: none;
user-select: none;

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"description": "Poky Table Robot Arm",
"name": "poky",
"main": "dist/poky.js",
"types": "dist/index.d.ts",
"module": "src/index.js",
"license": "MIT",
"scripts": {
"build": "webpack --mode=production --node-env=production",
"build:dev": "webpack --mode=development",
Expand Down
31 changes: 15 additions & 16 deletions src/poky.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import utils from './utils'
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import Robot, { Config as RobotConfig } from './robot'
import PointerModel, { Config as PointerConfig } from './models/pointer'
import InvKin from './invkin'
Expand All @@ -12,7 +12,8 @@ export type Config = {
type: 'relative' | 'absolute',
x: number,
y: number
}
},
showHelper: boolean
}

export default class Poky {
Expand Down Expand Up @@ -42,7 +43,8 @@ export default class Poky {
type: 'relative',
x: 0,
y: 1
}
},
showHelper: true
}
} else {
this._config = config
Expand Down Expand Up @@ -76,7 +78,7 @@ export default class Poky {
this._animate();


this._initScene();
this._initScene(this._config.showHelper);

/* initiate robot */

Expand Down Expand Up @@ -115,15 +117,15 @@ export default class Poky {
firstArc: {
bigRadius: 9,
smallRadius: 6,
length: maxRadius * 1.1,
length: 40, //maxRadius * 1.1,
depth: 4 ,
socketRadius: 1,
distance: 8
},
nextArcs: [
{
smallRadius: 4,
length: maxRadius * 1.1,
length: 40, // maxRadius * 1.1,
},
{
smallRadius: 3,
Expand All @@ -137,18 +139,18 @@ export default class Poky {
this._invkin = new InvKin(this._robot)

// initial position
this._robot.angles = [ -1/4 * Math.PI, 1/2 * Math.PI, 0, 0 ]
this._robot.angles = [ -1/4 * Math.PI, 1/2 * Math.PI, 1/2 * Math.PI, 1/2 * Math.PI ]
this._scene.add( this._robot );


// setup events
this._rootElement.addEventListener('touchstart', this.mouseUpdate.bind(this))
/* this._rootElement.addEventListener('touchstart', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('touchend', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('touchmove', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('mousedown', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('mouseup', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('mousemove', this.mouseUpdate.bind(this))
this._rootElement.addEventListener('mousemove', this.mouseUpdate.bind(this)) */

}

Expand Down Expand Up @@ -233,10 +235,10 @@ export default class Poky {

if (showHelper) {

const helperA = new THREE.GridHelper( 160, 100 );
/* const helperA = new THREE.GridHelper( 160, 100 );
helperA.rotation.x = Math.PI / 2;
this._scene.add(helperA)
this._scene.add(helperA) */

const helperB = new THREE.GridHelper( 160, 100 );
helperB.rotation.y = Math.PI / 2;
Expand All @@ -246,12 +248,9 @@ export default class Poky {
const axesHelper = new THREE.AxesHelper( 100 );
this._scene.add( axesHelper );

}

if (showHelper) {
const controls = new OrbitControls( this._camera, this._renderer.domElement );
controls.minDistance = 10;
controls.maxDistance = 1000;
controls.update();

}

}
Expand Down

0 comments on commit 4c45609

Please sign in to comment.