@viamrobotics/motion-tools 1.13.0 → 1.14.0
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.
- package/dist/FrameConfigUpdater.svelte.js +1 -1
- package/dist/attribute.js +10 -2
- package/dist/buf/draw/v1/service_connect.d.ts +14 -25
- package/dist/buf/draw/v1/service_connect.js +14 -25
- package/dist/buf/draw/v1/service_pb.d.ts +61 -76
- package/dist/buf/draw/v1/service_pb.js +58 -111
- package/dist/buffer.d.ts +56 -7
- package/dist/buffer.js +70 -12
- package/dist/color.js +3 -3
- package/dist/components/App.svelte +1 -5
- package/dist/components/Camera.svelte +1 -7
- package/dist/components/Camera.svelte.d.ts +0 -1
- package/dist/components/CameraControls.svelte +2 -2
- package/dist/components/{Arrows → Entities/Arrows}/ArrowGroups.svelte +3 -3
- package/dist/components/{Arrows → Entities/Arrows}/Arrows.svelte +6 -6
- package/dist/components/{Arrows → Entities/Arrows}/Arrows.svelte.d.ts +1 -1
- package/dist/components/{Entities.svelte → Entities/Entities.svelte} +7 -3
- package/dist/components/Entities/Frame.svelte +86 -0
- package/dist/components/{Frame.svelte.d.ts → Entities/Frame.svelte.d.ts} +1 -0
- package/dist/components/{GLTF.svelte → Entities/GLTF.svelte} +5 -5
- package/dist/components/Entities/Geometry.svelte +75 -0
- package/dist/components/Entities/Geometry.svelte.d.ts +10 -0
- package/dist/components/{Label.svelte → Entities/Label.svelte} +1 -1
- package/dist/components/Entities/Line.svelte +90 -0
- package/dist/components/Entities/Mesh.svelte +130 -0
- package/dist/components/Entities/Mesh.svelte.d.ts +4 -0
- package/dist/components/{Points.svelte → Entities/Points.svelte} +5 -5
- package/dist/components/{Pose.svelte → Entities/Pose.svelte} +3 -3
- package/dist/{hooks/useObjectEvents.svelte.d.ts → components/Entities/hooks/useEntityEvents.svelte.d.ts} +1 -1
- package/dist/{hooks/useObjectEvents.svelte.js → components/Entities/hooks/useEntityEvents.svelte.js} +6 -6
- package/dist/components/FileDrop/file-names.js +6 -3
- package/dist/components/FileDrop/snapshot-dropper.js +8 -4
- package/dist/components/FileDrop/useFileDrop.svelte.js +9 -6
- package/dist/components/Lasso/Lasso.svelte +4 -4
- package/dist/components/PCD.svelte +14 -6
- package/dist/components/PCD.svelte.d.ts +2 -0
- package/dist/components/Scene.svelte +1 -3
- package/dist/components/Selected.svelte +2 -0
- package/dist/components/StaticGeometries.svelte +1 -1
- package/dist/components/overlay/AddRelationship.svelte +1 -1
- package/dist/components/overlay/LiveUpdatesBanner.svelte +4 -6
- package/dist/components/overlay/left-pane/buildTree.js +15 -0
- package/dist/components/overlay/settings/Settings.svelte +11 -13
- package/dist/components/overlay/widgets/Camera.svelte +11 -9
- package/dist/components/xr/ArmTeleop.svelte +33 -33
- package/dist/components/xr/CameraFeed.svelte +21 -23
- package/dist/components/xr/JointLimitsWidget.svelte +19 -5
- package/dist/components/xr/XRConfigPanel.svelte +17 -16
- package/dist/components/xr/XRControllerSettings.svelte +5 -4
- package/dist/components/xr/XRToast.svelte +11 -6
- package/dist/ecs/relations.d.ts +1 -0
- package/dist/ecs/relations.js +1 -0
- package/dist/ecs/traits.d.ts +2 -19
- package/dist/ecs/traits.js +33 -6
- package/dist/ecs/useQuery.svelte.js +3 -3
- package/dist/format.js +1 -1
- package/dist/hooks/use3DModels.svelte.js +36 -38
- package/dist/hooks/useConfigFrames.svelte.js +2 -7
- package/dist/hooks/useDrawAPI.svelte.js +1 -1
- package/dist/hooks/useFramelessComponents.svelte.js +1 -1
- package/dist/hooks/useFrames.svelte.js +62 -56
- package/dist/hooks/useGeometries.svelte.js +59 -36
- package/dist/hooks/useLinked.svelte.js +5 -4
- package/dist/hooks/usePartConfig.svelte.js +16 -17
- package/dist/hooks/usePointcloudObjects.svelte.js +107 -62
- package/dist/hooks/usePointclouds.svelte.js +50 -32
- package/dist/hooks/usePose.svelte.js +3 -7
- package/dist/hooks/useResizable.svelte.js +4 -3
- package/dist/hooks/useSettings.svelte.js +2 -2
- package/dist/hooks/useWeblabs.svelte.js +3 -2
- package/dist/hooks/useWorldState.svelte.js +31 -28
- package/dist/loaders/pcd/index.js +2 -1
- package/dist/loaders/pcd/worker.inline.d.ts +1 -1
- package/dist/loaders/pcd/worker.inline.js +1 -1
- package/dist/loaders/pcd/worker.js +1 -1
- package/dist/metadata.d.ts +22 -0
- package/dist/metadata.js +66 -0
- package/dist/snapshot.d.ts +20 -0
- package/dist/snapshot.js +72 -28
- package/dist/three/InstancedArrows/InstancedArrows.js +1 -1
- package/dist/three/InstancedArrows/box.js +1 -1
- package/dist/three/InstancedArrows/raycast.js +12 -12
- package/dist/three/OBBHelper.d.ts +3 -2
- package/dist/three/OBBHelper.js +17 -5
- package/package.json +19 -11
- package/dist/WorldObject.svelte.d.ts +0 -27
- package/dist/WorldObject.svelte.js +0 -114
- package/dist/components/Frame.svelte +0 -89
- package/dist/components/Geometry.svelte +0 -211
- package/dist/components/Geometry.svelte.d.ts +0 -19
- package/dist/components/Line.svelte +0 -43
- /package/dist/components/{Arrows → Entities/Arrows}/ArrowGroups.svelte.d.ts +0 -0
- /package/dist/components/{Entities.svelte.d.ts → Entities/Entities.svelte.d.ts} +0 -0
- /package/dist/components/{GLTF.svelte.d.ts → Entities/GLTF.svelte.d.ts} +0 -0
- /package/dist/components/{Label.svelte.d.ts → Entities/Label.svelte.d.ts} +0 -0
- /package/dist/components/{Line.svelte.d.ts → Entities/Line.svelte.d.ts} +0 -0
- /package/dist/components/{LineDots.svelte → Entities/LineDots.svelte} +0 -0
- /package/dist/components/{LineDots.svelte.d.ts → Entities/LineDots.svelte.d.ts} +0 -0
- /package/dist/components/{LineGeometry.svelte → Entities/LineGeometry.svelte} +0 -0
- /package/dist/components/{LineGeometry.svelte.d.ts → Entities/LineGeometry.svelte.d.ts} +0 -0
- /package/dist/components/{Points.svelte.d.ts → Entities/Points.svelte.d.ts} +0 -0
- /package/dist/components/{Pose.svelte.d.ts → Entities/Pose.svelte.d.ts} +0 -0
|
@@ -3566,7 +3566,7 @@ void main() {
|
|
|
3566
3566
|
#include <fog_fragment>
|
|
3567
3567
|
}\`,C={alphahash_fragment:Bi,alphahash_pars_fragment:zi,alphamap_fragment:Vi,alphamap_pars_fragment:ki,alphatest_fragment:Gi,alphatest_pars_fragment:Hi,aomap_fragment:Wi,aomap_pars_fragment:Xi,batching_pars_vertex:qi,batching_vertex:Yi,begin_vertex:Zi,beginnormal_vertex:Ji,bsdfs:\$i,iridescence_fragment:Ki,bumpmap_pars_fragment:Qi,clipping_planes_fragment:ji,clipping_planes_pars_fragment:es,clipping_planes_pars_vertex:ts,clipping_planes_vertex:ns,color_fragment:is,color_pars_fragment:ss,color_pars_vertex:rs,color_vertex:as,common:os,cube_uv_reflection_fragment:ls,defaultnormal_vertex:cs,displacementmap_pars_vertex:hs,displacementmap_vertex:us,emissivemap_fragment:ds,emissivemap_pars_fragment:fs,colorspace_fragment:ps,colorspace_pars_fragment:ms,envmap_fragment:gs,envmap_common_pars_fragment:_s,envmap_pars_fragment:xs,envmap_pars_vertex:vs,envmap_physical_pars_fragment:Is,envmap_vertex:ys,fog_vertex:Ms,fog_pars_vertex:Ss,fog_fragment:bs,fog_pars_fragment:As,gradientmap_pars_fragment:Ts,lightmap_pars_fragment:Es,lights_lambert_fragment:ws,lights_lambert_pars_fragment:Cs,lights_pars_begin:Rs,lights_toon_fragment:Ps,lights_toon_pars_fragment:Ls,lights_phong_fragment:Ds,lights_phong_pars_fragment:Us,lights_physical_fragment:Ns,lights_physical_pars_fragment:Fs,lights_fragment_begin:Os,lights_fragment_maps:Bs,lights_fragment_end:zs,logdepthbuf_fragment:Vs,logdepthbuf_pars_fragment:ks,logdepthbuf_pars_vertex:Gs,logdepthbuf_vertex:Hs,map_fragment:Ws,map_pars_fragment:Xs,map_particle_fragment:qs,map_particle_pars_fragment:Ys,metalnessmap_fragment:Zs,metalnessmap_pars_fragment:Js,morphinstance_vertex:\$s,morphcolor_vertex:Ks,morphnormal_vertex:Qs,morphtarget_pars_vertex:js,morphtarget_vertex:er,normal_fragment_begin:tr,normal_fragment_maps:nr,normal_pars_fragment:ir,normal_pars_vertex:sr,normal_vertex:rr,normalmap_pars_fragment:ar,clearcoat_normal_fragment_begin:or,clearcoat_normal_fragment_maps:lr,clearcoat_pars_fragment:cr,iridescence_pars_fragment:hr,opaque_fragment:ur,packing:dr,premultiplied_alpha_fragment:fr,project_vertex:pr,dithering_fragment:mr,dithering_pars_fragment:gr,roughnessmap_fragment:_r,roughnessmap_pars_fragment:xr,shadowmap_pars_fragment:vr,shadowmap_pars_vertex:yr,shadowmap_vertex:Mr,shadowmask_pars_fragment:Sr,skinbase_vertex:br,skinning_pars_vertex:Ar,skinning_vertex:Tr,skinnormal_vertex:Er,specularmap_fragment:wr,specularmap_pars_fragment:Cr,tonemapping_fragment:Rr,tonemapping_pars_fragment:Ir,transmission_fragment:Pr,transmission_pars_fragment:Lr,uv_pars_fragment:Dr,uv_pars_vertex:Ur,uv_vertex:Nr,worldpos_vertex:Fr,background_vert:Or,background_frag:Br,backgroundCube_vert:zr,backgroundCube_frag:Vr,cube_vert:kr,cube_frag:Gr,depth_vert:Hr,depth_frag:Wr,distance_vert:Xr,distance_frag:qr,equirect_vert:Yr,equirect_frag:Zr,linedashed_vert:Jr,linedashed_frag:\$r,meshbasic_vert:Kr,meshbasic_frag:Qr,meshlambert_vert:jr,meshlambert_frag:ea,meshmatcap_vert:ta,meshmatcap_frag:na,meshnormal_vert:ia,meshnormal_frag:sa,meshphong_vert:ra,meshphong_frag:aa,meshphysical_vert:oa,meshphysical_frag:la,meshtoon_vert:ca,meshtoon_frag:ha,points_vert:ua,points_frag:da,shadow_vert:fa,shadow_frag:pa,sprite_vert:ma,sprite_frag:ga},M={common:{diffuse:{value:new D(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new w},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new w}},envmap:{envMap:{value:null},envMapRotation:{value:new w},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new w}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new w}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new w},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new w},normalScale:{value:new H(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new w},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new w}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new w}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new w}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new D(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new D(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0},uvTransform:{value:new w}},sprite:{diffuse:{value:new D(16777215)},opacity:{value:1},center:{value:new H(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new w},alphaMap:{value:null},alphaMapTransform:{value:new w},alphaTest:{value:0}}},fi={basic:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.fog]),vertexShader:C.meshbasic_vert,fragmentShader:C.meshbasic_frag},lambert:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.fog,M.lights,{emissive:{value:new D(0)}}]),vertexShader:C.meshlambert_vert,fragmentShader:C.meshlambert_frag},phong:{uniforms:W([M.common,M.specularmap,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.fog,M.lights,{emissive:{value:new D(0)},specular:{value:new D(1118481)},shininess:{value:30}}]),vertexShader:C.meshphong_vert,fragmentShader:C.meshphong_frag},standard:{uniforms:W([M.common,M.envmap,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.roughnessmap,M.metalnessmap,M.fog,M.lights,{emissive:{value:new D(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:C.meshphysical_vert,fragmentShader:C.meshphysical_frag},toon:{uniforms:W([M.common,M.aomap,M.lightmap,M.emissivemap,M.bumpmap,M.normalmap,M.displacementmap,M.gradientmap,M.fog,M.lights,{emissive:{value:new D(0)}}]),vertexShader:C.meshtoon_vert,fragmentShader:C.meshtoon_frag},matcap:{uniforms:W([M.common,M.bumpmap,M.normalmap,M.displacementmap,M.fog,{matcap:{value:null}}]),vertexShader:C.meshmatcap_vert,fragmentShader:C.meshmatcap_frag},points:{uniforms:W([M.points,M.fog]),vertexShader:C.points_vert,fragmentShader:C.points_frag},dashed:{uniforms:W([M.common,M.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:C.linedashed_vert,fragmentShader:C.linedashed_frag},depth:{uniforms:W([M.common,M.displacementmap]),vertexShader:C.depth_vert,fragmentShader:C.depth_frag},normal:{uniforms:W([M.common,M.bumpmap,M.normalmap,M.displacementmap,{opacity:{value:1}}]),vertexShader:C.meshnormal_vert,fragmentShader:C.meshnormal_frag},sprite:{uniforms:W([M.sprite,M.fog]),vertexShader:C.sprite_vert,fragmentShader:C.sprite_frag},background:{uniforms:{uvTransform:{value:new w},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:C.background_vert,fragmentShader:C.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new w}},vertexShader:C.backgroundCube_vert,fragmentShader:C.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:C.cube_vert,fragmentShader:C.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:C.equirect_vert,fragmentShader:C.equirect_frag},distance:{uniforms:W([M.common,M.displacementmap,{referencePosition:{value:new x},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:C.distance_vert,fragmentShader:C.distance_frag},shadow:{uniforms:W([M.lights,M.fog,{color:{value:new D(0)},opacity:{value:1}}]),vertexShader:C.shadow_vert,fragmentShader:C.shadow_frag}};fi.physical={uniforms:W([fi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new w},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new w},clearcoatNormalScale:{value:new H(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new w},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new w},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new w},sheen:{value:0},sheenColor:{value:new D(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new w},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new w},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new w},transmissionSamplerSize:{value:new H},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new w},attenuationDistance:{value:0},attenuationColor:{value:new D(0)},specularColor:{value:new D(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new w},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new w},anisotropyVector:{value:new H},anisotropyMap:{value:null},anisotropyMapTransform:{value:new w}}]),vertexShader:C.meshphysical_vert,fragmentShader:C.meshphysical_frag};var Ld={[En]:"LINEAR_TONE_MAPPING",[wn]:"REINHARD_TONE_MAPPING",[Cn]:"CINEON_TONE_MAPPING",[Rn]:"ACES_FILMIC_TONE_MAPPING",[Pn]:"AGX_TONE_MAPPING",[Ln]:"NEUTRAL_TONE_MAPPING",[In]:"CUSTOM_TONE_MAPPING"};var Dd=new Float32Array(16),Ud=new Float32Array(9),Nd=new Float32Array(4);var Fd={[En]:"Linear",[wn]:"Reinhard",[Cn]:"Cineon",[Rn]:"ACESFilmic",[Pn]:"AgX",[Ln]:"Neutral",[In]:"Custom"};var Od={[Kn]:"SHADOWMAP_TYPE_PCF",[Qn]:"SHADOWMAP_TYPE_VSM"};var Bd={[ni]:"ENVMAP_TYPE_CUBE",[Un]:"ENVMAP_TYPE_CUBE",[ii]:"ENVMAP_TYPE_CUBE_UV"};var zd={[Un]:"ENVMAP_MODE_REFRACTION"};var Vd={[jn]:"ENVMAP_BLENDING_MULTIPLY",[ei]:"ENVMAP_BLENDING_MIX",[ti]:"ENVMAP_BLENDING_ADD"};var kd={[vn]:yn,[Mn]:An,[Sn]:Tn,[We]:bn,[yn]:vn,[An]:Mn,[Tn]:Sn,[bn]:We};var Gd=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);var Ot=class extends Ae{constructor(e){super(e),this.littleEndian=!0}load(e,t,n,i){let s=this,r=new Ke(s.manager);r.setPath(s.path),r.setResponseType("arraybuffer"),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(e,function(a){try{t(s.parse(a))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}_getDataView(e,t,n,i){switch(n){case"F":return i===8?e.getFloat64(t,this.littleEndian):e.getFloat32(t,this.littleEndian);case"I":return i===1?e.getInt8(t):i===2?e.getInt16(t,this.littleEndian):e.getInt32(t,this.littleEndian);case"U":return i===1?e.getUint8(t):i===2?e.getUint16(t,this.littleEndian):e.getUint32(t,this.littleEndian)}}parse(e){function t(d,h){let m=d.length,_=new Uint8Array(h),g=0,y=0,v,b,S;do if(v=d[g++],v<32){if(v++,y+v>h)throw new Error("Output buffer is not large enough");if(g+v>m)throw new Error("Invalid compressed data");do _[y++]=d[g++];while(--v)}else{if(b=v>>5,S=y-((v&31)<<8)-1,g>=m)throw new Error("Invalid compressed data");if(b===7&&(b+=d[g++],g>=m))throw new Error("Invalid compressed data");if(S-=d[g++],y+b+2>h)throw new Error("Output buffer is not large enough");if(S<0)throw new Error("Invalid compressed data");if(S>=y)throw new Error("Invalid compressed data");do _[y++]=_[S++];while(--b+2)}while(g<m);return _}function n(d){let h={},m=new Uint8Array(d),_="",g="",y=0,v=!1,b=m.length;for(;y<b&&v===!1;){let A=String.fromCharCode(m[y++]);A===\`
|
|
3568
3568
|
\`||A==="\\r"?(g.trim().toLowerCase().startsWith("data")&&(v=!0),g=""):g+=A,_+=A}let S=_.search(/[\\r\\n]DATA\\s(\\S*)\\s/i),E=/[\\r\\n]DATA\\s(\\S*)\\s/i.exec(_.slice(S-1));if(h.data=E[1],h.headerLen=E[0].length+S,h.str=_.slice(0,h.headerLen),h.str=h.str.replace(/#.*/gi,""),h.version=/^VERSION (.*)/im.exec(h.str),h.fields=/^FIELDS (.*)/im.exec(h.str),h.size=/^SIZE (.*)/im.exec(h.str),h.type=/^TYPE (.*)/im.exec(h.str),h.count=/^COUNT (.*)/im.exec(h.str),h.width=/^WIDTH (.*)/im.exec(h.str),h.height=/^HEIGHT (.*)/im.exec(h.str),h.viewpoint=/^VIEWPOINT (.*)/im.exec(h.str),h.points=/^POINTS (.*)/im.exec(h.str),h.version!==null&&(h.version=parseFloat(h.version[1])),h.fields=h.fields!==null?h.fields[1].split(" "):[],h.type!==null&&(h.type=h.type[1].split(" ")),h.width!==null&&(h.width=parseInt(h.width[1])),h.height!==null&&(h.height=parseInt(h.height[1])),h.viewpoint!==null&&(h.viewpoint=h.viewpoint[1]),h.points!==null&&(h.points=parseInt(h.points[1],10)),h.points===null&&(h.points=h.width*h.height),h.size!==null&&(h.size=h.size[1].split(" ").map(function(A){return parseInt(A,10)})),h.count!==null)h.count=h.count[1].split(" ").map(function(A){return parseInt(A,10)});else{h.count=[];for(let A=0,P=h.fields.length;A<P;A++)h.count.push(1)}h.offset={};let T=0;for(let A=0,P=h.fields.length;A<P;A++)h.data==="ascii"?h.offset[h.fields[A]]=A:(h.offset[h.fields[A]]=T,T+=h.size[A]*h.count[A]);return h.rowSize=T,h}let i=n(e),s=[],r=[],a=[],l=[],o=[],c=new D;if(i.data==="ascii"){let d=i.offset,_=new TextDecoder().decode(e).slice(i.headerLen).split(\`
|
|
3569
|
-
\`);for(let g=0,y=_.length;g<y;g++){if(_[g]==="")continue;let v=_[g].split(" ");if(d.x!==void 0&&(s.push(parseFloat(v[d.x])),s.push(parseFloat(v[d.y])),s.push(parseFloat(v[d.z]))),d.rgb!==void 0){let b=i.fields.findIndex(U=>U==="rgb"),S=i.type[b],E=parseFloat(v[d.rgb]),T=E;if(S==="F"){let U=new Float32Array(1);U[0]=E,T=new Int32Array(U.buffer)[0]}let A=(T>>16&255)/255,P=(T>>8&255)/255,O=(T>>0&255)/255;c.setRGB(A,P,O,G),a.push(c.r,c.g,c.b)}d.normal_x!==void 0&&(r.push(parseFloat(v[d.normal_x])),r.push(parseFloat(v[d.normal_y])),r.push(parseFloat(v[d.normal_z]))),d.intensity!==void 0&&l.push(parseFloat(v[d.intensity])),d.label!==void 0&&o.push(parseInt(v[d.label]))}}if(i.data==="binary_compressed"){let d=new Uint32Array(e.slice(i.headerLen,i.headerLen+8)),h=d[0],m=d[1],_=t(new Uint8Array(e,i.headerLen+8,h),m),g=new DataView(_.buffer),y=i.offset;for(let v=0;v<i.points;v++){if(y.x!==void 0){let b=i.fields.indexOf("x"),S=i.fields.indexOf("y"),E=i.fields.indexOf("z");s.push(this._getDataView(g,i.points*y.x+i.size[b]*v,i.type[b],i.size[b])),s.push(this._getDataView(g,i.points*y.y+i.size[S]*v,i.type[S],i.size[S])),s.push(this._getDataView(g,i.points*y.z+i.size[E]*v,i.type[E],i.size[E]))}if(y.rgb!==void 0){let b=i.fields.indexOf("rgb"),S=g.getUint8(i.points*y.rgb+i.size[b]*v+2)/255,E=g.getUint8(i.points*y.rgb+i.size[b]*v+1)/255,T=g.getUint8(i.points*y.rgb+i.size[b]*v+0)/255;c.setRGB(S,E,T,G),a.push(c.r,c.g,c.b)}if(y.normal_x!==void 0){let b=i.fields.indexOf("normal_x"),S=i.fields.indexOf("normal_y"),E=i.fields.indexOf("normal_z");r.push(this._getDataView(g,i.points*y.normal_x+i.size[b]*v,i.type[b],i.size[b])),r.push(this._getDataView(g,i.points*y.normal_y+i.size[S]*v,i.type[S],i.size[S])),r.push(this._getDataView(g,i.points*y.normal_z+i.size[E]*v,i.type[E],i.size[E]))}if(y.intensity!==void 0){let b=i.fields.indexOf("intensity");l.push(this._getDataView(g,i.points*y.intensity+i.size[b]*v,i.type[b],i.size[b]))}if(y.label!==void 0){let b=i.fields.indexOf("label");o.push(g.getInt32(i.points*y.label+i.size[b]*v,this.littleEndian))}}}if(i.data==="binary"){let d=new DataView(e,i.headerLen),h=i.offset;for(let m=0,_=0;m<i.points;m++,_+=i.rowSize){if(h.x!==void 0){let g=i.fields.indexOf("x"),y=i.fields.indexOf("y"),v=i.fields.indexOf("z");s.push(this._getDataView(d,_+h.x,i.type[g],i.size[g])),s.push(this._getDataView(d,_+h.y,i.type[y],i.size[y])),s.push(this._getDataView(d,_+h.z,i.type[v],i.size[v]))}if(h.rgb!==void 0){let g=d.getUint8(_+h.rgb+2)/255,y=d.getUint8(_+h.rgb+1)/255,v=d.getUint8(_+h.rgb+0)/255;c.setRGB(g,y,v,G),a.push(c.r,c.g,c.b)}if(h.normal_x!==void 0){let g=i.fields.indexOf("normal_x"),y=i.fields.indexOf("normal_y"),v=i.fields.indexOf("normal_z");r.push(this._getDataView(d,_+h.normal_x,i.type[g],i.size[g])),r.push(this._getDataView(d,_+h.normal_y,i.type[y],i.size[y])),r.push(this._getDataView(d,_+h.normal_z,i.type[v],i.size[v]))}if(h.intensity!==void 0){let g=i.fields.indexOf("intensity");l.push(this._getDataView(d,_+h.intensity,i.type[g],i.size[g]))}h.label!==void 0&&o.push(d.getInt32(_+h.label,this.littleEndian))}}let u=new Ne;s.length>0&&u.setAttribute("position",new oe(s,3)),r.length>0&&u.setAttribute("normal",new oe(r,3)),a.length>0&&u.setAttribute("color",new oe(a,3)),l.length>0&&u.setAttribute("intensity",new oe(l,1)),o.length>0&&u.setAttribute("label",new Ze(o,1)),u.computeBoundingSphere();let f=new Fe({size:.005});return a.length>0&&(f.vertexColors=!0),new Je(u,f)}};var _a=new Ot;
|
|
3569
|
+
\`);for(let g=0,y=_.length;g<y;g++){if(_[g]==="")continue;let v=_[g].split(" ");if(d.x!==void 0&&(s.push(parseFloat(v[d.x])),s.push(parseFloat(v[d.y])),s.push(parseFloat(v[d.z]))),d.rgb!==void 0){let b=i.fields.findIndex(U=>U==="rgb"),S=i.type[b],E=parseFloat(v[d.rgb]),T=E;if(S==="F"){let U=new Float32Array(1);U[0]=E,T=new Int32Array(U.buffer)[0]}let A=(T>>16&255)/255,P=(T>>8&255)/255,O=(T>>0&255)/255;c.setRGB(A,P,O,G),a.push(c.r,c.g,c.b)}d.normal_x!==void 0&&(r.push(parseFloat(v[d.normal_x])),r.push(parseFloat(v[d.normal_y])),r.push(parseFloat(v[d.normal_z]))),d.intensity!==void 0&&l.push(parseFloat(v[d.intensity])),d.label!==void 0&&o.push(parseInt(v[d.label]))}}if(i.data==="binary_compressed"){let d=new Uint32Array(e.slice(i.headerLen,i.headerLen+8)),h=d[0],m=d[1],_=t(new Uint8Array(e,i.headerLen+8,h),m),g=new DataView(_.buffer),y=i.offset;for(let v=0;v<i.points;v++){if(y.x!==void 0){let b=i.fields.indexOf("x"),S=i.fields.indexOf("y"),E=i.fields.indexOf("z");s.push(this._getDataView(g,i.points*y.x+i.size[b]*v,i.type[b],i.size[b])),s.push(this._getDataView(g,i.points*y.y+i.size[S]*v,i.type[S],i.size[S])),s.push(this._getDataView(g,i.points*y.z+i.size[E]*v,i.type[E],i.size[E]))}if(y.rgb!==void 0){let b=i.fields.indexOf("rgb"),S=g.getUint8(i.points*y.rgb+i.size[b]*v+2)/255,E=g.getUint8(i.points*y.rgb+i.size[b]*v+1)/255,T=g.getUint8(i.points*y.rgb+i.size[b]*v+0)/255;c.setRGB(S,E,T,G),a.push(c.r,c.g,c.b)}if(y.normal_x!==void 0){let b=i.fields.indexOf("normal_x"),S=i.fields.indexOf("normal_y"),E=i.fields.indexOf("normal_z");r.push(this._getDataView(g,i.points*y.normal_x+i.size[b]*v,i.type[b],i.size[b])),r.push(this._getDataView(g,i.points*y.normal_y+i.size[S]*v,i.type[S],i.size[S])),r.push(this._getDataView(g,i.points*y.normal_z+i.size[E]*v,i.type[E],i.size[E]))}if(y.intensity!==void 0){let b=i.fields.indexOf("intensity");l.push(this._getDataView(g,i.points*y.intensity+i.size[b]*v,i.type[b],i.size[b]))}if(y.label!==void 0){let b=i.fields.indexOf("label");o.push(g.getInt32(i.points*y.label+i.size[b]*v,this.littleEndian))}}}if(i.data==="binary"){let d=new DataView(e,i.headerLen),h=i.offset;for(let m=0,_=0;m<i.points;m++,_+=i.rowSize){if(h.x!==void 0){let g=i.fields.indexOf("x"),y=i.fields.indexOf("y"),v=i.fields.indexOf("z");s.push(this._getDataView(d,_+h.x,i.type[g],i.size[g])),s.push(this._getDataView(d,_+h.y,i.type[y],i.size[y])),s.push(this._getDataView(d,_+h.z,i.type[v],i.size[v]))}if(h.rgb!==void 0){let g=d.getUint8(_+h.rgb+2)/255,y=d.getUint8(_+h.rgb+1)/255,v=d.getUint8(_+h.rgb+0)/255;c.setRGB(g,y,v,G),a.push(c.r,c.g,c.b)}if(h.normal_x!==void 0){let g=i.fields.indexOf("normal_x"),y=i.fields.indexOf("normal_y"),v=i.fields.indexOf("normal_z");r.push(this._getDataView(d,_+h.normal_x,i.type[g],i.size[g])),r.push(this._getDataView(d,_+h.normal_y,i.type[y],i.size[y])),r.push(this._getDataView(d,_+h.normal_z,i.type[v],i.size[v]))}if(h.intensity!==void 0){let g=i.fields.indexOf("intensity");l.push(this._getDataView(d,_+h.intensity,i.type[g],i.size[g]))}h.label!==void 0&&o.push(d.getInt32(_+h.label,this.littleEndian))}}let u=new Ne;s.length>0&&u.setAttribute("position",new oe(s,3)),r.length>0&&u.setAttribute("normal",new oe(r,3)),a.length>0&&u.setAttribute("color",new oe(a,3)),l.length>0&&u.setAttribute("intensity",new oe(l,1)),o.length>0&&u.setAttribute("label",new Ze(o,1)),u.computeBoundingSphere();let f=new Fe({size:.005});return a.length>0&&(f.vertexColors=!0),new Je(u,f)}};var _a=new Ot;globalThis.onmessage=async p=>{let{data:e,id:t}=p.data;if(!(e instanceof Uint8Array)){postMessage({id:t,error:"Invalid data format"});return}try{let n=_a.parse(e.buffer);if(n.geometry){let i=n.geometry.attributes.position?.array??new Float32Array(0),s=n.geometry.attributes.color?.array??null,r=s?new Uint8Array(s.length):null;if(r)for(let a=0,l=s.length;a<l;a++)r[a]=Math.round(s[a]*255);postMessage({positions:i,colors:r,id:t},r?[i.buffer,r.buffer]:[i.buffer])}else postMessage({id:t,error:"Failed to extract geometry"})}catch(n){postMessage({id:t,error:n.message})}};})();
|
|
3570
3570
|
/*! Bundled license information:
|
|
3571
3571
|
|
|
3572
3572
|
three/build/three.core.js:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PCDLoader } from 'three/examples/jsm/loaders/PCDLoader.js';
|
|
2
2
|
const loader = new PCDLoader();
|
|
3
|
-
|
|
3
|
+
globalThis.onmessage = async (event) => {
|
|
4
4
|
const { data, id } = event.data;
|
|
5
5
|
if (!(data instanceof Uint8Array)) {
|
|
6
6
|
postMessage({ id, error: 'Invalid data format' });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PlainMessage, Struct } from '@viamrobotics/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for a Viam `Transform`.
|
|
4
|
+
*
|
|
5
|
+
* Per the API this can be a struct of any data, so we type this version for
|
|
6
|
+
* fields we use and how we expect them to be defined.
|
|
7
|
+
*/
|
|
8
|
+
export type Metadata = {
|
|
9
|
+
colors?: Uint8Array<ArrayBuffer>;
|
|
10
|
+
};
|
|
11
|
+
/** Type guard that checks whether a string is a recognised {@link Metadata} field name. */
|
|
12
|
+
export declare const isMetadataKey: (key: string) => key is keyof Metadata;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts typed {@link Metadata} from a proto `Struct` fields map.
|
|
15
|
+
*
|
|
16
|
+
* The `colors` field is expected as a base64-encoded string (the only way to
|
|
17
|
+
* represent binary data in a `google.protobuf.Value`), which is decoded into
|
|
18
|
+
* a `Uint8Array`.
|
|
19
|
+
*
|
|
20
|
+
* Unknown keys are silently ignored.
|
|
21
|
+
*/
|
|
22
|
+
export declare const parseMetadata: (fields?: PlainMessage<Struct>["fields"]) => Metadata;
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Type guard that checks whether a string is a recognised {@link Metadata} field name. */
|
|
2
|
+
export const isMetadataKey = (key) => {
|
|
3
|
+
return key === 'colors';
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Extracts typed {@link Metadata} from a proto `Struct` fields map.
|
|
7
|
+
*
|
|
8
|
+
* The `colors` field is expected as a base64-encoded string (the only way to
|
|
9
|
+
* represent binary data in a `google.protobuf.Value`), which is decoded into
|
|
10
|
+
* a `Uint8Array`.
|
|
11
|
+
*
|
|
12
|
+
* Unknown keys are silently ignored.
|
|
13
|
+
*/
|
|
14
|
+
export const parseMetadata = (fields = {}) => {
|
|
15
|
+
const json = {};
|
|
16
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
17
|
+
if (!isMetadataKey(k))
|
|
18
|
+
continue;
|
|
19
|
+
const unwrappedValue = unwrapValue(v);
|
|
20
|
+
switch (k) {
|
|
21
|
+
case 'colors': {
|
|
22
|
+
if (typeof unwrappedValue === 'string') {
|
|
23
|
+
const binary = atob(unwrappedValue);
|
|
24
|
+
const colorBytes = new Uint8Array(binary.length);
|
|
25
|
+
for (let i = 0; i < binary.length; i++) {
|
|
26
|
+
colorBytes[i] = binary.charCodeAt(i);
|
|
27
|
+
}
|
|
28
|
+
json.colors = colorBytes;
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return json;
|
|
35
|
+
};
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
const unwrapValue = (value) => {
|
|
38
|
+
if (!value?.kind)
|
|
39
|
+
return value;
|
|
40
|
+
switch (value.kind.case) {
|
|
41
|
+
case 'numberValue':
|
|
42
|
+
case 'stringValue':
|
|
43
|
+
case 'boolValue': {
|
|
44
|
+
return value.kind.value;
|
|
45
|
+
}
|
|
46
|
+
case 'structValue': {
|
|
47
|
+
const result = {};
|
|
48
|
+
for (const [key, val] of Object.entries(value.kind.value.fields || {})) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
result[key] = unwrapValue(val);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
case 'listValue': {
|
|
55
|
+
return (value.kind.value.values?.map(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
(v) => unwrapValue(v)) || []);
|
|
58
|
+
}
|
|
59
|
+
case 'nullValue': {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
return value.kind.value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -2,6 +2,26 @@ import type { World, Entity } from 'koota';
|
|
|
2
2
|
import type { Snapshot } from './buf/draw/v1/snapshot_pb';
|
|
3
3
|
import { type SceneMetadata } from './buf/draw/v1/scene_pb';
|
|
4
4
|
import type { Settings } from './hooks/useSettings.svelte';
|
|
5
|
+
/**
|
|
6
|
+
* Merges scene-level metadata (grid, camera, point/line settings) into the
|
|
7
|
+
* current viewer settings. Millimetre values from the proto are converted
|
|
8
|
+
* to metres.
|
|
9
|
+
*/
|
|
5
10
|
export declare const applySceneMetadata: (settings: Settings, metadata: SceneMetadata) => Settings;
|
|
11
|
+
/**
|
|
12
|
+
* Spawns ECS entities for every transform and drawing in a {@link Snapshot}.
|
|
13
|
+
*
|
|
14
|
+
* Each transform produces one entity with Name, Pose, Parent, Geometry, and
|
|
15
|
+
* optional Color/Opacity traits. Each drawing produces one or more entities
|
|
16
|
+
* depending on the geometry type (arrows, points, line, nurbs, model, or
|
|
17
|
+
* simple shapes like box/sphere/capsule).
|
|
18
|
+
*
|
|
19
|
+
* @returns The spawned entities — pass them to {@link destroyEntities} to
|
|
20
|
+
* clean up before loading a new snapshot.
|
|
21
|
+
*/
|
|
6
22
|
export declare const spawnSnapshotEntities: (world: World, snapshot: Snapshot) => Entity[];
|
|
23
|
+
/**
|
|
24
|
+
* Destroys a list of entities that are still alive in the given world.
|
|
25
|
+
* Silently skips entities that have already been removed.
|
|
26
|
+
*/
|
|
7
27
|
export declare const destroyEntities: (world: World, entities: Entity[]) => void;
|
package/dist/snapshot.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { Vector3, Vector4 } from 'three';
|
|
1
|
+
import { Color, Vector3, Vector4 } from 'three';
|
|
2
2
|
import { NURBSCurve } from 'three/addons/curves/NURBSCurve.js';
|
|
3
3
|
import { RenderArmModels } from './buf/draw/v1/scene_pb';
|
|
4
4
|
import {} from './buf/draw/v1/drawing_pb';
|
|
5
5
|
import { traits } from './ecs';
|
|
6
6
|
import { Geometry } from '@viamrobotics/sdk';
|
|
7
|
-
import { parseMetadata } from './
|
|
8
|
-
import {
|
|
9
|
-
import { asFloat32Array, STRIDE } from './buffer';
|
|
7
|
+
import { parseMetadata } from './metadata';
|
|
8
|
+
import { rgbaToHex } from './color';
|
|
9
|
+
import { asColor, asFloat32Array, asOpacity, isPerVertexColors, STRIDE } from './buffer';
|
|
10
10
|
import { createBufferGeometry } from './attribute';
|
|
11
11
|
const vec3 = new Vector3();
|
|
12
|
+
const colorUtil = new Color();
|
|
13
|
+
/**
|
|
14
|
+
* Merges scene-level metadata (grid, camera, point/line settings) into the
|
|
15
|
+
* current viewer settings. Millimetre values from the proto are converted
|
|
16
|
+
* to metres.
|
|
17
|
+
*/
|
|
12
18
|
export const applySceneMetadata = (settings, metadata) => {
|
|
13
19
|
const next = { ...settings };
|
|
14
20
|
if (metadata.grid !== undefined) {
|
|
@@ -46,6 +52,17 @@ export const applySceneMetadata = (settings, metadata) => {
|
|
|
46
52
|
}
|
|
47
53
|
return next;
|
|
48
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Spawns ECS entities for every transform and drawing in a {@link Snapshot}.
|
|
57
|
+
*
|
|
58
|
+
* Each transform produces one entity with Name, Pose, Parent, Geometry, and
|
|
59
|
+
* optional Color/Opacity traits. Each drawing produces one or more entities
|
|
60
|
+
* depending on the geometry type (arrows, points, line, nurbs, model, or
|
|
61
|
+
* simple shapes like box/sphere/capsule).
|
|
62
|
+
*
|
|
63
|
+
* @returns The spawned entities — pass them to {@link destroyEntities} to
|
|
64
|
+
* clean up before loading a new snapshot.
|
|
65
|
+
*/
|
|
49
66
|
export const spawnSnapshotEntities = (world, snapshot) => {
|
|
50
67
|
const entities = [];
|
|
51
68
|
for (const transform of snapshot.transforms) {
|
|
@@ -59,6 +76,10 @@ export const spawnSnapshotEntities = (world, snapshot) => {
|
|
|
59
76
|
}
|
|
60
77
|
return entities;
|
|
61
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Destroys a list of entities that are still alive in the given world.
|
|
81
|
+
* Silently skips entities that have already been removed.
|
|
82
|
+
*/
|
|
62
83
|
export const destroyEntities = (world, entities) => {
|
|
63
84
|
for (const entity of entities) {
|
|
64
85
|
if (world.has(entity)) {
|
|
@@ -68,13 +89,16 @@ export const destroyEntities = (world, entities) => {
|
|
|
68
89
|
};
|
|
69
90
|
const getRenderArmModels = (renderArmModels) => {
|
|
70
91
|
switch (renderArmModels) {
|
|
71
|
-
case RenderArmModels.COLLIDERS:
|
|
92
|
+
case RenderArmModels.COLLIDERS: {
|
|
72
93
|
return 'colliders';
|
|
94
|
+
}
|
|
73
95
|
case RenderArmModels.UNSPECIFIED:
|
|
74
|
-
case RenderArmModels.COLLIDERS_AND_MODEL:
|
|
96
|
+
case RenderArmModels.COLLIDERS_AND_MODEL: {
|
|
75
97
|
return 'colliders+model';
|
|
76
|
-
|
|
98
|
+
}
|
|
99
|
+
case RenderArmModels.MODEL: {
|
|
77
100
|
return 'model';
|
|
101
|
+
}
|
|
78
102
|
}
|
|
79
103
|
};
|
|
80
104
|
const spawnTransformEntity = (world, transform) => {
|
|
@@ -86,16 +110,11 @@ const spawnTransformEntity = (world, transform) => {
|
|
|
86
110
|
traits.Removable,
|
|
87
111
|
];
|
|
88
112
|
const poseInFrame = transform.poseInObserverFrame;
|
|
89
|
-
entityTraits.push(traits.Pose(poseInFrame?.pose));
|
|
90
|
-
entityTraits.push(traits.Parent(poseInFrame?.referenceFrame));
|
|
113
|
+
entityTraits.push(traits.Pose(poseInFrame?.pose), traits.Parent(poseInFrame?.referenceFrame));
|
|
91
114
|
if (transform.metadata) {
|
|
92
115
|
const metadata = parseMetadata(transform.metadata.fields);
|
|
93
|
-
if (metadata.
|
|
94
|
-
entityTraits
|
|
95
|
-
}
|
|
96
|
-
if (metadata.opacity !== undefined) {
|
|
97
|
-
entityTraits.push(traits.Opacity(metadata.opacity));
|
|
98
|
-
}
|
|
116
|
+
if (metadata.colors)
|
|
117
|
+
addColorTraits(entityTraits, metadata.colors);
|
|
99
118
|
}
|
|
100
119
|
return world.spawn(...entityTraits);
|
|
101
120
|
};
|
|
@@ -165,15 +184,6 @@ const spawnEntitiesFromDrawing = (world, drawing) => {
|
|
|
165
184
|
if (parent && parent !== 'world') {
|
|
166
185
|
entityTraits.push(traits.Parent);
|
|
167
186
|
}
|
|
168
|
-
if (drawing.metadata?.colors) {
|
|
169
|
-
const colors = rgbaBytesToFloat32(drawing.metadata.colors);
|
|
170
|
-
if (colors.length === 4) {
|
|
171
|
-
entityTraits.push(traits.Color({ r: colors[0], g: colors[1], b: colors[2] }), traits.Opacity(colors[3]));
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
entityTraits.push(traits.VertexColors(colors));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
187
|
if (drawing.physicalObject?.center) {
|
|
178
188
|
entityTraits.push(traits.Center(drawing.physicalObject.center));
|
|
179
189
|
}
|
|
@@ -182,9 +192,20 @@ const spawnEntitiesFromDrawing = (world, drawing) => {
|
|
|
182
192
|
for (let i = 0, l = positions.length; i < l; i += 1) {
|
|
183
193
|
positions[i] *= 0.001;
|
|
184
194
|
}
|
|
185
|
-
entityTraits.push(traits.LinePositions(positions), traits.LineWidth(geometryType.value.lineWidth), traits.PointSize(geometryType.value.pointSize));
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
entityTraits.push(traits.LinePositions(positions), traits.LineWidth(geometryType.value.lineWidth), traits.PointSize((geometryType.value.pointSize ?? 0) * 0.001));
|
|
196
|
+
// Lines pack exactly 2 colors: [lineColor, pointColor]
|
|
197
|
+
const colors = drawing.metadata?.colors;
|
|
198
|
+
if (colors && colors.length >= STRIDE.COLORS_RGB) {
|
|
199
|
+
const stride = colors.length % STRIDE.COLORS_RGBA === 0 ? STRIDE.COLORS_RGBA : STRIDE.COLORS_RGB;
|
|
200
|
+
asColor(colors, colorUtil, 0);
|
|
201
|
+
entityTraits.push(traits.Color({ r: colorUtil.r, g: colorUtil.g, b: colorUtil.b }));
|
|
202
|
+
if (colors.length >= stride * 2) {
|
|
203
|
+
asColor(colors, colorUtil, stride);
|
|
204
|
+
entityTraits.push(traits.PointColor({ r: colorUtil.r, g: colorUtil.g, b: colorUtil.b }));
|
|
205
|
+
if (stride === STRIDE.COLORS_RGBA) {
|
|
206
|
+
entityTraits.push(traits.Opacity(asOpacity(colors, 1, 3)));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
188
209
|
}
|
|
189
210
|
}
|
|
190
211
|
else if (geometryType?.case === 'points') {
|
|
@@ -193,8 +214,13 @@ const spawnEntitiesFromDrawing = (world, drawing) => {
|
|
|
193
214
|
positions[i] *= 0.001;
|
|
194
215
|
}
|
|
195
216
|
const colors = drawing.metadata?.colors;
|
|
196
|
-
const
|
|
217
|
+
const numPoints = positions.length / STRIDE.POSITIONS;
|
|
218
|
+
const vertexColors = colors && isPerVertexColors(colors, numPoints) ? colors : undefined;
|
|
219
|
+
const geometry = createBufferGeometry(positions, vertexColors);
|
|
197
220
|
entityTraits.push(traits.BufferGeometry(geometry));
|
|
221
|
+
if (colors && !vertexColors) {
|
|
222
|
+
addColorTraits(entityTraits, colors);
|
|
223
|
+
}
|
|
198
224
|
if (geometryType.value.pointSize) {
|
|
199
225
|
entityTraits.push(traits.PointSize(geometryType.value.pointSize * 0.001));
|
|
200
226
|
}
|
|
@@ -225,9 +251,27 @@ const spawnEntitiesFromDrawing = (world, drawing) => {
|
|
|
225
251
|
points[i + 2] = vec3.z;
|
|
226
252
|
}
|
|
227
253
|
entityTraits.push(traits.LinePositions(points));
|
|
254
|
+
const colors = drawing.metadata?.colors;
|
|
255
|
+
if (colors) {
|
|
256
|
+
addColorTraits(entityTraits, colors);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
// Box, sphere, capsule, and other geometry shapes with a single color
|
|
261
|
+
const colors = drawing.metadata?.colors;
|
|
262
|
+
if (colors) {
|
|
263
|
+
addColorTraits(entityTraits, colors);
|
|
264
|
+
}
|
|
228
265
|
}
|
|
229
266
|
const entity = world.spawn(...entityTraits, traits.SnapshotAPI, traits.Removable);
|
|
230
267
|
entities.push(entity);
|
|
231
268
|
}
|
|
232
269
|
return entities;
|
|
233
270
|
};
|
|
271
|
+
const addColorTraits = (entityTraits, bytes) => {
|
|
272
|
+
asColor(bytes, colorUtil);
|
|
273
|
+
entityTraits.push(traits.Color(colorUtil));
|
|
274
|
+
const isRgba = bytes.length % STRIDE.COLORS_RGBA === 0;
|
|
275
|
+
if (isRgba)
|
|
276
|
+
entityTraits.push(traits.Opacity(asOpacity(bytes)));
|
|
277
|
+
};
|
|
@@ -18,7 +18,7 @@ const createMaterial = (options) => {
|
|
|
18
18
|
vertexShader,
|
|
19
19
|
fragmentShader,
|
|
20
20
|
uniforms: {
|
|
21
|
-
headAtOrigin: { value: 1
|
|
21
|
+
headAtOrigin: { value: 1 },
|
|
22
22
|
shaftRadius: { value: defaults.SHAFT_RADIUS },
|
|
23
23
|
headLength: { value: defaults.HEAD_LENGTH },
|
|
24
24
|
headWidth: { value: defaults.HEAD_WIDTH },
|
|
@@ -3,7 +3,7 @@ const bounds = new Box3();
|
|
|
3
3
|
export function computeBoundingBox(geometry) {
|
|
4
4
|
const src = this.poses.array;
|
|
5
5
|
const poseScale = this.shaftMesh.material.uniforms.poseScale?.value ?? 0.001;
|
|
6
|
-
const headAtOrigin = this.shaftMesh.material.uniforms.headAtOrigin?.value ?? 1
|
|
6
|
+
const headAtOrigin = this.shaftMesh.material.uniforms.headAtOrigin?.value ?? 1;
|
|
7
7
|
const r = Math.max(this.shaftRadius, this.headWidth);
|
|
8
8
|
let minX = +Infinity;
|
|
9
9
|
let minY = +Infinity;
|
|
@@ -13,29 +13,29 @@ function closestPointsRaySegment(ray, a, b, outRay, outSeg) {
|
|
|
13
13
|
const O = ray.origin;
|
|
14
14
|
const D = ray.direction; // assume normalized
|
|
15
15
|
const AB = direction.copy(b).sub(a);
|
|
16
|
-
const a0 = 1
|
|
16
|
+
const a0 = 1; // D·D
|
|
17
17
|
const b0 = D.dot(AB);
|
|
18
18
|
const c0 = AB.dot(AB);
|
|
19
19
|
const w0x = O.x - a.x, w0y = O.y - a.y, w0z = O.z - a.z;
|
|
20
20
|
const d0 = D.x * w0x + D.y * w0y + D.z * w0z;
|
|
21
21
|
const e0 = AB.x * w0x + AB.y * w0y + AB.z * w0z;
|
|
22
22
|
const denom = a0 * c0 - b0 * b0;
|
|
23
|
-
let t = 0
|
|
24
|
-
let u = 0
|
|
23
|
+
let t = 0;
|
|
24
|
+
let u = 0;
|
|
25
25
|
if (denom > 1e-8) {
|
|
26
26
|
t = (b0 * e0 - c0 * d0) / denom;
|
|
27
27
|
u = (a0 * e0 - b0 * d0) / denom;
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
t = 0
|
|
31
|
-
u = c0 > 0
|
|
30
|
+
t = 0;
|
|
31
|
+
u = c0 > 0 ? e0 / c0 : 0;
|
|
32
32
|
}
|
|
33
|
-
if (t < 0
|
|
34
|
-
t = 0
|
|
35
|
-
if (u < 0
|
|
36
|
-
u = 0
|
|
37
|
-
else if (u > 1
|
|
38
|
-
u = 1
|
|
33
|
+
if (t < 0)
|
|
34
|
+
t = 0;
|
|
35
|
+
if (u < 0)
|
|
36
|
+
u = 0;
|
|
37
|
+
else if (u > 1)
|
|
38
|
+
u = 1;
|
|
39
39
|
outRay.copy(D).multiplyScalar(t).add(O);
|
|
40
40
|
outSeg.copy(AB).multiplyScalar(u).add(a);
|
|
41
41
|
return outRay.distanceToSquared(outSeg);
|
|
@@ -68,7 +68,7 @@ export function raycast(raycaster, intersects) {
|
|
|
68
68
|
localRay.direction.normalize();
|
|
69
69
|
const material = this.shaftMesh.material;
|
|
70
70
|
const poseScale = material.uniforms?.poseScale?.value ?? 0.001;
|
|
71
|
-
const headAtOrigin = material.uniforms?.headAtOrigin?.value ?? 0
|
|
71
|
+
const headAtOrigin = material.uniforms?.headAtOrigin?.value ?? 0;
|
|
72
72
|
// pick radius in local space (same units as rendered)
|
|
73
73
|
const radius = Math.max(this.shaftRadius, this.headWidth);
|
|
74
74
|
const array = this.poses.array;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Vector3, Object3D } from 'three';
|
|
2
|
+
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2.js';
|
|
3
|
+
export declare class OBBHelper extends LineSegments2 {
|
|
3
4
|
constructor(color?: number, linewidth?: number);
|
|
4
5
|
setFromOBB(obb: {
|
|
5
6
|
center: Vector3;
|
package/dist/three/OBBHelper.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EdgesGeometry, BoxGeometry, Vector3, Quaternion, Matrix4, Object3D, Mesh, BufferGeometry, Matrix3, } from 'three';
|
|
2
|
+
import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
|
|
3
|
+
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2.js';
|
|
4
|
+
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
|
|
2
5
|
const center = new Vector3();
|
|
3
6
|
const half = new Vector3();
|
|
4
7
|
const size = new Vector3();
|
|
@@ -6,13 +9,22 @@ const quaternion = new Quaternion();
|
|
|
6
9
|
const scale = new Vector3();
|
|
7
10
|
const absScale = new Vector3();
|
|
8
11
|
const worldCenter = new Vector3();
|
|
9
|
-
export class OBBHelper extends
|
|
10
|
-
constructor(color = 0x000000, linewidth =
|
|
11
|
-
const
|
|
12
|
-
const
|
|
12
|
+
export class OBBHelper extends LineSegments2 {
|
|
13
|
+
constructor(color = 0x000000, linewidth = 2) {
|
|
14
|
+
const edges = new EdgesGeometry(new BoxGeometry());
|
|
15
|
+
const geometry = new LineSegmentsGeometry();
|
|
16
|
+
geometry.setPositions(edges.getAttribute('position').array);
|
|
17
|
+
const material = new LineMaterial({
|
|
18
|
+
color,
|
|
19
|
+
linewidth,
|
|
20
|
+
depthTest: false,
|
|
21
|
+
depthWrite: false,
|
|
22
|
+
transparent: true,
|
|
23
|
+
});
|
|
13
24
|
super(geometry, material);
|
|
14
25
|
this.matrixAutoUpdate = false;
|
|
15
26
|
this.frustumCulled = false;
|
|
27
|
+
this.renderOrder = 999;
|
|
16
28
|
}
|
|
17
29
|
setFromOBB(obb) {
|
|
18
30
|
// position/rotation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"@ag-grid-community/styles": "32.3.9",
|
|
11
11
|
"@changesets/cli": "2.29.6",
|
|
12
12
|
"@dimforge/rapier3d-compat": "0.18.2",
|
|
13
|
-
"@eslint/compat": "
|
|
14
|
-
"@eslint/js": "
|
|
13
|
+
"@eslint/compat": "2.0.2",
|
|
14
|
+
"@eslint/js": "10.0.1",
|
|
15
15
|
"@playwright/test": "1.55.0",
|
|
16
16
|
"@sentry/sveltekit": "10.10.0",
|
|
17
17
|
"@skeletonlabs/skeleton": "3.2.0",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@types/earcut": "^3.0.0",
|
|
34
34
|
"@types/lodash-es": "4.17.12",
|
|
35
35
|
"@types/three": "0.181.0",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
37
|
-
"@typescript-eslint/parser": "8.
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "8.56.1",
|
|
37
|
+
"@typescript-eslint/parser": "8.56.1",
|
|
38
38
|
"@viamrobotics/prime-core": "0.1.5",
|
|
39
39
|
"@viamrobotics/sdk": "0.58.0",
|
|
40
40
|
"@viamrobotics/svelte-sdk": "1.0.1",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
"@zag-js/tree-view": "1.22.1",
|
|
50
50
|
"camera-controls": "3.1.0",
|
|
51
51
|
"esbuild": "^0.27.3",
|
|
52
|
-
"eslint": "
|
|
52
|
+
"eslint": "10.0.2",
|
|
53
53
|
"eslint-config-prettier": "10.1.8",
|
|
54
|
-
"eslint-plugin-svelte": "3.
|
|
54
|
+
"eslint-plugin-svelte": "3.15.0",
|
|
55
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
55
56
|
"globals": "16.3.0",
|
|
56
57
|
"idb-keyval": "6.2.2",
|
|
57
58
|
"jsdom": "26.1.0",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"tsx": "4.20.5",
|
|
71
72
|
"type-fest": "^5.0.1",
|
|
72
73
|
"typescript": "5.9.2",
|
|
73
|
-
"typescript-eslint": "8.
|
|
74
|
+
"typescript-eslint": "8.56.1",
|
|
74
75
|
"vite": "7.1.11",
|
|
75
76
|
"vite-plugin-devtools-json": "1.0.0",
|
|
76
77
|
"vite-plugin-glsl": "^1.5.5",
|
|
@@ -146,10 +147,14 @@
|
|
|
146
147
|
"build": "vite build && npm run prepack",
|
|
147
148
|
"build:workers": "node scripts/build-workers.js",
|
|
148
149
|
"preview": "vite preview",
|
|
149
|
-
"check": "svelte-kit sync && pnpm
|
|
150
|
-
"check:watch": "svelte-kit sync && pnpm
|
|
150
|
+
"check": "svelte-kit sync && pnpm build:workers && svelte-check --tsconfig ./tsconfig.json && pnpm vet",
|
|
151
|
+
"check:watch": "svelte-kit sync && pnpm build:workers && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
151
152
|
"format": "prettier --write .",
|
|
152
|
-
"lint": "
|
|
153
|
+
"lint:draw": "golangci-lint run ./draw/...",
|
|
154
|
+
"lint:client": "golangci-lint run ./client/...",
|
|
155
|
+
"lint:prettier": "prettier --check .",
|
|
156
|
+
"lint:eslint": "eslint .",
|
|
157
|
+
"lint": "pnpm lint:prettier && pnpm lint:eslint && pnpm lint:draw",
|
|
153
158
|
"knip": "npx knip --include files,exports,types",
|
|
154
159
|
"test:unit": "vitest",
|
|
155
160
|
"test:client": "go test ./client/... -count=1",
|
|
@@ -158,6 +163,9 @@
|
|
|
158
163
|
"test:coverage": "npx vitest run --coverage",
|
|
159
164
|
"test:e2e": "playwright test",
|
|
160
165
|
"test:e2e-ui": "playwright test --ui",
|
|
166
|
+
"vet:draw": "go vet ./draw/...",
|
|
167
|
+
"vet:client": "go vet ./client/...",
|
|
168
|
+
"vet": "pnpm vet:draw && pnpm vet:client",
|
|
161
169
|
"model-pipeline:run": "node scripts/model-pipeline.js",
|
|
162
170
|
"release": "changeset publish"
|
|
163
171
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { PlainMessage, Struct } from '@viamrobotics/sdk';
|
|
2
|
-
import { BatchedMesh, Color, Vector3 } from 'three';
|
|
3
|
-
import type { GLTF } from 'three/examples/jsm/Addons.js';
|
|
4
|
-
import type { OBB } from 'three/addons/math/OBB.js';
|
|
5
|
-
declare enum SupportedShapes {
|
|
6
|
-
points = "points",
|
|
7
|
-
line = "line",
|
|
8
|
-
arrow = "arrow"
|
|
9
|
-
}
|
|
10
|
-
type Metadata = {
|
|
11
|
-
colors?: Float32Array<ArrayBufferLike>;
|
|
12
|
-
color?: Color;
|
|
13
|
-
opacity?: number;
|
|
14
|
-
gltf?: GLTF;
|
|
15
|
-
points?: Vector3[];
|
|
16
|
-
pointSize?: number;
|
|
17
|
-
lineWidth?: number;
|
|
18
|
-
lineDotColor?: Color;
|
|
19
|
-
batched?: {
|
|
20
|
-
id: number;
|
|
21
|
-
object: BatchedMesh;
|
|
22
|
-
};
|
|
23
|
-
shape?: SupportedShapes;
|
|
24
|
-
getBoundingBoxAt?: (box: OBB) => void;
|
|
25
|
-
};
|
|
26
|
-
export declare const parseMetadata: (fields?: PlainMessage<Struct>["fields"]) => Metadata;
|
|
27
|
-
export {};
|