@babylonjs/core 8.22.3 → 8.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Bones/skeleton.d.ts +4 -0
- package/Bones/skeleton.js +12 -0
- package/Bones/skeleton.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Misc/dumpTools.js +125 -123
- package/Misc/dumpTools.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +4 -0
- package/Morph/morphTargetManager.js +12 -0
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +16 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/alignAngleBlock.d.ts +2 -0
- package/Particles/Node/Blocks/Update/alignAngleBlock.js +11 -0
- package/Particles/Node/Blocks/Update/alignAngleBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +2 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.d.ts +19 -0
- package/Particles/Node/nodeParticleSystemSet.js +46 -0
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +4 -0
- package/Particles/gpuParticleSystem.js +10 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +4 -0
- package/Particles/particleSystem.js +10 -0
- package/Particles/particleSystem.js.map +1 -1
- package/package.json +1 -1
package/Misc/dumpTools.js
CHANGED
|
@@ -3,79 +3,63 @@ import { EffectRenderer, EffectWrapper } from "../Materials/effectRenderer.js";
|
|
|
3
3
|
import { Tools } from "./tools.js";
|
|
4
4
|
import { Clamp } from "../Maths/math.scalar.functions.js";
|
|
5
5
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
async function
|
|
9
|
-
if
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const options = {
|
|
14
|
-
preserveDrawingBuffer: true,
|
|
15
|
-
depth: false,
|
|
16
|
-
stencil: false,
|
|
17
|
-
alpha: true,
|
|
18
|
-
premultipliedAlpha: false,
|
|
19
|
-
antialias: false,
|
|
20
|
-
failIfMajorPerformanceCaveat: false,
|
|
21
|
-
};
|
|
22
|
-
import("../Engines/thinEngine.js")
|
|
23
|
-
// eslint-disable-next-line github/no-then
|
|
24
|
-
.then(({ ThinEngine: thinEngineClass }) => {
|
|
25
|
-
const engineInstanceCount = EngineStore.Instances.length;
|
|
26
|
-
try {
|
|
27
|
-
canvas = new OffscreenCanvas(100, 100); // will be resized later
|
|
28
|
-
engine = new thinEngineClass(canvas, false, options);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
if (engineInstanceCount < EngineStore.Instances.length) {
|
|
32
|
-
// The engine was created by another instance, let's use it
|
|
33
|
-
EngineStore.Instances.pop()?.dispose();
|
|
34
|
-
}
|
|
35
|
-
// The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas
|
|
36
|
-
canvas = document.createElement("canvas");
|
|
37
|
-
engine = new thinEngineClass(canvas, false, options);
|
|
38
|
-
}
|
|
39
|
-
// remove this engine from the list of instances to avoid using it for other purposes
|
|
40
|
-
EngineStore.Instances.pop();
|
|
41
|
-
// However, make sure to dispose it when no other engines are left
|
|
42
|
-
EngineStore.OnEnginesDisposedObservable.add((e) => {
|
|
43
|
-
// guaranteed to run when no other instances are left
|
|
44
|
-
// only dispose if it's not the current engine
|
|
45
|
-
if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {
|
|
46
|
-
// Dump the engine and the associated resources
|
|
47
|
-
Dispose();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
engine.getCaps().parallelShaderCompile = undefined;
|
|
51
|
-
const renderer = new EffectRenderer(engine);
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
|
|
53
|
-
import("../Shaders/pass.fragment.js").then(({ passPixelShader }) => {
|
|
54
|
-
if (!engine) {
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
56
|
-
reject("Engine is not defined");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const wrapper = new EffectWrapper({
|
|
60
|
-
engine,
|
|
61
|
-
name: passPixelShader.name,
|
|
62
|
-
fragmentShader: passPixelShader.shader,
|
|
63
|
-
samplerNames: ["textureSampler"],
|
|
64
|
-
});
|
|
65
|
-
DumpToolsEngine = {
|
|
66
|
-
canvas,
|
|
67
|
-
engine,
|
|
68
|
-
renderer,
|
|
69
|
-
wrapper,
|
|
70
|
-
};
|
|
71
|
-
resolve(DumpToolsEngine);
|
|
72
|
-
});
|
|
73
|
-
})
|
|
74
|
-
// eslint-disable-next-line github/no-then
|
|
75
|
-
.catch(reject);
|
|
76
|
-
});
|
|
6
|
+
import { Logger } from "./logger.js";
|
|
7
|
+
let ResourcesPromise = null;
|
|
8
|
+
async function _CreateDumpResourcesAsync() {
|
|
9
|
+
// Create a compatible canvas. Prefer an HTMLCanvasElement if possible to avoid alpha issues with OffscreenCanvas + WebGL in many browsers.
|
|
10
|
+
const canvas = (EngineStore.LastCreatedEngine?.createCanvas(100, 100) ?? new OffscreenCanvas(100, 100)); // will be resized later
|
|
11
|
+
if (canvas instanceof OffscreenCanvas) {
|
|
12
|
+
Logger.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");
|
|
77
13
|
}
|
|
78
|
-
|
|
14
|
+
// If WebGL via ThinEngine is not available (e.g. Native), use the BitmapRenderer.
|
|
15
|
+
// If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.
|
|
16
|
+
const { ThinEngine: thinEngineClass } = await import("../Engines/thinEngine.js");
|
|
17
|
+
if (!thinEngineClass.IsSupported) {
|
|
18
|
+
if (!canvas.getContext("bitmaprenderer")) {
|
|
19
|
+
throw new Error("DumpData: No WebGL or bitmap rendering context available. Cannot dump data.");
|
|
20
|
+
}
|
|
21
|
+
return { canvas };
|
|
22
|
+
}
|
|
23
|
+
const options = {
|
|
24
|
+
preserveDrawingBuffer: true,
|
|
25
|
+
depth: false,
|
|
26
|
+
stencil: false,
|
|
27
|
+
alpha: true,
|
|
28
|
+
premultipliedAlpha: false,
|
|
29
|
+
antialias: false,
|
|
30
|
+
failIfMajorPerformanceCaveat: false,
|
|
31
|
+
};
|
|
32
|
+
const engine = new thinEngineClass(canvas, false, options);
|
|
33
|
+
// remove this engine from the list of instances to avoid using it for other purposes
|
|
34
|
+
EngineStore.Instances.pop();
|
|
35
|
+
// However, make sure to dispose it when no other engines are left
|
|
36
|
+
EngineStore.OnEnginesDisposedObservable.add((e) => {
|
|
37
|
+
// guaranteed to run when no other instances are left
|
|
38
|
+
// only dispose if it's not the current engine
|
|
39
|
+
if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {
|
|
40
|
+
// Dump the engine and the associated resources
|
|
41
|
+
Dispose();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
engine.getCaps().parallelShaderCompile = undefined;
|
|
45
|
+
const renderer = new EffectRenderer(engine);
|
|
46
|
+
const { passPixelShader } = await import("../Shaders/pass.fragment.js");
|
|
47
|
+
const wrapper = new EffectWrapper({
|
|
48
|
+
engine,
|
|
49
|
+
name: passPixelShader.name,
|
|
50
|
+
fragmentShader: passPixelShader.shader,
|
|
51
|
+
samplerNames: ["textureSampler"],
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
canvas: canvas,
|
|
55
|
+
dumpEngine: { engine, renderer, wrapper },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function _GetDumpResourcesAsync() {
|
|
59
|
+
if (!ResourcesPromise) {
|
|
60
|
+
ResourcesPromise = _CreateDumpResourcesAsync();
|
|
61
|
+
}
|
|
62
|
+
return await ResourcesPromise;
|
|
79
63
|
}
|
|
80
64
|
/**
|
|
81
65
|
* Dumps the current bound framebuffer
|
|
@@ -109,8 +93,54 @@ export async function DumpFramebuffer(width, height, engine, successCallback, mi
|
|
|
109
93
|
* @returns a promise that resolve to the final data
|
|
110
94
|
*/
|
|
111
95
|
export async function DumpDataAsync(width, height, data, mimeType = "image/png", fileName, invertY = false, toArrayBuffer = false, quality) {
|
|
112
|
-
|
|
113
|
-
|
|
96
|
+
// Convert if data are float32
|
|
97
|
+
if (data instanceof Float32Array) {
|
|
98
|
+
const data2 = new Uint8Array(data.length);
|
|
99
|
+
let n = data.length;
|
|
100
|
+
while (n--) {
|
|
101
|
+
const v = data[n];
|
|
102
|
+
data2[n] = Math.round(Clamp(v) * 255);
|
|
103
|
+
}
|
|
104
|
+
data = data2;
|
|
105
|
+
}
|
|
106
|
+
const resources = await _GetDumpResourcesAsync();
|
|
107
|
+
// Keep the async render + read from the shared canvas atomic
|
|
108
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
109
|
+
return await new Promise(async (resolve) => {
|
|
110
|
+
if (resources.dumpEngine) {
|
|
111
|
+
const dumpEngine = resources.dumpEngine;
|
|
112
|
+
dumpEngine.engine.setSize(width, height, true);
|
|
113
|
+
// Create the image
|
|
114
|
+
const texture = dumpEngine.engine.createRawTexture(data, width, height, 5, false, !invertY, 1);
|
|
115
|
+
dumpEngine.renderer.setViewport();
|
|
116
|
+
dumpEngine.renderer.applyEffectWrapper(dumpEngine.wrapper);
|
|
117
|
+
dumpEngine.wrapper.effect._bindTexture("textureSampler", texture);
|
|
118
|
+
dumpEngine.renderer.draw();
|
|
119
|
+
texture.dispose();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const ctx = resources.canvas.getContext("bitmaprenderer");
|
|
123
|
+
resources.canvas.width = width;
|
|
124
|
+
resources.canvas.height = height;
|
|
125
|
+
const imageData = new ImageData(width, height); // ImageData(data, sw, sh) ctor not yet widely implemented
|
|
126
|
+
imageData.data.set(data);
|
|
127
|
+
const imageBitmap = await createImageBitmap(imageData, { premultiplyAlpha: "none", imageOrientation: invertY ? "flipY" : "from-image" });
|
|
128
|
+
ctx.transferFromImageBitmap(imageBitmap);
|
|
129
|
+
}
|
|
130
|
+
// Download the result
|
|
131
|
+
if (toArrayBuffer) {
|
|
132
|
+
Tools.ToBlob(resources.canvas, (blob) => {
|
|
133
|
+
const fileReader = new FileReader();
|
|
134
|
+
fileReader.onload = (event) => {
|
|
135
|
+
const arrayBuffer = event.target.result;
|
|
136
|
+
resolve(arrayBuffer);
|
|
137
|
+
};
|
|
138
|
+
fileReader.readAsArrayBuffer(blob);
|
|
139
|
+
}, mimeType, quality);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
Tools.EncodeScreenshotCanvasData(resources.canvas, resolve, mimeType, fileName, quality);
|
|
143
|
+
}
|
|
114
144
|
});
|
|
115
145
|
}
|
|
116
146
|
/**
|
|
@@ -126,63 +156,35 @@ export async function DumpDataAsync(width, height, data, mimeType = "image/png",
|
|
|
126
156
|
* @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
|
|
127
157
|
*/
|
|
128
158
|
export function DumpData(width, height, data, successCallback, mimeType = "image/png", fileName, invertY = false, toArrayBuffer = false, quality) {
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
let n = data.length;
|
|
136
|
-
while (n--) {
|
|
137
|
-
const v = data[n];
|
|
138
|
-
data2[n] = Math.round(Clamp(v) * 255);
|
|
139
|
-
}
|
|
140
|
-
data = data2;
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
160
|
+
DumpDataAsync(width, height, data, mimeType, fileName, invertY, toArrayBuffer, quality)
|
|
161
|
+
// eslint-disable-next-line github/no-then
|
|
162
|
+
.then((result) => {
|
|
163
|
+
if (successCallback) {
|
|
164
|
+
successCallback(result);
|
|
141
165
|
}
|
|
142
|
-
// Create the image
|
|
143
|
-
const texture = renderer.engine.createRawTexture(data, width, height, 5, false, !invertY, 1);
|
|
144
|
-
renderer.renderer.setViewport();
|
|
145
|
-
renderer.renderer.applyEffectWrapper(renderer.wrapper);
|
|
146
|
-
renderer.wrapper.effect._bindTexture("textureSampler", texture);
|
|
147
|
-
renderer.renderer.draw();
|
|
148
|
-
if (toArrayBuffer) {
|
|
149
|
-
Tools.ToBlob(renderer.canvas, (blob) => {
|
|
150
|
-
const fileReader = new FileReader();
|
|
151
|
-
fileReader.onload = (event) => {
|
|
152
|
-
const arrayBuffer = event.target.result;
|
|
153
|
-
if (successCallback) {
|
|
154
|
-
successCallback(arrayBuffer);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
fileReader.readAsArrayBuffer(blob);
|
|
158
|
-
}, mimeType, quality);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);
|
|
162
|
-
}
|
|
163
|
-
texture.dispose();
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Dispose the dump tools associated resources
|
|
168
170
|
*/
|
|
169
171
|
export function Dispose() {
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
DumpToolsEngine.renderer.dispose();
|
|
173
|
-
DumpToolsEngine.engine.dispose();
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
// in cases where the engine is not yet created, we need to wait for it to dispose it
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
|
|
178
|
-
EnginePromise?.then((dumpToolsEngine) => {
|
|
179
|
-
dumpToolsEngine.wrapper.dispose();
|
|
180
|
-
dumpToolsEngine.renderer.dispose();
|
|
181
|
-
dumpToolsEngine.engine.dispose();
|
|
182
|
-
});
|
|
172
|
+
if (!ResourcesPromise) {
|
|
173
|
+
return;
|
|
183
174
|
}
|
|
184
|
-
|
|
185
|
-
|
|
175
|
+
// in cases where the engine is not yet created, we need to wait for it to dispose it
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
|
|
177
|
+
ResourcesPromise?.then((resources) => {
|
|
178
|
+
if (resources.canvas instanceof HTMLCanvasElement) {
|
|
179
|
+
resources.canvas.remove();
|
|
180
|
+
}
|
|
181
|
+
if (resources.dumpEngine) {
|
|
182
|
+
resources.dumpEngine.engine.dispose();
|
|
183
|
+
resources.dumpEngine.renderer.dispose();
|
|
184
|
+
resources.dumpEngine.wrapper.dispose();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
ResourcesPromise = null;
|
|
186
188
|
}
|
|
187
189
|
/**
|
|
188
190
|
* Object containing a set of static utilities functions to dump data from a canvas
|
package/Misc/dumpTools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,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aAAa;IACb,gEAAgE;IAChE,eAAe;IACf,gEAAgE;IAChE,OAAO;CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5C,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\n\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\ntype DumpToolsEngine = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n};\r\n\r\nlet DumpToolsEngine: Nullable<DumpToolsEngine>;\r\n\r\nlet EnginePromise: Promise<DumpToolsEngine> | null = null;\r\n\r\nasync function _CreateDumpRendererAsync(): Promise<DumpToolsEngine> {\r\n if (!EnginePromise) {\r\n EnginePromise = new Promise((resolve, reject) => {\r\n let canvas: HTMLCanvasElement | OffscreenCanvas;\r\n let engine: Nullable<ThinEngine> = null;\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n import(\"../Engines/thinEngine\")\r\n // eslint-disable-next-line github/no-then\r\n .then(({ ThinEngine: thinEngineClass }) => {\r\n const engineInstanceCount = EngineStore.Instances.length;\r\n try {\r\n canvas = new OffscreenCanvas(100, 100); // will be resized later\r\n engine = new thinEngineClass(canvas, false, options);\r\n } catch (e) {\r\n if (engineInstanceCount < EngineStore.Instances.length) {\r\n // The engine was created by another instance, let's use it\r\n EngineStore.Instances.pop()?.dispose();\r\n }\r\n // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas\r\n canvas = document.createElement(\"canvas\");\r\n engine = new thinEngineClass(canvas, false, options);\r\n }\r\n // remove this engine from the list of instances to avoid using it for other purposes\r\n EngineStore.Instances.pop();\r\n // However, make sure to dispose it when no other engines are left\r\n EngineStore.OnEnginesDisposedObservable.add((e) => {\r\n // guaranteed to run when no other instances are left\r\n // only dispose if it's not the current engine\r\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\r\n // Dump the engine and the associated resources\r\n Dispose();\r\n }\r\n });\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n const renderer = new EffectRenderer(engine);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n import(\"../Shaders/pass.fragment\").then(({ passPixelShader }) => {\r\n if (!engine) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Engine is not defined\");\r\n return;\r\n }\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n DumpToolsEngine = {\r\n canvas,\r\n engine,\r\n renderer,\r\n wrapper,\r\n };\r\n resolve(DumpToolsEngine);\r\n });\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n });\r\n }\r\n return await EnginePromise;\r\n}\r\n\r\n/**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n// Should have \"Async\" in the name but this is a public API and we can't break it now\r\n// eslint-disable-next-line no-restricted-syntax\r\nexport async function DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: AbstractEngine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n}\r\n\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType: string | undefined,\r\n fileName: string | undefined,\r\n invertY: boolean | undefined,\r\n toArrayBuffer: true,\r\n quality?: number\r\n): Promise<ArrayBuffer>;\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n): Promise<string>;\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): Promise<string | ArrayBuffer> {\r\n return await new Promise((resolve) => {\r\n DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\r\n });\r\n}\r\n\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): void {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n _CreateDumpRendererAsync().then((renderer) => {\r\n renderer.engine.setSize(width, height, true);\r\n\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n // Create the image\r\n const texture = renderer.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n renderer.renderer.setViewport();\r\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\r\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n renderer.renderer.draw();\r\n\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n renderer.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n if (successCallback) {\r\n successCallback(arrayBuffer);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\r\n }\r\n\r\n texture.dispose();\r\n });\r\n}\r\n\r\n/**\r\n * Dispose the dump tools associated resources\r\n */\r\nexport function Dispose() {\r\n if (DumpToolsEngine) {\r\n DumpToolsEngine.wrapper.dispose();\r\n DumpToolsEngine.renderer.dispose();\r\n DumpToolsEngine.engine.dispose();\r\n } else {\r\n // in cases where the engine is not yet created, we need to wait for it to dispose it\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n EnginePromise?.then((dumpToolsEngine) => {\r\n dumpToolsEngine.wrapper.dispose();\r\n dumpToolsEngine.renderer.dispose();\r\n dumpToolsEngine.engine.dispose();\r\n });\r\n }\r\n EnginePromise = null;\r\n DumpToolsEngine = null;\r\n}\r\n\r\n/**\r\n * Object containing a set of static utilities functions to dump data from a canvas\r\n * @deprecated use functions\r\n */\r\nexport const DumpTools = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpData,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpDataAsync,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpFramebuffer,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Dispose,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst InitSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpData;\r\n Tools.DumpDataAsync = DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpFramebuffer;\r\n};\r\n\r\nInitSideEffects();\r\n"]}
|
|
1
|
+
{"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAWlC,IAAI,gBAAgB,GAAkC,IAAI,CAAC;AAE3D,KAAK,UAAU,yBAAyB;IACpC,2IAA2I;IAC3I,MAAM,MAAM,GAAG,CAAC,WAAW,CAAC,iBAAiB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAwC,CAAC,CAAC,wBAAwB;IACxK,IAAI,MAAM,YAAY,eAAe,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,iGAAiG,CAAC,CAAC;IACnH,CAAC;IAED,kFAAkF;IAClF,+IAA+I;IAC/I,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAC9E,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;QACnG,CA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_WarnImport } from \"./devTools\";\r\n\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"./logger\";\r\n\r\ntype DumpResources = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n dumpEngine?: {\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n };\r\n};\r\n\r\nlet ResourcesPromise: Promise<DumpResources> | null = null;\r\n\r\nasync function _CreateDumpResourcesAsync(): Promise<DumpResources> {\r\n // Create a compatible canvas. Prefer an HTMLCanvasElement if possible to avoid alpha issues with OffscreenCanvas + WebGL in many browsers.\r\n const canvas = (EngineStore.LastCreatedEngine?.createCanvas(100, 100) ?? new OffscreenCanvas(100, 100)) as HTMLCanvasElement | OffscreenCanvas; // will be resized later\r\n if (canvas instanceof OffscreenCanvas) {\r\n Logger.Warn(\"DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.\");\r\n }\r\n\r\n // If WebGL via ThinEngine is not available (e.g. Native), use the BitmapRenderer.\r\n // If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.\r\n const { ThinEngine: thinEngineClass } = await import(\"../Engines/thinEngine\");\r\n if (!thinEngineClass.IsSupported) {\r\n if (!canvas.getContext(\"bitmaprenderer\")) {\r\n throw new Error(\"DumpData: No WebGL or bitmap rendering context available. Cannot dump data.\");\r\n }\r\n return { canvas };\r\n }\r\n\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n const engine = new thinEngineClass(canvas, false, options);\r\n\r\n // remove this engine from the list of instances to avoid using it for other purposes\r\n EngineStore.Instances.pop();\r\n // However, make sure to dispose it when no other engines are left\r\n EngineStore.OnEnginesDisposedObservable.add((e) => {\r\n // guaranteed to run when no other instances are left\r\n // only dispose if it's not the current engine\r\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\r\n // Dump the engine and the associated resources\r\n Dispose();\r\n }\r\n });\r\n\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n\r\n const renderer = new EffectRenderer(engine);\r\n const { passPixelShader } = await import(\"../Shaders/pass.fragment\");\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n\r\n return {\r\n canvas: canvas,\r\n dumpEngine: { engine, renderer, wrapper },\r\n };\r\n}\r\n\r\nasync function _GetDumpResourcesAsync() {\r\n if (!ResourcesPromise) {\r\n ResourcesPromise = _CreateDumpResourcesAsync();\r\n }\r\n return await ResourcesPromise;\r\n}\r\n\r\n/**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n// Should have \"Async\" in the name but this is a public API and we can't break it now\r\n// eslint-disable-next-line no-restricted-syntax\r\nexport async function DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: AbstractEngine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n}\r\n\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType: string | undefined,\r\n fileName: string | undefined,\r\n invertY: boolean | undefined,\r\n toArrayBuffer: true,\r\n quality?: number\r\n): Promise<ArrayBuffer>;\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n): Promise<string>;\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): Promise<string | ArrayBuffer> {\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n const resources = await _GetDumpResourcesAsync();\r\n\r\n // Keep the async render + read from the shared canvas atomic\r\n // eslint-disable-next-line no-async-promise-executor\r\n return await new Promise<string | ArrayBuffer>(async (resolve) => {\r\n if (resources.dumpEngine) {\r\n const dumpEngine = resources.dumpEngine;\r\n dumpEngine.engine.setSize(width, height, true);\r\n\r\n // Create the image\r\n const texture = dumpEngine.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n dumpEngine.renderer.setViewport();\r\n dumpEngine.renderer.applyEffectWrapper(dumpEngine.wrapper);\r\n dumpEngine.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n dumpEngine.renderer.draw();\r\n\r\n texture.dispose();\r\n } else {\r\n const ctx = resources.canvas.getContext(\"bitmaprenderer\") as ImageBitmapRenderingContext;\r\n resources.canvas.width = width;\r\n resources.canvas.height = height;\r\n\r\n const imageData = new ImageData(width, height); // ImageData(data, sw, sh) ctor not yet widely implemented\r\n imageData.data.set(data as Uint8ClampedArray);\r\n const imageBitmap = await createImageBitmap(imageData, { premultiplyAlpha: \"none\", imageOrientation: invertY ? \"flipY\" : \"from-image\" });\r\n\r\n ctx.transferFromImageBitmap(imageBitmap);\r\n }\r\n\r\n // Download the result\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n resources.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n resolve(arrayBuffer);\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(resources.canvas, resolve, mimeType, fileName, quality);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): void {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n DumpDataAsync(width, height, data, mimeType, fileName, invertY, toArrayBuffer, quality)\r\n // eslint-disable-next-line github/no-then\r\n .then((result) => {\r\n if (successCallback) {\r\n successCallback(result);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Dispose the dump tools associated resources\r\n */\r\nexport function Dispose() {\r\n if (!ResourcesPromise) {\r\n return;\r\n }\r\n\r\n // in cases where the engine is not yet created, we need to wait for it to dispose it\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n ResourcesPromise?.then((resources) => {\r\n if (resources.canvas instanceof HTMLCanvasElement) {\r\n resources.canvas.remove();\r\n }\r\n if (resources.dumpEngine) {\r\n resources.dumpEngine.engine.dispose();\r\n resources.dumpEngine.renderer.dispose();\r\n resources.dumpEngine.wrapper.dispose();\r\n }\r\n });\r\n\r\n ResourcesPromise = null;\r\n}\r\n\r\n/**\r\n * Object containing a set of static utilities functions to dump data from a canvas\r\n * @deprecated use functions\r\n */\r\nexport const DumpTools = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpData,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpDataAsync,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpFramebuffer,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Dispose,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst InitSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpData;\r\n Tools.DumpDataAsync = DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpFramebuffer;\r\n};\r\n\r\nInitSideEffects();\r\n"]}
|
|
@@ -177,6 +177,10 @@ export declare class MorphTargetManager implements IDisposable {
|
|
|
177
177
|
* Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
|
|
178
178
|
*/
|
|
179
179
|
get isUsingTextureForTargets(): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Gets or sets an object used to store user defined information for the MorphTargetManager
|
|
182
|
+
*/
|
|
183
|
+
metadata: any;
|
|
180
184
|
/**
|
|
181
185
|
* Gets the active target at specified index. An active target is a target with an influence > 0
|
|
182
186
|
* @param index defines the index to check
|
|
@@ -88,6 +88,10 @@ export class MorphTargetManager {
|
|
|
88
88
|
this.enableColorMorphing = true;
|
|
89
89
|
this._numMaxInfluencers = 0;
|
|
90
90
|
this._useTextureToStoreTargets = true;
|
|
91
|
+
/**
|
|
92
|
+
* Gets or sets an object used to store user defined information for the MorphTargetManager
|
|
93
|
+
*/
|
|
94
|
+
this.metadata = null;
|
|
91
95
|
if (!scene) {
|
|
92
96
|
scene = EngineStore.LastCreatedScene;
|
|
93
97
|
}
|
|
@@ -340,6 +344,7 @@ export class MorphTargetManager {
|
|
|
340
344
|
copy.enableUVMorphing = this.enableUVMorphing;
|
|
341
345
|
copy.enableUV2Morphing = this.enableUV2Morphing;
|
|
342
346
|
copy.enableColorMorphing = this.enableColorMorphing;
|
|
347
|
+
copy.metadata = this.metadata;
|
|
343
348
|
return copy;
|
|
344
349
|
}
|
|
345
350
|
/**
|
|
@@ -353,6 +358,9 @@ export class MorphTargetManager {
|
|
|
353
358
|
for (const target of this._targets) {
|
|
354
359
|
serializationObject.targets.push(target.serialize());
|
|
355
360
|
}
|
|
361
|
+
if (this.metadata) {
|
|
362
|
+
serializationObject.metadata = this.metadata;
|
|
363
|
+
}
|
|
356
364
|
return serializationObject;
|
|
357
365
|
}
|
|
358
366
|
_syncActiveTargets(needUpdate = false) {
|
|
@@ -524,6 +532,7 @@ export class MorphTargetManager {
|
|
|
524
532
|
this._targetStoreTexture.dispose();
|
|
525
533
|
}
|
|
526
534
|
this._targetStoreTexture = null;
|
|
535
|
+
this.metadata = null;
|
|
527
536
|
// Remove from scene
|
|
528
537
|
if (this._scene) {
|
|
529
538
|
this._scene.removeMorphTargetManager(this);
|
|
@@ -551,6 +560,9 @@ export class MorphTargetManager {
|
|
|
551
560
|
for (const targetData of serializationObject.targets) {
|
|
552
561
|
result.addTarget(MorphTarget.Parse(targetData, scene));
|
|
553
562
|
}
|
|
563
|
+
if (serializationObject.metadata) {
|
|
564
|
+
result.metadata = serializationObject.metadata;
|
|
565
|
+
}
|
|
554
566
|
return result;
|
|
555
567
|
}
|
|
556
568
|
}
|