@rings-webgpu/core 1.0.11 → 1.0.13

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.
@@ -2120,7 +2120,7 @@
2120
2120
  }
2121
2121
 
2122
2122
  var __defProp$2 = Object.defineProperty;
2123
- var __decorateClass$j = (decorators, target, key, kind) => {
2123
+ var __decorateClass$m = (decorators, target, key, kind) => {
2124
2124
  var result = void 0 ;
2125
2125
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
2126
2126
  if (decorator = decorators[i])
@@ -2223,10 +2223,10 @@
2223
2223
  return struct.__size;
2224
2224
  }
2225
2225
  };
2226
- __decorateClass$j([
2226
+ __decorateClass$m([
2227
2227
  NonSerialize
2228
2228
  ], _Struct.prototype, "__refection");
2229
- __decorateClass$j([
2229
+ __decorateClass$m([
2230
2230
  NonSerialize
2231
2231
  ], _Struct.prototype, "__size");
2232
2232
  let Struct = _Struct;
@@ -5032,18 +5032,20 @@ fn dir_to_faceId(pt:vec3<f32>) -> i32 {
5032
5032
  }
5033
5033
  }
5034
5034
 
5035
- let VertexAttributes_vert = `
5035
+ let VertexAttributes_vert = (
5036
+ /*wgsl*/
5037
+ `
5036
5038
  var<private> PI: f32 = 3.14159265359;
5037
5039
  #if USE_METAHUMAN
5038
5040
  ${MorphTarget_shader.getMorphTargetShaderBinding(3, 0)}
5039
- ${SkeletonAnimation_shader.groupBindingAndFunctions(3, 2)}
5041
+ ${SkeletonAnimation_shader.groupBindingAndFunctions(3, 2)}
5040
5042
  #else
5041
5043
  #if USE_MORPHTARGETS
5042
5044
  ${MorphTarget_shader.getMorphTargetShaderBinding(3, 0)}
5043
5045
  #endif
5044
5046
 
5045
5047
  #if USE_SKELETON
5046
- ${SkeletonAnimation_shader.groupBindingAndFunctions(3, 0)}
5048
+ ${SkeletonAnimation_shader.groupBindingAndFunctions(3, 0)}
5047
5049
  #endif
5048
5050
  #endif
5049
5051
 
@@ -5078,6 +5080,10 @@ fn dir_to_faceId(pt:vec3<f32>) -> i32 {
5078
5080
  #endif
5079
5081
  #endif
5080
5082
  #else
5083
+ #if USE_TANGENT
5084
+ @location(auto) TANGENT: vec4<f32>,
5085
+ #endif
5086
+
5081
5087
  #if USE_SKELETON
5082
5088
  #if USE_TANGENT
5083
5089
  @location(auto) joints0: vec4<f32>,
@@ -5124,6 +5130,7 @@ fn dir_to_faceId(pt:vec3<f32>) -> i32 {
5124
5130
  #if USE_TANGENT
5125
5131
  @location(auto) varying_Tangent: vec4<f32>,
5126
5132
  #endif
5133
+
5127
5134
 
5128
5135
  @builtin(position) member: vec4<f32>
5129
5136
  };
@@ -5173,23 +5180,24 @@ fn dir_to_faceId(pt:vec3<f32>) -> i32 {
5173
5180
  clipPosition.z = log2Depth(clipPosition.w, globalUniform.near, globalUniform.far);
5174
5181
  #endif
5175
5182
 
5176
- ORI_CameraWorldDir = normalize(ORI_CAMERAMATRIX[3].xyz - worldPos.xyz);
5183
+ ORI_CameraWorldDir = normalize(ORI_CAMERAMATRIX[3].xyz - worldPos.xyz) ;
5177
5184
 
5178
- ORI_VertexOut.index = f32(vertex.index);
5185
+ ORI_VertexOut.index = f32(vertex.index) ;
5179
5186
 
5180
- ORI_VertexOut.varying_UV0 = vertex.uv.xy;
5187
+ ORI_VertexOut.varying_UV0 = vertex.uv.xy ;
5181
5188
 
5182
5189
  ORI_VertexOut.varying_UV1 = vertex.TEXCOORD_1.xy;
5183
5190
 
5184
- ORI_VertexOut.varying_ViewPos = viewPosition;
5185
- ORI_VertexOut.varying_Clip = clipPosition;
5186
- ORI_VertexOut.varying_WPos = worldPos;
5191
+ ORI_VertexOut.varying_ViewPos = viewPosition ;
5192
+ ORI_VertexOut.varying_Clip = clipPosition ;
5193
+ ORI_VertexOut.varying_WPos = worldPos ;
5187
5194
  ORI_VertexOut.varying_WPos.w = f32(vertex.index);
5188
- ORI_VertexOut.varying_WNormal = normalize(ORI_NORMALMATRIX * vertexNormal.xyz);
5195
+ ORI_VertexOut.varying_WNormal = normalize(ORI_NORMALMATRIX * vertexNormal.xyz) ;
5189
5196
 
5190
- ORI_VertexOut.member = clipPosition;
5197
+ ORI_VertexOut.member = clipPosition ;
5191
5198
  }
5192
- `;
5199
+ `
5200
+ );
5193
5201
 
5194
5202
  let VideoUniform_frag = `
5195
5203
  struct MaterialUniform {
@@ -5308,68 +5316,90 @@ var<uniform> materialUniform: MaterialUniform;
5308
5316
  `
5309
5317
  );
5310
5318
 
5311
- let Common_frag = `
5312
- #include "GlobalUniform"
5313
- #include "FragmentVarying"
5314
- #include "FragmentOutput"
5315
- #include "ShadingInput"
5316
- #include "ColorUtil_frag"
5317
- #include "BitUtil"
5318
-
5319
- var<private> ORI_FragmentOutput: FragmentOutput;
5320
- var<private> ORI_VertexVarying: FragmentVarying;
5321
- var<private> ORI_ShadingInput: ShadingInput;
5322
- var<private> viewDir:vec3<f32>;
5323
- var<private> modelIndex:u32;
5319
+ let Common_frag = (
5320
+ /*wgsl*/
5321
+ `
5322
+ #include "GlobalUniform"
5323
+ #include "FragmentVarying"
5324
+ #include "FragmentOutput"
5325
+ #include "ShadingInput"
5326
+ #include "ColorUtil_frag"
5327
+ #include "BitUtil"
5324
5328
 
5325
- @fragment
5326
- fn FragMain( vertex_varying:FragmentVarying ) -> FragmentOutput {
5327
- modelIndex = u32(round(vertex_varying.index));
5328
- ORI_VertexVarying = vertex_varying;
5329
- ORI_VertexVarying.vWorldNormal = normalize(vertex_varying.vWorldNormal);
5329
+ var<private> ORI_FragmentOutput: FragmentOutput;
5330
+ var<private> ORI_VertexVarying: FragmentVarying;
5331
+ var<private> ORI_ShadingInput: ShadingInput;
5332
+ var<private> viewDir:vec3<f32>;
5333
+ var<private> modelIndex:u32;
5334
+
5335
+ @fragment
5336
+ fn FragMain( vertex_varying:FragmentVarying ) -> FragmentOutput {
5330
5337
  ORI_FragmentOutput.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
5331
- viewDir = normalize(globalUniform.CameraPos.xyz - ORI_VertexVarying.vWorldPos.xyz);
5332
- frag();
5338
+ ORI_VertexVarying = vertex_varying;
5339
+ ORI_VertexVarying.vWorldNormal = normalize(vertex_varying.vWorldNormal);
5340
+ ORI_FragmentOutput.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
5341
+ viewDir = normalize(globalUniform.CameraPos.xyz - ORI_VertexVarying.vWorldPos.xyz) ;
5333
5342
 
5334
- #if USE_DEBUG
5335
- debugFragmentOut();
5336
- #endif
5343
+ frag();
5344
+
5345
+ #if USE_DEBUG
5346
+ debugFragmentOut();
5347
+ #endif
5337
5348
 
5338
- #if USE_OUTDEPTH
5339
- #if USE_LOGDEPTH
5340
- ORI_FragmentOutput.out_depth = log2DepthFixPersp(ORI_VertexVarying.fragPosition.w, globalUniform.near, globalUniform.far);
5341
- #else
5342
- ORI_FragmentOutput.out_depth = ORI_ShadingInput.FragDepth;
5343
- #endif
5344
- #endif
5349
+ #if USE_DEFAULTFRAGOUT
5350
+ // let finalMatrix = globalUniform.projMat * globalUniform.viewMat ;
5351
+ // let nMat = mat3x3<f32>(finalMatrix[0].xyz,finalMatrix[1].xyz,finalMatrix[2].xyz) ;
5352
+ // let ORI_NORMALMATRIX = transpose(inverse( nMat ));
5353
+ // var vNormal = normalize(ORI_NORMALMATRIX * (ORI_VertexVarying.vWorldNormal));
5354
+
5355
+ // let gBuffer = packNHMDGBuffer(
5356
+ // ORI_VertexVarying.fragCoord.z,
5357
+ // ORI_ShadingInput.BaseColor.rgb,
5358
+ // ORI_ShadingInput.BaseColor.rgb,
5359
+ // vec3f(ORI_ShadingInput.Roughness,ORI_ShadingInput.Metallic,ORI_ShadingInput.AmbientOcclusion),
5360
+ // ORI_ShadingInput.Normal,
5361
+ // ORI_ShadingInput.Opacity
5362
+ // ) ;
5363
+ #endif
5345
5364
 
5346
- return ORI_FragmentOutput;
5347
- }
5365
+ #if USE_OUTDEPTH
5366
+ #if USE_LOGDEPTH
5367
+ ORI_FragmentOutput.out_depth = log2DepthFixPersp(ORI_VertexVarying.fragPosition.w, globalUniform.near, globalUniform.far);
5368
+ #else
5369
+ ORI_FragmentOutput.out_depth = ORI_ShadingInput.FragDepth ;
5370
+ #endif
5371
+ #endif
5348
5372
 
5349
- fn packNHMDGBuffer(depth:f32, albedo:vec3f,hdrLighting:vec3f,rmao:vec3f,normal:vec3f,alpha:f32) -> vec4f {
5350
- var gBuffer : vec4f;
5351
- var octUVNormal = (octEncode(normalize( (normal) )) + 1.0) * 0.5;
5352
- var yc = f32(r11g11b9_to_float(vec3f(octUVNormal,rmao.r)));
5353
- #if USE_CASTREFLECTION
5354
- var rgbm = EncodeRGBM(hdrLighting);
5355
- var zc = f32(pack4x8unorm(vec4f(rgbm.rgb,0.0))) ;
5356
- var wc = f32(pack4x8unorm(vec4f(rmao.rg,rgbm.a,0.0)));
5357
- #else
5358
- var zc = f32(vec4fToFloat_7bits(vec4f(albedo.rgb,alpha)));
5359
- var wc = f32(r22g8_to_float(vec2f(f32(modelIndex)/f_r22g8.r,rmao.g)));
5360
- #endif
5373
+ return ORI_FragmentOutput ;
5374
+ }
5361
5375
 
5362
- gBuffer.x = depth ;
5363
- gBuffer.y = yc;
5364
- gBuffer.z = zc;
5365
- gBuffer.w = wc;
5366
- return gBuffer;
5367
- }
5368
5376
 
5369
- fn transformUV( uv:vec2f , offsetScale:vec4f ) -> vec2f{
5370
- return uv * offsetScale.zw + offsetScale.xy;
5371
- }
5372
- `;
5377
+ fn packNHMDGBuffer(depth:f32, albedo:vec3f,hdrLighting:vec3f,rmao:vec3f,normal:vec3f,alpha:f32) -> vec4f {
5378
+ var gBuffer : vec4f ;
5379
+ var octUVNormal = (octEncode(normalize( (normal) )) + 1.0) * 0.5 ;
5380
+ var yc = f32(r11g11b9_to_float(vec3f(octUVNormal,rmao.r))) ;
5381
+ #if USE_CASTREFLECTION
5382
+ var rgbm = EncodeRGBM(hdrLighting);
5383
+ var zc = f32(pack4x8unorm(vec4f(rgbm.rgb,0.0))) ;
5384
+ var wc = f32(pack4x8unorm(vec4f(rmao.rg,rgbm.a,0.0)));
5385
+ #else
5386
+ var zc = f32(vec4fToFloat_7bits(vec4f(albedo.rgb,alpha)));
5387
+ var wc = f32(r22g8_to_float(vec2f(f32(modelIndex)/f_r22g8.r,rmao.g)));
5388
+ #endif
5389
+
5390
+ gBuffer.x = depth ;
5391
+ gBuffer.y = yc ;
5392
+ gBuffer.z = zc ;
5393
+ gBuffer.w = wc ;
5394
+ return gBuffer ;
5395
+ }
5396
+
5397
+ fn transformUV( uv:vec2f , offsetScale:vec4f ) -> vec2f{
5398
+ return uv * offsetScale.zw + offsetScale.xy ;
5399
+ }
5400
+
5401
+ `
5402
+ );
5373
5403
 
5374
5404
  let Common_vert = (
5375
5405
  /*wgsl*/
@@ -5739,6 +5769,7 @@ var<uniform> materialUniform: MaterialUniform;
5739
5769
  let FragmentOutput = `
5740
5770
  #if USE_CASTREFLECTION
5741
5771
  struct FragmentOutput {
5772
+ @location(auto) color: vec4<f32>,
5742
5773
  @location(auto) gBuffer: vec4<f32>,
5743
5774
  #if USE_OUTDEPTH
5744
5775
  @builtin(frag_depth) out_depth: f32
@@ -9532,6 +9563,186 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
9532
9563
  }
9533
9564
  `;
9534
9565
 
9566
+ const FatLine_VS = (
9567
+ /* wgsl */
9568
+ `
9569
+ #include "GlobalUniform"
9570
+
9571
+ // Instance attributes stored in storage buffer
9572
+ // Extended with prevDir and nextDir for Line Join support
9573
+ struct InstanceData {
9574
+ start: vec3<f32>,
9575
+ _padding1: f32,
9576
+ end: vec3<f32>,
9577
+ _padding2: f32,
9578
+ colorStart: vec3<f32>,
9579
+ _padding3: f32,
9580
+ colorEnd: vec3<f32>,
9581
+ _padding4: f32,
9582
+ };
9583
+
9584
+ struct VertexInput {
9585
+ @builtin(instance_index) instanceIndex: u32,
9586
+ @location(0) position: vec3<f32>, // Quad vertices
9587
+ @location(1) uv: vec2<f32>, // UV coordinates
9588
+ };
9589
+
9590
+ struct VertexOutput {
9591
+ @builtin(position) position: vec4<f32>,
9592
+ @location(0) vUv: vec2<f32>,
9593
+ @location(1) vColor: vec3<f32>,
9594
+ };
9595
+
9596
+ struct MaterialUniform {
9597
+ baseColor: vec4<f32>,
9598
+ lineWidth: f32,
9599
+ opacity: f32,
9600
+ resolution: vec2<f32>,
9601
+ modelMatrix: mat4x4<f32>,
9602
+ };
9603
+
9604
+ @group(1) @binding(0) var<uniform> materialUniform: MaterialUniform;
9605
+ @group(1) @binding(1) var<storage, read> instances: array<InstanceData>;
9606
+
9607
+ @vertex
9608
+ fn VertMain(input: VertexInput) -> VertexOutput {
9609
+ var output: VertexOutput;
9610
+
9611
+ let instance = instances[input.instanceIndex];
9612
+
9613
+ // Transform from local space to world space, then to view space
9614
+ let start_world = materialUniform.modelMatrix * vec4<f32>(instance.start, 1.0);
9615
+ let end_world = materialUniform.modelMatrix * vec4<f32>(instance.end, 1.0);
9616
+
9617
+ let start_view = globalUniform.viewMat * start_world;
9618
+ let end_view = globalUniform.viewMat * end_world;
9619
+
9620
+ // Project to clip space
9621
+ var clip_start = globalUniform.projMat * start_view;
9622
+ var clip_end = globalUniform.projMat * end_view;
9623
+
9624
+ // Perspective division to NDC space
9625
+ let ndc_start = clip_start.xyz / clip_start.w;
9626
+ let ndc_end = clip_end.xyz / clip_end.w;
9627
+
9628
+ // Calculate screen-space direction
9629
+ var dir = ndc_end.xy - ndc_start.xy;
9630
+
9631
+ // Account for aspect ratio
9632
+ let aspect = materialUniform.resolution.x / materialUniform.resolution.y;
9633
+ dir.x *= aspect;
9634
+ dir = normalize(dir);
9635
+
9636
+ // Calculate perpendicular offset
9637
+ var offset = vec2<f32>(dir.y, -dir.x);
9638
+
9639
+ // Undo aspect ratio adjustment for both dir and offset
9640
+ dir.x /= aspect;
9641
+ offset.x /= aspect;
9642
+
9643
+ // Flip offset direction based on position.x
9644
+ if (input.position.x < 0.0) {
9645
+ offset *= -1.0;
9646
+ }
9647
+
9648
+ // Handle endcaps
9649
+ if (input.position.y < 0.0) {
9650
+ offset += -dir;
9651
+ } else if (input.position.y > 1.0) {
9652
+ offset += dir;
9653
+ }
9654
+
9655
+ // Apply line width
9656
+ offset *= materialUniform.lineWidth;
9657
+ offset /= materialUniform.resolution.y; // Convert to clip space
9658
+
9659
+ // Select start or end point
9660
+ var clip = select(clip_end, clip_start, input.position.y < 0.5);
9661
+
9662
+ // Shift the depth of the projected points so the line segments
9663
+ // overlap neatly and face the camera properly (billboard effect)
9664
+ let clipPose = select(ndc_end, ndc_start, input.position.y < 0.5);
9665
+ clip.z = clipPose.z * clip.w;
9666
+
9667
+ // Perspective correction
9668
+ offset *= clip.w;
9669
+ clip.x += offset.x;
9670
+ clip.y += offset.y;
9671
+
9672
+ output.position = clip;
9673
+ output.vUv = input.uv;
9674
+ output.vColor = select(instance.colorEnd, instance.colorStart, input.position.y < 0.5);
9675
+
9676
+ return output;
9677
+ }
9678
+ `
9679
+ );
9680
+ const FatLine_FS = (
9681
+ /* wgsl */
9682
+ `
9683
+ struct FragmentOutput {
9684
+ @location(0) color: vec4<f32>,
9685
+ @location(1) gBuffer: vec4<f32>,
9686
+ };
9687
+
9688
+ struct VertexOutput {
9689
+ @builtin(position) position: vec4<f32>,
9690
+ @location(0) vUv: vec2<f32>,
9691
+ @location(1) vColor: vec3<f32>,
9692
+ };
9693
+
9694
+ struct MaterialUniform {
9695
+ baseColor: vec4<f32>,
9696
+ lineWidth: f32,
9697
+ opacity: f32,
9698
+ resolution: vec2<f32>,
9699
+ modelMatrix: mat4x4<f32>,
9700
+ };
9701
+
9702
+ @group(1) @binding(0) var<uniform> materialUniform: MaterialUniform;
9703
+
9704
+ @fragment
9705
+ fn FragMain(input: VertexOutput) -> FragmentOutput {
9706
+ var output: FragmentOutput;
9707
+
9708
+ var alpha = materialUniform.opacity;
9709
+
9710
+ // Round endcap rendering with anti-aliasing
9711
+ let a = input.vUv.x;
9712
+ let b = select(input.vUv.y - 1.0, input.vUv.y + 1.0, input.vUv.y > 0.0);
9713
+ let len2 = a * a + b * b;
9714
+
9715
+ // Calculate derivative (must be in uniform control flow)
9716
+ let dlen = fwidth(len2);
9717
+
9718
+ // Round endcap rendering - simple approach
9719
+ if (abs(input.vUv.y) > 1.0) {
9720
+ // Determine circle center: (0, 1) for top, (0, -1) for bottom
9721
+ var basePoint = select(
9722
+ vec2<f32>(0.0, -1.0), // Bottom endcap
9723
+ vec2<f32>(0.0, 1.0), // Top endcap
9724
+ input.vUv.y > 0.0
9725
+ );
9726
+
9727
+ // Distance from UV to circle center
9728
+ // var dist = length(input.vUv - basePoint);
9729
+ var dist2 = (input.vUv.x - basePoint.x) * (input.vUv.x - basePoint.x) + (input.vUv.y - basePoint.y) * (input.vUv.y - basePoint.y);
9730
+
9731
+ // Discard pixels outside circle (radius = 1.0)
9732
+ if (dist2 > 1.0) {
9733
+ discard;
9734
+ }
9735
+ }
9736
+
9737
+ let color = input.vColor * materialUniform.baseColor.rgb;
9738
+ output.color = vec4<f32>(color, alpha);
9739
+ output.gBuffer = vec4<f32>(0.0, 0.0, 0.0, 0.0); // No GBuffer data for lines
9740
+
9741
+ return output;
9742
+ }
9743
+ `
9744
+ );
9745
+
9535
9746
  class ShaderLib {
9536
9747
  static init() {
9537
9748
  ShaderLib.register("MathShader", MathShader);
@@ -9601,6 +9812,8 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
9601
9812
  );
9602
9813
  ShaderLib.register("ZPass_shader_vs", ZPassShader_vs);
9603
9814
  ShaderLib.register("ZPass_shader_fs", ZPassShader_fs);
9815
+ ShaderLib.register("FatLine_VS", FatLine_VS);
9816
+ ShaderLib.register("FatLine_FS", FatLine_FS);
9604
9817
  }
9605
9818
  static register(keyName, code) {
9606
9819
  if (!ShaderLib[keyName.toLowerCase()]) {
@@ -21687,9 +21900,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
21687
21900
  }
21688
21901
 
21689
21902
  var __defProp$1 = Object.defineProperty;
21690
- var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
21691
- var __decorateClass$i = (decorators, target, key, kind) => {
21692
- var result = __getOwnPropDesc$i(target, key) ;
21903
+ var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
21904
+ var __decorateClass$l = (decorators, target, key, kind) => {
21905
+ var result = __getOwnPropDesc$l(target, key) ;
21693
21906
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
21694
21907
  if (decorator = decorators[i])
21695
21908
  result = (decorator(target, key, result) ) || result;
@@ -22274,221 +22487,16 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22274
22487
  this._combineShaderRefection = void 0;
22275
22488
  }
22276
22489
  }
22277
- __decorateClass$i([
22490
+ __decorateClass$l([
22278
22491
  EditorInspector
22279
22492
  ], RenderNode.prototype, "materials");
22280
- __decorateClass$i([
22493
+ __decorateClass$l([
22281
22494
  EditorInspector
22282
22495
  ], RenderNode.prototype, "castShadow");
22283
- __decorateClass$i([
22496
+ __decorateClass$l([
22284
22497
  EditorInspector
22285
22498
  ], RenderNode.prototype, "castGI");
22286
22499
 
22287
- class Shader {
22288
- computes;
22289
- passShader;
22290
- constructor() {
22291
- this.computes = [];
22292
- this.passShader = /* @__PURE__ */ new Map();
22293
- }
22294
- addRenderPass(renderShader, index = -1) {
22295
- let subShader = this.passShader.get(renderShader.passType) || [];
22296
- if (index == -1) {
22297
- subShader.push(renderShader);
22298
- } else {
22299
- subShader.splice(index, -1, renderShader);
22300
- }
22301
- this.passShader.set(renderShader.passType, subShader);
22302
- }
22303
- removeShader(renderShader, index = -1) {
22304
- let subShader = this.passShader.get(
22305
- renderShader.passType
22306
- );
22307
- if (subShader) {
22308
- if (index == -1) {
22309
- let index2 = subShader.indexOf(renderShader);
22310
- if (index2 != -1) {
22311
- subShader.splice(index2);
22312
- }
22313
- } else {
22314
- subShader.splice(index, 1);
22315
- }
22316
- }
22317
- }
22318
- removeShaderByIndex(passType, index = -1) {
22319
- let subShader = this.passShader.get(passType);
22320
- if (subShader) {
22321
- if (index == -1) {
22322
- this.passShader.delete(passType);
22323
- } else {
22324
- subShader.splice(index, 1);
22325
- }
22326
- }
22327
- }
22328
- getSubShaders(passType) {
22329
- return this.passShader.get(passType) || [];
22330
- }
22331
- hasSubShaders(passType) {
22332
- let subs = this.passShader.get(passType);
22333
- return subs.length > 0;
22334
- }
22335
- getDefaultShaders() {
22336
- return this.passShader.get(PassType.COLOR);
22337
- }
22338
- getDefaultColorShader() {
22339
- return this.passShader.get(PassType.COLOR)[0];
22340
- }
22341
- setDefine(arg0, arg1) {
22342
- for (const pass of this.passShader) {
22343
- for (const rd of pass[1]) {
22344
- rd.setDefine(arg0, arg1);
22345
- }
22346
- }
22347
- }
22348
- hasDefine(arg0) {
22349
- for (const pass of this.passShader) {
22350
- for (const rd of pass[1]) {
22351
- let has = rd.hasDefine(arg0);
22352
- if (has) return has;
22353
- }
22354
- }
22355
- return false;
22356
- }
22357
- deleteDefine(arg0) {
22358
- for (const pass of this.passShader) {
22359
- for (const rd of pass[1]) {
22360
- rd.deleteDefine(arg0);
22361
- }
22362
- }
22363
- }
22364
- setUniform(arg0, arg1) {
22365
- for (const pass of this.passShader) {
22366
- for (const rd of pass[1]) {
22367
- rd.setUniform(arg0, arg1);
22368
- }
22369
- }
22370
- }
22371
- setUniformFloat(arg0, arg1) {
22372
- for (const pass of this.passShader) {
22373
- for (const rd of pass[1]) {
22374
- rd.setUniformFloat(arg0, arg1);
22375
- }
22376
- }
22377
- }
22378
- setUniformVector2(arg0, arg1) {
22379
- for (const pass of this.passShader) {
22380
- for (const rd of pass[1]) {
22381
- rd.setUniformVector2(arg0, arg1);
22382
- }
22383
- }
22384
- }
22385
- setUniformVector3(arg0, arg1) {
22386
- for (const pass of this.passShader) {
22387
- for (const rd of pass[1]) {
22388
- rd.setUniformVector3(arg0, arg1);
22389
- }
22390
- }
22391
- }
22392
- setUniformVector4(arg0, arg1) {
22393
- for (const pass of this.passShader) {
22394
- for (const rd of pass[1]) {
22395
- rd.setUniformVector4(arg0, arg1);
22396
- }
22397
- }
22398
- }
22399
- setUniformColor(arg0, arg1) {
22400
- for (const pass of this.passShader) {
22401
- for (const rd of pass[1]) {
22402
- rd.setUniformColor(arg0, arg1);
22403
- }
22404
- }
22405
- }
22406
- getUniform(arg0) {
22407
- return this.getDefaultColorShader().getUniform(arg0);
22408
- }
22409
- getUniformFloat(arg0) {
22410
- return this.getDefaultColorShader().getUniformFloat(arg0);
22411
- }
22412
- getUniformVector2(arg0) {
22413
- return this.getDefaultColorShader().getUniformVector2(arg0);
22414
- }
22415
- getUniformVector3(arg0) {
22416
- return this.getDefaultColorShader().getUniformVector3(arg0);
22417
- }
22418
- getUniformVector4(arg0) {
22419
- return this.getDefaultColorShader().getUniformVector4(arg0);
22420
- }
22421
- getUniformColor(arg0) {
22422
- return this.getDefaultColorShader().getUniformColor(arg0);
22423
- }
22424
- setTexture(arg0, arg1) {
22425
- for (const pass of this.passShader) {
22426
- for (const rd of pass[1]) {
22427
- rd.setTexture(arg0, arg1);
22428
- }
22429
- }
22430
- this.setDefine(`USE_${arg0.toLocaleUpperCase()}`, true);
22431
- }
22432
- getTexture(arg0) {
22433
- return this.getDefaultColorShader().textures[arg0];
22434
- }
22435
- setUniformBuffer(arg0, arg1) {
22436
- for (const pass of this.passShader) {
22437
- for (const rd of pass[1]) {
22438
- rd.setUniformBuffer(arg0, arg1);
22439
- }
22440
- }
22441
- }
22442
- getUniformBuffer(arg0) {
22443
- return this.getDefaultColorShader().getBuffer(arg0);
22444
- }
22445
- setStorageBuffer(arg0, arg1) {
22446
- for (const pass of this.passShader) {
22447
- for (const rd of pass[1]) {
22448
- rd.setStorageBuffer(arg0, arg1);
22449
- }
22450
- }
22451
- }
22452
- getStorageBuffer(arg0) {
22453
- return this.getDefaultColorShader().getBuffer(arg0);
22454
- }
22455
- setStructStorageBuffer(arg0, arg1) {
22456
- for (const pass of this.passShader) {
22457
- for (const rd of pass[1]) {
22458
- rd.setStructStorageBuffer(arg0, arg1);
22459
- }
22460
- }
22461
- }
22462
- getStructStorageBuffer(arg0) {
22463
- return this.getDefaultColorShader().getBuffer(arg0);
22464
- }
22465
- noticeValueChange() {
22466
- for (const pass of this.passShader) {
22467
- for (const rd of pass[1]) {
22468
- rd.noticeValueChange();
22469
- }
22470
- }
22471
- }
22472
- destroy() {
22473
- this.getDefaultColorShader().destroy();
22474
- }
22475
- clone() {
22476
- let newShader = new Shader();
22477
- let sourceShaderPassList = this.getDefaultShaders();
22478
- for (const shadePass of sourceShaderPassList) {
22479
- newShader.addRenderPass(shadePass);
22480
- }
22481
- return newShader;
22482
- }
22483
- applyUniform() {
22484
- for (const pass of this.passShader) {
22485
- for (const rd of pass[1]) {
22486
- rd.applyUniform();
22487
- }
22488
- }
22489
- }
22490
- }
22491
-
22492
22500
  class Material {
22493
22501
  instanceID;
22494
22502
  name;
@@ -22677,61 +22685,35 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22677
22685
  /* wgsl */
22678
22686
  `
22679
22687
  #include "GlobalUniform"
22680
-
22681
- struct VSOut {
22682
- @location(auto) vColor : vec4f,
22683
- @location(auto) vTexCoord : vec2f,
22684
- @builtin(position) member : vec4f
22685
- };
22686
-
22687
- // ===== SPLAT CORE VS (from PlayCanvas shader-generator-gsplat.js) =====
22688
-
22689
- // Uniforms (mapped to WebGPU bindings)
22690
- // matrix_model, matrix_view, matrix_projection -> GlobalUniform + MaterialUniform
22691
- // viewport -> calculated from globalUniform.windowWidth/Height
22692
- // tex_params -> materialUniform.tex_params
22693
-
22694
- @group(1) @binding(0) var splatColor : texture_2d<f32>;
22695
- @group(1) @binding(1) var transformA : texture_2d<u32>;
22696
- @group(1) @binding(2) var transformB : texture_2d<f32>;
22697
- @group(1) @binding(4) var splatOrder : texture_2d<u32>;
22698
22688
 
22699
22689
  struct MaterialUniform {
22700
- tex_params: vec4f, // numSplats, textureWidth, validCount, visBoost
22701
22690
  modelMatrix: mat4x4<f32>,
22702
- pixelCull: vec4f, // minPixels, maxPixels, maxPixelCullDistance, reserved
22691
+ tex_params: vec4<f32>, // [numSplats, texWidth, validCount, visBoost]
22692
+ pixelCull: vec4<f32>, // [minPixels, maxPixels, maxPixelCullDistance, batchSize]
22703
22693
  };
22704
- @group(1) @binding(3) var<uniform> materialUniform : MaterialUniform;
22694
+ @group(1) @binding(0) var<uniform> materialUniform: MaterialUniform;
22705
22695
 
22706
- // Global variables (like PlayCanvas)
22707
- var<private> orderId: u32;
22708
- var<private> splatId: u32;
22696
+ struct VSOut {
22697
+ @builtin(position) member: vec4<f32>,
22698
+ @location(0) vColor: vec4<f32>,
22699
+ @location(1) vTexCoord: vec2<f32>,
22700
+ };
22701
+
22702
+ // Textures (like PlayCanvas)
22703
+ @group(1) @binding(1) var splatColor: texture_2d<f32>;
22704
+ @group(1) @binding(2) var transformA: texture_2d<u32>;
22705
+ @group(1) @binding(3) var transformB: texture_2d<f32>;
22706
+ @group(1) @binding(4) var splatOrder: texture_2d<u32>;
22707
+
22708
+ // Global variables for texture lookups
22709
22709
  var<private> splatUV: vec2<i32>;
22710
+ var<private> splatId: u32;
22710
22711
  var<private> tA: vec4<u32>;
22711
22712
 
22712
- // Helper: decode 16-bit half float
22713
- fn unpackHalf(h: u32) -> f32 {
22714
- let s = (h >> 15u) & 0x1u;
22715
- let e = (h >> 10u) & 0x1fu;
22716
- let m = h & 0x3ffu;
22717
- let sign = select(1.0, -1.0, s == 1u);
22718
- if (e == 0u) {
22719
- if (m == 0u) { return 0.0; }
22720
- return sign * (f32(m) * exp2(-24.0));
22721
- } else if (e == 31u) {
22722
- return sign * 65504.0;
22723
- } else {
22724
- return sign * (1.0 + f32(m) / 1024.0) * exp2(f32(i32(e) - 15));
22725
- }
22726
- }
22727
-
22728
22713
  // === calcSplatUV() - returns bool ===
22729
- fn calcSplatUV(instance_id: u32) -> bool {
22730
- let numSplats = u32(materialUniform.tex_params.x);
22714
+ fn calcSplatUV(orderId: u32) -> bool {
22731
22715
  let textureWidth = u32(materialUniform.tex_params.y);
22732
-
22733
- // calculate splat index
22734
- orderId = instance_id;
22716
+ let numSplats = u32(materialUniform.tex_params.x);
22735
22717
 
22736
22718
  if (orderId >= numSplats) {
22737
22719
  return false;
@@ -22778,6 +22760,19 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22778
22760
  return result;
22779
22761
  }
22780
22762
 
22763
+ // === getRotationMatrix() - returns mat3x3 ===
22764
+ fn getRotationMatrix() -> mat3x3f {
22765
+ let cov_data = getCovariance();
22766
+ let covA = cov_data.covA;
22767
+ let covB = cov_data.covB;
22768
+
22769
+ return mat3x3f(
22770
+ vec3f(1.0 - 2.0 * (covA.z * covA.z + covB.x * covB.x), 2.0 * (covA.y * covA.z + covB.y * covB.x), 2.0 * (covA.y * covB.x - covB.y * covA.z)),
22771
+ vec3f(2.0 * (covA.y * covA.z - covB.y * covB.x), 1.0 - 2.0 * (covA.y * covA.y + covB.x * covB.x), 2.0 * (covA.z * covB.x + covA.y * covB.y)),
22772
+ vec3f(2.0 * (covA.y * covB.x + covB.y * covA.z), 2.0 * (covA.z * covB.x - covA.y * covB.y), 1.0 - 2.0 * (covA.y * covA.y + covA.z * covA.z))
22773
+ );
22774
+ }
22775
+
22781
22776
  // === calcV1V2() - returns vec4 ===
22782
22777
  fn calcV1V2(splat_cam: vec3f, covA: vec3f, covB: vec3f, W: mat3x3f, viewport: vec2f, projMat: mat4x4f) -> vec4f {
22783
22778
  let Vrk = mat3x3f(
@@ -22821,22 +22816,25 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22821
22816
  @vertex
22822
22817
  fn VertMain(
22823
22818
  @builtin(vertex_index) vid : u32,
22824
- @builtin(instance_index) iid : u32
22819
+ @builtin(instance_index) iid : u32,
22820
+ @location(0) position: vec3<f32> // vertex_position from mesh (x, y, local_index)
22825
22821
  ) -> VSOut {
22826
22822
  var o: VSOut;
22827
22823
  let discardVec = vec4f(0.0, 0.0, 2.0, 1.0);
22828
22824
 
22829
- // Vertex position array (PlayCanvas uses attribute vec3 with x,y in [-1,1])
22830
- let vertex_position = array<vec2f, 4>(
22831
- vec2f(-2.0, -2.0),
22832
- vec2f( 2.0, -2.0),
22833
- vec2f(-2.0, 2.0),
22834
- vec2f( 2.0, 2.0)
22835
- );
22836
- let vertex_pos = vertex_position[vid & 3u];
22825
+ // Calculate splat ID
22826
+ // orderId = vertex_id_attrib + uint(vertex_position.z)
22827
+ // In our case: vertex_id_attrib = iid * batchSize
22828
+ let batchSize = u32(materialUniform.pixelCull.w);
22829
+ let base_splat_index = iid * batchSize;
22830
+ let local_splat_index = u32(position.z);
22831
+ let orderId = base_splat_index + local_splat_index;
22832
+
22833
+ // Use vertex position from mesh
22834
+ let vertex_pos = position.xy;
22837
22835
 
22838
22836
  // calculate splat uv
22839
- if (!calcSplatUV(iid)) {
22837
+ if (!calcSplatUV(orderId)) {
22840
22838
  o.member = discardVec;
22841
22839
  o.vColor = vec4f(0.0);
22842
22840
  o.vTexCoord = vec2f(0.0);
@@ -22864,9 +22862,8 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22864
22862
  }
22865
22863
 
22866
22864
  // Frustum culling: cull splats outside screen bounds
22867
- // Add margin for splat radius (conservative: ~2x max splat size)
22868
22865
  let ndc = splat_proj.xyz / splat_proj.w;
22869
- let margin = 0.5; // Allow splats near edges to be visible
22866
+ let margin = 0.0;
22870
22867
  if (ndc.x < -1.0 - margin || ndc.x > 1.0 + margin ||
22871
22868
  ndc.y < -1.0 - margin || ndc.y > 1.0 + margin ||
22872
22869
  ndc.z < 0.0 || ndc.z > 1.0) {
@@ -22884,6 +22881,12 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22884
22881
 
22885
22882
  // get color
22886
22883
  let color = textureLoad(splatColor, splatUV, 0);
22884
+ if (color.a < 1.0 / 255.0) {
22885
+ o.member = discardVec;
22886
+ o.vColor = vec4f(0.0);
22887
+ o.vTexCoord = vec2f(0.0);
22888
+ return o;
22889
+ }
22887
22890
 
22888
22891
  // calculate scale based on alpha
22889
22892
  let scale = min(1.0, sqrt(-log(1.0 / 255.0 / color.a)) / 2.0);
@@ -22892,7 +22895,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22892
22895
  let visBoost = materialUniform.tex_params.w;
22893
22896
  var v1v2_scaled = v1v2 * scale * visBoost;
22894
22897
 
22895
- // Pixel coverage culling (min and max thresholds)
22898
+ // Pixel coverage culling
22896
22899
  let v1_len_sq = dot(v1v2_scaled.xy, v1v2_scaled.xy);
22897
22900
  let v2_len_sq = dot(v1v2_scaled.zw, v1v2_scaled.zw);
22898
22901
 
@@ -22900,7 +22903,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22900
22903
  let maxPixels = materialUniform.pixelCull.y;
22901
22904
  let maxPixelCullDistance = materialUniform.pixelCull.z;
22902
22905
 
22903
- // Early out tiny splats (below minimum pixel coverage)
22906
+ // Early out tiny splats
22904
22907
  if (v1_len_sq < minPixels && v2_len_sq < minPixels) {
22905
22908
  o.member = discardVec;
22906
22909
  o.vColor = vec4f(0.0);
@@ -22908,13 +22911,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22908
22911
  return o;
22909
22912
  }
22910
22913
 
22911
- // Cull oversized splats (above maximum pixel coverage)
22912
- // Only apply to splats close to camera (distance-based condition)
22914
+ // Cull oversized splats
22913
22915
  if (maxPixels > 0.0) {
22914
- // Calculate distance from splat to camera
22915
22916
  let splatDistance = length(splat_cam.xyz);
22916
-
22917
- // Only cull oversized splats if they are close to camera
22918
22917
  if (maxPixelCullDistance <= 0.0 || splatDistance < maxPixelCullDistance) {
22919
22918
  let maxAxisSq = maxPixels * maxPixels;
22920
22919
  if (v1_len_sq > maxAxisSq || v2_len_sq > maxAxisSq) {
@@ -22926,12 +22925,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22926
22925
  }
22927
22926
  }
22928
22927
 
22929
- // gl_Position = splat_proj + vec4((vertex_position.x * v1v2.xy + vertex_position.y * v1v2.zw) / viewport * splat_proj.w, 0, 0);
22928
+ // Final position
22930
22929
  o.member = splat_proj + vec4f((vertex_pos.x * v1v2_scaled.xy + vertex_pos.y * v1v2_scaled.zw) / viewport * splat_proj.w, 0.0, 0.0);
22931
-
22932
- // texCoord = vertex_position.xy * scale / 2.0;
22933
22930
  o.vTexCoord = vertex_pos * scale / 2.0;
22934
-
22935
22931
  o.vColor = color;
22936
22932
 
22937
22933
  return o;
@@ -22946,49 +22942,279 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22946
22942
  // === evalSplat() - like PlayCanvas splatCoreFS ===
22947
22943
  fn evalSplat(texCoord: vec2f, color: vec4f) -> vec4f {
22948
22944
  let A = dot(texCoord, texCoord);
22945
+ var B = exp(-A * 4.0) * color.a;
22949
22946
  if (A > 1.0) {
22950
- discard;
22947
+ B = 0.0;
22951
22948
  }
22952
22949
 
22953
- let B = exp(-A * 4.0) * color.a;
22954
22950
  if (B < 1.0 / 255.0) {
22955
- discard;
22951
+ B = 0.0;
22956
22952
  }
22957
22953
 
22958
- // TONEMAP_ENABLED branch not implemented (would call toneMap() and gammaCorrectOutput())
22959
22954
  return vec4f(color.rgb, B);
22960
22955
  }
22961
-
22962
- // === main() - like PlayCanvas splatMainFS ===
22956
+
22963
22957
  @fragment
22964
- fn FragMain(@location(auto) vColor: vec4f, @location(auto) vTexCoord: vec2f) -> FragmentOutput {
22965
- let result = evalSplat(vTexCoord, vColor);
22966
-
22958
+ fn FragMain(
22959
+ @location(0) vColor: vec4<f32>,
22960
+ @location(1) vTexCoord: vec2<f32>
22961
+ ) -> FragmentOutput {
22967
22962
  var o: FragmentOutput;
22968
- o.color = result;
22969
- o.gBuffer = vec4f(0.0);
22963
+ o.color = evalSplat(vTexCoord, vColor);
22970
22964
  return o;
22971
22965
  }
22972
22966
  `
22973
22967
  );
22974
22968
 
22975
- class GSplatMaterial extends Material {
22969
+ class Shader {
22970
+ computes;
22971
+ passShader;
22972
+ constructor() {
22973
+ this.computes = [];
22974
+ this.passShader = /* @__PURE__ */ new Map();
22975
+ }
22976
+ addRenderPass(renderShader, index = -1) {
22977
+ let subShader = this.passShader.get(renderShader.passType) || [];
22978
+ if (index == -1) {
22979
+ subShader.push(renderShader);
22980
+ } else {
22981
+ subShader.splice(index, -1, renderShader);
22982
+ }
22983
+ this.passShader.set(renderShader.passType, subShader);
22984
+ }
22985
+ removeShader(renderShader, index = -1) {
22986
+ let subShader = this.passShader.get(
22987
+ renderShader.passType
22988
+ );
22989
+ if (subShader) {
22990
+ if (index == -1) {
22991
+ let index2 = subShader.indexOf(renderShader);
22992
+ if (index2 != -1) {
22993
+ subShader.splice(index2);
22994
+ }
22995
+ } else {
22996
+ subShader.splice(index, 1);
22997
+ }
22998
+ }
22999
+ }
23000
+ removeShaderByIndex(passType, index = -1) {
23001
+ let subShader = this.passShader.get(passType);
23002
+ if (subShader) {
23003
+ if (index == -1) {
23004
+ this.passShader.delete(passType);
23005
+ } else {
23006
+ subShader.splice(index, 1);
23007
+ }
23008
+ }
23009
+ }
23010
+ getSubShaders(passType) {
23011
+ return this.passShader.get(passType) || [];
23012
+ }
23013
+ hasSubShaders(passType) {
23014
+ let subs = this.passShader.get(passType);
23015
+ return subs.length > 0;
23016
+ }
23017
+ getDefaultShaders() {
23018
+ return this.passShader.get(PassType.COLOR);
23019
+ }
23020
+ getDefaultColorShader() {
23021
+ return this.passShader.get(PassType.COLOR)[0];
23022
+ }
23023
+ setDefine(arg0, arg1) {
23024
+ for (const pass of this.passShader) {
23025
+ for (const rd of pass[1]) {
23026
+ rd.setDefine(arg0, arg1);
23027
+ }
23028
+ }
23029
+ }
23030
+ hasDefine(arg0) {
23031
+ for (const pass of this.passShader) {
23032
+ for (const rd of pass[1]) {
23033
+ let has = rd.hasDefine(arg0);
23034
+ if (has) return has;
23035
+ }
23036
+ }
23037
+ return false;
23038
+ }
23039
+ deleteDefine(arg0) {
23040
+ for (const pass of this.passShader) {
23041
+ for (const rd of pass[1]) {
23042
+ rd.deleteDefine(arg0);
23043
+ }
23044
+ }
23045
+ }
23046
+ setUniform(arg0, arg1) {
23047
+ for (const pass of this.passShader) {
23048
+ for (const rd of pass[1]) {
23049
+ rd.setUniform(arg0, arg1);
23050
+ }
23051
+ }
23052
+ }
23053
+ setUniformFloat(arg0, arg1) {
23054
+ for (const pass of this.passShader) {
23055
+ for (const rd of pass[1]) {
23056
+ rd.setUniformFloat(arg0, arg1);
23057
+ }
23058
+ }
23059
+ }
23060
+ setUniformVector2(arg0, arg1) {
23061
+ for (const pass of this.passShader) {
23062
+ for (const rd of pass[1]) {
23063
+ rd.setUniformVector2(arg0, arg1);
23064
+ }
23065
+ }
23066
+ }
23067
+ setUniformVector3(arg0, arg1) {
23068
+ for (const pass of this.passShader) {
23069
+ for (const rd of pass[1]) {
23070
+ rd.setUniformVector3(arg0, arg1);
23071
+ }
23072
+ }
23073
+ }
23074
+ setUniformVector4(arg0, arg1) {
23075
+ for (const pass of this.passShader) {
23076
+ for (const rd of pass[1]) {
23077
+ rd.setUniformVector4(arg0, arg1);
23078
+ }
23079
+ }
23080
+ }
23081
+ setUniformColor(arg0, arg1) {
23082
+ for (const pass of this.passShader) {
23083
+ for (const rd of pass[1]) {
23084
+ rd.setUniformColor(arg0, arg1);
23085
+ }
23086
+ }
23087
+ }
23088
+ getUniform(arg0) {
23089
+ return this.getDefaultColorShader().getUniform(arg0);
23090
+ }
23091
+ getUniformFloat(arg0) {
23092
+ return this.getDefaultColorShader().getUniformFloat(arg0);
23093
+ }
23094
+ getUniformVector2(arg0) {
23095
+ return this.getDefaultColorShader().getUniformVector2(arg0);
23096
+ }
23097
+ getUniformVector3(arg0) {
23098
+ return this.getDefaultColorShader().getUniformVector3(arg0);
23099
+ }
23100
+ getUniformVector4(arg0) {
23101
+ return this.getDefaultColorShader().getUniformVector4(arg0);
23102
+ }
23103
+ getUniformColor(arg0) {
23104
+ return this.getDefaultColorShader().getUniformColor(arg0);
23105
+ }
23106
+ setTexture(arg0, arg1) {
23107
+ for (const pass of this.passShader) {
23108
+ for (const rd of pass[1]) {
23109
+ rd.setTexture(arg0, arg1);
23110
+ }
23111
+ }
23112
+ this.setDefine(`USE_${arg0.toLocaleUpperCase()}`, true);
23113
+ }
23114
+ getTexture(arg0) {
23115
+ return this.getDefaultColorShader().textures[arg0];
23116
+ }
23117
+ setUniformBuffer(arg0, arg1) {
23118
+ for (const pass of this.passShader) {
23119
+ for (const rd of pass[1]) {
23120
+ rd.setUniformBuffer(arg0, arg1);
23121
+ }
23122
+ }
23123
+ }
23124
+ getUniformBuffer(arg0) {
23125
+ return this.getDefaultColorShader().getBuffer(arg0);
23126
+ }
23127
+ setStorageBuffer(arg0, arg1) {
23128
+ for (const pass of this.passShader) {
23129
+ for (const rd of pass[1]) {
23130
+ rd.setStorageBuffer(arg0, arg1);
23131
+ }
23132
+ }
23133
+ }
23134
+ getStorageBuffer(arg0) {
23135
+ return this.getDefaultColorShader().getBuffer(arg0);
23136
+ }
23137
+ setStructStorageBuffer(arg0, arg1) {
23138
+ for (const pass of this.passShader) {
23139
+ for (const rd of pass[1]) {
23140
+ rd.setStructStorageBuffer(arg0, arg1);
23141
+ }
23142
+ }
23143
+ }
23144
+ getStructStorageBuffer(arg0) {
23145
+ return this.getDefaultColorShader().getBuffer(arg0);
23146
+ }
23147
+ noticeValueChange() {
23148
+ for (const pass of this.passShader) {
23149
+ for (const rd of pass[1]) {
23150
+ rd.noticeValueChange();
23151
+ }
23152
+ }
23153
+ }
23154
+ destroy() {
23155
+ this.getDefaultColorShader().destroy();
23156
+ }
23157
+ clone() {
23158
+ let newShader = new Shader();
23159
+ let sourceShaderPassList = this.getDefaultShaders();
23160
+ for (const shadePass of sourceShaderPassList) {
23161
+ newShader.addRenderPass(shadePass);
23162
+ }
23163
+ return newShader;
23164
+ }
23165
+ applyUniform() {
23166
+ for (const pass of this.passShader) {
23167
+ for (const rd of pass[1]) {
23168
+ rd.applyUniform();
23169
+ }
23170
+ }
23171
+ }
23172
+ }
23173
+
23174
+ var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
23175
+ var __decorateClass$k = (decorators, target, key, kind) => {
23176
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
23177
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
23178
+ if (decorator = decorators[i])
23179
+ result = (decorator(result)) || result;
23180
+ return result;
23181
+ };
23182
+ exports.GSplatShader = class GSplatShader extends Shader {
22976
23183
  constructor() {
22977
23184
  super();
22978
- ShaderLib.register("gsplat_vs_dc", GSplat_VS);
22979
- ShaderLib.register("gsplat_fs_dc", GSplat_FS);
22980
23185
  const pass = new RenderShaderPass("gsplat_vs_dc", "gsplat_fs_dc");
22981
23186
  pass.passType = PassType.COLOR;
22982
23187
  pass.setShaderEntry("VertMain", "FragMain");
22983
- pass.topology = GPUPrimitiveTopology.triangle_strip;
23188
+ pass.topology = GPUPrimitiveTopology.triangle_list;
22984
23189
  pass.depthWriteEnabled = false;
22985
- pass.cullMode = "none";
23190
+ pass.cullMode = GPUCullMode.none;
22986
23191
  pass.shaderState.transparent = true;
22987
23192
  pass.shaderState.blendMode = BlendMode.NORMAL;
22988
23193
  pass.shaderState.writeMasks = [15, 15];
22989
- const shader = new Shader();
22990
- shader.addRenderPass(pass);
22991
- this.shader = shader;
23194
+ this.addRenderPass(pass);
23195
+ this.setDefault();
23196
+ }
23197
+ /**
23198
+ * Set default uniform values
23199
+ */
23200
+ setDefault() {
23201
+ const pass = this.getDefaultColorShader();
23202
+ const identityMatrix = new Matrix4();
23203
+ pass.setUniform("modelMatrix", identityMatrix.rawData);
23204
+ pass.setUniform("pixelCull", new Float32Array([2, 0, 0, 0]));
23205
+ }
23206
+ };
23207
+ exports.GSplatShader = __decorateClass$k([
23208
+ RegisterShader(exports.GSplatShader, "GSplatShader")
23209
+ ], exports.GSplatShader);
23210
+
23211
+ class GSplatMaterial extends Material {
23212
+ _pixelCullArray = new Float32Array(4);
23213
+ constructor() {
23214
+ super();
23215
+ ShaderLib.register("gsplat_vs_dc", GSplat_VS);
23216
+ ShaderLib.register("gsplat_fs_dc", GSplat_FS);
23217
+ this.shader = new exports.GSplatShader();
22992
23218
  }
22993
23219
  setSplatTextures(splatColor, transformA, transformB, texParams, splatOrder) {
22994
23220
  const pass = this.shader.getDefaultColorShader();
@@ -22999,6 +23225,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
22999
23225
  if (splatOrder) {
23000
23226
  pass.setTexture("splatOrder", splatOrder);
23001
23227
  }
23228
+ pass.shaderState.depthCompare = GPUCompareFunction.less;
23002
23229
  }
23003
23230
  /**
23004
23231
  * Set the model matrix for transforming splats to world space
@@ -23013,9 +23240,13 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
23013
23240
  * @param maxPixels Maximum pixel coverage (cull oversized splats), default: 0 (disabled)
23014
23241
  * @param maxPixelCullDistance Only cull oversized splats within this distance, 0 = always cull
23015
23242
  */
23016
- setPixelCulling(minPixels, maxPixels, maxPixelCullDistance = 0) {
23243
+ setPixelCulling(minPixels, maxPixels, maxPixelCullDistance = 0, batchSize = 128) {
23244
+ this._pixelCullArray[0] = minPixels;
23245
+ this._pixelCullArray[1] = maxPixels;
23246
+ this._pixelCullArray[2] = maxPixelCullDistance;
23247
+ this._pixelCullArray[3] = batchSize;
23017
23248
  const pass = this.shader.getDefaultColorShader();
23018
- pass.setUniform("pixelCull", new Float32Array([minPixels, maxPixels, maxPixelCullDistance, 0]));
23249
+ pass.setUniform("pixelCull", this._pixelCullArray);
23019
23250
  }
23020
23251
  }
23021
23252
 
@@ -23673,108 +23904,47 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
23673
23904
  }
23674
23905
  }
23675
23906
 
23676
- class PlaneGeometry extends GeometryBase {
23677
- width;
23678
- height;
23679
- segmentW;
23680
- segmentH;
23681
- up;
23682
- constructor(width, height, segmentW = 1, segmentH = 1, up = Vector3.Y_AXIS) {
23907
+ class GSplatGeometry extends GeometryBase {
23908
+ batchSize;
23909
+ constructor(batchSize = 128) {
23683
23910
  super();
23684
- this.width = width;
23685
- this.height = height;
23686
- this.segmentW = segmentW;
23687
- this.segmentH = segmentH;
23688
- this.up = up;
23689
- this.buildGeometry(this.up);
23690
- }
23691
- buildGeometry(axis) {
23692
- var x, y;
23693
- var numIndices;
23694
- var base;
23695
- var tw = this.segmentW + 1;
23696
- (this.segmentH + 1) * tw;
23697
- this.bounds = new BoundingBox(
23698
- Vector3.ZERO.clone(),
23699
- new Vector3(this.width, 1, this.height)
23700
- );
23701
- numIndices = this.segmentH * this.segmentW * 6;
23702
- let vertexCount = (this.segmentW + 1) * (this.segmentH + 1);
23703
- let position_arr = new Float32Array(vertexCount * 3);
23704
- let normal_arr = new Float32Array(vertexCount * 3);
23705
- let uv_arr = new Float32Array(vertexCount * 2);
23706
- let indices_arr;
23707
- let totalIndexCount = this.segmentW * this.segmentH * 2 * 3;
23708
- if (totalIndexCount >= Uint16Array.length) {
23709
- indices_arr = new Uint32Array(this.segmentW * this.segmentH * 2 * 3);
23710
- } else {
23711
- indices_arr = new Uint16Array(this.segmentW * this.segmentH * 2 * 3);
23712
- }
23713
- numIndices = 0;
23714
- var indexP = 0;
23715
- var indexN = 0;
23716
- var indexU = 0;
23717
- for (var yi = 0; yi <= this.segmentH; ++yi) {
23718
- for (var xi = 0; xi <= this.segmentW; ++xi) {
23719
- x = (xi / this.segmentW - 0.5) * this.width;
23720
- y = (yi / this.segmentH - 0.5) * this.height;
23721
- switch (axis) {
23722
- case Vector3.Y_AXIS:
23723
- position_arr[indexP++] = x;
23724
- position_arr[indexP++] = 0;
23725
- position_arr[indexP++] = y;
23726
- normal_arr[indexN++] = 0;
23727
- normal_arr[indexN++] = 1;
23728
- normal_arr[indexN++] = 0;
23729
- break;
23730
- case Vector3.Z_AXIS:
23731
- position_arr[indexP++] = x;
23732
- position_arr[indexP++] = -y;
23733
- position_arr[indexP++] = 0;
23734
- normal_arr[indexN++] = 0;
23735
- normal_arr[indexN++] = 0;
23736
- normal_arr[indexN++] = 1;
23737
- break;
23738
- case Vector3.X_AXIS:
23739
- position_arr[indexP++] = 0;
23740
- position_arr[indexP++] = x;
23741
- position_arr[indexP++] = y;
23742
- normal_arr[indexN++] = 1;
23743
- normal_arr[indexN++] = 0;
23744
- normal_arr[indexN++] = 0;
23745
- break;
23746
- default:
23747
- position_arr[indexP++] = x;
23748
- position_arr[indexP++] = 0;
23749
- position_arr[indexP++] = y;
23750
- normal_arr[indexN++] = 0;
23751
- normal_arr[indexN++] = 1;
23752
- normal_arr[indexN++] = 0;
23753
- break;
23754
- }
23755
- uv_arr[indexU++] = xi / this.segmentW;
23756
- uv_arr[indexU++] = yi / this.segmentH;
23757
- if (xi != this.segmentW && yi != this.segmentH) {
23758
- base = xi + yi * tw;
23759
- indices_arr[numIndices++] = base + 1;
23760
- indices_arr[numIndices++] = base;
23761
- indices_arr[numIndices++] = base + tw;
23762
- indices_arr[numIndices++] = base + 1;
23763
- indices_arr[numIndices++] = base + tw;
23764
- indices_arr[numIndices++] = base + tw + 1;
23765
- }
23766
- }
23767
- }
23768
- this.setIndices(indices_arr);
23769
- this.setAttribute(VertexAttributeName.position, position_arr);
23770
- this.setAttribute(VertexAttributeName.normal, normal_arr);
23771
- this.setAttribute(VertexAttributeName.uv, uv_arr);
23772
- this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
23911
+ this.batchSize = batchSize;
23912
+ const meshPositions = new Float32Array(12 * batchSize);
23913
+ for (let i = 0; i < batchSize; ++i) {
23914
+ meshPositions.set([
23915
+ -2,
23916
+ -2,
23917
+ i,
23918
+ 2,
23919
+ -2,
23920
+ i,
23921
+ 2,
23922
+ 2,
23923
+ i,
23924
+ -2,
23925
+ 2,
23926
+ i
23927
+ ], i * 12);
23928
+ }
23929
+ const meshIndices = new Uint32Array(6 * batchSize);
23930
+ for (let i = 0; i < batchSize; ++i) {
23931
+ const b = i * 4;
23932
+ meshIndices.set([
23933
+ 0 + b,
23934
+ 1 + b,
23935
+ 2 + b,
23936
+ 0 + b,
23937
+ 2 + b,
23938
+ 3 + b
23939
+ ], i * 6);
23940
+ }
23941
+ this.setAttribute(VertexAttributeName.position, meshPositions);
23942
+ this.setIndices(meshIndices);
23773
23943
  this.addSubGeometry({
23774
23944
  indexStart: 0,
23775
- indexCount: indices_arr.length,
23945
+ indexCount: meshIndices.length,
23776
23946
  vertexStart: 0,
23777
- vertexCount: 0,
23947
+ vertexCount: meshPositions.length / 3,
23778
23948
  firstStart: 0,
23779
23949
  index: 0,
23780
23950
  topology: 0
@@ -23878,18 +24048,49 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
23878
24048
  updateTexture(width, height, data) {
23879
24049
  let device = webGPUContext.device;
23880
24050
  const bytesPerRow = width * 4 * 4;
23881
- const staging = device.createBuffer({
24051
+ device.queue.writeTexture(
24052
+ { texture: this.getGPUTexture() },
24053
+ data.buffer,
24054
+ { bytesPerRow },
24055
+ { width, height, depthOrArrayLayers: 1 }
24056
+ );
24057
+ }
24058
+ }
24059
+
24060
+ class R32UintTexture extends Texture {
24061
+ _dataBuffer;
24062
+ create(width, height, data) {
24063
+ let device = webGPUContext.device;
24064
+ const bytesPerRow = width * 4;
24065
+ this.format = GPUTextureFormat.r32uint;
24066
+ const mipmapCount = 1;
24067
+ this.createTextureDescriptor(width, height, mipmapCount, this.format);
24068
+ const textureDataBuffer = this._dataBuffer = device.createBuffer({
23882
24069
  size: data.byteLength,
23883
24070
  usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
23884
24071
  });
23885
- device.queue.writeBuffer(staging, 0, data.buffer);
24072
+ device.queue.writeBuffer(textureDataBuffer, 0, data.buffer);
23886
24073
  const encoder = device.createCommandEncoder();
23887
24074
  encoder.copyBufferToTexture(
23888
- { buffer: staging, bytesPerRow },
24075
+ { buffer: textureDataBuffer, bytesPerRow },
23889
24076
  { texture: this.getGPUTexture() },
23890
24077
  { width, height, depthOrArrayLayers: 1 }
23891
24078
  );
23892
24079
  device.queue.submit([encoder.finish()]);
24080
+ this.samplerBindingLayout.type = `non-filtering`;
24081
+ this.textureBindingLayout.sampleType = `uint`;
24082
+ this.gpuSampler = device.createSampler({});
24083
+ return this;
24084
+ }
24085
+ updateTexture(width, height, data) {
24086
+ let device = webGPUContext.device;
24087
+ const bytesPerRow = width * 4;
24088
+ device.queue.writeTexture(
24089
+ { texture: this.getGPUTexture() },
24090
+ data.buffer,
24091
+ { bytesPerRow },
24092
+ { width, height, depthOrArrayLayers: 1 }
24093
+ );
23893
24094
  }
23894
24095
  }
23895
24096
 
@@ -23997,9 +24198,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
23997
24198
  }
23998
24199
  }
23999
24200
 
24000
- var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
24001
- var __decorateClass$h = (decorators, target, key, kind) => {
24002
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
24201
+ var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
24202
+ var __decorateClass$j = (decorators, target, key, kind) => {
24203
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
24003
24204
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
24004
24205
  if (decorator = decorators[i])
24005
24206
  result = (decorator(result)) || result;
@@ -24031,14 +24232,15 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24031
24232
  // Web Worker for sorting
24032
24233
  _sortWorker;
24033
24234
  _lastSentTime = 0;
24034
- _minIntervalMs = 0;
24035
- // No throttle for immediate sorting
24235
+ _minIntervalMs = 16;
24036
24236
  _centersSent = false;
24037
24237
  _lastViewMatrixHash = 0;
24038
24238
  // Adaptive sorting optimization
24039
24239
  _lastCameraSpeed = 0;
24040
24240
  _adaptiveSorting = true;
24041
24241
  // Enable adaptive sorting by default
24242
+ _lastPixelCullParams = "";
24243
+ _texturesInitialized = false;
24042
24244
  // LOD (Level of Detail) system
24043
24245
  _lodEnabled = false;
24044
24246
  _lodDistances = [5, 10, 20, 40];
@@ -24060,6 +24262,11 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24060
24262
  get fullCount() {
24061
24263
  return this._fullCount;
24062
24264
  }
24265
+ // Batched rendering
24266
+ _batchSize = 128;
24267
+ // Splats per draw call
24268
+ instanceCount = 0;
24269
+ // For InstanceDrawComponent compatibility
24063
24270
  constructor() {
24064
24271
  super();
24065
24272
  }
@@ -24075,24 +24282,20 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24075
24282
  this.texParams = new Float32Array([this.count, this.size.x, this.count, 1]);
24076
24283
  this._positions = asset.position;
24077
24284
  const total = this.size.x * this.size.y;
24078
- this._orderData = new Uint32Array(total * 4);
24285
+ this._orderData = new Uint32Array(total);
24079
24286
  for (let i = 0; i < total; i++) {
24080
- const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
24081
- const base = i * 4;
24082
- this._orderData[base + 0] = src;
24083
- this._orderData[base + 1] = 0;
24084
- this._orderData[base + 2] = 0;
24085
- this._orderData[base + 3] = 0;
24086
- }
24087
- this.splatOrder = new Uint32ArrayTexture().create(this.size.x, this.size.y, this._orderData);
24287
+ this._orderData[i] = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
24288
+ }
24289
+ this.splatOrder = new R32UintTexture().create(this.size.x, this.size.y, this._orderData);
24088
24290
  this.splatOrder.name = "splatOrder";
24089
24291
  this.splatOrder.minFilter = "nearest";
24090
24292
  this.splatOrder.magFilter = "nearest";
24091
24293
  this.splatOrder.addressModeU = "clamp-to-edge";
24092
24294
  this.splatOrder.addressModeV = "clamp-to-edge";
24093
24295
  this.gsplatMaterial = new GSplatMaterial();
24094
- this.geometry = new PlaneGeometry(1, 1, 1, 1);
24296
+ this.geometry = new GSplatGeometry(this._batchSize);
24095
24297
  this.materials = [this.gsplatMaterial];
24298
+ this.instanceCount = 0;
24096
24299
  }
24097
24300
  /**
24098
24301
  * Update splat sorting before rendering
@@ -24169,12 +24372,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24169
24372
  this.texParams[2] = Math.min(this.texParams[0], this.count);
24170
24373
  const total = this.size.x * this.size.y;
24171
24374
  for (let i = 0; i < total; i++) {
24172
- const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
24173
- const base = i * 4;
24174
- this._orderData[base + 0] = src;
24175
- this._orderData[base + 1] = 0;
24176
- this._orderData[base + 2] = 0;
24177
- this._orderData[base + 3] = 0;
24375
+ this._orderData[i] = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
24178
24376
  }
24179
24377
  this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
24180
24378
  if (this._sortWorker) {
@@ -24201,6 +24399,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24201
24399
  } else {
24202
24400
  this._centersSent = false;
24203
24401
  }
24402
+ this.instanceCount = 0;
24204
24403
  }
24205
24404
  /**
24206
24405
  * Set visibility boost factor (material uniform tex_params.w)
@@ -24264,6 +24463,18 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24264
24463
  distanceEnabled: this._maxPixelCullDistance > 0
24265
24464
  };
24266
24465
  }
24466
+ /**
24467
+ * Get batching statistics
24468
+ */
24469
+ getBatchingStats() {
24470
+ return {
24471
+ enabled: true,
24472
+ batchSize: this._batchSize,
24473
+ instanceCount: this.instanceCount,
24474
+ splatCount: this.count,
24475
+ reduction: this.count > 0 ? (1 - this.instanceCount / this.count) * 100 : 0
24476
+ };
24477
+ }
24267
24478
  /**
24268
24479
  * Calculate texture size for given splat count
24269
24480
  */
@@ -24486,18 +24697,20 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24486
24697
  const indices = new Uint32Array(newOrder);
24487
24698
  const total = this.size.x * this.size.y;
24488
24699
  const count = this.count;
24489
- this._orderData = new Uint32Array(total * 4);
24490
- for (let i = 0; i < total; i++) {
24491
- const src = i < count ? indices[i] : count > 0 ? count - 1 : 0;
24492
- const base = i * 4;
24493
- this._orderData[base + 0] = src;
24494
- this._orderData[base + 1] = 0;
24495
- this._orderData[base + 2] = 0;
24496
- this._orderData[base + 3] = 0;
24700
+ if (!this._orderData || this._orderData.length !== total) {
24701
+ this._orderData = new Uint32Array(total);
24702
+ }
24703
+ const validCount = Math.min(count, indices.length);
24704
+ this._orderData.set(indices.subarray(0, validCount), 0);
24705
+ if (validCount < total) {
24706
+ const lastIndex = count > 0 ? count - 1 : 0;
24707
+ this._orderData.fill(lastIndex, validCount, total);
24497
24708
  }
24498
24709
  this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
24499
24710
  const valid = Math.max(0, Math.min(this.count, ev.data.count | 0));
24500
24711
  this.texParams[2] = valid;
24712
+ const newInstanceCount = Math.ceil(valid / this._batchSize);
24713
+ this.instanceCount = newInstanceCount;
24501
24714
  };
24502
24715
  const worldPos = this._worldPositions || this._positions;
24503
24716
  const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
@@ -24700,30 +24913,22 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24700
24913
  nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
24701
24914
  const worldMatrix = this.object3D.transform.worldMatrix;
24702
24915
  this.gsplatMaterial.setTransformMatrix(worldMatrix);
24703
- this.gsplatMaterial.setPixelCulling(this._minPixelCoverage, this._maxPixelCoverage, this._maxPixelCullDistance);
24704
- this.gsplatMaterial.setSplatTextures(
24705
- this.splatColor,
24706
- this.transformA,
24707
- this.transformB,
24708
- this.texParams,
24709
- this.splatOrder
24710
- );
24711
- super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
24712
- }
24713
- /**
24714
- * Render pass
24715
- */
24716
- renderPass2(view, passType, rendererPassState, clusterLightingBuffer, encoder, useBundle = false) {
24717
- for (let mat of this.materials) {
24718
- const passes = mat.getPass(passType);
24719
- if (!passes || passes.length === 0) continue;
24720
- for (const pass of passes) {
24721
- if (!pass.pipeline) continue;
24722
- pass.apply(this.geometry, rendererPassState);
24723
- GPUContext.bindPipeline(encoder, pass);
24724
- GPUContext.draw(encoder, 4, this.count, 0, 0);
24725
- }
24916
+ const currentParams = `${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;
24917
+ if (currentParams !== this._lastPixelCullParams) {
24918
+ this.gsplatMaterial.setPixelCulling(this._minPixelCoverage, this._maxPixelCoverage, this._maxPixelCullDistance, this._batchSize);
24919
+ this._lastPixelCullParams = currentParams;
24920
+ }
24921
+ if (!this._texturesInitialized) {
24922
+ this.gsplatMaterial.setSplatTextures(
24923
+ this.splatColor,
24924
+ this.transformA,
24925
+ this.transformB,
24926
+ this.texParams,
24927
+ this.splatOrder
24928
+ );
24929
+ this._texturesInitialized = true;
24726
24930
  }
24931
+ super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
24727
24932
  }
24728
24933
  /**
24729
24934
  * Render pass (fallback)
@@ -24737,7 +24942,28 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24737
24942
  if (!pass.pipeline) continue;
24738
24943
  pass.apply(this.geometry, renderContext.rendererPassState || renderContext);
24739
24944
  GPUContext.bindPipeline(encoder, pass);
24740
- GPUContext.draw(encoder, 4, this.count, 0, 0);
24945
+ GPUContext.bindGeometryBuffer(encoder, this.geometry);
24946
+ const subGeometry = this.geometry.subGeometries[0];
24947
+ const lodInfo = subGeometry.lodLevels[0];
24948
+ if (this.instanceCount > 0) {
24949
+ GPUContext.drawIndexed(
24950
+ encoder,
24951
+ lodInfo.indexCount,
24952
+ this.instanceCount,
24953
+ lodInfo.indexStart,
24954
+ 0,
24955
+ 0
24956
+ );
24957
+ } else {
24958
+ GPUContext.drawIndexed(
24959
+ encoder,
24960
+ lodInfo.indexCount,
24961
+ 1,
24962
+ lodInfo.indexStart,
24963
+ 0,
24964
+ 0
24965
+ );
24966
+ }
24741
24967
  }
24742
24968
  }
24743
24969
  }
@@ -24752,7 +24978,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
24752
24978
  super.destroy(force);
24753
24979
  }
24754
24980
  };
24755
- exports.GSplatRenderer = __decorateClass$h([
24981
+ exports.GSplatRenderer = __decorateClass$j([
24756
24982
  RegisterComponent(exports.GSplatRenderer, "GSplatRenderer")
24757
24983
  ], exports.GSplatRenderer);
24758
24984
 
@@ -25063,9 +25289,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
25063
25289
  }
25064
25290
  }
25065
25291
 
25066
- var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
25067
- var __decorateClass$g = (decorators, target, key, kind) => {
25068
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
25292
+ var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
25293
+ var __decorateClass$i = (decorators, target, key, kind) => {
25294
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
25069
25295
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
25070
25296
  if (decorator = decorators[i])
25071
25297
  result = (decorator(result)) || result;
@@ -25330,7 +25556,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
25330
25556
  super.destroy(force);
25331
25557
  }
25332
25558
  };
25333
- exports.Object3D = __decorateClass$g([
25559
+ exports.Object3D = __decorateClass$i([
25334
25560
  DecorateObject3D
25335
25561
  ], exports.Object3D);
25336
25562
  function DecorateObject3D(ctor, _) {
@@ -26659,9 +26885,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
26659
26885
  }
26660
26886
 
26661
26887
  var __defProp = Object.defineProperty;
26662
- var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
26663
- var __decorateClass$f = (decorators, target, key, kind) => {
26664
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
26888
+ var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
26889
+ var __decorateClass$h = (decorators, target, key, kind) => {
26890
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
26665
26891
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
26666
26892
  if (decorator = decorators[i])
26667
26893
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
@@ -26770,13 +26996,13 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
26770
26996
  super.destroy(force);
26771
26997
  }
26772
26998
  };
26773
- __decorateClass$f([
26999
+ __decorateClass$h([
26774
27000
  EditorInspector
26775
27001
  ], exports.MeshRenderer.prototype, "geometry", 1);
26776
- __decorateClass$f([
27002
+ __decorateClass$h([
26777
27003
  EditorInspector
26778
27004
  ], exports.MeshRenderer.prototype, "material", 1);
26779
- exports.MeshRenderer = __decorateClass$f([
27005
+ exports.MeshRenderer = __decorateClass$h([
26780
27006
  RegisterComponent(exports.MeshRenderer, "MeshRenderer")
26781
27007
  ], exports.MeshRenderer);
26782
27008
 
@@ -27273,9 +27499,118 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
27273
27499
  }
27274
27500
  }
27275
27501
 
27276
- var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
27277
- var __decorateClass$e = (decorators, target, key, kind) => {
27278
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
27502
+ class PlaneGeometry extends GeometryBase {
27503
+ width;
27504
+ height;
27505
+ segmentW;
27506
+ segmentH;
27507
+ up;
27508
+ constructor(width, height, segmentW = 1, segmentH = 1, up = Vector3.Y_AXIS) {
27509
+ super();
27510
+ this.width = width;
27511
+ this.height = height;
27512
+ this.segmentW = segmentW;
27513
+ this.segmentH = segmentH;
27514
+ this.up = up;
27515
+ this.buildGeometry(this.up);
27516
+ }
27517
+ buildGeometry(axis) {
27518
+ var x, y;
27519
+ var numIndices;
27520
+ var base;
27521
+ var tw = this.segmentW + 1;
27522
+ (this.segmentH + 1) * tw;
27523
+ this.bounds = new BoundingBox(
27524
+ Vector3.ZERO.clone(),
27525
+ new Vector3(this.width, 1, this.height)
27526
+ );
27527
+ numIndices = this.segmentH * this.segmentW * 6;
27528
+ let vertexCount = (this.segmentW + 1) * (this.segmentH + 1);
27529
+ let position_arr = new Float32Array(vertexCount * 3);
27530
+ let normal_arr = new Float32Array(vertexCount * 3);
27531
+ let uv_arr = new Float32Array(vertexCount * 2);
27532
+ let indices_arr;
27533
+ let totalIndexCount = this.segmentW * this.segmentH * 2 * 3;
27534
+ if (totalIndexCount >= Uint16Array.length) {
27535
+ indices_arr = new Uint32Array(this.segmentW * this.segmentH * 2 * 3);
27536
+ } else {
27537
+ indices_arr = new Uint16Array(this.segmentW * this.segmentH * 2 * 3);
27538
+ }
27539
+ numIndices = 0;
27540
+ var indexP = 0;
27541
+ var indexN = 0;
27542
+ var indexU = 0;
27543
+ for (var yi = 0; yi <= this.segmentH; ++yi) {
27544
+ for (var xi = 0; xi <= this.segmentW; ++xi) {
27545
+ x = (xi / this.segmentW - 0.5) * this.width;
27546
+ y = (yi / this.segmentH - 0.5) * this.height;
27547
+ switch (axis) {
27548
+ case Vector3.Y_AXIS:
27549
+ position_arr[indexP++] = x;
27550
+ position_arr[indexP++] = 0;
27551
+ position_arr[indexP++] = y;
27552
+ normal_arr[indexN++] = 0;
27553
+ normal_arr[indexN++] = 1;
27554
+ normal_arr[indexN++] = 0;
27555
+ break;
27556
+ case Vector3.Z_AXIS:
27557
+ position_arr[indexP++] = x;
27558
+ position_arr[indexP++] = -y;
27559
+ position_arr[indexP++] = 0;
27560
+ normal_arr[indexN++] = 0;
27561
+ normal_arr[indexN++] = 0;
27562
+ normal_arr[indexN++] = 1;
27563
+ break;
27564
+ case Vector3.X_AXIS:
27565
+ position_arr[indexP++] = 0;
27566
+ position_arr[indexP++] = x;
27567
+ position_arr[indexP++] = y;
27568
+ normal_arr[indexN++] = 1;
27569
+ normal_arr[indexN++] = 0;
27570
+ normal_arr[indexN++] = 0;
27571
+ break;
27572
+ default:
27573
+ position_arr[indexP++] = x;
27574
+ position_arr[indexP++] = 0;
27575
+ position_arr[indexP++] = y;
27576
+ normal_arr[indexN++] = 0;
27577
+ normal_arr[indexN++] = 1;
27578
+ normal_arr[indexN++] = 0;
27579
+ break;
27580
+ }
27581
+ uv_arr[indexU++] = xi / this.segmentW;
27582
+ uv_arr[indexU++] = yi / this.segmentH;
27583
+ if (xi != this.segmentW && yi != this.segmentH) {
27584
+ base = xi + yi * tw;
27585
+ indices_arr[numIndices++] = base + 1;
27586
+ indices_arr[numIndices++] = base;
27587
+ indices_arr[numIndices++] = base + tw;
27588
+ indices_arr[numIndices++] = base + 1;
27589
+ indices_arr[numIndices++] = base + tw;
27590
+ indices_arr[numIndices++] = base + tw + 1;
27591
+ }
27592
+ }
27593
+ }
27594
+ this.setIndices(indices_arr);
27595
+ this.setAttribute(VertexAttributeName.position, position_arr);
27596
+ this.setAttribute(VertexAttributeName.normal, normal_arr);
27597
+ this.setAttribute(VertexAttributeName.uv, uv_arr);
27598
+ this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
27599
+ this.addSubGeometry({
27600
+ indexStart: 0,
27601
+ indexCount: indices_arr.length,
27602
+ vertexStart: 0,
27603
+ vertexCount: 0,
27604
+ firstStart: 0,
27605
+ index: 0,
27606
+ topology: 0
27607
+ });
27608
+ }
27609
+ }
27610
+
27611
+ var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
27612
+ var __decorateClass$g = (decorators, target, key, kind) => {
27613
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
27279
27614
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
27280
27615
  if (decorator = decorators[i])
27281
27616
  result = (decorator(result)) || result;
@@ -27299,7 +27634,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
27299
27634
  this.setUniformFloat(`height`, 100);
27300
27635
  }
27301
27636
  };
27302
- exports.QuadShader = __decorateClass$e([
27637
+ exports.QuadShader = __decorateClass$g([
27303
27638
  RegisterShader(exports.QuadShader, "QuadShader")
27304
27639
  ], exports.QuadShader);
27305
27640
 
@@ -30247,7 +30582,15 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
30247
30582
  shadowMapPassRenderer;
30248
30583
  pointLightShadowRenderer;
30249
30584
  ddgiProbeRenderer;
30250
- postRenderer;
30585
+ _postRenderer;
30586
+ get postRenderer() {
30587
+ if (!this._postRenderer) {
30588
+ let gbufferFrame = GBufferFrame.getGBufferFrame("ColorPassGBuffer");
30589
+ this._postRenderer = this.addRenderer(PostRenderer);
30590
+ this._postRenderer.setRenderStates(gbufferFrame);
30591
+ }
30592
+ return this._postRenderer;
30593
+ }
30251
30594
  clusterLightingRender;
30252
30595
  reflectionRenderer;
30253
30596
  occlusionSystem;
@@ -30271,7 +30614,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
30271
30614
  }
30272
30615
  this.shadowMapPassRenderer = new ShadowMapPassRenderer();
30273
30616
  this.pointLightShadowRenderer = new PointLightShadowRenderer();
30274
- this.addPost(new FXAAPost());
30617
+ if (Engine3D.setting.render.postProcessing.fxaa.enable) {
30618
+ this.addPost(new FXAAPost());
30619
+ }
30275
30620
  }
30276
30621
  addRenderer(c, param) {
30277
30622
  let renderer;
@@ -30301,11 +30646,6 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
30301
30646
  this.pauseRender = false;
30302
30647
  }
30303
30648
  addPost(post) {
30304
- if (!this.postRenderer) {
30305
- let gbufferFrame = GBufferFrame.getGBufferFrame("ColorPassGBuffer");
30306
- this.postRenderer = this.addRenderer(PostRenderer);
30307
- this.postRenderer.setRenderStates(gbufferFrame);
30308
- }
30309
30649
  if (post instanceof PostBase) {
30310
30650
  this.postRenderer.attachPost(this.view, post);
30311
30651
  }
@@ -30323,15 +30663,21 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
30323
30663
  renderFrame() {
30324
30664
  let view = this._view;
30325
30665
  ProfilerUtil.startView(view);
30326
- GlobalBindGroup.getLightEntries(view.scene).update(view);
30327
- GlobalBindGroup.getReflectionEntries(view.scene).update(view);
30328
- this.occlusionSystem.update(view.camera, view.scene);
30329
- this.clusterLightingRender.render(view, this.occlusionSystem);
30330
- if (this.shadowMapPassRenderer) {
30666
+ if (this.clusterLightingRender) {
30667
+ GlobalBindGroup.getLightEntries(view.scene).update(view);
30668
+ GlobalBindGroup.getReflectionEntries(view.scene).update(view);
30669
+ }
30670
+ if (Engine3D.setting.occlusionQuery.enable && this.occlusionSystem) {
30671
+ this.occlusionSystem.update(view.camera, view.scene);
30672
+ }
30673
+ if (this.clusterLightingRender) {
30674
+ this.clusterLightingRender.render(view, this.occlusionSystem);
30675
+ }
30676
+ if (Engine3D.setting.shadow.enable && this.shadowMapPassRenderer) {
30331
30677
  ShadowLightsCollect.update(view);
30332
30678
  this.shadowMapPassRenderer.render(view, this.occlusionSystem);
30333
30679
  }
30334
- if (this.pointLightShadowRenderer) {
30680
+ if (Engine3D.setting.shadow.enable && this.pointLightShadowRenderer) {
30335
30681
  this.pointLightShadowRenderer.render(view, this.occlusionSystem);
30336
30682
  }
30337
30683
  if (this.depthPassRenderer) {
@@ -34573,9 +34919,9 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
34573
34919
  }
34574
34920
  }
34575
34921
 
34576
- var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
34577
- var __decorateClass$d = (decorators, target, key, kind) => {
34578
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
34922
+ var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
34923
+ var __decorateClass$f = (decorators, target, key, kind) => {
34924
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
34579
34925
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
34580
34926
  if (decorator = decorators[i])
34581
34927
  result = (decorator(result)) || result;
@@ -34617,13 +34963,13 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
34617
34963
  debug() {
34618
34964
  }
34619
34965
  };
34620
- exports.DirectLight = __decorateClass$d([
34966
+ exports.DirectLight = __decorateClass$f([
34621
34967
  RegisterComponent(exports.DirectLight, "DirectLight")
34622
34968
  ], exports.DirectLight);
34623
34969
 
34624
- var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
34625
- var __decorateClass$c = (decorators, target, key, kind) => {
34626
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
34970
+ var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
34971
+ var __decorateClass$e = (decorators, target, key, kind) => {
34972
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
34627
34973
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
34628
34974
  if (decorator = decorators[i])
34629
34975
  result = (decorator(result)) || result;
@@ -34681,13 +35027,13 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
34681
35027
  debugDraw(show) {
34682
35028
  }
34683
35029
  };
34684
- exports.PointLight = __decorateClass$c([
35030
+ exports.PointLight = __decorateClass$e([
34685
35031
  RegisterComponent(exports.PointLight, "PointLight")
34686
35032
  ], exports.PointLight);
34687
35033
 
34688
- var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
34689
- var __decorateClass$b = (decorators, target, key, kind) => {
34690
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
35034
+ var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
35035
+ var __decorateClass$d = (decorators, target, key, kind) => {
35036
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
34691
35037
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
34692
35038
  if (decorator = decorators[i])
34693
35039
  result = (decorator(result)) || result;
@@ -34752,7 +35098,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
34752
35098
  debugDraw(show) {
34753
35099
  }
34754
35100
  };
34755
- exports.SpotLight = __decorateClass$b([
35101
+ exports.SpotLight = __decorateClass$d([
34756
35102
  RegisterComponent(exports.SpotLight, "SpotLight")
34757
35103
  ], exports.SpotLight);
34758
35104
 
@@ -39305,483 +39651,483 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
39305
39651
  }
39306
39652
  }
39307
39653
 
39308
- // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
39309
- // https://tools.ietf.org/html/rfc1951
39310
- // You may also wish to take a look at the guide I made about this program:
39311
- // https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
39312
- // Some of the following code is similar to that of UZIP.js:
39313
- // https://github.com/photopea/UZIP.js
39314
- // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
39315
- // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
39316
- // is better for memory in most engines (I *think*).
39317
-
39318
- // aliases for shorter compressed code (most minifers don't do this)
39319
- var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
39320
- // fixed length extra bits
39321
- var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);
39322
- // fixed distance extra bits
39323
- var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);
39324
- // code length index map
39325
- var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
39326
- // get base, reverse index map from extra bits
39327
- var freb = function (eb, start) {
39328
- var b = new u16(31);
39329
- for (var i = 0; i < 31; ++i) {
39330
- b[i] = start += 1 << eb[i - 1];
39331
- }
39332
- // numbers here are at max 18 bits
39333
- var r = new i32(b[30]);
39334
- for (var i = 1; i < 30; ++i) {
39335
- for (var j = b[i]; j < b[i + 1]; ++j) {
39336
- r[j] = ((j - b[i]) << 5) | i;
39337
- }
39338
- }
39339
- return { b: b, r: r };
39340
- };
39341
- var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
39342
- // we can ignore the fact that the other numbers are wrong; they never happen anyway
39343
- fl[28] = 258, revfl[258] = 28;
39344
- var _b = freb(fdeb, 0), fd = _b.b;
39345
- // map of value to reverse (assuming 16 bits)
39346
- var rev = new u16(32768);
39347
- for (var i = 0; i < 32768; ++i) {
39348
- // reverse table algorithm from SO
39349
- var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);
39350
- x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
39351
- x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
39352
- rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;
39353
- }
39354
- // create huffman tree from u8 "map": index -> code length for code index
39355
- // mb (max bits) must be at most 15
39356
- // TODO: optimize/split up?
39357
- var hMap = (function (cd, mb, r) {
39358
- var s = cd.length;
39359
- // index
39360
- var i = 0;
39361
- // u16 "map": index -> # of codes with bit length = index
39362
- var l = new u16(mb);
39363
- // length of cd must be 288 (total # of codes)
39364
- for (; i < s; ++i) {
39365
- if (cd[i])
39366
- ++l[cd[i] - 1];
39367
- }
39368
- // u16 "map": index -> minimum code for bit length = index
39369
- var le = new u16(mb);
39370
- for (i = 1; i < mb; ++i) {
39371
- le[i] = (le[i - 1] + l[i - 1]) << 1;
39372
- }
39373
- var co;
39374
- if (r) {
39375
- // u16 "map": index -> number of actual bits, symbol for code
39376
- co = new u16(1 << mb);
39377
- // bits to remove for reverser
39378
- var rvb = 15 - mb;
39379
- for (i = 0; i < s; ++i) {
39380
- // ignore 0 lengths
39381
- if (cd[i]) {
39382
- // num encoding both symbol and bits read
39383
- var sv = (i << 4) | cd[i];
39384
- // free bits
39385
- var r_1 = mb - cd[i];
39386
- // start value
39387
- var v = le[cd[i] - 1]++ << r_1;
39388
- // m is end value
39389
- for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
39390
- // every 16 bit value starting with the code yields the same result
39391
- co[rev[v] >> rvb] = sv;
39392
- }
39393
- }
39394
- }
39395
- }
39396
- else {
39397
- co = new u16(s);
39398
- for (i = 0; i < s; ++i) {
39399
- if (cd[i]) {
39400
- co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);
39401
- }
39402
- }
39403
- }
39404
- return co;
39405
- });
39406
- // fixed length tree
39407
- var flt = new u8(288);
39408
- for (var i = 0; i < 144; ++i)
39409
- flt[i] = 8;
39410
- for (var i = 144; i < 256; ++i)
39411
- flt[i] = 9;
39412
- for (var i = 256; i < 280; ++i)
39413
- flt[i] = 7;
39414
- for (var i = 280; i < 288; ++i)
39415
- flt[i] = 8;
39416
- // fixed distance tree
39417
- var fdt = new u8(32);
39418
- for (var i = 0; i < 32; ++i)
39419
- fdt[i] = 5;
39420
- // fixed length map
39421
- var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
39422
- // fixed distance map
39423
- var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
39424
- // find max of array
39425
- var max = function (a) {
39426
- var m = a[0];
39427
- for (var i = 1; i < a.length; ++i) {
39428
- if (a[i] > m)
39429
- m = a[i];
39430
- }
39431
- return m;
39432
- };
39433
- // read d, starting at bit p and mask with m
39434
- var bits = function (d, p, m) {
39435
- var o = (p / 8) | 0;
39436
- return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
39437
- };
39438
- // read d, starting at bit p continuing for at least 16 bits
39439
- var bits16 = function (d, p) {
39440
- var o = (p / 8) | 0;
39441
- return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
39442
- };
39443
- // get end of byte
39444
- var shft = function (p) { return ((p + 7) / 8) | 0; };
39445
- // typed array slice - allows garbage collector to free original reference,
39446
- // while being more compatible than .slice
39447
- var slc = function (v, s, e) {
39448
- if (s == null || s < 0)
39449
- s = 0;
39450
- if (e == null || e > v.length)
39451
- e = v.length;
39452
- // can't use .constructor in case user-supplied
39453
- return new u8(v.subarray(s, e));
39454
- };
39455
- // error codes
39456
- var ec = [
39457
- 'unexpected EOF',
39458
- 'invalid block type',
39459
- 'invalid length/literal',
39460
- 'invalid distance',
39461
- 'stream finished',
39462
- 'no stream handler',
39463
- ,
39464
- 'no callback',
39465
- 'invalid UTF-8 data',
39466
- 'extra field too long',
39467
- 'date not in range 1980-2099',
39468
- 'filename too long',
39469
- 'stream finishing',
39470
- 'invalid zip data'
39471
- // determined by unknown compression method
39472
- ];
39473
- var err = function (ind, msg, nt) {
39474
- var e = new Error(msg || ec[ind]);
39475
- e.code = ind;
39476
- if (Error.captureStackTrace)
39477
- Error.captureStackTrace(e, err);
39478
- if (!nt)
39479
- throw e;
39480
- return e;
39481
- };
39482
- // expands raw DEFLATE data
39483
- var inflt = function (dat, st, buf, dict) {
39484
- // source length dict length
39485
- var sl = dat.length, dl = dict ? dict.length : 0;
39486
- if (!sl || st.f && !st.l)
39487
- return buf || new u8(0);
39488
- var noBuf = !buf;
39489
- // have to estimate size
39490
- var resize = noBuf || st.i != 2;
39491
- // no state
39492
- var noSt = st.i;
39493
- // Assumes roughly 33% compression ratio average
39494
- if (noBuf)
39495
- buf = new u8(sl * 3);
39496
- // ensure buffer can fit at least l elements
39497
- var cbuf = function (l) {
39498
- var bl = buf.length;
39499
- // need to increase size to fit
39500
- if (l > bl) {
39501
- // Double or set to necessary, whichever is greater
39502
- var nbuf = new u8(Math.max(bl * 2, l));
39503
- nbuf.set(buf);
39504
- buf = nbuf;
39505
- }
39506
- };
39507
- // last chunk bitpos bytes
39508
- var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
39509
- // total bits
39510
- var tbts = sl * 8;
39511
- do {
39512
- if (!lm) {
39513
- // BFINAL - this is only 1 when last chunk is next
39514
- final = bits(dat, pos, 1);
39515
- // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
39516
- var type = bits(dat, pos + 1, 3);
39517
- pos += 3;
39518
- if (!type) {
39519
- // go to end of byte boundary
39520
- var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
39521
- if (t > sl) {
39522
- if (noSt)
39523
- err(0);
39524
- break;
39525
- }
39526
- // ensure size
39527
- if (resize)
39528
- cbuf(bt + l);
39529
- // Copy over uncompressed data
39530
- buf.set(dat.subarray(s, t), bt);
39531
- // Get new bitpos, update byte count
39532
- st.b = bt += l, st.p = pos = t * 8, st.f = final;
39533
- continue;
39534
- }
39535
- else if (type == 1)
39536
- lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
39537
- else if (type == 2) {
39538
- // literal lengths
39539
- var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
39540
- var tl = hLit + bits(dat, pos + 5, 31) + 1;
39541
- pos += 14;
39542
- // length+distance tree
39543
- var ldt = new u8(tl);
39544
- // code length tree
39545
- var clt = new u8(19);
39546
- for (var i = 0; i < hcLen; ++i) {
39547
- // use index map to get real code
39548
- clt[clim[i]] = bits(dat, pos + i * 3, 7);
39549
- }
39550
- pos += hcLen * 3;
39551
- // code lengths bits
39552
- var clb = max(clt), clbmsk = (1 << clb) - 1;
39553
- // code lengths map
39554
- var clm = hMap(clt, clb, 1);
39555
- for (var i = 0; i < tl;) {
39556
- var r = clm[bits(dat, pos, clbmsk)];
39557
- // bits read
39558
- pos += r & 15;
39559
- // symbol
39560
- var s = r >> 4;
39561
- // code length to copy
39562
- if (s < 16) {
39563
- ldt[i++] = s;
39564
- }
39565
- else {
39566
- // copy count
39567
- var c = 0, n = 0;
39568
- if (s == 16)
39569
- n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
39570
- else if (s == 17)
39571
- n = 3 + bits(dat, pos, 7), pos += 3;
39572
- else if (s == 18)
39573
- n = 11 + bits(dat, pos, 127), pos += 7;
39574
- while (n--)
39575
- ldt[i++] = c;
39576
- }
39577
- }
39578
- // length tree distance tree
39579
- var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
39580
- // max length bits
39581
- lbt = max(lt);
39582
- // max dist bits
39583
- dbt = max(dt);
39584
- lm = hMap(lt, lbt, 1);
39585
- dm = hMap(dt, dbt, 1);
39586
- }
39587
- else
39588
- err(1);
39589
- if (pos > tbts) {
39590
- if (noSt)
39591
- err(0);
39592
- break;
39593
- }
39594
- }
39595
- // Make sure the buffer can hold this + the largest possible addition
39596
- // Maximum chunk size (practically, theoretically infinite) is 2^17
39597
- if (resize)
39598
- cbuf(bt + 131072);
39599
- var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
39600
- var lpos = pos;
39601
- for (;; lpos = pos) {
39602
- // bits read, code
39603
- var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
39604
- pos += c & 15;
39605
- if (pos > tbts) {
39606
- if (noSt)
39607
- err(0);
39608
- break;
39609
- }
39610
- if (!c)
39611
- err(2);
39612
- if (sym < 256)
39613
- buf[bt++] = sym;
39614
- else if (sym == 256) {
39615
- lpos = pos, lm = null;
39616
- break;
39617
- }
39618
- else {
39619
- var add = sym - 254;
39620
- // no extra bits needed if less
39621
- if (sym > 264) {
39622
- // index
39623
- var i = sym - 257, b = fleb[i];
39624
- add = bits(dat, pos, (1 << b) - 1) + fl[i];
39625
- pos += b;
39626
- }
39627
- // dist
39628
- var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
39629
- if (!d)
39630
- err(3);
39631
- pos += d & 15;
39632
- var dt = fd[dsym];
39633
- if (dsym > 3) {
39634
- var b = fdeb[dsym];
39635
- dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
39636
- }
39637
- if (pos > tbts) {
39638
- if (noSt)
39639
- err(0);
39640
- break;
39641
- }
39642
- if (resize)
39643
- cbuf(bt + 131072);
39644
- var end = bt + add;
39645
- if (bt < dt) {
39646
- var shift = dl - dt, dend = Math.min(dt, end);
39647
- if (shift + bt < 0)
39648
- err(3);
39649
- for (; bt < dend; ++bt)
39650
- buf[bt] = dict[shift + bt];
39651
- }
39652
- for (; bt < end; ++bt)
39653
- buf[bt] = buf[bt - dt];
39654
- }
39655
- }
39656
- st.l = lm, st.p = lpos, st.b = bt, st.f = final;
39657
- if (lm)
39658
- final = 1, st.m = lbt, st.d = dm, st.n = dbt;
39659
- } while (!final);
39660
- // don't reallocate for streams or user buffers
39661
- return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
39662
- };
39663
- // empty
39664
- var et = /*#__PURE__*/ new u8(0);
39665
- // read 2 bytes
39666
- var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
39667
- // read 4 bytes
39668
- var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
39669
- var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
39670
- /**
39671
- * Expands DEFLATE data with no wrapper
39672
- * @param data The data to decompress
39673
- * @param opts The decompression options
39674
- * @returns The decompressed version of the data
39675
- */
39676
- function inflateSync(data, opts) {
39677
- return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
39678
- }
39679
- // text decoder
39680
- var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
39681
- // text decoder stream
39682
- var tds = 0;
39683
- try {
39684
- td.decode(et, { stream: true });
39685
- tds = 1;
39686
- }
39687
- catch (e) { }
39688
- // decode UTF8
39689
- var dutf8 = function (d) {
39690
- for (var r = '', i = 0;;) {
39691
- var c = d[i++];
39692
- var eb = (c > 127) + (c > 223) + (c > 239);
39693
- if (i + eb > d.length)
39694
- return { s: r, r: slc(d, i - 1) };
39695
- if (!eb)
39696
- r += String.fromCharCode(c);
39697
- else if (eb == 3) {
39698
- c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
39699
- r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
39700
- }
39701
- else if (eb & 1)
39702
- r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
39703
- else
39704
- r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
39705
- }
39706
- };
39707
- /**
39708
- * Converts a Uint8Array to a string
39709
- * @param dat The data to decode to string
39710
- * @param latin1 Whether or not to interpret the data as Latin-1. This should
39711
- * not need to be true unless encoding to binary string.
39712
- * @returns The original UTF-8/Latin-1 string
39713
- */
39714
- function strFromU8(dat, latin1) {
39715
- if (latin1) {
39716
- var r = '';
39717
- for (var i = 0; i < dat.length; i += 16384)
39718
- r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
39719
- return r;
39720
- }
39721
- else if (td) {
39722
- return td.decode(dat);
39723
- }
39724
- else {
39725
- var _a = dutf8(dat), s = _a.s, r = _a.r;
39726
- if (r.length)
39727
- err(8);
39728
- return s;
39729
- }
39730
- }
39731
- // skip local zip header
39732
- var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
39733
- // read zip header
39734
- var zh = function (d, b, z) {
39735
- var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
39736
- var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
39737
- return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
39738
- };
39739
- // read zip64 extra field
39740
- var z64e = function (d, b) {
39741
- for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
39742
- ;
39743
- return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
39744
- };
39745
- /**
39746
- * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
39747
- * performance with more than one file.
39748
- * @param data The raw compressed ZIP file
39749
- * @param opts The ZIP extraction options
39750
- * @returns The decompressed files
39751
- */
39752
- function unzipSync(data, opts) {
39753
- var files = {};
39754
- var e = data.length - 22;
39755
- for (; b4(data, e) != 0x6054B50; --e) {
39756
- if (!e || data.length - e > 65558)
39757
- err(13);
39758
- }
39759
- var c = b2(data, e + 8);
39760
- if (!c)
39761
- return {};
39762
- var o = b4(data, e + 16);
39763
- var z = o == 4294967295 || c == 65535;
39764
- if (z) {
39765
- var ze = b4(data, e - 12);
39766
- z = b4(data, ze) == 0x6064B50;
39767
- if (z) {
39768
- c = b4(data, ze + 32);
39769
- o = b4(data, ze + 48);
39770
- }
39771
- }
39772
- for (var i = 0; i < c; ++i) {
39773
- var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
39774
- o = no;
39775
- {
39776
- if (!c_2)
39777
- files[fn] = slc(data, b, b + sc);
39778
- else if (c_2 == 8)
39779
- files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
39780
- else
39781
- err(14, 'unknown compression type ' + c_2);
39782
- }
39783
- }
39784
- return files;
39654
+ // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
39655
+ // https://tools.ietf.org/html/rfc1951
39656
+ // You may also wish to take a look at the guide I made about this program:
39657
+ // https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
39658
+ // Some of the following code is similar to that of UZIP.js:
39659
+ // https://github.com/photopea/UZIP.js
39660
+ // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
39661
+ // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
39662
+ // is better for memory in most engines (I *think*).
39663
+
39664
+ // aliases for shorter compressed code (most minifers don't do this)
39665
+ var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
39666
+ // fixed length extra bits
39667
+ var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);
39668
+ // fixed distance extra bits
39669
+ var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);
39670
+ // code length index map
39671
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
39672
+ // get base, reverse index map from extra bits
39673
+ var freb = function (eb, start) {
39674
+ var b = new u16(31);
39675
+ for (var i = 0; i < 31; ++i) {
39676
+ b[i] = start += 1 << eb[i - 1];
39677
+ }
39678
+ // numbers here are at max 18 bits
39679
+ var r = new i32(b[30]);
39680
+ for (var i = 1; i < 30; ++i) {
39681
+ for (var j = b[i]; j < b[i + 1]; ++j) {
39682
+ r[j] = ((j - b[i]) << 5) | i;
39683
+ }
39684
+ }
39685
+ return { b: b, r: r };
39686
+ };
39687
+ var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
39688
+ // we can ignore the fact that the other numbers are wrong; they never happen anyway
39689
+ fl[28] = 258, revfl[258] = 28;
39690
+ var _b = freb(fdeb, 0), fd = _b.b;
39691
+ // map of value to reverse (assuming 16 bits)
39692
+ var rev = new u16(32768);
39693
+ for (var i = 0; i < 32768; ++i) {
39694
+ // reverse table algorithm from SO
39695
+ var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);
39696
+ x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
39697
+ x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
39698
+ rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;
39699
+ }
39700
+ // create huffman tree from u8 "map": index -> code length for code index
39701
+ // mb (max bits) must be at most 15
39702
+ // TODO: optimize/split up?
39703
+ var hMap = (function (cd, mb, r) {
39704
+ var s = cd.length;
39705
+ // index
39706
+ var i = 0;
39707
+ // u16 "map": index -> # of codes with bit length = index
39708
+ var l = new u16(mb);
39709
+ // length of cd must be 288 (total # of codes)
39710
+ for (; i < s; ++i) {
39711
+ if (cd[i])
39712
+ ++l[cd[i] - 1];
39713
+ }
39714
+ // u16 "map": index -> minimum code for bit length = index
39715
+ var le = new u16(mb);
39716
+ for (i = 1; i < mb; ++i) {
39717
+ le[i] = (le[i - 1] + l[i - 1]) << 1;
39718
+ }
39719
+ var co;
39720
+ if (r) {
39721
+ // u16 "map": index -> number of actual bits, symbol for code
39722
+ co = new u16(1 << mb);
39723
+ // bits to remove for reverser
39724
+ var rvb = 15 - mb;
39725
+ for (i = 0; i < s; ++i) {
39726
+ // ignore 0 lengths
39727
+ if (cd[i]) {
39728
+ // num encoding both symbol and bits read
39729
+ var sv = (i << 4) | cd[i];
39730
+ // free bits
39731
+ var r_1 = mb - cd[i];
39732
+ // start value
39733
+ var v = le[cd[i] - 1]++ << r_1;
39734
+ // m is end value
39735
+ for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
39736
+ // every 16 bit value starting with the code yields the same result
39737
+ co[rev[v] >> rvb] = sv;
39738
+ }
39739
+ }
39740
+ }
39741
+ }
39742
+ else {
39743
+ co = new u16(s);
39744
+ for (i = 0; i < s; ++i) {
39745
+ if (cd[i]) {
39746
+ co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);
39747
+ }
39748
+ }
39749
+ }
39750
+ return co;
39751
+ });
39752
+ // fixed length tree
39753
+ var flt = new u8(288);
39754
+ for (var i = 0; i < 144; ++i)
39755
+ flt[i] = 8;
39756
+ for (var i = 144; i < 256; ++i)
39757
+ flt[i] = 9;
39758
+ for (var i = 256; i < 280; ++i)
39759
+ flt[i] = 7;
39760
+ for (var i = 280; i < 288; ++i)
39761
+ flt[i] = 8;
39762
+ // fixed distance tree
39763
+ var fdt = new u8(32);
39764
+ for (var i = 0; i < 32; ++i)
39765
+ fdt[i] = 5;
39766
+ // fixed length map
39767
+ var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
39768
+ // fixed distance map
39769
+ var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
39770
+ // find max of array
39771
+ var max = function (a) {
39772
+ var m = a[0];
39773
+ for (var i = 1; i < a.length; ++i) {
39774
+ if (a[i] > m)
39775
+ m = a[i];
39776
+ }
39777
+ return m;
39778
+ };
39779
+ // read d, starting at bit p and mask with m
39780
+ var bits = function (d, p, m) {
39781
+ var o = (p / 8) | 0;
39782
+ return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
39783
+ };
39784
+ // read d, starting at bit p continuing for at least 16 bits
39785
+ var bits16 = function (d, p) {
39786
+ var o = (p / 8) | 0;
39787
+ return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
39788
+ };
39789
+ // get end of byte
39790
+ var shft = function (p) { return ((p + 7) / 8) | 0; };
39791
+ // typed array slice - allows garbage collector to free original reference,
39792
+ // while being more compatible than .slice
39793
+ var slc = function (v, s, e) {
39794
+ if (s == null || s < 0)
39795
+ s = 0;
39796
+ if (e == null || e > v.length)
39797
+ e = v.length;
39798
+ // can't use .constructor in case user-supplied
39799
+ return new u8(v.subarray(s, e));
39800
+ };
39801
+ // error codes
39802
+ var ec = [
39803
+ 'unexpected EOF',
39804
+ 'invalid block type',
39805
+ 'invalid length/literal',
39806
+ 'invalid distance',
39807
+ 'stream finished',
39808
+ 'no stream handler',
39809
+ ,
39810
+ 'no callback',
39811
+ 'invalid UTF-8 data',
39812
+ 'extra field too long',
39813
+ 'date not in range 1980-2099',
39814
+ 'filename too long',
39815
+ 'stream finishing',
39816
+ 'invalid zip data'
39817
+ // determined by unknown compression method
39818
+ ];
39819
+ var err = function (ind, msg, nt) {
39820
+ var e = new Error(msg || ec[ind]);
39821
+ e.code = ind;
39822
+ if (Error.captureStackTrace)
39823
+ Error.captureStackTrace(e, err);
39824
+ if (!nt)
39825
+ throw e;
39826
+ return e;
39827
+ };
39828
+ // expands raw DEFLATE data
39829
+ var inflt = function (dat, st, buf, dict) {
39830
+ // source length dict length
39831
+ var sl = dat.length, dl = dict ? dict.length : 0;
39832
+ if (!sl || st.f && !st.l)
39833
+ return buf || new u8(0);
39834
+ var noBuf = !buf;
39835
+ // have to estimate size
39836
+ var resize = noBuf || st.i != 2;
39837
+ // no state
39838
+ var noSt = st.i;
39839
+ // Assumes roughly 33% compression ratio average
39840
+ if (noBuf)
39841
+ buf = new u8(sl * 3);
39842
+ // ensure buffer can fit at least l elements
39843
+ var cbuf = function (l) {
39844
+ var bl = buf.length;
39845
+ // need to increase size to fit
39846
+ if (l > bl) {
39847
+ // Double or set to necessary, whichever is greater
39848
+ var nbuf = new u8(Math.max(bl * 2, l));
39849
+ nbuf.set(buf);
39850
+ buf = nbuf;
39851
+ }
39852
+ };
39853
+ // last chunk bitpos bytes
39854
+ var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
39855
+ // total bits
39856
+ var tbts = sl * 8;
39857
+ do {
39858
+ if (!lm) {
39859
+ // BFINAL - this is only 1 when last chunk is next
39860
+ final = bits(dat, pos, 1);
39861
+ // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
39862
+ var type = bits(dat, pos + 1, 3);
39863
+ pos += 3;
39864
+ if (!type) {
39865
+ // go to end of byte boundary
39866
+ var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
39867
+ if (t > sl) {
39868
+ if (noSt)
39869
+ err(0);
39870
+ break;
39871
+ }
39872
+ // ensure size
39873
+ if (resize)
39874
+ cbuf(bt + l);
39875
+ // Copy over uncompressed data
39876
+ buf.set(dat.subarray(s, t), bt);
39877
+ // Get new bitpos, update byte count
39878
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
39879
+ continue;
39880
+ }
39881
+ else if (type == 1)
39882
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
39883
+ else if (type == 2) {
39884
+ // literal lengths
39885
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
39886
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
39887
+ pos += 14;
39888
+ // length+distance tree
39889
+ var ldt = new u8(tl);
39890
+ // code length tree
39891
+ var clt = new u8(19);
39892
+ for (var i = 0; i < hcLen; ++i) {
39893
+ // use index map to get real code
39894
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
39895
+ }
39896
+ pos += hcLen * 3;
39897
+ // code lengths bits
39898
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
39899
+ // code lengths map
39900
+ var clm = hMap(clt, clb, 1);
39901
+ for (var i = 0; i < tl;) {
39902
+ var r = clm[bits(dat, pos, clbmsk)];
39903
+ // bits read
39904
+ pos += r & 15;
39905
+ // symbol
39906
+ var s = r >> 4;
39907
+ // code length to copy
39908
+ if (s < 16) {
39909
+ ldt[i++] = s;
39910
+ }
39911
+ else {
39912
+ // copy count
39913
+ var c = 0, n = 0;
39914
+ if (s == 16)
39915
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
39916
+ else if (s == 17)
39917
+ n = 3 + bits(dat, pos, 7), pos += 3;
39918
+ else if (s == 18)
39919
+ n = 11 + bits(dat, pos, 127), pos += 7;
39920
+ while (n--)
39921
+ ldt[i++] = c;
39922
+ }
39923
+ }
39924
+ // length tree distance tree
39925
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
39926
+ // max length bits
39927
+ lbt = max(lt);
39928
+ // max dist bits
39929
+ dbt = max(dt);
39930
+ lm = hMap(lt, lbt, 1);
39931
+ dm = hMap(dt, dbt, 1);
39932
+ }
39933
+ else
39934
+ err(1);
39935
+ if (pos > tbts) {
39936
+ if (noSt)
39937
+ err(0);
39938
+ break;
39939
+ }
39940
+ }
39941
+ // Make sure the buffer can hold this + the largest possible addition
39942
+ // Maximum chunk size (practically, theoretically infinite) is 2^17
39943
+ if (resize)
39944
+ cbuf(bt + 131072);
39945
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
39946
+ var lpos = pos;
39947
+ for (;; lpos = pos) {
39948
+ // bits read, code
39949
+ var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
39950
+ pos += c & 15;
39951
+ if (pos > tbts) {
39952
+ if (noSt)
39953
+ err(0);
39954
+ break;
39955
+ }
39956
+ if (!c)
39957
+ err(2);
39958
+ if (sym < 256)
39959
+ buf[bt++] = sym;
39960
+ else if (sym == 256) {
39961
+ lpos = pos, lm = null;
39962
+ break;
39963
+ }
39964
+ else {
39965
+ var add = sym - 254;
39966
+ // no extra bits needed if less
39967
+ if (sym > 264) {
39968
+ // index
39969
+ var i = sym - 257, b = fleb[i];
39970
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
39971
+ pos += b;
39972
+ }
39973
+ // dist
39974
+ var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
39975
+ if (!d)
39976
+ err(3);
39977
+ pos += d & 15;
39978
+ var dt = fd[dsym];
39979
+ if (dsym > 3) {
39980
+ var b = fdeb[dsym];
39981
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
39982
+ }
39983
+ if (pos > tbts) {
39984
+ if (noSt)
39985
+ err(0);
39986
+ break;
39987
+ }
39988
+ if (resize)
39989
+ cbuf(bt + 131072);
39990
+ var end = bt + add;
39991
+ if (bt < dt) {
39992
+ var shift = dl - dt, dend = Math.min(dt, end);
39993
+ if (shift + bt < 0)
39994
+ err(3);
39995
+ for (; bt < dend; ++bt)
39996
+ buf[bt] = dict[shift + bt];
39997
+ }
39998
+ for (; bt < end; ++bt)
39999
+ buf[bt] = buf[bt - dt];
40000
+ }
40001
+ }
40002
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
40003
+ if (lm)
40004
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
40005
+ } while (!final);
40006
+ // don't reallocate for streams or user buffers
40007
+ return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
40008
+ };
40009
+ // empty
40010
+ var et = /*#__PURE__*/ new u8(0);
40011
+ // read 2 bytes
40012
+ var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
40013
+ // read 4 bytes
40014
+ var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
40015
+ var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
40016
+ /**
40017
+ * Expands DEFLATE data with no wrapper
40018
+ * @param data The data to decompress
40019
+ * @param opts The decompression options
40020
+ * @returns The decompressed version of the data
40021
+ */
40022
+ function inflateSync(data, opts) {
40023
+ return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
40024
+ }
40025
+ // text decoder
40026
+ var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
40027
+ // text decoder stream
40028
+ var tds = 0;
40029
+ try {
40030
+ td.decode(et, { stream: true });
40031
+ tds = 1;
40032
+ }
40033
+ catch (e) { }
40034
+ // decode UTF8
40035
+ var dutf8 = function (d) {
40036
+ for (var r = '', i = 0;;) {
40037
+ var c = d[i++];
40038
+ var eb = (c > 127) + (c > 223) + (c > 239);
40039
+ if (i + eb > d.length)
40040
+ return { s: r, r: slc(d, i - 1) };
40041
+ if (!eb)
40042
+ r += String.fromCharCode(c);
40043
+ else if (eb == 3) {
40044
+ c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
40045
+ r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
40046
+ }
40047
+ else if (eb & 1)
40048
+ r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
40049
+ else
40050
+ r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
40051
+ }
40052
+ };
40053
+ /**
40054
+ * Converts a Uint8Array to a string
40055
+ * @param dat The data to decode to string
40056
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
40057
+ * not need to be true unless encoding to binary string.
40058
+ * @returns The original UTF-8/Latin-1 string
40059
+ */
40060
+ function strFromU8(dat, latin1) {
40061
+ if (latin1) {
40062
+ var r = '';
40063
+ for (var i = 0; i < dat.length; i += 16384)
40064
+ r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
40065
+ return r;
40066
+ }
40067
+ else if (td) {
40068
+ return td.decode(dat);
40069
+ }
40070
+ else {
40071
+ var _a = dutf8(dat), s = _a.s, r = _a.r;
40072
+ if (r.length)
40073
+ err(8);
40074
+ return s;
40075
+ }
40076
+ }
40077
+ // skip local zip header
40078
+ var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
40079
+ // read zip header
40080
+ var zh = function (d, b, z) {
40081
+ var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
40082
+ var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
40083
+ return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
40084
+ };
40085
+ // read zip64 extra field
40086
+ var z64e = function (d, b) {
40087
+ for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
40088
+ ;
40089
+ return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
40090
+ };
40091
+ /**
40092
+ * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
40093
+ * performance with more than one file.
40094
+ * @param data The raw compressed ZIP file
40095
+ * @param opts The ZIP extraction options
40096
+ * @returns The decompressed files
40097
+ */
40098
+ function unzipSync(data, opts) {
40099
+ var files = {};
40100
+ var e = data.length - 22;
40101
+ for (; b4(data, e) != 0x6054B50; --e) {
40102
+ if (!e || data.length - e > 65558)
40103
+ err(13);
40104
+ }
40105
+ var c = b2(data, e + 8);
40106
+ if (!c)
40107
+ return {};
40108
+ var o = b4(data, e + 16);
40109
+ var z = o == 4294967295 || c == 65535;
40110
+ if (z) {
40111
+ var ze = b4(data, e - 12);
40112
+ z = b4(data, ze) == 0x6064B50;
40113
+ if (z) {
40114
+ c = b4(data, ze + 32);
40115
+ o = b4(data, ze + 48);
40116
+ }
40117
+ }
40118
+ for (var i = 0; i < c; ++i) {
40119
+ var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
40120
+ o = no;
40121
+ {
40122
+ if (!c_2)
40123
+ files[fn] = slc(data, b, b + sc);
40124
+ else if (c_2 == 8)
40125
+ files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
40126
+ else
40127
+ err(14, 'unknown compression type ' + c_2);
40128
+ }
40129
+ }
40130
+ return files;
39785
40131
  }
39786
40132
 
39787
40133
  class UnLitMaterial extends Material {
@@ -40552,7 +40898,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
40552
40898
  }
40553
40899
  }
40554
40900
 
40555
- const version = "1.0.11";
40901
+ const version = "1.0.13";
40556
40902
 
40557
40903
  class Engine3D {
40558
40904
  /**
@@ -45065,9 +45411,9 @@ fn frag(){
45065
45411
  }
45066
45412
  }
45067
45413
 
45068
- var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
45069
- var __decorateClass$a = (decorators, target, key, kind) => {
45070
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
45414
+ var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
45415
+ var __decorateClass$c = (decorators, target, key, kind) => {
45416
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
45071
45417
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
45072
45418
  if (decorator = decorators[i])
45073
45419
  result = (decorator(result)) || result;
@@ -45091,7 +45437,7 @@ fn frag(){
45091
45437
  shaderState.depthCompare = GPUCompareFunction.less;
45092
45438
  }
45093
45439
  };
45094
- exports.SkyShader = __decorateClass$a([
45440
+ exports.SkyShader = __decorateClass$c([
45095
45441
  RegisterShader(exports.SkyShader, "SkyShader")
45096
45442
  ], exports.SkyShader);
45097
45443
 
@@ -45889,9 +46235,9 @@ fn frag(){
45889
46235
  }
45890
46236
  }
45891
46237
 
45892
- var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
45893
- var __decorateClass$9 = (decorators, target, key, kind) => {
45894
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
46238
+ var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
46239
+ var __decorateClass$b = (decorators, target, key, kind) => {
46240
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
45895
46241
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
45896
46242
  if (decorator = decorators[i])
45897
46243
  result = (decorator(result)) || result;
@@ -46095,7 +46441,7 @@ fn frag(){
46095
46441
  this._currentClipState.weight = 1;
46096
46442
  }
46097
46443
  };
46098
- exports.SkeletonAnimationComponent = __decorateClass$9([
46444
+ exports.SkeletonAnimationComponent = __decorateClass$b([
46099
46445
  RegisterComponent(exports.SkeletonAnimationComponent, "SkeletonAnimationComponent")
46100
46446
  ], exports.SkeletonAnimationComponent);
46101
46447
  class SkeletonAnimationCrossFadeState {
@@ -46131,9 +46477,9 @@ fn frag(){
46131
46477
  }
46132
46478
  }
46133
46479
 
46134
- var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
46135
- var __decorateClass$8 = (decorators, target, key, kind) => {
46136
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
46480
+ var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
46481
+ var __decorateClass$a = (decorators, target, key, kind) => {
46482
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
46137
46483
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
46138
46484
  if (decorator = decorators[i])
46139
46485
  result = (decorator(result)) || result;
@@ -46544,7 +46890,7 @@ fn frag(){
46544
46890
  return dst;
46545
46891
  }
46546
46892
  };
46547
- exports.AnimatorComponent = __decorateClass$8([
46893
+ exports.AnimatorComponent = __decorateClass$a([
46548
46894
  RegisterComponent(exports.AnimatorComponent, "AnimatorComponent")
46549
46895
  ], exports.AnimatorComponent);
46550
46896
  class PropertyAnimationClipState {
@@ -47301,9 +47647,9 @@ fn frag(){
47301
47647
  }
47302
47648
  }
47303
47649
 
47304
- var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
47305
- var __decorateClass$7 = (decorators, target, key, kind) => {
47306
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
47650
+ var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
47651
+ var __decorateClass$9 = (decorators, target, key, kind) => {
47652
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
47307
47653
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
47308
47654
  if (decorator = decorators[i])
47309
47655
  result = (decorator(result)) || result;
@@ -47452,7 +47798,7 @@ fn frag(){
47452
47798
  super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
47453
47799
  }
47454
47800
  };
47455
- exports.SkinnedMeshRenderer2 = __decorateClass$7([
47801
+ exports.SkinnedMeshRenderer2 = __decorateClass$9([
47456
47802
  RegisterComponent(exports.SkinnedMeshRenderer2, "SkinnedMeshRenderer2")
47457
47803
  ], exports.SkinnedMeshRenderer2);
47458
47804
 
@@ -52585,9 +52931,9 @@ fn frag(){
52585
52931
  }
52586
52932
  }
52587
52933
 
52588
- var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
52589
- var __decorateClass$6 = (decorators, target, key, kind) => {
52590
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
52934
+ var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
52935
+ var __decorateClass$8 = (decorators, target, key, kind) => {
52936
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
52591
52937
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
52592
52938
  if (decorator = decorators[i])
52593
52939
  result = (decorator(result)) || result;
@@ -52664,10 +53010,86 @@ fn frag(){
52664
53010
  debugDraw(show) {
52665
53011
  }
52666
53012
  };
52667
- exports.Light = __decorateClass$6([
53013
+ exports.Light = __decorateClass$8([
52668
53014
  RegisterComponent(exports.Light, "Light")
52669
53015
  ], exports.Light);
52670
53016
 
53017
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
53018
+ var __decorateClass$7 = (decorators, target, key, kind) => {
53019
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
53020
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
53021
+ if (decorator = decorators[i])
53022
+ result = (decorator(result)) || result;
53023
+ return result;
53024
+ };
53025
+ exports.FatLineRenderer = class FatLineRenderer extends RenderNode {
53026
+ _fatLineMaterial = null;
53027
+ _fatLineGeometry = null;
53028
+ constructor() {
53029
+ super();
53030
+ }
53031
+ onEnable() {
53032
+ super.onEnable();
53033
+ }
53034
+ onDisable() {
53035
+ super.onDisable();
53036
+ }
53037
+ cloneTo(obj) {
53038
+ const component = obj.addComponent(exports.FatLineRenderer);
53039
+ component.copyComponent(this);
53040
+ }
53041
+ copyComponent(from) {
53042
+ super.copyComponent(from);
53043
+ return this;
53044
+ }
53045
+ /**
53046
+ * Set FatLine geometry
53047
+ */
53048
+ set geometry(value) {
53049
+ super.geometry = value;
53050
+ this._fatLineGeometry = value;
53051
+ if (value) {
53052
+ this.instanceCount = value.instanceCount;
53053
+ if (this._fatLineMaterial && value.instanceBuffer) {
53054
+ this._fatLineMaterial.setInstanceBuffer(value.instanceBuffer);
53055
+ }
53056
+ }
53057
+ }
53058
+ get geometry() {
53059
+ return this._fatLineGeometry;
53060
+ }
53061
+ /**
53062
+ * Set FatLine material
53063
+ */
53064
+ set material(value) {
53065
+ this.materials = [value];
53066
+ this._fatLineMaterial = value;
53067
+ if (this._fatLineGeometry && this._fatLineGeometry.instanceBuffer) {
53068
+ value.setInstanceBuffer(this._fatLineGeometry.instanceBuffer);
53069
+ }
53070
+ }
53071
+ get material() {
53072
+ return this._fatLineMaterial;
53073
+ }
53074
+ /**
53075
+ * Override nodeUpdate to automatically update FatLine-specific uniforms
53076
+ */
53077
+ nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
53078
+ if (this._fatLineMaterial && this.object3D) {
53079
+ this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);
53080
+ const width = webGPUContext.presentationSize[0];
53081
+ const height = webGPUContext.presentationSize[1];
53082
+ if (width > 0 && height > 0) {
53083
+ this._fatLineMaterial.resolution = new Vector2(width, height);
53084
+ }
53085
+ }
53086
+ super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
53087
+ }
53088
+ };
53089
+ exports.FatLineRenderer = __decorateClass$7([
53090
+ RegisterComponent(exports.FatLineRenderer, "FatLineRenderer")
53091
+ ], exports.FatLineRenderer);
53092
+
52671
53093
  class Probe extends exports.Object3D {
52672
53094
  index = 0;
52673
53095
  drawCallFrame = -1;
@@ -52966,9 +53388,9 @@ fn frag(){
52966
53388
  }
52967
53389
  }
52968
53390
 
52969
- var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
52970
- var __decorateClass$5 = (decorators, target, key, kind) => {
52971
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
53391
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
53392
+ var __decorateClass$6 = (decorators, target, key, kind) => {
53393
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
52972
53394
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
52973
53395
  if (decorator = decorators[i])
52974
53396
  result = (decorator(result)) || result;
@@ -52994,13 +53416,13 @@ fn frag(){
52994
53416
  }
52995
53417
  }
52996
53418
  };
52997
- exports.MeshFilter = __decorateClass$5([
53419
+ exports.MeshFilter = __decorateClass$6([
52998
53420
  RegisterComponent(exports.MeshFilter, "MeshFilter")
52999
53421
  ], exports.MeshFilter);
53000
53422
 
53001
- var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
53002
- var __decorateClass$4 = (decorators, target, key, kind) => {
53003
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
53423
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
53424
+ var __decorateClass$5 = (decorators, target, key, kind) => {
53425
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
53004
53426
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
53005
53427
  if (decorator = decorators[i])
53006
53428
  result = (decorator(result)) || result;
@@ -53126,7 +53548,7 @@ fn frag(){
53126
53548
  super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
53127
53549
  }
53128
53550
  };
53129
- exports.SkinnedMeshRenderer = __decorateClass$4([
53551
+ exports.SkinnedMeshRenderer = __decorateClass$5([
53130
53552
  RegisterComponent(exports.SkinnedMeshRenderer, "SkinnedMeshRenderer")
53131
53553
  ], exports.SkinnedMeshRenderer);
53132
53554
 
@@ -53958,6 +54380,230 @@ fn frag(){
53958
54380
  }
53959
54381
  }
53960
54382
 
54383
+ class FatLineGeometry extends GeometryBase {
54384
+ _instanceBuffer;
54385
+ _instanceData;
54386
+ _instanceCount = 0;
54387
+ constructor() {
54388
+ super();
54389
+ this.initBaseGeometry();
54390
+ }
54391
+ /**
54392
+ * Initialize base quad geometry (shared by all line segments)
54393
+ * This is similar to ThreeJS LineSegmentsGeometry base geometry
54394
+ */
54395
+ initBaseGeometry() {
54396
+ const positions = new Float32Array([
54397
+ -1,
54398
+ 2,
54399
+ 0,
54400
+ 1,
54401
+ 2,
54402
+ 0,
54403
+ // Top endcap
54404
+ -1,
54405
+ 1,
54406
+ 0,
54407
+ 1,
54408
+ 1,
54409
+ 0,
54410
+ // Top of line segment
54411
+ -1,
54412
+ 0,
54413
+ 0,
54414
+ 1,
54415
+ 0,
54416
+ 0,
54417
+ // Bottom of line segment
54418
+ -1,
54419
+ -1,
54420
+ 0,
54421
+ 1,
54422
+ -1,
54423
+ 0
54424
+ // Bottom endcap
54425
+ ]);
54426
+ const uvs = new Float32Array([
54427
+ -1,
54428
+ 2,
54429
+ 1,
54430
+ 2,
54431
+ -1,
54432
+ 1,
54433
+ 1,
54434
+ 1,
54435
+ -1,
54436
+ -1,
54437
+ 1,
54438
+ -1,
54439
+ -1,
54440
+ -2,
54441
+ 1,
54442
+ -2
54443
+ ]);
54444
+ const indices = new Uint16Array([
54445
+ 0,
54446
+ 2,
54447
+ 1,
54448
+ 2,
54449
+ 3,
54450
+ 1,
54451
+ // First quad
54452
+ 2,
54453
+ 4,
54454
+ 3,
54455
+ 4,
54456
+ 5,
54457
+ 3,
54458
+ // Second quad
54459
+ 4,
54460
+ 6,
54461
+ 5,
54462
+ 6,
54463
+ 7,
54464
+ 5
54465
+ // Third quad
54466
+ ]);
54467
+ this.setIndices(indices);
54468
+ this.setAttribute(VertexAttributeName.position, positions);
54469
+ this.setAttribute(VertexAttributeName.uv, uvs);
54470
+ this.addSubGeometry({
54471
+ indexStart: 0,
54472
+ indexCount: indices.length,
54473
+ vertexStart: 0,
54474
+ vertexCount: positions.length / 3,
54475
+ firstStart: 0,
54476
+ index: 0,
54477
+ topology: 0
54478
+ });
54479
+ }
54480
+ /**
54481
+ * Set line positions from continuous points array
54482
+ * @param positions Array of positions [x1,y1,z1, x2,y2,z2, ...]
54483
+ */
54484
+ setPositions(positions) {
54485
+ const posArray = positions instanceof Float32Array ? positions : new Float32Array(positions);
54486
+ const numPoints = posArray.length / 3;
54487
+ const numSegments = numPoints - 1;
54488
+ if (numSegments <= 0) {
54489
+ console.warn("FatLineGeometry: Need at least 2 points");
54490
+ return this;
54491
+ }
54492
+ const instanceData = new Float32Array(numSegments * 16);
54493
+ for (let i = 0; i < numSegments; i++) {
54494
+ const i0 = i * 3;
54495
+ const i1 = (i + 1) * 3;
54496
+ instanceData[i * 16 + 0] = posArray[i0 + 0];
54497
+ instanceData[i * 16 + 1] = posArray[i0 + 1];
54498
+ instanceData[i * 16 + 2] = posArray[i0 + 2];
54499
+ instanceData[i * 16 + 3] = 0;
54500
+ instanceData[i * 16 + 4] = posArray[i1 + 0];
54501
+ instanceData[i * 16 + 5] = posArray[i1 + 1];
54502
+ instanceData[i * 16 + 6] = posArray[i1 + 2];
54503
+ instanceData[i * 16 + 7] = 0;
54504
+ instanceData[i * 16 + 8] = 1;
54505
+ instanceData[i * 16 + 9] = 1;
54506
+ instanceData[i * 16 + 10] = 1;
54507
+ instanceData[i * 16 + 11] = 0;
54508
+ instanceData[i * 16 + 12] = 1;
54509
+ instanceData[i * 16 + 13] = 1;
54510
+ instanceData[i * 16 + 14] = 1;
54511
+ instanceData[i * 16 + 15] = 0;
54512
+ }
54513
+ this._instanceData = instanceData;
54514
+ this._instanceCount = numSegments;
54515
+ this.computeBoundingBox(posArray);
54516
+ return this;
54517
+ }
54518
+ /**
54519
+ * Set colors for line segments
54520
+ * @param colors Array of colors [r1,g1,b1, r2,g2,b2, ...] for each point
54521
+ */
54522
+ setColors(colors) {
54523
+ const colorArray = colors instanceof Float32Array ? colors : new Float32Array(colors);
54524
+ if (!this._instanceData) {
54525
+ console.warn(
54526
+ "FatLineGeometry: Must call setPositions() before setColors()"
54527
+ );
54528
+ return this;
54529
+ }
54530
+ const numPoints = colorArray.length / 3;
54531
+ const numSegments = numPoints - 1;
54532
+ if (numSegments !== this._instanceCount) {
54533
+ console.warn(
54534
+ "FatLineGeometry: Color array length doesn't match segment count"
54535
+ );
54536
+ return this;
54537
+ }
54538
+ for (let i = 0; i < numSegments; i++) {
54539
+ const i0 = i * 3;
54540
+ const i1 = (i + 1) * 3;
54541
+ this._instanceData[i * 16 + 8] = colorArray[i0 + 0];
54542
+ this._instanceData[i * 16 + 9] = colorArray[i0 + 1];
54543
+ this._instanceData[i * 16 + 10] = colorArray[i0 + 2];
54544
+ this._instanceData[i * 16 + 12] = colorArray[i1 + 0];
54545
+ this._instanceData[i * 16 + 13] = colorArray[i1 + 1];
54546
+ this._instanceData[i * 16 + 14] = colorArray[i1 + 2];
54547
+ }
54548
+ return this;
54549
+ }
54550
+ /**
54551
+ * Compute bounding box from positions
54552
+ */
54553
+ computeBoundingBox(positions) {
54554
+ const min = new Vector3(Infinity, Infinity, Infinity);
54555
+ const max = new Vector3(-Infinity, -Infinity, -Infinity);
54556
+ for (let i = 0; i < positions.length; i += 3) {
54557
+ const x = positions[i];
54558
+ const y = positions[i + 1];
54559
+ const z = positions[i + 2];
54560
+ min.x = Math.min(min.x, x);
54561
+ min.y = Math.min(min.y, y);
54562
+ min.z = Math.min(min.z, z);
54563
+ max.x = Math.max(max.x, x);
54564
+ max.y = Math.max(max.y, y);
54565
+ max.z = Math.max(max.z, z);
54566
+ }
54567
+ const size = Vector3.sub(max, min);
54568
+ this.bounds = new BoundingBox(Vector3.ZERO.clone(), size);
54569
+ this.bounds.setFromMinMax(min, max);
54570
+ }
54571
+ /**
54572
+ * Get instance data for GPU upload
54573
+ */
54574
+ get instanceData() {
54575
+ return this._instanceData;
54576
+ }
54577
+ /**
54578
+ * Get number of line segments (instances)
54579
+ */
54580
+ get instanceCount() {
54581
+ return this._instanceCount;
54582
+ }
54583
+ /**
54584
+ * Get or create instance buffer
54585
+ */
54586
+ get instanceBuffer() {
54587
+ if (!this._instanceBuffer && this._instanceData) {
54588
+ this._instanceBuffer = new StorageGPUBuffer(
54589
+ this._instanceData.byteLength
54590
+ );
54591
+ this._instanceBuffer.setFloat32Array("", this._instanceData);
54592
+ this._instanceBuffer.apply();
54593
+ }
54594
+ return this._instanceBuffer;
54595
+ }
54596
+ /**
54597
+ * Update instance buffer with new data
54598
+ */
54599
+ updateInstanceBuffer() {
54600
+ if (this._instanceBuffer && this._instanceData) {
54601
+ this._instanceBuffer.setFloat32Array("", this._instanceData);
54602
+ this._instanceBuffer.apply();
54603
+ }
54604
+ }
54605
+ }
54606
+
53961
54607
  class VertexBufferLayout {
53962
54608
  name;
53963
54609
  offset;
@@ -59228,9 +59874,9 @@ fn frag(){
59228
59874
  }
59229
59875
  }
59230
59876
 
59231
- var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
59232
- var __decorateClass$3 = (decorators, target, key, kind) => {
59233
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
59877
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
59878
+ var __decorateClass$4 = (decorators, target, key, kind) => {
59879
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
59234
59880
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
59235
59881
  if (decorator = decorators[i])
59236
59882
  result = (decorator(result)) || result;
@@ -59349,13 +59995,13 @@ fn frag(){
59349
59995
  }
59350
59996
  }
59351
59997
  };
59352
- exports.LitSSSShader = __decorateClass$3([
59998
+ exports.LitSSSShader = __decorateClass$4([
59353
59999
  RegisterShader(exports.LitSSSShader, "LitSSSShader")
59354
60000
  ], exports.LitSSSShader);
59355
60001
 
59356
- var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
59357
- var __decorateClass$2 = (decorators, target, key, kind) => {
59358
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
60002
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
60003
+ var __decorateClass$3 = (decorators, target, key, kind) => {
60004
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
59359
60005
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
59360
60006
  if (decorator = decorators[i])
59361
60007
  result = (decorator(result)) || result;
@@ -59451,7 +60097,7 @@ fn frag(){
59451
60097
  }
59452
60098
  }
59453
60099
  };
59454
- exports.LitShader = __decorateClass$2([
60100
+ exports.LitShader = __decorateClass$3([
59455
60101
  RegisterShader(exports.LitShader, "LitShader")
59456
60102
  ], exports.LitShader);
59457
60103
 
@@ -59610,6 +60256,47 @@ fn frag(){
59610
60256
  }
59611
60257
  }
59612
60258
 
60259
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
60260
+ var __decorateClass$2 = (decorators, target, key, kind) => {
60261
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
60262
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
60263
+ if (decorator = decorators[i])
60264
+ result = (decorator(result)) || result;
60265
+ return result;
60266
+ };
60267
+ exports.FatLineShader = class FatLineShader extends Shader {
60268
+ constructor() {
60269
+ super();
60270
+ const colorShader = new RenderShaderPass("FatLine_VS", "FatLine_FS");
60271
+ colorShader.setShaderEntry(`VertMain`, `FragMain`);
60272
+ this.addRenderPass(colorShader);
60273
+ const shaderState = colorShader.shaderState;
60274
+ shaderState.acceptShadow = false;
60275
+ shaderState.castShadow = false;
60276
+ shaderState.receiveEnv = false;
60277
+ shaderState.acceptGI = false;
60278
+ shaderState.useLight = false;
60279
+ shaderState.cullMode = GPUCullMode.none;
60280
+ shaderState.depthWriteEnabled = true;
60281
+ this.setDefault();
60282
+ }
60283
+ /**
60284
+ * Set default uniform values
60285
+ */
60286
+ setDefault() {
60287
+ this.setUniformColor(`baseColor`, new Color(1, 1, 1, 1));
60288
+ this.setUniformFloat(`lineWidth`, 1);
60289
+ this.setUniformFloat(`opacity`, 1);
60290
+ this.setUniformVector2(`resolution`, new Vector2(1920, 1080));
60291
+ const identityMatrix = new Matrix4();
60292
+ const pass = this.getDefaultColorShader();
60293
+ pass.setUniform(`modelMatrix`, identityMatrix.rawData);
60294
+ }
60295
+ };
60296
+ exports.FatLineShader = __decorateClass$2([
60297
+ RegisterShader(exports.FatLineShader, "FatLineShader")
60298
+ ], exports.FatLineShader);
60299
+
59613
60300
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
59614
60301
  var __decorateClass$1 = (decorators, target, key, kind) => {
59615
60302
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
@@ -59946,6 +60633,78 @@ fn frag(){
59946
60633
  }
59947
60634
  }
59948
60635
 
60636
+ class FatLineMaterial extends Material {
60637
+ constructor() {
60638
+ super();
60639
+ this.shader = new exports.FatLineShader();
60640
+ this.transparent = true;
60641
+ }
60642
+ /**
60643
+ * Set instance buffer for line segments
60644
+ * This should be called after setting the geometry
60645
+ */
60646
+ setInstanceBuffer(buffer) {
60647
+ this.shader.setStorageBuffer("instances", buffer);
60648
+ }
60649
+ /**
60650
+ * Set model matrix for transforming line segments
60651
+ * This should be updated each frame if the object moves
60652
+ */
60653
+ setModelMatrix(matrix) {
60654
+ const pass = this.shader.getDefaultColorShader();
60655
+ pass.setUniform("modelMatrix", matrix.rawData);
60656
+ }
60657
+ /**
60658
+ * Set base color (tint color)
60659
+ */
60660
+ set baseColor(color) {
60661
+ this.shader.setUniformColor(`baseColor`, color);
60662
+ }
60663
+ /**
60664
+ * Get base color (tint color)
60665
+ */
60666
+ get baseColor() {
60667
+ return this.shader.getUniformColor("baseColor");
60668
+ }
60669
+ /**
60670
+ * Set line width in pixels
60671
+ */
60672
+ set lineWidth(value) {
60673
+ this.shader.setUniformFloat(`lineWidth`, value);
60674
+ }
60675
+ /**
60676
+ * Get line width in pixels
60677
+ */
60678
+ get lineWidth() {
60679
+ return this.shader.getUniformFloat("lineWidth");
60680
+ }
60681
+ /**
60682
+ * Set opacity (0-1)
60683
+ */
60684
+ set opacity(value) {
60685
+ this.shader.setUniformFloat(`opacity`, value);
60686
+ }
60687
+ /**
60688
+ * Get opacity (0-1)
60689
+ */
60690
+ get opacity() {
60691
+ return this.shader.getUniformFloat("opacity");
60692
+ }
60693
+ /**
60694
+ * Set viewport resolution for correct pixel-space calculations
60695
+ * This should be set automatically by the renderer
60696
+ */
60697
+ set resolution(value) {
60698
+ this.shader.setUniformVector2(`resolution`, value);
60699
+ }
60700
+ /**
60701
+ * Get viewport resolution
60702
+ */
60703
+ get resolution() {
60704
+ return this.shader.getUniformVector2("resolution");
60705
+ }
60706
+ }
60707
+
59949
60708
  class LambertMaterial extends Material {
59950
60709
  /**
59951
60710
  * @constructor
@@ -65856,6 +66615,10 @@ fn frag(){
65856
66615
  exports.FXAAPost = FXAAPost;
65857
66616
  exports.FXAAShader = FXAAShader;
65858
66617
  exports.FastMathShader = FastMathShader;
66618
+ exports.FatLineGeometry = FatLineGeometry;
66619
+ exports.FatLineMaterial = FatLineMaterial;
66620
+ exports.FatLine_FS = FatLine_FS;
66621
+ exports.FatLine_VS = FatLine_VS;
65859
66622
  exports.FeatureTable = FeatureTable;
65860
66623
  exports.FileLoader = FileLoader;
65861
66624
  exports.FirstPersonCameraController = FirstPersonCameraController;
@@ -65923,6 +66686,7 @@ fn frag(){
65923
66686
  exports.GPUVertexFormat = GPUVertexFormat;
65924
66687
  exports.GPUVertexStepMode = GPUVertexStepMode;
65925
66688
  exports.GSplatFormat = GSplatFormat;
66689
+ exports.GSplatGeometry = GSplatGeometry;
65926
66690
  exports.GSplatMaterial = GSplatMaterial;
65927
66691
  exports.GSplat_FS = GSplat_FS;
65928
66692
  exports.GSplat_VS = GSplat_VS;
@@ -66171,6 +66935,7 @@ fn frag(){
66171
66935
  exports.Quad_frag_wgsl = Quad_frag_wgsl;
66172
66936
  exports.Quad_vert_wgsl = Quad_vert_wgsl;
66173
66937
  exports.Quaternion = Quaternion;
66938
+ exports.R32UintTexture = R32UintTexture;
66174
66939
  exports.RADIANS_TO_DEGREES = RADIANS_TO_DEGREES;
66175
66940
  exports.RGBEErrorCode = RGBEErrorCode;
66176
66941
  exports.RGBEHeader = RGBEHeader;