wanadev / gltf-bounding-box Goto Github PK
View Code? Open in Web Editor NEWComputes the global bounding box of a gltf model
License: Other
Computes the global bounding box of a gltf model
License: Other
According to the code, I found that when URI was not coded in base64, it could not continue to work.
the err:
gltf-bounding-box\dist\index.js:17335 if (!buffer.uri.startsWith("data:")) {
I am using this to compute the bounding box of a gltf
file, but an error happens. Here is the stack trace:
TypeError: Cannot read property 'slice' of null
at Object._loadBufferView (.../gltf-bounding-box/dist/webpack:/src/gltf-reader.js:92:19)
at Object._loadAccessor (.../gltf-bounding-box/dist/webpack:/src/gltf-reader.js:48:31)
at .../gltf-bounding-box/dist/webpack:/src/gltf-reader.js:25:47
at Array.forEach (<anonymous>)
at loadPositions (.../gltf-bounding-box/dist/webpack:/src/gltf-reader.js:21:21)
at .../gltf-bounding-box/dist/webpack:/src/gltf2-bounding-box.js:46:51
at Array.reduce (<anonymous>)
at Object.getMeshesTransformMatrices (.../gltf-bounding-box/dist/webpack:/src/gltf2-bounding-box.js:39:8)
at Object.computeBoundings (.../gltf-bounding-box/dist/webpack:/src/gltf2-bounding-box.js:8:28)
at Object.computeBoundings (.../gltf-bounding-box/dist/webpack:/src/index.js:23:33)
I am using node
8.15.0 on macOS 10.13.4
If a gltf
file contains transformations in the fields scaling
, rotation
, and translation
, these are not considered in the computation.
This happens because in the function getParentNodesMatrices
, only the field matrix
is checked.
However, the GLTF specifications says that also three other fields are present (for T, R, and S), which can contain the transformations separately.
In the files gltf1-bounding-box.js
and gltf2-bounding-box.js
the center is computed as:
center: {
x: precise.round((boundings.max[0] + boundings.min[0]) / 2, precision + 1),
y: precise.round((boundings.max[2] + boundings.min[2]) / 2, precision + 1),
z: precise.round((boundings.max[1] + boundings.min[1]) / 2, precision + 1),
},
However, the division by 2
is integer division and causes the number
argument of precise.round
to always be an integer.
To correct this bug, I believe it is enough to divide by 2.0
instead.
Should I make a PR for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.