sparcoon 0.4.0 → 0.4.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.
@@ -18,6 +18,6 @@ export interface FXScatterUniforms {
18
18
  value: number;
19
19
  };
20
20
  }
21
- export declare function buildFXDiffuseMaterial(varyings: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean, alphaTest: number, albedoNodes: readonly (FXColorNode | FXTextureNode)[], normalNodes: readonly (FXTextureNode | FXNormalNode)[], emissionNodes: readonly (FXColorNode | FXTextureNode)[], scatterUniforms?: FXScatterUniforms, shadowSensitivity?: {
21
+ export declare function buildFXDiffuseMaterial(varyings: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean, alphaTest: number, premultipliedAlpha: boolean, albedoNodes: readonly (FXColorNode | FXTextureNode)[], normalNodes: readonly (FXTextureNode | FXNormalNode)[], emissionNodes: readonly (FXColorNode | FXTextureNode)[], scatterUniforms?: FXScatterUniforms, shadowSensitivity?: {
22
22
  value: number;
23
- }, premultipliedAlpha?: boolean): MeshLambertMaterial;
23
+ }): MeshLambertMaterial;
@@ -37,7 +37,7 @@ function wrapShadowCalls(source, uniformName) {
37
37
  }
38
38
  return result;
39
39
  }
40
- function buildFXDiffuseMaterial(varyings, blending, useAlphaHashing, alphaTest, albedoNodes, normalNodes, emissionNodes, scatterUniforms, shadowSensitivity, premultipliedAlpha) {
40
+ function buildFXDiffuseMaterial(varyings, blending, useAlphaHashing, alphaTest, premultipliedAlpha, albedoNodes, normalNodes, emissionNodes, scatterUniforms, shadowSensitivity) {
41
41
  const useScatter = scatterUniforms !== undefined;
42
42
  const useShadowSensitivity = shadowSensitivity !== undefined;
43
43
  const attributeDeclarations = [];
@@ -13,14 +13,12 @@ export interface FXDiffuseMaterialOptions extends FXMaterialOptions {
13
13
  forwardScatterStrength: number;
14
14
  backScatterStrength: number;
15
15
  shadowSensitivity: number;
16
- premultipliedAlpha: boolean;
17
16
  }
18
17
  export declare class FXDiffuseMaterial extends FXMaterial {
19
18
  private readonly normalNodes;
20
19
  private readonly emissionNodes;
21
20
  private readonly scatterUniforms;
22
21
  private readonly shadowSensitivity;
23
- private readonly premultipliedAlpha;
24
22
  constructor(options?: Partial<FXDiffuseMaterialOptions>);
25
23
  destroy(): void;
26
24
  }
@@ -22,7 +22,6 @@ class FXDiffuseMaterial extends FXMaterial {
22
22
  }
23
23
  : undefined;
24
24
  this._private_shadowSensitivity = { value: options.shadowSensitivity ?? 1 };
25
- this._private_premultipliedAlpha = options.premultipliedAlpha ?? false;
26
25
  }
27
26
  destroy() {
28
27
  super.destroy();
@@ -35,7 +34,7 @@ class FXDiffuseMaterial extends FXMaterial {
35
34
  }
36
35
  /** @internal */
37
36
  buildThreeMaterial(varyings) {
38
- return buildFXDiffuseMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.albedoNodes, this._private_normalNodes, this._private_emissionNodes, this._private_scatterUniforms, this._private_shadowSensitivity, this._private_premultipliedAlpha);
37
+ return buildFXDiffuseMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.premultipliedAlpha, this.albedoNodes, this._private_normalNodes, this._private_emissionNodes, this._private_scatterUniforms, this._private_shadowSensitivity);
39
38
  }
40
39
  }
41
40
 
@@ -2,19 +2,20 @@ import type { Blending, MeshDistanceMaterial } from "three";
2
2
  import type { FXColorNode } from "../../nodes/color/FXColorNode";
3
3
  import type { FXTextureNode } from "../../nodes/texture/FXTextureNode";
4
4
  export interface FXMaterialOptions {
5
- albedoNodes?: (FXColorNode | FXTextureNode)[];
6
- blending?: Blending;
7
- useAlphaHashing?: boolean;
8
- alphaTest?: number;
9
- depthAlphaTest?: number;
10
- useDepthAlphaHash?: boolean;
11
- useSphericalDepth?: boolean;
5
+ albedoNodes: (FXColorNode | FXTextureNode)[];
6
+ blending: Blending;
7
+ useAlphaHashing: boolean;
8
+ alphaTest: number;
9
+ depthAlphaTest: number;
10
+ useDepthAlphaHash: boolean;
11
+ useSphericalDepth: boolean;
12
+ premultipliedAlpha: boolean;
12
13
  }
