Skip to main content
12-Amethyst
November 29, 2023
Question

Dynamic elements in Hololens experiences

  • November 29, 2023
  • 1 reply
  • 2483 views

Hello community, is there a way to emulate the 2D repeater in the 3D Canvas ?

I mean, I have a dynamic list coming from a TW service and I would like to add a dynamic number of 3D elements (could be 3D buttons, etc.) based on the number of rows from the output of the TW service.

 

Is it possible?

 

Thanks

1 reply

21-Topaz I
November 29, 2023

Hi @aletenti ,

so far I know there is no direct way to do this - via standard widget on HoloLens 2 or general in 3D space. Possibly there are some development  customized extension but I do not know such extension. Possibly somebody else could share here if he/she has information about other techniques.

For me -there should be 2 possible ways to try to implement it - what I consider there is only   the display of the data. Ok the data should be received by e.g. Thingworx service first and then need to be displayed . And I consider here only the display of e.g. Table but there we need to call the service and in the service -complete event we need then to call the function to display the data on e.g. 3D panel - so to update the data. Then possibly we need a timer or event setting e.g. call every 5 minutes to update the data this is also a think what we need to implement if we want to have an repeater functionality there in the 3D area. So the options I see are:

1.) use tmlText widget to define a shader and then  to display the data as shader on image panel. The data need to be passed to the shader as shaders parameter something like this  https://stackoverflow.com/questions/8847899/how-to-draw-text-using-only-opengl-methods for GLSL  ... But ! ... we need for HoloLens2 to use HLSL and I could not find a relevant example ... I did not search very detailed because I think the point 2 is that I prefer as option

2.) use the data to generate a dynamic table in SVG format and display it on e.g. Image widget. E.g. the following table from stack overflow... forum I used as example : https://stackoverflow.com/questions/6987005/create-a-table-in-svg

 

$scope.sampleSVG1 = function(text) { console.log("$scope.sampleSVG1")
 // Name of image widget to edit
 let sampleImgWidget = '3DImage-2'; 

 let svgData = `<?xml version='1.0' standalone='no'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'
 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg width='80%' height='80%' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>

 <title>SVG Table</title>

 <g id='columnGroup'>
 <rect x='65' y='10' width='75' height='110' fill='gainsboro'/>
 <rect x='265' y='10' width='75' height='110' fill='gainsboro'/>

 <text x='30' y='30' font-size='18px' font-weight='bold' fill='crimson'>
 <tspan x='30' dy='1.5em'>Q1</tspan>
 <tspan x='30' dy='1em'>Q2</tspan>
 <tspan x='30' dy='1em'>Q3</tspan>
 <tspan x='30' dy='1em'>Q4</tspan>
 </text>

 <text x='100' y='30' font-size='18px' text-anchor='middle'>
 <tspan x='100' font-weight='bold' fill='crimson'>Sales</tspan>
 <tspan x='100' dy='1.5em'>$ 223</tspan>
 <tspan x='100' dy='1em'>$ 183</tspan>
 <tspan x='100' dy='1em'>$ 277</tspan>
 <tspan x='100' dy='1em'>$ 402</tspan>
 </text>

 <text x='200' y='30' font-size='18px' text-anchor='middle'>
 <tspan x='200' font-weight='bold' fill='crimson'>Expenses</tspan>
 <tspan x='200' dy='1.5em'>$ 195</tspan>
 <tspan x='200' dy='1em'>$ 70</tspan>
 <tspan x='200' dy='1em'>$ 88</tspan>
 <tspan x='200' dy='1em'>$ 133</tspan>
 </text>

 <text x='300' y='30' font-size='18px' text-anchor='middle'>
 <tspan x='300' font-weight='bold' fill='crimson'>Net</tspan>
 <tspan x='300' dy='1.5em'>$ 28</tspan>
 <tspan x='300' dy='1em'>$ 113</tspan>
 <tspan x='300' dy='1em'>$ 189</tspan>
 <tspan x='300' dy='1em'>$ 269</tspan>
 </text>
 </g>
</svg>`;
 

 let svgURL = "data&colon;image/svg+xml;base64," + btoa(svgData);
 
 $scope.setWidgetProp(sampleImgWidget,'src',svgURL)
}

 

Here I consider it as static table but you can of course generate it dynamical using the data sets. So the mentioned code example in preview:

2023-11-29_15-41-49.jpg

I attached the test project , possibly could be helpful for you. Thanks

 

aletenti12-AmethystAuthor
12-Amethyst
November 30, 2023

Hi Roland,

thank you very much for your example and explanation, it's useful.

Anyway, I was thinking about more on dynamic 3D buttons.

I mean, I have a 3D image as a panel and I would like to fill this panel with a dynamic number of 3D buttons.

 

Do you have any idea? 🙂 

21-Topaz I
December 5, 2023

the question here  is , when I understand correctly the request , then  when we  click on a 3D element like this:

2023-12-05_14-06-17.jpg

it is not how to identify which  widget we did click as element , let say 3D Widget Image (we can get this easely by the userpick event) but what is required is  the information what we clicked. As here shown in the picture - the click  means selected is the second row and second column selected. And possibly we want to have the value used there. At least, I think, this was the original question in the topic -> required some functionality    like a repeat element in 3D space. So the picture will show that to display a list is no an issue e.g. as SVG in Image but possibly as it was mentioned in the last post  here as html. 

The question what I see,  is how to handle the selection - to find what was selected on the canvas.

The only idea I have is to use in 3D Space the eye vector of the device

 

 

tml3dRenderer.setupTrackingEventsCommand (function(target,eyepos,eyedir,eyeup) {
 // handle here the eyepos and calculate the intersection point with the plane
// of the panel, use x,y,z, rx, ry,rz to calcualte the plane eq.
}) 

 

 

and then to calculate the point where the eyevector will intersect the plane of the 3dWidget , let say 3DImage. Then  we will have a 3D point in space which we could interpret as ratio  in relation to the position and  the size of the 3Dimage (we need to know how many items , rows or column are displayed there) and so possibly we will then have idea what we did select.

I hope  somebody  has better idea. Thanks