Skip to content

Commit ab36fe8

Browse files
donmccurdydmarcos
authored andcommitted
Update gltf-model to glTF 2.0. (#2986)
* Update code and docs for glTF2. * Update test assets, fix tests.
1 parent 74d0cca commit ab36fe8

File tree

13 files changed

+237
-557
lines changed

13 files changed

+237
-557
lines changed

docs/components/gltf-model.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Note that glTF is a fairly new specification and adoption is still growing.
2222
Work on the [three.js glTF loader][threejsgltf] and converters are still
2323
active.
2424

25+
> **NOTE:** A-Frame supports glTF 2.0. For models using older versions of the
26+
> glTF format, use `gltf-model-legacy` from [donmccurdy/aframe-extras][extras].
27+
28+
[extras]: https://github.com/donmccurdy/aframe-extras/tree/master/src/loaders
29+
2530
<!--toc-->
2631

2732
## Why use glTF?
@@ -91,17 +96,18 @@ rendering.
9196

9297
## More Resources
9398

94-
The glTF format is fairly new, and few editors will export a `.gltf` file
95-
directly. Instead, various converters are available or in progress:
96-
97-
[fbx-converter]: http://gltf.autodesk.io/
98-
[collada-converter]: http://cesiumjs.org/convertmodel.html
99+
[sketchfab]: https://sketchfab.com/models?features=downloadable&sort_by=-likeCount
100+
[blender-exporter]: https://github.com/KhronosGroup/glTF-Blender-Exporter/
99101
[obj-converter]: https://github.com/AnalyticalGraphicsInc/obj2gltf
102+
[collada-converter]: http://cesiumjs.org/convertmodel.html
100103

101-
- [glTF Workflow for A Saturday Night](https://blog.mozvr.com/a-saturday-night-gltf-workflow/)
102-
- [FBX &rarr; glTF][fbx-converter] - Coming soon.
103-
- [COLLADA &rarr; glTF][collada-converter]
104+
Over 100,000 glTF models are free for download on [Sketchfab][sketchfab], and
105+
various exporters and converters converters are available:
106+
107+
- [Blender Exporter](blender-exporter)
104108
- [OBJ &rarr; glTF][obj-converter]
109+
- [COLLADA &rarr; glTF][collada-converter]
110+
- [glTF Workflow for A Saturday Night](https://blog.mozvr.com/a-saturday-night-gltf-workflow/)
105111

106112
[spec]: https://github.com/KhronosGroup/glTF
107113

src/components/gltf-model.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports.Component = registerComponent('gltf-model', {
99

1010
init: function () {
1111
this.model = null;
12-
this.loader = new THREE.GLTFLoader();
12+
this.loader = new THREE.GLTF2Loader();
1313
},
1414

1515
update: function () {
@@ -24,7 +24,6 @@ module.exports.Component = registerComponent('gltf-model', {
2424
this.loader.load(src, function gltfLoaded (gltfModel) {
2525
self.model = gltfModel.scene || gltfModel.scenes[0];
2626
self.model.animations = gltfModel.animations;
27-
self.system.registerModel(self.model);
2827
el.setObject3D('mesh', self.model);
2928
el.emit('model-loaded', {format: 'gltf', model: self.model});
3029
});
@@ -33,6 +32,5 @@ module.exports.Component = registerComponent('gltf-model', {
3332
remove: function () {
3433
if (!this.model) { return; }
3534
this.el.removeObject3D('mesh');
36-
this.system.unregisterModel(this.model);
3735
}
3836
});

src/lib/three.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ if (THREE.Cache) {
1919
}
2020

2121
// TODO: Eventually include these only if they are needed by a component.
22-
require('three/examples/js/loaders/GLTFLoader'); // THREE.GLTFLoader
22+
require('three/examples/js/loaders/GLTF2Loader'); // THREE.GLTF2Loader
2323
require('three/examples/js/loaders/OBJLoader'); // THREE.OBJLoader
2424
require('three/examples/js/loaders/MTLLoader'); // THREE.MTLLoader
2525
require('three/examples/js/loaders/ColladaLoader'); // THREE.ColladaLoader
2626
require('../../vendor/VRControls'); // THREE.VRControls
2727
require('../../vendor/VREffect'); // THREE.VREffect
2828

2929
THREE.ColladaLoader.prototype.crossOrigin = 'anonymous';
30-
THREE.GLTFLoader.prototype.crossOrigin = 'anonymous';
30+
THREE.GLTF2Loader.prototype.crossOrigin = 'anonymous';
3131
THREE.MTLLoader.prototype.crossOrigin = 'anonymous';
3232
THREE.OBJLoader.prototype.crossOrigin = 'anonymous';
3333

src/systems/gltf-model.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/systems/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require('./camera');
22
require('./geometry');
3-
require('./gltf-model');
43
require('./light');
54
require('./material');
65
require('./shadow');

tests/assets/box/Box.bin

-648 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)