13
14
  export declare abstract class FXMaterial {
14
15
  private readonly depthAlphaTest;
15
16
  private readonly useDepthAlphaHash;
16
17
  private readonly useSphericalDepth;
17
- constructor(options?: FXMaterialOptions);
18
+ constructor(options?: Partial<FXMaterialOptions>);
18
19
  destroy(): void;
19
20
  buildDistanceMaterial(): MeshDistanceMaterial;
20
21
  }
@@ -8,6 +8,8 @@ class FXMaterial {
8
8
  this.blending = options.blending ?? NormalBlending;
9
9
  this.useAlphaHashing = options.useAlphaHashing ?? false;
10
10
  this.alphaTest = options.alphaTest ?? 0.0075;
11
+ this.premultipliedAlpha =
12
+ (options.useAlphaHashing === undefined && options.premultipliedAlpha) ?? true;
11
13
  this._private_depthAlphaTest = options.depthAlphaTest ?? 0.5;
12
14
  this._private_useDepthAlphaHash = options.useDepthAlphaHash ?? false;
13
15
  this._private_useSphericalDepth = options.useSphericalDepth ?? true;
@@ -3,4 +3,4 @@ import { MeshBasicMaterial } from "three";
3
3
  import type { GLTypeInfo } from "../../instancedParticle/shared";
4
4
  import type { FXColorNode } from "../../nodes/color/FXColorNode";
5
5
  import type { FXTextureNode } from "../../nodes/texture/FXTextureNode";
6
- export declare function buildFXUnlitMaterial(varyings: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean, alphaTest: number, albedoNodes: readonly (FXColorNode | FXTextureNode)[]): MeshBasicMaterial;
6
+ export declare function buildFXUnlitMaterial(varyings: Record<string, GLTypeInfo>, blending: Blending, useAlphaHashing: boolean, alphaTest: number, premultipliedAlpha: boolean, albedoNodes: readonly (FXColorNode | FXTextureNode)[]): MeshBasicMaterial;
@@ -1,7 +1,7 @@
1
1
  import { MeshBasicMaterial, DoubleSide } from 'three';
2
2
  import { PARTICLE_DEFINES } from '../../miscellaneous/miscellaneous.js';
3
3
 
4
- function buildFXUnlitMaterial(varyings, blending, useAlphaHashing, alphaTest, albedoNodes) {
4
+ function buildFXUnlitMaterial(varyings, blending, useAlphaHashing, alphaTest, premultipliedAlpha, albedoNodes) {
5
5
  const attributeDeclarations = [];
6
6
  const varyingDeclarations = [];
7
7
  const vertexAssignments = [];
@@ -21,6 +21,7 @@ function buildFXUnlitMaterial(varyings, blending, useAlphaHashing, alphaTest, al
21
21
  side: DoubleSide,
22
22
  forceSinglePass: true,
23
23
  alphaTest,
24
+ premultipliedAlpha,
24
25
  });
25
26
  material.onBeforeCompile = (shader) => {
26
27
  const vertexPreamble = [
@@ -2,5 +2,5 @@ import type { FXMaterialOptions } from "../FXMaterial/FXMaterial";
2
2
  import { FXMaterial } from "../FXMaterial/FXMaterial";
3
3
  export type FXUnlitMaterialOptions = FXMaterialOptions;
4
4
  export declare class FXUnlitMaterial extends FXMaterial {
5
- constructor(options?: FXUnlitMaterialOptions);
5
+ constructor(options?: Partial<FXUnlitMaterialOptions>);
6
6
  }
@@ -7,7 +7,7 @@ class FXUnlitMaterial extends FXMaterial {
7
7
  }
8
8
  /** @internal */
9
9
  buildThreeMaterial(varyings) {
10
- return buildFXUnlitMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.albedoNodes);
10
+ return buildFXUnlitMaterial(varyings, this.blending, this.useAlphaHashing, this.alphaTest, this.premultipliedAlpha, this.albedoNodes);
11
11
  }
12
12
  }
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparcoon",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "particles",