@operato/scene-urdf 10.0.0-beta.2 → 10.0.0-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +22 -25
  2. package/TODO.md +58 -0
  3. package/dist/editors/index.d.ts +7 -0
  4. package/dist/editors/index.js +12 -1
  5. package/dist/editors/index.js.map +1 -1
  6. package/dist/editors/property-editor-urdf-joints.d.ts +54 -0
  7. package/dist/editors/property-editor-urdf-joints.js +246 -0
  8. package/dist/editors/property-editor-urdf-joints.js.map +1 -0
  9. package/dist/editors/property-editor-urdf-preset.d.ts +8 -0
  10. package/dist/editors/property-editor-urdf-preset.js +114 -0
  11. package/dist/editors/property-editor-urdf-preset.js.map +1 -0
  12. package/dist/index.d.ts +8 -2
  13. package/dist/index.js +22 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/joint-controller.d.ts +35 -0
  16. package/dist/joint-controller.js +34 -0
  17. package/dist/joint-controller.js.map +1 -0
  18. package/dist/real-object-urdf.d.ts +106 -0
  19. package/dist/real-object-urdf.js +527 -0
  20. package/dist/real-object-urdf.js.map +1 -0
  21. package/dist/smoothing-controller.d.ts +15 -0
  22. package/dist/smoothing-controller.js +88 -0
  23. package/dist/smoothing-controller.js.map +1 -0
  24. package/dist/templates/index.d.ts +3 -0
  25. package/dist/templates/index.js +2 -3
  26. package/dist/templates/index.js.map +1 -1
  27. package/dist/templates/{urdf-controller.d.ts → urdf.d.ts} +3 -0
  28. package/dist/templates/urdf.js +19 -0
  29. package/dist/templates/urdf.js.map +1 -0
  30. package/dist/urdf-object.d.ts +264 -0
  31. package/dist/urdf-object.js +190 -0
  32. package/dist/urdf-object.js.map +1 -0
  33. package/dist/urdf-presets.d.ts +22 -0
  34. package/dist/urdf-presets.js +176 -0
  35. package/dist/urdf-presets.js.map +1 -0
  36. package/icons/urdf.png +0 -0
  37. package/package.json +5 -4
  38. package/translations/en.json +10 -16
  39. package/translations/ja.json +10 -16
  40. package/translations/ko.json +10 -16
  41. package/translations/ms.json +10 -16
  42. package/translations/zh.json +10 -16
  43. package/dist/elements/drag-n-drop.d.ts +0 -2
  44. package/dist/elements/drag-n-drop.js +0 -126
  45. package/dist/elements/drag-n-drop.js.map +0 -1
  46. package/dist/elements/urdf-controller-element.d.ts +0 -12
  47. package/dist/elements/urdf-controller-element.js +0 -283
  48. package/dist/elements/urdf-controller-element.js.map +0 -1
  49. package/dist/elements/urdf-drag-controls.d.ts +0 -32
  50. package/dist/elements/urdf-drag-controls.js +0 -197
  51. package/dist/elements/urdf-drag-controls.js.map +0 -1
  52. package/dist/elements/urdf-manipulator-element.d.ts +0 -15
  53. package/dist/elements/urdf-manipulator-element.js +0 -112
  54. package/dist/elements/urdf-manipulator-element.js.map +0 -1
  55. package/dist/elements/urdf-viewer-element.d.ts +0 -53
  56. package/dist/elements/urdf-viewer-element.js +0 -414
  57. package/dist/elements/urdf-viewer-element.js.map +0 -1
  58. package/dist/templates/urdf-controller.js +0 -16
  59. package/dist/templates/urdf-controller.js.map +0 -1
  60. package/dist/templates/urdf-viewer.d.ts +0 -14
  61. package/dist/templates/urdf-viewer.js +0 -16
  62. package/dist/templates/urdf-viewer.js.map +0 -1
  63. package/dist/urdf-controller.d.ts +0 -15
  64. package/dist/urdf-controller.js +0 -70
  65. package/dist/urdf-controller.js.map +0 -1
  66. package/dist/urdf-viewer.d.ts +0 -16
  67. package/dist/urdf-viewer.js +0 -202
  68. package/dist/urdf-viewer.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { customElement } from 'lit/decorators.js';
