Giter VIP home page Giter VIP logo

tetra3d's Issues

panic: index out of range


goroutine 1 [running, locked to thread]:
github.com/solarlune/tetra3d.LoadGLTFData({0xc00044c000, 0x1d81b, 0x1d81b}, 0x0)
        /Users/xackery/Documents/code/go/pkg/mod/github.com/solarlune/[email protected]/gltf.go:162 +0x8e7a
exit status 2

seems:

newMat.TexturePath = doc.Images[*doc.Textures[texture.Index].Source].URI

is missing sanity checks and making assumptions, I'm using something similar to https://github.com/qmuntal/gltf/blob/80d3922a76d3e24371f8c99e0d213ecc8dae3ffe/modeler/example_test.go#L35 to generate a gltf and it is cutting corners on some steps, and causing tetra3d to panic non-gracefully

feature request: add `Load[DAE/GLTF]FromReader(io.Reader)`

Right now one has to io.ReadAll before passing the data slice into LoadGLTFData which wraps it in a reader, so why not pass a reader directly? Loading from file is not ideal, since assets may be embedded via //go:embed into an embed.FS (my case!), which also brings up a point of adding Load[DAE/GLTF]FromFS.

Looking at LoadDAEData, I assume it could also use a xml.NewDecoder, but if there is some arcane reasoning behind umarshaling it three times separately from a byte slice, it could just io.ReadAll to get it from the provided reader.

panic: Error: MeshPart.AddTriangles() not given enough vertices to construct complete triangles (i.e. multiples of 3 vertices).

I'm noticing a trend in this package:

func (part *MeshPart) AddTriangles(verts ...VertexInfo) {

	mesh := part.Mesh

	if part.TriangleEnd > -1 && part.TriangleEnd < mesh.triIndex {
		panic("Error: Cannot add triangles to MeshPart non-contiguously (i.e. partA.AddTriangles(), partB.AddTriangles(), partA.AddTriangles() ).")
	}

	if len(verts) == 0 || len(verts)%3 > 0 {
		panic("Error: MeshPart.AddTriangles() not given enough vertices to construct complete triangles (i.e. multiples of 3 vertices).")
	}

Is there any reason sanity checks constitute an entire program failure? why not restructure to..

func (part *MeshPart) AddTriangles(verts ...VertexInfo) error {

	mesh := part.Mesh

	if part.TriangleEnd > -1 && part.TriangleEnd < mesh.triIndex {
		return fmt.Errorf("cannot add triangles to MeshPart non-contiguously (i.e. partA.AddTriangles(), partB.AddTriangles(), partA.AddTriangles() ).")
	}

	if len(verts) == 0 || len(verts)%3 > 0 {
		return fmt.Errorf("not enough vertices are provided to construct complete triangles (i.e. multiples of 3 vertices).")
	}

There are 26 uses of panic in this package: https://github.com/SolarLune/Tetra3d/search?q=panic
And most aren't critical failures that require the entire application to exit immediately, most are simply malformed requests that can be reported back to abort current operation

Crashing when loading a mesh

Hello
Tetra3D's gltf loader crashes with this message:

panic: runtime error: index out of range [96] with length 96

goroutine 1 [running, locked to thread]:
github.com/solarlune/tetra3d.LoadGLTFData({0xa113e0, 0x76529, 0x76529}, 0xc000689f20)
	<...>/Tetra3d/gltf.go:306 +0x4a45

I've added a part of my model to shapes.blend so that you can reproduce it (hopefully)
It can be found here: https://github.com/eliasdaler/Tetra3d/tree/gltf-crash/examples/shapes

Here's the part that causes the problem:

for triIndex, tri := range newMesh.Triangles {
	tri.Normal = normals[triIndex] // <- here!
}

Adding a Print like this:

fmt.Println(len(normals), len(indices), len(newMesh.Triangles), mesh.Name)

shows this:

96 288 608 Cylinder.003

So, the number of triangles doesn't match number of indices...
Maybe I'm doing something wrong with Blender, so if there's something I need to do with my models, please let me know! :)

Lots of noise when displaying triangles

Hi I've tried running a few examples with the same results (see the attached).

I'm running Go 1.17 on Debian Stable (5.10.0-10-amd64) via Xorg. The GPU on my Thinkpad is an HD 520.

The video I've attached is of the animations example but the same thing happens on other examples. I've tried on the latest master branch and also checked out the v0.4.2 tag with the same results.

I know there isn't much you can do remotely for such a weird issue but figured I would still notify you. I'm a go developer myself and have built toy renderers before, but I'm kinda at a loss for how to debug this. If there is something I can do to help, let me know.

Install steps were just checkout, go mod tidy, go run ./examples/animation/main.go.

Peek.2022-01-17.19-14.mp4

Properties.Get documentation is incorrect

// passed name (propName) doesn't exist, Get will return nil.

The comment says that Get returns nil, but it definitely does not. It seems like this is the only way to set a property initially. So either the docs here are wrong, or its intended to set properties a different way?

I would have gone ahead and opened a PR to fix the doc, but I wasn't sure what the intention was.

nil exception in gltf loader

[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4431201]

goroutine 1 [running, locked to thread]:
github.com/solarlune/tetra3d.LoadGLTFData({0xc000ad8000, 0x1d71f, 0x1d71f}, 0x0)
        /Users/xackery/Documents/code/go/pkg/mod/github.com/solarlune/[email protected]/gltf.go:158 +0xba1
github.com/xackery/quail/cmd.(*viewer).load(0xc0004e4bf0, {0xc000ad8000?, 0xc0002b3c68?, 0x1?})

seems

if texture := gltfMat.PBRMetallicRoughness.BaseColorTexture; texture != nil {

isn't happy with my hand crafted gltf files

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.