@zephyr3d/scene 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/asset/assetmanager.js +1 -1
  2. package/dist/index.d.ts +34 -4
  3. package/dist/material/lightmodel.js +6 -7
  4. package/dist/material/lightmodel.js.map +1 -1
  5. package/dist/material/lit.js +5 -99
  6. package/dist/material/lit.js.map +1 -1
  7. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +8 -1
  8. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  9. package/dist/material/mixins/pbr/common.js +2 -0
  10. package/dist/material/mixins/pbr/common.js.map +1 -1
  11. package/dist/material/mixins/vertexcolor.js +2 -0
  12. package/dist/material/mixins/vertexcolor.js.map +1 -1
  13. package/dist/material/pbrmr.js +1 -1
  14. package/dist/material/pbrsg.js +9 -4
  15. package/dist/material/pbrsg.js.map +1 -1
  16. package/dist/material/terrainlightmodel.js +1 -3
  17. package/dist/material/terrainlightmodel.js.map +1 -1
  18. package/dist/render/depth_pass.js +2 -3
  19. package/dist/render/depth_pass.js.map +1 -1
  20. package/dist/render/forward.js +6 -3
  21. package/dist/render/forward.js.map +1 -1
  22. package/dist/render/forward_pass.js +5 -6
  23. package/dist/render/forward_pass.js.map +1 -1
  24. package/dist/render/render_queue.js +1 -1
  25. package/dist/scene/mesh.js +1 -1
  26. package/dist/scene/octree.js +3 -3
  27. package/dist/shaders/lighting.js +10 -14
  28. package/dist/shaders/lighting.js.map +1 -1
  29. package/dist/utility/noisetexture.js +66 -0
  30. package/dist/utility/noisetexture.js.map +1 -0
  31. package/dist/utility/textures/gradientnoise.js +66 -0
  32. package/dist/utility/textures/gradientnoise.js.map +1 -0
  33. package/dist/utility/textures/randomnoise.js +41 -0
  34. package/dist/utility/textures/randomnoise.js.map +1 -0
  35. package/package.json +1 -1
  36. package/dist/material/grassmat.js +0 -127
  37. package/dist/material/grassmat.js.map +0 -1
  38. package/dist/material/terrainmat.js +0 -357
  39. package/dist/material/terrainmat.js.map +0 -1
  40. package/dist/utility/sheenlut.js +0 -196
  41. package/dist/utility/sheenlut.js.map +0 -1
@@ -189,7 +189,7 @@ import { TGALoader } from './loaders/image/tga_Loader.js';
189
189
  * @returns The created model node
190
190
  */ async fetchModel(scene, url, options) {
191
191
  const sharedModel = await this.fetchModelData(scene, url, options?.mimeType, options?.postProcess);
192
- return this.createSceneNode(scene, sharedModel, !options?.disableInstancing);
192
+ return this.createSceneNode(scene, sharedModel, !!options?.enableInstancing);
193
193
  }
