rayzee 10.0.0 → 11.0.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.
Files changed (173) hide show
  1. package/README.md +252 -44
  2. package/dist/ActiveColor-YvuQq44O.js +13 -0
  3. package/dist/ArchiveImporter-BRQvLggb.js +4300 -0
  4. package/dist/AssetConfig-DSEntE65.js +30 -0
  5. package/dist/BidirectionalIntegrator-9lZQxFVH.js +934 -0
  6. package/dist/BufferLayout-D_IBo2ci.js +150 -0
  7. package/dist/ColorManagement-oeEk7oSu.js +1488 -0
  8. package/dist/EngineEvents-Ci8dVWCP.js +73 -0
  9. package/dist/EngineIssues-CIZnXHsF.js +72 -0
  10. package/dist/FileFormats-sPGJeCRc.js +102 -0
  11. package/dist/Logger-dDDGj9Av.js +97 -0
  12. package/dist/{NeuralRetouch-CYgkQY8Z.js → NeuralRetouch-BCXylThH.js} +8 -6
  13. package/dist/{NeuralSuperRes-PkgDLQcD.js → NeuralSuperRes-sZAeS142.js} +55 -120
  14. package/dist/PathTracer-CQPW06Mm.js +29971 -0
  15. package/dist/PhysicalSky-BvqCw_dy.js +1219 -0
  16. package/dist/RayzeeRenderer-COpwotpU.js +3551 -0
  17. package/dist/SolarLimb-CPaeZVwz.js +721 -0
  18. package/dist/ToneMapGPU-CjU3osDd.js +177 -0
  19. package/dist/ViewTransforms-CYN7bq2w.js +255 -0
  20. package/dist/WorkingMatrix-C6y233hT.js +27 -0
  21. package/dist/ZipReader-gDSWr0I5.js +98 -0
  22. package/dist/addons/archives.es.js +3 -0
  23. package/dist/addons/bidirectional.es.js +2 -0
  24. package/dist/addons/color.es.js +3 -0
  25. package/dist/addons/formats.es.js +2 -0
  26. package/dist/addons/physical-sky.es.js +2 -0
  27. package/dist/addons/storage.es.js +3 -0
  28. package/dist/archiveFormats-BZw7TiDp.js +75 -0
  29. package/dist/identity-DrQsGT2o.js +39 -0
  30. package/dist/openStorage-DwcBRUj7.js +820 -0
  31. package/dist/rayzee-core.es.js +12 -0
  32. package/dist/rayzee.es.js +2551 -44024
  33. package/dist/rayzee.umd.js +528 -487
  34. package/dist/sceneCachePolicy-BSSsKY98.js +443 -0
  35. package/dist/shared-BGBcSxBQ.js +17 -0
  36. package/package.json +23 -2
  37. package/src/Color/ActiveColor.js +34 -0
  38. package/src/Color/BasicColor.js +147 -0
  39. package/src/Color/ColorManagement.js +7 -31
  40. package/src/Color/ViewTransforms.js +5 -1
  41. package/src/EngineDefaults.js +62 -1029
  42. package/src/EngineEvents.js +2 -0
  43. package/src/EngineIssues.js +2 -0
  44. package/src/Headless.js +6 -5
  45. package/src/Passes/AIUpscaler.js +58 -141
  46. package/src/Passes/OIDNDenoiser.js +92 -65
  47. package/src/Passes/OIDNTemporalHistory.js +1 -1
  48. package/src/PathTracerApp.js +620 -4026
  49. package/src/Pipeline/PipelineContext.js +0 -4
  50. package/src/Platform.js +36 -0
  51. package/src/Processor/ArchiveCache.js +1 -1
  52. package/src/Processor/ArchiveImporter.js +1259 -0
  53. package/src/Processor/AssetLoader.js +327 -1763
  54. package/src/Processor/AtmosphereModel.js +1 -2
  55. package/src/Processor/BVHBuilder.js +14 -126
  56. package/src/Processor/BVHLeafFold.js +4 -6
  57. package/src/Processor/BVHRefitter.js +67 -46
  58. package/src/Processor/BufferLayout.js +291 -0
  59. package/src/Processor/EmissiveTriangleBuilder.js +1 -1
  60. package/src/Processor/EnvironmentExactTable.js +187 -0
  61. package/src/Processor/EquirectHDRInfo.js +30 -223
  62. package/src/Processor/FileFormats.js +116 -0
  63. package/src/Processor/GLTFDecoders.js +85 -0
  64. package/src/Processor/GLTFDiffuseTransmission.js +63 -0
  65. package/src/Processor/GeometryExtractor.js +15 -5
  66. package/src/Processor/HostMemory.js +7 -1
  67. package/src/Processor/IESParser.js +47 -35
  68. package/src/Processor/InstanceTable.js +1 -1
  69. package/src/Processor/KernelManager.js +35 -2
  70. package/src/Processor/MaterialPacking.js +10 -8
  71. package/src/Processor/PBRT/PBRTMaterials.js +129 -41
  72. package/src/Processor/PBRT/PBRTParser.js +30 -17
  73. package/src/Processor/PBRT/PBRTSceneBuilder.js +548 -37
  74. package/src/Processor/PBRT/PBRTTextureBake.js +154 -0
  75. package/src/Processor/PBRT/PFM.js +59 -0
  76. package/src/Processor/PackedRayBuffer.js +116 -9
  77. package/src/Processor/ParallelBVHBuilder.js +3 -6
  78. package/src/Processor/PhysicalSky.js +5 -4
  79. package/src/Processor/PlatformImageLoader.js +50 -6
  80. package/src/Processor/QueueManager.js +39 -5
  81. package/src/Processor/ReinsertionOptimizer.js +2 -2
  82. package/src/Processor/SceneProcessor.js +53 -62
  83. package/src/Processor/ShaderBuilder.js +6 -16
  84. package/src/Processor/SimpleSky.js +1 -62
  85. package/src/Processor/SolarLimb.js +3 -0
  86. package/src/Processor/SplitBLAS.js +1 -1
  87. package/src/Processor/StorageTexturePool.js +22 -1
  88. package/src/Processor/TLASBuilder.js +1 -3
  89. package/src/Processor/TextureBuckets.js +237 -0
  90. package/src/Processor/TextureCreator.js +181 -8
  91. package/src/Processor/ToneMapGPU.js +64 -15
  92. package/src/Processor/Workers/BVHRefitWorker.js +5 -2
  93. package/src/Processor/Workers/BVHSubtreeWorker.js +1 -34
  94. package/src/Processor/Workers/BVHWorker.js +5 -18
  95. package/src/Processor/Workers/CDFWorker.js +6 -183
  96. package/src/Processor/Workers/TexturesWorker.js +103 -18
  97. package/src/Processor/archiveFormats.js +7 -0
  98. package/src/Processor/utils.js +2 -1
  99. package/src/RayzeeRenderer.js +3899 -0
  100. package/src/RenderSettings.js +68 -62
  101. package/src/Stages/ASVGF.js +13 -14
  102. package/src/Stages/AutoExposure.js +17 -17
  103. package/src/Stages/BilateralFilter.js +2 -1
  104. package/src/Stages/Compositor.js +8 -23
  105. package/src/Stages/DenoiserSettings.js +182 -0
  106. package/src/Stages/EdgeFilter.js +2 -1
  107. package/src/Stages/MotionVector.js +1 -1
  108. package/src/Stages/NRD.js +11 -5
  109. package/src/Stages/NormalDepth.js +12 -8
  110. package/src/Stages/PathTracer.js +338 -43
  111. package/src/Stages/PathTracerStage.js +69 -66
  112. package/src/Stages/Variance.js +1 -1
  113. package/src/Storage/BLASCache.js +1 -1
  114. package/src/Storage/CDFCache.js +18 -17
  115. package/src/Storage/DownloadCache.js +1 -1
  116. package/src/Storage/SceneGraphCodec.js +46 -3
  117. package/src/Storage/SpillStore.js +1 -1
  118. package/src/Storage/StorageManager.js +45 -9
  119. package/src/Storage/areas.js +4 -0
  120. package/src/TSL/BVHTraversal.js +50 -25
  121. package/src/TSL/Bidirectional.js +204 -0
  122. package/src/TSL/BidirectionalLamps.js +132 -0
  123. package/src/TSL/Clearcoat.js +15 -6
  124. package/src/TSL/Common.js +20 -15
  125. package/src/TSL/ConnectKernel.js +147 -0
  126. package/src/TSL/Debugger.js +1 -1
  127. package/src/TSL/Displacement.js +4 -3
  128. package/src/TSL/EmissiveSampling.js +65 -18
  129. package/src/TSL/Environment.js +77 -106
  130. package/src/TSL/EnvironmentCDF.js +85 -39
  131. package/src/TSL/ExtendKernel.js +8 -3
  132. package/src/TSL/FinalWriteKernel.js +4 -4
  133. package/src/TSL/GenerateKernel.js +18 -4
  134. package/src/TSL/HitFacet.js +35 -5
  135. package/src/TSL/LightBVHSampling.js +40 -9
  136. package/src/TSL/LightGenerateKernel.js +293 -0
  137. package/src/TSL/LightGuide.js +198 -0
  138. package/src/TSL/LightSplatKernel.js +165 -0
  139. package/src/TSL/LightVisibility.js +111 -0
  140. package/src/TSL/LightsCore.js +13 -38
  141. package/src/TSL/LightsDirect.js +28 -29
  142. package/src/TSL/LightsIndirect.js +3 -1
  143. package/src/TSL/LightsSampling.js +239 -51
  144. package/src/TSL/MaterialEvaluation.js +113 -31
  145. package/src/TSL/MaterialProperties.js +44 -17
  146. package/src/TSL/MaterialTransmission.js +52 -47
  147. package/src/TSL/MergeKernel.js +218 -0
  148. package/src/TSL/PathTracerCore.js +65 -29
  149. package/src/TSL/Random.js +5 -1
  150. package/src/TSL/SceneResources.js +51 -0
  151. package/src/TSL/ShadeKernel.js +964 -101
  152. package/src/TSL/Struct.js +10 -0
  153. package/src/TSL/Sun.js +1 -1
  154. package/src/TSL/TextureSampling.js +66 -61
  155. package/src/addons/archives.js +14 -0
  156. package/src/addons/bidirectional.js +13 -0
  157. package/src/addons/color.js +32 -0
  158. package/src/addons/formats.js +16 -0
  159. package/src/addons/physicalSky.js +14 -0
  160. package/src/addons/storage.js +19 -0
  161. package/src/core.js +31 -0
  162. package/src/index.js +13 -23
  163. package/src/integrators/BidirectionalIntegrator.js +833 -0
  164. package/src/managers/AnimationManager.js +88 -6
  165. package/src/managers/CameraManager.js +103 -46
  166. package/src/managers/DenoisingManager.js +14 -10
  167. package/src/managers/EnvironmentManager.js +125 -103
  168. package/src/managers/GoboManager.js +9 -0
  169. package/src/managers/MaterialDataManager.js +48 -37
  170. package/src/managers/UniformManager.js +32 -10
  171. package/dist/ToneMapGPU-B6XIe3DU.js +0 -544
  172. package/dist/rolldown-runtime-CAFD8bLK.js +0 -11
  173. package/src/Processor/TreeletOptimizer.js +0 -574
