fauxgl

package module
v0.0.0-...-dd521f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

FauxGL-GLTF - 专业GLTF渲染引擎

FauxGL-GLTF 是一个专门针对GLTF格式优化的纯Go语言3D渲染引擎,支持完整的物理基础渲染(PBR)、高级材质系统、场景管理和动画播放,代码大部分由Goder编写,基于FauxGL开发。

特色功能

🎯 专业GLTF支持
  • 完整GLTF 2.0解析: 支持所有标准GLTF特性
  • 场景层次加载: 完整的节点树结构
  • 材质系统: 自动转换GLTF材质为PBR材质
  • 动画播放: 支持关键帧动画和变换动画
  • 纹理加载: 支持所有GLTF纹理类型
  • 相机和光源: 从GLTF文件加载场景设置
🎨 物理基础渲染 (PBR)
  • 完整的PBR材质系统: 支持金属工作流
  • 基于物理的光照: Cook-Torrance BRDF模型
  • 材质属性:
    • 基础颜色 (Base Color)
    • 金属度 (Metallic)
    • 粗糙度 (Roughness)
    • 法线贴图 (Normal Maps)
    • 遮蔽贴图 (Occlusion Maps)
    • 自发光 (Emissive)
🎨 动态UV映射系统 🆕
  • 智能UV修改器: 支持实时UV坐标变换
  • 多层变换效果: 缩放、旋转、偏移、剪切变换
  • 区域化映射: 矩形、圆形、渐变遮罩系统
  • 多种混合模式: 替换、加法、乘法、叠加模式
  • 部分区域贴图: 支持杯子等模型的局部纹理应用
  • 动画UV效果: 时间管理和动态变换
  • 智能纹理选择: 自动回退机制和内容验证
UV修改器使用示例

基础UV变换:

// 创建UV修改器
modifier := fauxgl.NewUVModifier()
// 设置全局变换
globalTransform := fauxgl.NewUVTransform()
globalTransform.ScaleU = 2.0
globalTransform.ScaleV = 1.5
globalTransform.Rotation = math.Pi / 4 // 45度旋转
modifier.SetGlobalTransform(globalTransform)
// 应用到纹理
texture.UVModifier = modifier

部分区域贴图:

// 创建前面板标志区域
frontLogoMapping := &fauxgl.UVMapping{
    Name:    "front_logo_area",
    Enabled: true,
    Region: fauxgl.UVRegion{
        MinU: 0.25, MaxU: 0.75,
        MinV: 0.35, MaxV: 0.65,
        MaskType: fauxgl.UVMaskRectangle,
    },
    Transform: &fauxgl.UVTransform{
        ScaleU: 0.8, ScaleV: 0.6,
    },
    BlendMode: fauxgl.UVBlendReplace,
    Priority:  2,
}
modifier.AddMapping(frontLogoMapping)

智能纹理加载:

// 程序会按优先级自动加载纹理文件
// 1. your_texture.jpg (用户自定义)
// 2. custom_texture.jpg 
// 3. logo_texture.png
// 4. texture.png (回退选项)

// 配置自定义纹理
const CUSTOM_TEXTURE_FILE = "my_logo.jpg"
🧩 UV编辑器系统 🆕
  • 平面展开算法: 基于Blender的UV展开逻辑实现
  • 自动松弛算法: 实现Seam Relaxation算法优化UV分布
  • UV岛屿处理: 支持多UV岛屿提取和独立处理
  • 坐标映射: 2D画布坐标与3D模型UV坐标双向转换
  • UV可视化: 生成UV展开图用于调试和分析
  • 保持约束: 支持面积保持和角度保持约束
UV编辑器使用示例

UV松弛处理:

// 创建UV松弛设置
settings := fauxgl.NewUVRelaxationSettings()
settings.Iterations = 20     // 松弛迭代次数
settings.StepSize = 0.3      // 松弛步长
settings.PinBoundary = true  // 固定边界顶点

// 应用UV松弛算法到网格
err := fauxgl.ApplyUVRelaxation(mesh, settings)
if err != nil {
    log.Fatal(err)
}

坐标映射:

// UV坐标转画布坐标
uv := fauxgl.Vector2{0.5, 0.5}
x, y := fauxgl.UVToCanvas(uv, 1024, 1024)
fmt.Printf("UV(0.5, 0.5) -> 画布坐标(%d, %d)\n", x, y)

// 画布坐标转UV坐标
uv2 := fauxgl.CanvasToUV(512, 512, 1024, 1024)
fmt.Printf("画布坐标(512, 512) -> UV(%.2f, %.2f)\n", uv2.X, uv2.Y)
🌒 阴影映射系统 🆕
  • 完整阴影映射实现: 支持多种阴影技术
  • PCF软阴影: Percentage Closer Filtering实现柔和阴影边缘
  • PCSS高级软阴影: Percentage Closer Soft Shadows实现真实感阴影
  • 级联阴影映射: 支持大场景的高质量阴影渲染
  • 全向阴影映射: 支持点光源的360度阴影
  • 多种阴影算法: 简单阴影、PCF、PCSS等多种技术可选
阴影映射使用示例
// 创建阴影渲染器
shadowRenderer := fauxgl.NewShadowMapRenderer(context, 1024, light, fauxgl.PCFShadow)
shadowMap := shadowRenderer.GenerateShadowMap(scene)

// 创建阴影接收着色器
shadowShader := fauxgl.NewSoftShadowReceiverShader(
    finalMatrix,
    lightMatrix,
    light.Direction,
    camera.Position,
    shadowMap,
    fauxgl.PCFShadow,
)

// 应用阴影着色器进行渲染
context.Shader = shadowShader
context.DrawMesh(node.Mesh)
🌈 后期处理效果系统 🆕
  • 完整的后期处理管线: 支持效果链式处理
  • 辉光效果: Bloom效果增强高光区域
  • 模糊效果: 高斯模糊实现景深和运动模糊
  • 色调映射: Reinhard色调映射实现HDR效果
  • FXAA抗锯齿: 快速近似抗锯齿减少锯齿
  • 色差效果: Chromatic Aberration模拟镜头色散
  • 暗角效果: Vignette增强画面氛围
  • 颜色分级: 色调、饱和度、亮度调整
后期处理使用示例
// 创建后期处理管线
pipeline := fauxgl.NewPostProcessingPipeline()

// 添加多种效果
bloomEffect := fauxgl.NewBloomEffect(0.7, 3, 0.5)
pipeline.AddEffect(bloomEffect)

toneMapEffect := fauxgl.NewToneMappingEffect(1.0, 2.2)
pipeline.AddEffect(toneMapEffect)

fxaaEffect := fauxgl.NewFXAAEffect()
pipeline.AddEffect(fxaaEffect)

// 应用后期处理
result := pipeline.Process(context.Image())
🎥 增强相机系统 🆕
  • 多种相机类型: 透视相机、正交相机
  • 轨道相机控制器: 围绕目标旋转的相机控制
  • 第一人称相机: FPS风格的相机控制
  • 视锥体剔除: 自动剔除不可见对象提升性能
  • 多相机支持: 场景中可同时存在多个相机
相机系统使用示例
// 创建轨道相机
camera := fauxgl.NewOrbitCamera(
    "orbit_camera",
    fauxgl.Vector{0, 0, 0}, // 目标点
    8.0,                    // 距离
    math.Pi/4,              // 45度视野
    float64(width)/float64(height),
    0.1, 100.0,
)

// 相机控制
camera.Rotate(0.2, 0.05) // 旋转相机
camera.Zoom(-0.5)        // 缩放相机
🧱 更多几何体类型 🆕
  • 丰富几何体库: 立方体、球体、圆锥体、圆柱体、平面、圆环体、胶囊体
  • 几何体细分: 支持网格细分提升模型质量
  • 网格平滑: 顶点平均算法实现网格平滑
  • 参数化几何体: 可自定义参数生成几何体
几何体使用示例
// 创建各种几何体
cube := fauxgl.NewCube()
sphere := fauxgl.NewSphere(4)
cylinder := fauxgl.NewCylinder(0.5, 1.0, 16, 1, false)
torus := fauxgl.NewTorus(1.0, 0.3, 20, 12)
capsule := fauxgl.NewCapsule(0.5, 1.5, 12, 1, 2)

// 几何体操作
subdivided := sphere.Subdivide() // 细分球体
smoothed := mesh.Smooth(3)       // 平滑网格
🧠 着色器材质系统 🆕
  • 可编程着色器: 支持自定义顶点和片段着色器
  • PBR着色器: 基于物理的渲染着色器
  • 自定义效果着色器: 支持创建特殊视觉效果
  • 着色器接口: 统一的着色器编程接口
自定义着色器示例
// 自定义着色器结构体
type CustomShader struct {
    Matrix         fauxgl.Matrix
    LightDirection fauxgl.Vector
    CameraPosition fauxgl.Vector
    Time           float64
}

// 实现顶点着色器
func (shader *CustomShader) Vertex(v fauxgl.Vertex) fauxgl.Vertex {
    v.Output = shader.Matrix.MulPositionW(v.Position)
    return v
}

// 实现片段着色器
func (shader *CustomShader) Fragment(v fauxgl.Vertex) fauxgl.Color {
    // 基于时间的颜色变化
    red := 0.5 + 0.5*math.Sin(shader.Time+v.Position.X)
    green := 0.5 + 0.5*math.Sin(shader.Time*1.2+v.Position.Y)
    blue := 0.5 + 0.5*math.Sin(shader.Time*0.8+v.Position.Z)
    
    return fauxgl.Color{red, green, blue, 1.0}
}
🖼️ 高级纹理系统
  • 多种纹理类型: 基础颜色、法线、金属度、粗糙度等
  • 纹理过滤: 最近邻、双线性插值
  • 环绕模式: 重复、夹取、镜像
  • Mipmap支持: 自动生成多级细节
  • 集成UV修改器: 无缝集成到纹理采样流程 🆕
🎬 场景管理
  • 层次化场景图: 支持复杂的节点关系
  • 变换系统: 本地和世界坐标系统
  • 多相机支持: 透视和正交投影
  • 动画播放器: 关键帧动画和插值
💡 环境光系统
  • AmbientLight支持: 提供均匀的全局照明
  • PBR兼容: 与物理基础渲染完全兼容
  • 多光源组合: 支持方向光、点光源、聚光灯和环境光
  • 高效渲染: 直接应用到材质基色,考虑遮蔽贴图
  • 智能兼容性: 优先使用AmbientLight光源,保持向后兼容
环境光使用示例
// 基本环境光使用
scene.AddAmbientLight(fauxgl.Color{0.2, 0.3, 0.4, 1.0}, 0.8)

// 多光源组合
scene.AddAmbientLight(fauxgl.Color{0.3, 0.3, 0.4, 1.0}, 0.5)  // 环境光
scene.AddDirectionalLight(                                      // 主光源
    fauxgl.V(-1, -1, -1),
    fauxgl.Color{1.0, 0.9, 0.8, 1.0},
    2.0,
)
scene.AddPointLight(                                            // 点光源
    fauxgl.V(2, 3, 1),
    fauxgl.Color{1.0, 0.8, 0.6, 1.0},
    5.0, 10.0,
)
场景照明最佳实践

室内场景:

// 室内散射光
scene.AddAmbientLight(fauxgl.Color{0.25, 0.27, 0.3, 1.0}, 0.4)
// 窗户光
scene.AddDirectionalLight(fauxgl.V(-0.5, -0.8, -0.3), fauxgl.Color{0.95, 0.9, 0.8, 1.0}, 3.0)

户外场景:

// 天空散射光
scene.AddAmbientLight(fauxgl.Color{0.4, 0.45, 0.6, 1.0}, 0.6)
// 太阳光
scene.AddDirectionalLight(fauxgl.V(-0.3, -0.8, -0.5), fauxgl.Color{1.0, 0.95, 0.85, 1.0}, 4.0)

夜晚场景:

// 月光环境光
scene.AddAmbientLight(fauxgl.Color{0.1, 0.15, 0.25, 1.0}, 0.2)
// 月光主光源
scene.AddDirectionalLight(fauxgl.V(-0.2, -0.9, -0.4), fauxgl.Color{0.7, 0.8, 1.0, 1.0}, 1.5)

快速开始

安装
go get github.com/swordkee/fauxgl-gltf
基本使用
package main

import (
    "log"
    "github.com/swordkee/fauxgl-gltf"
)

func main() {
    // 加载GLTF场景
    scene, err := fauxgl.LoadGLTFScene("model.gltf")
    if err != nil {
        log.Fatal(err)
    }

    // 创建渲染上下文
    context := fauxgl.NewContext(1920, 1080)
    context.ClearColor = fauxgl.Color{0.2, 0.2, 0.3, 1.0}
    context.ClearColorBuffer()

    // 渲染场景
    renderer := fauxgl.NewSceneRenderer(context)
    renderer.RenderScene(scene)

    // 保存结果
    err = fauxgl.SavePNG("output.png", context.Image())
    if err != nil {
        log.Fatal(err)
    }
}
自定义PBR材质和UV映射
// 创建自定义PBR材质
material := fauxgl.NewPBRMaterial()
material.BaseColorFactor = fauxgl.Color{0.8, 0.2, 0.2, 1.0} // 红色
material.MetallicFactor = 0.8   // 高金属度
material.RoughnessFactor = 0.2  // 低粗糙度

// 加载纹理
baseColorTexture, _ := fauxgl.LoadAdvancedTexture("base_color.jpg", fauxgl.BaseColorTexture)

// 添加UV修改器
modifier := fauxgl.NewUVModifier()
globalTransform := fauxgl.NewUVTransform()
globalTransform.ScaleU = 1.5
globalTransform.ScaleV = 1.2
modifier.SetGlobalTransform(globalTransform)
baseColorTexture.UVModifier = modifier

// 应用到场景节点
node.Material = material

运行示例

项目包含了多个完整的示例程序:

GLTF基础渲染
cd examples
go run gltf_demo.go
Mug模型渲染
cd examples
go run mug.go
PBR材质演示
cd examples
go run pbr_demo.go
精确GLTF渲染
cd examples
go run mug_uv.go
环境光功能演示
cd examples
go run ambient_light_demo.go
高级功能演示 (蒙皮动画 + 变形目标 + GLTF扩展)
cd examples
go run advanced_features_simple.go
KTX2纹理格式演示 🆕
cd examples
go run ktx2_texture_demo.go
扩展材质功能演示 🆕
cd examples
go run extended_materials_demo.go
GLTF扩展综合展示 🆕
cd examples
go run gltf_extensions_showcase.go
UV调试工具 🆕
cd examples
go run debug_uv.go
部分区域贴图演示 🆕
cd examples
go run mug_uv_final.go
UV编辑器演示 🆕
cd examples
go run uv_editor.go
完整功能演示(UV编辑器+多光源) 🆕
cd examples
go run complete_demo.go
阴影映射演示 🆕
cd examples
go run shadow_postprocessing_demo.go
几何体和相机系统演示 🆕
cd examples
go run geometry_camera_demo.go
自定义着色器演示 🆕
cd examples
go run custom_shader_demo.go
综合功能演示 🆕
cd examples
go run comprehensive_demo.go

支持的GLTF特性

✅ 完全支持:

  • GLTF 2.0格式
  • PBR材质 (Metallic-Roughness workflow)
  • 纹理映射 (Base Color, Normal, Metallic-Roughness)
  • 动态UV修改器: 实时UV坐标变换和部分贴图 🆕
  • 场景层次结构
  • 网格几何体
  • 关键帧动画
  • 蒙皮动画 (Skinned Animation) 🆕
  • 变形目标 (Morph Targets) 🆕
  • 相机定义
  • 光源设置
  • 环境光功能 (AmbientLight): 支持均匀全局照明 🆕

