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 to b3dm #4

Open
qdnguyen opened this issue Jun 12, 2017 · 12 comments
Open

gltf to b3dm #4

qdnguyen opened this issue Jun 12, 2017 · 12 comments

Comments

@qdnguyen
Copy link

HI,

Thank for your tools!

I have converted a gltf to b3dm file with success but when i use threejs GLTF loader to parse the b3dm file, i got this error:

GLTFLoader.js:980 Uncaught (in promise) TypeError: Cannot read property 'binary_glTF' of undefined
at GLTFLoader.js:980
at _each (GLTFLoader.js:592)
at GLTFLoader.js:978
at

Do you have any idea what is problem?

p/s : I can visualize my gltf file with this online demo without problem (please see attached file)
LYON_1ER_00033.zip

https://gltf-viewer.donmccurdy.com/

My gltf file has 21.4KB but the converted b3dm file takes 187KB, is it possible?

Thank for your reply!

@qdnguyen
Copy link
Author

i think it embed the texture by default, i tried to desactivate it without success.

@KermMartian
Copy link
Contributor

2ff30d6 should fix this; please test at your convenience.

@qdnguyen
Copy link
Author

qdnguyen commented Jun 12, 2017

Thank you very much for you quick reply, it seem that patch fix the embeded texture problem but i still can not visualize the converted file (both glb and b3dm) with gltf-viewer.

For online viewer (gltf-viewer), i got this error:

Uncaught Error: GLTF2Loader: Legacy binary file detected. Use GLTFLoader instead.
at new GLTFBinaryExtension (bundle.js:863)
at GLTF2Loader.parse (bundle.js:558)
at bundle.js:531
at XMLHttpRequest. (bundle.js:34154)

and for my viewer, i had this error:

GLTFLoader.js:980 Uncaught (in promise) TypeError: Cannot read property 'binary_glTF' of undefined
at GLTFLoader.js:980
at _each (GLTFLoader.js:592)
at GLTFLoader.js:978
at

Do you have any idea?

@qdnguyen
Copy link
Author

ok, the problem is that this tool is not compatible with gltf 2.0, if i use older gltfLoader, it work, have you plan to upgrade this tool?

thank anyway

@KermMartian
Copy link
Contributor

I'd certainly like to make it compatible with GLTF 2.0. Do you have any idea about what specifically is incompatible between this tool and GLTF 2.0?

@qdnguyen
Copy link
Author

qdnguyen commented Jun 14, 2017

i take a look at GLTFLoader, and i saw that it arrive to parse header, json but not accessor and i do not know why?

i have this error in the function loadAccessors

GLTFLoader.js:1023 Uncaught (in promise) RangeError: Invalid typed array length
at new Float32Array (native)

GLTFParser.prototype.loadAccessors = function () {

		var json = this.json;

		return this._withDependencies( [

			"bufferViews"

		] ).then( function ( dependencies ) {

			return _each( json.accessors, function ( accessor ) {

				var arraybuffer = dependencies.bufferViews[ accessor.bufferView ];
				var itemSize = WEBGL_TYPE_SIZES[ accessor.type ];
				var TypedArray = WEBGL_COMPONENT_TYPES[ accessor.componentType ];

				// For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
				var elementBytes = TypedArray.BYTES_PER_ELEMENT;
				var itemBytes = elementBytes * itemSize;

				// The buffer is not interleaved if the stride is the item size in bytes.
				if ( accessor.byteStride && accessor.byteStride !== itemBytes ) {

					// Use the full buffer if it's interleaved.
					var array = new TypedArray( arraybuffer );

					// Integer parameters to IB/IBA are in array elements, not bytes.
					var ib = new THREE.InterleavedBuffer( array, accessor.byteStride / elementBytes );

					return new THREE.InterleavedBufferAttribute( ib, itemSize, accessor.byteOffset / elementBytes );

				} else {

					**array = new TypedArray( arraybuffer, accessor.byteOffset, accessor.count * itemSize );**

					return new THREE.BufferAttribute( array, itemSize );

				}

			} );

		} );

	};

@KermMartian
Copy link
Contributor

Can you please provide the input GLTF 2.0 file and the command line you're trying to use to convert it for my debugging?

@qdnguyen
Copy link
Author

qdnguyen commented Jun 14, 2017

i attache the file here
TilesetBuilding.zip

i have tried with many command line such as
gltf2glb.py -b "" -o LYON_1ER_00042.b3dm LYON_1ER_00042.gltf

gltf2glb.py -c -b "" -o LYON_1ER_00042.b3dm LYON_1ER_00042.gltf

gltf2glb.py LYON_1ER_00042.gltf

the last one generate a glb file then you can test it with threejs gltfLoader

https://threejs.org/examples/#webgl_loader_gltf
http://localhost/Github/threejs/examples/#webgl_loader_gltf2

Thank for your debug!

p/s : I was wrong in my comment a day ago. The glb file, which is generated with your tools, does not work with threejs gltfLoader, but the glb file generated by https://github.com/Qantas94Heavy/binary-gltf-utils/, works well!

@KermMartian
Copy link
Contributor

I was able to use the latest commit to successfully convert your file into a GLB that the three.js example viewer can load. Please verify, and if you replicate my success, I'll close this.

@qdnguyen
Copy link
Author

Thank you, but it does not work for me, please see attached photo to have more information!

image

@iyush1993
Copy link

Hi @qdnguyen,
May I know how you converted gltf to b3dm?

@leopessanha74
Copy link

I'd like to know how to convert gltf files to b3dm too!

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

No branches or pull requests

4 participants