Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cesiumGeometryToGltfPrimitive does not generate unique accessor names #321

Merged
merged 1 commit into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/cesiumGeometryToGltfPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var Cesium = require('cesium');
var createAccessor = require('./createAccessor');
var findAccessorMinMax = require('./findAccessorMinMax');
var getPrimitiveAttributeSemantics = require('./getPrimitiveAttributeSemantics');
var getUniqueId = require('./getUniqueId');
var mergeBuffers = require('./mergeBuffers');
var uninterleaveAndPackBuffers = require('./uninterleaveAndPackBuffers');
var writeAccessor = require('./writeAccessor');
Expand Down Expand Up @@ -32,7 +33,7 @@ function getFirstAttributeSemantic(gltf, primitive, semantic, packedLength) {

// all attributes but texcoords may occur only once
if (semantic !== 'TEXCOORD') {
id = 'accessor_' + semantic.toLowerCase();
id = getUniqueId(gltf, 'accessor_' + semantic.toLowerCase());
}

primitive.attributes[semantic] = createAccessor(gltf, packedLength, type,
Expand Down
1 change: 1 addition & 0 deletions specs/data/generateNormals/boxahedron_no_normals.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"accessors":{"accessor_21":{"bufferView":"bufferView_1","byteOffset":0,"byteStride":0,"componentType":5123,"count":36,"type":"SCALAR","min":[0],"max":[23]},"accessor_23":{"bufferView":"bufferView_0","byteOffset":0,"byteStride":0,"componentType":5126,"count":24,"max":[0.5,0.5,0.5],"min":[-0.5,-0.5,-0.5],"type":"VEC3"},"accessor_index_0":{"bufferView":"bufferView_1","byteOffset":72,"byteStride":0,"componentType":5123,"count":12,"type":"SCALAR","min":[0],"max":[3]},"accessor_position":{"bufferView":"bufferView_0","byteOffset":288,"byteStride":0,"componentType":5126,"count":4,"min":[0,0,0],"max":[1,1,1],"type":"VEC3"}},"animations":{},"asset":{"generator":"collada2gltf@027f74366341d569dea42e9a68b7104cc3892054","premultipliedAlpha":true,"profile":{"api":"WebGL","version":"1.0.2"},"version":"1.0"},"bufferViews":{"bufferView_0":{"buffer":"buffer_0","byteLength":336,"byteOffset":0,"target":34962},"bufferView_1":{"buffer":"buffer_0","byteLength":96,"byteOffset":336,"target":34963}},"buffers":{"buffer_0":{"type":"arraybuffer","byteLength":432,"uri":"data:application/octet-stream;base64,AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUAAAABAAIAAAADAAEAAAACAAMAAgABAAMA"}},"materials":{"Effect-Red_0":{"values":{"diffuse":[0.8,0,0,1],"shininess":256,"specular":[0.2,0.2,0.2,1]},"technique":"technique1"},"Effect-Blue_0":{"values":{"diffuse":[0,0,0.8,1],"shininess":256,"specular":[0.2,0.2,0.2,1]},"technique":"technique1"}},"meshes":{"Geometry-mesh002":{"name":"Mesh","primitives":[{"attributes":{"POSITION":"accessor_23"},"indices":"accessor_21","material":"Effect-Red_0","mode":4},{"attributes":{"POSITION":"accessor_position"},"indices":"accessor_index_0","material":"Effect-Blue_0","mode":4}]}},"nodes":{"rootNode":{"children":["intermediateNode"],"meshes":["Geometry-mesh002"],"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},"intermediateNode":{"children":["copyNode"],"translation":[0.5,0,0],"rotation":[0,0,0,1],"scale":[1,1,1]},"copyNode":{"children":[],"meshes":["Geometry-mesh002"],"matrix":[0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0.5,0,0,1]}},"programs":{"program0":{"attributes":["a_position"],"fragmentShader":"fragmentShader0","vertexShader":"vertexShader0"}},"scene":"defaultScene","scenes":{"defaultScene":{"nodes":["rootNode"]}},"shaders":{"vertexShader0":{"type":35633,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIG1hdDQgdV9tb2RlbFZpZXdNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X3Byb2plY3Rpb25NYXRyaXg7CmF0dHJpYnV0ZSB2ZWMzIGFfcG9zaXRpb247CnZhcnlpbmcgdmVjMyB2X3Bvc2l0aW9uRUM7CnZvaWQgbWFpbih2b2lkKSB7CiAgdmVjNCBwb3MgPSB1X21vZGVsVmlld01hdHJpeCAqIHZlYzQoYV9wb3NpdGlvbiwxLjApOwogIHZfcG9zaXRpb25FQyA9IHBvcy54eXo7CiAgZ2xfUG9zaXRpb24gPSB1X3Byb2plY3Rpb25NYXRyaXggKiBwb3M7Cn0K"},"fragmentShader0":{"type":35632,"uri":"data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp1bmlmb3JtIHZlYzQgdV9kaWZmdXNlOwp1bmlmb3JtIGZsb2F0IHVfc2hpbmluZXNzOwp1bmlmb3JtIHZlYzQgdV9zcGVjdWxhcjsKdmFyeWluZyB2ZWMzIHZfcG9zaXRpb25FQzsKdm9pZCBtYWluKHZvaWQpIHsKICB2ZWMzIHZpZXdEaXIgPSAtbm9ybWFsaXplKHZfcG9zaXRpb25FQyk7CiAgdmVjMyBhbWJpZW50TGlnaHQgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGFtYmllbnRMaWdodCArPSB2ZWMzKDAuMiwgMC4yLCAwLjIpOwogIHZlYzMgY29sb3IgPSB2ZWMzKDAuMCwgMC4wLCAwLjApOwogIGdsX0ZyYWdDb2xvciA9IHZlYzQoY29sb3IsIDEuMCk7Cn0K"}},"skins":{},"techniques":{"technique1":{"attributes":{"a_position":"position"},"parameters":{"modelViewMatrix":{"semantic":"MODELVIEW","type":35676},"projectionMatrix":{"semantic":"PROJECTION","type":35676},"diffuse":{"type":35666},"shininess":{"type":5126},"specular":{"type":35666},"position":{"semantic":"POSITION","type":35665}},"program":"program0","states":{"enable":[2884,2929]},"uniforms":{"u_modelViewMatrix":"modelViewMatrix","u_projectionMatrix":"projectionMatrix","u_diffuse":"diffuse","u_shininess":"shininess","u_specular":"specular"}}},"extensionsUsed":[],"cameras":{},"images":{},"samplers":{},"textures":{}}
360 changes: 360 additions & 0 deletions specs/data/generateNormals/boxahedron_normals.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
{
"accessors": {
"accessor_21": {
"bufferView": "bufferView_1",
"byteOffset": 0,
"byteStride": 0,
"componentType": 5123,
"count": 36,
"type": "SCALAR",
"min": [
0
],
"max": [
23
]
},
"accessor_23": {
"bufferView": "bufferView_0",
"byteOffset": 0,
"byteStride": 0,
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
"accessor_25": {
"bufferView": "bufferView_0",
"byteOffset": 288,
"byteStride": 0,
"componentType": 5126,
"count": 24,
"max": [
1,
1,
1
],
"min": [
-1,
-1,
-1
],
"type": "VEC3"
},
"accessor_index_0": {
"bufferView": "bufferView_3",
"byteOffset": 0,
"byteStride": 0,
"componentType": 5123,
"count": 12,
"type": "SCALAR",
"min": [
0
],
"max": [
3
]
},
"accessor_position": {
"bufferView": "bufferView_2",
"byteOffset": 0,
"byteStride": 0,
"componentType": 5126,
"count": 4,
"min": [
0,
0,
0
],
"max": [
1,
1,
1
],
"type": "VEC3"
},
"accessor_normal": {
"bufferView": "bufferView_2",
"byteOffset": 48,
"byteStride": 0,
"componentType": 5126,
"count": 4,
"type": "VEC3",
"min": [
-0.5773502588272095,
-0.5773502588272095,
-0.5773502588272095
],
"max": [
1,
1,
1
]
}
},
"animations": {},
"asset": {
"generator": "collada2gltf@027f74366341d569dea42e9a68b7104cc3892054",
"premultipliedAlpha": true,
"profile": {
"api": "WebGL",
"version": "1.0.2"
},
"version": "1.0"
},
"bufferViews": {
"bufferView_0": {
"buffer": "buffer_0",
"byteLength": 576,
"byteOffset": 0,
"target": 34962
},
"bufferView_1": {
"buffer": "buffer_0",
"byteLength": 72,
"byteOffset": 576,
"target": 34963
},
"bufferView_2": {
"buffer": "buffer_1",
"byteLength": 96,
"byteOffset": 0,
"target": 34962
},
"bufferView_3": {
"buffer": "buffer_1",
"byteLength": 24,
"byteOffset": 96,
"target": 34963
}
},
"buffers": {
"buffer_0": {
"type": "arraybuffer",
"byteLength": 648,
"uri": "data:application/octet-stream;base64,AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAL8AAAC/AAAAPwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"
},
"buffer_1": {
"type": "arraybuffer",
"byteLength": 120,
"uri": "data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/Os0TvzrNE786zRO/AAAAAAAAgD8AAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAABAAIAAAADAAEAAAACAAMAAgABAAMA"
}
},
"materials": {
"Effect-Red": {
"name": "Red",
"technique": "technique0",
"values": {
"diffuse": [
0.8,
0,
0,
1
],
"shininess": 256,
"specular": [
0.2,
0.2,
0.2,
1
]
}
},
"Effect-Blue": {
"name": "Blue",
"technique": "technique0",
"values": {
"diffuse": [
0,
0,
0.8,
1
],
"shininess": 256,
"specular": [
0.2,
0.2,
0.2,
1
]
}
}
},
"meshes": {
"Geometry-mesh002": {
"name": "Mesh",
"primitives": [
{
"attributes": {
"NORMAL": "accessor_25",
"POSITION": "accessor_23"
},
"indices": "accessor_21",
"material": "Effect-Red",
"mode": 4
},
{
"attributes": {
"POSITION": "accessor_position",
"NORMAL": "accessor_normal"
},
"indices": "accessor_index_0",
"material": "Effect-Blue",
"mode": 4
}
]
}
},
"nodes": {
"rootNode": {
"children": ["intermediateNode"],
"meshes": [
"Geometry-mesh002"
],
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
]
},
"intermediateNode": {
"children": ["copyNode"],
"translation": [0.5, 0, 0]
},
"copyNode": {
"children": [],
"meshes": [
"Geometry-mesh002"
],
"matrix": [
0.5,
0,
0,
0,
0,
0.5,
0,
0,
0,
0,
0.5,
0,
0.5,
0,
0,
1
]
}
},
"programs": {
"program_0": {
"attributes": [
"a_normal",
"a_position"
],
"fragmentShader": "Box0FS",
"vertexShader": "Box0VS"
}
},
"scene": "defaultScene",
"scenes": {
"defaultScene": {
"nodes": [
"rootNode"
]
}
},
"shaders": {
"Box0FS": {
"type": 35632,
"uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Ow0KdmFyeWluZyB2ZWMzIHZfbm9ybWFsOw0KdW5pZm9ybSB2ZWM0IHVfZGlmZnVzZTsNCnVuaWZvcm0gdmVjNCB1X3NwZWN1bGFyOw0KdW5pZm9ybSBmbG9hdCB1X3NoaW5pbmVzczsNCnZvaWQgbWFpbih2b2lkKSB7DQogIHZlYzMgbm9ybWFsID0gbm9ybWFsaXplKHZfbm9ybWFsKTsNCiAgdmVjNCBjb2xvciA9IHZlYzQoMC4sIDAuLCAwLiwgMC4pOw0KICB2ZWM0IGRpZmZ1c2UgPSB2ZWM0KDAuLCAwLiwgMC4sIDEuKTsNCiAgdmVjNCBzcGVjdWxhcjsNCiAgZGlmZnVzZSA9IHVfZGlmZnVzZTsNCiAgc3BlY3VsYXIgPSB1X3NwZWN1bGFyOw0KICBkaWZmdXNlLnh5eiAqPSBtYXgoZG90KG5vcm1hbCx2ZWMzKDAuLDAuLDEuKSksIDAuKTsNCiAgY29sb3IueHl6ICs9IGRpZmZ1c2UueHl6Ow0KICBjb2xvciA9IHZlYzQoY29sb3IucmdiICogZGlmZnVzZS5hLCBkaWZmdXNlLmEpOw0KICBnbF9GcmFnQ29sb3IgPSBjb2xvcjsNCn0NCg=="
},
"Box0VS": {
"type": 35633,
"uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Ow0KYXR0cmlidXRlIHZlYzMgYV9wb3NpdGlvbjsNCmF0dHJpYnV0ZSB2ZWMzIGFfbm9ybWFsOw0KdmFyeWluZyB2ZWMzIHZfbm9ybWFsOw0KdW5pZm9ybSBtYXQzIHVfbm9ybWFsTWF0cml4Ow0KdW5pZm9ybSBtYXQ0IHVfbW9kZWxWaWV3TWF0cml4Ow0KdW5pZm9ybSBtYXQ0IHVfcHJvamVjdGlvbk1hdHJpeDsNCnZvaWQgbWFpbih2b2lkKSB7DQogIHZlYzQgcG9zID0gdV9tb2RlbFZpZXdNYXRyaXggKiB2ZWM0KGFfcG9zaXRpb24sMS4wKTsNCiAgdl9ub3JtYWwgPSB1X25vcm1hbE1hdHJpeCAqIGFfbm9ybWFsOw0KICBnbF9Qb3NpdGlvbiA9IHVfcHJvamVjdGlvbk1hdHJpeCAqIHBvczsNCn0NCg=="
}
},
"skins": {},
"techniques": {
"technique0": {
"attributes": {
"a_normal": "normal",
"a_position": "position"
},
"parameters": {
"diffuse": {
"type": 35666
},
"modelViewMatrix": {
"semantic": "MODELVIEW",
"type": 35676
},
"normal": {
"semantic": "NORMAL",
"type": 35665
},
"normalMatrix": {
"semantic": "MODELVIEWINVERSETRANSPOSE",
"type": 35675
},
"position": {
"semantic": "POSITION",
"type": 35665
},
"projectionMatrix": {
"semantic": "PROJECTION",
"type": 35676
},
"shininess": {
"type": 5126
},
"specular": {
"type": 35666
}
},
"program": "program_0",
"states": {
"enable": [
2929,
2884
],
"disable": []
},
"uniforms": {
"u_diffuse": "diffuse",
"u_modelViewMatrix": "modelViewMatrix",
"u_normalMatrix": "normalMatrix",
"u_projectionMatrix": "projectionMatrix",
"u_shininess": "shininess",
"u_specular": "specular"
}
}
},
"extensionsUsed": [],
"cameras": {},
"images": {},
"samplers": {},
"textures": {}
}
Loading