194
194
  /** @internal */ async loadTextData(url, postProcess) {
195
195
  let text = await this._httpRequest.requestText(url);
package/dist/index.d.ts CHANGED
@@ -634,6 +634,7 @@ declare const XForm_base: (new (...args: any[]) => {
634
634
  removed: boolean;
635
635
  }[];
636
636
  }>;
637
+ /** Inverse of the world transformation matrix of the xform */
637
638
  _internalRemoveEventListener<K_4 extends "nodeattached" | "noderemoved" | "transformchanged">(listenerMap: Partial<{
638
639
  [type: string]: {
639
640
  handler: _zephyr3d_base.EventListener<{
@@ -1382,6 +1383,7 @@ type CachedBindGroup = {
1382
1383
  buffer: Float32Array;
1383
1384
  dirty: boolean;
1384
1385
  };
1386
+ /** @internal */
1385
1387
  declare class InstanceBindGroupAllocator {
1386
1388
  private static _instanceBindGroupLayout;
1387
1389
  _usedBindGroupList: CachedBindGroup[];
@@ -2953,6 +2955,8 @@ interface IMixinVertexColor {
2953
2955
  *
2954
2956
  * @param BaseCls - Base class to mix in
2955
2957
  * @returns Mixed class
2958
+ *
2959
+ * @public
2956
2960
  */
2957
2961
  declare function mixinVertexColor<T extends typeof MeshMaterial>(BaseCls: T): T & (new (...args: any[]) => IMixinVertexColor);
2958
2962
 
@@ -3177,6 +3181,8 @@ type IMixinPBRCommon = {
3177
3181
  * PBR common stuff mixin
3178
3182
  * @param BaseCls - Class to mix in
3179
3183
  * @returns Mixed class
3184
+ *
3185
+ * @public
3180
3186
  */
3181
3187
  declare function mixinPBRCommon<T extends typeof MeshMaterial>(BaseCls: T): T & (new (...args: any[]) => IMixinPBRCommon);
3182
3188
 
@@ -3309,7 +3315,7 @@ declare class TerrainMaterial extends TerrainMaterial_base {
3309
3315
 
3310
3316
  declare const PBRMetallicRoughnessMaterial_base: typeof MeshMaterial & (new (...args: any[]) => IMixinPBRMetallicRoughness) & (new (...args: any[]) => IMixinVertexColor);
3311
3317
  /**
3312
- * PBRMetallicRoughness material class
3318
+ * PBRMetallicRoughnessMaterial class
3313
3319
  * @public
3314
3320
  */
3315
3321
  declare class PBRMetallicRoughnessMaterial extends PBRMetallicRoughnessMaterial_base {
@@ -3331,18 +3337,39 @@ declare class PBRMetallicRoughnessMaterial extends PBRMetallicRoughnessMaterial_
3331
3337
  fragmentShader(scope: PBFunctionScope): void;
3332
3338
  }
3333
3339
 
3340
+ /**
3341
+ * Interface for PBRSpecularGlossiness mixin
3342
+ * @public
3343
+ */
3334
3344
  type IMixinPBRSpecularGlossiness = {
3335
3345
  specularFactor: Vector4;
3336
3346
  glossinessFactor: number;
3337
3347
  PBRLight(scope: PBInsideFunctionScope, worldPos: PBShaderExp, normal: PBShaderExp, viewVec: PBShaderExp, albedo: PBShaderExp, TBN?: PBShaderExp): PBShaderExp;
3338
3348
  calculateCommonData(scope: PBInsideFunctionScope, albedo: PBShaderExp, viewVec: PBShaderExp, TBN: PBShaderExp, data: PBShaderExp): void;
3339
3349
  } & IMixinPBRCommon & IMixinLight & TextureMixinInstanceTypes<['specular']>;
3350
+ /**
3351
+ * PBRSpecularGlossiness mixin
3352
+ *
3353
+ * @param BaseCls - Base class to mix in
3354
+ * @returns Mixed class
3355
+ *
3356
+ * @public
3357
+ */
3340
3358
  declare function mixinPBRSpecularGlossness<T extends typeof MeshMaterial>(BaseCls: T): T & (new (...args: any[]) => IMixinPBRSpecularGlossiness);
3341
3359
 
3342
3360
  declare const PBRSpecularGlossinessMaterial_base: typeof MeshMaterial & (new (...args: any[]) => IMixinPBRSpecularGlossiness) & (new (...args: any[]) => IMixinVertexColor);
3361
+ /**
3362
+ * PBRSpecularGlossinessMaterial class
3363
+ * @public
3364
+ */
3343
3365
  declare class PBRSpecularGlossinessMaterial extends PBRSpecularGlossinessMaterial_base {
3366
+ /** @internal */
3344
3367
  private static FEATURE_VERTEX_NORMAL;
3368
+ /** @internal */
3345
3369
  private static FEATURE_VERTEX_TANGENT;
3370
+ /**
3371
+ * Creates an instance of PBRSpecularGlossinessMaterial class
3372
+ */
3346
3373
  constructor();
3347
3374
  /** true if vertex normal attribute presents */
3348
3375
  get vertexNormal(): boolean;
@@ -3415,7 +3442,7 @@ declare class Mesh extends GraphNode implements BatchDrawable {
3415
3442
  */
3416
3443
  getInstanceId(renderPass: RenderPass): string;
3417
3444
  /**
3418
- * {@inheritDoc BatchDrawable.getInstanceUniformCount}
3445
+ * {@inheritDoc BatchDrawable.getInstanceUniforms}
3419
3446
  */
3420
3447
  getInstanceUniforms(): Float32Array;
3421
3448
  /**
@@ -4796,7 +4823,7 @@ interface BatchDrawable extends Drawable {
4796
4823
  */
4797
4824
  getInstanceId(renderPass: RenderPass): string;
4798
4825
  /**
4799
- * Gets the instance uniforms count
4826
+ * Gets the instance uniforms
4800
4827
  */
4801
4828
  getInstanceUniforms(): Float32Array;
4802
4829
  /**
@@ -7489,8 +7516,11 @@ type TextureFetchOptions<T extends BaseTexture> = {
7489
7516
  * @public
7490
7517
  **/
7491
7518
  type ModelFetchOptions = {
7519
+ /** MIME type of the model, if not specified, model type will be determined by file extension */
7492
7520
  mimeType?: string;
7493
- disableInstancing?: boolean;
7521
+ /** True if the model need to be rendered instanced, the default value is false */
7522
+ enableInstancing?: boolean;
7523
+ /** PostProcess loading function for the mesh */
7494
7524
  postProcess?: (model: SharedModel) => SharedModel;
7495
7525
  };
7496
7526
  /**
@@ -699,6 +699,7 @@ const TEX_NAME_CLEARCOAT_NORMAL = 'clearcoatNormal';
699
699
  * Unlit light model
700
700
  * @public
701
701
  */ class UnlitLightModel extends LightModel {
702
+ /** @internal */ static funcNameBRDFUnlit = 'libLM_brdfUnlit';
702
703
  /**
703
704
  * {@inheritDoc LightModel.supportLighting}
704
705
  * @override
@@ -906,10 +907,10 @@ const TEX_NAME_CLEARCOAT_NORMAL = 'clearcoatNormal';
906
907
  ], function() {
907
908
  this.$l.n = this.bits;
908
909
  this.n = pb.compOr(pb.sal(this.n, 16), pb.sar(this.n, 16));
909
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xaaaaaaaa), 1));
910
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xcccccccc), 2));
911
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0f0f0f0f), 4), pb.sar(pb.compAnd(this.n, 0xf0f0f0f0), 4));
912
- this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00ff00ff), 8), pb.sar(pb.compAnd(this.n, 0xff00ff00), 8));
910
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xAAAAAAAA), 1));
911
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xCCCCCCCC), 2));
912
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0F0F0F0F), 4), pb.sar(pb.compAnd(this.n, 0xF0F0F0F0), 4));
913
+ this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00FF00FF), 8), pb.sar(pb.compAnd(this.n, 0xFF00FF00), 8));
913
914
  this.$return(pb.mul(pb.float(this.n), 2.3283064365386963e-10));
914
915
  });
915
916
  pb.func('hammersley2d', [
@@ -1038,9 +1039,7 @@ const TEX_NAME_CLEARCOAT_NORMAL = 'clearcoatNormal';
1038
1039
  rs.useRasterizerState().setCullMode('none');
1039
1040
  rs.useDepthState().enableTest(false).enableWrite(false);
1040
1041
  const tex = device.createTexture2D('rgba8unorm', size, size, {
1041
- samplerOptions: {
1042
- mipFilter: 'none'
1043
- }
1042
+ noMipmap: true
1044
1043
  });
1045
1044
  tex.name = 'GGXLUT';
1046
1045
  const fb = device.createFrameBuffer([
@@ -1 +1 @@
1
- {"version":3,"file":"lightmodel.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -30,10 +30,7 @@ class LitMaterial extends MeshMaterial {
30
30
  return this._normalScale;
31
31
  }
32
32
  set normalScale(val) {
33
- if (val !== this._normalScale) {
34
- this._normalScale = val;
35
- this.optionChanged(false);
36
- }
33
+ this._normalScale = val;
37
34
  }
38
35
  get normalMapMode() {
39
36
  return this.featureUsed(LitMaterial.FEATURE_OBJECT_SPACE_NORMALMAP, RENDER_PASS_TYPE_FORWARD);
@@ -63,15 +60,11 @@ class LitMaterial extends MeshMaterial {
63
60
  return this._normalTexture;
64
61
  }
65
62
  set normalTexture(tex) {
66
- if (this._normalTexture !== tex) {
67
- this.useFeature(LitMaterial.FEATURE_NORMAL_TEXTURE, !!tex);
68
- if (tex) {
69
- this.useFeature(LitMaterial.FEATURE_NORMAL_TEXCOORD_INDEX, this._normalTexCoordIndex);
70
- this.useFeature(LitMaterial.FEATURE_NORMAL_TEXTURE_MATRIX, !!this._normalTexCoordMatrix);
71
- }
72
- this._normalTexture = tex ?? null;
73
- this.optionChanged(false);
63
+ this.useFeature(LitMaterial.FEATURE_NORMAL_TEXTURE, !!tex);
64
+ if (tex) {
65
+ this.useFeature(LitMaterial.FEATURE_NORMAL_TEXCOORD_INDEX, this._normalTexCoordIndex);
74
66
  }
67
+ this._normalTexture = tex ?? null;
75
68
  }
76
69
  /** Normal texture sampler */ get normalTextureSampler() {
77
70
  return this._normalSampler;
@@ -99,7 +92,6 @@ class LitMaterial extends MeshMaterial {
99
92
  if (this._normalTexture) {
100
93
  this.useFeature(LitMaterial.FEATURE_NORMAL_TEXTURE_MATRIX, !!this._normalTexCoordMatrix);
101
94
  }
102
- this.optionChanged(false);
103
95
  }
104
96
  }
105
97
  /**
@@ -205,92 +197,6 @@ class LitMaterial extends MeshMaterial {
205
197
  return pb.getGlobalScope().kkCalculateNormal(...args);
206
198
  }
207
199
  /**
208
- * Calculate the normal vector for current fragment
209
- * @param scope - The shader scope
210
- * @param ctx - The drawing context
211
- * @returns Structure that contains normal vector and TBN matrix
212
- */ calculateNormalAndTBN(scope, ctx) {
213
- const pb = scope.$builder;
214
- const NormalStruct = pb.defineStruct([
215
- pb.mat3('TBN'),
216
- pb.vec3('normal')
217
- ]);
218
- const that = this;
219
- const args = [];
220
- const params = [];
221
- const worldNormal = ShaderFramework.getWorldNormal(scope);
222
- const worldTangent = ShaderFramework.getWorldTangent(scope);
223
- const worldBinormal = ShaderFramework.getWorldBinormal(scope);
224
- if (worldNormal) {
225
- params.push(pb.vec3('worldNormal'));
226
- args.push(worldNormal);
227
- if (worldTangent) {
228
- params.push(pb.vec3('worldTangent'), pb.vec3('worldBinormal'));
229
- args.push(worldTangent, worldBinormal);
230
- }
231
- }
232
- pb.func('kkCalculateNormalAndTBN', params, function() {
233
- const posW = ShaderFramework.getWorldPosition(this).xyz;
234
- this.$l.uv = that.featureUsed(LitMaterial.FEATURE_NORMAL_TEXTURE, ctx.renderPass.type) ? scope.$inputs.kkNormalTexCoord ?? pb.vec2(0) : that.featureUsed(LitMaterial.FEATURE_NORMAL_TEXTURE, ctx.renderPass.type) ? scope.$inputs.kkAlbedoTexCoord ?? pb.vec2(0) : pb.vec2(0);
235
- this.$l.TBN = pb.mat3();
236
- if (!worldNormal) {
237
- this.$l.uv_dx = pb.dpdx(pb.vec3(this.uv, 0));
238
- this.$l.uv_dy = pb.dpdy(pb.vec3(this.uv, 0));
239
- this.$if(pb.lessThanEqual(pb.add(pb.length(this.uv_dx), pb.length(this.uv_dy)), 0.000001), function() {
240
- this.uv_dx = pb.vec3(1, 0, 0);
241
- this.uv_dy = pb.vec3(0, 1, 0);
242
- });
243
- this.$l.t_ = pb.div(pb.sub(pb.mul(pb.dpdx(posW), this.uv_dy.y), pb.mul(pb.dpdy(posW), this.uv_dx.y)), pb.sub(pb.mul(this.uv_dx.x, this.uv_dy.y), pb.mul(this.uv_dx.y, this.uv_dy.x)));
244
- this.$l.ng = pb.normalize(pb.cross(pb.dpdx(posW), pb.dpdy(posW)));
245
- this.$l.t = pb.normalize(pb.sub(this.t_, pb.mul(this.ng, pb.dot(this.ng, this.t_))));
246
- this.$l.b = pb.cross(this.ng, this.t);
247
- if (that.doubleSidedLighting) {
248
- this.$if(pb.not(this.$builtins.frontFacing), function() {
249
- this.t = pb.mul(this.t, -1);
250
- this.b = pb.mul(this.b, -1);
251
- this.ng = pb.mul(this.ng, -1);
252
- });
253
- }
254
- this.TBN = pb.mat3(this.t, this.b, this.ng);
255
- } else if (!worldTangent) {
256
- this.$l.uv_dx = pb.dpdx(pb.vec3(this.uv, 0));
257
- this.$l.uv_dy = pb.dpdy(pb.vec3(this.uv, 0));
258
- this.$if(pb.lessThanEqual(pb.add(pb.length(this.uv_dx), pb.length(this.uv_dy)), 0.000001), function() {
259
- this.uv_dx = pb.vec3(1, 0, 0);
260
- this.uv_dy = pb.vec3(0, 1, 0);
261
- });
262
- this.$l.t_ = pb.div(pb.sub(pb.mul(pb.dpdx(posW), this.uv_dy.y), pb.mul(pb.dpdy(posW), this.uv_dx.y)), pb.sub(pb.mul(this.uv_dx.x, this.uv_dy.y), pb.mul(this.uv_dx.y, this.uv_dy.x)));
263
- this.$l.ng = pb.normalize(this.worldNormal);
264
- this.$l.t = pb.normalize(pb.sub(this.t_, pb.mul(this.ng, pb.dot(this.ng, this.t_))));
265
- this.$l.b = pb.cross(this.ng, this.t);
266
- if (that.doubleSidedLighting) {
267
- this.$if(pb.not(this.$builtins.frontFacing), function() {
268
- this.t = pb.mul(this.t, -1);
269
- this.b = pb.mul(this.b, -1);
270
- this.ng = pb.mul(this.ng, -1);
271
- });
272
- }
273
- this.TBN = pb.mat3(this.t, this.b, this.ng);
274
- } else {
275
- this.TBN = pb.mat3(pb.normalize(this.worldTangent), pb.normalize(this.worldBinormal), pb.normalize(this.worldNormal));
276
- }
277
- if (that.featureUsed(LitMaterial.FEATURE_NORMAL_TEXTURE, ctx.renderPass.type)) {
278
- if (that.normalMapMode === 'object-space') {
279
- const pixel = pb.sub(pb.mul(pb.textureSample(this.kkNormalTexture, this.uv).rgb, 2), pb.vec3(1));
280
- const normalTex = pb.mul(pixel, pb.vec3(pb.vec3(this.kkNormalScale).xx, 1));
281
- this.$return(NormalStruct(this.TBN, pb.normalize(normalTex)));
282
- } else {
283
- const pixel = pb.sub(pb.mul(pb.textureSample(this.kkNormalTexture, this.uv).rgb, 2), pb.vec3(1));
284
- const normalTex = pb.mul(pixel, pb.vec3(pb.vec3(this.kkNormalScale).xx, 1));
285
- this.$return(NormalStruct(this.TBN, pb.normalize(pb.mul(this.TBN, normalTex))));
286
- }
287
- } else {
288
- this.$return(NormalStruct(this.TBN, this.TBN[2]));
289
- }
290
- });
291
- return pb.getGlobalScope().kkCalculateNormalAndTBN(...args);
292
- }
293
- /**
294
200
  * {@inheritDoc MeshMaterial.applyUniformsValues}
295
201
  * @override
296
202
  */ applyUniformValues(bindGroup, ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"lit.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lit.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,14 @@ import { mixinPBRCommon } from '../pbr/common.js';
4
4
  import { Vector4 } from '@zephyr3d/base';
5
5
  import { mixinLight } from '../lit.js';
6
6
 
7
- function mixinPBRSpecularGlossness(BaseCls) {
7
+ /**
8
+ * PBRSpecularGlossiness mixin
9
+ *
10
+ * @param BaseCls - Base class to mix in
11
+ * @returns Mixed class
12
+ *
13
+ * @public
14
+ */ function mixinPBRSpecularGlossness(BaseCls) {
8
15
  if (BaseCls.pbrSpecularGlossnessMixed) {
9
16
  return BaseCls;
10
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pbrspecularglossness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"pbrspecularglossness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,6 +8,8 @@ import { ShaderHelper } from '../../shader/helper.js';
8
8
  * PBR common stuff mixin
9
9
  * @param BaseCls - Class to mix in
10
10
  * @returns Mixed class
11
+ *
12
+ * @public
11
13
  */ function mixinPBRCommon(BaseCls) {
12
14
  if (BaseCls.pbrCommonMixed) {
13
15
  return BaseCls;
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"common.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * @param BaseCls - Base class to mix in
5
5
  * @returns Mixed class
6
+ *
7
+ * @public
6
8
  */ function mixinVertexColor(BaseCls) {
7
9
  if (BaseCls.vertexColorMixed) {
8
10
  return BaseCls;
@@ -1 +1 @@
1
- {"version":3,"file":"vertexcolor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"vertexcolor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,7 @@ import { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughn
4
4
  import { ShaderHelper } from './shader/helper.js';
5
5
 
6
6
  /**
7
- * PBRMetallicRoughness material class
7
+ * PBRMetallicRoughnessMaterial class
8
8
  * @public
9
9
  */ class PBRMetallicRoughnessMaterial extends applyMaterialMixins(MeshMaterial, mixinPBRMetallicRoughness, mixinVertexColor) {
10
10
  /** @internal */ static FEATURE_VERTEX_NORMAL = this.defineFeature();
@@ -3,10 +3,15 @@ import { mixinVertexColor } from './mixins/vertexcolor.js';
3
3
  import { mixinPBRSpecularGlossness } from './mixins/lightmodel/pbrspecularglossness.js';
4
4
  import { ShaderHelper } from './shader/helper.js';
5
5
 
6
- class PBRSpecularGlossinessMaterial extends applyMaterialMixins(MeshMaterial, mixinPBRSpecularGlossness, mixinVertexColor) {
7
- static FEATURE_VERTEX_NORMAL = this.defineFeature();
8
- static FEATURE_VERTEX_TANGENT = this.defineFeature();
9
- constructor(){
6
+ /**
7
+ * PBRSpecularGlossinessMaterial class
8
+ * @public
9
+ */ class PBRSpecularGlossinessMaterial extends applyMaterialMixins(MeshMaterial, mixinPBRSpecularGlossness, mixinVertexColor) {
10
+ /** @internal */ static FEATURE_VERTEX_NORMAL = this.defineFeature();
11
+ /** @internal */ static FEATURE_VERTEX_TANGENT = this.defineFeature();
12
+ /**
13
+ * Creates an instance of PBRSpecularGlossinessMaterial class
14
+ */ constructor(){
10
15
  super();
11
16
  this.useFeature(PBRSpecularGlossinessMaterial.FEATURE_VERTEX_NORMAL, true);
12
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pbrsg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"pbrsg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -187,9 +187,7 @@ class TerrainLightModel extends PBRLightModelMR {
187
187
  const device = Application.instance.device;
188
188
  if (!this._options) {
189
189
  const tex = device.createTexture2D('rgba8unorm', 1, 1, {
190
- samplerOptions: {
191
- mipFilter: 'none'
192
- }
190
+ noMipmap: true
193
191
  });
194
192
  tex.update(new Uint8Array([
195
193
  0,
@@ -1 +1 @@
1
- {"version":3,"file":"terrainlightmodel.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"terrainlightmodel.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,7 @@
1
1
  import { RenderPass } from './renderpass.js';
2
2
  import { RENDER_PASS_TYPE_DEPTH_ONLY } from '../values.js';
3
- import { ShaderFramework } from '../shaders/framework.js';
4
- import '@zephyr3d/device';
5
3
  import { Application } from '../app.js';
4
+ import { ShaderHelper } from '../material/shader/helper.js';
6
5
 
7
6
  /**
8
7
  * Depth render pass
@@ -29,7 +28,7 @@ import { Application } from '../app.js';
29
28
  const device = Application.instance.device;
30
29
  const bindGroup = this.getGlobalBindGroupInfo(ctx).bindGroup;
31
30
  device.setBindGroup(0, bindGroup);
32
- ShaderFramework.setCameraUniforms(bindGroup, ctx, true);
31
+ ShaderHelper.setCameraUniforms(bindGroup, ctx, true);
33
32
  ctx.renderPassHash = this.getGlobalBindGroupHash(ctx);
34
33
  const reverseWinding = ctx.camera.worldMatrixDet < 0;
35
34
  for (const order of Object.keys(renderQueue.items).map((val)=>Number(val)).sort((a, b)=>a - b)){
@@ -1 +1 @@
1
- {"version":3,"file":"depth_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"depth_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,14 +5,17 @@ import { Vector4 } from '@zephyr3d/base';
5
5
  import { Application } from '../app.js';
6
6
  import '../shaders/framework.js';
7
7
  import '@zephyr3d/device';
8
+ import '../material/shader/helper.js';
8
9
  import { CopyBlitter } from '../blitter/copy.js';
9
10
  import '../scene/octree.js';
10
- import '../material/material.js';
11
- import './scatteringlut.js';
12
11
  import '../material/lambert.js';
13
12
  import '../material/blinn.js';
14
13
  import '../material/unlit.js';
15
- import '../material/lightmodel.js';
14
+ import '../material/material.js';
15
+ import '../material/grassmaterial.js';
16
+ import '../material/terrainmaterial.js';
17
+ import '../material/pbrmr.js';
18
+ import '../material/pbrsg.js';
16
19
  import './sky.js';
17
20
  import './clipmap.js';
18
21
  import { TemporalCache } from './temporalcache.js';
@@ -1 +1 @@
1
- {"version":3,"file":"forward.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"forward.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,9 +1,8 @@
1
1
  import { RenderPass } from './renderpass.js';
2
2
  import { RENDER_PASS_TYPE_FORWARD } from '../values.js';
3
- import { ShaderFramework } from '../shaders/framework.js';
4
- import '@zephyr3d/device';
5
3
  import { Application } from '../app.js';
6
4
  import { Vector4 } from '@zephyr3d/base';
5
+ import { ShaderHelper } from '../material/shader/helper.js';
7
6
 
8
7
  /**
9
8
  * Forward render pass
@@ -61,14 +60,14 @@ import { Vector4 } from '@zephyr3d/base';
61
60
  ctx.drawEnvLight = baseLightPass && ctx.env.light.type !== 'none' && (ctx.env.light.envLight.hasRadiance() || ctx.env.light.envLight.hasIrradiance());
62
61
  ctx.renderPassHash = this.getGlobalBindGroupHash(ctx);
63
62
  const info = this.getGlobalBindGroupInfo(ctx);
64
- ShaderFramework.setCameraUniforms(info.bindGroup, ctx, !!device.getFramebuffer());
63
+ ShaderHelper.setCameraUniforms(info.bindGroup, ctx, !!device.getFramebuffer());
65
64
  if (ctx.currentShadowLight) {
66
- ShaderFramework.setLightUniformsShadow(info.bindGroup, ctx, lights[0]);
65
+ ShaderHelper.setLightUniformsShadow(info.bindGroup, ctx, lights[0]);
67
66
  } else {
68
- ShaderFramework.setLightUniforms(info.bindGroup, ctx, ctx.clusteredLight.clusterParam, ctx.clusteredLight.countParam, ctx.clusteredLight.lightBuffer, ctx.clusteredLight.lightIndexTexture);
67
+ ShaderHelper.setLightUniforms(info.bindGroup, ctx, ctx.clusteredLight.clusterParam, ctx.clusteredLight.countParam, ctx.clusteredLight.lightBuffer, ctx.clusteredLight.lightIndexTexture);
69
68
  }
70
69
  if (ctx.applyFog) {
71
- ShaderFramework.setFogUniforms(info.bindGroup, ctx.env.sky.mappedFogType, baseLightPass ? ctx.env.sky.fogColor : Vector4.zero(), ctx.env.sky.fogParams, ctx.env.sky.getAerialPerspectiveLUT(ctx));
70
+ ShaderHelper.setFogUniforms(info.bindGroup, ctx.env.sky.mappedFogType, baseLightPass ? ctx.env.sky.fogColor : Vector4.zero(), ctx.env.sky.fogParams, ctx.env.sky.getAerialPerspectiveLUT(ctx));
72
71
  }
73
72
  device.setBindGroup(0, info.bindGroup);
74
73
  if (blend) {
@@ -1 +1 @@
1
- {"version":3,"file":"forward_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"forward_pass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -13,7 +13,7 @@ import '../material/pbrmr.js';
13
13
  import '../material/pbrsg.js';
14
14
  import '@zephyr3d/base';
15
15
 
16
- class InstanceBindGroupAllocator {
16
+ /** @internal */ class InstanceBindGroupAllocator {
17
17
  static _instanceBindGroupLayout = null;
18
18
  _usedBindGroupList = [];
19
19
  _freeBindGroupList = [];
@@ -63,7 +63,7 @@ import { QUEUE_OPAQUE } from '../values.js';
63
63
  return `${this._instanceHash}:${this.worldMatrixDet >= 0}`;
64
64
  }
65
65
  /**
66
- * {@inheritDoc BatchDrawable.getInstanceUniformCount}
66
+ * {@inheritDoc BatchDrawable.getInstanceUniforms}
67
67
  */ getInstanceUniforms() {
68
68
  return this.material.$instanceUniforms;
69
69
  }
@@ -520,9 +520,9 @@ var OctreePlacement;
520
520
  }
521
521
  const dim = this._chunks[level].getDimension();
522
522
  const inv_node_size = 1 / this._chunks[level].getNodeSize();
523
- let px = Math.floor((center.x + this._rootSize * 0.5) * inv_node_size);
524
- let py = Math.floor((center.y + this._rootSize * 0.5) * inv_node_size);
525
- let pz = Math.floor((center.z + this._rootSize * 0.5) * inv_node_size);
523
+ const px = Math.floor((center.x + this._rootSize * 0.5) * inv_node_size);
524
+ const py = Math.floor((center.y + this._rootSize * 0.5) * inv_node_size);
525
+ const pz = Math.floor((center.z + this._rootSize * 0.5) * inv_node_size);
526
526
  if (px >= dim || py >= dim || pz >= dim) {
527
527
  return null;
528
528
  }
@@ -38,14 +38,10 @@ import { Application } from '../app.js';
38
38
  pb.vec3('attenuation')
39
39
  ], function() {
40
40
  this.$l.dist = pb.distance(this.lightPositionRange.xyz, ShaderFramework.getWorldPosition(this).xyz);
41
- this.$l.a = pb.div(1, pb.add(1, pb.mul(this.dist, this.dist)));
42
- this.$l.falloff = pb.mul(this.a, pb.clamp(pb.sub(1, pb.div(this.dist, this.lightPositionRange.w)), 0, 1));
43
- //this.$l.t = pb.div(pb.mul(this.dist, 16), this.lightPositionRange.w);
44
- //this.$l.falloff = pb.div(1, pb.add(1, pb.mul(this.t, this.t)));
45
- //this.$l.falloff = pb.div(1, ) pb.max(0, pb.sub(1, pb.div(this.dist, this.lightPositionRange.w)));
46
- //this.falloff = pb.mul(this.falloff, this.falloff);
47
- this.$if(pb.greaterThan(this.falloff, 0), function() {
48
- lm.directBRDF(this, this.lightDir, pb.mul(this.attenuation, this.falloff));
41
+ this.$l.falloff = pb.max(0, pb.sub(1, pb.div(this.dist, this.lightPositionRange.w)));
42
+ this.$l.falloff2 = pb.mul(this.falloff, this.falloff);
43
+ this.$if(pb.greaterThan(this.falloff2, 0), function() {
44
+ lm.directBRDF(this, this.lightDir, pb.mul(this.attenuation, this.falloff2));
49
45
  });
50
46
  });
51
47
  pb.getGlobalScope()[funcNameIllumPointLight](...args);
@@ -170,12 +166,12 @@ import { Application } from '../app.js';
170
166
  this.lightDir = this.directionCutoff.xyz;
171
167
  this.$l.nl = pb.dot(this.surfaceData.normal, this.lightDir);
172
168
  this.$l.NdotL = pb.clamp(pb.neg(this.nl), 0, 1);
173
- this.$l.shadowBound = pb.vec4(0, 0, 1, 1);
174
- this.$l.linearDepth = nonLinearDepthToLinear(this, this.$builtins.fragCoord.z);
175
- this.$l.splitDistances = ShaderFramework.getCascadeDistances(this);
176
- this.$l.comparison = pb.vec4(pb.greaterThan(pb.vec4(this.linearDepth), this.splitDistances));
177
- this.$l.cascadeFlags = pb.vec4(pb.float(pb.greaterThan(this.shadowCascades, 0)), pb.float(pb.greaterThan(this.shadowCascades, 1)), pb.float(pb.greaterThan(this.shadowCascades, 2)), pb.float(pb.greaterThan(this.shadowCascades, 3)));
178
- this.$l.split = pb.int(pb.dot(this.comparison, this.cascadeFlags));
169
+ this.shadowBound = pb.vec4(0, 0, 1, 1);
170
+ this.linearDepth = nonLinearDepthToLinear(this, this.$builtins.fragCoord.z);
171
+ this.splitDistances = ShaderFramework.getCascadeDistances(this);
172
+ this.comparison = pb.vec4(pb.greaterThan(pb.vec4(this.linearDepth), this.splitDistances));
173
+ this.cascadeFlags = pb.vec4(pb.float(pb.greaterThan(this.shadowCascades, 0)), pb.float(pb.greaterThan(this.shadowCascades, 1)), pb.float(pb.greaterThan(this.shadowCascades, 2)), pb.float(pb.greaterThan(this.shadowCascades, 3)));
174
+ this.split = pb.int(pb.dot(this.comparison, this.cascadeFlags));
179
175
  this.$l.shadowVertex = pb.vec4();
180
176
  if (Application.instance.device.type === 'webgl') {
181
177
  this.$for(pb.int('cascade'), 0, 4, function() {
@@ -1 +1 @@
1
- {"version":3,"file":"lighting.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lighting.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}