merge ws/3d: obj stl ply off vox gltf/glb, ops/MeshOps, codecs Base64/MeshFlatten, api sibling files + texture encoding

This commit is contained in:
4DBug committed 2026-10-31 09:08:22 -05:00
commit 91eba2bc24
145 files changed
+16413 -17

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
-- codecs/Base64 tests: encode / decode against Python's base64 (standard, URL-safe, unpadded) for every length 0..70
-- and some large inputs, whitespace and missing padding on decode, data: URIs, bad input, and the fuzz no-throw pass.
-- Fixtures: tools/fixtures/base64.py.
local T = require("@tests/T")
local Base64 = require("@formats/codecs/Base64")
local Cases = require("@tests/gen/base64_cases")
local t = T.suite("base64")
for _, c in Cases do
local b = buffer.fromstring(c.data)
t:eq(Base64.encode(b), c.std, "encode " .. #c.data)
t:eq(Base64.encode(b, { url = true }), c.url, "encode url " .. #c.data)
t:eq(Base64.encode(b, { pad = false }), c.nopad, "encode unpadded " .. #c.data)
for _, s in { c.std, c.url, c.nopad } do
local d, err = Base64.decode(s)
t:check(d and buffer.tostring(d) == c.data, "decode " .. #c.data .. ": " .. tostring(err))
end
-- with line breaks every 76 characters (MIME)
local wrapped = string.gsub(c.std, "(" .. string.rep(".", 76) .. ")", "%1\r\n")
local d = Base64.decode(wrapped)
t:check(d and buffer.tostring(d) == c.data, "decode wrapped " .. #c.data)
end
-- a sub-range
t:eq(Base64.encode(buffer.fromstring("xxhelloyy"), nil, 2, 5), "aGVsbG8=", "encode a range")
-- data URIs
local b, mime = Base64.decodeDataUri("data:application/gltf-buffer;base64,AAEC")
t:check(b and buffer.len(b) == 3 and buffer.readu8(b, 2) == 2 and mime == "application/gltf-buffer", "data URI")
local b2, m2 = Base64.decodeDataUri("data:,a%20b")
t:check(b2 and buffer.tostring(b2) == "a b" and m2 == "text/plain", "percent-encoded data URI")
t:eq(Base64.dataUri(buffer.fromstring("hi"), "text/plain"), "data:text/plain;base64,aGk=", "dataUri")
-- bad input
t:check(Base64.decode("ab$d") == nil, "bad character")
t:check(Base64.decode("abcde") == nil, "a lone last character")
t:check(Base64.decode("ab==cd") == nil, "data after padding")
t:check(Base64.decodeDataUri("http://x") == nil, "not a data URI")
local samples = {}
for i, c in Cases do
if i % 10 == 0 then
table.insert(samples, c.std)
end
end
t:fuzz("decode", function(x: buffer)
return Base64.decode(x)
end, samples)
t:done()
+6
View File
@@ -212,6 +212,12 @@ do
count += 1
end
t:eq(count, 3, "for over a mixed table visits every key")
local zero = { [0] = 5, 6, 7 }
local zsum = 0
for _, v in zero do
zsum += v
end
t:eq(zsum, 18, "for over a table with key 0 visits it (LuaJIT keeps t[0] in the array part)")
local w = {}
for word in string.gmatch("a b c", "%a") do
table.insert(w, word)
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Animated Morph Cube
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,259 @@
{
"buffers":[
{
"uri":"AnimatedMorphCube.bin",
"byteLength":1700
}
],
"asset":{
"version":"2.0",
"generator":"gltfpack 0.13"
},
"extensionsUsed":[
"KHR_mesh_quantization"
],
"extensionsRequired":[
"KHR_mesh_quantization"
],
"bufferViews":[
{
"buffer":0,
"byteOffset":0,
"byteLength":288,
"byteStride":4,
"target":34962
},
{
"buffer":0,
"byteOffset":288,
"byteLength":576,
"byteStride":8,
"target":34962
},
{
"buffer":0,
"byteOffset":864,
"byteLength":72,
"target":34963
},
{
"buffer":0,
"byteOffset":936,
"byteLength":508
},
{
"buffer":0,
"byteOffset":1444,
"byteLength":254
}
],
"accessors":[
{
"bufferView":0,
"byteOffset":0,
"componentType":5120,
"count":24,
"type":"VEC3",
"normalized":true
},
{
"bufferView":1,
"byteOffset":0,
"componentType":5123,
"count":24,
"type":"VEC3",
"min":[
0,
5451,
0
],
"max":[
5481,
10932,
5481
]
},
{
"bufferView":0,
"byteOffset":96,
"componentType":5120,
"count":24,
"type":"VEC3",
"normalized":true
},
{
"bufferView":1,
"byteOffset":192,
"componentType":5122,
"count":24,
"type":"VEC3",
"min":[
0,
0,
0
],
"max":[
0,
5188,
0
]
},
{
"bufferView":0,
"byteOffset":192,
"componentType":5120,
"count":24,
"type":"VEC3",
"normalized":true
},
{
"bufferView":1,
"byteOffset":384,
"componentType":5122,
"count":24,
"type":"VEC3",
"min":[
0,
0,
0
],
"max":[
0,
5451,
0
]
},
{
"bufferView":2,
"byteOffset":0,
"componentType":5123,
"count":36,
"type":"SCALAR"
},
{
"bufferView":3,
"byteOffset":0,
"componentType":5126,
"count":127,
"type":"SCALAR",
"min":[
0
],
"max":[
4.19999981
]
},
{
"bufferView":4,
"byteOffset":0,
"componentType":5121,
"count":254,
"type":"SCALAR",
"normalized":true
}
],
"materials":[
{
"name":"Material",
"pbrMetallicRoughness":{
"baseColorFactor":[
0.603827417,
0.603827417,
0.603827417,
1
],
"metallicFactor":0,
"roughnessFactor":0.5
}
}
],
"meshes":[
{
"primitives":[
{
"attributes":{
"NORMAL":0,
"POSITION":1
},
"mode":4,
"targets":[
{
"NORMAL":2,
"POSITION":3
},
{
"NORMAL":4,
"POSITION":5
}
],
"indices":6,
"material":0
}
],
"weights":[
0,
0
]
}
],
"animations":[
{
"name":"Square",
"samplers":[
{
"input":7,
"output":8
}
],
"channels":[
{
"sampler":0,
"target":{
"node":0,
"path":"weights"
}
}
]
}
],
"nodes":[
{
"mesh":0,
"translation":[
-0.0100000044,
-0.0298908409,
-0.00999999978
],
"scale":[
3.64900689e-06,
3.64900689e-06,
3.64900689e-06
]
},
{
"name":"AnimatedMorphCube",
"rotation":[
0,
0.707106709,
-0.707106829,
0
],
"scale":[
100,
100,
100
],
"children":[
0
]
}
],
"scenes":[
{
"nodes":[
1
]
}
],
"scene":0
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Animated Triangle
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,118 @@
{
"scene" : 0,
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0,
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"animations": [
{
"samplers" : [
{
"input" : 2,
"interpolation" : "LINEAR",
"output" : 3
}
],
"channels" : [ {
"sampler" : 0,
"target" : {
"node" : 0,
"path" : "rotation"
}
} ]
}
],
"buffers" : [
{
"uri" : "AnimatedTriangle_geometry.bin",
"byteLength" : 44
},
{
"uri" : "AnimatedTriangle_animation.bin",
"byteLength" : 100
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 36,
"target" : 34962
},
{
"buffer" : 1,
"byteOffset" : 0,
"byteLength" : 100
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 5,
"type" : "SCALAR",
"max" : [ 1.0 ],
"min" : [ 0.0 ]
},
{
"bufferView" : 2,
"byteOffset" : 20,
"componentType" : 5126,
"count" : 5,
"type" : "VEC4",
"max" : [ 0.0, 0.0, 1.0, 1.0 ],
"min" : [ 0.0, 0.0, 0.0, -0.707 ]
}
],
"asset" : {
"version" : "2.0"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 B

+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Anisotropy Strength Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Attenuation Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Box
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
+142
View File
@@ -0,0 +1,142 @@
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"mesh": 0
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "Mesh"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
23
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 288,
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorFactor": [
0.800000011920929,
0.0,
0.0,
1.0
],
"metallicFactor": 0.0
},
"name": "Red"
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 576,
"byteLength": 72,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 576,
"byteStride": 12,
"target": 34962
}
],
"buffers": [
{
"byteLength": 648,
"uri": "Box0.bin"
}
]
}
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Box with interleaved position and normal attributes
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
# LICENSE file for the model: Box Textured
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* [Cesium Trademark or Logo](../../LICENSES/LicenseRef-LegalMark-Cesium.txt)
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,181 @@
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"mesh": 0
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2,
"TEXCOORD_0": 3
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "Mesh"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
23
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 288,
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
6.0,
1.0
],
"min": [
0.0,
0.0
],
"type": "VEC2"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicFactor": 0.0
},
"name": "Texture"
}
],
"textures": [
{
"sampler": 0,
"source": 0
}
],
"images": [
{
"uri": "data:image/png;base64,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 truncated
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9986,
"wrapS": 10497,
"wrapT": 10497
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 768,
"byteLength": 72,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 576,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 576,
"byteLength": 192,
"byteStride": 8,
"target": 34962
}
],
"buffers": [
{
"byteLength": 840,
"uri": "data:application/octet-stream;base64,AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAC/AADAQAAAAAAAAKBAAAAAAAAAwED+/38/AACgQP7/fz8AAIBAAAAAAAAAoEAAAAAAAACAQAAAgD8AAKBAAACAPwAAAEAAAAAAAACAPwAAAAAAAABAAACAPwAAgD8AAIA/AABAQAAAAAAAAIBAAAAAAAAAQEAAAIA/AACAQAAAgD8AAEBAAAAAAAAAAEAAAAAAAABAQAAAgD8AAABAAACAPwAAAAAAAAAAAAAAAP7/fz8AAIA/AAAAAAAAgD/+/38/AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"
}
]
}
+181
View File
@@ -0,0 +1,181 @@
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"nodes": [
{
"children": [
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
"mesh": 0
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"NORMAL": 1,
"POSITION": 2,
"TEXCOORD_0": 3
},
"indices": 0,
"mode": 4,
"material": 0
}
],
"name": "Mesh"
}
],
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 36,
"max": [
23
],
"min": [
0
],
"type": "SCALAR"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
1.0,
1.0,
1.0
],
"min": [
-1.0,
-1.0,
-1.0
],
"type": "VEC3"
},
{
"bufferView": 1,
"byteOffset": 288,
"componentType": 5126,
"count": 24,
"max": [
0.5,
0.5,
0.5
],
"min": [
-0.5,
-0.5,
-0.5
],
"type": "VEC3"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"count": 24,
"max": [
6.0,
1.0
],
"min": [
0.0,
0.0
],
"type": "VEC2"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicFactor": 0.0
},
"name": "Texture"
}
],
"textures": [
{
"sampler": 0,
"source": 0
}
],
"images": [
{
"uri": "CesiumLogoFlat.png"
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9986,
"wrapS": 10497,
"wrapT": 10497
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 768,
"byteLength": 72,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 576,
"byteStride": 12,
"target": 34962
},
{
"buffer": 0,
"byteOffset": 576,
"byteLength": 192,
"byteStride": 8,
"target": 34962
}
],
"buffers": [
{
"byteLength": 840,
"uri": "BoxTextured0.bin"
}
]
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Box Vertex Colors
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Cameras
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.

After

Width:  |  Height:  |  Size: 60 B

