three-rb 0.2.0 → 0.3.0
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 +38 -2
- data/README.md +14 -6
- data/docs/browser-runtime.md +10 -6
- data/docs/cloudflare-pages.md +205 -0
- data/docs/implementation-plan.md +6 -4
- data/docs/loaded-assets-design.md +1 -1
- data/docs/next-work.md +26 -25
- data/docs/publishing.md +4 -1
- data/docs/release-readiness.md +11 -11
- data/docs/standalone-browser-app.md +8 -2
- data/examples/browser/README.md +5 -1
- data/examples/browser/composition/index.html +65 -4
- data/examples/browser/composition/main.rb +2 -2
- data/examples/browser/cube/README.md +3 -3
- data/examples/browser/cube/index.html +61 -6
- data/examples/browser/cubemap/assets/checker.svg +11 -0
- data/examples/browser/cubemap/index.html +60 -5
- data/examples/browser/cubemap/main.rb +1 -1
- data/examples/browser/dango/README.md +26 -0
- data/examples/browser/dango/boot.mjs +6 -0
- data/examples/browser/dango/index.html +197 -0
- data/examples/browser/dango/main.rb +278 -0
- data/examples/browser/dango/smoke_test.mjs +232 -0
- data/examples/browser/gltf/index.html +60 -5
- data/examples/browser/gltf/main.rb +2 -2
- data/examples/browser/picking/index.html +61 -6
- data/examples/browser/postprocessing/index.html +61 -6
- data/examples/browser/primitives/assets/checker.svg +11 -0
- data/examples/browser/primitives/index.html +61 -6
- data/examples/browser/primitives/main.rb +1 -1
- data/examples/browser/ruby/README.md +2 -0
- data/examples/browser/ruby/assets/helvetiker_regular.typeface.json +1 -0
- data/examples/browser/ruby/index.html +112 -8
- data/examples/browser/ruby/main.rb +2 -6
- data/examples/browser/serialization/assets/checker.svg +11 -0
- data/examples/browser/serialization/index.html +61 -6
- data/examples/browser/serialization/main.rb +1 -1
- data/examples/browser/shared/boot.mjs +116 -14
- data/examples/browser/shared/config.mjs +3 -0
- data/examples/browser/shared/smoke_test_helpers.mjs +13 -8
- data/examples/browser/textures/assets/checker.svg +11 -0
- data/examples/browser/textures/index.html +61 -6
- data/examples/browser/textures/main.rb +2 -2
- data/exe/three-rb +1 -0
- data/lib/three/backends/threejs/parameters.rb +4 -1
- data/lib/three/backends/threejs/ruby_wasm_adapter.rb +8 -2
- data/lib/three/generators/browser_example.rb +220 -12
- data/lib/three/version.rb +1 -1
- data/package.json +9 -5
- data/pnpm-lock.yaml +1235 -31
- metadata +19 -7
- /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 → textures/assets}/studio.hdr +0 -0
data/docs/release-readiness.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
# Release Readiness
|
|
2
2
|
|
|
3
|
-
This document defines the quality gate for publishing
|
|
3
|
+
This document defines the quality gate for publishing a `three-rb` release.
|
|
4
4
|
|
|
5
5
|
## Current Position
|
|
6
6
|
|
|
7
7
|
The project is past the original MVP. It is now in Phase 8, renderer maturity: core Ruby scene authoring, browser rendering, JSON export/load, interaction, asset loading, instancing, picking, shadows, and initial postprocessing are implemented and covered by unit or browser smoke tests.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`0.1.0` was the first public release. Every release in the `0.x` series is a browser-first alpha. The stable promise is narrow: users can build Ruby-authored scenes and render them in a browser through ruby.wasm and the delegated three.js backend. Native rendering and full three.js API compatibility are not part of the alpha releases.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Alpha Release Definition
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
A `0.x` release is not a `1.0` stable API commitment. A future `1.0` should get a separate stability plan covering compatibility guarantees, deprecation policy, support windows, and any non-browser renderer commitment.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
A `0.x` release is ready when all of these are true:
|
|
16
16
|
|
|
17
17
|
- Scope is frozen to the browser-first alpha surface in this document and `README.md`; no additional material, loader, render-target, postprocessing, WebGPU, XR, native-renderer, or broad compatibility work is required for the release unless an already-advertised example is broken.
|
|
18
18
|
- Public API documentation matches the implemented, tested Ruby API surface loaded by `require "three"`.
|
|
19
19
|
- Ruby-authored browser examples use `Three::Browser` helpers instead of application-level `require "js"` and `JS.global`, and the `three-rb browser` generator can create the same Ruby-only entrypoint shape for standalone apps.
|
|
20
|
-
- Snake-case Ruby methods are the documented API style. Broad camelCase three.js compatibility aliases
|
|
20
|
+
- Snake-case Ruby methods are the documented API style. Broad camelCase three.js compatibility aliases remain deferred.
|
|
21
21
|
- `Three::Exporters::ThreeJSONExporter` and `Three::Loaders::ThreeJSONLoader` continue to round-trip Ruby-authored scenes covered by the saved `test/fixtures/scene_export_v1.json` regression fixture.
|
|
22
|
-
- JavaScript-loaded assets remain opaque `ExternalObject3D` roots
|
|
22
|
+
- JavaScript-loaded assets remain opaque `ExternalObject3D` roots in the alpha releases; transform-level use, renderer traversal helpers, animation mixer usage, and explicit subtree disposal are in scope, while Ruby child mutation inside loaded external roots is out of scope.
|
|
23
23
|
- Every browser example advertised in `README.md` and `examples/browser/README.md` has a matching deterministic Playwright smoke command, and `pnpm test:browser` runs them all.
|
|
24
24
|
- The required gate below passes locally before tagging, and the CI workflow passes on the release commit.
|
|
25
25
|
- Release metadata is final: `lib/three/version.rb` contains the exact target version, `CHANGELOG.md` has either the unreleased heading during development or the final release date before publishing, and `docs/publishing.md` has the manual publish steps.
|
|
26
26
|
|
|
27
27
|
## Public Scope
|
|
28
28
|
|
|
29
|
-
Included in the
|
|
29
|
+
Included in the alpha scope:
|
|
30
30
|
|
|
31
31
|
- Ruby object model for scenes, groups, transforms, cameras, lights, geometries, non-mesh primitives including sprites, common materials including matcap, toon, sprite, and shadow materials, textures, and common math primitives.
|
|
32
|
-
- Browser rendering through `Three::Renderers::ThreeJSRenderer`, ruby.wasm, and `three@0.
|
|
32
|
+
- Browser rendering through `Three::Renderers::ThreeJSRenderer`, ruby.wasm, and `three@0.187.0`.
|
|
33
33
|
- `Three::Browser` helpers and the `three-rb browser` executable for generating standalone Ruby-only browser examples.
|
|
34
34
|
- Dirty-tracked synchronization from Ruby objects into three.js handles.
|
|
35
35
|
- JSON export/load for Ruby-authored scenes.
|
|
36
36
|
- JavaScript-delegated browser integrations for textures, cube maps, RGBE environment maps, glTF, DRACO, animation mixers, OrbitControls, raycasting, instancing, shadows, and initial postprocessing with composer/render/bloom/dot-screen/output passes.
|
|
37
37
|
- Browser examples and smoke tests that verify visible rendering paths.
|
|
38
38
|
|
|
39
|
-
Explicitly out of scope for the
|
|
39
|
+
Explicitly out of scope for the alpha releases:
|
|
40
40
|
|
|
41
41
|
- A native Ruby renderer.
|
|
42
42
|
- Full three.js API coverage.
|
|
@@ -82,4 +82,4 @@ Before expanding feature scope, prefer:
|
|
|
82
82
|
3. Keep `CHANGELOG.md` accurate while the next release remains under an unreleased heading.
|
|
83
83
|
4. Improve public docs around browser examples, browser boot, and unsupported APIs; see `docs/next-work.md`.
|
|
84
84
|
5. Add new material classes, postprocessing passes, render targets, or loaders only when a dedicated example and smoke test need them.
|
|
85
|
-
6. Treat KTX2, WebGPU, WebXR, and native rendering as
|
|
85
|
+
6. Treat KTX2, WebGPU, WebXR, and native rendering as later planning items.
|
|
@@ -22,16 +22,22 @@ 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 title font under `examples/browser/ruby/assets/`.
|
|
26
|
+
|
|
25
27
|
The generator creates:
|
|
26
28
|
|
|
27
|
-
- `package.json
|
|
29
|
+
- `package.json`, listing only the browser runtime packages (three.js and ruby.wasm), and a matching `pnpm-lock.yaml`
|
|
28
30
|
- `lib/`, copied from the installed gem
|
|
29
|
-
- `examples/browser/shared/boot.mjs`
|
|
31
|
+
- `examples/browser/shared/boot.mjs` and `examples/browser/shared/config.mjs`
|
|
30
32
|
- `examples/browser/quickstart/index.html`
|
|
31
33
|
- `examples/browser/quickstart/boot.mjs`
|
|
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
|
+
|
|
39
|
+
If the project already has a `package.json`, the generator leaves it alone and doesn't write a lockfile. Add the `dependencies` from the gem's `package.json` to it yourself.
|
|
40
|
+
|
|
35
41
|
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
42
|
|
|
37
43
|
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:
|
|
@@ -18,6 +20,7 @@ Open an example URL:
|
|
|
18
20
|
```text
|
|
19
21
|
http://localhost:8000/examples/browser/ruby/
|
|
20
22
|
http://localhost:8000/examples/browser/cube/
|
|
23
|
+
http://localhost:8000/examples/browser/dango/
|
|
21
24
|
http://localhost:8000/examples/browser/composition/
|
|
22
25
|
http://localhost:8000/examples/browser/textures/
|
|
23
26
|
http://localhost:8000/examples/browser/cubemap/
|
|
@@ -42,8 +45,9 @@ Run one smoke test by using the command listed in the table below.
|
|
|
42
45
|
|
|
43
46
|
| Example | Primary APIs covered | Smoke command | Why it exists |
|
|
44
47
|
| --- | --- | --- | --- |
|
|
45
|
-
| `examples/browser/ruby/` | `BufferGeometry`, `Float32BufferAttribute`, `MeshPhysicalMaterial`, `
|
|
48
|
+
| `examples/browser/ruby/` | `BufferGeometry`, `Float32BufferAttribute`, `MeshPhysicalMaterial`, `FontLoader`, `TextGeometry`, `OrbitControls`, shadows | `pnpm test:browser:ruby` | Provides the first visual sample: a Ruby-authored faceted red gemstone with a three-dimensional `three-rb` title. |
|
|
46
49
|
| `examples/browser/cube/` | `Scene`, `PerspectiveCamera`, `BoxGeometry`, `Mesh`, `MeshBasicMaterial`, `ThreeJSRenderer`, animation loop | `pnpm test:browser:cube` | Verifies the smallest Ruby-authored scene can boot through ruby.wasm and draw nonblank WebGL pixels through the three.js renderer path. |
|
|
50
|
+
| `examples/browser/dango/` | `OrthographicCamera`, `SphereGeometry`, `BoxGeometry`, `Group`, `MeshPhongMaterial`, `MeshLambertMaterial`, directional/hemisphere/point lights, shadows, `OrbitControls` | `pnpm test:browser:dango` | Adds a recognizable Ruby-authored 3D graphics example by composing a three-color dango from primitive meshes with lighting, shadows, and camera controls. |
|
|
47
51
|
| `examples/browser/composition/` | `OrthographicCamera`, ambient/directional/point/hemisphere lights, shadows, `ShadowMaterial`, `Group`, `InstancedMesh`, `TextureLoader`, `OrbitControls`, material/texture disposal | `pnpm test:browser:composition` | Exercises the broad scene-composition path used by richer browser scenes, including dynamic material updates and camera controls. |
|
|
48
52
|
| `examples/browser/textures/` | `TextureLoader`, `RGBELoader`, repeat/wrap/filter/UV-transform settings, `MeshPhysicalMaterial`, `MeshMatcapMaterial`, `MeshToonMaterial`, physical, matcap, and toon texture slots, scene environment | `pnpm test:browser:textures` | Verifies browser texture loading, HDR environment synchronization, and the current material texture bridge. |
|
|
49
53
|
| `examples/browser/cubemap/` | `CubeTextureLoader`, `CubeTexture`, scene `background`, scene `environment`, reflective `MeshStandardMaterial` | `pnpm test:browser:cubemap` | Keeps cubemap background/environment behavior covered separately from ordinary 2D texture loading. |
|
|
@@ -54,10 +54,12 @@
|
|
|
54
54
|
position: absolute;
|
|
55
55
|
top: 16px;
|
|
56
56
|
left: 16px;
|
|
57
|
-
display:
|
|
57
|
+
display: grid;
|
|
58
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
58
59
|
align-items: center;
|
|
59
60
|
gap: 8px;
|
|
60
61
|
max-width: calc(100% - 32px);
|
|
62
|
+
min-width: min(360px, calc(100% - 32px));
|
|
61
63
|
padding: 8px 10px;
|
|
62
64
|
border: 1px solid rgba(255, 255, 255, 0.14);
|
|
63
65
|
border-radius: 6px;
|
|
@@ -87,6 +89,44 @@
|
|
|
87
89
|
background: #f15b5b;
|
|
88
90
|
box-shadow: 0 0 14px rgba(241, 91, 91, 0.72);
|
|
89
91
|
}
|
|
92
|
+
|
|
93
|
+
.status-dot[data-state="loading"] {
|
|
94
|
+
animation: status-dot-pulse 1.2s ease-in-out infinite;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@keyframes status-dot-pulse {
|
|
98
|
+
0%,
|
|
99
|
+
100% {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: scale(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
50% {
|
|
105
|
+
opacity: 0.4;
|
|
106
|
+
transform: scale(0.75);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.progress {
|
|
111
|
+
grid-column: 1 / -1;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 4px;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
border-radius: 999px;
|
|
116
|
+
background: rgba(255, 255, 255, 0.16);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.progress-bar {
|
|
120
|
+
width: 4%;
|
|
121
|
+
height: 100%;
|
|
122
|
+
border-radius: inherit;
|
|
123
|
+
background: linear-gradient(90deg, #55ace0, #60d394);
|
|
124
|
+
transition: width 180ms ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.progress[hidden] {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
90
130
|
</style>
|
|
91
131
|
<script type="importmap">
|
|
92
132
|
{
|
|
@@ -101,10 +141,22 @@
|
|
|
101
141
|
<script type="module">
|
|
102
142
|
const status = document.querySelector("#status");
|
|
103
143
|
const statusDot = document.querySelector("#status-dot");
|
|
144
|
+
const progress = document.querySelector("#progress");
|
|
145
|
+
const progressBar = document.querySelector("#progress-bar");
|
|
104
146
|
|
|
105
|
-
globalThis.__threeRbSetStatus = (message, state) => {
|
|
147
|
+
globalThis.__threeRbSetStatus = (message, state, percent) => {
|
|
106
148
|
if (status) status.textContent = message;
|
|
107
149
|
if (statusDot) statusDot.dataset.state = state;
|
|
150
|
+
if (progress && progressBar) {
|
|
151
|
+
if (state === "running" || state === "error") {
|
|
152
|
+
progress.hidden = true;
|
|
153
|
+
} else {
|
|
154
|
+
progress.hidden = false;
|
|
155
|
+
if (Number.isFinite(percent)) {
|
|
156
|
+
progressBar.style.width = `${Math.max(4, Math.min(100, percent))}%`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
108
160
|
};
|
|
109
161
|
|
|
110
162
|
globalThis.__threeRbBootFailed = (message) => {
|
|
@@ -120,7 +172,13 @@
|
|
|
120
172
|
globalThis.__threeRbBootFailed(reason && reason.message ? reason.message : "Ruby boot failed");
|
|
121
173
|
});
|
|
122
174
|
|
|
123
|
-
globalThis.
|
|
175
|
+
globalThis.setTimeout(() => {
|
|
176
|
+
if (status && statusDot && statusDot.dataset.state === "loading") {
|
|
177
|
+
status.textContent = "Still loading after 15 seconds. Try reloading the page.";
|
|
178
|
+
}
|
|
179
|
+
}, 15000);
|
|
180
|
+
|
|
181
|
+
globalThis.__threeRbSetStatus("Loading ruby.wasm", "loading", 4);
|
|
124
182
|
</script>
|
|
125
183
|
<script type="module" src="./boot.mjs"></script>
|
|
126
184
|
</head>
|
|
@@ -128,8 +186,11 @@
|
|
|
128
186
|
<main class="viewport" id="viewport">
|
|
129
187
|
<canvas id="scene" data-testid="scene-canvas"></canvas>
|
|
130
188
|
<div class="hud" aria-live="polite">
|
|
131
|
-
<span class="status-dot" id="status-dot"></span>
|
|
189
|
+
<span class="status-dot" id="status-dot" data-state="loading"></span>
|
|
132
190
|
<span id="status" data-testid="status">Loading ruby.wasm</span>
|
|
191
|
+
<div class="progress" id="progress" aria-hidden="true">
|
|
192
|
+
<div class="progress-bar" id="progress-bar"></div>
|
|
193
|
+
</div>
|
|
133
194
|
</div>
|
|
134
195
|
</main>
|
|
135
196
|
</body>
|
|
@@ -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) }
|
|
@@ -17,9 +17,9 @@ http://localhost:8000/examples/browser/cube/
|
|
|
17
17
|
|
|
18
18
|
The page uses these pnpm-managed browser dependencies:
|
|
19
19
|
|
|
20
|
-
- `@ruby/3.4-wasm-wasi@2.
|
|
21
|
-
- `@ruby/wasm-wasi@2.
|
|
22
|
-
- `three@0.
|
|
20
|
+
- `@ruby/3.4-wasm-wasi@2.10.1`
|
|
21
|
+
- `@ruby/wasm-wasi@2.10.1`
|
|
22
|
+
- `three@0.187.0`
|
|
23
23
|
|
|
24
24
|
The repository root must be served, not only this directory, because `boot.mjs` loads browser packages from `node_modules/` and `main.rb` loads the library source from `lib/`.
|
|
25
25
|
|
|
@@ -54,10 +54,12 @@
|
|
|
54
54
|
position: absolute;
|
|
55
55
|
top: 16px;
|
|
56
56
|
left: 16px;
|
|
57
|
-
display:
|
|
57
|
+
display: grid;
|
|
58
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
58
59
|
align-items: center;
|
|
59
60
|
gap: 8px;
|
|
60
61
|
max-width: calc(100% - 32px);
|
|
62
|
+
min-width: min(360px, calc(100% - 32px));
|
|
61
63
|
padding: 8px 10px;
|
|
62
64
|
border: 1px solid rgba(255, 255, 255, 0.14);
|
|
63
65
|
border-radius: 6px;
|
|
@@ -87,6 +89,44 @@
|
|
|
87
89
|
background: #f15b5b;
|
|
88
90
|
box-shadow: 0 0 14px rgba(241, 91, 91, 0.72);
|
|
89
91
|
}
|
|
92
|
+
|
|
93
|
+
.status-dot[data-state="loading"] {
|
|
94
|
+
animation: status-dot-pulse 1.2s ease-in-out infinite;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@keyframes status-dot-pulse {
|
|
98
|
+
0%,
|
|
99
|
+
100% {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: scale(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
50% {
|
|
105
|
+
opacity: 0.4;
|
|
106
|
+
transform: scale(0.75);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.progress {
|
|
111
|
+
grid-column: 1 / -1;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 4px;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
border-radius: 999px;
|
|
116
|
+
background: rgba(255, 255, 255, 0.16);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.progress-bar {
|
|
120
|
+
width: 4%;
|
|
121
|
+
height: 100%;
|
|
122
|
+
border-radius: inherit;
|
|
123
|
+
background: linear-gradient(90deg, #55ace0, #4ed08f);
|
|
124
|
+
transition: width 180ms ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.progress[hidden] {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
90
130
|
</style>
|
|
91
131
|
<script type="importmap">
|
|
92
132
|
{
|
|
@@ -101,10 +141,22 @@
|
|
|
101
141
|
<script type="module">
|
|
102
142
|
const status = document.querySelector("#status");
|
|
103
143
|
const statusDot = document.querySelector("#status-dot");
|
|
144
|
+
const progress = document.querySelector("#progress");
|
|
145
|
+
const progressBar = document.querySelector("#progress-bar");
|
|
104
146
|
|
|
105
|
-
globalThis.__threeRbSetStatus = (message, state) => {
|
|
147
|
+
globalThis.__threeRbSetStatus = (message, state, percent) => {
|
|
106
148
|
if (status) status.textContent = message;
|
|
107
149
|
if (statusDot) statusDot.dataset.state = state;
|
|
150
|
+
if (progress && progressBar) {
|
|
151
|
+
if (state === "running" || state === "error") {
|
|
152
|
+
progress.hidden = true;
|
|
153
|
+
} else {
|
|
154
|
+
progress.hidden = false;
|
|
155
|
+
if (Number.isFinite(percent)) {
|
|
156
|
+
progressBar.style.width = `${Math.max(4, Math.min(100, percent))}%`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
108
160
|
};
|
|
109
161
|
|
|
110
162
|
globalThis.__threeRbBootFailed = (message) => {
|
|
@@ -121,12 +173,12 @@
|
|
|
121
173
|
});
|
|
122
174
|
|
|
123
175
|
globalThis.setTimeout(() => {
|
|
124
|
-
if (status &&
|
|
125
|
-
status.textContent = "Still loading
|
|
176
|
+
if (status && statusDot && statusDot.dataset.state === "loading") {
|
|
177
|
+
status.textContent = "Still loading after 15 seconds. Try reloading the page.";
|
|
126
178
|
}
|
|
127
179
|
}, 15000);
|
|
128
180
|
|
|
129
|
-
globalThis.__threeRbSetStatus("Loading ruby.wasm", "loading");
|
|
181
|
+
globalThis.__threeRbSetStatus("Loading ruby.wasm", "loading", 4);
|
|
130
182
|
</script>
|
|
131
183
|
<script type="module" src="./boot.mjs"></script>
|
|
132
184
|
</head>
|
|
@@ -134,8 +186,11 @@
|
|
|
134
186
|
<main class="viewport" id="viewport">
|
|
135
187
|
<canvas id="scene" data-testid="scene-canvas"></canvas>
|
|
136
188
|
<div class="hud" aria-live="polite">
|
|
137
|
-
<span class="status-dot" id="status-dot"></span>
|
|
189
|
+
<span class="status-dot" id="status-dot" data-state="loading"></span>
|
|
138
190
|
<span id="status" data-testid="status">Loading ruby.wasm</span>
|
|
191
|
+
<div class="progress" id="progress" aria-hidden="true">
|
|
192
|
+
<div class="progress-bar" id="progress-bar"></div>
|
|
193
|
+
</div>
|
|
139
194
|
</div>
|
|
140
195
|
</main>
|
|
141
196
|
</body>
|
|
@@ -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>
|
|
@@ -54,10 +54,12 @@
|
|
|
54
54
|
position: absolute;
|
|
55
55
|
top: 16px;
|
|
56
56
|
left: 16px;
|
|
57
|
-
display:
|
|
57
|
+
display: grid;
|
|
58
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
58
59
|
align-items: center;
|
|
59
60
|
gap: 8px;
|
|
60
61
|
max-width: calc(100% - 32px);
|
|
62
|
+
min-width: min(360px, calc(100% - 32px));
|
|
61
63
|
padding: 8px 10px;
|
|
62
64
|
border: 1px solid rgba(255, 255, 255, 0.14);
|
|
63
65
|
border-radius: 6px;
|
|
@@ -87,6 +89,44 @@
|
|
|
87
89
|
background: #f15b5b;
|
|
88
90
|
box-shadow: 0 0 14px rgba(241, 91, 91, 0.72);
|
|
89
91
|
}
|
|
92
|
+
|
|
93
|
+
.status-dot[data-state="loading"] {
|
|
94
|
+
animation: status-dot-pulse 1.2s ease-in-out infinite;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@keyframes status-dot-pulse {
|
|
98
|
+
0%,
|
|
99
|
+
100% {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: scale(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
50% {
|
|
105
|
+
opacity: 0.4;
|
|
106
|
+
transform: scale(0.75);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.progress {
|
|
111
|
+
grid-column: 1 / -1;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 4px;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
border-radius: 999px;
|
|
116
|
+
background: rgba(255, 255, 255, 0.16);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.progress-bar {
|
|
120
|
+
width: 4%;
|
|
121
|
+
height: 100%;
|
|
122
|
+
border-radius: inherit;
|
|
123
|
+
background: linear-gradient(90deg, #55ace0, #60d394);
|
|
124
|
+
transition: width 180ms ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.progress[hidden] {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
90
130
|
</style>
|
|
91
131
|
<script type="importmap">
|
|
92
132
|
{
|
|
@@ -101,10 +141,22 @@
|
|
|
101
141
|
<script type="module">
|
|
102
142
|
const status = document.querySelector("#status");
|
|
103
143
|
const statusDot = document.querySelector("#status-dot");
|
|
144
|
+
const progress = document.querySelector("#progress");
|
|
145
|
+
const progressBar = document.querySelector("#progress-bar");
|
|
104
146
|
|
|
105
|
-
globalThis.__threeRbSetStatus = (message, state) => {
|
|
147
|
+
globalThis.__threeRbSetStatus = (message, state, percent) => {
|
|
106
148
|
if (status) status.textContent = message;
|
|
107
149
|
if (statusDot) statusDot.dataset.state = state;
|
|
150
|
+
if (progress && progressBar) {
|
|
151
|
+
if (state === "running" || state === "error") {
|
|
152
|
+
progress.hidden = true;
|
|
153
|
+
} else {
|
|
154
|
+
progress.hidden = false;
|
|
155
|
+
if (Number.isFinite(percent)) {
|
|
156
|
+
progressBar.style.width = `${Math.max(4, Math.min(100, percent))}%`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
108
160
|
};
|
|
109
161
|
|
|
110
162
|
globalThis.__threeRbBootFailed = (message) => {
|
|
@@ -121,12 +173,12 @@
|
|
|
121
173
|
});
|
|
122
174
|
|
|
123
175
|
globalThis.setTimeout(() => {
|
|
124
|
-
if (status &&
|
|
125
|
-
status.textContent = "Still loading
|
|
176
|
+
if (status && statusDot && statusDot.dataset.state === "loading") {
|
|
177
|
+
status.textContent = "Still loading after 15 seconds. Try reloading the page.";
|
|
126
178
|
}
|
|
127
179
|
}, 15000);
|
|
128
180
|
|
|
129
|
-
globalThis.__threeRbSetStatus("Loading ruby.wasm", "loading");
|
|
181
|
+
globalThis.__threeRbSetStatus("Loading ruby.wasm", "loading", 4);
|
|
130
182
|
</script>
|
|
131
183
|
</head>
|
|
132
184
|
<body>
|
|
@@ -135,6 +187,9 @@
|
|
|
135
187
|
<div class="hud" aria-live="polite">
|
|
136
188
|
<span id="status-dot" class="status-dot" data-state="loading"></span>
|
|
137
189
|
<span id="status" data-testid="status">Loading ruby.wasm</span>
|
|
190
|
+
<div class="progress" id="progress" aria-hidden="true">
|
|
191
|
+
<div class="progress-bar" id="progress-bar"></div>
|
|
192
|
+
</div>
|
|
138
193
|
</div>
|
|
139
194
|
</main>
|
|
140
195
|
<script type="module" src="./boot.mjs"></script>
|
|
@@ -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
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# three-rb dango browser example
|
|
2
|
+
|
|
3
|
+
This example renders a Ruby-authored three-color dango scene through ruby.wasm and three.js. It focuses on composing a recognizable 3D object from `SphereGeometry`, `BoxGeometry`, grouped meshes, glossy `MeshPhongMaterial`, lambertian supporting objects, shadows, and `OrbitControls`.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
From the repository root:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install
|
|
11
|
+
ruby -run -e httpd . -p 8000
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Open:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
http://localhost:8000/examples/browser/dango/
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Smoke Test
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pnpm test:browser:dango
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The smoke test serves the repository root, waits for the Ruby scene to reach `Running`, samples the WebGL canvas for nonblank pixels, verifies the three mochi meshes and skewer materialize with the expected geometry and colors, and confirms animation frames are rendered.
|