caustics 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10c88b54baa715ecbb00dc89d92a450a11376482b271b62830ecb3bdcaf07e8b
4
- data.tar.gz: f1784ca8a4e044c45d632f467dc30109e57b6ee9b2f02b635c45062941cf661a
3
+ metadata.gz: c67829aea9662c33cf0df62b40f293a063c19b99426617582ddfe5b49b43febe
4
+ data.tar.gz: 96c9e7af7d4563b1211c950b357b4e45fdb1ae626b62281eff85ba3d2dbd9aed
5
5
  SHA512:
6
- metadata.gz: 8f6205eef7c6d43866cacefaf43a95163c0d8b067567f659faf622e297fc1a43a2b93993f4764973b247cc391acb66eeceda5e1199ffedf767edfbcd9c8c410f
7
- data.tar.gz: 0dcea5536f7219d8a1161faeda31f86bcb2b4b8bdb61ca8a598b5ab3925b74601df16f02315caf127ef514da5a7ecc50f685544eb9cfb55ed0074d26a11b1205
6
+ metadata.gz: 1dc1ee270030df2ac75237c9c1a8ae94d0ca5b9fda06d8eee0077aaabf3a577afa427866e5fc58c51ce56b020357db5e456a4e3aa31136886a46b87c807c50d9
7
+ data.tar.gz: 6233d0882d15cb984345c98644b85da078287dcd69042785a956a81967d1efbad25938cd340c0281c77ccd8d58cb73f2c90e28bbfdd9f21b073a5df8b7b95a89
data/.codespellignore ADDED
File without changes
data/.yamllint ADDED
@@ -0,0 +1,16 @@
1
+ extends: default
2
+ ignore: |
3
+ build/
4
+ node_modules/
5
+ runtime/build/
6
+ tmp/
7
+ **/*.dSYM/**
8
+
9
+ rules:
10
+ comments:
11
+ min-spaces-from-content: 1
12
+ document-start: disable
13
+ line-length:
14
+ max: 200
15
+ truthy:
16
+ check-keys: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.1] - 2026-09-26
6
+
7
+ - Reject non-finite camera, material, and texture settings before rendering.
8
+
5
9
  ## [0.2.0] - 2026-09-25
6
10
 
7
11
  - Add cumulative GIF output to `caustics render` through optional Flipbook.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caustics
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/caustics.rb CHANGED
@@ -135,7 +135,7 @@ module Caustics
135
135
  attr_reader :center, :radius, :material
136
136
  def initialize(center:, radius:, material:)
137
137
  @center, @radius, @material = center, radius.to_f, material
138
- raise ArgumentError, "sphere radius must be positive" unless @radius.positive?
138
+ raise ArgumentError, "sphere radius must be positive and finite" unless @radius.finite? && @radius.positive?
139
139
  end
140
140
 
141
141
  def hit(ray, minimum, maximum)
@@ -246,8 +246,10 @@ module Caustics
246
246
  class Material
247
247
  def initialize(color: Vec3.new(1, 1, 1), fuzz: 0, index: 1.5, emission: Vec3.new(0, 0, 0), kind: :lambertian)
248
248
  @index = Float(index)
249
- raise ArgumentError, "refractive index must be positive" unless @index.positive?
250
- @color, @fuzz, @emission, @kind = color, Float(fuzz).clamp(0, 1), emission, kind
249
+ raise ArgumentError, "refractive index must be positive and finite" unless @index.finite? && @index.positive?
250
+ fuzz = Float(fuzz)
251
+ raise ArgumentError, "material fuzz must be finite" unless fuzz.finite?
252
+ @color, @fuzz, @emission, @kind = color, fuzz.clamp(0, 1), emission, kind
251
253
  end
252
254
  attr_reader :color, :emission, :index, :kind
253
255
 
@@ -278,10 +280,11 @@ module Caustics
278
280
  attr_reader :origin, :horizontal, :vertical, :lower_left
279
281
  def initialize(from: [13, 2, 3], to: [0, 0, 0], up: [0, 1, 0], fov: 20, aspect: 16.0 / 9, aperture: 0, focus_distance: 10)
280
282
  @origin = vec(from)
281
- raise ArgumentError, "camera fov must be between 0 and 180 degrees" unless fov.to_f.positive? && fov.to_f < 180
282
- raise ArgumentError, "camera aspect must be positive" unless aspect.to_f.positive?
283
- raise ArgumentError, "camera focus distance must be positive" unless focus_distance.to_f.positive?
284
- raise ArgumentError, "camera aperture must not be negative" if aperture.to_f.negative?
283
+ fov, aspect, aperture, focus_distance = [fov, aspect, aperture, focus_distance].map { |value| Float(value) }
284
+ raise ArgumentError, "camera fov must be between 0 and 180 degrees" unless fov.positive? && fov < 180
285
+ raise ArgumentError, "camera aspect must be finite and positive" unless aspect.finite? && aspect.positive?
286
+ raise ArgumentError, "camera focus distance must be finite and positive" unless focus_distance.finite? && focus_distance.positive?
287
+ raise ArgumentError, "camera aperture must be finite and non-negative" unless aperture.finite? && !aperture.negative?
285
288
  theta = fov * Math::PI / 180
286
289
  viewport_height = 2 * Math.tan(theta / 2)
287
290
  viewport_width = aspect * viewport_height
@@ -476,7 +479,7 @@ module Caustics
476
479
  class NoiseTexture
477
480
  def initialize(scale: 1, seed: 42)
478
481
  @scale = Float(scale)
479
- raise ArgumentError, "noise texture scale must be positive" unless @scale.positive?
482
+ raise ArgumentError, "noise texture scale must be finite and positive" unless @scale.finite? && @scale.positive?
480
483
  @noise = Perlin.new(seed)
481
484
  end
482
485
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caustics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yudai Takada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-25 00:00:00.000000000 Z
11
+ date: 2026-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tessel
@@ -38,6 +38,8 @@ executables:
38
38
  extensions: []
39
39
  extra_rdoc_files: []
40
40
  files:
41
+ - ".codespellignore"
42
+ - ".yamllint"
41
43
  - CHANGELOG.md
42
44
  - LICENSE.txt
43
45
  - README.md