From 0423267ed91c34fdb3163580b0396b5ac012d4b1 Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Wed, 14 Mar 2018 18:00:37 -0700 Subject: [PATCH] Fix inflating of entities with different rotation order from aframe --- src/elements/a-gltf-entity.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index 2214cce18..8c274cb44 100644 --- a/src/elements/a-gltf-entity.js +++ b/src/elements/a-gltf-entity.js @@ -81,6 +81,11 @@ const inflateEntities = function(classPrefix, parentEl, node) { el.classList.add(classPrefix + className); parentEl.appendChild(el); + // AFRAME rotation component expects rotations in YXZ, convert it + if (node.rotation.order !== "YXZ") { + node.rotation.setFromQuaternion(node.quaternion, "YXZ"); + } + // Copy over transform to the THREE.Group and reset the actual transform of the Object3D el.setAttribute("position", { x: node.position.x, @@ -98,9 +103,8 @@ const inflateEntities = function(classPrefix, parentEl, node) { z: node.scale.z }); - node.position.set(0, 0, 0); - node.rotation.set(0, 0, 0); - node.scale.set(1, 1, 1); + node.matrixAutoUpdate = false; + node.matrix.identity(); el.setObject3D(node.type.toLowerCase(), node); @@ -118,7 +122,6 @@ const inflateEntities = function(classPrefix, parentEl, node) { } const entityComponents = node.userData.components; - if (entityComponents) { for (const prop in entityComponents) { if (entityComponents.hasOwnProperty(prop)) { -- GitLab