Code Monkey home page Code Monkey logo

gltfscenekit's Introduction

Carthage compatible

GLTFSceneKit

glTF loader for SceneKit

ScreenShot

Installation

Using CocoaPods

Add the following to your Podfile:

pod 'GLTFSceneKit'

Using Carthage

Add the following to your Cartfile:

github "magicien/GLTFSceneKit" ~> 0.4.0
  1. Open your project with Xcode
  2. Select File > Swift Packages > Add Package Dependency...
  3. Put https://github.com/magicien/GLTFSceneKit in the search box and click Next

Usage

Swift

import GLTFSceneKit

var scene: SCNScene
do {
  let sceneSource = try GLTFSceneSource(named: "art.scnassets/Box/glTF/Box.gltf")
  scene = try sceneSource.scene()
} catch {
  print("\(error.localizedDescription)")
  return
}

Objective-C

@import GLTFSceneKit;

GLTFSceneSource *source = [[GLTFSceneSource alloc] initWithURL:url options:nil];
NSError *error;
SCNScene *scene = [source sceneWithOptions:nil error:&error];
if (error != nil) {
  NSLog(@"%@", error);
  return;
}

See also

GLTFQuickLook - QuickLook plugin for glTF files

gltfscenekit's People

Contributors

alicanc avatar arafo avatar ddnn55 avatar j6lim avatar jaredhalpern avatar jospinawayfair avatar magicien avatar ox avatar sgara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gltfscenekit's Issues

Not Working in ios 12 and xcode 10

App crashes on GLTFUnarchiver.swift, line 1036 with a message: "Fatal error: Unexpectedly found nil while unwrapping an Optional value".

An older app built using xcode 9.x was working, but threw the same error when built on xcode 10.

Extra Nodes get Created per object in a glb

image

When models are getting imported their hierarchy is getting created like above.
where the water bottle only defines one submesh called water bottle
image
So instead of loading the gltf like we do know.

WaterBottle
    -WaterBottleEmptyNode
        -WaterBottleMesh

we should do this

WaterBottle
    -WaterBottleMesh

because to access the materials of these nodes, we right now have to do something like

node.childNodes[0].childNodes[0].geometry?.firstMaterial

shader compile error on Xcode 13

Hi
I'm trying to show .glb file on swift.
I read the sample file and attached it on my Xcode project with same Assets.
But I encountered error like this.
Any help??

[SceneKit] Error: FATAL ERROR : failed compiling shader: Error Domain=MTLLibraryErrorDomain Code=3 "program_source:3718:1: error: C++ requires a type specifier for all declarations , constant float& metallicFactor ^ " UserInfo={NSLocalizedDescription=program_source:3718:1: error: C++ requires a type specifier for all declarations , constant float& metallicFactor ^ }

binaries use incompatible versions of Swift

My project runs on xcode 10.1 with Swift version 4.2
After integrating library i am getting following error:

error: The following binaries use incompatible versions of Swift:
/project-path/GLTFSceneKit_v0.1.3/iOS/GLTFSceneKit.framework/GLTFSceneKit
/project-pathr/project-name.app/project-name

I also tried with Swift version v4.0 but no success.

Material color is not reflected.

Hi,
We are converting the .babylon file to .gltf format and are trying to load this converted model on the iOS application. The model is getting rendered correctly barring the material color of certain objects which we added to the .babylon file before converting.
The converted model is showing all the material color properties on the .babylonSandbox for the gltf file. Attached are the screenshots of the sandbox and on the iPhone device respectively.

Any pointers regarding this issue would be really helpful.

Thanks & Regards
Ashutosh
babylonsandboxloadedmodelscreenshot
iphoneapploadedmodelscreenshot

Further animations support.

Hi
I am working on playing , pausing my animations attached in the GLTF file but I am facing certain issue with Pivot and the axis for the nodes I am trying to apply the animations to.

Is there any sample which illustrates the playing and pausing of animations attached to respective nodes or any pointers for the same would be really helpful.

Thanks & Regards
Ashutosh

How to trigger a specific animation in glb

I was able to render the glb file using gltfscenekit framework and wanted to know how to trigger a particular animation within a glb.

Everytime glb loads in scene it plays the last animation in the glb, glb has multiple animations baked in it.

Any help will be appreciated.

Custom vertex property

Would it be possible to load a custom vertex property from a .glb file and map a custom colour to it?
Thanks

Strange data mismatch

First off, incredible project! I'm blown away by the concise code structure and the broad support the library provides. However, I'm getting the following error trying to load a glTF file with many empty morph targets (due to using fbx2gltf):

DataInconsistent: loadWeightAnimationsSampler: data count mismatch: 3 != 25

The model I'm using is monster.glb.txt. I know the model isn't ideal but there are the right number of accessors for each morph target and nothing seems too out of place in that regard. Any thoughts on what could be the issue?

GLTFSceneSource -> SCNReferenceNode?

Is there a way to use a GLTFSceneSource as the source for an SCNReferenceNode? I'm using SCNRferenceNode.unload/.load to manage the memory consumption of other models and I'd like to also use it for GLTF models. Thanks!

Adding local UV maps

