Skip to content

Commit

Permalink
Move components to extensions after gltf export
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpeiris committed Jul 12, 2018
1 parent deb68bc commit fdf3a9b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client/editor/SceneLoader.js
@@ -1,4 +1,5 @@
import THREE from "../vendor/three";
import { Components } from "./components";
import SceneReferenceComponent from "./components/SceneReferenceComponent";

export function absoluteToRelativeURL(from, to) {
Expand Down Expand Up @@ -78,6 +79,21 @@ function postProcessGLTF(scene, sceneURI, gltf) {
}
}

const componentNames = Components.map(component => component.componentName);

for (const node of gltf.json.nodes) {
if (!node.extras) continue;
if (!node.extensions) {
node.extensions = [];
}
for (const component of node.extras._components) {
if (componentNames.includes(component.name)) {
node.extensions.push(component);
}
}
delete node.extras._components;
}

return gltf;
}

Expand Down

0 comments on commit fdf3a9b

Please sign in to comment.