1

使用 A-FRAME,您如何使用 Json 文件中的数据并创建新的对象/原语来充当 POIS?

****EXEMPLO JSON:**** ( https://leafletjs.com/examples/geojson/sample-geojson.js )

var lightRailStop = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "popupContent": "18th & California Light Rail Stop"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [-104.98999178409576, 39.74683938093904]
            }
        },{
            "type": "Feature",
            "properties": {
                "popupContent": "20th & Welton Light Rail Stop"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [-104.98689115047453, 39.747924136466565]
            }
        }
    ]
};

提取内容所需的 javascript/html 是什么,并使用每个数据创建一个新对象(a-box / a-entity),以便可以在 a-frame VR / AR 中使用?

4

1 回答 1

0
lightRailStop.features.forEach(stop => {
  let el = document.createElement('a-entity');
  el.setAttribute('text', 'value', stop.properties.popUpContent);
  el.object3D.position.set(parseFloat(stop.coordinates[0]), 1.6, parseFloat(stop.coordinates[1]));
  scene.appendChild(el);
});
于 2018-08-16T23:10:50.853 回答