@babylonjs/core 6.8.0 → 6.9.0
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.d.ts +4 -5
- package/Actions/action.js.map +1 -1
- package/Actions/condition.d.ts +1 -2
- package/Actions/condition.js.map +1 -1
- package/Actions/directActions.d.ts +1 -2
- package/Actions/directActions.js.map +1 -1
- package/Animations/animatable.interface.d.ts +1 -2
- package/Animations/animatable.interface.js.map +1 -1
- package/Animations/animation.d.ts +3 -4
- 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/Animations/runtimeAnimation.d.ts +1 -2
- package/Animations/runtimeAnimation.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.d.ts +3 -3
- 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.d.ts +1 -2
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +6 -7
- 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/Collisions/meshCollisionData.d.ts +1 -2
- package/Collisions/meshCollisionData.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +1 -2
- package/Collisions/pickingInfo.js.map +1 -1
- package/Compute/computeEffect.d.ts +1 -2
- 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/Octrees/octreeSceneComponent.d.ts +1 -2
- package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
- package/Culling/boundingBox.d.ts +1 -2
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/boundingInfo.d.ts +1 -2
- package/Culling/boundingInfo.js.map +1 -1
- package/Culling/boundingSphere.js.map +1 -1
- 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.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.storageBuffer.d.ts +1 -2
- package/Engines/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/Extensions/engine.textureSampler.d.ts +1 -2
- package/Engines/Extensions/engine.textureSampler.js.map +1 -1
- package/Engines/Extensions/engine.webVR.js +1 -5
- package/Engines/Extensions/engine.webVR.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/iShaderProcessor.d.ts +1 -2
- package/Engines/Processors/iShaderProcessor.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.d.ts +5 -6
- package/Engines/Processors/shaderProcessor.js +10 -3
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLShaderProcessors.d.ts +1 -2
- package/Engines/WebGL/webGLShaderProcessors.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.query.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.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/Extensions/engine.storageBuffer.d.ts +1 -2
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.d.ts +1 -2
- package/Engines/WebGPU/Extensions/engine.textureSampler.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/webgpuHardwareTexture.d.ts +1 -2
- package/Engines/WebGPU/webgpuHardwareTexture.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 +3 -3
- package/Engines/engine.js.map +1 -1
- package/Engines/engineStore.d.ts +4 -5
- package/Engines/engineStore.js.map +1 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -9
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +3 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -2
- package/Engines/webgpuEngine.js +3 -14
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/pointerEvents.d.ts +1 -2
- package/Events/pointerEvents.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.d.ts +1 -2
- 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/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +2 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +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 +2 -3
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +3 -4
- 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/Particle/particleTextureBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.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.js +2 -8
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialDecorator.d.ts +2 -3
- package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -4
- 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.d.ts +3 -4
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -4
- 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.d.ts +3 -4
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +3 -4
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +2 -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.d.ts +2 -3
- package/Materials/Textures/htmlElementTexture.js +1 -4
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +3 -4
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawTexture.d.ts +1 -2
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.d.ts +1 -2
- package/Materials/Textures/rawTexture2DArray.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +1 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +4 -5
- 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/drawWrapper.d.ts +3 -4
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +5 -6
- package/Materials/effect.js.map +1 -1
- package/Materials/effectFallbacks.d.ts +2 -3
- package/Materials/effectFallbacks.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/iEffectFallbacks.d.ts +1 -2
- package/Materials/iEffectFallbacks.js.map +1 -1
- package/Materials/imageProcessingConfiguration.d.ts +2 -3
- 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 +6 -4
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.d.ts +4 -5
- 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 +13 -14
- package/Materials/materialPluginBase.js +2 -2
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginEvent.d.ts +8 -9
- package/Materials/materialPluginEvent.js.map +1 -1
- package/Materials/materialPluginFactoryExport.d.ts +1 -2
- package/Materials/materialPluginFactoryExport.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +6 -6
- package/Materials/materialPluginManager.js +3 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/materialStencilState.d.ts +1 -2
- package/Materials/materialStencilState.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +4 -5
- package/Materials/shaderMaterial.js +6 -19
- 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/Builders/linesBuilder.d.ts +1 -2
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/Builders/textBuilder.d.ts +34 -0
- package/Meshes/Builders/textBuilder.js +10 -2
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +6 -6
- package/Meshes/abstractMesh.js +3 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +1 -2
- package/Meshes/geometry.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 +10 -6
- package/Meshes/mesh.js +20 -10
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -3
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +1 -8
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/subMesh.d.ts +7 -8
- package/Meshes/subMesh.js.map +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/basis.js.map +1 -1
- package/Misc/copyTools.d.ts +1 -2
- package/Misc/copyTools.js.map +1 -1
- package/Misc/decorators.d.ts +5 -6
- package/Misc/decorators.js.map +1 -1
- package/Misc/deepCopier.js +7 -1
- 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 +153 -0
- package/Misc/greasedLineTools.js +299 -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/rgbdTextureTools.d.ts +3 -4
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/screenshotTools.d.ts +16 -7
- 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.d.ts +2 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Offline/database.js.map +1 -1
- package/Particles/EmitterTypes/IParticleEmitterType.d.ts +1 -2
- package/Particles/EmitterTypes/IParticleEmitterType.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +2 -3
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +1 -2
- package/Particles/gpuParticleSystem.js +2 -6
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +1 -2
- package/Particles/particleSystem.js +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemSet.js.map +1 -1
- package/Particles/subEmitter.d.ts +2 -3
- package/Particles/subEmitter.js.map +1 -1
- package/Particles/webgl2ParticleSystem.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.d.ts +1 -2
- 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.d.ts +1 -2
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +1 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.d.ts +1 -2
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +1 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.d.ts +1 -2
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.d.ts +1 -2
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.d.ts +1 -2
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.d.ts +1 -2
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.d.ts +1 -2
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.d.ts +1 -2
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.d.ts +1 -2
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.d.ts +2 -3
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +1 -2
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +6 -6
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.d.ts +1 -2
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/PostProcesses/refractionPostProcess.d.ts +1 -2
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.d.ts +2 -3
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.d.ts +2 -3
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.d.ts +2 -3
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.d.ts +1 -2
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +1 -2
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthRenderer.d.ts +2 -3
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +2 -2
- 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.d.ts +5 -6
- 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 +3 -1
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Sprites/sprite.d.ts +1 -2
- package/Sprites/sprite.js.map +1 -1
- package/Sprites/spriteManager.d.ts +1 -2
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +2 -3
- package/Sprites/spriteRenderer.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 +2 -2
- 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.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/webXRExperienceHelper.js +1 -0
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.js +1 -4
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +1 -6
- package/XR/webXRInput.js.map +1 -1
- package/abstractScene.d.ts +3 -3
- package/abstractScene.js.map +1 -1
- package/assetContainer.js +1 -4
- package/assetContainer.js.map +1 -1
- package/node.d.ts +6 -7
- package/node.js.map +1 -1
- package/package.json +2 -4
- package/scene.d.ts +49 -50
- package/scene.js +4 -10
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +6 -7
- package/sceneComponent.js.map +1 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { Curve3 } from "../Maths/math.path.js";
|
|
2
|
+
import { VertexBuffer } from "../Buffers/buffer.js";
|
|
3
|
+
import { TmpVectors, Vector3 } from "../Maths/math.vector.js";
|
|
4
|
+
import { CreateTextShapePaths } from "../Meshes/Builders/textBuilder.js";
|
|
5
|
+
/**
|
|
6
|
+
* Tool functions for GreasedLine
|
|
7
|
+
*/
|
|
8
|
+
export class GreasedLineTools {
|
|
9
|
+
/**
|
|
10
|
+
* Gets mesh triangles as line positions
|
|
11
|
+
* @param meshes array of meshes
|
|
12
|
+
* @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero
|
|
13
|
+
* @returns array of arrays of points
|
|
14
|
+
*/
|
|
15
|
+
static MeshesToLines(meshes, omitZeroLengthLines = true) {
|
|
16
|
+
const points = [];
|
|
17
|
+
meshes.forEach((m) => {
|
|
18
|
+
const vertices = m.getVerticesData(VertexBuffer.PositionKind);
|
|
19
|
+
const indices = m.getIndices();
|
|
20
|
+
if (vertices && indices) {
|
|
21
|
+
for (let i = 0, ii = 0; i < indices.length; i++) {
|
|
22
|
+
const vi1 = indices[ii++] * 3;
|
|
23
|
+
const vi2 = indices[ii++] * 3;
|
|
24
|
+
const vi3 = indices[ii++] * 3;
|
|
25
|
+
const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);
|
|
26
|
+
const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);
|
|
27
|
+
const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);
|
|
28
|
+
if (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
points.push([p1, p2, p3, p1]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return points;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts number coordinates to Vector3s
|
|
39
|
+
* @param points number array of x, y, z, x, y z, ... coordinates
|
|
40
|
+
* @returns Vector3 array
|
|
41
|
+
*/
|
|
42
|
+
static ToVector3Array(points) {
|
|
43
|
+
const array = [];
|
|
44
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
45
|
+
array.push(new Vector3(points[i], points[i + 1], points[i + 2]));
|
|
46
|
+
}
|
|
47
|
+
return array;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets a number array from a Vector3 array.
|
|
51
|
+
* You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.
|
|
52
|
+
* @param points Vector3 array
|
|
53
|
+
* @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]
|
|
54
|
+
*/
|
|
55
|
+
static ToNumberArray(points) {
|
|
56
|
+
return points.flatMap((v) => [v.x, v.y, v.z]);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Calculates the sum of points of every line and the number of points in each line.
|
|
60
|
+
* This function is useful when you are drawing multiple lines in one mesh and you want
|
|
61
|
+
* to know the counts. For example for creating an offsets table.
|
|
62
|
+
* @param points point array
|
|
63
|
+
* @returns points count info
|
|
64
|
+
*/
|
|
65
|
+
static GetPointsCountInfo(points) {
|
|
66
|
+
const counts = new Array(points.length);
|
|
67
|
+
let total = 0;
|
|
68
|
+
for (let n = points.length; n--;) {
|
|
69
|
+
counts[n] = points[n].length / 3;
|
|
70
|
+
total += counts[n];
|
|
71
|
+
}
|
|
72
|
+
return { total, counts };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the length of the line counting all it's segments length
|
|
76
|
+
* @param data array of line points
|
|
77
|
+
* @returns length of the line
|
|
78
|
+
*/
|
|
79
|
+
static GetLineLength(data) {
|
|
80
|
+
if (data.length === 0) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
let points;
|
|
84
|
+
if (typeof data[0] === "number") {
|
|
85
|
+
points = GreasedLineTools.ToVector3Array(data);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
points = data;
|
|
89
|
+
}
|
|
90
|
+
const tmp = TmpVectors.Vector3[0];
|
|
91
|
+
let length = 0;
|
|
92
|
+
for (let index = 0; index < points.length - 1; index++) {
|
|
93
|
+
const point1 = points[index];
|
|
94
|
+
const point2 = points[index + 1];
|
|
95
|
+
length += point2.subtractToRef(point1, tmp).length();
|
|
96
|
+
}
|
|
97
|
+
return length;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Divides a segment into smaller segments.
|
|
101
|
+
* A segment is a part of the line between it's two points.
|
|
102
|
+
* @param point1 first point of the line
|
|
103
|
+
* @param point2 second point of the line
|
|
104
|
+
* @param segmentCount number of segments we want to have in the divided line
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
static SegmentizeSegmentByCount(point1, point2, segmentCount) {
|
|
108
|
+
const dividedLinePoints = [];
|
|
109
|
+
const diff = point2.subtract(point1);
|
|
110
|
+
const divisor = TmpVectors.Vector3[0];
|
|
111
|
+
divisor.setAll(segmentCount);
|
|
112
|
+
const segmentVector = TmpVectors.Vector3[1];
|
|
113
|
+
diff.divideToRef(divisor, segmentVector);
|
|
114
|
+
let nextPoint = point1.clone();
|
|
115
|
+
dividedLinePoints.push(nextPoint);
|
|
116
|
+
for (let index = 0; index < segmentCount; index++) {
|
|
117
|
+
nextPoint = nextPoint.clone();
|
|
118
|
+
dividedLinePoints.push(nextPoint.addInPlace(segmentVector));
|
|
119
|
+
}
|
|
120
|
+
return dividedLinePoints;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Divides a line into segments.
|
|
124
|
+
* A segment is a part of the line between it's two points.
|
|
125
|
+
* @param what line points
|
|
126
|
+
* @param segmentLength length of each segment of the resulting line (distance between two line points)
|
|
127
|
+
* @returns line point
|
|
128
|
+
*/
|
|
129
|
+
static SegmentizeLineBySegmentLength(what, segmentLength) {
|
|
130
|
+
const subLines = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what) : what;
|
|
131
|
+
const points = [];
|
|
132
|
+
subLines.forEach((s) => {
|
|
133
|
+
if (s.length > segmentLength) {
|
|
134
|
+
const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));
|
|
135
|
+
segments.forEach((seg) => {
|
|
136
|
+
points.push(seg);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
points.push(s.point1);
|
|
141
|
+
points.push(s.point2);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return points;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Divides a line into segments.
|
|
148
|
+
* A segment is a part of the line between it's two points.
|
|
149
|
+
* @param what line points
|
|
150
|
+
* @param segmentCount number of segments
|
|
151
|
+
* @returns line point
|
|
152
|
+
*/
|
|
153
|
+
static SegmentizeLineBySegmentCount(what, segmentCount) {
|
|
154
|
+
const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;
|
|
155
|
+
return GreasedLineTools.SegmentizeLineBySegmentLength(what, segmentLength);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets line segments.
|
|
159
|
+
* A segment is a part of the line between it's two points.
|
|
160
|
+
* @param points line points
|
|
161
|
+
* @returns segments information of the line segment including starting point, ending point and the distance between them
|
|
162
|
+
*/
|
|
163
|
+
static GetLineSegments(points) {
|
|
164
|
+
const segments = [];
|
|
165
|
+
for (let index = 0; index < points.length - 1; index++) {
|
|
166
|
+
const point1 = points[index];
|
|
167
|
+
const point2 = points[index + 1];
|
|
168
|
+
const length = point2.subtract(point1).length();
|
|
169
|
+
segments.push({ point1, point2, length });
|
|
170
|
+
}
|
|
171
|
+
return segments;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Gets the minimum and the maximum length of a line segment in the line.
|
|
175
|
+
* A segment is a part of the line between it's two points.
|
|
176
|
+
* @param points line points
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
static GetMinMaxSegmentLength(points) {
|
|
180
|
+
const subLines = GreasedLineTools.GetLineSegments(points);
|
|
181
|
+
const sorted = subLines.sort((s) => s.length);
|
|
182
|
+
return {
|
|
183
|
+
min: sorted[0].length,
|
|
184
|
+
max: sorted[sorted.length - 1].length,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Finds the last visible position in world space of the line according to the visibility parameter
|
|
189
|
+
* @param lineSegments segments of the line
|
|
190
|
+
* @param lineLength total length of the line
|
|
191
|
+
* @param visbility normalized value of visibility
|
|
192
|
+
* @returns world space coordinate of the last visible piece of the line
|
|
193
|
+
*/
|
|
194
|
+
static GetPositionOnLineByVisibility(lineSegments, lineLength, visbility, localSpace = false) {
|
|
195
|
+
const lengthVisibilityRatio = lineLength * visbility;
|
|
196
|
+
let sumSegmentLengths = 0;
|
|
197
|
+
let segmentIndex = 0;
|
|
198
|
+
const lineSegmentsLength = lineSegments.length;
|
|
199
|
+
for (let i = 0; i < lineSegmentsLength; i++) {
|
|
200
|
+
if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {
|
|
201
|
+
segmentIndex = i;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
sumSegmentLengths += lineSegments[i].length;
|
|
205
|
+
}
|
|
206
|
+
const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;
|
|
207
|
+
lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);
|
|
208
|
+
TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);
|
|
209
|
+
if (!localSpace) {
|
|
210
|
+
TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);
|
|
211
|
+
}
|
|
212
|
+
return TmpVectors.Vector3[1].clone();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Creates lines in a shape of circle/arc.
|
|
216
|
+
* A segment is a part of the line between it's two points.
|
|
217
|
+
* @param radiusX radiusX of the circle
|
|
218
|
+
* @param segments number of segments in the circle
|
|
219
|
+
* @param z z coordinate of the points. Defaults to 0.
|
|
220
|
+
* @param radiusY radiusY of the circle - you can draw an oval if using different values
|
|
221
|
+
* @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.
|
|
222
|
+
* @returns line points
|
|
223
|
+
*/
|
|
224
|
+
static GetCircleLinePoints(radiusX, segments, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {
|
|
225
|
+
const points = [];
|
|
226
|
+
for (let i = 0; i <= segments; i++) {
|
|
227
|
+
points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));
|
|
228
|
+
}
|
|
229
|
+
return points;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Gets line points in a shape of a bezier curve
|
|
233
|
+
* @param p0 bezier point0
|
|
234
|
+
* @param p1 bezier point1
|
|
235
|
+
* @param p2 bezier point2
|
|
236
|
+
* @param segments number of segments in the curve
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
static GetBezierLinePoints(p0, p1, p2, segments) {
|
|
240
|
+
return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)
|
|
241
|
+
.getPoints()
|
|
242
|
+
.flatMap((v) => [v.x, v.y, v.z]);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
* @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)
|
|
247
|
+
* @param direction direction which the arrow points to
|
|
248
|
+
* @param length length (size) of the arrow cap itself
|
|
249
|
+
* @param widthUp the arrow width above the line
|
|
250
|
+
* @param widthDown the arrow width belove the line
|
|
251
|
+
* @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.
|
|
252
|
+
* @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.
|
|
253
|
+
* @returns
|
|
254
|
+
*/
|
|
255
|
+
static GetArrowCap(position, direction, length, widthUp, widthDown, widthStartUp = 0, widthStartDown = 0) {
|
|
256
|
+
const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];
|
|
257
|
+
const widths = [widthUp, widthDown, widthStartUp, widthStartDown];
|
|
258
|
+
return {
|
|
259
|
+
points,
|
|
260
|
+
widths,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Gets 3D positions of points from a text and font
|
|
265
|
+
* @param text Text
|
|
266
|
+
* @param size Size of the font
|
|
267
|
+
* @param resolution Resolution of the font
|
|
268
|
+
* @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)
|
|
269
|
+
* @param z z coordinate
|
|
270
|
+
* @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.
|
|
271
|
+
* @returns number[][] of 3D positions
|
|
272
|
+
*/
|
|
273
|
+
static GetPointsFromText(text, size, resolution, fontData, z = 0, includeInner = true) {
|
|
274
|
+
const allPoints = [];
|
|
275
|
+
const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);
|
|
276
|
+
for (const sp of shapePaths) {
|
|
277
|
+
for (const p of sp.paths) {
|
|
278
|
+
const points = [];
|
|
279
|
+
const points2d = p.getPoints();
|
|
280
|
+
for (const p2d of points2d) {
|
|
281
|
+
points.push(p2d.x, p2d.y, z);
|
|
282
|
+
}
|
|
283
|
+
allPoints.push(points);
|
|
284
|
+
}
|
|
285
|
+
if (includeInner) {
|
|
286
|
+
for (const h of sp.holes) {
|
|
287
|
+
const holes = [];
|
|
288
|
+
const points2d = h.getPoints();
|
|
289
|
+
for (const p2d of points2d) {
|
|
290
|
+
holes.push(p2d.x, p2d.y, z);
|
|
291
|
+
}
|
|
292
|
+
allPoints.push(holes);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return allPoints;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=greasedLineTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greasedLine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AM,KAAK,GAAG,EAAE,CAAC;oBACjB,MAAM,QAAQ,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;oBAC/B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;wBACxB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;qBAC/B;oBACD,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACzB;aACJ;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import { Curve3 } from \"../Maths/math.path\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { IFontData } from \"core/Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"core/Meshes/Builders/textBuilder\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(meshes: AbstractMesh[], omitZeroLengthLines = true) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {\r\n continue;\r\n }\r\n points.push([p1, p2, p3, p1]);\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[]) {\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < points.length; i += 3) {\r\n array.push(new Vector3(points[i], points[i + 1], points[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data);\r\n } else {\r\n points = <Vector3[]>data;\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what as Vector3[]) : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[], segmentCount: number): Vector3[] {\r\n const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(what, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n\r\n /**\r\n * Gets 3D positions of points from a text and font\r\n * @param text Text\r\n * @param size Size of the font\r\n * @param resolution Resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param z z coordinate\r\n * @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.\r\n * @returns number[][] of 3D positions\r\n */\r\n public static GetPointsFromText(text: string, size: number, resolution: number, fontData: IFontData, z = 0, includeInner = true) {\r\n const allPoints = [];\r\n const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);\r\n\r\n for (const sp of shapePaths) {\r\n for (const p of sp.paths) {\r\n const points = [];\r\n const points2d = p.getPoints();\r\n for (const p2d of points2d) {\r\n points.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(points);\r\n }\r\n\r\n if (includeInner) {\r\n for (const h of sp.holes) {\r\n const holes = [];\r\n const points2d = h.getPoints();\r\n for (const p2d of points2d) {\r\n holes.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(holes);\r\n }\r\n }\r\n }\r\n\r\n return allPoints;\r\n }\r\n}\r\n"]}
|
package/Misc/index.d.ts
CHANGED
package/Misc/index.js
CHANGED
package/Misc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB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A4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAA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\"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"khronosTextureContainer.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/khronosTextureContainer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAmEhC;;;;OAIG;IACH;IACI,yCAAyC;IAClC,IAAqB,EAC5B,aAAqB;QADd,SAAI,GAAJ,IAAI,CAAiB;QAZhC;;WAEG;QACI,cAAS,GAAG,KAAK,CAAC;QAYrB,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAC/C,OAAO;SACV;QAED,qDAAqD;QACrD,MAAM,QAAQ,GAAG,WAAW,CAAC,iBAAiB,CAAC;QAC/C,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC;QAChG,MAAM,UAAU,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,UAAU,KAAK,UAAU,CAAC;QAE/C,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,GAAG,QAAQ,EAAE,YAAY,CAAC,C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mCAAmC;AACtD,qCAAa,GAAG,CAAC,CAAC,CAAC,mCAAmC;AACtD,8BAAM,GAAG,CAAC,CAAC,CAAC,yBAAyB;AACrC,8BAAM,GAAG,CAAC,CAAC,CAAC,yBAAyB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\n\r\n/**\r\n * for description see https://www.khronos.org/opengles/sdk/tools/KTX/\r\n * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/\r\n */\r\nexport class KhronosTextureContainer {\r\n private static HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)\r\n\r\n // load types\r\n private static COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()\r\n private static COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()\r\n private static TEX_2D = 2; // uses a gl.texImage2D()\r\n private static TEX_3D = 3; // uses a gl.texImage3D()\r\n\r\n // elements of the header\r\n /**\r\n * Gets the openGL type\r\n */\r\n public glType: number;\r\n /**\r\n * Gets the openGL type size\r\n */\r\n public glTypeSize: number;\r\n /**\r\n * Gets the openGL format\r\n */\r\n public glFormat: number;\r\n /**\r\n * Gets the openGL internal format\r\n */\r\n public glInternalFormat: number;\r\n /**\r\n * Gets the base internal format\r\n */\r\n public glBaseInternalFormat: number;\r\n /**\r\n * Gets image width in pixel\r\n */\r\n public pixelWidth: number;\r\n /**\r\n * Gets image height in pixel\r\n */\r\n public pixelHeight: number;\r\n /**\r\n * Gets image depth in pixels\r\n */\r\n public pixelDepth: number;\r\n /**\r\n * Gets the number of array elements\r\n */\r\n public numberOfArrayElements: number;\r\n /**\r\n * Gets the number of faces\r\n */\r\n public numberOfFaces: number;\r\n /**\r\n * Gets the number of mipmap levels\r\n */\r\n public numberOfMipmapLevels: number;\r\n /**\r\n * Gets the bytes of key value data\r\n */\r\n public bytesOfKeyValueData: number;\r\n /**\r\n * Gets the load type\r\n */\r\n public loadType: number;\r\n /**\r\n * If the container has been made invalid (eg. constructor failed to correctly load array buffer)\r\n */\r\n public isInvalid = false;\r\n\r\n /**\r\n * Creates a new KhronosTextureContainer\r\n * @param data contents of the KTX container file\r\n * @param facesExpected should be either 1 or 6, based whether a cube texture or or\r\n */\r\n public constructor(\r\n /** contents of the KTX container file */\r\n public data: ArrayBufferView,\r\n facesExpected: number\r\n ) {\r\n if (!KhronosTextureContainer.IsValid(data)) {\r\n this.isInvalid = true;\r\n Logger.Error(\"texture missing KTX identifier\");\r\n return;\r\n }\r\n\r\n // load the reset of the header in native 32 bit uint\r\n const dataSize = Uint32Array.BYTES_PER_ELEMENT;\r\n const headerDataView = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * dataSize);\r\n const endianness = headerDataView.getUint32(0, true);\r\n const littleEndian = endianness === 0x04030201;\r\n\r\n this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures\r\n this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)\r\n this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)\r\n this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)\r\n this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)\r\n this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)\r\n this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays\r\n this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6\r\n this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures\r\n this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data\r\n\r\n // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.\r\n if (this.glType !== 0) {\r\n Logger.Error(\"only compressed formats currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n } else {\r\n // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.\r\n this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);\r\n }\r\n\r\n if (this.pixelHeight === 0 || this.pixelDepth !== 0) {\r\n Logger.Error(\"only 2D textures currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfArrayElements !== 0) {\r\n Logger.Error(\"texture arrays not currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfFaces !== facesExpected) {\r\n Logger.Error(\"number of faces expected\" + facesExpected + \", but found \" + this.numberOfFaces);\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n // we now have a completely validated file, so could use existence of loadType as success\r\n // would need to make this more elaborate & adjust checks above to support more than one load type\r\n this.loadType = KhronosTextureContainer.COMPRESSED_2D;\r\n }\r\n\r\n /**\r\n * Uploads KTX content to a Babylon Texture.\r\n * It is assumed that the texture has already been created & is currently bound\r\n * @internal\r\n */\r\n public uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n switch (this.loadType) {\r\n case KhronosTextureContainer.COMPRESSED_2D:\r\n this._upload2DCompressedLevels(texture, loadMipmaps);\r\n break;\r\n\r\n case KhronosTextureContainer.TEX_2D:\r\n case KhronosTextureContainer.COMPRESSED_3D:\r\n case KhronosTextureContainer.TEX_3D:\r\n }\r\n }\r\n\r\n private _upload2DCompressedLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n // initialize width & height for level 1\r\n let dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;\r\n let width = this.pixelWidth;\r\n let height = this.pixelHeight;\r\n\r\n const mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;\r\n for (let level = 0; level < mipmapCount; level++) {\r\n const imageSize = new Int32Array(this.data.buffer, this.data.byteOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps\r\n dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.\r\n for (let face = 0; face < this.numberOfFaces; face++) {\r\n const byteArray = new Uint8Array(this.data.buffer, this.data.byteOffset + dataOffset, imageSize);\r\n\r\n const engine = texture.getEngine();\r\n engine._uploadCompressedDataToTextureDirectly(texture, texture.format, width, height, byteArray, face, level);\r\n\r\n dataOffset += imageSize; // add size of the image for the next face/mipmap\r\n dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image\r\n }\r\n width = Math.max(1.0, width * 0.5);\r\n height = Math.max(1.0, height * 0.5);\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the given data starts with a KTX file identifier.\r\n * @param data the data to check\r\n * @returns true if the data is a KTX file or false otherwise\r\n */\r\n public static IsValid(data: ArrayBufferView): boolean {\r\n if (data.byteLength >= 12) {\r\n // '«', 'K', 'T', 'X', ' ', '1', '1', '»', '\\r', '\\n', '\\x1A', '\\n'\r\n const identifier = new Uint8Array(data.buffer, data.byteOffset, 12);\r\n if (\r\n identifier[0] === 0xab &&\r\n identifier[1] === 0x4b &&\r\n identifier[2] === 0x54 &&\r\n identifier[3] === 0x58 &&\r\n identifier[4] === 0x20 &&\r\n identifier[5] === 0x31 &&\r\n identifier[6] === 0x31 &&\r\n identifier[7] === 0xbb &&\r\n identifier[8] === 0x0d &&\r\n identifier[9] === 0x0a &&\r\n identifier[10] === 0x1a &&\r\n identifier[11] === 0x0a\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
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C,CAAC;SACxC;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,IAAqB;QACvC,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE;YACvB,mEAAmE;YACnE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACpE,IACI,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI;gBACvB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,EACzB;gBACE,OAAO,IAAI,CAAC;aACf;SACJ;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;;AA3Mc,kCAAU,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,AAAd,CAAe,CAAC,yEAAyE;AAElH,aAAa;AACE,qCAAa,GAAG,CAAC,AAAJ,CAAK,CAAC,mCAAmC;AACtD,qCAAa,GAAG,CAAC,AAAJ,CAAK,CAAC,mCAAmC;AACtD,8BAAM,GAAG,CAAC,AAAJ,CAAK,CAAC,yBAAyB;AACrC,8BAAM,GAAG,CAAC,AAAJ,CAAK,CAAC,yBAAyB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\n\r\n/**\r\n * for description see https://www.khronos.org/opengles/sdk/tools/KTX/\r\n * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/\r\n */\r\nexport class KhronosTextureContainer {\r\n private static HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)\r\n\r\n // load types\r\n private static COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()\r\n private static COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()\r\n private static TEX_2D = 2; // uses a gl.texImage2D()\r\n private static TEX_3D = 3; // uses a gl.texImage3D()\r\n\r\n // elements of the header\r\n /**\r\n * Gets the openGL type\r\n */\r\n public glType: number;\r\n /**\r\n * Gets the openGL type size\r\n */\r\n public glTypeSize: number;\r\n /**\r\n * Gets the openGL format\r\n */\r\n public glFormat: number;\r\n /**\r\n * Gets the openGL internal format\r\n */\r\n public glInternalFormat: number;\r\n /**\r\n * Gets the base internal format\r\n */\r\n public glBaseInternalFormat: number;\r\n /**\r\n * Gets image width in pixel\r\n */\r\n public pixelWidth: number;\r\n /**\r\n * Gets image height in pixel\r\n */\r\n public pixelHeight: number;\r\n /**\r\n * Gets image depth in pixels\r\n */\r\n public pixelDepth: number;\r\n /**\r\n * Gets the number of array elements\r\n */\r\n public numberOfArrayElements: number;\r\n /**\r\n * Gets the number of faces\r\n */\r\n public numberOfFaces: number;\r\n /**\r\n * Gets the number of mipmap levels\r\n */\r\n public numberOfMipmapLevels: number;\r\n /**\r\n * Gets the bytes of key value data\r\n */\r\n public bytesOfKeyValueData: number;\r\n /**\r\n * Gets the load type\r\n */\r\n public loadType: number;\r\n /**\r\n * If the container has been made invalid (eg. constructor failed to correctly load array buffer)\r\n */\r\n public isInvalid = false;\r\n\r\n /**\r\n * Creates a new KhronosTextureContainer\r\n * @param data contents of the KTX container file\r\n * @param facesExpected should be either 1 or 6, based whether a cube texture or or\r\n */\r\n public constructor(\r\n /** contents of the KTX container file */\r\n public data: ArrayBufferView,\r\n facesExpected: number\r\n ) {\r\n if (!KhronosTextureContainer.IsValid(data)) {\r\n this.isInvalid = true;\r\n Logger.Error(\"texture missing KTX identifier\");\r\n return;\r\n }\r\n\r\n // load the reset of the header in native 32 bit uint\r\n const dataSize = Uint32Array.BYTES_PER_ELEMENT;\r\n const headerDataView = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * dataSize);\r\n const endianness = headerDataView.getUint32(0, true);\r\n const littleEndian = endianness === 0x04030201;\r\n\r\n this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures\r\n this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)\r\n this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)\r\n this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)\r\n this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)\r\n this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)\r\n this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays\r\n this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6\r\n this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures\r\n this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data\r\n\r\n // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.\r\n if (this.glType !== 0) {\r\n Logger.Error(\"only compressed formats currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n } else {\r\n // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.\r\n this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);\r\n }\r\n\r\n if (this.pixelHeight === 0 || this.pixelDepth !== 0) {\r\n Logger.Error(\"only 2D textures currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfArrayElements !== 0) {\r\n Logger.Error(\"texture arrays not currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfFaces !== facesExpected) {\r\n Logger.Error(\"number of faces expected\" + facesExpected + \", but found \" + this.numberOfFaces);\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n // we now have a completely validated file, so could use existence of loadType as success\r\n // would need to make this more elaborate & adjust checks above to support more than one load type\r\n this.loadType = KhronosTextureContainer.COMPRESSED_2D;\r\n }\r\n\r\n /**\r\n * Uploads KTX content to a Babylon Texture.\r\n * It is assumed that the texture has already been created & is currently bound\r\n * @internal\r\n */\r\n public uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n switch (this.loadType) {\r\n case KhronosTextureContainer.COMPRESSED_2D:\r\n this._upload2DCompressedLevels(texture, loadMipmaps);\r\n break;\r\n\r\n case KhronosTextureContainer.TEX_2D:\r\n case KhronosTextureContainer.COMPRESSED_3D:\r\n case KhronosTextureContainer.TEX_3D:\r\n }\r\n }\r\n\r\n private _upload2DCompressedLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n // initialize width & height for level 1\r\n let dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;\r\n let width = this.pixelWidth;\r\n let height = this.pixelHeight;\r\n\r\n const mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;\r\n for (let level = 0; level < mipmapCount; level++) {\r\n const imageSize = new Int32Array(this.data.buffer, this.data.byteOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps\r\n dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.\r\n for (let face = 0; face < this.numberOfFaces; face++) {\r\n const byteArray = new Uint8Array(this.data.buffer, this.data.byteOffset + dataOffset, imageSize);\r\n\r\n const engine = texture.getEngine();\r\n engine._uploadCompressedDataToTextureDirectly(texture, texture.format, width, height, byteArray, face, level);\r\n\r\n dataOffset += imageSize; // add size of the image for the next face/mipmap\r\n dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image\r\n }\r\n width = Math.max(1.0, width * 0.5);\r\n height = Math.max(1.0, height * 0.5);\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the given data starts with a KTX file identifier.\r\n * @param data the data to check\r\n * @returns true if the data is a KTX file or false otherwise\r\n */\r\n public static IsValid(data: ArrayBufferView): boolean {\r\n if (data.byteLength >= 12) {\r\n // '«', 'K', 'T', 'X', ' ', '1', '1', '»', '\\r', '\\n', '\\x1A', '\\n'\r\n const identifier = new Uint8Array(data.buffer, data.byteOffset, 12);\r\n if (\r\n identifier[0] === 0xab &&\r\n identifier[1] === 0x4b &&\r\n identifier[2] === 0x54 &&\r\n identifier[3] === 0x58 &&\r\n identifier[4] === 0x20 &&\r\n identifier[5] === 0x31 &&\r\n identifier[6] === 0x31 &&\r\n identifier[7] === 0xbb &&\r\n identifier[8] === 0x0d &&\r\n identifier[9] === 0x0a &&\r\n identifier[10] === 0x1a &&\r\n identifier[11] === 0x0a\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../Shaders/rgbdDecode.fragment";
|
|
2
2
|
import "../Engines/Extensions/engine.renderTarget";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { Texture } from "../Materials/Textures/texture";
|
|
4
|
+
import type { InternalTexture } from "../Materials/Textures/internalTexture";
|
|
5
|
+
import type { Scene } from "../scene";
|
|
6
6
|
/**
|
|
7
7
|
* Class used to host RGBD texture specific utilities
|
|
8
8
|
*/
|
|
@@ -21,4 +21,3 @@ export declare class RGBDTextureTools {
|
|
|
21
21
|
*/
|
|
22
22
|
static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
|
|
23
23
|
}
|
|
24
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAGxC,OAAO,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAgB;QAC5C,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACrC,OAAO;SACV;QAED,yBAAyB;QACzB,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,EAAY,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;QACxC,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,wDAAwD;QACxD,IAAI,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,+BAA+B,EAAE;YACrE,aAAa,GAAG,IAAI,CAAC;YACrB,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,sBAAsB,CAAC;SAC3D;QACD,wDAAwD;aACnD,IAAI,IAAI,CAAC,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AC,EAAE,CAAC,CAAC,CAAC;oBACpC,CAAC,CAAC;oBACF,OAAO,CAAC,QAAQ,EAAG,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,eAAgB,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;oBAE/F,UAAU;oBACV,MAAM,CAAC,yBAAyB,EAAE,CAAC;oBACnC,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;oBACxC,IAAI,eAAe,EAAE;wBACjB,eAAe,CAAC,OAAO,EAAE,CAAC;qBAC7B;oBAED,gBAAgB;oBAChB,eAAe,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;oBAE7C,8BAA8B;oBAC9B,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;gBACnC,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE;YACT,iBAAiB,EAAE,CAAC;SACvB;aAAM;YACH,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SACvD;IACL,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,mBAAmB,CAAC,eAAgC,EAAE,KAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC,yBAAyB;QACrI,OAAO,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,CAAC,4BAA4B,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport \"../Shaders/rgbdDecode.fragment\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AA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AAe,CAAC,CAAC;oBAE7C,8BAA8B;oBAC9B,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;gBACnC,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE;YACT,iBAAiB,EAAE,CAAC;SACvB;aAAM;YACH,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SACvD;IACL,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,mBAAmB,CAAC,eAAgC,EAAE,KAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC,yBAAyB;QACrI,OAAO,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,CAAC,4BAA4B,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport \"../Shaders/rgbdDecode.fragment\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { Texture } from \"../Materials/Textures/texture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * Class used to host RGBD texture specific utilities\r\n */\r\nexport class RGBDTextureTools {\r\n /**\r\n * Expand the RGBD Texture from RGBD to Half Float if possible.\r\n * @param texture the texture to expand.\r\n */\r\n public static ExpandRGBDTexture(texture: Texture) {\r\n const internalTexture = texture._texture;\r\n if (!internalTexture || !texture.isRGBD) {\r\n return;\r\n }\r\n\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n const caps = engine.getCaps();\r\n const isReady = internalTexture.isReady;\r\n let expandTexture = false;\r\n\r\n // If half float available we can uncompress the texture\r\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n if (expandTexture) {\r\n // Do not use during decode.\r\n internalTexture.isReady = false;\r\n internalTexture._isRGBD = false;\r\n internalTexture.invertY = false;\r\n }\r\n\r\n const expandRGBDTexture = () => {\r\n // Expand the texture if possible\r\n if (expandTexture) {\r\n // Simply run through the decode PP.\r\n const rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n internalTexture.type,\r\n undefined,\r\n null,\r\n false\r\n );\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode: internalTexture.samplingMode,\r\n type: internalTexture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n\r\n rgbdPostProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n texture.getScene()!.postProcessManager.directRender([rgbdPostProcess!], expandedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n expandedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.isReady = true;\r\n });\r\n }\r\n };\r\n\r\n if (isReady) {\r\n expandRGBDTexture();\r\n } else {\r\n texture.onLoadObservable.addOnce(expandRGBDTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Encode the texture to RGBD if possible.\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param outputTextureType type of the texture in which the encoding is performed\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n public static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise<InternalTexture> {\r\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA);\r\n }\r\n}\r\n"]}
|