@babylonjs/core 6.7.0 → 6.8.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/Actions/abstractActionManager.js.map +1 -1
- package/Actions/action.js.map +1 -1
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.d.ts +5 -0
- package/Animations/animationGroup.js +12 -0
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/easing.js.map +1 -1
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Bones/bone.js.map +1 -1
- package/Bones/boneIKController.js.map +1 -1
- package/Bones/boneLookController.js.map +1 -1
- package/Buffers/dataBuffer.js.map +1 -1
- package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js.map +1 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/followCamera.js.map +1 -1
- package/Cameras/freeCamera.js.map +1 -1
- package/Cameras/targetCamera.js.map +1 -1
- package/Collisions/collider.js.map +1 -1
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +1 -5
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Octrees/octree.js.map +1 -1
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/boundingInfo.js.map +1 -1
- package/Culling/boundingSphere.js.map +1 -1
- package/Culling/ray.d.ts +7 -2
- package/Culling/ray.js +8 -3
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.js +1 -9
- package/Debug/debugLayer.js.map +1 -1
- package/Debug/skeletonViewer.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.js +1 -6
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.multiview.d.ts +6 -1
- package/Engines/Extensions/engine.multiview.js +27 -7
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +1 -6
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.renderTargetCube.js +1 -9
- package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/Extensions/engine.webVR.js +1 -5
- package/Engines/Extensions/engine.webVR.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js +3 -0
- package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js.map +1 -1
- package/Engines/Processors/Expressions/shaderDefineExpression.d.ts +37 -0
- package/Engines/Processors/Expressions/shaderDefineExpression.js +57 -0
- package/Engines/Processors/Expressions/shaderDefineExpression.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +34 -14
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +19 -0
- package/Engines/WebGL/webGLRenderTargetWrapper.js +20 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +1 -7
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +1 -8
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +1 -10
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +1 -6
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +1 -4
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/engine.d.ts +8 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nativeEngine.d.ts +2 -0
- package/Engines/nativeEngine.js +16 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -9
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +7 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +3 -14
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gamepads/Controllers/gearVRController.js.map +1 -1
- package/Gamepads/Controllers/oculusTouchController.js.map +1 -1
- package/Gamepads/Controllers/poseEnabledController.js.map +1 -1
- package/Gamepads/Controllers/windowsMotionController.js.map +1 -1
- package/Gamepads/gamepad.js.map +1 -1
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +2 -8
- package/Helpers/environmentHelper.js.map +1 -1
- package/Helpers/textureDome.js.map +1 -1
- package/Inputs/scene.inputManager.js +4 -1
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +1 -8
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +1 -12
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +1 -11
- package/Layers/highlightLayer.js.map +1 -1
- package/Legacy/legacy.js +1 -1
- package/Legacy/legacy.js.map +1 -1
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +1 -4
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.js.map +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Loading/loadingScreen.js.map +1 -1
- package/Loading/sceneLoader.d.ts +8 -8
- package/Loading/sceneLoader.js +35 -19
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js +2 -0
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.d.ts +1 -0
- package/Materials/Node/Blocks/customBlock.js +18 -2
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/divideBlock.js +2 -0
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js +2 -0
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.js +2 -0
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +6 -1
- package/Materials/Node/nodeMaterial.js +6 -10
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -5
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +2 -1
- package/Materials/PBR/pbrMaterial.js +6 -13
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.js +1 -4
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +9 -22
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/colorCurves.js.map +1 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/greasedLinePluginMaterial.d.ts +307 -0
- package/Materials/greasedLinePluginMaterial.js +553 -0
- package/Materials/greasedLinePluginMaterial.js.map +1 -0
- package/Materials/imageProcessingConfiguration.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/material.d.ts +3 -0
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/material.js +40 -5
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +2 -2
- package/Materials/materialPluginBase.js +2 -2
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +3 -2
- package/Materials/materialPluginManager.js +3 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/multiMaterial.js +1 -1
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +23 -4
- package/Materials/shaderMaterial.js +41 -21
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -1
- package/Materials/standardMaterial.js +4 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +2 -1
- package/Maths/math.vector.js +3 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +4 -4
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +105 -0
- package/Meshes/Builders/greasedLineBuilder.js +330 -0
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -0
- package/Meshes/Builders/index.d.ts +1 -0
- package/Meshes/Builders/index.js +1 -0
- package/Meshes/Builders/index.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +3 -2
- package/Meshes/abstractMesh.js +5 -3
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/greasedLineMesh.d.ts +189 -0
- package/Meshes/greasedLineMesh.js +437 -0
- package/Meshes/greasedLineMesh.js.map +1 -0
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.d.ts +4 -0
- package/Meshes/mesh.js +20 -10
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +1 -8
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/basis.js.map +1 -1
- package/Misc/deepCopier.js +8 -2
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/dumpTools.d.ts +4 -3
- package/Misc/dumpTools.js +5 -4
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.js +1 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/fileTools.js +10 -10
- package/Misc/fileTools.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +141 -0
- package/Misc/greasedLineTools.js +263 -0
- package/Misc/greasedLineTools.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer.js.map +1 -1
- package/Misc/observable.d.ts +11 -0
- package/Misc/observable.js +26 -1
- package/Misc/observable.js.map +1 -1
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/screenshotTools.d.ts +15 -5
- package/Misc/screenshotTools.js +23 -13
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/smartArray.js.map +1 -1
- package/Misc/tools.d.ts +21 -9
- package/Misc/tools.js +21 -9
- package/Misc/tools.js.map +1 -1
- package/Misc/videoRecorder.js +1 -4
- package/Misc/videoRecorder.js.map +1 -1
- package/Misc/virtualJoystick.js +1 -4
- package/Misc/virtualJoystick.js.map +1 -1
- package/Misc/webRequest.js.map +1 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Offline/database.js.map +1 -1
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +1 -0
- package/Particles/gpuParticleSystem.js +5 -8
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.js +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemSet.js.map +1 -1
- package/Physics/physicsHelper.js +4 -4
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -1
- package/Physics/physicsRaycastResult.js +10 -1
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v1/physicsImpostor.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +3 -2
- package/Physics/v2/Plugins/havokPlugin.js +9 -6
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +2 -4
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +4 -2
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +11 -2
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/velocity.fragment.d.ts +5 -0
- package/Shaders/velocity.fragment.js +13 -0
- package/Shaders/velocity.fragment.js.map +1 -0
- package/Shaders/velocity.vertex.d.ts +7 -0
- package/Shaders/velocity.vertex.js +23 -0
- package/Shaders/velocity.vertex.js.map +1 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRBackgroundRemover.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +4 -13
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDOMOverlay.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXREyeTracking.js.map +1 -1
- package/XR/features/WebXRFeaturePointSystem.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +2 -8
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js +18 -8
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.d.ts +138 -0
- package/XR/features/WebXRSpaceWarp.js +290 -0
- package/XR/features/WebXRSpaceWarp.js.map +1 -0
- package/XR/features/index.d.ts +1 -0
- package/XR/features/index.js +1 -0
- package/XR/features/index.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +1 -4
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/motionController/webXRControllerComponent.js.map +1 -1
- package/XR/motionController/webXRGenericMotionController.js.map +1 -1
- package/XR/motionController/webXRHTCViveMotionController.js.map +1 -1
- package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
- package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRDefaultExperience.js +6 -28
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +4 -0
- package/XR/webXRFeaturesManager.js +5 -4
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +1 -6
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRSessionManager.d.ts +4 -0
- package/XR/webXRSessionManager.js +6 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/abstractScene.js.map +1 -1
- package/assetContainer.js +1 -4
- package/assetContainer.js.map +1 -1
- package/node.js.map +1 -1
- package/package.json +2 -4
- package/scene.d.ts +5 -2
- package/scene.js +9 -12
- package/scene.js.map +1 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { Engine } from "../Engines/engine.js";
|
|
2
|
+
import { RawTexture } from "./Textures/rawTexture.js";
|
|
3
|
+
import { MaterialPluginBase } from "./materialPluginBase.js";
|
|
4
|
+
import { TmpVectors } from "../Maths/math.vector.js";
|
|
5
|
+
import { Color3 } from "../Maths/math.color.js";
|
|
6
|
+
import { MaterialDefines } from "./materialDefines.js";
|
|
7
|
+
import { DeepCopier } from "../Misc/deepCopier.js";
|
|
8
|
+
import { RegisterClass } from "../Misc/typeStore.js";
|
|
9
|
+
export var GreasedLineMeshMaterialType;
|
|
10
|
+
(function (GreasedLineMeshMaterialType) {
|
|
11
|
+
GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_STANDARD"] = 0] = "MATERIAL_TYPE_STANDARD";
|
|
12
|
+
GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_PBR"] = 1] = "MATERIAL_TYPE_PBR";
|
|
13
|
+
})(GreasedLineMeshMaterialType || (GreasedLineMeshMaterialType = {}));
|
|
14
|
+
export var GreasedLineMeshColorMode;
|
|
15
|
+
(function (GreasedLineMeshColorMode) {
|
|
16
|
+
GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_SET"] = 0] = "COLOR_MODE_SET";
|
|
17
|
+
GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_ADD"] = 1] = "COLOR_MODE_ADD";
|
|
18
|
+
GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_MULTIPLY"] = 2] = "COLOR_MODE_MULTIPLY";
|
|
19
|
+
})(GreasedLineMeshColorMode || (GreasedLineMeshColorMode = {}));
|
|
20
|
+
export var GreasedLineMeshColorDistributionType;
|
|
21
|
+
(function (GreasedLineMeshColorDistributionType) {
|
|
22
|
+
GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_SEGMENT"] = 0] = "COLOR_DISTRIBUTION_TYPE_SEGMENT";
|
|
23
|
+
GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_LINE"] = 1] = "COLOR_DISTRIBUTION_TYPE_LINE";
|
|
24
|
+
})(GreasedLineMeshColorDistributionType || (GreasedLineMeshColorDistributionType = {}));
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export class MaterialGreasedLineDefines extends MaterialDefines {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/**
|
|
32
|
+
* The material has a color option specified
|
|
33
|
+
*/
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
35
|
+
this.GREASED_LINE_HAS_COLOR = false;
|
|
36
|
+
/**
|
|
37
|
+
* The material's size attenuation optiom
|
|
38
|
+
*/
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
+
this.GREASED_LINE_SIZE_ATTENUATION = false;
|
|
41
|
+
/**
|
|
42
|
+
* The type of color distribution is set to line this value equals to true.
|
|
43
|
+
*/
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
45
|
+
this.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* GreasedLinePluginMaterial for GreasedLineMesh
|
|
50
|
+
*/
|
|
51
|
+
export class GreasedLinePluginMaterial extends MaterialPluginBase {
|
|
52
|
+
constructor(material, _scene, options) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
55
|
+
const defines = new MaterialGreasedLineDefines();
|
|
56
|
+
defines.GREASED_LINE_HAS_COLOR = !!options.color;
|
|
57
|
+
defines.GREASED_LINE_SIZE_ATTENUATION = (_a = options.sizeAttenuation) !== null && _a !== void 0 ? _a : false;
|
|
58
|
+
defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
|
|
59
|
+
super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);
|
|
60
|
+
this._scene = _scene;
|
|
61
|
+
this._dashArray = 0;
|
|
62
|
+
this._options = options;
|
|
63
|
+
this._scene = (_b = this._scene) !== null && _b !== void 0 ? _b : material.getScene();
|
|
64
|
+
this._engine = this._scene.getEngine();
|
|
65
|
+
if (options.colors) {
|
|
66
|
+
this._createColorsTexture(`${material.name}-colors-texture`, options.colors);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);
|
|
70
|
+
}
|
|
71
|
+
this.setDashCount((_c = options.dashCount) !== null && _c !== void 0 ? _c : 1); // calculate the _dashArray value
|
|
72
|
+
this._enable(true); // always enabled
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the shader attributes
|
|
76
|
+
* @param attributes array which will be filled with the attributes
|
|
77
|
+
*/
|
|
78
|
+
getAttributes(attributes) {
|
|
79
|
+
attributes.push("grl_offsets");
|
|
80
|
+
attributes.push("grl_previousAndSide");
|
|
81
|
+
attributes.push("grl_nextAndCounters");
|
|
82
|
+
attributes.push("grl_widths");
|
|
83
|
+
attributes.push("grl_colorPointers");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the shader samplers
|
|
87
|
+
* @param samplers
|
|
88
|
+
*/
|
|
89
|
+
getSamplers(samplers) {
|
|
90
|
+
samplers.push("grl_colors");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the shader textures
|
|
94
|
+
* @param activeTextures
|
|
95
|
+
*/
|
|
96
|
+
getActiveTextures(activeTextures) {
|
|
97
|
+
if (this._colorsTexture) {
|
|
98
|
+
activeTextures.push(this._colorsTexture);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the shader uniforms
|
|
103
|
+
* @returns uniforms
|
|
104
|
+
*/
|
|
105
|
+
getUniforms() {
|
|
106
|
+
const ubo = [
|
|
107
|
+
{ name: "grl_projection", size: 16, type: "mat4" },
|
|
108
|
+
{ name: "grl_singleColor", size: 3, type: "vec3" },
|
|
109
|
+
{ name: "grl_resolution_lineWidth", size: 3, type: "vec3" },
|
|
110
|
+
{ name: "grl_dashOptions", size: 4, type: "vec4" },
|
|
111
|
+
{ name: "grl_colorMode_visibility_colorsWidth_useColors", size: 4, type: "vec4" },
|
|
112
|
+
];
|
|
113
|
+
return {
|
|
114
|
+
ubo,
|
|
115
|
+
vertex: `
|
|
116
|
+
uniform vec3 grl_resolution_lineWidth;
|
|
117
|
+
uniform mat4 grl_projection;
|
|
118
|
+
`,
|
|
119
|
+
fragment: `
|
|
120
|
+
uniform vec4 grl_dashOptions;
|
|
121
|
+
uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;
|
|
122
|
+
uniform vec3 grl_singleColor;
|
|
123
|
+
`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// only getter, it doesn't make sense to use this plugin on a mesh other than GreasedLineMesh
|
|
127
|
+
// and it doesn't make sense to disable it on the mesh
|
|
128
|
+
get isEnabled() {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Bind the uniform buffer
|
|
133
|
+
* @param uniformBuffer
|
|
134
|
+
*/
|
|
135
|
+
bindForSubMesh(uniformBuffer) {
|
|
136
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
137
|
+
const activeCamera = this._scene.activeCamera;
|
|
138
|
+
if (activeCamera) {
|
|
139
|
+
const projection = activeCamera.getProjectionMatrix();
|
|
140
|
+
uniformBuffer.updateMatrix("grl_projection", projection);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw Error("GreasedLinePluginMaterial requires an active camera.");
|
|
144
|
+
}
|
|
145
|
+
const resolutionLineWidth = TmpVectors.Vector3[0];
|
|
146
|
+
if (this._options.resolution) {
|
|
147
|
+
resolutionLineWidth.x = this._options.resolution.x;
|
|
148
|
+
resolutionLineWidth.y = this._options.resolution.y;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resolutionLineWidth.x = this._engine.getRenderWidth();
|
|
152
|
+
resolutionLineWidth.y = this._engine.getRenderHeight();
|
|
153
|
+
}
|
|
154
|
+
resolutionLineWidth.z = this._options.width ? this._options.width : this._options.sizeAttenuation ? 1 : 0.1;
|
|
155
|
+
uniformBuffer.updateVector3("grl_resolution_lineWidth", resolutionLineWidth);
|
|
156
|
+
const dashOptions = TmpVectors.Vector4[0];
|
|
157
|
+
dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this._options.useDash);
|
|
158
|
+
dashOptions.y = (_a = this._dashArray) !== null && _a !== void 0 ? _a : 0;
|
|
159
|
+
dashOptions.z = (_b = this._options.dashOffset) !== null && _b !== void 0 ? _b : 0;
|
|
160
|
+
dashOptions.w = (_c = this._options.dashRatio) !== null && _c !== void 0 ? _c : 0.5;
|
|
161
|
+
uniformBuffer.updateVector4("grl_dashOptions", dashOptions);
|
|
162
|
+
const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];
|
|
163
|
+
colorModeVisibilityColorsWidthUseColors.x = (_d = this._options.colorMode) !== null && _d !== void 0 ? _d : GreasedLineMeshColorMode.COLOR_MODE_SET;
|
|
164
|
+
colorModeVisibilityColorsWidthUseColors.y = (_e = this._options.visibility) !== null && _e !== void 0 ? _e : 1;
|
|
165
|
+
colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;
|
|
166
|
+
colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this._options.useColors);
|
|
167
|
+
uniformBuffer.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", colorModeVisibilityColorsWidthUseColors);
|
|
168
|
+
if (this._options.color) {
|
|
169
|
+
uniformBuffer.updateColor3("grl_singleColor", (_f = this._options.color) !== null && _f !== void 0 ? _f : Color3.White());
|
|
170
|
+
}
|
|
171
|
+
uniformBuffer.setTexture("grl_colors", (_g = this._colorsTexture) !== null && _g !== void 0 ? _g : GreasedLinePluginMaterial._EmptyColorsTexture);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Prepare the defines
|
|
175
|
+
* @param defines
|
|
176
|
+
* @param _scene
|
|
177
|
+
* @param _mesh
|
|
178
|
+
*/
|
|
179
|
+
prepareDefines(defines, _scene, _mesh) {
|
|
180
|
+
var _a;
|
|
181
|
+
const options = this._options;
|
|
182
|
+
defines.GREASED_LINE_HAS_COLOR = !!options.color;
|
|
183
|
+
defines.GREASED_LINE_SIZE_ATTENUATION = (_a = options.sizeAttenuation) !== null && _a !== void 0 ? _a : false;
|
|
184
|
+
defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get the class name
|
|
188
|
+
* @returns class name
|
|
189
|
+
*/
|
|
190
|
+
getClassName() {
|
|
191
|
+
return GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get shader code
|
|
195
|
+
* @param shaderType vertex/fragment
|
|
196
|
+
* @returns shader code
|
|
197
|
+
*/
|
|
198
|
+
getCustomCode(shaderType) {
|
|
199
|
+
if (shaderType === "vertex") {
|
|
200
|
+
return {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
202
|
+
CUSTOM_VERTEX_DEFINITIONS: `
|
|
203
|
+
attribute vec4 grl_previousAndSide;
|
|
204
|
+
attribute vec4 grl_nextAndCounters;
|
|
205
|
+
attribute float grl_widths;
|
|
206
|
+
attribute vec3 grl_offsets;
|
|
207
|
+
attribute float grl_colorPointers;
|
|
208
|
+
|
|
209
|
+
varying float grlCounters;
|
|
210
|
+
varying float grlColorPointer;
|
|
211
|
+
|
|
212
|
+
vec2 grlFix( vec4 i, float aspect ) {
|
|
213
|
+
vec2 res = i.xy / i.w;
|
|
214
|
+
res.x *= aspect;
|
|
215
|
+
return res;
|
|
216
|
+
}
|
|
217
|
+
`,
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
219
|
+
CUSTOM_VERTEX_UPDATE_POSITION: `
|
|
220
|
+
vec3 grlPositionOffset = grl_offsets;
|
|
221
|
+
positionUpdated += grlPositionOffset;
|
|
222
|
+
`,
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
224
|
+
CUSTOM_VERTEX_MAIN_END: `
|
|
225
|
+
vec2 grlResolution = grl_resolution_lineWidth.xy;
|
|
226
|
+
float grlBaseWidth = grl_resolution_lineWidth.z;
|
|
227
|
+
|
|
228
|
+
grlColorPointer = grl_colorPointers;
|
|
229
|
+
|
|
230
|
+
vec3 grlPrevious = grl_previousAndSide.xyz;
|
|
231
|
+
float grlSide = grl_previousAndSide.w;
|
|
232
|
+
|
|
233
|
+
vec3 grlNext = grl_nextAndCounters.xyz;
|
|
234
|
+
grlCounters = grl_nextAndCounters.w;
|
|
235
|
+
|
|
236
|
+
float grlAspect = grlResolution.x / grlResolution.y;
|
|
237
|
+
|
|
238
|
+
mat4 grlMatrix = viewProjection * world;
|
|
239
|
+
vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );
|
|
240
|
+
vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );
|
|
241
|
+
vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );
|
|
242
|
+
|
|
243
|
+
vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );
|
|
244
|
+
vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );
|
|
245
|
+
vec2 grlNextP = grlFix( grlNextPos, grlAspect );
|
|
246
|
+
|
|
247
|
+
float grlWidth = grlBaseWidth * grl_widths;
|
|
248
|
+
|
|
249
|
+
vec2 grlDir;
|
|
250
|
+
if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );
|
|
251
|
+
else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );
|
|
252
|
+
else {
|
|
253
|
+
vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );
|
|
254
|
+
vec2 grlDir2 = normalize( grlNextP - grlCurrentP );
|
|
255
|
+
grlDir = normalize( grlDir1 + grlDir2 );
|
|
256
|
+
}
|
|
257
|
+
vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );
|
|
258
|
+
grlNormal.xy *= .5 * grlWidth;
|
|
259
|
+
grlNormal *= grl_projection;
|
|
260
|
+
#ifdef GREASED_LINE_SIZE_ATTENUATION
|
|
261
|
+
grlNormal.xy *= grlFinalPosition.w;
|
|
262
|
+
grlNormal.xy /= ( vec4( grlResolution, 0., 1. ) * grl_projection ).xy;
|
|
263
|
+
#endif
|
|
264
|
+
grlFinalPosition.xy += grlNormal.xy * grlSide;
|
|
265
|
+
gl_Position = grlFinalPosition;
|
|
266
|
+
|
|
267
|
+
vPositionW = vec3(grlFinalPosition);
|
|
268
|
+
|
|
269
|
+
`,
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
271
|
+
"!gl_Position\\=viewProjection\\*worldPos;": "//", // remove
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (shaderType === "fragment") {
|
|
275
|
+
return {
|
|
276
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
277
|
+
CUSTOM_FRAGMENT_DEFINITIONS: `
|
|
278
|
+
varying float grlCounters;
|
|
279
|
+
varying float grlColorPointer;
|
|
280
|
+
uniform sampler2D grl_colors;
|
|
281
|
+
`,
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
283
|
+
CUSTOM_FRAGMENT_MAIN_END: `
|
|
284
|
+
float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;
|
|
285
|
+
float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;
|
|
286
|
+
float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;
|
|
287
|
+
float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;
|
|
288
|
+
|
|
289
|
+
float grlUseDash = grl_dashOptions.x;
|
|
290
|
+
float grlDashArray = grl_dashOptions.y;
|
|
291
|
+
float grlDashOffset = grl_dashOptions.z;
|
|
292
|
+
float grlDashRatio = grl_dashOptions.w;
|
|
293
|
+
|
|
294
|
+
gl_FragColor.a *= step(grlCounters, grlVisibility);
|
|
295
|
+
if( gl_FragColor.a == 0. ) discard;
|
|
296
|
+
|
|
297
|
+
if(grlUseDash == 1.){
|
|
298
|
+
gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));
|
|
299
|
+
if (gl_FragColor.a == 0.) discard;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
#ifdef GREASED_LINE_HAS_COLOR
|
|
303
|
+
if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {
|
|
304
|
+
gl_FragColor.rgb = grl_singleColor;
|
|
305
|
+
} else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {
|
|
306
|
+
gl_FragColor.rgb += grl_singleColor;
|
|
307
|
+
} else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {
|
|
308
|
+
gl_FragColor.rgb *= grl_singleColor;
|
|
309
|
+
}
|
|
310
|
+
#else
|
|
311
|
+
if (grlUseColors == 1.) {
|
|
312
|
+
#ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE
|
|
313
|
+
vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);
|
|
314
|
+
#else
|
|
315
|
+
vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);
|
|
316
|
+
#endif
|
|
317
|
+
if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {
|
|
318
|
+
gl_FragColor = grlColor;
|
|
319
|
+
} else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {
|
|
320
|
+
gl_FragColor += grlColor;
|
|
321
|
+
} else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {
|
|
322
|
+
gl_FragColor *= grlColor;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
#endif
|
|
326
|
+
`,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Converts boolean to number.
|
|
333
|
+
* @param bool
|
|
334
|
+
* @returns 1 if true, 0 if false.
|
|
335
|
+
*/
|
|
336
|
+
static _BooleanToNumber(bool) {
|
|
337
|
+
return bool ? 1 : 0;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Converts an array of Color3 to Uint8Array
|
|
341
|
+
* @param colors Arrray of Color3
|
|
342
|
+
* @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]
|
|
343
|
+
*/
|
|
344
|
+
static _Color3toRGBAUint8(colors) {
|
|
345
|
+
const colorTable = new Uint8Array(colors.length * 4);
|
|
346
|
+
for (let i = 0, j = 0; i < colors.length; i++) {
|
|
347
|
+
colorTable[j++] = colors[i].r * 255;
|
|
348
|
+
colorTable[j++] = colors[i].g * 255;
|
|
349
|
+
colorTable[j++] = colors[i].b * 255;
|
|
350
|
+
colorTable[j++] = 255;
|
|
351
|
+
}
|
|
352
|
+
return colorTable;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
|
|
356
|
+
* @param name name of the texture
|
|
357
|
+
* @param colors Uint8Array of colors
|
|
358
|
+
*/
|
|
359
|
+
_createColorsTexture(name, colors) {
|
|
360
|
+
var _a;
|
|
361
|
+
const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
|
|
362
|
+
this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, (_a = this._options.colorsSampling) !== null && _a !== void 0 ? _a : RawTexture.NEAREST_NEAREST);
|
|
363
|
+
this._colorsTexture.name = name;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Disposes the plugin material.
|
|
367
|
+
*/
|
|
368
|
+
dispose() {
|
|
369
|
+
var _a;
|
|
370
|
+
(_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
371
|
+
super.dispose();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Sets whether to use the colors option to colorize the line.
|
|
375
|
+
* @param value true if use the colors, otherwise false
|
|
376
|
+
*/
|
|
377
|
+
setUseColors(value) {
|
|
378
|
+
this._options.useColors = value;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Creates or updates the colors texture
|
|
382
|
+
* @param colors color table RGBA
|
|
383
|
+
* @param lazy if lazy, the colors are not updated
|
|
384
|
+
* @param forceUpdate force creation of a new texture
|
|
385
|
+
* @returns
|
|
386
|
+
*/
|
|
387
|
+
setColors(colors, lazy = false, forceUpdate = false) {
|
|
388
|
+
var _a, _b, _c, _d;
|
|
389
|
+
if (colors === null || colors.length === 0) {
|
|
390
|
+
(_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const origColorsCount = (_c = (_b = this._options.colors) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
394
|
+
this._options.colors = colors;
|
|
395
|
+
if (lazy && !forceUpdate) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (this._colorsTexture && origColorsCount === colors.length && !forceUpdate) {
|
|
399
|
+
const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
|
|
400
|
+
this._colorsTexture.update(colorArray);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
(_d = this._colorsTexture) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
404
|
+
this._createColorsTexture(`${this._material.name}-colors-texture`, colors);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Updates the material. Use when material created in lazy mode.
|
|
409
|
+
*/
|
|
410
|
+
updateLazy() {
|
|
411
|
+
if (this._options.colors) {
|
|
412
|
+
this.setColors(this._options.colors, false, true);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Gets the plugin material options
|
|
417
|
+
* @returns the plugin material options @see GreasedLineMaterialOptions
|
|
418
|
+
*/
|
|
419
|
+
getOptions() {
|
|
420
|
+
return this._options;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Sets the line length visibility.
|
|
424
|
+
* 0 - 0% of the line will be visible
|
|
425
|
+
* 1 - 100% of the line will be visible
|
|
426
|
+
* @param value
|
|
427
|
+
*/
|
|
428
|
+
setVisibility(value) {
|
|
429
|
+
this._options.visibility = value;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Turns on/off dashmode
|
|
433
|
+
* @param value
|
|
434
|
+
*/
|
|
435
|
+
setUseDash(value) {
|
|
436
|
+
this._options.useDash = value;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Sets the dash array.
|
|
440
|
+
* @param value dash array
|
|
441
|
+
*/
|
|
442
|
+
setDashCount(value) {
|
|
443
|
+
this._options.dashCount = value;
|
|
444
|
+
this._dashArray = 1 / value;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Sets the dash ratio
|
|
448
|
+
* @param value dash length ratio 0..1 (0.5 = half empty, half drawn)
|
|
449
|
+
*/
|
|
450
|
+
setDashRatio(value) {
|
|
451
|
+
this._options.dashRatio = value;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Sets the dash offset
|
|
455
|
+
* @param value the dashes will be offset by this value
|
|
456
|
+
*/
|
|
457
|
+
setDashOffset(value) {
|
|
458
|
+
this._options.dashOffset = value;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Sets line base width. At each point the line width is calculated by widths[pointIndex] * width
|
|
462
|
+
* @param value base width
|
|
463
|
+
*/
|
|
464
|
+
setWidth(value) {
|
|
465
|
+
this._options.width = value;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Turn on/off attenuation of the width option and widths array.
|
|
469
|
+
* @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines
|
|
470
|
+
*/
|
|
471
|
+
setSizeAttenuation(value) {
|
|
472
|
+
this._options.sizeAttenuation = value;
|
|
473
|
+
this.markAllDefinesAsDirty();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.
|
|
477
|
+
* @param value color
|
|
478
|
+
*/
|
|
479
|
+
setColor(value, doNotMarkDirty = false) {
|
|
480
|
+
if ((this._options.color === undefined && value !== undefined) || (this._options.color !== undefined && value === undefined)) {
|
|
481
|
+
this._options.color = value;
|
|
482
|
+
!doNotMarkDirty && this.markAllDefinesAsDirty();
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
this._options.color = value;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Sets the mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET
|
|
490
|
+
* @see GreasedLineMeshColorMode
|
|
491
|
+
* @param value color mode
|
|
492
|
+
*/
|
|
493
|
+
setColorMode(value) {
|
|
494
|
+
this._options.colorMode = value;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Serializes this plugin material
|
|
498
|
+
* @returns serializationObjec
|
|
499
|
+
*/
|
|
500
|
+
serialize() {
|
|
501
|
+
const serializationObject = super.serialize();
|
|
502
|
+
serializationObject.materialOptions = {};
|
|
503
|
+
DeepCopier.DeepCopy(this._options, serializationObject.materialOptions);
|
|
504
|
+
return serializationObject;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Parses a serialized objects
|
|
508
|
+
* @param source serialized object
|
|
509
|
+
* @param scene scene
|
|
510
|
+
* @param rootUrl root url for textures
|
|
511
|
+
*/
|
|
512
|
+
parse(source, scene, rootUrl) {
|
|
513
|
+
var _a;
|
|
514
|
+
super.parse(source, scene, rootUrl);
|
|
515
|
+
this._options = source.materialOptions;
|
|
516
|
+
(_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
517
|
+
if (this._options.colors) {
|
|
518
|
+
this._createColorsTexture(`${this._material.name}-colors-texture`, this._options.colors);
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);
|
|
522
|
+
}
|
|
523
|
+
this._options.color && this.setColor(this._options.color, true);
|
|
524
|
+
this._options.colorMode && this.setColorMode(this._options.colorMode);
|
|
525
|
+
this._options.useColors && this.setUseColors(this._options.useColors);
|
|
526
|
+
this._options.visibility && this.setVisibility(this._options.visibility);
|
|
527
|
+
this._options.useDash && this.setUseDash(this._options.useDash);
|
|
528
|
+
this._options.dashCount && this.setDashCount(this._options.dashCount);
|
|
529
|
+
this._options.dashRatio && this.setDashRatio(this._options.dashRatio);
|
|
530
|
+
this._options.dashOffset && this.setDashOffset(this._options.dashOffset);
|
|
531
|
+
this._options.width && this.setWidth(this._options.width);
|
|
532
|
+
this._options.sizeAttenuation && this.setSizeAttenuation(this._options.sizeAttenuation);
|
|
533
|
+
this.markAllDefinesAsDirty();
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* A minimum size texture for the colors sampler2D when there is no colors texture defined yet.
|
|
537
|
+
* For fast switching using the useColors property without the need to use defines.
|
|
538
|
+
* @param scene Scene
|
|
539
|
+
*/
|
|
540
|
+
static _PrepareEmptyColorsTexture(scene) {
|
|
541
|
+
if (!this._EmptyColorsTexture) {
|
|
542
|
+
const colorsArray = new Uint8Array(4);
|
|
543
|
+
this._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);
|
|
544
|
+
this._EmptyColorsTexture.name = "grlEmptyColorsTexture";
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Plugin name
|
|
550
|
+
*/
|
|
551
|
+
GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial";
|
|
552
|
+
RegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);
|
|
553
|
+
//# sourceMappingURL=greasedLinePluginMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greasedLinePluginMaterial.js","sourceRoot":"","sources":["../../../../lts/core/generated/Materials/greasedLinePluginMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACnC,iHAA0B,CAAA;IAC1B,uGAAqB,CAAA;AACzB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AA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C,QAAQ,CAAC,eAAe,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAExF,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,0BAA0B,CAAC,KAAY;QAClD,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC3B,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,mBAAmB,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;YACzI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,uBAAuB,CAAC;SAC3D;IACL,CAAC;;AA9iBD;;GAEG;AACoB,oDAA0B,GAAG,2BAA2B,AAA9B,CAA+B;AA8iBpF,aAAa,CAAC,WAAW,yBAAyB,CAAC,0BAA0B,EAAE,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { Engine } from \"../Engines/engine\";\r\nimport { RawTexture } from \"./Textures/rawTexture\";\r\nimport { MaterialPluginBase } from \"./materialPluginBase\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport { TmpVectors } from \"../Maths/math.vector\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Material } from \"./material\";\r\nimport { MaterialDefines } from \"./materialDefines\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { BaseTexture } from \"./Textures/baseTexture\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\nexport enum GreasedLineMeshMaterialType {\r\n MATERIAL_TYPE_STANDARD = 0,\r\n MATERIAL_TYPE_PBR = 1,\r\n}\r\n\r\nexport enum GreasedLineMeshColorMode {\r\n COLOR_MODE_SET = 0,\r\n COLOR_MODE_ADD = 1,\r\n COLOR_MODE_MULTIPLY = 2,\r\n}\r\n\r\nexport enum GreasedLineMeshColorDistributionType {\r\n COLOR_DISTRIBUTION_TYPE_SEGMENT = 0,\r\n COLOR_DISTRIBUTION_TYPE_LINE = 1,\r\n}\r\n\r\n/**\r\n * Options for GreasedLineMaterial\r\n */\r\nexport interface GreasedLineMaterialOptions {\r\n /**\r\n * Line width. If sizeAttenuation os false scene units will be used for width.\r\n * Defaults to 0.1 if @see sizeAttenuation is false, or to 1 if it's true.\r\n */\r\n width?: number;\r\n /**\r\n * If false then width units = scene units. If true then line will width be reduced.\r\n * Defaults to false.\r\n */\r\n sizeAttenuation?: boolean;\r\n /**\r\n * Type of the material to use to render the line.\r\n * Defaults to StandardMaterial.\r\n */\r\n materialType?: GreasedLineMeshMaterialType;\r\n /**\r\n * Color of the line. Applies to all line segments.\r\n * Defaults to White.\r\n */\r\n color?: Color3;\r\n /**\r\n * Color mode of the line. Applies to all line segments.\r\n * The pixel color from the material shader will be modified with the value of @see color using the colorMode.\r\n * Defaults to @see GreasedLineMeshColorMode.SET\r\n */\r\n colorMode?: GreasedLineMeshColorMode;\r\n /**\r\n * Colors of the line segments.\r\n * Defaults to empty.\r\n */\r\n colors?: Color3[];\r\n /**\r\n * If true, @see colors are used, otherwise they're ignored.\r\n * Defaults to false.\r\n */\r\n useColors?: boolean;\r\n /**\r\n * Sampling type of the colors texture\r\n * Defaults to NEAREST_NEAREST.\r\n */\r\n colorsSampling?: number;\r\n /**\r\n * The method used to distribute the colors along the line.\r\n * You can use segment distribution when each segment will use on color from the color table.\r\n * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.\r\n */\r\n colorDistributionType?: GreasedLineMeshColorDistributionType;\r\n /**\r\n * If true, dashing is used.\r\n * Defaults to false.\r\n */\r\n useDash?: boolean;\r\n /**\r\n * @see GreasedLinePluginMaterial.setDashCount\r\n * Number of dashes in the line.\r\n * Defaults to 1.\r\n */\r\n dashCount?: number;\r\n /**\r\n * Offset of the dashes along the line. 0 to 1.\r\n * Defaults to 0.\r\n * @see GreasedLinePluginMaterial.setDashOffset\r\n */\r\n dashOffset?: number;\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n * Defaults to 0.5.\r\n * @see GreasedLinePluginMaterial.setDashRatio\r\n */\r\n dashRatio?: number;\r\n /**\r\n * Sets the line length visibility.\r\n * 0 - 0% of the line will be visible.\r\n * 1 - 100% of the line will be visible.\r\n * @see GreasedLinePluginMaterial.setVisibility\r\n */\r\n visibility?: number;\r\n /**\r\n * Defaults to engine.getRenderWidth() and engine.getRenderHeight()\r\n * Rendering resolution\r\n */\r\n resolution?: Vector2;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class MaterialGreasedLineDefines extends MaterialDefines {\r\n /**\r\n * The material has a color option specified\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_HAS_COLOR = false;\r\n /**\r\n * The material's size attenuation optiom\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_SIZE_ATTENUATION = false;\r\n /**\r\n * The type of color distribution is set to line this value equals to true.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = false;\r\n}\r\n\r\n/**\r\n * GreasedLinePluginMaterial for GreasedLineMesh\r\n */\r\nexport class GreasedLinePluginMaterial extends MaterialPluginBase {\r\n /**\r\n * Plugin name\r\n */\r\n public static readonly GREASED_LINE_MATERIAL_NAME = \"GreasedLinePluginMaterial\";\r\n\r\n private _colorsTexture?: RawTexture;\r\n\r\n private _dashArray = 0;\r\n\r\n private _options: GreasedLineMaterialOptions;\r\n\r\n private _engine: Engine;\r\n\r\n private static _EmptyColorsTexture: BaseTexture;\r\n\r\n constructor(material: Material, private _scene: Scene, options: GreasedLineMaterialOptions) {\r\n options = options ?? {};\r\n\r\n const defines = new MaterialGreasedLineDefines();\r\n defines.GREASED_LINE_HAS_COLOR = !!options.color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = options.sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n\r\n super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);\r\n\r\n this._options = options;\r\n this._scene = this._scene ?? material.getScene();\r\n this._engine = this._scene.getEngine();\r\n\r\n if (options.colors) {\r\n this._createColorsTexture(`${material.name}-colors-texture`, options.colors);\r\n } else {\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);\r\n }\r\n\r\n this.setDashCount(options.dashCount ?? 1); // calculate the _dashArray value\r\n\r\n this._enable(true); // always enabled\r\n }\r\n\r\n /**\r\n * Get the shader attributes\r\n * @param attributes array which will be filled with the attributes\r\n */\r\n getAttributes(attributes: string[]) {\r\n attributes.push(\"grl_offsets\");\r\n attributes.push(\"grl_previousAndSide\");\r\n attributes.push(\"grl_nextAndCounters\");\r\n attributes.push(\"grl_widths\");\r\n attributes.push(\"grl_colorPointers\");\r\n }\r\n\r\n /**\r\n * Get the shader samplers\r\n * @param samplers\r\n */\r\n getSamplers(samplers: string[]) {\r\n samplers.push(\"grl_colors\");\r\n }\r\n\r\n /**\r\n * Get the shader textures\r\n * @param activeTextures\r\n */\r\n public getActiveTextures(activeTextures: BaseTexture[]): void {\r\n if (this._colorsTexture) {\r\n activeTextures.push(this._colorsTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Get the shader uniforms\r\n * @returns uniforms\r\n */\r\n getUniforms() {\r\n const ubo = [\r\n { name: \"grl_projection\", size: 16, type: \"mat4\" },\r\n { name: \"grl_singleColor\", size: 3, type: \"vec3\" },\r\n { name: \"grl_resolution_lineWidth\", size: 3, type: \"vec3\" },\r\n { name: \"grl_dashOptions\", size: 4, type: \"vec4\" },\r\n { name: \"grl_colorMode_visibility_colorsWidth_useColors\", size: 4, type: \"vec4\" },\r\n ];\r\n\r\n return {\r\n ubo,\r\n vertex: `\r\n uniform vec3 grl_resolution_lineWidth;\r\n uniform mat4 grl_projection;\r\n `,\r\n fragment: `\r\n uniform vec4 grl_dashOptions;\r\n uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;\r\n uniform vec3 grl_singleColor;\r\n `,\r\n };\r\n }\r\n\r\n // only getter, it doesn't make sense to use this plugin on a mesh other than GreasedLineMesh\r\n // and it doesn't make sense to disable it on the mesh\r\n get isEnabled() {\r\n return true;\r\n }\r\n\r\n /**\r\n * Bind the uniform buffer\r\n * @param uniformBuffer\r\n */\r\n bindForSubMesh(uniformBuffer: UniformBuffer) {\r\n const activeCamera = this._scene.activeCamera;\r\n\r\n if (activeCamera) {\r\n const projection = activeCamera.getProjectionMatrix();\r\n uniformBuffer.updateMatrix(\"grl_projection\", projection);\r\n } else {\r\n throw Error(\"GreasedLinePluginMaterial requires an active camera.\");\r\n }\r\n\r\n const resolutionLineWidth = TmpVectors.Vector3[0];\r\n if (this._options.resolution) {\r\n resolutionLineWidth.x = this._options.resolution.x;\r\n resolutionLineWidth.y = this._options.resolution.y;\r\n } else {\r\n resolutionLineWidth.x = this._engine.getRenderWidth();\r\n resolutionLineWidth.y = this._engine.getRenderHeight();\r\n }\r\n resolutionLineWidth.z = this._options.width ? this._options.width : this._options.sizeAttenuation ? 1 : 0.1;\r\n uniformBuffer.updateVector3(\"grl_resolution_lineWidth\", resolutionLineWidth);\r\n\r\n const dashOptions = TmpVectors.Vector4[0];\r\n dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this._options.useDash);\r\n dashOptions.y = this._dashArray ?? 0;\r\n dashOptions.z = this._options.dashOffset ?? 0;\r\n dashOptions.w = this._options.dashRatio ?? 0.5;\r\n uniformBuffer.updateVector4(\"grl_dashOptions\", dashOptions);\r\n\r\n const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];\r\n colorModeVisibilityColorsWidthUseColors.x = this._options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n colorModeVisibilityColorsWidthUseColors.y = this._options.visibility ?? 1;\r\n colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;\r\n colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this._options.useColors);\r\n uniformBuffer.updateVector4(\"grl_colorMode_visibility_colorsWidth_useColors\", colorModeVisibilityColorsWidthUseColors);\r\n\r\n if (this._options.color) {\r\n uniformBuffer.updateColor3(\"grl_singleColor\", this._options.color ?? Color3.White());\r\n }\r\n\r\n uniformBuffer.setTexture(\"grl_colors\", this._colorsTexture ?? GreasedLinePluginMaterial._EmptyColorsTexture);\r\n }\r\n\r\n /**\r\n * Prepare the defines\r\n * @param defines\r\n * @param _scene\r\n * @param _mesh\r\n */\r\n prepareDefines(defines: MaterialGreasedLineDefines, _scene: Scene, _mesh: AbstractMesh) {\r\n const options = this._options;\r\n defines.GREASED_LINE_HAS_COLOR = !!options.color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = options.sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n }\r\n\r\n /**\r\n * Get the class name\r\n * @returns class name\r\n */\r\n getClassName() {\r\n return GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME;\r\n }\r\n\r\n /**\r\n * Get shader code\r\n * @param shaderType vertex/fragment\r\n * @returns shader code\r\n */\r\n getCustomCode(shaderType: string): Nullable<{ [pointName: string]: string }> {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_DEFINITIONS: `\r\n attribute vec4 grl_previousAndSide;\r\n attribute vec4 grl_nextAndCounters;\r\n attribute float grl_widths;\r\n attribute vec3 grl_offsets;\r\n attribute float grl_colorPointers;\r\n\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n\r\n vec2 grlFix( vec4 i, float aspect ) {\r\n vec2 res = i.xy / i.w;\r\n res.x *= aspect;\r\n return res;\r\n }\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_UPDATE_POSITION: `\r\n vec3 grlPositionOffset = grl_offsets;\r\n positionUpdated += grlPositionOffset;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_MAIN_END: `\r\n vec2 grlResolution = grl_resolution_lineWidth.xy;\r\n float grlBaseWidth = grl_resolution_lineWidth.z;\r\n\r\n grlColorPointer = grl_colorPointers;\r\n\r\n vec3 grlPrevious = grl_previousAndSide.xyz;\r\n float grlSide = grl_previousAndSide.w;\r\n\r\n vec3 grlNext = grl_nextAndCounters.xyz;\r\n grlCounters = grl_nextAndCounters.w;\r\n\r\n float grlAspect = grlResolution.x / grlResolution.y;\r\n\r\n mat4 grlMatrix = viewProjection * world;\r\n vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );\r\n vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );\r\n vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );\r\n\r\n vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );\r\n vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );\r\n vec2 grlNextP = grlFix( grlNextPos, grlAspect );\r\n\r\n float grlWidth = grlBaseWidth * grl_widths;\r\n\r\n vec2 grlDir;\r\n if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );\r\n else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );\r\n else {\r\n vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );\r\n vec2 grlDir2 = normalize( grlNextP - grlCurrentP );\r\n grlDir = normalize( grlDir1 + grlDir2 );\r\n }\r\n vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );\r\n grlNormal.xy *= .5 * grlWidth;\r\n grlNormal *= grl_projection;\r\n #ifdef GREASED_LINE_SIZE_ATTENUATION\r\n grlNormal.xy *= grlFinalPosition.w;\r\n grlNormal.xy /= ( vec4( grlResolution, 0., 1. ) * grl_projection ).xy;\r\n #endif\r\n grlFinalPosition.xy += grlNormal.xy * grlSide;\r\n gl_Position = grlFinalPosition;\r\n\r\n vPositionW = vec3(grlFinalPosition);\r\n\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"!gl_Position\\\\=viewProjection\\\\*worldPos;\": \"//\", // remove\r\n };\r\n }\r\n\r\n if (shaderType === \"fragment\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n uniform sampler2D grl_colors;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_MAIN_END: `\r\n float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;\r\n float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;\r\n float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;\r\n float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;\r\n\r\n float grlUseDash = grl_dashOptions.x;\r\n float grlDashArray = grl_dashOptions.y;\r\n float grlDashOffset = grl_dashOptions.z;\r\n float grlDashRatio = grl_dashOptions.w;\r\n\r\n gl_FragColor.a *= step(grlCounters, grlVisibility);\r\n if( gl_FragColor.a == 0. ) discard;\r\n\r\n if(grlUseDash == 1.){\r\n gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));\r\n if (gl_FragColor.a == 0.) discard;\r\n }\r\n\r\n #ifdef GREASED_LINE_HAS_COLOR\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor.rgb = grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor.rgb += grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor.rgb *= grl_singleColor;\r\n }\r\n #else\r\n if (grlUseColors == 1.) {\r\n #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);\r\n #else\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);\r\n #endif\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor = grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor += grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor *= grlColor;\r\n }\r\n }\r\n #endif\r\n `,\r\n };\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool\r\n * @returns 1 if true, 0 if false.\r\n */\r\n private static _BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n private static _Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n */\r\n private _createColorsTexture(name: string, colors: Color3[]) {\r\n const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture = new RawTexture(\r\n colorsArray,\r\n colors.length,\r\n 1,\r\n Engine.TEXTUREFORMAT_RGBA,\r\n this._scene,\r\n false,\r\n true,\r\n this._options.colorsSampling ?? RawTexture.NEAREST_NEAREST\r\n );\r\n this._colorsTexture.name = name;\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Sets whether to use the colors option to colorize the line.\r\n * @param value true if use the colors, otherwise false\r\n */\r\n public setUseColors(value: boolean) {\r\n this._options.useColors = value;\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceUpdate force creation of a new texture\r\n * @returns\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceUpdate = false): void {\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n const origColorsCount = this._options.colors?.length ?? 0;\r\n\r\n this._options.colors = colors;\r\n\r\n if (lazy && !forceUpdate) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceUpdate) {\r\n const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, colors);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._options.colors) {\r\n this.setColors(this._options.colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the plugin material options\r\n * @returns the plugin material options @see GreasedLineMaterialOptions\r\n */\r\n public getOptions(): GreasedLineMaterialOptions {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Sets the line length visibility.\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n * @param value\r\n */\r\n public setVisibility(value: number) {\r\n this._options.visibility = value;\r\n }\r\n\r\n /**\r\n * Turns on/off dashmode\r\n * @param value\r\n */\r\n public setUseDash(value: boolean) {\r\n this._options.useDash = value;\r\n }\r\n\r\n /**\r\n * Sets the dash array.\r\n * @param value dash array\r\n */\r\n public setDashCount(value: number) {\r\n this._options.dashCount = value;\r\n this._dashArray = 1 / value;\r\n }\r\n\r\n /**\r\n * Sets the dash ratio\r\n * @param value dash length ratio 0..1 (0.5 = half empty, half drawn)\r\n */\r\n public setDashRatio(value: number) {\r\n this._options.dashRatio = value;\r\n }\r\n\r\n /**\r\n * Sets the dash offset\r\n * @param value the dashes will be offset by this value\r\n */\r\n public setDashOffset(value: number) {\r\n this._options.dashOffset = value;\r\n }\r\n\r\n /**\r\n * Sets line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n * @param value base width\r\n */\r\n public setWidth(value: number) {\r\n this._options.width = value;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n public setSizeAttenuation(value: boolean) {\r\n this._options.sizeAttenuation = value;\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * @param value color\r\n */\r\n public setColor(value: Color3 | undefined, doNotMarkDirty = false) {\r\n if ((this._options.color === undefined && value !== undefined) || (this._options.color !== undefined && value === undefined)) {\r\n this._options.color = value;\r\n !doNotMarkDirty && this.markAllDefinesAsDirty();\r\n } else {\r\n this._options.color = value;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET\r\n * @see GreasedLineMeshColorMode\r\n * @param value color mode\r\n */\r\n public setColorMode(value: GreasedLineMeshColorMode) {\r\n this._options.colorMode = value;\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.materialOptions = {};\r\n DeepCopier.DeepCopy(this._options, serializationObject.materialOptions);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n super.parse(source, scene, rootUrl);\r\n this._options = <GreasedLineMaterialOptions>source.materialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n if (this._options.colors) {\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, this._options.colors);\r\n } else {\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n this._options.color && this.setColor(this._options.color, true);\r\n this._options.colorMode && this.setColorMode(this._options.colorMode);\r\n this._options.useColors && this.setUseColors(this._options.useColors);\r\n this._options.visibility && this.setVisibility(this._options.visibility);\r\n this._options.useDash && this.setUseDash(this._options.useDash);\r\n this._options.dashCount && this.setDashCount(this._options.dashCount);\r\n this._options.dashRatio && this.setDashRatio(this._options.dashRatio);\r\n this._options.dashOffset && this.setDashOffset(this._options.dashOffset);\r\n this._options.width && this.setWidth(this._options.width);\r\n this._options.sizeAttenuation && this.setSizeAttenuation(this._options.sizeAttenuation);\r\n\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n */\r\n private static _PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!this._EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n this._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n this._EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);\r\n"]}
|