@@ -0,0 +1,443 @@
1
+ import { t as e } from "./EngineEvents-Ci8dVWCP.js";
2
+ import { s as t } from "./BufferLayout-D_IBo2ci.js";
3
+ import { n, r } from "./shared-BGBcSxBQ.js";
4
+ import { n as i } from "./AssetConfig-DSEntE65.js";
5
+ import "three";
6
+ //#region src/Processor/utils.js
7
+ var a = null;
8
+ function o(e) {
9
+ a = e;
10
+ }
11
+ var s = () => a?.({ type: e.LOADING_RESET }), c = (t) => {
12
+ a?.({
13
+ type: e.LOADING_UPDATE,
14
+ ...t
15
+ });
16
+ }, l = (t) => {
17
+ a?.({
18
+ type: e.STATS_UPDATE,
19
+ ...t
20
+ });
21
+ };
22
+ function u(e) {
23
+ return e.frameCount || 0;
24
+ }
25
+ function d(e) {
26
+ if (Array.isArray(e)) e.forEach((e) => {
27
+ e.userData && e.userData.isFallback || (f(e), e.dispose());
28
+ });
29
+ else {
30
+ if (e.userData && e.userData.isFallback) return;
31
+ f(e), e.dispose();
32
+ }
33
+ }
34
+ function f(e) {
35
+ e && [
36
+ "alphaMap",
37
+ "aoMap",
38
+ "bumpMap",
39
+ "clearcoatMap",
40
+ "clearcoatNormalMap",
41
+ "clearcoatRoughnessMap",
42
+ "displacementMap",
43
+ "emissiveMap",
44
+ "envMap",
45
+ "gradientMap",
46
+ "lightMap",
47
+ "map",
48
+ "metalnessMap",
49
+ "normalMap",
50
+ "roughnessMap",
51
+ "specularMap",
52
+ "sheenColorMap",
53
+ "sheenRoughnessMap",
54
+ "specularIntensityMap",
55
+ "specularColorMap",
56
+ "thicknessMap",
57
+ "transmissionMap",
58
+ "diffuseTransmissionMap",
59
+ "diffuseTransmissionColorMap"
60
+ ].forEach((t) => {
61
+ e[t] && (e[t].dispose(), e[t] = null);
62
+ });
63
+ }
64
+ function p({ material: e, geometry: t, children: n }) {
65
+ if (e && d(e), t && t.dispose(), n.length > 0) for (let e of n) p(e);
66
+ }
67
+ function m(e) {
68
+ if (!e) return;
69
+ e._canvasTarget && e._onCanvasTargetResize && e._canvasTarget.removeEventListener("resize", e._onCanvasTargetResize);
70
+ let t = e.dispose();
71
+ return e._canvasTarget = null, t;
72
+ }
73
+ function h(e, t = []) {
74
+ if (e && !(t.includes(e.name) || e.isScene)) {
75
+ if (e.isMaterial) {
76
+ d(e);
77
+ return;
78
+ }
79
+ for (; e.children.length > 0;) for (let t of e.children) h(t);
80
+ p(e), e.removeFromParent(), e.clear();
81
+ }
82
+ }
83
+ function g(e) {
84
+ e?.traverse((e) => {
85
+ e.geometry?.userData?.__rayzeeOwned && e.geometry.dispose();
86
+ });
87
+ }
88
+ function _(e, t) {
89
+ return t;
90
+ }
91
+ function v(e, t = !1) {
92
+ return t ? 1 : 1 / (e + 1);
93
+ }
94
+ function y() {
95
+ let e = 0, t = 0, n = 0, r = 0;
96
+ return {
97
+ start() {
98
+ e = performance.now();
99
+ },
100
+ end() {
101
+ t = performance.now();
102
+ let i = t - e;
103
+ return r += i, n++, i;
104
+ },
105
+ getAverageFrameTime() {
106
+ return n > 0 ? r / n : 0;
107
+ },
108
+ getFPS() {
109
+ let e = this.getAverageFrameTime();
110
+ return e > 0 ? 1e3 / e : 0;
111
+ },
112
+ reset() {
113
+ n = 0, r = 0;
114
+ }
115
+ };
116
+ }
117
+ //#endregion
118
+ //#region src/Processor/ChunkedRecords.js
119
+ var b = 64 * 1024 * 1024, x = typeof SharedArrayBuffer < "u", S = null;
120
+ function C(e) {
121
+ S = e;
122
+ }
123
+ function w(e, t, n) {
124
+ let r = n ? new e(new SharedArrayBuffer(t * e.BYTES_PER_ELEMENT)) : new e(t);
125
+ return S && r.byteLength > 0 && S(r.byteLength, n), r;
126
+ }
127
+ var T = class e {
128
+ constructor(e, t, n, r = b, i = !1) {
129
+ let a = t * n.BYTES_PER_ELEMENT, o = Math.max(1, Math.floor(r / a));
130
+ this.recordCount = e, this.lanesPerRecord = t, this.LaneType = n, this.recordsPerChunk = e <= o ? Math.max(e, 1) : o, this.shared = i, this.chunks = [];
131
+ let s = e;
132
+ for (; s > 0;) {
133
+ let e = Math.min(s, this.recordsPerChunk);
134
+ this.chunks.push(w(n, e * t, i)), s -= e;
135
+ }
136
+ this.chunks.length === 0 && this.chunks.push(w(n, 0, i));
137
+ }
138
+ static adopt(t, n, r, i) {
139
+ let a = Object.create(e.prototype);
140
+ return a.recordCount = n, a.lanesPerRecord = r, a.LaneType = t[0]?.constructor ?? null, a.recordsPerChunk = i, a.chunks = t, a.shared = typeof SharedArrayBuffer < "u" && t[0]?.buffer instanceof SharedArrayBuffer, a;
141
+ }
142
+ static lazy(t, n, r, i = b, a = !1) {
143
+ let o = Math.max(1, Math.floor(i / (n * r.BYTES_PER_ELEMENT))), s = Object.create(e.prototype);
144
+ return s.recordCount = t, s.lanesPerRecord = n, s.LaneType = r, s.recordsPerChunk = t <= o ? Math.max(t, 1) : o, s.shared = a, s.chunks = Array(Math.max(1, Math.ceil(t / s.recordsPerChunk))), s._views = [], s;
145
+ }
146
+ _materialize(e) {
147
+ if (this._owner) return this._owner._materialize(e), this.chunks[e];
148
+ let t = e * this.recordsPerChunk, n = Math.min(this.recordsPerChunk, this.recordCount - t) * this.lanesPerRecord, r = this.chunks[e] = w(this.LaneType, n, this.shared);
149
+ for (let t of this._liveViews()) t.chunks[e] = new t.LaneType(r.buffer, r.byteOffset, r.byteLength / t.LaneType.BYTES_PER_ELEMENT);
150
+ return r;
151
+ }
152
+ materializeAll() {
153
+ for (let e = 0; e < this.chunks.length; e++) !this.chunks[e] && !this._spilled?.has(e) && this._materialize(e);
154
+ return this;
155
+ }
156
+ get chunkCount() {
157
+ return this.chunks.length;
158
+ }
159
+ get single() {
160
+ return this.chunks.length === 1 ? this.chunks[0] : null;
161
+ }
162
+ get byteLength() {
163
+ let e = 0;
164
+ for (let t of this.chunks) t && (e += t.byteLength);
165
+ return e;
166
+ }
167
+ chunkFor(e) {
168
+ let t = e / this.recordsPerChunk | 0, n = this.chunks[t];
169
+ if (n) return n;
170
+ if (this._spilled?.has(t)) throw Error(`ChunkedRecords: chunk ${t} is on disk — await ensureResident() before touching record ${e}`);
171
+ return this._materialize(t);
172
+ }
173
+ async spill(e, { keep: t = () => !1 } = {}) {
174
+ if (this._owner) throw Error("ChunkedRecords: spill the storage, not a view of it");
175
+ this._store = e, this._spilled ??= /* @__PURE__ */ new Set();
176
+ let n = 0;
177
+ for (let r = 0; r < this.chunks.length; r++) {
178
+ let i = this.chunks[r];
179
+ if (!(!i || t(r))) {
180
+ await e.write(r, i), this.chunks[r] = null;
181
+ for (let e of this._liveViews()) e.chunks[r] = null;
182
+ this._spilled.add(r), n += i.byteLength;
183
+ }
184
+ }
185
+ return n;
186
+ }
187
+ async spillChunk(e, t) {
188
+ let n = this.chunks[e];
189
+ if (!n) return 0;
190
+ this._store = t, this._spilled ??= /* @__PURE__ */ new Set(), await t.write(e, n), this.chunks[e] = null;
191
+ for (let t of this._liveViews()) t.chunks[e] = null;
192
+ return this._spilled.add(e), n.byteLength;
193
+ }
194
+ async ensureResident(e = 0, t = this.recordCount) {
195
+ if (!this._spilled?.size || t <= 0) return;
196
+ let n = e / this.recordsPerChunk | 0, r = (e + t - 1) / this.recordsPerChunk | 0;
197
+ for (let e = n; e <= r; e++) {
198
+ if (!this._spilled.has(e)) continue;
199
+ let t = Math.min(this.recordsPerChunk, this.recordCount - e * this.recordsPerChunk) * this.lanesPerRecord, n = await this._store.read(e, t * this.LaneType.BYTES_PER_ELEMENT), r = w(this.LaneType, t, this.shared);
200
+ new Uint8Array(r.buffer, r.byteOffset, r.byteLength).set(new Uint8Array(n)), this.chunks[e] = r;
201
+ for (let t of this._liveViews()) t.chunks[e] = new t.LaneType(r.buffer, r.byteOffset, r.byteLength / t.LaneType.BYTES_PER_ELEMENT);
202
+ this._spilled.delete(e);
203
+ }
204
+ }
205
+ _liveViews() {
206
+ return this._weakViews &&= this._weakViews.filter((e) => e.deref()), [...this._views ?? [], ...(this._weakViews ?? []).map((e) => e.deref())];
207
+ }
208
+ isResident(e = 0, t = this.recordCount) {
209
+ if (!this._spilled?.size || t <= 0) return !0;
210
+ let n = e / this.recordsPerChunk | 0, r = (e + t - 1) / this.recordsPerChunk | 0;
211
+ for (let e = n; e <= r; e++) if (this._spilled.has(e)) return !1;
212
+ return !0;
213
+ }
214
+ get spilledChunks() {
215
+ return this._spilled?.size ?? 0;
216
+ }
217
+ baseOf(e) {
218
+ return e % this.recordsPerChunk * this.lanesPerRecord;
219
+ }
220
+ isContiguous(e, t) {
221
+ return t <= 0 ? !0 : (e / this.recordsPerChunk | 0) == ((e + t - 1) / this.recordsPerChunk | 0);
222
+ }
223
+ slice(e, t) {
224
+ let n = this.baseOf(e), r = t * this.lanesPerRecord;
225
+ if (this.isContiguous(e, t)) return this.chunkFor(e).subarray(n, n + r);
226
+ let i = new this.LaneType(r);
227
+ return this.readRecords(e, t, i), i;
228
+ }
229
+ readRecords(e, t, n) {
230
+ let r = 0;
231
+ for (; r < t;) {
232
+ let i = e + r, a = this.chunkFor(i), o = this.baseOf(i), s = this.recordsPerChunk - i % this.recordsPerChunk, c = Math.min(s, t - r);
233
+ n.set(a.subarray(o, o + c * this.lanesPerRecord), r * this.lanesPerRecord), r += c;
234
+ }
235
+ return n;
236
+ }
237
+ setRecords(e, t) {
238
+ let n = t.length / this.lanesPerRecord, r = 0;
239
+ for (; r < n;) {
240
+ let i = e + r, a = this.chunkFor(i), o = this.baseOf(i), s = this.recordsPerChunk - i % this.recordsPerChunk, c = Math.min(s, n - r);
241
+ a.set(t.subarray(r * this.lanesPerRecord, (r + c) * this.lanesPerRecord), o), r += c;
242
+ }
243
+ }
244
+ copyOf(e, t) {
245
+ return this.readRecords(e, t, new this.LaneType(t * this.lanesPerRecord));
246
+ }
247
+ trimTo(t) {
248
+ let n = Math.max(1, Math.ceil(t / this.recordsPerChunk)), r = this.chunks.slice(0, n), i = (t - (n - 1) * this.recordsPerChunk) * this.lanesPerRecord, a = r[n - 1];
249
+ return a.length > i && (r[n - 1] = a.subarray(0, Math.max(0, i))), e.adopt(r, t, this.lanesPerRecord, this.recordsPerChunk);
250
+ }
251
+ grow(e) {
252
+ if (e <= this.recordCount) return;
253
+ let t = this.chunks.length - 1, n = (e, t) => Math.min(this.recordsPerChunk, t - e * this.recordsPerChunk) * this.lanesPerRecord, r = this.chunks[t];
254
+ this.recordCount = e;
255
+ for (let t of this._liveViews()) t.recordCount = e;
256
+ if (this.chunks.length * this.recordsPerChunk < e) {
257
+ this.chunks.length = Math.ceil(e / this.recordsPerChunk);
258
+ for (let e of this._liveViews()) e.chunks.length = this.chunks.length;
259
+ }
260
+ if (r && r.length < n(t, e)) {
261
+ let i = w(this.LaneType, n(t, e), this.shared);
262
+ i.set(r), this.chunks[t] = i;
263
+ for (let e of this._liveViews()) e.chunks[t] = new e.LaneType(i.buffer, i.byteOffset, i.byteLength / e.LaneType.BYTES_PER_ELEMENT);
264
+ } else if (!r && this._spilled?.has(t)) throw Error(`ChunkedRecords: cannot grow past chunk ${t}, which is on disk`);
265
+ }
266
+ release(e, t) {
267
+ let n = this.recordsPerChunk, r = Math.ceil(e / n), i = Math.floor((e + t) / n), a = 0;
268
+ for (let e = r; e < i; e++) {
269
+ let t = this.chunks[e];
270
+ if (t) {
271
+ a += t.byteLength, this.chunks[e] = void 0;
272
+ for (let t of this._liveViews()) t.chunks[e] = void 0;
273
+ }
274
+ }
275
+ return a;
276
+ }
277
+ trimInPlace(e) {
278
+ let t = Math.max(1, Math.ceil(e / this.recordsPerChunk)), n = Math.max(0, (e - (t - 1) * this.recordsPerChunk) * this.lanesPerRecord), r = [this, ...this._liveViews()];
279
+ for (let i of r) {
280
+ i.chunks.length = t;
281
+ let r = i.chunks[t - 1];
282
+ r && r.length > n && (i.chunks[t - 1] = r.subarray(0, n)), i.recordCount = e;
283
+ }
284
+ if (this._spilled) for (let e of this._spilled) e >= t && this._spilled.delete(e);
285
+ return this;
286
+ }
287
+ viewAs(t) {
288
+ let n = (e) => new t(e.buffer, e.byteOffset, e.byteLength / t.BYTES_PER_ELEMENT), r = e.adopt(this.chunks.map((e) => e ? n(e) : void 0), this.recordCount, this.lanesPerRecord, this.recordsPerChunk);
289
+ return r.LaneType = t, r._owner = this, this._views ? this._views.push(r) : (this._weakViews ??= []).push(new WeakRef(r)), r._spilled = this._spilled ??= /* @__PURE__ */ new Set(), r;
290
+ }
291
+ }, E = 5;
292
+ function D(e, t) {
293
+ e && t && (e.userData.__rayzeeSource = t);
294
+ }
295
+ function O(e) {
296
+ let t = e?.userData?.__rayzeeSource;
297
+ if (!t) return null;
298
+ let { width: n = 0, height: r = 0 } = e.image ?? {};
299
+ return `cdf:${E}:${t}|${n}x${r}|${e.userData.__rayzeeColorSpace ?? "native"}`;
300
+ }
301
+ var k = () => n(i().cacheNamespace)?.area(r.CDF) ?? null, A = [
302
+ "exactConditional",
303
+ "exactMarginal",
304
+ "exactRowGuide",
305
+ "exactMarginalGuide"
306
+ ], j = A.map((e) => `${e}.f32`);
307
+ async function M(e) {
308
+ let t = O(e), n = t ? await k()?.open(t) : null;
309
+ if (!n) return null;
310
+ try {
311
+ let e = await Promise.all(j.map((e) => n.file(e)));
312
+ if (e.some((e) => !e)) return null;
313
+ let t = await Promise.all(e.map(async (e) => new Float32Array(await e.arrayBuffer()))), { totalSum: r, width: i, height: a, exactWidth: o, exactHeight: s, radianceIntegral: c } = n.extra;
314
+ return {
315
+ ...Object.fromEntries(A.map((e, n) => [e, t[n]])),
316
+ totalSum: r,
317
+ width: i,
318
+ height: a,
319
+ exactWidth: o,
320
+ exactHeight: s,
321
+ radianceIntegral: c
322
+ };
323
+ } finally {
324
+ n.release();
325
+ }
326
+ }
327
+ async function N(e, t) {
328
+ let { totalSum: n, width: r, height: i, exactWidth: a, exactHeight: o, radianceIntegral: s } = t, c = A.map((e) => t[e]), l = O(e), u = l ? k() : null;
329
+ if (!u || c.some((e) => !e)) return !1;
330
+ let d = await u.create(l, {
331
+ label: e.name || "environment",
332
+ expectedBytes: c.reduce((e, t) => e + t.byteLength, 0)
333
+ });
334
+ if (!d) return !1;
335
+ try {
336
+ for (let e = 0; e < j.length; e++) await d.write(j[e], c[e]);
337
+ return await d.commit({
338
+ totalSum: n,
339
+ width: r,
340
+ height: i,
341
+ exactWidth: a,
342
+ exactHeight: o,
343
+ radianceIntegral: s
344
+ }), !0;
345
+ } catch {
346
+ return await d.abort(), !1;
347
+ }
348
+ }
349
+ //#endregion
350
+ //#region src/Processor/HostMemory.js
351
+ var P = t.FLOATS_PER_TRIANGLE * 4, F = 64, I = .9, L = 64, R = 4, z = 1536 * 1024 * 1024, B = 7040 * 1024 * 1024, V = 9216 * 1024 * 1024, H = 6e7, U = 8e6;
352
+ function W(e) {
353
+ if (e > 0) return {
354
+ gb: e,
355
+ assumed: !1
356
+ };
357
+ let t = typeof navigator < "u" ? navigator.deviceMemory : void 0;
358
+ return t > 0 ? {
359
+ gb: t,
360
+ assumed: !1
361
+ } : {
362
+ gb: 4,
363
+ assumed: !0
364
+ };
365
+ }
366
+ var G = 1.15, K = 12 * 1024 * 1024 * 1024;
367
+ function q({ triangles: e, placements: t, geometryBytes: n = 0 }) {
368
+ let r = {
369
+ triangles: e * P,
370
+ bvh: Math.ceil(e * I) * F,
371
+ geometry: n,
372
+ placements: t * L,
373
+ orderMaps: e * R
374
+ };
375
+ return r.total = r.triangles + r.bvh + r.geometry + r.placements + r.orderMaps, r;
376
+ }
377
+ function J(e, { chunkBytes: t = b, shared: n = !1, allocate: r = null } = {}) {
378
+ let i = Math.min(e, K), a = r ?? (n ? (e) => new SharedArrayBuffer(e) : (e) => new ArrayBuffer(e)), o = [], s = 0;
379
+ try {
380
+ for (; s < i;) {
381
+ let e = Math.min(t, i - s);
382
+ o.push(a(e)), s += e;
383
+ }
384
+ } catch {}
385
+ for (let e = o.length - 1; e >= 0; e--) o[e] = null;
386
+ return o.length = 0, {
387
+ placed: s,
388
+ want: i,
389
+ exhausted: s < i,
390
+ capped: e > i
391
+ };
392
+ }
393
+ var Y = class {
394
+ constructor() {
395
+ this.reset();
396
+ }
397
+ reset() {
398
+ this.phase = "idle", this.events = [], this.samples = [], this.allocatedBytes = 0, this.peakLiveBytes = 0, this.byPhase = Object.create(null);
399
+ }
400
+ mark(e) {
401
+ return this.phase = e, this.byPhase[e] ??= {
402
+ allocated: 0,
403
+ chunks: 0
404
+ }, this;
405
+ }
406
+ alloc(e, t = "chunk") {
407
+ if (!(e > 0)) return;
408
+ let n = this.byPhase[this.phase] ??= {
409
+ allocated: 0,
410
+ chunks: 0
411
+ };
412
+ n.allocated += e, n.chunks++, this.allocatedBytes += e, this.events.push({
413
+ phase: this.phase,
414
+ bytes: e,
415
+ what: t,
416
+ at: performance.now()
417
+ });
418
+ }
419
+ sample(e, t) {
420
+ let n = 0;
421
+ for (let e in t) n += t[e] || 0;
422
+ return n > this.peakLiveBytes && (this.peakLiveBytes = n), this.samples.push({
423
+ label: e,
424
+ phase: this.phase,
425
+ total: n,
426
+ parts: t,
427
+ at: performance.now()
428
+ }), n;
429
+ }
430
+ get report() {
431
+ return {
432
+ allocatedBytes: this.allocatedBytes,
433
+ peakLiveBytes: this.peakLiveBytes,
434
+ byPhase: { ...this.byPhase },
435
+ samples: this.samples.slice()
436
+ };
437
+ }
438
+ }, X = "11.0.0", Z = 1e4, Q = 15e5;
439
+ function $(e, t, n = Z) {
440
+ return e >= n && t / Q < e / 3;
441
+ }
442
+ //#endregion
443
+ export { c as A, g as C, s as D, u as E, o as O, y as S, m as T, T as _, Y as a, C as b, B as c, W as d, q as f, D as g, N as h, V as i, l as j, _ as k, U as l, M as m, $ as n, z as o, J as p, X as r, G as s, Z as t, H as u, b as v, h as w, v as x, x as y };
@@ -0,0 +1,17 @@
1
+ //#region src/Storage/areas.js
2
+ var e = Object.freeze({
3
+ CACHE: "cache",
4
+ USER: "user",
5
+ SCRATCH: "scratch"
6
+ }), t = Object.freeze({
7
+ DOWNLOADS: "downloads",
8
+ ARCHIVES: "archives",
9
+ SCENES: "scenes",
10
+ CDF: "cdf",
11
+ SPILL: "spill"
12
+ }), n = /* @__PURE__ */ new Map();
13
+ function r(e) {
14
+ return n.get(e)?.storage ?? null;
15
+ }
16
+ //#endregion
17
+ export { e as i, r as n, t as r, n as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -10,6 +10,27 @@
10
10
  "import": "./dist/rayzee.es.js",
11
11
  "require": "./dist/rayzee.umd.js"
12
12
  },
