File size: 1,964 Bytes
3aea7c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script lang="ts">
	// Three.js visualization of an URDF.
	import { T } from '@threlte/core';
	import { getRootLinks } from '../utils/UrdfParser';
	import UrdfLink from './UrdfLink.svelte';
	import { scale } from 'svelte/transition';
	import type IUrdfLink from '../interfaces/IUrdfLink';
	import type IUrdfJoint from '../interfaces/IUrdfJoint';
	import type IUrdfRobot from '../interfaces/IUrdfRobot';

	interface Props {
		robot: IUrdfRobot;
		position?: [x: number, y: number, z: number];
		quaternion?: [x: number, y: number, z: number, w: number];
		showName?: boolean;
		showVisual?: boolean;
		showCollision?: boolean;
		visualOpacity?: number;
		collisionOpacity?: number;
		collisionColor?: string;
		jointNames?: boolean;
		joints?: boolean;
		jointColor?: string;
		jointIndicatorColor?: string;
		nameHeight?: number;
		selectedLink?: IUrdfLink;
		selectedJoint?: IUrdfJoint;
		textScale?: number;
		highlightColor?: string;
	}
	let {
		robot,
		position = [0, 0, 0],
		quaternion = [0, 0, 0, 1],
		showName = true,
		showVisual = true,
		showCollision = true,
		visualOpacity = 1,
		collisionOpacity = 1,
		collisionColor = '#000000',
		jointNames = true,
		joints = true,
		jointColor = '#000000',
		jointIndicatorColor = '#000000',
		nameHeight = 0.1,
		selectedLink = undefined,
		selectedJoint = undefined,
		textScale = 1,
		highlightColor = '#000000'
	}: Props = $props();
</script>

<T.Group {position} {quaternion} scale={[10, 10, 10]} rotation={[-Math.PI / 2, 0, 0]}>
	{#each getRootLinks(robot) as link}
		<UrdfLink
			{robot}
			{link}
			{textScale}
			{showName}
			{showVisual}
			{showCollision}
			{visualOpacity}
			{collisionOpacity}
			{collisionColor}
			{jointNames}
			{joints}
			{jointColor}
			{jointIndicatorColor}
			{nameHeight}
			{selectedLink}
			{selectedJoint}
			{highlightColor}
			showLine={false}
			opacity={1}
			isInteractive={false}
		/>
	{/each}
</T.Group>

<!-- From https://github.com/brean/urdf-viewer -->