3
- import * as THREE from 'three';
4
- import { PointerURDFDragControls } from './urdf-drag-controls.js';
5
- import URDFViewerElement from './urdf-viewer-element.js';
6
- // urdf-manipulator element
7
- // Displays a URDF model that can be manipulated with the mouse
8
- // Events
9
- // joint-mouseover: Fired when a joint is hovered over
10
- // joint-mouseout: Fired when a joint is no longer hovered over
11
- // manipulate-start: Fires when a joint is manipulated
12
- // manipulate-end: Fires when a joint is done being manipulated
13
- let URDFManipulatorElement = class URDFManipulatorElement extends URDFViewerElement {
14
- static get observedAttributes() {
15
- return ['highlight-color', ...super.observedAttributes];
16
- }
17
- highlightMaterial;
18
- dragControls;
19
- get disableDragging() {
20
- return this.hasAttribute('disable-dragging');
21
- }
22
- set disableDragging(val) {
23
- val ? this.setAttribute('disable-dragging', String(!!val)) : this.removeAttribute('disable-dragging');
24
- }
25
- get highlightColor() {
26
- return this.getAttribute('highlight-color') || '#FFFFFF';
27
- }
28
- set highlightColor(val) {
29
- val ? this.setAttribute('highlight-color', val) : this.removeAttribute('highlight-color');
30
- }
31
- constructor() {
32
- super();
33
- // The highlight material
34
- this.highlightMaterial = new THREE.MeshPhongMaterial({
35
- shininess: 10,
36
- color: this.highlightColor,
37
- emissive: this.highlightColor,
38
- emissiveIntensity: 0.25
39
- });
40
- const isJoint = (j) => {
41
- return j.isURDFJoint && j.jointType !== 'fixed';
42
- };
43
- // Highlight the link geometry under a joint
44
- const highlightLinkGeometry = (m, revert) => {
45
- const traverse = (c) => {
46
- // Set or revert the highlight color
47
- if (c.type === 'Mesh') {
48
- if (revert) {
49
- c.material = c.__origMaterial;
50
- delete c.__origMaterial;
51
- }
52
- else {
53
- c.__origMaterial = c.material;
54
- c.material = this.highlightMaterial;
55
- }
56
- }
57
- // Look into the children and stop if the next child is
58
- // another joint
59
- if (c === m || !isJoint(c)) {
60
- for (let i = 0; i < c.children.length; i++) {
61
- traverse(c.children[i]);
62
- }
63
- }
64
- };
65
- traverse(m);
66
- };
67
- const el = this.renderer.domElement;
68
- const dragControls = new PointerURDFDragControls(this.scene, this.camera, el);
69
- dragControls.onDragStart = joint => {
70
- this.dispatchEvent(new CustomEvent('manipulate-start', { bubbles: true, cancelable: true, detail: joint.name }));
71
- this.controls.enabled = false;
72
- this.redraw();
73
- };
74
- dragControls.onDragEnd = joint => {
75
- this.dispatchEvent(new CustomEvent('manipulate-end', { bubbles: true, cancelable: true, detail: joint.name }));
76
- this.controls.enabled = true;
77
- this.redraw();
78
- };
79
- dragControls.updateJoint = (joint, angle) => {
80
- this.setJointValue(joint.name, angle);
81
- };
82
- dragControls.onHover = (joint) => {
83
- highlightLinkGeometry(joint, false);
84
- this.dispatchEvent(new CustomEvent('joint-mouseover', { bubbles: true, cancelable: true, detail: joint.name }));
85
- this.redraw();
86
- };
87
- dragControls.onUnhover = joint => {
88
- highlightLinkGeometry(joint, true);
89
- this.dispatchEvent(new CustomEvent('joint-mouseout', { bubbles: true, cancelable: true, detail: joint.name }));
90
- this.redraw();
91
- };
92
- this.dragControls = dragControls;
93
- }
94
- disconnectedCallback() {
95
- super.disconnectedCallback();
96
- this.dragControls.dispose();
97
- }
98
- attributeChangedCallback(attr, oldval, newval) {
99
- super.attributeChangedCallback(attr, oldval, newval);
100
- switch (attr) {
101
- case 'highlight-color':
102
- this.highlightMaterial.color.set(this.highlightColor);
103
- this.highlightMaterial.emissive.set(this.highlightColor);
104
- break;
105
- }
106
- }
107
- };
108
- URDFManipulatorElement = __decorate([
109
- customElement('urdf-viewer')
110
- ], URDFManipulatorElement);
111
- export default URDFManipulatorElement;
112
- //# sourceMappingURL=urdf-manipulator-element.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urdf-manipulator-element.js","sourceRoot":"","sources":["../../src/elements/urdf-manipulator-element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,iBAAiB,MAAM,0BAA0B,CAAA;AAGxD,2BAA2B;AAC3B,+DAA+D;AAE/D,SAAS;AACT,sDAAsD;AACtD,+DAA+D;AAC/D,sDAAsD;AACtD,+DAA+D;AAGhD,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,iBAAiB;IACnE,MAAM,KAAK,kBAAkB;Q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ClB,KAAK,CAAC,oBAAoB,EAAE,CAAA;QAC5B,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;IAED,wBAAwB,CAAC,IAAY,EAAE,MAAW,EAAE,MAAW;QAC7D,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QAEpD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,iBAAiB;gBACpB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBACrD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;gBACxD,MAAK;QACT,CAAC;IACH,CAAC;CACF,CAAA;AAnHoB,sBAAsB;IAD1C,aAAa,CAAC,aAAa,CAAC;GACR,sBAAsB,CAmH1C;eAnHoB,sBAAsB","sourcesContent":["import { customElement } from 'lit/decorators.js'\nimport * as THREE from 'three'\nimport { PointerURDFDragControls } from './urdf-drag-controls.js'\nimport { Material, MeshPhongMaterial } from 'three'\nimport URDFViewerElement from './urdf-viewer-element.js'\nimport { URDFJoint } from 'urdf-loader'\n\n// urdf-manipulator element\n// Displays a URDF model that can be manipulated with the mouse\n\n// Events\n// joint-mouseover: Fired when a joint is hovered over\n// joint-mouseout: Fired when a joint is no longer hovered over\n// manipulate-start: Fires when a joint is manipulated\n// manipulate-end: Fires when a joint is done being manipulated\n\n@customElement('urdf-viewer')\nexport default class URDFManipulatorElement extends URDFViewerElement {\n static get observedAttributes() {\n return ['highlight-color', ...super.observedAttributes]\n }\n\n highlightMaterial: MeshPhongMaterial\n dragControls: PointerURDFDragControls\n\n get disableDragging() {\n return this.hasAttribute('disable-dragging')\n }\n\n set disableDragging(val) {\n val ? this.setAttribute('disable-dragging', String(!!val)) : this.removeAttribute('disable-dragging')\n }\n\n get highlightColor() {\n return this.getAttribute('highlight-color') || '#FFFFFF'\n }\n\n set highlightColor(val) {\n val ? this.setAttribute('highlight-color', val) : this.removeAttribute('highlight-color')\n }\n\n constructor() {\n super()\n\n // The highlight material\n this.highlightMaterial = new THREE.MeshPhongMaterial({\n shininess: 10,\n color: this.highlightColor,\n emissive: this.highlightColor,\n emissiveIntensity: 0.25\n })\n\n const isJoint = (j: URDFJoint) => {\n return j.isURDFJoint && j.jointType !== 'fixed'\n }\n\n // Highlight the link geometry under a joint\n const highlightLinkGeometry = (m: THREE.Material, revert: boolean) => {\n const traverse = (c: any) => {\n // Set or revert the highlight color\n if (c.type === 'Mesh') {\n if (revert) {\n c.material = c.__origMaterial\n delete c.__origMaterial\n } else {\n c.__origMaterial = c.material\n c.material = this.highlightMaterial\n }\n }\n\n // Look into the children and stop if the next child is\n // another joint\n if (c === m || !isJoint(c)) {\n for (let i = 0; i < c.children.length; i++) {\n traverse(c.children[i])\n }\n }\n }\n\n traverse(m)\n }\n\n const el = this.renderer.domElement\n\n const dragControls = new PointerURDFDragControls(this.scene, this.camera, el)\n\n dragControls.onDragStart = joint => {\n this.dispatchEvent(new CustomEvent('manipulate-start', { bubbles: true, cancelable: true, detail: joint.name }))\n this.controls.enabled = false\n this.redraw()\n }\n\n dragControls.onDragEnd = joint => {\n this.dispatchEvent(new CustomEvent('manipulate-end', { bubbles: true, cancelable: true, detail: joint.name }))\n this.controls.enabled = true\n this.redraw()\n }\n\n dragControls.updateJoint = (joint, angle) => {\n this.setJointValue(joint.name, angle)\n }\n\n dragControls.onHover = (joint: URDFJoint) => {\n highlightLinkGeometry(joint as any, false)\n this.dispatchEvent(new CustomEvent('joint-mouseover', { bubbles: true, cancelable: true, detail: joint.name }))\n this.redraw()\n }\n\n dragControls.onUnhover = joint => {\n highlightLinkGeometry(joint as any, true)\n this.dispatchEvent(new CustomEvent('joint-mouseout', { bubbles: true, cancelable: true, detail: joint.name }))\n this.redraw()\n }\n\n this.dragControls = dragControls\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.dragControls.dispose()\n }\n\n attributeChangedCallback(attr: string, oldval: any, newval: any) {\n super.attributeChangedCallback(attr, oldval, newval)\n\n switch (attr) {\n case 'highlight-color':\n this.highlightMaterial.color.set(this.highlightColor)\n this.highlightMaterial.emissive.set(this.highlightColor)\n break\n }\n }\n}\n"]}
@@ -1,53 +0,0 @@
1
- import * as THREE from 'three';
2
- import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
3
- import { URDFRobot } from 'urdf-loader/src/URDFLoader.js';
4
- export default class URDFViewerElement extends HTMLElement {
5
- static get observedAttributes(): string[];
6
- get package(): string;
7
- set package(val: string);
8
- get urdf(): string;
9
- set urdf(val: string);
10
- get ignoreLimits(): boolean;
11
- set ignoreLimits(val: boolean);
12
- get up(): string;
13
- set up(val: string);
14
- get displayShadow(): boolean;
15
- set displayShadow(val: boolean);
16
- get ambientColor(): string;
17
- set ambientColor(val: string);
18
- get noAutoRecenter(): boolean;
19
- set noAutoRecenter(val: boolean);
20
- get jointValues(): any;
21
- set jointValues(val: any);
22
- get angles(): any;
23
- set angles(v: any);
24
- robot?: URDFRobot;
25
- controls: OrbitControls;
26
- scene: THREE.Scene;
27
- camera: THREE.PerspectiveCamera;
28
- world: THREE.Object3D;
29
- renderer: THREE.WebGLRenderer;
30
- plane: THREE.Mesh;
31
- directionalLight: THREE.DirectionalLight;
32
- ambientLight: THREE.HemisphereLight;
33
- _prevload?: string;
34
- _requestId: number;
35
- _dirty: boolean;
36
- _loadScheduled: boolean;
37
- loadMeshFunc?: (url: string, manager: THREE.LoadingManager, onLoad: (mesh: THREE.Object3D, err?: Error) => void) => void;
38
- urlModifierFunc?: (url: string) => string;
39
- constructor();
40
- connectedCallback(): void;
41
- disconnectedCallback(): void;
42
- attributeChangedCallback(attr: string, oldval: any, newval: any): void;
43
- updateSize(): void;
44
- redraw(): void;
45
- recenter(): void;
46
- setJointValue(jointName: string, ...values: Number[]): void;
47
- setJointValues(values: Number[]): void;
48
- _updateEnvironment(): void;
49
- _scheduleLoad(): void;
50
- _loadUrdf(pkg: string, urdf: string): void;
51
- _setUp(up: string): void;
52
- _setIgnoreLimits(ignore: boolean, dispatch?: boolean): void;
53
- }
@@ -1,414 +0,0 @@
1
- import * as THREE from 'three';
2
- import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
3
- import URDFLoader from 'urdf-loader/src/URDFLoader.js';
4
- import { XacroLoader } from 'xacro-parser';
5
- // urdf-viewer element
6
- // Loads and displays a 3D view of a URDF-formatted robot
7
- // Events
8
- // urdf-change: Fires when the URDF has finished loading and getting processed
9
- // urdf-processed: Fires when the URDF has finished loading and getting processed
10
- // geometry-loaded: Fires when all the geometry has been fully loaded
11
- // ignore-limits-change: Fires when the 'ignore-limits' attribute changes
12
- // angle-change: Fires when an angle changes
13
- export default class URDFViewerElement extends HTMLElement {
14
- static get observedAttributes() {
15
- return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits', 'no-auto-recenter'];
16
- }
17
- get package() {
18
- return this.getAttribute('package') || '';
19
- }
20
- set package(val) {
21
- this.setAttribute('package', val);
22
- }
23
- get urdf() {
24
- return this.getAttribute('urdf') || '';
25
- }
26
- set urdf(val) {
27
- this.setAttribute('urdf', val);
28
- }
29
- get ignoreLimits() {
30
- return this.hasAttribute('ignore-limits') || false;
31
- }
32
- set ignoreLimits(val) {
33
- val ? this.setAttribute('ignore-limits', String(val)) : this.removeAttribute('ignore-limits');
34
- }
35
- get up() {
36
- return this.getAttribute('up') || '+Z';
37
- }
38
- set up(val) {
39
- this.setAttribute('up', val);
40
- }
41
- get displayShadow() {
42
- return this.hasAttribute('display-shadow') || false;
43
- }
44
- set displayShadow(val) {
45
- val ? this.setAttribute('display-shadow', '') : this.removeAttribute('display-shadow');
46
- }
47
- get ambientColor() {
48
- return this.getAttribute('ambient-color') || '#455A64';
49
- }
50
- set ambientColor(val) {
51
- val ? this.setAttribute('ambient-color', val) : this.removeAttribute('ambient-color');
52
- }
53
- get noAutoRecenter() {
54
- return this.hasAttribute('no-auto-recenter') || false;
55
- }
56
- set noAutoRecenter(val) {
57
- val ? this.setAttribute('no-auto-recenter', String(true)) : this.removeAttribute('no-auto-recenter');
58
- }
59
- get jointValues() {
60
- const values = {};
61
- if (this.robot) {
62
- for (const name in this.robot.joints) {
63
- const joint = this.robot.joints[name];
64
- values[name] = joint.jointValue.length === 1 ? joint.angle : [...joint.jointValue];
65
- }
66
- }
67
- return values;
68
- }
69
- set jointValues(val) {
70
- this.setJointValues(val);
71
- }
72
- get angles() {
73
- return this.jointValues;
74
- }
75
- set angles(v) {
76
- this.jointValues = v;
77
- }
78
- robot;
79
- controls;
80
- scene;
81
- camera;
82
- world;
83
- renderer;
84
- plane;
85
- directionalLight;
86
- ambientLight;
87
- _prevload;
88
- _requestId = 0;
89
- _dirty = true;
90
- _loadScheduled = false;
91
- loadMeshFunc;
92
- urlModifierFunc;
93
- /* Lifecycle Functions */
94
- constructor() {
95
- super();
96
- const scene = new THREE.Scene();
97
- const ambientLight = new THREE.HemisphereLight(this.ambientColor, '#000');
98
- ambientLight.groundColor.lerp(ambientLight.color, 0.5);
99
- ambientLight.intensity = 0.5;
100
- ambientLight.position.set(0, 1, 0);
101
- scene.add(ambientLight);
102
- // Light setup
103
- const dirLight = new THREE.DirectionalLight(0xffffff);
104
- dirLight.position.set(4, 10, 1);
105
- dirLight.shadow.mapSize.width = 2048;
106
- dirLight.shadow.mapSize.height = 2048;
107
- dirLight.shadow.normalBias = 0.001;
108
- dirLight.castShadow = true;
109
- scene.add(dirLight);
110
- scene.add(dirLight.target);
111
- // Renderer setup
112
- const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
113
- renderer.setClearColor(0xffffff);
114
- renderer.setClearAlpha(0);
115
- renderer.shadowMap.enabled = true;
116
- renderer.shadowMap.type = THREE.PCFSoftShadowMap;
117
- renderer.outputColorSpace = THREE.SRGBColorSpace;
118
- // Camera setup
119
- const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
120
- camera.position.z = -10;
121
- // World setup
122
- const world = new THREE.Object3D();
123
- scene.add(world);
124
- const plane = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.ShadowMaterial({ side: THREE.DoubleSide, transparent: true, opacity: 0.5 }));
125
- plane.rotation.x = -Math.PI / 2;
126
- plane.position.y = -0.5;
127
- plane.receiveShadow = true;
128
- plane.scale.set(10, 10, 10);
129
- scene.add(plane);
130
- // Controls setup
131
- const controls = new OrbitControls(camera, renderer.domElement);
132
- controls.rotateSpeed = 2.0;
133
- controls.zoomSpeed = 5;
134
- controls.panSpeed = 2;
135
- controls.enableZoom = true;
136
- controls.enableDamping = false;
137
- controls.maxDistance = 50;
138
- controls.minDistance = 0.25;
139
- controls.addEventListener('change', () => this.recenter());
140
- this.scene = scene;
141
- this.world = world;
142
- this.renderer = renderer;
143
- this.camera = camera;
144
- this.controls = controls;
145
- this.plane = plane;
146
- this.directionalLight = dirLight;
147
- this.ambientLight = ambientLight;
148
- this._setUp(this.up);
149
- }
150
- connectedCallback() {
151
- if (!this.querySelector('canvas')) {
152
- var canvas = this.renderer.domElement;
153
- canvas.style.display = 'block';
154
- canvas.style.width = '100%';
155
- canvas.style.height = '100%';
156
- this.appendChild(canvas);
157
- }
158
- requestAnimationFrame(() => this.recenter());
159
- }
160
- disconnectedCallback() { }
161
- attributeChangedCallback(attr, oldval, newval) {
162
- this.recenter();
163
- switch (attr) {
164
- case 'package':
165
- case 'urdf': {
166
- this._scheduleLoad();
167
- break;
168
- }
169
- case 'up': {
170
- this._setUp(this.up);
171
- break;
172
- }
173
- case 'ambient-color': {
174
- this.ambientLight.color.set(this.ambientColor);
175
- this.ambientLight.groundColor.set('#000').lerp(this.ambientLight.color, 0.5);
176
- break;
177
- }
178
- case 'ignore-limits': {
179
- this._setIgnoreLimits(this.ignoreLimits, true);
180
- break;
181
- }
182
- }
183
- }
184
- /* Public API */
185
- updateSize() {
186
- const r = this.renderer;
187
- const w = this.clientWidth;
188
- const h = this.clientHeight;
189
- const currsize = r.getSize(new THREE.Vector2());
190
- if (currsize.width !== w || currsize.height !== h) {
191
- this.recenter();
192
- }
193
- r.setPixelRatio(window.devicePixelRatio);
194
- r.setSize(w, h, false);
195
- this.camera.aspect = w / h;
196
- this.camera.updateProjectionMatrix();
197
- }
198
- redraw() {
199
- if (this.parentNode && this._dirty) {
200
- this._dirty = false;
201
- try {
202
- this.updateSize();
203
- if (!this.noAutoRecenter) {
204
- this._updateEnvironment();
205
- }
206
- this.renderer.render(this.scene, this.camera);
207
- // update controls after the environment in
208
- // case the controls are retargeted
209
- this.controls.update();
210
- }
211
- catch (err) {
212
- console.error(err);
213
- }
214
- finally {
215
- this._dirty = true;
216
- }
217
- }
218
- }
219
- recenter() {
220
- this._updateEnvironment();
221
- this.redraw();
222
- }
223
- // Set the joint with jointName to
224
- // angle in degrees
225
- setJointValue(jointName, ...values) {
226
- if (!this.robot)
227
- return;
228
- if (!this.robot.joints[jointName])
229
- return;
230
- if (this.robot.joints[jointName].setJointValue(values[0], values[1], values[2])) {
231
- this.redraw();
232
- this.dispatchEvent(new CustomEvent('angle-change', { bubbles: true, cancelable: true, detail: jointName }));
233
- }
234
- }
235
- setJointValues(values) {
236
- for (const name in values)
237
- this.setJointValue(name, values[name]);
238
- }
239
- /* Private Functions */
240
- // Updates the position of the plane to be at the
241
- // lowest point below the robot and focuses the
242
- // camera on the center of the scene
243
- _updateEnvironment() {
244
- if (!this.robot)
245
- return;
246
- this.world.updateMatrixWorld();
247
- const bbox = new THREE.Box3();
248
- bbox.setFromObject(this.robot);
249
- const center = bbox.getCenter(new THREE.Vector3());
250
- this.controls.target.y = center.y;
251
- this.plane.position.y = bbox.min.y - 1e-3;
252
- const dirLight = this.directionalLight;
253
- dirLight.castShadow = this.displayShadow;
254
- if (this.displayShadow) {
255
- // Update the shadow camera rendering bounds to encapsulate the
256
- // model. We use the bounding sphere of the bounding box for
257
- // simplicity -- this could be a tighter fit.
258
- const sphere = bbox.getBoundingSphere(new THREE.Sphere());
259
- const minmax = sphere.radius;
260
- const cam = dirLight.shadow.camera;
261
- cam.left = cam.bottom = -minmax;
262
- cam.right = cam.top = minmax;
263
- // Update the camera to focus on the center of the model so the
264
- // shadow can encapsulate it
265
- const offset = dirLight.position.clone().sub(dirLight.target.position);
266
- dirLight.target.position.copy(center);
267
- dirLight.position.copy(center).add(offset);
268
- cam.updateProjectionMatrix();
269
- }
270
- }
271
- _scheduleLoad() {
272
- // if our current model is already what's being requested
273
- // or has been loaded then early out
274
- if (this._prevload === `${this.package}|${this.urdf}`)
275
- return;
276
- this._prevload = `${this.package}|${this.urdf}`;
277
- // if we're already waiting on a load then early out
278
- if (this._loadScheduled)
279
- return;
280
- this._loadScheduled = true;
281
- if (this.robot) {
282
- this.robot.traverse((c) => c.dispose && c.dispose());
283
- this.robot.parent.remove(this.robot);
284
- delete this.robot;
285
- }
286
- requestAnimationFrame(() => {
287
- this._loadUrdf(this.package, this.urdf);
288
- this._loadScheduled = false;
289
- });
290
- }
291
- // Watch the package and urdf field and load the robot model.
292
- // This should _only_ be called from _scheduleLoad because that
293
- // ensures the that current robot has been removed
294
- _loadUrdf(pkg, urdf) {
295
- this.dispatchEvent(new CustomEvent('urdf-change', { bubbles: true, cancelable: true, composed: true }));
296
- if (urdf) {
297
- // Keep track of this request and make
298
- // sure it doesn't get overwritten by
299
- // a subsequent one
300
- this._requestId++;
301
- const requestId = this._requestId;
302
- const updateMaterials = (mesh) => {
303
- mesh.traverse(c => {
304
- if (c.isMesh) {
305
- c.castShadow = true;
306
- c.receiveShadow = true;
307
- if (c.material) {
308
- const mats = (Array.isArray(c.material) ? c.material : [c.material]).map((m) => {
309
- if (m instanceof THREE.MeshBasicMaterial) {
310
- m = new THREE.MeshPhongMaterial();
311
- }
312
- // FIXME THREE.GammaEncoding is removed at v136
313
- // if (m.map) {
314
- // m.map.encoding = THREE.GammaEncoding
315
- // }
316
- return m;
317
- });
318
- c.material = mats.length === 1 ? mats[0] : mats;
319
- }
320
- }
321
- });
322
- };
323
- if (pkg.includes(':') && pkg.split(':')[1].substring(0, 2) !== '//') {
324
- // E.g. pkg = "pkg_name: path/to/pkg_name, pk2: path2/to/pk2"}
325
- // Convert pkg(s) into a map. E.g.
326
- // { "pkg_name": "path/to/pkg_name",
327
- // "pk2": "path2/to/pk2" }
328
- pkg = pkg.split(',').reduce((map, value) => {
329
- const split = value.split(/:/).filter(x => !!x);
330
- const pkgName = split.shift().trim();
331
- const pkgPath = split.join(':').trim();
332
- map[pkgName] = pkgPath;
333
- return map;
334
- }, {});
335
- }
336
- let robot;
337
- const manager = new THREE.LoadingManager();
338
- manager.onLoad = () => {
339
- // If another request has come in to load a new
340
- // robot, then ignore this one
341
- if (this._requestId !== requestId) {
342
- robot.traverse(c => c.dispose && c.dispose());
343
- return;
344
- }
345
- this.robot = robot;
346
- this.world.add(robot);
347
- updateMaterials(robot);
348
- this._setIgnoreLimits(this.ignoreLimits);
349
- this.dispatchEvent(new CustomEvent('urdf-processed', { bubbles: true, cancelable: true, composed: true }));
350
- this.dispatchEvent(new CustomEvent('geometry-loaded', { bubbles: true, cancelable: true, composed: true }));
351
- this.recenter();
352
- };
353
- if (this.urlModifierFunc) {
354
- manager.setURLModifier(this.urlModifierFunc);
355
- }
356
- const checkXacro = /[.]/.exec(urdf) ? /[^.]+$/.exec(urdf) : undefined;
357
- if (checkXacro && checkXacro[0] === 'xacro') {
358
- const xacroLoader = new XacroLoader();
359
- try {
360
- xacroLoader.load(urdf, xml => {
361
- const loader = new URDFLoader(manager);
362
- loader.packages = pkg;
363
- loader.loadMeshCb = this.loadMeshFunc;
364
- loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' };
365
- robot = loader.parse(xml);
366
- }, err => {
367
- console.error('xacroloader error: ', err);
368
- });
369
- }
370
- catch (error) {
371
- console.error(error);
372
- }
373
- }
374
- else {
375
- const loader = new URDFLoader(manager);
376
- loader.packages = pkg;
377
- loader.loadMeshCb = this.loadMeshFunc;
378
- loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' };
379
- loader.load(urdf, model => (robot = model));
380
- }
381
- }
382
- }
383
- // Watch the coordinate frame and update the
384
- // rotation of the scene to match
385
- _setUp(up) {
386
- if (!up)
387
- up = '+Z';
388
- up = up.toUpperCase();
389
- const sign = up.replace(/[^-+]/g, '')[0] || '+';
390
- const axis = up.replace(/[^XYZ]/gi, '')[0] || 'Z';
391
- const PI = Math.PI;
392
- const HALFPI = PI / 2;
393
- if (axis === 'X')
394
- this.world.rotation.set(0, 0, sign === '+' ? HALFPI : -HALFPI);
395
- if (axis === 'Z')
396
- this.world.rotation.set(sign === '+' ? -HALFPI : HALFPI, 0, 0);
397
- if (axis === 'Y')
398
- this.world.rotation.set(sign === '+' ? 0 : PI, 0, 0);
399
- }
400
- // Updates the current robot's angles to ignore
401
- // joint limits or not
402
- _setIgnoreLimits(ignore, dispatch = false) {
403
- if (this.robot) {
404
- Object.values(this.robot.joints).forEach(joint => {
405
- joint.ignoreLimits = ignore;
406
- joint.setJointValue(joint.jointValue[0], joint.jointValue[1], joint.jointValue[2]);
407
- });
408
- }
409
- if (dispatch) {
410
- this.dispatchEvent(new CustomEvent('ignore-limits-change', { bubbles: true, cancelable: true, composed: true }));
411
- }
412
- }
413
- }
414
- //# sourceMappingURL=urdf-viewer-element.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urdf-viewer-element.js","sourceRoot":"","sources":["../../src/elements/urdf-viewer-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAC5E,OAAO,UAAoC,MAAM,+BAA+B,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,sBAAsB;AACtB,yDAAyD;AAEzD,SAAS;AACT,8EAA8E;AAC9E,iFAAiF;AACjF,qEAAqE;AACrE,yEAAyE;AACzE,4CAA4C;AAC5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,W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,CAAA;QAChF,IAAI,IAAI,KAAK,GAAG;YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACxE,CAAC;IAED,+CAA+C;IAC/C,sBAAsB;IACtB,gBAAgB,CAAC,MAAe,EAAE,QAAQ,GAAG,KAAK;QAChD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/C,KAAK,CAAC,YAAY,GAAG,MAAM,CAAA;gBAC3B,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;YACpF,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,sBAAsB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAClH,CAAC;IACH,CAAC;CACF","sourcesContent":["import * as THREE from 'three'\nimport { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'\nimport URDFLoader, { URDFJoint, URDFRobot } from 'urdf-loader/src/URDFLoader.js'\nimport { XacroLoader } from 'xacro-parser'\n\n// urdf-viewer element\n// Loads and displays a 3D view of a URDF-formatted robot\n\n// Events\n// urdf-change: Fires when the URDF has finished loading and getting processed\n// urdf-processed: Fires when the URDF has finished loading and getting processed\n// geometry-loaded: Fires when all the geometry has been fully loaded\n// ignore-limits-change: Fires when the 'ignore-limits' attribute changes\n// angle-change: Fires when an angle changes\nexport default class URDFViewerElement extends HTMLElement {\n static get observedAttributes() {\n return ['package', 'urdf', 'up', 'display-shadow', 'ambient-color', 'ignore-limits', 'no-auto-recenter']\n }\n\n get package() {\n return this.getAttribute('package') || ''\n }\n set package(val) {\n this.setAttribute('package', val)\n }\n\n get urdf() {\n return this.getAttribute('urdf') || ''\n }\n set urdf(val) {\n this.setAttribute('urdf', val)\n }\n\n get ignoreLimits() {\n return this.hasAttribute('ignore-limits') || false\n }\n set ignoreLimits(val) {\n val ? this.setAttribute('ignore-limits', String(val)) : this.removeAttribute('ignore-limits')\n }\n\n get up() {\n return this.getAttribute('up') || '+Z'\n }\n set up(val) {\n this.setAttribute('up', val)\n }\n\n get displayShadow() {\n return this.hasAttribute('display-shadow') || false\n }\n set displayShadow(val) {\n val ? this.setAttribute('display-shadow', '') : this.removeAttribute('display-shadow')\n }\n\n get ambientColor() {\n return this.getAttribute('ambient-color') || '#455A64'\n }\n set ambientColor(val) {\n val ? this.setAttribute('ambient-color', val) : this.removeAttribute('ambient-color')\n }\n\n get noAutoRecenter() {\n return this.hasAttribute('no-auto-recenter') || false\n }\n set noAutoRecenter(val) {\n val ? this.setAttribute('no-auto-recenter', String(true)) : this.removeAttribute('no-auto-recenter')\n }\n\n get jointValues() {\n const values = {} as any\n if (this.robot) {\n for (const name in this.robot.joints) {\n const joint = this.robot.joints[name]\n values[name] = joint.jointValue.length === 1 ? joint.angle : [...joint.jointValue]\n }\n }\n\n return values\n }\n set jointValues(val) {\n this.setJointValues(val)\n }\n\n get angles() {\n return this.jointValues\n }\n set angles(v) {\n this.jointValues = v\n }\n\n robot?: URDFRobot\n controls: OrbitControls\n scene: THREE.Scene\n camera: THREE.PerspectiveCamera\n\n world: THREE.Object3D\n renderer: THREE.WebGLRenderer\n plane: THREE.Mesh\n directionalLight: THREE.DirectionalLight\n ambientLight: THREE.HemisphereLight\n\n _prevload?: string\n _requestId = 0\n _dirty = true\n _loadScheduled = false\n loadMeshFunc?: (\n url: string,\n manager: THREE.LoadingManager,\n onLoad: (mesh: THREE.Object3D, err?: Error) => void\n ) => void\n urlModifierFunc?: (url: string) => string\n\n /* Lifecycle Functions */\n constructor() {\n super()\n\n const scene = new THREE.Scene()\n\n const ambientLight = new THREE.HemisphereLight(this.ambientColor, '#000')\n ambientLight.groundColor.lerp(ambientLight.color, 0.5)\n ambientLight.intensity = 0.5\n ambientLight.position.set(0, 1, 0)\n scene.add(ambientLight)\n\n // Light setup\n const dirLight = new THREE.DirectionalLight(0xffffff)\n dirLight.position.set(4, 10, 1)\n dirLight.shadow.mapSize.width = 2048\n dirLight.shadow.mapSize.height = 2048\n dirLight.shadow.normalBias = 0.001\n dirLight.castShadow = true\n scene.add(dirLight)\n scene.add(dirLight.target)\n\n // Renderer setup\n const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true })\n renderer.setClearColor(0xffffff)\n renderer.setClearAlpha(0)\n renderer.shadowMap.enabled = true\n renderer.shadowMap.type = THREE.PCFSoftShadowMap\n renderer.outputColorSpace = THREE.SRGBColorSpace\n\n // Camera setup\n const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000)\n camera.position.z = -10\n\n // World setup\n const world = new THREE.Object3D()\n scene.add(world)\n\n const plane = new THREE.Mesh(\n new THREE.PlaneGeometry(40, 40),\n new THREE.ShadowMaterial({ side: THREE.DoubleSide, transparent: true, opacity: 0.5 })\n )\n plane.rotation.x = -Math.PI / 2\n plane.position.y = -0.5\n plane.receiveShadow = true\n plane.scale.set(10, 10, 10)\n scene.add(plane)\n\n // Controls setup\n const controls = new OrbitControls(camera, renderer.domElement)\n controls.rotateSpeed = 2.0\n controls.zoomSpeed = 5\n controls.panSpeed = 2\n controls.enableZoom = true\n controls.enableDamping = false\n controls.maxDistance = 50\n controls.minDistance = 0.25\n controls.addEventListener('change', () => this.recenter())\n\n this.scene = scene\n this.world = world\n this.renderer = renderer\n this.camera = camera\n this.controls = controls\n this.plane = plane\n this.directionalLight = dirLight\n this.ambientLight = ambientLight\n\n this._setUp(this.up)\n }\n\n connectedCallback() {\n if (!this.querySelector('canvas')) {\n var canvas = this.renderer.domElement\n canvas.style.display = 'block'\n canvas.style.width = '100%'\n canvas.style.height = '100%'\n\n this.appendChild(canvas)\n }\n\n requestAnimationFrame(() => this.recenter())\n }\n\n disconnectedCallback() {}\n\n attributeChangedCallback(attr: string, oldval: any, newval: any) {\n this.recenter()\n\n switch (attr) {\n case 'package':\n case 'urdf': {\n this._scheduleLoad()\n break\n }\n\n case 'up': {\n this._setUp(this.up)\n break\n }\n\n case 'ambient-color': {\n this.ambientLight.color.set(this.ambientColor)\n this.ambientLight.groundColor.set('#000').lerp(this.ambientLight.color, 0.5)\n break\n }\n\n case 'ignore-limits': {\n this._setIgnoreLimits(this.ignoreLimits, true)\n break\n }\n }\n }\n\n /* Public API */\n updateSize() {\n const r = this.renderer\n const w = this.clientWidth\n const h = this.clientHeight\n\n const currsize = r.getSize(new THREE.Vector2())\n\n if (currsize.width !== w || currsize.height !== h) {\n this.recenter()\n }\n\n r.setPixelRatio(window.devicePixelRatio)\n r.setSize(w, h, false)\n\n this.camera.aspect = w / h\n this.camera.updateProjectionMatrix()\n }\n\n redraw() {\n if (this.parentNode && this._dirty) {\n this._dirty = false\n try {\n this.updateSize()\n\n if (!this.noAutoRecenter) {\n this._updateEnvironment()\n }\n\n this.renderer.render(this.scene, this.camera)\n\n // update controls after the environment in\n // case the controls are retargeted\n this.controls.update()\n } catch (err) {\n console.error(err)\n } finally {\n this._dirty = true\n }\n }\n }\n\n recenter() {\n this._updateEnvironment()\n this.redraw()\n }\n\n // Set the joint with jointName to\n // angle in degrees\n setJointValue(jointName: string, ...values: Number[]) {\n if (!this.robot) return\n if (!this.robot.joints[jointName]) return\n\n if (this.robot.joints[jointName].setJointValue(values[0], values[1], values[2]) as any) {\n this.redraw()\n this.dispatchEvent(new CustomEvent('angle-change', { bubbles: true, cancelable: true, detail: jointName }))\n }\n }\n\n setJointValues(values: Number[]) {\n for (const name in values) this.setJointValue(name, values[name])\n }\n\n /* Private Functions */\n // Updates the position of the plane to be at the\n // lowest point below the robot and focuses the\n // camera on the center of the scene\n _updateEnvironment() {\n if (!this.robot) return\n\n this.world.updateMatrixWorld()\n\n const bbox = new THREE.Box3()\n bbox.setFromObject(this.robot)\n\n const center = bbox.getCenter(new THREE.Vector3())\n this.controls.target.y = center.y\n this.plane.position.y = bbox.min.y - 1e-3\n\n const dirLight = this.directionalLight\n dirLight.castShadow = this.displayShadow\n\n if (this.displayShadow) {\n // Update the shadow camera rendering bounds to encapsulate the\n // model. We use the bounding sphere of the bounding box for\n // simplicity -- this could be a tighter fit.\n const sphere = bbox.getBoundingSphere(new THREE.Sphere())\n const minmax = sphere.radius\n const cam = dirLight.shadow.camera\n cam.left = cam.bottom = -minmax\n cam.right = cam.top = minmax\n\n // Update the camera to focus on the center of the model so the\n // shadow can encapsulate it\n const offset = dirLight.position.clone().sub(dirLight.target.position)\n dirLight.target.position.copy(center)\n dirLight.position.copy(center).add(offset)\n\n cam.updateProjectionMatrix()\n }\n }\n\n _scheduleLoad() {\n // if our current model is already what's being requested\n // or has been loaded then early out\n if (this._prevload === `${this.package}|${this.urdf}`) return\n this._prevload = `${this.package}|${this.urdf}`\n\n // if we're already waiting on a load then early out\n if (this._loadScheduled) return\n this._loadScheduled = true\n\n if (this.robot) {\n this.robot.traverse((c: any) => c.dispose && c.dispose())\n this.robot.parent!.remove(this.robot)\n delete this.robot\n }\n\n requestAnimationFrame(() => {\n this._loadUrdf(this.package, this.urdf)\n this._loadScheduled = false\n })\n }\n\n // Watch the package and urdf field and load the robot model.\n // This should _only_ be called from _scheduleLoad because that\n // ensures the that current robot has been removed\n _loadUrdf(pkg: string, urdf: string) {\n this.dispatchEvent(new CustomEvent('urdf-change', { bubbles: true, cancelable: true, composed: true }))\n\n if (urdf) {\n // Keep track of this request and make\n // sure it doesn't get overwritten by\n // a subsequent one\n this._requestId++\n const requestId = this._requestId\n\n const updateMaterials = (mesh: URDFRobot) => {\n mesh.traverse(c => {\n if ((c as any).isMesh) {\n c.castShadow = true\n c.receiveShadow = true\n\n if ((c as any).material) {\n const mats = (Array.isArray((c as any).material) ? (c as any).material : [(c as any).material]).map(\n (m: any) => {\n if (m instanceof THREE.MeshBasicMaterial) {\n m = new THREE.MeshPhongMaterial()\n }\n\n // FIXME THREE.GammaEncoding is removed at v136\n // if (m.map) {\n // m.map.encoding = THREE.GammaEncoding\n // }\n\n return m\n }\n )\n\n ;(c as any).material = mats.length === 1 ? mats[0] : mats\n }\n }\n })\n }\n\n if (pkg.includes(':') && pkg.split(':')[1].substring(0, 2) !== '//') {\n // E.g. pkg = \"pkg_name: path/to/pkg_name, pk2: path2/to/pk2\"}\n\n // Convert pkg(s) into a map. E.g.\n // { \"pkg_name\": \"path/to/pkg_name\",\n // \"pk2\": \"path2/to/pk2\" }\n\n pkg = pkg.split(',').reduce((map: any, value: string) => {\n const split = value.split(/:/).filter(x => !!x)\n const pkgName = split.shift()!.trim()\n const pkgPath = split.join(':').trim()\n map[pkgName] = pkgPath\n\n return map\n }, {} as any)\n }\n\n let robot: URDFRobot\n const manager = new THREE.LoadingManager()\n manager.onLoad = () => {\n // If another request has come in to load a new\n // robot, then ignore this one\n if (this._requestId !== requestId) {\n robot.traverse(c => (c as any).dispose && (c as any).dispose())\n return\n }\n\n this.robot = robot\n\n this.world.add(robot)\n updateMaterials(robot)\n\n this._setIgnoreLimits(this.ignoreLimits)\n\n this.dispatchEvent(new CustomEvent('urdf-processed', { bubbles: true, cancelable: true, composed: true }))\n this.dispatchEvent(new CustomEvent('geometry-loaded', { bubbles: true, cancelable: true, composed: true }))\n\n this.recenter()\n }\n\n if (this.urlModifierFunc) {\n manager.setURLModifier(this.urlModifierFunc)\n }\n\n const checkXacro = /[.]/.exec(urdf) ? /[^.]+$/.exec(urdf) : undefined\n\n if (checkXacro && checkXacro[0] === 'xacro') {\n const xacroLoader = new XacroLoader()\n try {\n xacroLoader.load(\n urdf,\n xml => {\n const loader = new URDFLoader(manager)\n loader.packages = pkg\n loader.loadMeshCb = this.loadMeshFunc!\n loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' }\n robot = loader.parse(xml)\n },\n err => {\n console.error('xacroloader error: ', err)\n }\n )\n } catch (error) {\n console.error(error)\n }\n } else {\n const loader = new URDFLoader(manager)\n loader.packages = pkg\n loader.loadMeshCb = this.loadMeshFunc!\n loader.fetchOptions = { mode: 'cors', credentials: 'same-origin' }\n loader.load(urdf, model => (robot = model))\n }\n }\n }\n\n // Watch the coordinate frame and update the\n // rotation of the scene to match\n _setUp(up: string) {\n if (!up) up = '+Z'\n up = up.toUpperCase()\n const sign = up.replace(/[^-+]/g, '')[0] || '+'\n const axis = up.replace(/[^XYZ]/gi, '')[0] || 'Z'\n\n const PI = Math.PI\n const HALFPI = PI / 2\n if (axis === 'X') this.world.rotation.set(0, 0, sign === '+' ? HALFPI : -HALFPI)\n if (axis === 'Z') this.world.rotation.set(sign === '+' ? -HALFPI : HALFPI, 0, 0)\n if (axis === 'Y') this.world.rotation.set(sign === '+' ? 0 : PI, 0, 0)\n }\n\n // Updates the current robot's angles to ignore\n // joint limits or not\n _setIgnoreLimits(ignore: boolean, dispatch = false) {\n if (this.robot) {\n Object.values(this.robot.joints).forEach(joint => {\n joint.ignoreLimits = ignore\n joint.setJointValue(joint.jointValue[0], joint.jointValue[1], joint.jointValue[2])\n })\n }\n\n if (dispatch) {\n this.dispatchEvent(new CustomEvent('ignore-limits-change', { bubbles: true, cancelable: true, composed: true }))\n }\n }\n}\n"]}