🚧 部分支持:

  • GLTF扩展系统 🆕 (21个扩展):
    • 材质扩展 (13个):
      • KHR_materials_emissive_strength (增强自发光强度)
      • KHR_materials_ior (折射率)
      • KHR_materials_specular (镜面反射)
      • KHR_materials_transmission (透射)
      • KHR_materials_volume (体积材质)
      • KHR_materials_anisotropy (各向异性) 🆕
      • KHR_materials_sheen (光泽效果) 🆕
      • KHR_materials_iridescence (彩虹色) 🆕
      • KHR_materials_dispersion (色散) 🆕
      • KHR_materials_clearcoat (清漆) 🆕
      • KHR_materials_unlit (无光照材质)
      • KHR_materials_variants (材质变体) 🆕
      • KHR_materials_pbrSpecularGlossiness (镜面光泽工作流)
    • 纹理扩展 (3个):
      • KHR_texture_basisu (KTX2/Basis Universal纹理) 🆕
      • KHR_texture_transform (纹理坐标变换)
      • EXT_texture_webp (WebP纹理) 🆕
    • 光照扩展 (1个):
      • KHR_lights_punctual (标准光源)
    • 动画扩展 (1个):
      • KHR_animation_pointer (动画指针) 🆕
    • 网格扩展 (2个):
      • KHR_mesh_quantization (网格量化) 🆕
      • EXT_mesh_gpu_instancing (GPU实例化) 🆕
    • 元数据扩展 (1个):
      • KHR_xmp_json_ld (XMP元数据) 🆕
  • 高级动画功能:
    • 骨骼系统和关节矩阵
    • 形状插值和面部动画
    • 四元数旋转插值
  • KTX2纹理格式 🆕:
    • KTX2容器格式解析
    • 多级mipmap支持
    • 数据格式描述符(DFD)解析
    • 键值对元数据提取
    • 超级压缩检测

⚠️ 计划支持 (高难度):

  • KTX2纹理解压缩 (Basis Universal, Zstd等)
  • Draco几何压缩 (需要CGO集成)
  • 某些高级扩展 (依赖外部库)

🚀 性能优化

SIMD向量计算优化 🆕

FauxGL-GLTF现在支持SIMD(单指令多数据)优化的向量计算,显著提升渲染性能:

  • 向量运算加速: 向量加法、减法、点积、叉积等运算性能提升2-4倍
  • 矩阵变换优化: 批量矩阵变换操作利用SIMD指令优化
  • 几何处理加速: 网格变换、法线计算等几何处理性能显著提升
  • 自动切换机制: 根据网格大小自动选择传统算法或SIMD优化算法
// SIMD优化的向量运算示例
v1 := fauxgl.Vector{1, 2, 3}
v2 := fauxgl.Vector{4, 5, 6}

// 传统向量加法
result1 := v1.Add(v2)

// SIMD优化的批量向量运算
vectors1 := []fauxgl.Vector{v1, v1, v1}
vectors2 := []fauxgl.Vector{v2, v2, v2}
result2 := fauxgl.SIMDAddVectors(vectors1, vectors2)
高质量渲染优化
  • 4K超分辨率渲染: 支持高达8K的渲染输出
  • 智能超采样: 自适应超采样抗锯齿技术
  • 并行渲染: 充分利用多核CPU进行并行渲染
  • 内存优化: 优化的内存管理和垃圾回收

🎯 使用示例

基础渲染
# 基础GLTF渲染
go run examples/gltf_demo.go

# 高质量4K渲染(带SIMD优化)
go run examples/mug_uv_improved.go

# SIMD性能测试
go run examples/simd_demo.go
高级功能演示
# UV修改器完整演示
go run examples/mug_uv_final.go

# 多光源PBR渲染
go run examples/pbr_demo.go

# 环境光效果演示
go run examples/ambient_light_demo.go

# KTX2纹理格式支持
go run examples/ktx2_texture_demo.go

📚 API参考

核心类型
// SIMD优化向量
type SIMDVector4 [4]float64

// SIMD优化矩阵
type SIMDMat4 [16]float64

// SIMD优化顶点
type SIMDVertex struct {
    Position SIMDVector4
    Normal   SIMDVector4
    Color    SIMDVector4
    TexCoord SIMDVector4
}

// 批量SIMD操作
func SIMDAddVectors(a, b []Vector) []Vector
func SIMDMulScalarVectors(vectors []Vector, scalar float64) []Vector
func SIMDNormalizeVectors(vectors []Vector) []Vector

// 场景加载
type Scene struct {
    RootNode  *SceneNode
    Cameras   map[string]*Camera
    Lights    []Light
    Materials map[string]*PBRMaterial
    Meshes    map[string]*Mesh
}

// PBR材质
type PBRMaterial struct {
    BaseColorFactor   Color
    MetallicFactor    float64
    RoughnessFactor   float64
    BaseColorTexture  *AdvancedTexture
    NormalTexture     *AdvancedTexture
    // ... 更多属性
}

// 场景节点
type SceneNode struct {
    Name        string
    Transform   Matrix
    Children    []*SceneNode
    Mesh        *Mesh
    Material    *PBRMaterial
}

// UV修改器 🆕
type UVModifier struct {
    GlobalTransform *UVTransform
    Mappings        []*UVMapping
}

type UVTransform struct {
    OffsetU, OffsetV float64 // UV偏移
    ScaleU, ScaleV   float64 // UV缩放
    Rotation         float64 // 旋转角度
    SkewU, SkewV     float64 // UV剪切
    PivotU, PivotV   float64 // 旋转中心点
}

type UVMapping struct {
    Name      string
    Enabled   bool
    Region    UVRegion
    Transform *UVTransform
    BlendMode UVBlendMode
    Priority  int
}

// UV编辑器系统 🆕
type UVRelaxationSettings struct {
    Iterations     int     // 松弛迭代次数
    StepSize       float64 // 松弛步长
    PinBoundary    bool    // 是否固定边界
    PreserveArea   bool    // 是否保持面积
    PreserveAngles bool    // 是否保持角度
    EnableSeams    bool    // 是否启用接缝
}

type UVIsland struct {
    Vertices      []Vector2 // UV坐标
    Indices       []int     // 三角形索引
    OriginalUVs   []Vector2 // 原始UV坐标
    Seams         []UVSeam  // 接缝列表
    BoundaryVerts []int     // 边界顶点
    PinnedVerts   []int     // 固定顶点
}

type UVSeam struct {
    Edge     [2]Vector // 接缝边的两个顶点
    Strength float64   // 接缝强度 (0-1)
    Fixed    bool      // 是否固定(不参与松弛)
}

type Vector2 struct {
    X, Y float64
}

// 阴影映射系统 🆕
type ShadowMap struct {
    Width    int
    Height   int
    DepthMap []float64
}

type ShadowMapRenderer struct {
    context     *Context
    shadowMap   *ShadowMap
    light       Light
    technique   ShadowTechnique
}

type ShadowTechnique int
const (
    SimpleShadow ShadowTechnique = iota
    PCFShadow
    PCSSShadow
)

// 后期处理效果系统 🆕
type PostProcessingPipeline struct {
    Effects []PostProcessingEffect
}

type PostProcessingEffect interface {
    Apply(input *image.NRGBA) *image.NRGBA
}

// 相机系统 🆕
type OrbitCamera struct {
    *Camera
    Target          Vector
    Distance        float64
    HorizontalAngle float64
    VerticalAngle   float64
}

type FirstPersonCamera struct {
    *Camera
    Yaw   float64
    Pitch float64
    Speed float64
}

// 几何体系统 🆕
type Mesh struct {
    Triangles []*Triangle
    Lines     []*Line
}

// 着色器系统 🆕
type Shader interface {
    Vertex(Vertex) Vertex
    Fragment(Vertex) Color
}
主要函数
// GLTF加载
func LoadGLTFScene(path string) (*Scene, error)

// 场景渲染
func NewSceneRenderer(context *Context) *SceneRenderer
func (r *SceneRenderer) RenderScene(scene *Scene)

// 材质和纹理
func NewPBRMaterial() *PBRMaterial
func LoadAdvancedTexture(path string, textureType TextureType) (*AdvancedTexture, error)

// UV修改器 🆕
func NewUVModifier() *UVModifier
func NewUVTransform() *UVTransform
func (modifier *UVModifier) AddMapping(mapping *UVMapping)
func (modifier *UVModifier) SetGlobalTransform(transform *UVTransform)
func (modifier *UVModifier) TransformUV(u, v float64) (float64, float64)
func ApplyUVModifierToMesh(mesh *Mesh, modifier *UVModifier)

// UV编辑器系统 🆕
func NewUVRelaxationSettings() *UVRelaxationSettings
func ApplyUVRelaxation(mesh *Mesh, settings *UVRelaxationSettings) error
func ExtractUVIslands(mesh *Mesh) []*UVIsland
func RelaxUVs(island *UVIsland, settings *UVRelaxationSettings)
func UVToCanvas(uv Vector2, canvasWidth, canvasHeight int) (int, int)
func CanvasToUV(x, y, canvasWidth, canvasHeight int) Vector2

// 阴影映射系统 🆕
func NewShadowMapRenderer(context *Context, shadowMapSize int, light Light, technique ShadowTechnique) *ShadowMapRenderer
func (sr *ShadowMapRenderer) GenerateShadowMap(scene *Scene) *ShadowMap
func NewSoftShadowReceiverShader(matrix, lightMatrix Matrix, lightDirection, cameraPosition Vector, shadowMap *ShadowMap, technique ShadowTechnique) *SoftShadowReceiverShader

// 后期处理效果系统 🆕
func NewPostProcessingPipeline() *PostProcessingPipeline
func (pp *PostProcessingPipeline) AddEffect(effect PostProcessingEffect)
func (pp *PostProcessingPipeline) Process(input *image.NRGBA) *image.NRGBA

// 相机系统 🆕
func NewOrbitCamera(name string, target Vector, distance, fov, aspectRatio, near, far float64) *OrbitCamera
func NewFirstPersonCamera(name string, position Vector, fov, aspectRatio, near, far float64) *FirstPersonCamera

// 几何体系统 🆕
func NewCube() *Mesh
func NewSphere(detail int) *Mesh
func NewCone(step int, capped bool) *Mesh
func NewCylinder(radius, height float64, radialSegments, heightSegments int, openEnded bool) *Mesh
func NewPlane(width, height float64) *Mesh
func NewTorus(radius, tubeRadius float64, radialSegments, tubularSegments int) *Mesh
func NewCapsule(radius, height float64, radialSegments, heightSegments, capSegments int) *Mesh
func (m *Mesh) Subdivide() *Mesh
func (m *Mesh) Tessellate(maxEdgeLength float64) *Mesh
func (m *Mesh) Smooth(iterations int) *Mesh

// 动画
func NewAnimationPlayer() *AnimationPlayer
func (p *AnimationPlayer) Play(name string)

// 光源管理
func (scene *Scene) AddDirectionalLight(direction Vector, color Color, intensity float64)
func (scene *Scene) AddPointLight(position Vector, color Color, intensity, range_ float64)
func (scene *Scene) AddSpotLight(position, direction Vector, color Color, intensity, range_, innerCone, outerCone float64)
func (scene *Scene) AddAmbientLight(color Color, intensity float64)
func (scene *Scene) ClearLights()
func (scene *Scene) GetLightsByType(lightType LightType) []Light

版本历史

v1.4.0 (阴影映射和后期处理版) 🆕
  • 🌒 阴影映射系统: 完整实现阴影贴图渲染
  • 🌈 后期处理效果: 实现效果组合器和常用效果
  • 🎥 增强相机系统: 多种相机控制类和视锥体剔除优化
  • 🧱 更多几何体类型: 内置常用几何体生成函数
  • 🧠 着色器材质系统: 支持自定义着色器程序
  • 🔄 几何体细分: 支持网格细分和修改功能
  • 📊 性能优化: 多种渲染优化技术
v1.3.0 (UV编辑器和多光源系统版) 🆕
  • 🧩 UV编辑器系统: 基于Blender的UV展开逻辑实现
  • 🔄 自动松弛算法: 实现Seam Relaxation算法优化UV分布
  • 🗺️ UV坐标映射: 2D画布坐标与3D模型UV坐标双向转换
  • 🎨 UV可视化: 生成UV展开图用于调试和分析
  • 💡 多光源系统: 支持方向光、环境光等多种光源组合
  • 🌈 PBR渲染: 基于物理的渲染支持多光源效果
  • 📊 保持约束: 支持面积保持和角度保持约束
v1.2.0 (UV映射系统版) 🆕
  • 🎨 动态UV修改器: 实时UV坐标变换系统
  • 🎯 部分区域贴图: 支持模型局部纹理应用
  • 🔄 多层变换效果: 缩放、旋转、偏移、剪切
  • 🔳 区域化映射: 矩形、圆形、渐变遮罩系统
  • 🌈 多种混合模式: 替换、加法、乘法、叠加
  • 🤖 智能纹理选择: 自动回退和内容验证
  • 🎥 动画UV效果: 时间管理和动态变换
  • 🛠️ 高质量渲染: 支持300KB+大文件输出
  • 📝 完整UV文档: 附带详细使用指南
v1.1.0 (高级特性版)
  • 🦾 蒙皮动画支持: 骨骼系统和关节矩阵
  • 🎦 变形目标支持: 形状插值和面部动画
  • 🔌 GLTF扩展系统: 支持多种KHR扩展
  • 🎯 增强场景管理: 蒙皮和变形目标集成
  • 🔧 动画系统扩展: 四元数插值和高级动画
v1.0.0 (GLTF专版)
  • 🎯 专注GLTF格式支持
  • 🗑️ 移除非GLTF格式解析器 (STL, OBJ, PLY等)
  • 🆕 完整PBR材质系统
  • 🆕 高级纹理支持
  • 🆕 场景管理和动画
  • 💡 环境光功能 (AmbientLight): 支持均匀全局照明
  • 🔧 优化GLTF加载性能
  • 📚 完整中文文档

依赖项

require (
    github.com/qmuntal/gltf v0.28.0
)

许可证

本项目采用MIT许可证。详见 LICENSE.md 文件。

贡献指南

欢迎提交问题报告和功能请求!

  1. Fork 本仓库
  2. 创建功能分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 开启 Pull Request

支持


FauxGL-GLTF - 让GLTF渲染变得简单高效!

Documentation

Overview

Package simd_vector 提供SIMD优化的向量计算功能

Index

Constants

View Source
const DFDBlockHeaderBasicLength = 16
View Source
const DFDHeaderLength = 8
View Source
const HeaderLength = 80
View Source
const LevelIndexLength = 24
View Source
const SampleInformationLength = 16

Variables

View Source
var (
	// Discard empty color
	Discard = Color{}
	// Transparent transparent color
	Transparent = Color{}
	// Black black color
	Black = Color{0, 0, 0, 1}
	// White white color
	White = Color{1, 1, 1, 1}
)
View Source
var DFDHeaderBasic = DFDHeader{
	VendorID:       0,
	DescriptorType: 0,
	VersionNumber:  2,
}
View Source
var EmptyBox = Box{}
View Source
var KTX2_MAGIC = [12]byte{0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}

KTX2魔数标识符,出现在文件开头

Functions

func AbsInt

func AbsInt(x int) int

func ApplyUVModifierToMesh

func ApplyUVModifierToMesh(mesh *Mesh, modifier *UVModifier)

ApplyUVModifierToMesh applies UV modifications to all triangles in a mesh

func ApplyUVRelaxation

func ApplyUVRelaxation(mesh *Mesh, settings *UVRelaxationSettings) error

ApplyUVRelaxation 应用UV松弛到网格

func Clamp

func Clamp(x, lo, hi float64) float64

func ClampInt

func ClampInt(x, lo, hi int) int

func Degrees

func Degrees(radians float64) float64

func InterpolateFloats

