@babylonjs/core 8.16.0 → 8.16.2
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 +10 -0
- package/Animations/animationGroup.js +13 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +4 -0
- package/FrameGraph/frameGraph.js +7 -5
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -1
- package/Materials/Textures/thinTexture.d.ts +2 -1
- package/Materials/Textures/thinTexture.js +3 -2
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Meshes/transformNode.js +5 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -0
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/index.d.ts +1 -0
- package/Particles/Node/Blocks/Emitters/index.js +1 -0
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +79 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +223 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -0
- package/Physics/v2/ragdoll.d.ts +1 -0
- package/Physics/v2/ragdoll.js +15 -1
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/postProcess.js +2 -5
- package/PostProcesses/postProcess.js.map +1 -1
- package/Sprites/spriteManager.d.ts +1 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +54 -0
- package/scene.js +89 -0
- package/scene.js.map +1 -1
|
@@ -28,6 +28,10 @@ export declare class FrameGraph {
|
|
|
28
28
|
* Name of the frame graph
|
|
29
29
|
*/
|
|
30
30
|
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the unique id of the frame graph
|
|
33
|
+
*/
|
|
34
|
+
readonly uniqueId: number;
|
|
31
35
|
/**
|
|
32
36
|
* Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)
|
|
33
37
|
*/
|
package/FrameGraph/frameGraph.js
CHANGED
|
@@ -7,6 +7,7 @@ import { FrameGraphTextureManager } from "./frameGraphTextureManager.js";
|
|
|
7
7
|
import { Observable } from "../Misc/observable.js";
|
|
8
8
|
import { _RetryWithInterval } from "../Misc/timingTools.js";
|
|
9
9
|
import { Logger } from "../Misc/logger.js";
|
|
10
|
+
import { UniqueIdGenerator } from "../Misc/uniqueIdGenerator.js";
|
|
10
11
|
import "../Engines/Extensions/engine.multiRender.js";
|
|
11
12
|
import "../Engines/WebGPU/Extensions/engine.multiRender.js";
|
|
12
13
|
var FrameGraphPassType;
|
|
@@ -60,6 +61,10 @@ export class FrameGraph {
|
|
|
60
61
|
* Name of the frame graph
|
|
61
62
|
*/
|
|
62
63
|
this.name = "Frame Graph";
|
|
64
|
+
/**
|
|
65
|
+
* Gets the unique id of the frame graph
|
|
66
|
+
*/
|
|
67
|
+
this.uniqueId = UniqueIdGenerator.UniqueId;
|
|
63
68
|
/**
|
|
64
69
|
* Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)
|
|
65
70
|
*/
|
|
@@ -73,7 +78,7 @@ export class FrameGraph {
|
|
|
73
78
|
this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);
|
|
74
79
|
this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);
|
|
75
80
|
this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);
|
|
76
|
-
this._scene.
|
|
81
|
+
this._scene.addFrameGraph(this);
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
79
84
|
* Gets the class name of the frame graph
|
|
@@ -264,10 +269,7 @@ export class FrameGraph {
|
|
|
264
269
|
this.clear();
|
|
265
270
|
this.textureManager._dispose();
|
|
266
271
|
this._renderContext._dispose();
|
|
267
|
-
|
|
268
|
-
if (index !== -1) {
|
|
269
|
-
this._scene.frameGraphs.splice(index, 1);
|
|
270
|
-
}
|
|
272
|
+
this._scene.removeFrameGraph(this);
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
//# sourceMappingURL=frameGraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,+BAA8B;AAC3D,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAE1C,qDAAoD;AACpD,4DAA2D;AAE3D,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACnB,+DAAU,CAAA;IACV,+DAAU,CAAA;IACV,2DAAQ,CAAA;AACZ,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IA6BnB;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MA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MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.frameGraphs.push(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await new Promise((resolve) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n const index = this._scene.frameGraphs.indexOf(this);\r\n if (index !== -1) {\r\n this._scene.frameGraphs.splice(index, 1);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,+BAA8B;AAC3D,OAAO,EAAE,MAAM,EAAE,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C;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE,CAAC;QAE7C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAEjC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;gBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAElC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene, AbstractEngine, FrameGraphTask, Nullable, NodeRenderGraph } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { _RetryWithInterval } from \"core/Misc/timingTools\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { UniqueIdGenerator } from \"core/Misc/uniqueIdGenerator\";\r\n\r\nimport \"core/Engines/Extensions/engine.multiRender\";\r\nimport \"core/Engines/WebGPU/Extensions/engine.multiRender\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n private _whenReadyAsyncCancel: Nullable<() => void> = null;\r\n\r\n /**\r\n * Name of the frame graph\r\n */\r\n public name = \"Frame Graph\";\r\n\r\n /**\r\n * Gets the unique id of the frame graph\r\n */\r\n public readonly uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that texture allocation should be optimized (that is, reuse existing textures when possible to limit GPU memory usage) (default: true)\r\n */\r\n public optimizeTextureAllocation = true;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the scene used by the frame graph\r\n */\r\n public get scene() {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * Gets the list of tasks in the frame graph\r\n */\r\n public get tasks() {\r\n return this._tasks;\r\n }\r\n\r\n /**\r\n * Gets the node render graph linked to the frame graph (if any)\r\n * @returns the linked node render graph or null if none\r\n */\r\n public getLinkedNodeRenderGraph(): Nullable<NodeRenderGraph> {\r\n return this._linkedNodeRenderGraph;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param scene defines the scene the frame graph is associated with\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector (default is false)\r\n * @param _linkedNodeRenderGraph defines the linked node render graph (if any)\r\n */\r\n constructor(\r\n scene: Scene,\r\n debugTextures = false,\r\n private readonly _linkedNodeRenderGraph: Nullable<NodeRenderGraph> = null\r\n ) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext(this._engine, this.textureManager, scene);\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n\r\n this._scene.addFrameGraph(this);\r\n }\r\n\r\n /**\r\n * Gets the class name of the frame graph\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FrameGraph\";\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Gets all tasks of a specific type\r\n * @param taskType Type of the task(s) to get\r\n * @returns The list of tasks of the specified type\r\n */\r\n public getTasksByType<T extends FrameGraphTask>(taskType: new (...args: any[]) => T): T[] {\r\n return this._tasks.filter((t) => t instanceof taskType) as T[];\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n try {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures(this.optimizeTextureAllocation ? this._tasks : undefined);\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n for (const task of this._tasks) {\r\n task.onTexturesAllocatedObservable.notifyObservers(this._renderContext);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n } catch (e) {\r\n this._tasks.length = 0;\r\n this._currentProcessedTask = null;\r\n this.textureManager._isRecordingTask = false;\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n let firstNotReadyTask: FrameGraphTask | null = null;\r\n return await new Promise((resolve) => {\r\n this._whenReadyAsyncCancel = _RetryWithInterval(\r\n () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n const taskIsReady = task.isReady();\r\n if (!taskIsReady && !firstNotReadyTask) {\r\n firstNotReadyTask = task;\r\n }\r\n ready &&= taskIsReady;\r\n }\r\n return ready;\r\n },\r\n () => {\r\n this._whenReadyAsyncCancel = null;\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n this._whenReadyAsyncCancel = null;\r\n if (!isTimeout) {\r\n Logger.Error(\"FrameGraph: An unexpected error occurred while waiting for the frame graph to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(\r\n `FrameGraph: Timeout while waiting for the frame graph to be ready.${firstNotReadyTask ? ` First task not ready: ${firstNotReadyTask.name}` : \"\"}`\r\n );\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this._whenReadyAsyncCancel?.();\r\n this._whenReadyAsyncCancel = null;\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n\r\n this._scene.removeFrameGraph(this);\r\n }\r\n}\r\n"]}
|
|
@@ -28,7 +28,7 @@ export class _IESTextureLoader {
|
|
|
28
28
|
loadData(data, texture, callback) {
|
|
29
29
|
const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
30
30
|
const textureData = LoadIESData(uint8array);
|
|
31
|
-
callback(textureData.width, textureData.height,
|
|
31
|
+
callback(textureData.width, textureData.height, texture.useMipMaps, false, () => {
|
|
32
32
|
const engine = texture.getEngine();
|
|
33
33
|
texture.type = 1;
|
|
34
34
|
texture.format = 6;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iesTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/iesTextureLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,yCAAkC;AAExD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAA9B;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAiC5C,CAAC;IA/BG;;OAEG;IACI,YAAY;QACf,4CAA4C;QAC5C,MAAM,6BAA6B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACX,IAAqB,EACrB,OAAwB,EACxB,QAA+G;QAE/G,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjF,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QAE5C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"iesTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/iesTextureLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,yCAAkC;AAExD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAA9B;QACI;;WAEG;QACa,oBAAe,GAAG,KAAK,CAAC;IAiC5C,CAAC;IA/BG;;OAEG;IACI,YAAY;QACf,4CAA4C;QAC5C,MAAM,6BAA6B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CACX,IAAqB,EACrB,OAAwB,EACxB,QAA+G;QAE/G,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjF,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QAE5C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;YAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,iBAAiB,CAAC;YAC3C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC;YAC3C,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;YAC5B,MAAM,CAAC,4BAA4B,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../internalTexture\";\r\nimport type { IInternalTextureLoader } from \"./internalTextureLoader\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { LoadIESData } from \"core/Lights/IES/iesLoader\";\r\n\r\n/**\r\n * Implementation of the IES Texture Loader.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class _IESTextureLoader implements IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n public readonly supportCascades = false;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n */\r\n public loadCubeData(): void {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \".ies not supported in Cube.\";\r\n }\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n */\r\n public loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void\r\n ): void {\r\n const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const textureData = LoadIESData(uint8array);\r\n\r\n callback(textureData.width, textureData.height, texture.useMipMaps, false, () => {\r\n const engine = texture.getEngine();\r\n texture.type = Constants.TEXTURETYPE_FLOAT;\r\n texture.format = Constants.TEXTUREFORMAT_R;\r\n texture._gammaSpace = false;\r\n engine._uploadDataToTextureDirectly(texture, textureData.data);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -138,8 +138,9 @@ export declare class ThinTexture {
|
|
|
138
138
|
* > _min_: minification filter (far from the viewer)
|
|
139
139
|
* > _mip_: filter used between mip map levels
|
|
140
140
|
*@param samplingMode Define the new sampling mode of the texture
|
|
141
|
+
*@param generateMipMaps Define if the texture should generate mip maps or not. Default is false.
|
|
141
142
|
*/
|
|
142
|
-
updateSamplingMode(samplingMode: number): void;
|
|
143
|
+
updateSamplingMode(samplingMode: number, generateMipMaps?: boolean): void;
|
|
143
144
|
/**
|
|
144
145
|
* Release and destroy the underlying lower level texture aka internalTexture.
|
|
145
146
|
*/
|
|
@@ -234,10 +234,11 @@ export class ThinTexture {
|
|
|
234
234
|
* > _min_: minification filter (far from the viewer)
|
|
235
235
|
* > _mip_: filter used between mip map levels
|
|
236
236
|
*@param samplingMode Define the new sampling mode of the texture
|
|
237
|
+
*@param generateMipMaps Define if the texture should generate mip maps or not. Default is false.
|
|
237
238
|
*/
|
|
238
|
-
updateSamplingMode(samplingMode) {
|
|
239
|
+
updateSamplingMode(samplingMode, generateMipMaps = false) {
|
|
239
240
|
if (this._texture && this._engine) {
|
|
240
|
-
this._engine.updateTextureSamplingMode(samplingMode, this._texture, this._texture.generateMipMaps);
|
|
241
|
+
this._engine.updateTextureSamplingMode(samplingMode, this._texture, this._texture.generateMipMaps && generateMipMaps);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/thinTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAK7C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAEpB;;;;;;OAMG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAGD;;;;;;OAMG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAuBD;;;OAGG;IACH,IAAW,eAAe;QACtB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,gEAAgE;IAChE,IAAc,MAAM,CAAC,KAAc;QAC/B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,I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,CAAC,UAAU,CAAC;QACvD,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAKD;;OAEG;IACH,IAAW,YAAY;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACI,kBAAkB,CAAC,YAAoB;QAC1C,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACvG,CAAC;IACL,CAAC;IAED;;OAEG;IACI,sBAAsB;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\n\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport { Size } from \"../../Maths/math.size\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { RenderTargetWrapper } from \"core/Engines/renderTargetWrapper\";\r\n\r\n/**\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties required to work with Thin Engine.\r\n */\r\nexport class ThinTexture {\r\n protected _wrapU = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public get wrapU() {\r\n return this._wrapU;\r\n }\r\n\r\n public set wrapU(value: number) {\r\n this._wrapU = value;\r\n }\r\n\r\n protected _wrapV = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public get wrapV() {\r\n return this._wrapV;\r\n }\r\n\r\n public set wrapV(value: number) {\r\n this._wrapV = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public wrapR = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n\r\n /**\r\n * With compliant hardware and browser (supporting anisotropic filtering)\r\n * this defines the level of anisotropic filtering in the texture.\r\n * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.\r\n */\r\n public anisotropicFilteringLevel = 4;\r\n\r\n /**\r\n * Define the current state of the loading sequence when in delayed load mode.\r\n */\r\n public delayLoadState = Constants.DELAYLOADSTATE_NONE;\r\n\r\n /**\r\n * How a texture is mapped.\r\n * Unused in thin texture mode.\r\n */\r\n public get coordinatesMode(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Define if the texture is a cube texture or if false a 2d texture.\r\n */\r\n public get isCube(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.isCube;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set isCube(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.isCube = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.\r\n */\r\n public get is3D(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is3D;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set is3D(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is3D = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.\r\n */\r\n public get is2DArray(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is2DArray;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set is2DArray(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is2DArray = value;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"ThinTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"ThinTexture\";\r\n }\r\n\r\n /** @internal */\r\n public _texture: Nullable<InternalTexture> = null;\r\n\r\n protected _engine: Nullable<AbstractEngine> = null;\r\n\r\n private _cachedSize: ISize = Size.Zero();\r\n private _cachedBaseSize: ISize = Size.Zero();\r\n\r\n private static _IsRenderTargetWrapper(texture: Nullable<InternalTexture> | Nullable<RenderTargetWrapper>): texture is RenderTargetWrapper {\r\n return (texture as RenderTargetWrapper)?.shareDepth !== undefined;\r\n }\r\n\r\n /**\r\n * Instantiates a new ThinTexture.\r\n * Base class of all the textures in babylon.\r\n * This can be used as an internal texture wrapper in AbstractEngine to benefit from the cache\r\n * @param internalTexture Define the internalTexture to wrap. You can also pass a RenderTargetWrapper, in which case the texture will be the render target's texture\r\n */\r\n constructor(internalTexture: Nullable<InternalTexture | RenderTargetWrapper>) {\r\n this._texture = ThinTexture._IsRenderTargetWrapper(internalTexture) ? internalTexture.texture : internalTexture;\r\n if (this._texture) {\r\n this._engine = this._texture.getEngine();\r\n\r\n this.wrapU = this._texture._cachedWrapU ?? this.wrapU;\r\n this.wrapV = this._texture._cachedWrapV ?? this.wrapV;\r\n this.wrapR = this._texture._cachedWrapR ?? this.wrapR;\r\n }\r\n }\r\n\r\n /**\r\n * Get if the texture is ready to be used (downloaded, converted, mip mapped...).\r\n * @returns true if fully ready\r\n */\r\n public isReady(): boolean {\r\n if (this.delayLoadState === Constants.DELAYLOADSTATE_NOTLOADED) {\r\n this.delayLoad();\r\n return false;\r\n }\r\n\r\n if (this._texture) {\r\n return this._texture.isReady;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Triggers the load sequence in delayed load mode.\r\n */\r\n public delayLoad(): void {}\r\n\r\n /**\r\n * Get the underlying lower level texture from Babylon.\r\n * @returns the internal texture\r\n */\r\n public getInternalTexture(): Nullable<InternalTexture> {\r\n return this._texture;\r\n }\r\n\r\n /**\r\n * Get the size of the texture.\r\n * @returns the texture size.\r\n */\r\n public getSize(): ISize {\r\n if (this._texture) {\r\n if (this._texture.width) {\r\n this._cachedSize.width = this._texture.width;\r\n this._cachedSize.height = this._texture.height;\r\n return this._cachedSize;\r\n }\r\n\r\n if (this._texture._size) {\r\n this._cachedSize.width = this._texture._size;\r\n this._cachedSize.height = this._texture._size;\r\n return this._cachedSize;\r\n }\r\n }\r\n\r\n return this._cachedSize;\r\n }\r\n\r\n /**\r\n * Get the base size of the texture.\r\n * It can be different from the size if the texture has been resized for POT for instance\r\n * @returns the base size\r\n */\r\n public getBaseSize(): ISize {\r\n if (!this.isReady() || !this._texture) {\r\n this._cachedBaseSize.width = 0;\r\n this._cachedBaseSize.height = 0;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n if (this._texture._size) {\r\n this._cachedBaseSize.width = this._texture._size;\r\n this._cachedBaseSize.height = this._texture._size;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n this._cachedBaseSize.width = this._texture.baseWidth;\r\n this._cachedBaseSize.height = this._texture.baseHeight;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n /** @internal */\r\n protected _initialSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * Get the current sampling mode associated with the texture.\r\n */\r\n public get samplingMode(): number {\r\n if (!this._texture) {\r\n return this._initialSamplingMode;\r\n }\r\n\r\n return this._texture.samplingMode;\r\n }\r\n\r\n /**\r\n * Update the sampling mode of the texture.\r\n * Default is Trilinear mode.\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |\r\n * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |\r\n * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |\r\n * | 4 | NEAREST_NEAREST_MIPNEAREST | |\r\n * | 5 | NEAREST_LINEAR_MIPNEAREST | |\r\n * | 6 | NEAREST_LINEAR_MIPLINEAR | |\r\n * | 7 | NEAREST_LINEAR | |\r\n * | 8 | NEAREST_NEAREST | |\r\n * | 9 | LINEAR_NEAREST_MIPNEAREST | |\r\n * | 10 | LINEAR_NEAREST_MIPLINEAR | |\r\n * | 11 | LINEAR_LINEAR | |\r\n * | 12 | LINEAR_NEAREST | |\r\n *\r\n * > _mag_: magnification filter (close to the viewer)\r\n * > _min_: minification filter (far from the viewer)\r\n * > _mip_: filter used between mip map levels\r\n *@param samplingMode Define the new sampling mode of the texture\r\n */\r\n public updateSamplingMode(samplingMode: number): void {\r\n if (this._texture && this._engine) {\r\n this._engine.updateTextureSamplingMode(samplingMode, this._texture, this._texture.generateMipMaps);\r\n }\r\n }\r\n\r\n /**\r\n * Release and destroy the underlying lower level texture aka internalTexture.\r\n */\r\n public releaseInternalTexture(): void {\r\n if (this._texture) {\r\n this._texture.dispose();\r\n this._texture = null;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n if (this._texture) {\r\n this.releaseInternalTexture();\r\n this._engine = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"thinTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/thinTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAK7C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAEpB;;;;;;OAMG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAGD;;;;;;OAMG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAuBD;;;OAGG;IACH,IAAW,eAAe;QACtB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,gEAAgE;IAChE,IAAc,MAAM,CAAC,KAAc;QAC/B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;IACj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M,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACvD,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAKD;;OAEG;IACH,IAAW,YAAY;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,kBAAkB,CAAC,YAAoB,EAAE,eAAe,GAAG,KAAK;QACnE,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe,IAAI,eAAe,CAAC,CAAC;QAC1H,CAAC;IACL,CAAC;IAED;;OAEG;IACI,sBAAsB;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\n\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport { Size } from \"../../Maths/math.size\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { RenderTargetWrapper } from \"core/Engines/renderTargetWrapper\";\r\n\r\n/**\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties required to work with Thin Engine.\r\n */\r\nexport class ThinTexture {\r\n protected _wrapU = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public get wrapU() {\r\n return this._wrapU;\r\n }\r\n\r\n public set wrapU(value: number) {\r\n this._wrapU = value;\r\n }\r\n\r\n protected _wrapV = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public get wrapV() {\r\n return this._wrapV;\r\n }\r\n\r\n public set wrapV(value: number) {\r\n this._wrapV = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n public wrapR = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n\r\n /**\r\n * With compliant hardware and browser (supporting anisotropic filtering)\r\n * this defines the level of anisotropic filtering in the texture.\r\n * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.\r\n */\r\n public anisotropicFilteringLevel = 4;\r\n\r\n /**\r\n * Define the current state of the loading sequence when in delayed load mode.\r\n */\r\n public delayLoadState = Constants.DELAYLOADSTATE_NONE;\r\n\r\n /**\r\n * How a texture is mapped.\r\n * Unused in thin texture mode.\r\n */\r\n public get coordinatesMode(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Define if the texture is a cube texture or if false a 2d texture.\r\n */\r\n public get isCube(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.isCube;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set isCube(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.isCube = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.\r\n */\r\n public get is3D(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is3D;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set is3D(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is3D = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.\r\n */\r\n public get is2DArray(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is2DArray;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected set is2DArray(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is2DArray = value;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"ThinTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"ThinTexture\";\r\n }\r\n\r\n /** @internal */\r\n public _texture: Nullable<InternalTexture> = null;\r\n\r\n protected _engine: Nullable<AbstractEngine> = null;\r\n\r\n private _cachedSize: ISize = Size.Zero();\r\n private _cachedBaseSize: ISize = Size.Zero();\r\n\r\n private static _IsRenderTargetWrapper(texture: Nullable<InternalTexture> | Nullable<RenderTargetWrapper>): texture is RenderTargetWrapper {\r\n return (texture as RenderTargetWrapper)?.shareDepth !== undefined;\r\n }\r\n\r\n /**\r\n * Instantiates a new ThinTexture.\r\n * Base class of all the textures in babylon.\r\n * This can be used as an internal texture wrapper in AbstractEngine to benefit from the cache\r\n * @param internalTexture Define the internalTexture to wrap. You can also pass a RenderTargetWrapper, in which case the texture will be the render target's texture\r\n */\r\n constructor(internalTexture: Nullable<InternalTexture | RenderTargetWrapper>) {\r\n this._texture = ThinTexture._IsRenderTargetWrapper(internalTexture) ? internalTexture.texture : internalTexture;\r\n if (this._texture) {\r\n this._engine = this._texture.getEngine();\r\n\r\n this.wrapU = this._texture._cachedWrapU ?? this.wrapU;\r\n this.wrapV = this._texture._cachedWrapV ?? this.wrapV;\r\n this.wrapR = this._texture._cachedWrapR ?? this.wrapR;\r\n }\r\n }\r\n\r\n /**\r\n * Get if the texture is ready to be used (downloaded, converted, mip mapped...).\r\n * @returns true if fully ready\r\n */\r\n public isReady(): boolean {\r\n if (this.delayLoadState === Constants.DELAYLOADSTATE_NOTLOADED) {\r\n this.delayLoad();\r\n return false;\r\n }\r\n\r\n if (this._texture) {\r\n return this._texture.isReady;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Triggers the load sequence in delayed load mode.\r\n */\r\n public delayLoad(): void {}\r\n\r\n /**\r\n * Get the underlying lower level texture from Babylon.\r\n * @returns the internal texture\r\n */\r\n public getInternalTexture(): Nullable<InternalTexture> {\r\n return this._texture;\r\n }\r\n\r\n /**\r\n * Get the size of the texture.\r\n * @returns the texture size.\r\n */\r\n public getSize(): ISize {\r\n if (this._texture) {\r\n if (this._texture.width) {\r\n this._cachedSize.width = this._texture.width;\r\n this._cachedSize.height = this._texture.height;\r\n return this._cachedSize;\r\n }\r\n\r\n if (this._texture._size) {\r\n this._cachedSize.width = this._texture._size;\r\n this._cachedSize.height = this._texture._size;\r\n return this._cachedSize;\r\n }\r\n }\r\n\r\n return this._cachedSize;\r\n }\r\n\r\n /**\r\n * Get the base size of the texture.\r\n * It can be different from the size if the texture has been resized for POT for instance\r\n * @returns the base size\r\n */\r\n public getBaseSize(): ISize {\r\n if (!this.isReady() || !this._texture) {\r\n this._cachedBaseSize.width = 0;\r\n this._cachedBaseSize.height = 0;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n if (this._texture._size) {\r\n this._cachedBaseSize.width = this._texture._size;\r\n this._cachedBaseSize.height = this._texture._size;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n this._cachedBaseSize.width = this._texture.baseWidth;\r\n this._cachedBaseSize.height = this._texture.baseHeight;\r\n return this._cachedBaseSize;\r\n }\r\n\r\n /** @internal */\r\n protected _initialSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * Get the current sampling mode associated with the texture.\r\n */\r\n public get samplingMode(): number {\r\n if (!this._texture) {\r\n return this._initialSamplingMode;\r\n }\r\n\r\n return this._texture.samplingMode;\r\n }\r\n\r\n /**\r\n * Update the sampling mode of the texture.\r\n * Default is Trilinear mode.\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |\r\n * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |\r\n * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |\r\n * | 4 | NEAREST_NEAREST_MIPNEAREST | |\r\n * | 5 | NEAREST_LINEAR_MIPNEAREST | |\r\n * | 6 | NEAREST_LINEAR_MIPLINEAR | |\r\n * | 7 | NEAREST_LINEAR | |\r\n * | 8 | NEAREST_NEAREST | |\r\n * | 9 | LINEAR_NEAREST_MIPNEAREST | |\r\n * | 10 | LINEAR_NEAREST_MIPLINEAR | |\r\n * | 11 | LINEAR_LINEAR | |\r\n * | 12 | LINEAR_NEAREST | |\r\n *\r\n * > _mag_: magnification filter (close to the viewer)\r\n * > _min_: minification filter (far from the viewer)\r\n * > _mip_: filter used between mip map levels\r\n *@param samplingMode Define the new sampling mode of the texture\r\n *@param generateMipMaps Define if the texture should generate mip maps or not. Default is false.\r\n */\r\n public updateSamplingMode(samplingMode: number, generateMipMaps = false): void {\r\n if (this._texture && this._engine) {\r\n this._engine.updateTextureSamplingMode(samplingMode, this._texture, this._texture.generateMipMaps && generateMipMaps);\r\n }\r\n }\r\n\r\n /**\r\n * Release and destroy the underlying lower level texture aka internalTexture.\r\n */\r\n public releaseInternalTexture(): void {\r\n if (this._texture) {\r\n this._texture.dispose();\r\n this._texture = null;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n if (this._texture) {\r\n this.releaseInternalTexture();\r\n this._engine = null;\r\n }\r\n }\r\n}\r\n"]}
|
package/Meshes/transformNode.js
CHANGED
|
@@ -1015,7 +1015,8 @@ export class TransformNode extends Node {
|
|
|
1015
1015
|
this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
|
|
1016
1016
|
// Get camera view matrix
|
|
1017
1017
|
TmpVectors.Matrix[1].copyFrom(camera.getViewMatrix());
|
|
1018
|
-
|
|
1018
|
+
const isRH = this.getScene().useRightHandedSystem;
|
|
1019
|
+
if (isRH) {
|
|
1019
1020
|
// This operation is necessary to cancel out the scaling component of the matrix without decomposing it.
|
|
1020
1021
|
// It's a trick to extract only the rotation part.
|
|
1021
1022
|
TmpVectors.Matrix[1].multiplyToRef(TransformNode._TmpRHRestore, TmpVectors.Matrix[1]);
|
|
@@ -1036,6 +1037,9 @@ export class TransformNode extends Node {
|
|
|
1036
1037
|
if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
|
|
1037
1038
|
eulerAngles.z = 0;
|
|
1038
1039
|
}
|
|
1040
|
+
if (isRH) {
|
|
1041
|
+
eulerAngles.y += Math.PI; // Yaw correction
|
|
1042
|
+
}
|
|
1039
1043
|
Matrix.RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, TmpVectors.Matrix[0]);
|
|
1040
1044
|
}
|
|
1041
1045
|
this._worldMatrix.setTranslationFromFloats(0, 0, 0);
|