urdf-loader
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -7,2 +7,10 @@ # Changelog | ||
## [0.4.3] - 2018-10-10 | ||
### Added | ||
- Add `no-auto-recenter` field to the `urdf-viewer` web component. | ||
## [0.4.2] - 2018-08-19 | ||
### Added | ||
- Include `example/styles.css` | ||
## [0.4.1] - 2018-08-19 | ||
@@ -9,0 +17,0 @@ ### Changed |
@@ -156,4 +156,4 @@ /* globals animToggle viewer setColor */ | ||
setColor('#263238'); | ||
animToggle.classList.remove('checked'); | ||
window.animToggle.classList.remove('checked'); | ||
}); |
{ | ||
"name": "urdf-loader", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "URDF Loader for THREE.js and webcomponent viewer", | ||
@@ -43,3 +43,3 @@ "scripts": { | ||
"@webcomponents/webcomponentsjs": "^2.0.0", | ||
"eslint": "^5.3.0", | ||
"eslint": "^5.4.0", | ||
"jest": "^23.5.0", | ||
@@ -46,0 +46,0 @@ "jest-cli": "^23.5.0", |
# javascript urdf-loader | ||
[ | ||
![npm version](https://img.shields.io/npm/v/urdf-loader.svg?style=flat-square) | ||
](https://www.npmjs.com/package/urdf-loader) | ||
[ | ||
![travis build](https://img.shields.io/travis/gkjohnson/urdf-loaders.svg?style=flat-square) | ||
](https://travis-ci.org/gkjohnson/urdf-loaders) | ||
[ | ||
![lgtm code quality](https://img.shields.io/lgtm/grade/javascript/g/gkjohnson/urdf-loaders.svg?style=flat-square&label=code-quality) | ||
](https://lgtm.com/projects/g/gkjohnson/urdf-loaders/) | ||
[![npm version](https://img.shields.io/npm/v/urdf-loader.svg?style=flat-square)](https://www.npmjs.com/package/urdf-loader) | ||
[![travis build](https://img.shields.io/travis/gkjohnson/urdf-loaders.svg?style=flat-square)](https://travis-ci.org/gkjohnson/urdf-loaders) | ||
[![lgtm code quality](https://img.shields.io/lgtm/grade/javascript/g/gkjohnson/urdf-loaders.svg?style=flat-square&label=code-quality)](https://lgtm.com/projects/g/gkjohnson/urdf-loaders/) | ||
@@ -90,3 +84,3 @@ Utilities for loading URDF files into THREE.js and a Web Component that loads and renders the model. | ||
##### options.loadMeshCallback(pathToModel, fileExtension, onComplete) : Function | ||
##### options.loadMeshCb(pathToModel, fileExtension, onComplete) : Function | ||
@@ -261,2 +255,6 @@ An optional function that can be used to override the default mesh loading functionality. The default loader is specified at `URDFLoader.defaultMeshLoader`. `onComplete` is called with the mesh once the geometry has been loaded. | ||
#### no-auto-recenter | ||
Recenter the camera only after loading the model. | ||
### Properties | ||
@@ -284,2 +282,6 @@ | ||
#### recenter() | ||
Recenter the camera to the model and redraw. | ||
### Events | ||
@@ -286,0 +288,0 @@ |
@@ -41,2 +41,5 @@ /* globals THREE URDFLoader */ | ||
get noAutoRecenter() { return this.hasAttribute('no-auto-recenter') || false; } | ||
set noAutoRecenter(val) { val ? this.setAttribute('no-auto-recenter', true) : this.removeAttribute('no-auto-recenter'); } | ||
get loadingManager() { return this._loadingManager = this._loadingManager || new THREE.LoadingManager(); } | ||
@@ -124,3 +127,3 @@ | ||
controls.minDistance = 0.25; | ||
controls.addEventListener('change', () => this._dirty = true); | ||
controls.addEventListener('change', () => this.recenter()); | ||
@@ -139,3 +142,3 @@ this.scene = scene; | ||
// redraw when something new has loaded | ||
this.loadingManager.onLoad = () => this._dirty = true; | ||
this.loadingManager.onLoad = () => this.recenter(); | ||
@@ -150,4 +153,10 @@ const _renderLoop = () => { | ||
this._updateEnvironment(); | ||
if (!this.noAutoRecenter) { | ||
this._updateEnvironment(); | ||
} | ||
this.renderer.render(scene, camera); | ||
this._dirty = false; | ||
} | ||
@@ -159,9 +168,2 @@ | ||
if (this._dirty || this.autoRedraw) { | ||
this.renderer.render(scene, camera); | ||
this._dirty = false; | ||
} | ||
} | ||
@@ -215,3 +217,3 @@ this._renderLoopId = requestAnimationFrame(_renderLoop); | ||
this._dirty = true; | ||
this.recenter(); | ||
@@ -264,3 +266,3 @@ switch (attr) { | ||
this._dirty = true; | ||
this.recenter(); | ||
@@ -280,3 +282,9 @@ } | ||
this._dirty = true; | ||
} | ||
recenter() { | ||
this._updateEnvironment(); | ||
this.redraw(); | ||
} | ||
@@ -294,3 +302,3 @@ | ||
joint.setAngle(angle); | ||
this._dirty = true; | ||
this.redraw(); | ||
@@ -315,13 +323,16 @@ } | ||
if (!this.robot) return; | ||
this.world.updateMatrixWorld(); | ||
const bbox = new THREE.Box3().setFromObject(this.robot); | ||
const center = bbox.getCenter(new THREE.Vector3()); | ||
this.controls.target.y = center.y; | ||
this.plane.position.y = bbox.min.y - 1e-3; | ||
const dirLight = this.directionalLight; | ||
dirLight.castShadow = this.displayShadow; | ||
if (this.robot && this.displayShadow) { | ||
this.world.updateMatrixWorld(); | ||
if (this.displayShadow) { | ||
const bbox = new THREE.Box3().setFromObject(this.robot); | ||
const center = bbox.getCenter(new THREE.Vector3()); | ||
this.controls.target.y = center.y; | ||
this.plane.position.y = bbox.min.y - 1e-3; | ||
// Update the shadow camera rendering bounds to encapsulate the | ||
@@ -480,3 +491,3 @@ // model. We use the bounding sphere of the bounding box for | ||
this._dirty = true; | ||
this.recenter(); | ||
@@ -504,3 +515,3 @@ }, | ||
this._dirty = true; | ||
this.recenter(); | ||
@@ -507,0 +518,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73050
1436
329