func InterpolateFloats(v1, v2, v3 float64, b VectorW) float64

func IsKTX2File

func IsKTX2File(data []byte) bool

IsKTX2File checks if the given data represents a KTX2 file

func LoadImage

func LoadImage(path string) (image.Image, error)

func PrintUVModifierInfo

func PrintUVModifierInfo(modifier *UVModifier)

PrintUVModifierInfo prints detailed information about a UV modifier

func Radians

func Radians(degrees float64) float64

func RelaxUVs

func RelaxUVs(island *UVIsland, settings *UVRelaxationSettings)

RelaxUVs 对UV岛屿执行松弛操作,类似Blender的Seam Relaxation

func Round

func Round(a float64) int

func RoundPlaces

func RoundPlaces(a float64, places int) float64

func SIMDVectorDistance

func SIMDVectorDistance(a, b Vector) float64

SIMDVectorDistance 计算两个向量之间的距离(SIMD优化)

func SIMDVectorDot

func SIMDVectorDot(a, b Vector) float64

SIMDVectorDot 计算两个向量的点积(SIMD优化)

func SavePNG

func SavePNG(path string, im image.Image) error

func UVToCanvas

func UVToCanvas(uv Vector2, canvasWidth, canvasHeight int) (int, int)

UVToCanvas 将UV坐标转换为画布坐标

Types

type AdvancedTexture

type AdvancedTexture struct {
	Image     image.Image
	Width     int
	Height    int
	Type      TextureType
	WrapS     TextureWrap
	WrapT     TextureWrap
	MinFilter TextureFilter
	MagFilter TextureFilter
	MipLevels []image.Image // For mipmap support
	Transform Matrix        // Texture coordinate transformation

	// **新增**: UV修改器支持
	UVModifier *UVModifier // 动态UV修改器
}

AdvancedTexture extends the basic texture interface with advanced features

func LoadAdvancedTexture

func LoadAdvancedTexture(path string, textureType TextureType) (*AdvancedTexture, error)

LoadAdvancedTexture loads an advanced texture from a file path

func LoadKTX2Texture

func LoadKTX2Texture(data []byte) (*AdvancedTexture, error)

LoadKTX2Texture loads a KTX2 texture from file data

func LoadKTX2TextureFromFile

func LoadKTX2TextureFromFile(path string) (*AdvancedTexture, error)

LoadKTX2TextureFromFile loads a KTX2 texture from a file path

func NewAdvancedTexture

func NewAdvancedTexture(img image.Image, textureType TextureType) *AdvancedTexture

NewAdvancedTexture creates a new advanced texture from an image

func (*AdvancedTexture) BilinearSample

func (t *AdvancedTexture) BilinearSample(u, v float64) Color

BilinearSample performs bilinear sampling

func (*AdvancedTexture) GenerateMipmaps

func (t *AdvancedTexture) GenerateMipmaps()

GenerateMipmaps generates mipmap levels for the texture

func (*AdvancedTexture) Sample

func (t *AdvancedTexture) Sample(u, v float64) Color

Sample samples the texture with basic UV coordinates

func (*AdvancedTexture) SampleHeight

func (t *AdvancedTexture) SampleHeight(u, v float64) float64

SampleHeight samples a height map and returns the height value

func (*AdvancedTexture) SampleNormal

func (t *AdvancedTexture) SampleNormal(u, v float64) Vector

SampleNormal samples a normal map and returns the normal in tangent space

func (*AdvancedTexture) SampleSingleChannel

func (t *AdvancedTexture) SampleSingleChannel(u, v float64, channel int) float64

SampleSingleChannel samples a single channel texture (metallic, roughness, etc.)

func (*AdvancedTexture) SampleWithFilter

func (t *AdvancedTexture) SampleWithFilter(u, v float64, filter TextureFilter) Color

SampleWithFilter samples the texture with specified filtering

type AlphaMode

type AlphaMode int

AlphaMode represents how alpha blending should be handled

const (
	// AlphaOpaque - fully opaque
	AlphaOpaque AlphaMode = iota
	// AlphaMask - alpha testing
	AlphaMask
	// AlphaBlend - alpha blending
	AlphaBlend
)

type Animation

type Animation struct {
	Name     string
	Duration float64
	Channels []AnimationChannel
}

Animation represents a collection of animation channels

func NewAnimation

func NewAnimation(name string, duration float64) *Animation

NewAnimation creates a new animation

func (*Animation) AddChannel

func (anim *Animation) AddChannel(channel AnimationChannel)

AddChannel adds an animation channel to the animation

func (*Animation) Evaluate

func (anim *Animation) Evaluate(time float64)

Evaluate evaluates the animation at a specific time

type AnimationChannel

type AnimationChannel struct {
	Target        *SceneNode
	Property      AnimationProperty
	Keyframes     []Keyframe
	Interpolation InterpolationType
}

AnimationChannel represents animation data for a specific node and property

func (*AnimationChannel) Evaluate

func (channel *AnimationChannel) Evaluate(time float64)

Evaluate evaluates the animation channel at a specific time

type AnimationPlayer

type AnimationPlayer struct {
	// contains filtered or unexported fields
}

AnimationPlayer handles playback of animations

func NewAnimationPlayer

func NewAnimationPlayer() *AnimationPlayer

NewAnimationPlayer creates a new animation player

func (*AnimationPlayer) AddAnimation

func (player *AnimationPlayer) AddAnimation(name string, animation *Animation)

AddAnimation adds an animation to the player

func (*AnimationPlayer) Pause

func (player *AnimationPlayer) Pause()

Pause pauses the current animation

func (*AnimationPlayer) Play

func (player *AnimationPlayer) Play(name string) bool

Play starts playing an animation

func (*AnimationPlayer) Resume

func (player *AnimationPlayer) Resume()

Resume resumes the paused animation

func (*AnimationPlayer) SetPlaySpeed

func (player *AnimationPlayer) SetPlaySpeed(speed float64)

SetPlaySpeed sets the playback speed

func (*AnimationPlayer) Stop

func (player *AnimationPlayer) Stop()

Stop stops the current animation

func (*AnimationPlayer) Update

func (player *AnimationPlayer) Update(deltaTime float64)

Update updates the animation player

type AnimationProperty

type AnimationProperty int

AnimationProperty represents what property is being animated

const (
	// Translation animates node translation
	Translation AnimationProperty = iota
	// Rotation animates node rotation
	Rotation
	// ScaleProperty animates node scale
	ScaleProperty
	// Weights animates morph target weights
	Weights
	// Joints animates skinned mesh joints
	Joints
)

type BloomEffect

type BloomEffect struct {
	Threshold  float64
	BlurRadius int
	Intensity  float64
}

BloomEffect implements a bloom effect

func NewBloomEffect

func NewBloomEffect(threshold float64, blurRadius int, intensity float64) *BloomEffect

NewBloomEffect creates a new bloom effect

func (*BloomEffect) Apply

