New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gltf-model component and system. #2333
Conversation
src/components/gltf-model.js
Outdated
|
||
this.remove(); | ||
|
||
this.loader.load(src, function (gltfModel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name the anonymous function for easier debugging
We can host the sample models at https://github.com/aframevr/assets. Just commit it there, and it'll be available via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got an error for r83 three.js loader using your model, do I update to r84? Code looks good though, we can start test/docs.
GLTFLoader.js:762 Uncaught (in promise) RangeError: Invalid typed array length
at new Float32Array (native)
at http://localhost:9000/dist/aframe-master.js:54669:14
at _each (http://localhost:9000/dist/aframe-master.js:54310:27)
at http://localhost:9000/dist/aframe-master.js:54646:11
src/systems/gltf-model.js
Outdated
* Registers a glTF asset. | ||
* @param {object} gltf Asset containing a scene and (optional) animations and cameras. | ||
*/ | ||
addModel: function (gltf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do registerModel/unregisterModel
Updated. |
docs/primitives/a-gltf-model.md
Outdated
@@ -0,0 +1,33 @@ | |||
--- | |||
title: <a-collada-model> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collada
* glTF model loader. | ||
*/ | ||
module.exports.Component = registerComponent('gltf-model', { | ||
schema: {type: 'model'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be multiprop to allow room for future props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly prefer multiprop, but can't actually think of any others we'd need. Maybe crossorigin. I'm expecting animation to be a separate component, but if not that would definitely need some properties. I've used src: {type: 'asset'}
in most of my loaders so far i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, can just leave it as is
var registerPrimitive = require('../primitives').registerPrimitive; | ||
var utils = require('../../../utils/'); | ||
|
||
registerPrimitive('a-gltf-model', utils.extendDeep({}, getMeshMixin(), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the material component have an effect on gltf
mesh? If not, we can remove getMeshMixin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (for both gltf and collada, for consistency)
* Updates shaders for all glTF models in the system. | ||
*/ | ||
tick: function () { | ||
var sceneEl = this.sceneEl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could test this code too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/components/gltf-model.test.js
Outdated
|
||
var SRC = '/base/tests/assets/box/Box.gltf'; | ||
|
||
suite.only('gltf-model', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got an only
stuck on here (need to lint that, i do this a lot).
I've been following this template for tests now (https://github.com/aframevr/angle/blob/master/templates/component/tests/index.test.js#L6) ... closured variables for el
and store the `component instance. saves a lot of proxy variables and grabbing the component.
docs/components/gltf-model.md
Outdated
<a-asset-item id="tree" src="/path/to/tree.gltf"></a-asset-item> | ||
</a-assets> | ||
|
||
<a-entity collada-model="#tree"></a-entity> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collada
<a-entity gltf-model="url(/path/to/tree.gltf)"></a-entity> | ||
``` | ||
|
||
## More Resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add sections on playing animations until we get an API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the answer is "write a component that looks very much like animation-mixer
", so IMO it would be better to leave that for another PR.
docs/components/gltf-model.md
Outdated
parent_section: components | ||
--- | ||
|
||
[glTF][about-gltf] is an open project by Khronos providing a common, extensible format for 3D assets that is both efficient and highly interoperable with modern web technologies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could describe give the advantages and purpose of glTF over other common formats (obj, collada). The .psd vs .jpg analogy is a good one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docs/components/gltf-model.md
Outdated
|
||
See the [official glTF specification][spec] for available features, community resources, and ways to contribute. | ||
|
||
[fbx-converter]: http://gltf.autodesk.io/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like putting link definitions above the paragraph its used to easier keep track
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -11,13 +11,16 @@ | |||
<a-assets> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cool to add text labels under each model for the model format. And the scene could use a better background <a-sky color="#FAFAFA">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also add the different format types in the page title & meta description Models (glTF, COLLADA, OBJ)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scope creep alert 😉
Added the meta title/description, but I'm getting errors trying to do text.
<a-text value="foo"></a-text>
THREE.WebGLShader: gl.getShaderInfoLog() fragment WARNING: 0:102: '
' : extension directive should occur before any non-preprocessor tokens
� 1: precision highp float;
2: precision highp int;
3: #define SHADER_NAME ShaderMaterial
4: #define GAMMA_FACTOR 2
5: #define NUM_CLIPPING_PLANES 0
6: #define UNION_CLIPPING_PLANES 0
7: uniform mat4 viewMatrix;
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that on latest? We pushed some text patches switching to raw shader material.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the latest and greatest master, that warning has been eliminated by using RawShaderMaterial for the sdf and msdf text shaders. so... maybe needs rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase did the trick. ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any code comments, but wanted to say thanks for this PR and glTF FTW :) |
I believe this is caught up now. |
tests/systems/gltf-model.test.js
Outdated
/* global process, setup, suite, test, sinon, THREE */ | ||
var entityFactory = require('../helpers').entityFactory; | ||
|
||
suite.only('glTF system', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only
looks good to me! |
great looks totally fantastic |
* Add gltf-model component and system. Fixes aframevr#2261. * Set *.bin extension as binary. * Remove model; reference assets repo. * Rename system API to (un)registerModel. * Add component docs. * Add primitive wrapper, and docs. * Revert .gitattributes changes. * Add registration for <a-gltf-model/>. * Add tests. * what other tests * Fix errors in docs. * Add formats to meta title/desc. * Remove material extensions from collada and gltf primitives. * Add tests for gltf-model system. * Add labels to models demo. * Add 'Why use glTF' section. * Wording tweak. * sigh
xirvr's gltf component has been merged in aframevr#2333
xirvr's gltf component has been merged in #2333
Fixes #2261.
Description:
Adds
gltf-model
component and system, based on @xirvr's aframe-gltf implementation.Changes proposed:
aframe-extras.animation-mixer
.Adds example model (which is 11MB, so we can pick another from gltf-test if we prefer).