diff --git a/samples-generator/bin/3d-tiles-samples-generator.js b/samples-generator/bin/3d-tiles-samples-generator.js index 1abbf56d..6de85582 100644 --- a/samples-generator/bin/3d-tiles-samples-generator.js +++ b/samples-generator/bin/3d-tiles-samples-generator.js @@ -2,8 +2,11 @@ 'use strict'; var Cesium = require('cesium'); var fsExtra = require('fs-extra'); +var gltfPipeline = require('gltf-pipeline'); var path = require('path'); var Promise = require('bluebird'); +var DataUri = require('datauri'); + var createBatchTableHierarchy = require('../lib/createBatchTableHierarchy'); var createBuildingsTile = require('../lib/createBuildingsTile'); var createB3dm = require('../lib/createB3dm'); @@ -13,11 +16,12 @@ var createInstancesTile = require('../lib/createInstancesTile'); var createPointCloudTile = require('../lib/createPointCloudTile'); var createTilesetJsonSingle = require('../lib/createTilesetJsonSingle'); var getProperties = require('../lib/getProperties'); -var modifyGltfPaths = require('../lib/modifyGltfPaths'); var saveTile = require('../lib/saveTile'); var saveTilesetJson = require('../lib/saveTilesetJson'); var util = require('../lib/utility'); +var processGlb = gltfPipeline.processGlb; + var Cartesian3 = Cesium.Cartesian3; var CesiumMath = Cesium.Math; var clone = Cesium.clone; @@ -31,13 +35,13 @@ var metersToLongitude = util.metersToLongitude; var metersToLatitude = util.metersToLatitude; var wgs84Transform = util.wgs84Transform; -var optimizeForCesium = true; -var relativeToCenter = true; var prettyJson = true; var gzip = false; var outputDirectory = 'output'; +var versionNumber = '1.0'; + var longitude = -1.31968; var latitude = 0.698874; var tileWidth = 200.0; @@ -55,7 +59,7 @@ var buildingTemplate = { tileWidth : tileWidth, averageWidth : 8.0, averageHeight : 10.0, - diffuseType : 'white', + baseColorType : 'white', translucencyType : 'opaque', longitude : longitude, latitude : latitude @@ -96,10 +100,9 @@ var pointCloudSphereLocal = [0.0, 0.0, 0.0, pointCloudRadius]; var instancesLength = 25; var instancesGeometricError = 70.0; // Estimated var instancesTileWidth = tileWidth; -var instancesUrl = 'data/box.glb'; // Model's center is at the origin (and for below) -var instancesRedUrl = 'data/red_box.glb'; -var instancesTexturedUrl = 'data/textured_box.glb'; -var instancesZUpUrl = 'data/box-z-up.glb'; +var instancesUri = 'data/box.glb'; // Model's center is at the origin (and for below) +var instancesRedUri = 'data/red_box.glb'; +var instancesTexturedUri = 'data/textured_box.glb'; var instancesModelSize = 20.0; var instancesHeight = instancesModelSize + 10.0; // Just a little extra padding at the top for aiding Cesium tests var instancesTransform = wgs84Transform(longitude, latitude, instancesModelSize / 2.0); @@ -127,8 +130,7 @@ var parentTileOptions = { buildingOptions : parentOptions, createBatchTable : true, transform : buildingsTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; var childrenRegion = [longitude - longitudeExtent, latitude - latitudeExtent, longitude + longitudeExtent, latitude + latitudeExtent, 0.0, smallHeight]; @@ -145,8 +147,7 @@ var llTileOptions = { buildingOptions : llOptions, createBatchTable : true, transform : llTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; var lrRegion = [longitude, latitude - latitudeExtent, longitude + longitudeExtent, latitude, 0.0, smallHeight]; @@ -161,8 +162,7 @@ var lrTileOptions = { buildingOptions : lrOptions, createBatchTable : true, transform : lrTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; var urRegion = [longitude, latitude, longitude + longitudeExtent, latitude + latitudeExtent, 0.0, smallHeight]; @@ -177,8 +177,7 @@ var urTileOptions = { buildingOptions : urOptions, createBatchTable : true, transform : urTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; var ulRegion = [longitude - longitudeExtent, latitude, longitude, latitude + latitudeExtent, 0.0, smallHeight]; @@ -193,8 +192,7 @@ var ulTileOptions = { buildingOptions : ulOptions, createBatchTable : true, transform : ulTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; var promises = [ @@ -208,20 +206,18 @@ var promises = [ createBatchedColorsTranslucent(), createBatchedColorsMix(), createBatchedTextured(), - createBatchedCompressedTextures(), createBatchedWithBoundingSphere(), createBatchedWithTransformBox(), createBatchedWithTransformSphere(), createBatchedWithTransformRegion(), + createBatchedWithRtcCenter(), createBatchedNoBatchIds(), - createBatchedWithKHRMaterialsCommon(), - createBatchedWithQuantization(), createBatchedWGS84(), createBatchedDeprecated1(), createBatchedDeprecated2(), - createBatchedGltfZUp(), createBatchedExpiration(), createBatchedWithVertexColors(), + createBatchedWithContentDataUri(), // Point Cloud createPointCloudRGB(), createPointCloudRGBA(), @@ -252,14 +248,13 @@ var promises = [ createInstancedRedMaterial(), createInstancedWithBatchIds(), createInstancedTextured(), - createInstancedCompressedTextures(), - createInstancedGltfZUp(), // Composite createComposite(), createCompositeOfComposite(), createCompositeOfInstanced(), // Hierarchy createHierarchy(), + createHierarchyLegacy(), createHierarchyMultipleParents(), createHierarchyNoParents(), createHierarchyBinary(), @@ -284,10 +279,7 @@ var promises = [ createExpireTileset() ]; -Promise.all(promises) - .then(function() { - console.log('Done'); - }); +return Promise.all(promises); function createBatchedWithBatchTable() { var tileOptions = { @@ -332,32 +324,16 @@ function createBatchedTranslucentOpaqueMix() { function createBatchedTextured() { var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'textured'; + buildingOptions.baseColorType = 'textured'; var tileOptions = { buildingOptions : buildingOptions }; return saveBatchedTileset('BatchedTextured', tileOptions); } -function createBatchedCompressedTextures() { - var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'textured'; - var tileOptions = { - buildingOptions : buildingOptions, - textureCompressionOptions : [{ - format : 'dxt1', - quality : 10 - }, { - format : 'etc1', - quality : 10 - }] - }; - return saveBatchedTileset('BatchedCompressedTextures', tileOptions); -} - function createBatchedColors() { var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'color'; + buildingOptions.baseColorType = 'color'; var tileOptions = { buildingOptions : buildingOptions }; @@ -366,7 +342,7 @@ function createBatchedColors() { function createBatchedColorsTranslucent() { var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'color'; + buildingOptions.baseColorType = 'color'; buildingOptions.translucencyType = 'translucent'; var tileOptions = { buildingOptions : buildingOptions @@ -376,7 +352,7 @@ function createBatchedColorsTranslucent() { function createBatchedColorsMix() { var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'color'; + buildingOptions.baseColorType = 'color'; buildingOptions.translucencyType = 'mix'; var tileOptions = { buildingOptions : buildingOptions @@ -427,25 +403,24 @@ function createBatchedWithTransformRegion() { return saveBatchedTileset('BatchedWithTransformRegion', tileOptions, tilesetOptions); } -function createBatchedNoBatchIds() { +function createBatchedWithRtcCenter() { var tileOptions = { - useBatchIds : false + transform : Matrix4.IDENTITY, + relativeToCenter : false, + rtcCenterPosition : [0.1, 0.2, 0.3] }; - return saveBatchedTileset('BatchedNoBatchIds', tileOptions); -} - -function createBatchedWithKHRMaterialsCommon() { - var tileOptions = { - khrMaterialsCommon : true + var tilesetOptions = { + region : smallRegion, + transform : buildingsTransform }; - return saveBatchedTileset('BatchedWithKHRMaterialsCommon', tileOptions); + return saveBatchedTileset('BatchedWithRtcCenter', tileOptions, tilesetOptions); } -function createBatchedWithQuantization() { +function createBatchedNoBatchIds() { var tileOptions = { - quantization : true + useBatchIds : false }; - return saveBatchedTileset('BatchedWithQuantization', tileOptions); + return saveBatchedTileset('BatchedNoBatchIds', tileOptions); } function createBatchedWGS84() { @@ -459,27 +434,27 @@ function createBatchedWGS84() { function createBatchedDeprecated1() { // Save the b3dm with the deprecated 20-byte header and the glTF with the BATCHID semantic var tileOptions = { - deprecated1 : true + deprecated1 : true, + transform : Matrix4.IDENTITY, + relativeToCenter : false }; - return saveBatchedTileset('BatchedDeprecated1', tileOptions); + var tilesetOptions = { + transform : buildingsTransform + }; + return saveBatchedTileset('BatchedDeprecated1', tileOptions, tilesetOptions); } function createBatchedDeprecated2() { // Save the b3dm with the deprecated 24-byte header and the glTF with the BATCHID semantic var tileOptions = { - deprecated2 : true - }; - return saveBatchedTileset('BatchedDeprecated2', tileOptions); -} - -function createBatchedGltfZUp() { - var tileOptions = { - gltfUpAxis : 'Z' + deprecated2 : true, + transform : Matrix4.IDENTITY, + relativeToCenter : false }; var tilesetOptions = { - gltfUpAxis : 'Z' + transform : buildingsTransform }; - return saveBatchedTileset('BatchedGltfZUp', tileOptions, tilesetOptions); + return saveBatchedTileset('BatchedDeprecated2', tileOptions, tilesetOptions); } function createBatchedExpiration() { @@ -493,15 +468,20 @@ function createBatchedExpiration() { function createBatchedWithVertexColors() { var buildingOptions = clone(buildingTemplate); - buildingOptions.diffuseType = 'color'; + buildingOptions.baseColorType = 'color'; var tileOptions = { buildingOptions : buildingOptions, - useVertexColors : true, - khrMaterialsCommon : true + useVertexColors : true }; return saveBatchedTileset('BatchedWithVertexColors', tileOptions); } +function createBatchedWithContentDataUri() { + return saveBatchedTileset('BatchedWithContentDataUri', undefined, { + contentDataUri : true + }); +} + function createPointCloudRGB() { var tileOptions = { colorMode : 'rgb' @@ -709,7 +689,7 @@ function createInstancedWithTransform() { function createInstancedRedMaterial() { var tileOptions = { - url : instancesRedUrl + uri : instancesRedUri }; return saveInstancedTileset('InstancedRedMaterial', tileOptions); } @@ -723,38 +703,14 @@ function createInstancedWithBatchIds() { function createInstancedTextured() { var tileOptions = { - url : instancesTexturedUrl + uri : instancesTexturedUri }; return saveInstancedTileset('InstancedTextured', tileOptions); } -function createInstancedCompressedTextures() { - var tileOptions = { - url : instancesTexturedUrl, - textureCompressionOptions : [{ - format : 'dxt1', - quality : 10 - }, { - format : 'etc1', - quality : 10 - }] - }; - return saveInstancedTileset('InstancedCompressedTextures', tileOptions); -} - -function createInstancedGltfZUp() { - var tileOptions = { - url : instancesZUpUrl - }; - var tilesetOptions = { - gltfUpAxis : 'Z' - }; - return saveInstancedTileset('InstancedGltfZUp', tileOptions, tilesetOptions); -} - function createComposite() { var i3dmOptions = { - url : instancesUrl, + uri : instancesUri, tileWidth : instancesTileWidth, transform : instancesTransform, instancesLength : instancesLength, @@ -765,8 +721,7 @@ function createComposite() { var b3dmOptions = { buildingOptions : buildingTemplate, transform : buildingsTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; return Promise.all([ @@ -783,18 +738,18 @@ function createComposite() { function createCompositeOfComposite() { var i3dmOptions = { - url : instancesUrl, + uri : instancesUri, tileWidth : instancesTileWidth, transform : instancesTransform, instancesLength : instancesLength, - modelSize : instancesModelSize + modelSize : instancesModelSize, + eastNorthUp : true }; var b3dmOptions = { buildingOptions : buildingTemplate, transform : buildingsTransform, - optimizeForCesium : optimizeForCesium, - relativeToCenter : relativeToCenter + relativeToCenter : true }; return Promise.all([ @@ -812,7 +767,7 @@ function createCompositeOfComposite() { function createCompositeOfInstanced() { var i3dmOptions1 = { - url : instancesUrl, + uri : instancesUri, tileWidth : instancesTileWidth, transform : instancesTransform, instancesLength : instancesLength, @@ -822,7 +777,7 @@ function createCompositeOfInstanced() { }; var i3dmOptions2 = { - url : instancesUrl, + uri : instancesUri, tileWidth : instancesTileWidth, transform : instancesTransform, instancesLength : instancesLength, @@ -842,19 +797,19 @@ function createCompositeOfInstanced() { return saveCompositeTileset('CompositeOfInstanced', [i3dm1, i3dm2], [i3dm1BatchTable, i3dm2BatchTable]); }).then(function() { var tilesetDirectory = path.join(outputDirectory, 'Composite', 'CompositeOfInstanced'); - var copyPath = path.join(tilesetDirectory, path.basename(instancesUrl)); - return fsExtra.copy(instancesUrl, copyPath); + var copyPath = path.join(tilesetDirectory, path.basename(instancesUri)); + return fsExtra.copy(instancesUri, copyPath); }); } function saveCompositeTileset(tilesetName, tiles, batchTables, tilesetOptions) { var tilesetDirectory = path.join(outputDirectory, 'Composite', tilesetName); - var tileName = lowercase(tilesetName) + '.cmpt'; - var tilePath = path.join(tilesetDirectory, tileName); + var contentUri = lowercase(tilesetName) + '.cmpt'; + var tilePath = path.join(tilesetDirectory, contentUri); var tilesetPath = path.join(tilesetDirectory, 'tileset.json'); tilesetOptions = defaultValue(tilesetOptions, {}); - tilesetOptions.tileName = tileName; + tilesetOptions.contentUri = contentUri; tilesetOptions.geometricError = compositeGeometricError; if (!defined(tilesetOptions.region) && !defined(tilesetOptions.sphere) && !defined(tilesetOptions.box)) { tilesetOptions.region = compositeRegion; @@ -873,12 +828,12 @@ function saveCompositeTileset(tilesetName, tiles, batchTables, tilesetOptions) { function saveInstancedTileset(tilesetName, tileOptions, tilesetOptions) { var tilesetDirectory = path.join(outputDirectory, 'Instanced', tilesetName); - var tileName = lowercase(tilesetName) + '.i3dm'; - var tilePath = path.join(tilesetDirectory, tileName); + var contentUri = lowercase(tilesetName) + '.i3dm'; + var tilePath = path.join(tilesetDirectory, contentUri); var tilesetPath = path.join(tilesetDirectory, 'tileset.json'); tileOptions = defaultValue(tileOptions, {}); - tileOptions.url = defaultValue(tileOptions.url, instancesUrl); + tileOptions.uri = defaultValue(tileOptions.uri, instancesUri); tileOptions.tileWidth = instancesTileWidth; tileOptions.transform = defaultValue(tileOptions.transform, instancesTransform); tileOptions.instancesLength = instancesLength; @@ -886,7 +841,7 @@ function saveInstancedTileset(tilesetName, tileOptions, tilesetOptions) { tileOptions.eastNorthUp = defaultValue(tileOptions.eastNorthUp, true); tilesetOptions = defaultValue(tilesetOptions, {}); - tilesetOptions.tileName = tileName; + tilesetOptions.contentUri = contentUri; tilesetOptions.geometricError = instancesGeometricError; if (!defined(tilesetOptions.region) && !defined(tilesetOptions.sphere) && !defined(tilesetOptions.box)) { tilesetOptions.region = instancesRegion; @@ -903,8 +858,8 @@ function saveInstancedTileset(tilesetName, tileOptions, tilesetOptions) { saveTile(tilePath, i3dm, gzip) ]; if (tileOptions.embed === false) { - var copyPath = path.join(tilesetDirectory, path.basename(tileOptions.url)); - promises.push(fsExtra.copy(tileOptions.url, copyPath)); + var copyPath = path.join(tilesetDirectory, path.basename(tileOptions.uri)); + promises.push(fsExtra.copy(tileOptions.uri, copyPath)); } return Promise.all(promises); }); @@ -912,18 +867,17 @@ function saveInstancedTileset(tilesetName, tileOptions, tilesetOptions) { function saveBatchedTileset(tilesetName, tileOptions, tilesetOptions) { var tilesetDirectory = path.join(outputDirectory, 'Batched', tilesetName); - var tileName = lowercase(tilesetName) + '.b3dm'; - var tilePath = path.join(tilesetDirectory, tileName); + var contentUri = lowercase(tilesetName) + '.b3dm'; + var tilePath = path.join(tilesetDirectory, contentUri); var tilesetPath = path.join(tilesetDirectory, 'tileset.json'); tileOptions = defaultValue(tileOptions, {}); tileOptions.buildingOptions = defaultValue(tileOptions.buildingOptions, buildingTemplate); tileOptions.transform = defaultValue(tileOptions.transform, buildingsTransform); - tileOptions.optimizeForCesium = optimizeForCesium; - tileOptions.relativeToCenter = defaultValue(tileOptions.relativeToCenter, relativeToCenter); + tileOptions.relativeToCenter = defaultValue(tileOptions.relativeToCenter, true); tilesetOptions = defaultValue(tilesetOptions, {}); - tilesetOptions.tileName = tileName; + tilesetOptions.contentUri = contentUri; tilesetOptions.geometricError = smallGeometricError; if (!defined(tilesetOptions.region) && !defined(tilesetOptions.sphere) && !defined(tilesetOptions.box)) { tilesetOptions.region = smallRegion; @@ -934,6 +888,14 @@ function saveBatchedTileset(tilesetName, tileOptions, tilesetOptions) { var b3dm = result.b3dm; var batchTableJson = result.batchTableJson; tilesetOptions.properties = getProperties(batchTableJson); + + if (tilesetOptions.contentDataUri) { + var dataUri = new DataUri(); + dataUri.format('.b3dm', b3dm); + tilesetOptions.contentUri = dataUri.content; + return saveTilesetJson(tilesetPath, createTilesetJsonSingle(tilesetOptions), prettyJson); + } + var tilesetJson = createTilesetJsonSingle(tilesetOptions); return Promise.all([ saveTilesetJson(tilesetPath, tilesetJson, prettyJson), @@ -944,8 +906,8 @@ function saveBatchedTileset(tilesetName, tileOptions, tilesetOptions) { function savePointCloudTileset(tilesetName, tileOptions, tilesetOptions) { var tilesetDirectory = path.join(outputDirectory, 'PointCloud', tilesetName); - var tileName = lowercase(tilesetName) + '.pnts'; - var tilePath = path.join(tilesetDirectory, tileName); + var contentUri = lowercase(tilesetName) + '.pnts'; + var tilePath = path.join(tilesetDirectory, contentUri); var tilesetPath = path.join(tilesetDirectory, 'tileset.json'); tileOptions = defaultValue(tileOptions, {}); @@ -958,7 +920,7 @@ function savePointCloudTileset(tilesetName, tileOptions, tilesetOptions) { var batchTableJson = result.batchTableJson; tilesetOptions = defaultValue(tilesetOptions, {}); - tilesetOptions.tileName = tileName; + tilesetOptions.contentUri = contentUri; tilesetOptions.properties = getProperties(batchTableJson); tilesetOptions.geometricError = pointCloudGeometricError; if (!defined(tilesetOptions.region) && !defined(tilesetOptions.sphere) && !defined(tilesetOptions.box)) { @@ -976,18 +938,26 @@ function createHierarchy() { return createBatchTableHierarchy({ directory : path.join(outputDirectory, 'Hierarchy', 'BatchTableHierarchy'), transform : buildingsTransform, - optimizeForCesium : optimizeForCesium, gzip : gzip, prettyJson : prettyJson }); } +function createHierarchyLegacy() { + return createBatchTableHierarchy({ + directory : path.join(outputDirectory, 'Hierarchy', 'BatchTableHierarchyLegacy'), + transform : buildingsTransform, + gzip : gzip, + prettyJson : prettyJson, + legacy : true + }); +} + function createHierarchyMultipleParents() { return createBatchTableHierarchy({ directory : path.join(outputDirectory, 'Hierarchy', 'BatchTableHierarchyMultipleParents'), transform : buildingsTransform, multipleParents : true, - optimizeForCesium : optimizeForCesium, gzip : gzip, prettyJson : prettyJson }); @@ -998,7 +968,6 @@ function createHierarchyNoParents() { directory : path.join(outputDirectory, 'Hierarchy', 'BatchTableHierarchyNoParents'), transform : buildingsTransform, noParents : true, - optimizeForCesium : optimizeForCesium, gzip : gzip, prettyJson : prettyJson }); @@ -1010,7 +979,6 @@ function createHierarchyBinary() { transform : buildingsTransform, batchTableBinary : true, multipleParents : true, - optimizeForCesium : optimizeForCesium, gzip : gzip, prettyJson : prettyJson }); @@ -1046,9 +1014,12 @@ function createTileset() { var tilesetJson = { asset : { - version : '1.0', + version : versionNumber, tilesetVersion : '1.2.3' }, + extras : { + name : 'Sample Tileset' + }, properties : undefined, geometricError : largeGeometricError, root : { @@ -1058,7 +1029,7 @@ function createTileset() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -1070,7 +1041,7 @@ function createTileset() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1079,7 +1050,10 @@ function createTileset() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' + }, + extras : { + id : 'Special Tile' } }, { @@ -1088,7 +1062,7 @@ function createTileset() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -1097,7 +1071,7 @@ function createTileset() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -1117,7 +1091,7 @@ function createTilesetEmptyRoot() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : smallGeometricError, @@ -1134,7 +1108,7 @@ function createTilesetEmptyRoot() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1143,7 +1117,7 @@ function createTilesetEmptyRoot() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -1152,7 +1126,7 @@ function createTilesetEmptyRoot() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -1161,7 +1135,7 @@ function createTilesetEmptyRoot() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -1184,7 +1158,7 @@ function createTilesetOfTilesets() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -1192,19 +1166,19 @@ function createTilesetOfTilesets() { boundingVolume : { region : parentRegion }, - geometricError : smallGeometricError, + geometricError : largeGeometricError, refine : 'ADD', content : { - url : 'tileset2.json' + uri : 'tileset2.json' } } }; var tileset2Json = { asset : { - version : '1.0' + version : versionNumber }, - geometricError : smallGeometricError, + geometricError : largeGeometricError, root : { boundingVolume : { region : parentRegion @@ -1212,16 +1186,16 @@ function createTilesetOfTilesets() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'parent.b3dm' + uri : 'parent.b3dm' }, children : [ { boundingVolume : { region : llRegion }, - geometricError : 0.0, + geometricError : smallGeometricError, content : { - url : 'tileset3/tileset3.json' + uri : 'tileset3/tileset3.json' } }, { @@ -1230,7 +1204,7 @@ function createTilesetOfTilesets() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -1239,7 +1213,7 @@ function createTilesetOfTilesets() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -1248,7 +1222,7 @@ function createTilesetOfTilesets() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -1257,9 +1231,9 @@ function createTilesetOfTilesets() { var tileset3Json = { asset : { - version : '1.0' + version : versionNumber }, - geometricError : 0.0, + geometricError : smallGeometricError, root : { boundingVolume : { region : llRegion @@ -1267,7 +1241,7 @@ function createTilesetOfTilesets() { geometricError : 0.0, refine : 'ADD', content : { - url : 'll.b3dm' + uri : 'll.b3dm' } } }; @@ -1281,6 +1255,22 @@ function createTilesetOfTilesets() { }); } +function modifyImageUri(glb, resourceDirectory, newResourceDirectory) { + var gltfOptions = { + resourceDirectory : resourceDirectory, + customStages : [ + function(gltf) { + gltf.images[0].uri = newResourceDirectory + gltf.images[0].uri; + return gltf; + } + ] + }; + return processGlb(glb, gltfOptions) + .then(function(results) { + return results.glb; + }); +} + function createTilesetWithExternalResources() { // Create a tileset that references an external tileset where tiles reference external resources var tilesetName = 'TilesetWithExternalResources'; @@ -1312,7 +1302,7 @@ function createTilesetWithExternalResources() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : smallGeometricError, root : { @@ -1329,7 +1319,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'tileset2/tileset2.json' + uri : 'tileset2/tileset2.json' } }, { @@ -1339,7 +1329,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'external.b3dm' + uri : 'external.b3dm' }, transform : transforms[0] }, @@ -1350,7 +1340,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'external.i3dm' + uri : 'external.i3dm' }, transform : transforms[1] }, @@ -1361,7 +1351,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'embed.i3dm' + uri : 'embed.i3dm' }, transform : transforms[2] } @@ -1371,7 +1361,7 @@ function createTilesetWithExternalResources() { var tileset2Json = { asset : { - version : '1.0' + version : versionNumber }, geometricError : smallGeometricError, root : { @@ -1388,7 +1378,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'external.b3dm' + uri : 'external.b3dm' }, transform : transforms[3] }, @@ -1399,7 +1389,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'external.i3dm' + uri : 'external.i3dm' }, transform : transforms[4] }, @@ -1410,7 +1400,7 @@ function createTilesetWithExternalResources() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'embed.i3dm' + uri : 'embed.i3dm' }, transform : transforms[5] } @@ -1429,32 +1419,38 @@ function createTilesetWithExternalResources() { return fsExtra.readFile(glbPath) .then(function(glb) { + return Promise.all([ + modifyImageUri(glb, glbBasePath, 'textured_box_separate/'), + modifyImageUri(glb, glbBasePath, '../textured_box_separate/') + ]); + }) + .then(function(glbs) { var tiles = [ createB3dm({ - glb : modifyGltfPaths(glb, 'textured_box_separate/') + glb : glbs[0] }), createI3dm({ featureTableJson : featureTableJson, featureTableBinary : featureTableBinary, - url : 'textured_box_separate/textured_box.glb' + uri : 'textured_box_separate/textured_box.glb' }), createI3dm({ featureTableJson : featureTableJson, featureTableBinary : featureTableBinary, - glb : modifyGltfPaths(glb, 'textured_box_separate/') + glb : glbs[0] }), createB3dm({ - glb : modifyGltfPaths(glb, '../textured_box_separate/') + glb : glbs[1] }), createI3dm({ featureTableJson : featureTableJson, featureTableBinary : featureTableBinary, - url : '../textured_box_separate/textured_box.glb' + uri : '../textured_box_separate/textured_box.glb' }), createI3dm({ featureTableJson : featureTableJson, featureTableBinary : featureTableBinary, - glb : modifyGltfPaths(glb, '../textured_box_separate/') + glb : glbs[1] }) ]; return Promise.map(tiles, function(tile, index) { @@ -1485,7 +1481,7 @@ function createTilesetRefinementMix() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -1496,7 +1492,7 @@ function createTilesetRefinementMix() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -1509,7 +1505,7 @@ function createTilesetRefinementMix() { geometricError : smallGeometricError, refine : 'REPLACE', content : { - url : 'parent.b3dm' + uri : 'parent.b3dm' }, children : [ { @@ -1519,7 +1515,7 @@ function createTilesetRefinementMix() { geometricError : 0.0, refine : 'ADD', content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1529,7 +1525,7 @@ function createTilesetRefinementMix() { geometricError : 0.0, refine : 'REPLACE', content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } } ] @@ -1541,7 +1537,7 @@ function createTilesetRefinementMix() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'parent.b3dm' + uri : 'parent.b3dm' }, children : [ { @@ -1551,7 +1547,7 @@ function createTilesetRefinementMix() { geometricError : 0.0, refine : 'ADD', content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } }, { @@ -1561,7 +1557,7 @@ function createTilesetRefinementMix() { geometricError : 0.0, refine : 'REPLACE', content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } } ] @@ -1588,7 +1584,7 @@ function createTilesetReplacement1() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -1599,7 +1595,7 @@ function createTilesetReplacement1() { geometricError : smallGeometricError, refine : 'REPLACE', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -1618,7 +1614,7 @@ function createTilesetReplacement1() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1627,7 +1623,7 @@ function createTilesetReplacement1() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } } ] @@ -1645,7 +1641,7 @@ function createTilesetReplacement1() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -1654,7 +1650,7 @@ function createTilesetReplacement1() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -1680,7 +1676,7 @@ function createTilesetReplacement2() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -1691,7 +1687,7 @@ function createTilesetReplacement2() { geometricError : smallGeometricError, refine : 'REPLACE', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -1717,7 +1713,7 @@ function createTilesetReplacement2() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } } ] @@ -1728,7 +1724,7 @@ function createTilesetReplacement2() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } } ] @@ -1754,7 +1750,7 @@ function createTilesetReplacement3() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -1765,7 +1761,7 @@ function createTilesetReplacement3() { geometricError : smallGeometricError, refine : 'REPLACE', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -1778,7 +1774,7 @@ function createTilesetReplacement3() { geometricError : smallGeometricError, refine : 'ADD', content : { - url : 'tileset2.json' + uri : 'tileset2.json' } } ] @@ -1787,7 +1783,7 @@ function createTilesetReplacement3() { var tileset2Json = { asset : { - version : '1.0' + version : versionNumber }, geometricError : smallGeometricError, root : { @@ -1803,7 +1799,7 @@ function createTilesetReplacement3() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1812,7 +1808,7 @@ function createTilesetReplacement3() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -1821,7 +1817,7 @@ function createTilesetReplacement3() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -1830,7 +1826,7 @@ function createTilesetReplacement3() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -1864,21 +1860,19 @@ function createTilesetWithTransforms() { tileWidth : instancesTileWidth, transform : Matrix4.IDENTITY, instancesLength : instancesLength, - url : instancesUrl, + uri : instancesUri, modelSize : instancesModelSize, eastNorthUp : false }; var buildingsOptions = { buildingOptions : buildingTemplate, - transform : Matrix4.IDENTITY, - optimizeForCesium : optimizeForCesium, - relativeToCenter : false + transform : Matrix4.IDENTITY }; var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : smallGeometricError, @@ -1890,7 +1884,7 @@ function createTilesetWithTransforms() { geometricError : instancesGeometricError, refine : 'ADD', content : { - url : buildingsTileName + uri : buildingsTileName }, children : [ { @@ -1900,7 +1894,7 @@ function createTilesetWithTransforms() { transform : childTransform, geometricError : 0.0, content : { - url : instancesTileName + uri : instancesTileName } } ] @@ -1944,13 +1938,12 @@ function createTilesetWithViewerRequestVolume() { tileWidth : pointCloudTileWidth, pointsLength : pointsLength, transform : Matrix4.IDENTITY, - relativeToCenter : false, shape : 'sphere' }; var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : largeGeometricError, root : { @@ -1966,7 +1959,7 @@ function createTilesetWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -1975,7 +1968,7 @@ function createTilesetWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -1984,7 +1977,7 @@ function createTilesetWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -1993,7 +1986,7 @@ function createTilesetWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } }, { @@ -2006,7 +1999,7 @@ function createTilesetWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'points.pnts' + uri : 'points.pnts' } } ] @@ -2033,7 +2026,7 @@ function createTilesetReplacementWithViewerRequestVolume() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -2051,7 +2044,7 @@ function createTilesetReplacementWithViewerRequestVolume() { geometricError : smallGeometricError, refine : 'REPLACE', content : { - url : 'parent.b3dm', + uri : 'parent.b3dm', boundingVolume : { region : parentContentRegion } @@ -2066,7 +2059,7 @@ function createTilesetReplacementWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -2078,7 +2071,7 @@ function createTilesetReplacementWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -2090,7 +2083,7 @@ function createTilesetReplacementWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -2102,7 +2095,7 @@ function createTilesetReplacementWithViewerRequestVolume() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -2124,7 +2117,7 @@ function createTilesetSubtreeExpiration() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : largeGeometricError, @@ -2138,7 +2131,7 @@ function createTilesetSubtreeExpiration() { boundingVolume : { region : parentContentRegion }, - url : 'parent.b3dm' + uri : 'parent.b3dm' }, children : [ { @@ -2150,7 +2143,7 @@ function createTilesetSubtreeExpiration() { }, geometricError : smallGeometricError, content : { - url : 'subtree.json' + uri : 'subtree.json' } } ] @@ -2159,7 +2152,7 @@ function createTilesetSubtreeExpiration() { var subtreeJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : smallGeometricError, @@ -2176,7 +2169,7 @@ function createTilesetSubtreeExpiration() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -2185,7 +2178,7 @@ function createTilesetSubtreeExpiration() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -2194,7 +2187,7 @@ function createTilesetSubtreeExpiration() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -2203,7 +2196,7 @@ function createTilesetSubtreeExpiration() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -2278,14 +2271,14 @@ function createTilesetPoints() { }, geometricError : 0.0, content : { - url : i + '.pnts' + uri : i + '.pnts' } }); } var tilesetJson = { asset : { - version : '0.0' + version : versionNumber }, properties : undefined, geometricError : parentGeometricError, @@ -2297,7 +2290,7 @@ function createTilesetPoints() { geometricError : childGeometricError, refine : 'ADD', content : { - url : 'parent.pnts' + uri : 'parent.pnts' }, children : childrenJson } @@ -2343,7 +2336,7 @@ function createDiscreteLOD() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : dragonLowGeometricError, root : { @@ -2354,7 +2347,7 @@ function createDiscreteLOD() { geometricError : dragonMediumGeometricError, refine : 'REPLACE', content : { - url : 'dragon_low.b3dm' + uri : 'dragon_low.b3dm' }, children : [ { @@ -2363,7 +2356,7 @@ function createDiscreteLOD() { }, geometricError : dragonHighGeometricError, content : { - url : 'dragon_medium.b3dm' + uri : 'dragon_medium.b3dm' }, children : [ { @@ -2372,7 +2365,7 @@ function createDiscreteLOD() { }, geometricError : 0.0, content : { - url : 'dragon_high.b3dm' + uri : 'dragon_high.b3dm' } } ] @@ -2423,18 +2416,18 @@ function createTreeBillboards() { }; var treeOptions = clone(options); - treeOptions.url = glbPaths[0]; + treeOptions.uri = glbPaths[0]; treeOptions.transform = wgs84Transform(longitude, latitude, 0.0); // Detailed model's base is at the origin var billboardOptions = clone(options); - billboardOptions.url = glbPaths[1]; + billboardOptions.uri = glbPaths[1]; billboardOptions.transform = wgs84Transform(longitude, latitude, treesHeight / 2.0); // Billboard model is centered about the origin var optionsArray = [treeOptions, billboardOptions]; var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : treeBillboardGeometricError, root : { @@ -2444,7 +2437,7 @@ function createTreeBillboards() { geometricError : treeGeometricError, refine : 'REPLACE', content : { - url : 'tree_billboard.i3dm' + uri : 'tree_billboard.i3dm' }, children : [ { @@ -2453,7 +2446,7 @@ function createTreeBillboards() { }, geometricError : 0.0, content : { - url : 'tree.i3dm' + uri : 'tree.i3dm' } } ] @@ -2529,7 +2522,7 @@ function createRequestVolume() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : buildingGeometricError, root : { @@ -2545,7 +2538,7 @@ function createRequestVolume() { }, geometricError : smallGeometricError, content : { - url : 'city/tileset.json' + uri : 'city/tileset.json' } }, { @@ -2555,7 +2548,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : buildingTileName + uri : buildingTileName } }, { @@ -2568,7 +2561,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : pointCloudTileName + uri : pointCloudTileName } } ] @@ -2577,7 +2570,7 @@ function createRequestVolume() { var cityTilesetJson = { asset : { - version : '1.0' + version : versionNumber }, properties : undefined, geometricError : smallGeometricError, @@ -2594,7 +2587,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : 'll.b3dm' + uri : 'll.b3dm' } }, { @@ -2603,7 +2596,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : 'lr.b3dm' + uri : 'lr.b3dm' } }, { @@ -2612,7 +2605,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : 'ur.b3dm' + uri : 'ur.b3dm' } }, { @@ -2621,7 +2614,7 @@ function createRequestVolume() { }, geometricError : 0.0, content : { - url : 'ul.b3dm' + uri : 'ul.b3dm' } } ] @@ -2697,7 +2690,7 @@ function createExpireTileset() { var tilesetJson = { asset : { - version : '1.0' + version : versionNumber }, geometricError : pointCloudGeometricError, root : { @@ -2711,7 +2704,7 @@ function createExpireTileset() { geometricError : 0.0, refine : 'ADD', content : { - url : pointCloudTileName + uri : pointCloudTileName } } }; diff --git a/samples-generator/data/box-z-up.glb b/samples-generator/data/box-z-up.glb deleted file mode 100644 index aa6b1ea2..00000000 Binary files a/samples-generator/data/box-z-up.glb and /dev/null differ diff --git a/samples-generator/data/box.glb b/samples-generator/data/box.glb index 2bde3c4e..66ca853f 100644 Binary files a/samples-generator/data/box.glb and b/samples-generator/data/box.glb differ diff --git a/samples-generator/data/building.glb b/samples-generator/data/building.glb index 648cb1cb..2feaaf1d 100644 Binary files a/samples-generator/data/building.glb and b/samples-generator/data/building.glb differ diff --git a/samples-generator/data/dragon_high.glb b/samples-generator/data/dragon_high.glb index 6733e595..199f9898 100644 Binary files a/samples-generator/data/dragon_high.glb and b/samples-generator/data/dragon_high.glb differ diff --git a/samples-generator/data/dragon_low.glb b/samples-generator/data/dragon_low.glb index bcf406aa..7c7a9d85 100644 Binary files a/samples-generator/data/dragon_low.glb and b/samples-generator/data/dragon_low.glb differ diff --git a/samples-generator/data/dragon_medium.glb b/samples-generator/data/dragon_medium.glb index f2b712fe..7cbbabcd 100644 Binary files a/samples-generator/data/dragon_medium.glb and b/samples-generator/data/dragon_medium.glb differ diff --git a/samples-generator/data/house/door0.gltf b/samples-generator/data/house/door0.gltf index f2311edf..fa1fff56 100644 --- a/samples-generator/data/house/door0.gltf +++ b/samples-generator/data/house/door0.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 72, "type": "SCALAR", @@ -14,10 +13,9 @@ 45 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 46, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 552, - "byteStride": 0, "componentType": 5126, "count": 46, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 1248, "uri": "data:application/octet-stream;base64,6UW9vqERqD+HpnC/6UW9vqERqD/eH4u/6UW9vgAAAADeH4u/6UW9vgAAAACHpnC/6UW9vqERqD/eH4u/6UW9PqERqD/eH4u/7fVePhXjND/eH4u/7fVePpmCkz/eH4u/6UW9vgAAAADeH4u/6UW9PgAAAADeH4u/6UW9PqERqD/eH4u/6UW9PqERqD+HpnC/6UW9PgAAAACHpnC/6UW9PgAAAADeH4u/6UW9PqERqD+HpnC/6UW9vqERqD+HpnC/6UW9vgAAAACHpnC/6UW9PgAAAACHpnC/6UW9vgAAAACHpnC/6UW9vgAAAADeH4u/6UW9PgAAAADeH4u/6UW9PgAAAACHpnC/6UW9PqERqD+HpnC/6UW9PqERqD/eH4u/6UW9vqERqD/eH4u/6UW9vqERqD+HpnC/hpJpvpmCkz987YG/hpJpvhXjND987YG/hpJpvhXjND/eH4u/hpJpvpmCkz/eH4u/7fVePpmCkz987YG/7fVePhXjND987YG/hpJpvhXjND987YG/hpJpvpmCkz987YG/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JgAnACgAJgAoACkAKgArACwAKgAsAC0A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 1104, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 144, "byteOffset": 1104, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.002": { - "name": "Material.002", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.45435, 0.245963, 0.171126, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0, - 0, - 0, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_door0": { - "name": "door0", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.002", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_door0" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_door0", - "scenes": { - "scene_door0": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWM0IHBvcyA9IHVfbW9kZWxWaWV3TWF0cml4ICogdmVjNChhX3Bvc2l0aW9uLDEuMCk7CiAgdl9wb3NpdGlvbkVDID0gcG9zLnh5ejsKICBnbF9Qb3NpdGlvbiA9IHVfcHJvamVjdGlvbk1hdHJpeCAqIHBvczs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xsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/door1.gltf b/samples-generator/data/house/door1.gltf index f371a838..7c53c51e 100644 --- a/samples-generator/data/house/door1.gltf +++ b/samples-generator/data/house/door1.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 72, "type": "SCALAR", @@ -14,10 +13,9 @@ 45 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 46, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 552, - "byteStride": 0, "componentType": 5126, "count": 46, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 1248, "uri": "data:application/octet-stream;base64,h6ZwP6ERqD/pRb2+3h+LP6ERqD/pRb2+3h+LPwAAAADpRb2+h6ZwPwAAAADpRb2+3h+LP6ERqD/pRb2+3h+LP6ERqD/pRb0+3h+LPxXjND/t9V4+3h+LP5mCkz/t9V4+3h+LPwAAAADpRb2+3h+LPwAAAADpRb0+3h+LP6ERqD/pRb0+h6ZwP6ERqD/pRb0+h6ZwPwAAAADpRb0+3h+LPwAAAADpRb0+h6ZwP6ERqD/pRb0+h6ZwP6ERqD/pRb2+h6ZwPwAAAADpRb2+h6ZwPwAAAADpRb0+h6ZwPwAAAADpRb2+3h+LPwAAAADpRb2+3h+LPwAAAADpRb0+h6ZwPwAAAADpRb0+h6ZwP6ERqD/pRb0+3h+LP6ERqD/pRb0+3h+LP6ERqD/pRb2+h6ZwP6ERqD/pRb2+fO2BP5mCkz+Gkmm+fO2BPxXjND+Gkmm+3h+LPxXjND+Gkmm+3h+LP5mCkz+Gkmm+fO2BP5mCkz/t9V4+fO2BPxXjND/t9V4+fO2BPxXjND+Gkmm+fO2BP5mCkz+Gkmm+fO2BPxXjND+Gkmm+fO2BPxXjND/t9V4+3h+LPxXjND/t9V4+3h+LPxXjND+Gkmm+fO2BP5mCkz/t9V4+fO2BP5mCkz+Gkmm+3h+LP5mCkz+Gkmm+3h+LP5mCkz/t9V4+3h+LPxXjND/t9V4+fO2BPxXjND/t9V4+fO2BP5mCkz/t9V4+3h+LP5mCkz/t9V4+AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AAAAgAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAABAAIAAAACAAMABAAFAAYABAAGAAcABQAIAAQABQAJAAgACgALAAwACgAMAA0ADgAPABAADgAQABEAEgATABQAEgAUABUAFgAXABgAFgAYABkAGgAbABwAGgAcAB0AHgAfACAAHgAgACEAIgAjACQAIgAkACUAJgAnACgAJgAoACkAKgArACwAKgAsAC0A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 1104, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 144, "byteOffset": 1104, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.002": { - "name": "Material.002", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.45435, 0.245963, 0.171126, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0, - 0, - 0, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_door1": { - "name": "door1", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.002", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_door1" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_door1", - "scenes": { - "scene_door1": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWM0IHBvcyA9IHVfbW9kZWxWaWV3TWF0cml4ICogdmVjNChhX3Bvc2l0aW9uLDEuMCk7CiAgdl9wb3NpdGlvbkVDID0gcG9zLnh5ejsKICBnbF9Qb3NpdGlvbiA9IHVfcHJvamVjdGlvbk1hdHJpeCAqIHBvczsKICB2X25vcm1hbCA9IHVfbm9ybWFsTWF0cml4ICogYV9ub3JtYWw7Cn0K" - }, - "fragmentShader0": { - "type": 35632, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIHZlYzQgdV9hbWJpZW50Owp1bmlmb3JtIHZlYzQgdV9kaWZmdXNlOwp1bmlmb3JtIHZlYzQgdV9lbWlzc2lvbjsKdW5pZm9ybSB2ZWM0IHVfc3BlY3VsYXI7CnVuaWZvcm0gZmxvYXQgdV9zaGluaW5lc3M7CnVuaWZvcm0gZmxvYXQgdV90cm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pZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/door2.gltf b/samples-generator/data/house/door2.gltf index 0aa8c15e..a036bf10 100644 --- a/samples-generator/data/house/door2.gltf +++ b/samples-generator/data/house/door2.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 72, "type": "SCALAR", @@ -14,10 +13,9 @@ 45 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 46, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 552, - "byteStride": 0, "componentType": 5126, "count": 46, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 1248, "uri": "data:application/octet-stream;base64,6UW9PqERqD+HpnA/6UW9PqERqD/eH4s/6UW9PgAAAADeH4s/6UW9PgAAAACHpnA/6UW9PqERqD/eH4s/6UW9vqERqD/eH4s/7fVevhXjND/eH4s/7fVevpmCkz/eH4s/6UW9PgAAAADeH4s/6UW9vgAAAADeH4s/6UW9vqERqD/eH4s/6UW9vqERq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AgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAABAAIAAAACAAMABAAFAAYABAAGAAcABQAIAAQABQAJAAgACgALAAwACgAMAA0ADgAPABAADgAQABEAEgATABQAEgAUABUAFgAXABgAFgAYABkAGgAbABwAGgAcAB0AHgAfACAAHgAgACEAIgAjACQAIgAkACUAJgAnACgAJgAoACkAKgArACwAKgAsAC0A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 1104, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 144, "byteOffset": 1104, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.002": { - "name": "Material.002", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.45435, 0.245963, 0.171126, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0, - 0, - 0, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_door2": { - "name": "door2", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.002", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_door2" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_door2", - "scenes": { - "scene_door2": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdH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I7CiAgdmVjMyBhbWJpZW50ID0gdV9hbWJpZW50LnJnYjsKICB2ZWMzIHZpZXdEaXIgPSAtbm9ybWFsaXplKHZfcG9zaXRpb25FQyk7CiAgdmVjMyBhbWJpZW50TGlnaHQgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/door3.gltf b/samples-generator/data/house/door3.gltf index b2d426e7..33cca19a 100644 --- a/samples-generator/data/house/door3.gltf +++ b/samples-generator/data/house/door3.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 72, "type": "SCALAR", @@ -14,10 +13,9 @@ 45 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 46, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 552, - "byteStride": 0, "componentType": 5126, "count": 46, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 1248, "uri": "data:application/octet-stream;base64,h6Zwv6ERqD/pRb0+3h+Lv6ERqD/pRb0+3h+LvwAAAADpRb0+h6ZwvwAAAADpRb0+3h+Lv6ERqD/pRb0+3h+Lv6ERqD/pRb2+3h+LvxXjND/t9V6+3h+Lv5mCkz/t9V6+3h+LvwAAAADpRb0+3h+LvwAAAADpRb2+3h+Lv6ERqD/pRb2+h6Zwv6ERqD/pRb2+h6ZwvwAAAADpRb2+3h+LvwAAAADpRb2+h6Zwv6ERqD/pRb2+h6Zwv6ERqD/pRb0+h6ZwvwAAAADpRb0+h6ZwvwAAAADpRb2+h6ZwvwAAAADpRb0+3h+LvwAAAADpRb0+3h+LvwAAAADpRb2+h6ZwvwAAAADpRb2+h6Zwv6ERqD/pRb2+3h+Lv6ERqD/pRb2+3h+Lv6ERqD/pRb0+h6Zwv6ERqD/pRb0+fO2Bv5mCkz+Gkmk+fO2BvxXjND+Gkmk+3h+LvxXjND+Gkmk+3h+Lv5mCkz+Gkmk+fO2Bv5mCkz/t9V6+fO2BvxXjND/t9V6+fO2BvxXjND+Gkmk+fO2Bv5mCkz+Gkmk+fO2BvxXjND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AAHgAgACEAIgAjACQAIgAkACUAJgAnACgAJgAoACkAKgArACwAKgAsAC0A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 1104, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 144, "byteOffset": 1104, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.002": { - "name": "Material.002", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.45435, 0.245963, 0.171126, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0, - 0, - 0, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_door3": { - "name": "door3", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.002", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_door3" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_door3", - "scenes": { - "scene_door3": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWM0IHBvcyA9IHVfbW9kZWxWaWV3TWF0cml4ICogdmVjNChhX3Bvc2l0aW9uLDEuMCk7CiAgdl9wb3NpdGlvbkVDID0gcG9zLnh5ejsKICBnbF9Qb3NpdGlvbiA9IHVfcHJvamV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kgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/doorknob0.gltf b/samples-generator/data/house/doorknob0.gltf index f3136be2..a86e7c38 100644 --- a/samples-generator/data/house/doorknob0.gltf +++ b/samples-generator/data/house/doorknob0.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 672, "type": "SCALAR", @@ -14,10 +13,9 @@ 113 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 114, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 1368, - "byteStride": 0, "componentType": 5126, "count": 114, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 4080, "uri": "data:application/octet-stream;base64,dF+Ovj7rHj8tPou/oP2IvkHyIj8tPou/h6eHvkHyIj8g7Iy/f6CMvj7rHj/0b42/PUOQvigrGj8tPou/dF+OvigrGj8a3oi/f6CMvj7rHj9fDIm/u++AviujJT8tPou/hzaAviujJT/dJoy/h6eHvkHyIj8ykIm/tU58viujJT8g7Iy/ZtmDvkHyIj+jWI6/dF+OvigrGj84no2/h6eHvj7rHj80TI+/dF+OvgFrFT8tPou/f6CMvgFrFT9fDIm/h6eHvgFrFT8fMIe/oP2IvigrGj+Y2oa/h6eHvj7rHj8fMIe/ZtmDvkHyIj+vI4i/hzaAviujJT91VYq/295uvhCVJj8tPou/VyR2viujJT/0b42/tU58vkHyIj80TI+/oP2IvigrGj+6oY+/hzaAvj7rHj9pipC/f6CMvgFrFT/0b42/oP2Ivv5jET8tPou/h6eHvv5jET8ykIm/ZtmDvv5jET+vI4i/hzaAvgFrFT/p8YW/tU58vv5jET8fMIe/u++AvigrGj8sgoW/hzaAvj7rHj/p8YW/tU58vkHyIj8fMIe/tU58viujJT8ykIm/VyR2viujJT9fDIm/295uvkHyIj+Y2oa/295uvj7rHj8sgoW/295uvigrGj85CYW/295uvgFrFT8sgoW/295uvv5jET+Y2oa/295uviWzDj8a3oi/VyR2viWzDj9fDIm/tU58viWzDj8ykIm/hzaAviWzDj91VYq/295uvkDBDT8tPou/X5lnviWzDj9fDIm/AG9hvv5jET8fMIe/qVBdvgFrFT/p8YW/QN5bvigrGj8sgoW/qVBdvj7rHj/p8YW/AG9hvkHyIj8fMIe/295uviujJT8a3oi/X5lnviujJT9fDIm/qG5Ovj7rHj8fMIe/LQtWvkHyIj+vI4i/dsJLvigr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oAbQBqAGkAbgBtAGkAbgBpAGgALgBuAGgALgBvAHAALgBwAG4ALgAtAG8AcABtAG4AcQBsAG0AcABxAG0AcQAaAGwAGgAYAGwAGwAaAHEAbwAbAHEAbwBxAHAALQAbAG8A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 2736, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 1344, "byteOffset": 2736, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.001": { - "name": "Material.001", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.8, 0.24657, 0.026813, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_doorknob0": { - "name": "doorknob0", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.001", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_doorknob0" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_doorknob0", - "scenes": { - "scene_doorknob0": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWM0IHBvcyA9IHVfbW9kZWxWaWV3TWF0cml4IC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OwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/doorknob1.gltf b/samples-generator/data/house/doorknob1.gltf index 9031698c..918dc981 100644 --- a/samples-generator/data/house/doorknob1.gltf +++ b/samples-generator/data/house/doorknob1.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 672, "type": "SCALAR", @@ -14,10 +13,9 @@ 113 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 114, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 1368, - "byteStride": 0, "componentType": 5126, "count": 114, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 4080, "uri": "data:application/octet-stream;base64,LT6LPz7rHj90X46+LT6LP0HyIj+g/Yi+IOyMP0HyIj+Hp4e+9G+NPz7rHj9/oIy+LT6LPygrGj89Q5C+Gt6IPygrGj90X46+XwyJPz7rHj9/oIy+LT6LPyujJT+774C+3SaMPyujJT+HNoC+MpCJP0HyIj+Hp4e+IOyMPyujJT+1Tny+o1iOP0HyIj9m2YO+OJ6NPygrGj90X46+NEyPPz7rHj+Hp4e+LT6LPwFrFT90X46+XwyJPwFrFT9/oIy+HzCHPwFrFT+Hp4e+mNqGPygrGj+g/Yi+HzCHPz7rHj+Hp4e+ryOIP0HyIj9m2YO+dVWKPyujJT+HNoC+LT6LPxCVJj/b3m6+9G+NPyujJT9XJHa+NEyPP0HyIj+1Tny+uqGPPygrGj+g/Yi+aYqQPz7rHj+HNoC+9G+NPwFrFT9/oIy+LT6LP/5jET+g/Yi+MpCJP/5jET+Hp4e+ryOIP/5jET9m2YO+6fGFPwFrFT+HNoC+HzCHP/5jET+1Tny+LIKFPygrGj+774C+6fGFPz7rHj+HNoC+HzCHP0HyIj+1Tny+MpCJPyujJT+1Tny+XwyJPyujJT9XJHa+mNqGP0HyIj/b3m6+LIKFPz7rHj/b3m6+OQmFPygrGj/b3m6+LIKFPwFrFT/b3m6+mNqGP/5jET/b3m6+Gt6IPyWzDj/b3m6+XwyJPyWzDj9XJHa+MpCJPyWzDj+1Tny+dVWKPyWzDj+HNoC+LT6LP0DBDT/b3m6+XwyJPyWzDj9fmWe+HzCHP/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8AHQAPABwAHgARABAAHwAeABAAHwAQAB0AHgAgABEAIAASABEAIQATABIAIAAhABIAIQAiABMAIgAjABMAEwAjABQAIwAVABQAJAAVACMAIgAkACMAJQAkACIAJgAlACIAJgAiACEAJwAmACEAJwAhACAAKAAnACAAKAAgAB4AKQAoAB4AKQAeAB8AKgApAB8AKgAfACsAKwAfAB0AKwAdACwALAAdABwALAAcAC0ALQAcABsALgArACwALgAsAC0ALgAqACsALgAvACoALwApACoAMAAoACkALwAwACkAMAAxACgAMQAnACgAMgAmACcAMQAyACcAMgAzACYAMwAlACYANAA1ACUAMwA0ACUAJQA1ACQANQAVACQANgAVADUANAA2ADUANwA4ADQANwA0ADMAOAA2ADQAOQA3ADMAOQAzADIAOgA5ADIAOgAyADEAOwA6ADEAOwAxADAAPAA7ADAAPAAwAC8ALgA8AC8APQA7ADwALgA9ADwAPQA+ADsAPgA6ADsAPwA5ADoAPgA/ADoAPwBAADkAQAA3ADkAQQA4ADcAQABBADcAQgBDADgAQQBCADgAOABDADYAQwAVADYAQgBEAEMARAAVAEMARQBEAEIARgBFAEIARgBCAEEARwBGAEEARwBBAEAASABHAEAASABAAD8ASQBIAD8ASQA/AD4ASgBJAD4ASgA+AD0ALgBKAD0ALgBLAEoASwBJAEoATABIAEkASwBMAEkATABNAEgATQBHAEgATgBGAEcATQBOAEcATwBFAEYATgBPAEYATwBQAEUAUABRAEUARQBRAEQAUQAVAEQAUgAVAFEAUABSAFEAUwBUAFAAUwBQAE8AVABSAFAAVQBTAE8AVQBPAE4AVgBVAE4AVgBOAE0AVwBWAE0AVwBNAEwAWABXAEwAWABMAEsALgBYAEsAWQBXAFgALgBZAFgAWQBaAFcAWgBWAFcAWwBVAFYAWgBbAFYAXABTAFUAWwBcAFUAXABdAFMAXQBUAFMAXgBfAFQAXQBeAFQAVABfAFIAXwAVAFIAFgAVAGAAYAAVAGEAYQAVAF8AXgBhAF8AYgBhAF4AYwBiAF4AYwBeAF0AZABjAF0AZABdAFwAZQBkAFwAZQBcAFsAZgBlAFsAZgBbAFoAZwBmAFoAZwBaAFkALgBnAFkALgBoAGcAaABmAGcAaQBlAGYAaABpAGYAagBkAGUAaQBqAGUAagBrAGQAawBjAGQAGQBiAGMAawAZAGMAGQAXAGIAFwBgAGIAYgBgAGEAFwAWAGAAGAAZAGsAbAAYAGsAbABrAGoAbQBsAGoAbQBqAGkAbgBtAGkAbgBpAGgALgBuAGgALgBvAHAALgBwAG4ALgAtAG8AcABtAG4AcQBsAG0AcABxAG0AcQAaAGwAGgAYAGwAGwAaAHEAbwAbAHEAbwBxAHAALQAbAG8A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 2736, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 1344, "byteOffset": 2736, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.001": { - "name": "Material.001", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.8, 0.24657, 0.026813, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_doorknob1": { - "name": "doorknob1", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.001", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_doorknob1" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_doorknob1", - "scenes": { - "scene_doorknob1": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIH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W50ID0gdV9hbWJpZW50LnJnYjsKICB2ZWMzIHZpZXdEaXIgPSAtbm9ybWFsaXplKHZfcG9zaXRpb25FQyk7CiAgdmVjMyBhbWJpZW50TGlnaHQgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/doorknob2.gltf b/samples-generator/data/house/doorknob2.gltf index ff6b860b..7cca1a93 100644 --- a/samples-generator/data/house/doorknob2.gltf +++ b/samples-generator/data/house/doorknob2.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 672, "type": "SCALAR", @@ -14,10 +13,9 @@ 113 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 114, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 1368, - "byteStride": 0, "componentType": 5126, "count": 114, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 4080, "uri": "data:application/octet-stream;base64,dF+OPj7rHj8tPos/oP2IPkHyIj8tPos/h6eHPkHyIj8g7Iw/f6CMPj7rHj/0b40/PUOQPigrGj8tPos/dF+OPigrGj8a3og/f6CMPj7rHj9fDIk/u++APiujJT8tPos/hzaAPiujJT/dJow/h6eHPkHyIj8ykIk/ck58PiujJT8g7Iw/RdmDPkHyIj+jWI4/dF+OPigrGj84no0/h6eHPj7rHj80TI8/dF+OPgFrFT8tPos/f6CMPgFrFT9fDIk/h6eHPgFrFT8fMIc/oP2IPigrGj+Y2oY/h6eHPj7rHj8fMIc/RdmDPkHyIj+vI4g/hzaAPiujJT91VYo/295uPhCVJj8tPos/VyR2PiujJT/0b40/ck58PkHyIj80TI8/oP2IPigrGj+6oY8/hzaAPj7rHj9pipA/f6CMPgFrFT/0b40/oP2IPv5jET8tPos/h6eHPv5jET8ykIk/RdmDPv5jET+vI4g/hzaAPgFrFT/p8YU/ck58Pv5jET8fMIc/u++APigrGj8sgoU/hzaAPj7rHj/p8YU/ck58PkHyIj8fMIc/ck58PiujJT8ykIk/VyR2PiujJT9fDIk/295uPkHyIj+Y2oY/295uPj7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wAVAAgAFAAVAAcACAAVAAoACgAVABYACwAKABYADQALABcACwAWABcADAANABgADQAXABkAGAANABkADgAMABoAGgAMABgAGwAOABoAHAAPAA4AHAAOABsAHQAQAA8AHQAPABwAHgARABAAHwAeABAAHwAQAB0AHgAgABEAIAASABEAIQATABIAIAAhABIAIQAiABMAIgAjABMAEwAjABQAIwAVABQAJAAVACMAIgAkACMAJQAkACIAJgAlACIAJgAiACEAJwAmACEAJwAhACAAKAAnACAAKAAgAB4AKQAoAB4AKQAeAB8AKgApAB8AKgAfACsAKwAfAB0AKwAdACwALAAdABwALAAcAC0ALQAcABsALgArACwALgAsAC0ALgAqACsALgAvACoALwApACoAMAAoACkALwAwACkAMAAxACgAMQAnACgAMgAmACcAMQAyACcAMgAzACYAMwAlACYANAA1ACUAMwA0ACUAJQA1ACQANQAVACQANgAVADUANAA2ADUANwA4ADQANwA0ADMAOAA2ADQAOQA3ADMAOQAzADIAOgA5ADIAOgAyADEAOwA6ADEAOwAxADAAPAA7ADAAPAAwAC8ALgA8AC8APQA7ADwALgA9ADwAPQA+ADsAPgA6ADsAPwA5ADoAPgA/ADoAPwBAADkAQAA3ADkAQQA4ADcAQABBADcAQgBDADgAQQBCADgAOABDADYAQwAVADYAQgBEAEMARAAVAEMARQBEAEIARgBFAEIARgBCAEEARwBGAEEARwBBAEAASABHAEAASABAAD8ASQBIAD8ASQA/AD4ASgBJAD4ASgA+AD0ALgBKAD0ALgBLAEoASwBJAEoATABIAEkASwBMAEkATABNAEgATQBHAEgATgBGAEcATQBOAEcATwBFAEYATgBPAEYATwBQAEUAUABRAEUARQBRAEQAUQAVAEQAUgAVAFEAUABSAFEAUwBUAFAAUwBQAE8AVABSAFAAVQBTAE8AVQBPAE4AVgBVAE4AVgBOAE0AVwBWAE0AVwBNAEwAWABXAEwAWABMAEsALgBYAEsAWQBXAFgALgBZAFgAWQBaAFcAWgBWAFcAWwBVAFYAWgBbAFYAXABTAFUAWwBcAFUAXABdAFMAXQBUAFMAXgBfAFQAXQBeAFQAVABfAFIAXwAVAFIAFgAVAGAAYAAVAGEAYQAVAF8AXgBhAF8AYgBhAF4AYwBiAF4AYwBeAF0AZABjAF0AZABdAFwAZQBkAFwAZQBcAFsAZgBlAFsAZgBbAFoAZwBmAFoAZwBaAFkALgBnAFkALgBoAGcAaABmAGcAaQBlAGYAaABpAGYAagBkAGUAaQBqAGUAagBrAGQAawBjAGQAGQBiAGMAawAZAGMAGQAXAGIAFwBgAGIAYgBgAGEAFwAWAGAAGAAZAGsAbAAYAGsAbABrAGoAbQBsAGoAbQBqAGkAbgBtAGkAbgBpAGgALgBuAGgALgBvAHAALgBwAG4ALgAtAG8AcABtAG4AcQBsAG0AcABxAG0AcQAaAGwAGgAYAGwAGwAaAHEAbwAbAHEAbwBxAHAALQAbAG8A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 2736, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 1344, "byteOffset": 2736, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.001": { - "name": "Material.001", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.8, 0.24657, 0.026813, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_doorknob2": { - "name": "doorknob2", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.001", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_doorknob2" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_doorknob2", - "scenes": { - "scene_doorknob2": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdN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WxhckxpZ2h0ID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICB2ZWMzIGVtaXNzaW9uID0gdV9lbWlzc2lvbi5yZ2I7CiAgdmVjMyBhbWJpZW50ID0gdV9hbWJpZW50LnJnYjsKICB2ZWMzIHZpZXdEaXIgPSAtbm9ybWFsaXplKHZfcG9zaXRpb25FQyk7CiAgdmVjMyBhbWJpZW50TGlnaHQgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/doorknob3.gltf b/samples-generator/data/house/doorknob3.gltf index 40ad5f40..96e3cb9a 100644 --- a/samples-generator/data/house/doorknob3.gltf +++ b/samples-generator/data/house/doorknob3.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 672, "type": "SCALAR", @@ -14,10 +13,9 @@ 113 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 114, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 1368, - "byteStride": 0, "componentType": 5126, "count": 114, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 4080, "uri": "data:application/octet-stream;base64,LT6Lvz7rHj90X44+LT6Lv0HyIj+g/Yg+IOyMv0HyIj+Hp4c+9G+Nvz7rHj9/oIw+LT6LvygrGj89Q5A+Gt6IvygrGj90X44+XwyJvz7rHj9/oIw+LT6LvyujJT+774A+3SaMvyujJT+HNoA+MpCJv0HyIj+Hp4c+IOyMvyujJT+1Tnw+o1iOv0HyIj9F2YM+OJ6NvygrGj90X44+NEyPvz7rHj+Hp4c+LT6LvwFrFT90X44+XwyJvwFrFT9/oIw+HzCHvwFrFT+Hp4c+mNqGvygrGj+g/Yg+HzCHvz7rHj+Hp4c+ryOIv0HyIj9F2YM+dVWKvyujJT+HNoA+LT6LvxCVJj/b3m4+9G+NvyujJT9XJHY+NEyPv0HyIj+1Tnw+uqGPvygrGj+g/Yg+aYqQvz7rHj+HNoA+9G+NvwFrFT9/oIw+LT6Lv/5jET+g/Yg+MpCJv/5jET+Hp4c+ryOIv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+stmMvlv4Mb8zAio/AAABAAIAAAACAAMABAAAAAMABQAGAAAABQAAAAQABgABAAAAAQAHAAgAAQAIAAIACQAHAAEABgAJAAEAAgAIAAoAAgAKAAsAAwACAAsABAADAAwADAADAA0AAwALAA0ADgAEAAwADwAFAAQADwAEAA4AEAARAAUAEAAFAA8AEQAGAAUAEgAJAAYAEQASAAYAEgATAAkAEwAUAAkACQAUAAcABwAVAAgAFAAVAAcACAAVAAoACgAVABYACwAKABYADQALABcACwAWABcADAANABgADQAXABkAGAANABkADgAMABoAGgAMABgAGwAOABoAHAAPAA4AHAAOABsAHQAQAA8AHQAPABwAHgARABAAHwAeABAAHwAQAB0AHgAgABEAIAASABEAIQATABIAIAAhABIAIQAiABMAIgAjABMAEwAjABQAIwAVABQAJAAVACMAIgAkACMAJQAkACIAJgAlACIAJgAiACEAJwAmACEAJwAhACAAKAAnACAAKAAgAB4AKQAoAB4AKQAeAB8AKgApAB8AKgAfACsAKwAfAB0AKwAdACwALAAdABwALAAcAC0ALQAcABsALgArACwALgAsAC0ALgAqACsALgAvACoALwApACoAMAAoACkALwAwACkAMAAxACgAMQAnACgAMgAmACcAMQAyACcAMgAzACYAMwAlACYANAA1ACUAMwA0ACUAJQA1ACQANQAVACQANgAVADUANAA2ADUANwA4ADQANwA0ADMAOAA2ADQAOQA3ADMAOQAzADIAOgA5ADIAOgAyADEAOwA6ADEAOwAxADAAPAA7ADAAPAAwAC8ALgA8AC8APQA7ADwALgA9ADwAPQA+ADsAPgA6ADsAPwA5ADoAPgA/ADoAPwBAADkAQAA3ADkAQQA4ADcAQABBADcAQgBDADgAQQBCADgAOABDADYAQwAVADYAQgBEAEMARAAVAEMARQBEAEIARgBFAEIARgBCAEEARwBGAEEARwBBAEAASABHAEAASABAAD8ASQBIAD8ASQA/AD4ASgBJAD4ASgA+AD0ALgBKAD0ALgBLAEoASwBJAEoATABIAEkASwBMAEkATABNAEgATQBHAEgATgBGAEcATQBOAEcATwBFAEYATgBPAEYATwBQAEUAUABRAEUARQBRAEQAUQAVAEQAUgAVAFEAUABSAFEAUwBUAFAAUwBQAE8AVABSAFAAVQBTAE8AVQBPAE4AVgBVAE4AVgBOAE0AVwBWAE0AVwBNAEwAWABXAEwAWABMAEsALgBYAEsAWQBXAFgALgBZAFgAWQBaAFcAWgBWAFcAWwBVAFYAWgBbAFYAXABTAFUAWwBcAFUAXABdAFMAXQBUAFMAXgBfAFQAXQBeAFQAVABfAFIAXwAVAFIAFgAVAGAAYAAVAGEAYQAVAF8AXgBhAF8AYgBhAF4AYwBiAF4AYwBeAF0AZABjAF0AZABdAFwAZQBkAFwAZQBcAFsAZgBlAFsAZgBbAFoAZwBmAFoAZwBaAFkALgBnAFkALgBoAGcAaABmAGcAaQBlAGYAaABpAGYAagBkAGUAaQBqAGUAagBrAGQAawBjAGQAGQBiAGMAawAZAGMAGQAXAGIAFwBgAGIAYgBgAGEAFwAWAGAAGAAZAGsAbAAYAGsAbABrAGoAbQBsAGoAbQBqAGkAbgBtAGkAbgBpAGgALgBuAGgALgBvAHAALgBwAG4ALgAtAG8AcABtAG4AcQBsAG0AcABxAG0AcQAaAGwAGgAYAGwAGwAaAHEAbwAbAHEAbwBxAHAALQAbAG8A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 2736, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 1344, "byteOffset": 2736, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.001": { - "name": "Material.001", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.8, 0.24657, 0.026813, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_doorknob3": { - "name": "doorknob3", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.001", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_doorknob3" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_doorknob3", - "scenes": { - "scene_doorknob3": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWM0IHBvcyA9IHVfbW9kZWxWaWV3TWF0cml4ICogdmVjNChhX3Bvc2l0aW9uLDEuMCk7CiAgdl9wb3NpdGlvbkVDID0gcG9zLnh5ejsKICBnbF9Qb3NpdGlvbiA9IHVfcHJvamVjdGlvbk1hdHJpeCAqIHBvczsKICB2X25vcm1hbCA9IHVfbm9ybWFsTWF0cml4ICogYV9ub3JtYWw7Cn0K" - }, - "fragmentShader0": { - "type": 35632, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIHZlYzQgdV9hbWJpZW50Owp1bmlmb3JtIHZlYzQgdV9kaWZmdXNlOwp1bmlmb3JtIHZlYzQgdV9lbWlzc2lvbjsKdW5pZm9ybSB2ZWM0IHVfc3BlY3VsYXI7CnVuaWZvcm0gZmxvYXQgdV9zaGluaW5lc3M7CnVuaWZvcm0gZmxvYXQgdV90cmFuc3BhcmVuY3k7CnZhcnlpbmcgdmVjMyB2X3Bvc2l0aW9uRUM7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZ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IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/roof.gltf b/samples-generator/data/house/roof.gltf index 1af33c45..8db1a625 100644 --- a/samples-generator/data/house/roof.gltf +++ b/samples-generator/data/house/roof.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 18, "type": "SCALAR", @@ -14,10 +13,9 @@ 15 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 16, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 192, - "byteStride": 0, "componentType": 5126, "count": 16, "type": "VEC3", @@ -50,214 +47,79 @@ 0.6997694373130798 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 420, "uri": "data:application/octet-stream;base64,AAAAAHWwPkAAAAAAAACAvwAAAEAAAIC/AACAvwAAAEAAAIA/AAAAAHWwPkAAAAAAAACAPwAAAEAAAIC/AACAvwAAAEAAAIC/AAAAAHWwPkAAAAAAAACAPwAAAEAAAIA/AACAPwAAAEAAAIC/AAAAAHWwPkAAAAAAAACAvwAAAEAAAIA/AACAPwAAAEAAAIA/AACAvwAAAEAAAIA/AACAvwAAAEAAAIC/AACAPwAAAEAAAIC/AACAPwAAAEAAAIA/FyQzv9/gNj8AAAAAFyQzv9/gNj8AAAAAFyQzv9/gNj8AAAAAAAAAAN/gNj8XJDO/AAAAAN/gNj8XJDO/AAAAAN/gNj8XJDO/FyQzP9/gNj8AAAAAFyQzP9/gNj8AAAAAFyQzP9/gNj8AAAAAAAAAAN/gNj8XJDM/AAAAAN/gNj8XJDM/AAAAAN/gNj8XJDM/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADAAOAA8A" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 384, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 36, "byteOffset": 384, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.004": { - "name": "Material.004", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.64, 0.204491, 0.219181, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_roof": { - "name": "roof", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.004", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_roof" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_roof", - "scenes": { - "scene_roof": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9z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SAtbm9ybWFsaXplKHZfcG9zaXRpb25FQyk7CiAgdmVjMyBhbWJpZW50TGlnaHQgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/house/wall.gltf b/samples-generator/data/house/wall.gltf index ac6b9e24..cc1c36a5 100644 --- a/samples-generator/data/house/wall.gltf +++ b/samples-generator/data/house/wall.gltf @@ -1,9 +1,8 @@ { - "accessors": { - "accessor_index_0": { - "bufferView": "bufferView_1", + "accessors": [ + { + "bufferView": 1, "byteOffset": 0, - "byteStride": 0, "componentType": 5123, "count": 36, "type": "SCALAR", @@ -14,10 +13,9 @@ 23 ] }, - "accessor_position": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 0, - "byteStride": 0, "componentType": 5126, "count": 24, "min": [ @@ -32,10 +30,9 @@ ], "type": "VEC3" }, - "accessor_normal": { - "bufferView": "bufferView_0", + { + "bufferView": 0, "byteOffset": 288, - "byteStride": 0, "componentType": 5126, "count": 24, "type": "VEC3", @@ -50,214 +47,79 @@ 1 ] } - }, + ], "asset": { "generator": "OBJ2GLTF", - "premultipliedAlpha": true, - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" + "version": "2.0" }, - "buffers": { - "buffer_0": { - "type": "arraybuffer", + "buffers": [ + { "byteLength": 648, "uri": "data:application/octet-stream;base64,AACAvwAAAEAAAIA/AACAvwAAAEAAAIC/AACAvwAAAAAAAIC/AACAvwAAAAAAAIA/AACAvwAAAEAAAIC/AACAPwAAAEAAAIC/AACAPwAAAAAAAIC/AACAvwAAAAAAAIC/AACAPwAAAEAAAIC/AACAPwAAAEAAAIA/AACAPwAAAAAAAIA/AACAPwAAAAAAAIC/AACAPwAAAEAAAIA/AACAvwAAAEAAAIA/AACAvwAAAAAAAIA/AACAPwAAAAAAAIA/AACAvwAAAAAAAIA/AACAvwAAAAAAAIC/AACAPwAAAAAAAIC/AACAPwAAAAAAAIA/AACAPwAAAEAAAIA/AACAPwAAAEAAAIC/AACAvwAAAEAAAIC/AACAvwAAAEAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA" } - }, - "bufferViews": { - "bufferView_0": { - "buffer": "buffer_0", + ], + "bufferViews": [ + { + "buffer": 0, "byteLength": 576, "byteOffset": 0, - "target": 34962 + "target": 34962, + "byteStride": 12 }, - "bufferView_1": { - "buffer": "buffer_0", + { + "buffer": 0, "byteLength": 72, "byteOffset": 576, "target": 34963 } - }, - "images": {}, - "materials": { - "material_Material.003": { - "name": "Material.003", - "extensions": {}, - "values": { - "ambient": [ - 1, - 1, - 1, - 1 - ], - "diffuse": [ + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ 0.8, 0.431283, 0.253046, 1 ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1 + "metallicFactor": 0, + "roughnessFactor": 1 }, - "technique": "technique0" + "emissiveFactor": [ + 0, + 0, + 0 + ], + "alphaMode": "OPAQUE", + "doubleSided": false } - }, - "meshes": { - "mesh_wall": { - "name": "wall", + ], + "meshes": [ + { "primitives": [ { "attributes": { - "POSITION": "accessor_position", - "NORMAL": "accessor_normal" + "POSITION": 1, + "NORMAL": 2 }, - "indices": "accessor_index_0", - "material": "material_Material.003", + "indices": 0, + "material": 0, "mode": 4 } ] } - }, - "nodes": { - "rootNode": { - "children": [], - "meshes": [ - "mesh_wall" - ], - "matrix": [ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ] + ], + "nodes": [ + { + "mesh": 0 } - }, - "samplers": {}, - "scene": "scene_wall", - "scenes": { - "scene_wall": { + ], + "scene": 0, + "scenes": [ + { "nodes": [ - "rootNode" + 0 ] } - }, - "textures": {}, - "extensionsUsed": [], - "animations": {}, - "cameras": {}, - "techniques": { - "technique0": { - "attributes": { - "a_position": "position", - "a_normal": "normal" - }, - "parameters": { - "modelViewMatrix": { - "semantic": "MODELVIEW", - "type": 35676 - }, - "projectionMatrix": { - "semantic": "PROJECTION", - "type": 35676 - }, - "normalMatrix": { - "semantic": "MODELVIEWINVERSETRANSPOSE", - "type": 35675 - }, - "ambient": { - "type": 35666 - }, - "diffuse": { - "type": 35666 - }, - "emission": { - "type": 35666 - }, - "specular": { - "type": 35666 - }, - "shininess": { - "type": 5126 - }, - "transparency": { - "type": 5126 - }, - "position": { - "semantic": "POSITION", - "type": 35665 - }, - "normal": { - "semantic": "NORMAL", - "type": 35665 - } - }, - "program": "program0", - "states": { - "enable": [ - 2884, - 2929 - ] - }, - "uniforms": { - "u_modelViewMatrix": "modelViewMatrix", - "u_projectionMatrix": "projectionMatrix", - "u_normalMatrix": "normalMatrix", - "u_ambient": "ambient", - "u_diffuse": "diffuse", - "u_emission": "emission", - "u_specular": "specular", - "u_shininess": "shininess", - "u_transparency": "transparency" - } - } - }, - "programs": { - "program0": { - "attributes": [ - "a_position", - "a_normal" - ], - "fragmentShader": "fragmentShader0", - "vertexShader": "vertexShader0" - } - }, - "shaders": { - "vertexShader0": { - "type": 35633, - "uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CnVuaWZvcm0gbWF0MyB1X25vcm1hbE1hdHJpeDsKYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKYXR0cmlidXRlIHZlYzMgYV9ub3JtYWw7CnZhcnlpbmcgdmVjMyB2X25vcm1hbDsKdm9pZCBtYWluKHZva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wogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgbCA9IHZlYzMoMC4wLCAwLjAsIDEuMCk7CiAgZGlmZnVzZUxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBtYXgoZG90KG5vcm1hbCxsKSwgMC4pOwogIHZlYzMgaCA9IG5vcm1hbGl6ZShsICsgdmlld0Rpcik7CiAgZmxvYXQgc3BlY3VsYXJJbnRlbnNpdHkgPSBtYXgoMC4sIHBvdyhtYXgoZG90KG5vcm1hbCwgaCksIDAuKSwgdV9zaGluaW5lc3MpKTsKICBzcGVjdWxhckxpZ2h0ICs9IHZlYzMoMS4wLCAxLjAsIDEuMCkgKiBzcGVjdWxhckludGVuc2l0eTsKICB2ZWMzIGNvbG9yID0gdmVjMygwLjAsIDAuMCwgMC4wKTsKICBjb2xvciArPSBkaWZmdXNlLnJnYiAqIGRpZmZ1c2VMaWdodDsKICBjb2xvciArPSBzcGVjdWxhciAqIHNwZWN1bGFyTGlnaHQ7CiAgY29sb3IgKz0gZW1pc3Npb247CiAgY29sb3IgKz0gYW1iaWVudCAqIGFtYmllbnRMaWdodDsKICBnbF9GcmFnQ29sb3IgPSB2ZWM0KGNvbG9yICogZGlmZnVzZS5hLCBkaWZmdXNlLmEgKiB1X3RyYW5zcGFyZW5jeSk7Cn0K" - } - }, - "skins": {}, - "extensions": {} + ] } diff --git a/samples-generator/data/red_box.glb b/samples-generator/data/red_box.glb index c42a9584..67599afd 100644 Binary files a/samples-generator/data/red_box.glb and b/samples-generator/data/red_box.glb differ diff --git a/samples-generator/data/textured_box.glb b/samples-generator/data/textured_box.glb index ef90a26e..db9afe3f 100644 Binary files a/samples-generator/data/textured_box.glb and b/samples-generator/data/textured_box.glb differ diff --git a/samples-generator/data/textured_box_separate/Cesium_Logo_Flat.png b/samples-generator/data/textured_box_separate/Cesium_Logo_Flat.png index 3b8baee1..96c01d4d 100644 Binary files a/samples-generator/data/textured_box_separate/Cesium_Logo_Flat.png and b/samples-generator/data/textured_box_separate/Cesium_Logo_Flat.png differ diff --git a/samples-generator/data/textured_box_separate/fragmentShader0.glsl b/samples-generator/data/textured_box_separate/fragmentShader0.glsl deleted file mode 100644 index 3b357000..00000000 --- a/samples-generator/data/textured_box_separate/fragmentShader0.glsl +++ /dev/null @@ -1,33 +0,0 @@ -precision highp float; -uniform vec4 u_ambient; -uniform sampler2D u_diffuse; -uniform vec4 u_emission; -uniform vec4 u_specular; -uniform float u_shininess; -uniform float u_transparency; -varying vec3 v_positionEC; -varying vec3 v_normal; -varying vec2 v_texcoord_0; -void main(void) { - vec3 normal = normalize(v_normal); - vec4 diffuse = texture2D(u_diffuse, v_texcoord_0); - vec3 diffuseLight = vec3(0.0, 0.0, 0.0); - vec3 specular = u_specular.rgb; - vec3 specularLight = vec3(0.0, 0.0, 0.0); - vec3 emission = u_emission.rgb; - vec3 ambient = u_ambient.rgb; - vec3 viewDir = -normalize(v_positionEC); - vec3 ambientLight = vec3(0.0, 0.0, 0.0); - ambientLight += vec3(0.2, 0.2, 0.2); - vec3 l = vec3(0.0, 0.0, 1.0); - diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal,l), 0.); - vec3 reflectDir = reflect(-l, normal); - float specularIntensity = max(0., pow(max(dot(reflectDir, viewDir), 0.), u_shininess)); - specularLight += vec3(1.0, 1.0, 1.0) * specularIntensity; - vec3 color = vec3(0.0, 0.0, 0.0); - color += diffuse.rgb * diffuseLight; - color += specular * specularLight; - color += emission; - color += ambient * ambientLight; - gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency); -} diff --git a/samples-generator/data/textured_box_separate/textured_box.glb b/samples-generator/data/textured_box_separate/textured_box.glb index 5f65357c..a0c016ef 100644 Binary files a/samples-generator/data/textured_box_separate/textured_box.glb and b/samples-generator/data/textured_box_separate/textured_box.glb differ diff --git a/samples-generator/data/textured_box_separate/vertexShader0.glsl b/samples-generator/data/textured_box_separate/vertexShader0.glsl deleted file mode 100644 index c489a559..00000000 --- a/samples-generator/data/textured_box_separate/vertexShader0.glsl +++ /dev/null @@ -1,17 +0,0 @@ -precision highp float; -uniform mat4 u_modelViewMatrix; -uniform mat4 u_projectionMatrix; -uniform mat3 u_normalMatrix; -attribute vec3 a_position; -varying vec3 v_positionEC; -attribute vec3 a_normal; -varying vec3 v_normal; -attribute vec2 a_texcoord_0; -varying vec2 v_texcoord_0; -void main(void) { - vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); - v_positionEC = pos.xyz; - gl_Position = u_projectionMatrix * pos; - v_normal = u_normalMatrix * a_normal; - v_texcoord_0 = a_texcoord_0; -} diff --git a/samples-generator/data/tree.glb b/samples-generator/data/tree.glb index b335a34a..71cedf12 100644 Binary files a/samples-generator/data/tree.glb and b/samples-generator/data/tree.glb differ diff --git a/samples-generator/data/tree_billboard.glb b/samples-generator/data/tree_billboard.glb index ab5a234c..9673a50a 100644 Binary files a/samples-generator/data/tree_billboard.glb and b/samples-generator/data/tree_billboard.glb differ diff --git a/samples-generator/lib/Extensions.js b/samples-generator/lib/Extensions.js new file mode 100644 index 00000000..e94a25bb --- /dev/null +++ b/samples-generator/lib/Extensions.js @@ -0,0 +1,54 @@ +'use strict'; +var Cesium = require('cesium'); + +var defined = Cesium.defined; + +module.exports = Extensions; + +function Extensions() { } + +/** + * Add an extension to the list of extensions used for a tileset JSON. + * @param {Object} tilesetJson The root tileset JSON object to which to add the extension. + * @param {String} extensionName The name of the extension to add. + */ +Extensions.addExtensionsUsed = function(tilesetJson, extensionName) { + var extensionsUsed = tilesetJson.extensionsUsed; + + if (!defined(extensionsUsed)) { + extensionsUsed = tilesetJson.extensionsUsed = []; + } + + extensionsUsed.push(extensionName); +}; + +/** + * Add an extension to the list of extensions required for a tileset JSON. + * @param {Object} tilesetJson The root tileset JSON object to which to add the extension. + * @param {String} extensionName The name of the extension to add. + */ +Extensions.addExtensionsRequired = function(tilesetJson, extensionName) { + var extensionsRequired = tilesetJson.extensionsRequired; + + if (!defined(extensionsRequired)) { + extensionsRequired = tilesetJson.extensionsRequired = []; + } + + extensionsRequired.push(extensionName); +}; + +/** + * Add an extension to the extensions dictionary object for a JSON object. + * @param {Object} tilesetJson The JSON object to which to add the extension. + * @param {String} extensionName The name of the extension to add. + * @param {*} extension The contents of the extension. + */ +Extensions.addExtension = function(tilesetJson, extensionName, extension) { + var extensions = tilesetJson.extensions; + + if (!defined(extensions)) { + extensions = tilesetJson.extensions = {}; + } + + extensions[extensionName] = extension; +}; diff --git a/samples-generator/lib/Material.js b/samples-generator/lib/Material.js index 50645d51..a7186dd0 100644 --- a/samples-generator/lib/Material.js +++ b/samples-generator/lib/Material.js @@ -9,21 +9,13 @@ module.exports = Material; * A material that is applied to a mesh. * * @param {Object} [options] An object with the following properties: - * @param {Array|String} [options.ambient] The ambient color or ambient texture path. - * @param {Array|String} [options.diffuse] The diffuse color or diffuse texture path. - * @param {Array|String} [options.emission] The emission color or emission texture path. - * @param {Array|String} [options.specular] The specular color or specular texture path. - * @param {Number} [options.shininess=0.0] The specular shininess. + * @param {Array|String} [options.baseColor] The base color or base color texture path. * * @constructor */ function Material(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - this.ambient = defaultValue(options.ambient, [0.0, 0.0, 0.0, 1.0]); - this.diffuse = defaultValue(options.diffuse, [0.5, 0.5, 0.5, 1.0]); - this.emission = defaultValue(options.emission, [0.0, 0.0, 0.0, 1.0]); - this.specular = defaultValue(options.specular, [0.0, 0.0, 0.0, 1.0]); - this.shininess = defaultValue(options.shininess, 0.0); + this.baseColor = defaultValue(options.baseColor, [0.5, 0.5, 0.5, 1.0]); } /** @@ -33,12 +25,7 @@ function Material(options) { * @returns {Material} The material. */ Material.fromGltf = function(material) { - var values = material.values; return new Material({ - ambient : values.ambient, - diffuse : values.diffuse, - emission : values.emission, - specular : values.specular, - shininess : values.shininess + baseColor : material.pbrMetallicRoughness.baseColorFactor }); }; diff --git a/samples-generator/lib/Mesh.js b/samples-generator/lib/Mesh.js index 287b506c..a5658e4b 100644 --- a/samples-generator/lib/Mesh.js +++ b/samples-generator/lib/Mesh.js @@ -16,7 +16,7 @@ var sizeOfUint16 = 2; var sizeOfFloat32 = 4; var whiteOpaqueMaterial = new Material({ - diffuse : [1.0, 1.0, 1.0, 1.0] + baseColor : [1.0, 1.0, 1.0, 1.0] }); /** @@ -146,10 +146,10 @@ Mesh.prototype.transferMaterialToVertexColors = function() { var vertexColors = new Array(vertexCount * 4); this.vertexColors = vertexColors; for (var i = 0; i < vertexCount; ++i) { - vertexColors[i * 4 + 0] = Math.floor(material.diffuse[0] * 255); - vertexColors[i * 4 + 1] = Math.floor(material.diffuse[1] * 255); - vertexColors[i * 4 + 2] = Math.floor(material.diffuse[2] * 255); - vertexColors[i * 4 + 3] = Math.floor(material.diffuse[3] * 255); + vertexColors[i * 4 + 0] = Math.floor(material.baseColor[0] * 255); + vertexColors[i * 4 + 1] = Math.floor(material.baseColor[1] * 255); + vertexColors[i * 4 + 2] = Math.floor(material.baseColor[2] * 255); + vertexColors[i * 4 + 3] = Math.floor(material.baseColor[3] * 255); } }; @@ -300,7 +300,7 @@ function getAccessor(gltf, accessor) { * @returns {Mesh} The mesh. */ Mesh.fromGltf = function(gltf) { - var gltfPrimitive = gltf.meshes[Object.keys(gltf.meshes)[0]].primitives[0]; + var gltfPrimitive = gltf.meshes[0].primitives[0]; var gltfMaterial = gltf.materials[gltfPrimitive.material]; var material = Material.fromGltf(gltfMaterial); var indices = getAccessor(gltf, gltf.accessors[gltfPrimitive.indices]); diff --git a/samples-generator/lib/createBatchTableHierarchy.js b/samples-generator/lib/createBatchTableHierarchy.js index 3864b50e..9afa85e5 100644 --- a/samples-generator/lib/createBatchTableHierarchy.js +++ b/samples-generator/lib/createBatchTableHierarchy.js @@ -3,9 +3,11 @@ var Cesium = require('cesium'); var fsExtra = require('fs-extra'); var path = require('path'); var Promise = require('bluebird'); + var createB3dm = require('./createB3dm'); var createGltf = require('./createGltf'); var createTilesetJsonSingle = require('./createTilesetJsonSingle'); +var Extensions = require('./Extensions'); var getBufferPadded = require('./getBufferPadded'); var Material = require('./Material'); var Mesh = require('./Mesh'); @@ -25,20 +27,20 @@ var sizeOfFloat = 4; var sizeOfUint16 = 2; var whiteOpaqueMaterial = new Material({ - diffuse : [1.0, 1.0, 1.0, 1.0], - ambient : [0.2, 0.2, 0.2, 1.0] + baseColor : [1.0, 1.0, 1.0, 1.0] }); /** - * Create a tileset that uses a batch table hierarchy. + * Create a tileset that uses a batch table hierarchy, + * by default using the 3DTILES_batch_table_hierarchy extension. * * @param {Object} options An object with the following properties: * @param {String} options.directory Directory in which to save the tileset. * @param {Boolean} [options.batchTableBinary=false] Create a batch table binary for the b3dm tile. * @param {Boolean} [options.noParents=false] Don't set any instance parents. * @param {Boolean} [options.multipleParents=false] Set multiple parents to some instances. - * @param {Matrix4] [options.transform=Matrix4.IDENTITY] The tile transform. - * @param {Boolean} [options.optimizeForCesium=false] Optimize the glTF for Cesium by using the sun as a default light source. + * @param {Boolean} [options.legacy=false] Generate the batch table hierarchy as part of the base Batch Table, now deprecated. + * @param {Matrix4} [options.transform=Matrix4.IDENTITY] The tile transform. * @param {Boolean} [options.gzip=false] Gzip the saved tile. * @param {Boolean} [options.prettyJson=true] Whether to prettify the JSON. * @returns {Promise} A promise that resolves when the tileset is saved. @@ -51,11 +53,11 @@ function createBatchTableHierarchy(options) { var transform = defaultValue(options.transform, Matrix4.IDENTITY); var instances = createInstances(noParents, multipleParents); - var batchTableJson = createBatchTable(instances); + var batchTableJson = createBatchTableJson(instances, options); var batchTableBinary; if (useBatchTableBinary) { - batchTableBinary = createBatchTableBinary(batchTableJson); // Modifies the json in place + batchTableBinary = createBatchTableBinary(batchTableJson, options); // Modifies the json in place } // Mesh urls listed in the same order as features in the classIds arrays @@ -89,9 +91,9 @@ function createBatchTableHierarchy(options) { Matrix4.fromTranslationQuaternionRotationScale(buildingPositions[2], yUpToZUp , scale) ]; - var tileName = 'tile.b3dm'; + var contentUri = 'tile.b3dm'; var directory = options.directory; - var tilePath = path.join(directory, tileName); + var tilePath = path.join(directory, contentUri); var tilesetJsonPath = path.join(directory, 'tileset.json'); var buildingsLength = 3; @@ -107,12 +109,17 @@ function createBatchTableHierarchy(options) { ]; var tilesetJson = createTilesetJsonSingle({ - tileName : tileName, + contentUri : contentUri, geometricError : geometricError, box : box, transform : transform }); + if (!options.legacy) { + Extensions.addExtensionsUsed(tilesetJson, '3DTILES_batch_table_hierarchy'); + Extensions.addExtensionsRequired(tilesetJson, '3DTILES_batch_table_hierarchy'); + } + var featureTableJson = { BATCH_LENGTH : batchLength }; @@ -135,8 +142,7 @@ function createBatchTableHierarchy(options) { } var batchedMesh = Mesh.batch(clonedMeshes); return createGltf({ - mesh : batchedMesh, - optimizeForCesium : options.optimizeForCesium + mesh : batchedMesh }); }).then(function(glb) { var b3dm = createB3dm({ @@ -170,7 +176,7 @@ function createUInt16Buffer(values) { return buffer; } -function createBatchTableBinary(batchTable) { +function createBatchTableBinary(batchTable, options) { var byteOffset = 0; var buffers = []; @@ -195,7 +201,10 @@ function createBatchTableBinary(batchTable) { // Convert regular batch table properties to binary var propertyName; for (propertyName in batchTable) { - if (batchTable.hasOwnProperty(propertyName) && propertyName !== 'HIERARCHY') { + if (batchTable.hasOwnProperty(propertyName) + && propertyName !== 'HIERARCHY' + && propertyName !== 'extensions' + && propertyName !== 'extras') { if (typeof batchTable[propertyName][0] === 'number') { batchTable[propertyName] = createBinaryProperty(batchTable[propertyName], 'FLOAT', 'SCALAR'); } @@ -203,7 +212,7 @@ function createBatchTableBinary(batchTable) { } // Convert instance properties to binary - var hierarchy = batchTable.HIERARCHY; + var hierarchy = options.legacy ? batchTable.HIERARCHY : batchTable.extensions['3DTILES_batch_table_hierarchy']; var classes = hierarchy.classes; var classesLength = classes.length; for (var i = 0; i < classesLength; ++i) { @@ -233,7 +242,7 @@ function createBatchTableBinary(batchTable) { return Buffer.concat(buffers); } -function createBatchTable(instances) { +function createBatchTableJson(instances, options) { // Create batch table from the instances' regular properties var batchTable = {}; var instancesLength = instances.length; @@ -252,8 +261,13 @@ function createBatchTable(instances) { } } - // Add HIERARCHY object - batchTable.HIERARCHY = createHierarchy(instances); + var hierarchy = createHierarchy(instances); + if (options.legacy) { + // Add HIERARCHY object + batchTable.HIERARCHY = hierarchy; + } else { + Extensions.addExtension(batchTable, '3DTILES_batch_table_hierarchy', hierarchy); + } return batchTable; } diff --git a/samples-generator/lib/createBuildings.js b/samples-generator/lib/createBuildings.js index efbb0e6e..3443898e 100644 --- a/samples-generator/lib/createBuildings.js +++ b/samples-generator/lib/createBuildings.js @@ -19,23 +19,19 @@ var scratchRotation = new Quaternion(); var scratchScale = new Cartesian3(); var whiteOpaqueMaterial = new Material({ - diffuse : [1.0, 1.0, 1.0, 1.0], - ambient : [0.2, 0.2, 0.2, 1.0] + baseColor : [1.0, 1.0, 1.0, 1.0] }); var whiteTranslucentMaterial = new Material({ - diffuse: [1.0, 1.0, 1.0, 0.5], - ambient : [0.2, 0.2, 0.2, 1.0] + baseColor : [1.0, 1.0, 1.0, 0.5] }); var texturedMaterial = new Material({ - diffuse : 'data/wood_red.jpg', - ambient : [0.2, 0.0, 0.0, 1.0] + baseColor : 'data/wood_red.jpg' }); var redMaterial = new Material({ - diffuse : [1.0, 0.0, 0.0, 1.0], - ambient : [0.2, 0.0, 0.0, 1.0] + baseColor : [1.0, 0.0, 0.0, 1.0] }); /** @@ -46,7 +42,7 @@ var redMaterial = new Material({ * @param {Number} [options.tileWidth=200.0] The width of the tile in meters. Buildings are placed randomly in this area. * @param {Number} [options.averageWidth=4.0] Average building width in meters around which random widths and depths are generated. * @param {Number} [options.averageHeight=5.0] Average building height in meters around which random heights are generated. - * @param {String} [options.diffuseType='white'] Specifies the type of diffuse color to apply to the tile. Possible values are 'white', 'color', 'textured'. + * @param {String} [options.baseColorType='white'] Specifies the type of diffuse color to apply to the tile. Possible values are 'white', 'color', 'textured'. * @param {String} [options.translucencyType='opaque'] Specifies the type of translucency to apply to the tile. Possible values are 'opaque', 'translucent', 'mix'. * @param {Number} [options.longitude=-1.31968] The center longitude of the tile. Used to generate metadata for the batch table. * @param {Number} [options.latitude=0.698874] The center latitude of the tile. Used to generate metadata for the batch table. @@ -55,24 +51,32 @@ var redMaterial = new Material({ * @returns {Building[]} An array of buildings. */ function createBuildings(options) { - // Set the random number seed before creating each set of buildings so that the generated buildings are the same between runs - var seed = defaultValue(options.seed, 2); - CesiumMath.setRandomNumberSeed(seed); - options = defaultValue(options, defaultValue.EMPTY_OBJECT); + var seed = defaultValue(options.seed, 11); var numberOfBuildings = defaultValue(options.numberOfBuildings, 10); var tileWidth = defaultValue(options.tileWidth, 200.0); var averageWidth = defaultValue(options.averageWidth, 4.0); var averageHeight = defaultValue(options.averageHeight, 5.0); - var diffuseType = defaultValue(options.diffuseType, 'white'); + var baseColorType = defaultValue(options.baseColorType, 'white'); var translucencyType = defaultValue(options.translucencyType, 'opaque'); var centerLongitude = defaultValue(options.longitude, -1.31968); var centerLatitude = defaultValue(options.latitude, 0.698874); + // Set the random number seed before creating materials + CesiumMath.setRandomNumberSeed(seed); + var materials = new Array(numberOfBuildings); + for (i = 0; i < numberOfBuildings; ++i) { + // For Cesium testing purposes make the first building red + var useRedMaterial = (baseColorType === 'color') && (translucencyType === 'opaque') && i === 0; + var randomMaterial = getMaterial(baseColorType, translucencyType, i, numberOfBuildings); + materials[i] = useRedMaterial ? redMaterial : randomMaterial; + } + + // Set the random number seed before creating buildings so that the generated buildings are the same between runs + CesiumMath.setRandomNumberSeed(seed); var buildings = new Array(numberOfBuildings); for (var i = 0; i < numberOfBuildings; ++i) { // Create buildings with the z-axis as up - var material = getMaterial(diffuseType, translucencyType, i, numberOfBuildings); var width = Math.max(averageWidth + (CesiumMath.nextRandomNumber() - 0.5) * 8.0, 1.0); var depth = Math.max(width + (CesiumMath.nextRandomNumber() - 0.5) * 4.0, 1.0); var height = Math.max(averageHeight + (CesiumMath.nextRandomNumber() - 0.5) * 8.0, 1.0); @@ -83,13 +87,10 @@ function createBuildings(options) { var rangeX = CesiumMath.nextRandomNumber() - 0.5; var rangeY = CesiumMath.nextRandomNumber() - 0.5; - // For Cesium testing purposes, always place one building in the center of the tile and make it red + // For Cesium testing purposes always place one building in the center of the tile if (i === 0) { rangeX = 0.0; rangeY = 0.0; - if ((diffuseType === 'color') && (translucencyType === 'opaque')) { - material = redMaterial; - } } var x = rangeX * tileWidth; @@ -110,7 +111,7 @@ function createBuildings(options) { buildings[i] = new Building({ matrix : matrix, - material : material, + material : materials[i], longitude : longitude, latitude : latitude, height : height @@ -146,14 +147,13 @@ function getRandomColorMaterial(alpha) { var green = CesiumMath.nextRandomNumber(); var blue = CesiumMath.nextRandomNumber(); return new Material({ - diffuse : [red, green, blue, alpha], - ambient : [0.2, 0.2, 0.2, 1.0] + baseColor : [red, green, blue, alpha] }); } -function getMaterial(diffuseType, translucencyType, buildingIndex, numberOfBuildings) { +function getMaterial(baseColorType, translucencyType, buildingIndex, numberOfBuildings) { var firstHalf = (buildingIndex < numberOfBuildings / 2); - if (diffuseType === 'white') { + if (baseColorType === 'white') { if (translucencyType === 'opaque') { return whiteOpaqueMaterial; } else if (translucencyType === 'translucent') { @@ -161,7 +161,7 @@ function getMaterial(diffuseType, translucencyType, buildingIndex, numberOfBuild } else if (translucencyType === 'mix') { return firstHalf ? whiteOpaqueMaterial : whiteTranslucentMaterial; } - } else if (diffuseType === 'color') { + } else if (baseColorType === 'color') { if (translucencyType === 'opaque') { return getRandomColorMaterial(1.0); } else if (translucencyType === 'translucent') { @@ -170,7 +170,7 @@ function getMaterial(diffuseType, translucencyType, buildingIndex, numberOfBuild var alpha = firstHalf ? 1.0 : 0.5; return getRandomColorMaterial(alpha); } - } else if (diffuseType === 'textured') { + } else if (baseColorType === 'textured') { return texturedMaterial; } } diff --git a/samples-generator/lib/createBuildingsTile.js b/samples-generator/lib/createBuildingsTile.js index 921ad07b..9969fde7 100644 --- a/samples-generator/lib/createBuildingsTile.js +++ b/samples-generator/lib/createBuildingsTile.js @@ -5,8 +5,10 @@ var createBuildings = require('./createBuildings'); var createGltf = require('./createGltf'); var Mesh = require('./Mesh'); +var Cartesian3 = Cesium.Cartesian3; var combine = Cesium.combine; var defaultValue = Cesium.defaultValue; +var defined = Cesium.defined; var Matrix4 = Cesium.Matrix4; module.exports = createBuildingsTile; @@ -26,15 +28,11 @@ var scratchMatrix = new Matrix4(); * @param {Boolean} [options.createBatchTableExtra=false] Add additional test properties to the batch table. * @param {Boolean} [options.createBatchTableBinary=false] Create a batch table binary for the b3dm tile. * @param {Matrix4} [options.transform=Matrix4.IDENTITY] A transform to bake into the tile, for example a transform into WGS84. - * @param {Boolean} [options.optimizeForCesium=false] Optimize the glTF for Cesium by using the sun as a default light source. - * @param {Boolean} [options.relativeToCenter=false] Use the Cesium_RTC extension. - * @param {Boolean} [options.khrMaterialsCommon=false] Save glTF with the KHR_materials_common extension. - * @param {Boolean} [options.quantization=false] Save glTF with quantized attributes. + * @param {Boolean} [options.relativeToCenter=false] Set mesh positions relative to center. + * @param {Number[]} [options.rtcCenterPosition] If defined, sets RTC_CENTER attribute in the feature table. * @param {Boolean} [options.useVertexColors=false] Bake materials as vertex colors. * @param {Boolean} [options.deprecated1=false] Save the b3dm with the deprecated 20-byte header and the glTF with the BATCHID semantic. * @param {Boolean} [options.deprecated2=false] Save the b3dm with the deprecated 24-byte header and the glTF with the BATCHID semantic. - * @param {Object|Object[]} [options.textureCompressionOptions] Options for compressing textures in the glTF. - * @param {String} [options.gltfUpAxis='Y'] Specifies the up-axis for the glTF model. * * @returns {Promise} A promise that resolves with the b3dm buffer and batch table JSON. */ @@ -45,15 +43,11 @@ function createBuildingsTile(options) { var createBatchTableExtra = defaultValue(options.createBatchTableExtra, false) && useBatchIds; var createBatchTableBinary = defaultValue(options.createBatchTableBinary, false) && useBatchIds; var tileTransform = defaultValue(options.transform, Matrix4.IDENTITY); - var optimizeForCesium = options.optimizeForCesium; var relativeToCenter = options.relativeToCenter; - var khrMaterialsCommon = options.khrMaterialsCommon; - var quantization = options.quantization; + var rtcCenterPosition = options.rtcCenterPosition; var useVertexColors = options.useVertexColors; var deprecated1 = options.deprecated1; var deprecated2 = options.deprecated2; - var textureCompressionOptions = options.textureCompressionOptions; - var gltfUpAxis = options.gltfUpAxis; var buildingsLength = buildings.length; var batchLength = useBatchIds ? buildingsLength : 0; @@ -91,18 +85,19 @@ function createBuildingsTile(options) { BATCH_LENGTH : batchLength }; + if (defined(rtcCenterPosition)) { + featureTableJson.RTC_CENTER = rtcCenterPosition; + } else if (relativeToCenter) { + featureTableJson.RTC_CENTER = Cartesian3.pack(batchedMesh.getCenter(), new Array(3)); + } + return createGltf({ mesh : batchedMesh, useBatchIds : useBatchIds, - optimizeForCesium : optimizeForCesium, relativeToCenter : relativeToCenter, - khrMaterialsCommon : khrMaterialsCommon, - quantization : quantization, - deprecated : deprecated1 || deprecated2, - textureCompressionOptions : textureCompressionOptions, - upAxis : gltfUpAxis + deprecated : deprecated1 || deprecated2 }).then(function(glb) { - var b3dm = createB3dm({ + var b3dm = createB3dm({ glb : glb, featureTableJson : featureTableJson, batchTableJson : batchTableJson, diff --git a/samples-generator/lib/createGltf.js b/samples-generator/lib/createGltf.js index 3f8c977a..0cb8f1f7 100644 --- a/samples-generator/lib/createGltf.js +++ b/samples-generator/lib/createGltf.js @@ -1,22 +1,18 @@ 'use strict'; var Cesium = require('cesium'); -var fsExtra = require('fs-extra'); var gltfPipeline = require('gltf-pipeline'); -var mime = require('mime'); var path = require('path'); -var Promise = require('bluebird'); +var getBufferPadded = require('./getBufferPadded'); -var Cartesian3 = Cesium.Cartesian3; -var combine = Cesium.combine; var defaultValue = Cesium.defaultValue; +var defined = Cesium.defined; -var addPipelineExtras = gltfPipeline.addPipelineExtras; -var getBinaryGltf = gltfPipeline.getBinaryGltf; -var loadGltfUris = gltfPipeline.loadGltfUris; -var processGltf = gltfPipeline.Pipeline.processJSON; +var gltfToGlb = gltfPipeline.gltfToGlb; module.exports = createGltf; +var rootDirectory = path.join(__dirname, '../'); + var sizeOfUint8 = 1; var sizeOfUint16 = 2; var sizeOfFloat32 = 4; @@ -27,56 +23,51 @@ var sizeOfFloat32 = 4; * @param {Object} options An object with the following properties: * @param {Mesh} options.mesh The mesh. * @param {Boolean} [options.useBatchIds=true] Modify the glTF to include the batchId vertex attribute. - * @param {Boolean} [options.optimizeForCesium=false] Optimize the glTF for Cesium by using the sun as a default light source. - * @param {Boolean} [options.relativeToCenter=false] Use the Cesium_RTC extension. - * @param {Boolean} [options.khrMaterialsCommon=false] Save glTF with the KHR_materials_common extension. - * @param {Boolean} [options.quantization=false] Save glTF with quantized attributes. + * @param {Boolean} [options.relativeToCenter=false] Set mesh positions relative to center. * @param {Boolean} [options.deprecated=false] Save the glTF with the old BATCHID semantic. - * @param {Object|Object[]} [options.textureCompressionOptions] Options for compressing textures in the glTF. - * @param {String} [options.upAxis='Y'] Specifies the up-axis for the glTF model. * * @returns {Promise} A promise that resolves with the binary glTF buffer. */ function createGltf(options) { var useBatchIds = defaultValue(options.useBatchIds, true); - var optimizeForCesium = defaultValue(options.optimizeForCesium, false); var relativeToCenter = defaultValue(options.relativeToCenter, false); - var khrMaterialsCommon = defaultValue(options.khrMaterialsCommon, false); - var quantization = defaultValue(options.quantization, false); var deprecated = defaultValue(options.deprecated, false); - var textureCompressionOptions = options.textureCompressionOptions; - var upAxis = defaultValue(options.upAxis, 'Y'); var mesh = options.mesh; var positions = mesh.positions; var normals = mesh.normals; var uvs = mesh.uvs; var vertexColors = mesh.vertexColors; + var batchIds = mesh.batchIds; var indices = mesh.indices; var views = mesh.views; // If all the vertex colors are 0 then the mesh does not have vertex colors - var hasVertexColors = !vertexColors.every(function(element) {return element === 0;}); + var useVertexColors = !vertexColors.every(function(element) {return element === 0;}); - // Get the center position in WGS84 coordinates - var center; if (relativeToCenter) { - center = mesh.getCenter(); mesh.setPositionsRelativeToCenter(); } - var rootMatrix; - if (upAxis === 'Y') { - // Models are z-up, so add a z-up to y-up transform. - // The glTF spec defines the y-axis as up, so this is the default behavior. - // In Cesium a y-up to z-up transform is applied later so that the glTF and 3D Tiles coordinate systems are consistent - rootMatrix = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]; - } else if (upAxis === 'Z') { - // No conversion needed - models are already z-up - rootMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; - } + // Models are z-up, so add a z-up to y-up transform. + // The glTF spec defines the y-axis as up, so this is the default behavior. + // In Cesium a y-up to z-up transform is applied later so that the glTF and 3D Tiles coordinate systems are consistent + var rootMatrix = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]; var i; + var view; + var material; + var viewsLength = views.length; + var useUvs = false; + for (i = 0; i < viewsLength; ++i) { + view = views[i]; + material = view.material; + if (typeof material.baseColor === 'string') { + useUvs = true; + break; + } + } + var positionsMinMax = getMinMax(positions, 3); var positionsLength = positions.length; var positionsBuffer = Buffer.alloc(positionsLength * sizeOfFloat32); @@ -91,16 +82,20 @@ function createGltf(options) { normalsBuffer.writeFloatLE(normals[i], i * sizeOfFloat32); } - var uvsMinMax = getMinMax(uvs, 2); - var uvsLength = uvs.length; - var uvsBuffer = Buffer.alloc(uvsLength * sizeOfFloat32); - for (i = 0; i < uvsLength; ++i) { - uvsBuffer.writeFloatLE(uvs[i], i * sizeOfFloat32); + var uvsMinMax; + var uvsBuffer = Buffer.alloc(0); + if (useUvs) { + uvsMinMax = getMinMax(uvs, 2); + var uvsLength = uvs.length; + uvsBuffer = Buffer.alloc(uvsLength * sizeOfFloat32); + for (i = 0; i < uvsLength; ++i) { + uvsBuffer.writeFloatLE(uvs[i], i * sizeOfFloat32); + } } var vertexColorsMinMax; var vertexColorsBuffer = Buffer.alloc(0); - if (hasVertexColors) { + if (useVertexColors) { vertexColorsMinMax = getMinMax(vertexColors, 4); var vertexColorsLength = vertexColors.length; vertexColorsBuffer = Buffer.alloc(vertexColorsLength, sizeOfUint8); @@ -109,426 +104,305 @@ function createGltf(options) { } } + var batchIdsMinMax; + var batchIdsBuffer = Buffer.alloc(0); + var batchIdSemantic = deprecated ? 'BATCHID' : '_BATCHID'; + var batchIdsLength; + if (useBatchIds) { + batchIdsMinMax = getMinMax(batchIds, 1); + batchIdsLength = batchIds.length; + batchIdsBuffer = Buffer.alloc(batchIdsLength * sizeOfFloat32); + for (i = 0; i < batchIdsLength; ++i) { + batchIdsBuffer.writeFloatLE(batchIds[i], i * sizeOfFloat32); + } + } + var indicesLength = indices.length; var indexBuffer = Buffer.alloc(indicesLength * sizeOfUint16); for (i = 0; i < indicesLength; ++i) { indexBuffer.writeUInt16LE(indices[i], i * sizeOfUint16); } - var vertexBuffer = Buffer.concat([positionsBuffer, normalsBuffer, uvsBuffer, vertexColorsBuffer]); - var vertexBufferByteOffset = 0; - var vertexBufferByteLength = vertexBuffer.byteLength; var vertexCount = mesh.getVertexCount(); - var indexBufferByteOffset = vertexBufferByteLength; - var indexBufferByteLength = indexBuffer.byteLength; - - var buffer = Buffer.concat([vertexBuffer, indexBuffer]); + var vertexBuffer = getBufferPadded(Buffer.concat([positionsBuffer, normalsBuffer, uvsBuffer, vertexColorsBuffer, batchIdsBuffer])); + var buffer = getBufferPadded(Buffer.concat([vertexBuffer, indexBuffer])); var bufferUri = 'data:application/octet-stream;base64,' + buffer.toString('base64'); var byteLength = buffer.byteLength; + var indexAccessors = []; + var materials = []; + var primitives = []; + + var images; + var samplers; + var textures; + + var bufferViewIndex = 0; + var positionsBufferViewIndex = bufferViewIndex++; + var normalsBufferViewIndex = bufferViewIndex++; + var uvsBufferViewIndex = useUvs ? bufferViewIndex++ : 0; + var vertexColorsBufferViewIndex = useVertexColors ? bufferViewIndex++ : 0; + var batchIdsBufferViewIndex = useBatchIds ? bufferViewIndex++ : 0; + var indexBufferViewIndex = bufferViewIndex++; + var byteOffset = 0; - var positionsByteOffset = byteOffset; + var positionsBufferByteOffset = byteOffset; byteOffset += positionsBuffer.length; - var normalsByteOffset = byteOffset; + var normalsBufferByteOffset = byteOffset; byteOffset += normalsBuffer.length; - var uvsByteOffset = byteOffset; - byteOffset += uvsBuffer.length; - - var vertexColorsByteOffset = byteOffset; - if (hasVertexColors) { - byteOffset += vertexColorsBuffer.length; - } - - var indexAccessors = {}; - var materials = {}; - var primitives = []; - var images = {}; - var samplers = {}; - var textures = {}; + var uvsBufferByteOffset = byteOffset; + byteOffset += useUvs ? uvsBuffer.length : 0; + var vertexColorsBufferByteOffset = byteOffset; + byteOffset += useVertexColors ? vertexColorsBuffer.length : 0; + var batchIdsBufferByteOffset = byteOffset; + byteOffset += useBatchIds ? batchIdsBuffer.length : 0; + + // Start index buffer at the padded byte offset + byteOffset = vertexBuffer.length; + var indexBufferByteOffset = byteOffset; + byteOffset += indexBuffer.length; - var viewsLength = views.length; for (i = 0; i < viewsLength; ++i) { - var view = views[i]; - var material = view.material; - var accessorName = 'accessor_index_' + i; - var materialName = 'material_' + i; + view = views[i]; + material = view.material; var indicesMinMax = getMinMax(indices, 1, view.indexOffset, view.indexCount); - indexAccessors[accessorName] = { - bufferView : 'bufferView_index', + indexAccessors.push({ + bufferView : indexBufferViewIndex, byteOffset : sizeOfUint16 * view.indexOffset, - byteStride : 0, componentType : 5123, // UNSIGNED_SHORT count : view.indexCount, type : 'SCALAR', min : indicesMinMax.min, max : indicesMinMax.max - }; + }); - var ambient = material.ambient; - var diffuse = material.diffuse; - var emission = material.emission; - var specular = material.specular; - var shininess = material.shininess; + var baseColor = material.baseColor; + var baseColorFactor = baseColor; + var baseColorTexture; var transparent = false; - if (typeof diffuse === 'string') { - images.image_diffuse = { - uri : diffuse - }; - samplers.sampler_diffuse = { - magFilter : 9729, // LINEAR - minFilter : 9729, // LINEAR - wrapS : 10497, // REPEAT - wrapT : 10497 // REPEAT - }; - textures.texture_diffuse = { - format : 6408, // RGBA - internalFormat : 6408, // RGBA - sampler : 'sampler_diffuse', - source : 'image_diffuse', - target : 3553, // TEXTURE_2D - type : 5121 // UNSIGNED_BYTE - }; - - diffuse = 'texture_diffuse'; + if (typeof baseColor === 'string') { + if (!defined(images)) { + images = []; + textures = []; + samplers = [{ + magFilter : 9729, // LINEAR + minFilter : 9729, // LINEAR + wrapS : 10497, // REPEAT + wrapT : 10497 // REPEAT + }]; + } + baseColorFactor = [1.0, 1.0, 1.0, 1.0]; + baseColorTexture = baseColor; + images.push({ + uri : baseColor + }); + textures.push({ + sampler : 0, + source : images.length - 1 + }); } else { - transparent = diffuse[3] < 1.0; + transparent = baseColor[3] < 1.0; } var doubleSided = transparent; - var technique = (shininess > 0.0) ? 'PHONG' : 'LAMBERT'; - - materials[materialName] = { - extensions : { - KHR_materials_common : { - technique : technique, - transparent : transparent, - doubleSided : doubleSided, - values : { - ambient : ambient, - diffuse : diffuse, - emission : emission, - specular : specular, - shininess : shininess, - transparency : 1.0, - transparent : transparent, - doubleSided : doubleSided - } - } - } + var alphaMode = transparent ? 'BLEND' : 'OPAQUE'; + + material = { + pbrMetallicRoughness : { + baseColorFactor : baseColorFactor, + roughnessFactor : 1.0, + metallicFactor : 0.0 + }, + alphaMode : alphaMode, + doubleSided : doubleSided }; + if (defined(baseColorTexture)) { + material.pbrMetallicRoughness.baseColorTexture = { + index : 0 + }; + } + + materials.push(material); + var attributes = { - POSITION : 'accessor_position', - NORMAL : 'accessor_normal', - TEXCOORD_0 : 'accessor_uv' + POSITION : positionsBufferViewIndex, + NORMAL : normalsBufferViewIndex }; - if (hasVertexColors) { - attributes.COLOR_0 = 'accessor_vertexColor'; + if (useUvs) { + attributes.TEXCOORD_0 = uvsBufferViewIndex; + } + + if (useVertexColors) { + attributes.COLOR_0 = vertexColorsBufferViewIndex; + } + + if (useBatchIds) { + attributes[batchIdSemantic] = batchIdsBufferViewIndex; } primitives.push({ attributes : attributes, - indices : accessorName, - material : materialName, + indices : indexBufferViewIndex + i, + material : i, mode : 4 // TRIANGLES }); } - var vertexAccessors = { - accessor_position : { - bufferView : 'bufferView_vertex', - byteOffset : positionsByteOffset, - byteStride : 0, + var vertexAccessors = [ + { + bufferView : positionsBufferViewIndex, + byteOffset : 0, componentType : 5126, // FLOAT count : vertexCount, type : 'VEC3', min : positionsMinMax.min, max : positionsMinMax.max }, - accessor_normal : { - bufferView : 'bufferView_vertex', - byteOffset : normalsByteOffset, - byteStride : 0, + { + bufferView : normalsBufferViewIndex, + byteOffset : 0, componentType : 5126, // FLOAT count : vertexCount, type : 'VEC3', min : normalsMinMax.min, max : normalsMinMax.max - }, - accessor_uv : { - bufferView : 'bufferView_vertex', - byteOffset : uvsByteOffset, - byteStride : 0, + } + ]; + + if (useUvs) { + vertexAccessors.push({ + bufferView : uvsBufferViewIndex, + byteOffset : 0, componentType : 5126, // FLOAT count : vertexCount, type : 'VEC2', min : uvsMinMax.min, max : uvsMinMax.max - } - }; + }); + } - if (hasVertexColors) { - vertexAccessors.accessor_vertexColor = { - bufferView : 'bufferView_vertex', - byteOffset : vertexColorsByteOffset, - byteStride : 0, + if (useVertexColors) { + vertexAccessors.push({ + bufferView : vertexColorsBufferViewIndex, + byteOffset : 0, componentType : 5121, // UNSIGNED_BYTE count : vertexCount, type : 'VEC4', min : vertexColorsMinMax.min, max : vertexColorsMinMax.max, normalized : true - }; + }); + } + + if (useBatchIds) { + vertexAccessors.push({ + bufferView : batchIdsBufferViewIndex, + byteOffset : 0, + componentType : 5126, // FLOAT + count : batchIdsLength, + type : 'SCALAR', + min : batchIdsMinMax.min, + max : batchIdsMinMax.max + }); + } + + var accessors = vertexAccessors.concat(indexAccessors); + + var bufferViews = [ + { + buffer : 0, + byteLength : positionsBuffer.length, + byteOffset : positionsBufferByteOffset, + target : 34962 // ARRAY_BUFFER + }, + { + buffer : 0, + byteLength : normalsBuffer.length, + byteOffset : normalsBufferByteOffset, + target : 34962 // ARRAY_BUFFER + } + ]; + + if (useUvs) { + bufferViews.push({ + buffer : 0, + byteLength : uvsBuffer.length, + byteOffset : uvsBufferByteOffset, + target : 34962 // ARRAY_BUFFER + }); } - var accessors = combine(vertexAccessors, indexAccessors); + if (useVertexColors) { + bufferViews.push({ + buffer : 0, + byteLength : vertexColorsBuffer.length, + byteOffset : vertexColorsBufferByteOffset, + target : 34962 // ARRAY_BUFFER + }); + } + + if (useBatchIds) { + bufferViews.push({ + buffer : 0, + byteLength : batchIdsBuffer.length, + byteOffset : batchIdsBufferByteOffset, + target : 34962 // ARRAY_BUFFER + }); + } + + bufferViews.push({ + buffer : 0, + byteLength : indexBuffer.length, + byteOffset : indexBufferByteOffset, + target : 34963 // ELEMENT_ARRAY_BUFFER + }); var gltf = { accessors : accessors, asset : { generator : '3d-tiles-samples-generator', - version : '1.0', - profile : { - api : 'WebGL', - version : '1.0' - } - }, - buffers : { - buffer : { - byteLength : byteLength, - uri : bufferUri - } + version : '2.0' }, - bufferViews : { - bufferView_vertex : { - buffer : 'buffer', - byteLength : vertexBufferByteLength, - byteOffset : vertexBufferByteOffset, - target : 34962 // ARRAY_BUFFER - }, - bufferView_index : { - buffer : 'buffer', - byteLength : indexBufferByteLength, - byteOffset : indexBufferByteOffset, - target : 34963 // ELEMENT_ARRAY_BUFFER - } - }, - extensionsUsed : ['KHR_materials_common'], + buffers : [{ + byteLength : byteLength, + uri : bufferUri + }], + bufferViews : bufferViews, images : images, materials : materials, - meshes : { - mesh : { + meshes : [ + { primitives : primitives } - }, - nodes : { - rootNode : { + ], + nodes : [ + { matrix : rootMatrix, - meshes : ['mesh'], + mesh : 0, name : 'rootNode' } - }, + ], samplers : samplers, - scene : 'scene', - scenes : { - scene : { - nodes : ['rootNode'] - } - }, + scene : 0, + scenes : [{ + nodes : [0] + }], textures : textures }; - var kmcOptions; - if (khrMaterialsCommon) { - kmcOptions = { - technique : 'LAMBERT', - doubleSided : false - }; - } - var gltfOptions = { - optimizeForCesium : optimizeForCesium, - kmcOptions : kmcOptions, - preserve : true, // Don't apply extra optimizations to the glTF - quantize : quantization, - compressTextureCoordinates : quantization, - encodeNormals : quantization, - textureCompressionOptions : textureCompressionOptions + resourceDirectory : rootDirectory }; - - return loadImages(gltf) - .then(function() { - // Run through the gltf-pipeline to generate techniques and shaders for the glTF - return processGltf(gltf, gltfOptions) - .then(function(gltf) { - if (useBatchIds) { - modifyGltfWithBatchIds(gltf, mesh, deprecated); - } - if (relativeToCenter) { - modifyGltfWithRelativeToCenter(gltf, center); - } - if (optimizeForCesium) { - modifyGltfForCesium(gltf); - } - return convertToBinaryGltf(gltf); - }); + return gltfToGlb(gltf, gltfOptions) + .then(function(results) { + return results.glb; }); } -function getLoadImageFunction(image) { - return function() { - var imagePath = image.uri; - var extension = path.extname(imagePath); - return fsExtra.readFile(imagePath) - .then(function(buffer) { - image.uri = 'data:' + mime.getType(extension) + ';base64,' + buffer.toString('base64'); - }); - }; -} - -function loadImages(gltf) { - var imagePromises = []; - var images = gltf.images; - for (var id in images) { - if (images.hasOwnProperty(id)) { - var image = images[id]; - imagePromises.push(getLoadImageFunction(image)()); - } - } - return Promise.all(imagePromises); -} - -function convertToBinaryGltf(gltf) { - addPipelineExtras(gltf); - return loadGltfUris(gltf) - .then(function(gltf) { - return getBinaryGltf(gltf, true, true).glb; - }); -} - -function modifyGltfWithBatchIds(gltf, mesh, deprecated) { - var i; - var batchIds = mesh.batchIds; - var batchIdsMinMax = getMinMax(batchIds, 1); - var batchIdsLength = batchIds.length; - var batchIdsBuffer = Buffer.alloc(batchIdsLength * sizeOfUint16); - for (i = 0; i < batchIdsLength; ++i) { - batchIdsBuffer.writeUInt16LE(batchIds[i], i * sizeOfUint16); - } - var batchIdsBufferUri = 'data:application/octet-stream;base64,' + batchIdsBuffer.toString('base64'); - var batchIdSemantic = deprecated ? 'BATCHID' : '_BATCHID'; - - gltf.accessors.accessor_batchId = { - bufferView : 'bufferView_batchId', - byteOffset : 0, - byteStride : 0, - componentType : 5123, // UNSIGNED_SHORT - count : batchIdsLength, - type : 'SCALAR', - min : batchIdsMinMax.min, - max : batchIdsMinMax.max - }; - - gltf.bufferViews.bufferView_batchId = { - buffer : 'buffer_batchId', - byteLength : batchIdsBuffer.length, - byteOffset : 0, - target : 34962 // ARRAY_BUFFER - }; - - gltf.buffers.buffer_batchId = { - byteLength : batchIdsBuffer.length, - uri : batchIdsBufferUri - }; - - var meshes = gltf.meshes; - for (var meshId in meshes) { - if (meshes.hasOwnProperty(meshId)) { - var primitives = meshes[meshId].primitives; - var length = primitives.length; - for (i = 0; i < length; ++i) { - var primitive = primitives[i]; - primitive.attributes[batchIdSemantic] = 'accessor_batchId'; - } - } - } - - var programs = gltf.programs; - for (var programId in programs) { - if (programs.hasOwnProperty(programId)) { - var program = programs[programId]; - program.attributes.push('a_batchId'); - } - } - - var techniques = gltf.techniques; - for (var techniqueId in techniques) { - if (techniques.hasOwnProperty(techniqueId)) { - var technique = techniques[techniqueId]; - technique.attributes.a_batchId = 'batchId'; - technique.parameters.batchId = { - semantic : batchIdSemantic, - type : 5123 // UNSIGNED_SHORT - }; - } - } - - var shaders = gltf.shaders; - for (var shaderId in shaders) { - if (shaders.hasOwnProperty(shaderId)) { - var shader = shaders[shaderId]; - if (shader.type === 35633) { // Is a vertex shader - var uriHeader = 'data:text/plain;base64,'; - var shaderEncoded = shader.uri.substring(uriHeader.length); - var shaderText = Buffer.from(shaderEncoded, 'base64'); - shaderText = 'attribute float a_batchId;\n' + shaderText; - shaderEncoded = Buffer.from(shaderText).toString('base64'); - shader.uri = uriHeader + shaderEncoded; - } - } - } -} - -function modifyGltfWithRelativeToCenter(gltf, center) { - gltf.extensionsUsed = defaultValue(gltf.extensionsUsed, []); - gltf.extensions = defaultValue(gltf.extensions, {}); - - gltf.extensionsUsed.push('CESIUM_RTC'); - gltf.extensions.CESIUM_RTC = { - center : Cartesian3.pack(center, new Array(3)) - }; - - var techniques = gltf.techniques; - for (var techniqueId in techniques) { - if (techniques.hasOwnProperty(techniqueId)) { - var technique = techniques[techniqueId]; - var parameters = technique.parameters; - for (var parameterId in parameters) { - if (parameters.hasOwnProperty(parameterId)) { - if (parameterId === 'modelViewMatrix') { - var parameter = parameters[parameterId]; - parameter.semantic = 'CESIUM_RTC_MODELVIEW'; - } - } - } - } - } -} - -function modifyGltfForCesium(gltf) { - // Add diffuse semantic to support colorBlendMode in Cesium - var techniques = gltf.techniques; - for (var techniqueId in techniques) { - if (techniques.hasOwnProperty(techniqueId)) { - var technique = techniques[techniqueId]; - technique.parameters.diffuse.semantic = '_3DTILESDIFFUSE'; - } - } -} - function getMinMax(array, components, start, length) { start = defaultValue(start, 0); length = defaultValue(length, array.length); diff --git a/samples-generator/lib/createI3dm.js b/samples-generator/lib/createI3dm.js index 4ab02cf6..8b965103 100644 --- a/samples-generator/lib/createI3dm.js +++ b/samples-generator/lib/createI3dm.js @@ -8,7 +8,7 @@ var defined = Cesium.defined; module.exports = createI3dm; /** - * Create an Instanced 3D Model (i3dm) tile from a feature table, batch table, and gltf buffer or url. + * Create an Instanced 3D Model (i3dm) tile from a feature table, batch table, and gltf buffer or uri. * * @param {Object} options An object with the following properties: * @param {Object} options.featureTableJson The feature table JSON. @@ -16,7 +16,7 @@ module.exports = createI3dm; * @param {Object} [options.batchTableJson] Batch table describing the per-feature metadata. * @param {Buffer} [options.batchTableBinary] The batch table binary. * @param {Buffer} [options.glb] The binary glTF buffer. - * @param {String} [options.url] Url to an external glTF model when options.glb is not specified. + * @param {String} [options.uri] Uri to an external glTF model when options.glb is not specified. * @returns {Buffer} The generated i3dm tile buffer. */ function createI3dm(options) { @@ -26,7 +26,7 @@ function createI3dm(options) { var batchTableBinary = getBufferPadded(options.batchTableBinary); var gltfFormat = defined(options.glb) ? 1 : 0; - var gltfBuffer = defined(options.glb) ? options.glb : getGltfUrlBuffer(options.url); + var gltfBuffer = defined(options.glb) ? options.glb : getGltfUriBuffer(options.uri); var version = 1; var headerByteLength = 32; @@ -50,7 +50,7 @@ function createI3dm(options) { return Buffer.concat([header, featureTableJson, featureTableBinary, batchTableJson, batchTableBinary, gltfBuffer]); } -function getGltfUrlBuffer(url) { - url = url.replace(/\\/g, '/'); - return Buffer.from(url); +function getGltfUriBuffer(uri) { + uri = uri.replace(/\\/g, '/'); + return Buffer.from(uri); } diff --git a/samples-generator/lib/createInstancesTile.js b/samples-generator/lib/createInstancesTile.js index 61583d86..c57d1d22 100644 --- a/samples-generator/lib/createInstancesTile.js +++ b/samples-generator/lib/createInstancesTile.js @@ -3,7 +3,6 @@ var Cesium = require('cesium'); var fsExtra = require('fs-extra'); var path = require('path'); var createI3dm = require('./createI3dm'); -var optimizeGltf = require('./optimizeGltf'); var AttributeCompression = Cesium.AttributeCompression; var Cartesian2 = Cesium.Cartesian2; @@ -23,7 +22,7 @@ var sizeOfFloat32 = 4; * Creates a i3dm tile that represents a set of instances. * * @param {Object} options Object with the following properties: - * @param {Object} options.url Url to the instanced binary glTF model. + * @param {Object} options.uri Uri to the instanced binary glTF model. * @param {Number} [options.tileWidth=200.0] The width of the tile in meters. * @param {Matrix4} [options.transform=Matrix4.IDENTITY] A transform to bake into the tile, for example a transform into WGS84. * @param {Number} [options.instancesLength=25] The number of instances. @@ -39,7 +38,6 @@ var sizeOfFloat32 = 4; * @param {Boolean} [options.uniformScales=false] Generate uniform scales for the instances. * @param {Boolean} [options.nonUniformScales=false] Generate non-uniform scales for the instances. * @param {Boolean} [options.batchIds=false] Generate batch ids for the instances. Not required even if createBatchTable is true. - * @param {Object|Object[]} [options.textureCompressionOptions] Options for compressing textures in the glTF. * * @returns {Promise} A promise that resolves with the i3dm buffer and batch table JSON. */ @@ -51,7 +49,7 @@ function createInstancesTile(options) { var tileWidth = defaultValue(options.tileWidth, 200.0); var transform = defaultValue(options.transform, Matrix4.IDENTITY); var instancesLength = defaultValue(options.instancesLength, 25); - var url = options.url; + var uri = options.uri; var embed = defaultValue(options.embed, true); var modelSize = defaultValue(options.modelSize, 20.0); var createBatchTable = defaultValue(options.createBatchTable, true); @@ -64,7 +62,6 @@ function createInstancesTile(options) { var uniformScales = defaultValue(options.uniformScales, false); var nonUniformScales = defaultValue(options.nonUniformScales, false); var batchIds = defaultValue(options.batchIds, false); - var textureCompressionOptions = options.textureCompressionOptions; var featureTableJson = {}; featureTableJson.INSTANCES_LENGTH = instancesLength; @@ -139,25 +136,17 @@ function createInstancesTile(options) { } } - var gltfOptions = { - textureCompressionOptions : textureCompressionOptions, - preserve : true - }; - - return fsExtra.readFile(url) - .then(function(glb) { - return optimizeGltf(glb, gltfOptions); - }) + return fsExtra.readFile(uri) .then(function(glb) { glb = embed ? glb : undefined; - url = path.basename(url); + uri = path.basename(uri); var i3dm = createI3dm({ featureTableJson : featureTableJson, featureTableBinary : featureTableBinary, batchTableJson : batchTableJson, batchTableBinary : batchTableBinary, glb : glb, - url : url + uri : uri }); return { i3dm : i3dm, diff --git a/samples-generator/lib/createTilesetJsonSingle.js b/samples-generator/lib/createTilesetJsonSingle.js index 70e62bd8..ccda5bac 100644 --- a/samples-generator/lib/createTilesetJsonSingle.js +++ b/samples-generator/lib/createTilesetJsonSingle.js @@ -7,18 +7,20 @@ var Matrix4 = Cesium.Matrix4; module.exports = createTilesetJsonSingle; +var defaultTilesetVersion = '1.0'; + /** * Create a tileset JSON for a single tile. * * @param {Object} options Object with the following properties: - * @param {String} options.tileName Relative path to the tile. + * @param {String} options.contentUri The content URI of the root tile. This may be a relative filepath or a data URI. * @param {Number} options.geometricError Geometric error of the tile. + * @param {String} options.versionNumber The 3D Tiles version number string. * @param {Object} [options.region] Bounding region of the tile. * @param {Object} [options.box] Bounding box of the tile. * @param {Object} [options.sphere] Bounding sphere of the tile. * @param {Matrix4} [options.transform=Matrix4.IDENTITY] The tile transform. * @param {Object} [options.properties] An object containing the min and max values for each property in the batch table. - * @param {String} [options.gltfUpAxis] Specifies the up-axis of embedded glTF models. * @param {Object} [options.expire] Tile expiration options. * * @returns {Object} The tileset JSON. @@ -30,8 +32,7 @@ function createTilesetJsonSingle(options) { var tilesetJson = { asset : { - version : '1.0', - gltfUpAxis : options.gltfUpAxis // If undefined, implicitly 'Y' + version : defaultValue(options.versionNumber, defaultTilesetVersion) }, properties : options.properties, geometricError : options.geometricError, @@ -42,7 +43,7 @@ function createTilesetJsonSingle(options) { boundingVolume : boundingVolume, geometricError : 0.0, content : { - url : options.tileName + uri : options.contentUri } } }; diff --git a/samples-generator/lib/getBufferPadded.js b/samples-generator/lib/getBufferPadded.js index 00ba630f..69ba21f8 100644 --- a/samples-generator/lib/getBufferPadded.js +++ b/samples-generator/lib/getBufferPadded.js @@ -8,7 +8,6 @@ module.exports = getBufferPadded; /** * Pad the buffer to the next 8-byte boundary to ensure proper alignment for the section that follows. - * Padding is not required by the 3D Tiles spec but is important when using Typed Arrays in JavaScript. * * @param {Buffer} buffer The buffer. * @param {Number} [byteOffset=0] The byte offset on which the buffer starts. diff --git a/samples-generator/lib/getJsonBufferPadded.js b/samples-generator/lib/getJsonBufferPadded.js index b9e0b2b7..7c521a81 100644 --- a/samples-generator/lib/getJsonBufferPadded.js +++ b/samples-generator/lib/getJsonBufferPadded.js @@ -11,7 +11,6 @@ module.exports = getJsonBufferPadded; * * Pad the JSON with extra whitespace to fit the next 8-byte boundary. This ensures proper alignment * for the section that follows (for example, batch table binary or feature table binary). - * Padding is not required by the 3D Tiles spec but is important when using Typed Arrays in JavaScript. * * @param {Object} [json] The JSON object. * @param {Number} [byteOffset=0] The byte offset on which the buffer starts. diff --git a/samples-generator/lib/modifyGltfPaths.js b/samples-generator/lib/modifyGltfPaths.js deleted file mode 100644 index 117de59c..00000000 --- a/samples-generator/lib/modifyGltfPaths.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; -var Cesium = require('cesium'); -var gltfPipeline = require('gltf-pipeline'); - -var defined = Cesium.defined; - -var getBinaryGltf = gltfPipeline.getBinaryGltf; - -var dataUriRegex = /^data\:/i; - -module.exports = modifyGltfPaths; - -/** - * Modify uri paths to point to a different folder - * - * @param {Buffer} glb The binary glTF buffer. - * @param {String} relativePath A new relative path for the external resources - * @returns {Buffer} The modified glb buffer - * - * @private - */ -function modifyGltfPaths(glb, relativePath) { - var gltf = gltfPipeline.parseBinaryGltf(glb); - var resources = []; - findResources(gltf, resources); - var resourcesLength = resources.length; - for (var i = 0; i < resourcesLength; ++i) { - resources[i].uri = relativePath + resources[i].uri; - } - return getBinaryGltf(gltf, false, false).glb; -} - -function findResources(object, resources) { - for (var propertyId in object) { - if (object.hasOwnProperty(propertyId)) { - var property = object[propertyId]; - if (defined(property) && typeof property === 'object') { - if (defined(property.uri) && !dataUriRegex.test(property.uri)) { - resources.push(property); - } - findResources(property, resources); - } - } - } -} diff --git a/samples-generator/lib/optimizeGltf.js b/samples-generator/lib/optimizeGltf.js deleted file mode 100644 index 5400f06f..00000000 --- a/samples-generator/lib/optimizeGltf.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -var GltfPipeline = require('gltf-pipeline'); - -var getBinaryGltf = GltfPipeline.getBinaryGltf; -var loadGltfUris = GltfPipeline.loadGltfUris; -var parseBinaryGltf = GltfPipeline.parseBinaryGltf; -var Pipeline = GltfPipeline.Pipeline; - -module.exports = optimizeGltf; - -/** - * Given an input buffer containing a binary glTF asset, optimize it using gltf-pipeline with the provided options - * - * @param {Buffer} glb The buffer containing the binary glTF. - * @param {Object} [options] Options specifying custom gltf-pipeline behavior. - * @returns {Promise} A promise that resolves to the optimized binary glTF. - * - * @private - */ -function optimizeGltf(glb, options) { - var gltf = parseBinaryGltf(glb); - return loadGltfUris(gltf) - .then(function() { - return Pipeline.processJSONWithExtras(gltf, options) - .then(function(gltf) { - return getBinaryGltf(gltf, true, true).glb; - }); - }); -} diff --git a/samples-generator/package.json b/samples-generator/package.json index 82871752..6302aaad 100644 --- a/samples-generator/package.json +++ b/samples-generator/package.json @@ -26,12 +26,13 @@ "bluebird": "^3.5.1", "cesium": "^1.39", "fs-extra": "^4.0.2", - "gltf-pipeline": "^1.0.2", + "gltf-pipeline": "^2.0.0", "mime": "^2.0.3", "simplex-noise": "^2.3.0" }, "devDependencies": { "cloc": "^2.3.3", + "datauri": "^1.1.0", "eslint": "^4.10.0", "eslint-config-cesium": "^2.0.1", "gulp": "^3.9.1",