首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >3d.io中相机旅游点的刷新

3d.io中相机旅游点的刷新
EN

Stack Overflow用户
提问于 2018-06-15 17:32:03
回答 1查看 96关注 0票数 2

我制作了相机旅游点的可排序菜单(只有jquery)

代码语言:javascript
复制
<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操作函数,如下所示:

代码语言:javascript
复制
var el = document.getElementsByClassName('cameraTourPoint')[currentItemIndex],
    elBefore = document.getElementsByClassName('cameraTourPoint')[currentItemIndex+1];
document.getElementById('cameraTour').insertBefore(el,elBefore.nextSibling);

为了添加新的way-point,我提出如下:

代码语言:javascript
复制
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给定的路径点clearPoint不存在。可用路径点:(4)“frontView”、"northSideView“、"southExit”、"southAngleView“

那么,在交换或添加新点之后,如何刷新旅游点呢?

aframe 0.8.0 3d.io 1.1.x aframe-动画.组件3.2.5

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-20 11:43:15

您可能忘了更新旅游组件,请查看源https://github.com/archilogic-com/3dio-js/blob/master/src/aframe/component/tour.js

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

这样做是可行的:

代码语言:javascript
复制
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)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50880287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档