-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Update gltf Pipeline and support KHR_techniques_webgl and KHR_blend #6805
Changes from 2 commits
be6fffa
9d907df
e82b4b6
395eb34
173f4b5
923874b
7abc5c7
1e5d67f
58f99b4
6de38fe
5651d79
c098115
be83cc2
681aa24
c0db13d
c69505b
a7a4ced
514c2b7
71ff4c4
ccad16c
b136052
7a9faa7
c56a339
21caa93
7c28d2a
ba4d840
db96ceb
ca4dc6c
f3afd01
0d8a577
6401433
3dad95a
6d8e5dc
974af0d
604400d
602db48
73db740
5fb072e
d97b899
fcd4433
e59593a
67ef702
22cc546
4ec829c
3cc7c98
5b94577
05ef68d
0e63533
3cad9ea
b137ab4
2de8d69
4d5d53f
e88ac9d
88ebec6
4c168a9
015e700
e5e495c
f78b4f5
125c36f
fb69626
c0eaf28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
define([ | ||
'../../Core/WebGLConstants' | ||
'./WebGLConstants' | ||
], function( | ||
WebGLConstants) { | ||
'use strict'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ define([ | |
'../ThirdParty/GltfPipeline/ForEach', | ||
'../ThirdParty/GltfPipeline/getAccessorByteStride', | ||
'../ThirdParty/GltfPipeline/numberOfComponentsForType', | ||
'../ThirdParty/GltfPipeline/parseBinaryGltf', | ||
'../ThirdParty/GltfPipeline/parseGlb', | ||
'../ThirdParty/when', | ||
'./Axis', | ||
'./ClassificationType', | ||
|
@@ -59,7 +59,7 @@ define([ | |
ForEach, | ||
getAccessorByteStride, | ||
numberOfComponentsForType, | ||
parseBinaryGltf, | ||
parseGlb, | ||
when, | ||
Axis, | ||
ClassificationType, | ||
|
@@ -124,25 +124,25 @@ define([ | |
|
||
if (gltf instanceof Uint8Array) { | ||
// Binary glTF | ||
gltf = parseBinaryGltf(gltf); | ||
gltf = parseGlb(gltf); | ||
} else { | ||
throw new RuntimeError('Only binary glTF is supported as a classifier.'); | ||
} | ||
|
||
var gltfNodes = gltf.nodes; | ||
var gltfMeshes = gltf.meshes; | ||
|
||
var gltfNode = gltfNodes[0]; | ||
var meshId = gltfNode.mesh; | ||
if (gltfNodes.length !== 1 || !defined(meshId)) { | ||
var gltfNode = gltfNodes.rootNode; | ||
if (!defined(gltfNode) || !defined(gltfNode.meshes)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It looks like After fixing that I suspect a lot of the other code changes below may not be needed. |
||
throw new RuntimeError('Only one node is supported for classification and it must have a mesh.'); | ||
} | ||
|
||
if (gltfMeshes.length !== 1) { | ||
throw new RuntimeError('Only one mesh is supported when using b3dm for classification.'); | ||
var nodeMesh = gltfNode.meshes[0]; | ||
if (!defined(nodeMesh)) { | ||
throw new RuntimeError('Only one node is supported for classification and it must have a mesh.'); | ||
} | ||
|
||
var gltfPrimitives = gltfMeshes[0].primitives; | ||
var gltfPrimitives = gltfMeshes[nodeMesh].primitives; | ||
if (gltfPrimitives.length !== 1) { | ||
throw new RuntimeError('Only one primitive per mesh is supported when using b3dm for classification.'); | ||
} | ||
|
@@ -499,8 +499,8 @@ define([ | |
var min = new Cartesian3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); | ||
var max = new Cartesian3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); | ||
|
||
var n = gltfNodes[0]; | ||
var meshId = n.mesh; | ||
var n = gltfNodes.rootNode; | ||
var meshId = n.meshes[0]; | ||
|
||
var transformToRoot = ModelUtility.getTransform(n); | ||
var mesh = gltfMeshes[meshId]; | ||
|
@@ -646,7 +646,9 @@ define([ | |
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly |
||
|
||
function modifyShaderForQuantizedAttributes(shader, model) { | ||
var primitive = model.gltf.meshes[0].primitives[0]; | ||
var gltfMeshes = model.gltf.meshes; | ||
var gltfRootNode = model.gltf.nodes.rootNode; | ||
var primitive = gltfMeshes[gltfRootNode.meshes[0]].primitives[0]; | ||
var result = ModelUtility.modifyShaderForQuantizedAttributes(model.gltf, primitive, shader); | ||
model._quantizedUniforms = result.uniforms; | ||
return result.shader; | ||
|
@@ -748,7 +750,8 @@ define([ | |
var gltf = model.gltf; | ||
var accessors = gltf.accessors; | ||
var meshes = gltf.meshes; | ||
var primitives = meshes[0].primitives; | ||
var rootNode = gltf.nodes.rootNode; | ||
var primitives = meshes[rootNode.meshes[0]].primitives; | ||
|
||
var primitive = primitives[0]; | ||
var attributeLocations = getAttributeLocations(); | ||
|
@@ -804,23 +807,19 @@ define([ | |
return; | ||
} | ||
|
||
var techniques = model.gltf.techniques; | ||
var technique = techniques[0]; | ||
var parameters = technique.parameters; | ||
var uniforms = technique.uniforms; | ||
|
||
var uniformMap = {}; | ||
for (var name in uniforms) { | ||
if (uniforms.hasOwnProperty(name) && name !== 'extras') { | ||
var parameterName = uniforms[name]; | ||
ForEach.technique(model.gltf, function(technique) { | ||
var parameters = technique.parameters; | ||
ForEach.techniqueUniform(technique, function(parameterName, uniformName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like another area that is depending on the glTF being 1.0. Normally a 2.0 model with the techniques extension would not have |
||
var parameter = parameters[parameterName]; | ||
|
||
if (!defined(parameter.semantic) || !defined(gltfSemanticUniforms[parameter.semantic])) { | ||
continue; | ||
return; | ||
} | ||
uniformMap[name] = gltfSemanticUniforms[parameter.semantic](context.uniformState, model); | ||
} | ||
} | ||
|
||
uniformMap[uniformName] = gltfSemanticUniforms[parameter.semantic](context.uniformState, model); | ||
}); | ||
}); | ||
|
||
model._uniformMap = uniformMap; | ||
} | ||
|
@@ -850,7 +849,8 @@ define([ | |
var gltf = model.gltf; | ||
var accessors = gltf.accessors; | ||
var gltfMeshes = gltf.meshes; | ||
var primitive = gltfMeshes[0].primitives[0]; | ||
var gltfRootNode = gltf.nodes.rootNode; | ||
var primitive = gltfMeshes[gltfRootNode.meshes[0]].primitives[0]; | ||
var ix = accessors[primitive.indices]; | ||
|
||
var positionAccessor = primitive.attributes.POSITION; | ||
|
@@ -999,7 +999,7 @@ define([ | |
|
||
var gltf = model.gltf; | ||
var nodes = gltf.nodes; | ||
var gltfNode = nodes[0]; | ||
var gltfNode = nodes.rootNode; | ||
model._nodeMatrix = ModelUtility.getTransform(gltfNode, model._nodeMatrix); | ||
|
||
createPrimitive(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.
It's probably worth doing a pass over the documentation to fix some of the existing problems like:
KHR_binary_glTF
extension@exception {DeveloperError} bgltf is not a valid Binary glTF file.
@exception {DeveloperError} Only glTF Binary version 1 is supported.
@param {Object|ArrayBuffer|Uint8Array} options.gltf The object for the glTF JSON or an arraybuffer of Binary glTF defined by the KHR_binary_glTF extension.
- only binary glTF is supported.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.
Also for
Model
andModel.fromGltf
.