Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add visible polyfill, collapse-model
- Loading branch information
1 parent
2f55654
commit fb3d303
Showing
4 changed files
with
34 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {AFrameComponent} from './AFrameComponent'; | ||
|
||
/** | ||
* Reaches into a model's hierarchy and directly assigns the first mesh found | ||
* to the containing entity. This is mostly necessary for use alongside native | ||
* components like [n-skeleton-parent]{@link module:altspace/components.n-skeleton-parent}. @aframe | ||
* | ||
* @alias collapse-model | ||
* @memberof module:altspace/components | ||
* @extends module:altspace/components.AFrameComponent | ||
*/ | ||
export default class CollapseModel extends AFrameComponent | ||
{ | ||
init() | ||
{ | ||
function getFirstMesh(obj){ | ||
if(obj.isMesh) | ||
return obj; | ||
else if(obj.children.length === 0) | ||
return null; | ||
else | ||
return obj.children.map(c => getFirstMesh(c)).find(o => !!o); | ||
} | ||
|
||
this.el.addEventListener('model-loaded', () => { | ||
this.el.setObject3D('mesh', getFirstMesh(this.el.object3DMap.mesh)); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters