three-rb 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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +2 -0
- data/docs/browser-runtime.md +3 -1
- data/docs/loaded-assets-design.md +1 -1
- data/docs/publishing.md +4 -1
- data/docs/standalone-browser-app.md +4 -0
- data/examples/browser/README.md +2 -0
- data/examples/browser/composition/main.rb +2 -2
- data/examples/browser/cubemap/assets/checker.svg +11 -0
- data/examples/browser/cubemap/main.rb +1 -1
- data/examples/browser/gltf/main.rb +2 -2
- data/examples/browser/primitives/assets/checker.svg +11 -0
- data/examples/browser/primitives/main.rb +1 -1
- data/examples/browser/ruby/README.md +2 -0
- data/examples/browser/ruby/main.rb +1 -1
- data/examples/browser/serialization/assets/checker.svg +11 -0
- data/examples/browser/serialization/main.rb +1 -1
- data/examples/browser/shared/boot.mjs +1 -1
- data/examples/browser/textures/assets/checker.svg +11 -0
- data/examples/browser/textures/assets/studio.hdr +5 -0
- data/examples/browser/textures/main.rb +2 -2
- data/exe/three-rb +1 -0
- data/lib/three/generators/browser_example.rb +86 -5
- data/lib/three/version.rb +1 -1
- metadata +11 -6
- /data/examples/browser/{assets → composition/assets}/checker.svg +0 -0
- /data/examples/browser/{assets → gltf/assets}/animated_triangle.gltf +0 -0
- /data/examples/browser/{assets → gltf/assets}/compressed_triangle.gltf +0 -0
- /data/examples/browser/{assets → gltf/assets}/triangle.gltf +0 -0
- /data/examples/browser/{assets → ruby/assets}/studio.hdr +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b6b3331ebb395126e0bbd0003e8cb8e9da2648107319e4c0953e6a1d33ddbfd
|
|
4
|
+
data.tar.gz: 1867f60db80fc386322c82ebc35b5bbda234712f2b9370164487e0105066001c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee90d10b58348b809c087d7c25dc29dd62c4173e83892bfe09710002c83dac9ccd65c8aaa1af91538100d262d595278904267273f1a0d4baa75ed2fe4dca6c45
|
|
7
|
+
data.tar.gz: f65cf3c1132a728e54601ca7b4f0de2433755320b1d9d842844118606e4391c4d286be65386c2d1a548132b406759e7d6af45be2fe604fad08034f1e9a50759a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 - 2026-05-17
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added a generated Ruby browser example template that copies the full gemstone example, including its local HDR asset.
|
|
8
|
+
- Added generator coverage for Ruby example asset copying and Ruby-only browser entrypoints.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Moved browser example assets into example-local asset directories so generated examples and smoke tests use self-contained paths.
|
|
13
|
+
- Strengthened release readiness checks for the browser generator template and installed executable.
|
|
14
|
+
|
|
3
15
|
## 0.2.0 - 2026-05-17
|
|
4
16
|
|
|
5
17
|
### Added
|
data/README.md
CHANGED
|
@@ -137,6 +137,8 @@ pnpm install
|
|
|
137
137
|
ruby -run -e httpd . -p 8000
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
Use `three-rb browser examples/browser/ruby` instead when you want the richer Ruby gemstone sample with its assets kept under `examples/browser/ruby/assets/`.
|
|
141
|
+
|
|
140
142
|
The generated Ruby entrypoint uses `Three::Browser.run`, so ordinary scene code does not need `require "js"` or `JS.global`.
|
|
141
143
|
|
|
142
144
|
Run the optional browser smoke tests:
|
data/docs/browser-runtime.md
CHANGED
|
@@ -183,7 +183,9 @@ For standalone projects, install the gem and generate a Ruby-only browser exampl
|
|
|
183
183
|
three-rb browser examples/browser/quickstart
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
`quickstart` generates an asset-free rotating cube. Use `three-rb browser examples/browser/ruby` to generate the richer Ruby gemstone sample; its HDR asset is copied under `examples/browser/ruby/assets/`.
|
|
187
|
+
|
|
188
|
+
The generator copies the browser runtime files, `package.json`, `pnpm-lock.yaml`, and `lib/` into the served project root, then creates `index.html`, `boot.mjs`, `main.rb`, and `README.md` for the example. Templates that need local files keep them under the generated example's `assets/` directory.
|
|
187
189
|
|
|
188
190
|
## JavaScript Escape Hatch
|
|
189
191
|
|
|
@@ -122,7 +122,7 @@ Local source locations:
|
|
|
122
122
|
|
|
123
123
|
The existing glTF browser smoke test verifies:
|
|
124
124
|
|
|
125
|
-
- `Three::Loaders::GLTFLoader` loads `examples/browser/assets
|
|
125
|
+
- `Three::Loaders::GLTFLoader` loads assets from `examples/browser/gltf/assets/`.
|
|
126
126
|
- The returned `gltf.scene` can be added to a Ruby `Scene`.
|
|
127
127
|
- The loaded JavaScript scene renders through `Three::Renderers::ThreeJSRenderer`.
|
|
128
128
|
- The animation loop can mutate the external root transform.
|
data/docs/publishing.md
CHANGED
|
@@ -136,6 +136,9 @@ three-rb --help
|
|
|
136
136
|
three-rb browser examples/browser/quickstart
|
|
137
137
|
test -f examples/browser/quickstart/main.rb
|
|
138
138
|
ruby -e 'main = File.read("examples/browser/quickstart/main.rb"); abort "generated Ruby entrypoint used JS bridge" if main.include?("require \"js\"") || main.include?("JS.global"); puts "generated Ruby entrypoint is Ruby-only"'
|
|
139
|
+
three-rb browser examples/browser/ruby
|
|
140
|
+
test -f examples/browser/ruby/main.rb
|
|
141
|
+
test -f examples/browser/ruby/assets/studio.hdr
|
|
139
142
|
```
|
|
140
143
|
|
|
141
144
|
Both Ruby commands must print:
|
|
@@ -144,7 +147,7 @@ Both Ruby commands must print:
|
|
|
144
147
|
$VERSION
|
|
145
148
|
```
|
|
146
149
|
|
|
147
|
-
The `three-rb browser` command must create `examples/browser/quickstart/main.rb`, and the final Ruby command must print:
|
|
150
|
+
The `three-rb browser` command must create `examples/browser/quickstart/main.rb` and `examples/browser/ruby/main.rb`, and the final Ruby command must print:
|
|
148
151
|
|
|
149
152
|
```text
|
|
150
153
|
generated Ruby entrypoint is Ruby-only
|
|
@@ -22,6 +22,8 @@ If you installed through Bundler, run:
|
|
|
22
22
|
bundle exec three-rb browser examples/browser/quickstart
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
Use `three-rb browser examples/browser/ruby` instead when you want the richer Ruby gemstone sample. It generates the same browser runtime shape and keeps its HDR file under `examples/browser/ruby/assets/`.
|
|
26
|
+
|
|
25
27
|
The generator creates:
|
|
26
28
|
|
|
27
29
|
- `package.json` and `pnpm-lock.yaml`
|
|
@@ -32,6 +34,8 @@ The generator creates:
|
|
|
32
34
|
- `examples/browser/quickstart/main.rb`
|
|
33
35
|
- `examples/browser/quickstart/README.md`
|
|
34
36
|
|
|
37
|
+
For templates that need assets, the generator also creates an `assets/` directory inside the example.
|
|
38
|
+
|
|
35
39
|
Copying `lib/` puts the installed gem's Ruby source in the served app directory. The browser Ruby VM loads Ruby files over HTTP, so this is the current standalone workflow.
|
|
36
40
|
|
|
37
41
|
Pass `--force` only when you want to overwrite generated example files:
|
data/examples/browser/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
These examples are the browser-facing coverage map for three-rb's browser-first alpha. They run Ruby through ruby.wasm, load pnpm-managed three.js packages, and render through `Three::Renderers::ThreeJSRenderer`.
|
|
4
4
|
|
|
5
|
+
Examples that need fixtures keep those files under their own `assets/` directory so each sample remains self-contained.
|
|
6
|
+
|
|
5
7
|
## Run Examples
|
|
6
8
|
|
|
7
9
|
Install browser dependencies and serve the repository root:
|
|
@@ -41,7 +41,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
41
41
|
rig.name = "composition-rig"
|
|
42
42
|
scene.add(rig)
|
|
43
43
|
|
|
44
|
-
primary_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/assets/checker.svg")
|
|
44
|
+
primary_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/composition/assets/checker.svg")
|
|
45
45
|
primary_texture.wrap_s = Three::RepeatWrapping
|
|
46
46
|
primary_texture.wrap_t = Three::RepeatWrapping
|
|
47
47
|
primary_texture.mag_filter = Three::NearestFilter
|
|
@@ -164,7 +164,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
164
164
|
renderer: renderer
|
|
165
165
|
)
|
|
166
166
|
|
|
167
|
-
disposable_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/assets/checker.svg")
|
|
167
|
+
disposable_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/composition/assets/checker.svg")
|
|
168
168
|
disposable_material = Three::MeshBasicMaterial.new(map: disposable_texture)
|
|
169
169
|
renderer.on_dispose(disposable_texture) { app.set(:texture_dispose_event, true) }
|
|
170
170
|
renderer.on_dispose(disposable_material) { app.set(:material_dispose_event, true) }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
|
2
|
+
<rect width="128" height="128" fill="#eef3f7"/>
|
|
3
|
+
<rect width="32" height="32" fill="#22313f"/>
|
|
4
|
+
<rect x="64" width="32" height="32" fill="#22313f"/>
|
|
5
|
+
<rect x="32" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
6
|
+
<rect x="96" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
7
|
+
<rect y="64" width="32" height="32" fill="#22313f"/>
|
|
8
|
+
<rect x="64" y="64" width="32" height="32" fill="#22313f"/>
|
|
9
|
+
<rect x="32" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
10
|
+
<rect x="96" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
11
|
+
</svg>
|
|
@@ -7,7 +7,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
7
7
|
camera = Three::PerspectiveCamera.new(45, aspect: 1.0, near: 0.1, far: 100)
|
|
8
8
|
camera.position.set(0, 0.7, 4.0)
|
|
9
9
|
|
|
10
|
-
cube_sources = Array.new(6, "/examples/browser/assets/checker.svg")
|
|
10
|
+
cube_sources = Array.new(6, "/examples/browser/cubemap/assets/checker.svg")
|
|
11
11
|
cube_texture = Three::Loaders::CubeTextureLoader.new.load(cube_sources)
|
|
12
12
|
scene.background = cube_texture
|
|
13
13
|
scene.environment = cube_texture
|
|
@@ -21,7 +21,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
21
21
|
)
|
|
22
22
|
renderer.set_clear_color(0x11151a, 1)
|
|
23
23
|
|
|
24
|
-
gltf = Three::Loaders::GLTFLoader.new(backend: renderer.backend).load("/examples/browser/assets/animated_triangle.gltf")
|
|
24
|
+
gltf = Three::Loaders::GLTFLoader.new(backend: renderer.backend).load("/examples/browser/gltf/assets/animated_triangle.gltf")
|
|
25
25
|
model = gltf.scene
|
|
26
26
|
model.position.x = -0.75
|
|
27
27
|
model.scale.set(1.2, 1.2, 1.2)
|
|
@@ -31,7 +31,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
31
31
|
compressed_gltf = Three::Loaders::GLTFLoader.new(
|
|
32
32
|
backend: renderer.backend,
|
|
33
33
|
draco_decoder_path: draco_decoder_path
|
|
34
|
-
).load("/examples/browser/assets/compressed_triangle.gltf")
|
|
34
|
+
).load("/examples/browser/gltf/assets/compressed_triangle.gltf")
|
|
35
35
|
compressed_model = compressed_gltf.scene
|
|
36
36
|
compressed_model.position.x = 1.05
|
|
37
37
|
compressed_model.scale.set(0.82, 0.82, 0.82)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
|
2
|
+
<rect width="128" height="128" fill="#eef3f7"/>
|
|
3
|
+
<rect width="32" height="32" fill="#22313f"/>
|
|
4
|
+
<rect x="64" width="32" height="32" fill="#22313f"/>
|
|
5
|
+
<rect x="32" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
6
|
+
<rect x="96" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
7
|
+
<rect y="64" width="32" height="32" fill="#22313f"/>
|
|
8
|
+
<rect x="64" y="64" width="32" height="32" fill="#22313f"/>
|
|
9
|
+
<rect x="32" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
10
|
+
<rect x="96" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
11
|
+
</svg>
|
|
@@ -43,7 +43,7 @@ Three::Browser.run(starting: "Starting primitives scene") do |app|
|
|
|
43
43
|
Three::PointsMaterial.new(color: 0xffcc4d, size: 12, size_attenuation: false)
|
|
44
44
|
)
|
|
45
45
|
|
|
46
|
-
sprite_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/assets/checker.svg")
|
|
46
|
+
sprite_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/primitives/assets/checker.svg")
|
|
47
47
|
sprite_material = Three::SpriteMaterial.new(
|
|
48
48
|
color: 0xffffff,
|
|
49
49
|
map: sprite_texture,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This browser example is the first visual sample for three-rb. It builds a faceted red gemstone in Ruby with `BufferGeometry`, renders it with `MeshPhysicalMaterial`, and adds an extruded `three-rb` title through the three.js `TextGeometry` addon.
|
|
4
4
|
|
|
5
|
+
Its HDR environment file lives under `examples/browser/ruby/assets/` with the sample.
|
|
6
|
+
|
|
5
7
|
Run it from the repository root:
|
|
6
8
|
|
|
7
9
|
```sh
|
|
@@ -106,7 +106,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
106
106
|
camera = Three::PerspectiveCamera.new(42, aspect: 1.0, near: 0.1, far: 100)
|
|
107
107
|
camera.position.set(0, 0.42, 6.9)
|
|
108
108
|
|
|
109
|
-
environment_texture = Three::Loaders::RGBELoader.new.load("/examples/browser/assets/studio.hdr")
|
|
109
|
+
environment_texture = Three::Loaders::RGBELoader.new.load("/examples/browser/ruby/assets/studio.hdr")
|
|
110
110
|
scene.environment = environment_texture
|
|
111
111
|
|
|
112
112
|
scene.add(Three::AmbientLight.new(0xffffff, 0.82))
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
|
2
|
+
<rect width="128" height="128" fill="#eef3f7"/>
|
|
3
|
+
<rect width="32" height="32" fill="#22313f"/>
|
|
4
|
+
<rect x="64" width="32" height="32" fill="#22313f"/>
|
|
5
|
+
<rect x="32" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
6
|
+
<rect x="96" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
7
|
+
<rect y="64" width="32" height="32" fill="#22313f"/>
|
|
8
|
+
<rect x="64" y="64" width="32" height="32" fill="#22313f"/>
|
|
9
|
+
<rect x="32" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
10
|
+
<rect x="96" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
11
|
+
</svg>
|
|
@@ -6,7 +6,7 @@ Three::Browser.run(starting: "Exporting Ruby scene") do |app|
|
|
|
6
6
|
source_scene = Three::Scene.new
|
|
7
7
|
source_scene.name = "serialization-source"
|
|
8
8
|
|
|
9
|
-
shared_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/assets/checker.svg")
|
|
9
|
+
shared_texture = Three::Loaders::TextureLoader.new.load("/examples/browser/serialization/assets/checker.svg")
|
|
10
10
|
shared_texture.wrap_s = Three::RepeatWrapping
|
|
11
11
|
shared_texture.wrap_t = Three::RepeatWrapping
|
|
12
12
|
shared_texture.mag_filter = Three::NearestFilter
|
|
@@ -90,7 +90,7 @@ function shouldBypassCache(input) {
|
|
|
90
90
|
if (pathname.startsWith("/lib/")) return true;
|
|
91
91
|
if (!pathname.startsWith("/examples/browser/")) return false;
|
|
92
92
|
|
|
93
|
-
return !pathname.
|
|
93
|
+
return !pathname.includes("/assets/");
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
async function compileWasm(url) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
|
2
|
+
<rect width="128" height="128" fill="#eef3f7"/>
|
|
3
|
+
<rect width="32" height="32" fill="#22313f"/>
|
|
4
|
+
<rect x="64" width="32" height="32" fill="#22313f"/>
|
|
5
|
+
<rect x="32" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
6
|
+
<rect x="96" y="32" width="32" height="32" fill="#6ed69a"/>
|
|
7
|
+
<rect y="64" width="32" height="32" fill="#22313f"/>
|
|
8
|
+
<rect x="64" y="64" width="32" height="32" fill="#22313f"/>
|
|
9
|
+
<rect x="32" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
10
|
+
<rect x="96" y="96" width="32" height="32" fill="#6ed69a"/>
|
|
11
|
+
</svg>
|
|
@@ -7,7 +7,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
7
7
|
camera = Three::OrthographicCamera.new(-2.5, 2.5, 1.6, -1.6, near: 0.1, far: 100)
|
|
8
8
|
camera.position.z = 5
|
|
9
9
|
|
|
10
|
-
environment_texture = Three::Loaders::RGBELoader.new.load("/examples/browser/assets/studio.hdr")
|
|
10
|
+
environment_texture = Three::Loaders::RGBELoader.new.load("/examples/browser/textures/assets/studio.hdr")
|
|
11
11
|
scene.environment = environment_texture
|
|
12
12
|
|
|
13
13
|
scene.add(Three::AmbientLight.new(0xffffff, 0.45))
|
|
@@ -16,7 +16,7 @@ Three::Browser.run(starting: "Starting Ruby scene") do |app|
|
|
|
16
16
|
key_light.position.set(2.5, 3.0, 4.0)
|
|
17
17
|
scene.add(key_light)
|
|
18
18
|
|
|
19
|
-
texture = Three::Loaders::TextureLoader.new.load("/examples/browser/assets/checker.svg")
|
|
19
|
+
texture = Three::Loaders::TextureLoader.new.load("/examples/browser/textures/assets/checker.svg")
|
|
20
20
|
texture.wrap_s = Three::RepeatWrapping
|
|
21
21
|
texture.wrap_t = Three::RepeatWrapping
|
|
22
22
|
texture.mag_filter = Three::NearestFilter
|
data/exe/three-rb
CHANGED
|
@@ -67,10 +67,42 @@ module Three
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def write_example_files
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
if ruby_example?
|
|
71
|
+
copy_ruby_example_files
|
|
72
|
+
else
|
|
73
|
+
write_file(example_path("index.html"), index_html, overwrite: @force)
|
|
74
|
+
write_file(example_path("boot.mjs"), boot_js, overwrite: @force)
|
|
75
|
+
write_file(example_path("main.rb"), main_rb, overwrite: @force)
|
|
76
|
+
write_file(example_path("README.md"), readme, overwrite: @force)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def copy_ruby_example_files
|
|
81
|
+
{
|
|
82
|
+
"index.html" => "index.html",
|
|
83
|
+
"boot.mjs" => "boot.mjs",
|
|
84
|
+
"main.rb" => "main.rb",
|
|
85
|
+
"assets/studio.hdr" => "assets/studio.hdr"
|
|
86
|
+
}.each do |source_name, destination_name|
|
|
87
|
+
copy_generated_file(
|
|
88
|
+
runtime_path(File.join("examples/browser/ruby", source_name)),
|
|
89
|
+
example_path(destination_name),
|
|
90
|
+
overwrite: @force
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
write_ruby_readme
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def write_ruby_readme
|
|
98
|
+
source = runtime_path("examples/browser/ruby/README.md")
|
|
99
|
+
destination = example_path("README.md")
|
|
100
|
+
if File.exist?(destination) && File.identical?(source, destination)
|
|
101
|
+
@skipped << relative_path(destination)
|
|
102
|
+
return
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
write_file(destination, ruby_readme, overwrite: @force)
|
|
74
106
|
end
|
|
75
107
|
|
|
76
108
|
def copy_tree(source, destination, overwrite:)
|
|
@@ -83,6 +115,11 @@ module Three
|
|
|
83
115
|
end
|
|
84
116
|
|
|
85
117
|
def copy_file(source, destination, overwrite:)
|
|
118
|
+
if File.exist?(destination) && File.identical?(source, destination)
|
|
119
|
+
@skipped << relative_path(destination)
|
|
120
|
+
return
|
|
121
|
+
end
|
|
122
|
+
|
|
86
123
|
if File.exist?(destination) && !overwrite
|
|
87
124
|
@skipped << relative_path(destination)
|
|
88
125
|
return
|
|
@@ -93,6 +130,21 @@ module Three
|
|
|
93
130
|
@created << relative_path(destination)
|
|
94
131
|
end
|
|
95
132
|
|
|
133
|
+
def copy_generated_file(source, destination, overwrite:)
|
|
134
|
+
if File.exist?(destination) && File.identical?(source, destination)
|
|
135
|
+
@skipped << relative_path(destination)
|
|
136
|
+
return
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if File.exist?(destination) && !overwrite
|
|
140
|
+
raise ArgumentError, "#{relative_path(destination)} already exists; pass --force to overwrite generated example files"
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
|
144
|
+
FileUtils.cp(source, destination)
|
|
145
|
+
@created << relative_path(destination)
|
|
146
|
+
end
|
|
147
|
+
|
|
96
148
|
def write_file(path, content, overwrite:)
|
|
97
149
|
if File.exist?(path) && !overwrite
|
|
98
150
|
raise ArgumentError, "#{relative_path(path)} already exists; pass --force to overwrite generated example files"
|
|
@@ -114,7 +166,9 @@ module Three
|
|
|
114
166
|
end
|
|
115
167
|
|
|
116
168
|
def example_files
|
|
117
|
-
%w[index.html boot.mjs main.rb README.md]
|
|
169
|
+
names = %w[index.html boot.mjs main.rb README.md]
|
|
170
|
+
names << "assets/studio.hdr" if ruby_example?
|
|
171
|
+
names.map { |name| example_path(name) }
|
|
118
172
|
end
|
|
119
173
|
|
|
120
174
|
def example_path(name)
|
|
@@ -155,6 +209,10 @@ module Three
|
|
|
155
209
|
JSON.generate(text)
|
|
156
210
|
end
|
|
157
211
|
|
|
212
|
+
def ruby_example?
|
|
213
|
+
relative_path(@target) == "examples/browser/ruby"
|
|
214
|
+
end
|
|
215
|
+
|
|
158
216
|
def index_html
|
|
159
217
|
<<~HTML
|
|
160
218
|
<!doctype html>
|
|
@@ -310,6 +368,29 @@ module Three
|
|
|
310
368
|
Keep serving the project root. The browser runtime loads `node_modules/`, `lib/`, and this example over HTTP.
|
|
311
369
|
MARKDOWN
|
|
312
370
|
end
|
|
371
|
+
|
|
372
|
+
def ruby_readme
|
|
373
|
+
<<~MARKDOWN
|
|
374
|
+
# three-rb Ruby Example
|
|
375
|
+
|
|
376
|
+
This generated browser example runs Ruby through ruby.wasm and renders a faceted red gemstone with a three-dimensional `three-rb` title.
|
|
377
|
+
|
|
378
|
+
From the project root:
|
|
379
|
+
|
|
380
|
+
```sh
|
|
381
|
+
pnpm install
|
|
382
|
+
ruby -run -e httpd . -p 8000
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Open:
|
|
386
|
+
|
|
387
|
+
```text
|
|
388
|
+
http://localhost:8000/#{relative_path(@target)}/
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Keep serving the project root. The browser runtime loads `node_modules/`, `lib/`, and this example's local `assets/` directory over HTTP.
|
|
392
|
+
MARKDOWN
|
|
393
|
+
end
|
|
313
394
|
end
|
|
314
395
|
end
|
|
315
396
|
end
|
data/lib/three/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: three-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LEF
|
|
@@ -56,12 +56,8 @@ files:
|
|
|
56
56
|
- docs/release-readiness.md
|
|
57
57
|
- docs/standalone-browser-app.md
|
|
58
58
|
- examples/browser/README.md
|
|
59
|
-
- examples/browser/assets/animated_triangle.gltf
|
|
60
|
-
- examples/browser/assets/checker.svg
|
|
61
|
-
- examples/browser/assets/compressed_triangle.gltf
|
|
62
|
-
- examples/browser/assets/studio.hdr
|
|
63
|
-
- examples/browser/assets/triangle.gltf
|
|
64
59
|
- examples/browser/composition/README.md
|
|
60
|
+
- examples/browser/composition/assets/checker.svg
|
|
65
61
|
- examples/browser/composition/boot.mjs
|
|
66
62
|
- examples/browser/composition/index.html
|
|
67
63
|
- examples/browser/composition/main.rb
|
|
@@ -72,11 +68,15 @@ files:
|
|
|
72
68
|
- examples/browser/cube/main.rb
|
|
73
69
|
- examples/browser/cube/smoke_test.mjs
|
|
74
70
|
- examples/browser/cubemap/README.md
|
|
71
|
+
- examples/browser/cubemap/assets/checker.svg
|
|
75
72
|
- examples/browser/cubemap/boot.mjs
|
|
76
73
|
- examples/browser/cubemap/index.html
|
|
77
74
|
- examples/browser/cubemap/main.rb
|
|
78
75
|
- examples/browser/cubemap/smoke_test.mjs
|
|
79
76
|
- examples/browser/gltf/README.md
|
|
77
|
+
- examples/browser/gltf/assets/animated_triangle.gltf
|
|
78
|
+
- examples/browser/gltf/assets/compressed_triangle.gltf
|
|
79
|
+
- examples/browser/gltf/assets/triangle.gltf
|
|
80
80
|
- examples/browser/gltf/boot.mjs
|
|
81
81
|
- examples/browser/gltf/index.html
|
|
82
82
|
- examples/browser/gltf/main.rb
|
|
@@ -92,16 +92,19 @@ files:
|
|
|
92
92
|
- examples/browser/postprocessing/main.rb
|
|
93
93
|
- examples/browser/postprocessing/smoke_test.mjs
|
|
94
94
|
- examples/browser/primitives/README.md
|
|
95
|
+
- examples/browser/primitives/assets/checker.svg
|
|
95
96
|
- examples/browser/primitives/boot.mjs
|
|
96
97
|
- examples/browser/primitives/index.html
|
|
97
98
|
- examples/browser/primitives/main.rb
|
|
98
99
|
- examples/browser/primitives/smoke_test.mjs
|
|
99
100
|
- examples/browser/ruby/README.md
|
|
101
|
+
- examples/browser/ruby/assets/studio.hdr
|
|
100
102
|
- examples/browser/ruby/boot.mjs
|
|
101
103
|
- examples/browser/ruby/index.html
|
|
102
104
|
- examples/browser/ruby/main.rb
|
|
103
105
|
- examples/browser/ruby/smoke_test.mjs
|
|
104
106
|
- examples/browser/serialization/README.md
|
|
107
|
+
- examples/browser/serialization/assets/checker.svg
|
|
105
108
|
- examples/browser/serialization/boot.mjs
|
|
106
109
|
- examples/browser/serialization/index.html
|
|
107
110
|
- examples/browser/serialization/main.rb
|
|
@@ -109,6 +112,8 @@ files:
|
|
|
109
112
|
- examples/browser/shared/boot.mjs
|
|
110
113
|
- examples/browser/shared/smoke_test_helpers.mjs
|
|
111
114
|
- examples/browser/textures/README.md
|
|
115
|
+
- examples/browser/textures/assets/checker.svg
|
|
116
|
+
- examples/browser/textures/assets/studio.hdr
|
|
112
117
|
- examples/browser/textures/boot.mjs
|
|
113
118
|
- examples/browser/textures/index.html
|
|
114
119
|
- examples/browser/textures/main.rb
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|