@@ -10,7 +10,7 @@ import (
1010 "github.com/qmuntal/gltf"
1111)
1212
13- func LoadGLTF (file io.Reader , desiredSize Types.Vector ) ([]* Types.Mesh , error ) {
13+ func LoadGLTF (file io.Reader , desiredSize * Types.Vector ) ([]* Types.Mesh , error ) {
1414 var doc gltf.Document
1515 gltf .NewDecoder (file ).Decode (& doc )
1616
@@ -20,11 +20,14 @@ func LoadGLTF(file io.Reader, desiredSize Types.Vector) ([]*Types.Mesh, error) {
2020 for _ , p := range m .Primitives {
2121 // contains Min and Max attr (for dimension calc)
2222 posAccessor := doc.Accessors [p.Attributes [gltf.POSITION ]]
23- scaling := Types.Vector {
24- // axes inverted to convert to correct coordinate system
25- X : desiredSize .X / (posAccessor .Max [0 ] - posAccessor .Min [0 ]),
26- Y : desiredSize .Y / (posAccessor .Max [2 ] - posAccessor .Min [2 ]),
27- Z : desiredSize .Z / (posAccessor .Max [1 ] - posAccessor .Min [1 ]),
23+ scaling := Types.Vector {X : 1 , Y : 1 , Z : 1 }
24+ if desiredSize != nil {
25+ scaling = Types.Vector {
26+ // axes inverted to convert to correct coordinate system
27+ X : desiredSize .X / (posAccessor .Max [0 ] - posAccessor .Min [0 ]),
28+ Y : desiredSize .Y / (posAccessor .Max [2 ] - posAccessor .Min [2 ]),
29+ Z : desiredSize .Z / (posAccessor .Max [1 ] - posAccessor .Min [1 ]),
30+ }
2831 }
2932 positions , err := gltfVec3 (& doc , posAccessor , scaling )
3033 if err != nil {
0 commit comments