From 5edc68ab22101382c6dd11c4fd4fc56c93c72b36 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 21 Dec 2022 18:58:32 +0100 Subject: [PATCH] Handle missing uvs in gltf meshes --- Assets/plugins/embed/import_gltf_glb.js | 3 ++- Assets/plugins/wasm/import_gltf_glb.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/plugins/embed/import_gltf_glb.js b/Assets/plugins/embed/import_gltf_glb.js index 1d9123d8..13ab21c5 100644 --- a/Assets/plugins/embed/import_gltf_glb.js +++ b/Assets/plugins/embed/import_gltf_glb.js @@ -17,7 +17,8 @@ let import_gltf_glb = function(path, done) { let inda = new Uint32Array(r.buffer, a._get_indices(), index_count); let posa = new Int16Array(r.buffer, a._get_positions(), vertex_count * 4); let nora = new Int16Array(r.buffer, a._get_normals(), vertex_count * 2); - let texa = new Int16Array(r.buffer, a._get_uvs(), vertex_count * 2); + let uvs = a._get_uvs(); + let texa = uvs == 0 ? null : new Int16Array(r.buffer, uvs, vertex_count * 2); let name = path.split("\\").pop().split("/").pop().split(".").shift(); done({ name: name, diff --git a/Assets/plugins/wasm/import_gltf_glb.js b/Assets/plugins/wasm/import_gltf_glb.js index abe4d65a..d2a27304 100644 --- a/Assets/plugins/wasm/import_gltf_glb.js +++ b/Assets/plugins/wasm/import_gltf_glb.js @@ -25,7 +25,8 @@ let import_gltf_glb = function(path, done) { let inda = new Uint32Array(r.buffer, a._get_indices(), index_count); let posa = new Int16Array(r.buffer, a._get_positions(), vertex_count * 4); let nora = new Int16Array(r.buffer, a._get_normals(), vertex_count * 2); - let texa = new Int16Array(r.buffer, a._get_uvs(), vertex_count * 2); + let uvs = a._get_uvs(); + let texa = uvs == 0 ? null : new Int16Array(r.buffer, uvs, vertex_count * 2); let name = path.split("\\").pop().split("/").pop().split(".").shift(); done({ name: name,