Can someon tell me how to load UV maps(jpg) to a node from phone's file system?
So I have saved images and I want to apply them to a specific node inside my scene...
Thank you

Cannot load *.glft with KHR_draco_mesh_compression extension

I have a *.gltf file with KHR_draco_mesh_compression extension.
So, I tried to load this file, but I cannot find loaded file in my phone screen.

And My log is here.

2020-01-22 18:20:05.273470+0900 arkit_gltf_test2[8239:2291248] Metal GPU Frame Capture Enabled
2020-01-22 18:20:05.273613+0900 arkit_gltf_test2[8239:2291248] Metal API Validation Enabled
The operation couldn’t be completed. (NSURLErrorDomain error -1100.)

Is this kit not available to this file? Then, Can you make this feature?

Not working if Access .gltf file via url

Its not accessing the .gltf file when I using it through url like:
do { let sceneSource = GLTFSceneSource(url: scenePath) scene = try sceneSource.scene() } catch { print("\(error.localizedDescription)") return }

its saying : The file “Box0.bin” couldn’t be opened because there is no such file.

SCNSkinner: “there must be the same number of bone weights and bone indices”

Running into an issue while rendering a gltf file through GLTFSceneKit. I've verifed that the file loads and animates through Bablyon.js, Cesium, Three.js but it is not working with SceneKit. more specifically I am getting this error on this line:

let skinner = SCNSkinner(baseGeometry: baseGeometry, bones: joints, boneInverseBindTransforms: boneInverseBindTransforms, boneWeights: boneWeights, boneIndices: boneIndices) in GLTFUnarchiver.swift

Any ideas how to fix it ?

Add shadow to AR object

Hi,
We tried different approaches to add shadows to the AR object converted from GLB files, but none of them worked, and the only way that we could do it, done by adding the fake shadows, which is a pretty expensive approach at the CPU level.
Any idea how we can do it and what is the issue?

Thanks

Animations for GLB in iOS

Hello there,
We have a humanoid character
We dont know how to add animation in Glb file. Can anyone let us know how to play animations in iOS for Glb

Doesn't work on iOS with png texture

I have a gltf model with an extenal .bin and .png file, but it seems thet the png file is not loaded.
I've looked into the code and I see these lines which is not good news I guess...
So basically it doesn't work on iOS when you have an texture image to load along with the .gltf ?

#if SEEMS_TO_HAVE_PNG_LOADING_BUG
 // FIXME: this workaround doesn't work for iOS...
return UIImage(cgImage: cgImage)

Animation not working

Spider_3_scaled.glb.zip
gltf with animation not loading , failing with error : Error Domain=AGXMetalA9 Code=3 "Cannot convert attribute from MTLAttributeFormatShort4 to an unsigned integer type" UserInfo={NSLocalizedDescription=Cannot convert attribute from MTLAttributeFormatShort4 to an unsigned integer type}

attached the glb I am trying to load

Loading options are ignored

Upon discovering that setting the options parameter in GLTFSceneSource.init or GLTFSceneSource.scene didn't affect the output, I checked the source only to realize that these options don't appear to be used anywhere by GLTFKit.

Is this intentional? Is there any plan to support these? If not I might suggest to simply remove the parameter from those functions because as it stands right now it's misleading.

Thanks for your time. The library is greatly appreciated.

Joints_2 and Weights_2

Need support for Joints_2 and Weights_2. Could you please update the library for the same?

Seems Tangent vectors are being calculated and handled incorrectly

https://github.com/cx20/gltf-test

I've been running the tests found at that github project on the model viewer and it seems like the normal tangent test is failing

https://github.com/cx20/gltf-test/tree/master/tutorialModels/NormalTangentTest

we are supposed to get something like

this is from http://sandbox.babylonjs.com/

image

but we end up getting something like this.

image

the two "spheres" should be exactly the same, but they arent' I haven't looked into it too much, but it seems like the way the tangent vectors that are read from the GLB are being calculated incorrectly

Problematic Models

Hey, thanks for the great library! I have been experimenting with some models from Sketchfab with the sample macOS app and I've found a few models that have problems.

The following models have no texture:
https://sketchfab.com/models/d237537968c8474abfd43a258c415304
https://sketchfab.com/models/5f28af46bb6b42de8a1045d92300f771
https://sketchfab.com/models/fd8fc2a6e9d9441c9b5338cf384b4b6b

The following model crashes:
https://sketchfab.com/models/c2bd67e2fc644dfb9a80def2f773a5e5

It would be great if we could figure out what's going on.

Thanks in advance!

Async loading of resources (images, buffers)

Hi there! Thanks for the great work here!
I've been doing some test with the loader and I ended up loading distant files with http protocol, and it actually works.
Using Data(contentsOf:) is synchronous and it doesn't give any room for customization (headers, authentication, ...) at least none that I know of.
I was wondering if we could make some changes to make resource loading async. This would allow on-demand fetching of glTF files over http, and we could even create an interface to give customization for requests.

My model shows a white texture

My model is showing correctly on the threejs-based Web browser, but GLTFSceneKit shows a white texture.
What's wrong?

error log
GLTFSceneKitSample[9058:612984] [SceneKit] Error: unsupported conversion uchar4 -> float4

URL of model

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.