Bind information panels for objects in the scene, display when clicked, reset to avoid clearing all panels
Var app = new THING.App({// scene address "url": "/ API /scene/url", // background setting "skyBox": "BlueSky"}); app.on('load', function (ev) { let things = app.query('.Thing'); things.forEach((obj) => { obj.on('click', ()=>{ reset(); new CreatePanel(obj); Constructor (o) {this.init(o); } /** * init panel */ init(o) {var obj = o; Var panel = new thing.widget. panel ({// set the width of the panel: '150px', // cornerType corner style // no corner none, noline corner noline, corner corner polyline cornerType: 'polyline}) / / add a class, to distinguish, the official document will remove all panel. The panel diydomElement. ClassList. Add (' myPanel'); AddString (obj, 'name').Caption (' name'); panel.addString(obj, 'id').caption('ID'); If (uiAnchor) {console.log(uiAnchor)} // create uiAnchor panel 'UIAnchor', // parent set parent: obj, // Element object of the page to bind: DomElement, // Set localPosition to [0, 0, 0] localPosition: [0, 0, 0], // The offset pixel value relative to the upper left corner of the Element pivotPixel: [-16, 109] // The current value is the center point}); } } function reset(){ $(".myPanel").remove(); // Remove panel}Copy the code