+99
View File
@@ -0,0 +1,99 @@
{
"scene" : 0,
"scenes" : [
{
"nodes" : [ 0, 1, 2 ]
}
],
"nodes" : [
{
"rotation" : [ -0.383, 0.0, 0.0, 0.92375 ],
"mesh" : 0
},
{
"translation" : [ 0.5, 0.5, 3.0 ],
"camera" : 0
},
{
"translation" : [ 0.5, 0.5, 3.0 ],
"camera" : 1
}
],
"cameras" : [
{
"type": "perspective",
"perspective": {
"aspectRatio": 1.0,
"yfov": 0.7,
"zfar": 100,
"znear": 0.01
}
},
{
"type": "orthographic",
"orthographic": {
"xmag": 1.0,
"ymag": 1.0,
"zfar": 100,
"znear": 0.01
}
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"buffers" : [
{
"uri" : "Cameras.bin",
"byteLength" : 60
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 12,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 12,
"byteLength" : 48,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 6,
"type" : "SCALAR",
"max" : [ 3 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Clear Coat Car Paint
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Emissive Strength Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Interpolation Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: LightVisibility
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Mesh Primitive Modes
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,233 @@
{
"asset": {
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [0, 1, 2, 3, 4, 5, 6]
}
],
"nodes": [
{
"translation": [-0, 3, 0],
"mesh": 0
},
{
"translation": [-2, 0, 0],
"mesh": 1
},
{
"translation": [0, 0, 0],
"mesh": 2
},
{
"translation": [2, 0, 0],
"mesh": 3
},
{
"translation": [-2, -3, 0],
"mesh": 4
},
{
"translation": [0, -3, 0],
"mesh": 5
},
{
"translation": [2, -3, 0],
"mesh": 6
}
],
"meshes": [
{
"name": "mesh with POINTS",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 0,
"mode": 0
}
]
},
{
"name": "mesh with LINES",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 1,
"mode": 1
}
]
},
{
"name": "mesh with LINE_LOOP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 2,
"mode": 2
}
]
},
{
"name": "mesh with LINE_STRIP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 3,
"mode": 3
}
]
},
{
"name": "mesh with TRIANGLES",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 4,
"mode": 4
}
]
},
{
"name": "mesh with GL_TRIANGLE_STRIP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 5,
"mode": 5
}
]
},
{
"name": "mesh with GL_TRIANGLE_FAN",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 6,
"mode": 6
}
]
}
],
"buffers": [
{
"uri": "buffer.bin",
"byteLength": 216
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 130,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 132,
"byteLength": 84,
"target": 34962
}
],
"accessors": [
{
"name": "indices for POINTS",
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINES",
"bufferView": 0,
"byteOffset": 14,
"componentType": 5123,
"count": 12,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINE_LOOP",
"bufferView": 0,
"byteOffset": 38,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINE_STRIP",
"bufferView": 0,
"byteOffset": 52,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for TRIANGLES",
"bufferView": 0,
"byteOffset": 66,
"componentType": 5123,
"count": 18,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for TRIANGLE_STRIP",
"bufferView": 0,
"byteOffset": 102,
"componentType": 5123,
"count": 6,
"type": "SCALAR",
"max": [6],
"min": [1]
},
{
"name": "indices for TRIANGLE_FAN",
"bufferView": 0,
"byteOffset": 114,
"componentType": 5123,
"count": 8,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "positions",
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 7,
"type": "VEC3",
"max": [0.866, 1.0, 0.0],
"min": [-0.866, -1.0, 0.0]
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

+19
View File
@@ -0,0 +1,19 @@
# LICENSE file for the model: MultiUV Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* [Khronos Trademark or Logo](../../LICENSES/LicenseRef-LegalMark-Khronos.txt)
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Multiple Scenes
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,118 @@
{
"scene" : 1,
"scenes" : [
{
"nodes" : [ 0 ]
},
{
"nodes" : [ 1 ]
}
],
"nodes" : [
{
"mesh" : 0
},
{
"mesh" : 1
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
},
{
"primitives" : [ {
"attributes" : {
"POSITION" : 3
},
"indices" : 2
} ]
}
],
"buffers" : [
{
"uri" : "MultipleScenes_triangle.bin",
"byteLength" : 44
},
{
"uri" : "MultipleScenes_square.bin",
"byteLength" : 60
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 36,
"target" : 34962
},
{
"buffer" : 1,
"byteOffset" : 0,
"byteLength" : 12,
"target" : 34963
},
{
"buffer" : 1,
"byteOffset" : 12,
"byteLength" : 48,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
},
{
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 6,
"type" : "SCALAR",
"max" : [ 3 ],
"min" : [ 0 ]
},
{
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 60 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 B

+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Negative Scale Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Point Light Intensity Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Rigged Simple
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Simple Meshes
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

+84
View File
@@ -0,0 +1,84 @@
{
"scene" : 0,
"scenes" : [
{
"nodes" : [ 0, 1]
}
],
"nodes" : [
{
"mesh" : 0
},
{
"mesh" : 0,
"translation" : [ 1.0, 0.0, 0.0 ]
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1,
"NORMAL" : 2
},
"indices" : 0
} ]
}
],
"buffers" : [
{
"uri" : "SimpleMeshes.bin",
"byteLength" : 80
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 72,
"byteStride" : 12,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
},
{
"bufferView" : 1,
"byteOffset" : 36,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 0.0, 0.0, 1.0 ],
"min" : [ 0.0, 0.0, 1.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Simple Morph
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+189
View File
@@ -0,0 +1,189 @@
{
"scene" : 0,
"scenes":[
{
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0
}
],
"meshes":[
{
"primitives":[
{
"attributes":{
"POSITION":1
},
"targets":[
{
"POSITION":2
},
{
"POSITION":3
}
],
"indices":0
}
],
"weights":[
0.5,
0.5
]
}
],
"animations":[
{
"samplers":[
{
"input":4,
"interpolation":"LINEAR",
"output":5
}
],
"channels":[
{
"sampler":0,
"target":{
"node":0,
"path":"weights"
}
}
]
}
],
"buffers":[
{
"uri" : "SimpleMorph_geometry.bin",
"byteLength":116
},
{
"uri" : "SimpleMorph_animation.bin",
"byteLength":60
}
],
"bufferViews":[
{
"buffer":0,
"byteOffset":0,
"byteLength":6,
"target":34963
},
{
"buffer":0,
"byteOffset":8,
"byteLength":108,
"byteStride":12,
"target":34962
},
{
"buffer":1,
"byteOffset":0,
"byteLength":20
},
{
"buffer":1,
"byteOffset":20,
"byteLength":40
}
],
"accessors":[
{
"bufferView":0,
"byteOffset":0,
"componentType":5123,
"count":3,
"type":"SCALAR",
"max":[
2
],
"min":[
0
]
},
{
"bufferView":1,
"byteOffset":0,
"componentType":5126,
"count":3,
"type":"VEC3",
"max":[
1.0,
0.5,
0.0
],
"min":[
0.0,
0.0,
0.0
]
},
{
"bufferView":1,
"byteOffset":36,
"componentType":5126,
"count":3,
"type":"VEC3",
"max":[
0.0,
1.0,
0.0
],
"min":[
-1.0,
0.0,
0.0
]
},
{
"bufferView":1,
"byteOffset":72,
"componentType":5126,
"count":3,
"type":"VEC3",
"max":[
1.0,
1.0,
0.0
],
"min":[
0.0,
0.0,
0.0
]
},
{
"bufferView":2,
"byteOffset":0,
"componentType":5126,
"count":5,
"type":"SCALAR",
"max":[
4.0
],
"min":[
0.0
]
},
{
"bufferView":3,
"byteOffset":0,
"componentType":5126,
"count":10,
"type":"SCALAR",
"max":[
1.0
],
"min":[
0.0
]
}
],
"asset":{
"version":"2.0"
}
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Simple Skin
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+131
View File
@@ -0,0 +1,131 @@
{
"scene" : 0,
"scenes" : [ {
"nodes" : [ 0, 1 ]
} ],
"nodes" : [ {
"skin" : 0,
"mesh" : 0
}, {
"children" : [ 2 ]
}, {
"translation" : [ 0.0, 1.0, 0.0 ],
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
} ],
"meshes" : [ {
"primitives" : [ {
"attributes" : {
"POSITION" : 1,
"JOINTS_0" : 2,
"WEIGHTS_0" : 3
},
"indices" : 0
} ]
} ],
"skins" : [ {
"inverseBindMatrices" : 4,
"joints" : [ 1, 2 ]
} ],
"animations" : [ {
"channels" : [ {
"sampler" : 0,
"target" : {
"node" : 2,
"path" : "rotation"
}
} ],
"samplers" : [ {
"input" : 5,
"interpolation" : "LINEAR",
"output" : 6
} ]
} ],
"buffers" : [ {
"uri" : "SimpleSkin_geometry.bin",
"byteLength" : 168
}, {
"uri" : "SimpleSkin_skinningData.bin",
"byteLength" : 320
}, {
"uri" : "SimpleSkin_inverseBindMatrices.bin",
"byteLength" : 128
}, {
"uri" : "SimpleSkin_animation.bin",
"byteLength" : 240
} ],
"bufferViews" : [ {
"buffer" : 0,
"byteLength" : 48,
"target" : 34963
}, {
"buffer" : 0,
"byteOffset" : 48,
"byteLength" : 120,
"target" : 34962
}, {
"buffer" : 1,
"byteLength" : 320,
"byteStride" : 16
}, {
"buffer" : 2,
"byteLength" : 128
}, {
"buffer" : 3,
"byteLength" : 240
} ],
"accessors" : [ {
"bufferView" : 0,
"componentType" : 5123,
"count" : 24,
"type" : "SCALAR"
}, {
"bufferView" : 1,
"componentType" : 5126,
"count" : 10,
"type" : "VEC3",
"max" : [ 0.5, 2.0, 0.0 ],
"min" : [ -0.5, 0.0, 0.0 ]
}, {
"bufferView" : 2,
"componentType" : 5123,
"count" : 10,
"type" : "VEC4"
}, {
"bufferView" : 2,
"byteOffset" : 160,
"componentType" : 5126,
"count" : 10,
"type" : "VEC4"
}, {
"bufferView" : 3,
"componentType" : 5126,
"count" : 2,
"type" : "MAT4"
}, {
"bufferView" : 4,
"componentType" : 5126,
"count" : 12,
"type" : "SCALAR",
"max" : [ 5.5 ],
"min" : [ 0.0 ]
}, {
"bufferView" : 4,
"byteOffset" : 48,
"componentType" : 5126,
"count" : 12,
"type" : "VEC4",
"max" : [ 0.0, 0.0, 0.707, 1.0 ],
"min" : [ 0.0, 0.0, -0.707, 0.707 ]
} ],
"asset" : {
"version" : "2.0"
}
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Simple Sparse Accessor
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,77 @@
{
"scene" : 0,
"scenes" : [ {
"nodes" : [ 0 ]
} ],
"nodes" : [ {
"mesh" : 0
} ],
"meshes" : [ {
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
} ],
"buffers" : [ {
"uri" : "data:application/gltf-buffer;base64,AAAIAAcAAAABAAgAAQAJAAgAAQACAAkAAgAKAAkAAgADAAoAAwALAAoAAwAEAAsABAAMAAsABAAFAAwABQANAAwABQAGAA0AAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAQAAAAAAAAAAAAABAQAAAAAAAAAAAAACAQAAAAAAAAAAAAACgQAAAAAAAAAAAAADAQAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAQAAAgD8AAAAAAABAQAAAgD8AAAAAAACAQAAAgD8AAAAAAACgQAAAgD8AAAAAAADAQAAAgD8AAAAACAAKAAwAAAAAAIA/AAAAQAAAAAAAAEBAAABAQAAAAAAAAKBAAACAQAAAAAA=",
"byteLength" : 284
} ],
"bufferViews" : [ {
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 72,
"target" : 34963
}, {
"buffer" : 0,
"byteOffset" : 72,
"byteLength" : 168
}, {
"buffer" : 0,
"byteOffset" : 240,
"byteLength" : 6
}, {
"buffer" : 0,
"byteOffset" : 248,
"byteLength" : 36
} ],
"accessors" : [ {
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 36,
"type" : "SCALAR",
"max" : [ 13 ],
"min" : [ 0 ]
}, {
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 14,
"type" : "VEC3",
"max" : [ 6.0, 4.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ],
"sparse" : {
"count" : 3,
"indices" : {
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5123
},
"values" : {
"bufferView" : 3,
"byteOffset" : 0
}
}
} ],
"asset" : {
"version" : "2.0"
}
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Texture Coordinate Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Texture Transform Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@@ -0,0 +1,540 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5126,
"count": 4,
"type": "VEC3",
"max": [
0.5,
0.5,
0.0
],
"min": [
-0.5,
-0.5,
0.0
],
"name": "Positions"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 4,
"type": "VEC2",
"name": "UV0"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 4,
"type": "VEC2",
"name": "UV1"
},
{
"bufferView": 3,
"componentType": 5125,
"count": 6,
"type": "SCALAR",
"name": "Indices"
}
],
"asset": {
"version": "2.0"
},
"buffers": [
{
"uri": "TextureTransformTest.bin",
"byteLength": 136
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 48,
"name": "Positions"
},
{
"buffer": 0,
"byteOffset": 48,
"byteLength": 32,
"name": "UV0"
},
{
"buffer": 0,
"byteOffset": 80,
"byteLength": 32,
"name": "UV1"
},
{
"buffer": 0,
"byteOffset": 112,
"byteLength": 24,
"name": "Indices"
}
],
"extensionsUsed": [
"KHR_texture_transform"
],
"images": [
{
"uri": "UV.png"
},
{
"uri": "Arrow.png"
},
{
"uri": "Correct.png"
},
{
"uri": "NotSupported.png"
},
{
"uri": "Error.png"
}
],
"materials": [
{
"name": "Offset U",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [
0.5,
0.0
]
}
}
},
"metallicFactor": 0
}
},
{
"name": "Offset V",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [
0.0,
0.5
]
}
}
},
"metallicFactor": 0
}
},
{
"name": "Offset UV",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0,
"extensions": {
"KHR_texture_transform": {
"offset": [
0.5,
0.5
]
}
}
},
"metallicFactor": 0
}
},
{
"name": "Rotation",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 1,
"extensions": {
"KHR_texture_transform": {
"rotation": 0.39269908169872415480783042290994
}
}
},
"metallicFactor": 0
}
},
{
"name": "Scale",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 1,
"extensions": {
"KHR_texture_transform": {
"scale": [
1.5,
1.5
]
}
}
},
"metallicFactor": 0
}
},
{
"name": "All",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 1,
"extensions": {
"KHR_texture_transform": {
"offset": [
-0.2,
-0.1
],
"rotation": 0.3,
"scale": [
1.5,
1.5
]
}
}
},
"metallicFactor": 0
}
},
{
"name": "Correct",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 2
},
"metallicFactor": 0
}
},
{
"name": "NotSupported",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 3
},
"metallicFactor": 0
}
},
{
"name": "Error",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 4
},
"metallicFactor": 0
}
}
],
"meshes": [
{
"name": "Offset U",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 2
},
"indices": 3,
"material": 0
}
]
},
{
"name": "Offset V",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 2
},
"indices": 3,
"material": 1
}
]
},
{
"name": "Offset UV",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 2
},
"indices": 3,
"material": 2
}
]
},
{
"name": "Rotation",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 3
}
]
},
{
"name": "Scale",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 4
}
]
},
{
"name": "All",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 5
}
]
},
{
"name": "Correct Marker",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 6
}
]
},
{
"name": "Not Supported Marker",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 7
}
]
},
{
"name": "Error Marker",
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 3,
"material": 8
}
]
}
],
"nodes": [
{
"name": "Offset U",
"mesh": 0,
"translation": [
-1.1,
0.55,
0
]
},
{
"name": "Offset V",
"mesh": 1,
"translation": [
0,
0.55,
0
]
},
{
"name": "Offset UV",
"mesh": 2,
"translation": [
1.1,
0.55,
0
]
},
{
"name": "Rotation",
"mesh": 3,
"translation": [
-1.1,
-0.55,
0
],
"children": [
4,
5,
6
]
},
{
"name": "Rotation - Correct",
"mesh": 6,
"translation": [
-0.07904822439840125109869401756656,
-0.51626748576241543174100150833647,
0.01
],
"scale": [
0.15,
0.15,
0.15
]
},
{
"name": "Rotation - Not Supported",
"mesh": 7,
"translation": [
0.27781745930520227684092879831533,
-0.27781745930520227684092879831533,
0.01
],
"scale": [
0.15,
0.15,
0.15
]
},
{
"name": "Rotation - Error",
"mesh": 8,
"translation": [
0.51626748576241543174100150833647,
0.07904822439840125109869401756656,
0.01
],
"scale": [
0.15,
0.15,
0.15
]
},
{
"name": "Scale",
"mesh": 4,
"translation": [
0,
-0.55,
0
],
"children": [
8,
9
]
},
{
"name": "Scale - Correct",
"mesh": 6,
"translation": [
0.01854497287013485122728586554355,
-0.01854497287013485122728586554355,
0.01
],
"scale": [
0.1,
0.1,
0.1
]
},
{
"name": "Scale - Not Supported",
"mesh": 7,
"translation": [
0.27781745930520227684092879831533,
-0.27781745930520227684092879831533,
0.01
],
"scale": [
0.15,
0.15,
0.15
]
},
{
"name": "All",
"mesh": 5,
"translation": [
1.1,
-0.55,
0
],
"children": [
11
]
},
{
"name": "All - Correct",
"mesh": 6,
"translation": [
-0.07,
-0.25,
0.01
],
"scale": [
0.1,
0.1,
0.1
]
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0,
1,
2,
3,
7,
10
]
}
],
"textures": [
{
"source": 0,
"sampler": 0
},
{
"source": 1,
"sampler": 0
},
{
"source": 2
},
{
"source": 3
},
{
"source": 4
}
],
"samplers": [
{
"wrapS": 33071,
"wrapT": 33071,
"magFilter": 9729,
"minFilter": 9729
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Triangle
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,70 @@
{
"scene" : 0,
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 1
},
"indices" : 0
} ]
}
],
"buffers" : [
{
"uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=",
"byteLength" : 44
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 6,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 8,
"byteLength" : 36,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 3,
"type" : "SCALAR",
"max" : [ 2 ],
"min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Triangle Without Indices
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
@@ -0,0 +1,55 @@
{
"scene" : 0,
"scenes" : [
{
"nodes" : [ 0 ]
}
],
"nodes" : [
{
"mesh" : 0
}
],
"meshes" : [
{
"primitives" : [ {
"attributes" : {
"POSITION" : 0
}
} ]
}
],
"buffers" : [
{
"uri" : "TriangleWithoutIndices.bin",
"byteLength" : 36
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 36,
"target" : 34962
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 3,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}
],
"asset" : {
"version" : "2.0"
}
}
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Unicode❤♻Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/legalcode) [SPDX license identifier: "CC0-1.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
# LICENSE file for the model: Unlit Test
All files in this directory tree are licensed as indicated below.
* All files directly associated with the model including all text, image and binary files:
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
* This file and all other metadocumentation files including "metadata.json":
* [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode) [SPDX license identifier: "CC-BY-4.0"]
Full license text of these licenses are available at the links above.
This license excludes logos and associated trademarks.
<!-- This file is auto-generated by modelmetadata. Do not edit by hand. -->
Binary file not shown.
@@ -0,0 +1,165 @@
* there can be multiple SIZE and XYZI chunks for multiple models; model id is their index in the stored order
* the palette chunk is always stored into the file, so default palette is not needed any more
* the MATT chunk is deprecated, replaced by the MATL chunk, see (4)
* (a), (b), (c) are special data types; (d) is the scene graph in the world editor
=================================
(a) STRING type
int32 : buffer size (in bytes)
int8xN : buffer (without the ending "\0")
=================================
(b) DICT type
int32 : num of key-value pairs
// for each key-value pair
{
STRING : key
STRING : value
}xN
=================================
(c) ROTATION type
store a row-major rotation in the bits of a byte
for example :
R =
0 1 0
0 0 -1
-1 0 0
==>
unsigned char _r = (1 << 0) | (2 << 2) | (0 << 4) | (1 << 5) | (1 << 6)
bit | value
0-1 : 1 : index of the non-zero entry in the first row
2-3 : 2 : index of the non-zero entry in the second row
4 : 0 : the sign in the first row (0 : positive; 1 : negative)
5 : 1 : the sign in the second row (0 : positive; 1 : negative)
6 : 1 : the sign in the third row (0 : positive; 1 : negative)
=================================
(d) Scene Graph
T : Transform Node
G : Group Node
S : Shape Node
T
|
G
/ \
T T
| |
G S
/ \
T T
| |
S S
=================================
(1) Transform Node Chunk : "nTRN"
int32 : node id
DICT : node attributes
(_name : string)
(_hidden : 0/1)
int32 : child node id
int32 : reserved id (must be -1)
int32 : layer id
int32 : num of frames (must be greater than 0)
// for each frame
{
DICT : frame attributes
(_r : int8) ROTATION, see (c)
(_t : int32x3) translation
(_f : int32) frame index, start from 0
}xN
=================================
(2) Group Node Chunk : "nGRP"
int32 : node id
DICT : node attributes
int32 : num of children nodes
// for each child
{
int32 : child node id
}xN
=================================
(3) Shape Node Chunk : "nSHP"
int32 : node id
DICT : node attributes
int32 : num of models (must be greater than 0)
// for each model
{
int32 : model id
DICT : model attributes : reserved
(_f : int32) frame index, start from 0
}xN
=================================
(4) Material Chunk : "MATL"
int32 : material id
DICT : material properties
(_type : str) _diffuse, _metal, _glass, _emit
(_weight : float) range 0 ~ 1
(_rough : float)
(_spec : float)
(_ior : float)
(_att : float)
(_flux : float)
(_plastic)
=================================
(5) Layer Chunk : "LAYR"
int32 : layer id
DICT : layer attribute
(_name : string)
(_hidden : 0/1)
int32 : reserved id, must be -1
=================================
(6) Render Objects Chunk : "rOBJ"
DICT : rendering attributes
=================================
(7) Render Camera Chunk : "rCAM"
int32 : camera id
DICT : camera attribute
(_mode : string)
(_focus : vec(3))
(_angle : vec(3))
(_radius : int)
(_frustum : float)
(_fov : int)
=================================
(8) Palette Note Chunk : "NOTE"
int32 : num of color names
// for each name
{
STRING : color name
}xN
=================================
(9) Index MAP Chunk : "IMAP"
size : 256
// for each index
{
int32 : palette index association
}x256
+111
View File
@@ -0,0 +1,111 @@
MagicaVoxel .vox File Format [10/18/2016]
1. File Structure : RIFF style
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
1x4 | char | id 'VOX ' : 'V' 'O' 'X' 'space', 'V' is first
4 | int | version number : 150
Chunk 'MAIN'
{
// pack of models
Chunk 'PACK' : optional
// models
Chunk 'SIZE'
Chunk 'XYZI'
Chunk 'SIZE'
Chunk 'XYZI'
...
Chunk 'SIZE'
Chunk 'XYZI'
// palette
Chunk 'RGBA' : optional
}
-------------------------------------------------------------------------------
2. Chunk Structure
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
1x4 | char | chunk id
4 | int | num bytes of chunk content (N)
4 | int | num bytes of children chunks (M)
N | | chunk content
M | | children chunks
-------------------------------------------------------------------------------
3. Chunk id 'MAIN' : the root chunk and parent chunk of all the other chunks
4. Chunk id 'PACK' : if it is absent, only one model in the file; only used for the animation in 0.98.2
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
4 | int | numModels : num of SIZE and XYZI chunks
-------------------------------------------------------------------------------
5. Chunk id 'SIZE' : model size
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
4 | int | size x
4 | int | size y
4 | int | size z : gravity direction
-------------------------------------------------------------------------------
6. Chunk id 'XYZI' : model voxels, paired with the SIZE chunk
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
4 | int | numVoxels (N)
4 x N | int | (x, y, z, colorIndex) : 1 byte for each component
-------------------------------------------------------------------------------
7. Chunk id 'RGBA' : palette
-------------------------------------------------------------------------------
# Bytes | Type | Value
-------------------------------------------------------------------------------
4 x 256 | int | (R, G, B, A) : 1 byte for each component
| * <NOTICE>
| * color [0-254] are mapped to palette index [1-255], e.g :
|
| for ( int i = 0; i <= 254; i++ ) {
| palette[i + 1] = ReadRGBA();
| }
-------------------------------------------------------------------------------
8. Default Palette : if chunk 'RGBA' is absent
-------------------------------------------------------------------------------
unsigned int default_palette[256] = {
0x00000000, 0xffffffff, 0xffccffff, 0xff99ffff, 0xff66ffff, 0xff33ffff, 0xff00ffff, 0xffffccff, 0xffccccff, 0xff99ccff, 0xff66ccff, 0xff33ccff, 0xff00ccff, 0xffff99ff, 0xffcc99ff, 0xff9999ff,
0xff6699ff, 0xff3399ff, 0xff0099ff, 0xffff66ff, 0xffcc66ff, 0xff9966ff, 0xff6666ff, 0xff3366ff, 0xff0066ff, 0xffff33ff, 0xffcc33ff, 0xff9933ff, 0xff6633ff, 0xff3333ff, 0xff0033ff, 0xffff00ff,
0xffcc00ff, 0xff9900ff, 0xff6600ff, 0xff3300ff, 0xff0000ff, 0xffffffcc, 0xffccffcc, 0xff99ffcc, 0xff66ffcc, 0xff33ffcc, 0xff00ffcc, 0xffffcccc, 0xffcccccc, 0xff99cccc, 0xff66cccc, 0xff33cccc,
0xff00cccc, 0xffff99cc, 0xffcc99cc, 0xff9999cc, 0xff6699cc, 0xff3399cc, 0xff0099cc, 0xffff66cc, 0xffcc66cc, 0xff9966cc, 0xff6666cc, 0xff3366cc, 0xff0066cc, 0xffff33cc, 0xffcc33cc, 0xff9933cc,
0xff6633cc, 0xff3333cc, 0xff0033cc, 0xffff00cc, 0xffcc00cc, 0xff9900cc, 0xff6600cc, 0xff3300cc, 0xff0000cc, 0xffffff99, 0xffccff99, 0xff99ff99, 0xff66ff99, 0xff33ff99, 0xff00ff99, 0xffffcc99,
0xffcccc99, 0xff99cc99, 0xff66cc99, 0xff33cc99, 0xff00cc99, 0xffff9999, 0xffcc9999, 0xff999999, 0xff669999, 0xff339999, 0xff009999, 0xffff6699, 0xffcc6699, 0xff996699, 0xff666699, 0xff336699,
0xff006699, 0xffff3399, 0xffcc3399, 0xff993399, 0xff663399, 0xff333399, 0xff003399, 0xffff0099, 0xffcc0099, 0xff990099, 0xff660099, 0xff330099, 0xff000099, 0xffffff66, 0xffccff66, 0xff99ff66,
0xff66ff66, 0xff33ff66, 0xff00ff66, 0xffffcc66, 0xffcccc66, 0xff99cc66, 0xff66cc66, 0xff33cc66, 0xff00cc66, 0xffff9966, 0xffcc9966, 0xff999966, 0xff669966, 0xff339966, 0xff009966, 0xffff6666,
0xffcc6666, 0xff996666, 0xff666666, 0xff336666, 0xff006666, 0xffff3366, 0xffcc3366, 0xff993366, 0xff663366, 0xff333366, 0xff003366, 0xffff0066, 0xffcc0066, 0xff990066, 0xff660066, 0xff330066,
0xff000066, 0xffffff33, 0xffccff33, 0xff99ff33, 0xff66ff33, 0xff33ff33, 0xff00ff33, 0xffffcc33, 0xffcccc33, 0xff99cc33, 0xff66cc33, 0xff33cc33, 0xff00cc33, 0xffff9933, 0xffcc9933, 0xff999933,
0xff669933, 0xff339933, 0xff009933, 0xffff6633, 0xffcc6633, 0xff996633, 0xff666633, 0xff336633, 0xff006633, 0xffff3333, 0xffcc3333, 0xff993333, 0xff663333, 0xff333333, 0xff003333, 0xffff0033,
0xffcc0033, 0xff990033, 0xff660033, 0xff330033, 0xff000033, 0xffffff00, 0xffccff00, 0xff99ff00, 0xff66ff00, 0xff33ff00, 0xff00ff00, 0xffffcc00, 0xffcccc00, 0xff99cc00, 0xff66cc00, 0xff33cc00,
0xff00cc00, 0xffff9900, 0xffcc9900, 0xff999900, 0xff669900, 0xff339900, 0xff009900, 0xffff6600, 0xffcc6600, 0xff996600, 0xff666600, 0xff336600, 0xff006600, 0xffff3300, 0xffcc3300, 0xff993300,
0xff663300, 0xff333300, 0xff003300, 0xffff0000, 0xffcc0000, 0xff990000, 0xff660000, 0xff330000, 0xff0000ee, 0xff0000dd, 0xff0000bb, 0xff0000aa, 0xff000088, 0xff000077, 0xff000055, 0xff000044,
0xff000022, 0xff000011, 0xff00ee00, 0xff00dd00, 0xff00bb00, 0xff00aa00, 0xff008800, 0xff007700, 0xff005500, 0xff004400, 0xff002200, 0xff001100, 0xffee0000, 0xffdd0000, 0xffbb0000, 0xffaa0000,
0xff880000, 0xff770000, 0xff550000, 0xff440000, 0xff220000, 0xff110000, 0xffeeeeee, 0xffdddddd, 0xffbbbbbb, 0xffaaaaaa, 0xff888888, 0xff777777, 0xff555555, 0xff444444, 0xff222222, 0xff111111
};
-------------------------------------------------------------------------------
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+351
View File
@@ -0,0 +1,351 @@
-- model/gltf tests: Khronos glTF-Sample-Assets models (JSON with external / embedded buffers, GLB, sparse, interleaved,
-- quantized, morph targets, skins, animations, cameras, lights, texture transforms, material extensions), gltfpack
-- quantized variants and assimp's exporter output, against assimp (meshes, faces, bounds, animations, cameras,
-- lights) and trimesh (area, triangles); full-structure round trips through GLB, embedded .gltf and external files;
-- assimp / trimesh reading our output (gltf_xcheck); textures decoded lazily at the api layer; errors; the fuzz
-- no-throw pass. Fixtures: tools/fixtures/gltf.py.
local T = require("@tests/T")
local F = require("@formats")
local Gltf = require("@formats/model/gltf")
local MeshOps = require("@formats/ops/MeshOps")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Cases = require("@tests/gen/gltf_cases")
local Xcheck = require("@tests/gen/gltf_xcheck")
local t = T.suite("gltf")
local function decode(data: any, opts: any?): (any, any)
local b = if type(data) == "string" then buffer.fromstring(data) else data
return Gltf.decode(Bytes.reader(b), opts)
end
t:eq(Gltf.name, "gltf", "name")
t:eq(Gltf.category, "model", "category")
t:check(Gltf.caps.decode and Gltf.caps.encode and table.find(Gltf.extensions, "glb"), "contract")
local function near(a: number, b: number, eps: number): boolean
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
end
local function triArea(prim: any): number
local pos = prim.attributes.POSITION
local ind = prim.indices
if not ind then
return 0
end
local area = 0
local function P(i: number, k: number): number
return buffer.readf32(pos.data, (i * 3 + k) * 4)
end
for tri = 0, ind.count // 3 - 1 do
local a, b, c = buffer.readu32(ind.data, tri * 12), buffer.readu32(ind.data, tri * 12 + 4), buffer.readu32(ind.data, tri * 12 + 8)
local e1 = { P(b, 0) - P(a, 0), P(b, 1) - P(a, 1), P(b, 2) - P(a, 2) }
local e2 = { P(c, 0) - P(a, 0), P(c, 1) - P(a, 1), P(c, 2) - P(a, 2) }
local x, y, z = e1[2] * e2[3] - e1[3] * e2[2], e1[3] * e2[1] - e1[1] * e2[3], e1[1] * e2[2] - e1[2] * e2[1]
area += math.sqrt(x * x + y * y + z * z) / 2
end
return area
end
-- assimp's counts: one mesh per primitive, faces after strips / fans / loops are unrolled
local function counts(scene: any): (number, number)
local prims, faces = 0, 0
-- the meshes of the default scene (assimp imports that one only)
local meshes, seen = {}, {}
for _, pl in Types.Scene.flatten(scene) do
if not seen[pl.mesh] then
seen[pl.mesh] = true
table.insert(meshes, scene.meshes[pl.mesh])
end
end
for _, m in meshes do
for _, p in m.primitives do
prims += 1
local n = if p.indices then p.indices.count else p.attributes.POSITION.count
local mode = p.mode
faces += if mode == "triangles" then n // 3
elseif mode == "triangle_strip" or mode == "triangle_fan" then math.max(n - 2, 0)
elseif mode == "lines" then n // 2
elseif mode == "line_strip" then math.max(n - 1, 0)
elseif mode == "line_loop" then n
else n
end
end
return prims, faces
end
-- every value of two scenes equal (buffers by content), meta skipped
local function same(a: any, b: any, path: string, seen: { [any]: boolean }?, skip: { [string]: boolean }?): (boolean, string?)
local s = seen or {}
local sk = skip or { meta = true, extras = true }
if type(a) == "buffer" and type(b) == "buffer" then
return buffer.tostring(a) == buffer.tostring(b), path
end
if type(a) ~= "table" or type(b) ~= "table" then
if type(a) == "number" and type(b) == "number" then
return near(a, b, 1e-6), path
end
return a == b, path
end
if s[a] then
return true, nil
end
s[a] = true
for k, v in a do
if not sk[k] then
local ok, where = same(v, b[k], path .. "." .. tostring(k), s, sk)
if not ok then
return false, where
end
end
end
for k, v in b do
if not sk[k] and a[k] == nil and v ~= nil then
return false, path .. "." .. tostring(k) .. " (extra)"
end
end
return true, nil
end
local byName = {}
local checked = { assimp = 0, trimesh = 0, roundTrips = 0 }
for i, c in Cases do
byName[c.name] = c
local scene, err = decode(c.data, { files = c.files })
t:check(scene, c.name .. ": decode: " .. tostring(err))
local ref = if c.like then nil else c.assimp
local prims, faces = counts(scene)
if ref and not ref.failed then
t:eq(prims, ref.meshes, c.name .. ": meshes (assimp)")
t:eq(faces, ref.faces, c.name .. ": faces (assimp)")
if ref.animations then
t:eq(#scene.animations, ref.animations, c.name .. ": animations (assimp)")
end
if ref.cameras then
t:eq(#scene.cameras, ref.cameras, c.name .. ": cameras (assimp)")
end
if ref.lights then
t:eq(#scene.lights, ref.lights, c.name .. ": lights (assimp)")
end
checked.assimp += 1
end
-- trimesh: the whole scene in world space (quantized variants: against the original model, within quantization)
local tm = if c.like then byName[c.like].trimesh else c.trimesh
local merged = MeshOps.merge(scene)
local onlyTriangles = true -- trimesh reads TRIANGLES primitives only (not strips / fans)
for _, m in scene.meshes do
for _, p in m.primitives do
if p.mode == "triangle_strip" or p.mode == "triangle_fan" then
onlyTriangles = false
end
end
end
-- trimesh ignores sparse accessors
local sparse = string.find(c.data, "\"sparse\"", 1, true) ~= nil
if tm and not tm.failed and tm.faces > 0 and onlyTriangles and not sparse then
local eps = if c.like then 2e-3 else 1e-5
t:eq(merged.indices.count // 3, tm.faces, c.name .. ": triangles (trimesh)")
t:check(near(triArea(merged), tm.area, eps), string.format("%s: area %.6g, trimesh %.6g", c.name, triArea(merged), tm.area))
local lo, hi = MeshOps.bounds(merged)
for k = 1, 3 do
t:check(near(lo[k], tm.bounds[k], eps * 10) and near(hi[k], tm.bounds[k + 3], eps * 10), c.name .. ": bounds (trimesh)")
end
checked.trimesh += 1
end
-- round trips: GLB, embedded .gltf, external files
local glb, gerr = Gltf.encode(scene, { binary = true })
t:check(glb, c.name .. ": encode glb: " .. tostring(gerr))
local back = decode(glb)
t:check(back, c.name .. ": decode our glb")
local SKIP = { meta = true, extras = true, uri = true } -- embedded images lose their file names
local ok, where = same(scene, back, "scene", nil, SKIP)
t:check(ok, c.name .. ": glb round trip differs at " .. tostring(where))
local text = Gltf.encode(scene) :: buffer
local back2 = decode(text)
local ok2, where2 = same(scene, back2, "scene", nil, SKIP)
t:check(ok2, c.name .. ": embedded .gltf round trip differs at " .. tostring(where2))
local files = {}
local ext = Gltf.encode(scene, { external = true, files = files, name = "x.gltf" }) :: buffer
t:check(files["x.bin"] ~= nil or #scene.meshes == 0, c.name .. ": external .bin")
local back3 = decode(ext, { files = files })
local ok3, where3 = same(scene, back3, "scene", nil, SKIP)
t:check(ok3, c.name .. ": external .gltf round trip differs at " .. tostring(where3))
-- writing what we read back gives the same bytes
t:check(buffer.tostring(Gltf.encode(back, { binary = true }) :: buffer) == buffer.tostring(glb :: buffer), c.name .. ": writing is stable")
checked.roundTrips += 1
c.index = i
end
t:note("%d files: %d against assimp, %d against trimesh, %d round trips", #Cases, checked.assimp, checked.trimesh, checked.roundTrips)
-- the reference tools read our files like the originals
local nx = 0
for _, x in Xcheck do
local c = Cases[x.case]
local a, ca = x.assimp, c.assimp
if not ca.failed then
t:check(not a.failed, x.name .. ": assimp reads our file")
t:eq(a.faces, ca.faces, x.name .. ": assimp faces of our file (" .. c.name .. ")")
t:eq(a.meshes, ca.meshes, x.name .. ": assimp meshes of our file")
for k = 1, 3 do
t:check(near(a.min[k], ca.min[k], 1e-4) and near(a.max[k], ca.max[k], 1e-4), x.name .. ": assimp bounds of our file (" .. c.name .. ")")
end
t:eq(a.animations, ca.animations, x.name .. ": assimp animations of our file")
t:eq(a.cameras, ca.cameras, x.name .. ": assimp cameras of our file")
t:eq(a.lights, ca.lights, x.name .. ": assimp lights of our file")
end
if c.trimesh and not c.trimesh.failed and c.trimesh.faces > 0 and c.name ~= "MeshPrimitiveModes/glTF" and not string.find(c.data, "\"sparse\"", 1, true) then
t:check(not x.trimesh.failed and near(x.trimesh.area, c.trimesh.area, 1e-5) and x.trimesh.faces == c.trimesh.faces, x.name .. ": trimesh area of our file (" .. c.name .. ")")
end
nx += 1
end
t:note("%d of our files read back by assimp / trimesh like the originals", nx)
-- details
do
local function load(name: string): any
local c = byName[name]
return decode(c.data, { files = c.files })
end
local box = load("Box/glTF")
t:check(box.nodes[box.roots[1]].matrix ~= nil and box.meta.source.binary == false, "Box: a matrix node, JSON")
t:check(box.materials[1].metallic == 0 and near(box.materials[1].baseColor[1], 0.8, 1e-6), "Box: material")
local bt = load("BoxTextured/glTF")
local tex = bt.textures[1]
t:check(tex.uri == "CesiumLogoFlat.png" and tex.mime == "image/png" and buffer.tostring(tex.data) == byName["BoxTextured/glTF"].files["CesiumLogoFlat.png"], "BoxTextured: the image bytes from opts.files")
t:check(tex.sampler and tex.sampler.wrapS == "repeat" and tex.sampler.minFilter == "nearest_mipmap_linear", "sampler")
-- the api decodes textures lazily (PNG here)
local _, terrs = F.model.loadTextures(bt)
t:check(tex.image and tex.image.width == 256 and next(terrs) == nil, "F.model.loadTextures decodes the PNG")
local files = {}
local ext = Gltf.encode(bt, { external = true, files = files, name = "bt.gltf" }) :: buffer
t:check(files["CesiumLogoFlat.png"] ~= nil and string.find(buffer.tostring(ext), "\"uri\": \"CesiumLogoFlat.png\"", 1, true) ~= nil, "external images keep their file names")
local emb = load("BoxTextured/glTF-Embedded")
t:check(emb.textures[1].data and buffer.tostring(emb.textures[1].data) == buffer.tostring(tex.data), "embedded data: URI image = the external file")
local sparse = load("SimpleSparseAccessor/glTF-Embedded")
local pos = sparse.meshes[1].primitives[1].attributes.POSITION
local maxY = -math.huge
for v = 0, pos.count - 1 do
maxY = math.max(maxY, buffer.readf32(pos.data, v * 12 + 4))
end
t:eq(maxY, 4, "sparse values substituted (the raised vertices, max = the accessor max)")
local cams = load("Cameras/glTF")
t:check(#cams.cameras == 2 and cams.cameras[1].type == "perspective" and cams.cameras[2].type == "orthographic", "cameras")
local skin = load("SimpleSkin/glTF")
t:check(#skin.skins == 1 and #skin.skins[1].joints == 2 and skin.skins[1].inverseBindMatrices.matrix and skin.skins[1].inverseBindMatrices.components == 16, "skin")
t:check(#skin.animations == 1 and skin.animations[1].channels[1].path == "rotation", "skin animation")
local morph = load("SimpleMorph/glTF")
t:check(#morph.meshes[1].primitives[1].targets == 2 and morph.meshes[1].weights[1] == 0.5, "morph targets, weights")
local q = load("AnimatedMorphCube/glTF-Quantized")
local qp = q.meshes[1].primitives[1]
t:check(qp.attributes.NORMAL.type == "snorm8" and qp.targets and qp.targets[1].POSITION.type == "i16", "quantized normals / target deltas")
local unlit = load("UnlitTest/glTF-Binary")
t:check(unlit.materials[1].extensions and unlit.materials[1].extensions.KHR_materials_unlit ~= nil, "KHR_materials_unlit")
local es = load("EmissiveStrengthTest/glTF-Binary")
local strength = 0
for _, m in es.materials do
local e = m.extensions and m.extensions.KHR_materials_emissive_strength
if e then
strength = math.max(strength, e.emissiveStrength)
end
end
t:check(strength > 1, "KHR_materials_emissive_strength")
local cc = load("ClearCoatCarPaint/glTF-Binary")
local clear = cc.materials[1].extensions and cc.materials[1].extensions.KHR_materials_clearcoat
t:check(clear and clear.clearcoatFactor ~= nil, "KHR_materials_clearcoat")
local tt = load("TextureTransformTest/glTF")
local nt = 0
for _, m in tt.materials do
if m.baseColorTexture and m.baseColorTexture.transform then
nt += 1
end
end
t:check(nt >= 5, "KHR_texture_transform on " .. nt .. " materials")
local lights = load("PointLightIntensityTest/glTF-Binary")
t:check(#lights.lights > 0 and lights.lights[1].type == "point", "KHR_lights_punctual")
local ms = load("MultipleScenes/glTF")
t:check(#ms.meta.gltf.scenes == 2, "multiple scenes kept")
local modes = load("MeshPrimitiveModes/glTF")
local seen = {}
for _, m in modes.meshes do
for _, p in m.primitives do
seen[p.mode] = true
end
end
t:check(seen.points and seen.lines and seen.line_loop and seen.line_strip and seen.triangle_strip and seen.triangle_fan, "every primitive mode")
local inter = load("BoxInterleaved/glTF-Binary")
t:check(inter.meshes[1].primitives[1].attributes.NORMAL.count == 24, "interleaved (byteStride) attributes")
-- quantized output declares KHR_mesh_quantization
local qglb = Gltf.encode(q, { binary = true }) :: buffer
t:check(string.find(buffer.tostring(qglb), "KHR_mesh_quantization", 1, true) ~= nil, "KHR_mesh_quantization written")
-- a Scene made by hand (an OBJ-like mesh with u8 colours and polygons) writes and reads back
local s = Types.Scene.new()
local p = Types.Scene.accessor(nil, "f32", 3, 4)
for v, xyz in { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 } } do
for k = 1, 3 do
buffer.writef32(p.data, ((v - 1) * 3 + k - 1) * 4, xyz[k])
end
end
local col = Types.Scene.accessor(nil, "unorm8", 3, 4)
local faces = Types.Scene.accessor(nil, "u32", 1, 1)
buffer.writeu32(faces.data, 0, 4)
local ind = Types.Scene.accessor(nil, "u32", 1, 4)
for k = 0, 3 do
buffer.writeu32(ind.data, k * 4, k)
end
local s2 = Types.Scene.fromPrimitive({ attributes = { POSITION = p, COLOR_0 = col }, indices = ind, faces = faces, mode = "polygons" }, "quad")
local out = Gltf.encode(s2, { binary = true }) :: buffer
local back = decode(out)
t:check(back and back.meshes[1].primitives[1].indices.count == 6 and back.meshes[1].primitives[1].attributes.COLOR_0.type == "unorm8", "polygons fan-triangulated, unorm8 VEC3 colours (padded stride)")
-- through the api: the destination's extension picks GLB
local viaApi = F.save(s2, nil, { format = "glb" })
t:check(viaApi and buffer.readstring(viaApi, 0, 4) == "glTF", "F.save format glb")
local viaApi2 = F.save(s2, nil, { format = "gltf" })
t:check(viaApi2 and buffer.readstring(viaApi2, 0, 1) == "{", "F.save format gltf")
local loaded = F.load(viaApi)
t:check(loaded and loaded.kind == "scene" and loaded.meta.source.format == "gltf", "F.load detects GLB")
end
-- errors
do
local _, e = decode("{ not json")
t:check(e and (e.code == Err.CORRUPT or e.code == Err.TRUNCATED), "bad JSON: " .. tostring(e))
local _, e2 = decode('{"asset": {"version": "1.0"}}')
t:check(e2 and e2.code == Err.UNSUPPORTED, "glTF 1: " .. tostring(e2))
local _, e3 = decode('{"asset": {"version": "2.0"}, "extensionsRequired": ["KHR_draco_mesh_compression"]}')
t:check(e3 and e3.code == Err.UNSUPPORTED, "Draco: " .. tostring(e3))
local c = byName["Box/glTF"]
local _, e4 = decode(c.data)
t:check(e4 and e4.code == Err.IO, "missing .bin: " .. tostring(e4))
local _, e5 = decode('{"asset": {"version": "2.0"}, "buffers": [{"byteLength": 4, "uri": "data:application/octet-stream;base64,AAAAAA=="}], "bufferViews": [{"buffer": 0, "byteLength": 4}], "accessors": [{"bufferView": 0, "componentType": 5126, "count": 2, "type": "SCALAR"}]}')
t:check(e5 and e5.code == Err.CORRUPT, "accessor past its view: " .. tostring(e5))
local glb = byName["Box/glTF-Binary"].data
local _, e6 = decode(string.sub(glb, 1, 100))
t:check(e6 and e6.code == Err.TRUNCATED, "truncated GLB: " .. tostring(e6))
local _, e7 = Gltf.encode({} :: any)
t:check(e7 and e7.code == Err.ARG, "encode junk")
local bad = Types.Scene.fromPrimitive({ attributes = { POSITION = Types.Scene.accessor(buffer.create(4), "f32", 3, 10) }, mode = "triangles" })
local _, e8 = Gltf.encode(bad)
t:check(e8 and e8.code == Err.ARG, "encode a short accessor: " .. tostring(e8))
end
-- fuzz
do
local samples = {}
for _, c in Cases do
if #c.data < 40000 then
table.insert(samples, c.data)
end
end
t:fuzz("decode", function(b: buffer)
local s = Gltf.decode(Bytes.reader(b))
if s then
Gltf.encode(s, { binary = true })
MeshOps.merge(s)
end
return s
end, samples, { mutations = 20 })
end
t:done()
+235
View File
@@ -0,0 +1,235 @@
-- model/obj tests: OBJ / MTL files (materials and texture maps, objects and groups, n-gons, negative indices, vertex
-- colours, continuations, lines and points, a concave polygon, assimp's exporter output) against assimp (meshes,
-- vertices, faces, bounds, materials) and trimesh (area, triangles); MTL mapping; ear clipping (MeshOps) against the
-- exact polygon area; round trips through the writer, and assimp / trimesh reading our output (obj_xcheck); errors;
-- the fuzz no-throw pass. Fixtures: tools/fixtures/obj.py.
local T = require("@tests/T")
local Obj = require("@formats/model/obj")
local MeshOps = require("@formats/ops/MeshOps")
local Bytes = require("@formats/core/Bytes")
local Err = require("@formats/core/Err")
local Cases = require("@tests/gen/obj_cases")
local Xcheck = require("@tests/gen/obj_xcheck")
local t = T.suite("obj")
local function decode(data: any, opts: any?): (any, any)
local b = if type(data) == "string" then buffer.fromstring(data) else data
return Obj.decode(Bytes.reader(b), opts)
end
t:eq(Obj.name, "obj", "name")
t:eq(Obj.category, "model", "category")
t:check(Obj.caps.decode and Obj.caps.encode, "caps")
local function near(a: number, b: number, eps: number): boolean
return math.abs(a - b) <= eps * math.max(1, math.abs(a), math.abs(b))
end
local function triArea(prim: any): number
local pos = prim.attributes.POSITION
local ind = prim.indices
local area = 0
local function P(i: number, k: number): number
return buffer.readf32(pos.data, (i * 3 + k) * 4)
end
for tri = 0, ind.count // 3 - 1 do
local a, b, c = buffer.readu32(ind.data, tri * 12), buffer.readu32(ind.data, tri * 12 + 4), buffer.readu32(ind.data, tri * 12 + 8)
local e1 = { P(b, 0) - P(a, 0), P(b, 1) - P(a, 1), P(b, 2) - P(a, 2) }
local e2 = { P(c, 0) - P(a, 0), P(c, 1) - P(a, 1), P(c, 2) - P(a, 2) }
local x, y, z = e1[2] * e2[3] - e1[3] * e2[2], e1[3] * e2[1] - e1[1] * e2[3], e1[1] * e2[2] - e1[2] * e2[1]
area += math.sqrt(x * x + y * y + z * z) / 2
end
return area
end
-- the counts assimp reports: meshes (= our primitives), vertices, faces (triangles + line segments + points)
local function counts(scene: any): (number, number, number)
local prims, verts, faces = 0, 0, 0
for _, m in scene.meshes do
for _, p in m.primitives do
prims += 1
verts += p.attributes.POSITION.count
local n = if p.indices then p.indices.count else p.attributes.POSITION.count
faces += if p.mode == "triangles" then n // 3 elseif p.mode == "lines" then n // 2 else n
end
end
return prims, verts, faces
end
local function checkAgainst(scene: any, assimp: any, trimesh: any?, label: string, vertices: boolean, fanArea: number)
local prims, verts, faces = counts(scene)
t:eq(prims, assimp.meshes, label .. ": meshes (assimp)")
if vertices then
t:eq(verts, assimp.vertices, label .. ": vertices (assimp)")
end
t:eq(faces, assimp.faces, label .. ": faces (assimp)")
local lo, hi = MeshOps.bounds(scene)
t:check(lo and hi, label .. ": bounds")
for k = 1, 3 do
t:check(near(lo[k], assimp.min[k], 1e-5) and near(hi[k], assimp.max[k], 1e-5), label .. ": bounds = assimp's")
end
local all = MeshOps.merge(scene)
t:check(near(triArea(all), fanArea, 1e-5), string.format("%s: area %g, exact fan area %g", label, triArea(all), fanArea))
if trimesh then
local merged = MeshOps.merge(scene)
t:eq(merged.indices.count // 3, trimesh.faces, label .. ": triangles (trimesh)")
t:check(near(triArea(merged), trimesh.area, 1e-5), string.format("%s: area %g, trimesh %g", label, triArea(merged), trimesh.area))
end
end
local byName = {}
for _, c in Cases do
byName[c.name] = c
local scene, err = decode(c.data, { files = c.files })
t:check(scene, c.name .. ": decode: " .. tostring(err))
checkAgainst(scene, c.assimp, c.trimesh, c.name, not c.noVertexCount, c.fanArea)
if #scene.materials > 0 then
t:eq(#scene.materials, c.assimp.materials, c.name .. ": materials (assimp)")
end
-- round trip through our writer
local files = {}
local out, eerr = Obj.encode(scene, { name = "rt.obj", files = files })
t:check(out, c.name .. ": encode: " .. tostring(eerr))
local back, berr = decode(out, { files = files })
t:check(back, c.name .. ": decode our OBJ: " .. tostring(berr))
local p1, v1, f1 = counts(scene)
local p2, v2, f2 = counts(back)
t:check(p1 == p2 and v1 == v2 and f1 == f2, c.name .. ": round trip counts")
local m1, m2 = MeshOps.merge(scene), MeshOps.merge(back)
for _, attr in { "POSITION", "TEXCOORD_0", "NORMAL", "COLOR_0" } do
local a, b = m1.attributes[attr], m2.attributes[attr]
t:check((a == nil) == (b == nil), c.name .. ": round trip has " .. attr)
if a and b then
t:check(buffer.tostring(a.data) == buffer.tostring(b.data), c.name .. ": round trip " .. attr .. " exact")
end
end
if m1.indices then
t:check(buffer.tostring(m1.indices.data) == buffer.tostring(m2.indices.data), c.name .. ": round trip indices")
end
t:eq(#back.materials, #scene.materials, c.name .. ": round trip materials")
end
-- the reference tools read our output like the original
for _, x in Xcheck do
local orig = byName[string.sub(x.name, 4)]
t:check(orig ~= nil, x.name .. ": a case")
t:eq(x.assimp.faces, orig.assimp.faces, x.name .. ": assimp faces of our file")
if not orig.noVertexCount then
t:eq(x.assimp.vertices, orig.assimp.vertices, x.name .. ": assimp vertices of our file")
end
t:eq(x.assimp.materials, orig.assimp.materials, x.name .. ": assimp materials of our file")
for k = 1, 3 do
t:check(near(x.assimp.min[k], orig.assimp.min[k], 1e-5) and near(x.assimp.max[k], orig.assimp.max[k], 1e-5), x.name .. ": assimp bounds of our file")
end
if orig.trimesh then
t:check(near(x.trimesh.area, orig.trimesh.area, 1e-5) and x.trimesh.faces == orig.trimesh.faces, x.name .. ": trimesh area of our file")
end
end
t:note("%d files match assimp / trimesh; %d of our files read back by assimp / trimesh", #Cases, #Xcheck)
-- the cube in detail: nodes, materials, textures
do
local c = byName["cube.obj"]
local s = decode(c.data, { files = c.files })
t:eq(#s.roots, 1, "one object")
local root = s.nodes[s.roots[1]]
t:check(root.name == "Cube" and #root.children == 2 and root.mesh == nil, "the object holds two groups")
t:check(s.nodes[root.children[1]].name == "top" and s.nodes[root.children[2]].name == "bottom", "group names")
local red, blue = s.materials[1], s.materials[2]
t:check(red.name == "red" and red.baseColor[1] == 1 and red.baseColor[2] == 0 and red.metallic == 0, "red: Kd, not metallic")
t:check(near(red.roughness, math.sqrt(2 / 52), 1e-9), "red: roughness from Ns")
local tex = s.textures[red.baseColorTexture.texture]
t:check(tex.uri == "textures/tex.png" and tex.mime == "image/png" and tex.data and buffer.len(tex.data) > 30, "map_Kd: uri, mime, bytes through opts.files")
t:check(red.baseColorTexture.transform.scale[1] == 2 and red.baseColorTexture.transform.offset[1] == 0.5, "map_Kd -s / -o")
t:check(red.normalTexture and red.normalTexture.scale == 0.5, "map_Bump -bm")
t:check(red.extras.obj.values.Ns[1] == 50 and red.extras.obj.values.illum[1] == 2, "Phong values in extras")
t:check(blue.baseColor[4] == 0.5 and blue.alphaMode == "blend" and blue.roughness == 0.25 and blue.metallic == 1 and blue.emissive[3] == 0.3, "blue: d, Pr, Pm, Ke")
t:check(s.nodes[root.children[1]].extras.obj.smoothing == "1", "smoothing group kept")
-- the uv flip
local top = s.meshes[s.nodes[root.children[1]].mesh].primitives[1]
t:check(top.attributes.TEXCOORD_0 ~= nil and buffer.readf32(top.attributes.TEXCOORD_0.data, 4) == 1, "vt 0 0 -> (0, 1) (top-left origin)")
local s2 = decode(c.data, { files = c.files, flipV = false })
local top2 = s2.meshes[s2.nodes[s2.nodes[s2.roots[1]].children[1]].mesh].primitives[1]
t:check(buffer.readf32(top2.attributes.TEXCOORD_0.data, 4) == 0, "flipV = false")
-- without the MTL: named default materials, the library listed as missing
local s3 = decode(c.data)
t:check(#s3.materials == 2 and s3.meta.source.missingMtl[1] == "cube.mtl", "missing mtllib")
-- through opts.mtl / resolve
local s4 = decode(c.data, { mtl = c.files["cube.mtl"] })
t:check(s4.materials[1].baseColor[1] == 1 and s4.textures[1].data == nil, "opts.mtl (texture bytes not found)")
local asked = {}
local s5 = decode(c.data, { resolve = function(uri: string): any
table.insert(asked, uri)
return c.files[uri]
end })
t:check(s5.materials[2].baseColor[4] == 0.5 and table.find(asked, "cube.mtl") and table.find(asked, "textures/tex.png"), "opts.resolve")
-- the MTL written back keeps the maps and their options
local files = {}
Obj.encode(s, { name = "x.obj", files = files })
local mtl = files["x.mtl"]
t:check(type(mtl) == "string" and string.find(mtl, "map_Kd -o 0.5 0 -s 2 2 textures/tex.png", 1, true) ~= nil, "MTL map_Kd written: " .. tostring(mtl))
t:check(string.find(mtl, "newmtl blue", 1, true) and string.find(mtl, "\nd 0.5", 1, true), "MTL blue written")
t:check(files["textures/tex.png"] ~= nil, "texture bytes written to opts.files")
end
-- polygons: triangulate = false keeps them; ear clipping gets the concave area right, the fan does not
do
local c = byName["concave.obj"]
local s = decode(c.data, { triangulate = false })
local p = s.meshes[1].primitives[1]
t:check(p.mode == "polygons" and p.faces.count == 2 and p.indices.count == 14, "polygons kept")
local tri = MeshOps.triangulate(p) :: any
t:check(near(triArea(tri), c.polygonArea, 1e-9), "ear clipping area " .. triArea(tri) .. " = " .. c.polygonArea)
local fan = MeshOps.triangulate(p, { method = "fan" }) :: any
t:check(near(triArea(fan), c.trimesh.area, 1e-9), "fan area = trimesh's (fan) area")
-- n-gons written as n-gons
local out = Obj.encode(s) :: buffer
t:check(string.find(buffer.tostring(out), "\nf 7 8 9 10 11 12 13 14", 1, true) ~= nil, "an octagon written as one face")
local back = decode(out, { triangulate = false })
t:eq(back.meshes[1].primitives[1].faces.count, 2, "polygons round trip")
end
-- lines and points
do
local s = decode(byName["wire.obj"].data)
local modes = {}
for _, p in s.meshes[1].primitives do
modes[p.mode] = p
end
t:check(modes.lines and modes.lines.indices.count == 8 and modes.points and modes.triangles, "l (polyline -> 4 segments), p, f")
end
-- errors
do
local _, e = decode("v 0 0 0\nf 1 2 3\n")
t:check(e and e.code == Err.CORRUPT, "index out of range: " .. tostring(e))
local _, e2 = decode("v 0 0\n")
t:check(e2 and e2.code == Err.CORRUPT, "short vertex: " .. tostring(e2))
local _, e3 = decode(byName["random.obj"].data, { maxVertices = 10 })
t:check(e3 and e3.code == Err.LIMIT, "maxVertices: " .. tostring(e3))
local _, e4 = Obj.encode({} :: any)
t:check(e4 and e4.code == Err.ARG, "encode junk")
t:check(Obj.sniff(Bytes.reader(buffer.fromstring(byName["cube.obj"].data))) > 0, "sniff an OBJ")
t:eq(Obj.sniff(Bytes.reader(buffer.fromstring("\137PNG\r\n\26\n"))), 0, "sniff a PNG")
local empty = decode("# nothing\n")
t:check(empty and #empty.nodes == 0, "an empty file is an empty scene")
end
-- fuzz
do
local samples = {}
for _, c in Cases do
table.insert(samples, c.data)
end
t:fuzz("decode", function(b: buffer)
local s = Obj.decode(Bytes.reader(b), { triangulate = false })
if s then
Obj.encode(s)
MeshOps.merge(s)
end
return s
end, samples, { mutations = 40 })
end
t:done()
+214
View File
@@ -0,0 +1,214 @@
-- model/off tests: OFF files written by trimesh and by the generator (COFF integer / float colours, RGB / RGBA, NOFF,
-- STOFF, STCNOFF, face colours, colormap indices, comments, counts on the header line, CRLF, tabs, n-gons, a point
-- cloud) against the values they were written from (positions cross-checked with trimesh); our encoder's output read
-- back by trimesh, assimp and the generator's reader (verdicts from the fixture step); round trips (polygons,
-- triangles, face colours, scenes); the contract, error codes and the fuzz no-throw pass. Fixtures:
-- tools/fixtures/off.py.
local T = require("@tests/T")
local Off = require("@formats/model/off")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Fx = require("@tests/gen/off")
local Scenes = require("@tests/gen/off_scenes")
local t = T.suite("off")
local function decode(data: any, opts: any?): (any, any)
local b = if type(data) == "string" then buffer.fromstring(data) else data
return Off.decode(Bytes.reader(b), opts)
end
local function same(a: any, b: any): boolean
if a == nil or b == nil then
return a == b
end
return a.type == b.type and a.components == b.components and a.count == b.count and buffer.tostring(a.data) == buffer.tostring(b.data)
end
-- 1. the contract
t:eq(Off.name, "off", "name")
t:eq(Off.category, "model", "category")
t:check(table.find(Off.extensions, "off") ~= nil, "extensions")
t:check(Off.caps.decode and Off.caps.encode, "caps")
-- 2. every fixture against the values it was written from; 3. round trips
for _, c in Fx.cases do
local label = c.name
local scene, err = decode(c.data)
t:check(scene, label .. ": " .. tostring(err))
local src = scene.meta.source
t:check(src.format == "off" and src.keyword == c.keyword and src.vertices == c.vertices and src.faces == c.faces, label .. ": meta.source")
t:eq(src.colormap, c.colormap, label .. ": colormap flag")
local p = scene.meshes[1].primitives[1]
local A = p.attributes
t:eq(Crc32.of(A.POSITION.data), c.pos_crc, label .. ": POSITION crc")
t:check((A.NORMAL and Crc32.of(A.NORMAL.data)) == c.nrm_crc, label .. ": NORMAL")
t:check((A.TEXCOORD_0 and Crc32.of(A.TEXCOORD_0.data)) == c.tex_crc, label .. ": TEXCOORD_0")
if c.color then
t:check(A.COLOR_0 and A.COLOR_0.type == c.color.type and A.COLOR_0.components == 4, label .. ": COLOR_0 type")
t:eq(Crc32.of(A.COLOR_0.data), c.color.crc, label .. ": COLOR_0 crc")
else
t:check(A.COLOR_0 == nil, label .. ": no COLOR_0")
end
local ex = p.extras or {}
if c.faceColors then
t:check(ex.faceColors and ex.faceColors.type == c.faceColors.type and ex.faceColors.count == c.faces, label .. ": faceColors type")
t:eq(Crc32.of(ex.faceColors.data), c.faceColors.crc, label .. ": faceColors crc")
else
t:check(ex.faceColors == nil, label .. ": no faceColors")
end
if c.faces == 0 then
t:check(p.mode == "points" and p.indices == nil, label .. ": a point cloud")
else
t:eq(p.mode, "triangles", label .. ": mode")
t:eq(p.indices.count, c.tris * 3, label .. ": index count")
t:eq(Crc32.of(p.indices.data), if c.allTri then c.corners_crc else c.tri_crc, label .. ": indices crc")
if c.faceColors and not c.allTri then
t:eq(Crc32.of(ex.faceOfTriangle.data), c.fot_crc, label .. ": faceOfTriangle")
end
end
t:eq(Off.sniff(Bytes.reader(buffer.fromstring(c.data))), 0.9, label .. ": sniff")
-- polygons kept
local poly = decode(c.data, { triangulate = false })
local pp = poly.meshes[1].primitives[1]
if c.faces > 0 and not c.allTri then
t:eq(pp.mode, "polygons", label .. ": polygons")
t:eq(Crc32.of(pp.indices.data), c.corners_crc, label .. ": corners")
t:eq(Crc32.of(pp.faces.data), c.sizes_crc, label .. ": sizes")
end
-- round trips: polygons in, polygons out; triangles in, triangles out (face colours through faceOfTriangle)
for _, s in { poly, scene } do
local out, eerr = Off.encode(s)
t:check(out, label .. ": encode: " .. tostring(eerr))
local back, berr = decode(out, { triangulate = false })
t:check(back, label .. ": decode our output: " .. tostring(berr))
local bp, sp = back.meshes[1].primitives[1], s.meshes[1].primitives[1]
for name, a in sp.attributes do
t:check(same(bp.attributes[name], a), label .. ": " .. name .. " round trip")
end
t:eq(bp.mode, sp.mode, label .. ": mode round trip")
t:check(same(bp.indices, sp.indices) and same(bp.faces, sp.faces), label .. ": faces round trip")
local sfc = sp.extras and sp.extras.faceColors
local bfc = bp.extras and bp.extras.faceColors
if sfc and sp.extras.faceOfTriangle then
t:eq(bfc.count, sp.extras.faceOfTriangle.count, label .. ": a colour per triangle")
else
t:check(same(bfc, sfc), label .. ": faceColors round trip")
end
end
end
t:note("%d files match their source values and round-trip", #Fx.cases)
for _, v in Fx.ours do
t:check(v.ok, "trimesh / assimp read our " .. v.name .. ": " .. v.detail)
end
t:note("%d encodings read back by trimesh, assimp and the generator", #Fx.ours)
-- the encoder scenes: decode(encode()) gives the scene back (identity transforms)
local function build(spec: any): Types.Scene
local scene = Types.Scene.new()
for i, m in spec.meshes do
local prims = {}
for _, p in m.prims do
local attrs = {}
for name, a in p.attrs do
attrs[name] = Types.Scene.accessor(buffer.fromstring(a[3]), a[1], a[2], p.count)
end
local prim: any = { attributes = attrs, mode = p.mode }
if p.indices then
prim.indices = Types.Scene.accessor(buffer.fromstring(p.indices), "u32", 1, #p.indices // 4)
end
if p.faces then
prim.faces = Types.Scene.accessor(buffer.fromstring(p.faces), "u32", 1, #p.faces // 4)
end
if p.faceColors then
prim.extras = { faceColors = Types.Scene.accessor(buffer.fromstring(p.faceColors), "unorm8", 4, #p.faceColors // 4) }
end
table.insert(prims, prim)
end
scene.meshes[i] = { primitives = prims }
end
for i, n in spec.nodes do
scene.nodes[i] = { mesh = n.mesh, children = n.children or {}, translation = n.translation, rotation = n.rotation, scale = n.scale, matrix = n.matrix }
end
scene.roots = spec.roots
return scene
end
for _, spec in Scenes do
local scene = build(spec)
local sp = scene.meshes[1].primitives[1]
local out = Off.encode(scene) :: buffer
local back = decode(out, { triangulate = false })
local bp = back.meshes[1].primitives[1]
if spec.name ~= "polys" then
for name, a in sp.attributes do
t:check(same(bp.attributes[name], a), spec.name .. ": " .. name .. " round trip")
end
end
t:eq(bp.mode, sp.mode, spec.name .. ": mode")
t:check(same(bp.indices, sp.indices) and same(bp.faces, sp.faces), spec.name .. ": faces")
t:check(same(bp.extras and bp.extras.faceColors, sp.extras and sp.extras.faceColors), spec.name .. ": face colours")
end
do
local scene = build(Scenes[1])
local plain = buffer.tostring(Off.encode(scene, { colors = false, normals = false, texcoords = false }) :: buffer)
t:eq(string.sub(plain, 1, 4), "OFF\n", "plain OFF")
t:eq(string.sub(buffer.tostring(Off.encode(scene, { colors = false }) :: buffer), 1, 6), "STNOFF", "no colours")
local cm = buffer.tostring(Off.encode(scene, { comment = "made\nhere" }) :: buffer)
t:check(string.find(cm, "STCNOFF\n# made here\n", 1, true) ~= nil, "comment option")
end
-- 4. error codes
do
local function code(s: string, opts: any?): string?
local _, e = decode(s, opts)
return e and e.code
end
t:check(decode("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n"), "a minimal file")
t:eq(code("PFF\n3 1 0\n"), Err.CORRUPT, "bad keyword")
t:eq(code("4OFF\n1 0 0\n0 0 0 1\n"), Err.UNSUPPORTED, "4OFF")
t:eq(code("nOFF\n4\n1 0 0\n0 0 0 0\n"), Err.UNSUPPORTED, "nOFF")
t:eq(code("OFF BINARY\n"), Err.UNSUPPORTED, "binary OFF")
t:eq(code("OFF\n"), Err.TRUNCATED, "no counts")
t:eq(code("# nothing\n\n"), Err.TRUNCATED, "empty")
t:eq(code("OFF\nx 1 0\n"), Err.CORRUPT, "bad counts")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n"), Err.TRUNCATED, "face missing")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n3 0 1 3\n"), Err.CORRUPT, "index out of range")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n4 0 1 2\n"), Err.CORRUPT, "short face")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 q 0\n0 1 0\n3 0 1 2\n"), Err.CORRUPT, "bad number")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0\n0 1 0\n3 0 1 2\n"), Err.CORRUPT, "short vertex")
t:eq(code("COFF\n3 1 0\n0 0 0 1 2\n1 0 0 1 2\n0 1 0 1 2\n3 0 1 2\n"), Err.CORRUPT, "two colour values")
t:eq(code("COFF\n3 1 0\n0 0 0 300 2 3\n1 0 0 1 2 3\n0 1 0 1 2 3\n3 0 1 2\n"), Err.CORRUPT, "colour over 255")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n", { maxVertices = 2 }), Err.LIMIT, "maxVertices")
t:eq(code("OFF\n3 1 0\n0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n", { maxFaces = 0 }), Err.LIMIT, "maxFaces")
t:eq(code("OFF\n10000000 0 0\n1 2 3\n"), Err.TRUNCATED, "counts over the data")
local _, a1 = Off.encode({} :: any)
t:check(a1 and a1.code == Err.ARG, "encode a non-scene: " .. tostring(a1))
local nan = Types.Scene.fromPrimitive({ attributes = { POSITION = Types.Scene.accessor(nil, "f32", 3, 1) }, mode = "points" })
buffer.writef32(nan.meshes[1].primitives[1].attributes.POSITION.data, 0, math.huge)
local _, a2 = Off.encode(nan)
t:check(a2 and a2.code == Err.ARG, "infinite coordinate: " .. tostring(a2))
t:eq(Off.sniff(Bytes.reader(buffer.fromstring("solid x\n"))), 0, "sniff an STL")
end
-- 5. fuzz
do
local samples = {}
for _, c in Fx.cases do
table.insert(samples, c.data)
end
t:fuzz("decode", function(b: buffer)
return Off.decode(Bytes.reader(b))
end, samples, { mutations = 20 })
t:fuzz("decode polygons + re-encode", function(b: buffer)
local s = Off.decode(Bytes.reader(b), { triangulate = false })
if s then
return Off.encode(s)
end
return nil
end, samples, { mutations = 6, garbage = 20 })
end
t:done()
+379
View File
@@ -0,0 +1,379 @@
-- model/ply tests: files written by plyfile (ascii / binary LE / BE, every property type and spelling, odd orders,
-- n-gons up to 300 vertices, face properties and lists, extra elements, comments, point clouds) and by assimp, against
-- plyfile's reading mapped to the Scene conventions (CRC-32 of every attribute, the indices triangulated or as
-- polygons, face data, raw elements); our encoder's output read back by plyfile and assimp (verdicts from the fixture
-- step); round trips in every encoding (fixtures and generated scenes, polygons and points); the contract, error
-- codes, the fuzz no-throw pass and a binary decode throughput note. Fixtures: tools/fixtures/ply.py.
local T = require("@tests/T")
local Ply = require("@formats/model/ply")
local Bytes = require("@formats/core/Bytes")
local Crc32 = require("@formats/core/Crc32")
local Err = require("@formats/core/Err")
local Types = require("@formats/Types")
local Fx = require("@tests/gen/ply")
local Scenes = require("@tests/gen/ply_scenes")
local t = T.suite("ply")
local function decode(data: any, opts: any?): (any, any)
local b = if type(data) == "string" then buffer.fromstring(data) else data
return Ply.decode(Bytes.reader(b), opts)
end
local ENCODINGS = { "ascii", "binary_little_endian", "binary_big_endian" }
-- 1. the contract
t:eq(Ply.name, "ply", "name")
t:eq(Ply.category, "model", "category")
t:check(table.find(Ply.extensions, "ply") ~= nil, "extensions")
t:check(Ply.caps.decode and Ply.caps.encode, "caps")
-- a decoded scene against a reference case (triangulated)
local function verify(scene: any, c: any, label: string)
t:check(scene.kind == "scene" and #scene.meshes == 1 and #scene.meshes[1].primitives == 1, label .. ": one primitive")
local p = scene.meshes[1].primitives[1]
local n = 0
for name, want in c.attrs do
local a = p.attributes[name]
t:check(a ~= nil, label .. ": attribute " .. name)
t:eq(a.type, want.type, label .. ": " .. name .. " type")
t:eq(a.components, want.components, label .. ": " .. name .. " components")
t:eq(a.count, c.vertices, label .. ": " .. name .. " count")
t:eq(Crc32.of(a.data), want.crc, label .. ": " .. name .. " crc")
n += 1
end
local m = 0
for _ in p.attributes do
m += 1
end
t:eq(m, n, label .. ": no other attributes")
if c.faces > 0 then
t:eq(p.mode, "triangles", label .. ": mode")
t:eq(Crc32.of(p.indices.data), if c.allTri then c.corners_crc else c.tri_crc, label .. ": indices crc")
t:eq(p.indices.count, c.tris * 3, label .. ": index count")
local fa = c.faceAttributes
local ex = p.extras or {}
if next(fa) ~= nil and not c.allTri then
t:eq(Crc32.of(ex.faceOfTriangle.data), c.fot_crc, label .. ": faceOfTriangle")
else
t:check(ex.faceOfTriangle == nil, label .. ": no faceOfTriangle")
end
for name, want in fa do
if want.list then
local fl = ex.faceLists[name]
t:eq(Crc32.of(fl.sizes.data), want.sizes_crc, label .. ": face list " .. name .. " sizes")
t:eq(Crc32.of(fl.items.data), want.items_crc, label .. ": face list " .. name .. " items")
else
local a = ex.faceAttributes[name]
t:eq(a.type, want.type, label .. ": face attribute " .. name .. " type")
t:eq(Crc32.of(a.data), want.crc, label .. ": face attribute " .. name)
end
end
else
t:eq(p.mode, "points", label .. ": a point cloud")
t:check(p.indices == nil, label .. ": no indices")
end
local meta = scene.meta.ply
t:eq(#meta.comments, #c.comments, label .. ": comment count")
for i, s in c.comments do
t:eq(meta.comments[i], s, label .. ": comment")
end
t:eq(#meta.objInfo, #c.objInfo, label .. ": obj_info count")
for i, s in c.objInfo do
t:eq(meta.objInfo[i], s, label .. ": obj_info")
end
t:eq(table.concat(meta.order, ","), table.concat(c.order, ","), label .. ": element order")
t:eq(#meta.elements, #c.elements, label .. ": raw elements")
for i, want in c.elements do
local el = meta.elements[i]
t:eq(el.name, want.name, label .. ": element name")
t:eq(el.count, want.count, label .. ": element count")
for k, wp in want.props do
local pr = el.properties[k]
t:eq(pr.name, wp.name, label .. ": element property")
if wp.list then
t:eq(Crc32.of(pr.sizes), wp.sizes_crc, label .. ": " .. el.name .. "." .. pr.name .. " sizes")
t:eq(Crc32.of(pr.values), wp.values_crc, label .. ": " .. el.name .. "." .. pr.name .. " items")
else
t:eq(Crc32.of(pr.values), wp.crc, label .. ": " .. el.name .. "." .. pr.name)
end
end
end
end
-- 2. every fixture against plyfile; 3. round trips of every fixture in every encoding
for _, c in Fx.cases do
local label = c.name
local scene, err = decode(c.data)
t:check(scene, label .. ": " .. tostring(err))
t:eq(scene.meta.source.format, "ply", label .. ": meta.source.format")
t:eq(scene.meta.source.encoding, c.encoding, label .. ": encoding")
t:eq(scene.meta.source.vertices, c.vertices, label .. ": vertices")
t:eq(scene.meta.source.faces, c.faces, label .. ": faces")
verify(scene, c, label)
t:eq(Ply.sniff(Bytes.reader(buffer.fromstring(c.data))), 1, label .. ": sniff")
local big = buffer.create(#c.data + 9)
buffer.writestring(big, 4, c.data)
local s2 = Ply.decode(Bytes.reader(big, 4, #c.data))
t:check(s2 and Crc32.of(s2.meshes[1].primitives[1].attributes.POSITION.data) == c.attrs.POSITION.crc, label .. ": decode from a sub-range")
-- polygons kept
local poly = decode(c.data, { triangulate = false })
local pp = poly.meshes[1].primitives[1]
if c.faces > 0 and not c.allTri then
t:eq(pp.mode, "polygons", label .. ": polygons mode")
t:eq(Crc32.of(pp.indices.data), c.corners_crc, label .. ": polygon corners")
t:eq(Crc32.of(pp.faces.data), c.sizes_crc, label .. ": polygon sizes")
end
for _, enc in ENCODINGS do
local out, eerr = Ply.encode(scene, { format = enc })
t:check(out, label .. " -> " .. enc .. ": " .. tostring(eerr))
local back, berr = decode(out)
t:check(back, label .. " -> " .. enc .. ": decode: " .. tostring(berr))
t:eq(back.meta.source.encoding, enc, label .. " -> " .. enc .. ": encoding")
local cc = table.clone(c)
if c.faces > 0 and not c.allTri then
-- written as triangles: the face data goes through faceOfTriangle, one row per triangle
cc.faces, cc.allTri, cc.corners_crc = c.tris, true, c.tri_crc
cc.faceAttributes = {}
local bp = back.meshes[1].primitives[1]
local fa = bp.extras and bp.extras.faceAttributes
for name in c.faceAttributes do
if not c.faceAttributes[name].list then
t:check(fa and fa[name] and fa[name].count == c.tris, label .. ": face attribute per triangle")
end
end
end
verify(back, cc, label .. " -> " .. enc)
-- polygons in, polygons out
local pout = Ply.encode(poly, { format = enc }) :: buffer
local pback = decode(pout, { triangulate = false })
verify(decode(pout), c, label .. " -> " .. enc .. " (polygons)")
local bp = pback.meshes[1].primitives[1]
t:eq(bp.mode, pp.mode, label .. ": polygons round trip mode")
if pp.indices then
t:check(buffer.tostring(bp.indices.data) == buffer.tostring(pp.indices.data), label .. ": polygons round trip indices")
end
if pp.faces then
t:check(buffer.tostring(bp.faces.data) == buffer.tostring(pp.faces.data), label .. ": polygons round trip sizes")
end
-- binary output of a binary input with the same byte order is the same file, header included
if enc == c.encoding and enc ~= "ascii" and string.sub(label, 1, 6) ~= "assimp" then
t:check(buffer.tostring(pout) == c.data, label .. ": byte-exact re-encode")
end
end
end
t:note("%d files match plyfile and round-trip in 3 encodings", #Fx.cases)
for _, v in Fx.ours do
t:check(v.ok, "plyfile / assimp read our " .. v.name .. ": " .. v.detail)
end
t:note("%d encodings read back by plyfile and assimp", #Fx.ours)
-- the encoder scenes: decode(encode()) against the properties computed by the generator
local function build(spec: any): Types.Scene
local scene = Types.Scene.new()
for i, m in spec.meshes do
local prims = {}
for _, p in m.prims do
local attrs = {}
for name, a in p.attrs do
attrs[name] = Types.Scene.accessor(buffer.fromstring(a[3]), a[1], a[2], p.count)
end
local prim: any = { attributes = attrs, mode = p.mode }
if p.indices then
prim.indices = Types.Scene.accessor(buffer.fromstring(p.indices), "u32", 1, #p.indices // 4)
end
if p.faces then
prim.faces = Types.Scene.accessor(buffer.fromstring(p.faces), "u32", 1, #p.faces // 4)
end
table.insert(prims, prim)
end
scene.meshes[i] = { primitives = prims }
end
for i, n in spec.nodes do
scene.nodes[i] = { mesh = n.mesh, children = n.children or {}, translation = n.translation, rotation = n.rotation, scale = n.scale, matrix = n.matrix }
end
scene.roots = spec.roots
return scene
end
local ATTR_OF: { [string]: { string | number } } = {
x = { "POSITION", 0 },
y = { "POSITION", 1 },
z = { "POSITION", 2 },
nx = { "NORMAL", 0 },
ny = { "NORMAL", 1 },
nz = { "NORMAL", 2 },
red = { "COLOR_0", 0 },
green = { "COLOR_0", 1 },
blue = { "COLOR_0", 2 },
alpha = { "COLOR_0", 3 },
s = { "TEXCOORD_0", 0 },
t = { "TEXCOORD_0", 1 },
}
local READ: { [string]: (buffer, number) -> number } = { ["<f4"] = buffer.readf32, u1 = buffer.readu8, ["<u2"] = buffer.readu16 }
local SIZE: { [string]: number } = { ["<f4"] = 4, u1 = 1, ["<u2"] = 2 }
for _, spec in Scenes do
local scene = build(spec)
for _, enc in ENCODINGS do
local label = spec.name .. "/" .. enc
local out, err = Ply.encode(scene, { format = enc })
t:check(out, label .. ": " .. tostring(err))
local back = decode(out, { triangulate = false })
local p = back.meshes[1].primitives[1]
for _, prop in spec.props do
local where = ATTR_OF[prop.name]
local a = if where then p.attributes[where[1]] else p.attributes["_" .. prop.name]
t:check(a ~= nil, label .. ": property " .. prop.name)
local comp = if where then where[2] :: number else 0
local rd, sz = READ[prop.dtype], SIZE[prop.dtype]
local vals = buffer.fromstring(prop.values)
local n = buffer.len(vals) // sz
t:eq(a.count, n, label .. ": " .. prop.name .. " count")
local csz = Types.COMPONENT_SIZE[a.type]
for i = 0, n - 1 do
local got = rd(a.data, (i * a.components + comp) * csz)
local want = rd(vals, i * sz)
if prop.tol then
t:check(math.abs(got - want) <= prop.tol, label .. ": " .. prop.name .. " value")
else
t:eq(got, want, label .. ": " .. prop.name .. " value")
end
end
end
if spec.faces then
local sizes = buffer.fromstring(spec.faceSizes)
local corners = buffer.fromstring(spec.faceCorners)
t:check(buffer.tostring(p.indices.data) == buffer.tostring(corners), label .. ": corners")
if p.mode == "polygons" then
t:check(buffer.tostring(p.faces.data) == buffer.tostring(sizes), label .. ": face sizes")
else
t:eq(p.mode, "triangles", label .. ": mode")
t:eq(p.indices.count, buffer.len(sizes) // 4 * 3, label .. ": all triangles")
end
else
t:eq(p.mode, "points", label .. ": points")
end
-- identity scenes: every attribute comes back as it was (COLOR_0 of the merged scene filled with white)
if not spec.transformed and #spec.meshes == 1 then
for name, a in scene.meshes[1].primitives[1].attributes do
t:check(buffer.tostring(p.attributes[name].data) == buffer.tostring(a.data), label .. ": " .. name .. " round trip")
t:eq(p.attributes[name].type, a.type, label .. ": " .. name .. " type")
end
end
end
end
-- options and meta: comments, extra elements written back, faceAttributes of a triangulated mesh
do
local scene = build(Scenes[1])
scene.meta.ply = { comments = { "first" }, objInfo = { "info line" } }
local out = Ply.encode(scene, { format = "ascii", comments = { "second" } }) :: buffer
local s = buffer.tostring(out)
t:check(string.find(s, "comment first\ncomment second\nobj_info info line\n", 1, true) ~= nil, "comments and obj_info")
local back = decode(out)
t:eq(back.meta.ply.comments[2], "second", "comment option")
local _, e = Ply.encode(scene, { format = "binary" } :: any)
t:check(e and e.code == Err.ARG, "bad format option: " .. tostring(e))
-- the default is binary little endian
t:check(string.find(buffer.tostring(Ply.encode(scene) :: buffer), "format binary_little_endian 1.0", 1, true) ~= nil, "default encoding")
-- a scene without nodes uses its meshes
local bare = Types.Scene.new()
bare.meshes[1] = scene.meshes[1]
t:eq(decode(Ply.encode(bare) :: buffer).meta.source.vertices, 20, "a scene without nodes")
end
-- 4. error codes
do
local function code(s: string, opts: any?): string?
local _, e = decode(s, opts)
return e and e.code
end
local H = "ply\nformat ascii 1.0\nelement vertex 3\nproperty float x\nproperty float y\nproperty float z\nelement face 1\nproperty list uchar int vertex_indices\nend_header\n"
t:check(decode(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n"), "a minimal ascii file")
t:eq(code("plx\n"), Err.CORRUPT, "bad signature")
t:eq(code("ply\nformat ascii 2.0\nend_header\n"), Err.UNSUPPORTED, "version 2")
t:eq(code("ply\nformat text 1.0\nend_header\n"), Err.UNSUPPORTED, "unknown format")
t:eq(code("ply\nformat ascii 1.0\nelement vertex 1\n"), Err.TRUNCATED, "no end_header")
t:eq(code("ply\nformat ascii 1.0\nproperty float x\nend_header\n"), Err.CORRUPT, "property before element")
t:eq(code("ply\nformat ascii 1.0\nelement vertex 1\nproperty float x\nproperty float x\nend_header\n0 0\n"), Err.CORRUPT, "duplicate property")
t:eq(code("ply\nformat ascii 1.0\nelement vertex 1\nproperty quad x\nend_header\n"), Err.CORRUPT, "unknown type")
t:eq(code("ply\nformat ascii 1.0\nelement vertex 1\nproperty list uchar float x\nend_header\n1 0\n"), Err.UNSUPPORTED, "list in the vertex element")
t:eq(code("ply\nformat ascii 1.0\nbanana\nend_header\n"), Err.CORRUPT, "unknown header line")
t:eq(code("ply\nformat ascii 1.0\nelement face 0\nend_header\n"), Err.CORRUPT, "no vertex element")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 3\n"), Err.CORRUPT, "ascii index out of range")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 -1\n"), Err.CORRUPT, "negative index")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1\n"), Err.TRUNCATED, "ascii cut")
t:eq(code(H .. "0 0 0\n1 zz 0\n0 1 0\n3 0 1 2\n"), Err.CORRUPT, "bad number")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n300 0 1 2\n"), Err.CORRUPT, "uchar count over 255")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 2.5\n"), Err.CORRUPT, "fractional index")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n", { maxVertices = 2 }), Err.LIMIT, "maxVertices")
t:eq(code(H .. "0 0 0\n1 0 0\n0 1 0\n3 0 1 2\n", { maxFaces = 0 }), Err.LIMIT, "maxFaces")
t:eq(code("ply\nformat ascii 1.0\nelement vertex 1000000\nproperty float x\nend_header\n1\n"), Err.TRUNCATED, "ascii count over the data")
local B = "ply\nformat binary_little_endian 1.0\nelement vertex 3\nproperty float x\nproperty float y\nproperty float z\nelement face 1\nproperty list uchar int vertex_indices\nend_header\n"
local verts = string.rep("\0", 36)
t:check(decode(B .. verts .. "\3\0\0\0\0\1\0\0\0\2\0\0\0"), "a minimal binary file")
t:eq(code(B .. verts .. "\3\0\0\0\0\1\0\0\0\3\0\0\0"), Err.CORRUPT, "binary index out of range")
t:eq(code(B .. verts .. "\3\0\0\0\0\1\0\0\0\2\0\0"), Err.TRUNCATED, "binary list cut")
t:eq(code(B .. string.sub(verts, 1, 30)), Err.TRUNCATED, "binary rows cut")
t:eq(code("ply\nformat binary_big_endian 1.0\nelement vertex 4000000000\nproperty float x\nend_header\n", { maxVertices = 2 ^ 40, maxFaces = 2 ^ 40 }), Err.TRUNCATED, "huge count")
local _, a1 = Ply.encode({} :: any)
t:check(a1 and a1.code == Err.ARG, "encode a non-scene: " .. tostring(a1))
local noPos = Types.Scene.fromPrimitive({ attributes = {}, mode = "points" })
local _, a2 = Ply.encode(noPos)
t:check(a2 and a2.code == Err.ARG, "no POSITION: " .. tostring(a2))
end
-- 5. fuzz
do
local samples = {}
for _, c in Fx.cases do
if #c.data < 30000 then
table.insert(samples, c.data)
end
end
t:fuzz("decode", function(b: buffer)
return Ply.decode(Bytes.reader(b))
end, samples, { mutations = 30 })
t:fuzz("decode polygons + re-encode", function(b: buffer)
local s = Ply.decode(Bytes.reader(b), { triangulate = false })
if s then
return Ply.encode(s, { format = "ascii" })
end
return nil
end, samples, { mutations = 6, garbage = 20 })
end
-- throughput: a 500 x 500 grid (250k vertices, 498k triangles), binary little endian
do
local W = 500
local pos = buffer.create(W * W * 12)
for i = 0, W * W - 1 do
buffer.writef32(pos, i * 12, i % W)
buffer.writef32(pos, i * 12 + 4, i // W)
buffer.writef32(pos, i * 12 + 8, (i * 7) % 13)
end
local nt = (W - 1) * (W - 1) * 2
local idx = buffer.create(nt * 12)
local k = 0
for y = 0, W - 2 do
for x = 0, W - 2 do
local a = y * W + x
for _, v in { a, a + 1, a + W + 1, a, a + W + 1, a + W } do
buffer.writeu32(idx, k * 4, v)
k += 1
end
end
end
local scene = Types.Scene.fromPrimitive({ attributes = { POSITION = Types.Scene.accessor(pos, "f32", 3, W * W) }, indices = Types.Scene.accessor(idx, "u32", 1, nt * 3), mode = "triangles" })
local t0 = os.clock()
local data = Ply.encode(scene) :: buffer
local te = os.clock() - t0
t0 = os.clock()
local back = Ply.decode(Bytes.reader(data))
local dt = os.clock() - t0
t:check(back and back.meshes[1].primitives[1].indices.count == nt * 3, "bench decode")
t:check(buffer.tostring(back.meshes[1].primitives[1].indices.data) == buffer.tostring(idx), "bench round trip")
t:note("binary LE decode: %d vertices + %d triangles (%.1f MB) in %.3f s, %.0f MB/s (encode %.2f s)", W * W, nt, buffer.len(data) / 1e6, dt, buffer.len(data) / 1e6 / math.max(dt, 1e-6), te)
end
t:done()
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff. Show more