@gnsx/three 0.185.5 → 0.185.7

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.
@@ -79,7 +79,12 @@ function _saveState() {
79
79
 
80
80
  }
81
81
 
82
- _loadState();
82
+ // WITH_GENESYS
83
+ // Defer state load until Settings is instantiated. Calling `_loadState()` at
84
+ // module evaluation time triggers `Inspector.getItem()`, which reads `REVISION`
85
+ // (imported from `three/webgpu`) while `Inspector.js` is still mid-evaluation (TDZ).
86
+ // _loadState();
87
+ // !WITH_GENESYS
83
88
 
84
89
  //
85
90
 
@@ -276,10 +281,11 @@ Shares the same state across any page within the current origin.` );
276
281
 
277
282
  extension.active = true;
278
283
 
279
- const extUrl = new URL( extension.url, import.meta.url ).href;
280
-
281
284
  // WITH_GENESYS
282
- const module = await import( /* @vite-ignore */ /* webpackIgnore: true */ extUrl );
285
+ // `new URL( extension.url, import.meta.url )` fails with webpack 5 because the
286
+ // first argument is dynamic ("Can't resolve <dynamic>"). With @vite-ignore and
287
+ // webpackIgnore, the browser resolves the relative `extension.url` at runtime.
288
+ const module = await import( /* @vite-ignore */ /* webpackIgnore: true */ extension.url );
283
289
  // !WITH_GENESYS
284
290
 
285
291
  const keys = Object.keys( module );
@@ -33,6 +33,7 @@ import {
33
33
  storageTexture,
34
34
  textureStore,
35
35
  uniform,
36
+ uint,
36
37
  uvec3,
37
38
  vec3,
38
39
  vec4
@@ -675,31 +676,6 @@ class LightProbeGrid extends Object3D {
675
676
 
676
677
  renderer.shadowMap.autoUpdate = savedShadowAutoUpdate;
677
678
 
678
- // Padding slices copy the nearest edge data slices on the GPU.
679
- const atlas = this.texture;
680
-
681
- for ( let textureIndex = 0; textureIndex < 7; textureIndex ++ ) {
682
-
683
- const baseSlice = textureIndex * paddedSlices;
684
- const dataSlice = baseSlice + ATLAS_PADDING;
685
- const trailingSlice = dataSlice + nz;
686
-
687
- renderer.copyTextureToTexture(
688
- atlas,
689
- atlas,
690
- new Box3( new Vector3( 0, 0, dataSlice ), new Vector3( nx, ny, dataSlice + 1 ) ),
691
- new Vector3( 0, 0, baseSlice )
692
- );
693
-
694
- renderer.copyTextureToTexture(
695
- atlas,
696
- atlas,
697
- new Box3( new Vector3( 0, 0, dataSlice + nz - 1 ), new Vector3( nx, ny, dataSlice + nz ) ),
698
- new Vector3( 0, 0, trailingSlice )
699
- );
700
-
701
- }
702
-
703
679
  await renderer.backend.device.queue.onSubmittedWorkDone();
704
680
 
705
681
  }
@@ -1172,35 +1148,56 @@ function _ensureWebGPUComputeResources( cubemapSize, envMapTexture, atlasTexture
1172
1148
 
1173
1149
  Loop( { end: 7, name: 't', type: 'int' }, ( { t } ) => {
1174
1150
 
1175
- const atlasZ = paddedSlices.mul( t ).add( 1 ).add( probeIz );
1151
+ const baseSlice = paddedSlices.mul( t );
1152
+ const atlasZ = baseSlice.add( 1 ).add( probeIz );
1153
+ const trailingSlice = baseSlice.add( paddedSlices ).sub( 1 );
1154
+ const lastDataSlice = paddedSlices.sub( 3 );
1155
+ const storeProbeValue = ( value ) => {
1156
+
1157
+ textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), value ).toWriteOnly();
1158
+
1159
+ // Write padding during the compute pass; WebGPU validation rejects atlas-to-itself copies.
1160
+ If( probeIz.equal( uint( 0 ) ), () => {
1161
+
1162
+ textureStore( atlas, uvec3( probeIx, probeIy, baseSlice ), value ).toWriteOnly();
1163
+
1164
+ } );
1165
+
1166
+ If( probeIz.equal( lastDataSlice ), () => {
1167
+
1168
+ textureStore( atlas, uvec3( probeIx, probeIy, trailingSlice ), value ).toWriteOnly();
1169
+
1170
+ } );
1171
+
1172
+ };
1176
1173
 
1177
1174
  If( t.equal( int( 0 ) ), () => {
1178
1175
 
1179
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c0.x, c0.y, c0.z, c1.x ) ).toWriteOnly();
1176
+ storeProbeValue( vec4( c0.x, c0.y, c0.z, c1.x ) );
1180
1177
 
1181
1178
  } ).ElseIf( t.equal( int( 1 ) ), () => {
1182
1179
 
1183
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c1.y, c1.z, c2.x, c2.y ) ).toWriteOnly();
1180
+ storeProbeValue( vec4( c1.y, c1.z, c2.x, c2.y ) );
1184
1181
 
1185
1182
  } ).ElseIf( t.equal( int( 2 ) ), () => {
1186
1183
 
1187
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c2.z, c3.x, c3.y, c3.z ) ).toWriteOnly();
1184
+ storeProbeValue( vec4( c2.z, c3.x, c3.y, c3.z ) );
1188
1185
 
1189
1186
  } ).ElseIf( t.equal( int( 3 ) ), () => {
1190
1187
 
1191
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c4.x, c4.y, c4.z, c5.x ) ).toWriteOnly();
1188
+ storeProbeValue( vec4( c4.x, c4.y, c4.z, c5.x ) );
1192
1189
 
1193
1190
  } ).ElseIf( t.equal( int( 4 ) ), () => {
1194
1191
 
1195
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c5.y, c5.z, c6.x, c6.y ) ).toWriteOnly();
1192
+ storeProbeValue( vec4( c5.y, c5.z, c6.x, c6.y ) );
1196
1193
 
1197
1194
  } ).ElseIf( t.equal( int( 5 ) ), () => {
1198
1195
 
1199
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c6.z, c7.x, c7.y, c7.z ) ).toWriteOnly();
1196
+ storeProbeValue( vec4( c6.z, c7.x, c7.y, c7.z ) );
1200
1197
 
1201
1198
  } ).Else( () => {
1202
1199
 
1203
- textureStore( atlas, uvec3( probeIx, probeIy, atlasZ ), vec4( c8.x, c8.y, c8.z, float( 0 ) ) ).toWriteOnly();
1200
+ storeProbeValue( vec4( c8.x, c8.y, c8.z, float( 0 ) ) );
1204
1201
 
1205
1202
  } );
1206
1203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnsx/three",
3
- "version": "0.185.5",
3
+ "version": "0.185.7",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
@@ -2267,6 +2267,11 @@ class WebGPUBackend extends Backend {
2267
2267
 
2268
2268
  const baseOffset = timestampQueryPool.allocateQueriesForContext( uid );
2269
2269
 
2270
+ // WITH_GENESYS
2271
+ // If query allocation fails, leave timestampWrites unset so WebGPU doesn't receive a null querySet.
2272
+ if ( baseOffset === null || timestampQueryPool.querySet === null ) return;
2273
+ // !WITH_GENESYS
2274
+
2270
2275
  _renderPassTimestampWrites.querySet = timestampQueryPool.querySet;
2271
2276
  _renderPassTimestampWrites.beginningOfPassWriteIndex = baseOffset;
2272
2277
  _renderPassTimestampWrites.endOfPassWriteIndex = baseOffset + 1;
@@ -250,6 +250,17 @@ class WebGPUTextureUtils {
250
250
  if ( bindingData.sampler !== undefined ) {
251
251
 
252
252
  const samplerData = this._samplerCache.get( bindingData.samplerKey );
253
+ // WITH_GENESYS
254
+ // Binding disposal can be reached more than once during renderer teardown; tolerate stale sampler cache data.
255
+ if ( samplerData === undefined ) {
256
+
257
+ bindingData.sampler = undefined;
258
+ bindingData.samplerKey = undefined;
259
+ return;
260
+
261
+ }
262
+
263
+ // !WITH_GENESYS
253
264
  samplerData.usedTimes --;
254
265
 
255
266
  if ( samplerData.usedTimes === 0 ) {