Skip to content

Commit f5f7bcb

Browse files
author
Mike Bond
committed
Fix error with es6 build and imageProcessing mixin
1 parent 125957b commit f5f7bcb

File tree

6 files changed

+28
-116
lines changed

6 files changed

+28
-116
lines changed

packages/dev/core/src/Materials/Node/nodeMaterial.ts

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ import { NodeMaterialBuildState } from "./nodeMaterialBuildState";
1010
import type { IEffectCreationOptions } from "../effect";
1111
import { Effect } from "../effect";
1212
import type { BaseTexture } from "../../Materials/Textures/baseTexture";
13-
import type { Observer } from "../../Misc/observable";
1413
import { Observable } from "../../Misc/observable";
1514
import { NodeMaterialBlockTargets } from "./Enums/nodeMaterialBlockTargets";
1615
import { NodeMaterialBuildStateSharedData } from "./nodeMaterialBuildStateSharedData";
1716
import type { SubMesh } from "../../Meshes/subMesh";
1817
import { MaterialDefines } from "../../Materials/materialDefines";
1918
import type { NodeMaterialOptimizer } from "./Optimizers/nodeMaterialOptimizer";
20-
import type { ImageProcessingConfiguration } from "../imageProcessingConfiguration";
2119
import type { Nullable } from "../../types";
2220
import { VertexBuffer } from "../../Buffers/buffer";
2321
import { Tools } from "../../Misc/tools";
@@ -73,6 +71,7 @@ import { AbstractEngine } from "../../Engines/abstractEngine";
7371
import type { LoopBlock } from "./Blocks/loopBlock";
7472
import { MaterialHelperGeometryRendering } from "../materialHelper.geometryrendering";
7573
import { UVDefinesMixin } from "../uv.defines";
74+
import { ImageProcessingMixin } from "../imageProcessing";
7675

7776
const onCreatedEffectParameters = { effect: null as unknown as Effect, subMesh: null as unknown as Nullable<SubMesh> };
7877

@@ -232,10 +231,11 @@ export type NodeMaterialTextureBlocks =
232231
| BiPlanarBlock
233232
| PrePassTextureBlock;
234233

