@onerjs/materials 8.23.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.
- package/cell/cell.fragment.d.ts +19 -0
- package/cell/cell.fragment.js +100 -0
- package/cell/cell.fragment.js.map +1 -0
- package/cell/cell.vertex.d.ts +21 -0
- package/cell/cell.vertex.js +96 -0
- package/cell/cell.vertex.js.map +1 -0
- package/cell/cellMaterial.d.ts +37 -0
- package/cell/cellMaterial.js +312 -0
- package/cell/cellMaterial.js.map +1 -0
- package/cell/index.d.ts +1 -0
- package/cell/index.js +2 -0
- package/cell/index.js.map +1 -0
- package/custom/customMaterial.d.ts +280 -0
- package/custom/customMaterial.js +355 -0
- package/custom/customMaterial.js.map +1 -0
- package/custom/index.d.ts +2 -0
- package/custom/index.js +3 -0
- package/custom/index.js.map +1 -0
- package/custom/pbrCustomMaterial.d.ts +299 -0
- package/custom/pbrCustomMaterial.js +397 -0
- package/custom/pbrCustomMaterial.js.map +1 -0
- package/fire/fire.fragment.d.ts +13 -0
- package/fire/fire.fragment.js +65 -0
- package/fire/fire.fragment.js.map +1 -0
- package/fire/fire.vertex.d.ts +18 -0
- package/fire/fire.vertex.js +80 -0
- package/fire/fire.vertex.js.map +1 -0
- package/fire/fireMaterial.d.ts +38 -0
- package/fire/fireMaterial.js +342 -0
- package/fire/fireMaterial.js.map +1 -0
- package/fire/index.d.ts +1 -0
- package/fire/index.js +2 -0
- package/fire/index.js.map +1 -0
- package/fur/fur.fragment.d.ts +19 -0
- package/fur/fur.fragment.js +94 -0
- package/fur/fur.fragment.js.map +1 -0
- package/fur/fur.vertex.d.ts +21 -0
- package/fur/fur.vertex.js +126 -0
- package/fur/fur.vertex.js.map +1 -0
- package/fur/furMaterial.d.ts +57 -0
- package/fur/furMaterial.js +505 -0
- package/fur/furMaterial.js.map +1 -0
- package/fur/index.d.ts +1 -0
- package/fur/index.js +2 -0
- package/fur/index.js.map +1 -0
- package/gradient/gradient.fragment.d.ts +19 -0
- package/gradient/gradient.fragment.js +80 -0
- package/gradient/gradient.fragment.js.map +1 -0
- package/gradient/gradient.vertex.d.ts +21 -0
- package/gradient/gradient.vertex.js +87 -0
- package/gradient/gradient.vertex.js.map +1 -0
- package/gradient/gradientMaterial.d.ts +37 -0
- package/gradient/gradientMaterial.js +283 -0
- package/gradient/gradientMaterial.js.map +1 -0
- package/gradient/index.d.ts +1 -0
- package/gradient/index.js +2 -0
- package/gradient/index.js.map +1 -0
- package/grid/grid.fragment.d.ts +12 -0
- package/grid/grid.fragment.js +79 -0
- package/grid/grid.fragment.js.map +1 -0
- package/grid/grid.vertex.d.ts +15 -0
- package/grid/grid.vertex.js +60 -0
- package/grid/grid.vertex.js.map +1 -0
- package/grid/gridMaterial.d.ts +85 -0
- package/grid/gridMaterial.js +308 -0
- package/grid/gridMaterial.js.map +1 -0
- package/grid/index.d.ts +1 -0
- package/grid/index.js +2 -0
- package/grid/index.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/lava/index.d.ts +1 -0
- package/lava/index.js +2 -0
- package/lava/index.js.map +1 -0
- package/lava/lava.fragment.d.ts +19 -0
- package/lava/lava.fragment.js +89 -0
- package/lava/lava.fragment.js.map +1 -0
- package/lava/lava.vertex.d.ts +21 -0
- package/lava/lava.vertex.js +113 -0
- package/lava/lava.vertex.js.map +1 -0
- package/lava/lavaMaterial.d.ts +45 -0
- package/lava/lavaMaterial.js +402 -0
- package/lava/lavaMaterial.js.map +1 -0
- package/legacy/legacy-cell.d.ts +1 -0
- package/legacy/legacy-cell.js +14 -0
- package/legacy/legacy-cell.js.map +1 -0
- package/legacy/legacy-custom.d.ts +1 -0
- package/legacy/legacy-custom.js +14 -0
- package/legacy/legacy-custom.js.map +1 -0
- package/legacy/legacy-fire.d.ts +1 -0
- package/legacy/legacy-fire.js +14 -0
- package/legacy/legacy-fire.js.map +1 -0
- package/legacy/legacy-fur.d.ts +1 -0
- package/legacy/legacy-fur.js +14 -0
- package/legacy/legacy-fur.js.map +1 -0
- package/legacy/legacy-gradient.d.ts +1 -0
- package/legacy/legacy-gradient.js +14 -0
- package/legacy/legacy-gradient.js.map +1 -0
- package/legacy/legacy-grid.d.ts +1 -0
- package/legacy/legacy-grid.js +14 -0
- package/legacy/legacy-grid.js.map +1 -0
- package/legacy/legacy-lava.d.ts +1 -0
- package/legacy/legacy-lava.js +14 -0
- package/legacy/legacy-lava.js.map +1 -0
- package/legacy/legacy-mix.d.ts +1 -0
- package/legacy/legacy-mix.js +14 -0
- package/legacy/legacy-mix.js.map +1 -0
- package/legacy/legacy-normal.d.ts +1 -0
- package/legacy/legacy-normal.js +14 -0
- package/legacy/legacy-normal.js.map +1 -0
- package/legacy/legacy-shadowOnly.d.ts +1 -0
- package/legacy/legacy-shadowOnly.js +14 -0
- package/legacy/legacy-shadowOnly.js.map +1 -0
- package/legacy/legacy-simple.d.ts +1 -0
- package/legacy/legacy-simple.js +14 -0
- package/legacy/legacy-simple.js.map +1 -0
- package/legacy/legacy-sky.d.ts +1 -0
- package/legacy/legacy-sky.js +14 -0
- package/legacy/legacy-sky.js.map +1 -0
- package/legacy/legacy-terrain.d.ts +1 -0
- package/legacy/legacy-terrain.js +14 -0
- package/legacy/legacy-terrain.js.map +1 -0
- package/legacy/legacy-triPlanar.d.ts +1 -0
- package/legacy/legacy-triPlanar.js +14 -0
- package/legacy/legacy-triPlanar.js.map +1 -0
- package/legacy/legacy-water.d.ts +1 -0
- package/legacy/legacy-water.js +14 -0
- package/legacy/legacy-water.js.map +1 -0
- package/legacy/legacy.d.ts +1 -0
- package/legacy/legacy.js +17 -0
- package/legacy/legacy.js.map +1 -0
- package/license.md +71 -0
- package/mix/index.d.ts +1 -0
- package/mix/index.js +2 -0
- package/mix/index.js.map +1 -0
- package/mix/mix.fragment.d.ts +19 -0
- package/mix/mix.fragment.js +106 -0
- package/mix/mix.fragment.js.map +1 -0
- package/mix/mix.vertex.d.ts +21 -0
- package/mix/mix.vertex.js +96 -0
- package/mix/mix.vertex.js.map +1 -0
- package/mix/mixMaterial.d.ts +65 -0
- package/mix/mixMaterial.js +508 -0
- package/mix/mixMaterial.js.map +1 -0
- package/normal/index.d.ts +1 -0
- package/normal/index.js +2 -0
- package/normal/index.js.map +1 -0
- package/normal/normal.fragment.d.ts +19 -0
- package/normal/normal.fragment.js +85 -0
- package/normal/normal.fragment.js.map +1 -0
- package/normal/normal.vertex.d.ts +20 -0
- package/normal/normal.vertex.js +88 -0
- package/normal/normal.vertex.js.map +1 -0
- package/normal/normalMaterial.d.ts +36 -0
- package/normal/normalMaterial.js +345 -0
- package/normal/normalMaterial.js.map +1 -0
- package/package.json +47 -0
- package/readme.md +30 -0
- package/shadowOnly/index.d.ts +1 -0
- package/shadowOnly/index.js +2 -0
- package/shadowOnly/index.js.map +1 -0
- package/shadowOnly/shadowOnly.fragment.d.ts +20 -0
- package/shadowOnly/shadowOnly.fragment.js +60 -0
- package/shadowOnly/shadowOnly.fragment.js.map +1 -0
- package/shadowOnly/shadowOnly.vertex.d.ts +22 -0
- package/shadowOnly/shadowOnly.vertex.js +69 -0
- package/shadowOnly/shadowOnly.vertex.js.map +1 -0
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -0
- package/shadowOnly/shadowOnlyMaterial.js +243 -0
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -0
- package/simple/index.d.ts +1 -0
- package/simple/index.js +2 -0
- package/simple/index.js.map +1 -0
- package/simple/simple.fragment.d.ts +19 -0
- package/simple/simple.fragment.js +81 -0
- package/simple/simple.fragment.js.map +1 -0
- package/simple/simple.vertex.d.ts +21 -0
- package/simple/simple.vertex.js +96 -0
- package/simple/simple.vertex.js.map +1 -0
- package/simple/simpleMaterial.d.ts +35 -0
- package/simple/simpleMaterial.js +303 -0
- package/simple/simpleMaterial.js.map +1 -0
- package/sky/index.d.ts +1 -0
- package/sky/index.js +2 -0
- package/sky/index.js.map +1 -0
- package/sky/sky.fragment.d.ts +13 -0
- package/sky/sky.fragment.js +81 -0
- package/sky/sky.fragment.js.map +1 -0
- package/sky/sky.vertex.d.ts +11 -0
- package/sky/sky.vertex.js +47 -0
- package/sky/sky.vertex.js.map +1 -0
- package/sky/skyMaterial.d.ts +151 -0
- package/sky/skyMaterial.js +367 -0
- package/sky/skyMaterial.js.map +1 -0
- package/terrain/index.d.ts +1 -0
- package/terrain/index.js +2 -0
- package/terrain/index.js.map +1 -0
- package/terrain/terrain.fragment.d.ts +19 -0
- package/terrain/terrain.fragment.js +110 -0
- package/terrain/terrain.fragment.js.map +1 -0
- package/terrain/terrain.vertex.d.ts +21 -0
- package/terrain/terrain.vertex.js +96 -0
- package/terrain/terrain.vertex.js.map +1 -0
- package/terrain/terrainMaterial.d.ts +50 -0
- package/terrain/terrainMaterial.js +445 -0
- package/terrain/terrainMaterial.js.map +1 -0
- package/triPlanar/index.d.ts +1 -0
- package/triPlanar/index.js +2 -0
- package/triPlanar/index.js.map +1 -0
- package/triPlanar/triPlanarMaterial.d.ts +49 -0
- package/triPlanar/triPlanarMaterial.js +421 -0
- package/triPlanar/triPlanarMaterial.js.map +1 -0
- package/triPlanar/triplanar.fragment.d.ts +19 -0
- package/triPlanar/triplanar.fragment.js +126 -0
- package/triPlanar/triplanar.fragment.js.map +1 -0
- package/triPlanar/triplanar.vertex.d.ts +22 -0
- package/triPlanar/triplanar.vertex.js +101 -0
- package/triPlanar/triplanar.vertex.js.map +1 -0
- package/water/index.d.ts +1 -0
- package/water/index.js +2 -0
- package/water/index.js.map +1 -0
- package/water/water.fragment.d.ts +19 -0
- package/water/water.fragment.js +160 -0
- package/water/water.fragment.js.map +1 -0
- package/water/water.vertex.d.ts +21 -0
- package/water/water.vertex.js +125 -0
- package/water/water.vertex.js.map +1 -0
- package/water/waterMaterial.d.ts +141 -0
- package/water/waterMaterial.js +729 -0
- package/water/waterMaterial.js.map +1 -0
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { __decorate } from "@babylonjs/core/tslib.es6.js";
|
|
2
|
+
import { serializeAsVector2, serializeAsTexture, serialize, expandToProperty, serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
|
|
3
|
+
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
|
+
import { Matrix, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
6
|
+
import { Plane } from "@babylonjs/core/Maths/math.plane.js";
|
|
7
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
8
|
+
import { SmartArray } from "@babylonjs/core/Misc/smartArray.js";
|
|
9
|
+
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture.js";
|
|
10
|
+
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
|
11
|
+
import { ImageProcessingConfiguration } from "@babylonjs/core/Materials/imageProcessingConfiguration.js";
|
|
12
|
+
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
|
13
|
+
import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
|
|
14
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
|
15
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
16
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
|
17
|
+
import "./water.fragment.js";
|
|
18
|
+
import "./water.vertex.js";
|
|
19
|
+
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
|
20
|
+
import { CreateGround } from "@babylonjs/core/Meshes/Builders/groundBuilder.js";
|
|
21
|
+
import { AddClipPlaneUniforms, BindClipPlane } from "@babylonjs/core/Materials/clipPlaneMaterialHelper.js";
|
|
22
|
+
import { BindBonesParameters, BindFogParameters, BindLights, BindLogDepth, HandleFallbacksForShadows, PrepareAttributesForBones, PrepareAttributesForInstances, PrepareDefinesForAttributes, PrepareDefinesForFrameBoundValues, PrepareDefinesForLights, PrepareDefinesForMisc, PrepareUniformsAndSamplersList, } from "@babylonjs/core/Materials/materialHelper.functions.js";
|
|
23
|
+
import "@babylonjs/core/Rendering/boundingBoxRenderer.js";
|
|
24
|
+
class WaterMaterialDefines extends MaterialDefines {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.BUMP = false;
|
|
28
|
+
this.REFLECTION = false;
|
|
29
|
+
this.CLIPPLANE = false;
|
|
30
|
+
this.CLIPPLANE2 = false;
|
|
31
|
+
this.CLIPPLANE3 = false;
|
|
32
|
+
this.CLIPPLANE4 = false;
|
|
33
|
+
this.CLIPPLANE5 = false;
|
|
34
|
+
this.CLIPPLANE6 = false;
|
|
35
|
+
this.ALPHATEST = false;
|
|
36
|
+
this.DEPTHPREPASS = false;
|
|
37
|
+
this.POINTSIZE = false;
|
|
38
|
+
this.FOG = false;
|
|
39
|
+
this.NORMAL = false;
|
|
40
|
+
this.UV1 = false;
|
|
41
|
+
this.UV2 = false;
|
|
42
|
+
this.VERTEXCOLOR = false;
|
|
43
|
+
this.VERTEXALPHA = false;
|
|
44
|
+
this.NUM_BONE_INFLUENCERS = 0;
|
|
45
|
+
this.BonesPerMesh = 0;
|
|
46
|
+
this.INSTANCES = false;
|
|
47
|
+
this.INSTANCESCOLOR = false;
|
|
48
|
+
this.SPECULARTERM = false;
|
|
49
|
+
this.LOGARITHMICDEPTH = false;
|
|
50
|
+
this.USE_REVERSE_DEPTHBUFFER = false;
|
|
51
|
+
this.FRESNELSEPARATE = false;
|
|
52
|
+
this.BUMPSUPERIMPOSE = false;
|
|
53
|
+
this.BUMPAFFECTSREFLECTION = false;
|
|
54
|
+
this.USE_WORLD_COORDINATES = false;
|
|
55
|
+
this.IMAGEPROCESSING = false;
|
|
56
|
+
this.VIGNETTE = false;
|
|
57
|
+
this.VIGNETTEBLENDMODEMULTIPLY = false;
|
|
58
|
+
this.VIGNETTEBLENDMODEOPAQUE = false;
|
|
59
|
+
this.TONEMAPPING = 0;
|
|
60
|
+
this.CONTRAST = false;
|
|
61
|
+
this.EXPOSURE = false;
|
|
62
|
+
this.COLORCURVES = false;
|
|
63
|
+
this.COLORGRADING = false;
|
|
64
|
+
this.COLORGRADING3D = false;
|
|
65
|
+
this.SAMPLER3DGREENDEPTH = false;
|
|
66
|
+
this.SAMPLER3DBGRMAP = false;
|
|
67
|
+
this.DITHER = false;
|
|
68
|
+
this.IMAGEPROCESSINGPOSTPROCESS = false;
|
|
69
|
+
this.SKIPFINALCOLORCLAMP = false;
|
|
70
|
+
this.rebuild();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class WaterMaterial extends PushMaterial {
|
|
74
|
+
/**
|
|
75
|
+
* Gets a boolean indicating that current material needs to register RTT
|
|
76
|
+
*/
|
|
77
|
+
get hasRenderTargetTextures() {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Constructor
|
|
82
|
+
* @param name
|
|
83
|
+
* @param scene
|
|
84
|
+
* @param renderTargetSize
|
|
85
|
+
*/
|
|
86
|
+
constructor(name, scene, renderTargetSize = new Vector2(512, 512)) {
|
|
87
|
+
super(name, scene);
|
|
88
|
+
this.renderTargetSize = renderTargetSize;
|
|
89
|
+
this.diffuseColor = new Color3(1, 1, 1);
|
|
90
|
+
this.specularColor = new Color3(0, 0, 0);
|
|
91
|
+
this.specularPower = 64;
|
|
92
|
+
this._disableLighting = false;
|
|
93
|
+
this._maxSimultaneousLights = 4;
|
|
94
|
+
/**
|
|
95
|
+
* Defines the wind force.
|
|
96
|
+
*/
|
|
97
|
+
this.windForce = 6;
|
|
98
|
+
/**
|
|
99
|
+
* Defines the direction of the wind in the plane (X, Z).
|
|
100
|
+
*/
|
|
101
|
+
this.windDirection = new Vector2(0, 1);
|
|
102
|
+
/**
|
|
103
|
+
* Defines the height of the waves.
|
|
104
|
+
*/
|
|
105
|
+
this.waveHeight = 0.4;
|
|
106
|
+
/**
|
|
107
|
+
* Defines the bump height related to the bump map.
|
|
108
|
+
*/
|
|
109
|
+
this.bumpHeight = 0.4;
|
|
110
|
+
/**
|
|
111
|
+
* Defines wether or not: to add a smaller moving bump to less steady waves.
|
|
112
|
+
*/
|
|
113
|
+
this._bumpSuperimpose = false;
|
|
114
|
+
/**
|
|
115
|
+
* Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
|
|
116
|
+
*/
|
|
117
|
+
this._fresnelSeparate = false;
|
|
118
|
+
/**
|
|
119
|
+
* Defines wether or not bump Wwves modify the reflection.
|
|
120
|
+
*/
|
|
121
|
+
this._bumpAffectsReflection = false;
|
|
122
|
+
/**
|
|
123
|
+
* Defines the water color blended with the refraction (near).
|
|
124
|
+
*/
|
|
125
|
+
this.waterColor = new Color3(0.1, 0.1, 0.6);
|
|
126
|
+
/**
|
|
127
|
+
* Defines the blend factor related to the water color.
|
|
128
|
+
*/
|
|
129
|
+
this.colorBlendFactor = 0.2;
|
|
130
|
+
/**
|
|
131
|
+
* Defines the water color blended with the reflection (far).
|
|
132
|
+
*/
|
|
133
|
+
this.waterColor2 = new Color3(0.1, 0.1, 0.6);
|
|
134
|
+
/**
|
|
135
|
+
* Defines the blend factor related to the water color (reflection, far).
|
|
136
|
+
*/
|
|
137
|
+
this.colorBlendFactor2 = 0.2;
|
|
138
|
+
/**
|
|
139
|
+
* Defines the maximum length of a wave.
|
|
140
|
+
*/
|
|
141
|
+
this.waveLength = 0.1;
|
|
142
|
+
/**
|
|
143
|
+
* Defines the waves speed.
|
|
144
|
+
*/
|
|
145
|
+
this.waveSpeed = 1.0;
|
|
146
|
+
/**
|
|
147
|
+
* Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
|
|
148
|
+
*/
|
|
149
|
+
this.waveCount = 20;
|
|
150
|
+
/**
|
|
151
|
+
* Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
|
|
152
|
+
* will avoid calculating useless pixels in the pixel shader of the water material.
|
|
153
|
+
*/
|
|
154
|
+
this.disableClipPlane = false;
|
|
155
|
+
/**
|
|
156
|
+
* Defines whether or not to use world coordinates for wave deformations.
|
|
157
|
+
* The default value is false, meaning that the deformation is applied in object (local) space.
|
|
158
|
+
* You will probably need to set it to true if you are using instances or thin instances for your water objects.
|
|
159
|
+
*/
|
|
160
|
+
this._useWorldCoordinatesForWaveDeformation = false;
|
|
161
|
+
this._renderTargets = new SmartArray(16);
|
|
162
|
+
/*
|
|
163
|
+
* Private members
|
|
164
|
+
*/
|
|
165
|
+
this._mesh = null;
|
|
166
|
+
this._reflectionTransform = Matrix.Zero();
|
|
167
|
+
this._lastTime = 0;
|
|
168
|
+
this._lastDeltaTime = 0;
|
|
169
|
+
this._createRenderTargets(this.getScene(), renderTargetSize);
|
|
170
|
+
// Create render targets
|
|
171
|
+
this.getRenderTargetTextures = () => {
|
|
172
|
+
this._renderTargets.reset();
|
|
173
|
+
this._renderTargets.push(this._reflectionRTT);
|
|
174
|
+
this._renderTargets.push(this._refractionRTT);
|
|
175
|
+
return this._renderTargets;
|
|
176
|
+
};
|
|
177
|
+
this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
|
|
178
|
+
if (this._imageProcessingConfiguration) {
|
|
179
|
+
this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(() => {
|
|
180
|
+
this._markAllSubMeshesAsImageProcessingDirty();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Get / Set
|
|
185
|
+
get refractionTexture() {
|
|
186
|
+
return this._refractionRTT;
|
|
187
|
+
}
|
|
188
|
+
get reflectionTexture() {
|
|
189
|
+
return this._reflectionRTT;
|
|
190
|
+
}
|
|
191
|
+
// Methods
|
|
192
|
+
addToRenderList(node) {
|
|
193
|
+
if (this._refractionRTT && this._refractionRTT.renderList) {
|
|
194
|
+
this._refractionRTT.renderList.push(node);
|
|
195
|
+
}
|
|
196
|
+
if (this._reflectionRTT && this._reflectionRTT.renderList) {
|
|
197
|
+
this._reflectionRTT.renderList.push(node);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
removeFromRenderList(node) {
|
|
201
|
+
if (this._refractionRTT && this._refractionRTT.renderList) {
|
|
202
|
+
const idx = this._refractionRTT.renderList.indexOf(node);
|
|
203
|
+
if (idx !== -1) {
|
|
204
|
+
this._refractionRTT.renderList.splice(idx, 1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (this._reflectionRTT && this._reflectionRTT.renderList) {
|
|
208
|
+
const idx = this._reflectionRTT.renderList.indexOf(node);
|
|
209
|
+
if (idx !== -1) {
|
|
210
|
+
this._reflectionRTT.renderList.splice(idx, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
enableRenderTargets(enable) {
|
|
215
|
+
const refreshRate = enable ? 1 : 0;
|
|
216
|
+
if (this._refractionRTT) {
|
|
217
|
+
this._refractionRTT.refreshRate = refreshRate;
|
|
218
|
+
}
|
|
219
|
+
if (this._reflectionRTT) {
|
|
220
|
+
this._reflectionRTT.refreshRate = refreshRate;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
getRenderList() {
|
|
224
|
+
return this._refractionRTT ? this._refractionRTT.renderList : [];
|
|
225
|
+
}
|
|
226
|
+
get renderTargetsEnabled() {
|
|
227
|
+
return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
|
|
228
|
+
}
|
|
229
|
+
needAlphaBlending() {
|
|
230
|
+
return this.alpha < 1.0;
|
|
231
|
+
}
|
|
232
|
+
needAlphaTesting() {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
getAlphaTestTexture() {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
isReadyForSubMesh(mesh, subMesh, useInstances) {
|
|
239
|
+
const drawWrapper = subMesh._drawWrapper;
|
|
240
|
+
if (this.isFrozen) {
|
|
241
|
+
if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!subMesh.materialDefines) {
|
|
246
|
+
subMesh.materialDefines = new WaterMaterialDefines();
|
|
247
|
+
}
|
|
248
|
+
const defines = subMesh.materialDefines;
|
|
249
|
+
const scene = this.getScene();
|
|
250
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
const engine = scene.getEngine();
|
|
254
|
+
// Textures
|
|
255
|
+
if (defines._areTexturesDirty) {
|
|
256
|
+
defines._needUVs = false;
|
|
257
|
+
if (scene.texturesEnabled) {
|
|
258
|
+
if (this.bumpTexture && MaterialFlags.BumpTextureEnabled) {
|
|
259
|
+
if (!this.bumpTexture.isReady()) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
defines._needUVs = true;
|
|
264
|
+
defines.BUMP = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (MaterialFlags.ReflectionTextureEnabled) {
|
|
268
|
+
defines.REFLECTION = true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
|
|
273
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines);
|
|
274
|
+
if (defines._areMiscDirty) {
|
|
275
|
+
defines.FRESNELSEPARATE = this._fresnelSeparate;
|
|
276
|
+
defines.BUMPSUPERIMPOSE = this._bumpSuperimpose;
|
|
277
|
+
defines.BUMPAFFECTSREFLECTION = this._bumpAffectsReflection;
|
|
278
|
+
defines.USE_WORLD_COORDINATES = this._useWorldCoordinatesForWaveDeformation;
|
|
279
|
+
}
|
|
280
|
+
// Lights
|
|
281
|
+
defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
|
|
282
|
+
// Image processing
|
|
283
|
+
if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
|
|
284
|
+
if (!this._imageProcessingConfiguration.isReady()) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
this._imageProcessingConfiguration.prepareDefines(defines);
|
|
288
|
+
defines.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace;
|
|
289
|
+
defines.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace;
|
|
290
|
+
}
|
|
291
|
+
// Attribs
|
|
292
|
+
PrepareDefinesForAttributes(mesh, defines, true, true);
|
|
293
|
+
// Configure this
|
|
294
|
+
this._mesh = mesh;
|
|
295
|
+
if (this._waitingRenderList) {
|
|
296
|
+
for (let i = 0; i < this._waitingRenderList.length; i++) {
|
|
297
|
+
this.addToRenderList(scene.getNodeById(this._waitingRenderList[i]));
|
|
298
|
+
}
|
|
299
|
+
this._waitingRenderList = null;
|
|
300
|
+
}
|
|
301
|
+
// Get correct effect
|
|
302
|
+
if (defines.isDirty) {
|
|
303
|
+
defines.markAsProcessed();
|
|
304
|
+
scene.resetCachedMaterial();
|
|
305
|
+
// Fallbacks
|
|
306
|
+
const fallbacks = new EffectFallbacks();
|
|
307
|
+
if (defines.FOG) {
|
|
308
|
+
fallbacks.addFallback(1, "FOG");
|
|
309
|
+
}
|
|
310
|
+
if (defines.LOGARITHMICDEPTH) {
|
|
311
|
+
fallbacks.addFallback(0, "LOGARITHMICDEPTH");
|
|
312
|
+
}
|
|
313
|
+
HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
|
314
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
|
315
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
|
316
|
+
}
|
|
317
|
+
//Attributes
|
|
318
|
+
const attribs = [VertexBuffer.PositionKind];
|
|
319
|
+
if (defines.NORMAL) {
|
|
320
|
+
attribs.push(VertexBuffer.NormalKind);
|
|
321
|
+
}
|
|
322
|
+
if (defines.UV1) {
|
|
323
|
+
attribs.push(VertexBuffer.UVKind);
|
|
324
|
+
}
|
|
325
|
+
if (defines.UV2) {
|
|
326
|
+
attribs.push(VertexBuffer.UV2Kind);
|
|
327
|
+
}
|
|
328
|
+
if (defines.VERTEXCOLOR) {
|
|
329
|
+
attribs.push(VertexBuffer.ColorKind);
|
|
330
|
+
}
|
|
331
|
+
PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
|
332
|
+
PrepareAttributesForInstances(attribs, defines);
|
|
333
|
+
// Legacy browser patch
|
|
334
|
+
const shaderName = "water";
|
|
335
|
+
const join = defines.toString();
|
|
336
|
+
const uniforms = [
|
|
337
|
+
"world",
|
|
338
|
+
"view",
|
|
339
|
+
"viewProjection",
|
|
340
|
+
"vEyePosition",
|
|
341
|
+
"vLightsType",
|
|
342
|
+
"vDiffuseColor",
|
|
343
|
+
"vSpecularColor",
|
|
344
|
+
"vFogInfos",
|
|
345
|
+
"vFogColor",
|
|
346
|
+
"pointSize",
|
|
347
|
+
"vNormalInfos",
|
|
348
|
+
"mBones",
|
|
349
|
+
"normalMatrix",
|
|
350
|
+
"logarithmicDepthConstant",
|
|
351
|
+
// Water
|
|
352
|
+
"reflectionViewProjection",
|
|
353
|
+
"windDirection",
|
|
354
|
+
"waveLength",
|
|
355
|
+
"time",
|
|
356
|
+
"windForce",
|
|
357
|
+
"cameraPosition",
|
|
358
|
+
"bumpHeight",
|
|
359
|
+
"waveHeight",
|
|
360
|
+
"waterColor",
|
|
361
|
+
"waterColor2",
|
|
362
|
+
"colorBlendFactor",
|
|
363
|
+
"colorBlendFactor2",
|
|
364
|
+
"waveSpeed",
|
|
365
|
+
"waveCount",
|
|
366
|
+
];
|
|
367
|
+
const samplers = [
|
|
368
|
+
"normalSampler",
|
|
369
|
+
// Water
|
|
370
|
+
"refractionSampler",
|
|
371
|
+
"reflectionSampler",
|
|
372
|
+
];
|
|
373
|
+
const uniformBuffers = [];
|
|
374
|
+
if (ImageProcessingConfiguration) {
|
|
375
|
+
ImageProcessingConfiguration.PrepareUniforms(uniforms, defines);
|
|
376
|
+
ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
|
|
377
|
+
}
|
|
378
|
+
AddClipPlaneUniforms(uniforms);
|
|
379
|
+
PrepareUniformsAndSamplersList({
|
|
380
|
+
uniformsNames: uniforms,
|
|
381
|
+
uniformBuffersNames: uniformBuffers,
|
|
382
|
+
samplers: samplers,
|
|
383
|
+
defines: defines,
|
|
384
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
|
385
|
+
});
|
|
386
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
387
|
+
attributes: attribs,
|
|
388
|
+
uniformsNames: uniforms,
|
|
389
|
+
uniformBuffersNames: uniformBuffers,
|
|
390
|
+
samplers: samplers,
|
|
391
|
+
defines: join,
|
|
392
|
+
fallbacks: fallbacks,
|
|
393
|
+
onCompiled: this.onCompiled,
|
|
394
|
+
onError: this.onError,
|
|
395
|
+
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights },
|
|
396
|
+
}, engine), defines, this._materialContext);
|
|
397
|
+
}
|
|
398
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
defines._renderId = scene.getRenderId();
|
|
402
|
+
drawWrapper._wasPreviouslyReady = true;
|
|
403
|
+
drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
bindForSubMesh(world, mesh, subMesh) {
|
|
407
|
+
const scene = this.getScene();
|
|
408
|
+
const defines = subMesh.materialDefines;
|
|
409
|
+
if (!defines) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const effect = subMesh.effect;
|
|
413
|
+
if (!effect || !this._mesh) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
this._activeEffect = effect;
|
|
417
|
+
// Matrices
|
|
418
|
+
this.bindOnlyWorldMatrix(world);
|
|
419
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
420
|
+
// Bones
|
|
421
|
+
BindBonesParameters(mesh, this._activeEffect);
|
|
422
|
+
if (this._mustRebind(scene, effect, subMesh)) {
|
|
423
|
+
// Textures
|
|
424
|
+
if (this.bumpTexture && MaterialFlags.BumpTextureEnabled) {
|
|
425
|
+
this._activeEffect.setTexture("normalSampler", this.bumpTexture);
|
|
426
|
+
this._activeEffect.setFloat2("vNormalInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
|
|
427
|
+
this._activeEffect.setMatrix("normalMatrix", this.bumpTexture.getTextureMatrix());
|
|
428
|
+
}
|
|
429
|
+
// Clip plane
|
|
430
|
+
BindClipPlane(effect, this, scene);
|
|
431
|
+
// Point size
|
|
432
|
+
if (this.pointsCloud) {
|
|
433
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
434
|
+
}
|
|
435
|
+
// Log. depth
|
|
436
|
+
if (this._useLogarithmicDepth) {
|
|
437
|
+
BindLogDepth(defines, effect, scene);
|
|
438
|
+
}
|
|
439
|
+
scene.bindEyePosition(effect);
|
|
440
|
+
}
|
|
441
|
+
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
442
|
+
if (defines.SPECULARTERM) {
|
|
443
|
+
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
|
444
|
+
}
|
|
445
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
|
446
|
+
BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
|
447
|
+
}
|
|
448
|
+
// View
|
|
449
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
450
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
|
451
|
+
}
|
|
452
|
+
// Fog
|
|
453
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
|
454
|
+
// Log. depth
|
|
455
|
+
BindLogDepth(defines, this._activeEffect, scene);
|
|
456
|
+
// Water
|
|
457
|
+
if (MaterialFlags.ReflectionTextureEnabled) {
|
|
458
|
+
this._activeEffect.setTexture("refractionSampler", this._refractionRTT);
|
|
459
|
+
this._activeEffect.setTexture("reflectionSampler", this._reflectionRTT);
|
|
460
|
+
}
|
|
461
|
+
const wrvp = this._reflectionTransform.multiply(scene.getProjectionMatrix());
|
|
462
|
+
// Add delta time. Prevent adding delta time if it hasn't changed.
|
|
463
|
+
const deltaTime = scene.getEngine().getDeltaTime();
|
|
464
|
+
if (deltaTime !== this._lastDeltaTime) {
|
|
465
|
+
this._lastDeltaTime = deltaTime;
|
|
466
|
+
this._lastTime += this._lastDeltaTime;
|
|
467
|
+
}
|
|
468
|
+
this._activeEffect.setMatrix("reflectionViewProjection", wrvp);
|
|
469
|
+
this._activeEffect.setVector2("windDirection", this.windDirection);
|
|
470
|
+
this._activeEffect.setFloat("waveLength", this.waveLength);
|
|
471
|
+
this._activeEffect.setFloat("time", this._lastTime / 100000);
|
|
472
|
+
this._activeEffect.setFloat("windForce", this.windForce);
|
|
473
|
+
this._activeEffect.setFloat("waveHeight", this.waveHeight);
|
|
474
|
+
this._activeEffect.setFloat("bumpHeight", this.bumpHeight);
|
|
475
|
+
this._activeEffect.setColor4("waterColor", this.waterColor, 1.0);
|
|
476
|
+
this._activeEffect.setFloat("colorBlendFactor", this.colorBlendFactor);
|
|
477
|
+
this._activeEffect.setColor4("waterColor2", this.waterColor2, 1.0);
|
|
478
|
+
this._activeEffect.setFloat("colorBlendFactor2", this.colorBlendFactor2);
|
|
479
|
+
this._activeEffect.setFloat("waveSpeed", this.waveSpeed);
|
|
480
|
+
this._activeEffect.setFloat("waveCount", this.waveCount);
|
|
481
|
+
// image processing
|
|
482
|
+
if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
|
|
483
|
+
this._imageProcessingConfiguration.bind(this._activeEffect);
|
|
484
|
+
}
|
|
485
|
+
this._afterBind(mesh, this._activeEffect, subMesh);
|
|
486
|
+
}
|
|
487
|
+
_createRenderTargets(scene, renderTargetSize) {
|
|
488
|
+
// Render targets
|
|
489
|
+
this._refractionRTT = new RenderTargetTexture(name + "_refraction", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
|
|
490
|
+
this._refractionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
|
491
|
+
this._refractionRTT.wrapV = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
|
492
|
+
this._refractionRTT.ignoreCameraViewport = true;
|
|
493
|
+
let boundingBoxRendererEnabled = false;
|
|
494
|
+
this._refractionRTT.onBeforeRenderObservable.add(() => {
|
|
495
|
+
boundingBoxRendererEnabled = scene.getBoundingBoxRenderer().enabled;
|
|
496
|
+
scene.getBoundingBoxRenderer().enabled = false;
|
|
497
|
+
});
|
|
498
|
+
this._refractionRTT.onAfterRenderObservable.add(() => {
|
|
499
|
+
scene.getBoundingBoxRenderer().enabled = boundingBoxRendererEnabled;
|
|
500
|
+
});
|
|
501
|
+
this._reflectionRTT = new RenderTargetTexture(name + "_reflection", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
|
|
502
|
+
this._reflectionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
|
503
|
+
this._reflectionRTT.wrapV = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
|
504
|
+
this._reflectionRTT.ignoreCameraViewport = true;
|
|
505
|
+
let isVisible;
|
|
506
|
+
let clipPlane = null;
|
|
507
|
+
let savedViewMatrix;
|
|
508
|
+
const mirrorMatrix = Matrix.Zero();
|
|
509
|
+
this._refractionRTT.onBeforeRender = () => {
|
|
510
|
+
if (this._mesh) {
|
|
511
|
+
isVisible = this._mesh.isVisible;
|
|
512
|
+
this._mesh.isVisible = false;
|
|
513
|
+
}
|
|
514
|
+
// Clip plane
|
|
515
|
+
if (!this.disableClipPlane) {
|
|
516
|
+
clipPlane = scene.clipPlane;
|
|
517
|
+
const positiony = this._mesh ? this._mesh.absolutePosition.y : 0.0;
|
|
518
|
+
scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony + 0.05, 0), new Vector3(0, 1, 0));
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
this._refractionRTT.onAfterRender = () => {
|
|
522
|
+
if (this._mesh) {
|
|
523
|
+
this._mesh.isVisible = isVisible;
|
|
524
|
+
}
|
|
525
|
+
// Clip plane
|
|
526
|
+
if (!this.disableClipPlane) {
|
|
527
|
+
scene.clipPlane = clipPlane;
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
this._reflectionRTT.onBeforeRender = () => {
|
|
531
|
+
if (this._mesh) {
|
|
532
|
+
isVisible = this._mesh.isVisible;
|
|
533
|
+
this._mesh.isVisible = false;
|
|
534
|
+
}
|
|
535
|
+
// Clip plane
|
|
536
|
+
if (!this.disableClipPlane) {
|
|
537
|
+
clipPlane = scene.clipPlane;
|
|
538
|
+
const positiony = this._mesh ? this._mesh.absolutePosition.y : 0.0;
|
|
539
|
+
scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony - 0.05, 0), new Vector3(0, -1, 0));
|
|
540
|
+
Matrix.ReflectionToRef(scene.clipPlane, mirrorMatrix);
|
|
541
|
+
}
|
|
542
|
+
// Transform
|
|
543
|
+
savedViewMatrix = scene.getViewMatrix();
|
|
544
|
+
mirrorMatrix.multiplyToRef(savedViewMatrix, this._reflectionTransform);
|
|
545
|
+
scene.setTransformMatrix(this._reflectionTransform, scene.getProjectionMatrix());
|
|
546
|
+
scene._mirroredCameraPosition = Vector3.TransformCoordinates(scene.activeCamera.position, mirrorMatrix);
|
|
547
|
+
};
|
|
548
|
+
this._reflectionRTT.onAfterRender = () => {
|
|
549
|
+
if (this._mesh) {
|
|
550
|
+
this._mesh.isVisible = isVisible;
|
|
551
|
+
}
|
|
552
|
+
// Clip plane
|
|
553
|
+
scene.clipPlane = clipPlane;
|
|
554
|
+
// Transform
|
|
555
|
+
scene.setTransformMatrix(savedViewMatrix, scene.getProjectionMatrix());
|
|
556
|
+
scene._mirroredCameraPosition = null;
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
getAnimatables() {
|
|
560
|
+
const results = [];
|
|
561
|
+
if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
|
|
562
|
+
results.push(this.bumpTexture);
|
|
563
|
+
}
|
|
564
|
+
if (this._reflectionRTT && this._reflectionRTT.animations && this._reflectionRTT.animations.length > 0) {
|
|
565
|
+
results.push(this._reflectionRTT);
|
|
566
|
+
}
|
|
567
|
+
if (this._refractionRTT && this._refractionRTT.animations && this._refractionRTT.animations.length > 0) {
|
|
568
|
+
results.push(this._refractionRTT);
|
|
569
|
+
}
|
|
570
|
+
return results;
|
|
571
|
+
}
|
|
572
|
+
getActiveTextures() {
|
|
573
|
+
const activeTextures = super.getActiveTextures();
|
|
574
|
+
if (this._bumpTexture) {
|
|
575
|
+
activeTextures.push(this._bumpTexture);
|
|
576
|
+
}
|
|
577
|
+
return activeTextures;
|
|
578
|
+
}
|
|
579
|
+
hasTexture(texture) {
|
|
580
|
+
if (super.hasTexture(texture)) {
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
if (this._bumpTexture === texture) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
dispose(forceDisposeEffect) {
|
|
589
|
+
if (this.bumpTexture) {
|
|
590
|
+
this.bumpTexture.dispose();
|
|
591
|
+
}
|
|
592
|
+
let index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
|
|
593
|
+
if (index != -1) {
|
|
594
|
+
this.getScene().customRenderTargets.splice(index, 1);
|
|
595
|
+
}
|
|
596
|
+
index = -1;
|
|
597
|
+
index = this.getScene().customRenderTargets.indexOf(this._reflectionRTT);
|
|
598
|
+
if (index != -1) {
|
|
599
|
+
this.getScene().customRenderTargets.splice(index, 1);
|
|
600
|
+
}
|
|
601
|
+
if (this._reflectionRTT) {
|
|
602
|
+
this._reflectionRTT.dispose();
|
|
603
|
+
}
|
|
604
|
+
if (this._refractionRTT) {
|
|
605
|
+
this._refractionRTT.dispose();
|
|
606
|
+
}
|
|
607
|
+
// Remove image-processing observer
|
|
608
|
+
if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
|
|
609
|
+
this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
|
|
610
|
+
}
|
|
611
|
+
super.dispose(forceDisposeEffect);
|
|
612
|
+
}
|
|
613
|
+
clone(name) {
|
|
614
|
+
return SerializationHelper.Clone(() => new WaterMaterial(name, this.getScene()), this);
|
|
615
|
+
}
|
|
616
|
+
serialize() {
|
|
617
|
+
const serializationObject = super.serialize();
|
|
618
|
+
serializationObject.customType = "BABYLON.WaterMaterial";
|
|
619
|
+
serializationObject.renderList = [];
|
|
620
|
+
if (this._refractionRTT && this._refractionRTT.renderList) {
|
|
621
|
+
for (let i = 0; i < this._refractionRTT.renderList.length; i++) {
|
|
622
|
+
serializationObject.renderList.push(this._refractionRTT.renderList[i].id);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return serializationObject;
|
|
626
|
+
}
|
|
627
|
+
getClassName() {
|
|
628
|
+
return "WaterMaterial";
|
|
629
|
+
}
|
|
630
|
+
// Statics
|
|
631
|
+
static Parse(source, scene, rootUrl) {
|
|
632
|
+
const mat = SerializationHelper.Parse(() => new WaterMaterial(source.name, scene), source, scene, rootUrl);
|
|
633
|
+
mat._waitingRenderList = source.renderList;
|
|
634
|
+
return mat;
|
|
635
|
+
}
|
|
636
|
+
static CreateDefaultMesh(name, scene) {
|
|
637
|
+
const mesh = CreateGround(name, { width: 512, height: 512, subdivisions: 32, updatable: false }, scene);
|
|
638
|
+
return mesh;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
__decorate([
|
|
642
|
+
serializeAsTexture("bumpTexture")
|
|
643
|
+
], WaterMaterial.prototype, "_bumpTexture", void 0);
|
|
644
|
+
__decorate([
|
|
645
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
646
|
+
], WaterMaterial.prototype, "bumpTexture", void 0);
|
|
647
|
+
__decorate([
|
|
648
|
+
serializeAsColor3()
|
|
649
|
+
], WaterMaterial.prototype, "diffuseColor", void 0);
|
|
650
|
+
__decorate([
|
|
651
|
+
serializeAsColor3()
|
|
652
|
+
], WaterMaterial.prototype, "specularColor", void 0);
|
|
653
|
+
__decorate([
|
|
654
|
+
serialize()
|
|
655
|
+
], WaterMaterial.prototype, "specularPower", void 0);
|
|
656
|
+
__decorate([
|
|
657
|
+
serialize("disableLighting")
|
|
658
|
+
], WaterMaterial.prototype, "_disableLighting", void 0);
|
|
659
|
+
__decorate([
|
|
660
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
661
|
+
], WaterMaterial.prototype, "disableLighting", void 0);
|
|
662
|
+
__decorate([
|
|
663
|
+
serialize("maxSimultaneousLights")
|
|
664
|
+
], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
|
|
665
|
+
__decorate([
|
|
666
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
667
|
+
], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
|
|
668
|
+
__decorate([
|
|
669
|
+
serialize()
|
|
670
|
+
], WaterMaterial.prototype, "windForce", void 0);
|
|
671
|
+
__decorate([
|
|
672
|
+
serializeAsVector2()
|
|
673
|
+
], WaterMaterial.prototype, "windDirection", void 0);
|
|
674
|
+
__decorate([
|
|
675
|
+
serialize()
|
|
676
|
+
], WaterMaterial.prototype, "waveHeight", void 0);
|
|
677
|
+
__decorate([
|
|
678
|
+
serialize()
|
|
679
|
+
], WaterMaterial.prototype, "bumpHeight", void 0);
|
|
680
|
+
__decorate([
|
|
681
|
+
serialize("bumpSuperimpose")
|
|
682
|
+
], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
|
|
683
|
+
__decorate([
|
|
684
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
|
685
|
+
], WaterMaterial.prototype, "bumpSuperimpose", void 0);
|
|
686
|
+
__decorate([
|
|
687
|
+
serialize("fresnelSeparate")
|
|
688
|
+
], WaterMaterial.prototype, "_fresnelSeparate", void 0);
|
|
689
|
+
__decorate([
|
|
690
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
|
691
|
+
], WaterMaterial.prototype, "fresnelSeparate", void 0);
|
|
692
|
+
__decorate([
|
|
693
|
+
serialize("bumpAffectsReflection")
|
|
694
|
+
], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
|
|
695
|
+
__decorate([
|
|
696
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
|
697
|
+
], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
|
|
698
|
+
__decorate([
|
|
699
|
+
serializeAsColor3()
|
|
700
|
+
], WaterMaterial.prototype, "waterColor", void 0);
|
|
701
|
+
__decorate([
|
|
702
|
+
serialize()
|
|
703
|
+
], WaterMaterial.prototype, "colorBlendFactor", void 0);
|
|
704
|
+
__decorate([
|
|
705
|
+
serializeAsColor3()
|
|
706
|
+
], WaterMaterial.prototype, "waterColor2", void 0);
|
|
707
|
+
__decorate([
|
|
708
|
+
serialize()
|
|
709
|
+
], WaterMaterial.prototype, "colorBlendFactor2", void 0);
|
|
710
|
+
__decorate([
|
|
711
|
+
serialize()
|
|
712
|
+
], WaterMaterial.prototype, "waveLength", void 0);
|
|
713
|
+
__decorate([
|
|
714
|
+
serialize()
|
|
715
|
+
], WaterMaterial.prototype, "waveSpeed", void 0);
|
|
716
|
+
__decorate([
|
|
717
|
+
serialize()
|
|
718
|
+
], WaterMaterial.prototype, "waveCount", void 0);
|
|
719
|
+
__decorate([
|
|
720
|
+
serialize()
|
|
721
|
+
], WaterMaterial.prototype, "disableClipPlane", void 0);
|
|
722
|
+
__decorate([
|
|
723
|
+
serialize("useWorldCoordinatesForWaveDeformation")
|
|
724
|
+
], WaterMaterial.prototype, "_useWorldCoordinatesForWaveDeformation", void 0);
|
|
725
|
+
__decorate([
|
|
726
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
|
727
|
+
], WaterMaterial.prototype, "useWorldCoordinatesForWaveDeformation", void 0);
|
|
728
|
+
RegisterClass("BABYLON.WaterMaterial", WaterMaterial);
|
|
729
|
+
//# sourceMappingURL=waterMaterial.js.map
|