@onerjs/core 8.37.7 → 8.37.9
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/Animations/animationGroup.d.ts +2 -3
- package/Animations/animationGroup.js +10 -15
- package/Animations/animationGroup.js.map +1 -1
- package/Bones/bone.d.ts +2 -0
- package/Bones/bone.js +2 -0
- package/Bones/bone.js.map +1 -1
- package/Bones/skeleton.js +7 -0
- package/Bones/skeleton.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +3 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js +3 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +3 -1
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -1
- package/Layers/effectLayer.d.ts +4 -0
- package/Layers/effectLayer.js +2 -0
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/highlightLayer.js +1 -0
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +2 -0
- package/Layers/index.js +2 -0
- package/Layers/index.js.map +1 -1
- package/Layers/selectionOutlineLayer.d.ts +185 -0
- package/Layers/selectionOutlineLayer.js +326 -0
- package/Layers/selectionOutlineLayer.js.map +1 -0
- package/Layers/thinEffectLayer.d.ts +5 -1
- package/Layers/thinEffectLayer.js +21 -16
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Layers/thinGlowLayer.js +1 -0
- package/Layers/thinGlowLayer.js.map +1 -1
- package/Layers/thinHighlightLayer.js +1 -0
- package/Layers/thinHighlightLayer.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.d.ts +154 -0
- package/Layers/thinSelectionOutlineLayer.js +611 -0
- package/Layers/thinSelectionOutlineLayer.js.map +1 -0
- package/Loading/Plugins/babylonFileLoader.js +136 -48
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +8 -0
- package/Maths/math.vector.functions.js +10 -0
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +4 -0
- package/Meshes/abstractMesh.js +4 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg2.js +9 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/instancedMesh.js +2 -2
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +6 -1
- package/Meshes/mesh.js.map +1 -1
- package/Morph/morphTarget.js +2 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Shaders/selection.fragment.d.ts +7 -0
- package/Shaders/selection.fragment.js +47 -0
- package/Shaders/selection.fragment.js.map +1 -0
- package/Shaders/selection.vertex.d.ts +17 -0
- package/Shaders/selection.vertex.js +95 -0
- package/Shaders/selection.vertex.js.map +1 -0
- package/Shaders/selectionOutline.fragment.d.ts +5 -0
- package/Shaders/selectionOutline.fragment.js +23 -0
- package/Shaders/selectionOutline.fragment.js.map +1 -0
- package/ShadersWGSL/selection.fragment.d.ts +7 -0
- package/ShadersWGSL/selection.fragment.js +47 -0
- package/ShadersWGSL/selection.fragment.js.map +1 -0
- package/ShadersWGSL/selection.vertex.d.ts +17 -0
- package/ShadersWGSL/selection.vertex.js +96 -0
- package/ShadersWGSL/selection.vertex.js.map +1 -0
- package/ShadersWGSL/selectionOutline.fragment.d.ts +5 -0
- package/ShadersWGSL/selectionOutline.fragment.js +24 -0
- package/ShadersWGSL/selectionOutline.fragment.js.map +1 -0
- package/package.json +1 -1
- package/scene.d.ts +2 -2
- package/scene.js +10 -2
- package/scene.js.map +1 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { __decorate } from "../tslib.es6.js";
|
|
2
|
+
import { serialize, serializeAsColor3 } from "../Misc/decorators.js";
|
|
3
|
+
import { Scene } from "../scene.js";
|
|
4
|
+
import { EffectLayer } from "./effectLayer.js";
|
|
5
|
+
|
|
6
|
+
import { RegisterClass } from "../Misc/typeStore.js";
|
|
7
|
+
import { SerializationHelper } from "../Misc/decorators.serialization.js";
|
|
8
|
+
import { ThinSelectionOutlineLayer } from "./thinSelectionOutlineLayer.js";
|
|
9
|
+
Scene.prototype.getSelectionOutlineLayerByName = function (name) {
|
|
10
|
+
for (let index = 0; index < this.effectLayers?.length; index++) {
|
|
11
|
+
if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === SelectionOutlineLayer.EffectName) {
|
|
12
|
+
return this.effectLayers[index];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The selection outline layer Helps adding a outline effect around a mesh.
|
|
19
|
+
*
|
|
20
|
+
* Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
|
|
21
|
+
* outlined meshes to your scene.
|
|
22
|
+
*/
|
|
23
|
+
export class SelectionOutlineLayer extends EffectLayer {
|
|
24
|
+
/**
|
|
25
|
+
* Effect Name of the selection outline layer.
|
|
26
|
+
*/
|
|
27
|
+
static get EffectName() {
|
|
28
|
+
return ThinSelectionOutlineLayer.EffectName;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The outline color (default (1, 0.5, 0))
|
|
32
|
+
*/
|
|
33
|
+
get outlineColor() {
|
|
34
|
+
return this._thinEffectLayer.outlineColor;
|
|
35
|
+
}
|
|
36
|
+
set outlineColor(value) {
|
|
37
|
+
this._thinEffectLayer.outlineColor = value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The thickness of the edges (default: 2.0)
|
|
41
|
+
*/
|
|
42
|
+
get outlineThickness() {
|
|
43
|
+
return this._thinEffectLayer.outlineThickness;
|
|
44
|
+
}
|
|
45
|
+
set outlineThickness(value) {
|
|
46
|
+
this._thinEffectLayer.outlineThickness = value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The strength of the occlusion effect (default: 0.8)
|
|
50
|
+
*/
|
|
51
|
+
get occlusionStrength() {
|
|
52
|
+
return this._thinEffectLayer.occlusionStrength;
|
|
53
|
+
}
|
|
54
|
+
set occlusionStrength(value) {
|
|
55
|
+
this._thinEffectLayer.occlusionStrength = value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The occlusion threshold (default: 0.01)
|
|
59
|
+
*/
|
|
60
|
+
get occlusionThreshold() {
|
|
61
|
+
return this._thinEffectLayer.occlusionThreshold;
|
|
62
|
+
}
|
|
63
|
+
set occlusionThreshold(value) {
|
|
64
|
+
this._thinEffectLayer.occlusionThreshold = value;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Instantiates a new selection outline Layer and references it to the scene..
|
|
68
|
+
* @param name The name of the layer
|
|
69
|
+
* @param scene The scene to use the layer in
|
|
70
|
+
* @param options Sets of none mandatory options to use with the layer (see ISelectionOutlineLayerOptions for more information)
|
|
71
|
+
*/
|
|
72
|
+
constructor(name, scene, options) {
|
|
73
|
+
super(name, scene, options !== undefined ? !!options.forceGLSL : false, new ThinSelectionOutlineLayer(name, scene, options));
|
|
74
|
+
// Adapt options
|
|
75
|
+
this._options = {
|
|
76
|
+
mainTextureRatio: 1.0,
|
|
77
|
+
mainTextureFixedSize: 0,
|
|
78
|
+
alphaBlendingMode: 2,
|
|
79
|
+
camera: null,
|
|
80
|
+
mainTextureSamples: 1,
|
|
81
|
+
renderingGroupId: -1,
|
|
82
|
+
mainTextureType: 1,
|
|
83
|
+
mainTextureFormat: 7,
|
|
84
|
+
forceGLSL: false,
|
|
85
|
+
storeCameraSpaceZ: false,
|
|
86
|
+
...options,
|
|
87
|
+
};
|
|
88
|
+
// Initialize the layer
|
|
89
|
+
this._init(this._options);
|
|
90
|
+
// Do not render as long as no meshes have been added
|
|
91
|
+
this._shouldRender = false;
|
|
92
|
+
this._scene.enableDepthRenderer();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the effect name of the layer.
|
|
96
|
+
* @returns The effect name
|
|
97
|
+
*/
|
|
98
|
+
getEffectName() {
|
|
99
|
+
return SelectionOutlineLayer.EffectName;
|
|
100
|
+
}
|
|
101
|
+
_numInternalDraws() {
|
|
102
|
+
return 1; // draw depth mask on main pass and outline on merge pass
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create the merge effect. This is the shader use to blit the information back
|
|
106
|
+
* to the main canvas at the end of the scene rendering.
|
|
107
|
+
* @returns The effect created
|
|
108
|
+
*/
|
|
109
|
+
_createMergeEffect() {
|
|
110
|
+
return this._thinEffectLayer._createMergeEffect();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Creates the render target textures and post processes used in the selection outline layer.
|
|
114
|
+
*/
|
|
115
|
+
_createTextureAndPostProcesses() {
|
|
116
|
+
this._textures = [];
|
|
117
|
+
this._thinEffectLayer.bindTexturesForCompose = (effect) => {
|
|
118
|
+
effect.setTexture("maskSampler", this._mainTexture);
|
|
119
|
+
const depthRenderer = this._scene.enableDepthRenderer();
|
|
120
|
+
effect.setTexture("depthSampler", depthRenderer.getDepthMap());
|
|
121
|
+
const mainTextureDesiredSize = this._mainTextureDesiredSize;
|
|
122
|
+
this._thinEffectLayer.textureWidth = mainTextureDesiredSize.width;
|
|
123
|
+
this._thinEffectLayer.textureHeight = mainTextureDesiredSize.height;
|
|
124
|
+
};
|
|
125
|
+
this._thinEffectLayer._createTextureAndPostProcesses();
|
|
126
|
+
this._postProcesses = [];
|
|
127
|
+
this._mainTexture.samples = this._options.mainTextureSamples;
|
|
128
|
+
this._mainTexture.onAfterUnbindObservable.add(() => {
|
|
129
|
+
// glow layer and highlight layer both call this._scene.postProcessManager.directRender
|
|
130
|
+
// when you call this._scene.postProcessManager.directRender, it has 4 side effects:
|
|
131
|
+
// 1. binds the framebuffer
|
|
132
|
+
// 2. setAlphaMode(ALPHA_DISABLE)
|
|
133
|
+
// 3. setDepthBuffer(true)
|
|
134
|
+
// 4. setDepthWrite(true)
|
|
135
|
+
// glow layer and highlight layer are restore framebuffer and depends on other side effects
|
|
136
|
+
// but for now 3 and 4 are not needed to resolve the state management issue, so we just restore alpha mode
|
|
137
|
+
this._scene.getEngine().setAlphaMode(0);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Creates the main texture for the effect layer.
|
|
142
|
+
*/
|
|
143
|
+
_createMainTexture() {
|
|
144
|
+
super._createMainTexture();
|
|
145
|
+
// set the render list for selective rendering
|
|
146
|
+
this._mainTexture.renderList = this._thinEffectLayer._selection;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @returns whether or not the layer needs stencil enabled during the mesh rendering.
|
|
150
|
+
*/
|
|
151
|
+
needStencil() {
|
|
152
|
+
return this._thinEffectLayer.needStencil();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Checks for the readiness of the element composing the layer.
|
|
156
|
+
* @param subMesh the mesh to check for
|
|
157
|
+
* @param useInstances specify whether or not to use instances to render the mesh
|
|
158
|
+
* @returns true if ready otherwise, false
|
|
159
|
+
*/
|
|
160
|
+
isReady(subMesh, useInstances) {
|
|
161
|
+
return this._thinEffectLayer.isReady(subMesh, useInstances);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Implementation specific of rendering the generating effect on the main canvas.
|
|
165
|
+
* @param effect The effect used to render through
|
|
166
|
+
* @param renderIndex
|
|
167
|
+
*/
|
|
168
|
+
_internalRender(effect, renderIndex) {
|
|
169
|
+
this._thinEffectLayer._internalCompose(effect, renderIndex);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @returns true if the layer contains information to display, otherwise false.
|
|
173
|
+
*/
|
|
174
|
+
shouldRender() {
|
|
175
|
+
return this._thinEffectLayer.shouldRender();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns true if the mesh should render, otherwise false.
|
|
179
|
+
* @param mesh The mesh to render
|
|
180
|
+
* @returns true if it should render otherwise false
|
|
181
|
+
*/
|
|
182
|
+
_shouldRenderMesh(mesh) {
|
|
183
|
+
return this._thinEffectLayer._shouldRenderMesh(mesh);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Returns true if the mesh can be rendered, otherwise false.
|
|
187
|
+
* @param mesh The mesh to render
|
|
188
|
+
* @param material The material used on the mesh
|
|
189
|
+
* @returns true if it can be rendered otherwise false
|
|
190
|
+
*/
|
|
191
|
+
_canRenderMesh(mesh, material) {
|
|
192
|
+
return this._thinEffectLayer._canRenderMesh(mesh, material);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Adds specific effects defines.
|
|
196
|
+
* @param defines The defines to add specifics to.
|
|
197
|
+
*/
|
|
198
|
+
_addCustomEffectDefines(defines) {
|
|
199
|
+
this._thinEffectLayer._addCustomEffectDefines(defines);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Sets the required values for both the emissive texture and and the main color.
|
|
203
|
+
* @param mesh
|
|
204
|
+
* @param subMesh
|
|
205
|
+
* @param material
|
|
206
|
+
*/
|
|
207
|
+
_setEmissiveTextureAndColor(mesh, subMesh, material) {
|
|
208
|
+
this._thinEffectLayer._setEmissiveTextureAndColor(mesh, subMesh, material);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Determine if a given mesh will be highlighted by the current SelectionOutlineLayer
|
|
212
|
+
* @param mesh mesh to test
|
|
213
|
+
* @returns true if the mesh will be highlighted by the current SelectionOutlineLayer
|
|
214
|
+
*/
|
|
215
|
+
hasMesh(mesh) {
|
|
216
|
+
return this._thinEffectLayer.hasMesh(mesh);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Remove all the meshes currently referenced in the selection outline layer
|
|
220
|
+
*/
|
|
221
|
+
clearSelection() {
|
|
222
|
+
this._thinEffectLayer.clearSelection();
|
|
223
|
+
this._mainTexture.renderList = this._thinEffectLayer._selection; // update render list
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Adds mesh or group of mesh to the current selection
|
|
227
|
+
*
|
|
228
|
+
* If a group of meshes is provided, they will outline as a single unit
|
|
229
|
+
* @param meshOrGroup Meshes to add to the selection
|
|
230
|
+
*/
|
|
231
|
+
addSelection(meshOrGroup) {
|
|
232
|
+
this._thinEffectLayer.addSelection(meshOrGroup);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Adds mesh or group of mesh to the current selection
|
|
236
|
+
* @param meshOrGroup Meshes to remove from the selection
|
|
237
|
+
*/
|
|
238
|
+
removeSelection(meshOrGroup) {
|
|
239
|
+
this._thinEffectLayer.removeSelection(meshOrGroup);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Free any resources and references associated to a mesh.
|
|
243
|
+
* Internal use
|
|
244
|
+
* @param mesh The mesh to free.
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
_disposeMesh(mesh) {
|
|
248
|
+
this._thinEffectLayer._disposeMesh(mesh);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Gets the class name of the effect layer
|
|
252
|
+
* @returns the string with the class name of the effect layer
|
|
253
|
+
*/
|
|
254
|
+
getClassName() {
|
|
255
|
+
return "SelectionOutlineLayer";
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Serializes this SelectionOutline layer
|
|
259
|
+
* @returns a serialized SelectionOutline layer object
|
|
260
|
+
*/
|
|
261
|
+
serialize() {
|
|
262
|
+
const serializationObject = SerializationHelper.Serialize(this);
|
|
263
|
+
serializationObject.customType = "BABYLON.SelectionOutlineLayer";
|
|
264
|
+
// Selected meshes
|
|
265
|
+
serializationObject.selection = [];
|
|
266
|
+
const selection = this._thinEffectLayer._selection;
|
|
267
|
+
if (selection) {
|
|
268
|
+
const meshUniqueIdToSelectionId = this._thinEffectLayer._meshUniqueIdToSelectionId;
|
|
269
|
+
// selection can be sparse since _removeMesh can remove entries
|
|
270
|
+
const selectionMap = {};
|
|
271
|
+
for (let i = 0; i < selection.length; ++i) {
|
|
272
|
+
const mesh = selection[i];
|
|
273
|
+
const selectionId = meshUniqueIdToSelectionId[mesh.uniqueId];
|
|
274
|
+
if (!selectionMap[selectionId]) {
|
|
275
|
+
selectionMap[selectionId] = {
|
|
276
|
+
meshIds: [],
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
selectionMap[selectionId].meshIds.push(mesh.id);
|
|
280
|
+
}
|
|
281
|
+
serializationObject.selection = selectionMap;
|
|
282
|
+
}
|
|
283
|
+
return serializationObject;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Creates a SelectionOutline layer from parsed SelectionOutline layer data
|
|
287
|
+
* @param parsedSelectionOutlineLayer defines the SelectionOutline layer data
|
|
288
|
+
* @param scene defines the current scene
|
|
289
|
+
* @param rootUrl defines the root URL containing the SelectionOutline layer information
|
|
290
|
+
* @returns a parsed SelectionOutline layer
|
|
291
|
+
*/
|
|
292
|
+
static Parse(parsedSelectionOutlineLayer, scene, rootUrl) {
|
|
293
|
+
const selectionOutlineLayer = SerializationHelper.Parse(() => new SelectionOutlineLayer(parsedSelectionOutlineLayer.name, scene, parsedSelectionOutlineLayer.options), parsedSelectionOutlineLayer, scene, rootUrl);
|
|
294
|
+
const selectionMap = parsedSelectionOutlineLayer.selection;
|
|
295
|
+
// Selected meshes
|
|
296
|
+
for (const outlinedMeshes of Object.values(selectionMap)) {
|
|
297
|
+
const meshes = [];
|
|
298
|
+
for (let meshIndex = 0; meshIndex < outlinedMeshes.meshIds.length; meshIndex++) {
|
|
299
|
+
const meshId = outlinedMeshes.meshIds[meshIndex];
|
|
300
|
+
const mesh = scene.getMeshById(meshId);
|
|
301
|
+
if (mesh) {
|
|
302
|
+
meshes.push(mesh);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
selectionOutlineLayer.addSelection(meshes);
|
|
306
|
+
}
|
|
307
|
+
return selectionOutlineLayer;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
__decorate([
|
|
311
|
+
serializeAsColor3()
|
|
312
|
+
], SelectionOutlineLayer.prototype, "outlineColor", null);
|
|
313
|
+
__decorate([
|
|
314
|
+
serialize()
|
|
315
|
+
], SelectionOutlineLayer.prototype, "outlineThickness", null);
|
|
316
|
+
__decorate([
|
|
317
|
+
serialize()
|
|
318
|
+
], SelectionOutlineLayer.prototype, "occlusionStrength", null);
|
|
319
|
+
__decorate([
|
|
320
|
+
serialize()
|
|
321
|
+
], SelectionOutlineLayer.prototype, "occlusionThreshold", null);
|
|
322
|
+
__decorate([
|
|
323
|
+
serialize("options")
|
|
324
|
+
], SelectionOutlineLayer.prototype, "_options", void 0);
|
|
325
|
+
RegisterClass("BABYLON.SelectionOutlineLayer", SelectionOutlineLayer);
|
|
326
|
+
//# sourceMappingURL=selectionOutlineLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionOutlineLayer.js","sourceRoot":"","sources":["../../../../dev/core/src/Layers/selectionOutlineLayer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAMjC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAexE,KAAK,CAA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E;yDAGnB;AAUD;IADC,SAAS,EAAE;6DAGX;AAUD;IADC,SAAS,EAAE;8DAGX;AAUD;IADC,SAAS,EAAE;+DAGX;AAOO;IADP,SAAS,CAAC,SAAS,CAAC;uDACqC;AA0S9D,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsColor3 } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Scene } from \"../scene\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { EffectLayer } from \"./effectLayer\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport type { IThinSelectionOutlineLayerOptions } from \"./thinSelectionOutlineLayer\";\r\nimport { ThinSelectionOutlineLayer } from \"./thinSelectionOutlineLayer\";\r\nimport type { Color3 } from \"../Maths/math.color\";\r\n\r\ndeclare module \"../scene\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Scene {\r\n /**\r\n * Return a the first selection outline layer of the scene with a given name.\r\n * @param name The name of the selection outline layer to look for.\r\n * @returns The selection outline layer if found otherwise null.\r\n */\r\n getSelectionOutlineLayerByName(name: string): Nullable<SelectionOutlineLayer>;\r\n }\r\n}\r\n\r\nScene.prototype.getSelectionOutlineLayerByName = function (name: string): Nullable<SelectionOutlineLayer> {\r\n for (let index = 0; index < this.effectLayers?.length; index++) {\r\n if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === SelectionOutlineLayer.EffectName) {\r\n return (<any>this.effectLayers[index]) as SelectionOutlineLayer;\r\n }\r\n }\r\n\r\n return null;\r\n};\r\n\r\n/**\r\n * Selection outline layer options. This helps customizing the behaviour\r\n * of the selection outline layer.\r\n */\r\nexport interface ISelectionOutlineLayerOptions extends IThinSelectionOutlineLayerOptions {\r\n /**\r\n * Enable MSAA by choosing the number of samples. Default: 1\r\n */\r\n mainTextureSamples?: number;\r\n}\r\n\r\n/**\r\n * The selection outline layer Helps adding a outline effect around a mesh.\r\n *\r\n * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove\r\n * outlined meshes to your scene.\r\n */\r\nexport class SelectionOutlineLayer extends EffectLayer {\r\n /**\r\n * Effect Name of the selection outline layer.\r\n */\r\n public static get EffectName() {\r\n return ThinSelectionOutlineLayer.EffectName;\r\n }\r\n\r\n /**\r\n * The outline color (default (1, 0.5, 0))\r\n */\r\n @serializeAsColor3()\r\n public get outlineColor(): Color3 {\r\n return this._thinEffectLayer.outlineColor;\r\n }\r\n\r\n public set outlineColor(value: Color3) {\r\n this._thinEffectLayer.outlineColor = value;\r\n }\r\n\r\n /**\r\n * The thickness of the edges (default: 2.0)\r\n */\r\n @serialize()\r\n public get outlineThickness(): number {\r\n return this._thinEffectLayer.outlineThickness;\r\n }\r\n\r\n public set outlineThickness(value: number) {\r\n this._thinEffectLayer.outlineThickness = value;\r\n }\r\n\r\n /**\r\n * The strength of the occlusion effect (default: 0.8)\r\n */\r\n @serialize()\r\n public get occlusionStrength(): number {\r\n return this._thinEffectLayer.occlusionStrength;\r\n }\r\n\r\n public set occlusionStrength(value: number) {\r\n this._thinEffectLayer.occlusionStrength = value;\r\n }\r\n\r\n /**\r\n * The occlusion threshold (default: 0.01)\r\n */\r\n @serialize()\r\n public get occlusionThreshold(): number {\r\n return this._thinEffectLayer.occlusionThreshold;\r\n }\r\n\r\n public set occlusionThreshold(value: number) {\r\n this._thinEffectLayer.occlusionThreshold = value;\r\n }\r\n\r\n @serialize(\"options\")\r\n private _options: Required<ISelectionOutlineLayerOptions>;\r\n\r\n protected override readonly _thinEffectLayer: ThinSelectionOutlineLayer;\r\n\r\n /**\r\n * Instantiates a new selection outline Layer and references it to the scene..\r\n * @param name The name of the layer\r\n * @param scene The scene to use the layer in\r\n * @param options Sets of none mandatory options to use with the layer (see ISelectionOutlineLayerOptions for more information)\r\n */\r\n public constructor(name: string, scene?: Scene, options?: Partial<ISelectionOutlineLayerOptions>) {\r\n super(name, scene, options !== undefined ? !!options.forceGLSL : false, new ThinSelectionOutlineLayer(name, scene, options));\r\n\r\n // Adapt options\r\n this._options = {\r\n mainTextureRatio: 1.0,\r\n mainTextureFixedSize: 0,\r\n alphaBlendingMode: Constants.ALPHA_COMBINE,\r\n camera: null,\r\n mainTextureSamples: 1,\r\n renderingGroupId: -1,\r\n mainTextureType: Constants.TEXTURETYPE_FLOAT,\r\n mainTextureFormat: Constants.TEXTUREFORMAT_RG,\r\n forceGLSL: false,\r\n storeCameraSpaceZ: false,\r\n ...options,\r\n };\r\n\r\n // Initialize the layer\r\n this._init(this._options);\r\n\r\n // Do not render as long as no meshes have been added\r\n this._shouldRender = false;\r\n\r\n this._scene.enableDepthRenderer();\r\n }\r\n\r\n /**\r\n * Get the effect name of the layer.\r\n * @returns The effect name\r\n */\r\n public getEffectName(): string {\r\n return SelectionOutlineLayer.EffectName;\r\n }\r\n\r\n protected override _numInternalDraws(): number {\r\n return 1; // draw depth mask on main pass and outline on merge pass\r\n }\r\n\r\n /**\r\n * Create the merge effect. This is the shader use to blit the information back\r\n * to the main canvas at the end of the scene rendering.\r\n * @returns The effect created\r\n */\r\n protected _createMergeEffect(): Effect {\r\n return this._thinEffectLayer._createMergeEffect();\r\n }\r\n\r\n /**\r\n * Creates the render target textures and post processes used in the selection outline layer.\r\n */\r\n protected _createTextureAndPostProcesses(): void {\r\n this._textures = [];\r\n\r\n this._thinEffectLayer.bindTexturesForCompose = (effect: Effect): void => {\r\n effect.setTexture(\"maskSampler\", this._mainTexture);\r\n const depthRenderer = this._scene.enableDepthRenderer();\r\n effect.setTexture(\"depthSampler\", depthRenderer.getDepthMap());\r\n\r\n const mainTextureDesiredSize = this._mainTextureDesiredSize;\r\n this._thinEffectLayer.textureWidth = mainTextureDesiredSize.width;\r\n this._thinEffectLayer.textureHeight = mainTextureDesiredSize.height;\r\n };\r\n\r\n this._thinEffectLayer._createTextureAndPostProcesses();\r\n\r\n this._postProcesses = [];\r\n\r\n this._mainTexture.samples = this._options.mainTextureSamples;\r\n this._mainTexture.onAfterUnbindObservable.add(() => {\r\n // glow layer and highlight layer both call this._scene.postProcessManager.directRender\r\n // when you call this._scene.postProcessManager.directRender, it has 4 side effects:\r\n // 1. binds the framebuffer\r\n // 2. setAlphaMode(ALPHA_DISABLE)\r\n // 3. setDepthBuffer(true)\r\n // 4. setDepthWrite(true)\r\n // glow layer and highlight layer are restore framebuffer and depends on other side effects\r\n // but for now 3 and 4 are not needed to resolve the state management issue, so we just restore alpha mode\r\n this._scene.getEngine().setAlphaMode(Constants.ALPHA_DISABLE);\r\n });\r\n }\r\n\r\n /**\r\n * Creates the main texture for the effect layer.\r\n */\r\n protected override _createMainTexture(): void {\r\n super._createMainTexture();\r\n // set the render list for selective rendering\r\n this._mainTexture.renderList = this._thinEffectLayer._selection;\r\n }\r\n\r\n /**\r\n * @returns whether or not the layer needs stencil enabled during the mesh rendering.\r\n */\r\n public needStencil(): boolean {\r\n return this._thinEffectLayer.needStencil();\r\n }\r\n\r\n /**\r\n * Checks for the readiness of the element composing the layer.\r\n * @param subMesh the mesh to check for\r\n * @param useInstances specify whether or not to use instances to render the mesh\r\n * @returns true if ready otherwise, false\r\n */\r\n public isReady(subMesh: SubMesh, useInstances: boolean): boolean {\r\n return this._thinEffectLayer.isReady(subMesh, useInstances);\r\n }\r\n\r\n /**\r\n * Implementation specific of rendering the generating effect on the main canvas.\r\n * @param effect The effect used to render through\r\n * @param renderIndex\r\n */\r\n protected _internalRender(effect: Effect, renderIndex: number): void {\r\n this._thinEffectLayer._internalCompose(effect, renderIndex);\r\n }\r\n\r\n /**\r\n * @returns true if the layer contains information to display, otherwise false.\r\n */\r\n public override shouldRender(): boolean {\r\n return this._thinEffectLayer.shouldRender();\r\n }\r\n\r\n /**\r\n * Returns true if the mesh should render, otherwise false.\r\n * @param mesh The mesh to render\r\n * @returns true if it should render otherwise false\r\n */\r\n protected override _shouldRenderMesh(mesh: Mesh): boolean {\r\n return this._thinEffectLayer._shouldRenderMesh(mesh);\r\n }\r\n\r\n /**\r\n * Returns true if the mesh can be rendered, otherwise false.\r\n * @param mesh The mesh to render\r\n * @param material The material used on the mesh\r\n * @returns true if it can be rendered otherwise false\r\n */\r\n protected override _canRenderMesh(mesh: AbstractMesh, material: Material): boolean {\r\n return this._thinEffectLayer._canRenderMesh(mesh, material);\r\n }\r\n\r\n /**\r\n * Adds specific effects defines.\r\n * @param defines The defines to add specifics to.\r\n */\r\n protected override _addCustomEffectDefines(defines: string[]): void {\r\n this._thinEffectLayer._addCustomEffectDefines(defines);\r\n }\r\n\r\n /**\r\n * Sets the required values for both the emissive texture and and the main color.\r\n * @param mesh\r\n * @param subMesh\r\n * @param material\r\n */\r\n protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void {\r\n this._thinEffectLayer._setEmissiveTextureAndColor(mesh, subMesh, material);\r\n }\r\n\r\n /**\r\n * Determine if a given mesh will be highlighted by the current SelectionOutlineLayer\r\n * @param mesh mesh to test\r\n * @returns true if the mesh will be highlighted by the current SelectionOutlineLayer\r\n */\r\n public override hasMesh(mesh: AbstractMesh): boolean {\r\n return this._thinEffectLayer.hasMesh(mesh);\r\n }\r\n\r\n /**\r\n * Remove all the meshes currently referenced in the selection outline layer\r\n */\r\n public clearSelection(): void {\r\n this._thinEffectLayer.clearSelection();\r\n this._mainTexture.renderList = this._thinEffectLayer._selection; // update render list\r\n }\r\n\r\n /**\r\n * Adds mesh or group of mesh to the current selection\r\n *\r\n * If a group of meshes is provided, they will outline as a single unit\r\n * @param meshOrGroup Meshes to add to the selection\r\n */\r\n public addSelection(meshOrGroup: AbstractMesh | AbstractMesh[]): void {\r\n this._thinEffectLayer.addSelection(meshOrGroup);\r\n }\r\n\r\n /**\r\n * Adds mesh or group of mesh to the current selection\r\n * @param meshOrGroup Meshes to remove from the selection\r\n */\r\n public removeSelection(meshOrGroup: AbstractMesh | AbstractMesh[]): void {\r\n this._thinEffectLayer.removeSelection(meshOrGroup);\r\n }\r\n\r\n /**\r\n * Free any resources and references associated to a mesh.\r\n * Internal use\r\n * @param mesh The mesh to free.\r\n * @internal\r\n */\r\n public _disposeMesh(mesh: Mesh): void {\r\n this._thinEffectLayer._disposeMesh(mesh);\r\n }\r\n\r\n /**\r\n * Gets the class name of the effect layer\r\n * @returns the string with the class name of the effect layer\r\n */\r\n public override getClassName(): string {\r\n return \"SelectionOutlineLayer\";\r\n }\r\n\r\n /**\r\n * Serializes this SelectionOutline layer\r\n * @returns a serialized SelectionOutline layer object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.customType = \"BABYLON.SelectionOutlineLayer\";\r\n\r\n // Selected meshes\r\n serializationObject.selection = [];\r\n\r\n const selection = this._thinEffectLayer._selection;\r\n if (selection) {\r\n const meshUniqueIdToSelectionId = this._thinEffectLayer._meshUniqueIdToSelectionId;\r\n\r\n // selection can be sparse since _removeMesh can remove entries\r\n const selectionMap: {\r\n [uniqueId: number]: {\r\n meshIds: string[];\r\n };\r\n } = {};\r\n\r\n for (let i = 0; i < selection.length; ++i) {\r\n const mesh = selection[i];\r\n const selectionId = meshUniqueIdToSelectionId[mesh.uniqueId];\r\n\r\n if (!selectionMap[selectionId]) {\r\n selectionMap[selectionId] = {\r\n meshIds: [],\r\n };\r\n }\r\n selectionMap[selectionId].meshIds.push(mesh.id);\r\n }\r\n serializationObject.selection = selectionMap;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a SelectionOutline layer from parsed SelectionOutline layer data\r\n * @param parsedSelectionOutlineLayer defines the SelectionOutline layer data\r\n * @param scene defines the current scene\r\n * @param rootUrl defines the root URL containing the SelectionOutline layer information\r\n * @returns a parsed SelectionOutline layer\r\n */\r\n public static override Parse(parsedSelectionOutlineLayer: any, scene: Scene, rootUrl: string): SelectionOutlineLayer {\r\n const selectionOutlineLayer = SerializationHelper.Parse(\r\n () => new SelectionOutlineLayer(parsedSelectionOutlineLayer.name, scene, parsedSelectionOutlineLayer.options),\r\n parsedSelectionOutlineLayer,\r\n scene,\r\n rootUrl\r\n );\r\n\r\n const selectionMap = parsedSelectionOutlineLayer.selection as { [uniqueId: number]: { meshIds: string[] } };\r\n\r\n // Selected meshes\r\n for (const outlinedMeshes of Object.values(selectionMap)) {\r\n const meshes: AbstractMesh[] = [];\r\n for (let meshIndex = 0; meshIndex < outlinedMeshes.meshIds.length; meshIndex++) {\r\n const meshId = outlinedMeshes.meshIds[meshIndex];\r\n const mesh = scene.getMeshById(meshId);\r\n if (mesh) {\r\n meshes.push(mesh);\r\n }\r\n }\r\n\r\n selectionOutlineLayer.addSelection(meshes);\r\n }\r\n\r\n return selectionOutlineLayer;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SelectionOutlineLayer\", SelectionOutlineLayer);\r\n"]}
|
|
@@ -55,6 +55,10 @@ export interface IThinEffectLayerOptions {
|
|
|
55
55
|
* The type of the main texture. Default: TEXTURETYPE_UNSIGNED_BYTE
|
|
56
56
|
*/
|
|
57
57
|
mainTextureType?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The format of the main texture. Default: TEXTUREFORMAT_RGBA
|
|
60
|
+
*/
|
|
61
|
+
mainTextureFormat?: number;
|
|
58
62
|
/**
|
|
59
63
|
* Alpha blending mode used to apply the blur. Default depends of the implementation. Default: ALPHA_COMBINE
|
|
60
64
|
*/
|
|
@@ -76,7 +80,7 @@ export declare class ThinEffectLayer {
|
|
|
76
80
|
private _vertexBuffers;
|
|
77
81
|
private _indexBuffer;
|
|
78
82
|
private _mergeDrawWrapper;
|
|
79
|
-
|
|
83
|
+
protected _dontCheckIfReady: boolean;
|
|
80
84
|
protected _scene: Scene;
|
|
81
85
|
protected _engine: AbstractEngine;
|
|
82
86
|
/** @internal */
|
|
@@ -8,7 +8,7 @@ import { Material } from "../Materials/material.js";
|
|
|
8
8
|
import { EffectFallbacks } from "../Materials/effectFallbacks.js";
|
|
9
9
|
import { DrawWrapper } from "../Materials/drawWrapper.js";
|
|
10
10
|
import { AddClipPlaneUniforms, BindClipPlane, PrepareStringDefinesForClipPlanes } from "../Materials/clipPlaneMaterialHelper.js";
|
|
11
|
-
import { BindMorphTargetParameters, PrepareDefinesAndAttributesForMorphTargets, PushAttributesForInstances } from "../Materials/materialHelper.functions.js";
|
|
11
|
+
import { BindBonesParameters, BindMorphTargetParameters, PrepareDefinesAndAttributesForMorphTargets, PushAttributesForInstances } from "../Materials/materialHelper.functions.js";
|
|
12
12
|
import { ObjectRenderer } from "../Rendering/objectRenderer.js";
|
|
13
13
|
import { Engine } from "../Engines/engine.js";
|
|
14
14
|
/**
|
|
@@ -259,6 +259,7 @@ export class ThinEffectLayer {
|
|
|
259
259
|
mainTextureRatio: 0.5,
|
|
260
260
|
mainTextureFixedSize: 0,
|
|
261
261
|
mainTextureType: 0,
|
|
262
|
+
mainTextureFormat: 5,
|
|
262
263
|
alphaBlendingMode: 2,
|
|
263
264
|
camera: null,
|
|
264
265
|
renderingGroupId: -1,
|
|
@@ -486,6 +487,14 @@ export class ThinEffectLayer {
|
|
|
486
487
|
defines.push("#define THIN_INSTANCES");
|
|
487
488
|
}
|
|
488
489
|
}
|
|
490
|
+
// Baked vertex animations
|
|
491
|
+
const bvaManager = mesh.bakedVertexAnimationManager;
|
|
492
|
+
if (bvaManager && bvaManager.isEnabled) {
|
|
493
|
+
defines.push("#define BAKED_VERTEX_ANIMATION_TEXTURE");
|
|
494
|
+
if (useInstances) {
|
|
495
|
+
attribs.push("bakedVertexAnimationSettingsInstanced");
|
|
496
|
+
}
|
|
497
|
+
}
|
|
489
498
|
// ClipPlanes
|
|
490
499
|
PrepareStringDefinesForClipPlanes(material, this._scene, defines);
|
|
491
500
|
this._addCustomEffectDefines(defines);
|
|
@@ -508,10 +517,14 @@ export class ThinEffectLayer {
|
|
|
508
517
|
"opacityIntensity",
|
|
509
518
|
"morphTargetTextureInfo",
|
|
510
519
|
"morphTargetTextureIndices",
|
|
520
|
+
"bakedVertexAnimationSettings",
|
|
521
|
+
"bakedVertexAnimationTextureSizeInverted",
|
|
522
|
+
"bakedVertexAnimationTime",
|
|
523
|
+
"bakedVertexAnimationTexture",
|
|
511
524
|
"glowIntensity",
|
|
512
525
|
];
|
|
513
526
|
AddClipPlaneUniforms(uniforms);
|
|
514
|
-
drawWrapper.setEffect(this._engine.createEffect("glowMapGeneration", attribs, uniforms, ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], join, fallbacks, undefined, undefined, { maxSimultaneousMorphTargets: numMorphInfluencers }, this._shaderLanguage, this._shadersLoaded
|
|
527
|
+
drawWrapper.setEffect(this._engine.createEffect("glowMapGeneration", attribs, uniforms, ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets", "bakedVertexAnimationTexture"], join, fallbacks, undefined, undefined, { maxSimultaneousMorphTargets: numMorphInfluencers }, this._shaderLanguage, this._shadersLoaded
|
|
515
528
|
? undefined
|
|
516
529
|
: async () => {
|
|
517
530
|
await this._importShadersAsync();
|
|
@@ -718,25 +731,17 @@ export class ThinEffectLayer {
|
|
|
718
731
|
effect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
|
|
719
732
|
}
|
|
720
733
|
// Bones
|
|
721
|
-
|
|
722
|
-
const skeleton = renderingMesh.skeleton;
|
|
723
|
-
if (skeleton.isUsingTextureForMatrices) {
|
|
724
|
-
const boneTexture = skeleton.getTransformMatrixTexture(renderingMesh);
|
|
725
|
-
if (!boneTexture) {
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
effect.setTexture("boneSampler", boneTexture);
|
|
729
|
-
effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
effect.setMatrices("mBones", skeleton.getTransformMatrices(renderingMesh));
|
|
733
|
-
}
|
|
734
|
-
}
|
|
734
|
+
BindBonesParameters(renderingMesh, effect);
|
|
735
735
|
// Morph targets
|
|
736
736
|
BindMorphTargetParameters(renderingMesh, effect);
|
|
737
737
|
if (renderingMesh.morphTargetManager && renderingMesh.morphTargetManager.isUsingTextureForTargets) {
|
|
738
738
|
renderingMesh.morphTargetManager._bind(effect);
|
|
739
739
|
}
|
|
740
|
+
// Baked vertex animations
|
|
741
|
+
const bvaManager = subMesh.getMesh().bakedVertexAnimationManager;
|
|
742
|
+
if (bvaManager && bvaManager.isEnabled) {
|
|
743
|
+
bvaManager.bind(effect, hardwareInstancedRendering);
|
|
744
|
+
}
|
|
740
745
|
// Alpha mode
|
|
741
746
|
if (enableAlphaMode) {
|
|
742
747
|
engine.setAlphaMode(material.alphaMode);
|