234+
class NodeMaterialBase extends ImageProcessingMixin(PushMaterial) {}
235235
/**
236236
* Class used to create a node based material built by assembling shader blocks
237237
*/
238-
export class NodeMaterial extends PushMaterial {
238+
export class NodeMaterial extends NodeMaterialBase {
239239
private static _BuildIdGenerator: number = 0;
240240
private _options: INodeMaterialOptions;
241241
private _vertexCompilationState: NodeMaterialBuildState;
@@ -373,30 +373,6 @@ export class NodeMaterial extends PushMaterial {
373373
this._options = options;
374374
}
375375

376-
/**
377-
* Default configuration related to image processing available in the standard Material.
378-
*/
379-
protected _imageProcessingConfiguration: ImageProcessingConfiguration;
380-
381-
/**
382-
* Gets the image processing configuration used either in this material.
383-
*/
384-
public get imageProcessingConfiguration(): ImageProcessingConfiguration {
385-
return this._imageProcessingConfiguration;
386-
}
387-
388-
/**
389-
* Sets the Default image processing configuration used either in the this material.
390-
*
391-
* If sets to null, the scene one is in use.
392-
*/
393-
public set imageProcessingConfiguration(value: ImageProcessingConfiguration) {
394-
this._attachImageProcessingConfiguration(value);
395-
396-
// Ensure the effect will be rebuilt.
397-
this._markAllSubMeshesAsTexturesDirty();
398-
}
399-
400376
/**
401377
* Gets an array of blocks that needs to be serialized even if they are not yet connected
402378
*/
@@ -470,40 +446,6 @@ export class NodeMaterial extends PushMaterial {
470446
return "NodeMaterial";
471447
}
472448

473-
/**
474-
* Keep track of the image processing observer to allow dispose and replace.
475-
*/
476-
private _imageProcessingObserver: Nullable<Observer<ImageProcessingConfiguration>>;
477-
478-
/**
479-
* Attaches a new image processing configuration to the Standard Material.
480-
* @param configuration
481-
*/
482-
protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void {
483-
if (configuration === this._imageProcessingConfiguration) {
484-
return;
485-
}
486-
487-
// Detaches observer.
488-
if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
489-
this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
490-
}
491-
492-
// Pick the scene configuration if needed.
493-
if (!configuration) {
494-
this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
495-
} else {
496-
this._imageProcessingConfiguration = configuration;
497-
}
498-
499-
// Attaches observer.
500-
if (this._imageProcessingConfiguration) {
501-
this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(() => {
502-
this._markAllSubMeshesAsImageProcessingDirty();
503-
});
504-
}
505-
}
506-
507449
/**
508450
* Get a block by its name
509451
* @param name defines the name of the block to retrieve

packages/dev/core/src/Materials/PBR/pbr2Material.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Nullable } from "../../types";
55
import type { Scene } from "../../scene";
66
import { Color3, Color4 } from "../../Maths/math.color";
77
import { ImageProcessingConfiguration } from "../imageProcessingConfiguration";
8-
import type { BaseTexture } from "../../Materials/Textures/baseTexture";
8+
import type { BaseTexture } from "../Textures/baseTexture";
99
import { PBRBaseMaterial } from "./pbrBaseMaterial";
1010
import { RegisterClass } from "../../Misc/typeStore";
1111
import { Material } from "../material";

packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ import { PBRBRDFConfiguration } from "./pbrBRDFConfiguration";
1515
import { PrePassConfiguration } from "../prePassConfiguration";
1616
import { Color3, TmpColors } from "../../Maths/math.color";
1717

18-
import { ImageProcessingDefinesMixin } from "../../Materials/imageProcessingConfiguration.defines";
19-
import { ImageProcessingConfiguration } from "../../Materials/imageProcessingConfiguration";
20-
import type { Effect, IEffectCreationOptions } from "../../Materials/effect";
21-
import type { IMaterialCompilationOptions, ICustomShaderNameResolveOptions } from "../../Materials/material";
22-
import { Material } from "../../Materials/material";
18+
import { ImageProcessingDefinesMixin } from "../imageProcessingConfiguration.defines";
19+
import { ImageProcessingConfiguration } from "../imageProcessingConfiguration";
20+
import type { Effect, IEffectCreationOptions } from "../effect";
21+
import type { IMaterialCompilationOptions, ICustomShaderNameResolveOptions } from "../material";
22+
import { Material } from "../material";
2323
import { MaterialPluginEvent } from "../materialPluginEvent";
24-
import { MaterialDefines } from "../../Materials/materialDefines";
25-
import { PushMaterial } from "../../Materials/pushMaterial";
24+
import { MaterialDefines } from "../materialDefines";
25+
import { PushMaterial } from "../pushMaterial";
2626

27-
import type { BaseTexture } from "../../Materials/Textures/baseTexture";
28-
import { Texture } from "../../Materials/Textures/texture";
29-
import type { RenderTargetTexture } from "../../Materials/Textures/renderTargetTexture";
30-
import type { CubeTexture } from "../../Materials/Textures/cubeTexture";
27+
import type { BaseTexture } from "../Textures/baseTexture";
28+
import { Texture } from "../Textures/texture";
29+
import type { RenderTargetTexture } from "../Textures/renderTargetTexture";
30+
import type { CubeTexture } from "../Textures/cubeTexture";
3131

3232
import { MaterialFlags } from "../materialFlags";
3333
import { Constants } from "../../Engines/constants";
3434
import type { IAnimatable } from "../../Animations/animatable.interface";
3535

36-
import "../../Materials/Textures/baseTexture.polynomial";
36+
import "../Textures/baseTexture.polynomial";
3737

3838
import { EffectFallbacks } from "../effectFallbacks";
3939
import { PBRClearCoatConfiguration } from "./pbrClearCoatConfiguration";

packages/dev/core/src/Materials/imageProcessing.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import { serializeAsImageProcessingConfiguration } from "../Misc/decorators";
33
import type { Nullable } from "../types";
44
import type { ImageProcessingConfiguration } from "./imageProcessingConfiguration";
55
import type { Observer } from "../Misc/observable";
6-
import type { BaseTexture } from "../Materials/Textures/baseTexture";
7-
import type { ColorCurves } from "../Materials/colorCurves";
6+
import type { BaseTexture } from "./Textures/baseTexture";
7+
import type { ColorCurves } from "./colorCurves";
8+
9+
// Explicit re-export of types to help TypeScript resolve them in declaration files
10+
export type { Observer } from "../Misc/observable";
11+
export type { ColorCurves } from "./colorCurves";
812

913
type Constructor<T = {}> = new (...args: any[]) => T;
1014

packages/dev/core/src/Materials/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from "./iEffectFallbacks";
55
export * from "./effectFallbacks";
66
export * from "./effect";
77
export * from "./fresnelParameters";
8+
export * from "./imageProcessing";
89
export * from "./imageProcessingConfiguration";
910
export * from "./material";
1011
export * from "./materialDefines";
@@ -39,6 +40,7 @@ export * from "./meshDebugPluginMaterial";
3940
export * from "./GaussianSplatting/gaussianSplattingMaterial";
4041
export * from "./materialHelper.functions";
4142
export * from "./materialHelper.geometryrendering";
43+
export * from "./uv.defines";
4244
import "./material.decalMap";
4345

4446
// async-loaded shaders

packages/dev/core/src/Particles/baseParticleSystem.ts

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import type { Nullable } from "../types";
33
import { Vector2, Vector3 } from "../Maths/math.vector";
44
import type { AbstractMesh } from "../Meshes/abstractMesh";
5-
import type { ImageProcessingConfiguration } from "../Materials/imageProcessingConfiguration";
65
import { ImageProcessingConfigurationDefines } from "../Materials/imageProcessingConfiguration.defines";
76
import type { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "../Misc/gradients";
87
import type { BoxParticleEmitter } from "../Particles/EmitterTypes/boxParticleEmitter";
@@ -25,14 +24,16 @@ import type { SphereDirectedParticleEmitter, SphereParticleEmitter } from "./Emi
2524
import type { CylinderDirectedParticleEmitter, CylinderParticleEmitter } from "./EmitterTypes/cylinderParticleEmitter";
2625
import type { ConeDirectedParticleEmitter, ConeParticleEmitter } from "./EmitterTypes/coneParticleEmitter";
2726
import { RegisterClass } from "../Misc/typeStore";
27+
import { ImageProcessingMixin } from "core/Materials/imageProcessing";
2828

29+
class BaseParticleSystemBase extends ImageProcessingMixin(Object) {}
2930
/**
3031
* This represents the base class for particle system in Babylon.
3132
* Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
3233
* Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
3334
* @example https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/particle_system_intro
3435
*/
35-
export class BaseParticleSystem implements IClipPlanesHolder {
36+
export class BaseParticleSystem extends BaseParticleSystemBase implements IClipPlanesHolder {
3637
/**
3738
* Source color is added to the destination color without alpha affecting the result. Great for additive glow effects (fire, magic, lasers)
3839
*/
@@ -740,44 +741,6 @@ export class BaseParticleSystem implements IClipPlanesHolder {
740741
*/
741742
protected _imageProcessingConfigurationDefines = new ImageProcessingConfigurationDefines();
742743

743-
/**
744-
* Default configuration related to image processing available in the standard Material.
745-
*/
746-
protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
747-
748-
/**
749-
* Gets the image processing configuration used either in this material.
750-
*/
751-
public get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration> {
752-
return this._imageProcessingConfiguration;
753-
}
754-
755-
/**
756-
* Sets the Default image processing configuration used either in the this material.
757-
*
758-
* If sets to null, the scene one is in use.
759-
*/
760-
public set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>) {
761-
this._attachImageProcessingConfiguration(value);
762-
}
763-
764-
/**
765-
* Attaches a new image processing configuration to the Standard Material.
766-
* @param configuration
767-
*/
768-
protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void {
769-
if (configuration === this._imageProcessingConfiguration) {
770-
return;
771-
}
772-
773-
// Pick the scene configuration if needed.
774-
if (!configuration && this._scene) {
775-
this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
776-
} else {
777-
this._imageProcessingConfiguration = configuration;
778-
}
779-
}
780-
781744
/** @internal */
782745
protected _reset() {}
783746

@@ -811,6 +774,7 @@ export class BaseParticleSystem implements IClipPlanesHolder {
811774
* @param name The name of the particle system
812775
*/
813776
public constructor(name: string) {
777+
super(name);
814778
this.id = name;
815779
this.name = name;
816780
}

0 commit comments

Comments
 (0)