@babylonjs/materials 9.15.0 → 9.16.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/cellMaterial.d.ts +4 -4
- package/cell/cellMaterial.js +313 -268
- package/cell/cellMaterial.js.map +1 -1
- package/fire/fireMaterial.d.ts +3 -3
- package/fire/fireMaterial.js +344 -303
- package/fire/fireMaterial.js.map +1 -1
- package/fur/furMaterial.d.ts +4 -4
- package/fur/furMaterial.js +519 -450
- package/fur/furMaterial.js.map +1 -1
- package/gradient/gradientMaterial.d.ts +2 -2
- package/gradient/gradientMaterial.js +286 -246
- package/gradient/gradientMaterial.js.map +1 -1
- package/grid/gridMaterial.d.ts +1 -1
- package/grid/gridMaterial.js +453 -398
- package/grid/gridMaterial.js.map +1 -1
- package/lava/lavaMaterial.d.ts +4 -4
- package/lava/lavaMaterial.js +377 -318
- package/lava/lavaMaterial.js.map +1 -1
- package/mix/mixMaterial.d.ts +12 -12
- package/mix/mixMaterial.js +584 -456
- package/mix/mixMaterial.js.map +1 -1
- package/normal/normalMaterial.d.ts +3 -3
- package/normal/normalMaterial.js +301 -264
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +2 -2
- package/simple/simpleMaterial.d.ts +3 -3
- package/simple/simpleMaterial.js +299 -262
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/skyMaterial.js +380 -344
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/terrainMaterial.d.ts +9 -9
- package/terrain/terrainMaterial.js +490 -395
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +8 -8
- package/triPlanar/triPlanarMaterial.js +460 -369
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/water/waterMaterial.d.ts +7 -7
- package/water/waterMaterial.js +759 -659
- package/water/waterMaterial.js.map +1 -1
package/fur/furMaterial.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsVector3, serializeAsTexture, serialize, expandToProperty, serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
4
|
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
@@ -48,476 +48,545 @@ class FurMaterialDefines extends MaterialDefines {
|
|
|
48
48
|
this.rebuild();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
51
|
+
let FurMaterial = (() => {
|
|
52
|
+
var _a, _FurMaterial_diffuseTexture_accessor_storage, _FurMaterial_heightTexture_accessor_storage, _FurMaterial_disableLighting_accessor_storage, _FurMaterial_maxSimultaneousLights_accessor_storage;
|
|
53
|
+
let _classSuper = PushMaterial;
|
|
54
|
+
let _instanceExtraInitializers = [];
|
|
55
|
+
let __diffuseTexture_decorators;
|
|
56
|
+
let __diffuseTexture_initializers = [];
|
|
57
|
+
let __diffuseTexture_extraInitializers = [];
|
|
58
|
+
let _diffuseTexture_decorators;
|
|
59
|
+
let _diffuseTexture_initializers = [];
|
|
60
|
+
let _diffuseTexture_extraInitializers = [];
|
|
61
|
+
let __heightTexture_decorators;
|
|
62
|
+
let __heightTexture_initializers = [];
|
|
63
|
+
let __heightTexture_extraInitializers = [];
|
|
64
|
+
let _heightTexture_decorators;
|
|
65
|
+
let _heightTexture_initializers = [];
|
|
66
|
+
let _heightTexture_extraInitializers = [];
|
|
67
|
+
let _diffuseColor_decorators;
|
|
68
|
+
let _diffuseColor_initializers = [];
|
|
69
|
+
let _diffuseColor_extraInitializers = [];
|
|
70
|
+
let _furLength_decorators;
|
|
71
|
+
let _furLength_initializers = [];
|
|
72
|
+
let _furLength_extraInitializers = [];
|
|
73
|
+
let _furAngle_decorators;
|
|
74
|
+
let _furAngle_initializers = [];
|
|
75
|
+
let _furAngle_extraInitializers = [];
|
|
76
|
+
let _furColor_decorators;
|
|
77
|
+
let _furColor_initializers = [];
|
|
78
|
+
let _furColor_extraInitializers = [];
|
|
79
|
+
let _furOffset_decorators;
|
|
80
|
+
let _furOffset_initializers = [];
|
|
81
|
+
let _furOffset_extraInitializers = [];
|
|
82
|
+
let _furSpacing_decorators;
|
|
83
|
+
let _furSpacing_initializers = [];
|
|
84
|
+
let _furSpacing_extraInitializers = [];
|
|
85
|
+
let _furGravity_decorators;
|
|
86
|
+
let _furGravity_initializers = [];
|
|
87
|
+
let _furGravity_extraInitializers = [];
|
|
88
|
+
let _furSpeed_decorators;
|
|
89
|
+
let _furSpeed_initializers = [];
|
|
90
|
+
let _furSpeed_extraInitializers = [];
|
|
91
|
+
let _furDensity_decorators;
|
|
92
|
+
let _furDensity_initializers = [];
|
|
93
|
+
let _furDensity_extraInitializers = [];
|
|
94
|
+
let _furOcclusion_decorators;
|
|
95
|
+
let _furOcclusion_initializers = [];
|
|
96
|
+
let _furOcclusion_extraInitializers = [];
|
|
97
|
+
let __disableLighting_decorators;
|
|
98
|
+
let __disableLighting_initializers = [];
|
|
99
|
+
let __disableLighting_extraInitializers = [];
|
|
100
|
+
let _disableLighting_decorators;
|
|
101
|
+
let _disableLighting_initializers = [];
|
|
102
|
+
let _disableLighting_extraInitializers = [];
|
|
103
|
+
let __maxSimultaneousLights_decorators;
|
|
104
|
+
let __maxSimultaneousLights_initializers = [];
|
|
105
|
+
let __maxSimultaneousLights_extraInitializers = [];
|
|
106
|
+
let _maxSimultaneousLights_decorators;
|
|
107
|
+
let _maxSimultaneousLights_initializers = [];
|
|
108
|
+
let _maxSimultaneousLights_extraInitializers = [];
|
|
109
|
+
let _highLevelFur_decorators;
|
|
110
|
+
let _highLevelFur_initializers = [];
|
|
111
|
+
let _highLevelFur_extraInitializers = [];
|
|
112
|
+
let _get_furTime_decorators;
|
|
113
|
+
return _a = class FurMaterial extends _classSuper {
|
|
114
|
+
get diffuseTexture() { return __classPrivateFieldGet(this, _FurMaterial_diffuseTexture_accessor_storage, "f"); }
|
|
115
|
+
set diffuseTexture(value) { __classPrivateFieldSet(this, _FurMaterial_diffuseTexture_accessor_storage, value, "f"); }
|
|
116
|
+
get heightTexture() { return __classPrivateFieldGet(this, _FurMaterial_heightTexture_accessor_storage, "f"); }
|
|
117
|
+
set heightTexture(value) { __classPrivateFieldSet(this, _FurMaterial_heightTexture_accessor_storage, value, "f"); }
|
|
118
|
+
get disableLighting() { return __classPrivateFieldGet(this, _FurMaterial_disableLighting_accessor_storage, "f"); }
|
|
119
|
+
set disableLighting(value) { __classPrivateFieldSet(this, _FurMaterial_disableLighting_accessor_storage, value, "f"); }
|
|
120
|
+
get maxSimultaneousLights() { return __classPrivateFieldGet(this, _FurMaterial_maxSimultaneousLights_accessor_storage, "f"); }
|
|
121
|
+
set maxSimultaneousLights(value) { __classPrivateFieldSet(this, _FurMaterial_maxSimultaneousLights_accessor_storage, value, "f"); }
|
|
122
|
+
/**
|
|
123
|
+
* Instantiates a Fur Material in the given scene
|
|
124
|
+
* @param name The friendly name of the material
|
|
125
|
+
* @param scene The scene to add the material to
|
|
126
|
+
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
|
|
127
|
+
*/
|
|
128
|
+
constructor(name, scene, forceGLSL = false) {
|
|
129
|
+
super(name, scene, undefined, forceGLSL);
|
|
130
|
+
this._diffuseTexture = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, __diffuseTexture_initializers, void 0));
|
|
131
|
+
_FurMaterial_diffuseTexture_accessor_storage.set(this, (__runInitializers(this, __diffuseTexture_extraInitializers), __runInitializers(this, _diffuseTexture_initializers, void 0)));
|
|
132
|
+
this._heightTexture = (__runInitializers(this, _diffuseTexture_extraInitializers), __runInitializers(this, __heightTexture_initializers, void 0));
|
|
133
|
+
_FurMaterial_heightTexture_accessor_storage.set(this, (__runInitializers(this, __heightTexture_extraInitializers), __runInitializers(this, _heightTexture_initializers, void 0)));
|
|
134
|
+
this.diffuseColor = (__runInitializers(this, _heightTexture_extraInitializers), __runInitializers(this, _diffuseColor_initializers, new Color3(1, 1, 1)));
|
|
135
|
+
this.furLength = (__runInitializers(this, _diffuseColor_extraInitializers), __runInitializers(this, _furLength_initializers, 1));
|
|
136
|
+
this.furAngle = (__runInitializers(this, _furLength_extraInitializers), __runInitializers(this, _furAngle_initializers, 0));
|
|
137
|
+
this.furColor = (__runInitializers(this, _furAngle_extraInitializers), __runInitializers(this, _furColor_initializers, new Color3(0.44, 0.21, 0.02)));
|
|
138
|
+
this.furOffset = (__runInitializers(this, _furColor_extraInitializers), __runInitializers(this, _furOffset_initializers, 0.0));
|
|
139
|
+
this.furSpacing = (__runInitializers(this, _furOffset_extraInitializers), __runInitializers(this, _furSpacing_initializers, 12));
|
|
140
|
+
this.furGravity = (__runInitializers(this, _furSpacing_extraInitializers), __runInitializers(this, _furGravity_initializers, new Vector3(0, 0, 0)));
|
|
141
|
+
this.furSpeed = (__runInitializers(this, _furGravity_extraInitializers), __runInitializers(this, _furSpeed_initializers, 100));
|
|
142
|
+
this.furDensity = (__runInitializers(this, _furSpeed_extraInitializers), __runInitializers(this, _furDensity_initializers, 20));
|
|
143
|
+
this.furOcclusion = (__runInitializers(this, _furDensity_extraInitializers), __runInitializers(this, _furOcclusion_initializers, 0.0));
|
|
144
|
+
this.furTexture = __runInitializers(this, _furOcclusion_extraInitializers);
|
|
145
|
+
this._disableLighting = __runInitializers(this, __disableLighting_initializers, false);
|
|
146
|
+
_FurMaterial_disableLighting_accessor_storage.set(this, (__runInitializers(this, __disableLighting_extraInitializers), __runInitializers(this, _disableLighting_initializers, void 0)));
|
|
147
|
+
this._maxSimultaneousLights = (__runInitializers(this, _disableLighting_extraInitializers), __runInitializers(this, __maxSimultaneousLights_initializers, 4));
|
|
148
|
+
_FurMaterial_maxSimultaneousLights_accessor_storage.set(this, (__runInitializers(this, __maxSimultaneousLights_extraInitializers), __runInitializers(this, _maxSimultaneousLights_initializers, void 0)));
|
|
149
|
+
this.highLevelFur = (__runInitializers(this, _maxSimultaneousLights_extraInitializers), __runInitializers(this, _highLevelFur_initializers, true));
|
|
150
|
+
this._meshes = __runInitializers(this, _highLevelFur_extraInitializers);
|
|
151
|
+
this._furTime = 0;
|
|
152
|
+
this._shadersLoaded = false;
|
|
153
|
+
}
|
|
154
|
+
get furTime() {
|
|
155
|
+
return this._furTime;
|
|
156
|
+
}
|
|
157
|
+
set furTime(furTime) {
|
|
158
|
+
this._furTime = furTime;
|
|
113
159
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
needAlphaBlending() {
|
|
161
|
+
return this.alpha < 1.0;
|
|
162
|
+
}
|
|
163
|
+
needAlphaTesting() {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
getAlphaTestTexture() {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
updateFur() {
|
|
170
|
+
for (let i = 1; i < this._meshes.length; i++) {
|
|
171
|
+
const offsetFur = this._meshes[i].material;
|
|
172
|
+
offsetFur.furLength = this.furLength;
|
|
173
|
+
offsetFur.furAngle = this.furAngle;
|
|
174
|
+
offsetFur.furGravity = this.furGravity;
|
|
175
|
+
offsetFur.furSpacing = this.furSpacing;
|
|
176
|
+
offsetFur.furSpeed = this.furSpeed;
|
|
177
|
+
offsetFur.furColor = this.furColor;
|
|
178
|
+
offsetFur.diffuseTexture = this.diffuseTexture;
|
|
179
|
+
offsetFur.furTexture = this.furTexture;
|
|
180
|
+
offsetFur.highLevelFur = this.highLevelFur;
|
|
181
|
+
offsetFur.furTime = this.furTime;
|
|
182
|
+
offsetFur.furDensity = this.furDensity;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Methods
|
|
186
|
+
isReadyForSubMesh(mesh, subMesh, useInstances) {
|
|
187
|
+
const drawWrapper = subMesh._drawWrapper;
|
|
188
|
+
if (this.isFrozen) {
|
|
189
|
+
if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
|
|
190
|
+
return true;
|
|
130
191
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
192
|
+
}
|
|
193
|
+
if (!subMesh.materialDefines) {
|
|
194
|
+
subMesh.materialDefines = new FurMaterialDefines();
|
|
195
|
+
}
|
|
196
|
+
const defines = subMesh.materialDefines;
|
|
197
|
+
const scene = this.getScene();
|
|
198
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
const engine = scene.getEngine();
|
|
202
|
+
// Textures
|
|
203
|
+
if (defines._areTexturesDirty) {
|
|
204
|
+
if (scene.texturesEnabled) {
|
|
205
|
+
if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
206
|
+
if (!this.diffuseTexture.isReady()) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
defines._needUVs = true;
|
|
211
|
+
defines.DIFFUSE = true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (this.heightTexture && engine.getCaps().maxVertexTextureImageUnits) {
|
|
215
|
+
if (!this.heightTexture.isReady()) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
defines._needUVs = true;
|
|
220
|
+
defines.HEIGHTMAP = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
134
223
|
}
|
|
135
224
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
225
|
+
// High level
|
|
226
|
+
if (this.highLevelFur !== defines.HIGHLEVEL) {
|
|
227
|
+
defines.HIGHLEVEL = true;
|
|
228
|
+
defines.markAsUnprocessed();
|
|
229
|
+
}
|
|
230
|
+
// Misc.
|
|
231
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, undefined, undefined, undefined, this._isVertexOutputInvariant);
|
|
232
|
+
// Lights
|
|
233
|
+
defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
|
234
|
+
// Values that need to be evaluated on every frame
|
|
235
|
+
PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
|
|
236
|
+
// Attribs
|
|
237
|
+
PrepareDefinesForAttributes(mesh, defines, true, true);
|
|
238
|
+
// Get correct effect
|
|
239
|
+
if (defines.isDirty) {
|
|
240
|
+
defines.markAsProcessed();
|
|
241
|
+
scene.resetCachedMaterial();
|
|
242
|
+
// Fallbacks
|
|
243
|
+
const fallbacks = new EffectFallbacks();
|
|
244
|
+
if (defines.FOG) {
|
|
245
|
+
fallbacks.addFallback(1, "FOG");
|
|
246
|
+
}
|
|
247
|
+
HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
|
248
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
|
249
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
|
250
|
+
}
|
|
251
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
|
252
|
+
//Attributes
|
|
253
|
+
const attribs = [VertexBuffer.PositionKind];
|
|
254
|
+
if (defines.NORMAL) {
|
|
255
|
+
attribs.push(VertexBuffer.NormalKind);
|
|
256
|
+
}
|
|
257
|
+
if (defines.UV1) {
|
|
258
|
+
attribs.push(VertexBuffer.UVKind);
|
|
139
259
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
defines.HEIGHTMAP = true;
|
|
260
|
+
if (defines.UV2) {
|
|
261
|
+
attribs.push(VertexBuffer.UV2Kind);
|
|
143
262
|
}
|
|
263
|
+
if (defines.VERTEXCOLOR) {
|
|
264
|
+
attribs.push(VertexBuffer.ColorKind);
|
|
265
|
+
}
|
|
266
|
+
PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
|
267
|
+
PrepareAttributesForInstances(attribs, defines);
|
|
268
|
+
// Legacy browser patch
|
|
269
|
+
const shaderName = "fur";
|
|
270
|
+
const join = defines.toString();
|
|
271
|
+
const uniforms = [
|
|
272
|
+
"world",
|
|
273
|
+
"view",
|
|
274
|
+
"viewProjection",
|
|
275
|
+
"vEyePosition",
|
|
276
|
+
"vLightsType",
|
|
277
|
+
"vDiffuseColor",
|
|
278
|
+
"vFogInfos",
|
|
279
|
+
"vFogColor",
|
|
280
|
+
"pointSize",
|
|
281
|
+
"vDiffuseInfos",
|
|
282
|
+
"mBones",
|
|
283
|
+
"diffuseMatrix",
|
|
284
|
+
"logarithmicDepthConstant",
|
|
285
|
+
"furLength",
|
|
286
|
+
"furAngle",
|
|
287
|
+
"furColor",
|
|
288
|
+
"furOffset",
|
|
289
|
+
"furGravity",
|
|
290
|
+
"furTime",
|
|
291
|
+
"furSpacing",
|
|
292
|
+
"furDensity",
|
|
293
|
+
"furOcclusion",
|
|
294
|
+
];
|
|
295
|
+
AddClipPlaneUniforms(uniforms);
|
|
296
|
+
const samplers = ["diffuseSampler", "heightTexture", "furTexture", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
|
|
297
|
+
const uniformBuffers = [];
|
|
298
|
+
PrepareUniformsAndSamplersList({
|
|
299
|
+
uniformsNames: uniforms,
|
|
300
|
+
uniformBuffersNames: uniformBuffers,
|
|
301
|
+
samplers: samplers,
|
|
302
|
+
defines: defines,
|
|
303
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
|
304
|
+
shaderLanguage: this._shaderLanguage,
|
|
305
|
+
});
|
|
306
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
307
|
+
attributes: attribs,
|
|
308
|
+
uniformsNames: uniforms,
|
|
309
|
+
uniformBuffersNames: uniformBuffers,
|
|
310
|
+
samplers: samplers,
|
|
311
|
+
defines: join,
|
|
312
|
+
fallbacks: fallbacks,
|
|
313
|
+
onCompiled: this.onCompiled,
|
|
314
|
+
onError: this.onError,
|
|
315
|
+
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
|
316
|
+
shaderLanguage: this._shaderLanguage,
|
|
317
|
+
extraInitializationsAsync: this._shadersLoaded
|
|
318
|
+
? undefined
|
|
319
|
+
: async () => {
|
|
320
|
+
if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
321
|
+
await Promise.all([import("./wgsl/fur.vertex.js"), import("./wgsl/fur.fragment.js")]);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
await Promise.all([import("./fur.vertex.js"), import("./fur.fragment.js")]);
|
|
325
|
+
}
|
|
326
|
+
this._shadersLoaded = true;
|
|
327
|
+
},
|
|
328
|
+
}, engine), defines, this._materialContext);
|
|
144
329
|
}
|
|
330
|
+
// Check if Area Lights have LTC texture.
|
|
331
|
+
if (defines["AREALIGHTUSED"]) {
|
|
332
|
+
for (let index = 0; index < mesh.lightSources.length; index++) {
|
|
333
|
+
if (!mesh.lightSources[index]._isReady()) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
defines._renderId = scene.getRenderId();
|
|
342
|
+
drawWrapper._wasPreviouslyReady = true;
|
|
343
|
+
drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
|
|
344
|
+
return true;
|
|
145
345
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
346
|
+
bindForSubMesh(world, mesh, subMesh) {
|
|
347
|
+
const scene = this.getScene();
|
|
348
|
+
const defines = subMesh.materialDefines;
|
|
349
|
+
if (!defines) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const effect = subMesh.effect;
|
|
353
|
+
if (!effect) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
this._activeEffect = effect;
|
|
357
|
+
// Matrices
|
|
358
|
+
this.bindOnlyWorldMatrix(world);
|
|
359
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
360
|
+
// Bones
|
|
361
|
+
BindBonesParameters(mesh, this._activeEffect);
|
|
362
|
+
if (this._mustRebind(scene, effect, subMesh)) {
|
|
363
|
+
// Textures
|
|
364
|
+
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
365
|
+
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
|
|
366
|
+
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
|
|
367
|
+
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
|
|
368
|
+
}
|
|
369
|
+
if (this._heightTexture) {
|
|
370
|
+
this._activeEffect.setTexture("heightTexture", this._heightTexture);
|
|
371
|
+
}
|
|
372
|
+
// Clip plane
|
|
373
|
+
BindClipPlane(this._activeEffect, this, scene);
|
|
374
|
+
// Point size
|
|
375
|
+
if (this.pointsCloud) {
|
|
376
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
377
|
+
}
|
|
378
|
+
// Log. depth
|
|
379
|
+
if (this._useLogarithmicDepth) {
|
|
380
|
+
BindLogDepth(defines, effect, scene);
|
|
381
|
+
}
|
|
382
|
+
scene.bindEyePosition(effect);
|
|
383
|
+
}
|
|
384
|
+
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
385
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
|
386
|
+
BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
|
387
|
+
}
|
|
388
|
+
// View
|
|
389
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
390
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
|
391
|
+
}
|
|
392
|
+
// Fog
|
|
393
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
|
394
|
+
this._activeEffect.setFloat("furLength", this.furLength);
|
|
395
|
+
this._activeEffect.setFloat("furAngle", this.furAngle);
|
|
396
|
+
this._activeEffect.setColor4("furColor", this.furColor, 1.0);
|
|
397
|
+
if (this.highLevelFur) {
|
|
398
|
+
this._activeEffect.setVector3("furGravity", this.furGravity);
|
|
399
|
+
this._activeEffect.setFloat("furOffset", this.furOffset);
|
|
400
|
+
this._activeEffect.setFloat("furSpacing", this.furSpacing);
|
|
401
|
+
this._activeEffect.setFloat("furDensity", this.furDensity);
|
|
402
|
+
this._activeEffect.setFloat("furOcclusion", this.furOcclusion);
|
|
403
|
+
this._furTime += this.getScene().getEngine().getDeltaTime() / this.furSpeed;
|
|
404
|
+
this._activeEffect.setFloat("furTime", this._furTime);
|
|
405
|
+
this._activeEffect.setTexture("furTexture", this.furTexture);
|
|
406
|
+
}
|
|
407
|
+
this._afterBind(mesh, this._activeEffect, subMesh);
|
|
178
408
|
}
|
|
179
|
-
|
|
180
|
-
|
|
409
|
+
getAnimatables() {
|
|
410
|
+
const results = [];
|
|
411
|
+
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
|
|
412
|
+
results.push(this.diffuseTexture);
|
|
413
|
+
}
|
|
414
|
+
if (this.heightTexture && this.heightTexture.animations && this.heightTexture.animations.length > 0) {
|
|
415
|
+
results.push(this.heightTexture);
|
|
416
|
+
}
|
|
417
|
+
return results;
|
|
181
418
|
}
|
|
182
|
-
|
|
183
|
-
|
|
419
|
+
getActiveTextures() {
|
|
420
|
+
const activeTextures = super.getActiveTextures();
|
|
421
|
+
if (this._diffuseTexture) {
|
|
422
|
+
activeTextures.push(this._diffuseTexture);
|
|
423
|
+
}
|
|
424
|
+
if (this._heightTexture) {
|
|
425
|
+
activeTextures.push(this._heightTexture);
|
|
426
|
+
}
|
|
427
|
+
return activeTextures;
|
|
184
428
|
}
|
|
185
|
-
|
|
186
|
-
|
|
429
|
+
hasTexture(texture) {
|
|
430
|
+
if (super.hasTexture(texture)) {
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
if (this.diffuseTexture === texture) {
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
if (this._heightTexture === texture) {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
187
440
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"vEyePosition",
|
|
198
|
-
"vLightsType",
|
|
199
|
-
"vDiffuseColor",
|
|
200
|
-
"vFogInfos",
|
|
201
|
-
"vFogColor",
|
|
202
|
-
"pointSize",
|
|
203
|
-
"vDiffuseInfos",
|
|
204
|
-
"mBones",
|
|
205
|
-
"diffuseMatrix",
|
|
206
|
-
"logarithmicDepthConstant",
|
|
207
|
-
"furLength",
|
|
208
|
-
"furAngle",
|
|
209
|
-
"furColor",
|
|
210
|
-
"furOffset",
|
|
211
|
-
"furGravity",
|
|
212
|
-
"furTime",
|
|
213
|
-
"furSpacing",
|
|
214
|
-
"furDensity",
|
|
215
|
-
"furOcclusion",
|
|
216
|
-
];
|
|
217
|
-
AddClipPlaneUniforms(uniforms);
|
|
218
|
-
const samplers = ["diffuseSampler", "heightTexture", "furTexture", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
|
|
219
|
-
const uniformBuffers = [];
|
|
220
|
-
PrepareUniformsAndSamplersList({
|
|
221
|
-
uniformsNames: uniforms,
|
|
222
|
-
uniformBuffersNames: uniformBuffers,
|
|
223
|
-
samplers: samplers,
|
|
224
|
-
defines: defines,
|
|
225
|
-
maxSimultaneousLights: this.maxSimultaneousLights,
|
|
226
|
-
shaderLanguage: this._shaderLanguage,
|
|
227
|
-
});
|
|
228
|
-
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
229
|
-
attributes: attribs,
|
|
230
|
-
uniformsNames: uniforms,
|
|
231
|
-
uniformBuffersNames: uniformBuffers,
|
|
232
|
-
samplers: samplers,
|
|
233
|
-
defines: join,
|
|
234
|
-
fallbacks: fallbacks,
|
|
235
|
-
onCompiled: this.onCompiled,
|
|
236
|
-
onError: this.onError,
|
|
237
|
-
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
|
238
|
-
shaderLanguage: this._shaderLanguage,
|
|
239
|
-
extraInitializationsAsync: this._shadersLoaded
|
|
240
|
-
? undefined
|
|
241
|
-
: async () => {
|
|
242
|
-
if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
243
|
-
await Promise.all([import("./wgsl/fur.vertex.js"), import("./wgsl/fur.fragment.js")]);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
await Promise.all([import("./fur.vertex.js"), import("./fur.fragment.js")]);
|
|
441
|
+
dispose(forceDisposeEffect) {
|
|
442
|
+
if (this.diffuseTexture) {
|
|
443
|
+
this.diffuseTexture.dispose();
|
|
444
|
+
}
|
|
445
|
+
if (this._meshes) {
|
|
446
|
+
for (let i = 1; i < this._meshes.length; i++) {
|
|
447
|
+
const mat = this._meshes[i].material;
|
|
448
|
+
if (mat) {
|
|
449
|
+
mat.dispose(forceDisposeEffect);
|
|
247
450
|
}
|
|
248
|
-
this.
|
|
249
|
-
}
|
|
250
|
-
}, engine), defines, this._materialContext);
|
|
251
|
-
}
|
|
252
|
-
// Check if Area Lights have LTC texture.
|
|
253
|
-
if (defines["AREALIGHTUSED"]) {
|
|
254
|
-
for (let index = 0; index < mesh.lightSources.length; index++) {
|
|
255
|
-
if (!mesh.lightSources[index]._isReady()) {
|
|
256
|
-
return false;
|
|
451
|
+
this._meshes[i].dispose();
|
|
452
|
+
}
|
|
257
453
|
}
|
|
454
|
+
super.dispose(forceDisposeEffect);
|
|
258
455
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
defines._renderId = scene.getRenderId();
|
|
264
|
-
drawWrapper._wasPreviouslyReady = true;
|
|
265
|
-
drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
bindForSubMesh(world, mesh, subMesh) {
|
|
269
|
-
const scene = this.getScene();
|
|
270
|
-
const defines = subMesh.materialDefines;
|
|
271
|
-
if (!defines) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const effect = subMesh.effect;
|
|
275
|
-
if (!effect) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
this._activeEffect = effect;
|
|
279
|
-
// Matrices
|
|
280
|
-
this.bindOnlyWorldMatrix(world);
|
|
281
|
-
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
282
|
-
// Bones
|
|
283
|
-
BindBonesParameters(mesh, this._activeEffect);
|
|
284
|
-
if (this._mustRebind(scene, effect, subMesh)) {
|
|
285
|
-
// Textures
|
|
286
|
-
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
287
|
-
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
|
|
288
|
-
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
|
|
289
|
-
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
|
|
456
|
+
clone(name) {
|
|
457
|
+
return SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
|
|
290
458
|
}
|
|
291
|
-
|
|
292
|
-
|
|
459
|
+
serialize() {
|
|
460
|
+
const serializationObject = super.serialize();
|
|
461
|
+
serializationObject.customType = "BABYLON.FurMaterial";
|
|
462
|
+
if (this._meshes) {
|
|
463
|
+
serializationObject.sourceMeshName = this._meshes[0].name;
|
|
464
|
+
serializationObject.quality = this._meshes.length;
|
|
465
|
+
}
|
|
466
|
+
return serializationObject;
|
|
293
467
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// Point size
|
|
297
|
-
if (this.pointsCloud) {
|
|
298
|
-
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
468
|
+
getClassName() {
|
|
469
|
+
return "FurMaterial";
|
|
299
470
|
}
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
471
|
+
// Statics
|
|
472
|
+
static Parse(source, scene, rootUrl) {
|
|
473
|
+
const material = SerializationHelper.Parse(() => new _a(source.name, scene), source, scene, rootUrl);
|
|
474
|
+
if (source.sourceMeshName && material.highLevelFur) {
|
|
475
|
+
scene.executeWhenReady(() => {
|
|
476
|
+
const sourceMesh = scene.getMeshByName(source.sourceMeshName);
|
|
477
|
+
if (sourceMesh) {
|
|
478
|
+
const furTexture = _a.GenerateTexture("Fur Texture", scene);
|
|
479
|
+
material.furTexture = furTexture;
|
|
480
|
+
_a.FurifyMesh(sourceMesh, source.quality);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return material;
|
|
303
485
|
}
|
|
304
|
-
scene
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
312
|
-
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
|
313
|
-
}
|
|
314
|
-
// Fog
|
|
315
|
-
BindFogParameters(scene, mesh, this._activeEffect);
|
|
316
|
-
this._activeEffect.setFloat("furLength", this.furLength);
|
|
317
|
-
this._activeEffect.setFloat("furAngle", this.furAngle);
|
|
318
|
-
this._activeEffect.setColor4("furColor", this.furColor, 1.0);
|
|
319
|
-
if (this.highLevelFur) {
|
|
320
|
-
this._activeEffect.setVector3("furGravity", this.furGravity);
|
|
321
|
-
this._activeEffect.setFloat("furOffset", this.furOffset);
|
|
322
|
-
this._activeEffect.setFloat("furSpacing", this.furSpacing);
|
|
323
|
-
this._activeEffect.setFloat("furDensity", this.furDensity);
|
|
324
|
-
this._activeEffect.setFloat("furOcclusion", this.furOcclusion);
|
|
325
|
-
this._furTime += this.getScene().getEngine().getDeltaTime() / this.furSpeed;
|
|
326
|
-
this._activeEffect.setFloat("furTime", this._furTime);
|
|
327
|
-
this._activeEffect.setTexture("furTexture", this.furTexture);
|
|
328
|
-
}
|
|
329
|
-
this._afterBind(mesh, this._activeEffect, subMesh);
|
|
330
|
-
}
|
|
331
|
-
getAnimatables() {
|
|
332
|
-
const results = [];
|
|
333
|
-
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
|
|
334
|
-
results.push(this.diffuseTexture);
|
|
335
|
-
}
|
|
336
|
-
if (this.heightTexture && this.heightTexture.animations && this.heightTexture.animations.length > 0) {
|
|
337
|
-
results.push(this.heightTexture);
|
|
338
|
-
}
|
|
339
|
-
return results;
|
|
340
|
-
}
|
|
341
|
-
getActiveTextures() {
|
|
342
|
-
const activeTextures = super.getActiveTextures();
|
|
343
|
-
if (this._diffuseTexture) {
|
|
344
|
-
activeTextures.push(this._diffuseTexture);
|
|
345
|
-
}
|
|
346
|
-
if (this._heightTexture) {
|
|
347
|
-
activeTextures.push(this._heightTexture);
|
|
348
|
-
}
|
|
349
|
-
return activeTextures;
|
|
350
|
-
}
|
|
351
|
-
hasTexture(texture) {
|
|
352
|
-
if (super.hasTexture(texture)) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
if (this.diffuseTexture === texture) {
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
if (this._heightTexture === texture) {
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
dispose(forceDisposeEffect) {
|
|
364
|
-
if (this.diffuseTexture) {
|
|
365
|
-
this.diffuseTexture.dispose();
|
|
366
|
-
}
|
|
367
|
-
if (this._meshes) {
|
|
368
|
-
for (let i = 1; i < this._meshes.length; i++) {
|
|
369
|
-
const mat = this._meshes[i].material;
|
|
370
|
-
if (mat) {
|
|
371
|
-
mat.dispose(forceDisposeEffect);
|
|
486
|
+
static GenerateTexture(name, scene) {
|
|
487
|
+
// Generate fur textures
|
|
488
|
+
const texture = new DynamicTexture("FurTexture " + name, 256, scene, true);
|
|
489
|
+
const context = texture.getContext();
|
|
490
|
+
for (let i = 0; i < 20000; ++i) {
|
|
491
|
+
context.fillStyle = "rgba(255, " + Math.floor(Math.random() * 255) + ", " + Math.floor(Math.random() * 255) + ", 1)";
|
|
492
|
+
context.fillRect(Math.random() * texture.getSize().width, Math.random() * texture.getSize().height, 2, 2);
|
|
372
493
|
}
|
|
373
|
-
|
|
494
|
+
texture.update(false);
|
|
495
|
+
texture.wrapU = Texture.WRAP_ADDRESSMODE;
|
|
496
|
+
texture.wrapV = Texture.WRAP_ADDRESSMODE;
|
|
497
|
+
return texture;
|
|
374
498
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
serializationObject.sourceMeshName = this._meshes[0].name;
|
|
386
|
-
serializationObject.quality = this._meshes.length;
|
|
387
|
-
}
|
|
388
|
-
return serializationObject;
|
|
389
|
-
}
|
|
390
|
-
getClassName() {
|
|
391
|
-
return "FurMaterial";
|
|
392
|
-
}
|
|
393
|
-
// Statics
|
|
394
|
-
static Parse(source, scene, rootUrl) {
|
|
395
|
-
const material = SerializationHelper.Parse(() => new FurMaterial(source.name, scene), source, scene, rootUrl);
|
|
396
|
-
if (source.sourceMeshName && material.highLevelFur) {
|
|
397
|
-
scene.executeWhenReady(() => {
|
|
398
|
-
const sourceMesh = scene.getMeshByName(source.sourceMeshName);
|
|
399
|
-
if (sourceMesh) {
|
|
400
|
-
const furTexture = FurMaterial.GenerateTexture("Fur Texture", scene);
|
|
401
|
-
material.furTexture = furTexture;
|
|
402
|
-
FurMaterial.FurifyMesh(sourceMesh, source.quality);
|
|
499
|
+
// Creates and returns an array of meshes used as shells for the Fur Material
|
|
500
|
+
// that can be disposed later in your code
|
|
501
|
+
// The quality is in interval [0, 100]
|
|
502
|
+
static FurifyMesh(sourceMesh, quality) {
|
|
503
|
+
const meshes = [sourceMesh];
|
|
504
|
+
const mat = sourceMesh.material;
|
|
505
|
+
let i;
|
|
506
|
+
if (!(mat instanceof _a)) {
|
|
507
|
+
// eslint-disable-next-line no-throw-literal
|
|
508
|
+
throw "The material of the source mesh must be a Fur Material";
|
|
403
509
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
], FurMaterial.prototype, "furColor", void 0);
|
|
486
|
-
__decorate([
|
|
487
|
-
serialize()
|
|
488
|
-
], FurMaterial.prototype, "furOffset", void 0);
|
|
489
|
-
__decorate([
|
|
490
|
-
serialize()
|
|
491
|
-
], FurMaterial.prototype, "furSpacing", void 0);
|
|
492
|
-
__decorate([
|
|
493
|
-
serializeAsVector3()
|
|
494
|
-
], FurMaterial.prototype, "furGravity", void 0);
|
|
495
|
-
__decorate([
|
|
496
|
-
serialize()
|
|
497
|
-
], FurMaterial.prototype, "furSpeed", void 0);
|
|
498
|
-
__decorate([
|
|
499
|
-
serialize()
|
|
500
|
-
], FurMaterial.prototype, "furDensity", void 0);
|
|
501
|
-
__decorate([
|
|
502
|
-
serialize()
|
|
503
|
-
], FurMaterial.prototype, "furOcclusion", void 0);
|
|
504
|
-
__decorate([
|
|
505
|
-
serialize("disableLighting")
|
|
506
|
-
], FurMaterial.prototype, "_disableLighting", void 0);
|
|
507
|
-
__decorate([
|
|
508
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
509
|
-
], FurMaterial.prototype, "disableLighting", void 0);
|
|
510
|
-
__decorate([
|
|
511
|
-
serialize("maxSimultaneousLights")
|
|
512
|
-
], FurMaterial.prototype, "_maxSimultaneousLights", void 0);
|
|
513
|
-
__decorate([
|
|
514
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
515
|
-
], FurMaterial.prototype, "maxSimultaneousLights", void 0);
|
|
516
|
-
__decorate([
|
|
517
|
-
serialize()
|
|
518
|
-
], FurMaterial.prototype, "highLevelFur", void 0);
|
|
519
|
-
__decorate([
|
|
520
|
-
serialize()
|
|
521
|
-
], FurMaterial.prototype, "furTime", null);
|
|
510
|
+
for (i = 1; i < quality; i++) {
|
|
511
|
+
const offsetFur = new _a(mat.name + i, sourceMesh.getScene());
|
|
512
|
+
sourceMesh.getScene().materials.pop();
|
|
513
|
+
Tags.EnableFor(offsetFur);
|
|
514
|
+
Tags.AddTagsTo(offsetFur, "furShellMaterial");
|
|
515
|
+
offsetFur.furLength = mat.furLength;
|
|
516
|
+
offsetFur.furAngle = mat.furAngle;
|
|
517
|
+
offsetFur.furGravity = mat.furGravity;
|
|
518
|
+
offsetFur.furSpacing = mat.furSpacing;
|
|
519
|
+
offsetFur.furSpeed = mat.furSpeed;
|
|
520
|
+
offsetFur.furColor = mat.furColor;
|
|
521
|
+
offsetFur.diffuseTexture = mat.diffuseTexture;
|
|
522
|
+
offsetFur.furOffset = i / quality;
|
|
523
|
+
offsetFur.furTexture = mat.furTexture;
|
|
524
|
+
offsetFur.highLevelFur = mat.highLevelFur;
|
|
525
|
+
offsetFur.furTime = mat.furTime;
|
|
526
|
+
offsetFur.furDensity = mat.furDensity;
|
|
527
|
+
const offsetMesh = sourceMesh.clone(sourceMesh.name + i);
|
|
528
|
+
offsetMesh.material = offsetFur;
|
|
529
|
+
offsetMesh.skeleton = sourceMesh.skeleton;
|
|
530
|
+
offsetMesh.position = Vector3.Zero();
|
|
531
|
+
meshes.push(offsetMesh);
|
|
532
|
+
}
|
|
533
|
+
for (i = 1; i < meshes.length; i++) {
|
|
534
|
+
meshes[i].parent = sourceMesh;
|
|
535
|
+
}
|
|
536
|
+
sourceMesh.material._meshes = meshes;
|
|
537
|
+
return meshes;
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
_FurMaterial_diffuseTexture_accessor_storage = new WeakMap(),
|
|
541
|
+
_FurMaterial_heightTexture_accessor_storage = new WeakMap(),
|
|
542
|
+
_FurMaterial_disableLighting_accessor_storage = new WeakMap(),
|
|
543
|
+
_FurMaterial_maxSimultaneousLights_accessor_storage = new WeakMap(),
|
|
544
|
+
(() => {
|
|
545
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
546
|
+
__diffuseTexture_decorators = [serializeAsTexture("diffuseTexture")];
|
|
547
|
+
_diffuseTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
|
|
548
|
+
__heightTexture_decorators = [serializeAsTexture("heightTexture")];
|
|
549
|
+
_heightTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
|
|
550
|
+
_diffuseColor_decorators = [serializeAsColor3()];
|
|
551
|
+
_furLength_decorators = [serialize()];
|
|
552
|
+
_furAngle_decorators = [serialize()];
|
|
553
|
+
_furColor_decorators = [serializeAsColor3()];
|
|
554
|
+
_furOffset_decorators = [serialize()];
|
|
555
|
+
_furSpacing_decorators = [serialize()];
|
|
556
|
+
_furGravity_decorators = [serializeAsVector3()];
|
|
557
|
+
_furSpeed_decorators = [serialize()];
|
|
558
|
+
_furDensity_decorators = [serialize()];
|
|
559
|
+
_furOcclusion_decorators = [serialize()];
|
|
560
|
+
__disableLighting_decorators = [serialize("disableLighting")];
|
|
561
|
+
_disableLighting_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
|
|
562
|
+
__maxSimultaneousLights_decorators = [serialize("maxSimultaneousLights")];
|
|
563
|
+
_maxSimultaneousLights_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
|
|
564
|
+
_highLevelFur_decorators = [serialize()];
|
|
565
|
+
_get_furTime_decorators = [serialize()];
|
|
566
|
+
__esDecorate(_a, null, _diffuseTexture_decorators, { kind: "accessor", name: "diffuseTexture", static: false, private: false, access: { has: obj => "diffuseTexture" in obj, get: obj => obj.diffuseTexture, set: (obj, value) => { obj.diffuseTexture = value; } }, metadata: _metadata }, _diffuseTexture_initializers, _diffuseTexture_extraInitializers);
|
|
567
|
+
__esDecorate(_a, null, _heightTexture_decorators, { kind: "accessor", name: "heightTexture", static: false, private: false, access: { has: obj => "heightTexture" in obj, get: obj => obj.heightTexture, set: (obj, value) => { obj.heightTexture = value; } }, metadata: _metadata }, _heightTexture_initializers, _heightTexture_extraInitializers);
|
|
568
|
+
__esDecorate(_a, null, _disableLighting_decorators, { kind: "accessor", name: "disableLighting", static: false, private: false, access: { has: obj => "disableLighting" in obj, get: obj => obj.disableLighting, set: (obj, value) => { obj.disableLighting = value; } }, metadata: _metadata }, _disableLighting_initializers, _disableLighting_extraInitializers);
|
|
569
|
+
__esDecorate(_a, null, _maxSimultaneousLights_decorators, { kind: "accessor", name: "maxSimultaneousLights", static: false, private: false, access: { has: obj => "maxSimultaneousLights" in obj, get: obj => obj.maxSimultaneousLights, set: (obj, value) => { obj.maxSimultaneousLights = value; } }, metadata: _metadata }, _maxSimultaneousLights_initializers, _maxSimultaneousLights_extraInitializers);
|
|
570
|
+
__esDecorate(_a, null, _get_furTime_decorators, { kind: "getter", name: "furTime", static: false, private: false, access: { has: obj => "furTime" in obj, get: obj => obj.furTime }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
571
|
+
__esDecorate(null, null, __diffuseTexture_decorators, { kind: "field", name: "_diffuseTexture", static: false, private: false, access: { has: obj => "_diffuseTexture" in obj, get: obj => obj._diffuseTexture, set: (obj, value) => { obj._diffuseTexture = value; } }, metadata: _metadata }, __diffuseTexture_initializers, __diffuseTexture_extraInitializers);
|
|
572
|
+
__esDecorate(null, null, __heightTexture_decorators, { kind: "field", name: "_heightTexture", static: false, private: false, access: { has: obj => "_heightTexture" in obj, get: obj => obj._heightTexture, set: (obj, value) => { obj._heightTexture = value; } }, metadata: _metadata }, __heightTexture_initializers, __heightTexture_extraInitializers);
|
|
573
|
+
__esDecorate(null, null, _diffuseColor_decorators, { kind: "field", name: "diffuseColor", static: false, private: false, access: { has: obj => "diffuseColor" in obj, get: obj => obj.diffuseColor, set: (obj, value) => { obj.diffuseColor = value; } }, metadata: _metadata }, _diffuseColor_initializers, _diffuseColor_extraInitializers);
|
|
574
|
+
__esDecorate(null, null, _furLength_decorators, { kind: "field", name: "furLength", static: false, private: false, access: { has: obj => "furLength" in obj, get: obj => obj.furLength, set: (obj, value) => { obj.furLength = value; } }, metadata: _metadata }, _furLength_initializers, _furLength_extraInitializers);
|
|
575
|
+
__esDecorate(null, null, _furAngle_decorators, { kind: "field", name: "furAngle", static: false, private: false, access: { has: obj => "furAngle" in obj, get: obj => obj.furAngle, set: (obj, value) => { obj.furAngle = value; } }, metadata: _metadata }, _furAngle_initializers, _furAngle_extraInitializers);
|
|
576
|
+
__esDecorate(null, null, _furColor_decorators, { kind: "field", name: "furColor", static: false, private: false, access: { has: obj => "furColor" in obj, get: obj => obj.furColor, set: (obj, value) => { obj.furColor = value; } }, metadata: _metadata }, _furColor_initializers, _furColor_extraInitializers);
|
|
577
|
+
__esDecorate(null, null, _furOffset_decorators, { kind: "field", name: "furOffset", static: false, private: false, access: { has: obj => "furOffset" in obj, get: obj => obj.furOffset, set: (obj, value) => { obj.furOffset = value; } }, metadata: _metadata }, _furOffset_initializers, _furOffset_extraInitializers);
|
|
578
|
+
__esDecorate(null, null, _furSpacing_decorators, { kind: "field", name: "furSpacing", static: false, private: false, access: { has: obj => "furSpacing" in obj, get: obj => obj.furSpacing, set: (obj, value) => { obj.furSpacing = value; } }, metadata: _metadata }, _furSpacing_initializers, _furSpacing_extraInitializers);
|
|
579
|
+
__esDecorate(null, null, _furGravity_decorators, { kind: "field", name: "furGravity", static: false, private: false, access: { has: obj => "furGravity" in obj, get: obj => obj.furGravity, set: (obj, value) => { obj.furGravity = value; } }, metadata: _metadata }, _furGravity_initializers, _furGravity_extraInitializers);
|
|
580
|
+
__esDecorate(null, null, _furSpeed_decorators, { kind: "field", name: "furSpeed", static: false, private: false, access: { has: obj => "furSpeed" in obj, get: obj => obj.furSpeed, set: (obj, value) => { obj.furSpeed = value; } }, metadata: _metadata }, _furSpeed_initializers, _furSpeed_extraInitializers);
|
|
581
|
+
__esDecorate(null, null, _furDensity_decorators, { kind: "field", name: "furDensity", static: false, private: false, access: { has: obj => "furDensity" in obj, get: obj => obj.furDensity, set: (obj, value) => { obj.furDensity = value; } }, metadata: _metadata }, _furDensity_initializers, _furDensity_extraInitializers);
|
|
582
|
+
__esDecorate(null, null, _furOcclusion_decorators, { kind: "field", name: "furOcclusion", static: false, private: false, access: { has: obj => "furOcclusion" in obj, get: obj => obj.furOcclusion, set: (obj, value) => { obj.furOcclusion = value; } }, metadata: _metadata }, _furOcclusion_initializers, _furOcclusion_extraInitializers);
|
|
583
|
+
__esDecorate(null, null, __disableLighting_decorators, { kind: "field", name: "_disableLighting", static: false, private: false, access: { has: obj => "_disableLighting" in obj, get: obj => obj._disableLighting, set: (obj, value) => { obj._disableLighting = value; } }, metadata: _metadata }, __disableLighting_initializers, __disableLighting_extraInitializers);
|
|
584
|
+
__esDecorate(null, null, __maxSimultaneousLights_decorators, { kind: "field", name: "_maxSimultaneousLights", static: false, private: false, access: { has: obj => "_maxSimultaneousLights" in obj, get: obj => obj._maxSimultaneousLights, set: (obj, value) => { obj._maxSimultaneousLights = value; } }, metadata: _metadata }, __maxSimultaneousLights_initializers, __maxSimultaneousLights_extraInitializers);
|
|
585
|
+
__esDecorate(null, null, _highLevelFur_decorators, { kind: "field", name: "highLevelFur", static: false, private: false, access: { has: obj => "highLevelFur" in obj, get: obj => obj.highLevelFur, set: (obj, value) => { obj.highLevelFur = value; } }, metadata: _metadata }, _highLevelFur_initializers, _highLevelFur_extraInitializers);
|
|
586
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
587
|
+
})(),
|
|
588
|
+
_a;
|
|
589
|
+
})();
|
|
590
|
+
export { FurMaterial };
|
|
522
591
|
RegisterClass("BABYLON.FurMaterial", FurMaterial);
|
|
523
592
|
//# sourceMappingURL=furMaterial.js.map
|