func (be *BloomEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies the bloom effect to the input image

type BlurEffect

type BlurEffect struct {
	Radius int
}

BlurEffect implements a simple blur effect

func NewBlurEffect

func NewBlurEffect(radius int) *BlurEffect

NewBlurEffect creates a new blur effect

func (*BlurEffect) Apply

func (be *BlurEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies the blur effect to the input image

type Box

type Box struct {
	Min, Max Vector
}

func (Box) Anchor

func (a Box) Anchor(anchor Vector) Vector

func (Box) Center

func (a Box) Center() Vector

func (Box) Contains

func (a Box) Contains(b Vector) bool

func (Box) Extend

func (a Box) Extend(b Box) Box

func (Box) Intersection

func (a Box) Intersection(b Box) Box

func (Box) Intersects

func (a Box) Intersects(b Box) bool

func (Box) Offset

func (a Box) Offset(x float64) Box

func (Box) Size

func (a Box) Size() Vector

func (Box) Transform

func (a Box) Transform(m Matrix) Box

func (Box) Translate

func (a Box) Translate(v Vector) Box

type Camera

type Camera struct {
	Name           string
	Position       Vector
	Target         Vector
	Up             Vector
	FOV            float64 // Field of view in radians
	AspectRatio    float64
	NearPlane      float64
	FarPlane       float64
	ProjectionType ProjectionType
	OrthoSize      float64 // For orthographic projection
}

Camera represents a camera in the scene

func NewOrthographicCamera

func NewOrthographicCamera(name string, position, target, up Vector, orthoSize, aspectRatio, near, far float64) *Camera

NewOrthographicCamera creates a new orthographic camera

func NewPerspectiveCamera

func NewPerspectiveCamera(name string, position, target, up Vector, fov, aspectRatio, near, far float64) *Camera

NewPerspectiveCamera creates a new perspective camera

func (*Camera) GetCameraMatrix

func (camera *Camera) GetCameraMatrix() Matrix

GetCameraMatrix returns the combined view-projection matrix

func (*Camera) GetProjectionMatrix

func (camera *Camera) GetProjectionMatrix() Matrix

GetProjectionMatrix returns the projection matrix for the camera

func (*Camera) GetViewMatrix

func (camera *Camera) GetViewMatrix() Matrix

GetViewMatrix returns the view matrix for the camera

func (*Camera) LookAt

func (camera *Camera) LookAt(position, target, up Vector)

LookAt sets the camera to look at a specific target

func (*Camera) OrbitAroundTarget

func (camera *Camera) OrbitAroundTarget(horizontalAngle, verticalAngle float64)

OrbitAroundTarget orbits the camera around its target

type CascadeShadowMap

type CascadeShadowMap struct {
	ShadowMaps     []*ShadowMap
	LightMatrices  []Matrix
	SplitDistances []float64
}

CascadeShadowMap implements cascaded shadow maps for large scenes

func NewCascadeShadowMap

func NewCascadeShadowMap(numCascades int, shadowMapSize int) *CascadeShadowMap

NewCascadeShadowMap creates a new cascaded shadow map system

type ChannelTypeQualifiers

type ChannelTypeQualifiers uint8

ChannelTypeQualifiers 通道类型限定符

const (
	QualifierLinear   ChannelTypeQualifiers = 1 << 0
	QualifierExponent ChannelTypeQualifiers = 1 << 1
	QualifierSigned   ChannelTypeQualifiers = 1 << 2
	QualifierFloat    ChannelTypeQualifiers = 1 << 3
)

type ChromaticAberrationEffect

type ChromaticAberrationEffect struct {
	RedOffset   Vector
	GreenOffset Vector
	BlueOffset  Vector
}

ChromaticAberrationEffect implements chromatic aberration

func NewChromaticAberrationEffect

func NewChromaticAberrationEffect(redOffset, greenOffset, blueOffset Vector) *ChromaticAberrationEffect

NewChromaticAberrationEffect creates a new chromatic aberration effect

func (*ChromaticAberrationEffect) Apply

func (cae *ChromaticAberrationEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies chromatic aberration to the input image

type Color

type Color struct {
	R, G, B, A float64
}

Color color struct

func Gray

func Gray(x float64) Color

Gray returns gray of given value

func HexColor

func HexColor(x string) Color

HexColor converts hex string to color

func InterpolateColors

func InterpolateColors(v1, v2, v3 Color, b VectorW) Color

func MakeColor

func MakeColor(c color.Color) Color

MakeColor converts color from color module to fauxgl

func (Color) Add

func (a Color) Add(b Color) Color

Add adds two colors

func (Color) AddScalar

func (a Color) AddScalar(b float64) Color

AddScalar adds based on scalar

func (Color) Alpha

func (a Color) Alpha(alpha float64) Color

Alpha sets the alpha of a color

func (Color) Div

func (a Color) Div(b Color) Color

Div divides two colors

func (Color) DivScalar

func (a Color) DivScalar(b float64) Color

DivScalar divides based on scalar

func (Color) Lerp

func (a Color) Lerp(b Color, t float64) Color

Lerp lerps two colors

func (Color) Max

func (a Color) Max(b Color) Color

Max maxes each color value

func (Color) Min

func (a Color) Min(b Color) Color

Min minimums each color value

func (Color) Mul

func (a Color) Mul(b Color) Color

Mul multiplies two colors

func (Color) MulScalar

func (a Color) MulScalar(b float64) Color

MulScalar multiplies based on scalar

func (Color) NRGBA

func (a Color) NRGBA() color.NRGBA

NRGBA returns nrgba color from fauxgl color

func (Color) Opaque

func (a Color) Opaque() Color

Opaque makes a color opaque

func (Color) Pow

func (a Color) Pow(b float64) Color

Pow applies exponent to each value

func (Color) Sub

func (a Color) Sub(b Color) Color

Sub subtracts two colors

func (Color) SubScalar

func (a Color) SubScalar(b float64) Color

SubScalar subtracts based on scalar

type ColorGradingEffect

type ColorGradingEffect struct {
	Brightness float64
	Contrast   float64
	Saturation float64
	HueShift   float64
}

ColorGradingEffect implements color grading

func NewColorGradingEffect

func NewColorGradingEffect(brightness, contrast, saturation, hueShift float64) *ColorGradingEffect

NewColorGradingEffect creates a new color grading effect

func (*ColorGradingEffect) Apply

func (cge *ColorGradingEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies color grading to the input image

type ColorModel

type ColorModel uint8

ColorModel 颜色模型

const (
	ColorModelUnspecified ColorModel = 0
	ColorModelRGBSDA      ColorModel = 1
	ColorModelYUVSDA      ColorModel = 2
	ColorModelYIQSDA      ColorModel = 3
	ColorModelLabSDA      ColorModel = 4
	ColorModelCMYKA       ColorModel = 5
	ColorModelXYZSDA      ColorModel = 6
	ColorModelHSVSDA      ColorModel = 7
	ColorModelHSLSDA      ColorModel = 8
	ColorModelBC7M6       ColorModel = 9
)

func NewColorModel

func NewColorModel(value uint8) *ColorModel

func (ColorModel) Value

func (c ColorModel) Value() uint8

type ColorPrimaries

type ColorPrimaries uint8

ColorPrimaries 颜色原色

const (
	ColorPrimariesUnspecified ColorPrimaries = 0
	ColorPrimariesBT709       ColorPrimaries = 1
	ColorPrimariesBT2020      ColorPrimaries = 2
	ColorPrimariesACES        ColorPrimaries = 3
)

func NewColorPrimaries

func NewColorPrimaries(value uint8) *ColorPrimaries

func (ColorPrimaries) Value

func (c ColorPrimaries) Value() uint8

type CompositeEffect

type CompositeEffect struct {
	Effects []PostProcessingEffect
}

CompositeEffect combines multiple effects

func NewCompositeEffect

func NewCompositeEffect(effects ...PostProcessingEffect) *CompositeEffect

NewCompositeEffect creates a new composite effect

func (*CompositeEffect) Apply

func (ce *CompositeEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies all effects in the composite

type Context

type Context struct {
	Width       int
	Height      int
	ColorBuffer *image.NRGBA
	DepthBuffer []float64
	ClearColor  Color
	Shader      Shader
	ReadDepth   bool
	WriteDepth  bool
	WriteColor  bool
	AlphaBlend  bool
	Wireframe   bool
	FrontFace   Face
	Cull        Cull
	LineWidth   float64
	DepthBias   float64
	// contains filtered or unexported fields
}

func NewContext

func NewContext(width, height int) *Context

func (*Context) ClearColorBuffer

func (dc *Context) ClearColorBuffer()

func (*Context) ClearColorBufferWith

func (dc *Context) ClearColorBufferWith(color Color)

func (*Context) ClearDepthBuffer

func (dc *Context) ClearDepthBuffer()

func (*Context) ClearDepthBufferWith

func (dc *Context) ClearDepthBufferWith(value float64)

func (*Context) DepthImage

func (dc *Context) DepthImage() image.Image

func (*Context) DrawLine

func (dc *Context) DrawLine(t *Line) RasterizeInfo

func (*Context) DrawLines

func (dc *Context) DrawLines(lines []*Line) RasterizeInfo

func (*Context) DrawMesh

func (dc *Context) DrawMesh(mesh *Mesh) RasterizeInfo

func (*Context) DrawTriangle

func (dc *Context) DrawTriangle(t *Triangle) RasterizeInfo

func (*Context) DrawTriangles

func (dc *Context) DrawTriangles(triangles []*Triangle) RasterizeInfo

func (*Context) Image

func (dc *Context) Image() image.Image

type CubeMapTexture

type CubeMapTexture struct {
	Faces [6]*AdvancedTexture // +X, -X, +Y, -Y, +Z, -Z
}

CubeMapTexture represents a cube map texture for environment mapping

func NewCubeMapTexture

func NewCubeMapTexture(faces [6]*AdvancedTexture) *CubeMapTexture

NewCubeMapTexture creates a new cube map texture

func (*CubeMapTexture) SampleCubeMap

func (cubemap *CubeMapTexture) SampleCubeMap(direction Vector) Color

SampleCubeMap samples the cube map using a direction vector

type Cull

type Cull int

Cull f

const (

	// CullNone f
	CullNone Cull
	// CullFront f
	CullFront
	// CullBack f
	CullBack
)

type CullingSceneRenderer

type CullingSceneRenderer struct {
	*SceneRenderer
}

CullingSceneRenderer extends SceneRenderer with frustum culling

func NewCullingSceneRenderer

func NewCullingSceneRenderer(context *Context) *CullingSceneRenderer

NewCullingSceneRenderer creates a new culling scene renderer

func (*CullingSceneRenderer) RenderNodeWithCulling

func (csr *CullingSceneRenderer) RenderNodeWithCulling(node *SceneNode, cameraMatrix Matrix, lights []Light, frustum *ViewFrustum, cameraPos Vector)

RenderNodeWithCulling renders a single scene node with frustum culling

func (*CullingSceneRenderer) RenderScene

func (csr *CullingSceneRenderer) RenderScene(scene *Scene)

RenderScene renders a complete scene with frustum culling

type DFDBlock

type DFDBlock struct {
	Header *DFDHeader
	Data   []byte
}

DFDBlock 数据格式描述符块

type DFDBlockHeaderBasic

type DFDBlockHeaderBasic struct {
	ColorModel           *ColorModel       // 颜色模型
	ColorPrimaries       *ColorPrimaries   // 颜色原色
	TransferFunction     *TransferFunction // 传输函数
	Flags                DataFormatFlags   // 标志
	TexelBlockDimensions [4]uint8          // 纹素块维度 (每个值+1)
	BytesPlanes          [8]uint8          // 字节平面
}

DFDBlockHeaderBasic 基本数据格式描述符块头部

func DFDBlockHeaderBasicFromBytes

func DFDBlockHeaderBasicFromBytes(data []byte) (*DFDBlockHeaderBasic, error)

FromBytes 从字节数组解析基本DFD块头部

func (*DFDBlockHeaderBasic) AsBytes

func (d *DFDBlockHeaderBasic) AsBytes() []byte

AsBytes 将基本DFD块头部转换为字节数组

type DFDHeader

type DFDHeader struct {
	VendorID       uint32 // 供应商ID (17位)
	DescriptorType uint32 // 描述符类型 (15位)
	VersionNumber  uint16 // 版本号 (16位)
}

DFDHeader 数据格式描述符头部

func ParseDFDHeader

func ParseDFDHeader(data []byte) (*DFDHeader, int, error)

ParseDFDHeader 解析DFD头部

func (*DFDHeader) AsBytes

func (d *DFDHeader) AsBytes(descriptorBlockSize uint16) []byte

AsBytes 将DFD头部转换为字节数组

type DataFormatFlags

type DataFormatFlags uint8

DataFormatFlags 数据格式标志

const (
	StraightAlpha      DataFormatFlags = 0
	AlphaPremultiplied DataFormatFlags = 1 << 0
)

type DepthOfFieldEffect

type DepthOfFieldEffect struct {
	FocusDepth float64
	Aperture   float64
	Samples    int
}

DepthOfFieldEffect implements depth of field

func NewDepthOfFieldEffect

func NewDepthOfFieldEffect(focusDepth, aperture float64, samples int) *DepthOfFieldEffect

NewDepthOfFieldEffect creates a new depth of field effect

func (*DepthOfFieldEffect) Apply

func (dof *DepthOfFieldEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies depth of field to the input image Note: This is a simplified implementation that simulates DoF based on pixel position

type EXTMeshGPUInstancingExtension

type EXTMeshGPUInstancingExtension struct{}

EXTMeshGPUInstancingExtension handles GPU instancing

func (*EXTMeshGPUInstancingExtension) GetName

func (ext *EXTMeshGPUInstancingExtension) GetName() string

func (*EXTMeshGPUInstancingExtension) Process

func (ext *EXTMeshGPUInstancingExtension) Process(data map[string]interface{}, scene *Scene) error

type EXTTextureWebPExtension

type EXTTextureWebPExtension struct{}

EXTTextureWebPExtension handles WebP textures

func (*EXTTextureWebPExtension) GetName

func (ext *EXTTextureWebPExtension) GetName() string

func (*EXTTextureWebPExtension) Process

func (ext *EXTTextureWebPExtension) Process(data map[string]interface{}, scene *Scene) error

type EnvironmentShader

type EnvironmentShader struct {
	Matrix         Matrix
	CubeMap        *CubeMapTexture
	CameraPosition Vector
	Reflectance    float64
}

EnvironmentShader renders environment mapping and reflections

func NewEnvironmentShader

func NewEnvironmentShader(matrix Matrix, cubeMap *CubeMapTexture, cameraPos Vector) *EnvironmentShader

NewEnvironmentShader creates a new environment shader

func (*EnvironmentShader) Fragment

func (shader *EnvironmentShader) Fragment(v Vertex) Color

Fragment performs environment mapping

func (*EnvironmentShader) Vertex

func (shader *EnvironmentShader) Vertex(v Vertex) Vertex

Vertex processes vertices for environment mapping

type ExtensionRegistry

type ExtensionRegistry struct {
	// contains filtered or unexported fields
}

ExtensionRegistry manages GLTF extensions

func NewExtensionRegistry

func NewExtensionRegistry() *ExtensionRegistry

NewExtensionRegistry creates a new extension registry

func (*ExtensionRegistry) GetSupportedExtensions

func (reg *ExtensionRegistry) GetSupportedExtensions() []string

GetSupportedExtensions returns a list of supported extension names

func (*ExtensionRegistry) ProcessExtensions

func (reg *ExtensionRegistry) ProcessExtensions(extensions map[string]interface{}, scene *Scene) error

ProcessExtensions processes GLTF extensions

func (*ExtensionRegistry) RegisterHandler

func (reg *ExtensionRegistry) RegisterHandler(handler GLTFExtensionHandler)

RegisterHandler registers an extension handler

type FXAAEffect

type FXAAEffect struct {
	SpanMax   float64
	ReduceMul float64
}

FXAAEffect implements Fast Approximate Anti-Aliasing

func NewFXAAEffect

func NewFXAAEffect() *FXAAEffect

NewFXAAEffect creates a new FXAA effect

func (*FXAAEffect) Apply

func (fxaa *FXAAEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies FXAA to the input image

type Face

type Face int

Face f

const (

	// FaceCW f
	FaceCW Face
	// FaceCCW f
	FaceCCW
)

type FirstPersonCamera

type FirstPersonCamera struct {
	*Camera
	Yaw   float64
	Pitch float64
	Speed float64
}

FirstPersonCamera implements a first-person camera controller

func NewFirstPersonCamera

func NewFirstPersonCamera(name string, position Vector, fov, aspectRatio, near, far float64) *FirstPersonCamera

NewFirstPersonCamera creates a new first-person camera

func (*FirstPersonCamera) Move

func (fpc *FirstPersonCamera) Move(direction Vector)

Move moves the camera in the specified direction

func (*FirstPersonCamera) Rotate

func (fpc *FirstPersonCamera) Rotate(yawDelta, pitchDelta float64)

Rotate rotates the camera view

func (*FirstPersonCamera) Update

func (fpc *FirstPersonCamera) Update()

Update updates the first-person camera orientation

type Format

type Format uint32

Format KTX2格式枚举

const (
	FormatUndefined Format = 0
)

常见的KTX2格式常量

func NewFormat

func NewFormat(value uint32) *Format

func (Format) Value

func (f Format) Value() uint32

type GLTFExtension

type GLTFExtension struct {
	Name string
	Data map[string]interface{}
}

GLTFExtension represents a GLTF extension

type GLTFExtensionHandler

type GLTFExtensionHandler interface {
	GetName() string
	Process(data map[string]interface{}, scene *Scene) error
}

GLTFExtensionHandler handles specific GLTF extensions

type GLTFLoader

type GLTFLoader struct {
	// contains filtered or unexported fields
}

GLTFLoader handles loading of GLTF files

type Header struct {
	Format                 *Format                 // VkFormat
	TypeSize               uint32                  // 类型大小
	PixelWidth             uint32                  // 像素宽度
	PixelHeight            uint32                  // 像素高度
	PixelDepth             uint32                  // 像素深度
	LayerCount             uint32                  // 层数
	FaceCount              uint32                  // 面数
	LevelCount             uint32                  // 级别数
	SupercompressionScheme *SupercompressionScheme // 超级压缩方案
	Index                  Index                   // 索引信息
}

Header KTX2容器级元数据

func GetKTX2Info

func GetKTX2Info(data []byte) (*Header, error)

GetKTX2Info extracts basic information from KTX2 file without full parsing

func HeaderFromBytes

func HeaderFromBytes(data []byte) (*Header, error)

FromBytes 从字节数组解析头部

func (*Header) AsBytes

func (h *Header) AsBytes() []byte

AsBytes 将头部转换为字节数组

type Index

type Index struct {
	DFDByteOffset uint32 // 数据格式描述符字节偏移量
	DFDByteLength uint32 // 数据格式描述符字节长度
	KVDByteOffset uint32 // 键值数据字节偏移量
	KVDByteLength uint32 // 键值数据字节长度
	SGDByteOffset uint64 // 超级压缩全局数据字节偏移量
	SGDByteLength uint64 // 超级压缩全局数据字节长度
}

Index KTX2文件各部分的字节偏移量和大小索引

type InterpolationType

type InterpolationType int

InterpolationType represents how values are interpolated between keyframes

const (
	// Linear interpolation
	Linear InterpolationType = iota
	// Step interpolation (no interpolation)
	Step
	// CubicSpline interpolation
	CubicSpline
)

type Joint

type Joint struct {
	Node              *SceneNode
	InverseBindMatrix Matrix
	JointMatrix       Matrix // Computed joint matrix
}

Joint represents a joint/bone in skeletal animation

type KHRAnimationPointerExtension

type KHRAnimationPointerExtension struct{}

KHRAnimationPointerExtension handles animation pointer targeting

func (*KHRAnimationPointerExtension) GetName

func (ext *KHRAnimationPointerExtension) GetName() string

func (*KHRAnimationPointerExtension) Process

func (ext *KHRAnimationPointerExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRLightsPunctualExtension

type KHRLightsPunctualExtension struct{}

KHRLightsPunctualExtension handles KHR_lights_punctual extension

func (*KHRLightsPunctualExtension) GetName

func (ext *KHRLightsPunctualExtension) GetName() string

func (*KHRLightsPunctualExtension) Process

func (ext *KHRLightsPunctualExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsAnisotropyExtension

type KHRMaterialsAnisotropyExtension struct{}

KHRMaterialsAnisotropyExtension handles anisotropic materials

func (*KHRMaterialsAnisotropyExtension) GetName

func (ext *KHRMaterialsAnisotropyExtension) GetName() string

func (*KHRMaterialsAnisotropyExtension) Process

func (ext *KHRMaterialsAnisotropyExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsClearcoatExtension

type KHRMaterialsClearcoatExtension struct{}

KHRMaterialsClearcoatExtension handles clearcoat materials

func (*KHRMaterialsClearcoatExtension) GetName

func (ext *KHRMaterialsClearcoatExtension) GetName() string

func (*KHRMaterialsClearcoatExtension) Process

func (ext *KHRMaterialsClearcoatExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsDispersionExtension

type KHRMaterialsDispersionExtension struct{}

KHRMaterialsDispersionExtension handles chromatic dispersion

func (*KHRMaterialsDispersionExtension) GetName

func (ext *KHRMaterialsDispersionExtension) GetName() string

func (*KHRMaterialsDispersionExtension) Process

func (ext *KHRMaterialsDispersionExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsEmissiveStrengthExtension

type KHRMaterialsEmissiveStrengthExtension struct{}

KHRMaterialsEmissiveStrengthExtension handles enhanced emissive strength

func (*KHRMaterialsEmissiveStrengthExtension) GetName

func (*KHRMaterialsEmissiveStrengthExtension) Process

func (ext *KHRMaterialsEmissiveStrengthExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsIORExtension

type KHRMaterialsIORExtension struct{}

KHRMaterialsIORExtension handles index of refraction

func (*KHRMaterialsIORExtension) GetName

func (ext *KHRMaterialsIORExtension) GetName() string

func (*KHRMaterialsIORExtension) Process

func (ext *KHRMaterialsIORExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsIridescenceExtension

type KHRMaterialsIridescenceExtension struct{}

KHRMaterialsIridescenceExtension handles iridescent materials

func (*KHRMaterialsIridescenceExtension) GetName

func (*KHRMaterialsIridescenceExtension) Process

func (ext *KHRMaterialsIridescenceExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsPBRSpecularGlossinessExtension

type KHRMaterialsPBRSpecularGlossinessExtension struct{}

KHRMaterialsPBRSpecularGlossinessExtension handles PBR specular-glossiness workflow

func (*KHRMaterialsPBRSpecularGlossinessExtension) GetName

func (*KHRMaterialsPBRSpecularGlossinessExtension) Process

func (ext *KHRMaterialsPBRSpecularGlossinessExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsSheenExtension

type KHRMaterialsSheenExtension struct{}

KHRMaterialsSheenExtension handles fabric sheen effect

func (*KHRMaterialsSheenExtension) GetName

func (ext *KHRMaterialsSheenExtension) GetName() string

func (*KHRMaterialsSheenExtension) Process

func (ext *KHRMaterialsSheenExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsSpecularExtension

type KHRMaterialsSpecularExtension struct{}

KHRMaterialsSpecularExtension handles enhanced specular reflection

func (*KHRMaterialsSpecularExtension) GetName

func (ext *KHRMaterialsSpecularExtension) GetName() string

func (*KHRMaterialsSpecularExtension) Process

func (ext *KHRMaterialsSpecularExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsTransmissionExtension

type KHRMaterialsTransmissionExtension struct{}

KHRMaterialsTransmissionExtension handles material transmission

func (*KHRMaterialsTransmissionExtension) GetName

func (*KHRMaterialsTransmissionExtension) Process

func (ext *KHRMaterialsTransmissionExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsUnlitExtension

type KHRMaterialsUnlitExtension struct{}

KHRMaterialsUnlitExtension handles KHR_materials_unlit extension

func (*KHRMaterialsUnlitExtension) GetName

func (ext *KHRMaterialsUnlitExtension) GetName() string

func (*KHRMaterialsUnlitExtension) Process

func (ext *KHRMaterialsUnlitExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsVariantsExtension

type KHRMaterialsVariantsExtension struct{}

KHRMaterialsVariantsExtension handles material variants

func (*KHRMaterialsVariantsExtension) GetName

func (ext *KHRMaterialsVariantsExtension) GetName() string

func (*KHRMaterialsVariantsExtension) Process

func (ext *KHRMaterialsVariantsExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMaterialsVolumeExtension

type KHRMaterialsVolumeExtension struct{}

KHRMaterialsVolumeExtension handles volumetric materials

func (*KHRMaterialsVolumeExtension) GetName

func (ext *KHRMaterialsVolumeExtension) GetName() string

func (*KHRMaterialsVolumeExtension) Process

func (ext *KHRMaterialsVolumeExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRMeshQuantizationExtension

type KHRMeshQuantizationExtension struct{}

KHRMeshQuantizationExtension handles mesh quantization

func (*KHRMeshQuantizationExtension) GetName

func (ext *KHRMeshQuantizationExtension) GetName() string

func (*KHRMeshQuantizationExtension) Process

func (ext *KHRMeshQuantizationExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRTextureBasisuExtension

type KHRTextureBasisuExtension struct{}

KHRTextureBasisuExtension handles KTX2/Basis Universal textures

func (*KHRTextureBasisuExtension) GetName

func (ext *KHRTextureBasisuExtension) GetName() string

func (*KHRTextureBasisuExtension) Process

func (ext *KHRTextureBasisuExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRTextureTransformExtension

type KHRTextureTransformExtension struct{}

KHRTextureTransformExtension handles texture coordinate transformations

func (*KHRTextureTransformExtension) GetName

func (ext *KHRTextureTransformExtension) GetName() string

func (*KHRTextureTransformExtension) Process

func (ext *KHRTextureTransformExtension) Process(data map[string]interface{}, scene *Scene) error

type KHRXMPJsonLdExtension

type KHRXMPJsonLdExtension struct{}

KHRXMPJsonLdExtension handles XMP metadata

func (*KHRXMPJsonLdExtension) GetName

func (ext *KHRXMPJsonLdExtension) GetName() string

func (*KHRXMPJsonLdExtension) Process

func (ext *KHRXMPJsonLdExtension) Process(data map[string]interface{}, scene *Scene) error

type KTX2TextureLoader

type KTX2TextureLoader struct {
	// contains filtered or unexported fields
}

KTX2TextureLoader handles loading of KTX2 format textures

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value []byte
}

KeyValuePair 键值对

type Keyframe

type Keyframe struct {
	Time  float64
	Value interface{} // Can be Vector, Quaternion, float64, etc.
}

Keyframe represents a single keyframe in an animation

type Level

type Level struct {
	Data                   []byte // 层级数据
	UncompressedByteLength uint64 // 未压缩字节长度
}

Level 纹理层级数据

type LevelIndex

type LevelIndex struct {
	ByteOffset             uint64 // 字节偏移量
	ByteLength             uint64 // 字节长度
	UncompressedByteLength uint64 // 未压缩字节长度
}

LevelIndex 级别索引信息

func LevelIndexFromBytes

func LevelIndexFromBytes(data []byte) (*LevelIndex, error)

FromBytes 从字节数组解析级别索引

func (*LevelIndex) AsBytes

func (l *LevelIndex) AsBytes() []byte

AsBytes 将级别索引转换为字节数组

type Light

type Light struct {
	Type      LightType
	Position  Vector
	Direction Vector
	Color     Color
	Intensity float64
	Range     float64
	InnerCone float64 // For spot lights
	OuterCone float64 // For spot lights
}

Light represents a light source

type LightType

type LightType int

LightType represents the type of light

const (
	// DirectionalLight - parallel rays (sun)
	DirectionalLight LightType = iota
	// PointLight - omnidirectional point light
	PointLight
	// SpotLight - cone-shaped light
	SpotLight
	// AmbientLight - uniform ambient lighting
	AmbientLight
)

type Line

type Line struct {
	V1, V2 Vertex
}

Line f

func ClipLine

func ClipLine(l *Line) *Line

ClipLine clips a line against the viewing frustum

func NewLine

func NewLine(v1, v2 Vertex) *Line

NewLine f

func NewLineForPoints

func NewLineForPoints(p1, p2 Vector) *Line

NewLineForPoints f

func (*Line) BoundingBox

func (l *Line) BoundingBox() Box

BoundingBox f

func (*Line) Transform

func (l *Line) Transform(matrix Matrix)

Transform F

type Matrix

type Matrix struct {
	X00, X01, X02, X03 float64
	X10, X11, X12, X13 float64
	X20, X21, X22, X23 float64
	X30, X31, X32, X33 float64
}

Matrix f

func Frustum

func Frustum(l, r, b, t, n, f float64) Matrix

Frustum f

func Identity

func Identity() Matrix

Identity f

func LookAt

func LookAt(eye, center, up Vector) Matrix

LookAt f

func LookAtDirection

func LookAtDirection(forward, up Vector) Matrix

LookAtDirection f

func Orient

func Orient(position, size, up Vector, rotation float64) Matrix

Orient f

func Orthographic

func Orthographic(l, r, b, t, n, f float64) Matrix

Orthographic f

func Perspective

func Perspective(fovy, aspect, near, far float64) Matrix

Perspective f

func Rotate

func Rotate(v Vector, a float64) Matrix

Rotate f

func RotateTo

func RotateTo(a, b Vector) Matrix

RotateTo f

func Scale

func Scale(v Vector) Matrix

Scale f

func Screen

func Screen(w, h int) Matrix

Screen f

func Translate

func Translate(v Vector) Matrix

Translate f

func Viewport

func Viewport(x, y, w, h float64) Matrix

Viewport f

func (Matrix) Determinant

func (a Matrix) Determinant() float64

Determinant f

func (Matrix) Frustum

func (a Matrix) Frustum(l, r, b, t, n, f float64) Matrix

Frustum f

func (Matrix) Inverse

func (a Matrix) Inverse() Matrix

Inverse f

func (Matrix) LookAt

func (a Matrix) LookAt(eye, center, up Vector) Matrix

LookAt f

func (Matrix) Mul

func (a Matrix) Mul(b Matrix) Matrix

Mul f

func (Matrix) MulBox

func (a Matrix) MulBox(box Box) Box

MulBox f

func (Matrix) MulDirection

func (a Matrix) MulDirection(b Vector) Vector

MulDirection f

func (Matrix) MulPosition

func (a Matrix) MulPosition(b Vector) Vector

MulPosition f

func (Matrix) MulPositionW

func (a Matrix) MulPositionW(b Vector) VectorW

MulPositionW f

func (Matrix) Orthographic

func (a Matrix) Orthographic(l, r, b, t, n, f float64) Matrix

Orthographic f

func (Matrix) Perspective

func (a Matrix) Perspective(fovy, aspect, near, far float64) Matrix

Perspective f

func (Matrix) Rotate

func (a Matrix) Rotate(v Vector, f float64) Matrix

Rotate f

func (Matrix) RotateTo

func (a Matrix) RotateTo(b, c Vector) Matrix

RotateTo f

func (Matrix) Scale

func (a Matrix) Scale(v Vector) Matrix

Scale f

func (Matrix) Translate

func (a Matrix) Translate(v Vector) Matrix

Translate f

func (Matrix) Transpose

func (a Matrix) Transpose() Matrix

Transpose f

type Mesh

type Mesh struct {
	Triangles []*Triangle
	Lines     []*Line
	// contains filtered or unexported fields
}

Mesh f

func ApplyMorphTargets

func ApplyMorphTargets(baseMesh *Mesh, targets *MorphTargets) *Mesh

ApplyMorphTargets applies morph target deformation to mesh

func NewCapsule

func NewCapsule(radius, height float64, radialSegments, heightSegments, capSegments int) *Mesh

NewCapsule creates a capsule (cylinder with hemispherical caps)

func NewCone

func NewCone(step int, capped bool) *Mesh

NewCone f

func NewCube

func NewCube() *Mesh

NewCube f

func NewCubeForBox

func NewCubeForBox(box Box) *Mesh

NewCubeForBox f

func NewCubeOutlineForBox

func NewCubeOutlineForBox(box Box) *Mesh

NewCubeOutlineForBox f

func NewCylinder

func NewCylinder(radius, height float64, radialSegments, heightSegments int, openEnded bool) *Mesh

NewCylinder creates a cylinder with the specified parameters

func NewEmptyMesh

func NewEmptyMesh() *Mesh

NewEmptyMesh returns an empty mesh

func NewIcosahedron

func NewIcosahedron() *Mesh

NewIcosahedron f

func NewLineMesh

func NewLineMesh(lines []*Line) *Mesh

NewLineMesh returns a mesh with given data

func NewMesh

func NewMesh(triangles []*Triangle, lines []*Line) *Mesh

NewMesh returns a mesh with given data

func NewPlane

func NewPlane(width, height float64) *Mesh

NewPlane creates a plane centered at the origin

func NewSphere

func NewSphere(detail int) *Mesh

NewSphere f

func NewTorus

func NewTorus(radius, tubeRadius float64, radialSegments, tubularSegments int) *Mesh

NewTorus creates a torus with the specified parameters

func NewTriangleMesh

func NewTriangleMesh(triangles []*Triangle) *Mesh

NewTriangleMesh returns a mesh with given data

func (*Mesh) Add

func (m *Mesh) Add(b *Mesh)

Add f

func (*Mesh) BiUnitCube

func (m *Mesh) BiUnitCube() Matrix

BiUnitCube f

func (*Mesh) BoundingBox

func (m *Mesh) BoundingBox() Box

BoundingBox f

func (*Mesh) Center

func (m *Mesh) Center() Matrix

Center f

func (*Mesh) Copy

func (m *Mesh) Copy() *Mesh

Copy f

func (*Mesh) FitInside

func (m *Mesh) FitInside(box Box, anchor Vector) Matrix

FitInside f

func (*Mesh) MoveTo

func (m *Mesh) MoveTo(position, anchor Vector) Matrix

MoveTo f

func (*Mesh) ReverseWinding

func (m *Mesh) ReverseWinding()

ReverseWinding f

func (*Mesh) SharpEdges

func (m *Mesh) SharpEdges(angleThreshold float64) *Mesh

func (*Mesh) Simplify

func (m *Mesh) Simplify(factor float64)

Simplify f

func (*Mesh) Smooth

func (m *Mesh) Smooth(iterations int) *Mesh

Smooth smooths a mesh by averaging vertex positions

func (*Mesh) SmoothNormals

func (m *Mesh) SmoothNormals()

SmoothNormals f

func (*Mesh) SmoothNormalsThreshold

func (m *Mesh) SmoothNormalsThreshold(radians float64)

SmoothNormalsThreshold f

func (*Mesh) SplitTriangles

func (m *Mesh) SplitTriangles(maxEdgeLength float64)

func (*Mesh) Subdivide

func (m *Mesh) Subdivide() *Mesh

Subdivide subdivides a mesh using loop subdivision

func (*Mesh) SurfaceArea

func (m *Mesh) SurfaceArea() float64

SurfaceArea f

func (*Mesh) Tessellate

func (m *Mesh) Tessellate(maxEdgeLength float64) *Mesh

Tessellate tessellates a mesh by splitting triangles

func (*Mesh) Transform

func (m *Mesh) Transform(matrix Matrix)

Transform f

func (*Mesh) UnitCube

func (m *Mesh) UnitCube() Matrix

UnitCube f

func (*Mesh) Volume

func (m *Mesh) Volume() float64

Volume f

func (*Mesh) WeldVertices

func (m *Mesh) WeldVertices(threshold float64)

WeldVertices welds vertices that are very close to each other

type MetallicRoughnessShader

type MetallicRoughnessShader struct {
	*PBRShader
	BaseColorTexture         *AdvancedTexture
	MetallicRoughnessTexture *AdvancedTexture
	NormalTexture            *AdvancedTexture
	OcclusionTexture         *AdvancedTexture
	EmissiveTexture          *AdvancedTexture
}

MetallicRoughnessShader is a specialized PBR shader for metallic-roughness workflow

func NewMetallicRoughnessShader

func NewMetallicRoughnessShader(matrix Matrix, lights []Light, cameraPos Vector) *MetallicRoughnessShader

NewMetallicRoughnessShader creates a metallic-roughness PBR shader

func (*MetallicRoughnessShader) Fragment

func (shader *MetallicRoughnessShader) Fragment(v Vertex) Color

Fragment performs metallic-roughness PBR shading

type MorphTarget

type MorphTarget struct {
	Name      string
	Positions []Vector // Target positions
	Normals   []Vector // Target normals (optional)
	Tangents  []Vector // Target tangents (optional)
}

MorphTarget represents a morph target for shape interpolation

func NewMorphTarget

func NewMorphTarget(name string, vertexCount int) *MorphTarget

NewMorphTarget creates a new morph target

type MorphTargets

type MorphTargets struct {
	Targets []MorphTarget
	Weights []float64
}

MorphTargets represents a collection of morph targets

type MotionBlurEffect

type MotionBlurEffect struct {
	Angle   float64
	Length  float64
	Samples int
}

MotionBlurEffect implements motion blur

func NewMotionBlurEffect

func NewMotionBlurEffect(angle, length float64, samples int) *MotionBlurEffect

NewMotionBlurEffect creates a new motion blur effect

func (*MotionBlurEffect) Apply

func (mbe *MotionBlurEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies motion blur to the input image

type OmniShadowMap

type OmniShadowMap struct {
	ShadowMaps    []*ShadowMap // 6 shadow maps for cube faces
	LightPosition Vector
	LightMatrices []Matrix
}

OmniShadowMap implements omnidirectional shadow mapping for point lights

func NewOmniShadowMap

func NewOmniShadowMap(shadowMapSize int, lightPosition Vector) *OmniShadowMap

NewOmniShadowMap creates a new omnidirectional shadow map for point lights

type OrbitCamera

type OrbitCamera struct {
	*Camera
	Target          Vector
	Distance        float64
	HorizontalAngle float64
	VerticalAngle   float64
}

OrbitCamera implements an orbiting camera controller

func NewOrbitCamera

func NewOrbitCamera(name string, target Vector, distance, fov, aspectRatio, near, far float64) *OrbitCamera

NewOrbitCamera creates a new orbit camera

func (*OrbitCamera) Rotate

func (oc *OrbitCamera) Rotate(horizontalDelta, verticalDelta float64)

Rotate rotates the camera around the target

func (*OrbitCamera) Update

func (oc *OrbitCamera) Update()

Update updates the orbit camera position based on angles

func (*OrbitCamera) Zoom

func (oc *OrbitCamera) Zoom(delta float64)

Zoom zooms the camera in or out

type PBRLighting

type PBRLighting struct{}

PBRLighting contains PBR lighting calculation functions

func (*PBRLighting) CalculatePBR

func (pbrL *PBRLighting) CalculatePBR(
	material *SampledMaterial,
	worldPos Vector,
	worldNormal Vector,
	viewDir Vector,
	lights []Light,
	ambientColor Color,
) Color

CalculatePBR performs PBR lighting calculation

type PBRMaterial

type PBRMaterial struct {
	// Base color and alpha
	BaseColorFactor  Color
	BaseColorTexture Texture

	// Metallic-Roughness workflow
	MetallicFactor           float64
	RoughnessFactor          float64
	MetallicRoughnessTexture Texture

	// Specular-Glossiness workflow (legacy support)
	DiffuseFactor             Color
	SpecularFactor            Color
	GlossinessFactor          float64
	DiffuseTexture            Texture
	SpecularGlossinessTexture Texture

	// Normal mapping
	NormalTexture Texture
	NormalScale   float64

	// Occlusion mapping
	OcclusionTexture  Texture
	OcclusionStrength float64

	// Emissive mapping
	EmissiveFactor  Color
	EmissiveTexture Texture

	// Extended material properties (GLTF Extensions)
	// KHR_materials_emissive_strength
	EmissiveStrength float64

	// KHR_materials_ior
	IOR float64 // Index of Refraction

	// KHR_materials_specular
	SpecularColorFactor  Color
	SpecularColorTexture Texture
	SpecularTexture      Texture

	// KHR_materials_transmission
	TransmissionFactor  float64
	TransmissionTexture Texture

	// KHR_materials_volume
	ThicknessFactor     float64
	ThicknessTexture    Texture
	AttenuationDistance float64
	AttenuationColor    Color

	// KHR_materials_anisotropy
	AnisotropyStrength float64
	AnisotropyRotation float64
	AnisotropyTexture  Texture

	// KHR_materials_sheen
	SheenColorFactor      Color
	SheenRoughnessFactor  float64
	SheenColorTexture     Texture
	SheenRoughnessTexture Texture

	// KHR_materials_iridescence
	IridescenceFactor           float64
	IridescenceIor              float64
	IridescenceThicknessMinimum float64
	IridescenceThicknessMaximum float64
	IridescenceTexture          Texture
	IridescenceThicknessTexture Texture

	// KHR_materials_dispersion
	DispersionFactor float64

	// KHR_materials_clearcoat
	ClearcoatFactor           float64
	ClearcoatRoughnessFactor  float64
	ClearcoatTexture          Texture
	ClearcoatRoughnessTexture Texture
	ClearcoatNormalTexture    Texture

	// Additional properties
	AlphaCutoff float64
	AlphaMode   AlphaMode
	DoubleSided bool
	Workflow    PBRWorkflow
}

PBRMaterial represents a physically-based rendering material

func NewPBRMaterial

func NewPBRMaterial() *PBRMaterial

NewPBRMaterial creates a new PBR material with default values

func (*PBRMaterial) Sample

func (m *PBRMaterial) Sample(u, v float64) *SampledMaterial

Sample samples the material at given texture coordinates

type PBRShader

type PBRShader struct {
	Matrix         Matrix
	Material       *PBRMaterial
	Lights         []Light
	AmbientColor   Color
	CameraPosition Vector
	// contains filtered or unexported fields
}

PBRShader implements physically-based rendering

func NewPBRShader

func NewPBRShader(matrix Matrix, material *PBRMaterial, lights []Light, cameraPos Vector) *PBRShader

NewPBRShader creates a new PBR shader

func (*PBRShader) Fragment

func (shader *PBRShader) Fragment(v Vertex) Color

Fragment performs PBR shading calculations

func (*PBRShader) Vertex

func (shader *PBRShader) Vertex(v Vertex) Vertex

Vertex processes a vertex through the PBR shader pipeline

type PBRWorkflow

type PBRWorkflow int

PBRWorkflow represents the type of PBR workflow

const (
	// MetallicRoughness is the metallic-roughness workflow
	MetallicRoughness PBRWorkflow = iota
	// SpecularGlossiness is the specular-glossiness workflow (legacy)
	SpecularGlossiness
)

type PCSShadowReceiverShader

type PCSShadowReceiverShader struct {
	*ShadowReceiverShader
	BlockerSearchSamples int
	PCFSamples           int
	LightSize            float64
}

PCSShadowReceiverShader implements Percentage Closer Soft Shadows

func NewPCSShadowReceiverShader

func NewPCSShadowReceiverShader(matrix, lightMatrix Matrix, lightDirection, cameraPosition Vector, shadowMap *ShadowMap) *PCSShadowReceiverShader

NewPCSShadowReceiverShader creates a new PCSS shadow receiver shader

type ParseError

type ParseError int

ParseError KTX2解析错误类型

const (
	UnexpectedEnd ParseError = iota
	BadMagic
	ZeroWidth
	ZeroFaceCount
	InvalidSampleBitLength
)

func (ParseError) Error

func (e ParseError) Error() string

type PhongShader

type PhongShader struct {
	Matrix         Matrix
	LightDirection Vector
	CameraPosition Vector
	ObjectColor    Color
	AmbientColor   Color
	DiffuseColor   Color
	SpecularColor  Color
	Texture        Texture
	SpecularPower  float64
}

PhongShader implements Phong shading with an optional texture.

func NewPhongShader

func NewPhongShader(matrix Matrix, lightDirection, cameraPosition Vector) *PhongShader

NewPhongShader f

func (*PhongShader) Fragment

func (shader *PhongShader) Fragment(v Vertex) Color

func (*PhongShader) Vertex

func (shader *PhongShader) Vertex(v Vertex) Vertex

Vertex f

type Plane

type Plane struct {
	Normal   Vector
	Distance float64
}

Plane represents a plane in 3D space

type PostProcessingEffect

type PostProcessingEffect interface {
	Apply(input *image.NRGBA) *image.NRGBA
}

PostProcessingEffect represents a post-processing effect

type PostProcessingPipeline

type PostProcessingPipeline struct {
	Effects []PostProcessingEffect
}

PostProcessingPipeline represents a chain of post-processing effects

func NewPostProcessingPipeline

func NewPostProcessingPipeline() *PostProcessingPipeline

NewPostProcessingPipeline creates a new post-processing pipeline

func (*PostProcessingPipeline) AddEffect

func (pp *PostProcessingPipeline) AddEffect(effect PostProcessingEffect)

AddEffect adds an effect to the pipeline

func (*PostProcessingPipeline) Process

func (pp *PostProcessingPipeline) Process(input *image.NRGBA) *image.NRGBA

Process applies all effects in the pipeline

type ProjectionType

type ProjectionType int

ProjectionType represents the type of camera projection

const (
	// PerspectiveProjection uses perspective projection
	PerspectiveProjection ProjectionType = iota
	// OrthographicProjection uses orthographic projection
	OrthographicProjection
)

type Quaternion

type Quaternion struct {
	X, Y, Z, W float64
}

Quaternion represents a rotation quaternion

func IdentityQuaternion

func IdentityQuaternion() Quaternion

Identity returns the identity quaternion

func NewQuaternion

func NewQuaternion(x, y, z, w float64) Quaternion

NewQuaternion creates a new quaternion

func QuaternionFromAxisAngle

func QuaternionFromAxisAngle(axis Vector, angle float64) Quaternion

FromAxisAngle creates a quaternion from axis and angle

func (Quaternion) Normalize

func (q Quaternion) Normalize() Quaternion

Normalize normalizes the quaternion

func (Quaternion) Slerp

func (q1 Quaternion) Slerp(q2 Quaternion, t float64) Quaternion

Slerp performs spherical linear interpolation between two quaternions

func (Quaternion) ToMatrix

func (q Quaternion) ToMatrix() Matrix

ToMatrix converts quaternion to rotation matrix

type RasterizeInfo

type RasterizeInfo struct {
	TotalPixels   uint64
	UpdatedPixels uint64
}

RasterizeInfo f

func (RasterizeInfo) Add

func (info RasterizeInfo) Add(other RasterizeInfo) RasterizeInfo

Add f

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader KTX2解码器

func NewKTX2Reader

func NewKTX2Reader(input []byte) (*Reader, error)

NewReader 创建新的KTX2解码器

func (*Reader) DFDBlocks

func (r *Reader) DFDBlocks() ([]*DFDBlock, error)

DFDBlocks 返回数据格式描述符块

func (*Reader) Data

func (r *Reader) Data() []byte

Data 返回底层原始字节

func (*Reader) Header

func (r *Reader) Header() *Header

Header 返回容器级元数据

func (*Reader) KeyValueData

func (r *Reader) KeyValueData() ([]*KeyValuePair, error)

KeyValueData 返回键值对数据迭代器

func (*Reader) Levels

func (r *Reader) Levels() ([]*Level, error)

Levels 返回纹理层级迭代器

func (*Reader) SupercompressionGlobalData

func (r *Reader) SupercompressionGlobalData() []byte

SupercompressionGlobalData 返回超级压缩全局数据

type SIMDMat4

type SIMDMat4 [16]float64

SIMDMat4 表示一个4x4 SIMD优化矩阵

func IdentitySIMD

func IdentitySIMD() SIMDMat4

IdentitySIMD 创建单位矩阵

func NewSIMDMat4

func NewSIMDMat4(
	m00, m01, m02, m03,
	m10, m11, m12, m13,
	m20, m21, m22, m23,
	m30, m31, m32, m33 float64) SIMDMat4

NewSIMDMat4 创建新的SIMD矩阵

func (SIMDMat4) MulPositionSIMD

func (m SIMDMat4) MulPositionSIMD(v SIMDVector4) SIMDVector4

MulPositionSIMD 向量变换(SIMD优化)

func (SIMDMat4) MulSIMD

func (m SIMDMat4) MulSIMD(other SIMDMat4) SIMDMat4

MulSIMD 矩阵乘法(SIMD优化)

func (SIMDMat4) TransposeSIMD

func (m SIMDMat4) TransposeSIMD() SIMDMat4

TransposeSIMD 矩阵转置(SIMD优化)

type SIMDTriangle

type SIMDTriangle struct {
	V1, V2, V3 *SIMDVertex
}

SIMDTriangle SIMD三角形结构

func NewSIMDTriangle

func NewSIMDTriangle(v1, v2, v3 *SIMDVertex) *SIMDTriangle

NewSIMDTriangle 创建新的SIMD三角形

func (*SIMDTriangle) Area

func (st *SIMDTriangle) Area() float64

Area SIMD计算三角形面积

func (*SIMDTriangle) Normal

func (st *SIMDTriangle) Normal() SIMDVector4

Normal SIMD计算法线向量

type SIMDVector4

type SIMDVector4 [4]float64

SIMDVector4 表示一个SIMD优化的4元素向量

func NewSIMDVector4

func NewSIMDVector4(x, y, z, w float64) SIMDVector4

NewSIMDVector4 创建新的SIMD向量

func NewSIMDVector4FromVector

func NewSIMDVector4FromVector(v Vector) SIMDVector4

NewSIMDVector4FromVector 从Vector创建SIMD向量

func (SIMDVector4) Add

func (sv SIMDVector4) Add(other SIMDVector4) SIMDVector4

Add SIMD向量加法

func (SIMDVector4) Cross

func (sv SIMDVector4) Cross(other SIMDVector4) SIMDVector4

Cross SIMD向量叉积(仅适用于3D向量)

func (SIMDVector4) DivScalar

func (sv SIMDVector4) DivScalar(scalar float64) SIMDVector4

DivScalar SIMD标量除法

func (SIMDVector4) Dot

func (sv SIMDVector4) Dot(other SIMDVector4) float64

Dot SIMD点积计算

func (SIMDVector4) Length

func (sv SIMDVector4) Length() float64

Length SIMD向量长度计算

func (SIMDVector4) Max

func (sv SIMDVector4) Max(other SIMDVector4) SIMDVector4

Max SIMD向量分量最大值

func (SIMDVector4) Min

func (sv SIMDVector4) Min(other SIMDVector4) SIMDVector4

Min SIMD向量分量最小值

func (SIMDVector4) MulScalar

func (sv SIMDVector4) MulScalar(scalar float64) SIMDVector4

MulScalar SIMD标量乘法

func (SIMDVector4) Normalize

func (sv SIMDVector4) Normalize() SIMDVector4

Normalize SIMD向量归一化

func (SIMDVector4) Sub

func (sv SIMDVector4) Sub(other SIMDVector4) SIMDVector4

Sub SIMD向量减法

func (SIMDVector4) ToVector

func (sv SIMDVector4) ToVector() Vector

ToVector 转换为Vector

type SIMDVector4Batch

type SIMDVector4Batch struct {
	Vectors []SIMDVector4
}

SIMDVector4Batch 批量SIMD向量操作

func NewSIMDVector4Batch

func NewSIMDVector4Batch(vectors []SIMDVector4) *SIMDVector4Batch

NewSIMDVector4Batch 创建新的批量向量操作对象

func (*SIMDVector4Batch) AddBatch

func (batch *SIMDVector4Batch) AddBatch(other []SIMDVector4) []SIMDVector4

AddBatch 批量向量加法

func (*SIMDVector4Batch) MulScalarBatch

func (batch *SIMDVector4Batch) MulScalarBatch(scalar float64) []SIMDVector4

MulScalarBatch 批量标量乘法

func (*SIMDVector4Batch) NormalizeBatch

func (batch *SIMDVector4Batch) NormalizeBatch() []SIMDVector4

NormalizeBatch 批量向量归一化

type SIMDVertex

type SIMDVertex struct {
	Position SIMDVector4
	Normal   SIMDVector4
	Color    SIMDVector4
	TexCoord SIMDVector4
}

SIMDVertex SIMD顶点结构

func NewSIMDVertex

func NewSIMDVertex(position, normal, texture Vector, color Color) *SIMDVertex

NewSIMDVertex 创建新的SIMD顶点

func (*SIMDVertex) ToVertex

func (sv *SIMDVertex) ToVertex() Vertex

ToVertex 转换为普通顶点

type SampleInformation

type SampleInformation struct {
	BitOffset             uint16                // 位偏移量
	BitLength             uint8                 // 位长度 (实际值+1)
	ChannelType           uint8                 // 通道类型
	ChannelTypeQualifiers ChannelTypeQualifiers // 通道类型限定符
	SamplePositions       [4]uint8              // 采样位置
	Lower                 uint32                // 下限
	Upper                 uint32                // 上限
}

SampleInformation 采样信息

func SampleInformationFromBytes

func SampleInformationFromBytes(data []byte) (*SampleInformation, error)

FromBytes 从字节数组解析采样信息

func (*SampleInformation) AsBytes

func (s *SampleInformation) AsBytes() []byte

AsBytes 将采样信息转换为字节数组

type SampledMaterial

type SampledMaterial struct {
	BaseColor Color
	Metallic  float64
	Roughness float64
	Normal    Vector
	Occlusion float64
	Emissive  Color

	// Extended properties
	EmissiveStrength    float64
	IOR                 float64
	SpecularColor       Color
	Transmission        float64
	Thickness           float64
	AttenuationColor    Color
	AttenuationDistance float64

	// Advanced material properties
	AnisotropyStrength   float64
	AnisotropyRotation   float64
	SheenColor           Color
	SheenRoughness       float64
	Iridescence          float64
	IridescenceIor       float64
	IridescenceThickness float64
	Dispersion           float64
	Clearcoat            float64
	ClearcoatRoughness   float64
	ClearcoatNormal      Vector
}

SampledMaterial represents material properties sampled at a specific point

type Scene

type Scene struct {
	RootNode     *SceneNode
	Cameras      []*Camera
	Lights       []Light
	Materials    map[string]*PBRMaterial
	Textures     map[string]*AdvancedTexture
	Meshes       map[string]*Mesh
	Animations   map[string]*Animation
	Skins        map[string]*Skin         // Skinned animation support
	MorphTargets map[string]*MorphTargets // Morph targets support
	Extensions   *ExtensionRegistry       // GLTF extensions support
	ActiveCamera *Camera
	Name         string
}

Scene represents a 3D scene with a hierarchy of nodes

func LoadGLTFScene

func LoadGLTFScene(path string) (*Scene, error)

LoadGLTFScene loads a complete GLTF scene with materials, cameras, lights, etc.

func NewScene

func NewScene(name string) *Scene

NewScene creates a new empty scene

func (*Scene) AddAmbientLight

func (scene *Scene) AddAmbientLight(color Color, intensity float64)

AddAmbientLight adds an ambient light to the scene Ambient light provides uniform illumination to all surfaces

func (*Scene) AddAnimation

func (scene *Scene) AddAnimation(name string, animation *Animation)

AddAnimation adds an animation to the scene animation library

func (*Scene) AddCamera

func (scene *Scene) AddCamera(camera *Camera)

AddCamera adds a camera to the scene

func (*Scene) AddDirectionalLight

func (scene *Scene) AddDirectionalLight(direction Vector, color Color, intensity float64)

AddDirectionalLight adds a directional light to the scene

func (*Scene) AddLight

func (scene *Scene) AddLight(light Light)

AddLight adds a light to the scene

func (*Scene) AddMaterial

func (scene *Scene) AddMaterial(name string, material *PBRMaterial)

AddMaterial adds a material to the scene material library

func (*Scene) AddMesh

func (scene *Scene) AddMesh(name string, mesh *Mesh)

AddMesh adds a mesh to the scene mesh library

func (*Scene) AddMorphTargets

func (scene *Scene) AddMorphTargets(name string, targets *MorphTargets)

AddMorphTargets adds morph targets to the scene morph target library

func (*Scene) AddPointLight

func (scene *Scene) AddPointLight(position Vector, color Color, intensity, range_ float64)

AddPointLight adds a point light to the scene

func (*Scene) AddSkin

func (scene *Scene) AddSkin(name string, skin *Skin)

AddSkin adds a skin to the scene skin library

func (*Scene) AddSpotLight

func (scene *Scene) AddSpotLight(position, direction Vector, color Color, intensity, range_, innerCone, outerCone float64)

AddSpotLight adds a spot light to the scene

func (*Scene) AddTexture

func (scene *Scene) AddTexture(name string, texture *AdvancedTexture)

AddTexture adds a texture to the scene texture library

func (*Scene) ApplyMorphTargetsToMeshes

func (scene *Scene) ApplyMorphTargetsToMeshes()

ApplyMorphTargetsToMeshes applies morph targets to all relevant meshes in the scene

func (*Scene) ClearLights

func (scene *Scene) ClearLights()

ClearLights removes all lights from the scene

func (*Scene) CreateMeshNode

func (scene *Scene) CreateMeshNode(name, meshName, materialName string) *SceneNode

CreateMeshNode creates a new scene node with a mesh and material

func (*Scene) CreateMorphTargetMeshNode

func (scene *Scene) CreateMorphTargetMeshNode(name, meshName, materialName, morphTargetName string) *SceneNode

CreateMorphTargetMeshNode creates a scene node with mesh, material, and morph targets

func (*Scene) CreateSkinnedMeshNode

func (scene *Scene) CreateSkinnedMeshNode(name, meshName, materialName, skinName string) *SceneNode

CreateSkinnedMeshNode creates a scene node with mesh, material, and skin

func (*Scene) GetAnimation

func (scene *Scene) GetAnimation(name string) *Animation

GetAnimation gets an animation from the scene animation library

func (*Scene) GetBounds

func (scene *Scene) GetBounds() Box

SceneBounds calculates the bounding box of the entire scene

func (*Scene) GetLightsByType

func (scene *Scene) GetLightsByType(lightType LightType) []Light

GetLightsByType returns all lights of a specific type

func (*Scene) GetMaterial

func (scene *Scene) GetMaterial(name string) *PBRMaterial

GetMaterial gets a material from the scene material library

func (*Scene) GetMesh

func (scene *Scene) GetMesh(name string) *Mesh

GetMesh gets a mesh from the scene mesh library

func (*Scene) GetMorphTargets

func (scene *Scene) GetMorphTargets(name string) *MorphTargets

GetMorphTargets gets morph targets from the scene morph target library

func (*Scene) GetSkin

func (scene *Scene) GetSkin(name string) *Skin

GetSkin gets a skin from the scene skin library

func (*Scene) GetSupportedGLTFExtensions

func (scene *Scene) GetSupportedGLTFExtensions() []string

GetSupportedGLTFExtensions returns supported GLTF extensions

func (*Scene) GetTexture

func (scene *Scene) GetTexture(name string) *AdvancedTexture

GetTexture gets a texture from the scene texture library

func (*Scene) ProcessGLTFExtensions

func (scene *Scene) ProcessGLTFExtensions(extensions map[string]interface{}) error

ProcessGLTFExtensions processes GLTF extensions for the scene

func (*Scene) SetActiveCamera

func (scene *Scene) SetActiveCamera(name string) bool

SetActiveCamera sets the active camera by name

func (*Scene) UpdateSkinnedMeshes

func (scene *Scene) UpdateSkinnedMeshes()

UpdateSkinnedMeshes updates all skinned meshes in the scene

type SceneNode

type SceneNode struct {
	Name           string
	LocalTransform Matrix
	WorldTransform Matrix
	Parent         *SceneNode
	Children       []*SceneNode
	Mesh           *Mesh
	Material       *PBRMaterial
	Skin           *Skin         // Skinned mesh support
	MorphTargets   *MorphTargets // Morph target support
	Visible        bool
	CastShadows    bool
	ReceiveShadows bool
}

SceneNode represents a node in the scene hierarchy

func NewSceneNode

func NewSceneNode(name string) *SceneNode

NewSceneNode creates a new scene node

func (*SceneNode) AddChild

func (node *SceneNode) AddChild(child *SceneNode)

AddChild adds a child node to this node

func (*SceneNode) FindChild

func (node *SceneNode) FindChild(name string) *SceneNode

FindChild finds a child node by name (recursive)

func (*SceneNode) GetRenderableNodes

func (node *SceneNode) GetRenderableNodes() []*SceneNode

GetRenderableNodes returns all nodes that have both mesh and material

func (*SceneNode) GetWorldPosition

func (node *SceneNode) GetWorldPosition() Vector

GetWorldPosition returns the world position of the node

func (*SceneNode) RemoveChild

func (node *SceneNode) RemoveChild(child *SceneNode)

RemoveChild removes a child node from this node

func (*SceneNode) Rotate

func (node *SceneNode) Rotate(axis Vector, angle float64)

Rotate rotates the node around the given axis by the given angle

func (*SceneNode) Scale

func (node *SceneNode) Scale(scale Vector)

Scale scales the node by the given factors

func (*SceneNode) SetTransform

func (node *SceneNode) SetTransform(transform Matrix)

SetTransform sets the local transform of the node

func (*SceneNode) Translate

func (node *SceneNode) Translate(translation Vector)

Translate translates the node by the given vector

func (*SceneNode) UpdateWorldTransform

func (node *SceneNode) UpdateWorldTransform()

UpdateWorldTransform updates the world transform based on parent transforms

func (*SceneNode) VisitNodes

func (node *SceneNode) VisitNodes(visitor func(*SceneNode))

VisitNodes visits all nodes in the hierarchy with the given function

type SceneRenderer

type SceneRenderer struct {
	// contains filtered or unexported fields
}

SceneRenderer handles rendering of scenes

func NewSceneRenderer

func NewSceneRenderer(context *Context) *SceneRenderer

NewSceneRenderer creates a new scene renderer

func (*SceneRenderer) RenderNode

func (renderer *SceneRenderer) RenderNode(node *SceneNode, cameraMatrix Matrix, lights []Light, cameraPos Vector)

RenderNode renders a single scene node

func (*SceneRenderer) RenderScene

func (renderer *SceneRenderer) RenderScene(scene *Scene)

RenderScene renders a complete scene

type Shader

type Shader interface {
	Vertex(Vertex) Vertex
	Fragment(Vertex) Color
}

type ShadowMap

type ShadowMap struct {
	Width     int
	Height    int
	DepthMap  []float64
	LightView Matrix
}

ShadowMap represents a shadow map for a light source

func NewShadowMap

func NewShadowMap(width, height int) *ShadowMap

NewShadowMap creates a new shadow map with the specified dimensions

func (*ShadowMap) Clear

func (sm *ShadowMap) Clear(depth float64)

Clear clears the shadow map with the specified depth value

func (*ShadowMap) GetDepth

func (sm *ShadowMap) GetDepth(x, y int) float64

GetDepth retrieves the depth value at the specified coordinates

func (*ShadowMap) SetDepth

func (sm *ShadowMap) SetDepth(x, y int, depth float64)

SetDepth sets the depth value at the specified coordinates

type ShadowMapRenderer

type ShadowMapRenderer struct {
	// contains filtered or unexported fields
}

ShadowMapRenderer handles advanced shadow mapping techniques

func NewShadowMapRenderer

func NewShadowMapRenderer(context *Context, shadowMapSize int, light Light, technique ShadowTechnique) *ShadowMapRenderer

NewShadowMapRenderer creates a new shadow map renderer with the specified technique

func (*ShadowMapRenderer) GenerateShadowMap

func (sr *ShadowMapRenderer) GenerateShadowMap(scene *Scene) *ShadowMap

GenerateShadowMap generates a shadow map using the specified technique

func (*ShadowMapRenderer) GetLightMatrix

func (sr *ShadowMapRenderer) GetLightMatrix() Matrix

GetLightMatrix returns the light's view-projection matrix

func (*ShadowMapRenderer) GetTechnique

func (sr *ShadowMapRenderer) GetTechnique() ShadowTechnique

GetTechnique returns the shadow mapping technique being used

type ShadowMapShader

type ShadowMapShader struct {
	Matrix Matrix
}

ShadowMapShader is a shader that renders depth information for shadow mapping

func NewShadowMapShader

func NewShadowMapShader(matrix Matrix) *ShadowMapShader

NewShadowMapShader creates a new shadow map shader

func (*ShadowMapShader) Fragment

func (shader *ShadowMapShader) Fragment(v Vertex) Color

Fragment returns the depth value for shadow mapping

func (*ShadowMapShader) Vertex

func (shader *ShadowMapShader) Vertex(v Vertex) Vertex

Vertex processes a vertex for shadow mapping

type ShadowReceiverShader

type ShadowReceiverShader struct {
	Matrix         Matrix
	LightDirection Vector
	CameraPosition Vector
	ObjectColor    Color
	Texture        Texture
	ShadowMap      *ShadowMap
	LightMatrix    Matrix
	ShadowBias     float64
	ShadowStrength float64
	PCFSize        int // Percentage Closer Filtering size
}

ShadowReceiverShader is a shader that receives shadows

func NewShadowReceiverShader

func NewShadowReceiverShader(matrix, lightMatrix Matrix, lightDirection, cameraPosition Vector, shadowMap *ShadowMap) *ShadowReceiverShader

NewShadowReceiverShader creates a new shadow receiver shader

func (*ShadowReceiverShader) Fragment

func (shader *ShadowReceiverShader) Fragment(v Vertex) Color

Fragment performs shading with shadow calculation

func (*ShadowReceiverShader) Vertex

func (shader *ShadowReceiverShader) Vertex(v Vertex) Vertex

Vertex processes a vertex for shadow receiving

type ShadowRenderer

type ShadowRenderer struct {
	// contains filtered or unexported fields
}

ShadowRenderer handles shadow map generation and rendering

func NewShadowRenderer

func NewShadowRenderer(context *Context, shadowMapSize int, light Light) *ShadowRenderer

NewShadowRenderer creates a new shadow renderer

func (*ShadowRenderer) ExtractDepthFromBuffer

func (sr *ShadowRenderer) ExtractDepthFromBuffer()

ExtractDepthFromBuffer extracts depth values from the depth buffer to the shadow map

func (*ShadowRenderer) GenerateShadowMap

func (sr *ShadowRenderer) GenerateShadowMap(scene *Scene) *ShadowMap

GenerateShadowMap generates a shadow map from the light's perspective

func (*ShadowRenderer) GetLightMatrix

func (sr *ShadowRenderer) GetLightMatrix() Matrix

GetLightMatrix returns the light's view-projection matrix

type ShadowTechnique

type ShadowTechnique int

ShadowTechnique represents the type of shadow mapping technique to use

const (
	// SimpleShadow uses basic shadow mapping
	SimpleShadow ShadowTechnique = iota
	// PCFShadow uses Percentage Closer Filtering
	PCFShadow
	// PCSSShadow uses Percentage Closer Soft Shadows
	PCSSShadow
	// VSMShadow uses Variance Shadow Maps
	VSMShadow
)

type Skin

type Skin struct {
	Name                string
	Joints              []*SceneNode // Joint nodes
	InverseBindMatrices []Matrix     // Inverse bind pose matrices
	Skeleton            *SceneNode   // Root skeleton node (optional)
}

Skin represents a skin for skeletal animation

func NewSkin

func NewSkin(name string) *Skin

func (*Skin) AddJoint

func (skin *Skin) AddJoint(joint *SceneNode, inverseBindMatrix Matrix)

AddJoint adds a joint to the skin

func (*Skin) UpdateJointMatrices

func (skin *Skin) UpdateJointMatrices()

UpdateJointMatrices updates all joint matrices for the current pose

type SoftShadowReceiverShader

type SoftShadowReceiverShader struct {
	Matrix              Matrix
	LightDirection      Vector
	CameraPosition      Vector
	ObjectColor         Color
	Texture             Texture
	ShadowMap           *ShadowMap
	LightMatrix         Matrix
	ShadowBias          float64
	ShadowStrength      float64
	SoftShadowTechnique ShadowTechnique
	FilterSize          int
}

SoftShadowReceiverShader implements advanced soft shadow techniques

func NewSoftShadowReceiverShader

func NewSoftShadowReceiverShader(matrix, lightMatrix Matrix, lightDirection, cameraPosition Vector, shadowMap *ShadowMap, technique ShadowTechnique) *SoftShadowReceiverShader

NewSoftShadowReceiverShader creates a new soft shadow receiver shader

func (*SoftShadowReceiverShader) Fragment

func (shader *SoftShadowReceiverShader) Fragment(v Vertex) Color

Fragment performs shading with advanced shadow calculation

func (*SoftShadowReceiverShader) Vertex

func (shader *SoftShadowReceiverShader) Vertex(v Vertex) Vertex

Vertex processes a vertex

type SolidColorShader

type SolidColorShader struct {
	Matrix Matrix
	Color  Color
}

SolidColorShader renders with a single, solid color.

func NewSolidColorShader

func NewSolidColorShader(matrix Matrix, color Color) *SolidColorShader

func (*SolidColorShader) Fragment

func (shader *SolidColorShader) Fragment(v Vertex) Color

func (*SolidColorShader) Vertex

func (shader *SolidColorShader) Vertex(v Vertex) Vertex

type SupercompressionScheme

type SupercompressionScheme uint32

SupercompressionScheme 超级压缩方案

const (
	SupercompressionNone    SupercompressionScheme = 0
	SupercompressionBasisLZ SupercompressionScheme = 1
	SupercompressionZstd    SupercompressionScheme = 2
	SupercompressionZLIB    SupercompressionScheme = 3
)

func NewSupercompressionScheme

func NewSupercompressionScheme(value uint32) *SupercompressionScheme

func (SupercompressionScheme) Value

func (s SupercompressionScheme) Value() uint32

type Texture

type Texture interface {
	// BilinearSample samples the texture using bilinear interpolation
	BilinearSample(u, v float64) Color
}

Texture interface defines the basic texture functionality This interface provides backward compatibility with the old texture system

func LoadTexture

func LoadTexture(path string) (Texture, error)

LoadTexture loads a texture from a file path (legacy compatibility)

type TextureAtlas

type TextureAtlas struct {
	Image   image.Image
	Width   int
	Height  int
	Regions map[string]TextureRegion
}

TextureAtlas represents a texture atlas for batching multiple textures

func NewTextureAtlas

func NewTextureAtlas(img image.Image) *TextureAtlas

NewTextureAtlas creates a new texture atlas

func (*TextureAtlas) AddRegion

func (atlas *TextureAtlas) AddRegion(name string, x, y, width, height int)

AddRegion adds a texture region to the atlas

func (*TextureAtlas) SampleRegion

func (atlas *TextureAtlas) SampleRegion(regionName string, u, v float64) Color

SampleRegion samples a specific region in the atlas

type TextureFilter

type TextureFilter int

TextureFilter defines texture filtering method

const (
	// FilterNearest - nearest neighbor filtering
	FilterNearest TextureFilter = iota
	// FilterLinear - bilinear filtering
	FilterLinear
	// FilterMipmap - mipmap filtering
	FilterMipmap
)

type TextureRegion

type TextureRegion struct {
	Name   string
	X, Y   int
	Width  int
	Height int
	U0, V0 float64 // Top-left UV
	U1, V1 float64 // Bottom-right UV
}

TextureRegion represents a region within a texture atlas

type TextureShader

type TextureShader struct {
	Matrix  Matrix
	Texture Texture
}

TextureShader renders with a texture and no lighting.

func NewTextureShader

func NewTextureShader(matrix Matrix, texture Texture) *TextureShader

func (*TextureShader) Fragment

func (shader *TextureShader) Fragment(v Vertex) Color

func (*TextureShader) Vertex

func (shader *TextureShader) Vertex(v Vertex) Vertex

type TextureType

type TextureType int

TextureType represents different types of textures

const (
	// BaseColorTexture - diffuse/albedo texture
	BaseColorTexture TextureType = iota
	// NormalTexture - normal map for surface detail
	NormalTexture
	// MetallicTexture - metallic values
	MetallicTexture
	// RoughnessTexture - surface roughness
	RoughnessTexture
	// OcclusionTexture - ambient occlusion
	OcclusionTexture
	// EmissiveTexture - emissive/glow texture
	EmissiveTexture
	// HeightTexture - height/displacement map
	HeightTexture
	// SpecularTexture - specular values (legacy)
	SpecularTexture
	// GlossinessTexture - glossiness values (legacy)
	GlossinessTexture
	// KTX2Texture - KTX2 container format texture
	KTX2Texture
)

type TextureWrap

type TextureWrap int

TextureWrap defines texture wrapping behavior

const (
	// WrapRepeat - repeat the texture
	WrapRepeat TextureWrap = iota
	// WrapClamp - clamp to edge
	WrapClamp
	// WrapMirror - mirror repeat
	WrapMirror
)

type ToneMappingEffect

type ToneMappingEffect struct {
	Exposure float64
	Gamma    float64
}

ToneMappingEffect implements tone mapping

func NewToneMappingEffect

func NewToneMappingEffect(exposure, gamma float64) *ToneMappingEffect

NewToneMappingEffect creates a new tone mapping effect

func (*ToneMappingEffect) Apply

func (tme *ToneMappingEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies tone mapping to the input image

type TransferFunction

type TransferFunction uint8

TransferFunction 传输函数

const (
	TransferFunctionUnspecified TransferFunction = 0
	TransferFunctionLinear      TransferFunction = 1
	TransferFunctionSRGB        TransferFunction = 2
	TransferFunctionITU         TransferFunction = 3
)

func NewTransferFunction

func NewTransferFunction(value uint8) *TransferFunction

func (TransferFunction) Value

func (t TransferFunction) Value() uint8

type Triangle

type Triangle struct {
	V1, V2, V3 Vertex
}

Triangle f

func ClipTriangle

func ClipTriangle(t *Triangle) []*Triangle

ClipTriangle clips a triangle against the viewing frustum

func NewTriangle

func NewTriangle(v1, v2, v3 Vertex) *Triangle

NewTriangle f

func NewTriangleForPoints

func NewTriangleForPoints(p1, p2, p3 Vector) *Triangle

NewTriangleForPoints f

func (*Triangle) Area

func (t *Triangle) Area() float64

Area f

func (*Triangle) BoundingBox

func (t *Triangle) BoundingBox() Box

BoundingBox f

func (*Triangle) FixNormals

func (t *Triangle) FixNormals()

FixNormals f

func (*Triangle) IsDegenerate

func (t *Triangle) IsDegenerate() bool

IsDegenerate f

func (*Triangle) Normal

func (t *Triangle) Normal() Vector

Normal f

func (*Triangle) ReverseWinding

func (t *Triangle) ReverseWinding()

ReverseWinding f

func (*Triangle) SetColor

func (t *Triangle) SetColor(c Color)

SetColor set the color of the vertexes

func (*Triangle) Transform

func (t *Triangle) Transform(matrix Matrix)

Transform f

type UVBlendMode

type UVBlendMode int

UVBlendMode defines how UV transformations are blended

const (
	UVBlendReplace  UVBlendMode = iota // 替换模式
	UVBlendAdd                         // 加法混合
	UVBlendMultiply                    // 乘法混合
	UVBlendOverlay                     // 叠加模式
)

type UVIsland

type UVIsland struct {
	Vertices      []Vector2 // UV坐标
	Indices       []int     // 三角形索引 (3个一组)
	OriginalUVs   []Vector2 // 原始UV坐标
	Seams         []UVSeam  // 接缝列表
	BoundaryVerts []int     // 边界顶点
	PinnedVerts   []int     // 固定顶点
}

UVIsland 表示一个UV岛屿

func ExtractUVIslands

func ExtractUVIslands(mesh *Mesh) []*UVIsland

ExtractUVIslands 从网格中提取UV岛屿

func NewUVIsland

func NewUVIsland() *UVIsland

NewUVIsland 创建一个新的UV岛屿

type UVMapping

type UVMapping struct {
	Name      string       // 映射名称
	Enabled   bool         // 是否启用
	Region    UVRegion     // UV区域定义
	Transform *UVTransform // UV变换
	BlendMode UVBlendMode  // 混合模式
	Priority  int          // 优先级(数值越高优先级越高)
}

UVMapping defines a UV mapping configuration

func CreateRotatingUVMapping

func CreateRotatingUVMapping(name string, speed float64, pivotU, pivotV float64, region UVRegion) *UVMapping

CreateRotatingUVMapping creates a rotating UV animation mapping

func CreateScalingUVMapping

func CreateScalingUVMapping(name string, scaleU, scaleV float64, region UVRegion) *UVMapping

CreateScalingUVMapping creates a scaling UV mapping

func CreateScrollingUVMapping

func CreateScrollingUVMapping(name string, speedU, speedV float64, region UVRegion) *UVMapping

CreateScrollingUVMapping creates a scrolling UV animation mapping

type UVMaskType

type UVMaskType int

UVMaskType defines the type of UV region mask

const (
	UVMaskRectangle UVMaskType = iota // 矩形遮罩
	UVMaskCircle                      // 圆形遮罩
	UVMaskGradient                    // 渐变遮罩
)

type UVModifier

type UVModifier struct {
	// contains filtered or unexported fields
}

UVModifier provides dynamic UV coordinate modification capabilities

func NewUVModifier

func NewUVModifier() *UVModifier

NewUVModifier creates a new UV modifier

func (*UVModifier) AddMapping

func (modifier *UVModifier) AddMapping(mapping *UVMapping)

AddMapping adds a UV mapping configuration

func (*UVModifier) EnableAnimation

func (modifier *UVModifier) EnableAnimation(enabled bool)

EnableAnimation enables/disables UV animation

func (*UVModifier) GetMapping

func (modifier *UVModifier) GetMapping(name string) *UVMapping

GetMapping gets a mapping by name

func (*UVModifier) RemoveMapping

func (modifier *UVModifier) RemoveMapping(name string) bool

RemoveMapping removes a mapping by name

func (*UVModifier) SetGlobalTransform

func (modifier *UVModifier) SetGlobalTransform(transform *UVTransform)

SetGlobalTransform sets the global UV transformation

func (*UVModifier) TransformUV

func (modifier *UVModifier) TransformUV(u, v float64) (float64, float64)

TransformUV applies all UV transformations to input coordinates

func (*UVModifier) UpdateAnimation

func (modifier *UVModifier) UpdateAnimation(deltaTime float64)

UpdateAnimation updates animation time for all transforms

type UVRegion

type UVRegion struct {
	MinU, MaxU float64    // U坐标范围 [0.0, 1.0]
	MinV, MaxV float64    // V坐标范围 [0.0, 1.0]
	MaskType   UVMaskType // 区域遮罩类型
}

UVRegion defines a UV coordinate region

type UVRelaxationSettings

type UVRelaxationSettings struct {
	Iterations     int     // 松弛迭代次数
	StepSize       float64 // 松弛步长
	PinBoundary    bool    // 是否固定边界
	PreserveArea   bool    // 是否保持面积
	PreserveAngles bool    // 是否保持角度
	EnableSeams    bool    // 是否启用接缝
}

UVRelaxationSettings 平面展开算法的设置

func NewUVRelaxationSettings

func NewUVRelaxationSettings() *UVRelaxationSettings

NewUVRelaxationSettings 创建默认的UV松弛设置

type UVSeam

type UVSeam struct {
	Edge     [2]Vector // 接缝边的两个顶点
	Strength float64   // 接缝强度 (0-1)
	Fixed    bool      // 是否固定(不参与松弛)
}

UVSeam 表示UV展开的接缝

type UVTransform

type UVTransform struct {
	// Basic transformations
	OffsetU, OffsetV float64 // UV偏移
	ScaleU, ScaleV   float64 // UV缩放
	Rotation         float64 // 旋转角度(弧度)

	// Advanced transformations
	SkewU, SkewV   float64 // UV剪切
	PivotU, PivotV float64 // 旋转中心点

	// Animation parameters
	AnimationTime float64 // 动画时间
	RotationSpeed float64 // 旋转速度
	ScrollSpeedU  float64 // U方向滚动速度
	ScrollSpeedV  float64 // V方向滚动速度
}

UVTransform represents a UV coordinate transformation

func NewUVTransform

func NewUVTransform() *UVTransform

NewUVTransform creates a new UV transform with default values

type Vector

type Vector struct {
	X, Y, Z float64
}

func InterpolateVectors

func InterpolateVectors(v1, v2, v3 Vector, b VectorW) Vector

func LatLngToXYZ

func LatLngToXYZ(lat, lng float64) Vector

func SIMDAddVectors

func SIMDAddVectors(a, b []Vector) []Vector

SIMDAddVectors 批量向量加法

func SIMDMulScalarVectors

func SIMDMulScalarVectors(vectors []Vector, scalar float64) []Vector

SIMDMulScalarVectors 批量向量标量乘法

func SIMDNormalizeVectors

func SIMDNormalizeVectors(vectors []Vector) []Vector

SIMDNormalizeVectors 批量向量归一化

func SIMDVectorCross

func SIMDVectorCross(a, b Vector) Vector

SIMDVectorCross 计算两个向量的叉积(SIMD优化)

func V

func V(x, y, z float64) Vector

func (Vector) Abs

func (a Vector) Abs() Vector

func (Vector) Add

func (a Vector) Add(b Vector) Vector

func (Vector) AddScalar

func (a Vector) AddScalar(b float64) Vector

func (Vector) Ceil

func (a Vector) Ceil() Vector

func (Vector) Cross

func (a Vector) Cross(b Vector) Vector

func (Vector) Distance

func (a Vector) Distance(b Vector) float64

func (Vector) DistanceSq

func (a Vector) DistanceSq(b Vector) float64

DistanceSq returns the square of the distance between two vectors

func (Vector) DistanceSquared

func (a Vector) DistanceSquared(b Vector) float64

func (Vector) Div

func (a Vector) Div(b Vector) Vector

func (Vector) DivScalar

func (a Vector) DivScalar(b float64) Vector

func (Vector) Dot

func (a Vector) Dot(b Vector) float64

func (Vector) Floor

func (a Vector) Floor() Vector

func (Vector) IsDegenerate

func (a Vector) IsDegenerate() bool

func (Vector) Length

func (a Vector) Length() float64

func (Vector) LengthSquared

func (a Vector) LengthSquared() float64

func (Vector) Lerp

func (a Vector) Lerp(b Vector, t float64) Vector

func (Vector) LerpDistance

func (a Vector) LerpDistance(b Vector, d float64) Vector

func (Vector) Less

func (a Vector) Less(b Vector) bool

func (Vector) Max

func (a Vector) Max(b Vector) Vector

func (Vector) MaxComponent

func (a Vector) MaxComponent() float64

func (Vector) Min

func (a Vector) Min(b Vector) Vector

func (Vector) MinComponent

func (a Vector) MinComponent() float64

func (Vector) Mul

func (a Vector) Mul(b Vector) Vector

func (Vector) MulScalar

func (a Vector) MulScalar(b float64) Vector

func (Vector) Negate

func (a Vector) Negate() Vector

func (Vector) Normalize

func (a Vector) Normalize() Vector

func (Vector) Perpendicular

func (a Vector) Perpendicular() Vector

func (Vector) PowScalar

func (a Vector) PowScalar(b float64) Vector

func (Vector) Reflect

func (a Vector) Reflect(n Vector) Vector

func (Vector) Round

func (a Vector) Round() Vector

func (Vector) RoundPlaces

func (a Vector) RoundPlaces(n int) Vector

func (Vector) SegmentDistance

func (a Vector) SegmentDistance(v Vector, w Vector) float64

func (Vector) Sub

func (a Vector) Sub(b Vector) Vector

func (Vector) SubScalar

func (a Vector) SubScalar(b float64) Vector

func (Vector) VectorW

func (a Vector) VectorW() VectorW

type Vector2

type Vector2 struct {
	X, Y float64
}

Vector2 表示一个二维向量

func CanvasToUV

func CanvasToUV(x, y, canvasWidth, canvasHeight int) Vector2

CanvasToUV 将画布坐标转换为UV坐标

func (Vector2) Add

func (a Vector2) Add(b Vector2) Vector2

Add 两个Vector2相加

func (Vector2) ApproxEqual

func (a Vector2) ApproxEqual(b Vector2, epsilon float64) bool

ApproxEqual 近似相等比较

func (Vector2) DivScalar

func (a Vector2) DivScalar(s float64) Vector2

DivScalar 标量除法

func (Vector2) Dot

func (a Vector2) Dot(b Vector2) float64

Dot 点积

func (Vector2) Length

func (a Vector2) Length() float64

Length 向量长度

func (Vector2) MulScalar

func (a Vector2) MulScalar(s float64) Vector2

MulScalar 标量乘法

func (Vector2) Normalize

func (a Vector2) Normalize() Vector2

Normalize 归一化向量

func (Vector2) Sub

func (a Vector2) Sub(b Vector2) Vector2

Sub 两个Vector2相减

type VectorW

type VectorW struct {
	X, Y, Z, W float64
}

VectorW 表示齐次坐标向量

func Barycentric

func Barycentric(p1, p2, p3, p Vector) VectorW

func InterpolateVectorWs

func InterpolateVectorWs(v1, v2, v3, b VectorW) VectorW

func (VectorW) Add

func (a VectorW) Add(b VectorW) VectorW

func (VectorW) DivScalar

func (a VectorW) DivScalar(b float64) VectorW

func (VectorW) Dot

func (a VectorW) Dot(b VectorW) float64

func (VectorW) MulScalar

func (a VectorW) MulScalar(b float64) VectorW

func (VectorW) Outside

func (a VectorW) Outside() bool

func (VectorW) Sub

func (a VectorW) Sub(b VectorW) VectorW

func (VectorW) Vector

func (a VectorW) Vector() Vector

type Vertex

type Vertex struct {
	Position Vector
	Normal   Vector
	Texture  Vector
	Color    Color
	Output   VectorW
}

func InterpolateVertexes

func InterpolateVertexes(v1, v2, v3 Vertex, b VectorW) Vertex

func (Vertex) Outside

func (a Vertex) Outside() bool

type ViewFrustum

type ViewFrustum struct {
	Planes [6]Plane
}

ViewFrustum represents a camera viewing frustum for culling

func NewViewFrustumFromMatrix

func NewViewFrustumFromMatrix(matrix Matrix) *ViewFrustum

NewViewFrustumFromMatrix creates a frustum from a projection-view matrix

func (*ViewFrustum) IntersectsBox

func (f *ViewFrustum) IntersectsBox(box Box) bool

IntersectsBox checks if a box intersects with the frustum

type VignetteEffect

type VignetteEffect struct {
	Strength float64
}

VignetteEffect implements a vignette effect

func NewVignetteEffect

func NewVignetteEffect(strength float64) *VignetteEffect

NewVignetteEffect creates a new vignette effect

func (*VignetteEffect) Apply

func (ve *VignetteEffect) Apply(input *image.NRGBA) *image.NRGBA

Apply applies vignette to the input image

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址