Socket
Socket
Sign inDemoInstall

urdf-loader

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urdf-loader - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

8

CHANGELOG.md

@@ -7,2 +7,6 @@ # Changelog

## [0.6.3] - 2019-06-28
### Added
- Support for parsing collision nodes.
## [0.6.2] - 2019-04-18

@@ -15,3 +19,3 @@ ### Added

- Continuous joints not being able to rotate.
- Always parse joint angles to numbers
- Always parse joint angles to numbers.

@@ -27,3 +31,3 @@ ## [0.6.0] - 2019-02-23

- The root link is now the same as the URDF Robot object.
- Moved the `packages` parameter to the options object
- Moved the `packages` parameter to the options object.

@@ -30,0 +34,0 @@ ### Removed

@@ -74,2 +74,3 @@ /* globals viewer THREE */

let originalNoAutoRecenter;
viewer.addEventListener('manipulate-start', e => {

@@ -83,4 +84,13 @@

originalNoAutoRecenter = viewer.noAutoRecenter;
viewer.noAutoRecenter = true;
});
viewer.addEventListener('manipulate-end', e => {
viewer.noAutoRecenter = originalNoAutoRecenter;
});
// create the sliders

@@ -87,0 +97,0 @@ viewer.addEventListener('urdf-processed', () => {

{
"name": "urdf-loader",
"version": "0.6.2",
"version": "0.6.3",
"description": "URDF Loader for THREE.js and webcomponent viewer",

@@ -5,0 +5,0 @@ "main": "umd/URDFLoader.js",

@@ -34,3 +34,2 @@ # javascript urdf-loader

- Only `prismatic`, `continuous`, `revolute`, and `fixed` joints are supported.
- Collision tags are not parsed.

@@ -97,3 +96,3 @@ ## URDFLoader API

##### workingPath : String
##### options.workingPath : String

@@ -104,2 +103,10 @@ The path to load geometry relative to.

##### options.parseVisual : Boolean
An optional value that can be used to enable / disable loading meshes for links from the `visual` nodes. Defaults to true.
##### options.parseCollision : Boolean
An optional value that can be used to enable / disable loading meshes for links from the `collision` nodes. Defaults to false.
### parse(urdfContent, options) : THREE.Object3D

@@ -106,0 +113,0 @@

@@ -88,3 +88,2 @@ import * as THREE from 'three';

dirLight.castShadow = true;
dirLight.shadow.bias = -0.00001;
scene.add(dirLight);

@@ -125,3 +124,2 @@ scene.add(dirLight.target);

controls.enableZoom = true;
controls.enablePan = false;
controls.enableDamping = false;

@@ -318,3 +316,25 @@ controls.maxDistance = 50;

const bbox = new THREE.Box3().setFromObject(this.robot);
const bbox = new THREE.Box3();
const temp = new THREE.Box3();
this.robot.traverse(c => {
const geometry = c.geometry;
if (geometry) {
if (geometry.boundingBox === null) {
geometry.computeBoundingBox();
}
temp.copy(geometry.boundingBox);
temp.applyMatrix4(c.matrixWorld);
bbox.union(temp);
}
});
const center = bbox.getCenter(new THREE.Vector3());

@@ -420,4 +440,2 @@ this.controls.target.y = center.y;

m.shadowSide = THREE.DoubleSide;
return m;

@@ -424,0 +442,0 @@

import { Object3D, Vector3 } from 'three';
export class URDFCollider extends Object3D {
isURDFCollider: true;
}
export class URDFLink extends Object3D {

@@ -4,0 +10,0 @@

import { Object3D, Quaternion } from 'three';
function URDFColliderClone(...args) {
const proto = Object.getPrototypeOf(this);
const result = proto.clone.call(this, ...args);
result.isURDFCollider = true;
return result;
};
function makeURDFCollider(object) {
object.isURDFCollider = true;
object.clone = URDFColliderClone;
}
class URDFLink extends Object3D {

@@ -249,2 +265,2 @@

export { URDFRobot, URDFLink, URDFJoint };
export { URDFRobot, URDFLink, URDFJoint, makeURDFCollider };
import * as THREE from 'three';
import { STLLoader } from 'three/examples/js/loaders/STLLoader';
import { ColladaLoader } from 'three/examples/js/loaders/ColladaLoader';
import { URDFRobot, URDFJoint, URDFLink } from './URDFClasses.js';
import { URDFRobot, URDFJoint, URDFLink, makeURDFCollider } from './URDFClasses.js';

@@ -76,3 +76,5 @@ /*

options = Object.assign({ workingPath }, options);
options = Object.assign({
workingPath,
}, options);

@@ -105,2 +107,4 @@ manager.itemStart(urdfPath);

const workingPath = options.workingPath || '';
const parseVisual = ('parseVisual' in options) ? options.parseVisual : true;
const parseCollision = options.parseCollision || false;
const manager = this.manager;

@@ -284,7 +288,13 @@ const linkMap = {};

const children = [ ...link.children ];
const visualNodes = children.filter(n => n.nodeName.toLowerCase() === 'visual');
target.name = link.getAttribute('name');
target.urdfNode = link;
visualNodes.forEach(vn => processVisualNode(vn, target, materialMap));
if (parseVisual) {
const visualNodes = children.filter(n => n.nodeName.toLowerCase() === 'visual');
visualNodes.forEach(vn => processLinkElement(vn, target, materialMap));
}
if (parseCollision) {
const collisionNodes = children.filter(n => n.nodeName.toLowerCase() === 'collision');
collisionNodes.forEach(vn => processLinkElement(vn, target));
}

@@ -330,5 +340,6 @@ return target;

// Process the visual nodes into meshes
function processVisualNode(vn, linkObj, materialMap) {
// Process the visual and collision nodes into meshes
function processLinkElement(vn, linkObj, materialMap = {}) {
const isCollisionNode = vn.nodeName.toLowerCase() === 'collision';
let xyz = [0, 0, 0];

@@ -409,2 +420,8 @@ let rpy = [0, 0, 0];

if (isCollisionNode) {
makeURDFCollider(obj);
}
}

@@ -427,2 +444,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
} else if (geoType === 'sphere') {

@@ -439,2 +462,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
} else if (geoType === 'cylinder') {

@@ -453,2 +482,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
}

@@ -455,0 +490,0 @@

@@ -91,3 +91,2 @@ (function (global, factory) {

dirLight.castShadow = true;
dirLight.shadow.bias = -0.00001;
scene.add(dirLight);

@@ -128,3 +127,2 @@ scene.add(dirLight.target);

controls.enableZoom = true;
controls.enablePan = false;
controls.enableDamping = false;

@@ -321,3 +319,25 @@ controls.maxDistance = 50;

const bbox = new THREE.Box3().setFromObject(this.robot);
const bbox = new THREE.Box3();
const temp = new THREE.Box3();
this.robot.traverse(c => {
const geometry = c.geometry;
if (geometry) {
if (geometry.boundingBox === null) {
geometry.computeBoundingBox();
}
temp.copy(geometry.boundingBox);
temp.applyMatrix4(c.matrixWorld);
bbox.union(temp);
}
});
const center = bbox.getCenter(new THREE.Vector3());

@@ -423,4 +443,2 @@ this.controls.target.y = center.y;

m.shadowSide = THREE.DoubleSide;
return m;

@@ -427,0 +445,0 @@

@@ -7,2 +7,18 @@ (function (global, factory) {

function URDFColliderClone(...args) {
const proto = Object.getPrototypeOf(this);
const result = proto.clone.call(this, ...args);
result.isURDFCollider = true;
return result;
}
function makeURDFCollider(object) {
object.isURDFCollider = true;
object.clone = URDFColliderClone;
}
class URDFLink extends THREE.Object3D {

@@ -323,3 +339,5 @@

options = Object.assign({ workingPath }, options);
options = Object.assign({
workingPath,
}, options);

@@ -352,2 +370,4 @@ manager.itemStart(urdfPath);

const workingPath = options.workingPath || '';
const parseVisual = ('parseVisual' in options) ? options.parseVisual : true;
const parseCollision = options.parseCollision || false;
const manager = this.manager;

@@ -531,7 +551,13 @@ const linkMap = {};

const children = [ ...link.children ];
const visualNodes = children.filter(n => n.nodeName.toLowerCase() === 'visual');
target.name = link.getAttribute('name');
target.urdfNode = link;
visualNodes.forEach(vn => processVisualNode(vn, target, materialMap));
if (parseVisual) {
const visualNodes = children.filter(n => n.nodeName.toLowerCase() === 'visual');
visualNodes.forEach(vn => processLinkElement(vn, target, materialMap));
}
if (parseCollision) {
const collisionNodes = children.filter(n => n.nodeName.toLowerCase() === 'collision');
collisionNodes.forEach(vn => processLinkElement(vn, target));
}

@@ -577,5 +603,6 @@ return target;

// Process the visual nodes into meshes
function processVisualNode(vn, linkObj, materialMap) {
// Process the visual and collision nodes into meshes
function processLinkElement(vn, linkObj, materialMap = {}) {
const isCollisionNode = vn.nodeName.toLowerCase() === 'collision';
let xyz = [0, 0, 0];

@@ -656,2 +683,8 @@ let rpy = [0, 0, 0];

if (isCollisionNode) {
makeURDFCollider(obj);
}
}

@@ -674,2 +707,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
} else if (geoType === 'sphere') {

@@ -686,2 +725,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
} else if (geoType === 'cylinder') {

@@ -700,2 +745,8 @@

if (isCollisionNode) {
makeURDFCollider(primitiveModel);
}
}

@@ -702,0 +753,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc