相机游览点刷新 3d.io

Camera tour points refresh in 3d.io

我制作了可排序的相机游览点菜单(仅jquery)

<a-entity id='cameraTour' camera tour='autoStart:false' position='21 12 -15' rotation='-35 30 0' style='display:none;'>
  <a-entity class='cameraTourPoint' tour-waypoint='Front View' io3d-uuid='frontView' position='2 10 -13' rotation='-25 0 -1.5'></a-entity>
  <a-entity class='cameraTourPoint' tour-waypoint='North Side View' io3d-uuid='northSideView' position='-25 8 -42' rotation='-45 -93 -1'></a-entity>
  <a-entity class='cameraTourPoint' tour-waypoint='South Exit' io3d-uuid='southExit' position='24 -.8 -37.7' rotation='-2 -90 0'></a-entity>
  <a-entity class='cameraTourPoint' tour-waypoint='South Angle View' io3d-uuid='southAngleView' position='21 12 -15' rotation='-35 30 0'></a-entity>
</a-entity>

为了交换相机点和菜单项,我使用 dom 操作函数,如下所示:

var el = document.getElementsByClassName('cameraTourPoint')[currentItemIndex],
    elBefore = document.getElementsByClassName('cameraTourPoint')[currentItemIndex+1];
document.getElementById('cameraTour').insertBefore(el,elBefore.nextSibling);

为了添加新的航路点,我做了这个:

var cameraTourPoint = document.createElement('a-entity'),
    cameraPointAttributes = {
      "id": generatePointId(),
      "class": "cameraTourPoint",
      "tour-waypoint": "CLEAR POINT",
      "io3d-uuid": "clearPoint",
      "position": function() {},
      "rotation": ""
    },
    lastChild = document.getElementById('cameraTour').lastChild;

document.getElementById('cameraTour').insertBefore(cameraTourPoint,lastChild.nextSibling);
var clearPoint = document.getElementById('cameraTour').lastChild;
$.each(cameraPointAttributes,function(key,value){
  clearPoint.setAttribute(key,value);
});

但它不起作用!交换 cameraTour 后我想更改顺序,当我添加新点并尝试去找他时 'onclick',我收到此消息:

tour.js:80 The given waypoint clearPoint does not exist. Available waypoints: (4) ["frontView", "northSideView", "southExit", "southAngleView"]

那么,交换或添加新点后如何刷新游览点?

aframe 0.8.0
3d.io 1.1.x
aframe-animation-component 3.2.5

可能是您忘记更新游览组件 看看源代码 https://github.com/archilogic-com/3dio-js/blob/master/src/aframe/component/tour.js

也许您没有等待创建新的航路点元素 https://aframe.io/docs/0.7.0/core/entity.html#events

这个有效:

var cameraTourPoint = document.createElement('a-entity'),
cameraPointAttributes = {
  "id": 'asd',
  "class": "cameraTourPoint",
  "tour-waypoint": "CLEAR POINT",
  "io3d-uuid": "clearPoint",
  "position": "-5 2 0",
  "rotation": "0 0 0"
},
cameraEl = document.querySelector('[camera]'),
lastChild = cameraEl.lastChild;

cameraEl.insertBefore(cameraTourPoint,lastChild.nextSibling);
var clearPoint = cameraEl.lastChild;
$.each(cameraPointAttributes,function(key,value){
  clearPoint.setAttribute(key,value);
});
// the waypoint dom element needs to be created
clearPoint.addEventListener('loaded', () => {
  // update the tour component
  cameraEl.components['tour'].update()
  // move to target
  cameraEl.components['tour'].goTo('clearPoint')
}, 100)