From e9b314560e58c627feba169fdcd9801b8d8f6d48 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Sat, 9 Aug 2025 17:07:23 -0400 Subject: [PATCH 1/3] KTX2Loader: Support RGB9E5 (#31611) --- examples/jsm/loaders/KTX2Loader.js | 21 +++++++++++++++++-- examples/textures/ktx2/2d_rgb9e5_linear.ktx2 | Bin 0 -> 8920 bytes examples/webgl_loader_texture_ktx2.html | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 examples/textures/ktx2/2d_rgb9e5_linear.ktx2 diff --git a/examples/jsm/loaders/KTX2Loader.js b/examples/jsm/loaders/KTX2Loader.js index 951efdb52e1cff..a962ce16b58598 100644 --- a/examples/jsm/loaders/KTX2Loader.js +++ b/examples/jsm/loaders/KTX2Loader.js @@ -26,10 +26,12 @@ import { RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, + RGBFormat, RGFormat, RedFormat, SRGBColorSpace, - UnsignedByteType + UnsignedByteType, + UnsignedInt5999Type } from 'three'; import { WorkerPool } from '../utils/WorkerPool.js'; import { @@ -70,6 +72,7 @@ import { VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8_SRGB, VK_FORMAT_R8_UNORM, + VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, VK_FORMAT_UNDEFINED } from '../libs/ktx-parse.module.js'; import { ZSTDDecoder } from '../libs/zstddec.module.js'; @@ -918,7 +921,7 @@ KTX2Loader.BasisWorker = function () { // Parsing for non-Basis textures. These textures may have supercompression // like Zstd, but they do not require transcoding. -const UNCOMPRESSED_FORMATS = new Set( [ RGBAFormat, RGFormat, RedFormat ] ); +const UNCOMPRESSED_FORMATS = new Set( [ RGBAFormat, RGBFormat, RGFormat, RedFormat ] ); const FORMAT_MAP = { @@ -937,6 +940,8 @@ const FORMAT_MAP = { [ VK_FORMAT_R8_SRGB ]: RedFormat, [ VK_FORMAT_R8_UNORM ]: RedFormat, + [ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: RGBFormat, + [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: RGB_ETC2_Format, [ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: RGBA_ETC2_EAC_Format, @@ -979,6 +984,8 @@ const TYPE_MAP = { [ VK_FORMAT_R8_SRGB ]: UnsignedByteType, [ VK_FORMAT_R8_UNORM ]: UnsignedByteType, + [ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: UnsignedInt5999Type, + [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: UnsignedByteType, [ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: UnsignedByteType, @@ -1071,6 +1078,16 @@ async function createRawTexture( container ) { ); + } else if ( TYPE_MAP[ vkFormat ] === UnsignedInt5999Type ) { + + data = new Uint32Array( + + levelData.buffer, + levelData.byteOffset, + levelData.byteLength / Uint32Array.BYTES_PER_ELEMENT + + ); + } else { data = levelData; diff --git a/examples/textures/ktx2/2d_rgb9e5_linear.ktx2 b/examples/textures/ktx2/2d_rgb9e5_linear.ktx2 new file mode 100644 index 0000000000000000000000000000000000000000..728c53a10ce7ac3ddd9d72673ebc39780ccf9750 GIT binary patch literal 8920 zcmeHI3rv<(82;cVMO1WXsL=2a6%8Es)YKvKf*171zzY*nLl6XX=X?_KT?A%M%nKSS znwFV4+puYwAz?zJP0dnL*2rqwbZKd`Qo}@>o#*@iqsMQ6XkwTB|91ZOdfxXv@B5td z?TVd}XblfN(AmSsLz5)QjjaKW#fb59VgKzM{P&FNY$Y>gq(di?uRA!TUiZ>X7P}nn z2*jzot6jeqN!X9m9S%9wu9i4m@6dO3=sD&4P(Oa0qE`G|r98>S#lD%_B+1=w#Q)Qh zWyU^!zLfDF+DJvGz z7naVU6SBL}sN{2G_>6B!P|QZd&qn&tRXrOb%zGa@0?yKr@NObuYD0GS2onk zsjD=$uLq5ueTl4(nxM8n=B*zjm(^`HRdqS+s#j*8RnPAz(OwDlQ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#31612) Co-authored-by: user --- examples/jsm/controls/DragControls.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/jsm/controls/DragControls.js b/examples/jsm/controls/DragControls.js index fbb6c606c83533..f06ffa140a37e9 100644 --- a/examples/jsm/controls/DragControls.js +++ b/examples/jsm/controls/DragControls.js @@ -305,6 +305,7 @@ function onPointerMove( event ) { if ( raycaster.ray.intersectPlane( _plane, _intersection ) ) { _selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) ); + this.dispatchEvent( { type: 'drag', object: _selected } ); } @@ -313,11 +314,10 @@ function onPointerMove( event ) { _diff.subVectors( _pointer, _previousPointer ).multiplyScalar( this.rotateSpeed ); _selected.rotateOnWorldAxis( _up, _diff.x ); _selected.rotateOnWorldAxis( _right.normalize(), - _diff.y ); + this.dispatchEvent( { type: 'drag', object: _selected } ); } - this.dispatchEvent( { type: 'drag', object: _selected } ); - _previousPointer.copy( _pointer ); } else { @@ -414,21 +414,21 @@ function onPointerDown( event ) { _inverseMatrix.copy( _selected.parent.matrixWorld ).invert(); _offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) ); + domElement.style.cursor = 'move'; + this.dispatchEvent( { type: 'dragstart', object: _selected } ); } else if ( this.state === STATE.ROTATE ) { // the controls only support Y+ up _up.set( 0, 1, 0 ).applyQuaternion( camera.quaternion ).normalize(); _right.set( 1, 0, 0 ).applyQuaternion( camera.quaternion ).normalize(); + domElement.style.cursor = 'move'; + this.dispatchEvent( { type: 'dragstart', object: _selected } ); } } - domElement.style.cursor = 'move'; - - this.dispatchEvent( { type: 'dragstart', object: _selected } ); - } _previousPointer.copy( _pointer ); From eb7609c062744e304fb8a33da8888d172b07e1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20H=C3=A4nsler?= Date: Sat, 9 Aug 2025 17:31:18 -0500 Subject: [PATCH 3/3] TSL: Fix instance buffer size in `instance()`. (#31608) Co-authored-by: user --- src/nodes/accessors/InstanceNode.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nodes/accessors/InstanceNode.js b/src/nodes/accessors/InstanceNode.js index 874a64835526a8..3d573a1f35901b 100644 --- a/src/nodes/accessors/InstanceNode.js +++ b/src/nodes/accessors/InstanceNode.js @@ -109,7 +109,9 @@ class InstanceNode extends Node { */ setup( builder ) { - const { count, instanceMatrix, instanceColor } = this; + const { instanceMatrix, instanceColor } = this; + + const { count } = instanceMatrix; let { instanceMatrixNode, instanceColorNode } = this;