【问题标题】:aframe, TransformControls is not working about 3D objectaframe,TransformControls 不适用于 3D 对象
【发布时间】:2021-08-11 00:11:46
【问题描述】:

这张图没问题。但下图有问题。

我正在使用 aframe 和 https://threejs.org/docs/#examples/en/controls/TransformControls

<a-scene embedded>
<!--
    <a-entity data-type="entity" id="yellowSphere" geometry="primitive: sphere" material="color:#ff0; metalness:0.0; roughness:1.0" position="-2 2 -2"></a-entity>
-->
    <a-entity gltf-model="url(https://cdn.aframe.io/examples/ar/models/triceratops/scene.gltf)" animation-mixer scale="0.1 0.1 0.1"></a-entity>

    <a-sky data-type="sky" color="#fff"></a-sky>
</a-scene>
this.transformControls = new TransformControls(this.camera, this.canvasEl);
this.transformControls.size = 0.75;
this.transformControls.addEventListener('objectChange', (evt) => {
    const object = this.transformControls.object;
    if (!object) {
        return;
    }

    console.log(evt, object);
    this.selectionBox.setFromObject(object).update();
});

【问题讨论】:

标签: three.js aframe


【解决方案1】:

代码试图移动skinnedMesh,而不是根mesh

一种解决方案是为Mesh 添加检查,如果没有,请使用getObject3D('mesh') 查找:

/* TransformControls, line 546 */
// Set current object
attach( object ) {
  if (object.type != "Mesh") {
    object = object.el.getObject3D("mesh") // this is the solution mentioned above
  }
  this.object = object;
  this.visible = true;
  return this;
}

故障here

【讨论】:

  • 如果清楚,请随意标记答案
猜你喜欢
  • 2018-03-20
  • 1970-01-01
  • 2015-09-07
  • 2019-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-06
  • 2012-03-03
相关资源
最近更新 更多