@babylonjs/core 7.19.1 → 7.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Bones/bone.js +3 -3
- package/Bones/bone.js.map +1 -1
- package/Bones/boneLookController.js +3 -3
- package/Bones/boneLookController.js.map +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +8 -2
- package/Collisions/gpuPicker.js +41 -20
- package/Collisions/gpuPicker.js.map +1 -1
- package/Compat/compatibilityOptions.d.ts +13 -6
- package/Compat/compatibilityOptions.js +20 -4
- package/Compat/compatibilityOptions.js.map +1 -1
- package/Compat/index.d.ts +1 -1
- package/Compat/index.js +1 -1
- package/Compat/index.js.map +1 -1
- package/Culling/boundingBox.js +5 -5
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/boundingInfo.js +2 -2
- package/Culling/boundingInfo.js.map +1 -1
- package/Culling/boundingSphere.js +2 -2
- package/Culling/boundingSphere.js.map +1 -1
- package/Culling/ray.js +2 -2
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.d.ts +3 -0
- package/Debug/debugLayer.js +15 -0
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/Processors/shaderProcessor.d.ts +1 -0
- package/Engines/Processors/shaderProcessor.js +1 -0
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +1 -0
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +4 -2
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +2 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +12 -5
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -4
- package/Engines/WebGPU/webgpuTextureManager.js +90 -75
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.js +11 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -1
- package/Engines/nativeEngine.js +2 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -1
- package/Engines/thinEngine.functions.d.ts +1 -1
- package/Engines/thinEngine.functions.js +2 -1
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +9 -5
- package/Engines/webgpuEngine.js +35 -22
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/Layers/effectLayer.d.ts +16 -1
- package/Layers/effectLayer.js +32 -2
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +1 -2
- package/Layers/glowLayer.js +16 -3
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +5 -4
- package/Layers/highlightLayer.js +35 -11
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +10 -0
- package/Layers/index.js +12 -0
- package/Layers/index.js.map +1 -1
- package/Lights/Shadows/index.d.ts +8 -0
- package/Lights/Shadows/index.js +9 -0
- package/Lights/Shadows/index.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +18 -5
- package/Lights/Shadows/shadowGenerator.js +44 -5
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/sceneLoader.d.ts +155 -16
- package/Loading/sceneLoader.js +197 -99
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +8 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +1 -1
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Textures/Loaders/hdrTextureLoader.js +3 -3
- package/Materials/Textures/Loaders/hdrTextureLoader.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +2 -2
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +3 -3
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/effect.functions.d.ts +1 -1
- package/Materials/effect.functions.js +6 -3
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +1 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -1
- package/Materials/standardMaterial.js +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.color.js +3 -3
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.constants.d.ts +1 -2
- package/Maths/math.constants.js +1 -2
- package/Maths/math.constants.js.map +1 -1
- package/Maths/math.like.d.ts +9 -0
- package/Maths/math.like.js.map +1 -1
- package/Maths/math.vector.d.ts +23 -23
- package/Maths/math.vector.js +56 -25
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/boxBuilder.js +5 -5
- package/Meshes/Builders/boxBuilder.js.map +1 -1
- package/Meshes/Builders/capsuleBuilder.js +4 -4
- package/Meshes/Builders/capsuleBuilder.js.map +1 -1
- package/Meshes/Builders/cylinderBuilder.js +8 -8
- package/Meshes/Builders/cylinderBuilder.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +3 -3
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/discBuilder.js +3 -3
- package/Meshes/Builders/discBuilder.js.map +1 -1
- package/Meshes/Builders/goldbergBuilder.js +2 -2
- package/Meshes/Builders/goldbergBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.js +2 -2
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/icoSphereBuilder.js +2 -2
- package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
- package/Meshes/Builders/planeBuilder.js +5 -5
- package/Meshes/Builders/planeBuilder.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.js +4 -4
- package/Meshes/Builders/polygonBuilder.js.map +1 -1
- package/Meshes/Builders/polyhedronBuilder.js +3 -3
- package/Meshes/Builders/polyhedronBuilder.js.map +1 -1
- package/Meshes/Builders/ribbonBuilder.js +4 -4
- package/Meshes/Builders/ribbonBuilder.js.map +1 -1
- package/Meshes/Builders/sphereBuilder.js +2 -2
- package/Meshes/Builders/sphereBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.js +2 -2
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/torusBuilder.js +2 -2
- package/Meshes/Builders/torusBuilder.js.map +1 -1
- package/Meshes/Builders/torusKnotBuilder.js +2 -2
- package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
- package/Meshes/geometry.js +7 -7
- package/Meshes/geometry.js.map +1 -1
- package/Misc/HighDynamicRange/hdr.d.ts +40 -42
- package/Misc/HighDynamicRange/hdr.js +209 -202
- package/Misc/HighDynamicRange/hdr.js.map +1 -1
- package/Misc/HighDynamicRange/index.d.ts +1 -1
- package/Misc/HighDynamicRange/index.js +1 -1
- package/Misc/HighDynamicRange/index.js.map +1 -1
- package/Misc/arrayTools.d.ts +12 -17
- package/Misc/arrayTools.js +18 -23
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/dumpTools.d.ts +50 -47
- package/Misc/dumpTools.js +153 -143
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.js +2 -2
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/equirectangularCapture.js +2 -2
- package/Misc/equirectangularCapture.js.map +1 -1
- package/Misc/index.d.ts +6 -1
- package/Misc/index.js +7 -1
- package/Misc/index.js.map +1 -1
- package/Misc/rgbdTextureTools.d.ts +1 -0
- package/Misc/rgbdTextureTools.js +16 -2
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/screenshotTools.js +3 -3
- package/Misc/screenshotTools.js.map +1 -1
- package/Physics/v1/physicsImpostor.js +2 -2
- package/Physics/v1/physicsImpostor.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +2 -2
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +6 -0
- package/PostProcesses/blurPostProcess.js +20 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/index.d.ts +8 -0
- package/PostProcesses/index.js +10 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +2 -0
- package/PostProcesses/passPostProcess.js +24 -2
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +17 -2
- package/PostProcesses/postProcess.js +38 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.js +17 -0
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.js +20 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.js +19 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.js +9 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.js +9 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +4 -4
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js +5 -5
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.js +26 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js +12 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.js +19 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js +4 -4
- package/ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.js +17 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.js.map +1 -0
- package/ShadersWGSL/background.fragment.js +1 -1
- package/ShadersWGSL/background.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +2 -2
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/depthBoxBlur.fragment.d.ts +5 -0
- package/ShadersWGSL/depthBoxBlur.fragment.js +14 -0
- package/ShadersWGSL/depthBoxBlur.fragment.js.map +1 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.d.ts +5 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.js +15 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapGeneration.fragment.d.ts +8 -0
- package/ShadersWGSL/glowMapGeneration.fragment.js +74 -0
- package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapGeneration.vertex.d.ts +17 -0
- package/ShadersWGSL/glowMapGeneration.vertex.js +92 -0
- package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -0
- package/ShadersWGSL/glowMapMerge.fragment.d.ts +5 -0
- package/ShadersWGSL/glowMapMerge.fragment.js +32 -0
- package/ShadersWGSL/glowMapMerge.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapMerge.vertex.d.ts +5 -0
- package/ShadersWGSL/glowMapMerge.vertex.js +16 -0
- package/ShadersWGSL/glowMapMerge.vertex.js.map +1 -0
- package/ShadersWGSL/kernelBlur.fragment.d.ts +9 -0
- package/ShadersWGSL/kernelBlur.fragment.js +48 -0
- package/ShadersWGSL/kernelBlur.fragment.js.map +1 -0
- package/ShadersWGSL/kernelBlur.vertex.d.ts +7 -0
- package/ShadersWGSL/kernelBlur.vertex.js +21 -0
- package/ShadersWGSL/kernelBlur.vertex.js.map +1 -0
- package/ShadersWGSL/pass.fragment.d.ts +5 -0
- package/ShadersWGSL/pass.fragment.js +12 -0
- package/ShadersWGSL/pass.fragment.js.map +1 -0
- package/ShadersWGSL/passCube.fragment.d.ts +5 -0
- package/ShadersWGSL/passCube.fragment.js +31 -0
- package/ShadersWGSL/passCube.fragment.js.map +1 -0
- package/ShadersWGSL/rgbdDecode.fragment.d.ts +6 -0
- package/ShadersWGSL/rgbdDecode.fragment.js +14 -0
- package/ShadersWGSL/rgbdDecode.fragment.js.map +1 -0
- package/ShadersWGSL/rgbdEncode.fragment.d.ts +6 -0
- package/ShadersWGSL/rgbdEncode.fragment.js +14 -0
- package/ShadersWGSL/rgbdEncode.fragment.js.map +1 -0
- package/ShadersWGSL/shadowMap.fragment.d.ts +9 -0
- package/ShadersWGSL/shadowMap.fragment.js +39 -0
- package/ShadersWGSL/shadowMap.fragment.js.map +1 -0
- package/ShadersWGSL/shadowMap.vertex.d.ts +22 -0
- package/ShadersWGSL/shadowMap.vertex.js +89 -0
- package/ShadersWGSL/shadowMap.vertex.js.map +1 -0
- package/package.json +1 -1
package/Engines/thinEngine.d.ts
CHANGED
|
@@ -559,7 +559,7 @@ export declare class ThinEngine extends AbstractEngine {
|
|
|
559
559
|
/**
|
|
560
560
|
* @internal
|
|
561
561
|
*/
|
|
562
|
-
_preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean,
|
|
562
|
+
_preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string, onReady: () => void): void;
|
|
563
563
|
protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
|
|
564
564
|
/**
|
|
565
565
|
* @internal
|
|
@@ -77,7 +77,7 @@ export declare function _finalizePipelineContext(pipelineContext: WebGLPipelineC
|
|
|
77
77
|
/**
|
|
78
78
|
* @internal
|
|
79
79
|
*/
|
|
80
|
-
export declare function _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, _rawVertexSourceCode: string, _rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, _key
|
|
80
|
+
export declare function _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, _rawVertexSourceCode: string, _rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, _key: string | undefined, onReady: () => void, createRawShaderProgramInjection?: typeof createRawShaderProgram, createShaderProgramInjection?: typeof createShaderProgram): void;
|
|
81
81
|
/**
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
@@ -172,7 +172,7 @@ export function _finalizePipelineContext(pipelineContext, gl, validateShaderProg
|
|
|
172
172
|
/**
|
|
173
173
|
* @internal
|
|
174
174
|
*/
|
|
175
|
-
export function _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, _rawVertexSourceCode, _rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, _key = "", createRawShaderProgramInjection, createShaderProgramInjection) {
|
|
175
|
+
export function _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, _rawVertexSourceCode, _rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, _key = "", onReady, createRawShaderProgramInjection, createShaderProgramInjection) {
|
|
176
176
|
const stateObject = getStateObject(pipelineContext.context);
|
|
177
177
|
if (!createRawShaderProgramInjection) {
|
|
178
178
|
createRawShaderProgramInjection = stateObject.createRawShaderProgramInjection ?? createRawShaderProgram;
|
|
@@ -188,6 +188,7 @@ export function _preparePipelineContext(pipelineContext, vertexSourceCode, fragm
|
|
|
188
188
|
webGLRenderingState.program = createShaderProgramInjection(webGLRenderingState, vertexSourceCode, fragmentSourceCode, defines, webGLRenderingState.context, transformFeedbackVaryings);
|
|
189
189
|
}
|
|
190
190
|
webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;
|
|
191
|
+
onReady();
|
|
191
192
|
}
|
|
192
193
|
function _compileShader(source, type, defines, shaderVersion, gl, _contextWasLost) {
|
|
193
194
|
return _compileRawShader(_ConcatenateShader(source, defines, shaderVersion), type, gl, _contextWasLost);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinEngine.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinEngine.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAiBhE;;GAEG;AACH,MAAM,YAAY,GAAkD,IAAI,OAAO,EAAE,CAAC;AAElF;;GAEG;AACH,MAAM,iBAAiB,GAA2B;IAC9C,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,EAAE;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAqB;IAChD,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE;QACR,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,iBAAiB,CAAC;SAC5B;QACD,KAAK,GAAG;YACJ,sFAAsF;YACtF,aAAa,EAAG,OAAkC,CAAC,kBAAkB,CAAC,CAAC,CAA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AAC,EAAE,CAAC,eAAe,CAAC,CAAC;IAE1F,IAAI,CAAC,MAAM,EAAE;QACT,IAAI,KAAK,GAAW,EAAE,CAAC,QAAQ,CAAC;QAChC,IAAI,SAAS,GAAW,EAAE,CAAC,QAAQ,CAAC;QACpC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;YAChD,KAAK,GAAG,SAAS,CAAC;SACrB;QAED,MAAM,IAAI,KAAK,CACX,4CAA4C,IAAI,4BAA4B,KAAK,sBAAsB,EAAE,CAAC,aAAa,EAAE,qBAAqB,eAAe,EAAE,CAClK,CAAC;KACL;IAED,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqB,EAAE,EAAgB;IAC/D,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CAAC,eAAiC,EAAE,MAAoD;IACxI,MAAM,oBAAoB,GAAG,eAAuC,CAAC;IAErE,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE;QAC1C,MAAM,CAAC,eAAe,CAAC,CAAC;QACxB,OAAO;KACV;IAED,MAAM,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC;IAEnD,oBAAoB,CAAC,UAAU,GAAG,GAAG,EAAE;QACnC,UAAU,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,eAAe,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { IPipelineContext } from \"./IPipelineContext\";\r\nimport type { ShaderProcessingContext } from \"./Processors/shaderProcessingOptions\";\r\nimport { WebGLPipelineContext } from \"./WebGL/webGLPipelineContext\";\r\nimport type { _loadFile } from \"./abstractEngine.functions\";\r\nimport { _ConcatenateShader } from \"./abstractEngine.functions\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IThinEngineStateObject {\r\n _contextWasLost?: boolean;\r\n validateShaderPrograms?: boolean;\r\n _webGLVersion: number;\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n _context?: WebGLContext;\r\n _createShaderProgramInjection?: typeof _createShaderProgram;\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram;\r\n createShaderProgramInjection?: typeof createShaderProgram;\r\n loadFileInjection?: typeof _loadFile;\r\n cachedPipelines: { [name: string]: IPipelineContext };\r\n}\r\n/**\r\n * @internal\r\n */\r\nconst _stateObject: WeakMap<WebGLContext, IThinEngineStateObject> = new WeakMap();\r\n\r\n/**\r\n * This will be used in cases where the engine doesn't have a context (like the nullengine)\r\n */\r\nconst singleStateObject: IThinEngineStateObject = {\r\n _webGLVersion: 2,\r\n cachedPipelines: {},\r\n};\r\n\r\n/**\r\n * get or create a state object for the given context\r\n * Note - Used in WebGL only at the moment.\r\n * @param context The context to get the state object from\r\n * @returns the state object\r\n * @internal\r\n */\r\nexport function getStateObject(context: WebGLContext): IThinEngineStateObject {\r\n let state = _stateObject.get(context);\r\n if (!state) {\r\n if (!context) {\r\n return singleStateObject;\r\n }\r\n state = {\r\n // use feature detection. instanceof returns false. This only exists on WebGL2 context\r\n _webGLVersion: (context as WebGL2RenderingContext).TEXTURE_BINDING_3D ? 2 : 1,\r\n _context: context,\r\n cachedPipelines: {},\r\n };\r\n _stateObject.set(context, state);\r\n }\r\n return state;\r\n}\r\n/**\r\n * Remove the state object that belongs to the specific context\r\n * @param context the context that is being\r\n */\r\nexport function deleteStateObject(context: WebGLContext): void {\r\n _stateObject.delete(context);\r\n}\r\n\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n/**\r\n * Directly creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createRawShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n\r\n const vertexShader = _compileRawShader(vertexCode, \"vertex\", context, stateObject._contextWasLost);\r\n const fragmentShader = _compileRawShader(fragmentCode, \"fragment\", context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n defines: Nullable<string>,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]> = null,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n const shaderVersion = stateObject._webGLVersion > 1 ? \"#version 300 es\\n#define WEBGL2 \\n\" : \"\";\r\n const vertexShader = _compileShader(vertexCode, \"vertex\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n const fragmentShader = _compileShader(fragmentCode, \"fragment\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a new pipeline context. Note, make sure to attach an engine instance to the created context\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param _shaderProcessingContext defines the shader processing context used during the processing if available\r\n * @returns the new pipeline\r\n */\r\nexport function createPipelineContext(context: WebGLContext, _shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext {\r\n const pipelineContext = new WebGLPipelineContext();\r\n const stateObject = getStateObject(context);\r\n if (stateObject.parallelShaderCompile) {\r\n pipelineContext.isParallelCompiled = true;\r\n }\r\n pipelineContext.context = stateObject._context;\r\n return pipelineContext;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _createShaderProgram(\r\n pipelineContext: WebGLPipelineContext,\r\n vertexShader: WebGLShader,\r\n fragmentShader: WebGLShader,\r\n context: WebGLContext,\r\n _transformFeedbackVaryings: Nullable<string[]> = null,\r\n validateShaderPrograms?: boolean\r\n): WebGLProgram {\r\n const shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n\r\n context.linkProgram(shaderProgram);\r\n\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n\r\n if (!pipelineContext.isParallelCompiled) {\r\n _finalizePipelineContext(pipelineContext, context, validateShaderPrograms);\r\n }\r\n\r\n return shaderProgram;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _finalizePipelineContext(pipelineContext: WebGLPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean) {\r\n const context = pipelineContext.context!;\r\n const vertexShader = pipelineContext.vertexShader!;\r\n const fragmentShader = pipelineContext.fragmentShader!;\r\n const program = pipelineContext.program!;\r\n\r\n const linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n if (!linked) {\r\n // Get more info\r\n // Vertex\r\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(vertexShader);\r\n if (log) {\r\n pipelineContext.vertexCompilationError = log;\r\n throw new Error(\"VERTEX SHADER \" + log);\r\n }\r\n }\r\n\r\n // Fragment\r\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(fragmentShader);\r\n if (log) {\r\n pipelineContext.fragmentCompilationError = log;\r\n throw new Error(\"FRAGMENT SHADER \" + log);\r\n }\r\n }\r\n\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programLinkError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n\r\n if (/*this.*/ validateShaderPrograms) {\r\n context.validateProgram(program);\r\n const validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n\r\n if (!validated) {\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programValidationError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n }\r\n\r\n context.deleteShader(vertexShader);\r\n context.deleteShader(fragmentShader);\r\n\r\n pipelineContext.vertexShader = undefined;\r\n pipelineContext.fragmentShader = undefined;\r\n\r\n if (pipelineContext.onCompiled) {\r\n pipelineContext.onCompiled();\r\n pipelineContext.onCompiled = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _preparePipelineContext(\r\n pipelineContext: IPipelineContext,\r\n vertexSourceCode: string,\r\n fragmentSourceCode: string,\r\n createAsRaw: boolean,\r\n _rawVertexSourceCode: string,\r\n _rawFragmentSourceCode: string,\r\n rebuildRebind: any,\r\n defines: Nullable<string>,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _key: string = \"\",\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram,\r\n createShaderProgramInjection?: typeof createShaderProgram\r\n) {\r\n const stateObject = getStateObject((pipelineContext as WebGLPipelineContext).context!);\r\n if (!createRawShaderProgramInjection) {\r\n createRawShaderProgramInjection = stateObject.createRawShaderProgramInjection ?? createRawShaderProgram;\r\n }\r\n if (!createShaderProgramInjection) {\r\n createShaderProgramInjection = stateObject.createShaderProgramInjection ?? createShaderProgram;\r\n }\r\n const webGLRenderingState = pipelineContext as WebGLPipelineContext;\r\n\r\n if (createAsRaw) {\r\n webGLRenderingState.program = createRawShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n } else {\r\n webGLRenderingState.program = createShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n defines,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n }\r\n webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;\r\n}\r\n\r\nfunction _compileShader(source: string, type: string, defines: Nullable<string>, shaderVersion: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n return _compileRawShader(_ConcatenateShader(source, defines, shaderVersion), type, gl, _contextWasLost);\r\n}\r\n\r\nfunction _compileRawShader(source: string, type: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n const shader = gl.createShader(type === \"vertex\" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);\r\n\r\n if (!shader) {\r\n let error: GLenum = gl.NO_ERROR;\r\n let tempError: GLenum = gl.NO_ERROR;\r\n while ((tempError = gl.getError()) !== gl.NO_ERROR) {\r\n error = tempError;\r\n }\r\n\r\n throw new Error(\r\n `Something went wrong while creating a gl ${type} shader object. gl error=${error}, gl isContextLost=${gl.isContextLost()}, _contextWasLost=${_contextWasLost}`\r\n );\r\n }\r\n\r\n gl.shaderSource(shader, source);\r\n gl.compileShader(shader);\r\n\r\n return shader;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _setProgram(program: WebGLProgram, gl: WebGLContext): void {\r\n gl.useProgram(program);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: (pipelineContext?: IPipelineContext) => void) {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n\r\n if (!webGLPipelineContext.isParallelCompiled) {\r\n action(pipelineContext);\r\n return;\r\n }\r\n\r\n const oldHandler = webGLPipelineContext.onCompiled;\r\n\r\n webGLPipelineContext.onCompiled = () => {\r\n oldHandler?.();\r\n action(pipelineContext);\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"thinEngine.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinEngine.functions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAiBhE;;GAEG;AACH,MAAM,YAAY,GAAkD,IAAI,OAAO,EAAE,CAAC;AAElF;;GAEG;AACH,MAAM,iBAAiB,GAA2B;IAC9C,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,EAAE;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAqB;IAChD,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE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AAC;IAC5B,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { IPipelineContext } from \"./IPipelineContext\";\r\nimport type { ShaderProcessingContext } from \"./Processors/shaderProcessingOptions\";\r\nimport { WebGLPipelineContext } from \"./WebGL/webGLPipelineContext\";\r\nimport type { _loadFile } from \"./abstractEngine.functions\";\r\nimport { _ConcatenateShader } from \"./abstractEngine.functions\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IThinEngineStateObject {\r\n _contextWasLost?: boolean;\r\n validateShaderPrograms?: boolean;\r\n _webGLVersion: number;\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n _context?: WebGLContext;\r\n _createShaderProgramInjection?: typeof _createShaderProgram;\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram;\r\n createShaderProgramInjection?: typeof createShaderProgram;\r\n loadFileInjection?: typeof _loadFile;\r\n cachedPipelines: { [name: string]: IPipelineContext };\r\n}\r\n/**\r\n * @internal\r\n */\r\nconst _stateObject: WeakMap<WebGLContext, IThinEngineStateObject> = new WeakMap();\r\n\r\n/**\r\n * This will be used in cases where the engine doesn't have a context (like the nullengine)\r\n */\r\nconst singleStateObject: IThinEngineStateObject = {\r\n _webGLVersion: 2,\r\n cachedPipelines: {},\r\n};\r\n\r\n/**\r\n * get or create a state object for the given context\r\n * Note - Used in WebGL only at the moment.\r\n * @param context The context to get the state object from\r\n * @returns the state object\r\n * @internal\r\n */\r\nexport function getStateObject(context: WebGLContext): IThinEngineStateObject {\r\n let state = _stateObject.get(context);\r\n if (!state) {\r\n if (!context) {\r\n return singleStateObject;\r\n }\r\n state = {\r\n // use feature detection. instanceof returns false. This only exists on WebGL2 context\r\n _webGLVersion: (context as WebGL2RenderingContext).TEXTURE_BINDING_3D ? 2 : 1,\r\n _context: context,\r\n cachedPipelines: {},\r\n };\r\n _stateObject.set(context, state);\r\n }\r\n return state;\r\n}\r\n/**\r\n * Remove the state object that belongs to the specific context\r\n * @param context the context that is being\r\n */\r\nexport function deleteStateObject(context: WebGLContext): void {\r\n _stateObject.delete(context);\r\n}\r\n\r\nexport type WebGLContext = WebGLRenderingContext | WebGL2RenderingContext;\r\n/**\r\n * Directly creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createRawShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n\r\n const vertexShader = _compileRawShader(vertexCode, \"vertex\", context, stateObject._contextWasLost);\r\n const fragmentShader = _compileRawShader(fragmentCode, \"fragment\", context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a webGL program\r\n * @param pipelineContext defines the pipeline context to attach to\r\n * @param vertexCode defines the vertex shader code to use\r\n * @param fragmentCode defines the fragment shader code to use\r\n * @param defines defines the string containing the defines to use to compile the shaders\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param transformFeedbackVaryings defines the list of transform feedback varyings to use\r\n * @param _createShaderProgramInjection defines an optional injection to use to create the shader program\r\n * @returns the new webGL program\r\n */\r\nexport function createShaderProgram(\r\n pipelineContext: IPipelineContext,\r\n vertexCode: string,\r\n fragmentCode: string,\r\n defines: Nullable<string>,\r\n context: WebGLContext,\r\n transformFeedbackVaryings: Nullable<string[]> = null,\r\n _createShaderProgramInjection?: typeof _createShaderProgram\r\n): WebGLProgram {\r\n const stateObject = getStateObject(context);\r\n if (!_createShaderProgramInjection) {\r\n _createShaderProgramInjection = stateObject._createShaderProgramInjection ?? _createShaderProgram;\r\n }\r\n const shaderVersion = stateObject._webGLVersion > 1 ? \"#version 300 es\\n#define WEBGL2 \\n\" : \"\";\r\n const vertexShader = _compileShader(vertexCode, \"vertex\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n const fragmentShader = _compileShader(fragmentCode, \"fragment\", defines, shaderVersion, context, stateObject._contextWasLost);\r\n\r\n return _createShaderProgramInjection(\r\n pipelineContext as WebGLPipelineContext,\r\n vertexShader,\r\n fragmentShader,\r\n context,\r\n transformFeedbackVaryings,\r\n stateObject.validateShaderPrograms\r\n );\r\n}\r\n\r\n/**\r\n * Creates a new pipeline context. Note, make sure to attach an engine instance to the created context\r\n * @param context defines the webGL context to use (if not set, the current one will be used)\r\n * @param _shaderProcessingContext defines the shader processing context used during the processing if available\r\n * @returns the new pipeline\r\n */\r\nexport function createPipelineContext(context: WebGLContext, _shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext {\r\n const pipelineContext = new WebGLPipelineContext();\r\n const stateObject = getStateObject(context);\r\n if (stateObject.parallelShaderCompile) {\r\n pipelineContext.isParallelCompiled = true;\r\n }\r\n pipelineContext.context = stateObject._context;\r\n return pipelineContext;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _createShaderProgram(\r\n pipelineContext: WebGLPipelineContext,\r\n vertexShader: WebGLShader,\r\n fragmentShader: WebGLShader,\r\n context: WebGLContext,\r\n _transformFeedbackVaryings: Nullable<string[]> = null,\r\n validateShaderPrograms?: boolean\r\n): WebGLProgram {\r\n const shaderProgram = context.createProgram();\r\n pipelineContext.program = shaderProgram;\r\n\r\n if (!shaderProgram) {\r\n throw new Error(\"Unable to create program\");\r\n }\r\n\r\n context.attachShader(shaderProgram, vertexShader);\r\n context.attachShader(shaderProgram, fragmentShader);\r\n\r\n context.linkProgram(shaderProgram);\r\n\r\n pipelineContext.context = context;\r\n pipelineContext.vertexShader = vertexShader;\r\n pipelineContext.fragmentShader = fragmentShader;\r\n\r\n if (!pipelineContext.isParallelCompiled) {\r\n _finalizePipelineContext(pipelineContext, context, validateShaderPrograms);\r\n }\r\n\r\n return shaderProgram;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _finalizePipelineContext(pipelineContext: WebGLPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean) {\r\n const context = pipelineContext.context!;\r\n const vertexShader = pipelineContext.vertexShader!;\r\n const fragmentShader = pipelineContext.fragmentShader!;\r\n const program = pipelineContext.program!;\r\n\r\n const linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n if (!linked) {\r\n // Get more info\r\n // Vertex\r\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(vertexShader);\r\n if (log) {\r\n pipelineContext.vertexCompilationError = log;\r\n throw new Error(\"VERTEX SHADER \" + log);\r\n }\r\n }\r\n\r\n // Fragment\r\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\r\n const log = gl.getShaderInfoLog(fragmentShader);\r\n if (log) {\r\n pipelineContext.fragmentCompilationError = log;\r\n throw new Error(\"FRAGMENT SHADER \" + log);\r\n }\r\n }\r\n\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programLinkError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n\r\n if (/*this.*/ validateShaderPrograms) {\r\n context.validateProgram(program);\r\n const validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n\r\n if (!validated) {\r\n const error = context.getProgramInfoLog(program);\r\n if (error) {\r\n pipelineContext.programValidationError = error;\r\n throw new Error(error);\r\n }\r\n }\r\n }\r\n\r\n context.deleteShader(vertexShader);\r\n context.deleteShader(fragmentShader);\r\n\r\n pipelineContext.vertexShader = undefined;\r\n pipelineContext.fragmentShader = undefined;\r\n\r\n if (pipelineContext.onCompiled) {\r\n pipelineContext.onCompiled();\r\n pipelineContext.onCompiled = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _preparePipelineContext(\r\n pipelineContext: IPipelineContext,\r\n vertexSourceCode: string,\r\n fragmentSourceCode: string,\r\n createAsRaw: boolean,\r\n _rawVertexSourceCode: string,\r\n _rawFragmentSourceCode: string,\r\n rebuildRebind: any,\r\n defines: Nullable<string>,\r\n transformFeedbackVaryings: Nullable<string[]>,\r\n _key: string = \"\",\r\n onReady: () => void,\r\n createRawShaderProgramInjection?: typeof createRawShaderProgram,\r\n createShaderProgramInjection?: typeof createShaderProgram\r\n) {\r\n const stateObject = getStateObject((pipelineContext as WebGLPipelineContext).context!);\r\n if (!createRawShaderProgramInjection) {\r\n createRawShaderProgramInjection = stateObject.createRawShaderProgramInjection ?? createRawShaderProgram;\r\n }\r\n if (!createShaderProgramInjection) {\r\n createShaderProgramInjection = stateObject.createShaderProgramInjection ?? createShaderProgram;\r\n }\r\n const webGLRenderingState = pipelineContext as WebGLPipelineContext;\r\n\r\n if (createAsRaw) {\r\n webGLRenderingState.program = createRawShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n } else {\r\n webGLRenderingState.program = createShaderProgramInjection(\r\n webGLRenderingState,\r\n vertexSourceCode,\r\n fragmentSourceCode,\r\n defines,\r\n webGLRenderingState.context!,\r\n transformFeedbackVaryings\r\n );\r\n }\r\n webGLRenderingState.program.__SPECTOR_rebuildProgram = rebuildRebind;\r\n\r\n onReady();\r\n}\r\n\r\nfunction _compileShader(source: string, type: string, defines: Nullable<string>, shaderVersion: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n return _compileRawShader(_ConcatenateShader(source, defines, shaderVersion), type, gl, _contextWasLost);\r\n}\r\n\r\nfunction _compileRawShader(source: string, type: string, gl: WebGLContext, _contextWasLost?: boolean): WebGLShader {\r\n const shader = gl.createShader(type === \"vertex\" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);\r\n\r\n if (!shader) {\r\n let error: GLenum = gl.NO_ERROR;\r\n let tempError: GLenum = gl.NO_ERROR;\r\n while ((tempError = gl.getError()) !== gl.NO_ERROR) {\r\n error = tempError;\r\n }\r\n\r\n throw new Error(\r\n `Something went wrong while creating a gl ${type} shader object. gl error=${error}, gl isContextLost=${gl.isContextLost()}, _contextWasLost=${_contextWasLost}`\r\n );\r\n }\r\n\r\n gl.shaderSource(shader, source);\r\n gl.compileShader(shader);\r\n\r\n return shader;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _setProgram(program: WebGLProgram, gl: WebGLContext): void {\r\n gl.useProgram(program);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: (pipelineContext?: IPipelineContext) => void) {\r\n const webGLPipelineContext = pipelineContext as WebGLPipelineContext;\r\n\r\n if (!webGLPipelineContext.isParallelCompiled) {\r\n action(pipelineContext);\r\n return;\r\n }\r\n\r\n const oldHandler = webGLPipelineContext.onCompiled;\r\n\r\n webGLPipelineContext.onCompiled = () => {\r\n oldHandler?.();\r\n action(pipelineContext);\r\n };\r\n}\r\n"]}
|
package/Engines/thinEngine.js
CHANGED
|
@@ -1634,7 +1634,7 @@ export class ThinEngine extends AbstractEngine {
|
|
|
1634
1634
|
/**
|
|
1635
1635
|
* @internal
|
|
1636
1636
|
*/
|
|
1637
|
-
_preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw,
|
|
1637
|
+
_preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady) {
|
|
1638
1638
|
const stateObject = getStateObject(this._gl);
|
|
1639
1639
|
stateObject._contextWasLost = this._contextWasLost;
|
|
1640
1640
|
stateObject.validateShaderPrograms = this.validateShaderPrograms;
|
|
@@ -1642,7 +1642,7 @@ export class ThinEngine extends AbstractEngine {
|
|
|
1642
1642
|
stateObject.createRawShaderProgramInjection = this.createRawShaderProgram.bind(this);
|
|
1643
1643
|
stateObject.createShaderProgramInjection = this.createShaderProgram.bind(this);
|
|
1644
1644
|
stateObject.loadFileInjection = this._loadFile.bind(this);
|
|
1645
|
-
return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw,
|
|
1645
|
+
return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady);
|
|
1646
1646
|
}
|
|
1647
1647
|
_createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings = null) {
|
|
1648
1648
|
return _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
|