@onerjs/core 8.30.4 → 8.30.6
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/Actions/action.d.ts +5 -0
- package/Actions/action.js.map +1 -1
- package/Actions/actionManager.js +6 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +0 -2
- package/Animations/runtimeAnimation.js +3 -5
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.d.ts +9 -5
- package/Audio/audioSceneComponent.js +1 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +1 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +8 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +10 -5
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/camera.d.ts +4 -0
- package/Cameras/camera.js +18 -9
- package/Cameras/camera.js.map +1 -1
- package/Collisions/gpuPicker.js +0 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +3 -1
- package/Decorators/nodeDecorator.js +2 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -13
- package/Engines/nativeEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
- package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
- package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -1
- package/FrameGraph/Passes/pass.js +11 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -1
- package/FrameGraph/frameGraph.js +3 -6
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +8 -1
- package/FrameGraph/frameGraphContext.js +9 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
- package/FrameGraph/frameGraphRenderContext.js +11 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +11 -2
- package/FrameGraph/frameGraphTask.js +17 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +2 -2
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Lights/directionalLight.js +1 -4
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/pointLight.js +2 -5
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +4 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +8 -0
- package/Materials/materialHelper.functions.js +31 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +21 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +55 -16
- package/Maths/math.vector.functions.js +68 -10
- package/Maths/math.vector.functions.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +10 -0
- package/Misc/copyTextureToTexture.js +15 -0
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/decorators.d.ts +1 -1
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.d.ts +20 -0
- package/Misc/dumpTools.js +60 -49
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/index.d.ts +1 -2
- package/Misc/index.js +1 -2
- package/Misc/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
- package/Particles/Node/Blocks/Emitters/index.js +5 -4
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
- package/Particles/Node/Blocks/systemBlock.js +82 -3
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +12 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
- package/Particles/Node/nodeParticleSystemSet.helper.js +344 -112
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
- package/Physics/v2/Plugins/havokPlugin.js +73 -9
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +12 -2
- package/Physics/v2/physicsEngine.js +15 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
- package/PostProcesses/thinSSAO2PostProcess.js +18 -6
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/particles.vertex.js +1 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/picking.fragment.js +1 -1
- package/Shaders/picking.fragment.js.map +1 -1
- package/Shaders/picking.vertex.js +1 -1
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -4
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +1 -1
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +1 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +1 -1
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +10 -8
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +8 -0
- package/XR/features/WebXRLightEstimation.js +6 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/assetContainer.d.ts +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +7 -2
- package/scene.js +11 -8
- package/scene.js.map +1 -1
|
@@ -1,27 +1,52 @@
|
|
|
1
1
|
import type { DeepImmutable } from "../types.js";
|
|
2
|
-
import type { IVector2Like, IVector3Like } from "./math.like.js";
|
|
2
|
+
import type { IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from "./math.like.js";
|
|
3
3
|
import { Quaternion, Vector3 } from "./math.vector.js";
|
|
4
|
-
import type { Vector4 } from "./math.vector.js";
|
|
5
4
|
/**
|
|
6
5
|
* Creates a string representation of the IVector2Like
|
|
7
6
|
* @param vector defines the IVector2Like to stringify
|
|
8
7
|
* @param decimalCount defines the number of decimals to use
|
|
9
8
|
* @returns a string with the IVector2Like coordinates.
|
|
10
9
|
*/
|
|
11
|
-
export declare function Vector2ToFixed(vector: IVector2Like
|
|
10
|
+
export declare function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string;
|
|
12
11
|
/**
|
|
13
12
|
* Computes the dot product of two IVector3Like objects.
|
|
14
13
|
* @param a defines the first vector
|
|
15
14
|
* @param b defines the second vector
|
|
16
15
|
* @returns the dot product
|
|
17
16
|
*/
|
|
18
|
-
export declare function Vector3Dot
|
|
17
|
+
export declare function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
18
|
+
/**
|
|
19
|
+
* Computes the squared length of the IVector3Like
|
|
20
|
+
* @param vector the vector to measure
|
|
21
|
+
* @returns the squared length of the vector
|
|
22
|
+
*/
|
|
23
|
+
export declare function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number;
|
|
24
|
+
/**
|
|
25
|
+
* Computes the length of the IVector3Like
|
|
26
|
+
* @param vector the vector to measure
|
|
27
|
+
* @returns the length of the vector
|
|
28
|
+
*/
|
|
29
|
+
export declare function Vector3Length(vector: DeepImmutable<IVector3Like>): number;
|
|
30
|
+
/**
|
|
31
|
+
* Computes the squared distance between the IVector3Like objects
|
|
32
|
+
* @param a defines the first vector
|
|
33
|
+
* @param b defines the second vector
|
|
34
|
+
* @returns the squared distance
|
|
35
|
+
*/
|
|
36
|
+
export declare function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
37
|
+
/**
|
|
38
|
+
* Computes the distance between the IVector3Like objects
|
|
39
|
+
* @param a defines the first vector
|
|
40
|
+
* @param b defines the second vector
|
|
41
|
+
* @returns the distance
|
|
42
|
+
*/
|
|
43
|
+
export declare function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
19
44
|
/**
|
|
20
45
|
* Sets the given floats into the result.
|
|
21
46
|
* @param x defines the x coordinate
|
|
22
47
|
* @param y defines the y coordinate
|
|
23
48
|
* @param z defines the z coordinate
|
|
24
|
-
* @param result defines the
|
|
49
|
+
* @param result defines the result vector
|
|
25
50
|
* @returns the result vector
|
|
26
51
|
*/
|
|
27
52
|
export declare function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T;
|
|
@@ -29,31 +54,45 @@ export declare function Vector3FromFloatsToRef<T extends IVector3Like>(x: number
|
|
|
29
54
|
* Stores the scaled values of a vector into the result.
|
|
30
55
|
* @param a defines the source vector
|
|
31
56
|
* @param scale defines the scale factor
|
|
32
|
-
* @param result defines the
|
|
57
|
+
* @param result defines the result vector
|
|
58
|
+
* @returns the scaled vector
|
|
59
|
+
*/
|
|
60
|
+
export declare function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T;
|
|
61
|
+
/**
|
|
62
|
+
* Scales the current vector values in place by a factor.
|
|
63
|
+
* @param vector defines the vector to scale
|
|
64
|
+
* @param scale defines the scale factor
|
|
33
65
|
* @returns the scaled vector
|
|
34
66
|
*/
|
|
35
|
-
export declare function
|
|
67
|
+
export declare function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T;
|
|
36
68
|
/**
|
|
37
|
-
* Creates a string representation of the
|
|
38
|
-
* @param vector defines the
|
|
69
|
+
* Creates a string representation of the IVector3Like
|
|
70
|
+
* @param vector defines the IVector3Like to stringify
|
|
39
71
|
* @param decimalCount defines the number of decimals to use
|
|
40
|
-
* @returns a string with the
|
|
72
|
+
* @returns a string with the IVector3Like coordinates.
|
|
73
|
+
*/
|
|
74
|
+
export declare function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string;
|
|
75
|
+
/**
|
|
76
|
+
* Computes the dot product of two IVector4Like objects
|
|
77
|
+
* @param a defines the first vector
|
|
78
|
+
* @param b defines the second vector
|
|
79
|
+
* @returns the dot product
|
|
41
80
|
*/
|
|
42
|
-
export declare function
|
|
81
|
+
export declare function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number;
|
|
43
82
|
/**
|
|
44
|
-
* Creates a string representation of the
|
|
45
|
-
* @param vector defines the
|
|
83
|
+
* Creates a string representation of the IVector4Like
|
|
84
|
+
* @param vector defines the IVector4Like to stringify
|
|
46
85
|
* @param decimalCount defines the number of decimals to use
|
|
47
|
-
* @returns a string with the
|
|
86
|
+
* @returns a string with the IVector4Like coordinates.
|
|
48
87
|
*/
|
|
49
|
-
export declare function Vector4ToFixed(vector:
|
|
88
|
+
export declare function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string;
|
|
50
89
|
/**
|
|
51
90
|
* Returns the angle in radians between two quaternions
|
|
52
91
|
* @param q1 defines the first quaternion
|
|
53
92
|
* @param q2 defines the second quaternion
|
|
54
93
|
* @returns the angle in radians between the two quaternions
|
|
55
94
|
*/
|
|
56
|
-
export declare function GetAngleBetweenQuaternions(q1: DeepImmutable<
|
|
95
|
+
export declare function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number;
|
|
57
96
|
/**
|
|
58
97
|
* Creates a quaternion from two direction vectors
|
|
59
98
|
* @param a defines the first direction vector
|
|
@@ -18,12 +18,49 @@ export function Vector2ToFixed(vector, decimalCount) {
|
|
|
18
18
|
export function Vector3Dot(a, b) {
|
|
19
19
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Computes the squared length of the IVector3Like
|
|
23
|
+
* @param vector the vector to measure
|
|
24
|
+
* @returns the squared length of the vector
|
|
25
|
+
*/
|
|
26
|
+
export function Vector3LengthSquared(vector) {
|
|
27
|
+
return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Computes the length of the IVector3Like
|
|
31
|
+
* @param vector the vector to measure
|
|
32
|
+
* @returns the length of the vector
|
|
33
|
+
*/
|
|
34
|
+
export function Vector3Length(vector) {
|
|
35
|
+
return Math.sqrt(Vector3LengthSquared(vector));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Computes the squared distance between the IVector3Like objects
|
|
39
|
+
* @param a defines the first vector
|
|
40
|
+
* @param b defines the second vector
|
|
41
|
+
* @returns the squared distance
|
|
42
|
+
*/
|
|
43
|
+
export function Vector3DistanceSquared(a, b) {
|
|
44
|
+
const x = b.x - a.x;
|
|
45
|
+
const y = b.y - a.y;
|
|
46
|
+
const z = b.z - a.z;
|
|
47
|
+
return x * x + y * y + z * z;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Computes the distance between the IVector3Like objects
|
|
51
|
+
* @param a defines the first vector
|
|
52
|
+
* @param b defines the second vector
|
|
53
|
+
* @returns the distance
|
|
54
|
+
*/
|
|
55
|
+
export function Vector3Distance(a, b) {
|
|
56
|
+
return Math.sqrt(Vector3DistanceSquared(a, b));
|
|
57
|
+
}
|
|
21
58
|
/**
|
|
22
59
|
* Sets the given floats into the result.
|
|
23
60
|
* @param x defines the x coordinate
|
|
24
61
|
* @param y defines the y coordinate
|
|
25
62
|
* @param z defines the z coordinate
|
|
26
|
-
* @param result defines the
|
|
63
|
+
* @param result defines the result vector
|
|
27
64
|
* @returns the result vector
|
|
28
65
|
*/
|
|
29
66
|
export function Vector3FromFloatsToRef(x, y, z, result) {
|
|
@@ -36,7 +73,7 @@ export function Vector3FromFloatsToRef(x, y, z, result) {
|
|
|
36
73
|
* Stores the scaled values of a vector into the result.
|
|
37
74
|
* @param a defines the source vector
|
|
38
75
|
* @param scale defines the scale factor
|
|
39
|
-
* @param result defines the
|
|
76
|
+
* @param result defines the result vector
|
|
40
77
|
* @returns the scaled vector
|
|
41
78
|
*/
|
|
42
79
|
export function Vector3ScaleToRef(a, scale, result) {
|
|
@@ -46,19 +83,40 @@ export function Vector3ScaleToRef(a, scale, result) {
|
|
|
46
83
|
return result;
|
|
47
84
|
}
|
|
48
85
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param vector defines the
|
|
86
|
+
* Scales the current vector values in place by a factor.
|
|
87
|
+
* @param vector defines the vector to scale
|
|
88
|
+
* @param scale defines the scale factor
|
|
89
|
+
* @returns the scaled vector
|
|
90
|
+
*/
|
|
91
|
+
export function Vector3ScaleInPlace(vector, scale) {
|
|
92
|
+
vector.x *= scale;
|
|
93
|
+
vector.y *= scale;
|
|
94
|
+
vector.z *= scale;
|
|
95
|
+
return vector;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a string representation of the IVector3Like
|
|
99
|
+
* @param vector defines the IVector3Like to stringify
|
|
51
100
|
* @param decimalCount defines the number of decimals to use
|
|
52
|
-
* @returns a string with the
|
|
101
|
+
* @returns a string with the IVector3Like coordinates.
|
|
53
102
|
*/
|
|
54
103
|
export function Vector3ToFixed(vector, decimalCount) {
|
|
55
|
-
return `{X: ${vector.
|
|
104
|
+
return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Computes the dot product of two IVector4Like objects
|
|
108
|
+
* @param a defines the first vector
|
|
109
|
+
* @param b defines the second vector
|
|
110
|
+
* @returns the dot product
|
|
111
|
+
*/
|
|
112
|
+
export function Vector4Dot(a, b) {
|
|
113
|
+
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
|
56
114
|
}
|
|
57
115
|
/**
|
|
58
|
-
* Creates a string representation of the
|
|
59
|
-
* @param vector defines the
|
|
116
|
+
* Creates a string representation of the IVector4Like
|
|
117
|
+
* @param vector defines the IVector4Like to stringify
|
|
60
118
|
* @param decimalCount defines the number of decimals to use
|
|
61
|
-
* @returns a string with the
|
|
119
|
+
* @returns a string with the IVector4Like coordinates.
|
|
62
120
|
*/
|
|
63
121
|
export function Vector4ToFixed(vector, decimalCount) {
|
|
64
122
|
return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;
|
|
@@ -70,7 +128,7 @@ export function Vector4ToFixed(vector, decimalCount) {
|
|
|
70
128
|
* @returns the angle in radians between the two quaternions
|
|
71
129
|
*/
|
|
72
130
|
export function GetAngleBetweenQuaternions(q1, q2) {
|
|
73
|
-
return Math.acos(Clamp(
|
|
131
|
+
return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;
|
|
74
132
|
}
|
|
75
133
|
/**
|
|
76
134
|
* Creates a quaternion from two direction vectors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAoB,EAAE,YAAoB;IACrE,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAiD,CAAmB,EAAE,CAAmB;IAC/G,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAyB,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,MAAS;IACrG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAuD,CAAmB,EAAE,KAAa,EAAE,MAAe;IACvI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KA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KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { Clamp } from \"./math.scalar.functions\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { IVector2Like, IVector3Like } from \"./math.like\";\r\nimport { Quaternion, Vector3 } from \"./math.vector\";\r\nimport type { Vector4 } from \"./math.vector\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: IVector2Like, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot<T extends IVector3Like, U extends IVector3Like>(a: DeepImmutable<T>, b: DeepImmutable<U>) {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the target vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the target vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like, ResultT extends IVector3Like>(a: DeepImmutable<T>, scale: number, result: ResultT): ResultT {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the Vector3\r\n * @param vector defines the Vector3 to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the Vector3 coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: Vector3, decimalCount: number): string {\r\n return `{X: ${vector._x.toFixed(decimalCount)} Y: ${vector._y.toFixed(decimalCount)} Z: ${vector._z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the Vector4\r\n * @param vector defines the Vector4 to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the Vector4 coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: Vector4, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Returns the angle in radians between two quaternions\r\n * @param q1 defines the first quaternion\r\n * @param q2 defines the second quaternion\r\n * @returns the angle in radians between the two quaternions\r\n */\r\nexport function GetAngleBetweenQuaternions(q1: DeepImmutable<Quaternion>, q2: DeepImmutable<Quaternion>): number {\r\n return Math.acos(Clamp(Quaternion.Dot(q1, q2))) * 2;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion {\r\n const result = new Quaternion();\r\n GetQuaternionFromDirectionsToRef(a, b, result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @param result defines the target quaternion\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT {\r\n const axis = Vector3.Cross(a, b);\r\n const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));\r\n Quaternion.RotationAxisToRef(axis, angle, result);\r\n return result;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAmC;IACpE,OAAO,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAmC;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CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAoB,CAAmB,EAAE,CAAmB;IACnG,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,gCAAgC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAgD,CAAmB,EAAE,CAAmB,EAAE,MAAe;IACrJ,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { Clamp } from \"./math.scalar.functions\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\nimport { Quaternion, Vector3 } from \"./math.vector\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the result vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the result vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n return vector;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Returns the angle in radians between two quaternions\r\n * @param q1 defines the first quaternion\r\n * @param q2 defines the second quaternion\r\n * @returns the angle in radians between the two quaternions\r\n */\r\nexport function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number {\r\n return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion {\r\n const result = new Quaternion();\r\n GetQuaternionFromDirectionsToRef(a, b, result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @param result defines the target quaternion\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT {\r\n const axis = Vector3.Cross(a, b);\r\n const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));\r\n Quaternion.RotationAxisToRef(axis, angle, result);\r\n return result;\r\n}\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
2
2
|
import type { InternalTexture } from "../Materials/Textures/internalTexture.js";
|
|
3
|
+
import { EffectWrapper } from "../Materials/effectRenderer.js";
|
|
3
4
|
import type { IRenderTargetTexture, RenderTargetWrapper } from "../Engines/renderTargetWrapper.js";
|
|
4
5
|
import type { ThinTexture } from "../Materials/Textures/thinTexture.js";
|
|
5
6
|
import type { Nullable } from "../types.js";
|
|
@@ -28,6 +29,15 @@ export declare class CopyTextureToTexture {
|
|
|
28
29
|
* Gets the shader language
|
|
29
30
|
*/
|
|
30
31
|
get shaderLanguage(): ShaderLanguage;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the effect wrapper used for the copy
|
|
34
|
+
*/
|
|
35
|
+
get effectWrapper(): EffectWrapper;
|
|
36
|
+
/**
|
|
37
|
+
* Gets or sets the source texture
|
|
38
|
+
*/
|
|
39
|
+
get source(): InternalTexture | ThinTexture;
|
|
40
|
+
set source(texture: InternalTexture | ThinTexture);
|
|
31
41
|
private _textureIsInternal;
|
|
32
42
|
/**
|
|
33
43
|
* Constructs a new instance of the class
|
|
@@ -19,6 +19,21 @@ export class CopyTextureToTexture {
|
|
|
19
19
|
get shaderLanguage() {
|
|
20
20
|
return this._shaderLanguage;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the effect wrapper used for the copy
|
|
24
|
+
*/
|
|
25
|
+
get effectWrapper() {
|
|
26
|
+
return this._effectWrapper;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gets or sets the source texture
|
|
30
|
+
*/
|
|
31
|
+
get source() {
|
|
32
|
+
return this._source;
|
|
33
|
+
}
|
|
34
|
+
set source(texture) {
|
|
35
|
+
this._source = texture;
|
|
36
|
+
}
|
|
22
37
|
_textureIsInternal(texture) {
|
|
23
38
|
return texture.getInternalTexture === undefined;
|
|
24
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;;OAKG;I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,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACxD,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,+EAA+E;QAErI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAExD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,OAAsC;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK;QAtChF,2BAA2B;QACjB,oBAAe,+BAAuB;QA+CxC,mBAAc,GAAG,KAAK,CAAC;QAT3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5C,mEAAmE;QACnE,IAAI,CAAC,sBAAsB,CAAC,c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eAAe,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
|
package/Misc/decorators.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function serializeAsCameraReference(sourceName?: string): (target
|
|
|
22
22
|
* Decorator used to redirect a function to a native implementation if available.
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
|
-
export declare function nativeOverride<T extends (...params: any[]) => boolean>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) =>
|
|
25
|
+
export declare function nativeOverride<T extends (...params: any[]) => boolean>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => any>, predicate?: T): void;
|
|
26
26
|
export declare namespace nativeOverride {
|
|
27
27
|
var filter: <T extends (...params: any) => boolean>(predicate: T) => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>) => void;
|
|
28
28
|
}
|
package/Misc/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,SAAS,0BAA0B,CAAC,IAAY,EAAE,UAAmB;IACjE,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,EAAE;QACjD,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3B,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QACrE,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED,SAAS,oBAAoB,CAAC,WAAmB,EAAE,YAA8B,IAAI;IACjF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACxC,MAAM,GAAG,GAAG,SAAS,IAAI,GAAG,GAAG,WAAW,CAAC;QAC3C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;YACvC,GAAG,EAAE;gBACD,+DAA+D;gBAC/D,OAAO,IAAI,C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CAAC;QAC/B,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;YAClC,GAAG,EAAE;gBACD,+DAA+D;gBAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YAC3B,CAAC;YACD,GAAG,EAAE,UAAqB,KAAK;gBAC3B,kEAAkE;gBAClE,+FAA+F;gBAC/F,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;oBACjD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBAChC,OAAO;oBACX,CAAC;gBACL,CAAC;gBACD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;oBAC5B,OAAO;gBACX,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;gBAExB,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { GetDirectStore } from \"./decorators.functions\";\r\nimport { _WarnImport } from \"./devTools\";\r\n\r\nfunction generateSerializableMember(type: number, sourceName?: string) {\r\n return (target: any, propertyKey: string | symbol) => {\r\n const classStore = GetDirectStore(target);\r\n\r\n if (!classStore[propertyKey]) {\r\n classStore[propertyKey] = { type: type, sourceName: sourceName };\r\n }\r\n };\r\n}\r\n\r\nfunction generateExpandMember(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = targetKey || \"_\" + propertyKey;\r\n Object.defineProperty(target, propertyKey, {\r\n get: function (this: any) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this[key];\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this[key]?.equals === \"function\") {\r\n if (this[key].equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key] === value) {\r\n return;\r\n }\r\n this[key] = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n\r\nexport function expandToProperty(callback: string, targetKey: Nullable<string> = null) {\r\n return generateExpandMember(callback, targetKey);\r\n}\r\n\r\nexport function serialize(sourceName?: string) {\r\n return generateSerializableMember(0, sourceName); // value member\r\n}\r\n\r\nexport function serializeAsTexture(sourceName?: string) {\r\n return generateSerializableMember(1, sourceName); // texture member\r\n}\r\n\r\nexport function serializeAsColor3(sourceName?: string) {\r\n return generateSerializableMember(2, sourceName); // color3 member\r\n}\r\n\r\nexport function serializeAsFresnelParameters(sourceName?: string) {\r\n return generateSerializableMember(3, sourceName); // fresnel parameters member\r\n}\r\n\r\nexport function serializeAsVector2(sourceName?: string) {\r\n return generateSerializableMember(4, sourceName); // vector2 member\r\n}\r\n\r\nexport function serializeAsVector3(sourceName?: string) {\r\n return generateSerializableMember(5, sourceName); // vector3 member\r\n}\r\n\r\nexport function serializeAsMeshReference(sourceName?: string) {\r\n return generateSerializableMember(6, sourceName); // mesh reference member\r\n}\r\n\r\nexport function serializeAsColorCurves(sourceName?: string) {\r\n return generateSerializableMember(7, sourceName); // color curves\r\n}\r\n\r\nexport function serializeAsColor4(sourceName?: string) {\r\n return generateSerializableMember(8, sourceName); // color 4\r\n}\r\n\r\nexport function serializeAsImageProcessingConfiguration(sourceName?: string) {\r\n return generateSerializableMember(9, sourceName); // image processing\r\n}\r\n\r\nexport function serializeAsQuaternion(sourceName?: string) {\r\n return generateSerializableMember(10, sourceName); // quaternion member\r\n}\r\n\r\nexport function serializeAsMatrix(sourceName?: string) {\r\n return generateSerializableMember(12, sourceName); // matrix member\r\n}\r\n\r\n/**\r\n * Decorator used to define property that can be serialized as reference to a camera\r\n * @param sourceName defines the name of the property to decorate\r\n * @returns Property Decorator\r\n */\r\nexport function serializeAsCameraReference(sourceName?: string) {\r\n return generateSerializableMember(11, sourceName); // camera reference member\r\n}\r\n\r\n/** @internal */\r\ndeclare const _native: any;\r\n\r\n/**\r\n * Decorator used to redirect a function to a native implementation if available.\r\n * @internal\r\n */\r\nexport function nativeOverride<T extends (...params: any[]) => boolean>(\r\n target: any,\r\n propertyKey: string,\r\n descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>,\r\n predicate?: T\r\n) {\r\n // Cache the original JS function for later.\r\n const jsFunc = descriptor.value!;\r\n\r\n // Override the JS function to check for a native override on first invocation. Setting descriptor.value overrides the function at the early stage of code being loaded/imported.\r\n descriptor.value = (...params: Parameters<T>): unknown => {\r\n // Assume the resolved function will be the original JS function, then we will check for the Babylon Native context.\r\n let func = jsFunc;\r\n\r\n // Check if we are executing in a Babylon Native context (e.g. check the presence of the _native global property) and if so also check if a function override is available.\r\n if (typeof _native !== \"undefined\" && _native[propertyKey]) {\r\n const nativeFunc = _native[propertyKey] as (...params: Parameters<T>) => unknown;\r\n // If a predicate was provided, then we'll need to invoke the predicate on each invocation of the underlying function to determine whether to call the native function or the JS function.\r\n if (predicate) {\r\n // The resolved function will execute the predicate and then either execute the native function or the JS function.\r\n func = (...params: Parameters<T>) => (predicate(...params) ? nativeFunc(...params) : jsFunc(...params));\r\n } else {\r\n // The resolved function will directly execute the native function.\r\n func = nativeFunc;\r\n }\r\n }\r\n\r\n // Override the JS function again with the final resolved target function.\r\n target[propertyKey] = func;\r\n\r\n // The JS function has now been overridden based on whether we're executing in the context of Babylon Native, but we still need to invoke that function.\r\n // Future invocations of the function will just directly invoke the final overridden function, not any of the decorator setup logic above.\r\n return func(...params);\r\n };\r\n}\r\n\r\n/**\r\n * Decorator factory that applies the nativeOverride decorator, but determines whether to redirect to the native implementation based on a filter function that evaluates the function arguments.\r\n * @param predicate\r\n * @example @nativeOverride.filter((...[arg1]: Parameters<typeof someClass.someMethod>) => arg1.length > 20)\r\n * public someMethod(arg1: string, arg2: number): string {\r\n * @internal\r\n */\r\nnativeOverride.filter = function <T extends (...params: any) => boolean>(predicate: T) {\r\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>) =>\r\n nativeOverride(target, propertyKey, descriptor, predicate);\r\n};\r\n\r\n/**\r\n * Adds accessors for a material property.\r\n * @param setCallback - The name of the callback function to call when the property is set.\r\n * @param targetKey - The key to use for the target property (defaults to the original property key).\r\n * @returns A property decorator.\r\n */\r\nexport function addAccessorsForMaterialProperty(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = propertyKey;\r\n const newKey = targetKey || \"\";\r\n Object.defineProperty(target, newKey, {\r\n get: function (this: any) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this[key].value;\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this[key]?.value?.equals === \"function\") {\r\n if (this[key].value.equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key].value === value) {\r\n return;\r\n }\r\n this[key].value = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,SAAS,0BAA0B,CAAC,IAAY,EAAE,UAAmB;IACjE,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,EAAE;QACjD,MA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E,IAAI;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { GetDirectStore } from \"./decorators.functions\";\r\nimport { _WarnImport } from \"./devTools\";\r\n\r\nfunction generateSerializableMember(type: number, sourceName?: string) {\r\n return (target: any, propertyKey: string | symbol) => {\r\n const classStore = GetDirectStore(target);\r\n\r\n if (!classStore[propertyKey]) {\r\n classStore[propertyKey] = { type: type, sourceName: sourceName };\r\n }\r\n };\r\n}\r\n\r\nfunction generateExpandMember(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = targetKey || \"_\" + propertyKey;\r\n Object.defineProperty(target, propertyKey, {\r\n get: function (this: any) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this[key];\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this[key]?.equals === \"function\") {\r\n if (this[key].equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key] === value) {\r\n return;\r\n }\r\n this[key] = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n\r\nexport function expandToProperty(callback: string, targetKey: Nullable<string> = null) {\r\n return generateExpandMember(callback, targetKey);\r\n}\r\n\r\nexport function serialize(sourceName?: string) {\r\n return generateSerializableMember(0, sourceName); // value member\r\n}\r\n\r\nexport function serializeAsTexture(sourceName?: string) {\r\n return generateSerializableMember(1, sourceName); // texture member\r\n}\r\n\r\nexport function serializeAsColor3(sourceName?: string) {\r\n return generateSerializableMember(2, sourceName); // color3 member\r\n}\r\n\r\nexport function serializeAsFresnelParameters(sourceName?: string) {\r\n return generateSerializableMember(3, sourceName); // fresnel parameters member\r\n}\r\n\r\nexport function serializeAsVector2(sourceName?: string) {\r\n return generateSerializableMember(4, sourceName); // vector2 member\r\n}\r\n\r\nexport function serializeAsVector3(sourceName?: string) {\r\n return generateSerializableMember(5, sourceName); // vector3 member\r\n}\r\n\r\nexport function serializeAsMeshReference(sourceName?: string) {\r\n return generateSerializableMember(6, sourceName); // mesh reference member\r\n}\r\n\r\nexport function serializeAsColorCurves(sourceName?: string) {\r\n return generateSerializableMember(7, sourceName); // color curves\r\n}\r\n\r\nexport function serializeAsColor4(sourceName?: string) {\r\n return generateSerializableMember(8, sourceName); // color 4\r\n}\r\n\r\nexport function serializeAsImageProcessingConfiguration(sourceName?: string) {\r\n return generateSerializableMember(9, sourceName); // image processing\r\n}\r\n\r\nexport function serializeAsQuaternion(sourceName?: string) {\r\n return generateSerializableMember(10, sourceName); // quaternion member\r\n}\r\n\r\nexport function serializeAsMatrix(sourceName?: string) {\r\n return generateSerializableMember(12, sourceName); // matrix member\r\n}\r\n\r\n/**\r\n * Decorator used to define property that can be serialized as reference to a camera\r\n * @param sourceName defines the name of the property to decorate\r\n * @returns Property Decorator\r\n */\r\nexport function serializeAsCameraReference(sourceName?: string) {\r\n return generateSerializableMember(11, sourceName); // camera reference member\r\n}\r\n\r\n/** @internal */\r\ndeclare const _native: any;\r\n\r\n/**\r\n * Decorator used to redirect a function to a native implementation if available.\r\n * @internal\r\n */\r\nexport function nativeOverride<T extends (...params: any[]) => boolean>(\r\n target: any,\r\n propertyKey: string,\r\n descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => any>,\r\n predicate?: T\r\n) {\r\n // Cache the original JS function for later.\r\n const jsFunc = descriptor.value!;\r\n\r\n // Override the JS function to check for a native override on first invocation. Setting descriptor.value overrides the function at the early stage of code being loaded/imported.\r\n descriptor.value = (...params: Parameters<T>): unknown => {\r\n // Assume the resolved function will be the original JS function, then we will check for the Babylon Native context.\r\n let func = jsFunc;\r\n\r\n // Check if we are executing in a Babylon Native context (e.g. check the presence of the _native global property) and if so also check if a function override is available.\r\n if (typeof _native !== \"undefined\" && _native[propertyKey]) {\r\n const nativeFunc = _native[propertyKey] as (...params: Parameters<T>) => unknown;\r\n // If a predicate was provided, then we'll need to invoke the predicate on each invocation of the underlying function to determine whether to call the native function or the JS function.\r\n if (predicate) {\r\n // The resolved function will execute the predicate and then either execute the native function or the JS function.\r\n func = (...params: Parameters<T>) => (predicate(...params) ? nativeFunc(...params) : jsFunc(...params));\r\n } else {\r\n // The resolved function will directly execute the native function.\r\n func = nativeFunc;\r\n }\r\n }\r\n\r\n // Override the JS function again with the final resolved target function.\r\n target[propertyKey] = func;\r\n\r\n // The JS function has now been overridden based on whether we're executing in the context of Babylon Native, but we still need to invoke that function.\r\n // Future invocations of the function will just directly invoke the final overridden function, not any of the decorator setup logic above.\r\n return func(...params);\r\n };\r\n}\r\n\r\n/**\r\n * Decorator factory that applies the nativeOverride decorator, but determines whether to redirect to the native implementation based on a filter function that evaluates the function arguments.\r\n * @param predicate\r\n * @example @nativeOverride.filter((...[arg1]: Parameters<typeof someClass.someMethod>) => arg1.length > 20)\r\n * public someMethod(arg1: string, arg2: number): string {\r\n * @internal\r\n */\r\nnativeOverride.filter = function <T extends (...params: any) => boolean>(predicate: T) {\r\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: Parameters<T>) => unknown>) =>\r\n nativeOverride(target, propertyKey, descriptor, predicate);\r\n};\r\n\r\n/**\r\n * Adds accessors for a material property.\r\n * @param setCallback - The name of the callback function to call when the property is set.\r\n * @param targetKey - The key to use for the target property (defaults to the original property key).\r\n * @returns A property decorator.\r\n */\r\nexport function addAccessorsForMaterialProperty(setCallback: string, targetKey: Nullable<string> = null) {\r\n return (target: any, propertyKey: string) => {\r\n const key = propertyKey;\r\n const newKey = targetKey || \"\";\r\n Object.defineProperty(target, newKey, {\r\n get: function (this: any) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this[key].value;\r\n },\r\n set: function (this: any, value) {\r\n // does this object (i.e. vector3) has an equals function? use it!\r\n // Note - not using \"with epsilon\" here, it is expected te behave like the internal cache does.\r\n if (typeof this[key]?.value?.equals === \"function\") {\r\n if (this[key].value.equals(value)) {\r\n return;\r\n }\r\n }\r\n if (this[key].value === value) {\r\n return;\r\n }\r\n this[key].value = value;\r\n\r\n target[setCallback].apply(this);\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n };\r\n}\r\n"]}
|
package/Misc/dumpTools.d.ts
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
2
|
+
declare class EncodingHelper {
|
|
3
|
+
/**
|
|
4
|
+
* Encodes image data to the given mime type.
|
|
5
|
+
* This is put into a helper class so we can apply the nativeOverride decorator to it.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
static EncodeImageAsync(pixelData: ArrayBufferView, width: number, height: number, mimeType?: string, invertY?: boolean, quality?: number): Promise<Blob>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Encodes pixel data to an image
|
|
12
|
+
* @param pixelData 8-bit RGBA pixel data
|
|
13
|
+
* @param width the width of the image
|
|
14
|
+
* @param height the height of the image
|
|
15
|
+
* @param mimeType the requested MIME type
|
|
16
|
+
* @param invertY true to invert the image in the Y direction
|
|
17
|
+
* @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.
|
|
18
|
+
* @returns a promise that resolves to the encoded image data. Note that the `blob.type` may differ from `mimeType` if it was not supported.
|
|
19
|
+
*/
|
|
20
|
+
export declare const EncodeImageAsync: typeof EncodingHelper.EncodeImageAsync;
|
|
2
21
|
/**
|
|
3
22
|
* Dumps the current bound framebuffer
|
|
4
23
|
* @param width defines the rendering width
|
|
@@ -40,3 +59,4 @@ export declare const DumpTools: {
|
|
|
40
59
|
DumpFramebuffer: typeof DumpFramebuffer;
|
|
41
60
|
Dispose: typeof Dispose;
|
|
42
61
|
};
|
|
62
|
+
export {};
|
package/Misc/dumpTools.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { __decorate } from "../tslib.es6.js";
|
|
1
2
|
|
|
2
3
|
import { EffectRenderer, EffectWrapper } from "../Materials/effectRenderer.js";
|
|
3
4
|
import { Tools } from "./tools.js";
|
|
4
5
|
import { Clamp } from "../Maths/math.scalar.functions.js";
|
|
5
6
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
6
7
|
import { Logger } from "./logger.js";
|
|
8
|
+
import { EncodeArrayBufferToBase64 } from "./stringTools.js";
|
|
9
|
+
import { nativeOverride } from "./decorators.js";
|
|
7
10
|
let ResourcesPromise = null;
|
|
8
11
|
async function _CreateDumpResourcesAsync() {
|
|
9
12
|
// Create a compatible canvas. Prefer an HTMLCanvasElement if possible to avoid alpha issues with OffscreenCanvas + WebGL in many browsers.
|
|
@@ -11,14 +14,11 @@ async function _CreateDumpResourcesAsync() {
|
|
|
11
14
|
if (canvas instanceof OffscreenCanvas) {
|
|
12
15
|
Logger.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");
|
|
13
16
|
}
|
|
14
|
-
// If WebGL via ThinEngine is not available
|
|
17
|
+
// If WebGL via ThinEngine is not available, we cannot encode the data.
|
|
15
18
|
// If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.
|
|
16
19
|
const { ThinEngine: thinEngineClass } = await import("../Engines/thinEngine.js");
|
|
17
20
|
if (!thinEngineClass.IsSupported) {
|
|
18
|
-
|
|
19
|
-
throw new Error("DumpData: No WebGL or bitmap rendering context available. Cannot dump data.");
|
|
20
|
-
}
|
|
21
|
-
return { canvas };
|
|
21
|
+
throw new Error("DumpData: No WebGL context available. Cannot dump data.");
|
|
22
22
|
}
|
|
23
23
|
const options = {
|
|
24
24
|
preserveDrawingBuffer: true,
|
|
@@ -61,6 +61,49 @@ async function _GetDumpResourcesAsync() {
|
|
|
61
61
|
}
|
|
62
62
|
return await ResourcesPromise;
|
|
63
63
|
}
|
|
64
|
+
class EncodingHelper {
|
|
65
|
+
/**
|
|
66
|
+
* Encodes image data to the given mime type.
|
|
67
|
+
* This is put into a helper class so we can apply the nativeOverride decorator to it.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
static async EncodeImageAsync(pixelData, width, height, mimeType, invertY, quality) {
|
|
71
|
+
const resources = await _GetDumpResourcesAsync();
|
|
72
|
+
const dumpEngine = resources.dumpEngine;
|
|
73
|
+
dumpEngine.engine.setSize(width, height, true);
|
|
74
|
+
// Create the image
|
|
75
|
+
const texture = dumpEngine.engine.createRawTexture(pixelData, width, height, 5, false, !invertY, 1);
|
|
76
|
+
dumpEngine.renderer.setViewport();
|
|
77
|
+
dumpEngine.renderer.applyEffectWrapper(dumpEngine.wrapper);
|
|
78
|
+
dumpEngine.wrapper.effect._bindTexture("textureSampler", texture);
|
|
79
|
+
dumpEngine.renderer.draw();
|
|
80
|
+
texture.dispose();
|
|
81
|
+
return await new Promise((resolve, reject) => {
|
|
82
|
+
Tools.ToBlob(resources.canvas, (blob) => {
|
|
83
|
+
if (!blob) {
|
|
84
|
+
reject(new Error("EncodeImageAsync: Failed to convert canvas to blob."));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
resolve(blob);
|
|
88
|
+
}
|
|
89
|
+
}, mimeType, quality);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
__decorate([
|
|
94
|
+
nativeOverride
|
|
95
|
+
], EncodingHelper, "EncodeImageAsync", null);
|
|
96
|
+
/**
|
|
97
|
+
* Encodes pixel data to an image
|
|
98
|
+
* @param pixelData 8-bit RGBA pixel data
|
|
99
|
+
* @param width the width of the image
|
|
100
|
+
* @param height the height of the image
|
|
101
|
+
* @param mimeType the requested MIME type
|
|
102
|
+
* @param invertY true to invert the image in the Y direction
|
|
103
|
+
* @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.
|
|
104
|
+
* @returns a promise that resolves to the encoded image data. Note that the `blob.type` may differ from `mimeType` if it was not supported.
|
|
105
|
+
*/
|
|
106
|
+
export const EncodeImageAsync = EncodingHelper.EncodeImageAsync;
|
|
64
107
|
/**
|
|
65
108
|
* Dumps the current bound framebuffer
|
|
66
109
|
* @param width defines the rendering width
|
|
@@ -103,50 +146,18 @@ export async function DumpDataAsync(width, height, data, mimeType = "image/png",
|
|
|
103
146
|
}
|
|
104
147
|
data = data2;
|
|
105
148
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
Tools.ToBlob(resources.canvas, (blob) => {
|
|
131
|
-
if (!blob) {
|
|
132
|
-
throw new Error("DumpData: Failed to convert canvas to blob.");
|
|
133
|
-
}
|
|
134
|
-
if (fileName !== undefined) {
|
|
135
|
-
Tools.DownloadBlob(blob, fileName);
|
|
136
|
-
}
|
|
137
|
-
const fileReader = new FileReader();
|
|
138
|
-
fileReader.onload = (event) => {
|
|
139
|
-
const result = event.target.result;
|
|
140
|
-
resolve(result);
|
|
141
|
-
};
|
|
142
|
-
if (toArrayBuffer) {
|
|
143
|
-
fileReader.readAsArrayBuffer(blob);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
fileReader.readAsDataURL(blob);
|
|
147
|
-
}
|
|
148
|
-
}, mimeType, quality);
|
|
149
|
-
});
|
|
149
|
+
const blob = await EncodingHelper.EncodeImageAsync(data, width, height, mimeType, invertY, quality);
|
|
150
|
+
if (fileName !== undefined) {
|
|
151
|
+
Tools.DownloadBlob(blob, fileName);
|
|
152
|
+
}
|
|
153
|
+
if (blob.type !== mimeType) {
|
|
154
|
+
Logger.Warn(`DumpData: The requested mimeType '${mimeType}' is not supported. The result has mimeType '${blob.type}' instead.`);
|
|
155
|
+
}
|
|
156
|
+
const buffer = await blob.arrayBuffer();
|
|
157
|
+
if (toArrayBuffer) {
|
|
158
|
+
return buffer;
|
|
159
|
+
}
|
|
160
|
+
return `data:${mimeType};base64,${EncodeArrayBufferToBase64(buffer)}`;
|
|
150
161
|
}
|
|
151
162
|
/**
|
|
152
163
|
* Dumps an array buffer
|