Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.10.4 to 0.10.5

2

package.json
{
"name": "urdf-loader",
"version": "0.10.4",
"version": "0.10.5",
"description": "URDF Loader for THREE.js and webcomponent viewer",

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

# urdf-loader
[![npm version](https://img.shields.io/npm/v/urdf-loader.svg?style=flat-square)](https://www.npmjs.com/package/urdf-loader)
[![build](https://img.shields.io/github/workflow/status/gkjohnson/urdf-loaders/Node.js%20CI?style=flat-square&label=build)](https://github.com/gkjohnson/urdf-loaders/actions)
[![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/)
[![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/urdf-loaders/node.js.yml?style=flat-square&label=build&branch=master)](https://github.com/gkjohnson/urdf-loaders/actions)

@@ -7,0 +6,0 @@ Utilities for loading URDF files into THREE.js and a Web Component that loads and renders the model.

@@ -75,4 +75,9 @@ import * as THREE from 'three';

traverse(c.children[i]);
const child = c.children[i];
if (!child.isURDFCollider) {
traverse(c.children[i]);
}
}

@@ -79,0 +84,0 @@

import * as THREE from 'three';
import { MeshPhongMaterial } from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

@@ -6,2 +7,3 @@ import URDFLoader from './URDFLoader.js';

const tempVec2 = new THREE.Vector2();
const emptyRaycast = () => {};

@@ -22,3 +24,3 @@ // urdf-viewer element

return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits'];
return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits', 'show-collision'];

@@ -51,2 +53,5 @@ }

get showCollision() { return this.hasAttribute('show-collision') || false; }
set showCollision(val) { val ? this.setAttribute('show-collision', true) : this.removeAttribute('show-collision'); }
get jointValues() {

@@ -161,2 +166,13 @@

this._collisionMaterial = new MeshPhongMaterial({
transparent: true,
opacity: 0.35,
shininess: 2.5,
premultipliedAlpha: true,
color: 0xffbe38,
polygonOffset: true,
polygonOffsetFactor: -1,
polygonOffsetUnits: -1,
});
const _renderLoop = () => {

@@ -232,3 +248,6 @@

this.recenter();
this._updateCollisionVisibility();
if (!this.noAutoRecenter) {
this.recenter();
}

@@ -277,5 +296,5 @@ switch (attr) {

const h = this.clientHeight;
const currsize = r.getSize(tempVec2);
const currSize = r.getSize(tempVec2);
if (currsize.width !== w || currsize.height !== h) {
if (currSize.width !== w || currSize.height !== h) {

@@ -334,3 +353,4 @@ this.recenter();

if (!this.robot) return;
const robot = this.robot;
if (!robot) return;

@@ -340,3 +360,8 @@ this.world.updateMatrixWorld();

const bbox = new THREE.Box3();
bbox.setFromObject(this.robot);
bbox.makeEmpty();
robot.traverse(c => {
if (c.isURDFVisual) {
bbox.expandByObject(c);
}
});

@@ -493,2 +518,3 @@ const center = bbox.getCenter(new THREE.Vector3());

this._setIgnoreLimits(this.ignoreLimits);
this._updateCollisionVisibility();

@@ -512,2 +538,3 @@ this.dispatchEvent(new CustomEvent('urdf-processed', { bubbles: true, cancelable: true, composed: true }));

loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' };
loader.parseCollision = true;
loader.load(urdf, model => robot = model);

@@ -519,2 +546,40 @@

_updateCollisionVisibility() {
const showCollision = this.showCollision;
const collisionMaterial = this._collisionMaterial;
const robot = this.robot;
if (robot === null) return;
const colliders = [];
robot.traverse(c => {
if (c.isURDFCollider) {
c.visible = showCollision;
colliders.push(c);
}
});
colliders.forEach(coll => {
coll.traverse(c => {
if (c.isMesh) {
c.raycast = emptyRaycast;
c.material = collisionMaterial;
c.castShadow = false;
}
});
});
}
// Watch the coordinate frame and update the

@@ -521,0 +586,0 @@ // rotation of the scene to match

@@ -0,0 +0,0 @@ import { Object3D, Vector3 } from 'three';

@@ -269,9 +269,2 @@ import { Object3D, Vector3 } from 'three';

/* Overrides */
setJointValue(...values) {
console.warn(`URDFMimicJoint: Setting the joint value of mimic joint "${ this.urdfName }" will cause it to be out of sync.`);
return super.setJointValue(...values);
}
/* Overrides */
copy(source, recursive) {

@@ -278,0 +271,0 @@

@@ -0,0 +0,0 @@ import { Raycaster, Vector3, Plane, Vector2 } from 'three';

@@ -29,4 +29,4 @@ import { LoadingManager, Object3D } from 'three';

onLoad: (robot: URDFRobot) => void,
onProgress?: () => void,
onError?: () => void
onProgress?: (progress?: any) => void,
onError?: (err?: any) => void
): void;

@@ -33,0 +33,0 @@ parse(content: string | Element | Document): URDFRobot;

@@ -0,0 +0,0 @@ import * as THREE from 'three';

@@ -429,4 +429,9 @@ (function (global, factory) {

traverse(c.children[i]);
const child = c.children[i];
if (!child.isURDFCollider) {
traverse(c.children[i]);
}
}

@@ -433,0 +438,0 @@

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

const tempVec2 = new THREE__namespace.Vector2();
const emptyRaycast = () => {};

@@ -48,3 +49,3 @@ // urdf-viewer element

return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits'];
return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits', 'show-collision'];

@@ -77,2 +78,5 @@ }

get showCollision() { return this.hasAttribute('show-collision') || false; }
set showCollision(val) { val ? this.setAttribute('show-collision', true) : this.removeAttribute('show-collision'); }
get jointValues() {

@@ -187,2 +191,13 @@

this._collisionMaterial = new THREE.MeshPhongMaterial({
transparent: true,
opacity: 0.35,
shininess: 2.5,
premultipliedAlpha: true,
color: 0xffbe38,
polygonOffset: true,
polygonOffsetFactor: -1,
polygonOffsetUnits: -1,
});
const _renderLoop = () => {

@@ -258,3 +273,6 @@

this.recenter();
this._updateCollisionVisibility();
if (!this.noAutoRecenter) {
this.recenter();
}

@@ -303,5 +321,5 @@ switch (attr) {

const h = this.clientHeight;
const currsize = r.getSize(tempVec2);
const currSize = r.getSize(tempVec2);
if (currsize.width !== w || currsize.height !== h) {
if (currSize.width !== w || currSize.height !== h) {

@@ -360,3 +378,4 @@ this.recenter();

if (!this.robot) return;
const robot = this.robot;
if (!robot) return;

@@ -366,3 +385,8 @@ this.world.updateMatrixWorld();

const bbox = new THREE__namespace.Box3();
bbox.setFromObject(this.robot);
bbox.makeEmpty();
robot.traverse(c => {
if (c.isURDFVisual) {
bbox.expandByObject(c);
}
});

@@ -519,2 +543,3 @@ const center = bbox.getCenter(new THREE__namespace.Vector3());

this._setIgnoreLimits(this.ignoreLimits);
this._updateCollisionVisibility();

@@ -538,2 +563,3 @@ this.dispatchEvent(new CustomEvent('urdf-processed', { bubbles: true, cancelable: true, composed: true }));

loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' };
loader.parseCollision = true;
loader.load(urdf, model => robot = model);

@@ -545,2 +571,40 @@

_updateCollisionVisibility() {
const showCollision = this.showCollision;
const collisionMaterial = this._collisionMaterial;
const robot = this.robot;
if (robot === null) return;
const colliders = [];
robot.traverse(c => {
if (c.isURDFCollider) {
c.visible = showCollision;
colliders.push(c);
}
});
colliders.forEach(coll => {
coll.traverse(c => {
if (c.isMesh) {
c.raycast = emptyRaycast;
c.material = collisionMaterial;
c.castShadow = false;
}
});
});
}
// Watch the coordinate frame and update the

@@ -547,0 +611,0 @@ // rotation of the scene to match

@@ -295,9 +295,2 @@ (function (global, factory) {

/* Overrides */
setJointValue(...values) {
console.warn(`URDFMimicJoint: Setting the joint value of mimic joint "${ this.urdfName }" will cause it to be out of sync.`);
return super.setJointValue(...values);
}
/* Overrides */
copy(source, recursive) {

@@ -304,0 +297,0 @@

Sorry, the diff of this file is not supported yet

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