13
+ "./core": {
14
+ "import": "./dist/rayzee-core.es.js"
15
+ },
16
+ "./addons/physical-sky": {
17
+ "import": "./dist/addons/physical-sky.es.js"
18
+ },
19
+ "./addons/archives": {
20
+ "import": "./dist/addons/archives.es.js"
21
+ },
22
+ "./addons/bidirectional": {
23
+ "import": "./dist/addons/bidirectional.es.js"
24
+ },
25
+ "./addons/color": {
26
+ "import": "./dist/addons/color.es.js"
27
+ },
28
+ "./addons/storage": {
29
+ "import": "./dist/addons/storage.es.js"
30
+ },
31
+ "./addons/formats": {
32
+ "import": "./dist/addons/formats.es.js"
33
+ },
13
34
  "./node": "./src/node/index.js"
14
35
  },
15
36
  "files": [
@@ -32,7 +53,7 @@
32
53
  "author": "Atul Mourya",
33
54
  "license": "MIT",
34
55
  "scripts": {
35
- "build": "vite build",
56
+ "build": "vite build && RAYZEE_FORMAT=umd vite build",
36
57
  "prepublishOnly": "npm run build"
37
58
  },
38
59
  "peerDependencies": {
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The colour management the engine reads — `BasicColor` in the renderer core, the OCIO `ColorManagement` once a host
3
+ * installs it (rayzee/addons/color). A config, a working space and a set of view transforms are process-wide — there
4
+ * is one OCIO runtime and one set of baked tables — so code far from the app (texture processing, the environment)
5
+ * asks for the active instance rather than having one threaded through six constructors.
6
+ */
7
+
8
+ /** What the engine renders in when no config has been adopted. */
9
+ export const DEFAULT_WORKING_SPACE = 'Linear Rec.709 (sRGB)';
10
+
11
+ let active = null;
12
+
13
+ /** The colour management the engine is currently using, or null. */
14
+ export function getActiveColorManagement() {
15
+
16
+ return active;
17
+
18
+ }
19
+
20
+ /** Make an instance the one the engine reads. Normally the app's own, set on construction. */
21
+ export function setActiveColorManagement( cm ) {
22
+
23
+ active = cm;
24
+ // Whatever the previous instance published is not this one's working space.
25
+ cm?._publishWorkingMatrix?.();
26
+
27
+ }
28
+
29
+ /** Becomes the active one only when there is none, without publishing (a constructor's claim). */
30
+ export function claimActiveColorManagement( cm ) {
31
+
32
+ if ( active === null ) active = cm;
33
+
34
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The renderer core's colour management: linear Rec.709, three.js's built-in view transforms, nothing converted — what
3
+ * the OCIO `ColorManagement` (rayzee/addons/color) does with no config loaded. `renderer.setColorManagement(
4
+ * ColorManagement )` replaces it.
5
+ */
6
+
7
+ import { SRGBColorSpace } from 'three';
8
+ import { DEFAULT_WORKING_SPACE, getActiveColorManagement, setActiveColorManagement } from './ActiveColor.js';
9
+ import { registerWithRenderer, onRegistryChange, getViewTransform, listViewTransforms, getRegistryVersion } from './ViewTransforms.js';
10
+ import { setWorkingMatrix } from './WorkingMatrix.js';
11
+ import { ISSUE_CODES } from '../EngineIssues.js';
12
+
13
+ export class BasicColor {
14
+
15
+ constructor( { issues = null } = {} ) {
16
+
17
+ this._issues = issues;
18
+ this._renderer = null;
19
+ this._offRegistry = onRegistryChange( () => {
20
+
21
+ if ( this._renderer ) registerWithRenderer( this._renderer );
22
+
23
+ } );
24
+
25
+ }
26
+
27
+ get hasConfig() {
28
+
29
+ return false;
30
+
31
+ }
32
+
33
+ get workingSpace() {
34
+
35
+ return DEFAULT_WORKING_SPACE;
36
+
37
+ }
38
+
39
+ get workingSpaceAdopted() {
40
+
41
+ return false;
42
+
43
+ }
44
+
45
+ /** Part of a converted texture's cache key: nothing is converted here. */
46
+ get inputKey() {
47
+
48
+ return '-';
49
+
50
+ }
51
+
52
+ attachRenderer( renderer ) {
53
+
54
+ this._renderer = renderer;
55
+ const n = registerWithRenderer( renderer );
56
+ renderer.outputColorSpace = SRGBColorSpace;
57
+ return n;
58
+
59
+ }
60
+
61
+ /** Every registered view transform, for a host menu. */
62
+ listViews() {
63
+
64
+ return listViewTransforms();
65
+
66
+ }
67
+
68
+ /** The active OCIO view: none without a config. */
69
+ get activeView() {
70
+
71
+ return null;
72
+
73
+ }
74
+
75
+ /**
76
+ * Make a registered transform the one the renderer uses — three.js's own seven, or one a host added. A view that
77
+ * returns display-encoded colour (an OCIO view) needs the OCIO pipeline, which sets the output colour space for it.
78
+ */
79
+ setActiveView( id ) {
80
+
81
+ const t = getViewTransform( id );
82
+ if ( ! t ) throw new Error( `no view transform with id ${id}` );
83
+ if ( t.outputEncoded ) throw new Error( `"${t.name}" returns display-encoded colour: it needs rayzee/addons/color` );
84
+ if ( this._renderer ) this._renderer.toneMapping = id;
85
+ return t;
86
+
87
+ }
88
+
89
+ _publishWorkingMatrix() {
90
+
91
+ setWorkingMatrix( null, DEFAULT_WORKING_SPACE );
92
+
93
+ }
94
+
95
+ /** Colour configs, views and working spaces need the OCIO pipeline. */
96
+ loadConfig() {
97
+
98
+ const message = 'colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color';
99
+ this._issues?.record( ISSUE_CODES.CAPABILITY_MISSING, message, { capability: 'color' } );
100
+ return Promise.reject( new Error( message ) );
101
+
102
+ }
103
+
104
+ unloadConfig() {}
105
+
106
+ setWorkingSpace() {}
107
+
108
+ /** No export space without a config: the working space as it is. */
109
+ exportPixels( rgba ) {
110
+
111
+ return { rgba, colorSpace: DEFAULT_WORKING_SPACE };
112
+
113
+ }
114
+
115
+ status() {
116
+
117
+ const active = this._renderer ? getViewTransform( this._renderer.toneMapping ) : null;
118
+ return {
119
+ config: null,
120
+ workingSpace: DEFAULT_WORKING_SPACE,
121
+ workingSpaceAdopted: false,
122
+ activeTransform: active ? { id: active.id, name: active.name, source: active.source } : null,
123
+ activeView: null,
124
+ context: null,
125
+ exportSpace: null,
126
+ views: listViewTransforms(),
127
+ registryVersion: getRegistryVersion(),
128
+ bakeError: active?.error ?? null,
129
+ };
130
+
131
+ }
132
+
133
+ dispose() {
134
+
135
+ this._offRegistry?.();
136
+ this._renderer = null;
137
+ this._issues = null;
138
+ if ( getActiveColorManagement() === this ) {
139
+
140
+ setWorkingMatrix( null );
141
+ setActiveColorManagement( null );
142
+
143
+ }
144
+
145
+ }
146
+
147
+ }