-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splat/SPZ refactor, file nodes now upload data on file drop
- Loading branch information
Showing
13 changed files
with
148 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package splat | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/EliCDavis/polyform/generator" | ||
"github.com/EliCDavis/polyform/generator/artifact" | ||
"github.com/EliCDavis/polyform/modeling" | ||
"github.com/EliCDavis/polyform/nodes" | ||
"github.com/EliCDavis/polyform/refutil" | ||
) | ||
|
||
func init() { | ||
factory := &refutil.TypeFactory{} | ||
|
||
refutil.RegisterType[ArtifactNode](factory) | ||
|
||
generator.RegisterTypes(factory) | ||
} | ||
|
||
type Splat struct { | ||
Mesh modeling.Mesh | ||
} | ||
|
||
func (sa Splat) Write(w io.Writer) error { | ||
return Write(w, sa.Mesh) | ||
} | ||
|
||
func (Splat) Mime() string { | ||
return "application/octet-stream" | ||
} | ||
|
||
type ArtifactNode = nodes.Struct[artifact.Artifact, ArtifactNodeData] | ||
|
||
type ArtifactNodeData struct { | ||
In nodes.NodeOutput[modeling.Mesh] | ||
} | ||
|
||
func (pn ArtifactNodeData) Description() string { | ||
return "Mkkellogg's SPLAT format for their three.js Gaussian Splat Viewer" | ||
} | ||
|
||
func (pn ArtifactNodeData) Process() (artifact.Artifact, error) { | ||
return Splat{Mesh: pn.In.Value()}, nil | ||
} | ||
|
||
func NewSplatNode(meshNode nodes.NodeOutput[modeling.Mesh]) nodes.NodeOutput[artifact.Artifact] { | ||
return (&ArtifactNode{ | ||
Data: ArtifactNodeData{ | ||
In: meshNode, | ||
}, | ||
}).Out() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package spz | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/EliCDavis/polyform/generator" | ||
"github.com/EliCDavis/polyform/modeling" | ||
"github.com/EliCDavis/polyform/nodes" | ||
"github.com/EliCDavis/polyform/refutil" | ||
) | ||
|
||
func init() { | ||
factory := &refutil.TypeFactory{} | ||
refutil.RegisterType[ReadNode](factory) | ||
generator.RegisterTypes(factory) | ||
} | ||
|
||
type ReadNode = nodes.Struct[modeling.Mesh, ReadNodeData] | ||
|
||
type ReadNodeData struct { | ||
Data nodes.NodeOutput[[]byte] | ||
} | ||
|
||
func (gad ReadNodeData) Process() (modeling.Mesh, error) { | ||
if gad.Data == nil { | ||
return modeling.EmptyMesh(modeling.PointTopology), nil | ||
} | ||
|
||
data := gad.Data.Value() | ||
if len(data) == 0 { | ||
return modeling.EmptyMesh(modeling.PointTopology), nil | ||
} | ||
|
||
cloud, err := Read(bytes.NewReader(data)) | ||
if err != nil { | ||
return modeling.EmptyMesh(modeling.PointTopology), err | ||
} | ||
|
||
return cloud.Mesh, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.