@babylonjs/core 7.28.0 → 7.30.0
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/Culling/ray.core.d.ts +13 -0
- package/Culling/ray.core.js +14 -6
- package/Culling/ray.core.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +24 -0
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +2 -1
- package/Engines/index.d.ts +1 -0
- package/Engines/index.js +1 -0
- package/Engines/index.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -0
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +4 -0
- package/Engines/webgpuEngine.js +2 -4
- package/Engines/webgpuEngine.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +1 -1
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +34 -18
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Textures/rawTexture3D.d.ts +12 -0
- package/Materials/Textures/rawTexture3D.js +18 -0
- package/Materials/Textures/rawTexture3D.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +1 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/effect.d.ts +11 -0
- package/Materials/effect.js +20 -0
- package/Materials/effect.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +46 -46
- package/Materials/materialPluginBase.js +46 -60
- package/Materials/materialPluginBase.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +0 -16
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +17 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +3 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +91 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js +194 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +11 -4
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +8 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js +22 -6
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInterceptorBlock.d.ts +5 -0
- package/Meshes/Node/Blocks/geometryInterceptorBlock.js +5 -1
- package/Meshes/Node/Blocks/geometryInterceptorBlock.js.map +1 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +5 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +4 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +12 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +2 -0
- package/Meshes/abstractMesh.hotSpot.d.ts +30 -0
- package/Meshes/abstractMesh.hotSpot.js +84 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -0
- package/Meshes/abstractMesh.js +2 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/index.d.ts +3 -0
- package/Meshes/index.js +3 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/lattice.d.ts +110 -0
- package/Meshes/lattice.js +224 -0
- package/Meshes/lattice.js.map +1 -0
- package/Meshes/lattice.material.d.ts +82 -0
- package/Meshes/lattice.material.js +259 -0
- package/Meshes/lattice.material.js.map +1 -0
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -2
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/screenshotTools.js +0 -3
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +63 -0
- package/Misc/snapshotRenderingHelper.js +182 -0
- package/Misc/snapshotRenderingHelper.js.map +1 -0
- package/Morph/morphTargetManager.js +0 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Shaders/spriteMap.fragment.d.ts +4 -0
- package/Shaders/spriteMap.fragment.js +16 -3
- package/Shaders/spriteMap.fragment.js.map +1 -1
- package/Shaders/spriteMap.vertex.d.ts +3 -0
- package/Shaders/spriteMap.vertex.js +14 -2
- package/Shaders/spriteMap.vertex.js.map +1 -1
- package/ShadersWGSL/bilateralBlurQuality.fragment.js +1 -1
- package/ShadersWGSL/bilateralBlurQuality.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +2 -2
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +2 -2
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +1 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/rsmFullGlobalIllumination.fragment.js +1 -1
- package/ShadersWGSL/rsmFullGlobalIllumination.fragment.js.map +1 -1
- package/Sprites/spriteManager.d.ts +10 -1
- package/Sprites/spriteManager.js +3 -2
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteMap.d.ts +7 -0
- package/Sprites/spriteMap.js +29 -1
- package/Sprites/spriteMap.js.map +1 -1
- package/Sprites/spritePackedManager.d.ts +6 -1
- package/Sprites/spritePackedManager.js +6 -2
- package/Sprites/spritePackedManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +16 -3
- package/Sprites/spriteRenderer.js +5 -3
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -79,51 +79,46 @@ export class MaterialPluginBase {
|
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Specifies that the submesh is ready to be used.
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
82
|
+
* @param _defines the list of "defines" to update.
|
|
83
|
+
* @param _scene defines the scene the material belongs to.
|
|
84
|
+
* @param _engine the engine this scene belongs to.
|
|
85
|
+
* @param _subMesh the submesh to check for readiness
|
|
86
86
|
* @returns - boolean indicating that the submesh is ready or not.
|
|
87
87
|
*/
|
|
88
|
-
|
|
89
|
-
isReadyForSubMesh(defines, scene, engine, subMesh) {
|
|
88
|
+
isReadyForSubMesh(_defines, _scene, _engine, _subMesh) {
|
|
90
89
|
return true;
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
93
92
|
* Binds the material data (this function is called even if mustRebind() returns false)
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
93
|
+
* @param _uniformBuffer defines the Uniform buffer to fill in.
|
|
94
|
+
* @param _scene defines the scene the material belongs to.
|
|
95
|
+
* @param _engine defines the engine the material belongs to.
|
|
96
|
+
* @param _subMesh the submesh to bind data for
|
|
98
97
|
*/
|
|
99
|
-
|
|
100
|
-
hardBindForSubMesh(uniformBuffer, scene, engine, subMesh) { }
|
|
98
|
+
hardBindForSubMesh(_uniformBuffer, _scene, _engine, _subMesh) { }
|
|
101
99
|
/**
|
|
102
100
|
* Binds the material data.
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
101
|
+
* @param _uniformBuffer defines the Uniform buffer to fill in.
|
|
102
|
+
* @param _scene defines the scene the material belongs to.
|
|
103
|
+
* @param _engine the engine this scene belongs to.
|
|
104
|
+
* @param _subMesh the submesh to bind data for
|
|
107
105
|
*/
|
|
108
|
-
|
|
109
|
-
bindForSubMesh(uniformBuffer, scene, engine, subMesh) { }
|
|
106
|
+
bindForSubMesh(_uniformBuffer, _scene, _engine, _subMesh) { }
|
|
110
107
|
/**
|
|
111
108
|
* Disposes the resources of the material.
|
|
112
|
-
* @param
|
|
109
|
+
* @param _forceDisposeTextures - Forces the disposal of all textures.
|
|
113
110
|
*/
|
|
114
|
-
|
|
115
|
-
dispose(forceDisposeTextures) { }
|
|
111
|
+
dispose(_forceDisposeTextures) { }
|
|
116
112
|
/**
|
|
117
113
|
* Returns a list of custom shader code fragments to customize the shader.
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
114
|
+
* @param _shaderType "vertex" or "fragment"
|
|
115
|
+
* @param _shaderLanguage The shader language to use.
|
|
120
116
|
* @returns null if no code to be added, or a list of pointName =\> code.
|
|
121
117
|
* Note that `pointName` can also be a regular expression if it starts with a `!`.
|
|
122
118
|
* In that case, the string found by the regular expression (if any) will be
|
|
123
119
|
* replaced by the code provided.
|
|
124
120
|
*/
|
|
125
|
-
|
|
126
|
-
getCustomCode(shaderType, shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
121
|
+
getCustomCode(_shaderType, _shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
127
122
|
return null;
|
|
128
123
|
}
|
|
129
124
|
/**
|
|
@@ -147,27 +142,24 @@ export class MaterialPluginBase {
|
|
|
147
142
|
}
|
|
148
143
|
/**
|
|
149
144
|
* Sets the defines for the next rendering. Called before PrepareDefinesForAttributes is called.
|
|
150
|
-
* @param
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
145
|
+
* @param _defines the list of "defines" to update.
|
|
146
|
+
* @param _scene defines the scene to the material belongs to.
|
|
147
|
+
* @param _mesh the mesh being rendered
|
|
153
148
|
*/
|
|
154
|
-
|
|
155
|
-
prepareDefinesBeforeAttributes(defines, scene, mesh) { }
|
|
149
|
+
prepareDefinesBeforeAttributes(_defines, _scene, _mesh) { }
|
|
156
150
|
/**
|
|
157
151
|
* Sets the defines for the next rendering
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
152
|
+
* @param _defines the list of "defines" to update.
|
|
153
|
+
* @param _scene defines the scene to the material belongs to.
|
|
154
|
+
* @param _mesh the mesh being rendered
|
|
161
155
|
*/
|
|
162
|
-
|
|
163
|
-
prepareDefines(defines, scene, mesh) { }
|
|
156
|
+
prepareDefines(_defines, _scene, _mesh) { }
|
|
164
157
|
/**
|
|
165
158
|
* Checks to see if a texture is used in the material.
|
|
166
|
-
* @param
|
|
159
|
+
* @param _texture - Base texture to use.
|
|
167
160
|
* @returns - Boolean specifying if a texture is used in the material.
|
|
168
161
|
*/
|
|
169
|
-
|
|
170
|
-
hasTexture(texture) {
|
|
162
|
+
hasTexture(_texture) {
|
|
171
163
|
return false;
|
|
172
164
|
}
|
|
173
165
|
/**
|
|
@@ -179,22 +171,19 @@ export class MaterialPluginBase {
|
|
|
179
171
|
}
|
|
180
172
|
/**
|
|
181
173
|
* Fills the list of render target textures.
|
|
182
|
-
* @param
|
|
174
|
+
* @param _renderTargets the list of render targets to update
|
|
183
175
|
*/
|
|
184
|
-
|
|
185
|
-
fillRenderTargetTextures(renderTargets) { }
|
|
176
|
+
fillRenderTargetTextures(_renderTargets) { }
|
|
186
177
|
/**
|
|
187
178
|
* Returns an array of the actively used textures.
|
|
188
|
-
* @param
|
|
179
|
+
* @param _activeTextures Array of BaseTextures
|
|
189
180
|
*/
|
|
190
|
-
|
|
191
|
-
getActiveTextures(activeTextures) { }
|
|
181
|
+
getActiveTextures(_activeTextures) { }
|
|
192
182
|
/**
|
|
193
183
|
* Returns the animatable textures.
|
|
194
|
-
* @param
|
|
184
|
+
* @param _animatables Array of animatable textures.
|
|
195
185
|
*/
|
|
196
|
-
|
|
197
|
-
getAnimatables(animatables) { }
|
|
186
|
+
getAnimatables(_animatables) { }
|
|
198
187
|
/**
|
|
199
188
|
* Add fallbacks to the effect fallbacks list.
|
|
200
189
|
* @param defines defines the Base texture to use.
|
|
@@ -207,30 +196,27 @@ export class MaterialPluginBase {
|
|
|
207
196
|
}
|
|
208
197
|
/**
|
|
209
198
|
* Gets the samplers used by the plugin.
|
|
210
|
-
* @param
|
|
199
|
+
* @param _samplers list that the sampler names should be added to.
|
|
211
200
|
*/
|
|
212
|
-
|
|
213
|
-
getSamplers(samplers) { }
|
|
201
|
+
getSamplers(_samplers) { }
|
|
214
202
|
/**
|
|
215
203
|
* Gets the attributes used by the plugin.
|
|
216
|
-
* @param
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
204
|
+
* @param _attributes list that the attribute names should be added to.
|
|
205
|
+
* @param _scene the scene that the material belongs to.
|
|
206
|
+
* @param _mesh the mesh being rendered.
|
|
219
207
|
*/
|
|
220
|
-
|
|
221
|
-
getAttributes(attributes, scene, mesh) { }
|
|
208
|
+
getAttributes(_attributes, _scene, _mesh) { }
|
|
222
209
|
/**
|
|
223
210
|
* Gets the uniform buffers names added by the plugin.
|
|
224
|
-
* @param
|
|
211
|
+
* @param _ubos list that the ubo names should be added to.
|
|
225
212
|
*/
|
|
226
|
-
|
|
227
|
-
getUniformBuffersNames(ubos) { }
|
|
213
|
+
getUniformBuffersNames(_ubos) { }
|
|
228
214
|
/**
|
|
229
215
|
* Gets the description of the uniforms to add to the ubo (if engine supports ubos) or to inject directly in the vertex/fragment shaders (if engine does not support ubos)
|
|
230
|
-
* @param
|
|
216
|
+
* @param _shaderLanguage The shader language to use.
|
|
231
217
|
* @returns the description of the uniforms
|
|
232
218
|
*/
|
|
233
|
-
getUniforms(
|
|
219
|
+
getUniforms(_shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
234
220
|
return {};
|
|
235
221
|
}
|
|
236
222
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialPluginBase.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialPluginBase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAajD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IA6B3B;;;;OAIG;IACI,YAAY,CAAC,cAA8B;QAC9C,QAAQ,cAAc,EAAE;YACpB;gBACI,OAAO,IAAI,CAAC;YAChB;gBACI,OAAO,KAAK,CAAC;SACpB;IACL,CAAC;IAES,OAAO,CAAC,MAAe;QAC7B,IAAI,MAAM,EAAE;YACR,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SAC7C;IACL,CAAC;IAOD;;;;;;;;;OASG;IACH,YAAY,QAAkB,EAAE,IAAY,EAAE,QAAgB,EAAE,OAAgC,EAAE,eAAe,GAAG,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QAzDjK;;WAEG;QAEI,aAAQ,GAAW,GAAG,CAAC;QAE9B;;WAEG;QAEI,oBAAe,GAAY,KAAK,CAAC;QAExC;;WAEG;QAEI,2BAAsB,GAAY,KAAK,CAAC;QA0C3C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,IAAI,CAAC,QAAQ,CAAC,a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AO,WAAW,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,6DAA6D;IACtD,WAAW,CAAC,QAAkB,IAAS,CAAC;IAE/C;;;;;OAKG;IACH,6DAA6D;IACtD,aAAa,CAAC,UAAoB,EAAE,KAAY,EAAE,IAAkB,IAAS,CAAC;IAErF;;;OAGG;IACH,6DAA6D;IACtD,sBAAsB,CAAC,IAAc,IAAS,CAAC;IAEtD;;;;OAIG;IACI,WAAW,CAAC,cAAc,8BAAsB;QAKnD,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAA0B;QACpC,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,OAAO,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QACnD,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ;AA1SU;IADN,SAAS,EAAE;gDACQ;AAMb;IADN,SAAS,EAAE;oDACkB;AAMvB;IADN,SAAS,EAAE;2DAC4B;AAMjC;IADN,SAAS,EAAE;kEACmC;AA0RnD,sBAAsB;AACtB,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport { MaterialPluginManager } from \"./materialPluginManager\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { EffectFallbacks } from \"./effectFallbacks\";\r\nimport type { MaterialDefines } from \"./materialDefines\";\r\nimport type { Material } from \"./material\";\r\nimport type { BaseTexture } from \"./Textures/baseTexture\";\r\nimport type { RenderTargetTexture } from \"./Textures/renderTargetTexture\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n/**\r\n * Base class for material plugins.\r\n * @since 5.0\r\n */\r\nexport class MaterialPluginBase {\r\n /**\r\n * Defines the name of the plugin\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Defines the priority of the plugin. Lower numbers run first.\r\n */\r\n @serialize()\r\n public priority: number = 500;\r\n\r\n /**\r\n * Indicates that any #include directive in the plugin code must be replaced by the corresponding code.\r\n */\r\n @serialize()\r\n public resolveIncludes: boolean = false;\r\n\r\n /**\r\n * Indicates that this plugin should be notified for the extra events (HasRenderTargetTextures / FillRenderTargetTextures / HardBindForSubMesh)\r\n */\r\n @serialize()\r\n public registerForExtraEvents: boolean = false;\r\n\r\n protected _material: Material;\r\n protected _pluginManager: MaterialPluginManager;\r\n protected _pluginDefineNames?: { [name: string]: any };\r\n\r\n /**\r\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\r\n * @param shaderLanguage The shader language to use.\r\n * @returns true if the plugin is compatible with the shader language\r\n */\r\n public isCompatible(shaderLanguage: ShaderLanguage): boolean {\r\n switch (shaderLanguage) {\r\n case ShaderLanguage.GLSL:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n protected _enable(enable: boolean) {\r\n if (enable) {\r\n this._pluginManager._activatePlugin(this);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to mark defines as being dirty.\r\n */\r\n public readonly markAllDefinesAsDirty: () => void;\r\n\r\n /**\r\n * Creates a new material plugin\r\n * @param material parent material of the plugin\r\n * @param name name of the plugin\r\n * @param priority priority of the plugin\r\n * @param defines list of defines used by the plugin. The value of the property is the default value for this property\r\n * @param addToPluginList true to add the plugin to the list of plugins managed by the material plugin manager of the material (default: true)\r\n * @param enable true to enable the plugin (it is handy if the plugin does not handle properties to switch its current activation)\r\n * @param resolveIncludes Indicates that any #include directive in the plugin code must be replaced by the corresponding code (default: false)\r\n */\r\n constructor(material: Material, name: string, priority: number, defines?: { [key: string]: any }, addToPluginList = true, enable = false, resolveIncludes = false) {\r\n this._material = material;\r\n this.name = name;\r\n this.priority = priority;\r\n this.resolveIncludes = resolveIncludes;\r\n\r\n if (!material.pluginManager) {\r\n material.pluginManager = new MaterialPluginManager(material);\r\n material.onDisposeObservable.add(() => {\r\n material.pluginManager = undefined;\r\n });\r\n }\r\n\r\n this._pluginDefineNames = defines;\r\n this._pluginManager = material.pluginManager;\r\n\r\n if (addToPluginList) {\r\n this._pluginManager._addPlugin(this);\r\n }\r\n\r\n if (enable) {\r\n this._enable(true);\r\n }\r\n\r\n this.markAllDefinesAsDirty = material._dirtyCallbacks[Constants.MATERIAL_AllDirtyFlag];\r\n }\r\n\r\n /**\r\n * Gets the current class name useful for serialization or dynamic coding.\r\n * @returns The class name.\r\n */\r\n public getClassName(): string {\r\n return \"MaterialPluginBase\";\r\n }\r\n\r\n /**\r\n * Specifies that the submesh is ready to be used.\r\n * @param defines the list of \"defines\" to update.\r\n * @param scene defines the scene the material belongs to.\r\n * @param engine the engine this scene belongs to.\r\n * @param subMesh the submesh to check for readiness\r\n * @returns - boolean indicating that the submesh is ready or not.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public isReadyForSubMesh(defines: MaterialDefines, scene: Scene, engine: AbstractEngine, subMesh: SubMesh): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Binds the material data (this function is called even if mustRebind() returns false)\r\n * @param uniformBuffer defines the Uniform buffer to fill in.\r\n * @param scene defines the scene the material belongs to.\r\n * @param engine defines the engine the material belongs to.\r\n * @param subMesh the submesh to bind data for\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public hardBindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: AbstractEngine, subMesh: SubMesh): void {}\r\n\r\n /**\r\n * Binds the material data.\r\n * @param uniformBuffer defines the Uniform buffer to fill in.\r\n * @param scene defines the scene the material belongs to.\r\n * @param engine the engine this scene belongs to.\r\n * @param subMesh the submesh to bind data for\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: AbstractEngine, subMesh: SubMesh): void {}\r\n\r\n /**\r\n * Disposes the resources of the material.\r\n * @param forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public dispose(forceDisposeTextures?: boolean): void {}\r\n\r\n /**\r\n * Returns a list of custom shader code fragments to customize the shader.\r\n * @param shaderType \"vertex\" or \"fragment\"\r\n * @param shaderLanguage The shader language to use.\r\n * @returns null if no code to be added, or a list of pointName =\\> code.\r\n * Note that `pointName` can also be a regular expression if it starts with a `!`.\r\n * In that case, the string found by the regular expression (if any) will be\r\n * replaced by the code provided.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getCustomCode(shaderType: string, shaderLanguage = ShaderLanguage.GLSL): Nullable<{ [pointName: string]: string }> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Collects all defines.\r\n * @param defines The object to append to.\r\n */\r\n public collectDefines(defines: { [name: string]: { type: string; default: any } }): void {\r\n if (!this._pluginDefineNames) {\r\n return;\r\n }\r\n for (const key of Object.keys(this._pluginDefineNames)) {\r\n if (key[0] === \"_\") {\r\n continue;\r\n }\r\n\r\n const type = typeof this._pluginDefineNames[key];\r\n defines[key] = {\r\n type: type === \"number\" ? \"number\" : type === \"string\" ? \"string\" : type === \"boolean\" ? \"boolean\" : \"object\",\r\n default: this._pluginDefineNames[key],\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Sets the defines for the next rendering. Called before PrepareDefinesForAttributes is called.\r\n * @param defines the list of \"defines\" to update.\r\n * @param scene defines the scene to the material belongs to.\r\n * @param mesh the mesh being rendered\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public prepareDefinesBeforeAttributes(defines: MaterialDefines, scene: Scene, mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Sets the defines for the next rendering\r\n * @param defines the list of \"defines\" to update.\r\n * @param scene defines the scene to the material belongs to.\r\n * @param mesh the mesh being rendered\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public prepareDefines(defines: MaterialDefines, scene: Scene, mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Checks to see if a texture is used in the material.\r\n * @param texture - Base texture to use.\r\n * @returns - Boolean specifying if a texture is used in the material.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public hasTexture(texture: BaseTexture): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that current material needs to register RTT\r\n * @returns true if this uses a render target otherwise false.\r\n */\r\n public hasRenderTargetTextures(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Fills the list of render target textures.\r\n * @param renderTargets the list of render targets to update\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void {}\r\n\r\n /**\r\n * Returns an array of the actively used textures.\r\n * @param activeTextures Array of BaseTextures\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getActiveTextures(activeTextures: BaseTexture[]): void {}\r\n\r\n /**\r\n * Returns the animatable textures.\r\n * @param animatables Array of animatable textures.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getAnimatables(animatables: IAnimatable[]): void {}\r\n\r\n /**\r\n * Add fallbacks to the effect fallbacks list.\r\n * @param defines defines the Base texture to use.\r\n * @param fallbacks defines the current fallback list.\r\n * @param currentRank defines the current fallback rank.\r\n * @returns the new fallback rank.\r\n */\r\n public addFallbacks(defines: MaterialDefines, fallbacks: EffectFallbacks, currentRank: number): number {\r\n return currentRank;\r\n }\r\n\r\n /**\r\n * Gets the samplers used by the plugin.\r\n * @param samplers list that the sampler names should be added to.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getSamplers(samplers: string[]): void {}\r\n\r\n /**\r\n * Gets the attributes used by the plugin.\r\n * @param attributes list that the attribute names should be added to.\r\n * @param scene the scene that the material belongs to.\r\n * @param mesh the mesh being rendered.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getAttributes(attributes: string[], scene: Scene, mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Gets the uniform buffers names added by the plugin.\r\n * @param ubos list that the ubo names should be added to.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getUniformBuffersNames(ubos: string[]): void {}\r\n\r\n /**\r\n * Gets the description of the uniforms to add to the ubo (if engine supports ubos) or to inject directly in the vertex/fragment shaders (if engine does not support ubos)\r\n * @param shaderLanguage The shader language to use.\r\n * @returns the description of the uniforms\r\n */\r\n public getUniforms(shaderLanguage = ShaderLanguage.GLSL): {\r\n ubo?: Array<{ name: string; size?: number; type?: string; arraySize?: number }>;\r\n vertex?: string;\r\n fragment?: string;\r\n } {\r\n return {};\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current configuration into another one.\r\n * @param plugin define the config where to copy the info\r\n */\r\n public copyTo(plugin: MaterialPluginBase): void {\r\n SerializationHelper.Clone(() => plugin, this);\r\n }\r\n\r\n /**\r\n * Serializes this plugin configuration.\r\n * @returns - An object with the serialized config.\r\n */\r\n public serialize(): any {\r\n return SerializationHelper.Serialize(this);\r\n }\r\n\r\n /**\r\n * Parses a plugin configuration from a serialized object.\r\n * @param source - Serialized object.\r\n * @param scene Defines the scene we are parsing for\r\n * @param rootUrl Defines the rootUrl to load from\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\r\n }\r\n}\r\n\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.MaterialPluginBase\", MaterialPluginBase);\r\n"]}
|
|
1
|
+
{"version":3,"file":"materialPluginBase.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialPluginBase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAajD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IA6B3B;;;;OAIG;IACI,YAAY,CAAC,cAA8B;QAC9C,QAAQ,cAAc,EAAE;YACpB;gBACI,OAAO,IAAI,CAAC;YAChB;gBACI,OAAO,KAAK,CAAC;SACpB;IACL,CAAC;IAES,OAAO,CAAC,MAAe;QAC7B,IAAI,MAAM,EAAE;YACR,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SAC7C;IACL,CAAC;IAOD;;;;;;;;;OASG;IACH,YAAY,QAAkB,EAAE,IAAY,EAAE,QAAgB,EAAE,OAAgC,EAAE,eAAe,GAAG,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QAzDjK;;WAEG;QAEI,aAAQ,GAAW,GAAG,CAAC;QAE9B;;WAEG;QAEI,oBAAe,GAAY,KAAK,CAAC;QAExC;;WAEG;QAEI,2BAAsB,GAAY,KAAK,CAAC;QA0C3C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC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AC;IACvB,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,SAAmB,IAAS,CAAC;IAEhD;;;;;OAKG;IACI,aAAa,CAAC,WAAqB,EAAE,MAAa,EAAE,KAAmB,IAAS,CAAC;IAExF;;;OAGG;IACI,sBAAsB,CAAC,KAAe,IAAS,CAAC;IAEvD;;;;OAIG;IACI,WAAW,CAAC,eAAe,8BAAsB;QAKpD,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAA0B;QACpC,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,OAAO,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QACnD,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ;AA5RU;IADN,SAAS,EAAE;gDACQ;AAMb;IADN,SAAS,EAAE;oDACkB;AAMvB;IADN,SAAS,EAAE;2DAC4B;AAMjC;IADN,SAAS,EAAE;kEACmC;AA4QnD,sBAAsB;AACtB,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport { MaterialPluginManager } from \"./materialPluginManager\";\r\nimport type { SmartArray } from \"../Misc/smartArray\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { EffectFallbacks } from \"./effectFallbacks\";\r\nimport type { MaterialDefines } from \"./materialDefines\";\r\nimport type { Material } from \"./material\";\r\nimport type { BaseTexture } from \"./Textures/baseTexture\";\r\nimport type { RenderTargetTexture } from \"./Textures/renderTargetTexture\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n/**\r\n * Base class for material plugins.\r\n * @since 5.0\r\n */\r\nexport class MaterialPluginBase {\r\n /**\r\n * Defines the name of the plugin\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Defines the priority of the plugin. Lower numbers run first.\r\n */\r\n @serialize()\r\n public priority: number = 500;\r\n\r\n /**\r\n * Indicates that any #include directive in the plugin code must be replaced by the corresponding code.\r\n */\r\n @serialize()\r\n public resolveIncludes: boolean = false;\r\n\r\n /**\r\n * Indicates that this plugin should be notified for the extra events (HasRenderTargetTextures / FillRenderTargetTextures / HardBindForSubMesh)\r\n */\r\n @serialize()\r\n public registerForExtraEvents: boolean = false;\r\n\r\n protected _material: Material;\r\n protected _pluginManager: MaterialPluginManager;\r\n protected _pluginDefineNames?: { [name: string]: any };\r\n\r\n /**\r\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\r\n * @param shaderLanguage The shader language to use.\r\n * @returns true if the plugin is compatible with the shader language\r\n */\r\n public isCompatible(shaderLanguage: ShaderLanguage): boolean {\r\n switch (shaderLanguage) {\r\n case ShaderLanguage.GLSL:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n protected _enable(enable: boolean) {\r\n if (enable) {\r\n this._pluginManager._activatePlugin(this);\r\n }\r\n }\r\n\r\n /**\r\n * Helper function to mark defines as being dirty.\r\n */\r\n public readonly markAllDefinesAsDirty: () => void;\r\n\r\n /**\r\n * Creates a new material plugin\r\n * @param material parent material of the plugin\r\n * @param name name of the plugin\r\n * @param priority priority of the plugin\r\n * @param defines list of defines used by the plugin. The value of the property is the default value for this property\r\n * @param addToPluginList true to add the plugin to the list of plugins managed by the material plugin manager of the material (default: true)\r\n * @param enable true to enable the plugin (it is handy if the plugin does not handle properties to switch its current activation)\r\n * @param resolveIncludes Indicates that any #include directive in the plugin code must be replaced by the corresponding code (default: false)\r\n */\r\n constructor(material: Material, name: string, priority: number, defines?: { [key: string]: any }, addToPluginList = true, enable = false, resolveIncludes = false) {\r\n this._material = material;\r\n this.name = name;\r\n this.priority = priority;\r\n this.resolveIncludes = resolveIncludes;\r\n\r\n if (!material.pluginManager) {\r\n material.pluginManager = new MaterialPluginManager(material);\r\n material.onDisposeObservable.add(() => {\r\n material.pluginManager = undefined;\r\n });\r\n }\r\n\r\n this._pluginDefineNames = defines;\r\n this._pluginManager = material.pluginManager;\r\n\r\n if (addToPluginList) {\r\n this._pluginManager._addPlugin(this);\r\n }\r\n\r\n if (enable) {\r\n this._enable(true);\r\n }\r\n\r\n this.markAllDefinesAsDirty = material._dirtyCallbacks[Constants.MATERIAL_AllDirtyFlag];\r\n }\r\n\r\n /**\r\n * Gets the current class name useful for serialization or dynamic coding.\r\n * @returns The class name.\r\n */\r\n public getClassName(): string {\r\n return \"MaterialPluginBase\";\r\n }\r\n\r\n /**\r\n * Specifies that the submesh is ready to be used.\r\n * @param _defines the list of \"defines\" to update.\r\n * @param _scene defines the scene the material belongs to.\r\n * @param _engine the engine this scene belongs to.\r\n * @param _subMesh the submesh to check for readiness\r\n * @returns - boolean indicating that the submesh is ready or not.\r\n */\r\n public isReadyForSubMesh(_defines: MaterialDefines, _scene: Scene, _engine: AbstractEngine, _subMesh: SubMesh): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Binds the material data (this function is called even if mustRebind() returns false)\r\n * @param _uniformBuffer defines the Uniform buffer to fill in.\r\n * @param _scene defines the scene the material belongs to.\r\n * @param _engine defines the engine the material belongs to.\r\n * @param _subMesh the submesh to bind data for\r\n */\r\n public hardBindForSubMesh(_uniformBuffer: UniformBuffer, _scene: Scene, _engine: AbstractEngine, _subMesh: SubMesh): void {}\r\n\r\n /**\r\n * Binds the material data.\r\n * @param _uniformBuffer defines the Uniform buffer to fill in.\r\n * @param _scene defines the scene the material belongs to.\r\n * @param _engine the engine this scene belongs to.\r\n * @param _subMesh the submesh to bind data for\r\n */\r\n public bindForSubMesh(_uniformBuffer: UniformBuffer, _scene: Scene, _engine: AbstractEngine, _subMesh: SubMesh): void {}\r\n\r\n /**\r\n * Disposes the resources of the material.\r\n * @param _forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n public dispose(_forceDisposeTextures?: boolean): void {}\r\n\r\n /**\r\n * Returns a list of custom shader code fragments to customize the shader.\r\n * @param _shaderType \"vertex\" or \"fragment\"\r\n * @param _shaderLanguage The shader language to use.\r\n * @returns null if no code to be added, or a list of pointName =\\> code.\r\n * Note that `pointName` can also be a regular expression if it starts with a `!`.\r\n * In that case, the string found by the regular expression (if any) will be\r\n * replaced by the code provided.\r\n */\r\n public getCustomCode(_shaderType: string, _shaderLanguage = ShaderLanguage.GLSL): Nullable<{ [pointName: string]: string }> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Collects all defines.\r\n * @param defines The object to append to.\r\n */\r\n public collectDefines(defines: { [name: string]: { type: string; default: any } }): void {\r\n if (!this._pluginDefineNames) {\r\n return;\r\n }\r\n for (const key of Object.keys(this._pluginDefineNames)) {\r\n if (key[0] === \"_\") {\r\n continue;\r\n }\r\n\r\n const type = typeof this._pluginDefineNames[key];\r\n defines[key] = {\r\n type: type === \"number\" ? \"number\" : type === \"string\" ? \"string\" : type === \"boolean\" ? \"boolean\" : \"object\",\r\n default: this._pluginDefineNames[key],\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Sets the defines for the next rendering. Called before PrepareDefinesForAttributes is called.\r\n * @param _defines the list of \"defines\" to update.\r\n * @param _scene defines the scene to the material belongs to.\r\n * @param _mesh the mesh being rendered\r\n */\r\n public prepareDefinesBeforeAttributes(_defines: MaterialDefines, _scene: Scene, _mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Sets the defines for the next rendering\r\n * @param _defines the list of \"defines\" to update.\r\n * @param _scene defines the scene to the material belongs to.\r\n * @param _mesh the mesh being rendered\r\n */\r\n public prepareDefines(_defines: MaterialDefines, _scene: Scene, _mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Checks to see if a texture is used in the material.\r\n * @param _texture - Base texture to use.\r\n * @returns - Boolean specifying if a texture is used in the material.\r\n */\r\n public hasTexture(_texture: BaseTexture): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that current material needs to register RTT\r\n * @returns true if this uses a render target otherwise false.\r\n */\r\n public hasRenderTargetTextures(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Fills the list of render target textures.\r\n * @param _renderTargets the list of render targets to update\r\n */\r\n public fillRenderTargetTextures(_renderTargets: SmartArray<RenderTargetTexture>): void {}\r\n\r\n /**\r\n * Returns an array of the actively used textures.\r\n * @param _activeTextures Array of BaseTextures\r\n */\r\n public getActiveTextures(_activeTextures: BaseTexture[]): void {}\r\n\r\n /**\r\n * Returns the animatable textures.\r\n * @param _animatables Array of animatable textures.\r\n */\r\n public getAnimatables(_animatables: IAnimatable[]): void {}\r\n\r\n /**\r\n * Add fallbacks to the effect fallbacks list.\r\n * @param defines defines the Base texture to use.\r\n * @param fallbacks defines the current fallback list.\r\n * @param currentRank defines the current fallback rank.\r\n * @returns the new fallback rank.\r\n */\r\n public addFallbacks(defines: MaterialDefines, fallbacks: EffectFallbacks, currentRank: number): number {\r\n return currentRank;\r\n }\r\n\r\n /**\r\n * Gets the samplers used by the plugin.\r\n * @param _samplers list that the sampler names should be added to.\r\n */\r\n public getSamplers(_samplers: string[]): void {}\r\n\r\n /**\r\n * Gets the attributes used by the plugin.\r\n * @param _attributes list that the attribute names should be added to.\r\n * @param _scene the scene that the material belongs to.\r\n * @param _mesh the mesh being rendered.\r\n */\r\n public getAttributes(_attributes: string[], _scene: Scene, _mesh: AbstractMesh): void {}\r\n\r\n /**\r\n * Gets the uniform buffers names added by the plugin.\r\n * @param _ubos list that the ubo names should be added to.\r\n */\r\n public getUniformBuffersNames(_ubos: string[]): void {}\r\n\r\n /**\r\n * Gets the description of the uniforms to add to the ubo (if engine supports ubos) or to inject directly in the vertex/fragment shaders (if engine does not support ubos)\r\n * @param _shaderLanguage The shader language to use.\r\n * @returns the description of the uniforms\r\n */\r\n public getUniforms(_shaderLanguage = ShaderLanguage.GLSL): {\r\n ubo?: Array<{ name: string; size?: number; type?: string; arraySize?: number }>;\r\n vertex?: string;\r\n fragment?: string;\r\n } {\r\n return {};\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current configuration into another one.\r\n * @param plugin define the config where to copy the info\r\n */\r\n public copyTo(plugin: MaterialPluginBase): void {\r\n SerializationHelper.Clone(() => plugin, this);\r\n }\r\n\r\n /**\r\n * Serializes this plugin configuration.\r\n * @returns - An object with the serialized config.\r\n */\r\n public serialize(): any {\r\n return SerializationHelper.Serialize(this);\r\n }\r\n\r\n /**\r\n * Parses a plugin configuration from a serialized object.\r\n * @param source - Serialized object.\r\n * @param scene Defines the scene we are parsing for\r\n * @param rootUrl Defines the rootUrl to load from\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\r\n }\r\n}\r\n\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.MaterialPluginBase\", MaterialPluginBase);\r\n"]}
|
|
@@ -68,18 +68,6 @@ export declare enum GreasedLineMeshWidthDistribution {
|
|
|
68
68
|
*/
|
|
69
69
|
WIDTH_DISTRIBUTION_START_END = 5
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Options for converting the points to the internal number[][] format used by GreasedLine
|
|
73
|
-
*/
|
|
74
|
-
export interface GreasedLinePointsOptions {
|
|
75
|
-
/**
|
|
76
|
-
* If defined and a Float32Array is used for the points parameter,
|
|
77
|
-
* it will create multiple disconnected lines.
|
|
78
|
-
* This parameter defines how many entries from the array to use for one line.
|
|
79
|
-
* One entry = 3 float values.
|
|
80
|
-
*/
|
|
81
|
-
floatArrayStride?: number;
|
|
82
|
-
}
|
|
83
71
|
/**
|
|
84
72
|
* Material options for GreasedLineBuilder
|
|
85
73
|
*/
|
|
@@ -100,10 +88,6 @@ export interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOp
|
|
|
100
88
|
* Line mesh options for GreasedLineBuilder
|
|
101
89
|
*/
|
|
102
90
|
export interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {
|
|
103
|
-
/**
|
|
104
|
-
* Options for converting the points.
|
|
105
|
-
*/
|
|
106
|
-
pointsOptions?: GreasedLinePointsOptions;
|
|
107
91
|
/**
|
|
108
92
|
* Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START
|
|
109
93
|
* @see CompleteGreasedLineWidthTable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAEtG;;;GAGG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B,qEAA6D,EAAE;YACvF,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,CAAC,IAAI,iBAAiB,CAAC;aAC1B;SACJ;aAAM,IAAI,iBAAiB,qEAA6D,EAAE;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;KACJ;SAAM;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACjC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Options for converting the points to the internal number[][] format used by GreasedLine\r\n */\r\nexport interface GreasedLinePointsOptions {\r\n /**\r\n * If defined and a Float32Array is used for the points parameter,\r\n * it will create multiple disconnected lines.\r\n * This parameter defines how many entries from the array to use for one line.\r\n * One entry = 3 float values.\r\n */\r\n floatArrayStride?: number;\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Options for converting the points.\r\n */\r\n pointsOptions?: GreasedLinePointsOptions;\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += (<number[]>points).length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AAEtG;;;GAGG;AACH,MAAM,CAAN,IAAkB,gCAyBjB;AAzBD,WAAkB,gCAAgC;IAC9C;;OAEG;IACH,6HAA2B,CAAA;IAC3B;;OAEG;IACH,iIAA6B,CAAA;IAC7B;;OAEG;IACH,6HAA2B,CAAA;IAC3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GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,CAAC,IAAI,iBAAiB,CAAC;aAC1B;SACJ;aAAM,IAAI,iBAAiB,qEAA6D,EAAE;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;KACJ;SAAM;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACjC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, true); // Forcing glsl for now\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += (<number[]>points).length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
|
|
@@ -76,6 +76,18 @@ export type GreasedLineRibbonOptions = {
|
|
|
76
76
|
smoothShading?: boolean;
|
|
77
77
|
};
|
|
78
78
|
export type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];
|
|
79
|
+
/**
|
|
80
|
+
* Options for converting the points to the internal number[][] format used by GreasedLine
|
|
81
|
+
*/
|
|
82
|
+
export interface GreasedLinePointsOptions {
|
|
83
|
+
/**
|
|
84
|
+
* If defined and a Float32Array is used for the points parameter,
|
|
85
|
+
* it will create multiple disconnected lines.
|
|
86
|
+
* This parameter defines how many entries from the array to use for one line.
|
|
87
|
+
* One entry = 3 float values.
|
|
88
|
+
*/
|
|
89
|
+
floatArrayStride?: number;
|
|
90
|
+
}
|
|
79
91
|
/**
|
|
80
92
|
* Options for creating a GreasedLineMesh
|
|
81
93
|
*/
|
|
@@ -119,6 +131,10 @@ export interface GreasedLineMeshOptions {
|
|
|
119
131
|
* If this option is set the line switches automatically to a non camera facing mode.
|
|
120
132
|
*/
|
|
121
133
|
ribbonOptions?: GreasedLineRibbonOptions;
|
|
134
|
+
/**
|
|
135
|
+
* Options for converting the points.
|
|
136
|
+
*/
|
|
137
|
+
pointsOptions?: GreasedLinePointsOptions;
|
|
122
138
|
}
|
|
123
139
|
/**
|
|
124
140
|
* GreasedLineBaseMesh
|
|
@@ -219,7 +235,7 @@ export declare abstract class GreasedLineBaseMesh extends Mesh {
|
|
|
219
235
|
* @param points points table
|
|
220
236
|
* @param options optional options
|
|
221
237
|
*/
|
|
222
|
-
setPoints(points:
|
|
238
|
+
setPoints(points: GreasedLinePoints, options?: GreasedLineMeshOptions): void;
|
|
223
239
|
protected _initGreasedLine(): void;
|
|
224
240
|
protected _createLineOptions(): GreasedLineMeshOptions;
|
|
225
241
|
/**
|
|
@@ -4,6 +4,7 @@ import { Buffer } from "../../Buffers/buffer.js";
|
|
|
4
4
|
import { VertexData } from "../mesh.vertexData.js";
|
|
5
5
|
import { DeepCopier } from "../../Misc/deepCopier.js";
|
|
6
6
|
import { GreasedLineSimpleMaterial } from "../../Materials/GreasedLine/greasedLineSimpleMaterial.js";
|
|
7
|
+
import { GreasedLineTools } from "../../Misc/greasedLineTools.js";
|
|
7
8
|
/**
|
|
8
9
|
* In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.
|
|
9
10
|
* In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.
|
|
@@ -209,12 +210,12 @@ export class GreasedLineBaseMesh extends Mesh {
|
|
|
209
210
|
* @param options optional options
|
|
210
211
|
*/
|
|
211
212
|
setPoints(points, options) {
|
|
212
|
-
this._points = points;
|
|
213
|
+
this._points = GreasedLineTools.ConvertPoints(points, options?.pointsOptions ?? this._options.pointsOptions);
|
|
213
214
|
this._updateWidths();
|
|
214
215
|
if (!options?.colorPointers) {
|
|
215
216
|
this._updateColorPointers();
|
|
216
217
|
}
|
|
217
|
-
this._setPoints(
|
|
218
|
+
this._setPoints(this._points, options);
|
|
218
219
|
}
|
|
219
220
|
_initGreasedLine() {
|
|
220
221
|
this._vertexPositions = [];
|