Skip to content

Commit

Permalink
Merge pull request #1949 from AnalyticalGraphicsInc/gltf-8
Browse files Browse the repository at this point in the history
Support for glTF 0.8
  • Loading branch information
mramato committed Jul 25, 2014
2 parents 29ffe69 + 2d1383d commit aa1a6b3
Show file tree
Hide file tree
Showing 38 changed files with 4,519 additions and 3,565 deletions.
Empty file modified Apps/SampleData/models/CesiumAir/Cesium_Air.dae
100644 → 100755
Empty file.
99 changes: 70 additions & 29 deletions Apps/SampleData/models/CesiumAir/Cesium_Air.gltf

Large diffs are not rendered by default.

Empty file modified Apps/SampleData/models/CesiumGround/Cesium_Ground.dae
100644 → 100755
Empty file.
54 changes: 33 additions & 21 deletions Apps/SampleData/models/CesiumGround/Cesium_Ground.gltf
100644 → 100755

Large diffs are not rendered by default.

316 changes: 189 additions & 127 deletions Apps/SampleData/models/CesiumMan/Cesium_Man.gltf
100644 → 100755

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Change Log
* Removed `ScreenSpaceCameraController.ellipsoid`. The behavior that depended on the ellipsoid is now determined based on the scene state.
* Sandcastle examples now automatically wrap the example code in RequireJS boilerplate. To upgrade any custom examples, copy the code into an existing example (such as Hello World) and save a new file.
* Replaced `PerspectiveFrustum.fovy` with `PerspectiveFrustum.fov` which will change the field of view angle in either the x or y direction depending on the aspect ratio.
* Updated the [Model Converter](http://cesiumjs.org/convertmodel.html) and `Model` to support [glTF 0.8](https://github.com/KhronosGroup/glTF/blob/schema-8/specification/README.md). See the [forum post](https://groups.google.com/forum/#!topic/cesium-dev/KNl2K3Cazno) for full details.
* Added northUpEast transform to help support display of glTF models because Y is their up axis.
* Cesium can now render an unlimited number of imagery layers, no matter how few texture units are supported by the hardware.
* Added `czm_octDecode` and `czm_signNotZero` builtin functions.
Expand Down
165 changes: 128 additions & 37 deletions Source/Scene/Model.js

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions Source/Scene/ModelAnimationCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ define([
'../Core/LinearSpline',
'../Core/Quaternion',
'../Core/QuaternionSpline',
'./ModelTypes'
'./getModelAccessor'
], function(
Cartesian3,
defined,
LinearSpline,
Quaternion,
QuaternionSpline,
ModelTypes) {
getModelAccessor) {
"use strict";
/*global WebGLRenderingContext*/

Expand All @@ -34,7 +34,7 @@ define([
var buffer = buffers[bufferView.buffer];

var byteOffset = bufferView.byteOffset + accessor.byteOffset;
var byteLength = accessor.count * ModelTypes[accessor.type].componentsPerAttribute;
var byteLength = accessor.count * getModelAccessor(accessor).componentsPerAttribute;

return model.basePath + buffer.path + ':' + byteOffset + ':' + byteLength;
}
Expand All @@ -53,22 +53,23 @@ define([

var bufferView = bufferViews[accessor.bufferView];

var componentType = accessor.componentType;
var type = accessor.type;
var count = accessor.count;

// Convert typed array to Cesium types
var typedArray = ModelTypes[type].createArrayBufferView(buffers[bufferView.buffer], bufferView.byteOffset + accessor.byteOffset, accessor.count);
var typedArray = getModelAccessor(accessor).createArrayBufferView(buffers[bufferView.buffer], bufferView.byteOffset + accessor.byteOffset, count);
var i;

if (type === WebGLRenderingContext.FLOAT) {
if ((componentType === WebGLRenderingContext.FLOAT) && (type === 'SCALAR')) {
values = typedArray;
}
else if (type === WebGLRenderingContext.FLOAT_VEC3) {
else if ((componentType === WebGLRenderingContext.FLOAT) && (type === 'VEC3')) {
values = new Array(count);
for (i = 0; i < count; ++i) {
values[i] = Cartesian3.fromArray(typedArray, 3 * i);
}
} else if (type === WebGLRenderingContext.FLOAT_VEC4) {
} else if ((componentType === WebGLRenderingContext.FLOAT) && (type === 'VEC4')) {
values = new Array(count);
for (i = 0; i < count; ++i) {
var byteOffset = 4 * i;
Expand Down Expand Up @@ -106,21 +107,24 @@ define([

if (!defined(spline)) {
var times = parameterValues[sampler.input];
var output = model.gltf.accessors[animation.parameters[sampler.output]];
var accessor = model.gltf.accessors[animation.parameters[sampler.output]];
var controlPoints = parameterValues[sampler.output];

// GLTF_SPEC: https://github.com/KhronosGroup/glTF/issues/185
if ((times.length === 1) && (controlPoints.length === 1)) {
spline = new ConstantSpline(controlPoints[0]);
} else {
// END GLTF_SPEC
var componentType = accessor.componentType;
var type = accessor.type;

if (sampler.interpolation === 'LINEAR') {
if (output.type === WebGLRenderingContext.FLOAT_VEC3) {
if ((componentType === WebGLRenderingContext.FLOAT) && (type === 'VEC3')) {
spline = new LinearSpline({
times : times,
points : controlPoints
});
} else if (output.type === WebGLRenderingContext.FLOAT_VEC4) {
} else if ((componentType === WebGLRenderingContext.FLOAT) && (type === 'VEC4')) {
spline = new QuaternionSpline({
times : times,
points : controlPoints
Expand Down
72 changes: 0 additions & 72 deletions Source/Scene/ModelTypes.js

This file was deleted.

34 changes: 34 additions & 0 deletions Source/Scene/getModelAccessor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*global define*/
define([
'../Core/ComponentDatatype'
], function(
ComponentDatatype) {
"use strict";

var ComponentsPerAttribute = {
'SCALAR' : 1,
'VEC2' : 2,
'VEC3' : 3,
'VEC4' : 4,
'MAT2' : 4,
'MAT3' : 9,
'MAT4' : 16
};

/**
* @private
*/
var getModelAccessor = function(accessor) {
var componentDatatype = accessor.componentType;
var componentsPerAttribute = ComponentsPerAttribute[accessor.type];

return {
componentsPerAttribute : componentsPerAttribute,
createArrayBufferView : function(buffer, byteOffset, length) {
return ComponentDatatype.createArrayBufferView(componentDatatype, buffer, byteOffset, componentsPerAttribute * length);
}
};
};

return getModelAccessor;
});
Loading

0 comments on commit aa1a6b3

Please sign in to comment.