From 446ccb29cd35edae4abb616ae987a63df6f729b0 Mon Sep 17 00:00:00 2001 From: Hiwen Date: Sat, 28 Jun 2025 13:44:14 +0800 Subject: [PATCH 1/6] Add wrapR property to Sampler and Texture3D, to support the newly added third dimension wrap. --- packages/engine/Source/Renderer/Sampler.js | 12 ++++++++++++ packages/engine/Source/Renderer/Texture3D.js | 5 +++++ packages/engine/Specs/Renderer/SamplerSpec.js | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/packages/engine/Source/Renderer/Sampler.js b/packages/engine/Source/Renderer/Sampler.js index e5d2ab9295a4..212215b78ce7 100644 --- a/packages/engine/Source/Renderer/Sampler.js +++ b/packages/engine/Source/Renderer/Sampler.js @@ -13,6 +13,7 @@ function Sampler(options) { options = options ?? Frozen.EMPTY_OBJECT; const { + wrapR = TextureWrap.CLAMP_TO_EDGE, wrapS = TextureWrap.CLAMP_TO_EDGE, wrapT = TextureWrap.CLAMP_TO_EDGE, minificationFilter = TextureMinificationFilter.LINEAR, @@ -21,6 +22,10 @@ function Sampler(options) { } = options; //>>includeStart('debug', pragmas.debug); + if (!TextureWrap.validate(wrapR)) { + throw new DeveloperError("Invalid sampler.wrapR."); + } + if (!TextureWrap.validate(wrapS)) { throw new DeveloperError("Invalid sampler.wrapS."); } @@ -44,6 +49,7 @@ function Sampler(options) { ); //>>includeEnd('debug'); + this._wrapR = wrapR; this._wrapS = wrapS; this._wrapT = wrapT; this._minificationFilter = minificationFilter; @@ -52,6 +58,11 @@ function Sampler(options) { } Object.defineProperties(Sampler.prototype, { + wrapR: { + get: function () { + return this._wrapR; + }, + }, wrapS: { get: function () { return this._wrapS; @@ -84,6 +95,7 @@ Sampler.equals = function (left, right) { left === right || (defined(left) && defined(right) && + left._wrapR === right._wrapR && left._wrapS === right._wrapS && left._wrapT === right._wrapT && left._minificationFilter === right._minificationFilter && diff --git a/packages/engine/Source/Renderer/Texture3D.js b/packages/engine/Source/Renderer/Texture3D.js index c44c2cd434a9..c77c72b43b59 100644 --- a/packages/engine/Source/Renderer/Texture3D.js +++ b/packages/engine/Source/Renderer/Texture3D.js @@ -18,6 +18,10 @@ import TextureMinificationFilter from "./TextureMinificationFilter.js"; * * @property {Context} context * @property {object} [source] The source for texel values to be loaded into the texture3D. + * @param {number} [source.width] The width of the 3D Texture. + * @param {number} [source.height] The width of the 3D Texture. + * @param {number} [source.depth] The width of the 3D Texture. + * @param {number} [source.arrayBufferView] The TypedArray data of the 3D Texture. The type needs to match the pixelDatatype. * @property {PixelFormat} [pixelFormat=PixelFormat.RGBA] The format of each pixel, i.e., the number of components it has and what they represent. * @property {PixelDatatype} [pixelDatatype=PixelDatatype.UNSIGNED_BYTE] The data type of each pixel. * @property {boolean} [flipY=true] If true, the source values will be read as if the y-axis is inverted (y=0 at the top). @@ -503,6 +507,7 @@ function setupSampler(texture3D, sampler) { gl.bindTexture(target, texture3D._texture); gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minificationFilter); gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magnificationFilter); + gl.texParameteri(target, gl.TEXTURE_WRAP_R, sampler.wrapR); gl.texParameteri(target, gl.TEXTURE_WRAP_S, sampler.wrapS); gl.texParameteri(target, gl.TEXTURE_WRAP_T, sampler.wrapT); if (defined(texture3D._textureFilterAnisotropic)) { diff --git a/packages/engine/Specs/Renderer/SamplerSpec.js b/packages/engine/Specs/Renderer/SamplerSpec.js index 7ae117336e27..71cfae9671f2 100644 --- a/packages/engine/Specs/Renderer/SamplerSpec.js +++ b/packages/engine/Specs/Renderer/SamplerSpec.js @@ -21,6 +21,7 @@ describe( it("has expected default values", function () { const sampler = new Sampler(); + expect(sampler.wrapR).toEqual(TextureWrap.CLAMP_TO_EDGE); expect(sampler.wrapS).toEqual(TextureWrap.CLAMP_TO_EDGE); expect(sampler.wrapT).toEqual(TextureWrap.CLAMP_TO_EDGE); expect(sampler.minificationFilter).toEqual( @@ -32,6 +33,14 @@ describe( expect(sampler.maximumAnisotropy).toEqual(1.0); }); + it("throws when creating a sampler with invalid wrapR", function () { + expect(function () { + return new Sampler({ + wrapR: "invalid wrap", + }); + }).toThrowDeveloperError(); + }); + it("throws when creating a sampler with invalid wrapS", function () { expect(function () { return new Sampler({ From 909de55ed8429329ae1bb779d271bee4f85e141f Mon Sep 17 00:00:00 2001 From: Hiwen Date: Sat, 28 Jun 2025 13:56:20 +0800 Subject: [PATCH 2/6] update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index ee84bbec3acd..cd3cbd37804f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ # Change Log +- Add wrapR property to Sampler and Texture3D, to support the newly added third dimension wrap.[#12701](https://github.com/CesiumGS/cesium/pull/12701) + ## 1.131 - 2025-07-01 ### @cesium/engine From 78dd3c83f1594f882e9f0b772cf7578c70f0b29d Mon Sep 17 00:00:00 2001 From: Hiwen Date: Sat, 28 Jun 2025 14:07:20 +0800 Subject: [PATCH 3/6] Move out VolumeCloud Sandbox Sample --- .../gallery/{development => }/VolumeCloud.html | 2 +- .../gallery/{development => }/VolumeCloud.jpg | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename Apps/Sandcastle/gallery/{development => }/VolumeCloud.html (99%) rename Apps/Sandcastle/gallery/{development => }/VolumeCloud.jpg (100%) diff --git a/Apps/Sandcastle/gallery/development/VolumeCloud.html b/Apps/Sandcastle/gallery/VolumeCloud.html similarity index 99% rename from Apps/Sandcastle/gallery/development/VolumeCloud.html rename to Apps/Sandcastle/gallery/VolumeCloud.html index c9b61289edb1..f7f3b632d3cc 100644 --- a/Apps/Sandcastle/gallery/development/VolumeCloud.html +++ b/Apps/Sandcastle/gallery/VolumeCloud.html @@ -11,7 +11,7 @@ name="description" content="Rendering Volume Cloud with Texture3D and Custom GLSL. Transplanted from Three.js" /> - + Cesium Demo