Skip to content
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

glTF 2.0 support #1904

Merged
merged 56 commits into from
Mar 13, 2020
Merged

glTF 2.0 support #1904

merged 56 commits into from
Mar 13, 2020

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented Mar 6, 2020

This PR contains the following:

  • support for loading glb and glTF models, animations, materials, textures (glb.js)
  • new animation system for GLB animations (anim.js) which supersedes skeleton and animation.js
  • new type of engine resource called a 'container' (container.js)
    • used for loading a GLB assets in the engine
    • the container instance wraps a list of sub-assets for the GLB textures, model, animation, materials
  • support for loading GLB model and animation assets
    • required for integrating the new GLB asset pipeline into the editor
  • support two versions of glb load:
    • asynchronous version which loads external resources (buffers and images)
    • synchronous version which ignores external resources, used for the model and animation support for glb files in editor
  • updated the animation component to work with the old skeleton/animation system and the new AnimController system
  • GLB viewer tool for the engine (viewer/*)
    • demonstrates loading GLB files in the engine

glb-viewer

I confirm I have signed the Contributor License Agreement.

@slimbuck
Copy link
Member Author

Regarding the naming of container - no resource type in the asset system is named after its file format. We have "texture" resources and "model" resources and "animation" resources and suddenly naming this "glb" will break convention. It's also slightly incorrect because the handler supports both GLB and GLTF format (which are related).

So for now I will rename these to GlbResource and GlbHandler as the lesser of two evils, but I do so under protest, until someone comes up with a better name!

@willeastcott
Copy link
Contributor

Pretty much any name can be aliased in the future. So it's not like we can't adjust these decisions in the future. But I would go along with @slimbuck and @mvaligursky here and say that names like Container are better than GlbContainer, say. Imagine a world where we wanted to load a binary FBX file at runtime - the contents are reasonably equivalent to what's in a GLB - so it should also be a Container but with an FbxParser instead of a GlbParser.

@Maksims
Copy link
Contributor

Maksims commented Mar 11, 2020

Reason for load and open, is that developer might provide raw data from somewhere else, instead of loading.
For example procedurally generating, or getting data via websockets, and then calling open on them.

src/anim/anim.js Outdated Show resolved Hide resolved
src/anim/anim.js Outdated Show resolved Hide resolved
* @example
* app.assets.loadFromUrl("../path/to/texture.jpg", "texture", function (err, asset) {
* var texture = asset.resource;
* });
*/
loadFromUrl: function (url, type, callback) {
loadFromUrl: function (url, type, callback, filename) {
Copy link

@mekwall mekwall Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is polluting the API unnecessarily. Callbacks are expected to be the last argument and since it would be a breaking change to move filename before callback it's not really viable either. How about adding a new method in the pc.Asset class for setting the name instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow, Asset already exposes name and filename? This was added so the GlbParser can identify whether the data is GLB or GLTF when loading from a blob.

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a bunch of comments from a first pass review of this. Looks great - so exciting!

src/anim/anim.js Outdated Show resolved Hide resolved
@slimbuck slimbuck merged commit cca7be0 into playcanvas:master Mar 13, 2020
@slimbuck slimbuck deleted the glb-support branch March 13, 2020 14:10
@willeastcott willeastcott changed the title Engine GLB support glTF 2.0 support Mar 13, 2020
@jinwoobot
Copy link
Contributor

jinwoobot commented Mar 17, 2020

So we don't have to use playcanvas-gltf anymore?

@slimbuck
Copy link
Member Author

Hi @Velbi,

It depends. The engine GLTF implementation is missing morph target support and draco compression. These haven't been added yet but are planned. Also the animation system is new and might not be as fully featured yet as the one in playcanvas-gltf.

Thanks!

TheJonRobinson added a commit to Mojiworks/playcanvas-engine that referenced this pull request Mar 30, 2020
* stable: (48 commits)
  [RELEASE] v1.26.0
  [FIX] null access when pushing SpectorJS marker without camera (playcanvas#1933)
  [FIX] pc.XrHitTest when WebXR not available
  Update package-lock.json
  Downgrade mocha to 6.2.2
  WebXR AR hit test support (playcanvas#1926)
  [ImgBot] Optimize images (playcanvas#1927)
  [DOCS] Make anim API private (playcanvas#1924)
  Update NPM dependencies.
  [FIX] Update some example paths
  Update to latest JSDoc template
  [FIX] Updating of particle systems local bounds
  Add pc.drawTexture to render texture to target using a shader (playcanvas#1920)
  Optimize Grab-Pass for WebGL 2 and fix when using anti-aliased RenderTarget (playcanvas#1918)
  [DOCS] Document drawQuadWithShader and copyRenderTarget (playcanvas#1919)
  [FIX] Mouse wheel events on elements (playcanvas#1916)
  glTF 2.0 support (playcanvas#1904)
  Update to latest JSDoc template.
  Add support for ES6 script classes (playcanvas#1908)
  Particle system randomize sprite animations (playcanvas#1911)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants